@analogjs/platform 3.0.0-alpha.3 → 3.0.0-alpha.31

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 (329) hide show
  1. package/package.json +30 -19
  2. package/src/index.d.ts +9 -2
  3. package/src/index.js +11 -3
  4. package/src/index.js.map +1 -0
  5. package/src/lib/clear-client-page-endpoint.d.ts +2 -2
  6. package/src/lib/clear-client-page-endpoint.js +22 -32
  7. package/src/lib/clear-client-page-endpoint.js.map +1 -0
  8. package/src/lib/content/marked/index.d.ts +5 -5
  9. package/src/lib/content/marked/index.js +10 -6
  10. package/src/lib/content/marked/index.js.map +1 -0
  11. package/src/lib/content/marked/marked-content-highlighter.d.ts +2 -2
  12. package/src/lib/content/marked/marked-content-highlighter.js +6 -3
  13. package/src/lib/content/marked/marked-content-highlighter.js.map +1 -0
  14. package/src/lib/content/marked/marked-setup.service.d.ts +8 -8
  15. package/src/lib/content/marked/marked-setup.service.js +44 -54
  16. package/src/lib/content/marked/marked-setup.service.js.map +1 -0
  17. package/src/lib/content/prism/angular.js +18 -19
  18. package/src/lib/content/prism/angular.js.map +1 -0
  19. package/src/lib/content/prism/index.d.ts +1 -1
  20. package/src/lib/content/prism/index.js +10 -7
  21. package/src/lib/content/prism/index.js.map +1 -0
  22. package/src/lib/content/prism/options.d.ts +1 -1
  23. package/src/lib/content/prism/prism-highlighter.d.ts +5 -5
  24. package/src/lib/content/prism/prism-highlighter.js +33 -33
  25. package/src/lib/content/prism/prism-highlighter.js.map +1 -0
  26. package/src/lib/content/shiki/index.d.ts +3 -3
  27. package/src/lib/content/shiki/index.js +22 -28
  28. package/src/lib/content/shiki/index.js.map +1 -0
  29. package/src/lib/content/shiki/options.d.ts +8 -7
  30. package/src/lib/content/shiki/shiki-highlighter.d.ts +14 -13
  31. package/src/lib/content/shiki/shiki-highlighter.js +49 -43
  32. package/src/lib/content/shiki/shiki-highlighter.js.map +1 -0
  33. package/src/lib/content-plugin.d.ts +19 -19
  34. package/src/lib/content-plugin.js +183 -196
  35. package/src/lib/content-plugin.js.map +1 -0
  36. package/src/lib/deps-plugin.d.ts +2 -2
  37. package/src/lib/deps-plugin.js +80 -82
  38. package/src/lib/deps-plugin.js.map +1 -0
  39. package/src/lib/discover-library-routes.d.ts +13 -0
  40. package/src/lib/discover-library-routes.js +64 -0
  41. package/src/lib/discover-library-routes.js.map +1 -0
  42. package/src/lib/i18n-extract-plugin.d.ts +33 -0
  43. package/src/lib/json-ld-manifest-plugin.d.ts +41 -0
  44. package/src/lib/json-ld-manifest-plugin.js +84 -0
  45. package/src/lib/json-ld-manifest-plugin.js.map +1 -0
  46. package/src/lib/nx-plugin/builders.json +7 -0
  47. package/src/lib/nx-plugin/executors.json +5 -0
  48. package/src/lib/nx-plugin/generators.json +25 -0
  49. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js +13 -0
  50. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js.map +1 -0
  51. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js +8 -0
  52. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js.map +1 -0
  53. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js +9 -0
  54. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js.map +1 -0
  55. package/src/lib/nx-plugin/package.json +1 -5
  56. package/src/lib/nx-plugin/src/executors/vite/compat.d.ts +1 -1
  57. package/src/lib/nx-plugin/src/executors/vite/compat.js +6 -7
  58. package/src/lib/nx-plugin/src/executors/vite/compat.js.map +1 -1
  59. package/src/lib/nx-plugin/src/executors/vite/schema.d.ts +1 -1
  60. package/src/lib/nx-plugin/src/executors/vite/vite.impl.d.ts +1 -1
  61. package/src/lib/nx-plugin/src/executors/vite/vite.impl.js +5 -4
  62. package/src/lib/nx-plugin/src/executors/vite/vite.impl.js.map +1 -1
  63. package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.d.ts +1 -1
  64. package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +6 -7
  65. package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +1 -1
  66. package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.d.ts +1 -1
  67. package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.d.ts +1 -1
  68. package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +5 -4
  69. package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +1 -1
  70. package/src/lib/nx-plugin/src/executors/vitest/compat.d.ts +1 -1
  71. package/src/lib/nx-plugin/src/executors/vitest/compat.js +6 -7
  72. package/src/lib/nx-plugin/src/executors/vitest/compat.js.map +1 -1
  73. package/src/lib/nx-plugin/src/executors/vitest/schema.d.ts +1 -1
  74. package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.d.ts +1 -1
  75. package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js +5 -4
  76. package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js.map +1 -1
  77. package/src/lib/nx-plugin/src/generators/app/compat.d.ts +9 -3
  78. package/src/lib/nx-plugin/src/generators/app/compat.js +17 -7
  79. package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
  80. package/src/lib/nx-plugin/src/generators/app/files/root/tsconfig.base.json +3 -6
  81. package/src/lib/nx-plugin/src/generators/app/files/template-angular/src/test-setup.ts__template__ +1 -0
  82. package/src/lib/nx-plugin/src/generators/app/files/template-angular/tsconfig.app.json__template__ +1 -3
  83. package/src/lib/nx-plugin/src/generators/app/files/template-angular/tsconfig.json__template__ +2 -1
  84. package/src/lib/nx-plugin/src/generators/app/files/template-angular/vite.config.ts__template__ +6 -2
  85. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/src/app/app.config.ts__template__ +0 -6
  86. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/tsconfig.json__template__ +4 -2
  87. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/vite.config.ts__template__ +0 -20
  88. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/src/app/app.config.ts__template__ +0 -6
  89. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/tsconfig.json__template__ +4 -2
  90. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/vite.config.ts__template__ +0 -20
  91. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/src/app/app.config.ts__template__ +0 -6
  92. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/tsconfig.app.json__template__ +1 -3
  93. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/tsconfig.json__template__ +4 -2
  94. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/vite.config.ts__template__ +0 -11
  95. package/src/lib/nx-plugin/src/generators/app/generator.d.ts +11 -11
  96. package/src/lib/nx-plugin/src/generators/app/generator.js +78 -92
  97. package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
  98. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.d.ts +1 -1
  99. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.d.ts +1 -1
  100. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js +72 -81
  101. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js.map +1 -1
  102. package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.d.ts +2 -2
  103. package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js +24 -58
  104. package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js.map +1 -1
  105. package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.d.ts +2 -2
  106. package/src/lib/nx-plugin/src/generators/app/lib/add-files.d.ts +2 -2
  107. package/src/lib/nx-plugin/src/generators/app/lib/add-files.js +15 -16
  108. package/src/lib/nx-plugin/src/generators/app/lib/add-files.js.map +1 -1
  109. package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.d.ts +2 -2
  110. package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js +14 -13
  111. package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js.map +1 -1
  112. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.d.ts +7 -7
  113. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js +18 -30
  114. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js.map +1 -1
  115. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.d.ts +4 -5
  116. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +61 -147
  117. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
  118. package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.d.ts +1 -1
  119. package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.d.ts +2 -2
  120. package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js +17 -20
  121. package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js.map +1 -1
  122. package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.d.ts +2 -2
  123. package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.d.ts +1 -1
  124. package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js +14 -18
  125. package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js.map +1 -1
  126. package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.d.ts +2 -3
  127. package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +6 -10
  128. package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
  129. package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.d.ts +0 -3
  130. package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.d.ts +1 -6
  131. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +12 -17
  132. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js +11 -37
  133. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
  134. package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.d.ts +1 -1
  135. package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js +11 -15
  136. package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js.map +1 -1
  137. package/src/lib/nx-plugin/src/generators/app/versions.d.ts +0 -28
  138. package/src/lib/nx-plugin/src/generators/init/compat.d.ts +9 -3
  139. package/src/lib/nx-plugin/src/generators/init/compat.js +17 -7
  140. package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
  141. package/src/lib/nx-plugin/src/generators/init/files/vite.config.ts__template__ +2 -6
  142. package/src/lib/nx-plugin/src/generators/init/generator.d.ts +3 -3
  143. package/src/lib/nx-plugin/src/generators/init/generator.js +54 -65
  144. package/src/lib/nx-plugin/src/generators/init/generator.js.map +1 -1
  145. package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.d.ts +1 -1
  146. package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +19 -20
  147. package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
  148. package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.d.ts +2 -2
  149. package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js +20 -21
  150. package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js.map +1 -1
  151. package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.d.ts +2 -2
  152. package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js +56 -66
  153. package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js.map +1 -1
  154. package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.d.ts +1 -1
  155. package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js +12 -11
  156. package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js.map +1 -1
  157. package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.d.ts +2 -2
  158. package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js +17 -21
  159. package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js.map +1 -1
  160. package/src/lib/nx-plugin/src/generators/init/lib/update-main.d.ts +2 -2
  161. package/src/lib/nx-plugin/src/generators/init/lib/update-main.js +12 -15
  162. package/src/lib/nx-plugin/src/generators/init/lib/update-main.js.map +1 -1
  163. package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.d.ts +2 -2
  164. package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js +19 -31
  165. package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js.map +1 -1
  166. package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.d.ts +2 -2
  167. package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js +43 -51
  168. package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js.map +1 -1
  169. package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.d.ts +2 -2
  170. package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js +27 -34
  171. package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js.map +1 -1
  172. package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.d.ts +2 -2
  173. package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js +19 -20
  174. package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js.map +1 -1
  175. package/src/lib/nx-plugin/src/generators/init/test-files/src/test-setup.ts__template__ +1 -0
  176. package/src/lib/nx-plugin/src/generators/page/__snapshots__/generator.spec.ts.snap +0 -7
  177. package/src/lib/nx-plugin/src/generators/page/compat.d.ts +9 -0
  178. package/src/lib/nx-plugin/src/generators/page/compat.js +18 -0
  179. package/src/lib/nx-plugin/src/generators/page/compat.js.map +1 -0
  180. package/src/lib/nx-plugin/src/generators/page/files/__fileName__.page.ts__template__ +0 -1
  181. package/src/lib/nx-plugin/src/generators/page/generator.d.ts +3 -4
  182. package/src/lib/nx-plugin/src/generators/page/generator.js +34 -44
  183. package/src/lib/nx-plugin/src/generators/page/generator.js.map +1 -1
  184. package/src/lib/nx-plugin/src/generators/preset/__snapshots__/generator.spec.ts.snap +5 -4
  185. package/src/lib/nx-plugin/src/generators/preset/generator.d.ts +3 -3
  186. package/src/lib/nx-plugin/src/generators/preset/generator.js +17 -43
  187. package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
  188. package/src/lib/nx-plugin/src/generators/setup-vitest/compat.d.ts +9 -3
  189. package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js +17 -7
  190. package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js.map +1 -1
  191. package/src/lib/nx-plugin/src/generators/setup-vitest/files/src/test-setup.ts__template__ +1 -0
  192. package/src/lib/nx-plugin/src/generators/setup-vitest/files/vite.config.mts__template__ +0 -6
  193. package/src/lib/nx-plugin/src/generators/setup-vitest/generator.d.ts +3 -3
  194. package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js +32 -42
  195. package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js.map +1 -1
  196. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.d.ts +1 -1
  197. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js +7 -7
  198. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js.map +1 -1
  199. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.d.ts +2 -2
  200. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js +20 -27
  201. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js.map +1 -1
  202. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.d.ts +2 -2
  203. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js +19 -22
  204. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js.map +1 -1
  205. package/src/lib/nx-plugin/src/index.js +0 -2
  206. package/src/lib/nx-plugin/src/utils/version-utils.d.ts +1 -1
  207. package/src/lib/nx-plugin/src/utils/version-utils.js +20 -27
  208. package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
  209. package/src/lib/nx-plugin/src/utils/versions/dependencies.js +42 -62
  210. package/src/lib/nx-plugin/src/utils/versions/dependencies.js.map +1 -1
  211. package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +49 -83
  212. package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
  213. package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.d.ts +1 -1
  214. package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js +33 -20
  215. package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js.map +1 -1
  216. package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.d.ts +1 -1
  217. package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js +33 -20
  218. package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js.map +1 -1
  219. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +8 -8
  220. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +37 -23
  221. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
  222. package/src/lib/options.d.ts +224 -80
  223. package/src/lib/platform-plugin.d.ts +2 -2
  224. package/src/lib/platform-plugin.js +88 -62
  225. package/src/lib/platform-plugin.js.map +1 -0
  226. package/src/lib/route-file-discovery.d.ts +23 -0
  227. package/src/lib/route-file-discovery.js +114 -0
  228. package/src/lib/route-file-discovery.js.map +1 -0
  229. package/src/lib/route-generation-plugin.d.ts +3 -0
  230. package/src/lib/route-generation-plugin.js +45 -0
  231. package/src/lib/route-generation-plugin.js.map +1 -0
  232. package/src/lib/route-idiom-diagnostics.d.ts +13 -0
  233. package/src/lib/route-idiom-diagnostics.js +160 -0
  234. package/src/lib/route-idiom-diagnostics.js.map +1 -0
  235. package/src/lib/route-manifest.d.ts +122 -0
  236. package/src/lib/route-manifest.js +431 -0
  237. package/src/lib/route-manifest.js.map +1 -0
  238. package/src/lib/router-plugin.d.ts +19 -19
  239. package/src/lib/router-plugin.js +234 -150
  240. package/src/lib/router-plugin.js.map +1 -0
  241. package/src/lib/ssr/inject-html-plugin.d.ts +1 -1
  242. package/src/lib/ssr/inject-html-plugin.js +25 -25
  243. package/src/lib/ssr/inject-html-plugin.js.map +1 -0
  244. package/src/lib/ssr/ssr-build-plugin.d.ts +18 -2
  245. package/src/lib/ssr/ssr-build-plugin.js +54 -30
  246. package/src/lib/ssr/ssr-build-plugin.js.map +1 -0
  247. package/src/lib/style-pipeline.d.ts +34 -0
  248. package/src/lib/style-pipeline.js +32 -0
  249. package/src/lib/style-pipeline.js.map +1 -0
  250. package/src/lib/style-preprocessor.d.ts +28 -0
  251. package/src/lib/style-preprocessor.js +35 -0
  252. package/src/lib/style-preprocessor.js.map +1 -0
  253. package/src/lib/tailwind-preprocessor.d.ts +23 -0
  254. package/src/lib/tailwind-preprocessor.js +57 -0
  255. package/src/lib/tailwind-preprocessor.js.map +1 -0
  256. package/src/lib/typed-routes-plugin.d.ts +50 -0
  257. package/src/lib/typed-routes-plugin.js +234 -0
  258. package/src/lib/typed-routes-plugin.js.map +1 -0
  259. package/src/lib/utils/debug-harness.d.ts +23 -0
  260. package/src/lib/utils/debug-harness.js +88 -0
  261. package/src/lib/utils/debug-harness.js.map +1 -0
  262. package/src/lib/utils/debug-log-file.d.ts +5 -0
  263. package/src/lib/utils/debug-log-file.js +56 -0
  264. package/src/lib/utils/debug-log-file.js.map +1 -0
  265. package/src/lib/utils/debug.d.ts +22 -0
  266. package/src/lib/utils/debug.js +27 -0
  267. package/src/lib/utils/debug.js.map +1 -0
  268. package/src/lib/utils/rolldown.d.ts +3 -0
  269. package/src/lib/utils/rolldown.js +15 -0
  270. package/src/lib/utils/rolldown.js.map +1 -0
  271. package/src/server-mode-plugin.d.ts +6 -6
  272. package/src/server-mode-plugin.js +16 -18
  273. package/src/server-mode-plugin.js.map +1 -0
  274. package/src/style-pipeline.d.ts +1 -0
  275. package/src/style-pipeline.js +2 -0
  276. package/src/style-preprocessor.d.ts +1 -0
  277. package/src/style-preprocessor.js +2 -0
  278. package/README.md +0 -5
  279. package/src/lib/content/prism/options.js +0 -1
  280. package/src/lib/content/shiki/options.js +0 -1
  281. package/src/lib/nx-plugin/README.md +0 -23
  282. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v2/postcss.config.cjs__template__ +0 -10
  283. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v2/tailwind.config.cjs__template__ +0 -14
  284. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v3/postcss.config.cjs__template__ +0 -10
  285. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v3/tailwind.config.ts__template__ +0 -14
  286. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/.postcssrc.json +0 -5
  287. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/tailwind.config.ts__template__ +0 -14
  288. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/index.html__template__ +0 -15
  289. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/app/app.component.spec.ts__template__ +0 -17
  290. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/app/app.component.ts__template__ +0 -10
  291. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/favicon.ico__template__ +0 -0
  292. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.providers.ts__template__ +0 -5
  293. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.server.ts__template__ +0 -23
  294. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.ts__template__ +0 -17
  295. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/.gitkeep__template__ +0 -0
  296. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/analog.svg__template__ +0 -1
  297. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/vite.svg__template__ +0 -1
  298. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/server/routes/v1/hello.ts__template__ +0 -3
  299. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/styles.css__template__ +0 -4
  300. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/test-setup.ts__template__ +0 -12
  301. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/vite-env.d.ts__template__ +0 -1
  302. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.app.json__template__ +0 -16
  303. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.editor.json__template__ +0 -7
  304. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.json__template__ +0 -32
  305. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.spec.json__template__ +0 -14
  306. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/vite.config.ts__template__ +0 -69
  307. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js +0 -15
  308. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js.map +0 -1
  309. package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js +0 -58
  310. package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js.map +0 -1
  311. package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js +0 -47
  312. package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js.map +0 -1
  313. package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js +0 -110
  314. package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js.map +0 -1
  315. package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js +0 -56
  316. package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js.map +0 -1
  317. package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js +0 -72
  318. package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js.map +0 -1
  319. package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js +0 -46
  320. package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js.map +0 -1
  321. package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js +0 -37
  322. package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js.map +0 -1
  323. package/src/lib/nx-plugin/src/generators/app/versions.js +0 -43
  324. package/src/lib/nx-plugin/src/generators/app/versions.js.map +0 -1
  325. package/src/lib/nx-plugin/src/index.d.ts +0 -0
  326. package/src/lib/nx-plugin/src/index.js.map +0 -1
  327. package/src/lib/options.js +0 -1
  328. package/src/lib/ssr/ssr-xhr-plugin.d.ts +0 -2
  329. package/src/lib/ssr/ssr-xhr-plugin.js +0 -28
@@ -1,31 +1,55 @@
1
- import { normalizePath } from 'vite';
2
- export function ssrBuildPlugin() {
3
- return {
4
- name: 'analogjs-ssr-build-plugin',
5
- transform(code, id) {
6
- if (id.includes('zone-node') &&
7
- code.includes('const global = globalThis;')) {
8
- return {
9
- code: code.replace('const global = globalThis;', ''),
10
- };
11
- }
12
- if (id.includes('platform-server')) {
13
- return {
14
- code: code
15
- .replace('new xhr2.XMLHttpRequest', 'new (xhr2.default.XMLHttpRequest || xhr2.default)')
16
- .replaceAll('global.', 'globalThis.')
17
- .replaceAll('global,', 'globalThis,')
18
- .replaceAll(' global[', ' globalThis['),
19
- };
20
- }
21
- // Remove usage of `with()` in sloppy.js file
22
- if (id.includes(normalizePath('domino/lib/sloppy.js'))) {
23
- return {
24
- code: code.replace(/with\(/gi, 'if('),
25
- };
26
- }
27
- return;
28
- },
29
- };
1
+ import * as vite from "vite";
2
+ import { createRequire } from "node:module";
3
+ //#region packages/platform/src/lib/ssr/ssr-build-plugin.ts
4
+ /**
5
+ * SSR build patches for Angular platform-server, Zone.js, and Domino.
6
+ *
7
+ * Returns an array of Vite plugins because under Vite 8+ (Rolldown) we
8
+ * append Rolldown's built-in `replacePlugin` for an AST-safe
9
+ * `global globalThis` rewrite that avoids false positives inside string
10
+ * literals and comments.
11
+ *
12
+ * **Why each patch exists:**
13
+ * - zone-node: removes a `const global = globalThis` alias that shadows the
14
+ * real global in strict mode.
15
+ * - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and
16
+ * replaces bare `global` references with `globalThis`.
17
+ * - xhr2: strips Node-specific `os`/`process` references for SSR bundling.
18
+ * - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.
19
+ */
20
+ function ssrBuildPlugin() {
21
+ const plugins = [{
22
+ name: "analogjs-ssr-build-plugin",
23
+ apply: "build",
24
+ config() {
25
+ return { ssr: { noExternal: ["xhr2"] } };
26
+ },
27
+ transform: {
28
+ filter: { id: /zone-node|platform-server|xhr2\.js|domino\/lib\/sloppy\.js/ },
29
+ handler(code, id) {
30
+ if (id.includes("zone-node") && code.includes("const global = globalThis;")) return { code: code.replace("const global = globalThis;", "") };
31
+ if (id.includes("platform-server")) {
32
+ let result = code.replace("new xhr2.XMLHttpRequest", "new (xhr2.default.XMLHttpRequest || xhr2.default)");
33
+ if (!vite.rolldownVersion) result = result.replaceAll("global.", "globalThis.").replaceAll("global,", "globalThis,").replaceAll(" global[", " globalThis[");
34
+ return { code: result };
35
+ }
36
+ if (id.includes(vite.normalizePath("xhr2.js"))) return { code: code.replace("os.type()", `''`).replace("os.arch()", `''`).replace("process.versions.node", `'node'`).replace("process.versions.v8", `'v8'`) };
37
+ if (id.includes(vite.normalizePath("domino/lib/sloppy.js"))) return { code: code.replace(/with\(/gi, "if(") };
38
+ }
39
+ }
40
+ }];
41
+ if (vite.rolldownVersion) {
42
+ const require = createRequire(import.meta.url);
43
+ const { replacePlugin } = require("rolldown/plugins");
44
+ const { withFilter } = require("rolldown/filter");
45
+ plugins.push(withFilter(replacePlugin({ global: "globalThis" }, {
46
+ preventAssignment: true,
47
+ objectGuards: true
48
+ }), { transform: { id: /platform-server/ } }));
49
+ }
50
+ return plugins;
30
51
  }
31
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3NyLWJ1aWxkLXBsdWdpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3BsYXRmb3JtL3NyYy9saWIvc3NyL3Nzci1idWlsZC1wbHVnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBVSxNQUFNLE1BQU0sQ0FBQztBQUU3QyxNQUFNLFVBQVUsY0FBYztJQUM1QixPQUFPO1FBQ0wsSUFBSSxFQUFFLDJCQUEyQjtRQUNqQyxTQUFTLENBQUMsSUFBSSxFQUFFLEVBQUU7WUFDaEIsSUFDRSxFQUFFLENBQUMsUUFBUSxDQUFDLFdBQVcsQ0FBQztnQkFDeEIsSUFBSSxDQUFDLFFBQVEsQ0FBQyw0QkFBNEIsQ0FBQyxFQUMzQyxDQUFDO2dCQUNELE9BQU87b0JBQ0wsSUFBSSxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsNEJBQTRCLEVBQUUsRUFBRSxDQUFDO2lCQUNyRCxDQUFDO1lBQ0osQ0FBQztZQUVELElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxpQkFBaUIsQ0FBQyxFQUFFLENBQUM7Z0JBQ25DLE9BQU87b0JBQ0wsSUFBSSxFQUFFLElBQUk7eUJBQ1AsT0FBTyxDQUNOLHlCQUF5QixFQUN6QixtREFBbUQsQ0FDcEQ7eUJBQ0EsVUFBVSxDQUFDLFNBQVMsRUFBRSxhQUFhLENBQUM7eUJBQ3BDLFVBQVUsQ0FBQyxTQUFTLEVBQUUsYUFBYSxDQUFDO3lCQUNwQyxVQUFVLENBQUMsVUFBVSxFQUFFLGNBQWMsQ0FBQztpQkFDMUMsQ0FBQztZQUNKLENBQUM7WUFFRCw2Q0FBNkM7WUFDN0MsSUFBSSxFQUFFLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBQyxzQkFBc0IsQ0FBQyxDQUFDLEVBQUUsQ0FBQztnQkFDdkQsT0FBTztvQkFDTCxJQUFJLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLEVBQUUsS0FBSyxDQUFDO2lCQUN0QyxDQUFDO1lBQ0osQ0FBQztZQUVELE9BQU87UUFDVCxDQUFDO0tBQ0YsQ0FBQztBQUNKLENBQUMifQ==
52
+ //#endregion
53
+ export { ssrBuildPlugin };
54
+
55
+ //# sourceMappingURL=ssr-build-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-build-plugin.js","names":[],"sources":["../../../../src/lib/ssr/ssr-build-plugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport * as vite from 'vite';\n\n/**\n * SSR build patches for Angular platform-server, Zone.js, and Domino.\n *\n * Returns an array of Vite plugins because under Vite 8+ (Rolldown) we\n * append Rolldown's built-in `replacePlugin` for an AST-safe\n * `global → globalThis` rewrite that avoids false positives inside string\n * literals and comments.\n *\n * **Why each patch exists:**\n * - zone-node: removes a `const global = globalThis` alias that shadows the\n * real global in strict mode.\n * - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and\n * replaces bare `global` references with `globalThis`.\n * - xhr2: strips Node-specific `os`/`process` references for SSR bundling.\n * - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.\n */\nexport function ssrBuildPlugin(): vite.Plugin[] {\n const plugins: vite.Plugin[] = [\n {\n name: 'analogjs-ssr-build-plugin',\n apply: 'build',\n config() {\n return {\n ssr: {\n noExternal: ['xhr2'],\n },\n };\n },\n transform: {\n filter: {\n id: /zone-node|platform-server|xhr2\\.js|domino\\/lib\\/sloppy\\.js/,\n },\n handler(code, id) {\n if (\n id.includes('zone-node') &&\n code.includes('const global = globalThis;')\n ) {\n return {\n code: code.replace('const global = globalThis;', ''),\n };\n }\n\n if (id.includes('platform-server')) {\n let result = code.replace(\n 'new xhr2.XMLHttpRequest',\n 'new (xhr2.default.XMLHttpRequest || xhr2.default)',\n );\n\n // Under Vite 8+ the appended `replacePlugin` handles\n // global → globalThis via AST-aware replacement (scoped to\n // platform-server by `withFilter`). For Vite ≤7 we fall back\n // to text-based replaceAll — imprecise but sufficient for the\n // known occurrences in @angular/platform-server bundles.\n if (!vite.rolldownVersion) {\n result = result\n .replaceAll('global.', 'globalThis.')\n .replaceAll('global,', 'globalThis,')\n .replaceAll(' global[', ' globalThis[');\n }\n\n return { code: result };\n }\n\n if (id.includes(vite.normalizePath('xhr2.js'))) {\n return {\n code: code\n .replace('os.type()', `''`)\n .replace('os.arch()', `''`)\n .replace('process.versions.node', `'node'`)\n .replace('process.versions.v8', `'v8'`),\n };\n }\n\n if (id.includes(vite.normalizePath('domino/lib/sloppy.js'))) {\n return {\n code: code.replace(/with\\(/gi, 'if('),\n };\n }\n\n return;\n },\n },\n },\n ];\n\n // Under Vite 8+ (Rolldown), append Rolldown's built-in `replacePlugin`\n // for AST-aware `global → globalThis` rewriting scoped to platform-server.\n //\n // `createRequire` is used instead of dynamic `import()` because this code\n // runs synchronously during plugin construction (not inside an async hook).\n // Rolldown is guaranteed to be installed when `vite.rolldownVersion` is truthy.\n if (vite.rolldownVersion) {\n const require = createRequire(import.meta.url);\n const { replacePlugin } =\n require('rolldown/plugins') as typeof import('rolldown/plugins');\n const { withFilter } =\n require('rolldown/filter') as typeof import('rolldown/filter');\n\n plugins.push(\n withFilter(\n replacePlugin(\n { global: 'globalThis' },\n { preventAssignment: true, objectGuards: true },\n ),\n { transform: { id: /platform-server/ } },\n ) as unknown as vite.Plugin,\n );\n }\n\n return plugins;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAgC;CAC9C,MAAM,UAAyB,CAC7B;EACE,MAAM;EACN,OAAO;EACP,SAAS;AACP,UAAO,EACL,KAAK,EACH,YAAY,CAAC,OAAO,EACrB,EACF;;EAEH,WAAW;GACT,QAAQ,EACN,IAAI,8DACL;GACD,QAAQ,MAAM,IAAI;AAChB,QACE,GAAG,SAAS,YAAY,IACxB,KAAK,SAAS,6BAA6B,CAE3C,QAAO,EACL,MAAM,KAAK,QAAQ,8BAA8B,GAAG,EACrD;AAGH,QAAI,GAAG,SAAS,kBAAkB,EAAE;KAClC,IAAI,SAAS,KAAK,QAChB,2BACA,oDACD;AAOD,SAAI,CAAC,KAAK,gBACR,UAAS,OACN,WAAW,WAAW,cAAc,CACpC,WAAW,WAAW,cAAc,CACpC,WAAW,YAAY,eAAe;AAG3C,YAAO,EAAE,MAAM,QAAQ;;AAGzB,QAAI,GAAG,SAAS,KAAK,cAAc,UAAU,CAAC,CAC5C,QAAO,EACL,MAAM,KACH,QAAQ,aAAa,KAAK,CAC1B,QAAQ,aAAa,KAAK,CAC1B,QAAQ,yBAAyB,SAAS,CAC1C,QAAQ,uBAAuB,OAAO,EAC1C;AAGH,QAAI,GAAG,SAAS,KAAK,cAAc,uBAAuB,CAAC,CACzD,QAAO,EACL,MAAM,KAAK,QAAQ,YAAY,MAAM,EACtC;;GAKN;EACF,CACF;AAQD,KAAI,KAAK,iBAAiB;EACxB,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;EAC9C,MAAM,EAAE,kBACN,QAAQ,mBAAmB;EAC7B,MAAM,EAAE,eACN,QAAQ,kBAAkB;AAE5B,UAAQ,KACN,WACE,cACE,EAAE,QAAQ,cAAc,EACxB;GAAE,mBAAmB;GAAM,cAAc;GAAM,CAChD,EACD,EAAE,WAAW,EAAE,IAAI,mBAAmB,EAAE,CACzC,CACF;;AAGH,QAAO"}
@@ -0,0 +1,34 @@
1
+ import type { Plugin } from "vite";
2
+ import type { StylesheetDependency, StylesheetDiagnostic, StylesheetTransformContext, StylesheetTransformResult } from "./style-preprocessor.js";
3
+ export interface StylePipelineStylesheetRegistry {
4
+ getPublicIdsForSource(sourcePath: string): string[];
5
+ getRequestIdsForSource(sourcePath: string): string[];
6
+ getDependenciesForSource(sourcePath: string): StylesheetDependency[];
7
+ getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];
8
+ getTagsForSource(sourcePath: string): string[];
9
+ }
10
+ export interface AngularStylePipelineContext {
11
+ workspaceRoot: string;
12
+ }
13
+ export interface AngularStylePipelinePlugin {
14
+ name: string;
15
+ preprocessStylesheet?: (code: string, context: StylesheetTransformContext) => string | StylesheetTransformResult | undefined;
16
+ configureStylesheetRegistry?: (registry: StylePipelineStylesheetRegistry, context: AngularStylePipelineContext) => void;
17
+ }
18
+ export interface AngularStylePipelineOptions {
19
+ plugins: AngularStylePipelinePlugin[];
20
+ }
21
+ export declare function defineAngularStylePipeline<const T extends AngularStylePipelineOptions>(options: T): T;
22
+ export declare function defineAngularStylePipelinePlugins<const T extends AngularStylePipelinePlugin[]>(plugins: T): T;
23
+ export interface StylePipelineContext {
24
+ workspaceRoot: string;
25
+ }
26
+ export type StylePipelinePluginFactory = (context: StylePipelineContext) => Plugin | Plugin[] | false | null | undefined;
27
+ export type StylePipelinePluginEntry = Plugin | Plugin[] | StylePipelinePluginFactory | false | null | undefined;
28
+ export interface StylePipelineOptions {
29
+ plugins?: StylePipelinePluginEntry[];
30
+ angularPlugins?: AngularStylePipelinePlugin[];
31
+ }
32
+ export declare function defineStylePipeline<const T extends StylePipelineOptions>(options: T): T;
33
+ export declare function defineStylePipelinePlugins<const T extends StylePipelinePluginEntry[]>(plugins: T): T;
34
+ export declare function resolveStylePipelinePlugins(options: StylePipelineOptions | false | undefined, workspaceRoot?: string): Plugin[];
@@ -0,0 +1,32 @@
1
+ //#region packages/platform/src/lib/style-pipeline.ts
2
+ function defineAngularStylePipeline(options) {
3
+ return options;
4
+ }
5
+ function defineAngularStylePipelinePlugins(plugins) {
6
+ return plugins;
7
+ }
8
+ function defineStylePipeline(options) {
9
+ return options;
10
+ }
11
+ function defineStylePipelinePlugins(plugins) {
12
+ return plugins;
13
+ }
14
+ function resolveStylePipelinePlugins(options, workspaceRoot) {
15
+ if (!options?.plugins?.length) return [];
16
+ const context = { workspaceRoot: workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd() };
17
+ const resolved = [];
18
+ for (const entry of options.plugins) {
19
+ const plugins = typeof entry === "function" ? entry(context) : entry;
20
+ if (!plugins) continue;
21
+ if (Array.isArray(plugins)) {
22
+ resolved.push(...plugins);
23
+ continue;
24
+ }
25
+ resolved.push(plugins);
26
+ }
27
+ return resolved;
28
+ }
29
+ //#endregion
30
+ export { defineAngularStylePipeline, defineAngularStylePipelinePlugins, defineStylePipeline, defineStylePipelinePlugins, resolveStylePipelinePlugins };
31
+
32
+ //# sourceMappingURL=style-pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-pipeline.js","names":[],"sources":["../../../src/lib/style-pipeline.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type {\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './style-preprocessor.js';\n\nexport interface StylePipelineStylesheetRegistry {\n getPublicIdsForSource(sourcePath: string): string[];\n getRequestIdsForSource(sourcePath: string): string[];\n getDependenciesForSource(sourcePath: string): StylesheetDependency[];\n getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];\n getTagsForSource(sourcePath: string): string[];\n}\n\nexport interface AngularStylePipelineContext {\n workspaceRoot: string;\n}\n\nexport interface AngularStylePipelinePlugin {\n name: string;\n preprocessStylesheet?: (\n code: string,\n context: StylesheetTransformContext,\n ) => string | StylesheetTransformResult | undefined;\n configureStylesheetRegistry?: (\n registry: StylePipelineStylesheetRegistry,\n context: AngularStylePipelineContext,\n ) => void;\n}\n\nexport interface AngularStylePipelineOptions {\n plugins: AngularStylePipelinePlugin[];\n}\n\nexport function defineAngularStylePipeline<\n const T extends AngularStylePipelineOptions,\n>(options: T): T {\n return options;\n}\n\nexport function defineAngularStylePipelinePlugins<\n const T extends AngularStylePipelinePlugin[],\n>(plugins: T): T {\n return plugins;\n}\n\nexport interface StylePipelineContext {\n workspaceRoot: string;\n}\n\nexport type StylePipelinePluginFactory = (\n context: StylePipelineContext,\n) => Plugin | Plugin[] | false | null | undefined;\n\nexport type StylePipelinePluginEntry =\n | Plugin\n | Plugin[]\n | StylePipelinePluginFactory\n | false\n | null\n | undefined;\n\nexport interface StylePipelineOptions {\n plugins?: StylePipelinePluginEntry[];\n angularPlugins?: AngularStylePipelinePlugin[];\n}\n\nexport function defineStylePipeline<const T extends StylePipelineOptions>(\n options: T,\n): T {\n return options;\n}\n\nexport function defineStylePipelinePlugins<\n const T extends StylePipelinePluginEntry[],\n>(plugins: T): T {\n return plugins;\n}\n\nexport function resolveStylePipelinePlugins(\n options: StylePipelineOptions | false | undefined,\n workspaceRoot?: string,\n): Plugin[] {\n if (!options?.plugins?.length) {\n return [];\n }\n\n const context: StylePipelineContext = {\n workspaceRoot:\n workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd(),\n };\n\n const resolved: Plugin[] = [];\n\n for (const entry of options.plugins) {\n const plugins = typeof entry === 'function' ? entry(context) : entry;\n\n if (!plugins) {\n continue;\n }\n\n if (Array.isArray(plugins)) {\n resolved.push(...plugins);\n continue;\n }\n\n resolved.push(plugins);\n }\n\n return resolved;\n}\n"],"mappings":";AAoCA,SAAgB,2BAEd,SAAe;AACf,QAAO;;AAGT,SAAgB,kCAEd,SAAe;AACf,QAAO;;AAwBT,SAAgB,oBACd,SACG;AACH,QAAO;;AAGT,SAAgB,2BAEd,SAAe;AACf,QAAO;;AAGT,SAAgB,4BACd,SACA,eACU;AACV,KAAI,CAAC,SAAS,SAAS,OACrB,QAAO,EAAE;CAGX,MAAM,UAAgC,EACpC,eACE,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK,EACrE;CAED,MAAM,WAAqB,EAAE;AAE7B,MAAK,MAAM,SAAS,QAAQ,SAAS;EACnC,MAAM,UAAU,OAAO,UAAU,aAAa,MAAM,QAAQ,GAAG;AAE/D,MAAI,CAAC,QACH;AAGF,MAAI,MAAM,QAAQ,QAAQ,EAAE;AAC1B,YAAS,KAAK,GAAG,QAAQ;AACzB;;AAGF,WAAS,KAAK,QAAQ;;AAGxB,QAAO"}
@@ -0,0 +1,28 @@
1
+ export interface StylesheetTransformContext {
2
+ filename: string;
3
+ containingFile?: string;
4
+ resourceFile?: string;
5
+ className?: string;
6
+ order?: number;
7
+ inline: boolean;
8
+ }
9
+ export interface StylesheetDependency {
10
+ id: string;
11
+ kind?: "file" | "virtual" | "token" | "bridge" | "manifest" | "runtime";
12
+ owner?: string;
13
+ }
14
+ export interface StylesheetDiagnostic {
15
+ severity: "warning" | "error";
16
+ code: string;
17
+ message: string;
18
+ }
19
+ export interface StylesheetTransformResult {
20
+ code: string;
21
+ dependencies?: Array<string | StylesheetDependency>;
22
+ diagnostics?: StylesheetDiagnostic[];
23
+ tags?: string[];
24
+ }
25
+ export type StylePreprocessor = (code: string, filename: string, context?: StylesheetTransformContext) => string | StylesheetTransformResult;
26
+ export declare function normalizeStylesheetTransformResult(value: string | StylesheetTransformResult | undefined, fallbackCode: string): StylesheetTransformResult;
27
+ export declare function normalizeStylesheetDependencies(dependencies: Array<string | StylesheetDependency> | undefined): StylesheetDependency[];
28
+ export declare function composeStylePreprocessors(preprocessors: Array<StylePreprocessor | false | null | undefined>): StylePreprocessor | undefined;
@@ -0,0 +1,35 @@
1
+ //#region packages/platform/src/lib/style-preprocessor.ts
2
+ function normalizeStylesheetTransformResult(value, fallbackCode) {
3
+ if (value == null) return { code: fallbackCode };
4
+ if (typeof value === "string") return { code: value };
5
+ return {
6
+ code: value.code ?? fallbackCode,
7
+ dependencies: normalizeStylesheetDependencies(value.dependencies),
8
+ diagnostics: value.diagnostics ?? [],
9
+ tags: value.tags ?? []
10
+ };
11
+ }
12
+ function normalizeStylesheetDependencies(dependencies) {
13
+ return (dependencies ?? []).map((dependency) => typeof dependency === "string" ? { id: dependency } : dependency);
14
+ }
15
+ function composeStylePreprocessors(preprocessors) {
16
+ const active = preprocessors.filter((preprocessor) => !!preprocessor);
17
+ if (!active.length) return;
18
+ return (code, filename, context) => {
19
+ let current = normalizeStylesheetTransformResult(void 0, code);
20
+ for (const preprocessor of active) {
21
+ const next = normalizeStylesheetTransformResult(preprocessor(current.code, filename, context), current.code);
22
+ current = {
23
+ code: next.code,
24
+ dependencies: [...current.dependencies ?? [], ...next.dependencies ?? []],
25
+ diagnostics: [...current.diagnostics ?? [], ...next.diagnostics ?? []],
26
+ tags: [...current.tags ?? [], ...next.tags ?? []]
27
+ };
28
+ }
29
+ return current;
30
+ };
31
+ }
32
+ //#endregion
33
+ export { composeStylePreprocessors, normalizeStylesheetDependencies, normalizeStylesheetTransformResult };
34
+
35
+ //# sourceMappingURL=style-preprocessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-preprocessor.js","names":[],"sources":["../../../src/lib/style-preprocessor.ts"],"sourcesContent":["export interface StylesheetTransformContext {\n filename: string;\n containingFile?: string;\n resourceFile?: string;\n className?: string;\n order?: number;\n inline: boolean;\n}\n\nexport interface StylesheetDependency {\n id: string;\n kind?: 'file' | 'virtual' | 'token' | 'bridge' | 'manifest' | 'runtime';\n owner?: string;\n}\n\nexport interface StylesheetDiagnostic {\n severity: 'warning' | 'error';\n code: string;\n message: string;\n}\n\nexport interface StylesheetTransformResult {\n code: string;\n dependencies?: Array<string | StylesheetDependency>;\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n}\n\nexport type StylePreprocessor = (\n code: string,\n filename: string,\n context?: StylesheetTransformContext,\n) => string | StylesheetTransformResult;\n\nexport function normalizeStylesheetTransformResult(\n value: string | StylesheetTransformResult | undefined,\n fallbackCode: string,\n): StylesheetTransformResult {\n if (value == null) {\n return { code: fallbackCode };\n }\n\n if (typeof value === 'string') {\n return { code: value };\n }\n\n return {\n code: value.code ?? fallbackCode,\n dependencies: normalizeStylesheetDependencies(value.dependencies),\n diagnostics: value.diagnostics ?? [],\n tags: value.tags ?? [],\n };\n}\n\nexport function normalizeStylesheetDependencies(\n dependencies: Array<string | StylesheetDependency> | undefined,\n): StylesheetDependency[] {\n return (dependencies ?? []).map((dependency) =>\n typeof dependency === 'string' ? { id: dependency } : dependency,\n );\n}\n\nexport function composeStylePreprocessors(\n preprocessors: Array<StylePreprocessor | false | null | undefined>,\n): StylePreprocessor | undefined {\n const active = preprocessors.filter(\n (preprocessor): preprocessor is StylePreprocessor => !!preprocessor,\n );\n\n if (!active.length) {\n return undefined;\n }\n\n return (code, filename, context) => {\n let current = normalizeStylesheetTransformResult(undefined, code);\n\n for (const preprocessor of active) {\n const next = normalizeStylesheetTransformResult(\n preprocessor(current.code, filename, context),\n current.code,\n );\n current = {\n code: next.code,\n dependencies: [\n ...(current.dependencies ?? []),\n ...(next.dependencies ?? []),\n ],\n diagnostics: [\n ...(current.diagnostics ?? []),\n ...(next.diagnostics ?? []),\n ],\n tags: [...(current.tags ?? []), ...(next.tags ?? [])],\n };\n }\n\n return current;\n };\n}\n"],"mappings":";AAkCA,SAAgB,mCACd,OACA,cAC2B;AAC3B,KAAI,SAAS,KACX,QAAO,EAAE,MAAM,cAAc;AAG/B,KAAI,OAAO,UAAU,SACnB,QAAO,EAAE,MAAM,OAAO;AAGxB,QAAO;EACL,MAAM,MAAM,QAAQ;EACpB,cAAc,gCAAgC,MAAM,aAAa;EACjE,aAAa,MAAM,eAAe,EAAE;EACpC,MAAM,MAAM,QAAQ,EAAE;EACvB;;AAGH,SAAgB,gCACd,cACwB;AACxB,SAAQ,gBAAgB,EAAE,EAAE,KAAK,eAC/B,OAAO,eAAe,WAAW,EAAE,IAAI,YAAY,GAAG,WACvD;;AAGH,SAAgB,0BACd,eAC+B;CAC/B,MAAM,SAAS,cAAc,QAC1B,iBAAoD,CAAC,CAAC,aACxD;AAED,KAAI,CAAC,OAAO,OACV;AAGF,SAAQ,MAAM,UAAU,YAAY;EAClC,IAAI,UAAU,mCAAmC,KAAA,GAAW,KAAK;AAEjE,OAAK,MAAM,gBAAgB,QAAQ;GACjC,MAAM,OAAO,mCACX,aAAa,QAAQ,MAAM,UAAU,QAAQ,EAC7C,QAAQ,KACT;AACD,aAAU;IACR,MAAM,KAAK;IACX,cAAc,CACZ,GAAI,QAAQ,gBAAgB,EAAE,EAC9B,GAAI,KAAK,gBAAgB,EAAE,CAC5B;IACD,aAAa,CACX,GAAI,QAAQ,eAAe,EAAE,EAC7B,GAAI,KAAK,eAAe,EAAE,CAC3B;IACD,MAAM,CAAC,GAAI,QAAQ,QAAQ,EAAE,EAAG,GAAI,KAAK,QAAQ,EAAE,CAAE;IACtD;;AAGH,SAAO"}
@@ -0,0 +1,23 @@
1
+ import type { StylePreprocessor } from "./style-preprocessor.js";
2
+ export type TailwindPreprocessorMode = "auto" | "disabled" | {
3
+ prefix: string;
4
+ };
5
+ export interface TailwindPreprocessorOptions {
6
+ /** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */
7
+ tailwindRootCss: string;
8
+ /**
9
+ * Controls whether the preprocessor auto-detects, disables, or manually
10
+ * overrides the Tailwind prefix for a given file.
11
+ */
12
+ mode?: TailwindPreprocessorMode | ((filename: string) => TailwindPreprocessorMode);
13
+ /**
14
+ * Optional predicate to override the default `@reference` injection behavior.
15
+ */
16
+ shouldInject?: (code: string, filename: string, resolvedPrefix: string | null) => boolean;
17
+ }
18
+ /**
19
+ * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`
20
+ * directives into Angular component styles when needed. The Tailwind prefix is
21
+ * detected from the configured root CSS file.
22
+ */
23
+ export declare function tailwindPreprocessor(options: TailwindPreprocessorOptions): StylePreprocessor;
@@ -0,0 +1,57 @@
1
+ import { debugTailwind } from "./utils/debug.js";
2
+ import path from "node:path";
3
+ import { readFileSync } from "node:fs";
4
+ //#region packages/platform/src/lib/tailwind-preprocessor.ts
5
+ /**
6
+ * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`
7
+ * directives into Angular component styles when needed. The Tailwind prefix is
8
+ * detected from the configured root CSS file.
9
+ */
10
+ function tailwindPreprocessor(options) {
11
+ const { tailwindRootCss, mode: modeOption = "auto", shouldInject } = options;
12
+ let rootPrefix;
13
+ debugTailwind("configured", {
14
+ tailwindRootCss,
15
+ mode: modeOption
16
+ });
17
+ return (code, filename) => {
18
+ if (code.includes("@reference")) {
19
+ debugTailwind("skip (already has @reference)", { filename });
20
+ return code;
21
+ }
22
+ const resolvedMode = typeof modeOption === "function" ? modeOption(filename) : modeOption;
23
+ if (resolvedMode === "disabled") {
24
+ debugTailwind("skip (mode disabled)", { filename });
25
+ return code;
26
+ }
27
+ const resolvedPrefix = typeof resolvedMode === "object" ? resolvedMode.prefix : getRootPrefix();
28
+ const isRootFile = path.resolve(filename) === path.resolve(tailwindRootCss) || /@import\s+["']tailwindcss["']/.test(code);
29
+ const hasTailwindUsage = resolvedPrefix ? code.includes(`${resolvedPrefix}:`) : false;
30
+ if (!(shouldInject ? shouldInject(code, filename, resolvedPrefix) : hasTailwindUsage && !isRootFile) || !resolvedPrefix) {
31
+ debugTailwind("skip (no injection needed)", {
32
+ filename,
33
+ resolvedPrefix,
34
+ isRootFile,
35
+ hasTailwindUsage
36
+ });
37
+ return code;
38
+ }
39
+ const refPath = path.relative(path.dirname(filename), tailwindRootCss).replace(/\\/g, "/");
40
+ debugTailwind("injected @reference", {
41
+ filename,
42
+ refPath
43
+ });
44
+ return `@reference "${refPath}";\n${code}`;
45
+ };
46
+ function getRootPrefix() {
47
+ if (rootPrefix === void 0) rootPrefix = extractTailwindPrefix(readFileSync(tailwindRootCss, "utf-8"));
48
+ return rootPrefix;
49
+ }
50
+ }
51
+ function extractTailwindPrefix(code) {
52
+ return code.match(/@import\s+["']tailwindcss["']\s+prefix\(\s*([^)\s;]+)\s*\)/i)?.[1]?.trim() ?? null;
53
+ }
54
+ //#endregion
55
+ export { tailwindPreprocessor };
56
+
57
+ //# sourceMappingURL=tailwind-preprocessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-preprocessor.js","names":[],"sources":["../../../src/lib/tailwind-preprocessor.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { debugTailwind } from './utils/debug.js';\n\nexport type TailwindPreprocessorMode = 'auto' | 'disabled' | { prefix: string };\n\nexport interface TailwindPreprocessorOptions {\n /** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */\n tailwindRootCss: string;\n\n /**\n * Controls whether the preprocessor auto-detects, disables, or manually\n * overrides the Tailwind prefix for a given file.\n */\n mode?:\n | TailwindPreprocessorMode\n | ((filename: string) => TailwindPreprocessorMode);\n\n /**\n * Optional predicate to override the default `@reference` injection behavior.\n */\n shouldInject?: (\n code: string,\n filename: string,\n resolvedPrefix: string | null,\n ) => boolean;\n}\n\n/**\n * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`\n * directives into Angular component styles when needed. The Tailwind prefix is\n * detected from the configured root CSS file.\n */\nexport function tailwindPreprocessor(\n options: TailwindPreprocessorOptions,\n): StylePreprocessor {\n const { tailwindRootCss, mode: modeOption = 'auto', shouldInject } = options;\n let rootPrefix: string | undefined;\n\n debugTailwind('configured', { tailwindRootCss, mode: modeOption });\n\n return (code: string, filename: string): string => {\n if (code.includes('@reference')) {\n debugTailwind('skip (already has @reference)', { filename });\n return code;\n }\n\n const resolvedMode =\n typeof modeOption === 'function' ? modeOption(filename) : modeOption;\n\n if (resolvedMode === 'disabled') {\n debugTailwind('skip (mode disabled)', { filename });\n return code;\n }\n\n const resolvedPrefix =\n typeof resolvedMode === 'object' ? resolvedMode.prefix : getRootPrefix();\n const isRootFile =\n path.resolve(filename) === path.resolve(tailwindRootCss) ||\n /@import\\s+[\"']tailwindcss[\"']/.test(code);\n const hasTailwindUsage = resolvedPrefix\n ? code.includes(`${resolvedPrefix}:`)\n : false;\n const shouldAddReference = shouldInject\n ? shouldInject(code, filename, resolvedPrefix)\n : hasTailwindUsage && !isRootFile;\n\n if (!shouldAddReference || !resolvedPrefix) {\n debugTailwind('skip (no injection needed)', {\n filename,\n resolvedPrefix,\n isRootFile,\n hasTailwindUsage,\n });\n return code;\n }\n\n const refPath = path\n .relative(path.dirname(filename), tailwindRootCss)\n .replace(/\\\\/g, '/');\n debugTailwind('injected @reference', { filename, refPath });\n\n return `@reference \"${refPath}\";\\n${code}`;\n };\n\n function getRootPrefix(): string | null {\n if (rootPrefix === undefined) {\n rootPrefix = extractTailwindPrefix(\n readFileSync(tailwindRootCss, 'utf-8'),\n );\n }\n\n return rootPrefix;\n }\n}\n\nfunction extractTailwindPrefix(code: string): string | null {\n const prefixMatch = code.match(\n /@import\\s+[\"']tailwindcss[\"']\\s+prefix\\(\\s*([^)\\s;]+)\\s*\\)/i,\n );\n\n return prefixMatch?.[1]?.trim() ?? null;\n}\n"],"mappings":";;;;;;;;;AAmCA,SAAgB,qBACd,SACmB;CACnB,MAAM,EAAE,iBAAiB,MAAM,aAAa,QAAQ,iBAAiB;CACrE,IAAI;AAEJ,eAAc,cAAc;EAAE;EAAiB,MAAM;EAAY,CAAC;AAElE,SAAQ,MAAc,aAA6B;AACjD,MAAI,KAAK,SAAS,aAAa,EAAE;AAC/B,iBAAc,iCAAiC,EAAE,UAAU,CAAC;AAC5D,UAAO;;EAGT,MAAM,eACJ,OAAO,eAAe,aAAa,WAAW,SAAS,GAAG;AAE5D,MAAI,iBAAiB,YAAY;AAC/B,iBAAc,wBAAwB,EAAE,UAAU,CAAC;AACnD,UAAO;;EAGT,MAAM,iBACJ,OAAO,iBAAiB,WAAW,aAAa,SAAS,eAAe;EAC1E,MAAM,aACJ,KAAK,QAAQ,SAAS,KAAK,KAAK,QAAQ,gBAAgB,IACxD,gCAAgC,KAAK,KAAK;EAC5C,MAAM,mBAAmB,iBACrB,KAAK,SAAS,GAAG,eAAe,GAAG,GACnC;AAKJ,MAAI,EAJuB,eACvB,aAAa,MAAM,UAAU,eAAe,GAC5C,oBAAoB,CAAC,eAEE,CAAC,gBAAgB;AAC1C,iBAAc,8BAA8B;IAC1C;IACA;IACA;IACA;IACD,CAAC;AACF,UAAO;;EAGT,MAAM,UAAU,KACb,SAAS,KAAK,QAAQ,SAAS,EAAE,gBAAgB,CACjD,QAAQ,OAAO,IAAI;AACtB,gBAAc,uBAAuB;GAAE;GAAU;GAAS,CAAC;AAE3D,SAAO,eAAe,QAAQ,MAAM;;CAGtC,SAAS,gBAA+B;AACtC,MAAI,eAAe,KAAA,EACjB,cAAa,sBACX,aAAa,iBAAiB,QAAQ,CACvC;AAGH,SAAO;;;AAIX,SAAS,sBAAsB,MAA6B;AAK1D,QAJoB,KAAK,MACvB,8DACD,GAEoB,IAAI,MAAM,IAAI"}
@@ -0,0 +1,50 @@
1
+ import { type Plugin } from "vite";
2
+ export interface TypedRoutesPluginOptions {
3
+ /**
4
+ * Output path for the single generated route module,
5
+ * relative to the app root.
6
+ *
7
+ * @default 'src/routeTree.gen.ts'
8
+ */
9
+ outFile?: string;
10
+ /**
11
+ * Workspace root used to resolve additional route/content directories.
12
+ *
13
+ * @default process.env['NX_WORKSPACE_ROOT'] ?? process.cwd()
14
+ */
15
+ workspaceRoot?: string;
16
+ /**
17
+ * Additional page directories to scan for `.page.ts` files.
18
+ */
19
+ additionalPagesDirs?: string[];
20
+ /**
21
+ * Additional content directories to scan for `.md` files.
22
+ */
23
+ additionalContentDirs?: string[];
24
+ /**
25
+ * Include generated `routeJsonLdManifest` exports in the generated route file.
26
+ *
27
+ * @default true
28
+ */
29
+ jsonLdManifest?: boolean;
30
+ /**
31
+ * When true, compare generated output against the existing file and
32
+ * throw an error if they differ instead of writing. Useful for CI to
33
+ * detect stale checked-in route files.
34
+ *
35
+ * @default false
36
+ */
37
+ verify?: boolean;
38
+ /**
39
+ * When true, production builds fail after regenerating a stale checked-in
40
+ * route file. This preserves self-healing writes in development while making
41
+ * build-time freshness issues visible by default.
42
+ *
43
+ * @default true
44
+ */
45
+ verifyOnBuild?: boolean;
46
+ }
47
+ /**
48
+ * Vite plugin that generates a single typed route module for Analog file routes.
49
+ */
50
+ export declare function typedRoutes(options?: TypedRoutesPluginOptions): Plugin;
@@ -0,0 +1,234 @@
1
+ import { debugTypedRouter } from "./utils/debug.js";
2
+ import { detectSchemaExports, filenameToRoutePath, formatManifestSummary, generateRouteManifest, generateRouteTableDeclaration, generateRouteTreeDeclaration } from "./route-manifest.js";
3
+ import { detectJsonLdModuleExports, extractMarkdownJsonLd, generateJsonLdManifestSource } from "./json-ld-manifest-plugin.js";
4
+ import { createRouteFileDiscovery } from "./route-file-discovery.js";
5
+ import { dirname, join, relative, resolve } from "node:path";
6
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
7
+ import { normalizePath } from "vite";
8
+ //#region packages/platform/src/lib/typed-routes-plugin.ts
9
+ var DEFAULT_OUT_FILE = "src/routeTree.gen.ts";
10
+ function resolvePluginOptions(options = {}) {
11
+ return {
12
+ outFile: options.outFile ?? DEFAULT_OUT_FILE,
13
+ workspaceRoot: options.workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd(),
14
+ additionalPagesDirs: options.additionalPagesDirs ?? [],
15
+ additionalContentDirs: options.additionalContentDirs ?? [],
16
+ jsonLdManifest: options.jsonLdManifest ?? true,
17
+ verify: options.verify ?? false,
18
+ verifyOnBuild: options.verifyOnBuild ?? true
19
+ };
20
+ }
21
+ /**
22
+ * Vite plugin that generates a single typed route module for Analog file routes.
23
+ */
24
+ function typedRoutes(options = {}) {
25
+ const resolvedOptions = resolvePluginOptions(options);
26
+ const workspaceRoot = normalizePath(resolvedOptions.workspaceRoot);
27
+ let root = "";
28
+ let command = "serve";
29
+ let discovery;
30
+ function isFreshnessCheck() {
31
+ return resolvedOptions.verify || command === "build" && resolvedOptions.verifyOnBuild;
32
+ }
33
+ function resolveDiscoveredFile(filename) {
34
+ const fromRoot = join(root, filename);
35
+ if (existsSync(fromRoot)) return fromRoot;
36
+ return join(workspaceRoot, filename);
37
+ }
38
+ function detectSchemas(relativeFilename) {
39
+ if (!relativeFilename.endsWith(".ts")) return {
40
+ hasParamsSchema: false,
41
+ hasQuerySchema: false
42
+ };
43
+ try {
44
+ return detectSchemaExports(readFileSync(resolveDiscoveredFile(relativeFilename), "utf-8"));
45
+ } catch {
46
+ return {
47
+ hasParamsSchema: false,
48
+ hasQuerySchema: false
49
+ };
50
+ }
51
+ }
52
+ /**
53
+ * Ensures the generated route file is imported from an app entry file
54
+ * so the module augmentation is always part of the TypeScript program.
55
+ */
56
+ function ensureEntryImport() {
57
+ const entryFiles = ["src/main.ts", "src/main.server.ts"];
58
+ function importSpecifierFor(entryFile) {
59
+ const rel = relative(dirname(entryFile), resolvedOptions.outFile).replace(/\.ts$/, "").replace(/\\/g, "/");
60
+ return rel.startsWith(".") ? rel : "./" + rel;
61
+ }
62
+ for (const entryFile of entryFiles) {
63
+ const entryPath = join(root, entryFile);
64
+ if (!existsSync(entryPath)) continue;
65
+ const content = readFileSync(entryPath, "utf-8");
66
+ const specifier = importSpecifierFor(entryFile);
67
+ const escaped = specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
68
+ if (new RegExp(`import\\s+['"]${escaped}(\\.ts|\\.js)?['"]`).test(content)) return;
69
+ if (isFreshnessCheck()) return;
70
+ const importLine = `import '${specifier}';`;
71
+ const lines = content.split("\n");
72
+ let lastImportLine = -1;
73
+ for (let i = 0; i < lines.length; i++) if (/^import\s/.test(lines[i])) lastImportLine = i;
74
+ if (lastImportLine >= 0) lines.splice(lastImportLine + 1, 0, importLine);
75
+ else lines.unshift(importLine);
76
+ writeFileSync(entryPath, lines.join("\n"), "utf-8");
77
+ console.log(`[analog] Added route tree import to ${entryFile}`);
78
+ return;
79
+ }
80
+ const specifier = importSpecifierFor("src/main.ts");
81
+ if (isFreshnessCheck()) return;
82
+ console.warn(`[analog] Could not find an entry file (src/main.ts or src/main.server.ts) to add the route tree import. Add \`import '${specifier}';\` to your app entry file to ensure typed routing is active.`);
83
+ }
84
+ function generate() {
85
+ const routeFiles = discovery.getRouteFiles();
86
+ const contentFiles = discovery.getContentFiles();
87
+ debugTypedRouter("discovered files", {
88
+ routeFiles: routeFiles.length,
89
+ contentFiles: contentFiles.length
90
+ });
91
+ const manifest = generateRouteManifest([...routeFiles, ...contentFiles], detectSchemas, (filename) => discovery.isAppLocal(filename) ? 0 : 1);
92
+ const declaration = generateRouteTableDeclaration(manifest);
93
+ const canonicalFiles = new Set(manifest.routes.map((route) => route.filename));
94
+ const jsonLdEntries = buildJsonLdEntries(resolveDiscoveredFile, routeFiles.filter((filename) => canonicalFiles.has(filename)), contentFiles.filter((filename) => canonicalFiles.has(filename)));
95
+ const output = combineGeneratedModules(declaration, generateRouteTreeDeclaration(manifest, { jsonLdFiles: jsonLdEntries.map((entry) => entry.sourceFile) }), resolvedOptions.jsonLdManifest && jsonLdEntries.length > 0 ? generateJsonLdManifestSource(jsonLdEntries, resolvedOptions.outFile) : "");
96
+ const hardCollisions = manifest.collisions.filter((c) => c.samePriority);
97
+ if (manifest.collisions.length > 0) debugTypedRouter("route collisions", {
98
+ total: manifest.collisions.length,
99
+ hard: hardCollisions.length,
100
+ collisions: manifest.collisions.map((c) => ({
101
+ path: c.fullPath,
102
+ kept: c.keptFile,
103
+ dropped: c.droppedFile
104
+ }))
105
+ });
106
+ if (hardCollisions.length > 0 && command === "build") {
107
+ const details = hardCollisions.map((c) => ` '${c.fullPath}': '${c.keptFile}' vs '${c.droppedFile}'`).join("\n");
108
+ throw new Error(`[analog] Route collisions detected during build:\n${details}\n\nEach route path must be defined by exactly one source file. Remove or rename the conflicting files to resolve the collision.`);
109
+ }
110
+ if (manifest.routes.length > 0) console.log(formatManifestSummary(manifest));
111
+ const outPath = join(root, resolvedOptions.outFile);
112
+ const outDir = dirname(outPath);
113
+ const hadExistingOutput = existsSync(outPath);
114
+ if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
115
+ let existing = "";
116
+ try {
117
+ existing = readFileSync(outPath, "utf-8");
118
+ } catch {}
119
+ if (output.includes(root)) console.warn(`[analog] Generated route output contains an absolute path prefix (${root}). Route keys and sourceFile values should be workspace-relative.`);
120
+ const normalizeEndings = (s) => s.replace(/\r\n/g, "\n");
121
+ if (normalizeEndings(existing) !== normalizeEndings(output)) {
122
+ debugTypedRouter("route file changed", {
123
+ outFile: resolvedOptions.outFile,
124
+ routes: manifest.routes.length,
125
+ verify: resolvedOptions.verify,
126
+ verifyOnBuild: resolvedOptions.verifyOnBuild,
127
+ command
128
+ });
129
+ if (resolvedOptions.verify) throw new Error(`[analog] Stale route file detected: ${resolvedOptions.outFile}\nThe checked-in generated route file does not match the current route sources.\nRegenerate route files and commit the updated output.`);
130
+ writeFileSync(outPath, output, "utf-8");
131
+ if (command === "build" && resolvedOptions.verifyOnBuild && hadExistingOutput) throw new Error(`[analog] Stale route file detected during build: ${resolvedOptions.outFile}\nThe generated route file was updated to match the current route sources.\nReview the updated output, commit it if it is checked in, and rerun the build.`);
132
+ }
133
+ }
134
+ return {
135
+ name: "analog-typed-routes",
136
+ config(config, env) {
137
+ command = env.command;
138
+ root = normalizePath(resolve(workspaceRoot, config.root || ".") || ".");
139
+ discovery = createRouteFileDiscovery({
140
+ root,
141
+ workspaceRoot,
142
+ additionalPagesDirs: resolvedOptions.additionalPagesDirs,
143
+ additionalContentDirs: resolvedOptions.additionalContentDirs
144
+ });
145
+ },
146
+ buildStart() {
147
+ generate();
148
+ if (!isFreshnessCheck()) ensureEntryImport();
149
+ },
150
+ configureServer(server) {
151
+ const regenerate = (path, event) => {
152
+ if (!discovery.getDiscoveredFileKind(path)) return;
153
+ debugTypedRouter("watch regenerate", {
154
+ event,
155
+ path
156
+ });
157
+ discovery.updateDiscoveredFile(path, event);
158
+ generate();
159
+ };
160
+ server.watcher.on("add", (path) => regenerate(path, "add"));
161
+ server.watcher.on("change", (path) => regenerate(path, "change"));
162
+ server.watcher.on("unlink", (path) => regenerate(path, "unlink"));
163
+ }
164
+ };
165
+ }
166
+ function buildJsonLdEntries(resolveFile, routeFiles, contentFiles) {
167
+ const entries = [];
168
+ let importIndex = 0;
169
+ routeFiles.forEach((filename) => {
170
+ try {
171
+ if (!detectJsonLdModuleExports(readFileSync(resolveFile(filename), "utf-8"))) return;
172
+ entries.push({
173
+ kind: "module",
174
+ routePath: filenameToRoutePath(filename),
175
+ sourceFile: filename,
176
+ importAlias: `routeModule${importIndex++}`
177
+ });
178
+ } catch {}
179
+ });
180
+ contentFiles.forEach((filename) => {
181
+ try {
182
+ const jsonLd = extractMarkdownJsonLd(readFileSync(resolveFile(filename), "utf-8"));
183
+ if (jsonLd.length === 0) return;
184
+ entries.push({
185
+ kind: "content",
186
+ routePath: filenameToRoutePath(filename),
187
+ sourceFile: filename,
188
+ jsonLd
189
+ });
190
+ } catch {}
191
+ });
192
+ return entries.sort((a, b) => a.routePath.localeCompare(b.routePath));
193
+ }
194
+ function combineGeneratedModules(...sources) {
195
+ const imports = [];
196
+ const seenImports = /* @__PURE__ */ new Set();
197
+ const bodies = [];
198
+ for (const source of sources) {
199
+ const { body, importLines } = splitGeneratedModule(source);
200
+ for (const importLine of importLines) if (!seenImports.has(importLine)) {
201
+ seenImports.add(importLine);
202
+ imports.push(importLine);
203
+ }
204
+ if (body.trim()) bodies.push(body.trim());
205
+ }
206
+ return [
207
+ "// This file is auto-generated by @analogjs/platform",
208
+ "// Do not edit manually",
209
+ "",
210
+ ...imports.length > 0 ? [...imports, ""] : [],
211
+ bodies.join("\n\n"),
212
+ ""
213
+ ].join("\n");
214
+ }
215
+ function splitGeneratedModule(source) {
216
+ const lines = source.split("\n");
217
+ let index = 0;
218
+ while (index < lines.length && lines[index].startsWith("//")) index++;
219
+ while (index < lines.length && lines[index] === "") index++;
220
+ const importLines = [];
221
+ while (index < lines.length && lines[index].startsWith("import ")) {
222
+ importLines.push(lines[index]);
223
+ index++;
224
+ }
225
+ while (index < lines.length && lines[index] === "") index++;
226
+ return {
227
+ importLines,
228
+ body: lines.slice(index).join("\n")
229
+ };
230
+ }
231
+ //#endregion
232
+ export { typedRoutes };
233
+
234
+ //# sourceMappingURL=typed-routes-plugin.js.map