astro 5.16.5 → 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 (393) hide show
  1. package/{astro.js → bin/astro.mjs} +7 -8
  2. package/client.d.ts +19 -45
  3. package/components/ClientRouter.astro +0 -5
  4. package/components/Code.astro +2 -2
  5. package/components/Image.astro +2 -2
  6. package/components/Picture.astro +1 -1
  7. package/dist/actions/consts.d.ts +2 -5
  8. package/dist/actions/consts.js +4 -8
  9. package/dist/actions/integration.js +2 -4
  10. package/dist/actions/runtime/client.d.ts +84 -3
  11. package/dist/actions/runtime/client.js +238 -7
  12. package/dist/actions/runtime/entrypoints/client.d.ts +7 -0
  13. package/dist/actions/runtime/entrypoints/client.js +91 -0
  14. package/dist/actions/runtime/entrypoints/route.d.ts +2 -0
  15. package/dist/actions/runtime/{route.js → entrypoints/route.js} +1 -1
  16. package/dist/actions/runtime/entrypoints/server.d.ts +6 -0
  17. package/dist/actions/runtime/entrypoints/server.js +33 -0
  18. package/dist/actions/runtime/server.d.ts +11 -29
  19. package/dist/actions/runtime/server.js +162 -82
  20. package/dist/actions/runtime/types.d.ts +64 -0
  21. package/dist/actions/runtime/types.js +0 -0
  22. package/dist/actions/utils.d.ts +2 -2
  23. package/dist/actions/utils.js +2 -2
  24. package/dist/actions/vite-plugin-actions.js +18 -21
  25. package/dist/assets/build/generate.d.ts +2 -2
  26. package/dist/assets/build/generate.js +11 -9
  27. package/dist/assets/build/remote.js +4 -14
  28. package/dist/assets/endpoint/config.js +2 -2
  29. package/dist/assets/endpoint/dev.js +7 -6
  30. package/dist/assets/fonts/config.d.ts +86 -174
  31. package/dist/assets/fonts/config.js +15 -17
  32. package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.d.ts +3 -3
  33. package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.js +4 -4
  34. package/dist/assets/fonts/types.d.ts +1 -1
  35. package/dist/assets/fonts/vite-plugin-fonts.js +6 -3
  36. package/dist/assets/services/sharp.js +5 -6
  37. package/dist/assets/utils/index.d.ts +0 -6
  38. package/dist/assets/utils/index.js +0 -9
  39. package/dist/assets/utils/{transformToPath.d.ts → node.d.ts} +15 -1
  40. package/dist/assets/utils/{node/emitAsset.js → node.js} +34 -56
  41. package/dist/assets/vite-plugin-assets.js +9 -14
  42. package/dist/cli/index.js +0 -2
  43. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  44. package/dist/cli/preferences/index.js +5 -1
  45. package/dist/config/index.js +11 -16
  46. package/dist/container/index.d.ts +0 -1
  47. package/dist/container/index.js +19 -14
  48. package/dist/container/pipeline.d.ts +2 -1
  49. package/dist/container/pipeline.js +4 -11
  50. package/dist/content/config.d.ts +34 -40
  51. package/dist/content/config.js +17 -13
  52. package/dist/content/content-layer.js +14 -21
  53. package/dist/content/data-store.d.ts +0 -2
  54. package/dist/content/loaders/errors.d.ts +3 -3
  55. package/dist/content/loaders/errors.js +5 -2
  56. package/dist/content/loaders/glob.d.ts +0 -5
  57. package/dist/content/loaders/glob.js +3 -30
  58. package/dist/content/loaders/types.d.ts +11 -4
  59. package/dist/content/mutable-data-store.js +1 -14
  60. package/dist/content/runtime-assets.d.ts +4 -4
  61. package/dist/content/runtime-assets.js +4 -7
  62. package/dist/content/runtime.d.ts +35 -73
  63. package/dist/content/runtime.js +63 -231
  64. package/dist/content/server-listeners.js +25 -88
  65. package/dist/content/types-generator.d.ts +1 -6
  66. package/dist/content/types-generator.js +87 -156
  67. package/dist/content/utils.d.ts +47 -412
  68. package/dist/content/utils.js +88 -203
  69. package/dist/content/vite-plugin-content-assets.d.ts +12 -4
  70. package/dist/content/vite-plugin-content-assets.js +100 -56
  71. package/dist/content/vite-plugin-content-imports.js +10 -8
  72. package/dist/content/vite-plugin-content-virtual-mod.js +13 -131
  73. package/dist/core/app/app.d.ts +5 -0
  74. package/dist/core/app/app.js +13 -0
  75. package/dist/core/app/base.d.ts +132 -0
  76. package/dist/core/app/base.js +448 -0
  77. package/dist/core/app/common.d.ts +6 -2
  78. package/dist/core/app/common.js +60 -33
  79. package/dist/core/app/dev/app.d.ts +15 -0
  80. package/dist/core/app/dev/app.js +86 -0
  81. package/dist/core/app/dev/pipeline.d.ts +13 -0
  82. package/dist/core/app/dev/pipeline.js +123 -0
  83. package/dist/core/app/entrypoint.d.ts +2 -0
  84. package/dist/core/app/entrypoint.js +15 -0
  85. package/dist/core/app/index.d.ts +7 -114
  86. package/dist/core/app/index.js +20 -557
  87. package/dist/core/app/logging.d.ts +3 -0
  88. package/dist/core/app/logging.js +11 -0
  89. package/dist/core/app/manifest.d.ts +9 -0
  90. package/dist/core/app/manifest.js +107 -0
  91. package/dist/core/app/middlewares.js +1 -1
  92. package/dist/core/app/node.d.ts +2 -8
  93. package/dist/core/app/node.js +8 -9
  94. package/dist/core/app/pipeline.d.ts +6 -5
  95. package/dist/core/app/pipeline.js +65 -49
  96. package/dist/core/app/types.d.ts +58 -22
  97. package/dist/core/app/validate-forwarded-headers.d.ts +16 -0
  98. package/dist/core/app/validate-forwarded-headers.js +60 -0
  99. package/dist/core/base-pipeline.d.ts +22 -14
  100. package/dist/core/base-pipeline.js +54 -6
  101. package/dist/core/build/app.d.ts +13 -0
  102. package/dist/core/build/app.js +38 -0
  103. package/dist/core/build/common.d.ts +1 -1
  104. package/dist/core/build/common.js +2 -2
  105. package/dist/core/build/generate.d.ts +1 -1
  106. package/dist/core/build/generate.js +95 -204
  107. package/dist/core/build/graph.js +2 -2
  108. package/dist/core/build/index.js +11 -19
  109. package/dist/core/build/internal.d.ts +3 -29
  110. package/dist/core/build/internal.js +1 -45
  111. package/dist/core/build/pipeline.d.ts +15 -26
  112. package/dist/core/build/pipeline.js +106 -170
  113. package/dist/core/build/plugins/index.d.ts +4 -2
  114. package/dist/core/build/plugins/index.js +17 -23
  115. package/dist/core/build/plugins/plugin-analyzer.d.ts +2 -2
  116. package/dist/core/build/plugins/plugin-analyzer.js +5 -13
  117. package/dist/core/build/plugins/plugin-component-entry.d.ts +7 -2
  118. package/dist/core/build/plugins/plugin-component-entry.js +5 -13
  119. package/dist/core/build/plugins/plugin-css.d.ts +2 -2
  120. package/dist/core/build/plugins/plugin-css.js +86 -41
  121. package/dist/core/build/plugins/plugin-internals.d.ts +2 -2
  122. package/dist/core/build/plugins/plugin-internals.js +24 -18
  123. package/dist/core/build/plugins/plugin-manifest.d.ts +33 -5
  124. package/dist/core/build/plugins/plugin-manifest.js +89 -131
  125. package/dist/core/build/plugins/plugin-middleware.d.ts +2 -2
  126. package/dist/core/build/plugins/plugin-middleware.js +5 -7
  127. package/dist/core/build/plugins/plugin-noop.d.ts +3 -0
  128. package/dist/core/build/plugins/plugin-noop.js +29 -0
  129. package/dist/core/build/plugins/plugin-prerender.d.ts +2 -2
  130. package/dist/core/build/plugins/plugin-prerender.js +7 -64
  131. package/dist/core/build/plugins/plugin-scripts.d.ts +5 -2
  132. package/dist/core/build/plugins/plugin-scripts.js +5 -13
  133. package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
  134. package/dist/core/build/plugins/plugin-ssr.js +60 -132
  135. package/dist/core/build/plugins/util.d.ts +1 -25
  136. package/dist/core/build/plugins/util.js +0 -47
  137. package/dist/core/build/runtime.d.ts +26 -0
  138. package/dist/core/build/runtime.js +45 -0
  139. package/dist/core/build/static-build.d.ts +2 -2
  140. package/dist/core/build/static-build.js +180 -154
  141. package/dist/core/build/types.d.ts +1 -2
  142. package/dist/core/build/util.d.ts +0 -1
  143. package/dist/core/build/util.js +0 -7
  144. package/dist/core/compile/compile.d.ts +2 -3
  145. package/dist/core/compile/compile.js +2 -4
  146. package/dist/core/config/config.js +2 -2
  147. package/dist/core/config/index.d.ts +0 -1
  148. package/dist/core/config/index.js +0 -2
  149. package/dist/core/config/schemas/base.d.ts +330 -1463
  150. package/dist/core/config/schemas/base.js +40 -56
  151. package/dist/core/config/schemas/refined.d.ts +2 -2
  152. package/dist/core/config/schemas/refined.js +8 -1
  153. package/dist/core/config/schemas/relative.d.ts +607 -1737
  154. package/dist/core/config/schemas/relative.js +4 -4
  155. package/dist/core/config/settings.d.ts +3 -3
  156. package/dist/core/config/settings.js +5 -6
  157. package/dist/core/config/validate.js +13 -2
  158. package/dist/core/config/vite-load.js +12 -3
  159. package/dist/core/constants.d.ts +12 -0
  160. package/dist/core/constants.js +22 -1
  161. package/dist/core/create-vite.d.ts +2 -6
  162. package/dist/core/create-vite.js +36 -47
  163. package/dist/core/csp/common.d.ts +1 -1
  164. package/dist/core/csp/common.js +1 -1
  165. package/dist/core/csp/config.d.ts +8 -4
  166. package/dist/core/csp/config.js +1 -1
  167. package/dist/core/dev/container.js +13 -9
  168. package/dist/core/dev/dev.js +1 -1
  169. package/dist/core/dev/restart.js +15 -6
  170. package/dist/core/errors/dev/runtime.d.ts +6 -0
  171. package/dist/core/errors/dev/runtime.js +27 -0
  172. package/dist/core/errors/dev/vite.js +2 -19
  173. package/dist/core/errors/errors-data.d.ts +85 -57
  174. package/dist/core/errors/errors-data.js +40 -28
  175. package/dist/core/errors/errors.d.ts +3 -3
  176. package/dist/core/errors/errors.js +1 -1
  177. package/dist/core/errors/overlay.js +1 -1
  178. package/dist/core/errors/zod-error-map.d.ts +2 -2
  179. package/dist/core/errors/zod-error-map.js +26 -24
  180. package/dist/core/messages.d.ts +2 -2
  181. package/dist/core/messages.js +2 -2
  182. package/dist/core/middleware/callMiddleware.js +1 -1
  183. package/dist/core/middleware/defineMiddleware.d.ts +2 -0
  184. package/dist/core/middleware/defineMiddleware.js +6 -0
  185. package/dist/core/middleware/index.d.ts +4 -4
  186. package/dist/core/middleware/index.js +6 -12
  187. package/dist/core/middleware/sequence.js +4 -4
  188. package/dist/core/middleware/vite-plugin.d.ts +1 -1
  189. package/dist/core/middleware/vite-plugin.js +18 -7
  190. package/dist/core/module-loader/index.d.ts +2 -2
  191. package/dist/core/module-loader/index.js +1 -1
  192. package/dist/core/module-loader/{loader.d.ts → runner.d.ts} +6 -17
  193. package/dist/core/module-loader/{loader.js → runner.js} +3 -0
  194. package/dist/core/module-loader/vite.d.ts +3 -2
  195. package/dist/core/module-loader/vite.js +17 -13
  196. package/dist/core/preview/index.js +20 -5
  197. package/dist/core/preview/static-preview-server.js +1 -0
  198. package/dist/core/redirects/component.js +1 -2
  199. package/dist/core/redirects/index.d.ts +0 -1
  200. package/dist/core/redirects/index.js +1 -3
  201. package/dist/core/redirects/render.js +5 -2
  202. package/dist/core/render/paginate.d.ts +1 -1
  203. package/dist/core/render/paginate.js +8 -6
  204. package/dist/core/render/params-and-props.d.ts +2 -0
  205. package/dist/core/render/params-and-props.js +19 -7
  206. package/dist/core/render/route-cache.d.ts +3 -3
  207. package/dist/core/render/route-cache.js +7 -7
  208. package/dist/core/render-context.d.ts +9 -7
  209. package/dist/core/render-context.js +46 -47
  210. package/dist/core/routing/astro-designed-error-pages.js +2 -2
  211. package/dist/core/routing/default.js +1 -1
  212. package/dist/core/routing/helpers.d.ts +22 -0
  213. package/dist/core/routing/helpers.js +25 -0
  214. package/dist/core/routing/index.d.ts +1 -1
  215. package/dist/core/routing/index.js +2 -2
  216. package/dist/core/routing/manifest/create.d.ts +6 -1
  217. package/dist/core/routing/manifest/create.js +9 -13
  218. package/dist/core/routing/manifest/generator.d.ts +3 -1
  219. package/dist/core/routing/params.d.ts +2 -1
  220. package/dist/core/routing/params.js +8 -8
  221. package/dist/core/routing/validation.d.ts +1 -2
  222. package/dist/core/routing/validation.js +2 -18
  223. package/dist/core/server-islands/endpoint.d.ts +1 -2
  224. package/dist/core/server-islands/endpoint.js +5 -4
  225. package/dist/core/server-islands/vite-plugin-server-islands.d.ts +1 -1
  226. package/dist/core/server-islands/vite-plugin-server-islands.js +89 -44
  227. package/dist/core/session/vite-plugin.d.ts +6 -0
  228. package/dist/core/session/vite-plugin.js +53 -0
  229. package/dist/core/session.d.ts +4 -2
  230. package/dist/core/session.js +8 -48
  231. package/dist/core/sync/index.d.ts +2 -5
  232. package/dist/core/sync/index.js +19 -34
  233. package/dist/core/util.d.ts +2 -2
  234. package/dist/core/util.js +3 -3
  235. package/dist/entrypoints/legacy.d.ts +2 -0
  236. package/dist/entrypoints/legacy.js +12 -0
  237. package/dist/entrypoints/prerender.d.ts +4 -0
  238. package/dist/entrypoints/prerender.js +7 -0
  239. package/dist/env/env-loader.d.ts +0 -1
  240. package/dist/env/env-loader.js +4 -17
  241. package/dist/env/schema.d.ts +21 -251
  242. package/dist/env/schema.js +6 -3
  243. package/dist/env/vite-plugin-env.js +3 -2
  244. package/dist/env/vite-plugin-import-meta-env.js +3 -2
  245. package/dist/environments.d.ts +3 -0
  246. package/dist/environments.js +11 -0
  247. package/dist/events/error.d.ts +2 -2
  248. package/dist/i18n/index.d.ts +2 -2
  249. package/dist/i18n/index.js +0 -3
  250. package/dist/i18n/utils.d.ts +1 -6
  251. package/dist/i18n/utils.js +1 -63
  252. package/dist/i18n/vite-plugin-i18n.d.ts +0 -5
  253. package/dist/i18n/vite-plugin-i18n.js +1 -22
  254. package/dist/integrations/hooks.d.ts +2 -3
  255. package/dist/integrations/hooks.js +9 -33
  256. package/dist/manifest/serialized.d.ts +9 -0
  257. package/dist/manifest/serialized.js +144 -0
  258. package/dist/manifest/virtual-module.d.ts +1 -4
  259. package/dist/manifest/virtual-module.js +77 -80
  260. package/dist/preferences/index.d.ts +1 -2
  261. package/dist/prefetch/index.d.ts +0 -10
  262. package/dist/prefetch/index.js +1 -1
  263. package/dist/prerender/routing.d.ts +5 -7
  264. package/dist/prerender/routing.js +6 -17
  265. package/dist/runtime/server/astro-global.d.ts +2 -2
  266. package/dist/runtime/server/astro-global.js +86 -24
  267. package/dist/runtime/server/render/server-islands.js +2 -2
  268. package/dist/runtime/server/transition.d.ts +1 -0
  269. package/dist/transitions/events.d.ts +7 -0
  270. package/dist/transitions/router.js +7 -3
  271. package/dist/transitions/vite-plugin-transitions.js +1 -4
  272. package/dist/types/astro.d.ts +10 -8
  273. package/dist/types/public/common.d.ts +1 -3
  274. package/dist/types/public/config.d.ts +364 -415
  275. package/dist/types/public/context.d.ts +21 -52
  276. package/dist/types/public/index.d.ts +2 -1
  277. package/dist/types/public/integrations.d.ts +23 -18
  278. package/dist/types/public/internal.d.ts +3 -18
  279. package/dist/types/public/preview.d.ts +6 -0
  280. package/dist/virtual-modules/i18n.d.ts +10 -2
  281. package/dist/virtual-modules/i18n.js +16 -7
  282. package/dist/virtual-modules/live-config.d.ts +1 -3
  283. package/dist/virtual-modules/live-config.js +1 -5
  284. package/dist/virtual-modules/middleware.d.ts +2 -1
  285. package/dist/virtual-modules/middleware.js +2 -1
  286. package/dist/vite-plugin-adapter-config/index.js +3 -2
  287. package/dist/vite-plugin-app/app.d.ts +47 -0
  288. package/dist/vite-plugin-app/app.js +410 -0
  289. package/dist/vite-plugin-app/createAstroServerApp.d.ts +8 -0
  290. package/dist/vite-plugin-app/createAstroServerApp.js +56 -0
  291. package/dist/vite-plugin-app/index.d.ts +3 -0
  292. package/dist/vite-plugin-app/index.js +16 -0
  293. package/dist/{vite-plugin-astro-server → vite-plugin-app}/pipeline.d.ts +5 -7
  294. package/dist/vite-plugin-app/pipeline.js +166 -0
  295. package/dist/vite-plugin-astro/index.js +11 -13
  296. package/dist/vite-plugin-astro-server/controller.d.ts +1 -1
  297. package/dist/vite-plugin-astro-server/error.d.ts +3 -4
  298. package/dist/vite-plugin-astro-server/error.js +2 -5
  299. package/dist/vite-plugin-astro-server/index.d.ts +1 -2
  300. package/dist/vite-plugin-astro-server/index.js +6 -4
  301. package/dist/vite-plugin-astro-server/metadata.js +1 -1
  302. package/dist/vite-plugin-astro-server/plugin.d.ts +4 -7
  303. package/dist/vite-plugin-astro-server/plugin.js +53 -96
  304. package/dist/vite-plugin-astro-server/server-state.d.ts +1 -1
  305. package/dist/vite-plugin-astro-server/util.d.ts +0 -2
  306. package/dist/vite-plugin-astro-server/util.js +1 -2
  307. package/dist/vite-plugin-astro-server/vite.d.ts +2 -2
  308. package/dist/vite-plugin-astro-server/vite.js +7 -7
  309. package/dist/vite-plugin-config-alias/index.js +40 -32
  310. package/dist/vite-plugin-css/index.d.ts +18 -0
  311. package/dist/vite-plugin-css/index.js +134 -0
  312. package/dist/vite-plugin-css/util.d.ts +5 -0
  313. package/dist/vite-plugin-css/util.js +8 -0
  314. package/dist/vite-plugin-environment/index.d.ts +15 -0
  315. package/dist/vite-plugin-environment/index.js +77 -0
  316. package/dist/vite-plugin-head/index.d.ts +1 -2
  317. package/dist/vite-plugin-head/index.js +42 -58
  318. package/dist/vite-plugin-hmr-reload/index.js +2 -1
  319. package/dist/vite-plugin-markdown/index.js +0 -1
  320. package/dist/vite-plugin-pages/const.d.ts +2 -0
  321. package/dist/vite-plugin-pages/const.js +6 -0
  322. package/dist/vite-plugin-pages/index.d.ts +2 -0
  323. package/dist/vite-plugin-pages/index.js +7 -0
  324. package/dist/vite-plugin-pages/page.d.ts +7 -0
  325. package/dist/vite-plugin-pages/page.js +48 -0
  326. package/dist/vite-plugin-pages/pages.d.ts +8 -0
  327. package/dist/vite-plugin-pages/pages.js +57 -0
  328. package/dist/vite-plugin-pages/util.d.ts +8 -0
  329. package/dist/vite-plugin-pages/util.js +15 -0
  330. package/dist/vite-plugin-renderers/index.d.ts +9 -0
  331. package/dist/vite-plugin-renderers/index.js +40 -0
  332. package/dist/vite-plugin-routes/index.d.ts +14 -0
  333. package/dist/vite-plugin-routes/index.js +177 -0
  334. package/dist/vite-plugin-scripts/index.js +2 -6
  335. package/dist/vite-plugin-scripts/page-ssr.js +3 -2
  336. package/dist/zod.d.ts +2 -2
  337. package/dist/zod.js +2 -2
  338. package/package.json +14 -15
  339. package/templates/content/module.mjs +9 -63
  340. package/templates/content/types.d.ts +32 -78
  341. package/types/actions.d.ts +1 -5
  342. package/types/content.d.ts +9 -11
  343. package/types/transitions.d.ts +25 -0
  344. package/dist/actions/loadActions.d.ts +0 -8
  345. package/dist/actions/loadActions.js +0 -13
  346. package/dist/actions/runtime/route.d.ts +0 -2
  347. package/dist/actions/runtime/shared.d.ts +0 -60
  348. package/dist/actions/runtime/shared.js +0 -296
  349. package/dist/actions/runtime/utils.d.ts +0 -31
  350. package/dist/actions/runtime/utils.js +0 -16
  351. package/dist/actions/runtime/virtual.d.ts +0 -4
  352. package/dist/actions/runtime/virtual.js +0 -127
  353. package/dist/assets/utils/node/emitAsset.d.ts +0 -29
  354. package/dist/assets/utils/transformToPath.js +0 -32
  355. package/dist/config/vite-plugin-content-listen.d.ts +0 -17
  356. package/dist/config/vite-plugin-content-listen.js +0 -26
  357. package/dist/container/polyfill.d.ts +0 -1
  358. package/dist/container/polyfill.js +0 -2
  359. package/dist/core/build/css-asset-name.d.ts +0 -9
  360. package/dist/core/build/css-asset-name.js +0 -89
  361. package/dist/core/build/plugin.d.ts +0 -43
  362. package/dist/core/build/plugin.js +0 -61
  363. package/dist/core/build/plugins/plugin-actions.d.ts +0 -4
  364. package/dist/core/build/plugins/plugin-actions.js +0 -16
  365. package/dist/core/build/plugins/plugin-chunks.d.ts +0 -2
  366. package/dist/core/build/plugins/plugin-chunks.js +0 -33
  367. package/dist/core/build/plugins/plugin-pages.d.ts +0 -6
  368. package/dist/core/build/plugins/plugin-pages.js +0 -66
  369. package/dist/core/build/plugins/plugin-renderers.d.ts +0 -5
  370. package/dist/core/build/plugins/plugin-renderers.js +0 -54
  371. package/dist/core/middleware/loadMiddleware.d.ts +0 -7
  372. package/dist/core/middleware/loadMiddleware.js +0 -14
  373. package/dist/core/polyfill.d.ts +0 -5
  374. package/dist/core/polyfill.js +0 -17
  375. package/dist/core/redirects/helpers.d.ts +0 -7
  376. package/dist/core/redirects/helpers.js +0 -10
  377. package/dist/core/routing/manifest/serialization.d.ts +0 -5
  378. package/dist/core/routing/manifest/serialization.js +0 -37
  379. package/dist/prerender/metadata.d.ts +0 -8
  380. package/dist/prerender/metadata.js +0 -18
  381. package/dist/vite-plugin-astro-postprocess/index.d.ts +0 -2
  382. package/dist/vite-plugin-astro-postprocess/index.js +0 -48
  383. package/dist/vite-plugin-astro-server/css.d.ts +0 -13
  384. package/dist/vite-plugin-astro-server/css.js +0 -48
  385. package/dist/vite-plugin-astro-server/pipeline.js +0 -166
  386. package/dist/vite-plugin-astro-server/request.d.ts +0 -14
  387. package/dist/vite-plugin-astro-server/request.js +0 -73
  388. package/dist/vite-plugin-astro-server/route.d.ts +0 -25
  389. package/dist/vite-plugin-astro-server/route.js +0 -283
  390. package/dist/vite-plugin-scanner/index.d.ts +0 -10
  391. package/dist/vite-plugin-scanner/index.js +0 -87
  392. package/dist/vite-plugin-ssr-manifest/index.d.ts +0 -2
  393. package/dist/vite-plugin-ssr-manifest/index.js +0 -26
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- // ISOMORPHIC FILE: NO TOP-LEVEL IMPORT/REQUIRE() ALLOWED
5
- // This file has to run as both ESM and CJS on older Node.js versions
6
-
7
4
  const CI_INSTRUCTIONS = {
8
5
  NETLIFY: 'https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript',
9
6
  GITHUB_ACTIONS:
@@ -11,9 +8,12 @@ const CI_INSTRUCTIONS = {
11
8
  VERCEL: 'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
12
9
  };
13
10
 
11
+ // TODO: remove once Stackblitz supports Node 22
12
+ const IS_STACKBLITZ = !!process.versions.webcontainer;
13
+
14
14
  // Hardcode supported Node.js version so we don't have to read differently in CJS & ESM.
15
- const engines = '>=18.20.8';
16
- const skipSemverCheckIfAbove = 19;
15
+ const engines = IS_STACKBLITZ ? '>=20.19.5' : '>=22.12.0';
16
+ const skipSemverCheckIfAbove = IS_STACKBLITZ ? 21 : 23;
17
17
 
18
18
  /** `astro *` */
19
19
  async function main() {
@@ -39,7 +39,7 @@ async function main() {
39
39
  if (correctedCwd !== cwd) process.chdir(correctedCwd);
40
40
  }
41
41
 
42
- return import('./dist/cli/index.js')
42
+ return import('../dist/cli/index.js')
43
43
  .then(({ cli }) => cli(process.argv))
44
44
  .catch((error) => {
45
45
  console.error(error);
@@ -52,8 +52,7 @@ async function errorNodeUnsupported() {
52
52
  Node.js v${process.versions.node} is not supported by Astro!
53
53
  Please upgrade Node.js to a supported version: "${engines}"\n`);
54
54
 
55
- // eslint-disable-next-line @typescript-eslint/no-require-imports
56
- const ci = typeof require !== 'undefined' ? require('ci-info') : await import('ci-info');
55
+ const ci = await import('ci-info');
57
56
 
58
57
  // Special instructions for CI environments, which may have special steps needed.
59
58
  // This is a common issue that we can help users with proactively.
package/client.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  /// <reference types="vite/types/import-meta.d.ts" />
2
- /// <reference path="./types/content.d.ts" />
2
+
3
3
  /// <reference path="./types/actions.d.ts" />
4
+ /// <reference path="./types/content.d.ts" />
4
5
  /// <reference path="./types/env.d.ts" />
5
6
  /// <reference path="./types/fonts.d.ts" />
7
+ /// <reference path="./types/transitions.d.ts" />
6
8
 
7
9
  interface ImportMetaEnv {
10
+ // TODO: remove in Astro 7
8
11
  /**
9
12
  * The prefix for Astro-generated asset links if the build.assetsPrefix config option is set. This can be used to create asset links not handled by Astro.
13
+ * @deprecated This will be removed in a future major version of Astro. Use `build.assetsPrefix` from `astro:config/server` instead.
10
14
  */
11
15
  readonly ASSETS_PREFIX: string | Record<string, string>;
12
16
  /**
@@ -117,50 +121,6 @@ declare module '*.svg' {
117
121
  export default Component;
118
122
  }
119
123
 
120
- declare module 'astro:transitions' {
121
- type TransitionModule = typeof import('./dist/virtual-modules/transitions.js');
122
- export const slide: TransitionModule['slide'];
123
- export const fade: TransitionModule['fade'];
124
- export const createAnimationScope: TransitionModule['createAnimationScope'];
125
-
126
- type ClientRouterModule = typeof import('./components/ClientRouter.astro');
127
- /**
128
- * @deprecated The ViewTransitions component has been renamed to ClientRouter
129
- */
130
- export const ViewTransitions: ClientRouterModule['default'];
131
- export const ClientRouter: ClientRouterModule['default'];
132
- }
133
-
134
- declare module 'astro:transitions/client' {
135
- type TransitionRouterModule = typeof import('./dist/virtual-modules/transitions-router.js');
136
- export const navigate: TransitionRouterModule['navigate'];
137
- export const supportsViewTransitions: TransitionRouterModule['supportsViewTransitions'];
138
- export const getFallback: TransitionRouterModule['getFallback'];
139
- export const transitionEnabledOnThisPage: TransitionRouterModule['transitionEnabledOnThisPage'];
140
-
141
- export type Fallback = import('./dist/virtual-modules/transitions-types.js').Fallback;
142
- export type Direction = import('./dist/virtual-modules/transitions-types.ts').Direction;
143
- // biome-ignore format: bug
144
- export type NavigationTypeString = import('./dist/virtual-modules/transitions-types.js').NavigationTypeString;
145
- export type Options = import('./dist/virtual-modules/transitions-types.js').Options;
146
-
147
- type EventModule = typeof import('./dist/virtual-modules/transitions-events.js');
148
- export const TRANSITION_BEFORE_PREPARATION: EventModule['TRANSITION_BEFORE_PREPARATION'];
149
- export const TRANSITION_AFTER_PREPARATION: EventModule['TRANSITION_AFTER_PREPARATION'];
150
- export const TRANSITION_BEFORE_SWAP: EventModule['TRANSITION_BEFORE_SWAP'];
151
- export const TRANSITION_AFTER_SWAP: EventModule['TRANSITION_AFTER_SWAP'];
152
- export const TRANSITION_PAGE_LOAD: EventModule['TRANSITION_PAGE_LOAD'];
153
- // biome-ignore format: bug
154
- export type TransitionBeforePreparationEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforePreparationEvent;
155
- // biome-ignore format: bug
156
- export type TransitionBeforeSwapEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforeSwapEvent;
157
- export const isTransitionBeforePreparationEvent: EventModule['isTransitionBeforePreparationEvent'];
158
- export const isTransitionBeforeSwapEvent: EventModule['isTransitionBeforeSwapEvent'];
159
- // biome-ignore format: bug
160
- type TransitionSwapFunctionModule = typeof import('./dist/virtual-modules/transitions-swap-functions.js');
161
- export const swapFunctions: TransitionSwapFunctionModule['swapFunctions'];
162
- }
163
-
164
124
  declare module 'astro:prefetch' {
165
125
  export { prefetch, PrefetchOptions } from 'astro/virtual-modules/prefetch.js';
166
126
  }
@@ -195,8 +155,22 @@ declare module 'astro:components' {
195
155
  export * from 'astro/components';
196
156
  }
197
157
 
158
+ // TODO: remove in Astro 7
159
+ /**
160
+ * @deprecated
161
+ * `import { z } from 'astro:schema'` is deprecated and will be removed
162
+ * in Astro 7. Use `import { z } from 'astro/zod'` instead.
163
+ */
198
164
  declare module 'astro:schema' {
199
165
  export * from 'astro/zod';
166
+ import zod from 'astro/zod';
167
+
168
+ /**
169
+ * @deprecated
170
+ * `import { z } from 'astro:schema'` is deprecated and will be removed
171
+ * in Astro 7. Use `import { z } from 'astro/zod'` instead.
172
+ */
173
+ export const z = zod.z;
200
174
  }
201
175
 
202
176
  type MD = import('./dist/types/public/content.js').MarkdownInstance<Record<string, any>>;
@@ -3,11 +3,6 @@ type Fallback = 'none' | 'animate' | 'swap';
3
3
 
4
4
  export interface Props {
5
5
  fallback?: Fallback;
6
- /** @deprecated handleForms is enabled by default in Astro 4.0
7
- *
8
- * Set `data-astro-reload` on your form to opt-out of the default behavior.
9
- */
10
- handleForms?: boolean;
11
6
  }
12
7
 
13
8
  const { fallback = 'animate' } = Astro.props;
@@ -3,8 +3,8 @@ import type { ThemePresets } from '@astrojs/markdown-remark';
3
3
  import type { ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
4
4
  import { bundledLanguages } from 'shiki/langs';
5
5
  import { getCachedHighlighter } from '../dist/core/shiki.js';
6
- import type { CodeLanguage } from '../dist/types/public';
7
- import type { HTMLAttributes } from '../types';
6
+ import type { CodeLanguage } from '../dist/types/public/common.js';
7
+ import type { HTMLAttributes } from '../types.js';
8
8
 
9
9
  interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
10
10
  /** The code to highlight. Required. */
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
3
- import type { UnresolvedImageTransform } from '../dist/assets/types';
3
+ import type { UnresolvedImageTransform } from '../dist/assets/types.js';
4
4
  import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
5
- import type { HTMLAttributes } from '../types';
5
+ import type { HTMLAttributes } from '../types.js';
6
6
 
7
7
  // The TypeScript diagnostic for JSX props uses the last member of the union to suggest props, so it would be better for
8
8
  // LocalImageProps to be last. Unfortunately, when we do this the error messages that remote images get are complete nonsense
@@ -8,7 +8,7 @@ import type {
8
8
  ImageOutputFormat,
9
9
  UnresolvedImageTransform,
10
10
  } from '../dist/types/public/index.js';
11
- import type { HTMLAttributes } from '../types';
11
+ import type { HTMLAttributes } from '../types.js';
12
12
 
13
13
  export type Props = (LocalImageProps | RemoteImageProps) & {
14
14
  formats?: ImageOutputFormat[];
@@ -1,11 +1,8 @@
1
1
  export declare const ACTIONS_TYPES_FILE = "actions.d.ts";
2
2
  export declare const VIRTUAL_MODULE_ID = "astro:actions";
3
3
  export declare const RESOLVED_VIRTUAL_MODULE_ID: string;
4
- /** Used to expose shared utilities, with server or client specific implementations */
5
- export declare const RUNTIME_VIRTUAL_MODULE_ID = "virtual:astro:actions/runtime";
6
- export declare const RESOLVED_RUNTIME_VIRTUAL_MODULE_ID: string;
7
- export declare const ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
8
- export declare const RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID: string;
4
+ export declare const ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
5
+ export declare const ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID: string;
9
6
  /** Used to pass data from the config to the main virtual module */
10
7
  export declare const OPTIONS_VIRTUAL_MODULE_ID = "virtual:astro:actions/options";
11
8
  export declare const RESOLVED_OPTIONS_VIRTUAL_MODULE_ID: string;
@@ -1,10 +1,8 @@
1
1
  const ACTIONS_TYPES_FILE = "actions.d.ts";
2
2
  const VIRTUAL_MODULE_ID = "astro:actions";
3
3
  const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
4
- const RUNTIME_VIRTUAL_MODULE_ID = "virtual:astro:actions/runtime";
5
- const RESOLVED_RUNTIME_VIRTUAL_MODULE_ID = "\0" + RUNTIME_VIRTUAL_MODULE_ID;
6
- const ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
7
- const RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID = "\0" + ENTRYPOINT_VIRTUAL_MODULE_ID;
4
+ const ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
5
+ const ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID = "\0" + ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID;
8
6
  const OPTIONS_VIRTUAL_MODULE_ID = "virtual:astro:actions/options";
9
7
  const RESOLVED_OPTIONS_VIRTUAL_MODULE_ID = "\0" + OPTIONS_VIRTUAL_MODULE_ID;
10
8
  const RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID = "\0virtual:astro:actions/noop-entrypoint";
@@ -14,16 +12,14 @@ const ACTION_QUERY_PARAMS = {
14
12
  };
15
13
  const ACTION_RPC_ROUTE_PATTERN = "/_actions/[...path]";
16
14
  export {
15
+ ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID,
16
+ ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID,
17
17
  ACTIONS_TYPES_FILE,
18
18
  ACTION_QUERY_PARAMS,
19
19
  ACTION_RPC_ROUTE_PATTERN,
20
- ENTRYPOINT_VIRTUAL_MODULE_ID,
21
20
  OPTIONS_VIRTUAL_MODULE_ID,
22
- RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID,
23
21
  RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID,
24
22
  RESOLVED_OPTIONS_VIRTUAL_MODULE_ID,
25
- RESOLVED_RUNTIME_VIRTUAL_MODULE_ID,
26
23
  RESOLVED_VIRTUAL_MODULE_ID,
27
- RUNTIME_VIRTUAL_MODULE_ID,
28
24
  VIRTUAL_MODULE_ID
29
25
  };
@@ -12,7 +12,7 @@ function astroIntegrationActionsRouteHandler({
12
12
  async "astro:config:setup"() {
13
13
  settings.injectedRoutes.push({
14
14
  pattern: ACTION_RPC_ROUTE_PATTERN,
15
- entrypoint: "astro/actions/runtime/route.js",
15
+ entrypoint: "astro/actions/runtime/entrypoints/route.js",
16
16
  prerender: false,
17
17
  origin: "internal"
18
18
  });
@@ -29,9 +29,7 @@ function astroIntegrationActionsRouteHandler({
29
29
  settings.injectedTypes.push({
30
30
  filename: ACTIONS_TYPES_FILE,
31
31
  content: `declare module "astro:actions" {
32
- type Actions = typeof import(${stringifiedActionsImport})["server"];
33
-
34
- export const actions: Actions;
32
+ export const actions: typeof import(${stringifiedActionsImport})["server"];
35
33
  }`
36
34
  });
37
35
  }
@@ -1,3 +1,84 @@
1
- export * from './shared.js';
2
- export declare function defineAction(): void;
3
- export declare function getActionContext(): void;
1
+ import type * as z from 'zod/v4/core';
2
+ import type { ActionClient, ActionErrorCode, ErrorInferenceObject, SafeResult, SerializedActionResult } from './types.js';
3
+ import type { APIContext } from '../../types/public/context.js';
4
+ export declare const codeToStatusMap: {
5
+ BAD_REQUEST: number;
6
+ UNAUTHORIZED: number;
7
+ PAYMENT_REQUIRED: number;
8
+ FORBIDDEN: number;
9
+ NOT_FOUND: number;
10
+ METHOD_NOT_ALLOWED: number;
11
+ NOT_ACCEPTABLE: number;
12
+ PROXY_AUTHENTICATION_REQUIRED: number;
13
+ REQUEST_TIMEOUT: number;
14
+ CONFLICT: number;
15
+ GONE: number;
16
+ LENGTH_REQUIRED: number;
17
+ PRECONDITION_FAILED: number;
18
+ CONTENT_TOO_LARGE: number;
19
+ URI_TOO_LONG: number;
20
+ UNSUPPORTED_MEDIA_TYPE: number;
21
+ RANGE_NOT_SATISFIABLE: number;
22
+ EXPECTATION_FAILED: number;
23
+ MISDIRECTED_REQUEST: number;
24
+ UNPROCESSABLE_CONTENT: number;
25
+ LOCKED: number;
26
+ FAILED_DEPENDENCY: number;
27
+ TOO_EARLY: number;
28
+ UPGRADE_REQUIRED: number;
29
+ PRECONDITION_REQUIRED: number;
30
+ TOO_MANY_REQUESTS: number;
31
+ REQUEST_HEADER_FIELDS_TOO_LARGE: number;
32
+ UNAVAILABLE_FOR_LEGAL_REASONS: number;
33
+ INTERNAL_SERVER_ERROR: number;
34
+ NOT_IMPLEMENTED: number;
35
+ BAD_GATEWAY: number;
36
+ SERVICE_UNAVAILABLE: number;
37
+ GATEWAY_TIMEOUT: number;
38
+ HTTP_VERSION_NOT_SUPPORTED: number;
39
+ VARIANT_ALSO_NEGOTIATES: number;
40
+ INSUFFICIENT_STORAGE: number;
41
+ LOOP_DETECTED: number;
42
+ NETWORK_AUTHENTICATION_REQUIRED: number;
43
+ };
44
+ export declare class ActionError<_T extends ErrorInferenceObject = ErrorInferenceObject> extends Error {
45
+ type: string;
46
+ code: ActionErrorCode;
47
+ status: number;
48
+ constructor(params: {
49
+ message?: string;
50
+ code: ActionErrorCode;
51
+ stack?: string;
52
+ });
53
+ static codeToStatus(code: ActionErrorCode): number;
54
+ static statusToCode(status: number): ActionErrorCode;
55
+ static fromJson(body: any): ActionError<ErrorInferenceObject>;
56
+ }
57
+ export declare function isActionError(error?: unknown): error is ActionError;
58
+ export declare function isInputError<T extends ErrorInferenceObject>(error?: ActionError<T>): error is ActionInputError<T>;
59
+ export declare function isInputError(error?: unknown): error is ActionInputError<ErrorInferenceObject>;
60
+ export declare class ActionInputError<T extends ErrorInferenceObject> extends ActionError {
61
+ type: string;
62
+ issues: z.$ZodIssue[];
63
+ fields: {
64
+ [P in keyof T]?: string[] | undefined;
65
+ };
66
+ constructor(issues: z.$ZodIssue[]);
67
+ }
68
+ export declare function deserializeActionResult(res: SerializedActionResult): SafeResult<any, any>;
69
+ export declare const actionResultErrorStack: {
70
+ set(stack: string | undefined): void;
71
+ get(): string | undefined;
72
+ };
73
+ export declare function getActionQueryString(name: string): string;
74
+ export declare function getActionPathFromString({ baseUrl, shouldAppendTrailingSlash, path: input, }: {
75
+ baseUrl: string;
76
+ shouldAppendTrailingSlash: boolean;
77
+ path: string;
78
+ }): string;
79
+ export declare function createGetActionPath(options: Pick<Parameters<typeof getActionPathFromString>[0], 'baseUrl' | 'shouldAppendTrailingSlash'>): (action: ActionClient<any, any, any>) => string;
80
+ export declare function createActionsProxy({ actionCallback, aggregatedPath, handleAction, }: {
81
+ actionCallback?: Record<string | symbol, any>;
82
+ aggregatedPath?: string;
83
+ handleAction: (param: any, path: string, context: APIContext | undefined) => Promise<SafeResult<any, any>>;
84
+ }): Record<string | symbol, any>;
@@ -1,11 +1,242 @@
1
- export * from "./shared.js";
2
- function defineAction() {
3
- throw new Error("[astro:action] `defineAction()` unexpectedly used on the client.");
1
+ import { parse as devalueParse } from "devalue";
2
+ import { ACTION_QUERY_PARAMS } from "../consts.js";
3
+ import { appendForwardSlash } from "../../core/path.js";
4
+ const codeToStatusMap = {
5
+ // Implemented from IANA HTTP Status Code Registry
6
+ // https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
7
+ BAD_REQUEST: 400,
8
+ UNAUTHORIZED: 401,
9
+ PAYMENT_REQUIRED: 402,
10
+ FORBIDDEN: 403,
11
+ NOT_FOUND: 404,
12
+ METHOD_NOT_ALLOWED: 405,
13
+ NOT_ACCEPTABLE: 406,
14
+ PROXY_AUTHENTICATION_REQUIRED: 407,
15
+ REQUEST_TIMEOUT: 408,
16
+ CONFLICT: 409,
17
+ GONE: 410,
18
+ LENGTH_REQUIRED: 411,
19
+ PRECONDITION_FAILED: 412,
20
+ CONTENT_TOO_LARGE: 413,
21
+ URI_TOO_LONG: 414,
22
+ UNSUPPORTED_MEDIA_TYPE: 415,
23
+ RANGE_NOT_SATISFIABLE: 416,
24
+ EXPECTATION_FAILED: 417,
25
+ MISDIRECTED_REQUEST: 421,
26
+ UNPROCESSABLE_CONTENT: 422,
27
+ LOCKED: 423,
28
+ FAILED_DEPENDENCY: 424,
29
+ TOO_EARLY: 425,
30
+ UPGRADE_REQUIRED: 426,
31
+ PRECONDITION_REQUIRED: 428,
32
+ TOO_MANY_REQUESTS: 429,
33
+ REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
34
+ UNAVAILABLE_FOR_LEGAL_REASONS: 451,
35
+ INTERNAL_SERVER_ERROR: 500,
36
+ NOT_IMPLEMENTED: 501,
37
+ BAD_GATEWAY: 502,
38
+ SERVICE_UNAVAILABLE: 503,
39
+ GATEWAY_TIMEOUT: 504,
40
+ HTTP_VERSION_NOT_SUPPORTED: 505,
41
+ VARIANT_ALSO_NEGOTIATES: 506,
42
+ INSUFFICIENT_STORAGE: 507,
43
+ LOOP_DETECTED: 508,
44
+ NETWORK_AUTHENTICATION_REQUIRED: 511
45
+ };
46
+ const statusToCodeMap = Object.entries(codeToStatusMap).reduce(
47
+ // reverse the key-value pairs
48
+ (acc, [key, value]) => ({ ...acc, [value]: key }),
49
+ {}
50
+ );
51
+ class ActionError extends Error {
52
+ type = "AstroActionError";
53
+ code = "INTERNAL_SERVER_ERROR";
54
+ status = 500;
55
+ constructor(params) {
56
+ super(params.message);
57
+ this.code = params.code;
58
+ this.status = ActionError.codeToStatus(params.code);
59
+ if (params.stack) {
60
+ this.stack = params.stack;
61
+ }
62
+ }
63
+ static codeToStatus(code) {
64
+ return codeToStatusMap[code];
65
+ }
66
+ static statusToCode(status) {
67
+ return statusToCodeMap[status] ?? "INTERNAL_SERVER_ERROR";
68
+ }
69
+ static fromJson(body) {
70
+ if (isInputError(body)) {
71
+ return new ActionInputError(body.issues);
72
+ }
73
+ if (isActionError(body)) {
74
+ return new ActionError(body);
75
+ }
76
+ return new ActionError({
77
+ code: "INTERNAL_SERVER_ERROR"
78
+ });
79
+ }
80
+ }
81
+ function isActionError(error) {
82
+ return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionError";
83
+ }
84
+ function isInputError(error) {
85
+ return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionInputError" && "issues" in error && Array.isArray(error.issues);
86
+ }
87
+ class ActionInputError extends ActionError {
88
+ type = "AstroActionInputError";
89
+ // We don't expose all ZodError properties.
90
+ // Not all properties will serialize from server to client,
91
+ // and we don't want to import the full ZodError object into the client.
92
+ issues;
93
+ fields;
94
+ constructor(issues) {
95
+ super({
96
+ message: `Failed to validate: ${JSON.stringify(issues, null, 2)}`,
97
+ code: "BAD_REQUEST"
98
+ });
99
+ this.issues = issues;
100
+ this.fields = {};
101
+ for (const issue of issues) {
102
+ if (issue.path.length > 0) {
103
+ const key = issue.path[0].toString();
104
+ this.fields[key] ??= [];
105
+ this.fields[key]?.push(issue.message);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ function deserializeActionResult(res) {
111
+ if (res.type === "error") {
112
+ let json;
113
+ try {
114
+ json = JSON.parse(res.body);
115
+ } catch {
116
+ return {
117
+ data: void 0,
118
+ error: new ActionError({
119
+ message: res.body,
120
+ code: "INTERNAL_SERVER_ERROR"
121
+ })
122
+ };
123
+ }
124
+ if (import.meta.env?.PROD) {
125
+ return { error: ActionError.fromJson(json), data: void 0 };
126
+ } else {
127
+ const error = ActionError.fromJson(json);
128
+ error.stack = actionResultErrorStack.get();
129
+ return {
130
+ error,
131
+ data: void 0
132
+ };
133
+ }
134
+ }
135
+ if (res.type === "empty") {
136
+ return { data: void 0, error: void 0 };
137
+ }
138
+ return {
139
+ data: devalueParse(res.body, {
140
+ URL: (href) => new URL(href)
141
+ }),
142
+ error: void 0
143
+ };
144
+ }
145
+ const actionResultErrorStack = /* @__PURE__ */ function actionResultErrorStackFn() {
146
+ let errorStack;
147
+ return {
148
+ set(stack) {
149
+ errorStack = stack;
150
+ },
151
+ get() {
152
+ return errorStack;
153
+ }
154
+ };
155
+ }();
156
+ function getActionQueryString(name) {
157
+ const searchParams = new URLSearchParams({ [ACTION_QUERY_PARAMS.actionName]: name });
158
+ return `?${searchParams.toString()}`;
159
+ }
160
+ function getActionPathFromString({
161
+ baseUrl,
162
+ shouldAppendTrailingSlash,
163
+ path: input
164
+ }) {
165
+ let path = `${baseUrl.replace(/\/$/, "")}/_actions/${new URLSearchParams(input).get(ACTION_QUERY_PARAMS.actionName)}`;
166
+ if (shouldAppendTrailingSlash) {
167
+ path = appendForwardSlash(path);
168
+ }
169
+ return path;
170
+ }
171
+ function createGetActionPath(options) {
172
+ return function getActionPath(action) {
173
+ return getActionPathFromString({
174
+ baseUrl: options.baseUrl,
175
+ shouldAppendTrailingSlash: options.shouldAppendTrailingSlash,
176
+ path: action.toString()
177
+ });
178
+ };
4
179
  }
5
- function getActionContext() {
6
- throw new Error("[astro:action] `getActionContext()` unexpectedly used on the client.");
180
+ const ENCODED_DOT = "%2E";
181
+ function createActionsProxy({
182
+ actionCallback = {},
183
+ aggregatedPath = "",
184
+ handleAction
185
+ }) {
186
+ return new Proxy(actionCallback, {
187
+ get(target, objKey) {
188
+ if (target.hasOwnProperty(objKey) || typeof objKey === "symbol") {
189
+ return target[objKey];
190
+ }
191
+ const path = aggregatedPath + encodeURIComponent(objKey.toString()).replaceAll(".", ENCODED_DOT);
192
+ function action(param) {
193
+ return handleAction(param, path, this);
194
+ }
195
+ Object.assign(action, {
196
+ queryString: getActionQueryString(path),
197
+ toString: () => action.queryString,
198
+ // redefine prototype methods as the object's own property, not the prototype's
199
+ bind: action.bind,
200
+ valueOf: () => action.valueOf,
201
+ // Progressive enhancement info for React.
202
+ $$FORM_ACTION: function() {
203
+ const searchParams = new URLSearchParams(action.toString());
204
+ return {
205
+ method: "POST",
206
+ // `name` creates a hidden input.
207
+ // It's unused by Astro, but we can't turn this off.
208
+ // At least use a name that won't conflict with a user's formData.
209
+ name: "_astroAction",
210
+ action: "?" + searchParams.toString()
211
+ };
212
+ },
213
+ // Note: `orThrow` does not have progressive enhancement info.
214
+ // If you want to throw exceptions,
215
+ // you must handle those exceptions with client JS.
216
+ async orThrow(param) {
217
+ const { data, error } = await handleAction(param, path, this);
218
+ if (error) throw error;
219
+ return data;
220
+ }
221
+ });
222
+ return createActionsProxy({
223
+ actionCallback: action,
224
+ aggregatedPath: path + ".",
225
+ handleAction
226
+ });
227
+ }
228
+ });
7
229
  }
8
230
  export {
9
- defineAction,
10
- getActionContext
231
+ ActionError,
232
+ ActionInputError,
233
+ actionResultErrorStack,
234
+ codeToStatusMap,
235
+ createActionsProxy,
236
+ createGetActionPath,
237
+ deserializeActionResult,
238
+ getActionPathFromString,
239
+ getActionQueryString,
240
+ isActionError,
241
+ isInputError
11
242
  };
@@ -0,0 +1,7 @@
1
+ export { ACTION_QUERY_PARAMS } from '../../consts.js';
2
+ export { ActionError, isActionError, isInputError, } from '../client.js';
3
+ export type { ActionAPIContext, ActionClient, ActionErrorCode, ActionInputSchema, ActionReturnType, SafeResult, } from '../types.js';
4
+ export declare function defineAction(): void;
5
+ export declare function getActionContext(): void;
6
+ export declare const getActionPath: (action: import("../types.js").ActionClient<any, any, any>) => string;
7
+ export declare const actions: Record<string | symbol, any>;