@analogjs/vite-plugin-angular 2.0.0-alpha.2 → 2.0.0-alpha.21

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.
Files changed (69) hide show
  1. package/README.md +2 -0
  2. package/package.json +8 -4
  3. package/src/index.d.ts +0 -2
  4. package/src/index.js +0 -2
  5. package/src/index.js.map +1 -1
  6. package/src/lib/angular-pending-tasks.plugin.js +3 -2
  7. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  8. package/src/lib/angular-storybook-plugin.d.ts +2 -2
  9. package/src/lib/angular-storybook-plugin.js +11 -4
  10. package/src/lib/angular-storybook-plugin.js.map +1 -1
  11. package/src/lib/angular-vite-plugin.d.ts +17 -22
  12. package/src/lib/angular-vite-plugin.js +378 -210
  13. package/src/lib/angular-vite-plugin.js.map +1 -1
  14. package/src/lib/angular-vitest-plugin.js +1 -6
  15. package/src/lib/angular-vitest-plugin.js.map +1 -1
  16. package/src/lib/component-resolvers.js +1 -1
  17. package/src/lib/component-resolvers.js.map +1 -1
  18. package/src/lib/host.d.ts +4 -7
  19. package/src/lib/host.js +47 -80
  20. package/src/lib/host.js.map +1 -1
  21. package/src/lib/live-reload-plugin.d.ts +6 -0
  22. package/src/lib/live-reload-plugin.js +63 -0
  23. package/src/lib/live-reload-plugin.js.map +1 -0
  24. package/src/lib/models.d.ts +11 -0
  25. package/src/lib/models.js +2 -0
  26. package/src/lib/models.js.map +1 -0
  27. package/src/lib/nx-folder-plugin.d.ts +7 -0
  28. package/src/lib/nx-folder-plugin.js +18 -0
  29. package/src/lib/nx-folder-plugin.js.map +1 -0
  30. package/src/lib/tools/README.md +3 -0
  31. package/src/lib/tools/builders.json +15 -0
  32. package/src/lib/tools/package.json +8 -0
  33. package/src/lib/tools/src/builders/vite/schema.d.ts +6 -0
  34. package/src/lib/tools/src/builders/vite/schema.json +39 -0
  35. package/src/lib/tools/src/builders/vite/vite-build.impl.d.ts +2 -0
  36. package/src/lib/tools/src/builders/vite/vite-build.impl.js +38 -0
  37. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -0
  38. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.d.ts +2 -0
  39. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +62 -0
  40. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -0
  41. package/src/lib/tools/src/builders/vite-dev-server/schema.d.ts +5 -0
  42. package/src/lib/tools/src/builders/vite-dev-server/schema.json +25 -0
  43. package/src/lib/tools/src/index.d.ts +0 -0
  44. package/src/lib/tools/src/index.js +1 -0
  45. package/src/lib/tools/src/index.js.map +1 -0
  46. package/src/lib/utils/devkit.js +3 -11
  47. package/src/lib/utils/devkit.js.map +1 -1
  48. package/src/lib/utils/hmr-candidates.d.ts +32 -0
  49. package/src/lib/utils/hmr-candidates.js +272 -0
  50. package/src/lib/utils/hmr-candidates.js.map +1 -0
  51. package/src/lib/utils/source-file-cache.d.ts +2 -2
  52. package/esbuild.d.ts +0 -3
  53. package/esbuild.js +0 -31
  54. package/esbuild.js.map +0 -1
  55. package/src/lib/authoring/analog.d.ts +0 -1
  56. package/src/lib/authoring/analog.js +0 -550
  57. package/src/lib/authoring/analog.js.map +0 -1
  58. package/src/lib/authoring/constants.d.ts +0 -26
  59. package/src/lib/authoring/constants.js +0 -47
  60. package/src/lib/authoring/constants.js.map +0 -1
  61. package/src/lib/authoring/frontmatter.d.ts +0 -2
  62. package/src/lib/authoring/frontmatter.js +0 -26
  63. package/src/lib/authoring/frontmatter.js.map +0 -1
  64. package/src/lib/authoring/markdown-transform.d.ts +0 -4
  65. package/src/lib/authoring/markdown-transform.js +0 -14
  66. package/src/lib/authoring/markdown-transform.js.map +0 -1
  67. package/src/lib/authoring/marked-setup.service.d.ts +0 -23
  68. package/src/lib/authoring/marked-setup.service.js +0 -119
  69. package/src/lib/authoring/marked-setup.service.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-build.impl.js","sourceRoot":"","sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAInC,KAAK,UAAU,WAAW,CACxB,OAAwB,EACxB,OAAuB;IAEvB,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;IACpE,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3C,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,aAAa,IAAI,YAAY,CAAC;IACpE,MAAM,oBAAoB,GAAG,KAAK,aAAa,EAAE,CAAC;IAClD,MAAM,WAAW,GAAG,sBAAsB,CACxC,oBAAoB,EACpB,WAAW,EACX,OAAO,CACR,CAAC;IAEF,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,eAAe,CAChD,eAAe,EACf,kBAAkB,CACnB,CAAC;IAEF,MAAM,WAAW,GAAiB;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,IAAI,EAAE,aAAa,CAAC,IAAc;QAClC,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;YACzB,YAAY,CAAC,IAAI;YACjB,aAAa,CAAW;QAC1B,KAAK,EAAE;YACL,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS;SACpC;KACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACxD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEzB,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;AACH,CAAC;AAED,eAAe,aAAa,CAAC,WAAW,CAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
2
+ async function viteDevServerBuilder(options, context) {
3
+ const { createServer } = await Function('return import("vite")')();
4
+ const projectConfig = await context.getProjectMetadata(context.target);
5
+ const projectName = context.target.project;
6
+ const buildTargetSpecifier = options.buildTarget ?? `::development`;
7
+ const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
8
+ const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
9
+ const rawBuildOptions = await context.getTargetOptions(buildTarget);
10
+ const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
11
+ const serverConfig = {
12
+ configFile: buildOptions.configFile,
13
+ root: projectConfig.root,
14
+ mode: (process.env.NODE_ENV ??
15
+ buildOptions.mode ??
16
+ 'development'),
17
+ build: {
18
+ sourcemap: !!buildOptions.sourcemap,
19
+ },
20
+ server: {
21
+ hmr: options?.hmr,
22
+ port: options?.port,
23
+ },
24
+ };
25
+ try {
26
+ const server = await createServer(serverConfig);
27
+ await runViteDevServer(server);
28
+ const resolvedUrls = [
29
+ ...server.resolvedUrls.local,
30
+ ...server.resolvedUrls.network,
31
+ ];
32
+ await new Promise((resolve) => {
33
+ process.once('SIGINT', () => resolve());
34
+ process.once('SIGTERM', () => resolve());
35
+ process.once('exit', () => resolve());
36
+ });
37
+ return {
38
+ success: true,
39
+ baseUrl: resolvedUrls[0] ?? '',
40
+ };
41
+ }
42
+ catch (e) {
43
+ console.error(e);
44
+ return {
45
+ success: false,
46
+ baseUrl: '',
47
+ };
48
+ }
49
+ }
50
+ // vite ViteDevServer
51
+ async function runViteDevServer(server) {
52
+ await server.listen();
53
+ server.printUrls();
54
+ const processOnExit = async () => {
55
+ await server.close();
56
+ };
57
+ process.once('SIGINT', processOnExit);
58
+ process.once('SIGTERM', processOnExit);
59
+ process.once('exit', processOnExit);
60
+ }
61
+ export default createBuilder(viteDevServerBuilder);
62
+ //# sourceMappingURL=dev-server.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-server.impl.js","sourceRoot":"","sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAInC,KAAK,UAAU,oBAAoB,CACjC,OAA4B,EAC5B,OAAuB;IAEvB,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;IACnE,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3C,MAAM,oBAAoB,GAAG,OAAO,CAAC,WAAW,IAAI,eAAe,CAAC;IACpE,MAAM,WAAW,GAAG,sBAAsB,CACxC,oBAAoB,EACpB,WAAW,EACX,OAAO,CACR,CAAC;IAEF,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,eAAe,CAChD,eAAe,EACf,kBAAkB,C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C;AACH,CAAC;AAED,qBAAqB;AACrB,KAAK,UAAU,gBAAgB,CAAC,MAA2B;IACzD,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;IAEtB,MAAM,CAAC,SAAS,EAAE,CAAC;IAEnB,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACtC,CAAC;AAED,eAAe,aAAa,CAAC,oBAAoB,CAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface ViteDevServerSchema {
2
+ buildTarget: string;
3
+ port?: number;
4
+ hmr?: boolean;
5
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Vite Dev Server",
5
+ "description": "Starts a dev server using Vite.",
6
+ "type": "object",
7
+ "properties": {
8
+ "buildTarget": {
9
+ "type": "string",
10
+ "description": "Target which builds the application. Only used to retrieve the configuration as the dev-server does not build the code.",
11
+ "x-priority": "important"
12
+ },
13
+ "port": {
14
+ "type": "number",
15
+ "description": "Port to listen on.",
16
+ "x-priority": "important"
17
+ },
18
+ "hmr": {
19
+ "description": "Enable hot module replacement. For more options, use the 'hmr' option in the Vite configuration file.",
20
+ "type": "boolean"
21
+ }
22
+ },
23
+ "definitions": {},
24
+ "required": ["buildTarget"]
25
+ }
File without changes
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/vite-plugin-angular-tools/src/index.ts"],"names":[],"mappings":""}
@@ -8,18 +8,10 @@ const angularPatch = Number(VERSION.patch);
8
8
  let sourceFileCache;
9
9
  let cjt;
10
10
  let jt;
11
- if (angularMajor < 15) {
12
- throw new Error('AnalogJS is not compatible with Angular v14 and lower');
11
+ if (angularMajor < 17) {
12
+ throw new Error('AnalogJS is not compatible with Angular v16 and lower');
13
13
  }
14
- else if (angularMajor >= 15 && angularMajor < 16) {
15
- const cp = require('@angular-devkit/build-angular/src/builders/browser-esbuild/compiler-plugin.js');
16
- const { createJitResourceTransformer, } = require('@angular-devkit/build-angular/src/builders/browser-esbuild/angular/jit-resource-transformer.js');
17
- const { JavaScriptTransformer, } = require('@angular-devkit/build-angular/src/builders/browser-esbuild/javascript-transformer.js');
18
- sourceFileCache = cp.SourceFileCache;
19
- cjt = createJitResourceTransformer;
20
- jt = JavaScriptTransformer;
21
- }
22
- else if (angularMajor >= 16 && angularMajor < 18) {
14
+ else if (angularMajor >= 17 && angularMajor < 18) {
23
15
  const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');
24
16
  const { createJitResourceTransformer, } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');
25
17
  const { JavaScriptTransformer, } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');
@@ -1 +1 @@
1
- {"version":3,"file":"devkit.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/utils/devkit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,GAAG,MAAM,wBAAwB,CAAC;AAE9C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3C,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3C,MAAM,YAAY,G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,2EAA2E,CAAC,CAAC;IAEzF;;OAEG;IACH,IAAI,OAAO,EAAE,CAAC,iBAAiB,CAAC,KAAK,WAAW,EAAE,CAAC;QACjD,eAAe,GAAG,EAAE,CAAC,eAAe,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,eAAe,GAAG,GAAG,CAAC,eAAe,CAAC;IACxC,CAAC;IAED,GAAG,GAAG,4BAA4B,CAAC;IACnC,EAAE,GAAG,qBAAqB,CAAC;AAC7B,CAAC;KAAM,CAAC;IACN,MAAM,EACJ,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,GAChB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAEtC,eAAe,GAAG,eAAe,CAAC;IAClC,GAAG,GAAG,4BAA4B,CAAC;IACnC,EAAE,GAAG,qBAAqB,CAAC;AAC7B,CAAC;AAED,OAAO,EACL,GAAG,IAAI,4BAA4B,EACnC,EAAE,IAAI,qBAAqB,EAC3B,eAAe,IAAI,eAAe,EAElC,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,CAAC"}
@@ -0,0 +1,32 @@
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.dev/license
7
+ */
8
+ import { NgtscProgram } from '@angular/compiler-cli';
9
+ import ts from 'typescript';
10
+ /**
11
+ * Analyzes one or more modified files for changes to determine if any
12
+ * class declarations for Angular components are candidates for hot
13
+ * module replacement (HMR). If any source files are also modified but
14
+ * are not candidates then all candidates become invalid. This invalidation
15
+ * ensures that a full rebuild occurs and the running application stays
16
+ * synchronized with the code.
17
+ * @param modifiedFiles A set of modified files to analyze.
18
+ * @param param1 An Angular compiler instance
19
+ * @param staleSourceFiles A map of paths to previous source file instances.
20
+ * @returns A set of HMR candidate component class declarations.
21
+ */
22
+ export declare function collectHmrCandidates(modifiedFiles: Set<string>, { compiler }: NgtscProgram, staleSourceFiles: Map<string, ts.SourceFile> | undefined): Set<ts.ClassDeclaration>;
23
+ /**
24
+ * Analyzes the updates of a source file for potential HMR component class candidates.
25
+ * A source file can contain candidates if only the Angular component metadata of a class
26
+ * has been changed and the metadata changes are only of supported fields.
27
+ * @param stale The stale (previous) source file instance.
28
+ * @param updated The updated source file instance.
29
+ * @param compiler An Angular compiler instance.
30
+ * @returns An array of candidate class declarations; or `null` if unsupported changes are present.
31
+ */
32
+ export declare function analyzeFileUpdates(stale: ts.SourceFile, updated: ts.SourceFile, compiler: NgtscProgram['compiler']): ts.ClassDeclaration[] | null;
@@ -0,0 +1,272 @@
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.dev/license
7
+ */
8
+ import assert from 'node:assert';
9
+ import ts from 'typescript';
10
+ /**
11
+ * Analyzes one or more modified files for changes to determine if any
12
+ * class declarations for Angular components are candidates for hot
13
+ * module replacement (HMR). If any source files are also modified but
14
+ * are not candidates then all candidates become invalid. This invalidation
15
+ * ensures that a full rebuild occurs and the running application stays
16
+ * synchronized with the code.
17
+ * @param modifiedFiles A set of modified files to analyze.
18
+ * @param param1 An Angular compiler instance
19
+ * @param staleSourceFiles A map of paths to previous source file instances.
20
+ * @returns A set of HMR candidate component class declarations.
21
+ */
22
+ export function collectHmrCandidates(modifiedFiles, { compiler }, staleSourceFiles) {
23
+ const candidates = new Set();
24
+ for (const file of modifiedFiles) {
25
+ // If the file is a template for component(s), add component classes as candidates
26
+ const templateFileNodes = compiler.getComponentsWithTemplateFile(file);
27
+ if (templateFileNodes.size) {
28
+ templateFileNodes.forEach((node) => candidates.add(node));
29
+ continue;
30
+ }
31
+ // If the file is a style for component(s), add component classes as candidates
32
+ const styleFileNodes = compiler.getComponentsWithStyleFile(file);
33
+ if (styleFileNodes.size) {
34
+ styleFileNodes.forEach((node) => candidates.add(node));
35
+ continue;
36
+ }
37
+ const staleSource = staleSourceFiles?.get(file);
38
+ if (staleSource === undefined) {
39
+ // Unknown file requires a rebuild so clear out the candidates and stop collecting
40
+ candidates.clear();
41
+ break;
42
+ }
43
+ const updatedSource = compiler.getCurrentProgram().getSourceFile(file);
44
+ if (updatedSource === undefined) {
45
+ // No longer existing program file requires a rebuild so clear out the candidates and stop collecting
46
+ candidates.clear();
47
+ break;
48
+ }
49
+ // Analyze the stale and updated file for changes
50
+ const fileCandidates = analyzeFileUpdates(staleSource, updatedSource, compiler);
51
+ if (fileCandidates) {
52
+ fileCandidates.forEach((node) => candidates.add(node));
53
+ }
54
+ else {
55
+ // Unsupported HMR changes present
56
+ // Only template and style literal changes are allowed.
57
+ candidates.clear();
58
+ break;
59
+ }
60
+ }
61
+ return candidates;
62
+ }
63
+ /**
64
+ * Analyzes the updates of a source file for potential HMR component class candidates.
65
+ * A source file can contain candidates if only the Angular component metadata of a class
66
+ * has been changed and the metadata changes are only of supported fields.
67
+ * @param stale The stale (previous) source file instance.
68
+ * @param updated The updated source file instance.
69
+ * @param compiler An Angular compiler instance.
70
+ * @returns An array of candidate class declarations; or `null` if unsupported changes are present.
71
+ */
72
+ export function analyzeFileUpdates(stale, updated, compiler) {
73
+ if (stale.statements.length !== updated.statements.length) {
74
+ return null;
75
+ }
76
+ const candidates = [];
77
+ for (let i = 0; i < updated.statements.length; ++i) {
78
+ const updatedNode = updated.statements[i];
79
+ const staleNode = stale.statements[i];
80
+ if (ts.isClassDeclaration(updatedNode)) {
81
+ if (!ts.isClassDeclaration(staleNode)) {
82
+ return null;
83
+ }
84
+ // Check class declaration differences (name/heritage/modifiers)
85
+ if (updatedNode.name?.text !== staleNode.name?.text) {
86
+ return null;
87
+ }
88
+ if (!equalRangeText(updatedNode.heritageClauses, updated, staleNode.heritageClauses, stale)) {
89
+ return null;
90
+ }
91
+ const updatedModifiers = ts.getModifiers(updatedNode);
92
+ const staleModifiers = ts.getModifiers(staleNode);
93
+ if (updatedModifiers?.length !== staleModifiers?.length ||
94
+ !updatedModifiers?.every((updatedModifier) => staleModifiers?.some((staleModifier) => updatedModifier.kind === staleModifier.kind))) {
95
+ return null;
96
+ }
97
+ // Check for component class nodes
98
+ const meta = compiler?.getMeta(updatedNode);
99
+ console.log('meta', stale.fileName, meta);
100
+ if (meta?.decorator &&
101
+ meta.isComponent === true) {
102
+ const updatedDecorators = ts.getDecorators(updatedNode);
103
+ const staleDecorators = ts.getDecorators(staleNode);
104
+ if (!staleDecorators ||
105
+ staleDecorators.length !== updatedDecorators?.length) {
106
+ return null;
107
+ }
108
+ // TODO: Check other decorators instead of assuming all multi-decorator components are unsupported
109
+ if (staleDecorators.length > 1) {
110
+ return null;
111
+ }
112
+ // Find index of component metadata decorator
113
+ const metaDecoratorIndex = updatedDecorators?.indexOf(meta.decorator);
114
+ assert(metaDecoratorIndex !== undefined, 'Component metadata decorator should always be present on component class.');
115
+ const updatedDecoratorExpression = meta.decorator.expression;
116
+ assert(ts.isCallExpression(updatedDecoratorExpression) &&
117
+ updatedDecoratorExpression.arguments.length === 1, 'Component metadata decorator should contain a call expression with a single argument.');
118
+ // Check the matching stale index for the component decorator
119
+ const staleDecoratorExpression = staleDecorators[metaDecoratorIndex]?.expression;
120
+ if (!staleDecoratorExpression ||
121
+ !ts.isCallExpression(staleDecoratorExpression) ||
122
+ staleDecoratorExpression.arguments.length !== 1) {
123
+ return null;
124
+ }
125
+ // Check decorator name/expression
126
+ // NOTE: This would typically be `Component` but can also be a property expression or some other alias.
127
+ // To avoid complex checks, this ensures the textual representation does not change. This has a low chance
128
+ // of a false positive if the expression is changed to still reference the `Component` type but has different
129
+ // text. However, it is rare for `Component` to not be used directly and additionally unlikely that it would
130
+ // be changed between edits. A false positive would also only lead to a difference of a full page reload versus
131
+ // an HMR update.
132
+ if (!equalRangeText(updatedDecoratorExpression.expression, updated, staleDecoratorExpression.expression, stale)) {
133
+ return null;
134
+ }
135
+ // Compare component meta decorator object literals
136
+ const analysis = analyzeMetaUpdates(staleDecoratorExpression, stale, updatedDecoratorExpression, updated);
137
+ if (analysis === MetaUpdateAnalysis.Unsupported) {
138
+ return null;
139
+ }
140
+ // Compare text of the member nodes to determine if any changes have occurred
141
+ if (!equalRangeText(updatedNode.members, updated, staleNode.members, stale)) {
142
+ // A change to a member outside a component's metadata is unsupported
143
+ return null;
144
+ }
145
+ // If all previous class checks passed, this class is supported for HMR updates
146
+ if (analysis === MetaUpdateAnalysis.Supported) {
147
+ candidates.push(updatedNode);
148
+ }
149
+ continue;
150
+ }
151
+ }
152
+ // Compare text of the statement nodes to determine if any changes have occurred
153
+ // TODO: Consider expanding this to check semantic updates for each node kind
154
+ if (!equalRangeText(updatedNode, updated, staleNode, stale)) {
155
+ // A change to a statement outside a component's metadata is unsupported
156
+ return null;
157
+ }
158
+ }
159
+ return candidates;
160
+ }
161
+ /**
162
+ * The set of Angular component metadata fields that are supported by HMR updates.
163
+ */
164
+ const SUPPORTED_FIELD_NAMES = new Set([
165
+ 'template',
166
+ 'templateUrl',
167
+ 'styles',
168
+ 'styleUrl',
169
+ 'stylesUrl',
170
+ ]);
171
+ var MetaUpdateAnalysis;
172
+ (function (MetaUpdateAnalysis) {
173
+ MetaUpdateAnalysis[MetaUpdateAnalysis["Supported"] = 0] = "Supported";
174
+ MetaUpdateAnalysis[MetaUpdateAnalysis["Unsupported"] = 1] = "Unsupported";
175
+ MetaUpdateAnalysis[MetaUpdateAnalysis["None"] = 2] = "None";
176
+ })(MetaUpdateAnalysis || (MetaUpdateAnalysis = {}));
177
+ /**
178
+ * Analyzes the metadata fields of a decorator call expression for unsupported HMR updates.
179
+ * Only updates to supported fields can be present for HMR to be viable.
180
+ * @param staleCall A call expression instance.
181
+ * @param staleSource The source file instance containing the stale call instance.
182
+ * @param updatedCall A call expression instance.
183
+ * @param updatedSource The source file instance containing the updated call instance.
184
+ * @returns A MetaUpdateAnalysis enum value.
185
+ */
186
+ function analyzeMetaUpdates(staleCall, staleSource, updatedCall, updatedSource) {
187
+ const staleObject = staleCall.arguments[0];
188
+ const updatedObject = updatedCall.arguments[0];
189
+ let hasSupportedUpdate = false;
190
+ if (!ts.isObjectLiteralExpression(staleObject) ||
191
+ !ts.isObjectLiteralExpression(updatedObject)) {
192
+ return MetaUpdateAnalysis.Unsupported;
193
+ }
194
+ const supportedFields = new Map();
195
+ const unsupportedFields = [];
196
+ for (const property of staleObject.properties) {
197
+ if (!ts.isPropertyAssignment(property) ||
198
+ ts.isComputedPropertyName(property.name)) {
199
+ // Unsupported object literal property
200
+ return MetaUpdateAnalysis.Unsupported;
201
+ }
202
+ const name = property.name.text;
203
+ if (SUPPORTED_FIELD_NAMES.has(name)) {
204
+ supportedFields.set(name, property.initializer);
205
+ continue;
206
+ }
207
+ unsupportedFields.push(property.initializer);
208
+ }
209
+ let i = 0;
210
+ for (const property of updatedObject.properties) {
211
+ if (!ts.isPropertyAssignment(property) ||
212
+ ts.isComputedPropertyName(property.name)) {
213
+ // Unsupported object literal property
214
+ return MetaUpdateAnalysis.Unsupported;
215
+ }
216
+ const name = property.name.text;
217
+ if (SUPPORTED_FIELD_NAMES.has(name)) {
218
+ const staleInitializer = supportedFields.get(name);
219
+ // If the supported field was added or has its content changed, there has been a supported update
220
+ if (!staleInitializer ||
221
+ !equalRangeText(property.initializer, updatedSource, staleInitializer, staleSource)) {
222
+ hasSupportedUpdate = true;
223
+ }
224
+ // Remove the field entry to allow tracking removed fields
225
+ supportedFields.delete(name);
226
+ continue;
227
+ }
228
+ // Compare in order
229
+ if (!equalRangeText(property.initializer, updatedSource, unsupportedFields[i++], staleSource)) {
230
+ return MetaUpdateAnalysis.Unsupported;
231
+ }
232
+ }
233
+ if (i !== unsupportedFields.length) {
234
+ return MetaUpdateAnalysis.Unsupported;
235
+ }
236
+ // Any remaining supported field indicates a field removal. This is also considered a supported update.
237
+ hasSupportedUpdate ||= supportedFields.size > 0;
238
+ return hasSupportedUpdate
239
+ ? MetaUpdateAnalysis.Supported
240
+ : MetaUpdateAnalysis.None;
241
+ }
242
+ /**
243
+ * Compares the text from a provided range in a source file to the text of a range in a second source file.
244
+ * The comparison avoids making any intermediate string copies.
245
+ * @param firstRange A text range within the first source file.
246
+ * @param firstSource A source file instance.
247
+ * @param secondRange A text range within the second source file.
248
+ * @param secondSource A source file instance.
249
+ * @returns true, if the text from both ranges is equal; false, otherwise.
250
+ */
251
+ function equalRangeText(firstRange, firstSource, secondRange, secondSource) {
252
+ // Check matching undefined values
253
+ if (!firstRange || !secondRange) {
254
+ return firstRange === secondRange;
255
+ }
256
+ // Ensure lengths are equal
257
+ const firstLength = firstRange.end - firstRange.pos;
258
+ const secondLength = secondRange.end - secondRange.pos;
259
+ if (firstLength !== secondLength) {
260
+ return false;
261
+ }
262
+ // Check each character
263
+ for (let i = 0; i < firstLength; ++i) {
264
+ const firstChar = firstSource.text.charCodeAt(i + firstRange.pos);
265
+ const secondChar = secondSource.text.charCodeAt(i + secondRange.pos);
266
+ if (firstChar !== secondChar) {
267
+ return false;
268
+ }
269
+ }
270
+ return true;
271
+ }
272
+ //# sourceMappingURL=hmr-candidates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr-candidates.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/utils/hmr-candidates.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,aAA0B,EAC1B,EAAE,QAAQ,EAAgB,EAC1B,gBAAwD;IAExD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAElD,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,kFAAkF;QAClF,MAAM,iBAAiB,GAAG,QAAQ,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;QACvE,IAAI,iBAAiB,CAAC,IAAI,EAAE,CAAC;YAC3B,iBAAiB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE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rB,UAA4C,EAC5C,WAA0B,EAC1B,WAA6C,EAC7C,YAA2B;IAE3B,kCAAkC;IAClC,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE,CAAC;QAChC,OAAO,UAAU,KAAK,WAAW,CAAC;IACpC,CAAC;IAED,2BAA2B;IAC3B,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IACpD,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;IACvD,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uBAAuB;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QACrE,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -9,8 +9,8 @@ import type ts from 'typescript';
9
9
  export declare class SourceFileCache extends Map<string, ts.SourceFile> {
10
10
  readonly persistentCachePath?: string | undefined;
11
11
  readonly modifiedFiles: Set<string>;
12
- readonly babelFileCache: Map<string, Uint8Array>;
13
- readonly typeScriptFileCache: Map<string, string | Uint8Array>;
12
+ readonly babelFileCache: Map<string, Uint8Array<ArrayBufferLike>>;
13
+ readonly typeScriptFileCache: Map<string, string | Uint8Array<ArrayBufferLike>>;
14
14
  referencedFiles?: readonly string[];
15
15
  constructor(persistentCachePath?: string | undefined);
16
16
  invalidate(files: Iterable<string>): void;
package/esbuild.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type * as esbuild from 'esbuild';
2
- import { PluginOptions } from './src';
3
- export declare const analogSFC: (options?: PluginOptions) => esbuild.Plugin;
package/esbuild.js DELETED
@@ -1,31 +0,0 @@
1
- import analog from '@analogjs/vite-plugin-angular';
2
- export const analogSFC = (options) => ({
3
- name: 'analog-sfc-esbuild-plugin',
4
- async setup(build) {
5
- const analogPlugins = analog({
6
- ...(options || {}),
7
- experimental: {
8
- supportAnalogFormat: true,
9
- ...(options?.experimental || {}),
10
- },
11
- });
12
- const analogPlugin = analogPlugins[0];
13
- await analogPlugin.config({ root: '.' }, { command: 'build' });
14
- await analogPlugin.buildStart?.({
15
- plugins: [
16
- {
17
- name: 'vite:css',
18
- transform(code) {
19
- return { code };
20
- },
21
- },
22
- ],
23
- });
24
- build.onLoad({ filter: /\.(analog|ag)$/ }, async (args) => {
25
- await analogPlugin.handleHotUpdate?.({ file: args.path, modules: [] });
26
- const result = await analogPlugin.transform?.('', args.path);
27
- return { loader: 'js', contents: result?.code };
28
- });
29
- },
30
- });
31
- //# sourceMappingURL=esbuild.js.map
package/esbuild.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../../packages/vite-plugin-angular/esbuild.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAInD,MAAM,CAAC,MAAM,SAAS,GAAgD,CACpE,OAAO,EACP,EAAE,CAAC,CAAC;IACJ,IAAI,EAAE,2BAA2B;IACjC,KAAK,CAAC,KAAK,CAAC,KAAK;QACf,MAAM,aAAa,GAAQ,MAAM,CAAC;YAChC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;YAClB,YAAY,EAAE;gBACZ,mBAAmB,EAAE,IAAI;gBACzB,GAAG,CAAC,OAAO,EAAE,YAAY,IAAI,EAAE,CAAC;aACjC;SACF,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CA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