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,4 +0,0 @@
1
- import type { ActionClient } from './server.js';
2
- export * from 'virtual:astro:actions/runtime';
3
- export declare function getActionPath(action: ActionClient<any, any, any>): string;
4
- export declare const actions: Record<string | symbol, any>;
@@ -1,127 +0,0 @@
1
- import { shouldAppendTrailingSlash } from "virtual:astro:actions/options";
2
- import { internalFetchHeaders } from "virtual:astro:adapter-config/client";
3
- import {
4
- ACTION_QUERY_PARAMS,
5
- ActionError,
6
- appendForwardSlash,
7
- astroCalledServerError,
8
- deserializeActionResult,
9
- getActionQueryString
10
- } from "./shared.js";
11
- export * from "virtual:astro:actions/runtime";
12
- const apiContextRoutesSymbol = Symbol.for("context.routes");
13
- const ENCODED_DOT = "%2E";
14
- function toActionProxy(actionCallback = {}, aggregatedPath = "") {
15
- return new Proxy(actionCallback, {
16
- get(target, objKey) {
17
- if (target.hasOwnProperty(objKey) || typeof objKey === "symbol") {
18
- return target[objKey];
19
- }
20
- const path = aggregatedPath + encodeURIComponent(objKey.toString()).replaceAll(".", ENCODED_DOT);
21
- function action(param) {
22
- return handleAction(param, path, this);
23
- }
24
- Object.assign(action, {
25
- queryString: getActionQueryString(path),
26
- toString: () => action.queryString,
27
- // redefine prototype methods as the object's own property, not the prototype's
28
- bind: action.bind,
29
- valueOf: () => action.valueOf,
30
- // Progressive enhancement info for React.
31
- $$FORM_ACTION: function() {
32
- const searchParams = new URLSearchParams(action.toString());
33
- return {
34
- method: "POST",
35
- // `name` creates a hidden input.
36
- // It's unused by Astro, but we can't turn this off.
37
- // At least use a name that won't conflict with a user's formData.
38
- name: "_astroAction",
39
- action: "?" + searchParams.toString()
40
- };
41
- },
42
- // Note: `orThrow` does not have progressive enhancement info.
43
- // If you want to throw exceptions,
44
- // you must handle those exceptions with client JS.
45
- async orThrow(param) {
46
- const { data, error } = await handleAction(param, path, this);
47
- if (error) throw error;
48
- return data;
49
- }
50
- });
51
- return toActionProxy(action, path + ".");
52
- }
53
- });
54
- }
55
- function _getActionPath(toString) {
56
- let path = `${import.meta.env.BASE_URL.replace(/\/$/, "")}/_actions/${new URLSearchParams(toString()).get(ACTION_QUERY_PARAMS.actionName)}`;
57
- if (shouldAppendTrailingSlash) {
58
- path = appendForwardSlash(path);
59
- }
60
- return path;
61
- }
62
- function getActionPath(action) {
63
- return _getActionPath(action.toString);
64
- }
65
- async function handleAction(param, path, context) {
66
- if (import.meta.env.SSR && context) {
67
- const pipeline = Reflect.get(context, apiContextRoutesSymbol);
68
- if (!pipeline) {
69
- throw astroCalledServerError();
70
- }
71
- const action = await pipeline.getAction(path);
72
- if (!action) throw new Error(`Action not found: ${path}`);
73
- return action.bind(context)(param);
74
- }
75
- const headers = new Headers();
76
- headers.set("Accept", "application/json");
77
- for (const [key, value] of Object.entries(internalFetchHeaders)) {
78
- headers.set(key, value);
79
- }
80
- let body = param;
81
- if (!(body instanceof FormData)) {
82
- try {
83
- body = JSON.stringify(param);
84
- } catch (e) {
85
- throw new ActionError({
86
- code: "BAD_REQUEST",
87
- message: `Failed to serialize request body to JSON. Full error: ${e.message}`
88
- });
89
- }
90
- if (body) {
91
- headers.set("Content-Type", "application/json");
92
- } else {
93
- headers.set("Content-Length", "0");
94
- }
95
- }
96
- const rawResult = await fetch(
97
- _getActionPath(() => getActionQueryString(path)),
98
- {
99
- method: "POST",
100
- body,
101
- headers
102
- }
103
- );
104
- if (rawResult.status === 204) {
105
- return deserializeActionResult({ type: "empty", status: 204 });
106
- }
107
- const bodyText = await rawResult.text();
108
- if (rawResult.ok) {
109
- return deserializeActionResult({
110
- type: "data",
111
- body: bodyText,
112
- status: 200,
113
- contentType: "application/json+devalue"
114
- });
115
- }
116
- return deserializeActionResult({
117
- type: "error",
118
- body: bodyText,
119
- status: rawResult.status,
120
- contentType: "application/json"
121
- });
122
- }
123
- const actions = toActionProxy();
124
- export {
125
- actions,
126
- getActionPath
127
- };
@@ -1,29 +0,0 @@
1
- import type * as vite from 'vite';
2
- import type { ImageMetadata } from '../../types.js';
3
- type FileEmitter = vite.Rollup.EmitFile;
4
- type ImageMetadataWithContents = ImageMetadata & {
5
- contents?: Buffer;
6
- };
7
- /**
8
- * Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
9
- *
10
- * @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
11
- * @param {boolean} _watchMode - **Deprecated**: Indicates if the method is operating in watch mode. This parameter will be removed or updated in the future.
12
- * @param {boolean} _experimentalSvgEnabled - **Deprecated**: A flag to enable experimental handling of SVG files. Embeds SVG file data if set to true.
13
- * @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
14
- * @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
15
- */
16
- export declare function emitESMImage(id: string | undefined,
17
- /** @deprecated */
18
- _watchMode: boolean,
19
- /** @deprecated */
20
- _experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
21
- /**
22
- * Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
23
- *
24
- * @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
25
- * @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
26
- * @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
27
- */
28
- export declare function emitImageMetadata(id: string | undefined, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
29
- export {};
@@ -1,32 +0,0 @@
1
- import { basename, dirname, extname } from "node:path";
2
- import { deterministicString } from "deterministic-object-hash";
3
- import { removeQueryString } from "../../core/path.js";
4
- import { shorthash } from "../../runtime/server/shorthash.js";
5
- import { isESMImportedImage } from "./imageKind.js";
6
- const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g;
7
- function propsToFilename(filePath, transform, hash) {
8
- let filename = decodeURIComponent(removeQueryString(filePath));
9
- const ext = extname(filename);
10
- if (filePath.startsWith("data:")) {
11
- filename = shorthash(filePath);
12
- } else {
13
- filename = basename(filename, ext).replace(INVALID_CHAR_REGEX, "_");
14
- }
15
- const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : "";
16
- let outputExt = transform.format ? `.${transform.format}` : ext;
17
- return `${prefixDirname}/${filename}_${hash}${outputExt}`;
18
- }
19
- function hashTransform(transform, imageService, propertiesToHash) {
20
- const hashFields = propertiesToHash.reduce(
21
- (acc, prop) => {
22
- acc[prop] = transform[prop];
23
- return acc;
24
- },
25
- { imageService }
26
- );
27
- return shorthash(deterministicString(hashFields));
28
- }
29
- export {
30
- hashTransform,
31
- propsToFilename
32
- };
@@ -1,17 +0,0 @@
1
- import type fsMod from 'node:fs';
2
- import type { Plugin } from 'vite';
3
- import type { Logger } from '../core/logger/core.js';
4
- import type { AstroSettings } from '../types/astro.js';
5
- /**
6
- * Listen for Astro content directory changes and generate types.
7
- *
8
- * This is a separate plugin for `getViteConfig` as the `attachContentServerListeners` API
9
- * needs to be called at different times in `astro dev` and `getViteConfig`. For `astro dev`,
10
- * it needs to be called after the Astro server is started (packages/astro/src/core/dev/dev.ts).
11
- * For `getViteConfig`, it needs to be called after the Vite server is started.
12
- */
13
- export declare function astroContentListenPlugin({ settings, logger, fs, }: {
14
- settings: AstroSettings;
15
- logger: Logger;
16
- fs: typeof fsMod;
17
- }): Plugin;
@@ -1,26 +0,0 @@
1
- import { attachContentServerListeners } from "../content/server-listeners.js";
2
- function astroContentListenPlugin({
3
- settings,
4
- logger,
5
- fs
6
- }) {
7
- let server;
8
- return {
9
- name: "astro:content-listen",
10
- apply: "serve",
11
- configureServer(_server) {
12
- server = _server;
13
- },
14
- async buildStart() {
15
- await attachContentServerListeners({
16
- fs,
17
- settings,
18
- logger,
19
- viteServer: server
20
- });
21
- }
22
- };
23
- }
24
- export {
25
- astroContentListenPlugin
26
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { applyPolyfills } from "../core/app/node.js";
2
- applyPolyfills();
@@ -1,9 +0,0 @@
1
- import type { GetModuleInfo } from 'rollup';
2
- import type { AstroSettings } from '../../types/astro.js';
3
- export declare function shortHashedName(settings: AstroSettings): (id: string, ctx: {
4
- getModuleInfo: GetModuleInfo;
5
- }) => string;
6
- export declare function createNameHash(baseId: string | undefined, hashIds: string[], settings: AstroSettings): string;
7
- export declare function createSlugger(settings: AstroSettings): (id: string, ctx: {
8
- getModuleInfo: GetModuleInfo;
9
- }) => string;
@@ -1,89 +0,0 @@
1
- import crypto from "node:crypto";
2
- import npath from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { viteID } from "../util.js";
5
- import { normalizePath } from "../viteUtils.js";
6
- import { getTopLevelPageModuleInfos } from "./graph.js";
7
- const confusingBaseNames = ["404", "500"];
8
- function shortHashedName(settings) {
9
- return function(id, ctx) {
10
- const parents = getTopLevelPageModuleInfos(id, ctx);
11
- return createNameHash(
12
- getFirstParentId(parents),
13
- parents.map((page) => page.id),
14
- settings
15
- );
16
- };
17
- }
18
- function createNameHash(baseId, hashIds, settings) {
19
- const baseName = baseId ? prettifyBaseName(npath.parse(baseId).name) : "index";
20
- const hash = crypto.createHash("sha256");
21
- const root = fileURLToPath(settings.config.root);
22
- for (const id of hashIds) {
23
- const relativePath = npath.relative(root, id);
24
- hash.update(normalizePath(relativePath), "utf-8");
25
- }
26
- const h = hash.digest("hex").slice(0, 8);
27
- const proposedName = baseName + "." + h;
28
- return proposedName;
29
- }
30
- function createSlugger(settings) {
31
- const pagesDir = viteID(new URL("./pages", settings.config.srcDir));
32
- const indexPage = viteID(new URL("./pages/index", settings.config.srcDir));
33
- const map = /* @__PURE__ */ new Map();
34
- const sep = "-";
35
- return function(id, ctx) {
36
- const parents = Array.from(getTopLevelPageModuleInfos(id, ctx));
37
- const allParentsKey = parents.map((page) => page.id).sort().join("-");
38
- const firstParentId = getFirstParentId(parents) || indexPage;
39
- let dir = firstParentId;
40
- let key = "";
41
- let i = 0;
42
- while (i < 2) {
43
- if (dir === pagesDir) {
44
- break;
45
- }
46
- const name2 = prettifyBaseName(npath.parse(npath.basename(dir)).name);
47
- key = key.length ? name2 + sep + key : name2;
48
- dir = npath.dirname(dir);
49
- i++;
50
- }
51
- let name = key;
52
- if (!map.has(key)) {
53
- map.set(key, /* @__PURE__ */ new Map([[allParentsKey, 0]]));
54
- } else {
55
- const inner = map.get(key);
56
- if (inner.has(allParentsKey)) {
57
- const num = inner.get(allParentsKey);
58
- if (num > 0) {
59
- name = name + sep + num;
60
- }
61
- } else {
62
- const num = inner.size;
63
- inner.set(allParentsKey, num);
64
- name = name + sep + num;
65
- }
66
- }
67
- return name;
68
- };
69
- }
70
- function getFirstParentId(parents) {
71
- for (const parent of parents) {
72
- const id = parent.id;
73
- const baseName = npath.parse(id).name;
74
- if (!confusingBaseNames.includes(baseName)) {
75
- return id;
76
- }
77
- }
78
- return parents[0]?.id;
79
- }
80
- const charsToReplaceRe = /[.[\]]/g;
81
- const underscoresRe = /_+/g;
82
- function prettifyBaseName(str) {
83
- return str.replace(charsToReplaceRe, "_").replace(underscoresRe, "_");
84
- }
85
- export {
86
- createNameHash,
87
- createSlugger,
88
- shortHashedName
89
- };
@@ -1,43 +0,0 @@
1
- import type { Rollup, Plugin as VitePlugin } from 'vite';
2
- import type { BuildInternals } from './internal.js';
3
- import type { StaticBuildOptions, ViteBuildReturn } from './types.js';
4
- type RollupOutputArray = Extract<ViteBuildReturn, Array<any>>;
5
- type OutputChunkorAsset = RollupOutputArray[number]['output'][number];
6
- type OutputChunk = Extract<OutputChunkorAsset, {
7
- type: 'chunk';
8
- }>;
9
- export type BuildTarget = 'server' | 'client';
10
- type MutateChunk = (chunk: OutputChunk, targets: BuildTarget[], newCode: string) => void;
11
- interface BuildBeforeHookResult {
12
- enforce?: 'after-user-plugins';
13
- vitePlugin: VitePlugin | VitePlugin[] | undefined;
14
- }
15
- export type AstroBuildPlugin = {
16
- targets: BuildTarget[];
17
- hooks?: {
18
- 'build:before'?: (opts: {
19
- target: BuildTarget;
20
- input: Set<string>;
21
- }) => BuildBeforeHookResult | Promise<BuildBeforeHookResult>;
22
- 'build:post'?: (opts: {
23
- ssrOutputs: RollupOutputArray;
24
- clientOutputs: RollupOutputArray;
25
- mutate: MutateChunk;
26
- }) => void | Promise<void>;
27
- };
28
- };
29
- export declare function createPluginContainer(options: StaticBuildOptions, internals: BuildInternals): {
30
- options: StaticBuildOptions;
31
- internals: BuildInternals;
32
- register(plugin: AstroBuildPlugin): void;
33
- runBeforeHook(target: BuildTarget, input: Set<string>): Promise<{
34
- vitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
35
- lastVitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
36
- }>;
37
- runPostHook(ssrOutputs: Rollup.RollupOutput[], clientOutputs: Rollup.RollupOutput[]): Promise<Map<string, {
38
- targets: BuildTarget[];
39
- code: string;
40
- }>>;
41
- };
42
- export type AstroBuildPluginContainer = ReturnType<typeof createPluginContainer>;
43
- export {};
@@ -1,61 +0,0 @@
1
- function createPluginContainer(options, internals) {
2
- const plugins = /* @__PURE__ */ new Map();
3
- const allPlugins = /* @__PURE__ */ new Set();
4
- for (const target of ["client", "server"]) {
5
- plugins.set(target, []);
6
- }
7
- return {
8
- options,
9
- internals,
10
- register(plugin) {
11
- allPlugins.add(plugin);
12
- for (const target of plugin.targets) {
13
- const targetPlugins = plugins.get(target) ?? [];
14
- targetPlugins.push(plugin);
15
- plugins.set(target, targetPlugins);
16
- }
17
- },
18
- // Hooks
19
- async runBeforeHook(target, input) {
20
- let targetPlugins = plugins.get(target) ?? [];
21
- let vitePlugins = [];
22
- let lastVitePlugins = [];
23
- for (const plugin of targetPlugins) {
24
- if (plugin.hooks?.["build:before"]) {
25
- let result = await plugin.hooks["build:before"]({ target, input });
26
- if (result.vitePlugin) {
27
- vitePlugins.push(result.vitePlugin);
28
- }
29
- }
30
- }
31
- return {
32
- vitePlugins,
33
- lastVitePlugins
34
- };
35
- },
36
- async runPostHook(ssrOutputs, clientOutputs) {
37
- const mutations = /* @__PURE__ */ new Map();
38
- const mutate = (chunk, targets, newCode) => {
39
- chunk.code = newCode;
40
- mutations.set(chunk.fileName, {
41
- targets,
42
- code: newCode
43
- });
44
- };
45
- for (const plugin of allPlugins) {
46
- const postHook = plugin.hooks?.["build:post"];
47
- if (postHook) {
48
- await postHook({
49
- ssrOutputs,
50
- clientOutputs,
51
- mutate
52
- });
53
- }
54
- }
55
- return mutations;
56
- }
57
- };
58
- }
59
- export {
60
- createPluginContainer
61
- };
@@ -1,4 +0,0 @@
1
- import type { BuildInternals } from '../internal.js';
2
- import type { AstroBuildPlugin } from '../plugin.js';
3
- import type { StaticBuildOptions } from '../types.js';
4
- export declare function pluginActions(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
@@ -1,16 +0,0 @@
1
- import { vitePluginActionsBuild } from "../../../actions/vite-plugin-actions.js";
2
- function pluginActions(opts, internals) {
3
- return {
4
- targets: ["server"],
5
- hooks: {
6
- "build:before": () => {
7
- return {
8
- vitePlugin: vitePluginActionsBuild(opts, internals)
9
- };
10
- }
11
- }
12
- };
13
- }
14
- export {
15
- pluginActions
16
- };
@@ -1,2 +0,0 @@
1
- import type { AstroBuildPlugin } from '../plugin.js';
2
- export declare function pluginChunks(): AstroBuildPlugin;
@@ -1,33 +0,0 @@
1
- import { extendManualChunks } from "./util.js";
2
- function vitePluginChunks() {
3
- return {
4
- name: "astro:chunks",
5
- outputOptions(outputOptions) {
6
- extendManualChunks(outputOptions, {
7
- after(id) {
8
- if (id.includes("astro/dist/runtime/server/")) {
9
- return "astro/server";
10
- }
11
- if (id.includes("astro/dist/runtime")) {
12
- return "astro";
13
- }
14
- }
15
- });
16
- }
17
- };
18
- }
19
- function pluginChunks() {
20
- return {
21
- targets: ["server"],
22
- hooks: {
23
- "build:before": () => {
24
- return {
25
- vitePlugin: vitePluginChunks()
26
- };
27
- }
28
- }
29
- };
30
- }
31
- export {
32
- pluginChunks
33
- };
@@ -1,6 +0,0 @@
1
- import type { BuildInternals } from '../internal.js';
2
- import type { AstroBuildPlugin } from '../plugin.js';
3
- import type { StaticBuildOptions } from '../types.js';
4
- export declare const ASTRO_PAGE_MODULE_ID = "@astro-page:";
5
- export declare const ASTRO_PAGE_RESOLVED_MODULE_ID: string;
6
- export declare function pluginPages(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
@@ -1,66 +0,0 @@
1
- import { routeIsRedirect } from "../../redirects/index.js";
2
- import { addRollupInput } from "../add-rollup-input.js";
3
- import { RENDERERS_MODULE_ID } from "./plugin-renderers.js";
4
- import { getPagesFromVirtualModulePageName, getVirtualModulePageName } from "./util.js";
5
- const ASTRO_PAGE_MODULE_ID = "@astro-page:";
6
- const ASTRO_PAGE_RESOLVED_MODULE_ID = "\0" + ASTRO_PAGE_MODULE_ID;
7
- function vitePluginPages(opts, internals) {
8
- return {
9
- name: "@astro/plugin-build-pages",
10
- options(options) {
11
- if (opts.settings.buildOutput === "static") {
12
- const inputs = /* @__PURE__ */ new Set();
13
- for (const pageData of Object.values(opts.allPages)) {
14
- if (routeIsRedirect(pageData.route)) {
15
- continue;
16
- }
17
- inputs.add(getVirtualModulePageName(ASTRO_PAGE_MODULE_ID, pageData.component));
18
- }
19
- return addRollupInput(options, Array.from(inputs));
20
- }
21
- },
22
- resolveId(id) {
23
- if (id.startsWith(ASTRO_PAGE_MODULE_ID)) {
24
- return "\0" + id;
25
- }
26
- },
27
- async load(id) {
28
- if (id.startsWith(ASTRO_PAGE_RESOLVED_MODULE_ID)) {
29
- const imports = [];
30
- const exports = [];
31
- const pageDatas = getPagesFromVirtualModulePageName(
32
- internals,
33
- ASTRO_PAGE_RESOLVED_MODULE_ID,
34
- id
35
- );
36
- for (const pageData of pageDatas) {
37
- const resolvedPage = await this.resolve(pageData.moduleSpecifier);
38
- if (resolvedPage) {
39
- imports.push(`import * as _page from ${JSON.stringify(pageData.moduleSpecifier)};`);
40
- exports.push(`export const page = () => _page`);
41
- imports.push(`import { renderers } from "${RENDERERS_MODULE_ID}";`);
42
- exports.push(`export { renderers };`);
43
- return { code: `${imports.join("\n")}${exports.join("\n")}` };
44
- }
45
- }
46
- }
47
- }
48
- };
49
- }
50
- function pluginPages(opts, internals) {
51
- return {
52
- targets: ["server"],
53
- hooks: {
54
- "build:before": () => {
55
- return {
56
- vitePlugin: vitePluginPages(opts, internals)
57
- };
58
- }
59
- }
60
- };
61
- }
62
- export {
63
- ASTRO_PAGE_MODULE_ID,
64
- ASTRO_PAGE_RESOLVED_MODULE_ID,
65
- pluginPages
66
- };
@@ -1,5 +0,0 @@
1
- import type { AstroBuildPlugin } from '../plugin.js';
2
- import type { StaticBuildOptions } from '../types.js';
3
- export declare const RENDERERS_MODULE_ID = "@astro-renderers";
4
- export declare const RESOLVED_RENDERERS_MODULE_ID = "\0@astro-renderers";
5
- export declare function pluginRenderers(opts: StaticBuildOptions): AstroBuildPlugin;
@@ -1,54 +0,0 @@
1
- import { addRollupInput } from "../add-rollup-input.js";
2
- const RENDERERS_MODULE_ID = "@astro-renderers";
3
- const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`;
4
- function vitePluginRenderers(opts) {
5
- return {
6
- name: "@astro/plugin-renderers",
7
- options(options) {
8
- return addRollupInput(options, [RENDERERS_MODULE_ID]);
9
- },
10
- resolveId(id) {
11
- if (id === RENDERERS_MODULE_ID) {
12
- return RESOLVED_RENDERERS_MODULE_ID;
13
- }
14
- },
15
- async load(id) {
16
- if (id === RESOLVED_RENDERERS_MODULE_ID) {
17
- if (opts.settings.renderers.length > 0) {
18
- const imports = [];
19
- const exports = [];
20
- let i = 0;
21
- let rendererItems = "";
22
- for (const renderer of opts.settings.renderers) {
23
- const variable = `_renderer${i}`;
24
- imports.push(`import ${variable} from ${JSON.stringify(renderer.serverEntrypoint)};`);
25
- rendererItems += `Object.assign(${JSON.stringify(renderer)}, { ssr: ${variable} }),`;
26
- i++;
27
- }
28
- exports.push(`export const renderers = [${rendererItems}];`);
29
- return { code: `${imports.join("\n")}
30
- ${exports.join("\n")}` };
31
- } else {
32
- return { code: `export const renderers = [];` };
33
- }
34
- }
35
- }
36
- };
37
- }
38
- function pluginRenderers(opts) {
39
- return {
40
- targets: ["server"],
41
- hooks: {
42
- "build:before": () => {
43
- return {
44
- vitePlugin: vitePluginRenderers(opts)
45
- };
46
- }
47
- }
48
- };
49
- }
50
- export {
51
- RENDERERS_MODULE_ID,
52
- RESOLVED_RENDERERS_MODULE_ID,
53
- pluginRenderers
54
- };
@@ -1,7 +0,0 @@
1
- import type { ModuleLoader } from '../module-loader/index.js';
2
- /**
3
- * It accepts a module loader and the astro settings, and it attempts to load the middlewares defined in the configuration.
4
- *
5
- * If not middlewares were not set, the function returns an empty array.
6
- */
7
- export declare function loadMiddleware(moduleLoader: ModuleLoader): Promise<Record<string, any>>;
@@ -1,14 +0,0 @@
1
- import { MiddlewareCantBeLoaded } from "../errors/errors-data.js";
2
- import { AstroError } from "../errors/index.js";
3
- import { MIDDLEWARE_MODULE_ID } from "./vite-plugin.js";
4
- async function loadMiddleware(moduleLoader) {
5
- try {
6
- return await moduleLoader.import(MIDDLEWARE_MODULE_ID);
7
- } catch (error) {
8
- const astroError = new AstroError(MiddlewareCantBeLoaded, { cause: error });
9
- throw astroError;
10
- }
11
- }
12
- export {
13
- loadMiddleware
14
- };