@analogjs/vite-plugin-angular 3.0.0-beta.9 → 3.0.0
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/migrations/migrate-setup-vitest/migrate-setup-vitest.js +3 -3
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46806 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +601 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +5 -2
- package/src/index.d.ts +2 -0
- package/src/index.js +4 -3
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.js +2 -3
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +360 -0
- package/src/lib/angular-build-context.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
- package/src/lib/angular-build-optimizer-plugin.js +25 -11
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +5 -3
- package/src/lib/angular-jit-plugin.js +16 -9
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -109
- package/src/lib/angular-vite-plugin.js +9 -1251
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +3 -2
- package/src/lib/angular-vitest-plugin.js +7 -5
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/companion-plugins.d.ts +7 -0
- package/src/lib/companion-plugins.js +37 -0
- package/src/lib/companion-plugins.js.map +1 -0
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
- package/src/lib/compilation-api/compilation-api-plugin.js +156 -285
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compilation-api/index.js +1 -2
- package/src/lib/compiler/angular-version.js +0 -1
- package/src/lib/compiler/class-field-lowering.js +1 -2
- package/src/lib/compiler/compile.d.ts +1 -1
- package/src/lib/compiler/compile.js +224 -151
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/constants.js +1 -2
- package/src/lib/compiler/debug.js +1 -2
- package/src/lib/compiler/defer.d.ts +2 -3
- package/src/lib/compiler/defer.js +13 -16
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +6 -1
- package/src/lib/compiler/dts-reader.js +20 -12
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +8 -4
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +6 -6
- package/src/lib/compiler/jit-metadata.js +1 -2
- package/src/lib/compiler/jit-transform.js +37 -15
- package/src/lib/compiler/jit-transform.js.map +1 -1
- package/src/lib/compiler/js-emitter.d.ts +0 -3
- package/src/lib/compiler/js-emitter.js +4 -23
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler/metadata.js +2 -3
- package/src/lib/compiler/registry.d.ts +9 -1
- package/src/lib/compiler/registry.js +36 -8
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/compiler/resource-inliner.d.ts +8 -9
- package/src/lib/compiler/resource-inliner.js +11 -20
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.d.ts +22 -1
- package/src/lib/compiler/style-ast.js +37 -20
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/compiler/type-elision.d.ts +4 -3
- package/src/lib/compiler/type-elision.js +11 -13
- package/src/lib/compiler/type-elision.js.map +1 -1
- package/src/lib/compiler/utils.d.ts +9 -7
- package/src/lib/compiler/utils.js +50 -11
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/compiler-plugin.js +1 -2
- package/src/lib/component-resolvers.js +1 -2
- package/src/lib/component-scanner.d.ts +101 -0
- package/src/lib/component-scanner.js +331 -0
- package/src/lib/component-scanner.js.map +1 -0
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +352 -0
- package/src/lib/component-styles-plugin.js.map +1 -0
- package/src/lib/compose-angular-plugins.d.ts +12 -0
- package/src/lib/compose-angular-plugins.js +30 -0
- package/src/lib/compose-angular-plugins.js.map +1 -0
- package/src/lib/dev-server-mode-plugin.d.ts +7 -0
- package/src/lib/dev-server-mode-plugin.js +22 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/encapsulation-plugin.js +1 -2
- package/src/lib/fast-compile-api.d.ts +62 -0
- package/src/lib/fast-compile-api.js +11 -0
- package/src/lib/fast-compile-api.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +6 -1
- package/src/lib/fast-compile-plugin.js +222 -117
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +3 -0
- package/src/lib/host.js +5 -4
- package/src/lib/host.js.map +1 -1
- package/src/lib/hot-update-batch.js +1 -2
- package/src/lib/live-reload-plugin.d.ts +6 -3
- package/src/lib/live-reload-plugin.js +14 -8
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-api.d.ts +55 -0
- package/src/lib/ngp-compile-api.js +11 -0
- package/src/lib/ngp-compile-api.js.map +1 -0
- package/src/lib/ngp-compile-plugin.d.ts +4 -0
- package/src/lib/ngp-compile-plugin.js +675 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +776 -0
- package/src/lib/ngtsc-compile-plugin.js.map +1 -0
- package/src/lib/nx-folder-plugin.d.ts +6 -5
- package/src/lib/nx-folder-plugin.js +13 -9
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
- package/src/lib/plugins/file-replacements.plugin.js +2 -2
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +5 -1
- package/src/lib/router-plugin.js +14 -6
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.js +1 -2
- package/src/lib/stylesheet-registry.js +1 -2
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -3
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +1 -2
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +3 -4
- package/src/lib/utils/css-extension-resolver.js +1 -2
- package/src/lib/utils/css-preprocessor-workers.js +1 -2
- package/src/lib/utils/debug-harness.js +1 -2
- package/src/lib/utils/debug-log-file.js +1 -2
- package/src/lib/utils/debug.js +1 -2
- package/src/lib/utils/devkit.js +2 -3
- package/src/lib/utils/hmr-component-updates.d.ts +7 -0
- package/src/lib/utils/hmr-component-updates.js +86 -0
- package/src/lib/utils/hmr-component-updates.js.map +1 -0
- package/src/lib/utils/jit-inline-styles.js +1 -2
- package/src/lib/utils/lsp-type-checker.d.ts +75 -0
- package/src/lib/utils/lsp-type-checker.js +532 -0
- package/src/lib/utils/lsp-type-checker.js.map +1 -0
- package/src/lib/utils/ngp-host-fs.d.ts +43 -0
- package/src/lib/utils/ngp-host-fs.js +128 -0
- package/src/lib/utils/ngp-host-fs.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +15 -8
- package/src/lib/utils/plugin-config.js +19 -7
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/rolldown.js +1 -2
- package/src/lib/utils/safe-module-paths.js +1 -2
- package/src/lib/utils/stylesheet-warning.d.ts +2 -0
- package/src/lib/utils/stylesheet-warning.js +10 -0
- package/src/lib/utils/stylesheet-warning.js.map +1 -0
- package/src/lib/utils/transform-cache.js +1 -2
- package/src/lib/utils/transform-cache.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +2 -3
- package/src/lib/utils/virtual-ids.js +1 -2
- package/src/lib/utils/virtual-resources.js +1 -2
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +70 -15
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -1,17 +1,57 @@
|
|
|
1
1
|
import "./constants.js";
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { parseSync, rawTransferSupported } from "oxc-parser";
|
|
4
|
+
// packages/vite-plugin-angular/src/lib/compiler/utils.ts
|
|
5
|
+
var rawTransferOptions = { experimentalRawTransfer: true };
|
|
6
|
+
var useRawTransfer = rawTransferSupported();
|
|
7
|
+
/**
|
|
8
|
+
* Parse with oxc-parser, using raw transfer when the platform supports it.
|
|
9
|
+
* Falls back to the default transfer for this and later calls if raw
|
|
10
|
+
* transfer throws (e.g. its large buffer cannot be allocated).
|
|
11
|
+
*/
|
|
12
|
+
var JS_TS_EXTENSIONS = [
|
|
13
|
+
".ts",
|
|
14
|
+
".tsx",
|
|
15
|
+
".mts",
|
|
16
|
+
".cts",
|
|
17
|
+
".js",
|
|
18
|
+
".jsx",
|
|
19
|
+
".mjs",
|
|
20
|
+
".cjs"
|
|
21
|
+
];
|
|
22
|
+
function parseOxc(fileName, code) {
|
|
23
|
+
if (!JS_TS_EXTENSIONS.some((ext) => fileName.endsWith(ext))) fileName += ".ts";
|
|
24
|
+
if (useRawTransfer) try {
|
|
25
|
+
return parseSync(fileName, code, rawTransferOptions);
|
|
26
|
+
} catch {
|
|
27
|
+
useRawTransfer = false;
|
|
11
28
|
}
|
|
12
|
-
|
|
29
|
+
return parseSync(fileName, code);
|
|
30
|
+
}
|
|
31
|
+
/** Recursively find all class declarations in an OXC AST, including nested scopes. */
|
|
32
|
+
function findAllClasses(program) {
|
|
33
|
+
const result = [];
|
|
34
|
+
walkOxc(program, (node) => {
|
|
35
|
+
if (node.type === "ClassDeclaration") result.push(node);
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
13
38
|
return result;
|
|
14
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Depth-first walk over OXC AST nodes. `visit` returns `false` to skip a
|
|
42
|
+
* node's children.
|
|
43
|
+
*/
|
|
44
|
+
function walkOxc(node, visit) {
|
|
45
|
+
if (Array.isArray(node)) {
|
|
46
|
+
for (const child of node) walkOxc(child, visit);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (!node || typeof node.type !== "string" || !visit(node)) return;
|
|
50
|
+
for (const key in node) {
|
|
51
|
+
const value = node[key];
|
|
52
|
+
if (value && typeof value === "object") walkOxc(value, visit);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
15
55
|
/** Unwrap forwardRef(() => X) to X for OXC AST nodes. Returns the original node if not a forwardRef call. */
|
|
16
56
|
function unwrapForwardRefOxc(node) {
|
|
17
57
|
if (node?.type === "CallExpression" && node.callee?.type === "Identifier" && node.callee.name === "forwardRef") {
|
|
@@ -72,7 +112,6 @@ function deriveRelativeImportPath(fromFile, toFile) {
|
|
|
72
112
|
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
73
113
|
return rel;
|
|
74
114
|
}
|
|
75
|
-
|
|
76
|
-
export { deriveRelativeImportPath, findAllClasses, resolveSyntheticImportSpecifier, unwrapForwardRefOxc };
|
|
115
|
+
export { deriveRelativeImportPath, findAllClasses, parseOxc, resolveSyntheticImportSpecifier, unwrapForwardRefOxc, walkOxc };
|
|
77
116
|
|
|
78
117
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/lib/compiler/utils.ts"],"sourcesContent":["import * as
|
|
1
|
+
{"version":3,"file":"utils.js","names":["path"],"sources":["../../../../src/lib/compiler/utils.ts"],"sourcesContent":["import * as path from 'node:path';\nimport {\n parseSync,\n rawTransferSupported,\n type ParseResult,\n type ParserOptions,\n} from 'oxc-parser';\n\n// Raw transfer reads the AST straight from Rust memory instead of going\n// through JSON (~3x faster). Not yet in oxc-parser's published types.\nconst rawTransferOptions = { experimentalRawTransfer: true } as ParserOptions;\nlet useRawTransfer = rawTransferSupported();\n\n/**\n * Parse with oxc-parser, using raw transfer when the platform supports it.\n * Falls back to the default transfer for this and later calls if raw\n * transfer throws (e.g. its large buffer cannot be allocated).\n */\nconst JS_TS_EXTENSIONS = [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n];\n\nexport function parseOxc(fileName: string, code: string): ParseResult {\n // OXC picks the language from the extension. Modules of other source\n // formats reach the compiler already converted to TypeScript.\n if (!JS_TS_EXTENSIONS.some((ext) => fileName.endsWith(ext))) {\n fileName += '.ts';\n }\n if (useRawTransfer) {\n try {\n return parseSync(fileName, code, rawTransferOptions);\n } catch {\n useRawTransfer = false;\n }\n }\n return parseSync(fileName, code);\n}\n\n/** Recursively find all class declarations in an OXC AST, including nested scopes. */\nexport function findAllClasses(program: any): any[] {\n const result: any[] = [];\n walkOxc(program, (node) => {\n if (node.type === 'ClassDeclaration') result.push(node);\n return true;\n });\n return result;\n}\n\n/**\n * Depth-first walk over OXC AST nodes. `visit` returns `false` to skip a\n * node's children.\n */\nexport function walkOxc(node: any, visit: (node: any) => boolean): void {\n if (Array.isArray(node)) {\n for (const child of node) walkOxc(child, visit);\n return;\n }\n if (!node || typeof node.type !== 'string' || !visit(node)) return;\n for (const key in node) {\n const value = node[key];\n if (value && typeof value === 'object') walkOxc(value, visit);\n }\n}\n\n/** Unwrap forwardRef(() => X) to X for OXC AST nodes. Returns the original node if not a forwardRef call. */\nexport function unwrapForwardRefOxc(node: any): any {\n if (\n node?.type === 'CallExpression' &&\n node.callee?.type === 'Identifier' &&\n node.callee.name === 'forwardRef'\n ) {\n const arg = node.arguments?.[0];\n if (arg?.type === 'ArrowFunctionExpression') {\n if (\n arg.body?.type === 'FunctionBody' ||\n arg.body?.type === 'BlockStatement'\n ) {\n const stmts = arg.body.statements || arg.body.body || [];\n const stmt = stmts[0];\n if (stmt?.type === 'ReturnStatement' && stmt.argument)\n return stmt.argument;\n } else {\n // Expression body: forwardRef(() => X)\n return arg.body;\n }\n }\n if (arg?.type === 'FunctionExpression') {\n const stmts = arg.body?.statements || arg.body?.body || [];\n if (stmts.length === 1) {\n const stmt = stmts[0];\n if (stmt?.type === 'ReturnStatement' && stmt.argument)\n return stmt.argument;\n }\n }\n }\n return node;\n}\n\n/**\n * Resolve the module specifier to use for a synthetic import of a registry\n * declaration referenced from `currentFileName`.\n *\n * Order of preference:\n * 1. `entry.sourcePackage` — external packages scanned from `.d.ts` resolve\n * via their package name (proper barrel exports).\n * 2. A relative path derived from `currentFileName` to `entry.fileName` — for\n * local workspace classes scanned from real source files. This is what\n * NgModule/tuple export expansion must use: the class lives in its own\n * file, not the module/barrel file that re-exports it, so importing from\n * the module specifier fails with\n * `\"X\" is not exported by \".../the.module.ts\"`.\n * 3. `fallbackSpecifier` — the import path of the module/tuple itself, used\n * for `.d.ts` entries (whose file path is not a usable import target) and\n * when the registry has no file location for the class.\n *\n * Returns `undefined` when the class is declared in `currentFileName` itself\n * (already in scope — no synthetic import needed).\n */\nexport function resolveSyntheticImportSpecifier(\n currentFileName: string,\n entry: { sourcePackage?: string; fileName?: string },\n fallbackSpecifier: string | undefined,\n): string | undefined {\n if (entry.sourcePackage) return entry.sourcePackage;\n // `.d.ts` entries come from scanning external package type declarations;\n // their file path is not a usable relative import target, so defer to the\n // module/tuple specifier the consumer already imports from.\n if (entry.fileName && !entry.fileName.endsWith('.d.ts')) {\n if (entry.fileName === currentFileName) return undefined;\n return deriveRelativeImportPath(currentFileName, entry.fileName);\n }\n return fallbackSpecifier;\n}\n\n/**\n * Derive a relative module specifier from `fromFile` to `toFile`, suitable for\n * a synthetic `import { … } from '…'` statement: strips the file extension,\n * normalizes to POSIX separators, and ensures an explicit `./` prefix.\n */\nexport function deriveRelativeImportPath(\n fromFile: string,\n toFile: string,\n): string {\n let rel = path.relative(path.dirname(fromFile), toFile);\n rel = rel.replace(/\\.[cm]?[jt]sx?$/, '');\n rel = rel.split(path.sep).join('/');\n if (!rel.startsWith('.')) rel = './' + rel;\n return rel;\n}\n\nexport { ANGULAR_DECORATORS } from './constants.js';\n"],"mappings":";;;;AAUA,IAAM,qBAAqB,EAAE,yBAAyB,KAAK;AAC3D,IAAI,iBAAiB,qBAAqB;;;;;;AAO1C,IAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,SAAS,UAAkB,MAA2B;CAGpE,IAAI,CAAC,iBAAiB,MAAM,QAAQ,SAAS,SAAS,GAAG,CAAC,GACxD,YAAY;CAEd,IAAI,gBACF,IAAI;EACF,OAAO,UAAU,UAAU,MAAM,kBAAkB;CACrD,QAAQ;EACN,iBAAiB;CACnB;CAEF,OAAO,UAAU,UAAU,IAAI;AACjC;;AAGA,SAAgB,eAAe,SAAqB;CAClD,MAAM,SAAgB,CAAC;CACvB,QAAQ,UAAU,SAAS;EACzB,IAAI,KAAK,SAAS,oBAAoB,OAAO,KAAK,IAAI;EACtD,OAAO;CACT,CAAC;CACD,OAAO;AACT;;;;;AAMA,SAAgB,QAAQ,MAAW,OAAqC;CACtE,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,SAAS,MAAM,QAAQ,OAAO,KAAK;EAC9C;CACF;CACA,IAAI,CAAC,QAAQ,OAAO,KAAK,SAAS,YAAY,CAAC,MAAM,IAAI,GAAG;CAC5D,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,KAAK;EACnB,IAAI,SAAS,OAAO,UAAU,UAAU,QAAQ,OAAO,KAAK;CAC9D;AACF;;AAGA,SAAgB,oBAAoB,MAAgB;CAClD,IACE,MAAM,SAAS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/src/lib/compiler-plugin.ts
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -50,7 +50,6 @@ function createRolldownCompilerPlugin(pluginOptions, isTest, closeTransformer, c
|
|
|
50
50
|
if (closeTransformer) plugin.buildEnd = () => javascriptTransformer?.close();
|
|
51
51
|
return plugin;
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { createCompilerPlugin, createRolldownCompilerPlugin };
|
|
55
54
|
|
|
56
55
|
//# sourceMappingURL=compiler-plugin.js.map
|
|
@@ -2,7 +2,7 @@ import { dirname, resolve } from "node:path";
|
|
|
2
2
|
import { normalizePath } from "vite";
|
|
3
3
|
import { parseSync } from "oxc-parser";
|
|
4
4
|
import { Visitor } from "rolldown/utils";
|
|
5
|
-
|
|
5
|
+
// packages/vite-plugin-angular/src/lib/component-resolvers.ts
|
|
6
6
|
/**
|
|
7
7
|
* Extracts a string value from an ESTree AST node.
|
|
8
8
|
*
|
|
@@ -106,7 +106,6 @@ var TemplateUrlsResolver = class {
|
|
|
106
106
|
return templateUrlPaths;
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
//#endregion
|
|
110
109
|
export { StyleUrlsResolver, TemplateUrlsResolver, getStyleUrls, getTemplateUrls };
|
|
111
110
|
|
|
112
111
|
//# sourceMappingURL=component-resolvers.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { parseSync } from "oxc-parser";
|
|
2
|
+
import type { ComponentRegistryEntries } from "./analog-plugin-interop.js";
|
|
3
|
+
import { type ComponentRegistry, type RegistryEntry } from "./compiler/index.js";
|
|
4
|
+
import type { FastCompileResolve, FastCompileSourceFormat } from "./fast-compile-api.js";
|
|
5
|
+
type OxcProgram = ReturnType<typeof parseSync>["program"];
|
|
6
|
+
/** Resolves an import to a source file to scan, or `null` to skip it. */
|
|
7
|
+
export type ResolveImport = (spec: string, importer: string) => Promise<string | null>;
|
|
8
|
+
/** Optional import site context for module-scoped selector lookup. */
|
|
9
|
+
export interface SelectorLookupContext {
|
|
10
|
+
moduleSpecifier?: string;
|
|
11
|
+
containingFile?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Angular classes scanned from source files and package `.d.ts` declarations,
|
|
15
|
+
* so source formats can look up the selectors of the components they import
|
|
16
|
+
* before any compiler sees their modules. Shared by the fast compile and NGP
|
|
17
|
+
* plugins.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ComponentScanner {
|
|
20
|
+
readonly registry: ComponentRegistry;
|
|
21
|
+
readonly scannedDtsPackages: Set<string>;
|
|
22
|
+
/** Files scanned on demand, mapped to the barrel chain each pulled in. */
|
|
23
|
+
readonly lazyScans: Map<string, Promise<Set<string>>>;
|
|
24
|
+
/** Modules compiled against each scanned file. */
|
|
25
|
+
readonly importersByFile: Map<string, Set<string>>;
|
|
26
|
+
/** Entries declared in each scanned source file, keyed by normalized path. */
|
|
27
|
+
private readonly entriesByFile;
|
|
28
|
+
/** Direct resolved target file per importer and module specifier. */
|
|
29
|
+
private readonly resolvedImports;
|
|
30
|
+
/** Export aliases and re-export bindings per scanned file, keyed by normalized path. */
|
|
31
|
+
private readonly reExportsByFile;
|
|
32
|
+
private readonly sourceFormats;
|
|
33
|
+
private root;
|
|
34
|
+
/** Where package declarations are looked up from. */
|
|
35
|
+
get projectRoot(): string;
|
|
36
|
+
reset(projectRoot: string): void;
|
|
37
|
+
registerSourceFormat(format: FastCompileSourceFormat): void;
|
|
38
|
+
sourceFormatOf(file: string): FastCompileSourceFormat | undefined;
|
|
39
|
+
/** Whether `file` is TypeScript or a module of a registered source format. */
|
|
40
|
+
isCompiledSource(file: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Reads a source file for scanning. Modules of a registered source format
|
|
43
|
+
* are converted to TypeScript first so the scanner sees their classes.
|
|
44
|
+
*/
|
|
45
|
+
readScanSource(file: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Adapts a Vite-style resolver to the scanner's: only source files this
|
|
48
|
+
* scanner reads, outside `node_modules` (package declarations come from the
|
|
49
|
+
* `.d.ts` scanner instead).
|
|
50
|
+
*/
|
|
51
|
+
toResolveImport(resolve: FastCompileResolve): ResolveImport;
|
|
52
|
+
/** Scans the `.d.ts` declarations of `packages` into the registry, once each. */
|
|
53
|
+
ensureDtsRegistryForPackages(packages: Iterable<string>): void;
|
|
54
|
+
ensureDtsRegistryForSource(code: string, id: string, program?: OxcProgram): void;
|
|
55
|
+
/**
|
|
56
|
+
* Scans the modules behind `specifiers`, imported by `importer`: packages
|
|
57
|
+
* from their `.d.ts` declarations, everything else from source.
|
|
58
|
+
*/
|
|
59
|
+
scanImports(specifiers: string[], importer: string, resolve: FastCompileResolve): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Scans the files behind `specs`, imported by `id`, into the registry and
|
|
62
|
+
* records `id` as their importer.
|
|
63
|
+
*/
|
|
64
|
+
resolveImportSpecifiers(specs: string[], id: string, resolveImport: ResolveImport): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves the registry entry for an imported or global Angular declaration.
|
|
67
|
+
* When `context` gives the importing file and module specifier, exported
|
|
68
|
+
* bindings on the resolved module (including barrel re-exports) are followed
|
|
69
|
+
* before falling back to the global registry.
|
|
70
|
+
*/
|
|
71
|
+
lookupEntry(className: string, external?: readonly ComponentRegistryEntries[], context?: SelectorLookupContext): RegistryEntry | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The element selector of a component or directive class. `external` are
|
|
74
|
+
* registries contributed through `analog.setup()`. When `context` gives the
|
|
75
|
+
* importing file and module specifier, declarations scanned from that module
|
|
76
|
+
* (and its re-exports) are checked before falling back to the global registry.
|
|
77
|
+
*/
|
|
78
|
+
lookupSelector(className: string, external?: readonly ComponentRegistryEntries[], context?: SelectorLookupContext): string | null;
|
|
79
|
+
/** The files scanned for `importer`. */
|
|
80
|
+
dependenciesOf(importer: string): string[];
|
|
81
|
+
entriesOf(file: string): RegistryEntry[];
|
|
82
|
+
/**
|
|
83
|
+
* Records the entries scanned from a source file in both per-file storage
|
|
84
|
+
* and the global registry.
|
|
85
|
+
*/
|
|
86
|
+
recordFileEntries(file: string, entries: RegistryEntry[], overwrite?: boolean): void;
|
|
87
|
+
/** Drops what was scanned from `file`, so the next scan reads it again. */
|
|
88
|
+
invalidate(file: string): void;
|
|
89
|
+
private addEntry;
|
|
90
|
+
private resolveExportedEntry;
|
|
91
|
+
private removeFromRegistryIfOwned;
|
|
92
|
+
private scanOnDemand;
|
|
93
|
+
/**
|
|
94
|
+
* Scan a file and everything it re-exports, resolving specifiers through
|
|
95
|
+
* Vite so path aliases work. Tuple barrels and NgModules can list classes
|
|
96
|
+
* their file imports without re-exporting, so their imports are followed
|
|
97
|
+
* too. Returns every file scanned.
|
|
98
|
+
*/
|
|
99
|
+
private scanWithReExports;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import "./compiler/index.js";
|
|
2
|
+
import { parseOxc } from "./compiler/utils.js";
|
|
3
|
+
import { scanFile } from "./compiler/registry.js";
|
|
4
|
+
import { collectAllImports, collectImportedPackages, collectReExports, scanPackageDts } from "./compiler/dts-reader.js";
|
|
5
|
+
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
|
|
6
|
+
import { promises } from "node:fs";
|
|
7
|
+
import { normalizePath } from "vite";
|
|
8
|
+
// packages/vite-plugin-angular/src/lib/component-scanner.ts
|
|
9
|
+
/**
|
|
10
|
+
* Angular classes scanned from source files and package `.d.ts` declarations,
|
|
11
|
+
* so source formats can look up the selectors of the components they import
|
|
12
|
+
* before any compiler sees their modules. Shared by the fast compile and NGP
|
|
13
|
+
* plugins.
|
|
14
|
+
*/
|
|
15
|
+
var ComponentScanner = class {
|
|
16
|
+
registry = /* @__PURE__ */ new Map();
|
|
17
|
+
scannedDtsPackages = /* @__PURE__ */ new Set();
|
|
18
|
+
/** Files scanned on demand, mapped to the barrel chain each pulled in. */
|
|
19
|
+
lazyScans = /* @__PURE__ */ new Map();
|
|
20
|
+
/** Modules compiled against each scanned file. */
|
|
21
|
+
importersByFile = /* @__PURE__ */ new Map();
|
|
22
|
+
/** Entries declared in each scanned source file, keyed by normalized path. */
|
|
23
|
+
entriesByFile = /* @__PURE__ */ new Map();
|
|
24
|
+
/** Direct resolved target file per importer and module specifier. */
|
|
25
|
+
resolvedImports = /* @__PURE__ */ new Map();
|
|
26
|
+
/** Export aliases and re-export bindings per scanned file, keyed by normalized path. */
|
|
27
|
+
reExportsByFile = /* @__PURE__ */ new Map();
|
|
28
|
+
sourceFormats = [];
|
|
29
|
+
root = "";
|
|
30
|
+
/** Where package declarations are looked up from. */
|
|
31
|
+
get projectRoot() {
|
|
32
|
+
return this.root;
|
|
33
|
+
}
|
|
34
|
+
reset(projectRoot) {
|
|
35
|
+
this.root = projectRoot;
|
|
36
|
+
this.registry.clear();
|
|
37
|
+
this.scannedDtsPackages.clear();
|
|
38
|
+
this.lazyScans.clear();
|
|
39
|
+
this.importersByFile.clear();
|
|
40
|
+
this.entriesByFile.clear();
|
|
41
|
+
this.resolvedImports.clear();
|
|
42
|
+
this.reExportsByFile.clear();
|
|
43
|
+
}
|
|
44
|
+
registerSourceFormat(format) {
|
|
45
|
+
if (!this.sourceFormats.includes(format)) this.sourceFormats.push(format);
|
|
46
|
+
}
|
|
47
|
+
sourceFormatOf(file) {
|
|
48
|
+
const path = file.split("?")[0];
|
|
49
|
+
return this.sourceFormats.find((format) => format.test(path));
|
|
50
|
+
}
|
|
51
|
+
/** Whether `file` is TypeScript or a module of a registered source format. */
|
|
52
|
+
isCompiledSource(file) {
|
|
53
|
+
return TS_EXT_REGEX.test(file) || this.sourceFormatOf(file) !== void 0;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads a source file for scanning. Modules of a registered source format
|
|
57
|
+
* are converted to TypeScript first so the scanner sees their classes.
|
|
58
|
+
*/
|
|
59
|
+
async readScanSource(file) {
|
|
60
|
+
const code = await promises.readFile(file, "utf-8");
|
|
61
|
+
const format = this.sourceFormatOf(file);
|
|
62
|
+
return format ? format.toScanSource(code, file) : code;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adapts a Vite-style resolver to the scanner's: only source files this
|
|
66
|
+
* scanner reads, outside `node_modules` (package declarations come from the
|
|
67
|
+
* `.d.ts` scanner instead).
|
|
68
|
+
*/
|
|
69
|
+
toResolveImport(resolve) {
|
|
70
|
+
return async (spec, importer) => {
|
|
71
|
+
const resolved = await resolve(spec, importer);
|
|
72
|
+
if (!resolved || resolved.external) return null;
|
|
73
|
+
const file = normalizePath(resolved.id.split("?")[0]);
|
|
74
|
+
return this.isCompiledSource(file) && !EXCLUDED_TS_EXT_REGEX.test(file) && !file.includes("/node_modules/") ? file : null;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Scans the `.d.ts` declarations of `packages` into the registry, once each. */
|
|
78
|
+
ensureDtsRegistryForPackages(packages) {
|
|
79
|
+
for (const pkg of packages) {
|
|
80
|
+
if (this.scannedDtsPackages.has(pkg)) continue;
|
|
81
|
+
this.scannedDtsPackages.add(pkg);
|
|
82
|
+
try {
|
|
83
|
+
const dtsEntries = scanPackageDts(pkg, this.root || process.cwd(), this.scannedDtsPackages);
|
|
84
|
+
for (const entry of dtsEntries) this.addEntry(entry);
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
ensureDtsRegistryForSource(code, id, program) {
|
|
89
|
+
this.ensureDtsRegistryForPackages(collectImportedPackages(code, id, program));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Scans the modules behind `specifiers`, imported by `importer`: packages
|
|
93
|
+
* from their `.d.ts` declarations, everything else from source.
|
|
94
|
+
*/
|
|
95
|
+
scanImports(specifiers, importer, resolve) {
|
|
96
|
+
this.ensureDtsRegistryForPackages(specifiers.filter((spec) => !spec.startsWith(".") && !spec.startsWith("/")).map((spec) => {
|
|
97
|
+
const parts = spec.split("/");
|
|
98
|
+
return spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
99
|
+
}));
|
|
100
|
+
return this.resolveImportSpecifiers(specifiers, importer, this.toResolveImport(resolve));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Scans the files behind `specs`, imported by `id`, into the registry and
|
|
104
|
+
* records `id` as their importer.
|
|
105
|
+
*/
|
|
106
|
+
async resolveImportSpecifiers(specs, id, resolveImport) {
|
|
107
|
+
const importerKey = normalizePath(id);
|
|
108
|
+
await Promise.all(specs.map(async (spec) => {
|
|
109
|
+
const file = await resolveImport(spec, id);
|
|
110
|
+
if (!file) {
|
|
111
|
+
this.resolvedImports.get(importerKey)?.delete(spec);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const normalizedFile = normalizePath(file);
|
|
115
|
+
const scannedFiles = await this.scanOnDemand(normalizedFile, resolveImport);
|
|
116
|
+
let bySpec = this.resolvedImports.get(importerKey);
|
|
117
|
+
if (!bySpec) {
|
|
118
|
+
bySpec = /* @__PURE__ */ new Map();
|
|
119
|
+
this.resolvedImports.set(importerKey, bySpec);
|
|
120
|
+
}
|
|
121
|
+
bySpec.set(spec, normalizedFile);
|
|
122
|
+
for (const scanned of scannedFiles) {
|
|
123
|
+
let importers = this.importersByFile.get(scanned);
|
|
124
|
+
if (!importers) {
|
|
125
|
+
importers = /* @__PURE__ */ new Set();
|
|
126
|
+
this.importersByFile.set(scanned, importers);
|
|
127
|
+
}
|
|
128
|
+
importers.add(id);
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolves the registry entry for an imported or global Angular declaration.
|
|
134
|
+
* When `context` gives the importing file and module specifier, exported
|
|
135
|
+
* bindings on the resolved module (including barrel re-exports) are followed
|
|
136
|
+
* before falling back to the global registry.
|
|
137
|
+
*/
|
|
138
|
+
lookupEntry(className, external = [], context) {
|
|
139
|
+
if (context?.moduleSpecifier && context.containingFile) {
|
|
140
|
+
const targetFile = this.resolvedImports.get(normalizePath(context.containingFile))?.get(context.moduleSpecifier);
|
|
141
|
+
if (targetFile) {
|
|
142
|
+
const match = this.resolveExportedEntry(targetFile, className, /* @__PURE__ */ new Set());
|
|
143
|
+
if (match) return match;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return this.registry.get(className) ?? external.map((r) => r.get(className)).find((e) => e !== void 0);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The element selector of a component or directive class. `external` are
|
|
150
|
+
* registries contributed through `analog.setup()`. When `context` gives the
|
|
151
|
+
* importing file and module specifier, declarations scanned from that module
|
|
152
|
+
* (and its re-exports) are checked before falling back to the global registry.
|
|
153
|
+
*/
|
|
154
|
+
lookupSelector(className, external = [], context) {
|
|
155
|
+
const entry = this.lookupEntry(className, external, context);
|
|
156
|
+
if (!entry || !isSelectableEntry(entry)) return null;
|
|
157
|
+
return entry.selector;
|
|
158
|
+
}
|
|
159
|
+
/** The files scanned for `importer`. */
|
|
160
|
+
dependenciesOf(importer) {
|
|
161
|
+
return [...this.importersByFile].filter(([, importers]) => importers.has(importer)).map(([file]) => file);
|
|
162
|
+
}
|
|
163
|
+
entriesOf(file) {
|
|
164
|
+
return this.entriesByFile.get(normalizePath(file)) ?? [];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Records the entries scanned from a source file in both per-file storage
|
|
168
|
+
* and the global registry.
|
|
169
|
+
*/
|
|
170
|
+
recordFileEntries(file, entries, overwrite = false) {
|
|
171
|
+
const key = normalizePath(file);
|
|
172
|
+
const previous = this.entriesByFile.get(key);
|
|
173
|
+
if (entries.length > 0) this.entriesByFile.set(key, entries);
|
|
174
|
+
else this.entriesByFile.delete(key);
|
|
175
|
+
if (previous) {
|
|
176
|
+
const nextNames = new Set(entries.map((e) => e.className));
|
|
177
|
+
for (const old of previous) if (!nextNames.has(old.className)) this.removeFromRegistryIfOwned(old.className, key);
|
|
178
|
+
}
|
|
179
|
+
for (const entry of entries) {
|
|
180
|
+
const current = this.registry.get(entry.className);
|
|
181
|
+
if (overwrite || !current || normalizePath(current.fileName) === key) this.registry.set(entry.className, entry);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** Drops what was scanned from `file`, so the next scan reads it again. */
|
|
185
|
+
invalidate(file) {
|
|
186
|
+
const key = normalizePath(file);
|
|
187
|
+
const oldEntries = this.entriesByFile.get(key) ?? [];
|
|
188
|
+
this.entriesByFile.delete(key);
|
|
189
|
+
for (const entry of oldEntries) this.removeFromRegistryIfOwned(entry.className, key);
|
|
190
|
+
this.resolvedImports.delete(key);
|
|
191
|
+
this.reExportsByFile.delete(key);
|
|
192
|
+
this.lazyScans.clear();
|
|
193
|
+
}
|
|
194
|
+
addEntry(entry) {
|
|
195
|
+
if (!this.registry.has(entry.className)) this.registry.set(entry.className, entry);
|
|
196
|
+
}
|
|
197
|
+
resolveExportedEntry(file, exportName, visited) {
|
|
198
|
+
const visitKey = `${file}\0${exportName}`;
|
|
199
|
+
if (visited.has(visitKey)) return;
|
|
200
|
+
visited.add(visitKey);
|
|
201
|
+
const exportMap = this.reExportsByFile.get(file);
|
|
202
|
+
const namedReExport = exportMap?.namedReExports.get(exportName);
|
|
203
|
+
if (namedReExport) return this.resolveExportedEntry(namedReExport.file, namedReExport.importedName, visited);
|
|
204
|
+
const entries = this.entriesByFile.get(file);
|
|
205
|
+
if (entries) {
|
|
206
|
+
if (exportName === "default") {
|
|
207
|
+
const localDefault = exportMap?.localAliases.get("default");
|
|
208
|
+
const match = entries.find((entry) => entry.isDefaultExport === true || localDefault !== void 0 && entry.className === localDefault);
|
|
209
|
+
if (match) return match;
|
|
210
|
+
} else {
|
|
211
|
+
const localName = exportMap?.localAliases.get(exportName) ?? exportName;
|
|
212
|
+
const match = entries.find((entry) => entry.className === localName);
|
|
213
|
+
if (match) return match;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (exportName !== "default" && exportMap) for (const starFile of exportMap.starReExports) {
|
|
217
|
+
const match = this.resolveExportedEntry(starFile, exportName, visited);
|
|
218
|
+
if (match) return match;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
removeFromRegistryIfOwned(className, ownerKey) {
|
|
222
|
+
const current = this.registry.get(className);
|
|
223
|
+
if (!current || normalizePath(current.fileName) !== ownerKey) return;
|
|
224
|
+
this.registry.delete(className);
|
|
225
|
+
for (const entries of this.entriesByFile.values()) {
|
|
226
|
+
const replacement = entries.find((e) => e.className === className);
|
|
227
|
+
if (replacement) {
|
|
228
|
+
this.registry.set(className, replacement);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
scanOnDemand(file, resolveImport) {
|
|
234
|
+
let scan = this.lazyScans.get(file);
|
|
235
|
+
if (!scan) {
|
|
236
|
+
scan = this.scanWithReExports(file, resolveImport);
|
|
237
|
+
this.lazyScans.set(file, scan);
|
|
238
|
+
}
|
|
239
|
+
return scan;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Scan a file and everything it re-exports, resolving specifiers through
|
|
243
|
+
* Vite so path aliases work. Tuple barrels and NgModules can list classes
|
|
244
|
+
* their file imports without re-exporting, so their imports are followed
|
|
245
|
+
* too. Returns every file scanned.
|
|
246
|
+
*/
|
|
247
|
+
async scanWithReExports(file, resolveImport) {
|
|
248
|
+
const visited = /* @__PURE__ */ new Set();
|
|
249
|
+
const visit = async (current) => {
|
|
250
|
+
const currentKey = normalizePath(current);
|
|
251
|
+
if (visited.has(currentKey)) return;
|
|
252
|
+
visited.add(currentKey);
|
|
253
|
+
let code;
|
|
254
|
+
let program;
|
|
255
|
+
try {
|
|
256
|
+
code = await this.readScanSource(currentKey);
|
|
257
|
+
program = parseOxc(currentKey, code).program;
|
|
258
|
+
} catch {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const entries = scanFile(code, currentKey, program);
|
|
262
|
+
this.recordFileEntries(currentKey, entries);
|
|
263
|
+
this.ensureDtsRegistryForSource(code, currentKey, program);
|
|
264
|
+
const specifiers = entries.some((e) => e.kind === "tuple" || e.kind === "ngmodule") ? collectAllImports(code, currentKey, program) : collectReExports(code, currentKey, program);
|
|
265
|
+
const resolvedBySpec = /* @__PURE__ */ new Map();
|
|
266
|
+
for (const spec of specifiers) {
|
|
267
|
+
if (resolvedBySpec.has(spec)) continue;
|
|
268
|
+
const dep = await resolveImport(spec, currentKey);
|
|
269
|
+
if (dep) resolvedBySpec.set(spec, normalizePath(dep));
|
|
270
|
+
}
|
|
271
|
+
const exportMap = collectFileExportMap(program, resolvedBySpec);
|
|
272
|
+
if (exportMap) this.reExportsByFile.set(currentKey, exportMap);
|
|
273
|
+
else this.reExportsByFile.delete(currentKey);
|
|
274
|
+
for (const dep of resolvedBySpec.values()) await visit(dep);
|
|
275
|
+
};
|
|
276
|
+
await visit(file);
|
|
277
|
+
return visited;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
function isSelectableEntry(entry) {
|
|
281
|
+
return entry.kind === "component" || entry.kind === "directive";
|
|
282
|
+
}
|
|
283
|
+
function moduleExportName(node) {
|
|
284
|
+
if (!node) return void 0;
|
|
285
|
+
if (node.type === "Identifier") return node.name;
|
|
286
|
+
if (node.type === "Literal" && typeof node.value === "string") return node.value;
|
|
287
|
+
}
|
|
288
|
+
function collectFileExportMap(program, resolvedBySpec) {
|
|
289
|
+
const localAliases = /* @__PURE__ */ new Map();
|
|
290
|
+
const namedReExports = /* @__PURE__ */ new Map();
|
|
291
|
+
const starReExports = [];
|
|
292
|
+
for (const stmt of program.body || []) {
|
|
293
|
+
if (stmt.exportKind === "type") continue;
|
|
294
|
+
if (stmt.type === "ExportNamedDeclaration") {
|
|
295
|
+
const source = stmt.source?.value;
|
|
296
|
+
if (!source) for (const spec of stmt.specifiers || []) {
|
|
297
|
+
if (spec.exportKind === "type") continue;
|
|
298
|
+
const localName = moduleExportName(spec.local);
|
|
299
|
+
const exportedName = moduleExportName(spec.exported);
|
|
300
|
+
if (localName && exportedName && localName !== exportedName) localAliases.set(exportedName, localName);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
const targetFile = resolvedBySpec.get(source);
|
|
304
|
+
if (!targetFile) continue;
|
|
305
|
+
for (const spec of stmt.specifiers || []) {
|
|
306
|
+
if (spec.exportKind === "type") continue;
|
|
307
|
+
const importedName = moduleExportName(spec.local);
|
|
308
|
+
const exportedName = moduleExportName(spec.exported);
|
|
309
|
+
if (importedName && exportedName) namedReExports.set(exportedName, {
|
|
310
|
+
file: targetFile,
|
|
311
|
+
importedName
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
} else if (stmt.type === "ExportAllDeclaration") {
|
|
316
|
+
if (stmt.exported) continue;
|
|
317
|
+
const source = stmt.source?.value;
|
|
318
|
+
const targetFile = source ? resolvedBySpec.get(source) : void 0;
|
|
319
|
+
if (targetFile && !starReExports.includes(targetFile)) starReExports.push(targetFile);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (localAliases.size === 0 && namedReExports.size === 0 && starReExports.length === 0) return null;
|
|
323
|
+
return {
|
|
324
|
+
localAliases,
|
|
325
|
+
namedReExports,
|
|
326
|
+
starReExports
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
export { ComponentScanner };
|
|
330
|
+
|
|
331
|
+
//# sourceMappingURL=component-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-scanner.js","names":["fsPromises"],"sources":["../../../src/lib/component-scanner.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport type { parseSync } from 'oxc-parser';\nimport { normalizePath } from 'vite';\n\nimport type { ComponentRegistryEntries } from './analog-plugin-interop.js';\nimport {\n collectAllImports,\n collectImportedPackages,\n collectReExports,\n scanFile,\n scanPackageDts,\n type ComponentRegistry,\n type RegistryEntry,\n} from './compiler/index.js';\nimport { parseOxc } from './compiler/utils.js';\nimport type {\n FastCompileResolve,\n FastCompileSourceFormat,\n} from './fast-compile-api.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\ntype OxcProgram = ReturnType<typeof parseSync>['program'];\n\n/** Resolves an import to a source file to scan, or `null` to skip it. */\nexport type ResolveImport = (\n spec: string,\n importer: string,\n) => Promise<string | null>;\n\n/** Optional import site context for module-scoped selector lookup. */\nexport interface SelectorLookupContext {\n moduleSpecifier?: string;\n containingFile?: string;\n}\n\ninterface ReExportTarget {\n file: string;\n importedName: string;\n}\n\ninterface FileExportMap {\n /** `export { LocalName as ExportedName }` for declarations in this file. */\n localAliases: Map<string, string>;\n /** `export { ImportedName as ExportedName } from './target'`. */\n namedReExports: Map<string, ReExportTarget>;\n /** `export * from './target'` (excluding `export * as ns from`). */\n starReExports: string[];\n}\n\n/**\n * Angular classes scanned from source files and package `.d.ts` declarations,\n * so source formats can look up the selectors of the components they import\n * before any compiler sees their modules. Shared by the fast compile and NGP\n * plugins.\n */\nexport class ComponentScanner {\n readonly registry: ComponentRegistry = new Map();\n readonly scannedDtsPackages: Set<string> = new Set();\n /** Files scanned on demand, mapped to the barrel chain each pulled in. */\n readonly lazyScans: Map<string, Promise<Set<string>>> = new Map();\n /** Modules compiled against each scanned file. */\n readonly importersByFile: Map<string, Set<string>> = new Map();\n /** Entries declared in each scanned source file, keyed by normalized path. */\n private readonly entriesByFile: Map<string, RegistryEntry[]> = new Map();\n /** Direct resolved target file per importer and module specifier. */\n private readonly resolvedImports: Map<string, Map<string, string>> =\n new Map();\n /** Export aliases and re-export bindings per scanned file, keyed by normalized path. */\n private readonly reExportsByFile: Map<string, FileExportMap> = new Map();\n private readonly sourceFormats: FastCompileSourceFormat[] = [];\n private root = '';\n\n /** Where package declarations are looked up from. */\n get projectRoot(): string {\n return this.root;\n }\n\n reset(projectRoot: string): void {\n this.root = projectRoot;\n this.registry.clear();\n this.scannedDtsPackages.clear();\n this.lazyScans.clear();\n this.importersByFile.clear();\n this.entriesByFile.clear();\n this.resolvedImports.clear();\n this.reExportsByFile.clear();\n }\n\n registerSourceFormat(format: FastCompileSourceFormat): void {\n if (!this.sourceFormats.includes(format)) {\n this.sourceFormats.push(format);\n }\n }\n\n sourceFormatOf(file: string): FastCompileSourceFormat | undefined {\n const path = file.split('?')[0];\n return this.sourceFormats.find((format) => format.test(path));\n }\n\n /** Whether `file` is TypeScript or a module of a registered source format. */\n isCompiledSource(file: string): boolean {\n return TS_EXT_REGEX.test(file) || this.sourceFormatOf(file) !== undefined;\n }\n\n /**\n * Reads a source file for scanning. Modules of a registered source format\n * are converted to TypeScript first so the scanner sees their classes.\n */\n async readScanSource(file: string): Promise<string> {\n const code = await fsPromises.readFile(file, 'utf-8');\n const format = this.sourceFormatOf(file);\n return format ? format.toScanSource(code, file) : code;\n }\n\n /**\n * Adapts a Vite-style resolver to the scanner's: only source files this\n * scanner reads, outside `node_modules` (package declarations come from the\n * `.d.ts` scanner instead).\n */\n toResolveImport(resolve: FastCompileResolve): ResolveImport {\n return async (spec, importer) => {\n const resolved = await resolve(spec, importer);\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n return this.isCompiledSource(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n };\n }\n\n /** Scans the `.d.ts` declarations of `packages` into the registry, once each. */\n ensureDtsRegistryForPackages(packages: Iterable<string>): void {\n for (const pkg of packages) {\n if (this.scannedDtsPackages.has(pkg)) continue;\n this.scannedDtsPackages.add(pkg);\n try {\n const dtsEntries = scanPackageDts(\n pkg,\n // Before a tsconfig resolves, look up packages from the working directory.\n this.root || process.cwd(),\n this.scannedDtsPackages,\n );\n for (const entry of dtsEntries) {\n this.addEntry(entry);\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: OxcProgram,\n ): void {\n this.ensureDtsRegistryForPackages(\n collectImportedPackages(code, id, program),\n );\n }\n\n /**\n * Scans the modules behind `specifiers`, imported by `importer`: packages\n * from their `.d.ts` declarations, everything else from source.\n */\n scanImports(\n specifiers: string[],\n importer: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n this.ensureDtsRegistryForPackages(\n specifiers\n .filter((spec) => !spec.startsWith('.') && !spec.startsWith('/'))\n .map((spec) => {\n const parts = spec.split('/');\n return spec.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n }),\n );\n return this.resolveImportSpecifiers(\n specifiers,\n importer,\n this.toResolveImport(resolve),\n );\n }\n\n /**\n * Scans the files behind `specs`, imported by `id`, into the registry and\n * records `id` as their importer.\n */\n async resolveImportSpecifiers(\n specs: string[],\n id: string,\n resolveImport: ResolveImport,\n ): Promise<void> {\n const importerKey = normalizePath(id);\n await Promise.all(\n specs.map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) {\n this.resolvedImports.get(importerKey)?.delete(spec);\n return;\n }\n const normalizedFile = normalizePath(file);\n const scannedFiles = await this.scanOnDemand(\n normalizedFile,\n resolveImport,\n );\n let bySpec = this.resolvedImports.get(importerKey);\n if (!bySpec) {\n bySpec = new Map();\n this.resolvedImports.set(importerKey, bySpec);\n }\n bySpec.set(spec, normalizedFile);\n for (const scanned of scannedFiles) {\n let importers = this.importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n this.importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n /**\n * Resolves the registry entry for an imported or global Angular declaration.\n * When `context` gives the importing file and module specifier, exported\n * bindings on the resolved module (including barrel re-exports) are followed\n * before falling back to the global registry.\n */\n lookupEntry(\n className: string,\n external: readonly ComponentRegistryEntries[] = [],\n context?: SelectorLookupContext,\n ): RegistryEntry | undefined {\n if (context?.moduleSpecifier && context.containingFile) {\n const targetFile = this.resolvedImports\n .get(normalizePath(context.containingFile))\n ?.get(context.moduleSpecifier);\n if (targetFile) {\n const match = this.resolveExportedEntry(\n targetFile,\n className,\n new Set(),\n );\n if (match) {\n return match;\n }\n }\n }\n\n return (\n this.registry.get(className) ??\n external.map((r) => r.get(className)).find((e) => e !== undefined)\n );\n }\n\n /**\n * The element selector of a component or directive class. `external` are\n * registries contributed through `analog.setup()`. When `context` gives the\n * importing file and module specifier, declarations scanned from that module\n * (and its re-exports) are checked before falling back to the global registry.\n */\n lookupSelector(\n className: string,\n external: readonly ComponentRegistryEntries[] = [],\n context?: SelectorLookupContext,\n ): string | null {\n const entry = this.lookupEntry(className, external, context);\n if (!entry || !isSelectableEntry(entry)) {\n return null;\n }\n return entry.selector;\n }\n\n /** The files scanned for `importer`. */\n dependenciesOf(importer: string): string[] {\n return [...this.importersByFile]\n .filter(([, importers]) => importers.has(importer))\n .map(([file]) => file);\n }\n\n entriesOf(file: string): RegistryEntry[] {\n return this.entriesByFile.get(normalizePath(file)) ?? [];\n }\n\n /**\n * Records the entries scanned from a source file in both per-file storage\n * and the global registry.\n */\n recordFileEntries(\n file: string,\n entries: RegistryEntry[],\n overwrite = false,\n ): void {\n const key = normalizePath(file);\n const previous = this.entriesByFile.get(key);\n if (entries.length > 0) {\n this.entriesByFile.set(key, entries);\n } else {\n this.entriesByFile.delete(key);\n }\n if (previous) {\n const nextNames = new Set(entries.map((e) => e.className));\n for (const old of previous) {\n if (!nextNames.has(old.className)) {\n this.removeFromRegistryIfOwned(old.className, key);\n }\n }\n }\n for (const entry of entries) {\n const current = this.registry.get(entry.className);\n if (overwrite || !current || normalizePath(current.fileName) === key) {\n this.registry.set(entry.className, entry);\n }\n }\n }\n\n /** Drops what was scanned from `file`, so the next scan reads it again. */\n invalidate(file: string): void {\n const key = normalizePath(file);\n const oldEntries = this.entriesByFile.get(key) ?? [];\n this.entriesByFile.delete(key);\n for (const entry of oldEntries) {\n this.removeFromRegistryIfOwned(entry.className, key);\n }\n this.resolvedImports.delete(key);\n this.reExportsByFile.delete(key);\n this.lazyScans.clear();\n }\n\n private addEntry(entry: RegistryEntry): void {\n if (!this.registry.has(entry.className)) {\n this.registry.set(entry.className, entry);\n }\n }\n\n private resolveExportedEntry(\n file: string,\n exportName: string,\n visited: Set<string>,\n ): RegistryEntry | undefined {\n const visitKey = `${file}\\0${exportName}`;\n if (visited.has(visitKey)) {\n return undefined;\n }\n visited.add(visitKey);\n\n const exportMap = this.reExportsByFile.get(file);\n const namedReExport = exportMap?.namedReExports.get(exportName);\n if (namedReExport) {\n return this.resolveExportedEntry(\n namedReExport.file,\n namedReExport.importedName,\n visited,\n );\n }\n\n const entries = this.entriesByFile.get(file);\n if (entries) {\n if (exportName === 'default') {\n const localDefault = exportMap?.localAliases.get('default');\n const match = entries.find(\n (entry) =>\n entry.isDefaultExport === true ||\n (localDefault !== undefined && entry.className === localDefault),\n );\n if (match) {\n return match;\n }\n } else {\n const localName = exportMap?.localAliases.get(exportName) ?? exportName;\n const match = entries.find((entry) => entry.className === localName);\n if (match) {\n return match;\n }\n }\n }\n\n if (exportName !== 'default' && exportMap) {\n for (const starFile of exportMap.starReExports) {\n const match = this.resolveExportedEntry(starFile, exportName, visited);\n if (match) {\n return match;\n }\n }\n }\n\n return undefined;\n }\n\n private removeFromRegistryIfOwned(className: string, ownerKey: string): void {\n const current = this.registry.get(className);\n if (!current || normalizePath(current.fileName) !== ownerKey) {\n return;\n }\n this.registry.delete(className);\n for (const entries of this.entriesByFile.values()) {\n const replacement = entries.find((e) => e.className === className);\n if (replacement) {\n this.registry.set(className, replacement);\n break;\n }\n }\n }\n\n private scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = this.lazyScans.get(file);\n if (!scan) {\n scan = this.scanWithReExports(file, resolveImport);\n this.lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n private async scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n const currentKey = normalizePath(current);\n if (visited.has(currentKey)) return;\n visited.add(currentKey);\n let code: string;\n let program: OxcProgram;\n try {\n code = await this.readScanSource(currentKey);\n program = parseOxc(currentKey, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, currentKey, program);\n this.recordFileEntries(currentKey, entries);\n this.ensureDtsRegistryForSource(code, currentKey, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, currentKey, program)\n : collectReExports(code, currentKey, program);\n\n const resolvedBySpec = new Map<string, string>();\n for (const spec of specifiers) {\n if (resolvedBySpec.has(spec)) continue;\n const dep = await resolveImport(spec, currentKey);\n if (dep) resolvedBySpec.set(spec, normalizePath(dep));\n }\n\n const exportMap = collectFileExportMap(program, resolvedBySpec);\n if (exportMap) {\n this.reExportsByFile.set(currentKey, exportMap);\n } else {\n this.reExportsByFile.delete(currentKey);\n }\n\n for (const dep of resolvedBySpec.values()) {\n await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n}\n\nfunction isSelectableEntry(entry: RegistryEntry): boolean {\n return entry.kind === 'component' || entry.kind === 'directive';\n}\n\nfunction moduleExportName(node: any): string | undefined {\n if (!node) return undefined;\n if (node.type === 'Identifier') return node.name;\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n return undefined;\n}\n\nfunction collectFileExportMap(\n program: OxcProgram,\n resolvedBySpec: Map<string, string>,\n): FileExportMap | null {\n const localAliases = new Map<string, string>();\n const namedReExports = new Map<string, ReExportTarget>();\n const starReExports: string[] = [];\n\n for (const stmt of program.body || []) {\n if ((stmt as any).exportKind === 'type') continue;\n if (stmt.type === 'ExportNamedDeclaration') {\n const source: string | undefined = stmt.source?.value;\n if (!source) {\n for (const spec of (stmt as any).specifiers || []) {\n if (spec.exportKind === 'type') continue;\n const localName = moduleExportName(spec.local);\n const exportedName = moduleExportName(spec.exported);\n if (localName && exportedName && localName !== exportedName) {\n localAliases.set(exportedName, localName);\n }\n }\n } else {\n const targetFile = resolvedBySpec.get(source);\n if (!targetFile) continue;\n for (const spec of (stmt as any).specifiers || []) {\n if (spec.exportKind === 'type') continue;\n const importedName = moduleExportName(spec.local);\n const exportedName = moduleExportName(spec.exported);\n if (importedName && exportedName) {\n namedReExports.set(exportedName, {\n file: targetFile,\n importedName,\n });\n }\n }\n }\n } else if (stmt.type === 'ExportAllDeclaration') {\n if ((stmt as any).exported) continue;\n const source: string | undefined = stmt.source?.value;\n const targetFile = source ? resolvedBySpec.get(source) : undefined;\n if (targetFile && !starReExports.includes(targetFile)) {\n starReExports.push(targetFile);\n }\n }\n }\n\n if (\n localAliases.size === 0 &&\n namedReExports.size === 0 &&\n starReExports.length === 0\n ) {\n return null;\n }\n return { localAliases, namedReExports, starReExports };\n}\n"],"mappings":";;;;;;;;;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAC5B,2BAAuC,IAAI,IAAI;CAC/C,qCAA2C,IAAI,IAAI;;CAEnD,4BAAwD,IAAI,IAAI;;CAEhE,kCAAqD,IAAI,IAAI;;CAE7D,gCAA+D,IAAI,IAAI;;CAEvE,kCACE,IAAI,IAAI;;CAEV,kCAA+D,IAAI,IAAI;CACvE,gBAA4D,CAAC;CAC7D,OAAe;;CAGf,IAAI,cAAsB;EACxB,OAAO,KAAK;CACd;CAEA,MAAM,aAA2B;EAC/B,KAAK,OAAO;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,mBAAmB,MAAM;EAC9B,KAAK,UAAU,MAAM;EACrB,KAAK,gBAAgB,MAAM;EAC3B,KAAK,cAAc,MAAM;EACzB,KAAK,gBAAgB,MAAM;EAC3B,KAAK,gBAAgB,MAAM;CAC7B;CAEA,qBAAqB,QAAuC;EAC1D,IAAI,CAAC,KAAK,cAAc,SAAS,MAAM,GACrC,KAAK,cAAc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