@analogjs/vite-plugin-angular 3.0.0-alpha.4 → 3.0.0-alpha.40

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 (168) hide show
  1. package/README.md +28 -0
  2. package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
  3. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
  4. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
  5. package/migrations/migration.json +7 -1
  6. package/migrations/migrations.json +9 -0
  7. package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
  8. package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
  9. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
  10. package/package.json +25 -12
  11. package/src/index.d.ts +3 -2
  12. package/src/index.js +6 -2
  13. package/src/index.js.map +1 -1
  14. package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
  15. package/src/lib/angular-build-optimizer-plugin.js +48 -62
  16. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  17. package/src/lib/angular-jit-plugin.d.ts +3 -3
  18. package/src/lib/angular-jit-plugin.js +42 -37
  19. package/src/lib/angular-jit-plugin.js.map +1 -1
  20. package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
  21. package/src/lib/angular-pending-tasks.plugin.js +17 -18
  22. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  23. package/src/lib/angular-vite-plugin.d.ts +250 -40
  24. package/src/lib/angular-vite-plugin.js +2216 -964
  25. package/src/lib/angular-vite-plugin.js.map +1 -1
  26. package/src/lib/angular-vitest-plugin.d.ts +19 -15
  27. package/src/lib/angular-vitest-plugin.js +99 -114
  28. package/src/lib/angular-vitest-plugin.js.map +1 -1
  29. package/src/lib/compiler/angular-version.d.ts +19 -0
  30. package/src/lib/compiler/angular-version.js +16 -0
  31. package/src/lib/compiler/angular-version.js.map +1 -0
  32. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  33. package/src/lib/compiler/class-field-lowering.js +131 -0
  34. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  35. package/src/lib/compiler/compile.d.ts +44 -0
  36. package/src/lib/compiler/compile.js +731 -0
  37. package/src/lib/compiler/compile.js.map +1 -0
  38. package/src/lib/compiler/constants.d.ts +18 -0
  39. package/src/lib/compiler/constants.js +52 -0
  40. package/src/lib/compiler/constants.js.map +1 -0
  41. package/src/lib/compiler/debug.d.ts +22 -0
  42. package/src/lib/compiler/debug.js +20 -0
  43. package/src/lib/compiler/debug.js.map +1 -0
  44. package/src/lib/compiler/defer.d.ts +47 -0
  45. package/src/lib/compiler/defer.js +138 -0
  46. package/src/lib/compiler/defer.js.map +1 -0
  47. package/src/lib/compiler/dts-reader.d.ts +35 -0
  48. package/src/lib/compiler/dts-reader.js +365 -0
  49. package/src/lib/compiler/dts-reader.js.map +1 -0
  50. package/src/lib/compiler/hmr.d.ts +16 -0
  51. package/src/lib/compiler/hmr.js +69 -0
  52. package/src/lib/compiler/hmr.js.map +1 -0
  53. package/src/lib/compiler/index.d.ts +7 -0
  54. package/src/lib/compiler/index.js +7 -0
  55. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  56. package/src/lib/compiler/jit-metadata.js +146 -0
  57. package/src/lib/compiler/jit-metadata.js.map +1 -0
  58. package/src/lib/compiler/jit-transform.d.ts +24 -0
  59. package/src/lib/compiler/jit-transform.js +200 -0
  60. package/src/lib/compiler/jit-transform.js.map +1 -0
  61. package/src/lib/compiler/js-emitter.d.ts +10 -0
  62. package/src/lib/compiler/js-emitter.js +420 -0
  63. package/src/lib/compiler/js-emitter.js.map +1 -0
  64. package/src/lib/compiler/metadata.d.ts +45 -0
  65. package/src/lib/compiler/metadata.js +633 -0
  66. package/src/lib/compiler/metadata.js.map +1 -0
  67. package/src/lib/compiler/registry.d.ts +49 -0
  68. package/src/lib/compiler/registry.js +164 -0
  69. package/src/lib/compiler/registry.js.map +1 -0
  70. package/src/lib/compiler/resource-inliner.d.ts +21 -0
  71. package/src/lib/compiler/resource-inliner.js +152 -0
  72. package/src/lib/compiler/resource-inliner.js.map +1 -0
  73. package/src/lib/compiler/style-ast.d.ts +8 -0
  74. package/src/lib/compiler/style-ast.js +54 -0
  75. package/src/lib/compiler/style-ast.js.map +1 -0
  76. package/src/lib/compiler/styles.d.ts +13 -0
  77. package/src/lib/compiler/test-helpers.d.ts +7 -0
  78. package/src/lib/compiler/type-elision.d.ts +26 -0
  79. package/src/lib/compiler/type-elision.js +211 -0
  80. package/src/lib/compiler/type-elision.js.map +1 -0
  81. package/src/lib/compiler/utils.d.ts +10 -0
  82. package/src/lib/compiler/utils.js +35 -0
  83. package/src/lib/compiler/utils.js.map +1 -0
  84. package/src/lib/compiler-plugin.d.ts +11 -11
  85. package/src/lib/compiler-plugin.js +43 -44
  86. package/src/lib/compiler-plugin.js.map +1 -1
  87. package/src/lib/component-resolvers.d.ts +23 -5
  88. package/src/lib/component-resolvers.js +153 -63
  89. package/src/lib/component-resolvers.js.map +1 -1
  90. package/src/lib/fast-compile-plugin.d.ts +14 -0
  91. package/src/lib/fast-compile-plugin.js +270 -0
  92. package/src/lib/fast-compile-plugin.js.map +1 -0
  93. package/src/lib/host.d.ts +10 -8
  94. package/src/lib/host.js +111 -101
  95. package/src/lib/host.js.map +1 -1
  96. package/src/lib/live-reload-plugin.d.ts +5 -5
  97. package/src/lib/live-reload-plugin.js +61 -62
  98. package/src/lib/live-reload-plugin.js.map +1 -1
  99. package/src/lib/models.d.ts +9 -9
  100. package/src/lib/nx-folder-plugin.d.ts +5 -5
  101. package/src/lib/nx-folder-plugin.js +18 -16
  102. package/src/lib/nx-folder-plugin.js.map +1 -1
  103. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  104. package/src/lib/plugins/file-replacements.plugin.js +40 -62
  105. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  106. package/src/lib/router-plugin.d.ts +1 -1
  107. package/src/lib/router-plugin.js +23 -23
  108. package/src/lib/router-plugin.js.map +1 -1
  109. package/src/lib/style-pipeline.d.ts +15 -0
  110. package/src/lib/style-pipeline.js +31 -0
  111. package/src/lib/style-pipeline.js.map +1 -0
  112. package/src/lib/style-preprocessor.d.ts +35 -0
  113. package/src/lib/style-preprocessor.js +35 -0
  114. package/src/lib/style-preprocessor.js.map +1 -0
  115. package/src/lib/stylesheet-registry.d.ts +73 -0
  116. package/src/lib/stylesheet-registry.js +168 -0
  117. package/src/lib/stylesheet-registry.js.map +1 -0
  118. package/src/lib/tools/package.json +2 -7
  119. package/src/lib/tools/src/builders/vite/vite-build.impl.js +31 -38
  120. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  121. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +51 -62
  122. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  123. package/src/lib/tools/src/index.js +0 -2
  124. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  125. package/src/lib/utils/debug-harness.d.ts +23 -0
  126. package/src/lib/utils/debug-harness.js +88 -0
  127. package/src/lib/utils/debug-harness.js.map +1 -0
  128. package/src/lib/utils/debug-log-file.d.ts +5 -0
  129. package/src/lib/utils/debug-log-file.js +56 -0
  130. package/src/lib/utils/debug-log-file.js.map +1 -0
  131. package/src/lib/utils/debug.d.ts +28 -0
  132. package/src/lib/utils/debug.js +39 -0
  133. package/src/lib/utils/debug.js.map +1 -0
  134. package/src/lib/utils/devkit.d.ts +6 -6
  135. package/src/lib/utils/devkit.js +34 -38
  136. package/src/lib/utils/devkit.js.map +1 -1
  137. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  138. package/src/lib/utils/plugin-config.d.ts +30 -0
  139. package/src/lib/utils/plugin-config.js +64 -0
  140. package/src/lib/utils/plugin-config.js.map +1 -0
  141. package/src/lib/utils/rolldown.d.ts +2 -0
  142. package/src/lib/utils/rolldown.js +12 -0
  143. package/src/lib/utils/rolldown.js.map +1 -0
  144. package/src/lib/utils/source-file-cache.d.ts +8 -15
  145. package/src/lib/utils/source-file-cache.js +35 -37
  146. package/src/lib/utils/source-file-cache.js.map +1 -1
  147. package/src/lib/utils/tailwind-reference.d.ts +12 -0
  148. package/src/lib/utils/tailwind-reference.js +99 -0
  149. package/src/lib/utils/tailwind-reference.js.map +1 -0
  150. package/src/lib/utils/virtual-ids.d.ts +8 -0
  151. package/src/lib/utils/virtual-ids.js +35 -0
  152. package/src/lib/utils/virtual-ids.js.map +1 -0
  153. package/src/lib/utils/virtual-resources.d.ts +47 -0
  154. package/src/lib/utils/virtual-resources.js +89 -0
  155. package/src/lib/utils/virtual-resources.js.map +1 -0
  156. package/src/test-setup.d.ts +2 -0
  157. package/setup-vitest.d.ts +0 -4
  158. package/setup-vitest.js +0 -215
  159. package/setup-vitest.js.map +0 -1
  160. package/src/lib/models.js +0 -1
  161. package/src/lib/models.js.map +0 -1
  162. package/src/lib/tools/README.md +0 -3
  163. package/src/lib/tools/src/index.d.ts +0 -0
  164. package/src/lib/tools/src/index.js.map +0 -1
  165. package/src/lib/utils/compiler-plugin-options.js +0 -1
  166. package/src/lib/utils/compiler-plugin-options.js.map +0 -1
  167. package/src/lib/utils/hmr-candidates.js +0 -272
  168. package/src/lib/utils/hmr-candidates.js.map +0 -1
@@ -1,41 +1,37 @@
1
- import { VERSION } from '@angular/compiler-cli';
2
- import { createRequire } from 'node:module';
3
- import * as sfc from './source-file-cache.js';
4
- const require = createRequire(import.meta.url);
5
- const angularMajor = Number(VERSION.major);
6
- const angularMinor = Number(VERSION.minor);
7
- const angularPatch = Number(VERSION.patch);
8
- const padVersion = (version) => String(version).padStart(2, '0');
9
- const angularFullVersion = Number(`${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`);
10
- let sourceFileCache;
11
- let cjt;
12
- let jt;
13
- let createAngularCompilation;
14
- if (angularMajor < 17) {
15
- throw new Error('AnalogJS is not compatible with Angular v16 and lower');
16
- }
1
+ import { SourceFileCache } from "./source-file-cache.js";
2
+ import { VERSION } from "@angular/compiler-cli";
3
+ import { createRequire } from "node:module";
4
+ //#region packages/vite-plugin-angular/src/lib/utils/devkit.ts
5
+ var require = createRequire(import.meta.url);
6
+ var angularMajor = Number(VERSION.major);
7
+ var angularMinor = Number(VERSION.minor);
8
+ var angularPatch = Number(VERSION.patch);
9
+ var padVersion = (version) => String(version).padStart(2, "0");
10
+ var angularFullVersion = Number(`${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`);
11
+ var sourceFileCache;
12
+ var cjt;
13
+ var jt;
14
+ var createAngularCompilation;
15
+ if (angularMajor < 17) throw new Error("AnalogJS is not compatible with Angular v16 and lower");
17
16
  else if (angularMajor >= 17 && angularMajor < 18) {
18
- const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');
19
- const { createJitResourceTransformer, } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');
20
- const { JavaScriptTransformer, } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');
21
- /**
22
- * Workaround for compatibility with Angular 17.0+
23
- */
24
- if (typeof cp['SourceFileCache'] !== 'undefined') {
25
- sourceFileCache = cp.SourceFileCache;
26
- }
27
- else {
28
- sourceFileCache = sfc.SourceFileCache;
29
- }
30
- cjt = createJitResourceTransformer;
31
- jt = JavaScriptTransformer;
32
- }
33
- else {
34
- const { createJitResourceTransformer, JavaScriptTransformer, SourceFileCache, createAngularCompilation: createAngularCompilationFn, } = require('@angular/build/private');
35
- sourceFileCache = SourceFileCache;
36
- cjt = createJitResourceTransformer;
37
- jt = JavaScriptTransformer;
38
- createAngularCompilation = createAngularCompilationFn;
17
+ const cp = require("@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js");
18
+ const { createJitResourceTransformer } = require("@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js");
19
+ const { JavaScriptTransformer } = require("@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js");
20
+ /**
21
+ * Workaround for compatibility with Angular 17.0+
22
+ */
23
+ if (typeof cp["SourceFileCache"] !== "undefined") sourceFileCache = cp.SourceFileCache;
24
+ else sourceFileCache = SourceFileCache;
25
+ cjt = createJitResourceTransformer;
26
+ jt = JavaScriptTransformer;
27
+ } else {
28
+ const { createJitResourceTransformer, JavaScriptTransformer, SourceFileCache, createAngularCompilation: createAngularCompilationFn } = require("@angular/build/private");
29
+ sourceFileCache = SourceFileCache;
30
+ cjt = createJitResourceTransformer;
31
+ jt = JavaScriptTransformer;
32
+ createAngularCompilation = createAngularCompilationFn;
39
33
  }
40
- export { cjt as createJitResourceTransformer, jt as JavaScriptTransformer, sourceFileCache as SourceFileCache, angularMajor, angularMinor, angularPatch, createAngularCompilation, angularFullVersion, };
34
+ //#endregion
35
+ export { angularFullVersion, cjt, createAngularCompilation, jt, sourceFileCache };
36
+
41
37
  //# sourceMappingURL=devkit.js.map
@@ -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,GAAW,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,MAAM,YAAY,GAAW,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,MAAM,YAAY,GAAW,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzE,MAAM,kBAAkB,GAAW,MAAM,CACvC,GAAG,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,EAAE,CACxE,CAAC;AACF,IAAI,eAAoB,CAAC;AACzB,IAAI,GAA4B,CAAC;AACjC,IAAI,EAAO,CAAC;AACZ,IAAI,wBAAiD,CAAC;AAEtD,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;IACtB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AAC3E,CAAC;KAAM,IAAI,YAAY,IAAI,EAAE,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;IACnD,MAAM,EAAE,GAAG,OAAO,CAAC,4EAA4E,CAAC,CAAC;IACjG,MAAM,EACJ,4BAA4B,GAC7B,GAAG,OAAO,CAAC,qFAAqF,CAAC,CAAC;IACnG,MAAM,EACJ,qBAAqB,GACtB,GAAG,OAAO,CAAC,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,EACf,wBAAwB,EAAE,0BAA0B,GACrD,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAEtC,eAAe,GAAG,eAAe,CAAC;IAClC,GAAG,GAAG,4BAA4B,CAAC;IACnC,EAAE,GAAG,qBAAqB,CAAC;IAC3B,wBAAwB,GAAG,0BAA0B,CAAC;AACxD,CAAC;AAED,OAAO,EACL,GAAG,IAAI,4BAA4B,EACnC,EAAE,IAAI,qBAAqB,EAC3B,eAAe,IAAI,eAAe,EAElC,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,GACnB,CAAC"}
1
+ {"version":3,"file":"devkit.js","names":[],"sources":["../../../../src/lib/utils/devkit.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport { createRequire } from 'node:module';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport * as sfc from './source-file-cache.js';\n\nconst require = createRequire(import.meta.url);\n\nconst angularMajor = Number(VERSION.major);\nconst angularMinor = Number(VERSION.minor);\nconst angularPatch = Number(VERSION.patch);\nconst padVersion = (version: number) => String(version).padStart(2, '0');\nconst angularFullVersion = Number(\n `${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`,\n);\nlet sourceFileCache: any;\nlet cjt: (...args: any[]) => any;\nlet jt: any;\nlet createAngularCompilation: (...args: any[]) => any;\n\nif (angularMajor < 17) {\n throw new Error('AnalogJS is not compatible with Angular v16 and lower');\n} else if (angularMajor >= 17 && angularMajor < 18) {\n const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');\n const {\n createJitResourceTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');\n const {\n JavaScriptTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');\n\n /**\n * Workaround for compatibility with Angular 17.0+\n */\n if (typeof cp['SourceFileCache'] !== 'undefined') {\n sourceFileCache = cp.SourceFileCache;\n } else {\n sourceFileCache = sfc.SourceFileCache;\n }\n\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n} else {\n const {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n } = require('@angular/build/private');\n\n sourceFileCache = SourceFileCache;\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n createAngularCompilation = createAngularCompilationFn;\n}\n\nexport {\n cjt as createJitResourceTransformer,\n jt as JavaScriptTransformer,\n sourceFileCache as SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;AAKA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,cAAc,YAAoB,OAAO,QAAQ,CAAC,SAAS,GAAG,IAAI;AACxE,IAAM,qBAAqB,OACzB,GAAG,eAAe,WAAW,aAAa,GAAG,WAAW,aAAa,GACtE;AACD,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,IAAI,eAAe,GACjB,OAAM,IAAI,MAAM,wDAAwD;SAC/D,gBAAgB,MAAM,eAAe,IAAI;CAClD,MAAM,KAAK,QAAQ,6EAA6E;CAChG,MAAM,EACJ,iCACE,QAAQ,sFAAsF;CAClG,MAAM,EACJ,0BACE,QAAQ,4EAA4E;;;;AAKxF,KAAI,OAAO,GAAG,uBAAuB,YACnC,mBAAkB,GAAG;KAErB,mBAAkB;AAGpB,OAAM;AACN,MAAK;OACA;CACL,MAAM,EACJ,8BACA,uBACA,iBACA,0BAA0B,+BACxB,QAAQ,yBAAyB;AAErC,mBAAkB;AAClB,OAAM;AACN,MAAK;AACL,4BAA2B"}
@@ -1,32 +1,32 @@
1
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';
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
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
- */
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
22
  export declare function collectHmrCandidates(modifiedFiles: Set<string>, { compiler }: NgtscProgram, staleSourceFiles: Map<string, ts.SourceFile> | undefined): Set<ts.ClassDeclaration>;
23
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;
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,30 @@
1
+ /**
2
+ * TypeScript file extension regex
3
+ * Match .(c or m)ts, .ts extensions with an optional ? for query params
4
+ * Ignore .tsx extensions
5
+ */
6
+ export declare const TS_EXT_REGEX: unknown;
7
+ export interface TsConfigResolutionContext {
8
+ root: string;
9
+ isProd: boolean;
10
+ isLib: boolean;
11
+ }
12
+ export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean);
13
+ export declare function createTsConfigGetter(tsconfigOrGetter?: string | (() => string));
14
+ export interface DepOptimizerOptions {
15
+ tsconfig: string;
16
+ isProd: boolean;
17
+ jit: boolean;
18
+ watchMode: boolean;
19
+ isTest: boolean;
20
+ isAstroIntegration: boolean;
21
+ }
22
+ export declare function createDepOptimizerConfig(opts: DepOptimizerOptions): {
23
+ optimizeDeps: {
24
+ include: unknown;
25
+ exclude: unknown;
26
+ };
27
+ resolve: {
28
+ conditions: unknown;
29
+ };
30
+ };
@@ -0,0 +1,64 @@
1
+ import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
2
+ import { existsSync } from "node:fs";
3
+ import { isAbsolute, resolve } from "node:path";
4
+ import * as vite from "vite";
5
+ //#region packages/vite-plugin-angular/src/lib/utils/plugin-config.ts
6
+ /**
7
+ * TypeScript file extension regex
8
+ * Match .(c or m)ts, .ts extensions with an optional ? for query params
9
+ * Ignore .tsx extensions
10
+ */
11
+ var TS_EXT_REGEX = /\.[cm]?(ts)[^x]?\??/;
12
+ function getTsConfigPath(root, tsconfig, isProd, isTest, isLib) {
13
+ if (tsconfig && isAbsolute(tsconfig)) {
14
+ if (!existsSync(tsconfig)) console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
15
+ return tsconfig;
16
+ }
17
+ let tsconfigFilePath = "./tsconfig.app.json";
18
+ if (isLib) tsconfigFilePath = isProd ? "./tsconfig.lib.prod.json" : "./tsconfig.lib.json";
19
+ if (isTest) tsconfigFilePath = "./tsconfig.spec.json";
20
+ if (tsconfig) tsconfigFilePath = tsconfig;
21
+ const resolvedPath = resolve(root, tsconfigFilePath);
22
+ if (!existsSync(resolvedPath)) console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${resolvedPath}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
23
+ return resolvedPath;
24
+ }
25
+ function createTsConfigGetter(tsconfigOrGetter) {
26
+ if (typeof tsconfigOrGetter === "function") return tsconfigOrGetter;
27
+ return () => tsconfigOrGetter || "";
28
+ }
29
+ function createDepOptimizerConfig(opts) {
30
+ const defineOptions = {
31
+ ngJitMode: "false",
32
+ ngI18nClosureMode: "false",
33
+ ...opts.watchMode ? {} : { ngDevMode: "false" }
34
+ };
35
+ const rolldownOptions = { plugins: [createRolldownCompilerPlugin({
36
+ tsconfig: opts.tsconfig,
37
+ sourcemap: !opts.isProd,
38
+ advancedOptimizations: opts.isProd,
39
+ jit: opts.jit,
40
+ incremental: opts.watchMode
41
+ })] };
42
+ const esbuildOptions = {
43
+ plugins: [createCompilerPlugin({
44
+ tsconfig: opts.tsconfig,
45
+ sourcemap: !opts.isProd,
46
+ advancedOptimizations: opts.isProd,
47
+ jit: opts.jit,
48
+ incremental: opts.watchMode
49
+ }, opts.isTest, !opts.isAstroIntegration)],
50
+ define: defineOptions
51
+ };
52
+ return {
53
+ optimizeDeps: {
54
+ include: ["rxjs/operators", "rxjs"],
55
+ exclude: ["@angular/platform-server"],
56
+ ...vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }
57
+ },
58
+ resolve: { conditions: ["style"] }
59
+ };
60
+ }
61
+ //#endregion
62
+ export { TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath };
63
+
64
+ //# sourceMappingURL=plugin-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\nimport { defaultClientConditions } from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\n\n/**\n * TypeScript file extension regex\n * Match .(c or m)ts, .ts extensions with an optional ? for query params\n * Ignore .tsx extensions\n */\nexport const TS_EXT_REGEX = /\\.[cm]?(ts)[^x]?\\??/;\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (!existsSync(resolvedPath)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${resolvedPath}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return resolvedPath;\n}\n\nexport function createTsConfigGetter(\n tsconfigOrGetter?: string | (() => string),\n) {\n if (typeof tsconfigOrGetter === 'function') {\n return tsconfigOrGetter;\n }\n\n return () => tsconfigOrGetter || '';\n}\n\nexport interface DepOptimizerOptions {\n tsconfig: string;\n isProd: boolean;\n jit: boolean;\n watchMode: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n}\n\nexport function createDepOptimizerConfig(opts: DepOptimizerOptions) {\n const defineOptions = {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ...(opts.watchMode ? {} : { ngDevMode: 'false' }),\n };\n\n const rolldownOptions: vite.DepOptimizationOptions['rolldownOptions'] = {\n plugins: [\n createRolldownCompilerPlugin({\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n }),\n ],\n };\n\n const esbuildOptions: vite.DepOptimizationOptions['esbuildOptions'] = {\n plugins: [\n createCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n ),\n ],\n define: defineOptions,\n };\n\n return {\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs'],\n exclude: ['@angular/platform-server'],\n ...(vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }),\n },\n resolve: {\n conditions: ['style'],\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,eAAe;AAQ5B,SAAgB,gBACd,MACA,UACA,QACA,QACA,OACA;AACA,KAAI,YAAY,WAAW,SAAS,EAAE;AACpC,MAAI,CAAC,WAAW,SAAS,CACvB,SAAQ,MACN,kEAAkE,SAAS,wGAC5E;AAGH,SAAO;;CAGT,IAAI,mBAAmB;AAEvB,KAAI,MACF,oBAAmB,SACf,6BACA;AAGN,KAAI,OACF,oBAAmB;AAGrB,KAAI,SACF,oBAAmB;CAGrB,MAAM,eAAe,QAAQ,MAAM,iBAAiB;AAEpD,KAAI,CAAC,WAAW,aAAa,CAC3B,SAAQ,MACN,kEAAkE,aAAa,wGAChF;AAGH,QAAO;;AAGT,SAAgB,qBACd,kBACA;AACA,KAAI,OAAO,qBAAqB,WAC9B,QAAO;AAGT,cAAa,oBAAoB;;AAYnC,SAAgB,yBAAyB,MAA2B;CAClE,MAAM,gBAAgB;EACpB,WAAW;EACX,mBAAmB;EACnB,GAAI,KAAK,YAAY,EAAE,GAAG,EAAE,WAAW,SAAS;EACjD;CAED,MAAM,kBAAkE,EACtE,SAAS,CACP,6BAA6B;EAC3B,UAAU,KAAK;EACf,WAAW,CAAC,KAAK;EACjB,uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;EACnB,CAAC,CACH,EACF;CAED,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;GACnB,EACD,KAAK,QACL,CAAC,KAAK,mBACP,CACF;EACD,QAAQ;EACT;AAED,QAAO;EACL,cAAc;GACZ,SAAS,CAAC,kBAAkB,OAAO;GACnC,SAAS,CAAC,2BAA2B;GACrC,GAAI,KAAK,kBAAkB,EAAE,iBAAiB,GAAG,EAAE,gBAAgB;GACpE;EACD,SAAS,EACP,YAAY,CAAC,QAAQ,EACtB;EACF"}
@@ -0,0 +1,2 @@
1
+ export declare function isRolldown(): boolean;
2
+ export declare function getJsTransformConfigKey(): "oxc" | "esbuild";
@@ -0,0 +1,12 @@
1
+ import * as vite from "vite";
2
+ //#region packages/vite-plugin-angular/src/lib/utils/rolldown.ts
3
+ function isRolldown() {
4
+ return !!vite.rolldownVersion;
5
+ }
6
+ function getJsTransformConfigKey() {
7
+ return isRolldown() ? "oxc" : "esbuild";
8
+ }
9
+ //#endregion
10
+ export { getJsTransformConfigKey, isRolldown };
11
+
12
+ //# sourceMappingURL=rolldown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rolldown.js","names":[],"sources":["../../../../src/lib/utils/rolldown.ts"],"sourcesContent":["import * as vite from 'vite';\n\nexport function isRolldown(): boolean {\n return !!vite.rolldownVersion;\n}\n\nexport function getJsTransformConfigKey(): 'oxc' | 'esbuild' {\n return isRolldown() ? 'oxc' : 'esbuild';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;AACpC,QAAO,CAAC,CAAC,KAAK;;AAGhB,SAAgB,0BAA6C;AAC3D,QAAO,YAAY,GAAG,QAAQ"}
@@ -1,17 +1,10 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import type ts from 'typescript';
1
+ import type ts from "typescript";
9
2
  export declare class SourceFileCache extends Map<string, ts.SourceFile> {
10
- readonly persistentCachePath?: string | undefined;
11
- readonly modifiedFiles: Set<string>;
12
- readonly babelFileCache: Map<string, Uint8Array>;
13
- readonly typeScriptFileCache: Map<string, string | Uint8Array>;
14
- referencedFiles?: readonly string[];
15
- constructor(persistentCachePath?: string | undefined);
16
- invalidate(files: Iterable<string>): void;
3
+ readonly persistentCachePath?: string | undefined;
4
+ readonly modifiedFiles: Set<string>;
5
+ readonly babelFileCache: Map<string, Uint8Array>;
6
+ readonly typeScriptFileCache: Map<string, string | Uint8Array>;
7
+ referencedFiles?: readonly string[];
8
+ constructor(persistentCachePath?: string | undefined);
9
+ invalidate(files: Iterable<string>): void;
17
10
  }
@@ -1,39 +1,37 @@
1
+ import * as path$1 from "node:path";
2
+ import { platform } from "node:os";
3
+ import { pathToFileURL } from "node:url";
4
+ //#region packages/vite-plugin-angular/src/lib/utils/source-file-cache.ts
1
5
  /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { platform } from 'node:os';
9
- import * as path from 'node:path';
10
- import { pathToFileURL } from 'node:url';
11
- const USING_WINDOWS = platform() === 'win32';
12
- const WINDOWS_SEP_REGEXP = new RegExp(`\\${path.win32.sep}`, 'g');
13
- export class SourceFileCache extends Map {
14
- persistentCachePath;
15
- modifiedFiles = new Set();
16
- babelFileCache = new Map();
17
- typeScriptFileCache = new Map();
18
- referencedFiles;
19
- constructor(persistentCachePath) {
20
- super();
21
- this.persistentCachePath = persistentCachePath;
22
- }
23
- invalidate(files) {
24
- if (files !== this.modifiedFiles) {
25
- this.modifiedFiles.clear();
26
- }
27
- for (let file of files) {
28
- this.babelFileCache.delete(file);
29
- this.typeScriptFileCache.delete(pathToFileURL(file).href);
30
- // Normalize separators to allow matching TypeScript Host paths
31
- if (USING_WINDOWS) {
32
- file = file.replace(WINDOWS_SEP_REGEXP, path.posix.sep);
33
- }
34
- this.delete(file);
35
- this.modifiedFiles.add(file);
36
- }
37
- }
38
- }
6
+ * @license
7
+ * Copyright Google LLC All Rights Reserved.
8
+ *
9
+ * Use of this source code is governed by an MIT-style license that can be
10
+ * found in the LICENSE file at https://angular.io/license
11
+ */
12
+ var USING_WINDOWS = platform() === "win32";
13
+ var WINDOWS_SEP_REGEXP = new RegExp(`\\${path$1.win32.sep}`, "g");
14
+ var SourceFileCache = class extends Map {
15
+ modifiedFiles = /* @__PURE__ */ new Set();
16
+ babelFileCache = /* @__PURE__ */ new Map();
17
+ typeScriptFileCache = /* @__PURE__ */ new Map();
18
+ referencedFiles;
19
+ constructor(persistentCachePath) {
20
+ super();
21
+ this.persistentCachePath = persistentCachePath;
22
+ }
23
+ invalidate(files) {
24
+ if (files !== this.modifiedFiles) this.modifiedFiles.clear();
25
+ for (let file of files) {
26
+ this.babelFileCache.delete(file);
27
+ this.typeScriptFileCache.delete(pathToFileURL(file).href);
28
+ if (USING_WINDOWS) file = file.replace(WINDOWS_SEP_REGEXP, path$1.posix.sep);
29
+ this.delete(file);
30
+ this.modifiedFiles.add(file);
31
+ }
32
+ }
33
+ };
34
+ //#endregion
35
+ export { SourceFileCache };
36
+
39
37
  //# sourceMappingURL=source-file-cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-file-cache.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/utils/source-file-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,aAAa,GAAG,QAAQ,EAAE,KAAK,OAAO,CAAC;AAC7C,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AAElE,MAAM,OAAO,eAAgB,SAAQ,GAA0B;IAaxC;IAZZ,aAAa,GAAgB,IAAI,GAAG,EAAU,CAAC;IAC/C,cAAc,GAA4B,IAAI,GAAG,EAGvD,CAAC;IACK,mBAAmB,GAAqC,IAAI,GAAG,EAGrE,CAAC;IAEJ,eAAe,CAAqB;IAEpC,YAAqB,mBAA4B;QAC/C,KAAK,EAAE,CAAC;QADW,wBAAmB,GAAnB,mBAAmB,CAAS;IAEjD,CAAC;IAED,UAAU,CAAC,KAAuB;QAChC,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;YACjC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;QACD,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;YAE1D,+DAA+D;YAC/D,IAAI,aAAa,EAAE,CAAC;gBAClB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1D,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAClB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"source-file-cache.js","names":[],"sources":["../../../../src/lib/utils/source-file-cache.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport { platform } from 'node:os';\nimport * as path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type ts from 'typescript';\n\nconst USING_WINDOWS = platform() === 'win32';\nconst WINDOWS_SEP_REGEXP = new RegExp(`\\\\${path.win32.sep}`, 'g');\n\nexport class SourceFileCache extends Map<string, ts.SourceFile> {\n readonly modifiedFiles: Set<string> = new Set<string>();\n readonly babelFileCache: Map<string, Uint8Array> = new Map<\n string,\n Uint8Array\n >();\n readonly typeScriptFileCache: Map<string, string | Uint8Array> = new Map<\n string,\n string | Uint8Array\n >();\n\n referencedFiles?: readonly string[];\n\n constructor(readonly persistentCachePath?: string) {\n super();\n }\n\n invalidate(files: Iterable<string>): void {\n if (files !== this.modifiedFiles) {\n this.modifiedFiles.clear();\n }\n for (let file of files) {\n this.babelFileCache.delete(file);\n this.typeScriptFileCache.delete(pathToFileURL(file).href);\n\n // Normalize separators to allow matching TypeScript Host paths\n if (USING_WINDOWS) {\n file = file.replace(WINDOWS_SEP_REGEXP, path.posix.sep);\n }\n\n this.delete(file);\n this.modifiedFiles.add(file);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAM,gBAAgB,UAAU,KAAK;AACrC,IAAM,qBAAqB,IAAI,OAAO,KAAK,OAAK,MAAM,OAAO,IAAI;AAEjE,IAAa,kBAAb,cAAqC,IAA2B;CAC9D,gCAAsC,IAAI,KAAa;CACvD,iCAAmD,IAAI,KAGpD;CACH,sCAAiE,IAAI,KAGlE;CAEH;CAEA,YAAY,qBAAuC;AACjD,SAAO;AADY,OAAA,sBAAA;;CAIrB,WAAW,OAA+B;AACxC,MAAI,UAAU,KAAK,cACjB,MAAK,cAAc,OAAO;AAE5B,OAAK,IAAI,QAAQ,OAAO;AACtB,QAAK,eAAe,OAAO,KAAK;AAChC,QAAK,oBAAoB,OAAO,cAAc,KAAK,CAAC,KAAK;AAGzD,OAAI,cACF,QAAO,KAAK,QAAQ,oBAAoB,OAAK,MAAM,IAAI;AAGzD,QAAK,OAAO,KAAK;AACjB,QAAK,cAAc,IAAI,KAAK"}
@@ -0,0 +1,12 @@
1
+ export interface CssTailwindDirectiveState {
2
+ commentlessCode: string;
3
+ hasReferenceDirective: boolean;
4
+ hasReferenceText: boolean;
5
+ hasTailwindImportDirective: boolean;
6
+ }
7
+ export declare class TailwindReferenceError extends Error {
8
+ readonly name = "TailwindReferenceError";
9
+ }
10
+ export declare function inspectCssTailwindDirectives(code: string): CssTailwindDirectiveState;
11
+ export declare function throwTailwindReferenceTextError(filename: string, rootStylesheet: string): never;
12
+ export declare function isTailwindReferenceError(error: unknown): error is TailwindReferenceError;
@@ -0,0 +1,99 @@
1
+ //#region packages/vite-plugin-angular/src/lib/utils/tailwind-reference.ts
2
+ var ANGULAR_TAILWIND_PREFIX = "[@analogjs/vite-plugin-angular]";
3
+ var CSS_REFERENCE_DIRECTIVE_REGEX = /(^|[;}\n\r])\s*@reference\b/m;
4
+ var CSS_TAILWIND_IMPORT_REGEX = /(^|[;}\n\r])\s*@import\s+["']tailwindcss["']/m;
5
+ var TailwindReferenceError = class extends Error {
6
+ name = "TailwindReferenceError";
7
+ };
8
+ function stripCssBlockComments(code) {
9
+ let result = "";
10
+ let quote = null;
11
+ for (let index = 0; index < code.length; index++) {
12
+ const character = code[index];
13
+ const nextCharacter = code[index + 1];
14
+ if (quote) {
15
+ if (character === "\\" && nextCharacter) {
16
+ result += character;
17
+ result += nextCharacter;
18
+ index++;
19
+ continue;
20
+ }
21
+ if (character === quote) quote = null;
22
+ result += character;
23
+ continue;
24
+ }
25
+ if (character === "\"" || character === "'" || character === "`") {
26
+ quote = character;
27
+ result += character;
28
+ continue;
29
+ }
30
+ if (character === "/" && nextCharacter === "*") {
31
+ result += " ";
32
+ index += 2;
33
+ while (index < code.length) {
34
+ const commentCharacter = code[index];
35
+ const commentNextCharacter = code[index + 1];
36
+ if (commentCharacter === "*" && commentNextCharacter === "/") {
37
+ result += " ";
38
+ index++;
39
+ break;
40
+ }
41
+ result += commentCharacter === "\n" || commentCharacter === "\r" ? commentCharacter : " ";
42
+ index++;
43
+ }
44
+ continue;
45
+ }
46
+ result += character;
47
+ }
48
+ return result;
49
+ }
50
+ function hasReferenceTextInComments(code) {
51
+ let quote = null;
52
+ for (let index = 0; index < code.length; index++) {
53
+ const character = code[index];
54
+ const nextCharacter = code[index + 1];
55
+ if (quote) {
56
+ if (character === "\\" && nextCharacter) {
57
+ index++;
58
+ continue;
59
+ }
60
+ if (character === quote) quote = null;
61
+ continue;
62
+ }
63
+ if (character === "\"" || character === "'" || character === "`") {
64
+ quote = character;
65
+ continue;
66
+ }
67
+ if (character === "/" && nextCharacter === "*") {
68
+ const commentStart = index + 2;
69
+ index += 2;
70
+ while (index < code.length) {
71
+ const commentCharacter = code[index];
72
+ const commentNextCharacter = code[index + 1];
73
+ if (commentCharacter === "*" && commentNextCharacter === "/") break;
74
+ index++;
75
+ }
76
+ if (code.slice(commentStart, index).includes("@reference")) return true;
77
+ }
78
+ }
79
+ return false;
80
+ }
81
+ function inspectCssTailwindDirectives(code) {
82
+ const commentlessCode = stripCssBlockComments(code);
83
+ return {
84
+ commentlessCode,
85
+ hasReferenceDirective: CSS_REFERENCE_DIRECTIVE_REGEX.test(commentlessCode),
86
+ hasReferenceText: hasReferenceTextInComments(code),
87
+ hasTailwindImportDirective: CSS_TAILWIND_IMPORT_REGEX.test(commentlessCode)
88
+ };
89
+ }
90
+ function throwTailwindReferenceTextError(filename, rootStylesheet) {
91
+ throw new TailwindReferenceError(`${ANGULAR_TAILWIND_PREFIX} Tailwind @reference auto-injection was blocked for "${filename}" because the stylesheet contains the text "@reference" but does not contain a real @reference directive.\n\nThis is usually caused by a CSS comment such as "/* ... @reference ... */".\n\nFix one of:\n - Reword the comment so it does not contain "@reference"\n - Add a real @reference "${rootStylesheet}"; directive\n`);
92
+ }
93
+ function isTailwindReferenceError(error) {
94
+ return error instanceof TailwindReferenceError;
95
+ }
96
+ //#endregion
97
+ export { inspectCssTailwindDirectives, isTailwindReferenceError, throwTailwindReferenceTextError };
98
+
99
+ //# sourceMappingURL=tailwind-reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-reference.js","names":[],"sources":["../../../../src/lib/utils/tailwind-reference.ts"],"sourcesContent":["const ANGULAR_TAILWIND_PREFIX = '[@analogjs/vite-plugin-angular]';\nconst CSS_REFERENCE_DIRECTIVE_REGEX = /(^|[;}\\n\\r])\\s*@reference\\b/m;\nconst CSS_TAILWIND_IMPORT_REGEX =\n /(^|[;}\\n\\r])\\s*@import\\s+[\"']tailwindcss[\"']/m;\n\nexport interface CssTailwindDirectiveState {\n commentlessCode: string;\n hasReferenceDirective: boolean;\n hasReferenceText: boolean;\n hasTailwindImportDirective: boolean;\n}\n\nexport class TailwindReferenceError extends Error {\n readonly name = 'TailwindReferenceError';\n}\n\n// Match real CSS directives, not prose inside block comments. The scanner keeps\n// quoted CSS content intact so `/* ... */` sequences inside strings do not get\n// mistaken for real comments.\nfunction stripCssBlockComments(code: string): string {\n let result = '';\n let quote: '\"' | \"'\" | '`' | null = null;\n\n for (let index = 0; index < code.length; index++) {\n const character = code[index];\n const nextCharacter = code[index + 1];\n\n if (quote) {\n if (character === '\\\\' && nextCharacter) {\n result += character;\n result += nextCharacter;\n index++;\n continue;\n }\n if (character === quote) {\n quote = null;\n }\n result += character;\n continue;\n }\n\n if (character === '\"' || character === \"'\" || character === '`') {\n quote = character;\n result += character;\n continue;\n }\n\n if (character === '/' && nextCharacter === '*') {\n result += ' ';\n index += 2;\n\n while (index < code.length) {\n const commentCharacter = code[index];\n const commentNextCharacter = code[index + 1];\n\n if (commentCharacter === '*' && commentNextCharacter === '/') {\n result += ' ';\n index++;\n break;\n }\n\n result +=\n commentCharacter === '\\n' || commentCharacter === '\\r'\n ? commentCharacter\n : ' ';\n index++;\n }\n continue;\n }\n\n result += character;\n }\n\n return result;\n}\n\nfunction hasReferenceTextInComments(code: string): boolean {\n let quote: '\"' | \"'\" | '`' | null = null;\n\n for (let index = 0; index < code.length; index++) {\n const character = code[index];\n const nextCharacter = code[index + 1];\n\n if (quote) {\n if (character === '\\\\' && nextCharacter) {\n index++;\n continue;\n }\n if (character === quote) {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\" || character === '`') {\n quote = character;\n continue;\n }\n\n if (character === '/' && nextCharacter === '*') {\n const commentStart = index + 2;\n index += 2;\n\n while (index < code.length) {\n const commentCharacter = code[index];\n const commentNextCharacter = code[index + 1];\n\n if (commentCharacter === '*' && commentNextCharacter === '/') {\n break;\n }\n index++;\n }\n\n if (code.slice(commentStart, index).includes('@reference')) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function inspectCssTailwindDirectives(\n code: string,\n): CssTailwindDirectiveState {\n const commentlessCode = stripCssBlockComments(code);\n\n return {\n commentlessCode,\n hasReferenceDirective: CSS_REFERENCE_DIRECTIVE_REGEX.test(commentlessCode),\n hasReferenceText: hasReferenceTextInComments(code),\n hasTailwindImportDirective: CSS_TAILWIND_IMPORT_REGEX.test(commentlessCode),\n };\n}\n\nexport function throwTailwindReferenceTextError(\n filename: string,\n rootStylesheet: string,\n): never {\n throw new TailwindReferenceError(\n `${ANGULAR_TAILWIND_PREFIX} Tailwind @reference auto-injection was ` +\n `blocked for \"${filename}\" because the stylesheet contains the ` +\n `text \"@reference\" but does not contain a real @reference ` +\n `directive.\\n\\n` +\n `This is usually caused by a CSS comment such as ` +\n `\"/* ... @reference ... */\".\\n\\n` +\n `Fix one of:\\n` +\n ` - Reword the comment so it does not contain \"@reference\"\\n` +\n ` - Add a real @reference \"${rootStylesheet}\"; directive\\n`,\n );\n}\n\nexport function isTailwindReferenceError(\n error: unknown,\n): error is TailwindReferenceError {\n return error instanceof TailwindReferenceError;\n}\n"],"mappings":";AAAA,IAAM,0BAA0B;AAChC,IAAM,gCAAgC;AACtC,IAAM,4BACJ;AASF,IAAa,yBAAb,cAA4C,MAAM;CAChD,OAAgB;;AAMlB,SAAS,sBAAsB,MAAsB;CACnD,IAAI,SAAS;CACb,IAAI,QAAgC;AAEpC,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,YAAY,KAAK;EACvB,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,MAAI,OAAO;AACT,OAAI,cAAc,QAAQ,eAAe;AACvC,cAAU;AACV,cAAU;AACV;AACA;;AAEF,OAAI,cAAc,MAChB,SAAQ;AAEV,aAAU;AACV;;AAGF,MAAI,cAAc,QAAO,cAAc,OAAO,cAAc,KAAK;AAC/D,WAAQ;AACR,aAAU;AACV;;AAGF,MAAI,cAAc,OAAO,kBAAkB,KAAK;AAC9C,aAAU;AACV,YAAS;AAET,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,mBAAmB,KAAK;IAC9B,MAAM,uBAAuB,KAAK,QAAQ;AAE1C,QAAI,qBAAqB,OAAO,yBAAyB,KAAK;AAC5D,eAAU;AACV;AACA;;AAGF,cACE,qBAAqB,QAAQ,qBAAqB,OAC9C,mBACA;AACN;;AAEF;;AAGF,YAAU;;AAGZ,QAAO;;AAGT,SAAS,2BAA2B,MAAuB;CACzD,IAAI,QAAgC;AAEpC,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,YAAY,KAAK;EACvB,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,MAAI,OAAO;AACT,OAAI,cAAc,QAAQ,eAAe;AACvC;AACA;;AAEF,OAAI,cAAc,MAChB,SAAQ;AAEV;;AAGF,MAAI,cAAc,QAAO,cAAc,OAAO,cAAc,KAAK;AAC/D,WAAQ;AACR;;AAGF,MAAI,cAAc,OAAO,kBAAkB,KAAK;GAC9C,MAAM,eAAe,QAAQ;AAC7B,YAAS;AAET,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,mBAAmB,KAAK;IAC9B,MAAM,uBAAuB,KAAK,QAAQ;AAE1C,QAAI,qBAAqB,OAAO,yBAAyB,IACvD;AAEF;;AAGF,OAAI,KAAK,MAAM,cAAc,MAAM,CAAC,SAAS,aAAa,CACxD,QAAO;;;AAKb,QAAO;;AAGT,SAAgB,6BACd,MAC2B;CAC3B,MAAM,kBAAkB,sBAAsB,KAAK;AAEnD,QAAO;EACL;EACA,uBAAuB,8BAA8B,KAAK,gBAAgB;EAC1E,kBAAkB,2BAA2B,KAAK;EAClD,4BAA4B,0BAA0B,KAAK,gBAAgB;EAC5E;;AAGH,SAAgB,gCACd,UACA,gBACO;AACP,OAAM,IAAI,uBACR,GAAG,wBAAwB,uDACT,SAAS,kSAOK,eAAe,gBAChD;;AAGH,SAAgB,yBACd,OACiC;AACjC,QAAO,iBAAiB"}
@@ -0,0 +1,8 @@
1
+ export declare const VIRTUAL_STYLE_PREFIX = "virtual:@analogjs/vite-plugin-angular:inline-style:";
2
+ export declare const VIRTUAL_RAW_PREFIX = "virtual:@analogjs/vite-plugin-angular:raw:";
3
+ export declare function toVirtualStyleId(absPath: string): string;
4
+ export declare function isVirtualStyleId(id: string): boolean;
5
+ export declare function fromVirtualStyleId(id: string): string;
6
+ export declare function toVirtualRawId(absPath: string): string;
7
+ export declare function isVirtualRawId(id: string): boolean;
8
+ export declare function fromVirtualRawId(id: string): string;
@@ -0,0 +1,35 @@
1
+ //#region packages/vite-plugin-angular/src/lib/utils/virtual-ids.ts
2
+ var VIRTUAL_STYLE_PREFIX = "virtual:@analogjs/vite-plugin-angular:inline-style:";
3
+ var VIRTUAL_RAW_PREFIX = "virtual:@analogjs/vite-plugin-angular:raw:";
4
+ function encode(absPath) {
5
+ return Buffer.from(absPath, "utf-8").toString("base64url");
6
+ }
7
+ function decode(encoded) {
8
+ return Buffer.from(encoded, "base64url").toString("utf-8");
9
+ }
10
+ function toVirtualStyleId(absPath) {
11
+ return `${VIRTUAL_STYLE_PREFIX}${encode(absPath)}`;
12
+ }
13
+ function isVirtualStyleId(id) {
14
+ return (id.startsWith("\0") ? id.slice(1) : id).startsWith(VIRTUAL_STYLE_PREFIX);
15
+ }
16
+ function fromVirtualStyleId(id) {
17
+ const normalizedId = id.startsWith("\0") ? id.slice(1) : id;
18
+ if (!normalizedId.startsWith("virtual:@analogjs/vite-plugin-angular:inline-style:")) throw new Error(`Invalid virtual style id: ${id}`);
19
+ return decode(normalizedId.slice(51));
20
+ }
21
+ function toVirtualRawId(absPath) {
22
+ return `${VIRTUAL_RAW_PREFIX}${encode(absPath)}`;
23
+ }
24
+ function isVirtualRawId(id) {
25
+ return (id.startsWith("\0") ? id.slice(1) : id).startsWith(VIRTUAL_RAW_PREFIX);
26
+ }
27
+ function fromVirtualRawId(id) {
28
+ const normalizedId = id.startsWith("\0") ? id.slice(1) : id;
29
+ if (!normalizedId.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) throw new Error(`Invalid virtual raw id: ${id}`);
30
+ return decode(normalizedId.slice(42));
31
+ }
32
+ //#endregion
33
+ export { VIRTUAL_RAW_PREFIX, VIRTUAL_STYLE_PREFIX, fromVirtualRawId, fromVirtualStyleId, isVirtualRawId, isVirtualStyleId, toVirtualRawId, toVirtualStyleId };
34
+
35
+ //# sourceMappingURL=virtual-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-ids.js","names":[],"sources":["../../../../src/lib/utils/virtual-ids.ts"],"sourcesContent":["// Virtual module id helpers for external component resources (template and\n// style files). Routing through virtual ids keeps Vite's built-in plugins\n// (vite:css, vite:asset, the server.fs Denied ID check) out of the picture:\n// the id Vite sees has no file extension, so extension-based matchers never\n// fire, and it does not match the /[?&](raw|inline)\\b/ security regex that\n// blocks user-facing ?raw and ?inline queries.\n//\n// Both prefixes share the same shape — a literal prefix followed by a\n// base64url-encoded absolute file path — so load hooks can round-trip back\n// to the source file for reading and watching. See #2263 / #2283.\n\nexport const VIRTUAL_STYLE_PREFIX =\n 'virtual:@analogjs/vite-plugin-angular:inline-style:';\n\nexport const VIRTUAL_RAW_PREFIX = 'virtual:@analogjs/vite-plugin-angular:raw:';\n\nfunction encode(absPath: string): string {\n return Buffer.from(absPath, 'utf-8').toString('base64url');\n}\n\nfunction decode(encoded: string): string {\n return Buffer.from(encoded, 'base64url').toString('utf-8');\n}\n\nexport function toVirtualStyleId(absPath: string): string {\n return `${VIRTUAL_STYLE_PREFIX}${encode(absPath)}`;\n}\n\nexport function isVirtualStyleId(id: string): boolean {\n const stripped = id.startsWith('\\0') ? id.slice(1) : id;\n return stripped.startsWith(VIRTUAL_STYLE_PREFIX);\n}\n\nexport function fromVirtualStyleId(id: string): string {\n const normalizedId = id.startsWith('\\0') ? id.slice(1) : id;\n if (!normalizedId.startsWith(VIRTUAL_STYLE_PREFIX)) {\n throw new Error(`Invalid virtual style id: ${id}`);\n }\n return decode(normalizedId.slice(VIRTUAL_STYLE_PREFIX.length));\n}\n\nexport function toVirtualRawId(absPath: string): string {\n return `${VIRTUAL_RAW_PREFIX}${encode(absPath)}`;\n}\n\nexport function isVirtualRawId(id: string): boolean {\n const stripped = id.startsWith('\\0') ? id.slice(1) : id;\n return stripped.startsWith(VIRTUAL_RAW_PREFIX);\n}\n\nexport function fromVirtualRawId(id: string): string {\n const normalizedId = id.startsWith('\\0') ? id.slice(1) : id;\n if (!normalizedId.startsWith(VIRTUAL_RAW_PREFIX)) {\n throw new Error(`Invalid virtual raw id: ${id}`);\n }\n return decode(normalizedId.slice(VIRTUAL_RAW_PREFIX.length));\n}\n"],"mappings":";AAWA,IAAa,uBACX;AAEF,IAAa,qBAAqB;AAElC,SAAS,OAAO,SAAyB;AACvC,QAAO,OAAO,KAAK,SAAS,QAAQ,CAAC,SAAS,YAAY;;AAG5D,SAAS,OAAO,SAAyB;AACvC,QAAO,OAAO,KAAK,SAAS,YAAY,CAAC,SAAS,QAAQ;;AAG5D,SAAgB,iBAAiB,SAAyB;AACxD,QAAO,GAAG,uBAAuB,OAAO,QAAQ;;AAGlD,SAAgB,iBAAiB,IAAqB;AAEpD,SADiB,GAAG,WAAW,KAAK,GAAG,GAAG,MAAM,EAAE,GAAG,IACrC,WAAW,qBAAqB;;AAGlD,SAAgB,mBAAmB,IAAoB;CACrD,MAAM,eAAe,GAAG,WAAW,KAAK,GAAG,GAAG,MAAM,EAAE,GAAG;AACzD,KAAI,CAAC,aAAa,WAAA,sDAAgC,CAChD,OAAM,IAAI,MAAM,6BAA6B,KAAK;AAEpD,QAAO,OAAO,aAAa,MAAM,GAA4B,CAAC;;AAGhE,SAAgB,eAAe,SAAyB;AACtD,QAAO,GAAG,qBAAqB,OAAO,QAAQ;;AAGhD,SAAgB,eAAe,IAAqB;AAElD,SADiB,GAAG,WAAW,KAAK,GAAG,GAAG,MAAM,EAAE,GAAG,IACrC,WAAW,mBAAmB;;AAGhD,SAAgB,iBAAiB,IAAoB;CACnD,MAAM,eAAe,GAAG,WAAW,KAAK,GAAG,GAAG,MAAM,EAAE,GAAG;AACzD,KAAI,CAAC,aAAa,WAAA,6CAA8B,CAC9C,OAAM,IAAI,MAAM,2BAA2B,KAAK;AAElD,QAAO,OAAO,aAAa,MAAM,GAA0B,CAAC"}