1 line
21 KiB
JSON
1 line
21 KiB
JSON
|
{"ast":null,"code":"/**\n * @license Angular v16.2.12\n * (c) 2010-2022 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport { CompilerConfig, ResourceLoader } from '@angular/compiler';\nimport * as i0 from '@angular/core';\nimport { Compiler, ViewEncapsulation, MissingTranslationStrategy, Injector, createPlatformFactory, platformCore, COMPILER_OPTIONS, CompilerFactory, Injectable, PLATFORM_ID, ɵglobal, Version } from '@angular/core';\nimport { ɵPLATFORM_BROWSER_ID } from '@angular/common';\nimport { ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS } from '@angular/platform-browser';\nconst COMPILER_PROVIDERS = [{\n provide: Compiler,\n useFactory: () => new Compiler()\n}];\n/**\n * @publicApi\n *\n * @deprecated\n * Ivy JIT mode doesn't require accessing this symbol.\n * See [JIT API changes due to ViewEngine deprecation](guide/deprecations#jit-api-changes) for\n * additional context.\n */\nclass JitCompilerFactory {\n /** @internal */\n constructor(defaultOptions) {\n const compilerOptions = {\n useJit: true,\n defaultEncapsulation: ViewEncapsulation.Emulated,\n missingTranslation: MissingTranslationStrategy.Warning\n };\n this._defaultOptions = [compilerOptions, ...defaultOptions];\n }\n createCompiler(options = []) {\n const opts = _mergeOptions(this._defaultOptions.concat(options));\n const injector = Injector.create({\n providers: [COMPILER_PROVIDERS, {\n provide: CompilerConfig,\n useFactory: () => {\n return new CompilerConfig({\n // let explicit values from the compiler options overwrite options\n // from the app providers\n useJit: opts.useJit,\n // let explicit values from the compiler options overwrite options\n // from the app providers\n defaultEncapsulation: opts.defaultEncapsulation,\n missingTranslation: opts.missingTranslation,\n preserveWhitespaces: opts.preserveWhitespaces\n });\n },\n deps: []\n }, opts.providers]\n });\n return injector.get(Compiler);\n }\n}\nfunction _mergeOptions(optionsArr) {\n return {\n useJit: _lastDefined(optionsArr.map(options => options.useJit)),\n defaultEncapsulation: _lastDefined(optionsArr.map(options => options.defaultEncapsulation)),\n providers: _mergeArrays(optionsArr.map(options => options.providers)),\n missingTranslation: _lastDefined(optionsArr.map(options => options.missingTranslation)),\n preserveWhitespaces: _lastDefined(optionsArr.map(options => options.preserveWhitespaces))\n };\n}\nfunction _lastDefined(args) {\n for (let i = args.length - 1; i >= 0; i--) {\n if (args[i] !== undefined) {\n return args[i];\n }\n }\n return undefined;\n}\nfunction _mergeArrays(parts) {\n const result = [];\n parts.forEach(part => part && result.push(...part));\n return result;\n}\n\n/**\n * A platform that included corePlatform and the compiler.\n *\n * @publicApi\n */\nconst platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [{\n provide: COMPILER_OPTIONS,\n useValue: {},\n multi: true\n}, {\n provide: CompilerFactory,\n useClass: JitCompilerFactory,\n deps: [COMPILER_OPTIONS]\n}]);\nclass ResourceLoaderImpl extends ResourceLoader {\n get(url) {\n let resolve;\n let reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n const xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'text';\n xhr.onload = function () {\n const response = xhr.response;\n let status = xhr.status;\n // fix status code when it is 0 (0 status is undocumented).\n // Occurs when accessing file resources or on Android 4.1 stock browser\n // while retrieving files from application cache.\n if (status === 0) {\n status = response ? 200 : 0;\n }\n if (200 <= status && status <= 300) {\n resolve(response);\n } else {\n reject(`Failed to load ${url}`);\n }\n };\n xhr.onerror = function
|