@angular/build 18.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/builders.json +14 -0
- package/package.json +87 -0
- package/src/builders/application/build-action.d.ts +33 -0
- package/src/builders/application/build-action.js +183 -0
- package/src/builders/application/execute-build.d.ts +11 -0
- package/src/builders/application/execute-build.js +125 -0
- package/src/builders/application/execute-post-bundle.d.ts +25 -0
- package/src/builders/application/execute-post-bundle.js +93 -0
- package/src/builders/application/i18n.d.ts +29 -0
- package/src/builders/application/i18n.js +128 -0
- package/src/builders/application/index.d.ts +57 -0
- package/src/builders/application/index.js +121 -0
- package/src/builders/application/options.d.ts +149 -0
- package/src/builders/application/options.js +369 -0
- package/src/builders/application/schema.d.ts +512 -0
- package/src/builders/application/schema.js +58 -0
- package/src/builders/application/schema.json +635 -0
- package/src/builders/application/setup-bundling.d.ts +19 -0
- package/src/builders/application/setup-bundling.js +71 -0
- package/src/builders/dev-server/builder.d.ts +32 -0
- package/src/builders/dev-server/builder.js +70 -0
- package/src/builders/dev-server/index.d.ts +14 -0
- package/src/builders/dev-server/index.js +15 -0
- package/src/builders/dev-server/internal.d.ts +19 -0
- package/src/builders/dev-server/internal.js +29 -0
- package/src/builders/dev-server/options.d.ts +47 -0
- package/src/builders/dev-server/options.js +65 -0
- package/src/builders/dev-server/output.d.ts +16 -0
- package/src/builders/dev-server/output.js +9 -0
- package/src/builders/dev-server/schema.d.ts +118 -0
- package/src/builders/dev-server/schema.js +4 -0
- package/src/builders/dev-server/schema.json +131 -0
- package/src/builders/dev-server/vite-server.d.ts +31 -0
- package/src/builders/dev-server/vite-server.js +504 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +16 -0
- package/src/private.d.ts +35 -0
- package/src/private.js +70 -0
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +26 -0
- package/src/tools/babel/plugins/adjust-static-class-members.js +351 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +22 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.js +113 -0
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +22 -0
- package/src/tools/babel/plugins/elide-angular-metadata.js +110 -0
- package/src/tools/babel/plugins/index.d.ts +11 -0
- package/src/tools/babel/plugins/index.js +21 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +15 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.js +90 -0
- package/src/tools/babel/typings.d.ts +21 -0
- package/src/tools/esbuild/angular/angular-host.d.ts +26 -0
- package/src/tools/esbuild/angular/angular-host.js +134 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +94 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +224 -0
- package/src/tools/esbuild/angular/compilation/factory.d.ts +16 -0
- package/src/tools/esbuild/angular/compilation/factory.js +56 -0
- package/src/tools/esbuild/angular/compilation/index.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/index.js +17 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +182 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +106 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +20 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +26 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +123 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +33 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +90 -0
- package/src/tools/esbuild/angular/compilation-state.d.ts +15 -0
- package/src/tools/esbuild/angular/compilation-state.js +44 -0
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +27 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +441 -0
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +44 -0
- package/src/tools/esbuild/angular/component-stylesheets.js +150 -0
- package/src/tools/esbuild/angular/diagnostics.d.ts +15 -0
- package/src/tools/esbuild/angular/diagnostics.js +69 -0
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +17 -0
- package/src/tools/esbuild/angular/file-reference-tracker.js +57 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +23 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +117 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.js +186 -0
- package/src/tools/esbuild/angular/source-file-cache.d.ts +18 -0
- package/src/tools/esbuild/angular/source-file-cache.js +65 -0
- package/src/tools/esbuild/angular/uri.d.ts +54 -0
- package/src/tools/esbuild/angular/uri.js +74 -0
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/web-worker-transformer.js +94 -0
- package/src/tools/esbuild/application-code-bundle.d.ts +20 -0
- package/src/tools/esbuild/application-code-bundle.js +368 -0
- package/src/tools/esbuild/budget-stats.d.ts +19 -0
- package/src/tools/esbuild/budget-stats.js +59 -0
- package/src/tools/esbuild/bundler-context.d.ts +75 -0
- package/src/tools/esbuild/bundler-context.js +366 -0
- package/src/tools/esbuild/bundler-execution-result.d.ts +71 -0
- package/src/tools/esbuild/bundler-execution-result.js +131 -0
- package/src/tools/esbuild/cache.d.ts +88 -0
- package/src/tools/esbuild/cache.js +92 -0
- package/src/tools/esbuild/commonjs-checker.d.ts +28 -0
- package/src/tools/esbuild/commonjs-checker.js +151 -0
- package/src/tools/esbuild/compiler-plugin-options.d.ts +16 -0
- package/src/tools/esbuild/compiler-plugin-options.js +49 -0
- package/src/tools/esbuild/external-packages-plugin.d.ts +18 -0
- package/src/tools/esbuild/external-packages-plugin.js +70 -0
- package/src/tools/esbuild/global-scripts.d.ts +16 -0
- package/src/tools/esbuild/global-scripts.js +142 -0
- package/src/tools/esbuild/global-styles.d.ts +10 -0
- package/src/tools/esbuild/global-styles.js +74 -0
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +42 -0
- package/src/tools/esbuild/i18n-inliner-worker.js +136 -0
- package/src/tools/esbuild/i18n-inliner.d.ts +44 -0
- package/src/tools/esbuild/i18n-inliner.js +150 -0
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +22 -0
- package/src/tools/esbuild/i18n-locale-plugin.js +120 -0
- package/src/tools/esbuild/index-html-generator.d.ts +15 -0
- package/src/tools/esbuild/index-html-generator.js +81 -0
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +19 -0
- package/src/tools/esbuild/javascript-transformer-worker.js +154 -0
- package/src/tools/esbuild/javascript-transformer.d.ts +54 -0
- package/src/tools/esbuild/javascript-transformer.js +147 -0
- package/src/tools/esbuild/license-extractor.d.ts +25 -0
- package/src/tools/esbuild/license-extractor.js +158 -0
- package/src/tools/esbuild/load-result-cache.d.ts +21 -0
- package/src/tools/esbuild/load-result-cache.js +75 -0
- package/src/tools/esbuild/profiling.d.ts +11 -0
- package/src/tools/esbuild/profiling.js +78 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +18 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +44 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +17 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +73 -0
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +35 -0
- package/src/tools/esbuild/stylesheets/bundle-options.js +64 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
- package/src/tools/esbuild/stylesheets/css-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/css-language.js +15 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +18 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +114 -0
- package/src/tools/esbuild/stylesheets/less-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/less-language.js +155 -0
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +10 -0
- package/src/tools/esbuild/stylesheets/sass-language.js +185 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +58 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +282 -0
- package/src/tools/esbuild/utils.d.ts +49 -0
- package/src/tools/esbuild/utils.js +392 -0
- package/src/tools/esbuild/virtual-module-plugin.d.ts +33 -0
- package/src/tools/esbuild/virtual-module-plugin.js +43 -0
- package/src/tools/esbuild/watcher.d.ts +25 -0
- package/src/tools/esbuild/watcher.js +118 -0
- package/src/tools/sass/lexer.d.ts +18 -0
- package/src/tools/sass/lexer.js +161 -0
- package/src/tools/sass/rebasing-importer.d.ts +101 -0
- package/src/tools/sass/rebasing-importer.js +334 -0
- package/src/tools/sass/sass-service.d.ts +72 -0
- package/src/tools/sass/sass-service.js +213 -0
- package/src/tools/sass/worker.d.ts +8 -0
- package/src/tools/sass/worker.js +192 -0
- package/src/tools/vite/angular-memory-plugin.d.ts +24 -0
- package/src/tools/vite/angular-memory-plugin.js +268 -0
- package/src/tools/vite/i18n-locale-plugin.d.ts +18 -0
- package/src/tools/vite/i18n-locale-plugin.js +55 -0
- package/src/utils/bundle-calculator.d.ts +44 -0
- package/src/utils/bundle-calculator.js +303 -0
- package/src/utils/check-port.d.ts +8 -0
- package/src/utils/check-port.js +58 -0
- package/src/utils/color.d.ts +10 -0
- package/src/utils/color.js +63 -0
- package/src/utils/delete-output-dir.d.ts +11 -0
- package/src/utils/delete-output-dir.js +46 -0
- package/src/utils/environment-options.d.ts +16 -0
- package/src/utils/environment-options.js +79 -0
- package/src/utils/error.d.ts +10 -0
- package/src/utils/error.js +21 -0
- package/src/utils/format-bytes.d.ts +8 -0
- package/src/utils/format-bytes.js +22 -0
- package/src/utils/i18n-options.d.ts +33 -0
- package/src/utils/i18n-options.js +161 -0
- package/src/utils/index-file/add-event-dispatch-contract.d.ts +8 -0
- package/src/utils/index-file/add-event-dispatch-contract.js +28 -0
- package/src/utils/index-file/augment-index-html.d.ts +40 -0
- package/src/utils/index-file/augment-index-html.js +239 -0
- package/src/utils/index-file/html-rewriting-stream.d.ts +11 -0
- package/src/utils/index-file/html-rewriting-stream.js +28 -0
- package/src/utils/index-file/index-html-generator.d.ts +57 -0
- package/src/utils/index-file/index-html-generator.js +135 -0
- package/src/utils/index-file/inline-critical-css.d.ts +24 -0
- package/src/utils/index-file/inline-critical-css.js +179 -0
- package/src/utils/index-file/inline-fonts.d.ts +23 -0
- package/src/utils/index-file/inline-fonts.js +267 -0
- package/src/utils/index-file/nonce.d.ts +12 -0
- package/src/utils/index-file/nonce.js +55 -0
- package/src/utils/index-file/style-nonce.d.ts +12 -0
- package/src/utils/index-file/style-nonce.js +55 -0
- package/src/utils/index.d.ts +11 -0
- package/src/utils/index.js +27 -0
- package/src/utils/load-esm.d.ts +20 -0
- package/src/utils/load-esm.js +31 -0
- package/src/utils/load-proxy-config.d.ts +8 -0
- package/src/utils/load-proxy-config.js +189 -0
- package/src/utils/load-translations.d.ts +16 -0
- package/src/utils/load-translations.js +84 -0
- package/src/utils/normalize-asset-patterns.d.ts +14 -0
- package/src/utils/normalize-asset-patterns.js +96 -0
- package/src/utils/normalize-cache.d.ts +16 -0
- package/src/utils/normalize-cache.js +44 -0
- package/src/utils/normalize-optimization.d.ts +13 -0
- package/src/utils/normalize-optimization.js +42 -0
- package/src/utils/normalize-source-maps.d.ts +9 -0
- package/src/utils/normalize-source-maps.js +23 -0
- package/src/utils/postcss-configuration.d.ts +17 -0
- package/src/utils/postcss-configuration.js +86 -0
- package/src/utils/purge-cache.d.ts +10 -0
- package/src/utils/purge-cache.js +40 -0
- package/src/utils/resolve-assets.d.ts +18 -0
- package/src/utils/resolve-assets.js +35 -0
- package/src/utils/routes-extractor/extractor.d.ts +15 -0
- package/src/utils/routes-extractor/extractor.js +97 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +18 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +129 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +8 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +13 -0
- package/src/utils/server-rendering/fetch-patch.d.ts +8 -0
- package/src/utils/server-rendering/fetch-patch.js +66 -0
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
- package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
- package/src/utils/server-rendering/main-bundle-exports.d.ts +27 -0
- package/src/utils/server-rendering/main-bundle-exports.js +9 -0
- package/src/utils/server-rendering/prerender.d.ts +23 -0
- package/src/utils/server-rendering/prerender.js +192 -0
- package/src/utils/server-rendering/render-page.d.ts +26 -0
- package/src/utils/server-rendering/render-page.js +110 -0
- package/src/utils/server-rendering/render-worker.d.ts +22 -0
- package/src/utils/server-rendering/render-worker.js +30 -0
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +21 -0
- package/src/utils/server-rendering/routes-extractor-worker.js +53 -0
- package/src/utils/service-worker.d.ts +25 -0
- package/src/utils/service-worker.js +211 -0
- package/src/utils/spinner.d.ts +20 -0
- package/src/utils/spinner.js +55 -0
- package/src/utils/stats-table.d.ts +20 -0
- package/src/utils/stats-table.js +205 -0
- package/src/utils/supported-browsers.d.ts +10 -0
- package/src/utils/supported-browsers.js +42 -0
- package/src/utils/tty.d.ts +8 -0
- package/src/utils/tty.js +23 -0
- package/src/utils/url.d.ts +8 -0
- package/src/utils/url.js +18 -0
- package/src/utils/version.d.ts +8 -0
- package/src/utils/version.js +59 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.convertTypeScriptDiagnostic = void 0;
|
|
11
|
+
const node_os_1 = require("node:os");
|
|
12
|
+
/**
|
|
13
|
+
* Converts TypeScript Diagnostic related information into an esbuild compatible note object.
|
|
14
|
+
* Related information is a subset of a full TypeScript Diagnostic and also used for diagnostic
|
|
15
|
+
* notes associated with the main Diagnostic.
|
|
16
|
+
* @param info The TypeScript diagnostic relative information to convert.
|
|
17
|
+
* @returns An esbuild diagnostic message as a PartialMessage object
|
|
18
|
+
*/
|
|
19
|
+
function convertTypeScriptDiagnosticInfo(typescript, info, textPrefix) {
|
|
20
|
+
const newLine = (0, node_os_1.platform)() === 'win32' ? '\r\n' : '\n';
|
|
21
|
+
let text = typescript.flattenDiagnosticMessageText(info.messageText, newLine);
|
|
22
|
+
if (textPrefix) {
|
|
23
|
+
text = textPrefix + text;
|
|
24
|
+
}
|
|
25
|
+
const note = { text };
|
|
26
|
+
if (info.file) {
|
|
27
|
+
note.location = {
|
|
28
|
+
file: info.file.fileName,
|
|
29
|
+
length: info.length,
|
|
30
|
+
};
|
|
31
|
+
// Calculate the line/column location and extract the full line text that has the diagnostic
|
|
32
|
+
if (info.start) {
|
|
33
|
+
const { line, character } = typescript.getLineAndCharacterOfPosition(info.file, info.start);
|
|
34
|
+
note.location.line = line + 1;
|
|
35
|
+
note.location.column = character;
|
|
36
|
+
// The start position for the slice is the first character of the error line
|
|
37
|
+
const lineStartPosition = typescript.getPositionOfLineAndCharacter(info.file, line, 0);
|
|
38
|
+
// The end position for the slice is the first character of the next line or the length of
|
|
39
|
+
// the entire file if the line is the last line of the file (getPositionOfLineAndCharacter
|
|
40
|
+
// will error if a nonexistent line is passed).
|
|
41
|
+
const { line: lastLineOfFile } = typescript.getLineAndCharacterOfPosition(info.file, info.file.text.length - 1);
|
|
42
|
+
const lineEndPosition = line < lastLineOfFile
|
|
43
|
+
? typescript.getPositionOfLineAndCharacter(info.file, line + 1, 0)
|
|
44
|
+
: info.file.text.length;
|
|
45
|
+
note.location.lineText = info.file.text.slice(lineStartPosition, lineEndPosition).trimEnd();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return note;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts a TypeScript Diagnostic message into an esbuild compatible message object.
|
|
52
|
+
* @param diagnostic The TypeScript diagnostic to convert.
|
|
53
|
+
* @returns An esbuild diagnostic message as a PartialMessage object
|
|
54
|
+
*/
|
|
55
|
+
function convertTypeScriptDiagnostic(typescript, diagnostic) {
|
|
56
|
+
let codePrefix = 'TS';
|
|
57
|
+
let code = `${diagnostic.code}`;
|
|
58
|
+
if (diagnostic.source === 'ngtsc') {
|
|
59
|
+
codePrefix = 'NG';
|
|
60
|
+
// Remove `-99` Angular prefix from diagnostic code
|
|
61
|
+
code = code.slice(3);
|
|
62
|
+
}
|
|
63
|
+
const message = convertTypeScriptDiagnosticInfo(typescript, diagnostic, `${codePrefix}${code}: `);
|
|
64
|
+
if (diagnostic.relatedInformation?.length) {
|
|
65
|
+
message.notes = diagnostic.relatedInformation.map((info) => convertTypeScriptDiagnosticInfo(typescript, info));
|
|
66
|
+
}
|
|
67
|
+
return message;
|
|
68
|
+
}
|
|
69
|
+
exports.convertTypeScriptDiagnostic = convertTypeScriptDiagnostic;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
export declare class FileReferenceTracker {
|
|
9
|
+
#private;
|
|
10
|
+
get referencedFiles(): IterableIterator<string>;
|
|
11
|
+
add(containingFile: string, referencedFiles: Iterable<string>): void;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param changed The set of changed files.
|
|
15
|
+
*/
|
|
16
|
+
update(changed: Set<string>): Set<string>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.FileReferenceTracker = void 0;
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
class FileReferenceTracker {
|
|
13
|
+
#referencingFiles = new Map();
|
|
14
|
+
get referencedFiles() {
|
|
15
|
+
return this.#referencingFiles.keys();
|
|
16
|
+
}
|
|
17
|
+
add(containingFile, referencedFiles) {
|
|
18
|
+
const normalizedContainingFile = (0, node_path_1.normalize)(containingFile);
|
|
19
|
+
for (const file of referencedFiles) {
|
|
20
|
+
const normalizedReferencedFile = (0, node_path_1.normalize)(file);
|
|
21
|
+
if (normalizedReferencedFile === normalizedContainingFile) {
|
|
22
|
+
// Containing file is already known to the AOT compiler
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const referencing = this.#referencingFiles.get(normalizedReferencedFile);
|
|
26
|
+
if (referencing === undefined) {
|
|
27
|
+
this.#referencingFiles.set(normalizedReferencedFile, new Set([normalizedContainingFile]));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
referencing.add(normalizedContainingFile);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param changed The set of changed files.
|
|
37
|
+
*/
|
|
38
|
+
update(changed) {
|
|
39
|
+
// Lazily initialized to avoid unneeded copying if there are no additions to return
|
|
40
|
+
let allChangedFiles;
|
|
41
|
+
// Add referencing files to fully notify the AOT compiler of required component updates
|
|
42
|
+
for (const modifiedFile of changed) {
|
|
43
|
+
const normalizedModifiedFile = (0, node_path_1.normalize)(modifiedFile);
|
|
44
|
+
const referencing = this.#referencingFiles.get(normalizedModifiedFile);
|
|
45
|
+
if (referencing) {
|
|
46
|
+
allChangedFiles ??= new Set(changed);
|
|
47
|
+
for (const referencingFile of referencing) {
|
|
48
|
+
allChangedFiles.add(referencingFile);
|
|
49
|
+
}
|
|
50
|
+
// Cleanup the stale record which will be updated by new resource transforms
|
|
51
|
+
this.#referencingFiles.delete(normalizedModifiedFile);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return allChangedFiles ?? changed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.FileReferenceTracker = FileReferenceTracker;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Metafile, OutputFile, PluginBuild } from 'esbuild';
|
|
9
|
+
import { LoadResultCache } from '../load-result-cache';
|
|
10
|
+
import { ComponentStylesheetBundler } from './component-stylesheets';
|
|
11
|
+
/**
|
|
12
|
+
* Sets up esbuild resolve and load callbacks to support Angular JIT mode processing
|
|
13
|
+
* for both Component stylesheets and templates. These callbacks work alongside the JIT
|
|
14
|
+
* resource TypeScript transformer to convert and then bundle Component resources as
|
|
15
|
+
* static imports.
|
|
16
|
+
* @param build An esbuild {@link PluginBuild} instance used to add callbacks.
|
|
17
|
+
* @param styleOptions The options to use when bundling stylesheets.
|
|
18
|
+
* @param additionalResultFiles A Map where stylesheet resources will be added.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setupJitPluginCallbacks(build: PluginBuild, stylesheetBundler: ComponentStylesheetBundler, additionalResultFiles: Map<string, {
|
|
21
|
+
outputFiles?: OutputFile[];
|
|
22
|
+
metafile?: Metafile;
|
|
23
|
+
}>, inlineStyleLanguage: string, loadCache?: LoadResultCache): void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.setupJitPluginCallbacks = void 0;
|
|
11
|
+
const promises_1 = require("node:fs/promises");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
const load_result_cache_1 = require("../load-result-cache");
|
|
14
|
+
const uri_1 = require("./uri");
|
|
15
|
+
/**
|
|
16
|
+
* Loads/extracts the contents from a load callback Angular JIT entry.
|
|
17
|
+
* An Angular JIT entry represents either a file path for a component resource or base64
|
|
18
|
+
* encoded data for an inline component resource.
|
|
19
|
+
* @param entry The value that represents content to load.
|
|
20
|
+
* @param root The absolute path for the root of the build (typically the workspace root).
|
|
21
|
+
* @param skipRead If true, do not attempt to read the file; if false, read file content from disk.
|
|
22
|
+
* This option has no effect if the entry does not originate from a file. Defaults to false.
|
|
23
|
+
* @returns An object containing the absolute path of the contents and optionally the actual contents.
|
|
24
|
+
* For inline entries the contents will always be provided.
|
|
25
|
+
*/
|
|
26
|
+
async function loadEntry(entry, root, skipRead) {
|
|
27
|
+
if (entry.startsWith('file:')) {
|
|
28
|
+
const specifier = (0, node_path_1.join)(root, entry.slice(5));
|
|
29
|
+
return {
|
|
30
|
+
path: specifier,
|
|
31
|
+
contents: skipRead ? undefined : await (0, promises_1.readFile)(specifier, 'utf-8'),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else if (entry.startsWith('inline:')) {
|
|
35
|
+
const [importer, data] = entry.slice(7).split(';', 2);
|
|
36
|
+
return {
|
|
37
|
+
path: (0, node_path_1.join)(root, importer),
|
|
38
|
+
contents: Buffer.from(data, 'base64').toString(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error('Invalid data for Angular JIT entry.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets up esbuild resolve and load callbacks to support Angular JIT mode processing
|
|
47
|
+
* for both Component stylesheets and templates. These callbacks work alongside the JIT
|
|
48
|
+
* resource TypeScript transformer to convert and then bundle Component resources as
|
|
49
|
+
* static imports.
|
|
50
|
+
* @param build An esbuild {@link PluginBuild} instance used to add callbacks.
|
|
51
|
+
* @param styleOptions The options to use when bundling stylesheets.
|
|
52
|
+
* @param additionalResultFiles A Map where stylesheet resources will be added.
|
|
53
|
+
*/
|
|
54
|
+
function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles, inlineStyleLanguage, loadCache) {
|
|
55
|
+
const root = build.initialOptions.absWorkingDir ?? '';
|
|
56
|
+
// Add a resolve callback to capture and parse any JIT URIs that were added by the
|
|
57
|
+
// JIT resource TypeScript transformer.
|
|
58
|
+
// Resources originating from a file are resolved as relative from the containing file (importer).
|
|
59
|
+
build.onResolve({ filter: uri_1.JIT_NAMESPACE_REGEXP }, (args) => {
|
|
60
|
+
const parsed = (0, uri_1.parseJitUri)(args.path);
|
|
61
|
+
if (!parsed) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const { namespace, origin, specifier } = parsed;
|
|
65
|
+
if (origin === 'file') {
|
|
66
|
+
return {
|
|
67
|
+
// Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
|
|
68
|
+
// This is only necessary for custom namespaces. esbuild will handle the file namespace.
|
|
69
|
+
path: 'file:' + (0, node_path_1.relative)(root, (0, node_path_1.join)((0, node_path_1.dirname)(args.importer), specifier)),
|
|
70
|
+
namespace,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Inline data may need the importer to resolve imports/references within the content
|
|
75
|
+
const importer = (0, node_path_1.relative)(root, args.importer);
|
|
76
|
+
return {
|
|
77
|
+
path: `inline:${importer};${specifier}`,
|
|
78
|
+
namespace,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
// Add a load callback to handle Component stylesheets (both inline and external)
|
|
83
|
+
build.onLoad({ filter: /./, namespace: uri_1.JIT_STYLE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
|
|
84
|
+
// skipRead is used here because the stylesheet bundling will read a file stylesheet
|
|
85
|
+
// directly either via a preprocessor or esbuild itself.
|
|
86
|
+
const entry = await loadEntry(args.path, root, true /* skipRead */);
|
|
87
|
+
let stylesheetResult;
|
|
88
|
+
// Stylesheet contents only exist for internal stylesheets
|
|
89
|
+
if (entry.contents === undefined) {
|
|
90
|
+
stylesheetResult = await stylesheetBundler.bundleFile(entry.path);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
stylesheetResult = await stylesheetBundler.bundleInline(entry.contents, entry.path, inlineStyleLanguage);
|
|
94
|
+
}
|
|
95
|
+
const { contents, outputFiles, errors, warnings, metafile, referencedFiles } = stylesheetResult;
|
|
96
|
+
additionalResultFiles.set(entry.path, { outputFiles, metafile });
|
|
97
|
+
return {
|
|
98
|
+
errors,
|
|
99
|
+
warnings,
|
|
100
|
+
contents,
|
|
101
|
+
loader: 'text',
|
|
102
|
+
watchFiles: referencedFiles && [...referencedFiles],
|
|
103
|
+
};
|
|
104
|
+
}));
|
|
105
|
+
// Add a load callback to handle Component templates
|
|
106
|
+
// NOTE: While this callback supports both inline and external templates, the transformer
|
|
107
|
+
// currently only supports generating URIs for external templates.
|
|
108
|
+
build.onLoad({ filter: /./, namespace: uri_1.JIT_TEMPLATE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
|
|
109
|
+
const { contents, path } = await loadEntry(args.path, root);
|
|
110
|
+
return {
|
|
111
|
+
contents,
|
|
112
|
+
loader: 'text',
|
|
113
|
+
watchFiles: [path],
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
exports.setupJitPluginCallbacks = setupJitPluginCallbacks;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import ts from 'typescript';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a TypeScript Transformer to transform Angular Component resource references into
|
|
11
|
+
* static import statements. This transformer is used in Angular's JIT compilation mode to
|
|
12
|
+
* support processing of component resources. When in AOT mode, the Angular AOT compiler handles
|
|
13
|
+
* this processing and this transformer is not used.
|
|
14
|
+
* @param getTypeChecker A function that returns a TypeScript TypeChecker instance for the program.
|
|
15
|
+
* @returns A TypeScript transformer factory.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createJitResourceTransformer(getTypeChecker: () => ts.TypeChecker): ts.TransformerFactory<ts.SourceFile>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createJitResourceTransformer = void 0;
|
|
14
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
15
|
+
const uri_1 = require("./uri");
|
|
16
|
+
/**
|
|
17
|
+
* Creates a TypeScript Transformer to transform Angular Component resource references into
|
|
18
|
+
* static import statements. This transformer is used in Angular's JIT compilation mode to
|
|
19
|
+
* support processing of component resources. When in AOT mode, the Angular AOT compiler handles
|
|
20
|
+
* this processing and this transformer is not used.
|
|
21
|
+
* @param getTypeChecker A function that returns a TypeScript TypeChecker instance for the program.
|
|
22
|
+
* @returns A TypeScript transformer factory.
|
|
23
|
+
*/
|
|
24
|
+
function createJitResourceTransformer(getTypeChecker) {
|
|
25
|
+
return (context) => {
|
|
26
|
+
const typeChecker = getTypeChecker();
|
|
27
|
+
const nodeFactory = context.factory;
|
|
28
|
+
const resourceImportDeclarations = [];
|
|
29
|
+
const visitNode = (node) => {
|
|
30
|
+
if (typescript_1.default.isClassDeclaration(node)) {
|
|
31
|
+
const decorators = typescript_1.default.getDecorators(node);
|
|
32
|
+
if (!decorators || decorators.length === 0) {
|
|
33
|
+
return node;
|
|
34
|
+
}
|
|
35
|
+
return nodeFactory.updateClassDeclaration(node, [
|
|
36
|
+
...decorators.map((current) => visitDecorator(nodeFactory, current, typeChecker, resourceImportDeclarations)),
|
|
37
|
+
...(typescript_1.default.getModifiers(node) ?? []),
|
|
38
|
+
], node.name, node.typeParameters, node.heritageClauses, node.members);
|
|
39
|
+
}
|
|
40
|
+
return typescript_1.default.visitEachChild(node, visitNode, context);
|
|
41
|
+
};
|
|
42
|
+
return (sourceFile) => {
|
|
43
|
+
const updatedSourceFile = typescript_1.default.visitEachChild(sourceFile, visitNode, context);
|
|
44
|
+
if (resourceImportDeclarations.length > 0) {
|
|
45
|
+
return nodeFactory.updateSourceFile(updatedSourceFile, typescript_1.default.setTextRange(nodeFactory.createNodeArray([...resourceImportDeclarations, ...updatedSourceFile.statements], updatedSourceFile.statements.hasTrailingComma), updatedSourceFile.statements), updatedSourceFile.isDeclarationFile, updatedSourceFile.referencedFiles, updatedSourceFile.typeReferenceDirectives, updatedSourceFile.hasNoDefaultLib, updatedSourceFile.libReferenceDirectives);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return updatedSourceFile;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.createJitResourceTransformer = createJitResourceTransformer;
|
|
54
|
+
function visitDecorator(nodeFactory, node, typeChecker, resourceImportDeclarations) {
|
|
55
|
+
const origin = getDecoratorOrigin(node, typeChecker);
|
|
56
|
+
if (!origin || origin.module !== '@angular/core' || origin.name !== 'Component') {
|
|
57
|
+
return node;
|
|
58
|
+
}
|
|
59
|
+
if (!typescript_1.default.isCallExpression(node.expression)) {
|
|
60
|
+
return node;
|
|
61
|
+
}
|
|
62
|
+
const decoratorFactory = node.expression;
|
|
63
|
+
const args = decoratorFactory.arguments;
|
|
64
|
+
if (args.length !== 1 || !typescript_1.default.isObjectLiteralExpression(args[0])) {
|
|
65
|
+
// Unsupported component metadata
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
const objectExpression = args[0];
|
|
69
|
+
const styleReplacements = [];
|
|
70
|
+
// visit all properties
|
|
71
|
+
let properties = typescript_1.default.visitNodes(objectExpression.properties, (node) => typescript_1.default.isObjectLiteralElementLike(node)
|
|
72
|
+
? visitComponentMetadata(nodeFactory, node, styleReplacements, resourceImportDeclarations)
|
|
73
|
+
: node);
|
|
74
|
+
// replace properties with updated properties
|
|
75
|
+
if (styleReplacements.length > 0) {
|
|
76
|
+
const styleProperty = nodeFactory.createPropertyAssignment(nodeFactory.createIdentifier('styles'), nodeFactory.createArrayLiteralExpression(styleReplacements));
|
|
77
|
+
properties = nodeFactory.createNodeArray([...properties, styleProperty]);
|
|
78
|
+
}
|
|
79
|
+
return nodeFactory.updateDecorator(node, nodeFactory.updateCallExpression(decoratorFactory, decoratorFactory.expression, decoratorFactory.typeArguments, [nodeFactory.updateObjectLiteralExpression(objectExpression, properties)]));
|
|
80
|
+
}
|
|
81
|
+
function visitComponentMetadata(nodeFactory, node, styleReplacements, resourceImportDeclarations) {
|
|
82
|
+
if (!typescript_1.default.isPropertyAssignment(node) || typescript_1.default.isComputedPropertyName(node.name)) {
|
|
83
|
+
return node;
|
|
84
|
+
}
|
|
85
|
+
switch (node.name.text) {
|
|
86
|
+
case 'templateUrl':
|
|
87
|
+
// Only analyze string literals
|
|
88
|
+
if (!typescript_1.default.isStringLiteralLike(node.initializer)) {
|
|
89
|
+
return node;
|
|
90
|
+
}
|
|
91
|
+
return node.initializer.text.length === 0
|
|
92
|
+
? node
|
|
93
|
+
: nodeFactory.updatePropertyAssignment(node, nodeFactory.createIdentifier('template'), createResourceImport(nodeFactory, (0, uri_1.generateJitFileUri)(node.initializer.text, 'template'), resourceImportDeclarations));
|
|
94
|
+
case 'styles':
|
|
95
|
+
if (typescript_1.default.isStringLiteralLike(node.initializer)) {
|
|
96
|
+
styleReplacements.unshift(createResourceImport(nodeFactory, (0, uri_1.generateJitInlineUri)(node.initializer.text, 'style'), resourceImportDeclarations));
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (typescript_1.default.isArrayLiteralExpression(node.initializer)) {
|
|
100
|
+
const inlineStyles = typescript_1.default.visitNodes(node.initializer.elements, (node) => {
|
|
101
|
+
if (!typescript_1.default.isStringLiteralLike(node)) {
|
|
102
|
+
return node;
|
|
103
|
+
}
|
|
104
|
+
return node.text.length === 0
|
|
105
|
+
? undefined // An empty inline style is equivalent to not having a style element
|
|
106
|
+
: createResourceImport(nodeFactory, (0, uri_1.generateJitInlineUri)(node.text, 'style'), resourceImportDeclarations);
|
|
107
|
+
});
|
|
108
|
+
// Inline styles should be placed first
|
|
109
|
+
styleReplacements.unshift(...inlineStyles);
|
|
110
|
+
// The inline styles will be added afterwards in combination with any external styles
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
return node;
|
|
114
|
+
case 'styleUrl':
|
|
115
|
+
if (typescript_1.default.isStringLiteralLike(node.initializer)) {
|
|
116
|
+
styleReplacements.push(createResourceImport(nodeFactory, (0, uri_1.generateJitFileUri)(node.initializer.text, 'style'), resourceImportDeclarations));
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return node;
|
|
120
|
+
case 'styleUrls':
|
|
121
|
+
if (!typescript_1.default.isArrayLiteralExpression(node.initializer)) {
|
|
122
|
+
return node;
|
|
123
|
+
}
|
|
124
|
+
const externalStyles = typescript_1.default.visitNodes(node.initializer.elements, (node) => {
|
|
125
|
+
if (!typescript_1.default.isStringLiteralLike(node)) {
|
|
126
|
+
return node;
|
|
127
|
+
}
|
|
128
|
+
return node.text
|
|
129
|
+
? createResourceImport(nodeFactory, (0, uri_1.generateJitFileUri)(node.text, 'style'), resourceImportDeclarations)
|
|
130
|
+
: undefined;
|
|
131
|
+
});
|
|
132
|
+
// External styles are applied after any inline styles
|
|
133
|
+
styleReplacements.push(...externalStyles);
|
|
134
|
+
// The external styles will be added afterwards in combination with any inline styles
|
|
135
|
+
return undefined;
|
|
136
|
+
default:
|
|
137
|
+
// All other elements are passed through
|
|
138
|
+
return node;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function createResourceImport(nodeFactory, url, resourceImportDeclarations) {
|
|
142
|
+
const urlLiteral = nodeFactory.createStringLiteral(url);
|
|
143
|
+
const importName = nodeFactory.createIdentifier(`__NG_CLI_RESOURCE__${resourceImportDeclarations.length}`);
|
|
144
|
+
resourceImportDeclarations.push(nodeFactory.createImportDeclaration(undefined, nodeFactory.createImportClause(false, importName, undefined), urlLiteral));
|
|
145
|
+
return importName;
|
|
146
|
+
}
|
|
147
|
+
function getDecoratorOrigin(decorator, typeChecker) {
|
|
148
|
+
if (!typescript_1.default.isCallExpression(decorator.expression)) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
let identifier;
|
|
152
|
+
let name = '';
|
|
153
|
+
if (typescript_1.default.isPropertyAccessExpression(decorator.expression.expression)) {
|
|
154
|
+
identifier = decorator.expression.expression.expression;
|
|
155
|
+
name = decorator.expression.expression.name.text;
|
|
156
|
+
}
|
|
157
|
+
else if (typescript_1.default.isIdentifier(decorator.expression.expression)) {
|
|
158
|
+
identifier = decorator.expression.expression;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
// NOTE: resolver.getReferencedImportDeclaration would work as well but is internal
|
|
164
|
+
const symbol = typeChecker.getSymbolAtLocation(identifier);
|
|
165
|
+
if (symbol && symbol.declarations && symbol.declarations.length > 0) {
|
|
166
|
+
const declaration = symbol.declarations[0];
|
|
167
|
+
let module;
|
|
168
|
+
if (typescript_1.default.isImportSpecifier(declaration)) {
|
|
169
|
+
name = (declaration.propertyName || declaration.name).text;
|
|
170
|
+
module = declaration.parent.parent.parent.moduleSpecifier.text;
|
|
171
|
+
}
|
|
172
|
+
else if (typescript_1.default.isNamespaceImport(declaration)) {
|
|
173
|
+
// Use the name from the decorator namespace property access
|
|
174
|
+
module = declaration.parent.parent.moduleSpecifier.text;
|
|
175
|
+
}
|
|
176
|
+
else if (typescript_1.default.isImportClause(declaration)) {
|
|
177
|
+
name = declaration.name.text;
|
|
178
|
+
module = declaration.parent.moduleSpecifier.text;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return { name, module };
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import type ts from 'typescript';
|
|
9
|
+
import { MemoryLoadResultCache } from '../load-result-cache';
|
|
10
|
+
export declare class SourceFileCache extends Map<string, ts.SourceFile> {
|
|
11
|
+
readonly persistentCachePath?: string | undefined;
|
|
12
|
+
readonly modifiedFiles: Set<string>;
|
|
13
|
+
readonly typeScriptFileCache: Map<string, string | Uint8Array>;
|
|
14
|
+
readonly loadResultCache: MemoryLoadResultCache;
|
|
15
|
+
referencedFiles?: readonly string[];
|
|
16
|
+
constructor(persistentCachePath?: string | undefined);
|
|
17
|
+
invalidate(files: Iterable<string>): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.SourceFileCache = void 0;
|
|
34
|
+
const node_os_1 = require("node:os");
|
|
35
|
+
const path = __importStar(require("node:path"));
|
|
36
|
+
const load_result_cache_1 = require("../load-result-cache");
|
|
37
|
+
const USING_WINDOWS = (0, node_os_1.platform)() === 'win32';
|
|
38
|
+
const WINDOWS_SEP_REGEXP = new RegExp(`\\${path.win32.sep}`, 'g');
|
|
39
|
+
class SourceFileCache extends Map {
|
|
40
|
+
persistentCachePath;
|
|
41
|
+
modifiedFiles = new Set();
|
|
42
|
+
typeScriptFileCache = new Map();
|
|
43
|
+
loadResultCache = new load_result_cache_1.MemoryLoadResultCache();
|
|
44
|
+
referencedFiles;
|
|
45
|
+
constructor(persistentCachePath) {
|
|
46
|
+
super();
|
|
47
|
+
this.persistentCachePath = persistentCachePath;
|
|
48
|
+
}
|
|
49
|
+
invalidate(files) {
|
|
50
|
+
if (files !== this.modifiedFiles) {
|
|
51
|
+
this.modifiedFiles.clear();
|
|
52
|
+
}
|
|
53
|
+
for (let file of files) {
|
|
54
|
+
file = path.normalize(file);
|
|
55
|
+
this.loadResultCache.invalidate(file);
|
|
56
|
+
// Normalize separators to allow matching TypeScript Host paths
|
|
57
|
+
if (USING_WINDOWS) {
|
|
58
|
+
file = file.replace(WINDOWS_SEP_REGEXP, path.posix.sep);
|
|
59
|
+
}
|
|
60
|
+
this.delete(file);
|
|
61
|
+
this.modifiedFiles.add(file);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.SourceFileCache = SourceFileCache;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A string value representing the namespace for Angular JIT mode related imports for
|
|
10
|
+
* Component styles. This namespace is used for both inline (`styles`) and external
|
|
11
|
+
* (`styleUrls`) styles.
|
|
12
|
+
*/
|
|
13
|
+
export declare const JIT_STYLE_NAMESPACE: "angular:jit:style";
|
|
14
|
+
/**
|
|
15
|
+
* A string value representing the namespace for Angular JIT mode related imports for
|
|
16
|
+
* Component templates. This namespace is currently only used for external (`templateUrl`)
|
|
17
|
+
* templates.
|
|
18
|
+
*/
|
|
19
|
+
export declare const JIT_TEMPLATE_NAMESPACE: "angular:jit:template";
|
|
20
|
+
/**
|
|
21
|
+
* A regular expression that can be used to match a Angular JIT mode namespace URI.
|
|
22
|
+
* It contains capture groups for the type (template/style), origin (file/inline), and specifier.
|
|
23
|
+
* The {@link parseJitUri} function can be used to parse and return an object representation of a JIT URI.
|
|
24
|
+
*/
|
|
25
|
+
export declare const JIT_NAMESPACE_REGEXP: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Generates an Angular JIT mode namespace URI for a given file.
|
|
28
|
+
* @param file The path of the file to be included.
|
|
29
|
+
* @param type The type of the file (`style` or `template`).
|
|
30
|
+
* @returns A string containing the full JIT namespace URI.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateJitFileUri(file: string, type: 'style' | 'template'): string;
|
|
33
|
+
/**
|
|
34
|
+
* Generates an Angular JIT mode namespace URI for a given inline style or template.
|
|
35
|
+
* The provided content is base64 encoded and included in the URI.
|
|
36
|
+
* @param data The content to encode within the URI.
|
|
37
|
+
* @param type The type of the content (`style` or `template`).
|
|
38
|
+
* @returns A string containing the full JIT namespace URI.
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateJitInlineUri(data: string | Uint8Array, type: 'style' | 'template'): string;
|
|
41
|
+
/**
|
|
42
|
+
* Parses a string containing a JIT namespace URI.
|
|
43
|
+
* JIT namespace URIs are used to encode the information for an Angular component's stylesheets
|
|
44
|
+
* and templates when compiled in JIT mode.
|
|
45
|
+
* @param uri The URI to parse into its underlying components.
|
|
46
|
+
* @returns An object containing the namespace, type, origin, and specifier of the URI;
|
|
47
|
+
* `undefined` if not a JIT namespace URI.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseJitUri(uri: string): {
|
|
50
|
+
namespace: string;
|
|
51
|
+
type: "style" | "template";
|
|
52
|
+
origin: "file" | "inline";
|
|
53
|
+
specifier: string;
|
|
54
|
+
} | undefined;
|