UNPKG

34 kBJavaScriptView Raw
1/**
2 * @license Angular v9.0.0
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7(function (global, factory) {
8 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/compiler'), require('@angular/core'), require('@angular/common'), require('@angular/platform-browser')) :
9 typeof define === 'function' && define.amd ? define('@angular/platform-browser-dynamic', ['exports', '@angular/compiler', '@angular/core', '@angular/common', '@angular/platform-browser'], factory) :
10 (global = global || self, factory((global.ng = global.ng || {}, global.ng.platformBrowserDynamic = {}), global.ng.compiler, global.ng.core, global.ng.common, global.ng.platformBrowser));
11}(this, (function (exports, compiler, core, common, platformBrowser) { 'use strict';
12
13 /*! *****************************************************************************
14 Copyright (c) Microsoft Corporation. All rights reserved.
15 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
16 this file except in compliance with the License. You may obtain a copy of the
17 License at http://www.apache.org/licenses/LICENSE-2.0
18
19 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
21 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
22 MERCHANTABLITY OR NON-INFRINGEMENT.
23
24 See the Apache Version 2.0 License for specific language governing permissions
25 and limitations under the License.
26 ***************************************************************************** */
27 /* global Reflect, Promise */
28
29 var extendStatics = function(d, b) {
30 extendStatics = Object.setPrototypeOf ||
31 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33 return extendStatics(d, b);
34 };
35
36 function __extends(d, b) {
37 extendStatics(d, b);
38 function __() { this.constructor = d; }
39 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40 }
41
42 var __assign = function() {
43 __assign = Object.assign || function __assign(t) {
44 for (var s, i = 1, n = arguments.length; i < n; i++) {
45 s = arguments[i];
46 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47 }
48 return t;
49 };
50 return __assign.apply(this, arguments);
51 };
52
53 function __rest(s, e) {
54 var t = {};
55 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56 t[p] = s[p];
57 if (s != null && typeof Object.getOwnPropertySymbols === "function")
58 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60 t[p[i]] = s[p[i]];
61 }
62 return t;
63 }
64
65 function __decorate(decorators, target, key, desc) {
66 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
67 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
68 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71
72 function __param(paramIndex, decorator) {
73 return function (target, key) { decorator(target, key, paramIndex); }
74 }
75
76 function __metadata(metadataKey, metadataValue) {
77 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
78 }
79
80 function __awaiter(thisArg, _arguments, P, generator) {
81 return new (P || (P = Promise))(function (resolve, reject) {
82 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
83 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
84 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
85 step((generator = generator.apply(thisArg, _arguments || [])).next());
86 });
87 }
88
89 function __generator(thisArg, body) {
90 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
91 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
92 function verb(n) { return function (v) { return step([n, v]); }; }
93 function step(op) {
94 if (f) throw new TypeError("Generator is already executing.");
95 while (_) try {
96 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
97 if (y = 0, t) op = [op[0] & 2, t.value];
98 switch (op[0]) {
99 case 0: case 1: t = op; break;
100 case 4: _.label++; return { value: op[1], done: false };
101 case 5: _.label++; y = op[1]; op = [0]; continue;
102 case 7: op = _.ops.pop(); _.trys.pop(); continue;
103 default:
104 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
105 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
106 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
107 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
108 if (t[2]) _.ops.pop();
109 _.trys.pop(); continue;
110 }
111 op = body.call(thisArg, _);
112 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
113 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
114 }
115 }
116
117 function __exportStar(m, exports) {
118 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
119 }
120
121 function __values(o) {
122 var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
123 if (m) return m.call(o);
124 return {
125 next: function () {
126 if (o && i >= o.length) o = void 0;
127 return { value: o && o[i++], done: !o };
128 }
129 };
130 }
131
132 function __read(o, n) {
133 var m = typeof Symbol === "function" && o[Symbol.iterator];
134 if (!m) return o;
135 var i = m.call(o), r, ar = [], e;
136 try {
137 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
138 }
139 catch (error) { e = { error: error }; }
140 finally {
141 try {
142 if (r && !r.done && (m = i["return"])) m.call(i);
143 }
144 finally { if (e) throw e.error; }
145 }
146 return ar;
147 }
148
149 function __spread() {
150 for (var ar = [], i = 0; i < arguments.length; i++)
151 ar = ar.concat(__read(arguments[i]));
152 return ar;
153 }
154
155 function __spreadArrays() {
156 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
157 for (var r = Array(s), k = 0, i = 0; i < il; i++)
158 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
159 r[k] = a[j];
160 return r;
161 };
162
163 function __await(v) {
164 return this instanceof __await ? (this.v = v, this) : new __await(v);
165 }
166
167 function __asyncGenerator(thisArg, _arguments, generator) {
168 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
169 var g = generator.apply(thisArg, _arguments || []), i, q = [];
170 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
171 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
172 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
173 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
174 function fulfill(value) { resume("next", value); }
175 function reject(value) { resume("throw", value); }
176 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
177 }
178
179 function __asyncDelegator(o) {
180 var i, p;
181 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
182 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
183 }
184
185 function __asyncValues(o) {
186 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
187 var m = o[Symbol.asyncIterator], i;
188 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
189 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
190 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
191 }
192
193 function __makeTemplateObject(cooked, raw) {
194 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
195 return cooked;
196 };
197
198 function __importStar(mod) {
199 if (mod && mod.__esModule) return mod;
200 var result = {};
201 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
202 result.default = mod;
203 return result;
204 }
205
206 function __importDefault(mod) {
207 return (mod && mod.__esModule) ? mod : { default: mod };
208 }
209
210 /**
211 * @license
212 * Copyright Google Inc. All Rights Reserved.
213 *
214 * Use of this source code is governed by an MIT-style license that can be
215 * found in the LICENSE file at https://angular.io/license
216 */
217 var MODULE_SUFFIX = '';
218 var builtinExternalReferences = createBuiltinExternalReferencesMap();
219 var JitReflector = /** @class */ (function () {
220 function JitReflector() {
221 this.reflectionCapabilities = new core.ɵReflectionCapabilities();
222 }
223 JitReflector.prototype.componentModuleUrl = function (type, cmpMetadata) {
224 var moduleId = cmpMetadata.moduleId;
225 if (typeof moduleId === 'string') {
226 var scheme = compiler.getUrlScheme(moduleId);
227 return scheme ? moduleId : "package:" + moduleId + MODULE_SUFFIX;
228 }
229 else if (moduleId !== null && moduleId !== void 0) {
230 throw compiler.syntaxError("moduleId should be a string in \"" + core.ɵstringify(type) + "\". See https://goo.gl/wIDDiL for more information.\n" +
231 "If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.");
232 }
233 return "./" + core.ɵstringify(type);
234 };
235 JitReflector.prototype.parameters = function (typeOrFunc) {
236 return this.reflectionCapabilities.parameters(typeOrFunc);
237 };
238 JitReflector.prototype.tryAnnotations = function (typeOrFunc) { return this.annotations(typeOrFunc); };
239 JitReflector.prototype.annotations = function (typeOrFunc) {
240 return this.reflectionCapabilities.annotations(typeOrFunc);
241 };
242 JitReflector.prototype.shallowAnnotations = function (typeOrFunc) {
243 throw new Error('Not supported in JIT mode');
244 };
245 JitReflector.prototype.propMetadata = function (typeOrFunc) {
246 return this.reflectionCapabilities.propMetadata(typeOrFunc);
247 };
248 JitReflector.prototype.hasLifecycleHook = function (type, lcProperty) {
249 return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
250 };
251 JitReflector.prototype.guards = function (type) { return this.reflectionCapabilities.guards(type); };
252 JitReflector.prototype.resolveExternalReference = function (ref) {
253 return builtinExternalReferences.get(ref) || ref.runtime;
254 };
255 return JitReflector;
256 }());
257 function createBuiltinExternalReferencesMap() {
258 var map = new Map();
259 map.set(compiler.Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS, core.ANALYZE_FOR_ENTRY_COMPONENTS);
260 map.set(compiler.Identifiers.ElementRef, core.ElementRef);
261 map.set(compiler.Identifiers.NgModuleRef, core.NgModuleRef);
262 map.set(compiler.Identifiers.ViewContainerRef, core.ViewContainerRef);
263 map.set(compiler.Identifiers.ChangeDetectorRef, core.ChangeDetectorRef);
264 map.set(compiler.Identifiers.Renderer2, core.Renderer2);
265 map.set(compiler.Identifiers.QueryList, core.QueryList);
266 map.set(compiler.Identifiers.TemplateRef, core.TemplateRef);
267 map.set(compiler.Identifiers.CodegenComponentFactoryResolver, core.ɵCodegenComponentFactoryResolver);
268 map.set(compiler.Identifiers.ComponentFactoryResolver, core.ComponentFactoryResolver);
269 map.set(compiler.Identifiers.ComponentFactory, core.ComponentFactory);
270 map.set(compiler.Identifiers.ComponentRef, core.ComponentRef);
271 map.set(compiler.Identifiers.NgModuleFactory, core.NgModuleFactory);
272 map.set(compiler.Identifiers.createModuleFactory, core.ɵcmf);
273 map.set(compiler.Identifiers.moduleDef, core.ɵmod);
274 map.set(compiler.Identifiers.moduleProviderDef, core.ɵmpd);
275 map.set(compiler.Identifiers.RegisterModuleFactoryFn, core.ɵregisterModuleFactory);
276 map.set(compiler.Identifiers.Injector, core.Injector);
277 map.set(compiler.Identifiers.ViewEncapsulation, core.ViewEncapsulation);
278 map.set(compiler.Identifiers.ChangeDetectionStrategy, core.ChangeDetectionStrategy);
279 map.set(compiler.Identifiers.SecurityContext, core.SecurityContext);
280 map.set(compiler.Identifiers.LOCALE_ID, core.LOCALE_ID);
281 map.set(compiler.Identifiers.TRANSLATIONS_FORMAT, core.TRANSLATIONS_FORMAT);
282 map.set(compiler.Identifiers.inlineInterpolate, core.ɵinlineInterpolate);
283 map.set(compiler.Identifiers.interpolate, core.ɵinterpolate);
284 map.set(compiler.Identifiers.EMPTY_ARRAY, core.ɵEMPTY_ARRAY);
285 map.set(compiler.Identifiers.EMPTY_MAP, core.ɵEMPTY_MAP);
286 map.set(compiler.Identifiers.viewDef, core.ɵvid);
287 map.set(compiler.Identifiers.elementDef, core.ɵeld);
288 map.set(compiler.Identifiers.anchorDef, core.ɵand);
289 map.set(compiler.Identifiers.textDef, core.ɵted);
290 map.set(compiler.Identifiers.directiveDef, core.ɵdid);
291 map.set(compiler.Identifiers.providerDef, core.ɵprd);
292 map.set(compiler.Identifiers.queryDef, core.ɵqud);
293 map.set(compiler.Identifiers.pureArrayDef, core.ɵpad);
294 map.set(compiler.Identifiers.pureObjectDef, core.ɵpod);
295 map.set(compiler.Identifiers.purePipeDef, core.ɵppd);
296 map.set(compiler.Identifiers.pipeDef, core.ɵpid);
297 map.set(compiler.Identifiers.nodeValue, core.ɵnov);
298 map.set(compiler.Identifiers.ngContentDef, core.ɵncd);
299 map.set(compiler.Identifiers.unwrapValue, core.ɵunv);
300 map.set(compiler.Identifiers.createRendererType2, core.ɵcrt);
301 map.set(compiler.Identifiers.createComponentFactory, core.ɵccf);
302 return map;
303 }
304
305 /**
306 * @license
307 * Copyright Google Inc. All Rights Reserved.
308 *
309 * Use of this source code is governed by an MIT-style license that can be
310 * found in the LICENSE file at https://angular.io/license
311 */
312 var ERROR_COLLECTOR_TOKEN = new core.InjectionToken('ErrorCollector');
313 /**
314 * A default provider for {@link PACKAGE_ROOT_URL} that maps to '/'.
315 */
316 var DEFAULT_PACKAGE_URL_PROVIDER = {
317 provide: core.PACKAGE_ROOT_URL,
318 useValue: '/'
319 };
320 var _NO_RESOURCE_LOADER = {
321 get: function (url) {
322 throw new Error("No ResourceLoader implementation has been provided. Can't read the url \"" + url + "\"");
323 }
324 };
325 var baseHtmlParser = new core.InjectionToken('HtmlParser');
326 var CompilerImpl = /** @class */ (function () {
327 function CompilerImpl(injector, _metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console) {
328 this._metadataResolver = _metadataResolver;
329 this._delegate = new compiler.JitCompiler(_metadataResolver, templateParser, styleCompiler, viewCompiler, ngModuleCompiler, summaryResolver, compileReflector, jitEvaluator, compilerConfig, console, this.getExtraNgModuleProviders.bind(this));
330 this.injector = injector;
331 }
332 CompilerImpl.prototype.getExtraNgModuleProviders = function () {
333 return [this._metadataResolver.getProviderMetadata(new compiler.ProviderMeta(core.Compiler, { useValue: this }))];
334 };
335 CompilerImpl.prototype.compileModuleSync = function (moduleType) {
336 return this._delegate.compileModuleSync(moduleType);
337 };
338 CompilerImpl.prototype.compileModuleAsync = function (moduleType) {
339 return this._delegate.compileModuleAsync(moduleType);
340 };
341 CompilerImpl.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
342 var result = this._delegate.compileModuleAndAllComponentsSync(moduleType);
343 return {
344 ngModuleFactory: result.ngModuleFactory,
345 componentFactories: result.componentFactories,
346 };
347 };
348 CompilerImpl.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
349 return this._delegate.compileModuleAndAllComponentsAsync(moduleType)
350 .then(function (result) { return ({
351 ngModuleFactory: result.ngModuleFactory,
352 componentFactories: result.componentFactories,
353 }); });
354 };
355 CompilerImpl.prototype.loadAotSummaries = function (summaries) { this._delegate.loadAotSummaries(summaries); };
356 CompilerImpl.prototype.hasAotSummary = function (ref) { return this._delegate.hasAotSummary(ref); };
357 CompilerImpl.prototype.getComponentFactory = function (component) {
358 return this._delegate.getComponentFactory(component);
359 };
360 CompilerImpl.prototype.clearCache = function () { this._delegate.clearCache(); };
361 CompilerImpl.prototype.clearCacheFor = function (type) { this._delegate.clearCacheFor(type); };
362 CompilerImpl.prototype.getModuleId = function (moduleType) {
363 var meta = this._metadataResolver.getNgModuleMetadata(moduleType);
364 return meta && meta.id || undefined;
365 };
366 return CompilerImpl;
367 }());
368 var ɵ0 = new JitReflector(), ɵ1 = _NO_RESOURCE_LOADER, ɵ2 = function (parser, translations, format, config, console) {
369 translations = translations || '';
370 var missingTranslation = translations ? config.missingTranslation : core.MissingTranslationStrategy.Ignore;
371 return new compiler.I18NHtmlParser(parser, translations, format, missingTranslation, console);
372 }, ɵ3 = new compiler.CompilerConfig();
373 /**
374 * A set of providers that provide `JitCompiler` and its dependencies to use for
375 * template compilation.
376 */
377 var COMPILER_PROVIDERS__PRE_R3__ = [
378 { provide: compiler.CompileReflector, useValue: ɵ0 },
379 { provide: compiler.ResourceLoader, useValue: ɵ1 },
380 { provide: compiler.JitSummaryResolver, deps: [] },
381 { provide: compiler.SummaryResolver, useExisting: compiler.JitSummaryResolver },
382 { provide: core.ɵConsole, deps: [] },
383 { provide: compiler.Lexer, deps: [] },
384 { provide: compiler.Parser, deps: [compiler.Lexer] },
385 {
386 provide: baseHtmlParser,
387 useClass: compiler.HtmlParser,
388 deps: [],
389 },
390 {
391 provide: compiler.I18NHtmlParser,
392 useFactory: ɵ2,
393 deps: [
394 baseHtmlParser,
395 [new core.Optional(), new core.Inject(core.TRANSLATIONS)],
396 [new core.Optional(), new core.Inject(core.TRANSLATIONS_FORMAT)],
397 [compiler.CompilerConfig],
398 [core.ɵConsole],
399 ]
400 },
401 {
402 provide: compiler.HtmlParser,
403 useExisting: compiler.I18NHtmlParser,
404 },
405 {
406 provide: compiler.TemplateParser, deps: [compiler.CompilerConfig, compiler.CompileReflector,
407 compiler.Parser, compiler.ElementSchemaRegistry,
408 compiler.I18NHtmlParser, core.ɵConsole]
409 },
410 { provide: compiler.JitEvaluator, useClass: compiler.JitEvaluator, deps: [] },
411 { provide: compiler.DirectiveNormalizer, deps: [compiler.ResourceLoader, compiler.UrlResolver, compiler.HtmlParser, compiler.CompilerConfig] },
412 { provide: compiler.CompileMetadataResolver, deps: [compiler.CompilerConfig, compiler.HtmlParser, compiler.NgModuleResolver,
413 compiler.DirectiveResolver, compiler.PipeResolver,
414 compiler.SummaryResolver,
415 compiler.ElementSchemaRegistry,
416 compiler.DirectiveNormalizer, core.ɵConsole,
417 [core.Optional, compiler.StaticSymbolCache],
418 compiler.CompileReflector,
419 [core.Optional, ERROR_COLLECTOR_TOKEN]] },
420 DEFAULT_PACKAGE_URL_PROVIDER,
421 { provide: compiler.StyleCompiler, deps: [compiler.UrlResolver] },
422 { provide: compiler.ViewCompiler, deps: [compiler.CompileReflector] },
423 { provide: compiler.NgModuleCompiler, deps: [compiler.CompileReflector] },
424 { provide: compiler.CompilerConfig, useValue: ɵ3 },
425 { provide: core.Compiler, useClass: CompilerImpl, deps: [core.Injector, compiler.CompileMetadataResolver,
426 compiler.TemplateParser, compiler.StyleCompiler,
427 compiler.ViewCompiler, compiler.NgModuleCompiler,
428 compiler.SummaryResolver, compiler.CompileReflector, compiler.JitEvaluator, compiler.CompilerConfig,
429 core.ɵConsole] },
430 { provide: compiler.DomElementSchemaRegistry, deps: [] },
431 { provide: compiler.ElementSchemaRegistry, useExisting: compiler.DomElementSchemaRegistry },
432 { provide: compiler.UrlResolver, deps: [core.PACKAGE_ROOT_URL] },
433 { provide: compiler.DirectiveResolver, deps: [compiler.CompileReflector] },
434 { provide: compiler.PipeResolver, deps: [compiler.CompileReflector] },
435 { provide: compiler.NgModuleResolver, deps: [compiler.CompileReflector] },
436 ];
437 var COMPILER_PROVIDERS__POST_R3__ = [{ provide: core.Compiler, useFactory: function () { return new core.Compiler(); } }];
438 var COMPILER_PROVIDERS = COMPILER_PROVIDERS__PRE_R3__;
439 /**
440 * @publicApi
441 */
442 var JitCompilerFactory = /** @class */ (function () {
443 /* @internal */
444 function JitCompilerFactory(defaultOptions) {
445 var compilerOptions = {
446 useJit: true,
447 defaultEncapsulation: core.ViewEncapsulation.Emulated,
448 missingTranslation: core.MissingTranslationStrategy.Warning,
449 };
450 this._defaultOptions = __spread([compilerOptions], defaultOptions);
451 }
452 JitCompilerFactory.prototype.createCompiler = function (options) {
453 if (options === void 0) { options = []; }
454 var opts = _mergeOptions(this._defaultOptions.concat(options));
455 var injector = core.Injector.create([
456 COMPILER_PROVIDERS, {
457 provide: compiler.CompilerConfig,
458 useFactory: function () {
459 return new compiler.CompilerConfig({
460 // let explicit values from the compiler options overwrite options
461 // from the app providers
462 useJit: opts.useJit,
463 jitDevMode: core.isDevMode(),
464 // let explicit values from the compiler options overwrite options
465 // from the app providers
466 defaultEncapsulation: opts.defaultEncapsulation,
467 missingTranslation: opts.missingTranslation,
468 preserveWhitespaces: opts.preserveWhitespaces,
469 });
470 },
471 deps: []
472 },
473 opts.providers
474 ]);
475 return injector.get(core.Compiler);
476 };
477 return JitCompilerFactory;
478 }());
479 function _mergeOptions(optionsArr) {
480 return {
481 useJit: _lastDefined(optionsArr.map(function (options) { return options.useJit; })),
482 defaultEncapsulation: _lastDefined(optionsArr.map(function (options) { return options.defaultEncapsulation; })),
483 providers: _mergeArrays(optionsArr.map(function (options) { return options.providers; })),
484 missingTranslation: _lastDefined(optionsArr.map(function (options) { return options.missingTranslation; })),
485 preserveWhitespaces: _lastDefined(optionsArr.map(function (options) { return options.preserveWhitespaces; })),
486 };
487 }
488 function _lastDefined(args) {
489 for (var i = args.length - 1; i >= 0; i--) {
490 if (args[i] !== undefined) {
491 return args[i];
492 }
493 }
494 return undefined;
495 }
496 function _mergeArrays(parts) {
497 var result = [];
498 parts.forEach(function (part) { return part && result.push.apply(result, __spread(part)); });
499 return result;
500 }
501
502 /**
503 * @license
504 * Copyright Google Inc. All Rights Reserved.
505 *
506 * Use of this source code is governed by an MIT-style license that can be
507 * found in the LICENSE file at https://angular.io/license
508 */
509 var ɵ0$1 = {};
510 /**
511 * A platform that included corePlatform and the compiler.
512 *
513 * @publicApi
514 */
515 var platformCoreDynamic = core.createPlatformFactory(core.platformCore, 'coreDynamic', [
516 { provide: core.COMPILER_OPTIONS, useValue: ɵ0$1, multi: true },
517 { provide: core.CompilerFactory, useClass: JitCompilerFactory, deps: [core.COMPILER_OPTIONS] },
518 ]);
519
520 var ResourceLoaderImpl = /** @class */ (function (_super) {
521 __extends(ResourceLoaderImpl, _super);
522 function ResourceLoaderImpl() {
523 return _super !== null && _super.apply(this, arguments) || this;
524 }
525 ResourceLoaderImpl.prototype.get = function (url) {
526 var resolve;
527 var reject;
528 var promise = new Promise(function (res, rej) {
529 resolve = res;
530 reject = rej;
531 });
532 var xhr = new XMLHttpRequest();
533 xhr.open('GET', url, true);
534 xhr.responseType = 'text';
535 xhr.onload = function () {
536 // responseText is the old-school way of retrieving response (supported by IE8 & 9)
537 // response/responseType properties were introduced in ResourceLoader Level2 spec (supported
538 // by IE10)
539 var response = xhr.response || xhr.responseText;
540 // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
541 var status = xhr.status === 1223 ? 204 : xhr.status;
542 // fix status code when it is 0 (0 status is undocumented).
543 // Occurs when accessing file resources or on Android 4.1 stock browser
544 // while retrieving files from application cache.
545 if (status === 0) {
546 status = response ? 200 : 0;
547 }
548 if (200 <= status && status <= 300) {
549 resolve(response);
550 }
551 else {
552 reject("Failed to load " + url);
553 }
554 };
555 xhr.onerror = function () { reject("Failed to load " + url); };
556 xhr.send();
557 return promise;
558 };
559 ResourceLoaderImpl = __decorate([
560 core.Injectable()
561 ], ResourceLoaderImpl);
562 return ResourceLoaderImpl;
563 }(compiler.ResourceLoader));
564
565 /**
566 * @license
567 * Copyright Google Inc. All Rights Reserved.
568 *
569 * Use of this source code is governed by an MIT-style license that can be
570 * found in the LICENSE file at https://angular.io/license
571 */
572 var ɵ0$2 = { providers: [{ provide: compiler.ResourceLoader, useClass: ResourceLoaderImpl, deps: [] }] }, ɵ1$1 = common.ɵPLATFORM_BROWSER_ID;
573 /**
574 * @publicApi
575 */
576 var INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS = [
577 platformBrowser.ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS,
578 {
579 provide: core.COMPILER_OPTIONS,
580 useValue: ɵ0$2,
581 multi: true
582 },
583 { provide: core.PLATFORM_ID, useValue: ɵ1$1 },
584 ];
585
586 /**
587 * @license
588 * Copyright Google Inc. All Rights Reserved.
589 *
590 * Use of this source code is governed by an MIT-style license that can be
591 * found in the LICENSE file at https://angular.io/license
592 */
593 /**
594 * An implementation of ResourceLoader that uses a template cache to avoid doing an actual
595 * ResourceLoader.
596 *
597 * The template cache needs to be built and loaded into window.$templateCache
598 * via a separate mechanism.
599 *
600 * @publicApi
601 */
602 var CachedResourceLoader = /** @class */ (function (_super) {
603 __extends(CachedResourceLoader, _super);
604 function CachedResourceLoader() {
605 var _this = _super.call(this) || this;
606 _this._cache = core.ɵglobal.$templateCache;
607 if (_this._cache == null) {
608 throw new Error('CachedResourceLoader: Template cache was not found in $templateCache.');
609 }
610 return _this;
611 }
612 CachedResourceLoader.prototype.get = function (url) {
613 if (this._cache.hasOwnProperty(url)) {
614 return Promise.resolve(this._cache[url]);
615 }
616 else {
617 return Promise.reject('CachedResourceLoader: Did not find cached template for ' + url);
618 }
619 };
620 return CachedResourceLoader;
621 }(compiler.ResourceLoader));
622
623 /**
624 * @license
625 * Copyright Google Inc. All Rights Reserved.
626 *
627 * Use of this source code is governed by an MIT-style license that can be
628 * found in the LICENSE file at https://angular.io/license
629 */
630
631 /**
632 * @license
633 * Copyright Google Inc. All Rights Reserved.
634 *
635 * Use of this source code is governed by an MIT-style license that can be
636 * found in the LICENSE file at https://angular.io/license
637 */
638 /**
639 * @publicApi
640 */
641 var VERSION = new core.Version('9.0.0');
642
643 /**
644 * @license
645 * Copyright Google Inc. All Rights Reserved.
646 *
647 * Use of this source code is governed by an MIT-style license that can be
648 * found in the LICENSE file at https://angular.io/license
649 */
650 /**
651 * @publicApi
652 */
653 var RESOURCE_CACHE_PROVIDER = [{ provide: compiler.ResourceLoader, useClass: CachedResourceLoader, deps: [] }];
654 /**
655 * @publicApi
656 */
657 var platformBrowserDynamic = core.createPlatformFactory(platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
658
659 /**
660 * @license
661 * Copyright Google Inc. All Rights Reserved.
662 *
663 * Use of this source code is governed by an MIT-style license that can be
664 * found in the LICENSE file at https://angular.io/license
665 */
666 // This file only reexports content of the `src` folder. Keep it that way.
667
668 /**
669 * @license
670 * Copyright Google Inc. All Rights Reserved.
671 *
672 * Use of this source code is governed by an MIT-style license that can be
673 * found in the LICENSE file at https://angular.io/license
674 */
675
676 /**
677 * Generated bundle index. Do not edit.
678 */
679
680 exports.JitCompilerFactory = JitCompilerFactory;
681 exports.RESOURCE_CACHE_PROVIDER = RESOURCE_CACHE_PROVIDER;
682 exports.VERSION = VERSION;
683 exports.platformBrowserDynamic = platformBrowserDynamic;
684 exports.ɵCOMPILER_PROVIDERS__POST_R3__ = COMPILER_PROVIDERS__POST_R3__;
685 exports.ɵCompilerImpl = CompilerImpl;
686 exports.ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS = INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS;
687 exports.ɵResourceLoaderImpl = ResourceLoaderImpl;
688 exports.ɵangular_packages_platform_browser_dynamic_platform_browser_dynamic_a = CachedResourceLoader;
689 exports.ɵplatformCoreDynamic = platformCoreDynamic;
690
691 Object.defineProperty(exports, '__esModule', { value: true });
692
693})));
694//# sourceMappingURL=platform-browser-dynamic.umd.js.map