blob: 4db48593a37ec034afd46c7c078d785eaa137db6 [file] [log] [blame]
/**
* @license Angular v11.2.14
* (c) 2010-2021 Google LLC. https://angular.io/
* License: MIT
*/
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';
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';
import { ɵPLATFORM_BROWSER_ID } from '@angular/common';
import { ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS } from '@angular/platform-browser';
/**
* @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
*/
const MODULE_SUFFIX = '';
const builtinExternalReferences = createBuiltinExternalReferencesMap();
class JitReflector {
constructor() {
this.reflectionCapabilities = new ɵReflectionCapabilities();
}
componentModuleUrl(type, cmpMetadata) {
const moduleId = cmpMetadata.moduleId;
if (typeof moduleId === 'string') {
const scheme = getUrlScheme(moduleId);
return scheme ? moduleId : `package:${moduleId}${MODULE_SUFFIX}`;
}
else if (moduleId !== null && moduleId !== void 0) {
throw syntaxError(`moduleId should be a string in "${ɵstringify(type)}". See https://goo.gl/wIDDiL for more information.\n` +
`If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.`);
}
return `./$stringify(type)}`;
}
parameters(typeOrFunc) {
return this.reflectionCapabilities.parameters(typeOrFunc);
}
tryAnnotations(typeOrFunc) {
return this.annotations(typeOrFunc);
}
annotations(typeOrFunc) {
return this.reflectionCapabilities.annotations(typeOrFunc);
}
shallowAnnotations(typeOrFunc) {
throw new Error('Not supported in JIT mode');
}
propMetadata(typeOrFunc) {
return this.reflectionCapabilities.propMetadata(typeOrFunc);
}
hasLifecycleHook(type, lcProperty) {
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
}
guards(type) {
return this.reflectionCapabilities.guards(type);
}
resolveExternalReference(ref) {
return builtinExternalReferences.get(ref) || ref.runtime;
}
}
function createBuiltinExternalReferencesMap() {
const map = new Map();
map.set(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS, ANALYZE_FOR_ENTRY_COMPONENTS);
map.set(Identifiers.ElementRef, ElementRef);
map.set(Identifiers.NgModuleRef, NgModuleRef);
map.set(Identifiers.ViewContainerRef, ViewContainerRef);
map.set(Identifiers.ChangeDetectorRef, ChangeDetectorRef);
map.set(Identifiers.Renderer2, Renderer2);
map.set(Identifiers.QueryList, QueryList);
map.set(Identifiers.TemplateRef, TemplateRef);
map.set(Identifiers.CodegenComponentFactoryResolver, ɵCodegenComponentFactoryResolver);
map.set(Identifiers.ComponentFactoryResolver, ComponentFactoryResolver);
map.set(Identifiers.ComponentFactory, ComponentFactory);
map.set(Identifiers.ComponentRef, ComponentRef);
map.set(Identifiers.NgModuleFactory, NgModuleFactory);
map.set(Identifiers.createModuleFactory, ɵcmf);
map.set(Identifiers.moduleDef, ɵmod);
map.set(Identifiers.moduleProviderDef, ɵmpd);
map.set(Identifiers.RegisterModuleFactoryFn, ɵregisterModuleFactory);
map.set(Identifiers.Injector, Injector);
map.set(Identifiers.ViewEncapsulation, ViewEncapsulation);
map.set(Identifiers.ChangeDetectionStrategy, ChangeDetectionStrategy);
map.set(Identifiers.SecurityContext, SecurityContext);
map.set(Identifiers.LOCALE_ID, LOCALE_ID);
map.set(Identifiers.TRANSLATIONS_FORMAT, TRANSLATIONS_FORMAT);
map.set(Identifiers.inlineInterpolate, ɵinlineInterpolate);
map.set(Identifiers.interpolate, ɵinterpolate);
map.set(Identifiers.EMPTY_ARRAY, ɵEMPTY_ARRAY);
map.set(Identifiers.EMPTY_MAP, ɵEMPTY_MAP);
map.set(Identifiers.viewDef, ɵvid);
map.set(Identifiers.elementDef, ɵeld);
map.set(Identifiers.anchorDef, ɵand);
map.set(Identifiers.textDef, ɵted);
map.set(Identifiers.directiveDef, ɵdid);
map.set(Identifiers.providerDef, ɵprd);
map.set(Identifiers.queryDef, ɵqud);
map.set(Identifiers.pureArrayDef, ɵpad);
map.set(Identifiers.pureObjectDef, ɵpod);
map.set(Identifiers.purePipeDef, ɵppd);
map.set(Identifiers.pipeDef, ɵpid);
map.set(Identifiers.nodeValue, ɵnov);
map.set(Identifiers.ngContentDef, ɵncd);
map.set(Identifiers.unwrapValue, ɵunv);
map.set(Identifiers.createRendererType2, ɵcrt);
map.set(Identifiers.createComponentFactory, ɵccf);
return map;
}
/**
* @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
*/
const ERROR_COLLECTOR_TOKEN = new InjectionToken('ErrorCollector');
/**
* A default provider for {@link PACKAGE_ROOT_URL} that maps to '/'.
*/
const DEFAULT_PACKAGE_URL_PROVIDER = {
provide: PACKAGE_ROOT_URL,
useValue: '/'
};
const _NO_RESOURCE_LOADER = {
get(url) {
throw new Error(`No ResourceLoader implementation has been provided. Can't read the url "${url}"`);
}
};
const baseHtmlParser = new InjectionToken('HtmlParser');
class CompilerImpl {
constructor(injector, _metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console) {
this._metadataResolver = _metadataResolver;
this._delegate = new JitCompiler(_metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console, this.getExtraNgModuleProviders.bind(this));
this.injector = injector;
}
getExtraNgModuleProviders() {
return [this._metadataResolver.getProviderMetadata(new ProviderMeta(Compiler, { useValue: this }))];
}
compileModuleSync(moduleType) {
return this._delegate.compileModuleSync(moduleType);
}
compileModuleAsync(moduleType) {
return this._delegate.compileModuleAsync(moduleType);
}
compileModuleAndAllComponentsSync(moduleType) {
const result = this._delegate.compileModuleAndAllComponentsSync(moduleType);
return {
ngModuleFactory: result.ngModuleFactory,
componentFactories: result.componentFactories,
};
}
compileModuleAndAllComponentsAsync(moduleType) {
return this._delegate.compileModuleAndAllComponentsAsync(moduleType)
.then((result) => ({
ngModuleFactory: result.ngModuleFactory,
componentFactories: result.componentFactories,
}));
}
loadAotSummaries(summaries) {
this._delegate.loadAotSummaries(summaries);
}
hasAotSummary(ref) {
return this._delegate.hasAotSummary(ref);
}
getComponentFactory(component) {
return this._delegate.getComponentFactory(component);
}
clearCache() {
this._delegate.clearCache();
}
clearCacheFor(type) {
this._delegate.clearCacheFor(type);
}
getModuleId(moduleType) {
const meta = this._metadataResolver.getNgModuleMetadata(moduleType);
return meta && meta.id || undefined;
}
}
const ɵ0 = new JitReflector(), ɵ1 = _NO_RESOURCE_LOADER, ɵ2 = (parser, translations, format, config, console) => {
translations = translations || '';
const missingTranslation = translations ? config.missingTranslation : MissingTranslationStrategy.Ignore;
return new I18NHtmlParser(parser, translations, format, missingTranslation, console);
}, ɵ3 = new CompilerConfig();
/**
* A set of providers that provide `JitCompiler` and its dependencies to use for
* template compilation.
*/
const COMPILER_PROVIDERS__PRE_R3__ = [
{ provide: CompileReflector, useValue: ɵ0 },
{ provide: ResourceLoader, useValue: ɵ1 },
{ provide: JitSummaryResolver, deps: [] },
{ provide: SummaryResolver, useExisting: JitSummaryResolver },
{ provide: ɵConsole, deps: [] },
{ provide: Lexer, deps: [] },
{ provide: Parser, deps: [Lexer] },
{
provide: baseHtmlParser,
useClass: HtmlParser,
deps: [],
},
{
provide: I18NHtmlParser,
useFactory: ɵ2,
deps: [
baseHtmlParser,
[new Optional(), new Inject(TRANSLATIONS)],
[new Optional(), new Inject(TRANSLATIONS_FORMAT)],
[CompilerConfig],
Console],
]
},
{
provide: HtmlParser,
useExisting: I18NHtmlParser,
},
{
provide: TemplateParser,
deps: [CompilerConfig, CompileReflector, Parser, ElementSchemaRegistry, I18NHtmlParser, ɵConsole]
},
{ provide: JitEvaluator, useClass: JitEvaluator, deps: [] },
{ provide: DirectiveNormalizer, deps: [ResourceLoader, UrlResolver, HtmlParser, CompilerConfig] },
{
provide: CompileMetadataResolver,
deps: [
CompilerConfig, HtmlParser, NgModuleResolver, DirectiveResolver, PipeResolver,
SummaryResolver, ElementSchemaRegistry, DirectiveNormalizer, ɵConsole,
[Optional, StaticSymbolCache], CompileReflector, [Optional, ERROR_COLLECTOR_TOKEN]
]
},
DEFAULT_PACKAGE_URL_PROVIDER,
{ provide: StyleCompiler, deps: [UrlResolver] },
{ provide: ViewCompiler, deps: [CompileReflector] },
{ provide: NgModuleCompiler, deps: [CompileReflector] },
{ provide: CompilerConfig, useValue: ɵ3 },
{
provide: Compiler,
useClass: CompilerImpl,
deps: [
Injector, CompileMetadataResolver, TemplateParser, StyleCompiler, ViewCompiler,
NgModuleCompiler, SummaryResolver, CompileReflector, JitEvaluator, CompilerConfig, ɵConsole
]
},
{ provide: DomElementSchemaRegistry, deps: [] },
{ provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry },
{ provide: UrlResolver, deps: [PACKAGE_ROOT_URL] },
{ provide: DirectiveResolver, deps: [CompileReflector] },
{ provide: PipeResolver, deps: [CompileReflector] },
{ provide: NgModuleResolver, deps: [CompileReflector] },
];
const COMPILER_PROVIDERS__POST_R3__ = [{ provide: Compiler, useFactory: () => new Compiler() }];
const COMPILER_PROVIDERS = COMPILER_PROVIDERS__PRE_R3__;
/**
* @publicApi
*/
class JitCompilerFactory {
/* @internal */
constructor(defaultOptions) {
const compilerOptions = {
useJit: true,
defaultEncapsulation: ViewEncapsulation.Emulated,
missingTranslation: MissingTranslationStrategy.Warning,
};
this._defaultOptions = [compilerOptions, ...defaultOptions];
}
createCompiler(options = []) {
const opts = _mergeOptions(this._defaultOptions.concat(options));
const injector = Injector.create([
COMPILER_PROVIDERS, {
provide: CompilerConfig,
useFactory: () => {
return new CompilerConfig({
// let explicit values from the compiler options overwrite options
// from the app providers
useJit: opts.useJit,
jitDevMode: isDevMode(),
// let explicit values from the compiler options overwrite options
// from the app providers
defaultEncapsulation: opts.defaultEncapsulation,
missingTranslation: opts.missingTranslation,
preserveWhitespaces: opts.preserveWhitespaces,
});
},
deps: []
},
opts.providers
]);
return injector.get(Compiler);
}
}
function _mergeOptions(optionsArr) {
return {
useJit: _lastDefined(optionsArr.map(options => options.useJit)),
defaultEncapsulation: _lastDefined(optionsArr.map(options => options.defaultEncapsulation)),
providers: _mergeArrays(optionsArr.map(options => options.providers)),
missingTranslation: _lastDefined(optionsArr.map(options => options.missingTranslation)),
preserveWhitespaces: _lastDefined(optionsArr.map(options => options.preserveWhitespaces)),
};
}
function _lastDefined(args) {
for (let i = args.length - 1; i >= 0; i--) {
if (args[i] !== undefined) {
return args[i];
}
}
return undefined;
}
function _mergeArrays(parts) {
const result = [];
parts.forEach((part) => part && result.push(...part));
return result;
}
/**
* @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
*/
const ɵ0$1 = {};
/**
* A platform that included corePlatform and the compiler.
*
* @publicApi
*/
const platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [
{ provide: COMPILER_OPTIONS, useValue: ɵ0$1, multi: true },
{ provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS] },
]);
/**
* @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
*/
class ResourceLoaderImpl extends ResourceLoader {
get(url) {
let resolve;
let reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'text';
xhr.onload = function () {
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
// response/responseType properties were introduced in ResourceLoader Level2 spec (supported
// by IE10)
const response = xhr.response || xhr.responseText;
// normalize IE9 bug (https://bugs.jquery.com/ticket/1450)
let status = xhr.status === 1223 ? 204 : xhr.status;
// fix status code when it is 0 (0 status is undocumented).
// Occurs when accessing file resources or on Android 4.1 stock browser
// while retrieving files from application cache.
if (status === 0) {
status = response ? 200 : 0;
}
if (200 <= status && status <= 300) {
resolve(response);
}
else {
reject(`Failed to load ${url}`);
}
};
xhr.onerror = function () {
reject(`Failed to load ${url}`);
};
xhr.send();
return promise;
}
}
ResourceLoaderImpl.decorators = [
{ type: Injectable }
];
/**
* @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
*/
const ɵ0$2 = { providers: [{ provide: ResourceLoader, useClass: ResourceLoaderImpl, deps: [] }] }, ɵ1$1 = ɵPLATFORM_BROWSER_ID;
/**
* @publicApi
*/
const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS = [
ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS,
{
provide: COMPILER_OPTIONS,
useValue: ɵ0$2,
multi: true
},
{ provide: PLATFORM_ID, useValue: ɵ1$1 },
];
/**
* @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
*/
/**
* 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
*/
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);
}
}
}
/**
* @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
*/
/**
* @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
*/
/**
* @publicApi
*/
const VERSION = new Version('11.2.14');
/**
* @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
*/
/**
* @publicApi
*/
const RESOURCE_CACHE_PROVIDER = [{ provide: ResourceLoader, useClass: CachedResourceLoader, deps: [] }];
/**
* @publicApi
*/
const platformBrowserDynamic = createPlatformFactory(platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
/**
* @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
*/
// This file only reexports content of the `src` folder. Keep it that way.
/**
* @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
*/
/**
* Generated bundle index. Do not edit.
*/
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 };
//# sourceMappingURL=platform-browser-dynamic.js.map