[6a3a178] | 1 | /**
|
---|
| 2 | * @license Angular v12.2.9
|
---|
| 3 | * (c) 2010-2021 Google LLC. https://angular.io/
|
---|
| 4 | * License: MIT
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | import { getUrlScheme, syntaxError, Identifiers, JitCompiler, ProviderMeta, I18NHtmlParser, CompilerConfig, CompileReflector, ResourceLoader, JitSummaryResolver, SummaryResolver, Lexer, Parser, HtmlParser, TemplateParser, ElementSchemaRegistry, JitEvaluator, DirectiveNormalizer, UrlResolver, CompileMetadataResolver, NgModuleResolver, DirectiveResolver, PipeResolver, StaticSymbolCache, StyleCompiler, ViewCompiler, NgModuleCompiler, DomElementSchemaRegistry } from '@angular/compiler';
|
---|
| 8 | import { ɵReflectionCapabilities, ɵstringify, ANALYZE_FOR_ENTRY_COMPONENTS, ElementRef, NgModuleRef, ViewContainerRef, ChangeDetectorRef, Renderer2, QueryList, TemplateRef, ɵCodegenComponentFactoryResolver, ComponentFactoryResolver, ComponentFactory, ComponentRef, NgModuleFactory, ɵcmf, ɵmod, ɵmpd, ɵregisterModuleFactory, Injector, ViewEncapsulation, ChangeDetectionStrategy, SecurityContext, LOCALE_ID, TRANSLATIONS_FORMAT, ɵinlineInterpolate, ɵinterpolate, ɵEMPTY_ARRAY, ɵEMPTY_MAP, ɵvid, ɵeld, ɵand, ɵted, ɵdid, ɵprd, ɵqud, ɵpad, ɵpod, ɵppd, ɵpid, ɵnov, ɵncd, ɵunv, ɵcrt, ɵccf, InjectionToken, PACKAGE_ROOT_URL, Compiler, MissingTranslationStrategy, ɵConsole, Optional, Inject, TRANSLATIONS, isDevMode, createPlatformFactory, platformCore, COMPILER_OPTIONS, CompilerFactory, Injectable, PLATFORM_ID, ɵglobal, Version } from '@angular/core';
|
---|
| 9 | import { ɵPLATFORM_BROWSER_ID } from '@angular/common';
|
---|
| 10 | import { ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS } from '@angular/platform-browser';
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | * @license
|
---|
| 14 | * Copyright Google LLC All Rights Reserved.
|
---|
| 15 | *
|
---|
| 16 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 17 | * found in the LICENSE file at https://angular.io/license
|
---|
| 18 | */
|
---|
| 19 | import * as ɵngcc0 from '@angular/core';
|
---|
| 20 | const MODULE_SUFFIX = '';
|
---|
| 21 | const builtinExternalReferences = createBuiltinExternalReferencesMap();
|
---|
| 22 | class JitReflector {
|
---|
| 23 | constructor() {
|
---|
| 24 | this.reflectionCapabilities = new ɵReflectionCapabilities();
|
---|
| 25 | }
|
---|
| 26 | componentModuleUrl(type, cmpMetadata) {
|
---|
| 27 | const moduleId = cmpMetadata.moduleId;
|
---|
| 28 | if (typeof moduleId === 'string') {
|
---|
| 29 | const scheme = getUrlScheme(moduleId);
|
---|
| 30 | return scheme ? moduleId : `package:${moduleId}${MODULE_SUFFIX}`;
|
---|
| 31 | }
|
---|
| 32 | else if (moduleId !== null && moduleId !== void 0) {
|
---|
| 33 | throw syntaxError(`moduleId should be a string in "${ɵstringify(type)}". See https://goo.gl/wIDDiL for more information.\n` +
|
---|
| 34 | `If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.`);
|
---|
| 35 | }
|
---|
| 36 | return `./${ɵstringify(type)}`;
|
---|
| 37 | }
|
---|
| 38 | parameters(typeOrFunc) {
|
---|
| 39 | return this.reflectionCapabilities.parameters(typeOrFunc);
|
---|
| 40 | }
|
---|
| 41 | tryAnnotations(typeOrFunc) {
|
---|
| 42 | return this.annotations(typeOrFunc);
|
---|
| 43 | }
|
---|
| 44 | annotations(typeOrFunc) {
|
---|
| 45 | return this.reflectionCapabilities.annotations(typeOrFunc);
|
---|
| 46 | }
|
---|
| 47 | shallowAnnotations(typeOrFunc) {
|
---|
| 48 | throw new Error('Not supported in JIT mode');
|
---|
| 49 | }
|
---|
| 50 | propMetadata(typeOrFunc) {
|
---|
| 51 | return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
---|
| 52 | }
|
---|
| 53 | hasLifecycleHook(type, lcProperty) {
|
---|
| 54 | return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
---|
| 55 | }
|
---|
| 56 | guards(type) {
|
---|
| 57 | return this.reflectionCapabilities.guards(type);
|
---|
| 58 | }
|
---|
| 59 | resolveExternalReference(ref) {
|
---|
| 60 | return builtinExternalReferences.get(ref) || ref.runtime;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | function createBuiltinExternalReferencesMap() {
|
---|
| 64 | const map = new Map();
|
---|
| 65 | map.set(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS, ANALYZE_FOR_ENTRY_COMPONENTS);
|
---|
| 66 | map.set(Identifiers.ElementRef, ElementRef);
|
---|
| 67 | map.set(Identifiers.NgModuleRef, NgModuleRef);
|
---|
| 68 | map.set(Identifiers.ViewContainerRef, ViewContainerRef);
|
---|
| 69 | map.set(Identifiers.ChangeDetectorRef, ChangeDetectorRef);
|
---|
| 70 | map.set(Identifiers.Renderer2, Renderer2);
|
---|
| 71 | map.set(Identifiers.QueryList, QueryList);
|
---|
| 72 | map.set(Identifiers.TemplateRef, TemplateRef);
|
---|
| 73 | map.set(Identifiers.CodegenComponentFactoryResolver, ɵCodegenComponentFactoryResolver);
|
---|
| 74 | map.set(Identifiers.ComponentFactoryResolver, ComponentFactoryResolver);
|
---|
| 75 | map.set(Identifiers.ComponentFactory, ComponentFactory);
|
---|
| 76 | map.set(Identifiers.ComponentRef, ComponentRef);
|
---|
| 77 | map.set(Identifiers.NgModuleFactory, NgModuleFactory);
|
---|
| 78 | map.set(Identifiers.createModuleFactory, ɵcmf);
|
---|
| 79 | map.set(Identifiers.moduleDef, ɵmod);
|
---|
| 80 | map.set(Identifiers.moduleProviderDef, ɵmpd);
|
---|
| 81 | map.set(Identifiers.RegisterModuleFactoryFn, ɵregisterModuleFactory);
|
---|
| 82 | map.set(Identifiers.Injector, Injector);
|
---|
| 83 | map.set(Identifiers.ViewEncapsulation, ViewEncapsulation);
|
---|
| 84 | map.set(Identifiers.ChangeDetectionStrategy, ChangeDetectionStrategy);
|
---|
| 85 | map.set(Identifiers.SecurityContext, SecurityContext);
|
---|
| 86 | map.set(Identifiers.LOCALE_ID, LOCALE_ID);
|
---|
| 87 | map.set(Identifiers.TRANSLATIONS_FORMAT, TRANSLATIONS_FORMAT);
|
---|
| 88 | map.set(Identifiers.inlineInterpolate, ɵinlineInterpolate);
|
---|
| 89 | map.set(Identifiers.interpolate, ɵinterpolate);
|
---|
| 90 | map.set(Identifiers.EMPTY_ARRAY, ɵEMPTY_ARRAY);
|
---|
| 91 | map.set(Identifiers.EMPTY_MAP, ɵEMPTY_MAP);
|
---|
| 92 | map.set(Identifiers.viewDef, ɵvid);
|
---|
| 93 | map.set(Identifiers.elementDef, ɵeld);
|
---|
| 94 | map.set(Identifiers.anchorDef, ɵand);
|
---|
| 95 | map.set(Identifiers.textDef, ɵted);
|
---|
| 96 | map.set(Identifiers.directiveDef, ɵdid);
|
---|
| 97 | map.set(Identifiers.providerDef, ɵprd);
|
---|
| 98 | map.set(Identifiers.queryDef, ɵqud);
|
---|
| 99 | map.set(Identifiers.pureArrayDef, ɵpad);
|
---|
| 100 | map.set(Identifiers.pureObjectDef, ɵpod);
|
---|
| 101 | map.set(Identifiers.purePipeDef, ɵppd);
|
---|
| 102 | map.set(Identifiers.pipeDef, ɵpid);
|
---|
| 103 | map.set(Identifiers.nodeValue, ɵnov);
|
---|
| 104 | map.set(Identifiers.ngContentDef, ɵncd);
|
---|
| 105 | map.set(Identifiers.unwrapValue, ɵunv);
|
---|
| 106 | map.set(Identifiers.createRendererType2, ɵcrt);
|
---|
| 107 | map.set(Identifiers.createComponentFactory, ɵccf);
|
---|
| 108 | return map;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /**
|
---|
| 112 | * @license
|
---|
| 113 | * Copyright Google LLC All Rights Reserved.
|
---|
| 114 | *
|
---|
| 115 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 116 | * found in the LICENSE file at https://angular.io/license
|
---|
| 117 | */
|
---|
| 118 | const ERROR_COLLECTOR_TOKEN = new InjectionToken('ErrorCollector');
|
---|
| 119 | /**
|
---|
| 120 | * A default provider for {@link PACKAGE_ROOT_URL} that maps to '/'.
|
---|
| 121 | */
|
---|
| 122 | const DEFAULT_PACKAGE_URL_PROVIDER = {
|
---|
| 123 | provide: PACKAGE_ROOT_URL,
|
---|
| 124 | useValue: '/'
|
---|
| 125 | };
|
---|
| 126 | const _NO_RESOURCE_LOADER = {
|
---|
| 127 | get(url) {
|
---|
| 128 | throw new Error(`No ResourceLoader implementation has been provided. Can't read the url "${url}"`);
|
---|
| 129 | }
|
---|
| 130 | };
|
---|
| 131 | const baseHtmlParser = new InjectionToken('HtmlParser');
|
---|
| 132 | class CompilerImpl {
|
---|
| 133 | constructor(injector, _metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console) {
|
---|
| 134 | this._metadataResolver = _metadataResolver;
|
---|
| 135 | this._delegate = new JitCompiler(_metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console, this.getExtraNgModuleProviders.bind(this));
|
---|
| 136 | this.injector = injector;
|
---|
| 137 | }
|
---|
| 138 | getExtraNgModuleProviders() {
|
---|
| 139 | return [this._metadataResolver.getProviderMetadata(new ProviderMeta(Compiler, { useValue: this }))];
|
---|
| 140 | }
|
---|
| 141 | compileModuleSync(moduleType) {
|
---|
| 142 | return this._delegate.compileModuleSync(moduleType);
|
---|
| 143 | }
|
---|
| 144 | compileModuleAsync(moduleType) {
|
---|
| 145 | return this._delegate.compileModuleAsync(moduleType);
|
---|
| 146 | }
|
---|
| 147 | compileModuleAndAllComponentsSync(moduleType) {
|
---|
| 148 | const result = this._delegate.compileModuleAndAllComponentsSync(moduleType);
|
---|
| 149 | return {
|
---|
| 150 | ngModuleFactory: result.ngModuleFactory,
|
---|
| 151 | componentFactories: result.componentFactories,
|
---|
| 152 | };
|
---|
| 153 | }
|
---|
| 154 | compileModuleAndAllComponentsAsync(moduleType) {
|
---|
| 155 | return this._delegate.compileModuleAndAllComponentsAsync(moduleType)
|
---|
| 156 | .then((result) => ({
|
---|
| 157 | ngModuleFactory: result.ngModuleFactory,
|
---|
| 158 | componentFactories: result.componentFactories,
|
---|
| 159 | }));
|
---|
| 160 | }
|
---|
| 161 | loadAotSummaries(summaries) {
|
---|
| 162 | this._delegate.loadAotSummaries(summaries);
|
---|
| 163 | }
|
---|
| 164 | hasAotSummary(ref) {
|
---|
| 165 | return this._delegate.hasAotSummary(ref);
|
---|
| 166 | }
|
---|
| 167 | getComponentFactory(component) {
|
---|
| 168 | return this._delegate.getComponentFactory(component);
|
---|
| 169 | }
|
---|
| 170 | clearCache() {
|
---|
| 171 | this._delegate.clearCache();
|
---|
| 172 | }
|
---|
| 173 | clearCacheFor(type) {
|
---|
| 174 | this._delegate.clearCacheFor(type);
|
---|
| 175 | }
|
---|
| 176 | getModuleId(moduleType) {
|
---|
| 177 | const meta = this._metadataResolver.getNgModuleMetadata(moduleType);
|
---|
| 178 | return meta && meta.id || undefined;
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 | const ɵ0 = new JitReflector(), ɵ1 = _NO_RESOURCE_LOADER, ɵ2 = (parser, translations, format, config, console) => {
|
---|
| 182 | translations = translations || '';
|
---|
| 183 | const missingTranslation = translations ? config.missingTranslation : MissingTranslationStrategy.Ignore;
|
---|
| 184 | return new I18NHtmlParser(parser, translations, format, missingTranslation, console);
|
---|
| 185 | }, ɵ3 = new CompilerConfig();
|
---|
| 186 | /**
|
---|
| 187 | * A set of providers that provide `JitCompiler` and its dependencies to use for
|
---|
| 188 | * template compilation.
|
---|
| 189 | */
|
---|
| 190 | const COMPILER_PROVIDERS__PRE_R3__ = [
|
---|
| 191 | { provide: CompileReflector, useValue: ɵ0 },
|
---|
| 192 | { provide: ResourceLoader, useValue: ɵ1 },
|
---|
| 193 | { provide: JitSummaryResolver, deps: [] },
|
---|
| 194 | { provide: SummaryResolver, useExisting: JitSummaryResolver },
|
---|
| 195 | { provide: ɵConsole, deps: [] },
|
---|
| 196 | { provide: Lexer, deps: [] },
|
---|
| 197 | { provide: Parser, deps: [Lexer] },
|
---|
| 198 | {
|
---|
| 199 | provide: baseHtmlParser,
|
---|
| 200 | useClass: HtmlParser,
|
---|
| 201 | deps: [],
|
---|
| 202 | },
|
---|
| 203 | {
|
---|
| 204 | provide: I18NHtmlParser,
|
---|
| 205 | useFactory: ɵ2,
|
---|
| 206 | deps: [
|
---|
| 207 | baseHtmlParser,
|
---|
| 208 | [new Optional(), new Inject(TRANSLATIONS)],
|
---|
| 209 | [new Optional(), new Inject(TRANSLATIONS_FORMAT)],
|
---|
| 210 | [CompilerConfig],
|
---|
| 211 | [ɵConsole],
|
---|
| 212 | ]
|
---|
| 213 | },
|
---|
| 214 | {
|
---|
| 215 | provide: HtmlParser,
|
---|
| 216 | useExisting: I18NHtmlParser,
|
---|
| 217 | },
|
---|
| 218 | {
|
---|
| 219 | provide: TemplateParser,
|
---|
| 220 | deps: [CompilerConfig, CompileReflector, Parser, ElementSchemaRegistry, I18NHtmlParser, ɵConsole]
|
---|
| 221 | },
|
---|
| 222 | { provide: JitEvaluator, useClass: JitEvaluator, deps: [] },
|
---|
| 223 | { provide: DirectiveNormalizer, deps: [ResourceLoader, UrlResolver, HtmlParser, CompilerConfig] },
|
---|
| 224 | {
|
---|
| 225 | provide: CompileMetadataResolver,
|
---|
| 226 | deps: [
|
---|
| 227 | CompilerConfig, HtmlParser, NgModuleResolver, DirectiveResolver, PipeResolver,
|
---|
| 228 | SummaryResolver, ElementSchemaRegistry, DirectiveNormalizer, ɵConsole,
|
---|
| 229 | [Optional, StaticSymbolCache], CompileReflector, [Optional, ERROR_COLLECTOR_TOKEN]
|
---|
| 230 | ]
|
---|
| 231 | },
|
---|
| 232 | DEFAULT_PACKAGE_URL_PROVIDER,
|
---|
| 233 | { provide: StyleCompiler, deps: [UrlResolver] },
|
---|
| 234 | { provide: ViewCompiler, deps: [CompileReflector] },
|
---|
| 235 | { provide: NgModuleCompiler, deps: [CompileReflector] },
|
---|
| 236 | { provide: CompilerConfig, useValue: ɵ3 },
|
---|
| 237 | {
|
---|
| 238 | provide: Compiler,
|
---|
| 239 | useClass: CompilerImpl,
|
---|
| 240 | deps: [
|
---|
| 241 | Injector, CompileMetadataResolver, TemplateParser, StyleCompiler, ViewCompiler,
|
---|
| 242 | NgModuleCompiler, SummaryResolver, CompileReflector, JitEvaluator, CompilerConfig, ɵConsole
|
---|
| 243 | ]
|
---|
| 244 | },
|
---|
| 245 | { provide: DomElementSchemaRegistry, deps: [] },
|
---|
| 246 | { provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry },
|
---|
| 247 | { provide: UrlResolver, deps: [PACKAGE_ROOT_URL] },
|
---|
| 248 | { provide: DirectiveResolver, deps: [CompileReflector] },
|
---|
| 249 | { provide: PipeResolver, deps: [CompileReflector] },
|
---|
| 250 | { provide: NgModuleResolver, deps: [CompileReflector] },
|
---|
| 251 | ];
|
---|
| 252 | const COMPILER_PROVIDERS__POST_R3__ = [{ provide: Compiler, useFactory: () => new Compiler() }];
|
---|
| 253 | const COMPILER_PROVIDERS = COMPILER_PROVIDERS__POST_R3__;
|
---|
| 254 | /**
|
---|
| 255 | * @publicApi
|
---|
| 256 | */
|
---|
| 257 | class JitCompilerFactory {
|
---|
| 258 | /* @internal */
|
---|
| 259 | constructor(defaultOptions) {
|
---|
| 260 | const compilerOptions = {
|
---|
| 261 | useJit: true,
|
---|
| 262 | defaultEncapsulation: ViewEncapsulation.Emulated,
|
---|
| 263 | missingTranslation: MissingTranslationStrategy.Warning,
|
---|
| 264 | };
|
---|
| 265 | this._defaultOptions = [compilerOptions, ...defaultOptions];
|
---|
| 266 | }
|
---|
| 267 | createCompiler(options = []) {
|
---|
| 268 | const opts = _mergeOptions(this._defaultOptions.concat(options));
|
---|
| 269 | const injector = Injector.create([
|
---|
| 270 | COMPILER_PROVIDERS, {
|
---|
| 271 | provide: CompilerConfig,
|
---|
| 272 | useFactory: () => {
|
---|
| 273 | return new CompilerConfig({
|
---|
| 274 | // let explicit values from the compiler options overwrite options
|
---|
| 275 | // from the app providers
|
---|
| 276 | useJit: opts.useJit,
|
---|
| 277 | jitDevMode: isDevMode(),
|
---|
| 278 | // let explicit values from the compiler options overwrite options
|
---|
| 279 | // from the app providers
|
---|
| 280 | defaultEncapsulation: opts.defaultEncapsulation,
|
---|
| 281 | missingTranslation: opts.missingTranslation,
|
---|
| 282 | preserveWhitespaces: opts.preserveWhitespaces,
|
---|
| 283 | });
|
---|
| 284 | },
|
---|
| 285 | deps: []
|
---|
| 286 | },
|
---|
| 287 | opts.providers
|
---|
| 288 | ]);
|
---|
| 289 | return injector.get(Compiler);
|
---|
| 290 | }
|
---|
| 291 | }
|
---|
| 292 | function _mergeOptions(optionsArr) {
|
---|
| 293 | return {
|
---|
| 294 | useJit: _lastDefined(optionsArr.map(options => options.useJit)),
|
---|
| 295 | defaultEncapsulation: _lastDefined(optionsArr.map(options => options.defaultEncapsulation)),
|
---|
| 296 | providers: _mergeArrays(optionsArr.map(options => options.providers)),
|
---|
| 297 | missingTranslation: _lastDefined(optionsArr.map(options => options.missingTranslation)),
|
---|
| 298 | preserveWhitespaces: _lastDefined(optionsArr.map(options => options.preserveWhitespaces)),
|
---|
| 299 | };
|
---|
| 300 | }
|
---|
| 301 | function _lastDefined(args) {
|
---|
| 302 | for (let i = args.length - 1; i >= 0; i--) {
|
---|
| 303 | if (args[i] !== undefined) {
|
---|
| 304 | return args[i];
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 | return undefined;
|
---|
| 308 | }
|
---|
| 309 | function _mergeArrays(parts) {
|
---|
| 310 | const result = [];
|
---|
| 311 | parts.forEach((part) => part && result.push(...part));
|
---|
| 312 | return result;
|
---|
| 313 | }
|
---|
| 314 |
|
---|
| 315 | /**
|
---|
| 316 | * @license
|
---|
| 317 | * Copyright Google LLC All Rights Reserved.
|
---|
| 318 | *
|
---|
| 319 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 320 | * found in the LICENSE file at https://angular.io/license
|
---|
| 321 | */
|
---|
| 322 | const ɵ0$1 = {};
|
---|
| 323 | /**
|
---|
| 324 | * A platform that included corePlatform and the compiler.
|
---|
| 325 | *
|
---|
| 326 | * @publicApi
|
---|
| 327 | */
|
---|
| 328 | const platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [
|
---|
| 329 | { provide: COMPILER_OPTIONS, useValue: ɵ0$1, multi: true },
|
---|
| 330 | { provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS] },
|
---|
| 331 | ]);
|
---|
| 332 |
|
---|
| 333 | /**
|
---|
| 334 | * @license
|
---|
| 335 | * Copyright Google LLC All Rights Reserved.
|
---|
| 336 | *
|
---|
| 337 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 338 | * found in the LICENSE file at https://angular.io/license
|
---|
| 339 | */
|
---|
| 340 | class ResourceLoaderImpl extends ResourceLoader {
|
---|
| 341 | get(url) {
|
---|
| 342 | let resolve;
|
---|
| 343 | let reject;
|
---|
| 344 | const promise = new Promise((res, rej) => {
|
---|
| 345 | resolve = res;
|
---|
| 346 | reject = rej;
|
---|
| 347 | });
|
---|
| 348 | const xhr = new XMLHttpRequest();
|
---|
| 349 | xhr.open('GET', url, true);
|
---|
| 350 | xhr.responseType = 'text';
|
---|
| 351 | xhr.onload = function () {
|
---|
| 352 | // responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
---|
| 353 | // response/responseType properties were introduced in ResourceLoader Level2 spec (supported
|
---|
| 354 | // by IE10)
|
---|
| 355 | const response = xhr.response || xhr.responseText;
|
---|
| 356 | // normalize IE9 bug (https://bugs.jquery.com/ticket/1450)
|
---|
| 357 | let status = xhr.status === 1223 ? 204 : xhr.status;
|
---|
| 358 | // fix status code when it is 0 (0 status is undocumented).
|
---|
| 359 | // Occurs when accessing file resources or on Android 4.1 stock browser
|
---|
| 360 | // while retrieving files from application cache.
|
---|
| 361 | if (status === 0) {
|
---|
| 362 | status = response ? 200 : 0;
|
---|
| 363 | }
|
---|
| 364 | if (200 <= status && status <= 300) {
|
---|
| 365 | resolve(response);
|
---|
| 366 | }
|
---|
| 367 | else {
|
---|
| 368 | reject(`Failed to load ${url}`);
|
---|
| 369 | }
|
---|
| 370 | };
|
---|
| 371 | xhr.onerror = function () {
|
---|
| 372 | reject(`Failed to load ${url}`);
|
---|
| 373 | };
|
---|
| 374 | xhr.send();
|
---|
| 375 | return promise;
|
---|
| 376 | }
|
---|
| 377 | }
|
---|
| 378 | ResourceLoaderImpl.ɵfac = /*@__PURE__*/ function () { let ɵResourceLoaderImpl_BaseFactory; return function ResourceLoaderImpl_Factory(t) { return (ɵResourceLoaderImpl_BaseFactory || (ɵResourceLoaderImpl_BaseFactory = ɵngcc0.ɵɵgetInheritedFactory(ResourceLoaderImpl)))(t || ResourceLoaderImpl); }; }();
|
---|
| 379 | ResourceLoaderImpl.ɵprov = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjectable({ token: ResourceLoaderImpl, factory: ResourceLoaderImpl.ɵfac });
|
---|
| 380 | (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(ResourceLoaderImpl, [{
|
---|
| 381 | type: Injectable
|
---|
| 382 | }], null, null); })();
|
---|
| 383 |
|
---|
| 384 | /**
|
---|
| 385 | * @license
|
---|
| 386 | * Copyright Google LLC All Rights Reserved.
|
---|
| 387 | *
|
---|
| 388 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 389 | * found in the LICENSE file at https://angular.io/license
|
---|
| 390 | */
|
---|
| 391 | const ɵ0$2 = { providers: [{ provide: ResourceLoader, useClass: ResourceLoaderImpl, deps: [] }] }, ɵ1$1 = ɵPLATFORM_BROWSER_ID;
|
---|
| 392 | /**
|
---|
| 393 | * @publicApi
|
---|
| 394 | */
|
---|
| 395 | const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS = [
|
---|
| 396 | ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS,
|
---|
| 397 | {
|
---|
| 398 | provide: COMPILER_OPTIONS,
|
---|
| 399 | useValue: ɵ0$2,
|
---|
| 400 | multi: true
|
---|
| 401 | },
|
---|
| 402 | { provide: PLATFORM_ID, useValue: ɵ1$1 },
|
---|
| 403 | ];
|
---|
| 404 |
|
---|
| 405 | /**
|
---|
| 406 | * @license
|
---|
| 407 | * Copyright Google LLC All Rights Reserved.
|
---|
| 408 | *
|
---|
| 409 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 410 | * found in the LICENSE file at https://angular.io/license
|
---|
| 411 | */
|
---|
| 412 | /**
|
---|
| 413 | * An implementation of ResourceLoader that uses a template cache to avoid doing an actual
|
---|
| 414 | * ResourceLoader.
|
---|
| 415 | *
|
---|
| 416 | * The template cache needs to be built and loaded into window.$templateCache
|
---|
| 417 | * via a separate mechanism.
|
---|
| 418 | *
|
---|
| 419 | * @publicApi
|
---|
| 420 | */
|
---|
| 421 | class CachedResourceLoader extends ResourceLoader {
|
---|
| 422 | constructor() {
|
---|
| 423 | super();
|
---|
| 424 | this._cache = ɵglobal.$templateCache;
|
---|
| 425 | if (this._cache == null) {
|
---|
| 426 | throw new Error('CachedResourceLoader: Template cache was not found in $templateCache.');
|
---|
| 427 | }
|
---|
| 428 | }
|
---|
| 429 | get(url) {
|
---|
| 430 | if (this._cache.hasOwnProperty(url)) {
|
---|
| 431 | return Promise.resolve(this._cache[url]);
|
---|
| 432 | }
|
---|
| 433 | else {
|
---|
| 434 | return Promise.reject('CachedResourceLoader: Did not find cached template for ' + url);
|
---|
| 435 | }
|
---|
| 436 | }
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | /**
|
---|
| 440 | * @license
|
---|
| 441 | * Copyright Google LLC All Rights Reserved.
|
---|
| 442 | *
|
---|
| 443 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 444 | * found in the LICENSE file at https://angular.io/license
|
---|
| 445 | */
|
---|
| 446 |
|
---|
| 447 | /**
|
---|
| 448 | * @license
|
---|
| 449 | * Copyright Google LLC All Rights Reserved.
|
---|
| 450 | *
|
---|
| 451 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 452 | * found in the LICENSE file at https://angular.io/license
|
---|
| 453 | */
|
---|
| 454 | /**
|
---|
| 455 | * @publicApi
|
---|
| 456 | */
|
---|
| 457 | const VERSION = new Version('12.2.9');
|
---|
| 458 |
|
---|
| 459 | /**
|
---|
| 460 | * @license
|
---|
| 461 | * Copyright Google LLC All Rights Reserved.
|
---|
| 462 | *
|
---|
| 463 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 464 | * found in the LICENSE file at https://angular.io/license
|
---|
| 465 | */
|
---|
| 466 | /**
|
---|
| 467 | * @publicApi
|
---|
| 468 | */
|
---|
| 469 | const RESOURCE_CACHE_PROVIDER = [{ provide: ResourceLoader, useClass: CachedResourceLoader, deps: [] }];
|
---|
| 470 | /**
|
---|
| 471 | * @publicApi
|
---|
| 472 | */
|
---|
| 473 | const platformBrowserDynamic = createPlatformFactory(platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
|
---|
| 474 |
|
---|
| 475 | /**
|
---|
| 476 | * @license
|
---|
| 477 | * Copyright Google LLC All Rights Reserved.
|
---|
| 478 | *
|
---|
| 479 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 480 | * found in the LICENSE file at https://angular.io/license
|
---|
| 481 | */
|
---|
| 482 | // This file only reexports content of the `src` folder. Keep it that way.
|
---|
| 483 |
|
---|
| 484 | /**
|
---|
| 485 | * @license
|
---|
| 486 | * Copyright Google LLC All Rights Reserved.
|
---|
| 487 | *
|
---|
| 488 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 489 | * found in the LICENSE file at https://angular.io/license
|
---|
| 490 | */
|
---|
| 491 |
|
---|
| 492 | /**
|
---|
| 493 | * Generated bundle index. Do not edit.
|
---|
| 494 | */
|
---|
| 495 |
|
---|
| 496 | export { JitCompilerFactory, RESOURCE_CACHE_PROVIDER, VERSION, platformBrowserDynamic, COMPILER_PROVIDERS__POST_R3__ as ɵCOMPILER_PROVIDERS__POST_R3__, CompilerImpl as ɵCompilerImpl, INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, ResourceLoaderImpl as ɵResourceLoaderImpl, CachedResourceLoader as ɵangular_packages_platform_browser_dynamic_platform_browser_dynamic_a, platformCoreDynamic as ɵplatformCoreDynamic };
|
---|
| 497 |
|
---|
| 498 | //# sourceMappingURL=platform-browser-dynamic.js.map |
---|