/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ResourceLoader } from '@angular/compiler'; import { ɵglobal as global } from '@angular/core'; /** * An implementation of ResourceLoader that uses a template cache to avoid doing an actual * ResourceLoader. * * The template cache needs to be built and loaded into window.$templateCache * via a separate mechanism. * * @publicApi * * @deprecated This was previously necessary in some cases to test AOT-compiled components with View * Engine, but is no longer since Ivy. */ export class CachedResourceLoader extends ResourceLoader { constructor() { super(); this._cache = global.$templateCache; if (this._cache == null) { throw new Error('CachedResourceLoader: Template cache was not found in $templateCache.'); } } get(url) { if (this._cache.hasOwnProperty(url)) { return Promise.resolve(this._cache[url]); } else { return Promise.reject('CachedResourceLoader: Did not find cached template for ' + url); } } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzb3VyY2VfbG9hZGVyX2NhY2hlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvcGxhdGZvcm0tYnJvd3Nlci1keW5hbWljL3NyYy9yZXNvdXJjZV9sb2FkZXIvcmVzb3VyY2VfbG9hZGVyX2NhY2hlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxjQUFjLEVBQUMsTUFBTSxtQkFBbUIsQ0FBQztBQUNqRCxPQUFPLEVBQUMsT0FBTyxJQUFJLE1BQU0sRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUVoRDs7Ozs7Ozs7Ozs7R0FXRztBQUNILE1BQU0sT0FBTyxvQkFBcUIsU0FBUSxjQUFjO0lBR3REO1FBQ0UsS0FBSyxFQUFFLENBQUM7UUFDUixJQUFJLENBQUMsTUFBTSxHQUFTLE1BQU8sQ0FBQyxjQUFjLENBQUM7UUFDM0MsSUFBSSxJQUFJLENBQUMsTUFBTSxJQUF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