UNPKG

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