1 line
26 KiB
Text
1 line
26 KiB
Text
|
{"version":3,"file":"ssr.mjs","sources":["../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/src/inline-css-processor.mjs","../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/src/peformance-profiler.mjs","../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/src/common-engine.mjs"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport Critters from 'critters';\nimport { readFile } from 'node:fs/promises';\n/**\n * Pattern used to extract the media query set by Critters in an `onload` handler.\n */\nconst MEDIA_SET_HANDLER_PATTERN = /^this\\.media=[\"'](.*)[\"'];?$/;\n/**\n * Name of the attribute used to save the Critters media query so it can be re-assigned on load.\n */\nconst CSP_MEDIA_ATTR = 'ngCspMedia';\n/**\n * Script text used to change the media value of the link tags.\n *\n * NOTE:\n * We do not use `document.querySelectorAll('link').forEach((s) => s.addEventListener('load', ...)`\n * because this does not always fire on Chome.\n * See: https://github.com/angular/angular-cli/issues/26932 and https://crbug.com/1521256\n */\nconst LINK_LOAD_SCRIPT_CONTENT = [\n '(() => {',\n ` const CSP_MEDIA_ATTR = '${CSP_MEDIA_ATTR}';`,\n ' const documentElement = document.documentElement;',\n ' const listener = (e) => {',\n ' const target = e.target;',\n ` if (!target || target.tagName !== 'LINK' || !target.hasAttribute(CSP_MEDIA_ATTR)) {`,\n ' return;',\n ' }',\n ' target.media = target.getAttribute(CSP_MEDIA_ATTR);',\n ' target.removeAttribute(CSP_MEDIA_ATTR);',\n // Remove onload listener when there are no longer styles that need to be loaded.\n ' if (!document.head.querySelector(`link[${CSP_MEDIA_ATTR}]`)) {',\n ` documentElement.removeEventListener('load', listener);`,\n ' }',\n ' };',\n // We use an event with capturing (the true parameter) because load events don't bubble.\n ` documentElement.addEventListener('load', listener, true);`,\n '})();',\n].join('\\n');\nclass CrittersExtended extends Critters {\n optionsExtended;\n resourceCache;\n warnings = [];\n errors = [];\n initialEmbedLinkedStylesheet;\n addedCspScriptsDocuments = new WeakSet();\n documentNonces = new WeakMap();\n constructor(optionsExtended, resourceCache) {\n super({\n logger: {\n warn: (s) => this.warnings.push(s),\n error: (s) => this.errors.push(s),\n info: () => { },\n },\n logLevel: 'warn',\n path: optionsExtended.outputPath,\n publicPath: optionsExtended.deployUrl,\n compress: !!optionsExtended.minify,\n pruneSource: false,\n reduceInlineStyles: false,\n mergeStylesheets: false,\n // Note: if `preload` changes to anything other than `media`, the logic in\n // `embedLinkedStylesheetOverride` will have to be updated.\n preload: 'media',\n noscriptFallback: true,\n inlineFonts: true,\n });\n this.optionsExtended = optionsExtended;\n this.resourceCache = resourceCache;\n // We can't use inheritance to override `embedLinkedStylesheet`, because it's not declared in\n // the `Critters` .d.ts which means that we can't call the `super` implementation. TS doesn't\n // allow for `super` to be cast to a different type.\n this.initialEmbedLinkedStylesheet = this.embedLinkedStylesheet;\n this.embedLinkedStylesheet = this.embedLinkedStylesheetOverride;\n }\n async readFile(path) {\n let resourceContent = this.resourceCache.get(path);\n if (resourceContent === undefined) {\n resourceContent = await readFile(path, 'utf-8');\n this.resourceCache.set(path, resourceContent);\n }\n return reso
|