@analogjs/vite-plugin-angular 3.0.0-beta.6 → 3.0.0-beta.61
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 +7 -1
- package/src/lib/compiler/registry.js +24 -5
- 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 +74 -0
- package/src/lib/component-scanner.js +177 -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 +169 -110
- 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 +672 -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,7 +1,7 @@
|
|
|
1
1
|
import { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog } from "./debug-log-file.js";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { enable } from "obug";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
|
|
5
5
|
/**
|
|
6
6
|
* Duplicates of this file (keep in sync):
|
|
7
7
|
* packages/platform/src/lib/utils/debug-harness.ts
|
|
@@ -82,7 +82,6 @@ function createDebugHarness(config) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
//#endregion
|
|
86
85
|
export { createDebugHarness };
|
|
87
86
|
|
|
88
87
|
//# sourceMappingURL=debug-harness.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { format } from "node:util";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
|
|
5
5
|
/**
|
|
6
6
|
* Duplicates of this file (keep in sync):
|
|
7
7
|
* packages/platform/src/lib/utils/debug-log-file.ts
|
|
@@ -51,7 +51,6 @@ function wrapInstancesForScopedFileLog(instances, dirPath) {
|
|
|
51
51
|
wrapLog(dbg, scopedPath);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=debug-log-file.js.map
|
package/src/lib/utils/debug.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createDebugHarness } from "./debug-harness.js";
|
|
2
2
|
import { createDebug } from "obug";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-angular/src/lib/utils/debug.ts
|
|
4
4
|
var debugHmr = createDebug("analog:angular:hmr");
|
|
5
5
|
var debugStyles = createDebug("analog:angular:styles");
|
|
6
6
|
var debugCompiler = createDebug("analog:angular:compiler");
|
|
@@ -29,7 +29,6 @@ var harness = createDebugHarness({
|
|
|
29
29
|
var applyDebugOption = harness.applyDebugOption;
|
|
30
30
|
var activateDeferredDebug = harness.activateDeferredDebug;
|
|
31
31
|
harness._resetDeferredDebug;
|
|
32
|
-
//#endregion
|
|
33
32
|
export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStylePipeline, debugStyles, debugStylesV };
|
|
34
33
|
|
|
35
34
|
//# sourceMappingURL=debug.js.map
|
package/src/lib/utils/devkit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { dirname, join } from "node:path";
|
|
2
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
3
|
import { VERSION } from "@angular/compiler-cli";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-angular/src/lib/utils/devkit.ts
|
|
5
5
|
var require = createRequire(import.meta.url);
|
|
6
6
|
var angularMajor = Number(VERSION.major);
|
|
7
7
|
var angularMinor = Number(VERSION.minor);
|
|
@@ -51,7 +51,6 @@ var JavaScriptTransformer = class extends AngularJavaScriptTransformerClass {
|
|
|
51
51
|
return super.close();
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
//#endregion
|
|
55
54
|
export { JavaScriptTransformer, SourceFileCache, angularFullVersion, angularMajor, angularMinor, angularPatch, createAngularCompilation, createJitResourceTransformer };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=devkit.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies the Angular CLI's HMR rule to an edited file. Returns the
|
|
3
|
+
* components whose `template`, `templateUrl`, `styles`, `styleUrl` or
|
|
4
|
+
* `stylesUrl` fields are the only changes, or `null` when the edit
|
|
5
|
+
* needs a full reload.
|
|
6
|
+
*/
|
|
7
|
+
export declare function findHmrComponentUpdates(filename: string, staleText: string, updatedText: string, components: ReadonlySet<string>): string[] | null;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { parseSync } from "oxc-parser";
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/utils/hmr-component-updates.ts
|
|
3
|
+
var HMR_FIELDS = /* @__PURE__ */ new Set([
|
|
4
|
+
"template",
|
|
5
|
+
"templateUrl",
|
|
6
|
+
"styles",
|
|
7
|
+
"styleUrl",
|
|
8
|
+
"stylesUrl"
|
|
9
|
+
]);
|
|
10
|
+
function parse(filename, text) {
|
|
11
|
+
const { program, errors } = parseSync(filename, text);
|
|
12
|
+
return errors.length ? null : {
|
|
13
|
+
text,
|
|
14
|
+
body: program.body
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function classOf(statement) {
|
|
18
|
+
if (statement.type === "ClassDeclaration") return statement;
|
|
19
|
+
return statement.declaration?.type === "ClassDeclaration" ? statement.declaration : void 0;
|
|
20
|
+
}
|
|
21
|
+
function statementStart(statement) {
|
|
22
|
+
return Math.min(statement.start, classOf(statement)?.decorators[0]?.start ?? statement.start);
|
|
23
|
+
}
|
|
24
|
+
function statementText(source, statement) {
|
|
25
|
+
return source.text.slice(statementStart(statement), statement.end);
|
|
26
|
+
}
|
|
27
|
+
function classHeader(source, statement, cls) {
|
|
28
|
+
const [decorator] = cls.decorators;
|
|
29
|
+
return source.text.slice(statementStart(statement), decorator.start) + source.text.slice(decorator.end, cls.body.start) + source.text.slice(cls.body.end, statement.end);
|
|
30
|
+
}
|
|
31
|
+
function decoratorMetadata(source, decorator) {
|
|
32
|
+
const call = decorator.expression;
|
|
33
|
+
const metadata = call.arguments?.[0];
|
|
34
|
+
if (call.arguments?.length !== 1 || metadata.type !== "ObjectExpression") return null;
|
|
35
|
+
const fields = [];
|
|
36
|
+
for (const property of metadata.properties) {
|
|
37
|
+
if (property.type !== "Property" || property.kind !== "init" || property.computed || property.shorthand || property.method) return null;
|
|
38
|
+
fields.push([String(property.key.name ?? property.key.value), source.text.slice(property.value.start, property.value.end)]);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
callee: source.text.slice(call.callee.start, call.callee.end),
|
|
42
|
+
fields
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function fieldsText(fields, hmr) {
|
|
46
|
+
const selected = fields.filter(([name]) => HMR_FIELDS.has(name) === hmr);
|
|
47
|
+
if (hmr) selected.sort(([a], [b]) => a.localeCompare(b));
|
|
48
|
+
return JSON.stringify(selected);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether a component changed only in its HMR fields, or `null` when
|
|
52
|
+
* anything else in the statement changed.
|
|
53
|
+
*/
|
|
54
|
+
function componentChanged(stale, staleStatement, updated, updatedStatement) {
|
|
55
|
+
const staleClass = classOf(staleStatement);
|
|
56
|
+
const updatedClass = classOf(updatedStatement);
|
|
57
|
+
if (staleStatement.type !== updatedStatement.type || staleClass?.decorators.length !== 1 || updatedClass.decorators.length !== 1 || classHeader(stale, staleStatement, staleClass) !== classHeader(updated, updatedStatement, updatedClass) || stale.text.slice(staleClass.body.start, staleClass.body.end) !== updated.text.slice(updatedClass.body.start, updatedClass.body.end)) return null;
|
|
58
|
+
const staleMeta = decoratorMetadata(stale, staleClass.decorators[0]);
|
|
59
|
+
const updatedMeta = decoratorMetadata(updated, updatedClass.decorators[0]);
|
|
60
|
+
if (!staleMeta || !updatedMeta || staleMeta.callee !== updatedMeta.callee || fieldsText(staleMeta.fields, false) !== fieldsText(updatedMeta.fields, false)) return null;
|
|
61
|
+
return fieldsText(staleMeta.fields, true) !== fieldsText(updatedMeta.fields, true);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Applies the Angular CLI's HMR rule to an edited file. Returns the
|
|
65
|
+
* components whose `template`, `templateUrl`, `styles`, `styleUrl` or
|
|
66
|
+
* `stylesUrl` fields are the only changes, or `null` when the edit
|
|
67
|
+
* needs a full reload.
|
|
68
|
+
*/
|
|
69
|
+
function findHmrComponentUpdates(filename, staleText, updatedText, components) {
|
|
70
|
+
const stale = parse(filename, staleText);
|
|
71
|
+
const updated = parse(filename, updatedText);
|
|
72
|
+
if (!stale || !updated || stale.body.length !== updated.body.length) return null;
|
|
73
|
+
const changed = [];
|
|
74
|
+
for (let i = 0; i < updated.body.length; i++) {
|
|
75
|
+
const name = classOf(updated.body[i])?.id?.name;
|
|
76
|
+
if (name && components.has(name)) {
|
|
77
|
+
const result = componentChanged(stale, stale.body[i], updated, updated.body[i]);
|
|
78
|
+
if (result === null) return null;
|
|
79
|
+
if (result) changed.push(name);
|
|
80
|
+
} else if (statementText(stale, stale.body[i]) !== statementText(updated, updated.body[i])) return null;
|
|
81
|
+
}
|
|
82
|
+
return changed.length ? changed : null;
|
|
83
|
+
}
|
|
84
|
+
export { findHmrComponentUpdates };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=hmr-component-updates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr-component-updates.js","names":[],"sources":["../../../../src/lib/utils/hmr-component-updates.ts"],"sourcesContent":["import { parseSync } from 'oxc-parser';\n\n// Component metadata fields the Angular CLI updates in place\nconst HMR_FIELDS = new Set([\n 'template',\n 'templateUrl',\n 'styles',\n 'styleUrl',\n 'stylesUrl',\n]);\n\ninterface Source {\n text: string;\n body: any[];\n}\n\ntype Fields = [name: string, value: string][];\n\nfunction parse(filename: string, text: string): Source | null {\n const { program, errors } = parseSync(filename, text);\n return errors.length ? null : { text, body: program.body };\n}\n\nfunction classOf(statement: any) {\n if (statement.type === 'ClassDeclaration') return statement;\n return statement.declaration?.type === 'ClassDeclaration'\n ? statement.declaration\n : undefined;\n}\n\n// Decorators written before `export` fall outside the statement span\nfunction statementStart(statement: any) {\n return Math.min(\n statement.start,\n classOf(statement)?.decorators[0]?.start ?? statement.start,\n );\n}\n\nfunction statementText(source: Source, statement: any) {\n return source.text.slice(statementStart(statement), statement.end);\n}\n\n// The statement without its decorator and class body\nfunction classHeader(source: Source, statement: any, cls: any) {\n const [decorator] = cls.decorators;\n return (\n source.text.slice(statementStart(statement), decorator.start) +\n source.text.slice(decorator.end, cls.body.start) +\n source.text.slice(cls.body.end, statement.end)\n );\n}\n\nfunction decoratorMetadata(source: Source, decorator: any) {\n const call = decorator.expression;\n const metadata = call.arguments?.[0];\n if (call.arguments?.length !== 1 || metadata.type !== 'ObjectExpression') {\n return null;\n }\n const fields: Fields = [];\n for (const property of metadata.properties) {\n if (\n property.type !== 'Property' ||\n property.kind !== 'init' ||\n property.computed ||\n property.shorthand ||\n property.method\n ) {\n return null;\n }\n fields.push([\n String(property.key.name ?? property.key.value),\n source.text.slice(property.value.start, property.value.end),\n ]);\n }\n return {\n callee: source.text.slice(call.callee.start, call.callee.end),\n fields,\n };\n}\n\nfunction fieldsText(fields: Fields, hmr: boolean) {\n const selected = fields.filter(([name]) => HMR_FIELDS.has(name) === hmr);\n // HMR fields can move; other fields must keep their order\n if (hmr) selected.sort(([a], [b]) => a.localeCompare(b));\n return JSON.stringify(selected);\n}\n\n/**\n * Whether a component changed only in its HMR fields, or `null` when\n * anything else in the statement changed.\n */\nfunction componentChanged(\n stale: Source,\n staleStatement: any,\n updated: Source,\n updatedStatement: any,\n): boolean | null {\n const staleClass = classOf(staleStatement);\n const updatedClass = classOf(updatedStatement);\n if (\n staleStatement.type !== updatedStatement.type ||\n staleClass?.decorators.length !== 1 ||\n updatedClass.decorators.length !== 1 ||\n classHeader(stale, staleStatement, staleClass) !==\n classHeader(updated, updatedStatement, updatedClass) ||\n stale.text.slice(staleClass.body.start, staleClass.body.end) !==\n updated.text.slice(updatedClass.body.start, updatedClass.body.end)\n ) {\n return null;\n }\n const staleMeta = decoratorMetadata(stale, staleClass.decorators[0]);\n const updatedMeta = decoratorMetadata(updated, updatedClass.decorators[0]);\n if (\n !staleMeta ||\n !updatedMeta ||\n staleMeta.callee !== updatedMeta.callee ||\n fieldsText(staleMeta.fields, false) !==\n fieldsText(updatedMeta.fields, false)\n ) {\n return null;\n }\n return (\n fieldsText(staleMeta.fields, true) !== fieldsText(updatedMeta.fields, true)\n );\n}\n\n/**\n * Applies the Angular CLI's HMR rule to an edited file. Returns the\n * components whose `template`, `templateUrl`, `styles`, `styleUrl` or\n * `stylesUrl` fields are the only changes, or `null` when the edit\n * needs a full reload.\n */\nexport function findHmrComponentUpdates(\n filename: string,\n staleText: string,\n updatedText: string,\n components: ReadonlySet<string>,\n): string[] | null {\n const stale = parse(filename, staleText);\n const updated = parse(filename, updatedText);\n if (!stale || !updated || stale.body.length !== updated.body.length) {\n return null;\n }\n const changed: string[] = [];\n for (let i = 0; i < updated.body.length; i++) {\n const name = classOf(updated.body[i])?.id?.name;\n if (name && components.has(name)) {\n const result = componentChanged(\n stale,\n stale.body[i],\n updated,\n updated.body[i],\n );\n if (result === null) return null;\n if (result) changed.push(name);\n } else if (\n statementText(stale, stale.body[i]) !==\n statementText(updated, updated.body[i])\n ) {\n return null;\n }\n }\n return changed.length ? changed : null;\n}\n"],"mappings":";;AAGA,IAAM,6BAAa,IAAI,IAAI;CACzB;CACA;CACA;CACA;CACA;AACF,CAAC;AASD,SAAS,MAAM,UAAkB,MAA6B;CAC5D,MAAM,EAAE,SAAS,WAAW,UAAU,UAAU,IAAI;CACpD,OAAO,OAAO,SAAS,OAAO;EAAE;EAAM,MAAM,QAAQ;CAAK;AAC3D;AAEA,SAAS,QAAQ,WAAgB;CAC/B,IAAI,UAAU,SAAS,oBAAoB,OAAO;CAClD,OAAO,U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5B,IAAI,QAAQ,QAAQ,KAAK,IAAI;EAC/B,OAAO,IACL,cAAc,OAAO,MAAM,KAAK,EAAE,MAClC,cAAc,SAAS,QAAQ,KAAK,EAAE,GAEtC,OAAO;CAEX;CACA,OAAO,QAAQ,SAAS,UAAU;AACpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/utils/jit-inline-styles.ts
|
|
3
3
|
var JIT_INLINE_STYLE_PREFIX = "virtual:angular:jit:style:inline;";
|
|
4
4
|
var inlineStyles = /* @__PURE__ */ new Map();
|
|
5
5
|
function toJitInlineStyleId(encodedStyles, isTest) {
|
|
@@ -14,7 +14,6 @@ function getJitInlineStyles(idSuffix) {
|
|
|
14
14
|
function hashJitInlineStyles(encodedStyles) {
|
|
15
15
|
return createHash("sha256").update(encodedStyles).digest("hex").slice(0, 16);
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { JIT_INLINE_STYLE_PREFIX, getJitInlineStyles, hashJitInlineStyles, toJitInlineStyleId };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=jit-inline-styles.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface TcbTemplateSource {
|
|
2
|
+
templateFile?: string;
|
|
3
|
+
templateExpression?: {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
type TemplateSources = Record<string, TcbTemplateSource>;
|
|
9
|
+
interface TcbLineRange {
|
|
10
|
+
startLine: number;
|
|
11
|
+
endLine: number;
|
|
12
|
+
filePath: string;
|
|
13
|
+
sourceCode: string;
|
|
14
|
+
templateSources: TemplateSources;
|
|
15
|
+
}
|
|
16
|
+
/** NGP's footer comment mapping TCB ids to the template they were generated from. */
|
|
17
|
+
export declare const TCB_TEMPLATE_SOURCES_PREFIX = "ngp-tcb-template-sources:";
|
|
18
|
+
export declare function readSpanComment(value: string): {
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
} | null;
|
|
22
|
+
export type TypeCheckerOption = "tsgo" | "tsrs" | {
|
|
23
|
+
command: string;
|
|
24
|
+
args?: string[];
|
|
25
|
+
};
|
|
26
|
+
interface TypeCheckerCommand {
|
|
27
|
+
command: string;
|
|
28
|
+
args: string[];
|
|
29
|
+
}
|
|
30
|
+
/** LSP `FileChangeType`: 1 created, 2 changed, 3 deleted. */
|
|
31
|
+
export type FileChangeType = 1 | 2 | 3;
|
|
32
|
+
/** A reported location, with a one-based line and character. */
|
|
33
|
+
export interface SourceLocation {
|
|
34
|
+
file: string;
|
|
35
|
+
line: number;
|
|
36
|
+
character: number;
|
|
37
|
+
}
|
|
38
|
+
/** Hooks for checking files that don't exist on disk. */
|
|
39
|
+
export interface LspTypeCheckerHost {
|
|
40
|
+
/**
|
|
41
|
+
* The text of files that exist only in memory, by normalized path. They're
|
|
42
|
+
* opened before any check, so imports of them resolve.
|
|
43
|
+
*/
|
|
44
|
+
inMemoryFiles(): ReadonlyMap<string, string>;
|
|
45
|
+
/** Maps a reported location to the source it was generated from. */
|
|
46
|
+
mapLocation(location: SourceLocation): SourceLocation;
|
|
47
|
+
}
|
|
48
|
+
export declare function resolveTypeChecker(tsconfig: string, option: TypeCheckerOption): TypeCheckerCommand;
|
|
49
|
+
export declare class LspTypeChecker {
|
|
50
|
+
private readonly host?;
|
|
51
|
+
private proc;
|
|
52
|
+
private seq;
|
|
53
|
+
private pending;
|
|
54
|
+
private versions;
|
|
55
|
+
private queued;
|
|
56
|
+
/** The text last sent for each open in-memory file. */
|
|
57
|
+
private inMemoryText;
|
|
58
|
+
private buffer;
|
|
59
|
+
private exitError;
|
|
60
|
+
readonly ready: Promise<void>;
|
|
61
|
+
constructor(tsconfig: string, option?: TypeCheckerOption, host?: LspTypeCheckerHost);
|
|
62
|
+
private onData;
|
|
63
|
+
private send;
|
|
64
|
+
private notify;
|
|
65
|
+
private request;
|
|
66
|
+
updateDocument(filePath: string, text: string);
|
|
67
|
+
checkFile(filePath: string, sourceLineCount?: number, lines?: string[], tcbRanges?: TcbLineRange[], inMemory?: boolean): Promise<string[]>;
|
|
68
|
+
private formatLocation;
|
|
69
|
+
/** Reports a change on disk; an open copy is closed so the checker rereads the file. */
|
|
70
|
+
notifyFileChanged(filePath: string, type: FileChangeType);
|
|
71
|
+
queueFile(filePath: string, sourceCode: string, tcbCode?: string | null);
|
|
72
|
+
flushQueue(watchMode?: boolean): Promise<string[]>;
|
|
73
|
+
close();
|
|
74
|
+
}
|
|
75
|
+
export {};
|