1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { getUrlScheme, syntaxError, Identifiers, JitCompiler, ProviderMeta, CompileReflector, ResourceLoader, JitSummaryResolver, SummaryResolver, Lexer, Parser, HtmlParser, I18NHtmlParser, CompilerConfig, 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, Renderer, ɵvid, ɵeld, ɵand, ɵted, ɵdid, ɵprd, ɵqud, ɵpad, ɵpod, ɵppd, ɵpid, ɵnov, ɵncd, ɵunv, ɵcrt, ɵccf, InjectionToken, PACKAGE_ROOT_URL, Compiler, ɵConsole, MissingTranslationStrategy, Optional, Inject, TRANSLATIONS, isDevMode, createPlatformFactory, platformCore, COMPILER_OPTIONS, CompilerFactory, Injectable, PLATFORM_ID, ɵglobal, Version } from '@angular/core';
|
9 | import { __spread, __extends, __decorate } from 'tslib';
|
10 | import { ɵPLATFORM_BROWSER_ID } from '@angular/common';
|
11 | import { ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS } from '@angular/platform-browser';
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | var MODULE_SUFFIX = '';
|
21 | var builtinExternalReferences = createBuiltinExternalReferencesMap();
|
22 | var JitReflector = (function () {
|
23 | function JitReflector() {
|
24 | this.reflectionCapabilities = new ɵReflectionCapabilities();
|
25 | }
|
26 | JitReflector.prototype.componentModuleUrl = function (type, cmpMetadata) {
|
27 | var moduleId = cmpMetadata.moduleId;
|
28 | if (typeof moduleId === 'string') {
|
29 | var 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 | JitReflector.prototype.parameters = function (typeOrFunc) {
|
39 | return this.reflectionCapabilities.parameters(typeOrFunc);
|
40 | };
|
41 | JitReflector.prototype.tryAnnotations = function (typeOrFunc) { return this.annotations(typeOrFunc); };
|
42 | JitReflector.prototype.annotations = function (typeOrFunc) {
|
43 | return this.reflectionCapabilities.annotations(typeOrFunc);
|
44 | };
|
45 | JitReflector.prototype.shallowAnnotations = function (typeOrFunc) {
|
46 | throw new Error('Not supported in JIT mode');
|
47 | };
|
48 | JitReflector.prototype.propMetadata = function (typeOrFunc) {
|
49 | return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
50 | };
|
51 | JitReflector.prototype.hasLifecycleHook = function (type, lcProperty) {
|
52 | return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
53 | };
|
54 | JitReflector.prototype.guards = function (type) { return this.reflectionCapabilities.guards(type); };
|
55 | JitReflector.prototype.resolveExternalReference = function (ref) {
|
56 | return builtinExternalReferences.get(ref) || ref.runtime;
|
57 | };
|
58 | return JitReflector;
|
59 | }());
|
60 | function createBuiltinExternalReferencesMap() {
|
61 | var map = new Map();
|
62 | map.set(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS, ANALYZE_FOR_ENTRY_COMPONENTS);
|
63 | map.set(Identifiers.ElementRef, ElementRef);
|
64 | map.set(Identifiers.NgModuleRef, NgModuleRef);
|
65 | map.set(Identifiers.ViewContainerRef, ViewContainerRef);
|
66 | map.set(Identifiers.ChangeDetectorRef, ChangeDetectorRef);
|
67 | map.set(Identifiers.Renderer2, Renderer2);
|
68 | map.set(Identifiers.QueryList, QueryList);
|
69 | map.set(Identifiers.TemplateRef, TemplateRef);
|
70 | map.set(Identifiers.CodegenComponentFactoryResolver, ɵCodegenComponentFactoryResolver);
|
71 | map.set(Identifiers.ComponentFactoryResolver, ComponentFactoryResolver);
|
72 | map.set(Identifiers.ComponentFactory, ComponentFactory);
|
73 | map.set(Identifiers.ComponentRef, ComponentRef);
|
74 | map.set(Identifiers.NgModuleFactory, NgModuleFactory);
|
75 | map.set(Identifiers.createModuleFactory, ɵcmf);
|
76 | map.set(Identifiers.moduleDef, ɵmod);
|
77 | map.set(Identifiers.moduleProviderDef, ɵmpd);
|
78 | map.set(Identifiers.RegisterModuleFactoryFn, ɵregisterModuleFactory);
|
79 | map.set(Identifiers.Injector, Injector);
|
80 | map.set(Identifiers.ViewEncapsulation, ViewEncapsulation);
|
81 | map.set(Identifiers.ChangeDetectionStrategy, ChangeDetectionStrategy);
|
82 | map.set(Identifiers.SecurityContext, SecurityContext);
|
83 | map.set(Identifiers.LOCALE_ID, LOCALE_ID);
|
84 | map.set(Identifiers.TRANSLATIONS_FORMAT, TRANSLATIONS_FORMAT);
|
85 | map.set(Identifiers.inlineInterpolate, ɵinlineInterpolate);
|
86 | map.set(Identifiers.interpolate, ɵinterpolate);
|
87 | map.set(Identifiers.EMPTY_ARRAY, ɵEMPTY_ARRAY);
|
88 | map.set(Identifiers.EMPTY_MAP, ɵEMPTY_MAP);
|
89 | map.set(Identifiers.Renderer, Renderer);
|
90 | map.set(Identifiers.viewDef, ɵvid);
|
91 | map.set(Identifiers.elementDef, ɵeld);
|
92 | map.set(Identifiers.anchorDef, ɵand);
|
93 | map.set(Identifiers.textDef, ɵted);
|
94 | map.set(Identifiers.directiveDef, ɵdid);
|
95 | map.set(Identifiers.providerDef, ɵprd);
|
96 | map.set(Identifiers.queryDef, ɵqud);
|
97 | map.set(Identifiers.pureArrayDef, ɵpad);
|
98 | map.set(Identifiers.pureObjectDef, ɵpod);
|
99 | map.set(Identifiers.purePipeDef, ɵppd);
|
100 | map.set(Identifiers.pipeDef, ɵpid);
|
101 | map.set(Identifiers.nodeValue, ɵnov);
|
102 | map.set(Identifiers.ngContentDef, ɵncd);
|
103 | map.set(Identifiers.unwrapValue, ɵunv);
|
104 | map.set(Identifiers.createRendererType2, ɵcrt);
|
105 | map.set(Identifiers.createComponentFactory, ɵccf);
|
106 | return map;
|
107 | }
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | var ERROR_COLLECTOR_TOKEN = new InjectionToken('ErrorCollector');
|
117 |
|
118 |
|
119 |
|
120 | var DEFAULT_PACKAGE_URL_PROVIDER = {
|
121 | provide: PACKAGE_ROOT_URL,
|
122 | useValue: '/'
|
123 | };
|
124 | var _NO_RESOURCE_LOADER = {
|
125 | get: function (url) {
|
126 | throw new Error("No ResourceLoader implementation has been provided. Can't read the url \"" + url + "\"");
|
127 | }
|
128 | };
|
129 | var baseHtmlParser = new InjectionToken('HtmlParser');
|
130 | var CompilerImpl = (function () {
|
131 | function CompilerImpl(injector, _metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console) {
|
132 | this._metadataResolver = _metadataResolver;
|
133 | this._delegate = new JitCompiler(_metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console, this.getExtraNgModuleProviders.bind(this));
|
134 | this.injector = injector;
|
135 | }
|
136 | CompilerImpl.prototype.getExtraNgModuleProviders = function () {
|
137 | return [this._metadataResolver.getProviderMetadata(new ProviderMeta(Compiler, { useValue: this }))];
|
138 | };
|
139 | CompilerImpl.prototype.compileModuleSync = function (moduleType) {
|
140 | return this._delegate.compileModuleSync(moduleType);
|
141 | };
|
142 | CompilerImpl.prototype.compileModuleAsync = function (moduleType) {
|
143 | return this._delegate.compileModuleAsync(moduleType);
|
144 | };
|
145 | CompilerImpl.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
|
146 | var result = this._delegate.compileModuleAndAllComponentsSync(moduleType);
|
147 | return {
|
148 | ngModuleFactory: result.ngModuleFactory,
|
149 | componentFactories: result.componentFactories,
|
150 | };
|
151 | };
|
152 | CompilerImpl.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
|
153 | return this._delegate.compileModuleAndAllComponentsAsync(moduleType)
|
154 | .then(function (result) { return ({
|
155 | ngModuleFactory: result.ngModuleFactory,
|
156 | componentFactories: result.componentFactories,
|
157 | }); });
|
158 | };
|
159 | CompilerImpl.prototype.loadAotSummaries = function (summaries) { this._delegate.loadAotSummaries(summaries); };
|
160 | CompilerImpl.prototype.hasAotSummary = function (ref) { return this._delegate.hasAotSummary(ref); };
|
161 | CompilerImpl.prototype.getComponentFactory = function (component) {
|
162 | return this._delegate.getComponentFactory(component);
|
163 | };
|
164 | CompilerImpl.prototype.clearCache = function () { this._delegate.clearCache(); };
|
165 | CompilerImpl.prototype.clearCacheFor = function (type) { this._delegate.clearCacheFor(type); };
|
166 | CompilerImpl.prototype.getModuleId = function (moduleType) {
|
167 | var meta = this._metadataResolver.getNgModuleMetadata(moduleType);
|
168 | return meta && meta.id || undefined;
|
169 | };
|
170 | return CompilerImpl;
|
171 | }());
|
172 |
|
173 |
|
174 |
|
175 |
|
176 | var COMPILER_PROVIDERS = [
|
177 | { provide: CompileReflector, useValue: new JitReflector() },
|
178 | { provide: ResourceLoader, useValue: _NO_RESOURCE_LOADER },
|
179 | { provide: JitSummaryResolver, deps: [] },
|
180 | { provide: SummaryResolver, useExisting: JitSummaryResolver },
|
181 | { provide: ɵConsole, deps: [] },
|
182 | { provide: Lexer, deps: [] },
|
183 | { provide: Parser, deps: [Lexer] },
|
184 | {
|
185 | provide: baseHtmlParser,
|
186 | useClass: HtmlParser,
|
187 | deps: [],
|
188 | },
|
189 | {
|
190 | provide: I18NHtmlParser,
|
191 | useFactory: function (parser, translations, format, config, console) {
|
192 | translations = translations || '';
|
193 | var missingTranslation = translations ? config.missingTranslation : MissingTranslationStrategy.Ignore;
|
194 | return new I18NHtmlParser(parser, translations, format, missingTranslation, console);
|
195 | },
|
196 | deps: [
|
197 | baseHtmlParser,
|
198 | [new Optional(), new Inject(TRANSLATIONS)],
|
199 | [new Optional(), new Inject(TRANSLATIONS_FORMAT)],
|
200 | [CompilerConfig],
|
201 | [ɵConsole],
|
202 | ]
|
203 | },
|
204 | {
|
205 | provide: HtmlParser,
|
206 | useExisting: I18NHtmlParser,
|
207 | },
|
208 | {
|
209 | provide: TemplateParser, deps: [CompilerConfig, CompileReflector,
|
210 | Parser, ElementSchemaRegistry,
|
211 | I18NHtmlParser, ɵConsole]
|
212 | },
|
213 | { provide: JitEvaluator, useClass: JitEvaluator, deps: [] },
|
214 | { provide: DirectiveNormalizer, deps: [ResourceLoader, UrlResolver, HtmlParser, CompilerConfig] },
|
215 | { provide: CompileMetadataResolver, deps: [CompilerConfig, HtmlParser, NgModuleResolver,
|
216 | DirectiveResolver, PipeResolver,
|
217 | SummaryResolver,
|
218 | ElementSchemaRegistry,
|
219 | DirectiveNormalizer, ɵConsole,
|
220 | [Optional, StaticSymbolCache],
|
221 | CompileReflector,
|
222 | [Optional, ERROR_COLLECTOR_TOKEN]] },
|
223 | DEFAULT_PACKAGE_URL_PROVIDER,
|
224 | { provide: StyleCompiler, deps: [UrlResolver] },
|
225 | { provide: ViewCompiler, deps: [CompileReflector] },
|
226 | { provide: NgModuleCompiler, deps: [CompileReflector] },
|
227 | { provide: CompilerConfig, useValue: new CompilerConfig() },
|
228 | { provide: Compiler, useClass: CompilerImpl, deps: [Injector, CompileMetadataResolver,
|
229 | TemplateParser, StyleCompiler,
|
230 | ViewCompiler, NgModuleCompiler,
|
231 | SummaryResolver, CompileReflector, JitEvaluator, CompilerConfig,
|
232 | ɵConsole] },
|
233 | { provide: DomElementSchemaRegistry, deps: [] },
|
234 | { provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry },
|
235 | { provide: UrlResolver, deps: [PACKAGE_ROOT_URL] },
|
236 | { provide: DirectiveResolver, deps: [CompileReflector] },
|
237 | { provide: PipeResolver, deps: [CompileReflector] },
|
238 | { provide: NgModuleResolver, deps: [CompileReflector] },
|
239 | ];
|
240 |
|
241 |
|
242 |
|
243 | var JitCompilerFactory = (function () {
|
244 |
|
245 | function JitCompilerFactory(defaultOptions) {
|
246 | var compilerOptions = {
|
247 | useJit: true,
|
248 | defaultEncapsulation: ViewEncapsulation.Emulated,
|
249 | missingTranslation: MissingTranslationStrategy.Warning,
|
250 | };
|
251 | this._defaultOptions = __spread([compilerOptions], defaultOptions);
|
252 | }
|
253 | JitCompilerFactory.prototype.createCompiler = function (options) {
|
254 | if (options === void 0) { options = []; }
|
255 | var opts = _mergeOptions(this._defaultOptions.concat(options));
|
256 | var injector = Injector.create([
|
257 | COMPILER_PROVIDERS, {
|
258 | provide: CompilerConfig,
|
259 | useFactory: function () {
|
260 | return new CompilerConfig({
|
261 |
|
262 |
|
263 | useJit: opts.useJit,
|
264 | jitDevMode: isDevMode(),
|
265 |
|
266 |
|
267 | defaultEncapsulation: opts.defaultEncapsulation,
|
268 | missingTranslation: opts.missingTranslation,
|
269 | preserveWhitespaces: opts.preserveWhitespaces,
|
270 | });
|
271 | },
|
272 | deps: []
|
273 | },
|
274 | opts.providers
|
275 | ]);
|
276 | return injector.get(Compiler);
|
277 | };
|
278 | return JitCompilerFactory;
|
279 | }());
|
280 | function _mergeOptions(optionsArr) {
|
281 | return {
|
282 | useJit: _lastDefined(optionsArr.map(function (options) { return options.useJit; })),
|
283 | defaultEncapsulation: _lastDefined(optionsArr.map(function (options) { return options.defaultEncapsulation; })),
|
284 | providers: _mergeArrays(optionsArr.map(function (options) { return options.providers; })),
|
285 | missingTranslation: _lastDefined(optionsArr.map(function (options) { return options.missingTranslation; })),
|
286 | preserveWhitespaces: _lastDefined(optionsArr.map(function (options) { return options.preserveWhitespaces; })),
|
287 | };
|
288 | }
|
289 | function _lastDefined(args) {
|
290 | for (var i = args.length - 1; i >= 0; i--) {
|
291 | if (args[i] !== undefined) {
|
292 | return args[i];
|
293 | }
|
294 | }
|
295 | return undefined;
|
296 | }
|
297 | function _mergeArrays(parts) {
|
298 | var result = [];
|
299 | parts.forEach(function (part) { return part && result.push.apply(result, __spread(part)); });
|
300 | return result;
|
301 | }
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 | var ɵ0 = {};
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 | var platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [
|
317 | { provide: COMPILER_OPTIONS, useValue: ɵ0, multi: true },
|
318 | { provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS] },
|
319 | ]);
|
320 |
|
321 | var ResourceLoaderImpl = (function (_super) {
|
322 | __extends(ResourceLoaderImpl, _super);
|
323 | function ResourceLoaderImpl() {
|
324 | return _super !== null && _super.apply(this, arguments) || this;
|
325 | }
|
326 | ResourceLoaderImpl.prototype.get = function (url) {
|
327 | var resolve;
|
328 | var reject;
|
329 | var promise = new Promise(function (res, rej) {
|
330 | resolve = res;
|
331 | reject = rej;
|
332 | });
|
333 | var xhr = new XMLHttpRequest();
|
334 | xhr.open('GET', url, true);
|
335 | xhr.responseType = 'text';
|
336 | xhr.onload = function () {
|
337 |
|
338 |
|
339 |
|
340 | var response = xhr.response || xhr.responseText;
|
341 |
|
342 | var status = xhr.status === 1223 ? 204 : xhr.status;
|
343 |
|
344 |
|
345 |
|
346 | if (status === 0) {
|
347 | status = response ? 200 : 0;
|
348 | }
|
349 | if (200 <= status && status <= 300) {
|
350 | resolve(response);
|
351 | }
|
352 | else {
|
353 | reject("Failed to load " + url);
|
354 | }
|
355 | };
|
356 | xhr.onerror = function () { reject("Failed to load " + url); };
|
357 | xhr.send();
|
358 | return promise;
|
359 | };
|
360 | ResourceLoaderImpl = __decorate([
|
361 | Injectable()
|
362 | ], ResourceLoaderImpl);
|
363 | return ResourceLoaderImpl;
|
364 | }(ResourceLoader));
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 | var ɵ0$1 = { providers: [{ provide: ResourceLoader, useClass: ResourceLoaderImpl, deps: [] }] }, ɵ1 = ɵPLATFORM_BROWSER_ID;
|
374 |
|
375 |
|
376 |
|
377 | var INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS = [
|
378 | ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS,
|
379 | {
|
380 | provide: COMPILER_OPTIONS,
|
381 | useValue: ɵ0$1,
|
382 | multi: true
|
383 | },
|
384 | { provide: PLATFORM_ID, useValue: ɵ1 },
|
385 | ];
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 | var CachedResourceLoader = (function (_super) {
|
404 | __extends(CachedResourceLoader, _super);
|
405 | function CachedResourceLoader() {
|
406 | var _this = _super.call(this) || this;
|
407 | _this._cache = ɵglobal.$templateCache;
|
408 | if (_this._cache == null) {
|
409 | throw new Error('CachedResourceLoader: Template cache was not found in $templateCache.');
|
410 | }
|
411 | return _this;
|
412 | }
|
413 | CachedResourceLoader.prototype.get = function (url) {
|
414 | if (this._cache.hasOwnProperty(url)) {
|
415 | return Promise.resolve(this._cache[url]);
|
416 | }
|
417 | else {
|
418 | return Promise.reject('CachedResourceLoader: Did not find cached template for ' + url);
|
419 | }
|
420 | };
|
421 | return CachedResourceLoader;
|
422 | }(ResourceLoader));
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 | var VERSION = new Version('8.2.9');
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 | var RESOURCE_CACHE_PROVIDER = [{ provide: ResourceLoader, useClass: CachedResourceLoader, deps: [] }];
|
455 |
|
456 |
|
457 |
|
458 | var platformBrowserDynamic = createPlatformFactory(platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 | export { CachedResourceLoader as ɵangular_packages_platform_browser_dynamic_platform_browser_dynamic_a, RESOURCE_CACHE_PROVIDER, platformBrowserDynamic, VERSION, JitCompilerFactory, CompilerImpl as ɵCompilerImpl, platformCoreDynamic as ɵplatformCoreDynamic, INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, ResourceLoaderImpl as ɵResourceLoaderImpl };
|
482 |
|