{"version":3,"file":"platform-browser-dynamic.umd.js","sources":["../../../../packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts","../../../../packages/platform-browser-dynamic/src/private_export.ts","../../../../packages/platform-browser-dynamic/src/platform_providers.ts","../../../../packages/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ResourceLoader} from '@angular/compiler';\nimport {ɵglobal as global} from '@angular/core';\n\n/**\n * An implementation of ResourceLoader that uses a template cache to avoid doing an actual\n * ResourceLoader.\n *\n * The template cache needs to be built and loaded into window.$templateCache\n * via a separate mechanism.\n */\nexport class CachedResourceLoader extends ResourceLoader {\n  private _cache: {[url: string]: string};\n\n  constructor() {\n    super();\n    this._cache = (<any>global).$templateCache;\n    if (this._cache == null) {\n      throw new Error('CachedResourceLoader: Template cache was not found in $templateCache.');\n    }\n  }\n\n  get(url: string): Promise<string> {\n    if (this._cache.hasOwnProperty(url)) {\n      return Promise.resolve(this._cache[url]);\n    } else {\n      return <Promise<any>>Promise.reject(\n          'CachedResourceLoader: Did not find cached template for ' + url);\n    }\n  }\n}\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './platform_providers';\nexport {ResourceLoaderImpl as ɵResourceLoaderImpl} from './resource_loader/resource_loader_impl';\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID} from '@angular/common';\nimport {ResourceLoader} from '@angular/compiler';\nimport {COMPILER_OPTIONS, PLATFORM_ID, Provider} from '@angular/core';\n\nimport {ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS as INTERNAL_BROWSER_PLATFORM_PROVIDERS} from '@angular/platform-browser';\n\nimport {ResourceLoaderImpl} from './resource_loader/resource_loader_impl';\n\nexport const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Provider[] = [\n  INTERNAL_BROWSER_PLATFORM_PROVIDERS,\n  {\n    provide: COMPILER_OPTIONS,\n    useValue: {providers: [{provide: ResourceLoader, useClass: ResourceLoaderImpl}]},\n    multi: true\n  },\n  {provide: PLATFORM_ID, useValue: PLATFORM_BROWSER_ID},\n];\n","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {ResourceLoader} from '@angular/compiler';\nimport {Injectable} from '@angular/core';\n\n\n\nexport class ResourceLoaderImpl extends ResourceLoader {\n  get(url: string): Promise<string> {\n    let resolve: (result: any) => void;\n    let reject: (error: any) => void;\n    const promise = new Promise((res, rej) => {\n      resolve = res;\n      reject = rej;\n    });\n    const xhr = new XMLHttpRequest();\n    xhr.open('GET', url, true);\n    xhr.responseType = 'text';\n\n    xhr.onload = function() {\n      // responseText is the old-school way of retrieving response (supported by IE8 & 9)\n      // response/responseType properties were introduced in ResourceLoader Level2 spec (supported\n      // by IE10)\n      const response = xhr.response || xhr.responseText;\n\n      // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)\n      let status = xhr.status === 1223 ? 204 : xhr.status;\n\n      // fix status code when it is 0 (0 status is undocumented).\n      // Occurs when accessing file resources or on Android 4.1 stock browser\n      // while retrieving files from application cache.\n      if (status === 0) {\n        status = response ? 200 : 0;\n      }\n\n      if (200 <= status && status <= 300) {\n        resolve(response);\n      } else {\n        reject(`Failed to load ${url}`);\n      }\n    };\n\n    xhr.onerror = function() { reject(`Failed to load ${url}`); };\n\n    xhr.send();\n    return promise;\n  }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\ninterface DecoratorInvocation {\n  type: Function;\n  args?: any[];\n}\n"],"names":["ResourceLoader","ɵglobal","COMPILER_OPTIONS","ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS","Injectable"],"mappings":";;;;;;;;;;;;;;;;AGAA;;;;;;;AAiBA,IAAA,kBAAA,IAAA,UAAA,MAAA,EAAA;IAAA,SAAA,CAAA,kBAAA,EAAA,MAAA,CAAA,CAAA;IAAA,SAAA,kBAAA,GAAA;;KAuCA;IAtCA,kBAAA,CAAA,SAAA,CAAA,GAAA,GAAA,UAAA,GAAA,EAAA;QACA,IAAA,OAAA,CAAA;QACI,IAAJ,MAAA,CAAA;QACI,IAAJ,OAAA,GAAoB,IAApB,OAA+B,CAA/B,UAAA,GAAA,EAAA,GAAA,EAAA;YACQ,OAAR,GAAA,GAAA,CAAA;YAEQ,MAAM,GAAG,GAAjB,CAAA;;;;QAIA,GAAA,CAAM,YAAN,GAAA,MAA2B,CAA3B;;;;;;;YASA,IAAQ,MAAM,GAAG,GAAjB,CAAA,MAAA,KAAA,IAAoC,GAApC,GAAA,GAAA,GAAA,CAAA,MAAA,CAAA;;;;YAKA,IAAA,MAAA,KAAA,CAAA,EAAA;gBAAA,MAAA,GAAA,QAAA,GAAA,GAAA,GAAA,CAAA,CAAA;aACA;YACA,IAAA,GAAA,IAAA,MAAA,IAAA,MAAA,IAAA,GAAA,EAAA;gBACA,OAAA,CAAA,QAAA,CAAA,CAAA;aAEA;iBAEA;gBACA,MAAkB,CAAC,iBAAnB,GAAA,GAAA,CAAA,CAAA;aACA;;QACA,GAAA,CAAA,OAAA,GAAA,YAAA,EAAA,MAAA,CAAA,iBAAA,GAAA,GAAA,CAAA,CAAA,EAAA,CAAA;QACA,GAAA,CAAQ,IAAR,EAAA,CAAA;QACA,OAAA,OAAA,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