@analogjs/platform 3.0.0-alpha.8 → 3.0.0-alpha.81

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 (374) hide show
  1. package/migrations/migration.json +7 -1
  2. package/package.json +27 -24
  3. package/src/index.d.ts +5 -2
  4. package/src/index.js +9 -3
  5. package/src/index.js.map +1 -0
  6. package/src/lib/analog-integration-plugin.d.ts +9 -0
  7. package/src/lib/analog-integration-plugin.js +22 -0
  8. package/src/lib/analog-integration-plugin.js.map +1 -0
  9. package/src/lib/clear-client-page-endpoint.d.ts +2 -2
  10. package/src/lib/clear-client-page-endpoint.js +44 -34
  11. package/src/lib/clear-client-page-endpoint.js.map +1 -0
  12. package/src/lib/content/marked/index.d.ts +5 -5
  13. package/src/lib/content/marked/index.js +10 -6
  14. package/src/lib/content/marked/index.js.map +1 -0
  15. package/src/lib/content/marked/marked-content-highlighter.d.ts +2 -2
  16. package/src/lib/content/marked/marked-content-highlighter.js +6 -3
  17. package/src/lib/content/marked/marked-content-highlighter.js.map +1 -0
  18. package/src/lib/content/marked/marked-setup.service.d.ts +8 -8
  19. package/src/lib/content/marked/marked-setup.service.js +44 -54
  20. package/src/lib/content/marked/marked-setup.service.js.map +1 -0
  21. package/src/lib/content/prism/angular.js +18 -19
  22. package/src/lib/content/prism/angular.js.map +1 -0
  23. package/src/lib/content/prism/index.d.ts +1 -1
  24. package/src/lib/content/prism/index.js +10 -7
  25. package/src/lib/content/prism/index.js.map +1 -0
  26. package/src/lib/content/prism/options.d.ts +1 -1
  27. package/src/lib/content/prism/prism-highlighter.d.ts +5 -5
  28. package/src/lib/content/prism/prism-highlighter.js +33 -33
  29. package/src/lib/content/prism/prism-highlighter.js.map +1 -0
  30. package/src/lib/content/shiki/index.d.ts +3 -3
  31. package/src/lib/content/shiki/index.js +22 -28
  32. package/src/lib/content/shiki/index.js.map +1 -0
  33. package/src/lib/content/shiki/options.d.ts +8 -7
  34. package/src/lib/content/shiki/shiki-highlighter.d.ts +14 -13
  35. package/src/lib/content/shiki/shiki-highlighter.js +49 -43
  36. package/src/lib/content/shiki/shiki-highlighter.js.map +1 -0
  37. package/src/lib/content-plugin.d.ts +19 -19
  38. package/src/lib/content-plugin.js +181 -223
  39. package/src/lib/content-plugin.js.map +1 -0
  40. package/src/lib/deps-plugin.d.ts +2 -2
  41. package/src/lib/deps-plugin.js +84 -78
  42. package/src/lib/deps-plugin.js.map +1 -0
  43. package/src/lib/discover-library-routes.d.ts +19 -0
  44. package/src/lib/discover-library-routes.js +72 -0
  45. package/src/lib/discover-library-routes.js.map +1 -0
  46. package/src/lib/i18n-component-registry-plugin.d.ts +17 -0
  47. package/src/lib/i18n-component-registry-plugin.js +100 -0
  48. package/src/lib/i18n-component-registry-plugin.js.map +1 -0
  49. package/src/lib/i18n-extract-plugin.d.ts +33 -0
  50. package/src/lib/inject-server-fn-ids.d.ts +17 -0
  51. package/src/lib/inject-server-fn-ids.js +94 -0
  52. package/src/lib/inject-server-fn-ids.js.map +1 -0
  53. package/src/lib/json-ld-manifest-plugin.d.ts +41 -0
  54. package/src/lib/json-ld-manifest-plugin.js +84 -0
  55. package/src/lib/json-ld-manifest-plugin.js.map +1 -0
  56. package/src/lib/nitro/analog-nitro-plugin.d.ts +18 -0
  57. package/src/lib/nitro/analog-nitro-plugin.js +555 -0
  58. package/src/lib/nitro/analog-nitro-plugin.js.map +1 -0
  59. package/src/lib/nitro/angular-linker-plugin.d.ts +17 -0
  60. package/src/lib/nitro/angular-linker-plugin.js +51 -0
  61. package/src/lib/nitro/angular-linker-plugin.js.map +1 -0
  62. package/src/lib/nitro/build-sitemap.d.ts +23 -0
  63. package/src/lib/nitro/build-sitemap.js +137 -0
  64. package/src/lib/nitro/build-sitemap.js.map +1 -0
  65. package/src/lib/nitro/debug.d.ts +5 -0
  66. package/src/lib/nitro/debug.js +11 -0
  67. package/src/lib/nitro/debug.js.map +1 -0
  68. package/src/lib/nitro/get-content-files.d.ts +13 -0
  69. package/src/lib/nitro/get-content-files.js +52 -0
  70. package/src/lib/nitro/get-content-files.js.map +1 -0
  71. package/src/lib/nitro/get-page-handlers.d.ts +22 -0
  72. package/src/lib/nitro/get-page-handlers.js +33 -0
  73. package/src/lib/nitro/get-page-handlers.js.map +1 -0
  74. package/src/lib/nitro/i18n-prerender.d.ts +29 -0
  75. package/src/lib/nitro/i18n-prerender.js +61 -0
  76. package/src/lib/nitro/i18n-prerender.js.map +1 -0
  77. package/src/lib/nitro/page-endpoints-plugin.d.ts +7 -0
  78. package/src/lib/nitro/page-endpoints-plugin.js +72 -0
  79. package/src/lib/nitro/page-endpoints-plugin.js.map +1 -0
  80. package/src/lib/nitro/post-rendering-hook.d.ts +2 -0
  81. package/src/lib/nitro/post-rendering-hook.js +10 -0
  82. package/src/lib/nitro/post-rendering-hook.js.map +1 -0
  83. package/src/lib/nitro/renderers.d.ts +33 -0
  84. package/src/lib/nitro/renderers.js +22 -0
  85. package/src/lib/nitro/renderers.js.map +1 -0
  86. package/src/lib/nitro/types.d.ts +122 -0
  87. package/src/lib/nx-plugin/_virtual/_rolldown/runtime.js +23 -0
  88. package/src/lib/nx-plugin/builders.json +15 -0
  89. package/src/lib/nx-plugin/executors.json +13 -5
  90. package/src/lib/nx-plugin/generators.json +25 -0
  91. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js +13 -0
  92. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js.map +1 -0
  93. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js +8 -0
  94. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js.map +1 -0
  95. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js +9 -0
  96. package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js.map +1 -0
  97. package/src/lib/nx-plugin/package.json +1 -5
  98. package/src/lib/nx-plugin/src/builders/vite/schema.json +39 -0
  99. package/src/lib/nx-plugin/src/builders/vite/vite-build.d.ts +11 -0
  100. package/src/lib/nx-plugin/src/builders/vite/vite-build.js +18 -0
  101. package/src/lib/nx-plugin/src/builders/vite/vite-build.js.map +1 -0
  102. package/src/lib/nx-plugin/src/builders/vite-dev-server/dev-server.d.ts +7 -0
  103. package/src/lib/nx-plugin/src/builders/vite-dev-server/dev-server.js +14 -0
  104. package/src/lib/nx-plugin/src/builders/vite-dev-server/dev-server.js.map +1 -0
  105. package/src/lib/nx-plugin/src/builders/vite-dev-server/schema.json +27 -0
  106. package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.d.ts +1 -1
  107. package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +7 -7
  108. package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +1 -1
  109. package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.d.ts +1 -1
  110. package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.d.ts +1 -1
  111. package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +6 -4
  112. package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +1 -1
  113. package/src/lib/nx-plugin/src/executors/vitest/compat.d.ts +1 -1
  114. package/src/lib/nx-plugin/src/executors/vitest/compat.js +7 -7
  115. package/src/lib/nx-plugin/src/executors/vitest/compat.js.map +1 -1
  116. package/src/lib/nx-plugin/src/executors/vitest/schema.d.ts +1 -1
  117. package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.d.ts +1 -1
  118. package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js +6 -4
  119. package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js.map +1 -1
  120. package/src/lib/nx-plugin/src/generators/app/compat.d.ts +9 -3
  121. package/src/lib/nx-plugin/src/generators/app/compat.js +18 -7
  122. package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
  123. package/src/lib/nx-plugin/src/generators/app/files/agents/AGENTS.md +11 -0
  124. package/src/lib/nx-plugin/src/generators/app/files/agents/CLAUDE.md +1 -0
  125. package/src/lib/nx-plugin/src/generators/app/files/root/tsconfig.base.json +3 -6
  126. package/src/lib/nx-plugin/src/generators/app/files/template-angular/src/test-setup.ts__template__ +1 -0
  127. package/src/lib/nx-plugin/src/generators/app/files/template-angular/tsconfig.app.json__template__ +1 -3
  128. package/src/lib/nx-plugin/src/generators/app/files/template-angular/tsconfig.json__template__ +2 -1
  129. package/src/lib/nx-plugin/src/generators/app/files/template-angular/vite.config.ts__template__ +6 -2
  130. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/src/app/app.config.ts__template__ +0 -6
  131. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/tsconfig.json__template__ +4 -2
  132. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/vite.config.ts__template__ +1 -21
  133. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/src/app/app.config.ts__template__ +0 -6
  134. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/tsconfig.json__template__ +4 -2
  135. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/vite.config.ts__template__ +2 -22
  136. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/src/app/app.config.ts__template__ +0 -6
  137. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/tsconfig.app.json__template__ +1 -3
  138. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/tsconfig.json__template__ +4 -2
  139. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/vite.config.ts__template__ +1 -12
  140. package/src/lib/nx-plugin/src/generators/app/generator.d.ts +11 -11
  141. package/src/lib/nx-plugin/src/generators/app/generator.js +81 -92
  142. package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
  143. package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.d.ts +2 -0
  144. package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.js +16 -0
  145. package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.js.map +1 -0
  146. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.d.ts +1 -1
  147. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.d.ts +1 -1
  148. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js +73 -81
  149. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js.map +1 -1
  150. package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.d.ts +2 -2
  151. package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js +25 -58
  152. package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js.map +1 -1
  153. package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.d.ts +2 -2
  154. package/src/lib/nx-plugin/src/generators/app/lib/add-files.d.ts +2 -2
  155. package/src/lib/nx-plugin/src/generators/app/lib/add-files.js +16 -16
  156. package/src/lib/nx-plugin/src/generators/app/lib/add-files.js.map +1 -1
  157. package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.d.ts +2 -2
  158. package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js +15 -13
  159. package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js.map +1 -1
  160. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.d.ts +7 -7
  161. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js +19 -29
  162. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js.map +1 -1
  163. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.d.ts +4 -5
  164. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +61 -103
  165. package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
  166. package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.d.ts +1 -1
  167. package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.d.ts +2 -2
  168. package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js +17 -20
  169. package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js.map +1 -1
  170. package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.d.ts +2 -2
  171. package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.d.ts +1 -1
  172. package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js +15 -18
  173. package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js.map +1 -1
  174. package/src/lib/nx-plugin/src/generators/app/schema.d.ts +2 -0
  175. package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.d.ts +2 -3
  176. package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +7 -10
  177. package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
  178. package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.d.ts +0 -3
  179. package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.d.ts +1 -6
  180. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +12 -17
  181. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js +11 -37
  182. package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
  183. package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.d.ts +1 -1
  184. package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js +11 -15
  185. package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js.map +1 -1
  186. package/src/lib/nx-plugin/src/generators/app/versions.d.ts +0 -28
  187. package/src/lib/nx-plugin/src/generators/init/compat.d.ts +9 -3
  188. package/src/lib/nx-plugin/src/generators/init/compat.js +18 -7
  189. package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
  190. package/src/lib/nx-plugin/src/generators/init/files/vite.config.ts__template__ +2 -6
  191. package/src/lib/nx-plugin/src/generators/init/generator.d.ts +3 -3
  192. package/src/lib/nx-plugin/src/generators/init/generator.js +55 -65
  193. package/src/lib/nx-plugin/src/generators/init/generator.js.map +1 -1
  194. package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.d.ts +1 -1
  195. package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +20 -20
  196. package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
  197. package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.d.ts +2 -2
  198. package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js +21 -21
  199. package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js.map +1 -1
  200. package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.d.ts +2 -2
  201. package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js +57 -66
  202. package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js.map +1 -1
  203. package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.d.ts +1 -1
  204. package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js +12 -11
  205. package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js.map +1 -1
  206. package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.d.ts +2 -2
  207. package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js +18 -21
  208. package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js.map +1 -1
  209. package/src/lib/nx-plugin/src/generators/init/lib/update-main.d.ts +2 -2
  210. package/src/lib/nx-plugin/src/generators/init/lib/update-main.js +13 -15
  211. package/src/lib/nx-plugin/src/generators/init/lib/update-main.js.map +1 -1
  212. package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.d.ts +2 -2
  213. package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js +20 -31
  214. package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js.map +1 -1
  215. package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.d.ts +2 -2
  216. package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js +44 -51
  217. package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js.map +1 -1
  218. package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.d.ts +2 -2
  219. package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js +28 -34
  220. package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js.map +1 -1
  221. package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.d.ts +2 -2
  222. package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js +20 -20
  223. package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js.map +1 -1
  224. package/src/lib/nx-plugin/src/generators/init/test-files/src/test-setup.ts__template__ +1 -0
  225. package/src/lib/nx-plugin/src/generators/page/__snapshots__/generator.spec.ts.snap +0 -7
  226. package/src/lib/nx-plugin/src/generators/page/compat.d.ts +9 -0
  227. package/src/lib/nx-plugin/src/generators/page/compat.js +19 -0
  228. package/src/lib/nx-plugin/src/generators/page/compat.js.map +1 -0
  229. package/src/lib/nx-plugin/src/generators/page/files/__fileName__.page.ts__template__ +0 -1
  230. package/src/lib/nx-plugin/src/generators/page/generator.d.ts +3 -4
  231. package/src/lib/nx-plugin/src/generators/page/generator.js +35 -44
  232. package/src/lib/nx-plugin/src/generators/page/generator.js.map +1 -1
  233. package/src/lib/nx-plugin/src/generators/preset/__snapshots__/generator.spec.ts.snap +8 -7
  234. package/src/lib/nx-plugin/src/generators/preset/generator.d.ts +3 -3
  235. package/src/lib/nx-plugin/src/generators/preset/generator.js +24 -43
  236. package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
  237. package/src/lib/nx-plugin/src/generators/setup-vitest/compat.d.ts +9 -3
  238. package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js +18 -7
  239. package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js.map +1 -1
  240. package/src/lib/nx-plugin/src/generators/setup-vitest/files/src/test-setup.ts__template__ +1 -0
  241. package/src/lib/nx-plugin/src/generators/setup-vitest/files/vite.config.mts__template__ +0 -6
  242. package/src/lib/nx-plugin/src/generators/setup-vitest/generator.d.ts +3 -3
  243. package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js +33 -42
  244. package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js.map +1 -1
  245. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.d.ts +1 -1
  246. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js +8 -7
  247. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js.map +1 -1
  248. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.d.ts +2 -2
  249. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js +21 -27
  250. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js.map +1 -1
  251. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.d.ts +2 -2
  252. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js +20 -22
  253. package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js.map +1 -1
  254. package/src/lib/nx-plugin/src/index.js +0 -2
  255. package/src/lib/nx-plugin/src/utils/version-utils.d.ts +1 -1
  256. package/src/lib/nx-plugin/src/utils/version-utils.js +21 -27
  257. package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
  258. package/src/lib/nx-plugin/src/utils/versions/dependencies.js +43 -62
  259. package/src/lib/nx-plugin/src/utils/versions/dependencies.js.map +1 -1
  260. package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +50 -83
  261. package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
  262. package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.d.ts +1 -1
  263. package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js +33 -20
  264. package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js.map +1 -1
  265. package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.d.ts +1 -1
  266. package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js +33 -20
  267. package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js.map +1 -1
  268. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +9 -8
  269. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +39 -23
  270. package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
  271. package/src/lib/options.d.ts +165 -84
  272. package/src/lib/platform-plugin.d.ts +2 -2
  273. package/src/lib/platform-plugin.js +45 -65
  274. package/src/lib/platform-plugin.js.map +1 -0
  275. package/src/lib/route-file-discovery.d.ts +23 -0
  276. package/src/lib/route-file-discovery.js +114 -0
  277. package/src/lib/route-file-discovery.js.map +1 -0
  278. package/src/lib/route-generation-plugin.d.ts +3 -0
  279. package/src/lib/route-generation-plugin.js +45 -0
  280. package/src/lib/route-generation-plugin.js.map +1 -0
  281. package/src/lib/route-idiom-diagnostics.d.ts +13 -0
  282. package/src/lib/route-idiom-diagnostics.js +160 -0
  283. package/src/lib/route-idiom-diagnostics.js.map +1 -0
  284. package/src/lib/route-manifest.d.ts +122 -0
  285. package/src/lib/route-manifest.js +431 -0
  286. package/src/lib/route-manifest.js.map +1 -0
  287. package/src/lib/router-plugin.d.ts +19 -19
  288. package/src/lib/router-plugin.js +229 -185
  289. package/src/lib/router-plugin.js.map +1 -0
  290. package/src/lib/server-fn-client-transform.d.ts +26 -0
  291. package/src/lib/server-fn-client-transform.js +97 -0
  292. package/src/lib/server-fn-client-transform.js.map +1 -0
  293. package/src/lib/server-fn-id.d.ts +25 -0
  294. package/src/lib/server-fn-id.js +37 -0
  295. package/src/lib/server-fn-id.js.map +1 -0
  296. package/src/lib/ssr/defer-streaming-plugin.d.ts +65 -0
  297. package/src/lib/ssr/inject-html-plugin.d.ts +1 -1
  298. package/src/lib/ssr/inject-html-plugin.js +25 -25
  299. package/src/lib/ssr/inject-html-plugin.js.map +1 -0
  300. package/src/lib/ssr/ssr-build-plugin.d.ts +24 -16
  301. package/src/lib/ssr/ssr-build-plugin.js +37 -88
  302. package/src/lib/ssr/ssr-build-plugin.js.map +1 -0
  303. package/src/lib/typed-routes-plugin.d.ts +50 -0
  304. package/src/lib/typed-routes-plugin.js +234 -0
  305. package/src/lib/typed-routes-plugin.js.map +1 -0
  306. package/src/lib/utils/debug-harness.d.ts +23 -0
  307. package/src/lib/utils/debug-harness.js +88 -0
  308. package/src/lib/utils/debug-harness.js.map +1 -0
  309. package/src/lib/utils/debug-log-file.d.ts +5 -0
  310. package/src/lib/utils/debug-log-file.js +56 -0
  311. package/src/lib/utils/debug-log-file.js.map +1 -0
  312. package/src/lib/utils/debug.d.ts +20 -0
  313. package/src/lib/utils/debug.js +24 -0
  314. package/src/lib/utils/debug.js.map +1 -0
  315. package/src/lib/utils/rolldown.d.ts +2 -2
  316. package/src/lib/utils/rolldown.js +12 -8
  317. package/src/lib/utils/rolldown.js.map +1 -0
  318. package/src/server-mode-plugin.d.ts +5 -5
  319. package/src/server-mode-plugin.js +16 -20
  320. package/src/server-mode-plugin.js.map +1 -0
  321. package/README.md +0 -5
  322. package/src/lib/content/prism/options.js +0 -1
  323. package/src/lib/content/shiki/options.js +0 -1
  324. package/src/lib/nx-plugin/README.md +0 -23
  325. package/src/lib/nx-plugin/src/executors/vite/compat.d.ts +0 -3
  326. package/src/lib/nx-plugin/src/executors/vite/compat.js +0 -8
  327. package/src/lib/nx-plugin/src/executors/vite/compat.js.map +0 -1
  328. package/src/lib/nx-plugin/src/executors/vite/schema.d.ts +0 -2
  329. package/src/lib/nx-plugin/src/executors/vite/schema.json +0 -147
  330. package/src/lib/nx-plugin/src/executors/vite/vite.impl.d.ts +0 -2
  331. package/src/lib/nx-plugin/src/executors/vite/vite.impl.js +0 -5
  332. package/src/lib/nx-plugin/src/executors/vite/vite.impl.js.map +0 -1
  333. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/.postcssrc.json +0 -5
  334. package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/tailwind.config.ts__template__ +0 -14
  335. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/index.html__template__ +0 -15
  336. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/app/app.component.spec.ts__template__ +0 -17
  337. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/app/app.component.ts__template__ +0 -10
  338. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/favicon.ico__template__ +0 -0
  339. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.providers.ts__template__ +0 -5
  340. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.server.ts__template__ +0 -23
  341. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.ts__template__ +0 -17
  342. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/.gitkeep__template__ +0 -0
  343. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/analog.svg__template__ +0 -1
  344. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/vite.svg__template__ +0 -1
  345. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/server/routes/v1/hello.ts__template__ +0 -3
  346. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/styles.css__template__ +0 -4
  347. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/test-setup.ts__template__ +0 -12
  348. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/vite-env.d.ts__template__ +0 -1
  349. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.app.json__template__ +0 -16
  350. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.editor.json__template__ +0 -7
  351. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.json__template__ +0 -32
  352. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.spec.json__template__ +0 -14
  353. package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/vite.config.ts__template__ +0 -69
  354. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js +0 -15
  355. package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js.map +0 -1
  356. package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js +0 -58
  357. package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js.map +0 -1
  358. package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js +0 -47
  359. package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js.map +0 -1
  360. package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js +0 -110
  361. package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js.map +0 -1
  362. package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js +0 -56
  363. package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js.map +0 -1
  364. package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js +0 -72
  365. package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js.map +0 -1
  366. package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js +0 -46
  367. package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js.map +0 -1
  368. package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js +0 -37
  369. package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js.map +0 -1
  370. package/src/lib/nx-plugin/src/generators/app/versions.js +0 -43
  371. package/src/lib/nx-plugin/src/generators/app/versions.js.map +0 -1
  372. package/src/lib/nx-plugin/src/index.d.ts +0 -0
  373. package/src/lib/nx-plugin/src/index.js.map +0 -1
  374. package/src/lib/options.js +0 -1
@@ -0,0 +1,84 @@
1
+ import { normalizeJsonLd } from "./route-manifest.js";
2
+ import { dirname, relative } from "node:path";
3
+ import { normalizePath } from "vite";
4
+ import fm from "front-matter";
5
+ //#region packages/platform/src/lib/json-ld-manifest-plugin.ts
6
+ /**
7
+ * Heuristic detector for JSON-LD exports in route modules.
8
+ *
9
+ * This is intentionally regex-based for speed during file scanning.
10
+ * It reliably detects these direct export patterns:
11
+ *
12
+ * - `export const routeJsonLd = ...`
13
+ * - `export const routeMeta = { ..., jsonLd: ... }`
14
+ * - `export const routeJsonLd = (route) => ...` (function form)
15
+ *
16
+ * Known limitations (not detected):
17
+ *
18
+ * - re-exports: `export { routeJsonLd } from './data'`
19
+ * - aliased exports: `export { something as routeJsonLd }`
20
+ * - default exports: `export default { jsonLd: ... }`
21
+ * - indirect assignment: `const data = { jsonLd: ... }; export const routeMeta = data`
22
+ *
23
+ * Known false-positive risks:
24
+ *
25
+ * - comment text containing `export const routeJsonLd`
26
+ * - unrelated `jsonLd` text appearing after `export const routeMeta`
27
+ *
28
+ * Prefer the supported direct export patterns listed above.
29
+ */
30
+ function detectJsonLdModuleExports(fileContent) {
31
+ return /export\s+const\s+routeJsonLd\b/.test(fileContent) || /export\s+const\s+routeMeta\b[\s\S]*?\bjsonLd\b/.test(fileContent);
32
+ }
33
+ function extractMarkdownJsonLd(rawContent) {
34
+ const { attributes } = fm(rawContent);
35
+ return normalizeJsonLd(attributes["jsonLd"]);
36
+ }
37
+ function generateJsonLdManifestSource(entries, outFile) {
38
+ const lines = [];
39
+ const moduleEntries = entries.filter((entry) => entry.kind === "module");
40
+ lines.push("// This file is auto-generated by @analogjs/platform");
41
+ lines.push("// Do not edit manually");
42
+ lines.push("");
43
+ lines.push("import type { Graph, Thing, WithContext } from 'schema-dts';");
44
+ moduleEntries.forEach((entry) => {
45
+ lines.push(`import * as ${entry.importAlias} from '${toImportPath(outFile, entry.sourceFile)}';`);
46
+ });
47
+ lines.push("");
48
+ lines.push("export type AnalogJsonLdDocument = WithContext<Thing> | Graph | Array<WithContext<Thing>>;");
49
+ lines.push("export type GeneratedJsonLdManifestEntry = { routePath: string; sourceFile: string; kind: 'module' | 'content'; resolveJsonLd: () => AnalogJsonLdDocument[]; };");
50
+ lines.push("");
51
+ lines.push("function normalizeJsonLd(value: unknown): AnalogJsonLdDocument[] {");
52
+ lines.push(" if (Array.isArray(value)) {");
53
+ lines.push(" return value.filter((entry): entry is AnalogJsonLdDocument => typeof entry === 'object' && entry !== null && !Array.isArray(entry));");
54
+ lines.push(" }");
55
+ lines.push("");
56
+ lines.push(" return typeof value === 'object' && value !== null ? [value as AnalogJsonLdDocument] : [];");
57
+ lines.push("}");
58
+ lines.push("");
59
+ lines.push("function resolveModuleJsonLd(routeModule: unknown): AnalogJsonLdDocument[] {");
60
+ lines.push(" const typedRouteModule = routeModule as { routeJsonLd?: unknown; routeMeta?: { jsonLd?: unknown } };");
61
+ lines.push(" return normalizeJsonLd(typedRouteModule.routeMeta?.jsonLd ?? typedRouteModule.routeJsonLd);");
62
+ lines.push("}");
63
+ lines.push("");
64
+ lines.push("export const routeJsonLdManifest = new Map<string, GeneratedJsonLdManifestEntry>([");
65
+ entries.forEach((entry) => {
66
+ if (entry.kind === "module") {
67
+ lines.push(` ['${entry.routePath}', { routePath: '${entry.routePath}', sourceFile: '${entry.sourceFile}', kind: 'module', resolveJsonLd: () => resolveModuleJsonLd(${entry.importAlias}) }],`);
68
+ return;
69
+ }
70
+ lines.push(` ['${entry.routePath}', { routePath: '${entry.routePath}', sourceFile: '${entry.sourceFile}', kind: 'content', resolveJsonLd: () => ${JSON.stringify(entry.jsonLd)} }],`);
71
+ });
72
+ lines.push("]);");
73
+ lines.push("");
74
+ return lines.join("\n");
75
+ }
76
+ function toImportPath(outFile, sourceFile) {
77
+ const relativePath = normalizePath(relative(dirname(outFile), sourceFile.replace(/^\//, "").replace(/\.(ts|js|analog|ag)$/, "")));
78
+ if (relativePath.startsWith(".")) return relativePath;
79
+ return `./${relativePath}`;
80
+ }
81
+ //#endregion
82
+ export { detectJsonLdModuleExports, extractMarkdownJsonLd, generateJsonLdManifestSource };
83
+
84
+ //# sourceMappingURL=json-ld-manifest-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-ld-manifest-plugin.js","names":[],"sources":["../../../src/lib/json-ld-manifest-plugin.ts"],"sourcesContent":["import fm from 'front-matter';\nimport { normalizePath } from 'vite';\nimport { dirname, relative } from 'node:path';\n\nimport { normalizeJsonLd, type JsonLdObject } from './route-manifest.js';\n\nexport type JsonLdModuleManifestEntry = {\n kind: 'module';\n routePath: string;\n sourceFile: string;\n importAlias: string;\n};\n\nexport type JsonLdContentManifestEntry = {\n kind: 'content';\n routePath: string;\n sourceFile: string;\n jsonLd: JsonLdObject[];\n};\n\nexport type JsonLdManifestEntry =\n | JsonLdModuleManifestEntry\n | JsonLdContentManifestEntry;\n\n/**\n * Heuristic detector for JSON-LD exports in route modules.\n *\n * This is intentionally regex-based for speed during file scanning.\n * It reliably detects these direct export patterns:\n *\n * - `export const routeJsonLd = ...`\n * - `export const routeMeta = { ..., jsonLd: ... }`\n * - `export const routeJsonLd = (route) => ...` (function form)\n *\n * Known limitations (not detected):\n *\n * - re-exports: `export { routeJsonLd } from './data'`\n * - aliased exports: `export { something as routeJsonLd }`\n * - default exports: `export default { jsonLd: ... }`\n * - indirect assignment: `const data = { jsonLd: ... }; export const routeMeta = data`\n *\n * Known false-positive risks:\n *\n * - comment text containing `export const routeJsonLd`\n * - unrelated `jsonLd` text appearing after `export const routeMeta`\n *\n * Prefer the supported direct export patterns listed above.\n */\nexport function detectJsonLdModuleExports(fileContent: string): boolean {\n return (\n /export\\s+const\\s+routeJsonLd\\b/.test(fileContent) ||\n /export\\s+const\\s+routeMeta\\b[\\s\\S]*?\\bjsonLd\\b/.test(fileContent)\n );\n}\n\nexport function extractMarkdownJsonLd(rawContent: string): JsonLdObject[] {\n const { attributes } = fm<Record<string, unknown>>(rawContent);\n return normalizeJsonLd(attributes['jsonLd']);\n}\n\nexport function generateJsonLdManifestSource(\n entries: JsonLdManifestEntry[],\n outFile: string,\n): string {\n const lines: string[] = [];\n const moduleEntries = entries.filter(\n (entry): entry is JsonLdModuleManifestEntry => entry.kind === 'module',\n );\n\n lines.push('// This file is auto-generated by @analogjs/platform');\n lines.push('// Do not edit manually');\n lines.push('');\n\n lines.push(\"import type { Graph, Thing, WithContext } from 'schema-dts';\");\n\n moduleEntries.forEach((entry) => {\n lines.push(\n `import * as ${entry.importAlias} from '${toImportPath(outFile, entry.sourceFile)}';`,\n );\n });\n\n lines.push('');\n lines.push(\n 'export type AnalogJsonLdDocument = WithContext<Thing> | Graph | Array<WithContext<Thing>>;',\n );\n lines.push(\n \"export type GeneratedJsonLdManifestEntry = { routePath: string; sourceFile: string; kind: 'module' | 'content'; resolveJsonLd: () => AnalogJsonLdDocument[]; };\",\n );\n lines.push('');\n lines.push(\n 'function normalizeJsonLd(value: unknown): AnalogJsonLdDocument[] {',\n );\n lines.push(' if (Array.isArray(value)) {');\n lines.push(\n \" return value.filter((entry): entry is AnalogJsonLdDocument => typeof entry === 'object' && entry !== null && !Array.isArray(entry));\",\n );\n lines.push(' }');\n lines.push('');\n lines.push(\n \" return typeof value === 'object' && value !== null ? [value as AnalogJsonLdDocument] : [];\",\n );\n lines.push('}');\n lines.push('');\n lines.push(\n 'function resolveModuleJsonLd(routeModule: unknown): AnalogJsonLdDocument[] {',\n );\n lines.push(\n ' const typedRouteModule = routeModule as { routeJsonLd?: unknown; routeMeta?: { jsonLd?: unknown } };',\n );\n lines.push(\n // Match runtime precedence (mergeRouteJsonLdIntoRouteMeta in routes.ts):\n // routeMeta.jsonLd wins over standalone routeJsonLd.\n ' return normalizeJsonLd(typedRouteModule.routeMeta?.jsonLd ?? typedRouteModule.routeJsonLd);',\n );\n lines.push('}');\n lines.push('');\n lines.push(\n 'export const routeJsonLdManifest = new Map<string, GeneratedJsonLdManifestEntry>([',\n );\n\n entries.forEach((entry) => {\n if (entry.kind === 'module') {\n lines.push(\n ` ['${entry.routePath}', { routePath: '${entry.routePath}', sourceFile: '${entry.sourceFile}', kind: 'module', resolveJsonLd: () => resolveModuleJsonLd(${entry.importAlias}) }],`,\n );\n return;\n }\n\n lines.push(\n ` ['${entry.routePath}', { routePath: '${entry.routePath}', sourceFile: '${entry.sourceFile}', kind: 'content', resolveJsonLd: () => ${JSON.stringify(entry.jsonLd)} }],`,\n );\n });\n\n lines.push(']);');\n lines.push('');\n\n return lines.join('\\n');\n}\n\nfunction toImportPath(outFile: string, sourceFile: string): string {\n // JSON-LD entries are emitted inside the same generated route module, so\n // imports are always resolved relative to that single output file.\n const fromDir = dirname(outFile);\n const sourceNoExt = sourceFile\n .replace(/^\\//, '')\n .replace(/\\.(ts|js|analog|ag)$/, '');\n const relativePath = normalizePath(relative(fromDir, sourceNoExt));\n\n if (relativePath.startsWith('.')) {\n return relativePath;\n }\n\n return `./${relativePath}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,0BAA0B,aAA8B;AACtE,QACE,iCAAiC,KAAK,YAAY,IAClD,iDAAiD,KAAK,YAAY;;AAItE,SAAgB,sBAAsB,YAAoC;CACxE,MAAM,EAAE,eAAe,GAA4B,WAAW;AAC9D,QAAO,gBAAgB,WAAW,UAAU;;AAG9C,SAAgB,6BACd,SACA,SACQ;CACR,MAAM,QAAkB,EAAE;CAC1B,MAAM,gBAAgB,QAAQ,QAC3B,UAA8C,MAAM,SAAS,SAC/D;AAED,OAAM,KAAK,uDAAuD;AAClE,OAAM,KAAK,0BAA0B;AACrC,OAAM,KAAK,GAAG;AAEd,OAAM,KAAK,+DAA+D;AAE1E,eAAc,SAAS,UAAU;AAC/B,QAAM,KACJ,eAAe,MAAM,YAAY,SAAS,aAAa,SAAS,MAAM,WAAW,CAAC,IACnF;GACD;AAEF,OAAM,KAAK,GAAG;AACd,OAAM,KACJ,6FACD;AACD,OAAM,KACJ,kKACD;AACD,OAAM,KAAK,GAAG;AACd,OAAM,KACJ,qEACD;AACD,OAAM,KAAK,gCAAgC;AAC3C,OAAM,KACJ,2IACD;AACD,OAAM,KAAK,MAAM;AACjB,OAAM,KAAK,GAAG;AACd,OAAM,KACJ,+FACD;AACD,OAAM,KAAK,IAAI;AACf,OAAM,KAAK,GAAG;AACd,OAAM,KACJ,+EACD;AACD,OAAM,KACJ,yGACD;AACD,OAAM,KAGJ,gGACD;AACD,OAAM,KAAK,IAAI;AACf,OAAM,KAAK,GAAG;AACd,OAAM,KACJ,qFACD;AAED,SAAQ,SAAS,UAAU;AACzB,MAAI,MAAM,SAAS,UAAU;AAC3B,SAAM,KACJ,OAAO,MAAM,UAAU,mBAAmB,MAAM,UAAU,kBAAkB,MAAM,WAAW,8DAA8D,MAAM,YAAY,OAC9K;AACD;;AAGF,QAAM,KACJ,OAAO,MAAM,UAAU,mBAAmB,MAAM,UAAU,kBAAkB,MAAM,WAAW,2CAA2C,KAAK,UAAU,MAAM,OAAO,CAAC,MACtK;GACD;AAEF,OAAM,KAAK,MAAM;AACjB,OAAM,KAAK,GAAG;AAEd,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,aAAa,SAAiB,YAA4B;CAOjE,MAAM,eAAe,cAAc,SAJnB,QAAQ,QAAQ,EACZ,WACjB,QAAQ,OAAO,GAAG,CAClB,QAAQ,wBAAwB,GAAG,CAC2B,CAAC;AAElE,KAAI,aAAa,WAAW,IAAI,CAC9B,QAAO;AAGT,QAAO,KAAK"}
@@ -0,0 +1,18 @@
1
+ import type { Nitro } from "nitro/types";
2
+ import type { Plugin } from "vite";
3
+ import type { Options } from "../options.js";
4
+ /**
5
+ * Analog's NitroModule. Plug it into the Vite plugin chain alongside
6
+ * `nitro()` from `nitro/vite`; nitro/vite picks up the `.nitro` property
7
+ * and runs `setup(nitro)` once the Nitro instance is ready.
8
+ */
9
+ export declare function analogNitroPlugin(options?: Options): Plugin;
10
+ /**
11
+ * Walks Nitro's resolved routeRules and stamps `x-analog-no-ssr: true` onto
12
+ * any rule with `ssr: false`, and `x-analog-no-streaming: true` onto any rule
13
+ * with `streaming: false`. Kept as response-header hints for downstream
14
+ * consumers (CDN, edge logic); the actual SSR short-circuit happens inside
15
+ * the SSR renderer virtual above, and the router falls back to a buffered
16
+ * render when it sees the streaming hint.
17
+ */
18
+ export declare function injectAnalogRouteRuleHeaders(nitro: Nitro): void;
@@ -0,0 +1,555 @@
1
+ import { getPageHandlers } from "./get-page-handlers.js";
2
+ import { pageEndpointsPlugin } from "./page-endpoints-plugin.js";
3
+ import { getMatchingContentFilesWithFrontMatter } from "./get-content-files.js";
4
+ import { buildSitemap } from "./build-sitemap.js";
5
+ import { addPostRenderingHooks } from "./post-rendering-hook.js";
6
+ import { createI18nPostRenderingHook, expandRoutesWithLocales } from "./i18n-prerender.js";
7
+ import { angularLinkerPlugin } from "./angular-linker-plugin.js";
8
+ import { basename, dirname, relative, resolve } from "node:path";
9
+ import { existsSync, readFileSync, readdirSync, unlinkSync } from "node:fs";
10
+ import { mkdir, writeFile } from "node:fs/promises";
11
+ //#region packages/platform/src/lib/nitro/analog-nitro-plugin.ts
12
+ var SSR_ENTRY_VIRTUAL_ID = "\0virtual:@analogjs/nitro/ssr-entry";
13
+ /**
14
+ * Angular packages that ship in partial-compilation form and must pass
15
+ * through the linker before the SSR / nitro bundle can execute without
16
+ * JIT. Wired into `ssr.optimizeDeps.rolldownOptions.plugins`.
17
+ */
18
+ var ANGULAR_SSR_DEPS = [
19
+ "@angular/compiler",
20
+ "@angular/core",
21
+ "@angular/common",
22
+ "@angular/platform-browser",
23
+ "@angular/platform-server"
24
+ ];
25
+ /**
26
+ * Analog's NitroModule. Plug it into the Vite plugin chain alongside
27
+ * `nitro()` from `nitro/vite`; nitro/vite picks up the `.nitro` property
28
+ * and runs `setup(nitro)` once the Nitro instance is ready.
29
+ */
30
+ function analogNitroPlugin(options = {}) {
31
+ const workspaceRoot = options.workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd();
32
+ const sourceRoot = "src";
33
+ const ssr = options.ssr ?? true;
34
+ const apiPrefix = options.apiPrefix ?? "api";
35
+ let context = {
36
+ workspaceRoot,
37
+ rootDir: ".",
38
+ sourceRoot
39
+ };
40
+ let ssrEntryMarkerPath = "";
41
+ let userPublicDir;
42
+ let isBuild = false;
43
+ let builtIndexHtml;
44
+ function refreshContext(viteRoot) {
45
+ context = {
46
+ workspaceRoot,
47
+ rootDir: relative(workspaceRoot, viteRoot ?? process.cwd()) || ".",
48
+ sourceRoot
49
+ };
50
+ ssrEntryMarkerPath = resolve(context.workspaceRoot, context.rootDir, ".analog/__ssr-entry.mjs");
51
+ }
52
+ function indexHtmlPath() {
53
+ return resolve(context.workspaceRoot, context.rootDir, options.index ?? "index.html");
54
+ }
55
+ function readIndexHtml() {
56
+ if (!isBuild) {
57
+ const source = indexHtmlPath();
58
+ return existsSync(source) ? readFileSync(source, "utf-8") : "<!doctype html><html><body><div id=\"app\"></div></body></html>";
59
+ }
60
+ if (builtIndexHtml === void 0) throw new Error(`[analog] The client build produced no ${basename(indexHtmlPath())}, so there is no document to server-render around. Rendering around the source document instead would ship markup pointing at the unbundled entry, which does not exist in a build.`);
61
+ return builtIndexHtml;
62
+ }
63
+ function resolveEntryServer() {
64
+ return options.entryServer ?? resolve(context.workspaceRoot, context.rootDir, `${sourceRoot}/main.server.ts`);
65
+ }
66
+ return {
67
+ name: "@analogjs/nitro",
68
+ enforce: "pre",
69
+ config(userConfig, configEnv) {
70
+ refreshContext(userConfig.root);
71
+ isBuild = configEnv?.command === "build";
72
+ if (userConfig.publicDir !== false) userPublicDir = resolve(context.workspaceRoot, context.rootDir, userConfig.publicDir ?? "public");
73
+ if (!process.env["NITRO_PRESET"]) {
74
+ if (process.env["BUILD_PRESET"]) process.env["NITRO_PRESET"] = process.env["BUILD_PRESET"];
75
+ else if (process.env["VERCEL"]) process.env["NITRO_PRESET"] = "vercel";
76
+ else if (process.env["NETLIFY"]) process.env["NITRO_PRESET"] = "netlify";
77
+ else if (process.env["CF_PAGES"]) process.env["NITRO_PRESET"] = "cloudflare-pages";
78
+ }
79
+ const overrides = {
80
+ server: { fs: { allow: [context.workspaceRoot] } },
81
+ environments: { client: { build: { rollupOptions: { input: indexHtmlPath() } } } }
82
+ };
83
+ if (ssr) {
84
+ overrides.experimental = { vite: { services: { ssr: { entry: ssrEntryMarkerPath } } } };
85
+ overrides.environments["ssr"] = {
86
+ build: {
87
+ outDir: resolve(context.workspaceRoot, "dist", context.rootDir, "ssr"),
88
+ rollupOptions: { input: { index: ssrEntryMarkerPath } }
89
+ },
90
+ optimizeDeps: {
91
+ include: ANGULAR_SSR_DEPS,
92
+ rolldownOptions: { plugins: [angularLinkerPlugin()] }
93
+ }
94
+ };
95
+ }
96
+ return overrides;
97
+ },
98
+ resolveId(id) {
99
+ if (id === ssrEntryMarkerPath || id === SSR_ENTRY_VIRTUAL_ID) return SSR_ENTRY_VIRTUAL_ID;
100
+ return null;
101
+ },
102
+ load(id) {
103
+ if (id !== SSR_ENTRY_VIRTUAL_ID) return null;
104
+ return generateSsrEntryWrapper(resolveEntryServer(), readIndexHtml());
105
+ },
106
+ writeBundle(_outputOptions, bundle) {
107
+ if (this.environment?.name !== "client") return;
108
+ const emitted = bundle[basename(indexHtmlPath())];
109
+ if (emitted?.type === "asset") {
110
+ const { source } = emitted;
111
+ builtIndexHtml = typeof source === "string" ? source : new TextDecoder().decode(source);
112
+ }
113
+ },
114
+ nitro: { async setup(nitro) {
115
+ if (!context || context.rootDir === ".") refreshContext(nitro.options.rootDir);
116
+ if (nitro.options.dev && !process.env["NITRO_DEV_RUNNER"] && !nitro.options.devServer?.runner) nitro.options.devServer = {
117
+ ...nitro.options.devServer,
118
+ runner: "self"
119
+ };
120
+ if (!nitro.options.dev) {
121
+ const preset = (nitro.options.preset ?? "").toLowerCase();
122
+ const isManagedPreset = preset !== "" && preset !== "node-server" && preset !== "node" && preset !== "nitro-dev";
123
+ if (preset.includes("vercel")) {
124
+ const vercel = nitro.options.vercel;
125
+ nitro.options.vercel = {
126
+ ...vercel,
127
+ entryFormat: vercel?.entryFormat ?? "node",
128
+ functions: {
129
+ runtime: vercel?.functions?.runtime ?? "nodejs24.x",
130
+ ...vercel?.functions
131
+ }
132
+ };
133
+ const vercelDir = resolve(context.workspaceRoot, ".vercel/output");
134
+ nitro.options.output = {
135
+ ...nitro.options.output,
136
+ dir: vercelDir,
137
+ serverDir: resolve(vercelDir, "functions/__server.func"),
138
+ publicDir: resolve(vercelDir, "static")
139
+ };
140
+ }
141
+ if (preset === "netlify" || preset === "netlify-edge") {
142
+ const netlifyDir = resolve(context.workspaceRoot, ".netlify/functions-internal");
143
+ nitro.options.output = {
144
+ ...nitro.options.output,
145
+ dir: netlifyDir,
146
+ serverDir: resolve(netlifyDir, "server"),
147
+ publicDir: resolve(context.workspaceRoot, "dist", context.rootDir, "analog/public")
148
+ };
149
+ }
150
+ if (preset.includes("cloudflare")) {
151
+ const cfDir = resolve(context.workspaceRoot, "dist", context.rootDir);
152
+ nitro.options.output = {
153
+ ...nitro.options.output,
154
+ dir: cfDir,
155
+ publicDir: cfDir,
156
+ serverDir: resolve(cfDir, "_worker.js")
157
+ };
158
+ }
159
+ if (!isManagedPreset) {
160
+ const distRoot = resolve(context.workspaceRoot, "dist", context.rootDir);
161
+ nitro.options.output = {
162
+ ...nitro.options.output,
163
+ dir: resolve(distRoot, "analog"),
164
+ publicDir: resolve(distRoot, "analog/public"),
165
+ serverDir: resolve(distRoot, "analog/server")
166
+ };
167
+ }
168
+ nitro.hooks.hook("prerender:route", async (route) => {
169
+ if (!route.skip || route.error) return;
170
+ const buffer = route.data;
171
+ if (!buffer || !route.fileName) return;
172
+ const filePath = resolve(nitro.options.output.publicDir, route.fileName.replace(/^[\\/]+/, ""));
173
+ try {
174
+ await mkdir(dirname(filePath), { recursive: true });
175
+ await writeFile(filePath, Buffer.from(buffer));
176
+ route.skip = false;
177
+ } catch {}
178
+ });
179
+ }
180
+ if (userPublicDir && existsSync(userPublicDir)) {
181
+ if (!nitro.options.publicAssets.some((asset) => asset.dir === userPublicDir)) nitro.options.publicAssets.push({
182
+ dir: userPublicDir,
183
+ baseURL: "/",
184
+ maxAge: 0,
185
+ fallthrough: true
186
+ });
187
+ }
188
+ nitro.hooks.hook("prerender:config", (prerendererConfig) => {
189
+ prerendererConfig.output = {
190
+ ...prerendererConfig.output,
191
+ publicDir: nitro.options.output.publicDir
192
+ };
193
+ });
194
+ const pageHandlers = getPageHandlers({
195
+ workspaceRoot: context.workspaceRoot,
196
+ sourceRoot: context.sourceRoot,
197
+ rootDir: context.rootDir,
198
+ additionalPagesDirs: options.additionalPagesDirs
199
+ });
200
+ nitro.options.handlers.push(...pageHandlers);
201
+ const serverDir = resolve(context.workspaceRoot, context.rootDir, `${context.sourceRoot}/server`);
202
+ if (existsSync(serverDir) && !nitro.options.scanDirs.includes(serverDir)) nitro.options.scanDirs.push(serverDir);
203
+ nitro.hooks.hook("rollup:before", (_n, rollupConfig) => {
204
+ if (Array.isArray(rollupConfig.plugins)) rollupConfig.plugins.push(pageEndpointsPlugin());
205
+ applyAnalogNitroExternals(rollupConfig);
206
+ sanitizeNitroBundlerConfig(rollupConfig);
207
+ });
208
+ if (ssr) {
209
+ nitro.options.virtual["#analog/ssr"] = () => generateSsrServiceVirtual(nitro);
210
+ nitro.options.virtual["#analog/ssr-renderer"] = () => generateSsrRendererVirtual(readIndexHtml());
211
+ nitro.options.renderer ??= {};
212
+ nitro.options.renderer.handler = "#analog/ssr-renderer";
213
+ delete nitro.options.renderer.template;
214
+ }
215
+ injectAnalogRouteRuleHeaders(nitro);
216
+ await wirePrerender(nitro, options, context, apiPrefix);
217
+ if (options.i18n) addPostRenderingHooks(nitro, [createI18nPostRenderingHook({
218
+ defaultLocale: options.i18n.defaultLocale,
219
+ locales: options.i18n.locales
220
+ })]);
221
+ } }
222
+ };
223
+ }
224
+ /**
225
+ * Builds the h3 handler installed as Nitro's `renderer.handler`. Short-circuits
226
+ * `ssr: false` routes to the raw client template; otherwise dispatches the
227
+ * request to the SSR service env (`fetchViteEnv("ssr", req)` works in dev via
228
+ * the env-runner and in prod via the `__nitro_vite_envs__` global set up by
229
+ * nitro/vite's `prodSetup`).
230
+ */
231
+ function generateSsrRendererVirtual(template) {
232
+ return `
233
+ import { defineHandler } from 'nitro/h3';
234
+ import ssr from '#analog/ssr';
235
+
236
+ const TEMPLATE = ${JSON.stringify(template)};
237
+
238
+ export default defineHandler(async (event) => {
239
+ event.res.headers.set('content-type', 'text/html; charset=utf-8');
240
+ // 'x-analog-no-ssr' is stamped on response headers by
241
+ // injectAnalogRouteRuleHeaders for routeRules with \`ssr: false\`. Nitro
242
+ // applies routeRule headers to the response before the renderer fires,
243
+ // so we can short-circuit by reading them here.
244
+ if (event.res.headers.get('x-analog-no-ssr') === 'true') {
245
+ return TEMPLATE;
246
+ }
247
+ const service = ssr.default ?? ssr;
248
+ return service.fetch(event.req);
249
+ });
250
+ `;
251
+ }
252
+ /**
253
+ * Resolves \`#analog/ssr\` to the SSR fetch handler. The shape returned by
254
+ * this function is bundler-agnostic: works in Vite-built main bundles and
255
+ * Rolldown-built prerender bundles alike.
256
+ *
257
+ * - Dev: dispatch through nitro/vite's env runner (\`fetchViteEnv\`); the SSR
258
+ * service module isn't on disk yet, so we delegate to the runner.
259
+ * - Build / prerender: re-export the built SSR entry directly from the
260
+ * filesystem. By the time Nitro's bundlers ask for \`#analog/ssr\`, Vite has
261
+ * already produced \`<buildDir>/vite/services/ssr/<entry>.mjs\`.
262
+ */
263
+ function generateSsrServiceVirtual(nitro) {
264
+ if (nitro.options.dev) return `
265
+ import { fetchViteEnv } from 'nitro/vite/runtime';
266
+ export default {
267
+ // The dev runner answers from a worker, and a rejection there comes back as
268
+ // something Nitro cannot turn into a response, so the request hangs with no
269
+ // status and no message. Answer with the failure instead.
270
+ async fetch(req) {
271
+ try {
272
+ return await fetchViteEnv('ssr', req);
273
+ } catch (err) {
274
+ console.error('[analog ssr]', err);
275
+ const message = err instanceof Error ? (err.stack ?? err.message) : String(err);
276
+ return new Response(message, {
277
+ status: 500,
278
+ headers: { 'content-type': 'text/plain; charset=utf-8' },
279
+ });
280
+ }
281
+ },
282
+ };
283
+ `;
284
+ const ssrDir = resolve(nitro.options.buildDir, "vite/services/ssr");
285
+ if (!existsSync(ssrDir)) return `export default { async fetch() { throw new Error('Analog SSR service directory missing: ${ssrDir}'); } };`;
286
+ const entries = readdirSync(ssrDir).filter((f) => f.endsWith(".mjs"));
287
+ if (entries.length === 0) return `export default { async fetch() { throw new Error('No Analog SSR entry file built in: ${ssrDir}'); } };`;
288
+ const entryPath = resolve(ssrDir, entries.find((f) => f === "main.server.mjs") ?? entries[0]);
289
+ return `export { default } from ${JSON.stringify(entryPath)};`;
290
+ }
291
+ /**
292
+ * Packages Analog forces external in the Nitro server bundle. Each entry is
293
+ * here for a specific reason — see comments.
294
+ */
295
+ var ANALOG_NITRO_EXTERNALS = [
296
+ "rxjs",
297
+ "node-fetch-native/dist/polyfill",
298
+ "sharp"
299
+ ];
300
+ function applyAnalogNitroExternals(rollupConfig) {
301
+ const prev = rollupConfig.external;
302
+ const existing = prev === void 0 ? [] : Array.isArray(prev) ? prev : prev instanceof RegExp ? [prev] : typeof prev === "string" ? [prev] : [];
303
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
304
+ for (const entry of ANALOG_NITRO_EXTERNALS) {
305
+ const pattern = new RegExp(`^${escapeRegExp(entry)}(?:/|$)`);
306
+ if (!existing.some((p) => String(p) === String(pattern))) existing.push(pattern);
307
+ }
308
+ rollupConfig.external = existing;
309
+ }
310
+ /**
311
+ * Workarounds for Nitro v3 + Rolldown bundler interaction quirks. Each
312
+ * is narrowly scoped and can be removed once the upstream bug is fixed:
313
+ *
314
+ * 1. `output.codeSplitting` — Nitro 3.0.x sets this; Rolldown rejects it
315
+ * as an unknown key.
316
+ * 2. `output.manualChunks` — Nitro's default manual chunking crashes
317
+ * Nitro's prerender rebundle.
318
+ * 3. `output.chunkFileNames` — Nitro's chunk-name function produces
319
+ * route-derived `[token]` patterns which Rollup/Rolldown interprets as
320
+ * placeholders; we rewrite non-standard tokens to `_token_`.
321
+ */
322
+ function sanitizeNitroBundlerConfig(rollupConfig) {
323
+ const output = rollupConfig.output;
324
+ if (!output || Array.isArray(output) || typeof output !== "object") return;
325
+ const out = output;
326
+ if ("codeSplitting" in out) delete out["codeSplitting"];
327
+ if ("manualChunks" in out) delete out["manualChunks"];
328
+ const VALID_ROLLUP_PLACEHOLDER = /^\[(?:name|hash|format|ext)\]$/;
329
+ const chunkFileNames = out["chunkFileNames"];
330
+ if (typeof chunkFileNames === "function") {
331
+ const originalFn = chunkFileNames;
332
+ out["chunkFileNames"] = (...args) => {
333
+ const result = originalFn(...args);
334
+ if (typeof result !== "string") return result;
335
+ return result.replace(/\[[^\]]+\]/g, (match) => VALID_ROLLUP_PLACEHOLDER.test(match) ? match : `_${match.slice(1, -1)}_`);
336
+ };
337
+ }
338
+ }
339
+ /**
340
+ * Walks Nitro's resolved routeRules and stamps `x-analog-no-ssr: true` onto
341
+ * any rule with `ssr: false`, and `x-analog-no-streaming: true` onto any rule
342
+ * with `streaming: false`. Kept as response-header hints for downstream
343
+ * consumers (CDN, edge logic); the actual SSR short-circuit happens inside
344
+ * the SSR renderer virtual above, and the router falls back to a buffered
345
+ * render when it sees the streaming hint.
346
+ */
347
+ function injectAnalogRouteRuleHeaders(nitro) {
348
+ const routeRules = nitro.options.routeRules;
349
+ if (!routeRules) return;
350
+ for (const rule of Object.values(routeRules)) {
351
+ if (rule?.ssr === false) rule.headers = {
352
+ ...rule.headers,
353
+ "x-analog-no-ssr": "true"
354
+ };
355
+ if (rule?.streaming === false) rule.headers = {
356
+ ...rule.headers,
357
+ "x-analog-no-streaming": "true"
358
+ };
359
+ }
360
+ }
361
+ /**
362
+ * Builds the SSR service entry source. The wrapper imports the user's
363
+ * `main.server.ts` Angular renderer and adapts it to the `{ fetch(req) }`
364
+ * shape that nitro/vite's service mechanism expects.
365
+ */
366
+ function generateSsrEntryWrapper(entryServer, template) {
367
+ return `
368
+ // Import \`serverFetch\` from the root \`nitro\` entry rather than \`nitro/app\`.
369
+ // The /app subpath creates a fresh \`useNitroApp()\` instance scoped to the
370
+ // importing bundle, which in our setup is the standalone SSR vite bundle —
371
+ // it has no route handlers, so every fetch 404s. The root entry instead
372
+ // reads \`globalThis.__nitro__.{default,prerender}\`, which the surrounding
373
+ // Nitro server (prerender pass or production runtime) has already
374
+ // populated with the real app + handlers.
375
+ import { serverFetch as nitroServerFetch } from 'nitro';
376
+ import { createFetch } from 'ofetch';
377
+ import renderer from ${JSON.stringify(entryServer)};
378
+
379
+ const TEMPLATE = ${JSON.stringify(template)};
380
+
381
+ const normalizeRequestPath = (url) =>
382
+ url.replace(/\\/index\\.html(?=$|[?#])/, '/');
383
+
384
+ // In-process fetch wired into Nitro's request pipeline. Angular's HttpClient
385
+ // (via withFetch()) and Analog's injectLoad() call this during SSR/prerender
386
+ // so they hit the running app's page-endpoint and API routes without going
387
+ // through the network — the prerender pipeline doesn't have a listening
388
+ // socket. Without this, every SSR data fetch ECONNREFUSEs and Angular's
389
+ // router fails to resolve any data-bound route, producing an empty
390
+ // <router-outlet/> in the prerendered HTML.
391
+ const ssrFetch = (resource, init) => {
392
+ let url = typeof resource === 'string'
393
+ ? resource
394
+ : resource instanceof URL
395
+ ? resource.href
396
+ : resource.url;
397
+ // Relative URLs from injectAPIPrefix() etc. need a host for Nitro's
398
+ // Request constructor to accept them.
399
+ if (typeof url === 'string' && url.startsWith('/')) {
400
+ url = 'http://localhost' + url;
401
+ }
402
+ return nitroServerFetch(url, init);
403
+ };
404
+
405
+ // Wrap in ofetch so consumers that expect \`$fetch.raw()\` (the router's
406
+ // request-context interceptor short-circuits SSR HttpClient calls through
407
+ // \`globalThis.$fetch.raw\`) can call it. Set on globalThis so router code
408
+ // running inside the Angular renderer can find it.
409
+ const ssrOFetch = createFetch({ fetch: ssrFetch });
410
+ if (typeof globalThis.$fetch === 'undefined') {
411
+ globalThis.$fetch = ssrOFetch;
412
+ }
413
+
414
+ export default {
415
+ async fetch(req) {
416
+ const url = new URL(req.url);
417
+ const requestPath = normalizeRequestPath(url.pathname);
418
+ // Preserve the query string so Angular's router + injectQuery() and
419
+ // server data loaders that read from req.url see the full path+query.
420
+ const requestUrl = requestPath + url.search;
421
+
422
+ if (req.headers.get('x-analog-no-ssr') === 'true') {
423
+ return new Response(TEMPLATE, {
424
+ status: 200,
425
+ headers: { 'content-type': 'text/html; charset=utf-8' },
426
+ });
427
+ }
428
+
429
+ const reqShim = {
430
+ headers: Object.fromEntries(req.headers.entries()),
431
+ url: requestUrl,
432
+ originalUrl: requestUrl,
433
+ connection: {},
434
+ };
435
+
436
+ try {
437
+ const html = await renderer(requestUrl, TEMPLATE, {
438
+ req: reqShim,
439
+ // Pass the ofetch-wrapped fetch — INTERNAL_FETCH is consumed by the
440
+ // router's request-context interceptor via \`serverFetch.raw(...)\`,
441
+ // which is ofetch's response-shape API. Plain fetch lacks \`.raw\`
442
+ // and throws TypeError during prerender/SSR.
443
+ fetch: ssrOFetch,
444
+ });
445
+ return new Response(html, {
446
+ status: 200,
447
+ headers: { 'content-type': 'text/html; charset=utf-8' },
448
+ });
449
+ } catch (err) {
450
+ console.error('[analog ssr]', err);
451
+ return new Response(TEMPLATE, {
452
+ status: 500,
453
+ headers: { 'content-type': 'text/html; charset=utf-8' },
454
+ });
455
+ }
456
+ },
457
+ };
458
+ `;
459
+ }
460
+ async function wirePrerender(nitro, options, context, apiPrefix) {
461
+ const prerender = options.prerender;
462
+ if (!prerender && !options.i18n) return;
463
+ const { routes: collected, sitemaps: routeSitemaps, routeSourceFiles } = await collectRoutes(prerender?.routes, context, apiPrefix);
464
+ const expanded = options.i18n ? expandRoutesWithLocales(collected, {
465
+ defaultLocale: options.i18n.defaultLocale,
466
+ locales: options.i18n.locales
467
+ }) : collected;
468
+ const nitroPrerender = nitro.options.prerender ??= {};
469
+ nitroPrerender.routes ??= [];
470
+ nitroPrerender.routes.push(...expanded);
471
+ if (prerender?.discover ?? false) nitroPrerender.crawlLinks = true;
472
+ const prerendersRoot = nitroPrerender.routes.some((route) => route === "/");
473
+ if ((options.ssr ?? true) && prerendersRoot) nitro.hooks.hook("prerender:init", () => {
474
+ const publicDir = resolve(nitro.options.output.publicDir);
475
+ for (const extension of [
476
+ "",
477
+ ".br",
478
+ ".gz"
479
+ ]) {
480
+ const indexFile = resolve(publicDir, `index.html${extension}`);
481
+ if (existsSync(indexFile)) unlinkSync(indexFile);
482
+ }
483
+ });
484
+ if (prerender?.postRenderingHooks?.length) addPostRenderingHooks(nitro, prerender.postRenderingHooks);
485
+ if (Object.keys(routeSourceFiles).length > 0) nitro.hooks.hook("prerender:done", async () => {
486
+ const publicDir = resolve(nitro.options.output.publicDir);
487
+ const { mkdirSync, writeFileSync } = await import("node:fs");
488
+ const { dirname, join } = await import("node:path");
489
+ for (const [route, content] of Object.entries(routeSourceFiles)) {
490
+ const outputPath = join(publicDir, `${route}.md`);
491
+ mkdirSync(dirname(outputPath), { recursive: true });
492
+ writeFileSync(outputPath, content, "utf8");
493
+ }
494
+ });
495
+ const sitemapConfig = prerender?.sitemap;
496
+ if (sitemapConfig) nitro.hooks.hook("prerender:done", async (result) => {
497
+ await buildSitemap({}, sitemapConfig, (result?.prerenderedRoutes ?? []).map((r) => r.route), resolve(nitro.options.output.publicDir), routeSitemaps, { apiPrefix });
498
+ });
499
+ }
500
+ async function collectRoutes(routesInput, context, apiPrefix) {
501
+ const out = [];
502
+ const sitemaps = {};
503
+ const routeSourceFiles = {};
504
+ if (!routesInput) return {
505
+ routes: out,
506
+ sitemaps,
507
+ routeSourceFiles
508
+ };
509
+ const inputs = Array.isArray(routesInput) ? routesInput : typeof routesInput === "function" ? await routesInput() : [];
510
+ for (const entry of inputs) {
511
+ if (!entry) continue;
512
+ if (typeof entry === "string") {
513
+ out.push(entry);
514
+ continue;
515
+ }
516
+ if ("contentDir" in entry) {
517
+ const dir = entry;
518
+ const files = getMatchingContentFilesWithFrontMatter(context.workspaceRoot, context.rootDir, dir.contentDir, !!dir.recursive);
519
+ for (const file of files) {
520
+ const route = dir.transform(file);
521
+ if (route === false) continue;
522
+ out.push(route);
523
+ if (dir.sitemap) sitemaps[route] = typeof dir.sitemap === "function" ? dir.sitemap(file) : dir.sitemap;
524
+ if (dir.outputSourceFile) {
525
+ const sourceContent = dir.outputSourceFile(file);
526
+ if (typeof sourceContent === "string") routeSourceFiles[route] = sourceContent;
527
+ }
528
+ }
529
+ continue;
530
+ }
531
+ if ("route" in entry) {
532
+ const cfg = entry;
533
+ out.push(cfg.route);
534
+ if (cfg.sitemap) sitemaps[cfg.route] = cfg.sitemap;
535
+ if (cfg.outputSourceFile) {
536
+ const sourcePath = resolve(context.workspaceRoot, context.rootDir, cfg.outputSourceFile);
537
+ if (existsSync(sourcePath)) routeSourceFiles[cfg.route] = readFileSync(sourcePath, "utf8");
538
+ }
539
+ if (cfg.staticData) {
540
+ const prefix = apiPrefix.startsWith("/") ? apiPrefix : `/${apiPrefix}`;
541
+ const route = cfg.route.startsWith("/") ? cfg.route : `/${cfg.route}`;
542
+ out.push(`${prefix}/_analog/pages${route}`);
543
+ }
544
+ }
545
+ }
546
+ return {
547
+ routes: out,
548
+ sitemaps,
549
+ routeSourceFiles
550
+ };
551
+ }
552
+ //#endregion
553
+ export { analogNitroPlugin };
554
+
555
+ //# sourceMappingURL=analog-nitro-plugin.js.map