astro 6.0.0-alpha.0 → 6.0.0-alpha.1

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 (543) hide show
  1. package/astro-jsx.d.ts +11 -0
  2. package/client.d.ts +17 -41
  3. package/components/Code.astro +2 -2
  4. package/components/Image.astro +2 -2
  5. package/components/Picture.astro +1 -1
  6. package/dist/actions/consts.d.ts +2 -5
  7. package/dist/actions/consts.js +4 -8
  8. package/dist/actions/integration.js +2 -4
  9. package/dist/actions/runtime/client.d.ts +84 -3
  10. package/dist/actions/runtime/client.js +238 -7
  11. package/dist/actions/runtime/entrypoints/client.d.ts +7 -0
  12. package/dist/actions/runtime/entrypoints/client.js +91 -0
  13. package/dist/actions/runtime/entrypoints/route.d.ts +2 -0
  14. package/dist/actions/runtime/{route.js → entrypoints/route.js} +1 -1
  15. package/dist/actions/runtime/entrypoints/server.d.ts +6 -0
  16. package/dist/actions/runtime/entrypoints/server.js +33 -0
  17. package/dist/actions/runtime/server.d.ts +11 -18
  18. package/dist/actions/runtime/server.js +162 -82
  19. package/dist/actions/runtime/types.d.ts +64 -0
  20. package/dist/actions/utils.d.ts +2 -2
  21. package/dist/actions/utils.js +2 -2
  22. package/dist/actions/vite-plugin-actions.js +18 -21
  23. package/dist/assets/build/generate.d.ts +2 -2
  24. package/dist/assets/build/generate.js +12 -10
  25. package/dist/assets/endpoint/config.js +2 -2
  26. package/dist/assets/endpoint/dev.js +7 -6
  27. package/dist/assets/fonts/config.d.ts +91 -350
  28. package/dist/assets/fonts/config.js +35 -136
  29. package/dist/assets/fonts/constants.js +1 -1
  30. package/dist/assets/fonts/core/dedupe-font-faces.d.ts +2 -0
  31. package/dist/assets/fonts/core/dedupe-font-faces.js +30 -0
  32. package/dist/assets/fonts/definitions.d.ts +9 -22
  33. package/dist/assets/fonts/infra/build-remote-font-provider-mod-resolver.d.ts +4 -0
  34. package/dist/assets/fonts/infra/build-remote-font-provider-mod-resolver.js +8 -0
  35. package/dist/assets/fonts/infra/build-url-proxy-hash-resolver.d.ts +15 -0
  36. package/dist/assets/fonts/infra/build-url-proxy-hash-resolver.js +20 -0
  37. package/dist/assets/fonts/infra/build-url-resolver.d.ts +12 -0
  38. package/dist/assets/fonts/infra/build-url-resolver.js +40 -0
  39. package/dist/assets/fonts/infra/cached-font-fetcher.d.ts +11 -0
  40. package/dist/assets/fonts/infra/cached-font-fetcher.js +42 -0
  41. package/dist/assets/fonts/infra/capsize-font-metrics-resolver.d.ts +18 -0
  42. package/dist/assets/fonts/infra/capsize-font-metrics-resolver.js +71 -0
  43. package/dist/assets/fonts/infra/data-collector.d.ts +10 -0
  44. package/dist/assets/fonts/infra/data-collector.js +35 -0
  45. package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.d.ts +9 -0
  46. package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.js +14 -0
  47. package/dist/assets/fonts/infra/dev-url-proxy-hash-resolver.d.ts +15 -0
  48. package/dist/assets/fonts/infra/dev-url-proxy-hash-resolver.js +37 -0
  49. package/dist/assets/fonts/infra/dev-url-resolver.d.ts +10 -0
  50. package/dist/assets/fonts/infra/dev-url-resolver.js +29 -0
  51. package/dist/assets/fonts/infra/font-type-extractor.d.ts +5 -0
  52. package/dist/assets/fonts/infra/font-type-extractor.js +21 -0
  53. package/dist/assets/fonts/infra/fontace-font-file-reader.d.ts +11 -0
  54. package/dist/assets/fonts/infra/fontace-font-file-reader.js +25 -0
  55. package/dist/assets/fonts/infra/levenshtein-string-matcher.d.ts +5 -0
  56. package/dist/assets/fonts/infra/levenshtein-string-matcher.js +145 -0
  57. package/dist/assets/fonts/infra/local-url-proxy-content-resolver.d.ts +4 -0
  58. package/dist/assets/fonts/infra/local-url-proxy-content-resolver.js +14 -0
  59. package/dist/assets/fonts/{implementations/css-renderer.d.ts → infra/minifiable-css-renderer.d.ts} +8 -3
  60. package/dist/assets/fonts/{implementations/css-renderer.js → infra/minifiable-css-renderer.js} +12 -10
  61. package/dist/assets/fonts/infra/remote-font-provider-resolver.d.ts +10 -0
  62. package/dist/assets/fonts/infra/remote-font-provider-resolver.js +49 -0
  63. package/dist/assets/fonts/infra/remote-url-proxy-content-resolver.d.ts +4 -0
  64. package/dist/assets/fonts/infra/remote-url-proxy-content-resolver.js +9 -0
  65. package/dist/assets/fonts/infra/require-local-provider-url-resolver.d.ts +9 -0
  66. package/dist/assets/fonts/infra/require-local-provider-url-resolver.js +22 -0
  67. package/dist/assets/fonts/infra/system-fallbacks-provider.d.ts +6 -0
  68. package/dist/assets/fonts/{implementations → infra}/system-fallbacks-provider.js +8 -11
  69. package/dist/assets/fonts/infra/unstorage-fs-storage.d.ts +11 -0
  70. package/dist/assets/fonts/infra/unstorage-fs-storage.js +26 -0
  71. package/dist/assets/fonts/infra/url-proxy.d.ts +16 -0
  72. package/dist/assets/fonts/infra/url-proxy.js +50 -0
  73. package/dist/assets/fonts/infra/xxhash-hasher.d.ts +7 -0
  74. package/dist/assets/fonts/infra/xxhash-hasher.js +18 -0
  75. package/dist/assets/fonts/orchestrate.d.ts +1 -2
  76. package/dist/assets/fonts/orchestrate.js +50 -17
  77. package/dist/assets/fonts/providers/index.d.ts +6 -24
  78. package/dist/assets/fonts/types.d.ts +138 -8
  79. package/dist/assets/fonts/utils.d.ts +1 -2
  80. package/dist/assets/fonts/vite-plugin-fonts.js +56 -61
  81. package/dist/assets/services/noop.js +5 -0
  82. package/dist/assets/utils/index.d.ts +0 -2
  83. package/dist/assets/utils/index.js +0 -5
  84. package/dist/assets/utils/{transformToPath.d.ts → node.d.ts} +15 -1
  85. package/dist/assets/utils/{node/emitAsset.js → node.js} +34 -6
  86. package/dist/assets/utils/remotePattern.d.ts +1 -3
  87. package/dist/assets/utils/svg.d.ts +2 -1
  88. package/dist/assets/utils/svg.js +30 -4
  89. package/dist/assets/vite-plugin-assets.js +10 -8
  90. package/dist/cli/add/index.js +21 -13
  91. package/dist/cli/create-key/infra/crypto-key-generator.d.ts +3 -1
  92. package/dist/cli/create-key/infra/crypto-key-generator.js +7 -9
  93. package/dist/cli/definitions.d.ts +19 -2
  94. package/dist/cli/dev/index.js +1 -1
  95. package/dist/cli/docs/core/open-docs.d.ts +5 -3
  96. package/dist/cli/docs/core/open-docs.js +2 -9
  97. package/dist/cli/docs/definitions.d.ts +3 -11
  98. package/dist/cli/docs/domain/cloud-ide.d.ts +1 -0
  99. package/dist/cli/docs/domain/cloud-ide.js +0 -0
  100. package/dist/cli/docs/infra/process-cloud-ide-provider.d.ts +5 -0
  101. package/dist/cli/docs/infra/process-cloud-ide-provider.js +6 -0
  102. package/dist/cli/flags.d.ts +1 -0
  103. package/dist/cli/index.js +78 -21
  104. package/dist/cli/info/core/get-package-manager.d.ts +8 -0
  105. package/dist/cli/info/core/get-package-manager.js +37 -0
  106. package/dist/cli/info/core/info.d.ts +21 -0
  107. package/dist/cli/info/core/info.js +21 -0
  108. package/dist/cli/info/definitions.d.ts +30 -0
  109. package/dist/cli/info/definitions.js +0 -0
  110. package/dist/cli/info/domain/debug-info.d.ts +1 -0
  111. package/dist/cli/info/domain/debug-info.js +0 -0
  112. package/dist/cli/info/infra/bun-package-manager.d.ts +5 -0
  113. package/dist/cli/info/infra/bun-package-manager.js +9 -0
  114. package/dist/cli/info/infra/cli-astro-config-resolver.d.ts +10 -0
  115. package/dist/cli/info/infra/cli-astro-config-resolver.js +36 -0
  116. package/dist/cli/info/infra/cli-clipboard.d.ts +13 -0
  117. package/dist/cli/info/infra/cli-clipboard.js +78 -0
  118. package/dist/cli/info/infra/cli-debug-info-provider.d.ts +15 -0
  119. package/dist/cli/info/infra/cli-debug-info-provider.js +57 -0
  120. package/dist/cli/info/infra/dev-debug-info-provider.d.ts +18 -0
  121. package/dist/cli/info/infra/dev-debug-info-provider.js +36 -0
  122. package/dist/cli/info/infra/noop-package-manager.d.ts +5 -0
  123. package/dist/cli/info/infra/noop-package-manager.js +9 -0
  124. package/dist/cli/info/infra/npm-package-manager.d.ts +10 -0
  125. package/dist/cli/info/infra/npm-package-manager.js +32 -0
  126. package/dist/cli/info/infra/pnpm-package-manager.d.ts +10 -0
  127. package/dist/cli/info/infra/pnpm-package-manager.js +33 -0
  128. package/dist/cli/info/infra/process-node-version-provider.d.ts +4 -0
  129. package/dist/cli/info/infra/process-node-version-provider.js +6 -0
  130. package/dist/cli/info/infra/process-package-manager-user-agent-provider.d.ts +4 -0
  131. package/dist/cli/info/infra/process-package-manager-user-agent-provider.js +7 -0
  132. package/dist/cli/info/infra/prompts-prompt.d.ts +11 -0
  133. package/dist/cli/info/infra/prompts-prompt.js +25 -0
  134. package/dist/cli/info/infra/styled-debug-info-formatter.d.ts +10 -0
  135. package/dist/cli/info/infra/styled-debug-info-formatter.js +29 -0
  136. package/dist/cli/info/infra/yarn-package-manager.d.ts +10 -0
  137. package/dist/cli/info/infra/yarn-package-manager.js +34 -0
  138. package/dist/cli/infra/build-time-astro-version-provider.d.ts +3 -1
  139. package/dist/cli/infra/build-time-astro-version-provider.js +4 -8
  140. package/dist/cli/infra/cli-command-runner.d.ts +7 -4
  141. package/dist/cli/infra/cli-command-runner.js +14 -10
  142. package/dist/cli/infra/logger-help-display.d.ts +11 -7
  143. package/dist/cli/infra/logger-help-display.js +62 -50
  144. package/dist/cli/infra/passthrough-text-styler.d.ts +9 -0
  145. package/dist/cli/infra/passthrough-text-styler.js +23 -0
  146. package/dist/cli/infra/piccolore-text-styler.d.ts +2 -0
  147. package/dist/cli/infra/piccolore-text-styler.js +5 -0
  148. package/dist/cli/infra/process-operating-system-provider.d.ts +6 -0
  149. package/dist/cli/infra/process-operating-system-provider.js +12 -0
  150. package/dist/cli/infra/tinyexec-command-executor.d.ts +6 -0
  151. package/dist/cli/infra/tinyexec-command-executor.js +34 -0
  152. package/dist/cli/install-package.js +1 -1
  153. package/dist/cli/preferences/index.js +6 -2
  154. package/dist/cli/preview/index.js +1 -1
  155. package/dist/cli/utils/format-version.js +1 -1
  156. package/dist/config/index.js +9 -5
  157. package/dist/container/index.js +19 -13
  158. package/dist/container/pipeline.d.ts +2 -1
  159. package/dist/container/pipeline.js +4 -11
  160. package/dist/content/config.d.ts +34 -40
  161. package/dist/content/content-layer.js +13 -18
  162. package/dist/content/loaders/errors.d.ts +3 -3
  163. package/dist/content/loaders/errors.js +5 -2
  164. package/dist/content/loaders/glob.js +6 -1
  165. package/dist/content/loaders/types.d.ts +11 -4
  166. package/dist/content/runtime-assets.d.ts +4 -4
  167. package/dist/content/runtime-assets.js +2 -2
  168. package/dist/content/runtime.d.ts +21 -20
  169. package/dist/content/runtime.js +14 -16
  170. package/dist/content/types-generator.js +81 -54
  171. package/dist/content/utils.d.ts +46 -338
  172. package/dist/content/utils.js +43 -48
  173. package/dist/content/vite-plugin-content-assets.d.ts +12 -4
  174. package/dist/content/vite-plugin-content-assets.js +100 -56
  175. package/dist/content/vite-plugin-content-imports.js +10 -4
  176. package/dist/content/vite-plugin-content-virtual-mod.js +10 -7
  177. package/dist/core/app/app.d.ts +5 -0
  178. package/dist/core/app/app.js +13 -0
  179. package/dist/core/app/base.d.ts +132 -0
  180. package/dist/core/app/base.js +448 -0
  181. package/dist/core/app/common.d.ts +6 -2
  182. package/dist/core/app/common.js +60 -33
  183. package/dist/core/app/dev/app.d.ts +15 -0
  184. package/dist/core/app/dev/app.js +86 -0
  185. package/dist/core/app/dev/pipeline.d.ts +13 -0
  186. package/dist/core/app/dev/pipeline.js +123 -0
  187. package/dist/core/app/entrypoint.d.ts +2 -0
  188. package/dist/core/app/entrypoint.js +15 -0
  189. package/dist/core/app/index.d.ts +7 -99
  190. package/dist/core/app/index.js +20 -486
  191. package/dist/core/app/logging.d.ts +3 -0
  192. package/dist/core/app/logging.js +11 -0
  193. package/dist/core/app/manifest.d.ts +9 -0
  194. package/dist/core/app/manifest.js +107 -0
  195. package/dist/core/app/middlewares.js +1 -1
  196. package/dist/core/app/node.js +14 -13
  197. package/dist/core/app/pipeline.d.ts +6 -5
  198. package/dist/core/app/pipeline.js +65 -49
  199. package/dist/core/app/types.d.ts +58 -22
  200. package/dist/core/app/validate-forwarded-headers.d.ts +16 -0
  201. package/dist/core/app/validate-forwarded-headers.js +60 -0
  202. package/dist/core/base-pipeline.d.ts +22 -14
  203. package/dist/core/base-pipeline.js +54 -6
  204. package/dist/core/build/app.d.ts +13 -0
  205. package/dist/core/build/app.js +38 -0
  206. package/dist/core/build/common.d.ts +1 -1
  207. package/dist/core/build/common.js +2 -2
  208. package/dist/core/build/generate.d.ts +1 -1
  209. package/dist/core/build/generate.js +96 -204
  210. package/dist/core/build/graph.js +2 -2
  211. package/dist/core/build/index.js +11 -16
  212. package/dist/core/build/internal.d.ts +2 -27
  213. package/dist/core/build/internal.js +1 -44
  214. package/dist/core/build/page-data.js +1 -1
  215. package/dist/core/build/pipeline.d.ts +15 -26
  216. package/dist/core/build/pipeline.js +106 -170
  217. package/dist/core/build/plugins/index.d.ts +4 -2
  218. package/dist/core/build/plugins/index.js +17 -23
  219. package/dist/core/build/plugins/plugin-analyzer.d.ts +2 -2
  220. package/dist/core/build/plugins/plugin-analyzer.js +5 -13
  221. package/dist/core/build/plugins/plugin-component-entry.d.ts +7 -2
  222. package/dist/core/build/plugins/plugin-component-entry.js +5 -13
  223. package/dist/core/build/plugins/plugin-css.d.ts +2 -2
  224. package/dist/core/build/plugins/plugin-css.js +86 -41
  225. package/dist/core/build/plugins/plugin-internals.d.ts +2 -2
  226. package/dist/core/build/plugins/plugin-internals.js +24 -18
  227. package/dist/core/build/plugins/plugin-manifest.d.ts +33 -5
  228. package/dist/core/build/plugins/plugin-manifest.js +89 -129
  229. package/dist/core/build/plugins/plugin-middleware.d.ts +2 -2
  230. package/dist/core/build/plugins/plugin-middleware.js +5 -7
  231. package/dist/core/build/plugins/plugin-noop.d.ts +3 -0
  232. package/dist/core/build/plugins/plugin-noop.js +29 -0
  233. package/dist/core/build/plugins/plugin-prerender.d.ts +2 -2
  234. package/dist/core/build/plugins/plugin-prerender.js +7 -64
  235. package/dist/core/build/plugins/plugin-scripts.d.ts +5 -2
  236. package/dist/core/build/plugins/plugin-scripts.js +5 -13
  237. package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
  238. package/dist/core/build/plugins/plugin-ssr.js +60 -132
  239. package/dist/core/build/plugins/util.d.ts +1 -25
  240. package/dist/core/build/plugins/util.js +0 -47
  241. package/dist/core/build/runtime.d.ts +26 -0
  242. package/dist/core/build/runtime.js +45 -0
  243. package/dist/core/build/static-build.d.ts +2 -2
  244. package/dist/core/build/static-build.js +181 -155
  245. package/dist/core/build/types.d.ts +1 -2
  246. package/dist/core/build/util.d.ts +0 -1
  247. package/dist/core/build/util.js +0 -7
  248. package/dist/core/compile/compile.d.ts +2 -3
  249. package/dist/core/compile/compile.js +2 -2
  250. package/dist/core/config/config.js +3 -3
  251. package/dist/core/config/index.d.ts +0 -1
  252. package/dist/core/config/index.js +0 -2
  253. package/dist/core/config/schemas/base.d.ts +336 -1434
  254. package/dist/core/config/schemas/base.js +42 -41
  255. package/dist/core/config/schemas/refined.d.ts +2 -2
  256. package/dist/core/config/schemas/refined.js +1 -1
  257. package/dist/core/config/schemas/relative.d.ts +672 -1761
  258. package/dist/core/config/schemas/relative.js +4 -4
  259. package/dist/core/config/settings.d.ts +3 -3
  260. package/dist/core/config/settings.js +5 -6
  261. package/dist/core/config/validate.js +13 -2
  262. package/dist/core/config/vite-load.js +12 -3
  263. package/dist/core/constants.d.ts +11 -0
  264. package/dist/core/constants.js +20 -1
  265. package/dist/core/create-vite.d.ts +2 -6
  266. package/dist/core/create-vite.js +35 -43
  267. package/dist/core/csp/common.d.ts +1 -1
  268. package/dist/core/csp/common.js +1 -1
  269. package/dist/core/csp/config.d.ts +8 -4
  270. package/dist/core/csp/config.js +1 -1
  271. package/dist/core/csp/runtime.d.ts +11 -0
  272. package/dist/core/csp/runtime.js +35 -0
  273. package/dist/core/dev/container.js +13 -7
  274. package/dist/core/dev/dev.js +2 -2
  275. package/dist/core/dev/restart.js +15 -6
  276. package/dist/core/errors/dev/runtime.d.ts +6 -0
  277. package/dist/core/errors/dev/runtime.js +27 -0
  278. package/dist/core/errors/dev/utils.js +1 -1
  279. package/dist/core/errors/dev/vite.js +1 -1
  280. package/dist/core/errors/errors-data.d.ts +27 -7
  281. package/dist/core/errors/errors-data.js +17 -4
  282. package/dist/core/errors/errors.d.ts +3 -3
  283. package/dist/core/errors/errors.js +8 -8
  284. package/dist/core/errors/zod-error-map.d.ts +2 -2
  285. package/dist/core/errors/zod-error-map.js +26 -24
  286. package/dist/core/logger/core.js +1 -1
  287. package/dist/core/messages.d.ts +2 -2
  288. package/dist/core/messages.js +3 -3
  289. package/dist/core/middleware/callMiddleware.js +1 -1
  290. package/dist/core/middleware/defineMiddleware.d.ts +2 -0
  291. package/dist/core/middleware/defineMiddleware.js +6 -0
  292. package/dist/core/middleware/index.d.ts +3 -3
  293. package/dist/core/middleware/index.js +1 -3
  294. package/dist/core/middleware/sequence.js +4 -4
  295. package/dist/core/middleware/vite-plugin.d.ts +1 -1
  296. package/dist/core/middleware/vite-plugin.js +18 -7
  297. package/dist/core/module-loader/index.d.ts +2 -2
  298. package/dist/core/module-loader/index.js +1 -1
  299. package/dist/core/module-loader/{loader.d.ts → runner.d.ts} +6 -17
  300. package/dist/core/module-loader/{loader.js → runner.js} +3 -0
  301. package/dist/core/module-loader/vite.d.ts +3 -2
  302. package/dist/core/module-loader/vite.js +17 -13
  303. package/dist/core/preview/index.js +20 -3
  304. package/dist/core/preview/static-preview-server.js +11 -0
  305. package/dist/core/redirects/component.js +1 -2
  306. package/dist/core/redirects/index.d.ts +0 -1
  307. package/dist/core/redirects/index.js +1 -3
  308. package/dist/core/redirects/render.js +5 -2
  309. package/dist/core/render/paginate.d.ts +1 -1
  310. package/dist/core/render/paginate.js +8 -6
  311. package/dist/core/render/params-and-props.d.ts +2 -0
  312. package/dist/core/render/params-and-props.js +19 -6
  313. package/dist/core/render/route-cache.d.ts +3 -2
  314. package/dist/core/render/route-cache.js +6 -5
  315. package/dist/core/render-context.d.ts +6 -4
  316. package/dist/core/render-context.js +66 -25
  317. package/dist/core/routing/astro-designed-error-pages.js +2 -2
  318. package/dist/core/routing/default.js +1 -1
  319. package/dist/core/routing/helpers.d.ts +22 -0
  320. package/dist/core/routing/helpers.js +25 -0
  321. package/dist/core/routing/index.d.ts +1 -1
  322. package/dist/core/routing/index.js +2 -2
  323. package/dist/core/routing/manifest/create.d.ts +6 -1
  324. package/dist/core/routing/manifest/create.js +11 -14
  325. package/dist/core/routing/manifest/generator.d.ts +3 -1
  326. package/dist/core/routing/params.d.ts +2 -1
  327. package/dist/core/routing/params.js +3 -2
  328. package/dist/core/server-islands/endpoint.js +40 -19
  329. package/dist/core/server-islands/vite-plugin-server-islands.d.ts +1 -1
  330. package/dist/core/server-islands/vite-plugin-server-islands.js +89 -44
  331. package/dist/core/session/vite-plugin.d.ts +6 -0
  332. package/dist/core/session/vite-plugin.js +53 -0
  333. package/dist/core/session.d.ts +4 -2
  334. package/dist/core/session.js +8 -48
  335. package/dist/core/sync/index.d.ts +2 -5
  336. package/dist/core/sync/index.js +34 -22
  337. package/dist/core/util/pathname.d.ts +10 -0
  338. package/dist/core/util/pathname.js +17 -0
  339. package/dist/core/util.d.ts +2 -2
  340. package/dist/core/util.js +3 -3
  341. package/dist/entrypoints/legacy.d.ts +2 -0
  342. package/dist/entrypoints/legacy.js +12 -0
  343. package/dist/entrypoints/prerender.d.ts +4 -0
  344. package/dist/entrypoints/prerender.js +7 -0
  345. package/dist/env/schema.d.ts +21 -251
  346. package/dist/env/schema.js +6 -3
  347. package/dist/env/vite-plugin-env.js +15 -10
  348. package/dist/env/vite-plugin-import-meta-env.js +3 -2
  349. package/dist/environments.d.ts +3 -0
  350. package/dist/environments.js +11 -0
  351. package/dist/events/error.d.ts +2 -2
  352. package/dist/i18n/index.d.ts +2 -2
  353. package/dist/i18n/utils.d.ts +1 -6
  354. package/dist/i18n/utils.js +1 -63
  355. package/dist/i18n/vite-plugin-i18n.d.ts +0 -5
  356. package/dist/i18n/vite-plugin-i18n.js +1 -22
  357. package/dist/integrations/hooks.d.ts +1 -1
  358. package/dist/integrations/hooks.js +10 -7
  359. package/dist/manifest/serialized.d.ts +9 -0
  360. package/dist/manifest/serialized.js +144 -0
  361. package/dist/manifest/virtual-module.d.ts +1 -4
  362. package/dist/manifest/virtual-module.js +77 -80
  363. package/dist/preferences/index.d.ts +1 -2
  364. package/dist/prerender/routing.d.ts +5 -7
  365. package/dist/prerender/routing.js +6 -17
  366. package/dist/runtime/client/dev-toolbar/ui-library/badge.d.ts +2 -2
  367. package/dist/runtime/client/dev-toolbar/ui-library/button.d.ts +2 -2
  368. package/dist/runtime/client/dev-toolbar/ui-library/card.d.ts +2 -2
  369. package/dist/runtime/client/dev-toolbar/ui-library/highlight.d.ts +2 -2
  370. package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.d.ts +2 -2
  371. package/dist/runtime/client/dev-toolbar/ui-library/select.d.ts +2 -2
  372. package/dist/runtime/client/dev-toolbar/ui-library/toggle.d.ts +2 -2
  373. package/dist/runtime/server/endpoint.js +1 -1
  374. package/dist/runtime/server/render/server-islands.js +5 -4
  375. package/dist/runtime/server/transition.d.ts +1 -0
  376. package/dist/template/4xx.js +3 -1
  377. package/dist/transitions/events.d.ts +7 -0
  378. package/dist/transitions/router.js +7 -3
  379. package/dist/transitions/swap-functions.js +4 -0
  380. package/dist/types/astro.d.ts +8 -6
  381. package/dist/types/public/config.d.ts +404 -288
  382. package/dist/types/public/context.d.ts +3 -4
  383. package/dist/types/public/index.d.ts +2 -1
  384. package/dist/types/public/integrations.d.ts +23 -1
  385. package/dist/types/public/internal.d.ts +1 -16
  386. package/dist/types/public/preview.d.ts +6 -0
  387. package/dist/virtual-modules/i18n.d.ts +10 -2
  388. package/dist/virtual-modules/i18n.js +16 -7
  389. package/dist/virtual-modules/live-config.d.ts +1 -1
  390. package/dist/virtual-modules/live-config.js +1 -1
  391. package/dist/virtual-modules/middleware.d.ts +2 -1
  392. package/dist/virtual-modules/middleware.js +2 -1
  393. package/dist/vite-plugin-adapter-config/index.js +3 -2
  394. package/dist/vite-plugin-app/app.d.ts +47 -0
  395. package/dist/vite-plugin-app/app.js +410 -0
  396. package/dist/vite-plugin-app/createAstroServerApp.d.ts +8 -0
  397. package/dist/vite-plugin-app/createAstroServerApp.js +56 -0
  398. package/dist/vite-plugin-app/index.d.ts +3 -0
  399. package/dist/vite-plugin-app/index.js +16 -0
  400. package/dist/{vite-plugin-astro-server → vite-plugin-app}/pipeline.d.ts +6 -7
  401. package/dist/vite-plugin-app/pipeline.js +166 -0
  402. package/dist/vite-plugin-astro/index.js +21 -7
  403. package/dist/vite-plugin-astro-server/base.js +1 -1
  404. package/dist/vite-plugin-astro-server/controller.d.ts +1 -1
  405. package/dist/vite-plugin-astro-server/error.d.ts +3 -4
  406. package/dist/vite-plugin-astro-server/error.js +2 -5
  407. package/dist/vite-plugin-astro-server/index.d.ts +1 -2
  408. package/dist/vite-plugin-astro-server/index.js +6 -4
  409. package/dist/vite-plugin-astro-server/metadata.js +1 -1
  410. package/dist/vite-plugin-astro-server/plugin.d.ts +4 -7
  411. package/dist/vite-plugin-astro-server/plugin.js +54 -65
  412. package/dist/vite-plugin-astro-server/server-state.d.ts +1 -1
  413. package/dist/vite-plugin-astro-server/util.d.ts +0 -2
  414. package/dist/vite-plugin-astro-server/util.js +1 -2
  415. package/dist/vite-plugin-astro-server/vite.d.ts +2 -2
  416. package/dist/vite-plugin-astro-server/vite.js +7 -7
  417. package/dist/vite-plugin-config-alias/index.js +40 -32
  418. package/dist/vite-plugin-css/index.d.ts +18 -0
  419. package/dist/vite-plugin-css/index.js +134 -0
  420. package/dist/vite-plugin-css/util.d.ts +5 -0
  421. package/dist/vite-plugin-css/util.js +8 -0
  422. package/dist/vite-plugin-environment/index.d.ts +15 -0
  423. package/dist/vite-plugin-environment/index.js +77 -0
  424. package/dist/vite-plugin-head/index.d.ts +1 -2
  425. package/dist/vite-plugin-head/index.js +42 -58
  426. package/dist/vite-plugin-hmr-reload/index.js +2 -1
  427. package/dist/vite-plugin-pages/const.d.ts +2 -0
  428. package/dist/vite-plugin-pages/const.js +6 -0
  429. package/dist/vite-plugin-pages/index.d.ts +2 -0
  430. package/dist/vite-plugin-pages/index.js +7 -0
  431. package/dist/vite-plugin-pages/page.d.ts +7 -0
  432. package/dist/vite-plugin-pages/page.js +48 -0
  433. package/dist/vite-plugin-pages/pages.d.ts +8 -0
  434. package/dist/vite-plugin-pages/pages.js +57 -0
  435. package/dist/vite-plugin-pages/util.d.ts +8 -0
  436. package/dist/vite-plugin-pages/util.js +15 -0
  437. package/dist/vite-plugin-renderers/index.d.ts +9 -0
  438. package/dist/vite-plugin-renderers/index.js +40 -0
  439. package/dist/vite-plugin-routes/index.d.ts +14 -0
  440. package/dist/vite-plugin-routes/index.js +177 -0
  441. package/dist/vite-plugin-scripts/index.js +2 -6
  442. package/dist/vite-plugin-scripts/page-ssr.js +3 -2
  443. package/dist/zod.d.ts +2 -2
  444. package/dist/zod.js +2 -2
  445. package/package.json +34 -31
  446. package/templates/content/module.mjs +1 -0
  447. package/templates/content/types.d.ts +24 -11
  448. package/types/actions.d.ts +1 -5
  449. package/types/content.d.ts +9 -11
  450. package/types/transitions.d.ts +25 -0
  451. package/dist/actions/loadActions.d.ts +0 -8
  452. package/dist/actions/loadActions.js +0 -13
  453. package/dist/actions/runtime/route.d.ts +0 -2
  454. package/dist/actions/runtime/shared.d.ts +0 -60
  455. package/dist/actions/runtime/shared.js +0 -296
  456. package/dist/actions/runtime/utils.d.ts +0 -25
  457. package/dist/actions/runtime/utils.js +0 -16
  458. package/dist/actions/runtime/virtual.d.ts +0 -4
  459. package/dist/actions/runtime/virtual.js +0 -127
  460. package/dist/assets/fonts/implementations/data-collector.d.ts +0 -3
  461. package/dist/assets/fonts/implementations/data-collector.js +0 -21
  462. package/dist/assets/fonts/implementations/error-handler.d.ts +0 -2
  463. package/dist/assets/fonts/implementations/error-handler.js +0 -41
  464. package/dist/assets/fonts/implementations/font-fetcher.d.ts +0 -8
  465. package/dist/assets/fonts/implementations/font-fetcher.js +0 -34
  466. package/dist/assets/fonts/implementations/font-file-reader.d.ts +0 -4
  467. package/dist/assets/fonts/implementations/font-file-reader.js +0 -26
  468. package/dist/assets/fonts/implementations/font-metrics-resolver.d.ts +0 -5
  469. package/dist/assets/fonts/implementations/font-metrics-resolver.js +0 -66
  470. package/dist/assets/fonts/implementations/font-type-extractor.d.ts +0 -4
  471. package/dist/assets/fonts/implementations/font-type-extractor.js +0 -22
  472. package/dist/assets/fonts/implementations/hasher.d.ts +0 -2
  473. package/dist/assets/fonts/implementations/hasher.js +0 -14
  474. package/dist/assets/fonts/implementations/levenshtein-string-matcher.d.ts +0 -2
  475. package/dist/assets/fonts/implementations/levenshtein-string-matcher.js +0 -147
  476. package/dist/assets/fonts/implementations/local-provider-url-resolver.d.ts +0 -5
  477. package/dist/assets/fonts/implementations/local-provider-url-resolver.js +0 -17
  478. package/dist/assets/fonts/implementations/remote-font-provider-mod-resolver.d.ts +0 -6
  479. package/dist/assets/fonts/implementations/remote-font-provider-mod-resolver.js +0 -20
  480. package/dist/assets/fonts/implementations/remote-font-provider-resolver.d.ts +0 -6
  481. package/dist/assets/fonts/implementations/remote-font-provider-resolver.js +0 -47
  482. package/dist/assets/fonts/implementations/storage.d.ts +0 -4
  483. package/dist/assets/fonts/implementations/storage.js +0 -14
  484. package/dist/assets/fonts/implementations/system-fallbacks-provider.d.ts +0 -11
  485. package/dist/assets/fonts/implementations/url-proxy-content-resolver.d.ts +0 -5
  486. package/dist/assets/fonts/implementations/url-proxy-content-resolver.js +0 -28
  487. package/dist/assets/fonts/implementations/url-proxy-hash-resolver.d.ts +0 -8
  488. package/dist/assets/fonts/implementations/url-proxy-hash-resolver.js +0 -39
  489. package/dist/assets/fonts/implementations/url-proxy.d.ts +0 -7
  490. package/dist/assets/fonts/implementations/url-proxy.js +0 -31
  491. package/dist/assets/fonts/implementations/url-resolver.d.ts +0 -11
  492. package/dist/assets/fonts/implementations/url-resolver.js +0 -55
  493. package/dist/assets/utils/node/emitAsset.d.ts +0 -15
  494. package/dist/assets/utils/transformToPath.js +0 -32
  495. package/dist/cli/docs/domains/platform.d.ts +0 -1
  496. package/dist/cli/docs/infra/process-platform-provider.d.ts +0 -2
  497. package/dist/cli/docs/infra/process-platform-provider.js +0 -11
  498. package/dist/cli/docs/infra/tinyexec-command-executor.d.ts +0 -2
  499. package/dist/cli/docs/infra/tinyexec-command-executor.js +0 -30
  500. package/dist/cli/info/index.d.ts +0 -12
  501. package/dist/cli/info/index.js +0 -267
  502. package/dist/cli/infra/picocolors-text-styler.d.ts +0 -2
  503. package/dist/cli/infra/picocolors-text-styler.js +0 -7
  504. package/dist/core/build/css-asset-name.d.ts +0 -9
  505. package/dist/core/build/css-asset-name.js +0 -89
  506. package/dist/core/build/plugin.d.ts +0 -43
  507. package/dist/core/build/plugin.js +0 -61
  508. package/dist/core/build/plugins/plugin-actions.d.ts +0 -4
  509. package/dist/core/build/plugins/plugin-actions.js +0 -16
  510. package/dist/core/build/plugins/plugin-chunks.d.ts +0 -2
  511. package/dist/core/build/plugins/plugin-chunks.js +0 -33
  512. package/dist/core/build/plugins/plugin-pages.d.ts +0 -6
  513. package/dist/core/build/plugins/plugin-pages.js +0 -66
  514. package/dist/core/build/plugins/plugin-renderers.d.ts +0 -5
  515. package/dist/core/build/plugins/plugin-renderers.js +0 -54
  516. package/dist/core/middleware/loadMiddleware.d.ts +0 -7
  517. package/dist/core/middleware/loadMiddleware.js +0 -14
  518. package/dist/core/redirects/helpers.d.ts +0 -7
  519. package/dist/core/redirects/helpers.js +0 -10
  520. package/dist/core/routing/manifest/serialization.d.ts +0 -5
  521. package/dist/core/routing/manifest/serialization.js +0 -37
  522. package/dist/prerender/metadata.d.ts +0 -8
  523. package/dist/prerender/metadata.js +0 -18
  524. package/dist/vite-plugin-astro-server/css.d.ts +0 -13
  525. package/dist/vite-plugin-astro-server/css.js +0 -48
  526. package/dist/vite-plugin-astro-server/pipeline.js +0 -161
  527. package/dist/vite-plugin-astro-server/request.d.ts +0 -14
  528. package/dist/vite-plugin-astro-server/request.js +0 -66
  529. package/dist/vite-plugin-astro-server/route.d.ts +0 -25
  530. package/dist/vite-plugin-astro-server/route.js +0 -283
  531. package/dist/vite-plugin-scanner/index.d.ts +0 -10
  532. package/dist/vite-plugin-scanner/index.js +0 -87
  533. package/dist/vite-plugin-ssr-manifest/index.d.ts +0 -2
  534. package/dist/vite-plugin-ssr-manifest/index.js +0 -26
  535. /package/dist/{cli/docs/domains/platform.js → actions/runtime/types.js} +0 -0
  536. /package/dist/assets/fonts/{logic → core}/extract-unifont-providers.d.ts +0 -0
  537. /package/dist/assets/fonts/{logic → core}/extract-unifont-providers.js +0 -0
  538. /package/dist/assets/fonts/{logic → core}/normalize-remote-font-faces.d.ts +0 -0
  539. /package/dist/assets/fonts/{logic → core}/normalize-remote-font-faces.js +0 -0
  540. /package/dist/assets/fonts/{logic → core}/optimize-fallbacks.d.ts +0 -0
  541. /package/dist/assets/fonts/{logic → core}/optimize-fallbacks.js +0 -0
  542. /package/dist/assets/fonts/{logic → core}/resolve-families.d.ts +0 -0
  543. /package/dist/assets/fonts/{logic → core}/resolve-families.js +0 -0
@@ -1,13 +1,14 @@
1
1
  import type { ComponentInstance } from '../../types/astro.js';
2
2
  import type { RewritePayload } from '../../types/public/common.js';
3
- import type { RouteData, SSRResult } from '../../types/public/internal.js';
4
- import { Pipeline, type TryRewriteResult } from '../base-pipeline.js';
3
+ import type { RouteData } from '../../types/public/internal.js';
4
+ import { type HeadElements, Pipeline, type TryRewriteResult } from '../base-pipeline.js';
5
5
  import type { SinglePageBuiltModule } from '../build/types.js';
6
6
  export declare class AppPipeline extends Pipeline {
7
- static create({ logger, manifest, runtimeMode, renderers, resolve, serverLike, streaming, defaultRoutes, }: Pick<AppPipeline, 'logger' | 'manifest' | 'runtimeMode' | 'renderers' | 'resolve' | 'serverLike' | 'streaming' | 'defaultRoutes'>): AppPipeline;
8
- headElements(routeData: RouteData): Pick<SSRResult, 'scripts' | 'styles' | 'links'>;
7
+ getName(): string;
8
+ static create({ manifest, streaming }: Pick<AppPipeline, 'manifest' | 'streaming'>): AppPipeline;
9
+ headElements(routeData: RouteData): Promise<HeadElements>;
9
10
  componentMetadata(): void;
10
11
  getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
11
- tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
12
12
  getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
13
+ tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
13
14
  }
@@ -1,25 +1,36 @@
1
1
  import { Pipeline } from "../base-pipeline.js";
2
- import { RedirectSinglePageBuiltModule } from "../redirects/component.js";
3
- import { createModuleScriptElement, createStylesheetElementSet } from "../render/ssr-element.js";
2
+ import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
3
+ import {
4
+ createAssetLink,
5
+ createModuleScriptElement,
6
+ createStylesheetElementSet
7
+ } from "../render/ssr-element.js";
8
+ import { getFallbackRoute, routeIsFallback, routeIsRedirect } from "../routing/helpers.js";
4
9
  import { findRouteToRewrite } from "../routing/rewrite.js";
10
+ import { createConsoleLogger } from "./logging.js";
5
11
  class AppPipeline extends Pipeline {
6
- static create({
7
- logger,
8
- manifest,
9
- runtimeMode,
10
- renderers,
11
- resolve,
12
- serverLike,
13
- streaming,
14
- defaultRoutes
15
- }) {
12
+ getName() {
13
+ return "AppPipeline";
14
+ }
15
+ static create({ manifest, streaming }) {
16
+ const resolve = async function resolve2(specifier) {
17
+ if (!(specifier in manifest.entryModules)) {
18
+ throw new Error(`Unable to resolve [${specifier}]`);
19
+ }
20
+ const bundlePath = manifest.entryModules[specifier];
21
+ if (bundlePath.startsWith("data:") || bundlePath.length === 0) {
22
+ return bundlePath;
23
+ } else {
24
+ return createAssetLink(bundlePath, manifest.base, manifest.assetsPrefix);
25
+ }
26
+ };
27
+ const logger = createConsoleLogger(manifest.logLevel);
16
28
  const pipeline = new AppPipeline(
17
29
  logger,
18
30
  manifest,
19
- runtimeMode,
20
- renderers,
31
+ "production",
32
+ manifest.renderers,
21
33
  resolve,
22
- serverLike,
23
34
  streaming,
24
35
  void 0,
25
36
  void 0,
@@ -28,16 +39,16 @@ class AppPipeline extends Pipeline {
28
39
  void 0,
29
40
  void 0,
30
41
  void 0,
31
- void 0,
32
- defaultRoutes
42
+ void 0
33
43
  );
34
44
  return pipeline;
35
45
  }
36
- headElements(routeData) {
46
+ async headElements(routeData) {
47
+ const { assetsPrefix, base } = this.manifest;
37
48
  const routeInfo = this.manifest.routes.find((route) => route.routeData === routeData);
38
49
  const links = /* @__PURE__ */ new Set();
39
50
  const scripts = /* @__PURE__ */ new Set();
40
- const styles = createStylesheetElementSet(routeInfo?.styles ?? []);
51
+ const styles = createStylesheetElementSet(routeInfo?.styles ?? [], base, assetsPrefix);
41
52
  for (const script of routeInfo?.scripts ?? []) {
42
53
  if ("stage" in script) {
43
54
  if (script.stage === "head-inline") {
@@ -47,7 +58,7 @@ class AppPipeline extends Pipeline {
47
58
  });
48
59
  }
49
60
  } else {
50
- scripts.add(createModuleScriptElement(script));
61
+ scripts.add(createModuleScriptElement(script, base, assetsPrefix));
51
62
  }
52
63
  }
53
64
  return { links, styles, scripts };
@@ -58,6 +69,39 @@ class AppPipeline extends Pipeline {
58
69
  const module = await this.getModuleForRoute(routeData);
59
70
  return module.page();
60
71
  }
72
+ async getModuleForRoute(route) {
73
+ for (const defaultRoute of this.defaultRoutes) {
74
+ if (route.component === defaultRoute.component) {
75
+ return {
76
+ page: () => Promise.resolve(defaultRoute.instance)
77
+ };
78
+ }
79
+ }
80
+ let routeToProcess = route;
81
+ if (routeIsRedirect(route)) {
82
+ if (route.redirectRoute) {
83
+ routeToProcess = route.redirectRoute;
84
+ } else {
85
+ return RedirectSinglePageBuiltModule;
86
+ }
87
+ } else if (routeIsFallback(route)) {
88
+ routeToProcess = getFallbackRoute(route, this.manifest.routes);
89
+ }
90
+ if (this.manifest.pageMap) {
91
+ const importComponentInstance = this.manifest.pageMap.get(routeToProcess.component);
92
+ if (!importComponentInstance) {
93
+ throw new Error(
94
+ `Unexpectedly unable to find a component instance for route ${route.route}`
95
+ );
96
+ }
97
+ return await importComponentInstance();
98
+ } else if (this.manifest.pageModule) {
99
+ return this.manifest.pageModule;
100
+ }
101
+ throw new Error(
102
+ "Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue."
103
+ );
104
+ }
61
105
  async tryRewrite(payload, request) {
62
106
  const { newUrl, pathname, routeData } = findRouteToRewrite({
63
107
  payload,
@@ -66,39 +110,11 @@ class AppPipeline extends Pipeline {
66
110
  trailingSlash: this.manifest.trailingSlash,
67
111
  buildFormat: this.manifest.buildFormat,
68
112
  base: this.manifest.base,
69
- outDir: this.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
113
+ outDir: this.manifest?.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
70
114
  });
71
115
  const componentInstance = await this.getComponentByRoute(routeData);
72
116
  return { newUrl, pathname, componentInstance, routeData };
73
117
  }
74
- async getModuleForRoute(route) {
75
- for (const defaultRoute of this.defaultRoutes) {
76
- if (route.component === defaultRoute.component) {
77
- return {
78
- page: () => Promise.resolve(defaultRoute.instance),
79
- renderers: []
80
- };
81
- }
82
- }
83
- if (route.type === "redirect") {
84
- return RedirectSinglePageBuiltModule;
85
- } else {
86
- if (this.manifest.pageMap) {
87
- const importComponentInstance = this.manifest.pageMap.get(route.component);
88
- if (!importComponentInstance) {
89
- throw new Error(
90
- `Unexpectedly unable to find a component instance for route ${route.route}`
91
- );
92
- }
93
- return await importComponentInstance();
94
- } else if (this.manifest.pageModule) {
95
- return this.manifest.pageModule;
96
- }
97
- throw new Error(
98
- "Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue."
99
- );
100
- }
101
- }
102
118
  }
103
119
  export {
104
120
  AppPipeline
@@ -1,12 +1,13 @@
1
- import type { ZodType } from 'zod';
2
- import type { ActionAccept, ActionClient } from '../../actions/runtime/server.js';
3
- import type { RoutingStrategies } from '../../i18n/utils.js';
1
+ import type { ActionClient } from '../../actions/runtime/types.js';
4
2
  import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
5
3
  import type { AstroMiddlewareInstance } from '../../types/public/common.js';
6
4
  import type { AstroConfig, CspAlgorithm, Locales, RemotePattern, ResolvedSessionConfig } from '../../types/public/config.js';
7
5
  import type { RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
8
6
  import type { SinglePageBuiltModule } from '../build/types.js';
9
7
  import type { CspDirective } from '../csp/config.js';
8
+ import type { LoggerLevel } from '../logger/core.js';
9
+ import type { SessionDriver } from '../session.js';
10
+ import type { RoutingStrategies } from './common.js';
10
11
  type ComponentPath = string;
11
12
  export type StylesheetAsset = {
12
13
  type: 'inline';
@@ -15,28 +16,32 @@ export type StylesheetAsset = {
15
16
  type: 'external';
16
17
  src: string;
17
18
  };
19
+ type ScriptAsset = {
20
+ children: string;
21
+ stage: string;
22
+ } | {
23
+ type: 'inline' | 'external';
24
+ value: string;
25
+ };
18
26
  export interface RouteInfo {
19
27
  routeData: RouteData;
20
28
  file: string;
21
29
  links: string[];
22
- scripts: ({
23
- children: string;
24
- stage: string;
25
- } | {
26
- type: 'inline' | 'external';
27
- value: string;
28
- })[];
30
+ scripts: ScriptAsset[];
29
31
  styles: StylesheetAsset[];
30
32
  }
31
33
  export type SerializedRouteInfo = Omit<RouteInfo, 'routeData'> & {
32
34
  routeData: SerializedRouteData;
33
35
  };
34
36
  type ImportComponentInstance = () => Promise<SinglePageBuiltModule>;
37
+ export type ServerIslandMappings = {
38
+ serverIslandMap?: Map<string, () => Promise<ComponentInstance>>;
39
+ serverIslandNameMap?: Map<string, string>;
40
+ };
35
41
  export type AssetsPrefix = string | ({
36
42
  fallback: string;
37
43
  } & Record<string, string>) | undefined;
38
44
  export type SSRManifest = {
39
- hrefRoot: string;
40
45
  adapterName: string;
41
46
  routes: RouteInfo[];
42
47
  site?: string;
@@ -53,6 +58,13 @@ export type SSRManifest = {
53
58
  compressHTML: boolean;
54
59
  assetsPrefix?: AssetsPrefix;
55
60
  renderers: SSRLoadedRenderer[];
61
+ /**
62
+ * Based on Astro config's `output` option, `true` if "server" or "hybrid".
63
+ *
64
+ * Whether this application is SSR-like. If so, this has some implications, such as
65
+ * the creation of `dist/client` and `dist/server` folders.
66
+ */
67
+ serverLike: boolean;
56
68
  /**
57
69
  * Map of directive name (e.g. `load`) to the directive script code
58
70
  */
@@ -63,26 +75,43 @@ export type SSRManifest = {
63
75
  componentMetadata: SSRResult['componentMetadata'];
64
76
  pageModule?: SinglePageBuiltModule;
65
77
  pageMap?: Map<ComponentPath, ImportComponentInstance>;
66
- serverIslandMap?: Map<string, () => Promise<ComponentInstance>>;
67
- serverIslandNameMap?: Map<string, string>;
78
+ serverIslandMappings?: () => Promise<ServerIslandMappings> | ServerIslandMappings;
68
79
  key: Promise<CryptoKey>;
69
80
  i18n: SSRManifestI18n | undefined;
70
81
  middleware?: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
71
82
  actions?: () => Promise<SSRActions> | SSRActions;
83
+ sessionDriver?: () => Promise<{
84
+ default: SessionDriver | null;
85
+ }>;
72
86
  checkOrigin: boolean;
73
87
  allowedDomains?: Partial<RemotePattern>[];
74
88
  sessionConfig?: ResolvedSessionConfig<any>;
75
- cacheDir: string | URL;
76
- srcDir: string | URL;
77
- outDir: string | URL;
78
- publicDir: string | URL;
79
- buildClientDir: string | URL;
80
- buildServerDir: string | URL;
89
+ cacheDir: URL;
90
+ srcDir: URL;
91
+ outDir: URL;
92
+ rootDir: URL;
93
+ publicDir: URL;
94
+ assetsDir: string;
95
+ buildClientDir: URL;
96
+ buildServerDir: URL;
81
97
  csp: SSRManifestCSP | undefined;
98
+ devToolbar: {
99
+ enabled: boolean;
100
+ /**
101
+ * Latest version of Astro, will be undefined if:
102
+ * - unable to check
103
+ * - the user has disabled the check
104
+ * - the check has not completed yet
105
+ * - the user is on the latest version already
106
+ */
107
+ latestAstroVersion: string | undefined;
108
+ debugInfoOutput: string | undefined;
109
+ };
82
110
  internalFetchHeaders?: Record<string, string>;
111
+ logLevel: LoggerLevel;
83
112
  };
84
113
  export type SSRActions = {
85
- server: Record<string, ActionClient<unknown, ActionAccept, ZodType>>;
114
+ server: Record<string, ActionClient<any, any, any>>;
86
115
  };
87
116
  export type SSRManifestI18n = {
88
117
  fallback: Record<string, string> | undefined;
@@ -91,6 +120,7 @@ export type SSRManifestI18n = {
91
120
  locales: Locales;
92
121
  defaultLocale: string;
93
122
  domainLookupTable: Record<string, string>;
123
+ domains: Record<string, string> | undefined;
94
124
  };
95
125
  export type SSRManifestCSP = {
96
126
  cspDestination: 'adapter' | 'meta' | 'header' | undefined;
@@ -103,13 +133,19 @@ export type SSRManifestCSP = {
103
133
  directives: CspDirective[];
104
134
  };
105
135
  /** Public type exposed through the `astro:build:ssr` integration hook */
106
- export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key'> & {
136
+ export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key' | 'rootDir' | 'srcDir' | 'cacheDir' | 'outDir' | 'publicDir' | 'buildClientDir' | 'buildServerDir'> & {
137
+ rootDir: string;
138
+ srcDir: string;
139
+ cacheDir: string;
140
+ outDir: string;
141
+ publicDir: string;
142
+ buildClientDir: string;
143
+ buildServerDir: string;
107
144
  routes: SerializedRouteInfo[];
108
145
  assets: string[];
109
146
  componentMetadata: [string, SSRComponentMetadata][];
110
147
  inlinedScripts: [string, string][];
111
148
  clientDirectives: [string, string][];
112
- serverIslandNameMap: [string, string][];
113
149
  key: string;
114
150
  };
115
151
  export type NodeAppHeadersJson = {
@@ -0,0 +1,16 @@
1
+ import { type RemotePattern } from '../../assets/utils/remotePattern.js';
2
+ /**
3
+ * Validate a hostname by rejecting any with path separators.
4
+ * Prevents path injection attacks. Invalid hostnames return undefined.
5
+ */
6
+ export declare function sanitizeHost(hostname: string | undefined): string | undefined;
7
+ /**
8
+ * Validate forwarded headers (proto, host, port) against allowedDomains.
9
+ * Returns validated values or undefined for rejected headers.
10
+ * Uses strict defaults: http/https only for proto, rejects port if not in allowedDomains.
11
+ */
12
+ export declare function validateForwardedHeaders(forwardedProtocol?: string, forwardedHost?: string, forwardedPort?: string, allowedDomains?: Partial<RemotePattern>[]): {
13
+ protocol?: string;
14
+ host?: string;
15
+ port?: string;
16
+ };
@@ -0,0 +1,60 @@
1
+ import { matchPattern } from "../../assets/utils/remotePattern.js";
2
+ function sanitizeHost(hostname) {
3
+ if (!hostname) return void 0;
4
+ if (/[/\\]/.test(hostname)) return void 0;
5
+ return hostname;
6
+ }
7
+ function validateForwardedHeaders(forwardedProtocol, forwardedHost, forwardedPort, allowedDomains) {
8
+ const result = {};
9
+ if (forwardedProtocol) {
10
+ if (allowedDomains && allowedDomains.length > 0) {
11
+ const hasProtocolPatterns = allowedDomains.some((pattern) => pattern.protocol !== void 0);
12
+ if (hasProtocolPatterns) {
13
+ try {
14
+ const testUrl = new URL(`${forwardedProtocol}://example.com`);
15
+ const isAllowed = allowedDomains.some((pattern) => matchPattern(testUrl, pattern));
16
+ if (isAllowed) {
17
+ result.protocol = forwardedProtocol;
18
+ }
19
+ } catch {
20
+ }
21
+ } else if (/^https?$/.test(forwardedProtocol)) {
22
+ result.protocol = forwardedProtocol;
23
+ }
24
+ } else if (/^https?$/.test(forwardedProtocol)) {
25
+ result.protocol = forwardedProtocol;
26
+ }
27
+ }
28
+ if (forwardedPort && allowedDomains && allowedDomains.length > 0) {
29
+ const hasPortPatterns = allowedDomains.some((pattern) => pattern.port !== void 0);
30
+ if (hasPortPatterns) {
31
+ const isAllowed = allowedDomains.some((pattern) => pattern.port === forwardedPort);
32
+ if (isAllowed) {
33
+ result.port = forwardedPort;
34
+ }
35
+ }
36
+ }
37
+ if (forwardedHost && forwardedHost.length > 0 && allowedDomains && allowedDomains.length > 0) {
38
+ const protoForValidation = result.protocol || "https";
39
+ const sanitized = sanitizeHost(forwardedHost);
40
+ if (sanitized) {
41
+ try {
42
+ const hostnameOnly = sanitized.split(":")[0];
43
+ const portFromHost = sanitized.includes(":") ? sanitized.split(":")[1] : void 0;
44
+ const portForValidation = result.port || portFromHost;
45
+ const hostWithPort = portForValidation ? `${hostnameOnly}:${portForValidation}` : hostnameOnly;
46
+ const testUrl = new URL(`${protoForValidation}://${hostWithPort}`);
47
+ const isAllowed = allowedDomains.some((pattern) => matchPattern(testUrl, pattern));
48
+ if (isAllowed) {
49
+ result.host = sanitized;
50
+ }
51
+ } catch {
52
+ }
53
+ }
54
+ }
55
+ return result;
56
+ }
57
+ export {
58
+ sanitizeHost,
59
+ validateForwardedHeaders
60
+ };
@@ -1,11 +1,14 @@
1
- import type { ZodType } from 'zod';
2
- import type { ActionAccept, ActionClient } from '../actions/runtime/server.js';
1
+ import type { $ZodType } from 'zod/v4/core';
2
+ import type { ActionAccept, ActionClient } from '../actions/runtime/types.js';
3
3
  import type { ComponentInstance } from '../types/astro.js';
4
4
  import type { MiddlewareHandler, RewritePayload } from '../types/public/common.js';
5
5
  import type { RuntimeMode } from '../types/public/config.js';
6
6
  import type { RouteData, SSRActions, SSRLoadedRenderer, SSRManifest, SSRResult } from '../types/public/internal.js';
7
+ import type { ServerIslandMappings } from './app/types.js';
8
+ import type { SinglePageBuiltModule } from './build/types.js';
7
9
  import type { Logger } from './logger/core.js';
8
10
  import { RouteCache } from './render/route-cache.js';
11
+ import type { SessionDriver } from './session.js';
9
12
  /**
10
13
  * The `Pipeline` represents the static parts of rendering that do not change between requests.
11
14
  * These are mostly known when the server first starts up and do not change.
@@ -21,10 +24,6 @@ export declare abstract class Pipeline {
21
24
  readonly runtimeMode: RuntimeMode;
22
25
  readonly renderers: SSRLoadedRenderer[];
23
26
  readonly resolve: (s: string) => Promise<string>;
24
- /**
25
- * Based on Astro config's `output` option, `true` if "server" or "hybrid".
26
- */
27
- readonly serverLike: boolean;
28
27
  readonly streaming: boolean;
29
28
  /**
30
29
  * Used to provide better error messages for `Astro.clientAddress`
@@ -51,18 +50,19 @@ export declare abstract class Pipeline {
51
50
  component: string;
52
51
  }[];
53
52
  readonly actions: (() => Promise<SSRActions> | SSRActions) | undefined;
53
+ readonly sessionDriver: (() => Promise<{
54
+ default: SessionDriver | null;
55
+ }>) | undefined;
56
+ readonly serverIslands: (() => Promise<ServerIslandMappings> | ServerIslandMappings) | undefined;
54
57
  readonly internalMiddleware: MiddlewareHandler[];
55
58
  resolvedMiddleware: MiddlewareHandler | undefined;
56
59
  resolvedActions: SSRActions | undefined;
60
+ resolvedSessionDriver: SessionDriver | null | undefined;
57
61
  constructor(logger: Logger, manifest: SSRManifest,
58
62
  /**
59
63
  * "development" or "production" only
60
64
  */
61
- runtimeMode: RuntimeMode, renderers: SSRLoadedRenderer[], resolve: (s: string) => Promise<string>,
62
- /**
63
- * Based on Astro config's `output` option, `true` if "server" or "hybrid".
64
- */
65
- serverLike: boolean, streaming: boolean,
65
+ runtimeMode: RuntimeMode, renderers: SSRLoadedRenderer[], resolve: (s: string) => Promise<string>, streaming: boolean,
66
66
  /**
67
67
  * Used to provide better error messages for `Astro.clientAddress`
68
68
  */
@@ -80,7 +80,9 @@ export declare abstract class Pipeline {
80
80
  matchesComponent(filePath: URL): boolean;
81
81
  route: string;
82
82
  component: string;
83
- }[], actions?: (() => Promise<SSRActions> | SSRActions) | undefined);
83
+ }[], actions?: (() => Promise<SSRActions> | SSRActions) | undefined, sessionDriver?: (() => Promise<{
84
+ default: SessionDriver | null;
85
+ }>) | undefined, serverIslands?: (() => Promise<ServerIslandMappings> | ServerIslandMappings) | undefined);
84
86
  abstract headElements(routeData: RouteData): Promise<HeadElements> | HeadElements;
85
87
  abstract componentMetadata(routeData: RouteData): Promise<SSRResult['componentMetadata']> | void;
86
88
  /**
@@ -99,14 +101,20 @@ export declare abstract class Pipeline {
99
101
  * @param routeData
100
102
  */
101
103
  abstract getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
104
+ /**
105
+ * The current name of the pipeline. Useful for debugging
106
+ */
107
+ abstract getName(): string;
102
108
  /**
103
109
  * Resolves the middleware from the manifest, and returns the `onRequest` function. If `onRequest` isn't there,
104
110
  * it returns a no-op function
105
111
  */
106
112
  getMiddleware(): Promise<MiddlewareHandler>;
107
- setActions(actions: SSRActions): void;
108
113
  getActions(): Promise<SSRActions>;
109
- getAction(path: string): Promise<ActionClient<unknown, ActionAccept, ZodType>>;
114
+ getSessionDriver(): Promise<SessionDriver | null>;
115
+ getServerIslands(): Promise<ServerIslandMappings>;
116
+ getAction(path: string): Promise<ActionClient<unknown, ActionAccept, $ZodType>>;
117
+ getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
110
118
  }
111
119
  export interface HeadElements extends Pick<SSRResult, 'scripts' | 'styles' | 'links'> {
112
120
  }
@@ -5,16 +5,16 @@ import { ActionNotFoundError } from "./errors/errors-data.js";
5
5
  import { AstroError } from "./errors/index.js";
6
6
  import { NOOP_MIDDLEWARE_FN } from "./middleware/noop-middleware.js";
7
7
  import { sequence } from "./middleware/sequence.js";
8
+ import { RedirectSinglePageBuiltModule } from "./redirects/index.js";
8
9
  import { RouteCache } from "./render/route-cache.js";
9
10
  import { createDefaultRoutes } from "./routing/default.js";
10
11
  class Pipeline {
11
- constructor(logger, manifest, runtimeMode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, inlinedScripts = manifest.inlinedScripts, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, runtimeMode), site = manifest.site ? new URL(manifest.site) : void 0, defaultRoutes = createDefaultRoutes(manifest), actions = manifest.actions) {
12
+ constructor(logger, manifest, runtimeMode, renderers, resolve, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, inlinedScripts = manifest.inlinedScripts, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, runtimeMode), site = manifest.site ? new URL(manifest.site) : void 0, defaultRoutes = createDefaultRoutes(manifest), actions = manifest.actions, sessionDriver = manifest.sessionDriver, serverIslands = manifest.serverIslandMappings) {
12
13
  this.logger = logger;
13
14
  this.manifest = manifest;
14
15
  this.runtimeMode = runtimeMode;
15
16
  this.renderers = renderers;
16
17
  this.resolve = resolve;
17
- this.serverLike = serverLike;
18
18
  this.streaming = streaming;
19
19
  this.adapterName = adapterName;
20
20
  this.clientDirectives = clientDirectives;
@@ -26,6 +26,8 @@ class Pipeline {
26
26
  this.site = site;
27
27
  this.defaultRoutes = defaultRoutes;
28
28
  this.actions = actions;
29
+ this.sessionDriver = sessionDriver;
30
+ this.serverIslands = serverIslands;
29
31
  this.internalMiddleware = [];
30
32
  if (i18n?.strategy !== "manual") {
31
33
  this.internalMiddleware.push(
@@ -36,6 +38,7 @@ class Pipeline {
36
38
  internalMiddleware;
37
39
  resolvedMiddleware = void 0;
38
40
  resolvedActions = void 0;
41
+ resolvedSessionDriver = void 0;
39
42
  /**
40
43
  * Resolves the middleware from the manifest, and returns the `onRequest` function. If `onRequest` isn't there,
41
44
  * it returns a no-op function
@@ -57,17 +60,35 @@ class Pipeline {
57
60
  return this.resolvedMiddleware;
58
61
  }
59
62
  }
60
- setActions(actions) {
61
- this.resolvedActions = actions;
62
- }
63
63
  async getActions() {
64
64
  if (this.resolvedActions) {
65
65
  return this.resolvedActions;
66
66
  } else if (this.actions) {
67
- return await this.actions();
67
+ return this.actions();
68
68
  }
69
69
  return NOOP_ACTIONS_MOD;
70
70
  }
71
+ async getSessionDriver() {
72
+ if (this.resolvedSessionDriver !== void 0) {
73
+ return this.resolvedSessionDriver;
74
+ }
75
+ if (this.sessionDriver) {
76
+ const driverModule = await this.sessionDriver();
77
+ this.resolvedSessionDriver = driverModule?.default || null;
78
+ return this.resolvedSessionDriver;
79
+ }
80
+ this.resolvedSessionDriver = null;
81
+ return null;
82
+ }
83
+ async getServerIslands() {
84
+ if (this.serverIslands) {
85
+ return this.serverIslands();
86
+ }
87
+ return {
88
+ serverIslandMap: /* @__PURE__ */ new Map(),
89
+ serverIslandNameMap: /* @__PURE__ */ new Map()
90
+ };
91
+ }
71
92
  async getAction(path) {
72
93
  const pathKeys = path.split(".").map((key) => decodeURIComponent(key));
73
94
  let { server } = await this.getActions();
@@ -92,6 +113,33 @@ class Pipeline {
92
113
  }
93
114
  return server;
94
115
  }
116
+ async getModuleForRoute(route) {
117
+ for (const defaultRoute of this.defaultRoutes) {
118
+ if (route.component === defaultRoute.component) {
119
+ return {
120
+ page: () => Promise.resolve(defaultRoute.instance)
121
+ };
122
+ }
123
+ }
124
+ if (route.type === "redirect") {
125
+ return RedirectSinglePageBuiltModule;
126
+ } else {
127
+ if (this.manifest.pageMap) {
128
+ const importComponentInstance = this.manifest.pageMap.get(route.component);
129
+ if (!importComponentInstance) {
130
+ throw new Error(
131
+ `Unexpectedly unable to find a component instance for route ${route.route}`
132
+ );
133
+ }
134
+ return await importComponentInstance();
135
+ } else if (this.manifest.pageModule) {
136
+ return this.manifest.pageModule;
137
+ }
138
+ throw new Error(
139
+ "Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue."
140
+ );
141
+ }
142
+ }
95
143
  }
96
144
  export {
97
145
  Pipeline
@@ -0,0 +1,13 @@
1
+ import { BaseApp, type RenderErrorOptions } from '../app/index.js';
2
+ import type { SSRManifest } from '../app/types.js';
3
+ import type { BuildInternals } from './internal.js';
4
+ import { BuildPipeline } from './pipeline.js';
5
+ import type { StaticBuildOptions } from './types.js';
6
+ export declare class BuildApp extends BaseApp<BuildPipeline> {
7
+ createPipeline(_streaming: boolean, manifest: SSRManifest, ..._args: any[]): BuildPipeline;
8
+ setInternals(internals: BuildInternals): void;
9
+ setOptions(options: StaticBuildOptions): void;
10
+ getOptions(): StaticBuildOptions;
11
+ getSettings(): import("../../types/astro.js").AstroSettings;
12
+ renderError(request: Request, options: RenderErrorOptions): Promise<Response>;
13
+ }
@@ -0,0 +1,38 @@
1
+ import { BaseApp } from "../app/index.js";
2
+ import { BuildPipeline } from "./pipeline.js";
3
+ class BuildApp extends BaseApp {
4
+ createPipeline(_streaming, manifest, ..._args) {
5
+ return BuildPipeline.create({
6
+ manifest
7
+ });
8
+ }
9
+ setInternals(internals) {
10
+ this.pipeline.setInternals(internals);
11
+ }
12
+ setOptions(options) {
13
+ this.pipeline.setOptions(options);
14
+ this.logger = options.logger;
15
+ }
16
+ getOptions() {
17
+ return this.pipeline.getOptions();
18
+ }
19
+ getSettings() {
20
+ return this.pipeline.getSettings();
21
+ }
22
+ async renderError(request, options) {
23
+ if (options.status === 500) {
24
+ if (options.response) {
25
+ return options.response;
26
+ }
27
+ throw options.error;
28
+ } else {
29
+ return super.renderError(request, {
30
+ ...options,
31
+ prerenderedErrorPageFetch: void 0
32
+ });
33
+ }
34
+ }
35
+ }
36
+ export {
37
+ BuildApp
38
+ };
@@ -2,7 +2,7 @@ import type { AstroSettings } from '../../types/astro.js';
2
2
  import type { AstroConfig } from '../../types/public/config.js';
3
3
  import type { RouteData } from '../../types/public/internal.js';
4
4
  export declare function getOutFolder(astroSettings: AstroSettings, pathname: string, routeData: RouteData): URL;
5
- export declare function getOutFile(astroConfig: AstroConfig, outFolder: URL, pathname: string, routeData: RouteData): URL;
5
+ export declare function getOutFile(buildFormat: NonNullable<AstroConfig['build']>['format'], outFolder: URL, pathname: string, routeData: RouteData): URL;
6
6
  /**
7
7
  * Ensures the `outDir` is within `process.cwd()`. If not it will fallback to `<cwd>/.astro`.
8
8
  * This is used for static `ssrBuild` so the output can access node_modules when we import