cloudcommerce 0.4.0 → 0.5.0

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 (128) hide show
  1. package/.github/renovate.json +1 -1
  2. package/CHANGELOG.md +42 -0
  3. package/action.yml +1 -2
  4. package/package.json +10 -10
  5. package/packages/api/package.json +1 -1
  6. package/packages/apps/correios/package.json +2 -2
  7. package/packages/apps/custom-payment/package.json +1 -1
  8. package/packages/apps/custom-shipping/package.json +1 -1
  9. package/packages/apps/datafrete/package.json +3 -3
  10. package/packages/apps/discounts/package.json +1 -1
  11. package/packages/apps/emails/package.json +1 -1
  12. package/packages/apps/fb-conversions/package.json +2 -2
  13. package/packages/apps/frenet/package.json +3 -3
  14. package/packages/apps/galaxpay/package.json +3 -3
  15. package/packages/apps/google-analytics/package.json +3 -3
  16. package/packages/apps/infinitepay/lib/ip-create-transaction.js +1 -1
  17. package/packages/apps/infinitepay/lib/ip-create-transaction.js.map +1 -1
  18. package/packages/apps/infinitepay/package.json +3 -3
  19. package/packages/apps/infinitepay/src/ip-create-transaction.ts +1 -1
  20. package/packages/apps/jadlog/package.json +2 -2
  21. package/packages/apps/loyalty-points/package.json +1 -1
  22. package/packages/apps/melhor-envio/package.json +3 -3
  23. package/packages/apps/mercadopago/package.json +3 -3
  24. package/packages/apps/pagarme/package.json +4 -4
  25. package/packages/apps/paghiper/package.json +3 -3
  26. package/packages/apps/pix/package.json +3 -3
  27. package/packages/apps/tiny-erp/package.json +3 -3
  28. package/packages/apps/webhooks/CHANGELOG.md +1 -0
  29. package/packages/apps/webhooks/README.md +1 -0
  30. package/packages/apps/webhooks/lib/app-webhooks.js +9 -0
  31. package/packages/apps/webhooks/lib/app-webhooks.js.map +1 -0
  32. package/packages/apps/webhooks/lib/events-to-webhooks-app.js +127 -0
  33. package/packages/apps/webhooks/lib/events-to-webhooks-app.js.map +1 -0
  34. package/packages/apps/webhooks/lib/index.js +2 -0
  35. package/packages/apps/webhooks/lib/index.js.map +1 -0
  36. package/packages/apps/webhooks/package.json +32 -0
  37. package/packages/apps/webhooks/src/app-webhooks.ts +14 -0
  38. package/packages/apps/webhooks/src/events-to-webhooks-app.ts +178 -0
  39. package/packages/apps/webhooks/src/index.ts +1 -0
  40. package/packages/apps/webhooks/tsconfig.json +3 -0
  41. package/packages/cli/lib/setup-gcloud.js +120 -20
  42. package/packages/cli/package.json +1 -1
  43. package/packages/cli/src/cli.ts +1 -1
  44. package/packages/cli/src/setup-gcloud.ts +146 -21
  45. package/packages/config/package.json +1 -1
  46. package/packages/emails/package.json +2 -2
  47. package/packages/emails/tests/assets/order.json +1 -1
  48. package/packages/events/lib/firebase.js +2 -0
  49. package/packages/events/lib/firebase.js.map +1 -1
  50. package/packages/events/package.json +3 -2
  51. package/packages/events/src/firebase.ts +2 -0
  52. package/packages/firebase/lib/config.d.ts +4 -0
  53. package/packages/firebase/lib/config.js +10 -1
  54. package/packages/firebase/lib/config.js.map +1 -1
  55. package/packages/firebase/lib/handlers/check-store-events.js +13 -4
  56. package/packages/firebase/lib/handlers/check-store-events.js.map +1 -1
  57. package/packages/firebase/package.json +2 -2
  58. package/packages/firebase/src/config.ts +10 -7
  59. package/packages/firebase/src/handlers/check-store-events.ts +14 -4
  60. package/packages/i18n/package.json +1 -1
  61. package/packages/modules/lib/firebase/checkout.js +7 -4
  62. package/packages/modules/lib/firebase/checkout.js.map +1 -1
  63. package/packages/modules/package.json +3 -3
  64. package/packages/modules/schemas/@checkout.cjs +0 -5
  65. package/packages/modules/schemas/create_transaction.cjs +6 -1
  66. package/packages/modules/src/firebase/checkout.ts +7 -4
  67. package/packages/passport/package.json +2 -2
  68. package/packages/ssr/package.json +7 -7
  69. package/packages/storefront/config/storefront.cms.cjs +31 -5
  70. package/packages/storefront/config/storefront.cms.mjs +31 -5
  71. package/packages/storefront/dist/client/_astro/PitchBar.df2672ff.js +1 -0
  72. package/packages/storefront/dist/client/_astro/Prices.99fa99bf.js +1 -0
  73. package/packages/storefront/dist/client/_astro/ProductCard.a322c854.js +1 -0
  74. package/packages/storefront/dist/client/_astro/ShopHeader.abd6dec6.js +1 -0
  75. package/packages/storefront/dist/client/_astro/_...slug_.648728f3.css +1 -0
  76. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.e6f0b936.js +1 -0
  77. package/packages/storefront/dist/client/_astro/client.e6b58b55.js +1 -0
  78. package/packages/storefront/dist/client/_astro/index.5dd878ac.js +1 -0
  79. package/packages/storefront/dist/client/_astro/modules-info.e8935203.js +1 -0
  80. package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.e8b26f2c.js +1 -0
  81. package/packages/storefront/dist/client/fallback/index.html +12 -11
  82. package/packages/storefront/dist/client/sw.js +1 -1
  83. package/packages/storefront/dist/server/chunks/{astro.89bd9221.mjs → astro.7d9d5f6e.mjs} +957 -850
  84. package/packages/storefront/dist/server/chunks/pages/{all.6379e666.mjs → all.ba8f4b85.mjs} +771 -627
  85. package/packages/storefront/dist/server/chunks/{prerender.a1ec39e0.mjs → prerender.8cd4ad42.mjs} +0 -0
  86. package/packages/storefront/dist/server/entry.mjs +113 -53
  87. package/packages/storefront/package.json +16 -16
  88. package/packages/storefront/src/lib/assets/base.css +6 -0
  89. package/packages/storefront/src/lib/cms.d.ts +25 -0
  90. package/packages/storefront/src/lib/components/Drawer.vue +10 -1
  91. package/packages/storefront/src/lib/composables/use-shop-header.ts +79 -0
  92. package/packages/storefront/src/lib/layouts/Base.astro +4 -5
  93. package/packages/storefront/src/lib/layouts/BaseBody.astro +3 -2
  94. package/packages/storefront/src/lib/layouts/BaseHead.astro +7 -7
  95. package/packages/storefront/src/lib/layouts/PagesHeader.astro +5 -23
  96. package/packages/storefront/src/lib/ssr-context.ts +3 -4
  97. package/packages/storefront/src/lib/state/modules-info.ts +1 -1
  98. package/packages/storefront/tailwind.config.cjs +0 -4
  99. package/packages/types/index.ts +8 -0
  100. package/packages/types/modules/@checkout:params.d.ts +1 -5
  101. package/packages/types/modules/apply_discount:params.d.ts +1 -1
  102. package/packages/types/modules/apply_discount:response.d.ts +1 -1
  103. package/packages/types/modules/calculate_shipping:params.d.ts +1 -1
  104. package/packages/types/modules/calculate_shipping:response.d.ts +1 -1
  105. package/packages/types/modules/create_transaction:params.d.ts +6 -2
  106. package/packages/types/modules/create_transaction:response.d.ts +1 -1
  107. package/packages/types/modules/list_payments:params.d.ts +1 -1
  108. package/packages/types/modules/list_payments:response.d.ts +1 -1
  109. package/packages/types/package.json +1 -1
  110. package/pnpm-workspace.yaml +3 -3
  111. package/packages/storefront/dist/client/_astro/PitchBar.103168e6.js +0 -1
  112. package/packages/storefront/dist/client/_astro/Prices.b75d44d6.js +0 -1
  113. package/packages/storefront/dist/client/_astro/Prices.vue_vue_type_script_setup_true_lang.054033ef.js +0 -1
  114. package/packages/storefront/dist/client/_astro/ProductCard.9138ec25.js +0 -1
  115. package/packages/storefront/dist/client/_astro/ShopHeader.65213f83.js +0 -1
  116. package/packages/storefront/dist/client/_astro/_...slug_.39c46f54.css +0 -1
  117. package/packages/storefront/dist/client/_astro/client.eba0daa7.js +0 -1
  118. package/packages/storefront/dist/client/_astro/index.7577af70.js +0 -1
  119. package/packages/storefront/dist/client/_astro/modules-info.0c999f60.js +0 -1
  120. package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.4da3640b.js +0 -1
  121. package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.0869e112.js +0 -1
  122. package/packages/storefront/src/lib/components/ShopHeader.vue +0 -110
  123. package/packages/storefront/src/lib/components/ShopSidenav.vue +0 -26
  124. package/packages/storefront/src/lib/types/cms-code.d.ts +0 -5
  125. package/packages/storefront/src/lib/types/cms-contacts.d.ts +0 -5
  126. package/packages/storefront/src/lib/types/cms-header.d.ts +0 -5
  127. package/packages/storefront/src/lib/types/cms-settings.d.ts +0 -8
  128. package/packages/storefront/src/lib/types/cms-social.d.ts +0 -5
@@ -52,9 +52,11 @@ function deserializeManifest(serializedManifest) {
52
52
  route.routeData = deserializeRouteData(serializedRoute.routeData);
53
53
  }
54
54
  const assets = new Set(serializedManifest.assets);
55
+ const propagation = new Map(serializedManifest.propagation);
55
56
  return {
56
57
  ...serializedManifest,
57
58
  assets,
59
+ propagation,
58
60
  routes
59
61
  };
60
62
  }
@@ -235,748 +237,924 @@ function* getSetCookiesFromResponse(response) {
235
237
  }
236
238
  }
237
239
 
238
- function baseCreateComponent(cb, moduleId) {
239
- cb.isAstroComponentFactory = true;
240
- cb.moduleId = moduleId;
241
- return cb;
242
- }
243
- function createComponentWithOptions(opts) {
244
- const cb = baseCreateComponent(opts.factory, opts.moduleId);
245
- cb.propagation = opts.propagation;
246
- return cb;
247
- }
248
- function createComponent(arg1, moduleId) {
249
- if (typeof arg1 === "function") {
250
- return baseCreateComponent(arg1, moduleId);
251
- } else {
252
- return createComponentWithOptions(arg1);
253
- }
254
- }
255
-
256
- const ASTRO_VERSION = "2.0.2";
257
-
258
- function createAstroGlobFn() {
259
- const globHandler = (importMetaGlobResult, globValue) => {
260
- let allEntries = [...Object.values(importMetaGlobResult)];
261
- if (allEntries.length === 0) {
262
- throw new Error(`Astro.glob(${JSON.stringify(globValue())}) - no matches found.`);
263
- }
264
- return Promise.all(allEntries.map((fn) => fn()));
265
- };
266
- return globHandler;
267
- }
268
- function createAstro(site) {
269
- return {
270
- site: site ? new URL(site) : void 0,
271
- generator: `Astro v${ASTRO_VERSION}`,
272
- glob: createAstroGlobFn()
273
- };
274
- }
275
-
276
- function getHandlerFromModule(mod, method) {
277
- if (mod[method]) {
278
- return mod[method];
279
- }
280
- if (method === "delete" && mod["del"]) {
281
- return mod["del"];
282
- }
283
- if (mod["all"]) {
284
- return mod["all"];
285
- }
286
- return void 0;
287
- }
288
- async function renderEndpoint(mod, context, ssr) {
289
- var _a;
290
- const { request, params } = context;
291
- const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
292
- const handler = getHandlerFromModule(mod, chosenMethod);
293
- if (!ssr && ssr === false && chosenMethod && chosenMethod !== "get") {
294
- console.warn(`
295
- ${chosenMethod} requests are not available when building a static site. Update your config to output: 'server' to handle ${chosenMethod} requests.`);
296
- }
297
- if (!handler || typeof handler !== "function") {
298
- let response = new Response(null, {
299
- status: 404,
300
- headers: {
301
- "X-Astro-Response": "Not-Found"
302
- }
303
- });
304
- return response;
305
- }
306
- if (handler.length > 1) {
307
- console.warn(`
308
- API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of:
309
-
310
- export function get({ params, request }) {
311
- //...
312
- }
313
-
314
- Update your code to remove this warning.`);
315
- }
316
- const proxy = new Proxy(context, {
317
- get(target, prop) {
318
- if (prop in target) {
319
- return Reflect.get(target, prop);
320
- } else if (prop in params) {
321
- console.warn(`
322
- API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of:
323
-
324
- export function get({ params }) {
325
- // ...
326
- }
240
+ const defineErrors = (errs) => errs;
241
+ const AstroErrorData = defineErrors({
242
+ UnknownCompilerError: {
243
+ title: "Unknown compiler error.",
244
+ code: 1e3,
245
+ hint: "This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler."
246
+ },
247
+ StaticRedirectNotAvailable: {
248
+ title: "`Astro.redirect` is not available in static mode.",
249
+ code: 3001,
250
+ message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
251
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
252
+ },
253
+ ClientAddressNotAvailable: {
254
+ title: "`Astro.clientAddress` is not available in current adapter.",
255
+ code: 3002,
256
+ message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
257
+ },
258
+ StaticClientAddressNotAvailable: {
259
+ title: "`Astro.clientAddress` is not available in static mode.",
260
+ code: 3003,
261
+ message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
262
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
263
+ },
264
+ NoMatchingStaticPathFound: {
265
+ title: "No static path found for requested path.",
266
+ code: 3004,
267
+ message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
268
+ hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
269
+ },
270
+ OnlyResponseCanBeReturned: {
271
+ title: "Invalid type returned by Astro page.",
272
+ code: 3005,
273
+ message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
274
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
275
+ },
276
+ MissingMediaQueryDirective: {
277
+ title: "Missing value for `client:media` directive.",
278
+ code: 3006,
279
+ message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
280
+ },
281
+ NoMatchingRenderer: {
282
+ title: "No matching renderer found.",
283
+ code: 3007,
284
+ message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
327
285
 
328
- Update your code to remove this warning.`);
329
- return Reflect.get(params, prop);
330
- } else {
331
- return void 0;
332
- }
333
- }
334
- });
335
- return handler.call(mod, proxy, request);
336
- }
286
+ ${validRenderersCount > 0 ? `There ${plural ? "are." : "is."} ${validRenderersCount} renderer${plural ? "s." : ""} configured in your \`astro.config.mjs\` file,
287
+ but ${plural ? "none were." : "it was not."} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.`}`}`,
288
+ hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
337
289
 
338
- function serializeListValue(value) {
339
- const hash = {};
340
- push(value);
341
- return Object.keys(hash).join(" ");
342
- function push(item) {
343
- if (item && typeof item.forEach === "function")
344
- item.forEach(push);
345
- else if (item === Object(item))
346
- Object.keys(item).forEach((name) => {
347
- if (item[name])
348
- push(name);
349
- });
350
- else {
351
- item = item === false || item == null ? "" : String(item).trim();
352
- if (item) {
353
- item.split(/\s+/).forEach((name) => {
354
- hash[name] = true;
355
- });
356
- }
357
- }
358
- }
359
- }
360
- function isPromise(value) {
361
- return !!value && typeof value === "object" && typeof value.then === "function";
362
- }
363
- async function* streamAsyncIterator(stream) {
364
- const reader = stream.getReader();
365
- try {
366
- while (true) {
367
- const { done, value } = await reader.read();
368
- if (done)
369
- return;
370
- yield value;
371
- }
372
- } finally {
373
- reader.releaseLock();
374
- }
375
- }
290
+ See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`
291
+ },
292
+ NoClientEntrypoint: {
293
+ title: "No client entrypoint specified in renderer.",
294
+ code: 3008,
295
+ message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
296
+ hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
297
+ },
298
+ NoClientOnlyHint: {
299
+ title: "Missing hint on client:only directive.",
300
+ code: 3009,
301
+ message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
302
+ hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
303
+ },
304
+ InvalidGetStaticPathParam: {
305
+ title: "Invalid value returned by a `getStaticPaths` path.",
306
+ code: 3010,
307
+ message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
308
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
309
+ },
310
+ InvalidGetStaticPathsReturn: {
311
+ title: "Invalid value returned by getStaticPaths.",
312
+ code: 3011,
313
+ message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
314
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
315
+ },
316
+ GetStaticPathsRemovedRSSHelper: {
317
+ title: "getStaticPaths RSS helper is not available anymore.",
318
+ code: 3012,
319
+ message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
320
+ hint: "See https://docs.astro.build/en/guides/rss/ for more information."
321
+ },
322
+ GetStaticPathsExpectedParams: {
323
+ title: "Missing params property on `getStaticPaths` route.",
324
+ code: 3013,
325
+ message: "Missing or empty required `params` property on `getStaticPaths` route.",
326
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
327
+ },
328
+ GetStaticPathsInvalidRouteParam: {
329
+ title: "Invalid value for `getStaticPaths` route parameter.",
330
+ code: 3014,
331
+ message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
332
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
333
+ },
334
+ GetStaticPathsRequired: {
335
+ title: "`getStaticPaths()` function required for dynamic routes.",
336
+ code: 3015,
337
+ message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
338
+ hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
376
339
 
377
- const escapeHTML = escape;
378
- class HTMLBytes extends Uint8Array {
379
- }
380
- Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
381
- get() {
382
- return "HTMLBytes";
383
- }
384
- });
385
- class HTMLString extends String {
386
- get [Symbol.toStringTag]() {
387
- return "HTMLString";
388
- }
389
- }
390
- const markHTMLString = (value) => {
391
- if (value instanceof HTMLString) {
392
- return value;
393
- }
394
- if (typeof value === "string") {
395
- return new HTMLString(value);
396
- }
397
- return value;
398
- };
399
- function isHTMLString(value) {
400
- return Object.prototype.toString.call(value) === "[object HTMLString]";
401
- }
402
- function markHTMLBytes(bytes) {
403
- return new HTMLBytes(bytes);
404
- }
405
- function hasGetReader(obj) {
406
- return typeof obj.getReader === "function";
340
+ Alternatively, set \`output: "server"\` in your Astro config file to switch to a non-static server build. This error can also occur if using \`export const prerender = true;\`.
341
+ See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
342
+ },
343
+ ReservedSlotName: {
344
+ title: "Invalid slot name.",
345
+ code: 3016,
346
+ message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
347
+ },
348
+ NoAdapterInstalled: {
349
+ title: "Cannot use Server-side Rendering without an adapter.",
350
+ code: 3017,
351
+ message: `Cannot use \`output: 'server'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
352
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
353
+ },
354
+ NoMatchingImport: {
355
+ title: "No import found for component.",
356
+ code: 3018,
357
+ message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
358
+ hint: "Please make sure the component is properly imported."
359
+ },
360
+ InvalidPrerenderExport: {
361
+ title: "Invalid prerender export.",
362
+ code: 3019,
363
+ message: (prefix, suffix) => {
364
+ let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
365
+ if (prefix !== "const")
366
+ msg += `
367
+ Expected \`const\` declaration but got \`${prefix}\`.`;
368
+ if (suffix !== "true")
369
+ msg += `
370
+ Expected \`true\` value but got \`${suffix}\`.`;
371
+ return msg;
372
+ },
373
+ hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."
374
+ },
375
+ InvalidComponentArgs: {
376
+ title: "Invalid component arguments.",
377
+ code: 3020,
378
+ message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
379
+ hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
380
+ },
381
+ PageNumberParamNotFound: {
382
+ title: "Page number param not found.",
383
+ code: 3021,
384
+ message: (paramName) => `[paginate()] page number param \`${paramName}\` not found in your filepath.`,
385
+ hint: "Rename your file to `[page].astro` or `[...page].astro`."
386
+ },
387
+ UnknownViteError: {
388
+ title: "Unknown Vite Error.",
389
+ code: 4e3
390
+ },
391
+ FailedToLoadModuleSSR: {
392
+ title: "Could not import file.",
393
+ code: 4001,
394
+ message: (importName) => `Could not import \`${importName}\`.`,
395
+ hint: "This is often caused by a typo in the import path. Please make sure the file exists."
396
+ },
397
+ InvalidGlob: {
398
+ title: "Invalid glob pattern.",
399
+ code: 4002,
400
+ message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
401
+ hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
402
+ },
403
+ UnknownCSSError: {
404
+ title: "Unknown CSS Error.",
405
+ code: 5e3
406
+ },
407
+ CSSSyntaxError: {
408
+ title: "CSS Syntax Error.",
409
+ code: 5001
410
+ },
411
+ UnknownMarkdownError: {
412
+ title: "Unknown Markdown Error.",
413
+ code: 6e3
414
+ },
415
+ MarkdownFrontmatterParseError: {
416
+ title: "Failed to parse Markdown frontmatter.",
417
+ code: 6001
418
+ },
419
+ InvalidFrontmatterInjectionError: {
420
+ title: "Invalid frontmatter injection.",
421
+ code: 6003,
422
+ message: 'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
423
+ hint: "See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."
424
+ },
425
+ MdxIntegrationMissingError: {
426
+ title: "MDX integration missing.",
427
+ code: 6004,
428
+ message: (file) => `Unable to render ${file}. Ensure that the \`@astrojs/mdx\` integration is installed.`,
429
+ hint: "See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"
430
+ },
431
+ UnknownConfigError: {
432
+ title: "Unknown configuration error.",
433
+ code: 7e3
434
+ },
435
+ ConfigNotFound: {
436
+ title: "Specified configuration file not found.",
437
+ code: 7001,
438
+ message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
439
+ },
440
+ ConfigLegacyKey: {
441
+ title: "Legacy configuration detected.",
442
+ code: 7002,
443
+ message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
444
+ hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
445
+ },
446
+ UnknownCLIError: {
447
+ title: "Unknown CLI Error.",
448
+ code: 8e3
449
+ },
450
+ GenerateContentTypesError: {
451
+ title: "Failed to generate content types.",
452
+ code: 8001,
453
+ message: "`astro sync` command failed to generate content collection types.",
454
+ hint: "Check your `src/content/config.*` file for typos."
455
+ },
456
+ UnknownContentCollectionError: {
457
+ title: "Unknown Content Collection Error.",
458
+ code: 9e3
459
+ },
460
+ InvalidContentEntryFrontmatterError: {
461
+ title: "Content entry frontmatter does not match schema.",
462
+ code: 9001,
463
+ message: (collection, entryId, error) => {
464
+ return [
465
+ `${String(collection)} \u2192 ${String(entryId)} frontmatter does not match collection schema.`,
466
+ ...error.errors.map((zodError) => zodError.message)
467
+ ].join("\n");
468
+ },
469
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."
470
+ },
471
+ InvalidContentEntrySlugError: {
472
+ title: "Invalid content entry slug.",
473
+ code: 9002,
474
+ message: (collection, entryId) => {
475
+ return `${String(collection)} \u2192 ${String(
476
+ entryId
477
+ )} has an invalid slug. \`slug\` must be a string.`;
478
+ },
479
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
480
+ },
481
+ ContentSchemaContainsSlugError: {
482
+ title: "Content Schema should not contain `slug`.",
483
+ code: 9003,
484
+ message: (collection) => {
485
+ return `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collection} collection schema.`;
486
+ },
487
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
488
+ },
489
+ UnknownError: {
490
+ title: "Unknown Error.",
491
+ code: 99999
492
+ }
493
+ });
494
+
495
+ function normalizeLF(code) {
496
+ return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
407
497
  }
408
- async function* unescapeChunksAsync(iterable) {
409
- if (hasGetReader(iterable)) {
410
- for await (const chunk of streamAsyncIterator(iterable)) {
411
- yield unescapeHTML(chunk);
412
- }
413
- } else {
414
- for await (const chunk of iterable) {
415
- yield unescapeHTML(chunk);
416
- }
498
+ function getErrorDataByCode(code) {
499
+ const entry = Object.entries(AstroErrorData).find((data) => data[1].code === code);
500
+ if (entry) {
501
+ return {
502
+ name: entry[0],
503
+ data: entry[1]
504
+ };
417
505
  }
418
506
  }
419
- function* unescapeChunks(iterable) {
420
- for (const chunk of iterable) {
421
- yield unescapeHTML(chunk);
507
+
508
+ function codeFrame(src, loc) {
509
+ if (!loc || loc.line === void 0 || loc.column === void 0) {
510
+ return "";
511
+ }
512
+ const lines = normalizeLF(src).split("\n").map((ln) => ln.replace(/\t/g, " "));
513
+ const visibleLines = [];
514
+ for (let n = -2; n <= 2; n++) {
515
+ if (lines[loc.line + n])
516
+ visibleLines.push(loc.line + n);
517
+ }
518
+ let gutterWidth = 0;
519
+ for (const lineNo of visibleLines) {
520
+ let w = `> ${lineNo}`;
521
+ if (w.length > gutterWidth)
522
+ gutterWidth = w.length;
523
+ }
524
+ let output = "";
525
+ for (const lineNo of visibleLines) {
526
+ const isFocusedLine = lineNo === loc.line - 1;
527
+ output += isFocusedLine ? "> " : " ";
528
+ output += `${lineNo + 1} | ${lines[lineNo]}
529
+ `;
530
+ if (isFocusedLine)
531
+ output += `${Array.from({ length: gutterWidth }).join(" ")} | ${Array.from({
532
+ length: loc.column
533
+ }).join(" ")}^
534
+ `;
422
535
  }
536
+ return output;
423
537
  }
424
- function unescapeHTML(str) {
425
- if (!!str && typeof str === "object") {
426
- if (str instanceof Uint8Array) {
427
- return markHTMLBytes(str);
428
- } else if (str instanceof Response && str.body) {
429
- const body = str.body;
430
- return unescapeChunksAsync(body);
431
- } else if (typeof str.then === "function") {
432
- return Promise.resolve(str).then((value) => {
433
- return unescapeHTML(value);
434
- });
435
- } else if (Symbol.iterator in str) {
436
- return unescapeChunks(str);
437
- } else if (Symbol.asyncIterator in str || hasGetReader(str)) {
438
- return unescapeChunksAsync(str);
538
+
539
+ class AstroError extends Error {
540
+ constructor(props, ...params) {
541
+ var _a;
542
+ super(...params);
543
+ this.type = "AstroError";
544
+ const { code, name, title, message, stack, location, hint, frame } = props;
545
+ this.errorCode = code;
546
+ if (name && name !== "Error") {
547
+ this.name = name;
548
+ } else {
549
+ this.name = ((_a = getErrorDataByCode(this.errorCode)) == null ? void 0 : _a.name) ?? "UnknownError";
439
550
  }
551
+ this.title = title;
552
+ if (message)
553
+ this.message = message;
554
+ this.stack = stack ? stack : this.stack;
555
+ this.loc = location;
556
+ this.hint = hint;
557
+ this.frame = frame;
558
+ }
559
+ setErrorCode(errorCode) {
560
+ this.errorCode = errorCode;
561
+ }
562
+ setLocation(location) {
563
+ this.loc = location;
564
+ }
565
+ setName(name) {
566
+ this.name = name;
567
+ }
568
+ setMessage(message) {
569
+ this.message = message;
570
+ }
571
+ setHint(hint) {
572
+ this.hint = hint;
573
+ }
574
+ setFrame(source, location) {
575
+ this.frame = codeFrame(source, location);
576
+ }
577
+ static is(err) {
578
+ return err.type === "AstroError";
440
579
  }
441
- return markHTMLString(str);
442
580
  }
443
581
 
444
- const AstroJSX = "astro:jsx";
445
- const Empty = Symbol("empty");
446
- const toSlotName = (slotAttr) => slotAttr;
447
- function isVNode(vnode) {
448
- return vnode && typeof vnode === "object" && vnode[AstroJSX];
582
+ function validateArgs(args) {
583
+ if (args.length !== 3)
584
+ return false;
585
+ if (!args[0] || typeof args[0] !== "object")
586
+ return false;
587
+ return true;
449
588
  }
450
- function transformSlots(vnode) {
451
- if (typeof vnode.type === "string")
452
- return vnode;
453
- const slots = {};
454
- if (isVNode(vnode.props.children)) {
455
- const child = vnode.props.children;
456
- if (!isVNode(child))
457
- return;
458
- if (!("slot" in child.props))
459
- return;
460
- const name = toSlotName(child.props.slot);
461
- slots[name] = [child];
462
- slots[name]["$$slot"] = true;
463
- delete child.props.slot;
464
- delete vnode.props.children;
465
- }
466
- if (Array.isArray(vnode.props.children)) {
467
- vnode.props.children = vnode.props.children.map((child) => {
468
- if (!isVNode(child))
469
- return child;
470
- if (!("slot" in child.props))
471
- return child;
472
- const name = toSlotName(child.props.slot);
473
- if (Array.isArray(slots[name])) {
474
- slots[name].push(child);
475
- } else {
476
- slots[name] = [child];
477
- slots[name]["$$slot"] = true;
478
- }
479
- delete child.props.slot;
480
- return Empty;
481
- }).filter((v) => v !== Empty);
482
- }
483
- Object.assign(vnode.props, slots);
589
+ function baseCreateComponent(cb, moduleId) {
590
+ var _a;
591
+ const name = ((_a = moduleId == null ? void 0 : moduleId.split("/").pop()) == null ? void 0 : _a.replace(".astro", "")) ?? "";
592
+ const fn = (...args) => {
593
+ if (!validateArgs(args)) {
594
+ throw new AstroError({
595
+ ...AstroErrorData.InvalidComponentArgs,
596
+ message: AstroErrorData.InvalidComponentArgs.message(name)
597
+ });
598
+ }
599
+ return cb(...args);
600
+ };
601
+ Object.defineProperty(fn, "name", { value: name, writable: false });
602
+ fn.isAstroComponentFactory = true;
603
+ fn.moduleId = moduleId;
604
+ return fn;
484
605
  }
485
- function markRawChildren(child) {
486
- if (typeof child === "string")
487
- return markHTMLString(child);
488
- if (Array.isArray(child))
489
- return child.map((c) => markRawChildren(c));
490
- return child;
606
+ function createComponentWithOptions(opts) {
607
+ const cb = baseCreateComponent(opts.factory, opts.moduleId);
608
+ cb.propagation = opts.propagation;
609
+ return cb;
491
610
  }
492
- function transformSetDirectives(vnode) {
493
- if (!("set:html" in vnode.props || "set:text" in vnode.props))
494
- return;
495
- if ("set:html" in vnode.props) {
496
- const children = markRawChildren(vnode.props["set:html"]);
497
- delete vnode.props["set:html"];
498
- Object.assign(vnode.props, { children });
499
- return;
500
- }
501
- if ("set:text" in vnode.props) {
502
- const children = vnode.props["set:text"];
503
- delete vnode.props["set:text"];
504
- Object.assign(vnode.props, { children });
505
- return;
611
+ function createComponent(arg1, moduleId) {
612
+ if (typeof arg1 === "function") {
613
+ return baseCreateComponent(arg1, moduleId);
614
+ } else {
615
+ return createComponentWithOptions(arg1);
506
616
  }
507
617
  }
508
- function createVNode(type, props) {
509
- const vnode = {
510
- [Renderer]: "astro:jsx",
511
- [AstroJSX]: true,
512
- type,
513
- props: props ?? {}
514
- };
515
- transformSetDirectives(vnode);
516
- transformSlots(vnode);
517
- return vnode;
518
- }
519
-
520
- var idle_prebuilt_default = `(self.Astro=self.Astro||{}).idle=t=>{const e=async()=>{await(await t())()};"requestIdleCallback"in window?window.requestIdleCallback(e):setTimeout(e,200)},window.dispatchEvent(new Event("astro:idle"));`;
521
-
522
- var load_prebuilt_default = `(self.Astro=self.Astro||{}).load=a=>{(async()=>await(await a())())()},window.dispatchEvent(new Event("astro:load"));`;
523
-
524
- var media_prebuilt_default = `(self.Astro=self.Astro||{}).media=(s,a)=>{const t=async()=>{await(await s())()};if(a.value){const e=matchMedia(a.value);e.matches?t():e.addEventListener("change",t,{once:!0})}},window.dispatchEvent(new Event("astro:media"));`;
525
-
526
- var only_prebuilt_default = `(self.Astro=self.Astro||{}).only=t=>{(async()=>await(await t())())()},window.dispatchEvent(new Event("astro:only"));`;
527
618
 
528
- var visible_prebuilt_default = `(self.Astro=self.Astro||{}).visible=(s,c,n)=>{const r=async()=>{await(await s())()};let i=new IntersectionObserver(e=>{for(const t of e)if(!!t.isIntersecting){i.disconnect(),r();break}});for(let e=0;e<n.children.length;e++){const t=n.children[e];i.observe(t)}},window.dispatchEvent(new Event("astro:visible"));`;
619
+ const ASTRO_VERSION = "2.0.10";
529
620
 
530
- var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(const d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
621
+ function createAstroGlobFn() {
622
+ const globHandler = (importMetaGlobResult, globValue) => {
623
+ let allEntries = [...Object.values(importMetaGlobResult)];
624
+ if (allEntries.length === 0) {
625
+ throw new Error(`Astro.glob(${JSON.stringify(globValue())}) - no matches found.`);
626
+ }
627
+ return Promise.all(allEntries.map((fn) => fn()));
628
+ };
629
+ return globHandler;
630
+ }
631
+ function createAstro(site) {
632
+ return {
633
+ site: site ? new URL(site) : void 0,
634
+ generator: `Astro v${ASTRO_VERSION}`,
635
+ glob: createAstroGlobFn()
636
+ };
637
+ }
531
638
 
532
- function determineIfNeedsHydrationScript(result) {
533
- if (result._metadata.hasHydrationScript) {
534
- return false;
639
+ function getHandlerFromModule(mod, method) {
640
+ if (mod[method]) {
641
+ return mod[method];
535
642
  }
536
- return result._metadata.hasHydrationScript = true;
537
- }
538
- const hydrationScripts = {
539
- idle: idle_prebuilt_default,
540
- load: load_prebuilt_default,
541
- only: only_prebuilt_default,
542
- media: media_prebuilt_default,
543
- visible: visible_prebuilt_default
544
- };
545
- function determinesIfNeedsDirectiveScript(result, directive) {
546
- if (result._metadata.hasDirectives.has(directive)) {
547
- return false;
643
+ if (method === "delete" && mod["del"]) {
644
+ return mod["del"];
548
645
  }
549
- result._metadata.hasDirectives.add(directive);
550
- return true;
646
+ if (mod["all"]) {
647
+ return mod["all"];
648
+ }
649
+ return void 0;
551
650
  }
552
- function getDirectiveScriptText(directive) {
553
- if (!(directive in hydrationScripts)) {
554
- throw new Error(`Unknown directive: ${directive}`);
651
+ async function renderEndpoint(mod, context, ssr) {
652
+ var _a;
653
+ const { request, params } = context;
654
+ const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
655
+ const handler = getHandlerFromModule(mod, chosenMethod);
656
+ if (!ssr && ssr === false && chosenMethod && chosenMethod !== "get") {
657
+ console.warn(`
658
+ ${chosenMethod} requests are not available when building a static site. Update your config to output: 'server' to handle ${chosenMethod} requests.`);
555
659
  }
556
- const directiveScriptText = hydrationScripts[directive];
557
- return directiveScriptText;
660
+ if (!handler || typeof handler !== "function") {
661
+ let response = new Response(null, {
662
+ status: 404,
663
+ headers: {
664
+ "X-Astro-Response": "Not-Found"
665
+ }
666
+ });
667
+ return response;
668
+ }
669
+ if (handler.length > 1) {
670
+ console.warn(`
671
+ API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of:
672
+
673
+ export function get({ params, request }) {
674
+ //...
558
675
  }
559
- function getPrescripts(type, directive) {
560
- switch (type) {
561
- case "both":
562
- return `<style>astro-island,astro-slot{display:contents}</style><script>${getDirectiveScriptText(directive) + astro_island_prebuilt_default}<\/script>`;
563
- case "directive":
564
- return `<script>${getDirectiveScriptText(directive)}<\/script>`;
676
+
677
+ Update your code to remove this warning.`);
565
678
  }
566
- return "";
679
+ const proxy = new Proxy(context, {
680
+ get(target, prop) {
681
+ if (prop in target) {
682
+ return Reflect.get(target, prop);
683
+ } else if (prop in params) {
684
+ console.warn(`
685
+ API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of:
686
+
687
+ export function get({ params }) {
688
+ // ...
567
689
  }
568
690
 
569
- const headAndContentSym = Symbol.for("astro.headAndContent");
570
- function isHeadAndContent(obj) {
571
- return typeof obj === "object" && !!obj[headAndContentSym];
691
+ Update your code to remove this warning.`);
692
+ return Reflect.get(params, prop);
693
+ } else {
694
+ return void 0;
695
+ }
696
+ }
697
+ });
698
+ return handler.call(mod, proxy, request);
572
699
  }
573
700
 
574
- var _a$1;
575
- const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
576
- class RenderTemplateResult {
577
- constructor(htmlParts, expressions) {
578
- this[_a$1] = true;
579
- this.htmlParts = htmlParts;
580
- this.error = void 0;
581
- this.expressions = expressions.map((expression) => {
582
- if (isPromise(expression)) {
583
- return Promise.resolve(expression).catch((err) => {
584
- if (!this.error) {
585
- this.error = err;
586
- throw err;
587
- }
701
+ function serializeListValue(value) {
702
+ const hash = {};
703
+ push(value);
704
+ return Object.keys(hash).join(" ");
705
+ function push(item) {
706
+ if (item && typeof item.forEach === "function")
707
+ item.forEach(push);
708
+ else if (item === Object(item))
709
+ Object.keys(item).forEach((name) => {
710
+ if (item[name])
711
+ push(name);
712
+ });
713
+ else {
714
+ item = item === false || item == null ? "" : String(item).trim();
715
+ if (item) {
716
+ item.split(/\s+/).forEach((name) => {
717
+ hash[name] = true;
588
718
  });
589
719
  }
590
- return expression;
591
- });
592
- }
593
- async *[(_a$1 = renderTemplateResultSym, Symbol.asyncIterator)]() {
594
- const { htmlParts, expressions } = this;
595
- for (let i = 0; i < htmlParts.length; i++) {
596
- const html = htmlParts[i];
597
- const expression = expressions[i];
598
- yield markHTMLString(html);
599
- yield* renderChild(expression);
600
720
  }
601
721
  }
602
722
  }
603
- function isRenderTemplateResult(obj) {
604
- return typeof obj === "object" && !!obj[renderTemplateResultSym];
723
+ function isPromise(value) {
724
+ return !!value && typeof value === "object" && typeof value.then === "function";
605
725
  }
606
- async function* renderAstroTemplateResult(component) {
607
- for await (const value of component) {
608
- if (value || value === 0) {
609
- for await (const chunk of renderChild(value)) {
610
- switch (chunk.type) {
611
- case "directive": {
612
- yield chunk;
613
- break;
614
- }
615
- default: {
616
- yield markHTMLString(chunk);
617
- break;
618
- }
619
- }
620
- }
726
+ async function* streamAsyncIterator(stream) {
727
+ const reader = stream.getReader();
728
+ try {
729
+ while (true) {
730
+ const { done, value } = await reader.read();
731
+ if (done)
732
+ return;
733
+ yield value;
621
734
  }
735
+ } finally {
736
+ reader.releaseLock();
622
737
  }
623
738
  }
624
- function renderTemplate(htmlParts, ...expressions) {
625
- return new RenderTemplateResult(htmlParts, expressions);
626
- }
627
739
 
628
- function isAstroComponentFactory(obj) {
629
- return obj == null ? false : obj.isAstroComponentFactory === true;
740
+ const escapeHTML = escape;
741
+ class HTMLBytes extends Uint8Array {
630
742
  }
631
- async function renderToString(result, componentFactory, props, children) {
632
- const factoryResult = await componentFactory(result, props, children);
633
- if (factoryResult instanceof Response) {
634
- const response = factoryResult;
635
- throw response;
743
+ Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
744
+ get() {
745
+ return "HTMLBytes";
636
746
  }
637
- let parts = new HTMLParts();
638
- const templateResult = isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
639
- for await (const chunk of renderAstroTemplateResult(templateResult)) {
640
- parts.append(chunk, result);
747
+ });
748
+ class HTMLString extends String {
749
+ get [Symbol.toStringTag]() {
750
+ return "HTMLString";
641
751
  }
642
- return parts.toString();
643
752
  }
644
- function isAPropagatingComponent(result, factory) {
645
- let hint = factory.propagation || "none";
646
- if (factory.moduleId && result.propagation.has(factory.moduleId) && hint === "none") {
647
- hint = result.propagation.get(factory.moduleId);
753
+ const markHTMLString = (value) => {
754
+ if (value instanceof HTMLString) {
755
+ return value;
648
756
  }
649
- return hint === "in-tree" || hint === "self";
757
+ if (typeof value === "string") {
758
+ return new HTMLString(value);
759
+ }
760
+ return value;
761
+ };
762
+ function isHTMLString(value) {
763
+ return Object.prototype.toString.call(value) === "[object HTMLString]";
650
764
  }
651
-
652
- const defineErrors = (errs) => errs;
653
- const AstroErrorData = defineErrors({
654
- UnknownCompilerError: {
655
- title: "Unknown compiler error.",
656
- code: 1e3,
657
- hint: "This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler."
658
- },
659
- StaticRedirectNotAvailable: {
660
- title: "`Astro.redirect` is not available in static mode.",
661
- code: 3001,
662
- message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
663
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
664
- },
665
- ClientAddressNotAvailable: {
666
- title: "`Astro.clientAddress` is not available in current adapter.",
667
- code: 3002,
668
- message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
669
- },
670
- StaticClientAddressNotAvailable: {
671
- title: "`Astro.clientAddress` is not available in static mode.",
672
- code: 3003,
673
- message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
674
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
675
- },
676
- NoMatchingStaticPathFound: {
677
- title: "No static path found for requested path.",
678
- code: 3004,
679
- message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
680
- hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
681
- },
682
- OnlyResponseCanBeReturned: {
683
- title: "Invalid type returned by Astro page.",
684
- code: 3005,
685
- message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
686
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
687
- },
688
- MissingMediaQueryDirective: {
689
- title: "Missing value for `client:media` directive.",
690
- code: 3006,
691
- message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
692
- },
693
- NoMatchingRenderer: {
694
- title: "No matching renderer found.",
695
- code: 3007,
696
- message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
697
-
698
- ${validRenderersCount > 0 ? `There ${plural ? "are." : "is."} ${validRenderersCount} renderer${plural ? "s." : ""} configured in your \`astro.config.mjs\` file,
699
- but ${plural ? "none were." : "it was not."} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.`}`}`,
700
- hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
701
-
702
- See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`
703
- },
704
- NoClientEntrypoint: {
705
- title: "No client entrypoint specified in renderer.",
706
- code: 3008,
707
- message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
708
- hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
709
- },
710
- NoClientOnlyHint: {
711
- title: "Missing hint on client:only directive.",
712
- code: 3009,
713
- message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
714
- hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
715
- },
716
- InvalidGetStaticPathParam: {
717
- title: "Invalid value returned by a `getStaticPaths` path.",
718
- code: 3010,
719
- message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
720
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
721
- },
722
- InvalidGetStaticPathsReturn: {
723
- title: "Invalid value returned by getStaticPaths.",
724
- code: 3011,
725
- message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
726
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
727
- },
728
- GetStaticPathsRemovedRSSHelper: {
729
- title: "getStaticPaths RSS helper is not available anymore.",
730
- code: 3012,
731
- message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
732
- hint: "See https://docs.astro.build/en/guides/rss/ for more information."
733
- },
734
- GetStaticPathsExpectedParams: {
735
- title: "Missing params property on `getStaticPaths` route.",
736
- code: 3013,
737
- message: "Missing or empty required `params` property on `getStaticPaths` route.",
738
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
739
- },
740
- GetStaticPathsInvalidRouteParam: {
741
- title: "Invalid value for `getStaticPaths` route parameter.",
742
- code: 3014,
743
- message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
744
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
745
- },
746
- GetStaticPathsRequired: {
747
- title: "`getStaticPaths()` function required for dynamic routes.",
748
- code: 3015,
749
- message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
750
- hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
751
-
752
- Alternatively, set \`output: "server"\` in your Astro config file to switch to a non-static server build. This error can also occur if using \`export const prerender = true;\`.
753
- See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
754
- },
755
- ReservedSlotName: {
756
- title: "Invalid slot name.",
757
- code: 3016,
758
- message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
759
- },
760
- NoAdapterInstalled: {
761
- title: "Cannot use Server-side Rendering without an adapter.",
762
- code: 3017,
763
- message: `Cannot use \`output: 'server'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
764
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
765
- },
766
- NoMatchingImport: {
767
- title: "No import found for component.",
768
- code: 3018,
769
- message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
770
- hint: "Please make sure the component is properly imported."
771
- },
772
- InvalidPrerenderExport: {
773
- title: "Invalid prerender export.",
774
- code: 3019,
775
- message: (prefix, suffix) => {
776
- let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
777
- if (prefix !== "const")
778
- msg += `
779
- Expected \`const\` declaration but got \`${prefix}\`.`;
780
- if (suffix !== "true")
781
- msg += `
782
- Expected \`true\` value but got \`${suffix}\`.`;
783
- return msg;
784
- },
785
- hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."
786
- },
787
- UnknownViteError: {
788
- title: "Unknown Vite Error.",
789
- code: 4e3
790
- },
791
- FailedToLoadModuleSSR: {
792
- title: "Could not import file.",
793
- code: 4001,
794
- message: (importName) => `Could not import \`${importName}\`.`,
795
- hint: "This is often caused by a typo in the import path. Please make sure the file exists."
796
- },
797
- InvalidGlob: {
798
- title: "Invalid glob pattern.",
799
- code: 4002,
800
- message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
801
- hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
802
- },
803
- UnknownCSSError: {
804
- title: "Unknown CSS Error.",
805
- code: 5e3
806
- },
807
- CSSSyntaxError: {
808
- title: "CSS Syntax Error.",
809
- code: 5001
810
- },
811
- UnknownMarkdownError: {
812
- title: "Unknown Markdown Error.",
813
- code: 6e3
814
- },
815
- MarkdownFrontmatterParseError: {
816
- title: "Failed to parse Markdown frontmatter.",
817
- code: 6001
818
- },
819
- InvalidFrontmatterInjectionError: {
820
- title: "Invalid frontmatter injection.",
821
- code: 6003,
822
- message: 'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
823
- hint: "See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."
824
- },
825
- MdxIntegrationMissingError: {
826
- title: "MDX integration missing.",
827
- code: 6004,
828
- message: (file) => `Unable to render ${file}. Ensure that the \`@astrojs/mdx\` integration is installed.`,
829
- hint: "See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"
830
- },
831
- UnknownConfigError: {
832
- title: "Unknown configuration error.",
833
- code: 7e3
834
- },
835
- ConfigNotFound: {
836
- title: "Specified configuration file not found.",
837
- code: 7001,
838
- message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
839
- },
840
- ConfigLegacyKey: {
841
- title: "Legacy configuration detected.",
842
- code: 7002,
843
- message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
844
- hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
845
- },
846
- UnknownCLIError: {
847
- title: "Unknown CLI Error.",
848
- code: 8e3
849
- },
850
- GenerateContentTypesError: {
851
- title: "Failed to generate content types.",
852
- code: 8001,
853
- message: "`astro sync` command failed to generate content collection types.",
854
- hint: "Check your `src/content/config.*` file for typos."
855
- },
856
- UnknownContentCollectionError: {
857
- title: "Unknown Content Collection Error.",
858
- code: 9e3
859
- },
860
- InvalidContentEntryFrontmatterError: {
861
- title: "Content entry frontmatter does not match schema.",
862
- code: 9001,
863
- message: (collection, entryId, error) => {
864
- return [
865
- `${String(collection)} \u2192 ${String(entryId)} frontmatter does not match collection schema.`,
866
- ...error.errors.map((zodError) => zodError.message)
867
- ].join("\n");
868
- },
869
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."
870
- },
871
- InvalidContentEntrySlugError: {
872
- title: "Invalid content entry slug.",
873
- code: 9002,
874
- message: (collection, entryId) => {
875
- return `${String(collection)} \u2192 ${String(
876
- entryId
877
- )} has an invalid slug. \`slug\` must be a string.`;
878
- },
879
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
880
- },
881
- ContentSchemaContainsSlugError: {
882
- title: "Content Schema should not contain `slug`.",
883
- code: 9003,
884
- message: (collection) => {
885
- return `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collection} collection schema.`;
886
- },
887
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
888
- },
889
- UnknownError: {
890
- title: "Unknown Error.",
891
- code: 99999
765
+ function markHTMLBytes(bytes) {
766
+ return new HTMLBytes(bytes);
767
+ }
768
+ function hasGetReader(obj) {
769
+ return typeof obj.getReader === "function";
770
+ }
771
+ async function* unescapeChunksAsync(iterable) {
772
+ if (hasGetReader(iterable)) {
773
+ for await (const chunk of streamAsyncIterator(iterable)) {
774
+ yield unescapeHTML(chunk);
775
+ }
776
+ } else {
777
+ for await (const chunk of iterable) {
778
+ yield unescapeHTML(chunk);
779
+ }
780
+ }
781
+ }
782
+ function* unescapeChunks(iterable) {
783
+ for (const chunk of iterable) {
784
+ yield unescapeHTML(chunk);
785
+ }
786
+ }
787
+ function unescapeHTML(str) {
788
+ if (!!str && typeof str === "object") {
789
+ if (str instanceof Uint8Array) {
790
+ return markHTMLBytes(str);
791
+ } else if (str instanceof Response && str.body) {
792
+ const body = str.body;
793
+ return unescapeChunksAsync(body);
794
+ } else if (typeof str.then === "function") {
795
+ return Promise.resolve(str).then((value) => {
796
+ return unescapeHTML(value);
797
+ });
798
+ } else if (Symbol.iterator in str) {
799
+ return unescapeChunks(str);
800
+ } else if (Symbol.asyncIterator in str || hasGetReader(str)) {
801
+ return unescapeChunksAsync(str);
802
+ }
892
803
  }
893
- });
804
+ return markHTMLString(str);
805
+ }
894
806
 
895
- function normalizeLF(code) {
896
- return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
807
+ const AstroJSX = "astro:jsx";
808
+ const Empty = Symbol("empty");
809
+ const toSlotName = (slotAttr) => slotAttr;
810
+ function isVNode(vnode) {
811
+ return vnode && typeof vnode === "object" && vnode[AstroJSX];
897
812
  }
898
- function getErrorDataByCode(code) {
899
- const entry = Object.entries(AstroErrorData).find((data) => data[1].code === code);
900
- if (entry) {
901
- return {
902
- name: entry[0],
903
- data: entry[1]
904
- };
813
+ function transformSlots(vnode) {
814
+ if (typeof vnode.type === "string")
815
+ return vnode;
816
+ const slots = {};
817
+ if (isVNode(vnode.props.children)) {
818
+ const child = vnode.props.children;
819
+ if (!isVNode(child))
820
+ return;
821
+ if (!("slot" in child.props))
822
+ return;
823
+ const name = toSlotName(child.props.slot);
824
+ slots[name] = [child];
825
+ slots[name]["$$slot"] = true;
826
+ delete child.props.slot;
827
+ delete vnode.props.children;
828
+ }
829
+ if (Array.isArray(vnode.props.children)) {
830
+ vnode.props.children = vnode.props.children.map((child) => {
831
+ if (!isVNode(child))
832
+ return child;
833
+ if (!("slot" in child.props))
834
+ return child;
835
+ const name = toSlotName(child.props.slot);
836
+ if (Array.isArray(slots[name])) {
837
+ slots[name].push(child);
838
+ } else {
839
+ slots[name] = [child];
840
+ slots[name]["$$slot"] = true;
841
+ }
842
+ delete child.props.slot;
843
+ return Empty;
844
+ }).filter((v) => v !== Empty);
845
+ }
846
+ Object.assign(vnode.props, slots);
847
+ }
848
+ function markRawChildren(child) {
849
+ if (typeof child === "string")
850
+ return markHTMLString(child);
851
+ if (Array.isArray(child))
852
+ return child.map((c) => markRawChildren(c));
853
+ return child;
854
+ }
855
+ function transformSetDirectives(vnode) {
856
+ if (!("set:html" in vnode.props || "set:text" in vnode.props))
857
+ return;
858
+ if ("set:html" in vnode.props) {
859
+ const children = markRawChildren(vnode.props["set:html"]);
860
+ delete vnode.props["set:html"];
861
+ Object.assign(vnode.props, { children });
862
+ return;
863
+ }
864
+ if ("set:text" in vnode.props) {
865
+ const children = vnode.props["set:text"];
866
+ delete vnode.props["set:text"];
867
+ Object.assign(vnode.props, { children });
868
+ return;
905
869
  }
906
870
  }
871
+ function createVNode(type, props) {
872
+ const vnode = {
873
+ [Renderer]: "astro:jsx",
874
+ [AstroJSX]: true,
875
+ type,
876
+ props: props ?? {}
877
+ };
878
+ transformSetDirectives(vnode);
879
+ transformSlots(vnode);
880
+ return vnode;
881
+ }
907
882
 
908
- function codeFrame(src, loc) {
909
- if (!loc || loc.line === void 0 || loc.column === void 0) {
910
- return "";
883
+ var idle_prebuilt_default = `(self.Astro=self.Astro||{}).idle=t=>{const e=async()=>{await(await t())()};"requestIdleCallback"in window?window.requestIdleCallback(e):setTimeout(e,200)},window.dispatchEvent(new Event("astro:idle"));`;
884
+
885
+ var load_prebuilt_default = `(self.Astro=self.Astro||{}).load=a=>{(async()=>await(await a())())()},window.dispatchEvent(new Event("astro:load"));`;
886
+
887
+ var media_prebuilt_default = `(self.Astro=self.Astro||{}).media=(s,a)=>{const t=async()=>{await(await s())()};if(a.value){const e=matchMedia(a.value);e.matches?t():e.addEventListener("change",t,{once:!0})}},window.dispatchEvent(new Event("astro:media"));`;
888
+
889
+ var only_prebuilt_default = `(self.Astro=self.Astro||{}).only=t=>{(async()=>await(await t())())()},window.dispatchEvent(new Event("astro:only"));`;
890
+
891
+ var visible_prebuilt_default = `(self.Astro=self.Astro||{}).visible=(s,c,n)=>{const r=async()=>{await(await s())()};let i=new IntersectionObserver(e=>{for(const t of e)if(!!t.isIntersecting){i.disconnect(),r();break}});for(let e=0;e<n.children.length;e++){const t=n.children[e];i.observe(t)}},window.dispatchEvent(new Event("astro:visible"));`;
892
+
893
+ var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(const d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
894
+
895
+ function determineIfNeedsHydrationScript(result) {
896
+ if (result._metadata.hasHydrationScript) {
897
+ return false;
911
898
  }
912
- const lines = normalizeLF(src).split("\n").map((ln) => ln.replace(/\t/g, " "));
913
- const visibleLines = [];
914
- for (let n = -2; n <= 2; n++) {
915
- if (lines[loc.line + n])
916
- visibleLines.push(loc.line + n);
899
+ return result._metadata.hasHydrationScript = true;
900
+ }
901
+ const hydrationScripts = {
902
+ idle: idle_prebuilt_default,
903
+ load: load_prebuilt_default,
904
+ only: only_prebuilt_default,
905
+ media: media_prebuilt_default,
906
+ visible: visible_prebuilt_default
907
+ };
908
+ function determinesIfNeedsDirectiveScript(result, directive) {
909
+ if (result._metadata.hasDirectives.has(directive)) {
910
+ return false;
917
911
  }
918
- let gutterWidth = 0;
919
- for (const lineNo of visibleLines) {
920
- let w = `> ${lineNo}`;
921
- if (w.length > gutterWidth)
922
- gutterWidth = w.length;
912
+ result._metadata.hasDirectives.add(directive);
913
+ return true;
914
+ }
915
+ function getDirectiveScriptText(directive) {
916
+ if (!(directive in hydrationScripts)) {
917
+ throw new Error(`Unknown directive: ${directive}`);
918
+ }
919
+ const directiveScriptText = hydrationScripts[directive];
920
+ return directiveScriptText;
921
+ }
922
+ function getPrescripts(type, directive) {
923
+ switch (type) {
924
+ case "both":
925
+ return `<style>astro-island,astro-slot{display:contents}</style><script>${getDirectiveScriptText(directive) + astro_island_prebuilt_default}<\/script>`;
926
+ case "directive":
927
+ return `<script>${getDirectiveScriptText(directive)}<\/script>`;
923
928
  }
929
+ return "";
930
+ }
931
+
932
+ const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
933
+ const htmlBooleanAttributes = /^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
934
+ const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
935
+ const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
936
+ const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
937
+ const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
938
+ if (/[^\w]|\s/.test(match))
939
+ return "";
940
+ return index === 0 ? match : match.toUpperCase();
941
+ });
942
+ const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&#38;").replace(/"/g, "&#34;") : value;
943
+ const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
944
+ const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => `${kebab(k)}:${v}`).join(";");
945
+ function defineScriptVars(vars) {
924
946
  let output = "";
925
- for (const lineNo of visibleLines) {
926
- const isFocusedLine = lineNo === loc.line - 1;
927
- output += isFocusedLine ? "> " : " ";
928
- output += `${lineNo + 1} | ${lines[lineNo]}
929
- `;
930
- if (isFocusedLine)
931
- output += `${Array.from({ length: gutterWidth }).join(" ")} | ${Array.from({
932
- length: loc.column
933
- }).join(" ")}^
947
+ for (const [key, value] of Object.entries(vars)) {
948
+ output += `const ${toIdent(key)} = ${JSON.stringify(value)};
934
949
  `;
935
950
  }
936
- return output;
951
+ return markHTMLString(output);
952
+ }
953
+ function formatList(values) {
954
+ if (values.length === 1) {
955
+ return values[0];
956
+ }
957
+ return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
958
+ }
959
+ function addAttribute(value, key, shouldEscape = true) {
960
+ if (value == null) {
961
+ return "";
962
+ }
963
+ if (value === false) {
964
+ if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
965
+ return markHTMLString(` ${key}="false"`);
966
+ }
967
+ return "";
968
+ }
969
+ if (STATIC_DIRECTIVES.has(key)) {
970
+ console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
971
+
972
+ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
973
+ return "";
974
+ }
975
+ if (key === "class:list") {
976
+ const listValue = toAttributeString(serializeListValue(value), shouldEscape);
977
+ if (listValue === "") {
978
+ return "";
979
+ }
980
+ return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
981
+ }
982
+ if (key === "style" && !(value instanceof HTMLString) && typeof value === "object") {
983
+ return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
984
+ }
985
+ if (key === "className") {
986
+ return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
987
+ }
988
+ if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
989
+ return markHTMLString(` ${key}`);
990
+ } else {
991
+ return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
992
+ }
993
+ }
994
+ function internalSpreadAttributes(values, shouldEscape = true) {
995
+ let output = "";
996
+ for (const [key, value] of Object.entries(values)) {
997
+ output += addAttribute(value, key, shouldEscape);
998
+ }
999
+ return markHTMLString(output);
1000
+ }
1001
+ function renderElement$1(name, { props: _props, children = "" }, shouldEscape = true) {
1002
+ const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
1003
+ if (defineVars) {
1004
+ if (name === "style") {
1005
+ delete props["is:global"];
1006
+ delete props["is:scoped"];
1007
+ }
1008
+ if (name === "script") {
1009
+ delete props.hoist;
1010
+ children = defineScriptVars(defineVars) + "\n" + children;
1011
+ }
1012
+ }
1013
+ if ((children == null || children == "") && voidElementNames.test(name)) {
1014
+ return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
1015
+ }
1016
+ return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
1017
+ }
1018
+
1019
+ const uniqueElements = (item, index, all) => {
1020
+ const props = JSON.stringify(item.props);
1021
+ const children = item.children;
1022
+ return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
1023
+ };
1024
+ function renderAllHeadContent(result) {
1025
+ result._metadata.hasRenderedHead = true;
1026
+ const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement$1("style", style));
1027
+ result.styles.clear();
1028
+ const scripts = Array.from(result.scripts).filter(uniqueElements).map((script, i) => {
1029
+ return renderElement$1("script", script, false);
1030
+ });
1031
+ const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement$1("link", link, false));
1032
+ let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
1033
+ if (result.extraHead.length > 0) {
1034
+ for (const part of result.extraHead) {
1035
+ content += part;
1036
+ }
1037
+ }
1038
+ return markHTMLString(content);
1039
+ }
1040
+ function* renderHead(result) {
1041
+ yield { type: "head", result };
1042
+ }
1043
+ function* maybeRenderHead(result) {
1044
+ if (result._metadata.hasRenderedHead) {
1045
+ return;
1046
+ }
1047
+ yield { type: "maybe-head", result, scope: result.scope };
937
1048
  }
938
1049
 
939
- class AstroError extends Error {
940
- constructor(props, ...params) {
941
- var _a;
942
- super(...params);
943
- this.type = "AstroError";
944
- const { code, name, title, message, stack, location, hint, frame } = props;
945
- this.errorCode = code;
946
- if (name && name !== "Error") {
947
- this.name = name;
948
- } else {
949
- this.name = ((_a = getErrorDataByCode(this.errorCode)) == null ? void 0 : _a.name) ?? "UnknownError";
1050
+ const ScopeFlags = {
1051
+ Astro: 1 << 0,
1052
+ JSX: 1 << 1,
1053
+ Slot: 1 << 2,
1054
+ HeadBuffer: 1 << 3,
1055
+ RenderSlot: 1 << 4
1056
+ };
1057
+ function addScopeFlag(result, flag) {
1058
+ result.scope |= flag;
1059
+ }
1060
+ function hasScopeFlag(result, flag) {
1061
+ return (result.scope & flag) === flag;
1062
+ }
1063
+ function createScopedResult(result, flag) {
1064
+ const scopedResult = Object.create(result, {
1065
+ scope: {
1066
+ writable: true,
1067
+ value: result.scope
950
1068
  }
951
- this.title = title;
952
- if (message)
953
- this.message = message;
954
- this.stack = stack ? stack : this.stack;
955
- this.loc = location;
956
- this.hint = hint;
957
- this.frame = frame;
958
- }
959
- setErrorCode(errorCode) {
960
- this.errorCode = errorCode;
1069
+ });
1070
+ if (flag != null) {
1071
+ addScopeFlag(scopedResult, flag);
961
1072
  }
962
- setLocation(location) {
963
- this.loc = location;
1073
+ return scopedResult;
1074
+ }
1075
+
1076
+ const headAndContentSym = Symbol.for("astro.headAndContent");
1077
+ function isHeadAndContent(obj) {
1078
+ return typeof obj === "object" && !!obj[headAndContentSym];
1079
+ }
1080
+
1081
+ var _a$1;
1082
+ const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
1083
+ class RenderTemplateResult {
1084
+ constructor(htmlParts, expressions) {
1085
+ this[_a$1] = true;
1086
+ this.htmlParts = htmlParts;
1087
+ this.error = void 0;
1088
+ this.expressions = expressions.map((expression) => {
1089
+ if (isPromise(expression)) {
1090
+ return Promise.resolve(expression).catch((err) => {
1091
+ if (!this.error) {
1092
+ this.error = err;
1093
+ throw err;
1094
+ }
1095
+ });
1096
+ }
1097
+ return expression;
1098
+ });
964
1099
  }
965
- setName(name) {
966
- this.name = name;
1100
+ async *[(_a$1 = renderTemplateResultSym, Symbol.asyncIterator)]() {
1101
+ const { htmlParts, expressions } = this;
1102
+ for (let i = 0; i < htmlParts.length; i++) {
1103
+ const html = htmlParts[i];
1104
+ const expression = expressions[i];
1105
+ yield markHTMLString(html);
1106
+ yield* renderChild(expression);
1107
+ }
967
1108
  }
968
- setMessage(message) {
969
- this.message = message;
1109
+ }
1110
+ function isRenderTemplateResult(obj) {
1111
+ return typeof obj === "object" && !!obj[renderTemplateResultSym];
1112
+ }
1113
+ async function* renderAstroTemplateResult(component) {
1114
+ for await (const value of component) {
1115
+ if (value || value === 0) {
1116
+ for await (const chunk of renderChild(value)) {
1117
+ switch (chunk.type) {
1118
+ case "directive": {
1119
+ yield chunk;
1120
+ break;
1121
+ }
1122
+ default: {
1123
+ yield markHTMLString(chunk);
1124
+ break;
1125
+ }
1126
+ }
1127
+ }
1128
+ }
970
1129
  }
971
- setHint(hint) {
972
- this.hint = hint;
1130
+ }
1131
+ function renderTemplate(htmlParts, ...expressions) {
1132
+ return new RenderTemplateResult(htmlParts, expressions);
1133
+ }
1134
+
1135
+ function isAstroComponentFactory(obj) {
1136
+ return obj == null ? false : obj.isAstroComponentFactory === true;
1137
+ }
1138
+ async function renderToString(result, componentFactory, props, children) {
1139
+ const scoped = createScopedResult(result, ScopeFlags.Astro);
1140
+ const factoryResult = await componentFactory(scoped, props, children);
1141
+ if (factoryResult instanceof Response) {
1142
+ const response = factoryResult;
1143
+ throw response;
973
1144
  }
974
- setFrame(source, location) {
975
- this.frame = codeFrame(source, location);
1145
+ let parts = new HTMLParts();
1146
+ const templateResult = isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
1147
+ for await (const chunk of renderAstroTemplateResult(templateResult)) {
1148
+ parts.append(chunk, result);
976
1149
  }
977
- static is(err) {
978
- return err.type === "AstroError";
1150
+ return parts.toString();
1151
+ }
1152
+ function isAPropagatingComponent(result, factory) {
1153
+ let hint = factory.propagation || "none";
1154
+ if (factory.moduleId && result.propagation.has(factory.moduleId) && hint === "none") {
1155
+ hint = result.propagation.get(factory.moduleId);
979
1156
  }
1157
+ return hint === "in-tree" || hint === "self";
980
1158
  }
981
1159
 
982
1160
  const PROP_TYPE = {
@@ -1190,17 +1368,19 @@ class AstroComponentInstance {
1190
1368
  this.props = props;
1191
1369
  this.factory = factory;
1192
1370
  this.slotValues = {};
1371
+ const scoped = createScopedResult(result, ScopeFlags.Slot);
1193
1372
  for (const name in slots) {
1194
- this.slotValues[name] = slots[name]();
1373
+ const value = slots[name](scoped);
1374
+ this.slotValues[name] = () => value;
1195
1375
  }
1196
1376
  }
1197
- async init() {
1198
- this.returnValue = this.factory(this.result, this.props, this.slotValues);
1377
+ async init(result) {
1378
+ this.returnValue = this.factory(result, this.props, this.slotValues);
1199
1379
  return this.returnValue;
1200
1380
  }
1201
1381
  async *render() {
1202
1382
  if (this.returnValue === void 0) {
1203
- await this.init();
1383
+ await this.init(this.result);
1204
1384
  }
1205
1385
  let value = this.returnValue;
1206
1386
  if (isPromise(value)) {
@@ -1278,13 +1458,14 @@ class SlotString extends HTMLString {
1278
1458
  function isSlotString(str) {
1279
1459
  return !!str[slotString];
1280
1460
  }
1281
- async function renderSlot(_result, slotted, fallback) {
1461
+ async function renderSlot(result, slotted, fallback) {
1282
1462
  if (slotted) {
1283
- let iterator = renderChild(slotted);
1463
+ const scoped = createScopedResult(result, ScopeFlags.Slot);
1464
+ let iterator = renderChild(typeof slotted === "function" ? slotted(scoped) : slotted);
1284
1465
  let content = "";
1285
1466
  let instructions = null;
1286
1467
  for await (const chunk of iterator) {
1287
- if (chunk.type === "directive") {
1468
+ if (typeof chunk.type === "string") {
1288
1469
  if (instructions === null) {
1289
1470
  instructions = [];
1290
1471
  }
@@ -1295,7 +1476,10 @@ async function renderSlot(_result, slotted, fallback) {
1295
1476
  }
1296
1477
  return markHTMLString(new SlotString(content, instructions));
1297
1478
  }
1298
- return fallback;
1479
+ if (fallback) {
1480
+ return renderSlot(result, fallback);
1481
+ }
1482
+ return "";
1299
1483
  }
1300
1484
  async function renderSlots(result, slots = {}) {
1301
1485
  let slotInstructions = null;
@@ -1323,33 +1507,72 @@ const Renderer = Symbol.for("astro:renderer");
1323
1507
  const encoder = new TextEncoder();
1324
1508
  const decoder = new TextDecoder();
1325
1509
  function stringifyChunk(result, chunk) {
1326
- switch (chunk.type) {
1327
- case "directive": {
1328
- const { hydration } = chunk;
1329
- let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
1330
- let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
1331
- let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
1332
- if (prescriptType) {
1333
- let prescripts = getPrescripts(prescriptType, hydration.directive);
1334
- return markHTMLString(prescripts);
1335
- } else {
1336
- return "";
1510
+ if (typeof chunk.type === "string") {
1511
+ const instruction = chunk;
1512
+ switch (instruction.type) {
1513
+ case "directive": {
1514
+ const { hydration } = instruction;
1515
+ let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
1516
+ let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
1517
+ let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
1518
+ if (prescriptType) {
1519
+ let prescripts = getPrescripts(prescriptType, hydration.directive);
1520
+ return markHTMLString(prescripts);
1521
+ } else {
1522
+ return "";
1523
+ }
1337
1524
  }
1338
- }
1339
- default: {
1340
- if (isSlotString(chunk)) {
1341
- let out = "";
1342
- const c = chunk;
1343
- if (c.instructions) {
1344
- for (const instr of c.instructions) {
1345
- out += stringifyChunk(result, instr);
1525
+ case "head": {
1526
+ if (result._metadata.hasRenderedHead) {
1527
+ return "";
1528
+ }
1529
+ return renderAllHeadContent(result);
1530
+ }
1531
+ case "maybe-head": {
1532
+ if (result._metadata.hasRenderedHead) {
1533
+ return "";
1534
+ }
1535
+ const scope = instruction.scope;
1536
+ switch (scope) {
1537
+ case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro:
1538
+ case ScopeFlags.JSX | ScopeFlags.Astro | ScopeFlags.HeadBuffer:
1539
+ case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro | ScopeFlags.HeadBuffer: {
1540
+ return "";
1541
+ }
1542
+ case ScopeFlags.JSX | ScopeFlags.Astro: {
1543
+ if (hasScopeFlag(result, ScopeFlags.JSX)) {
1544
+ return "";
1545
+ }
1546
+ break;
1547
+ }
1548
+ case ScopeFlags.Slot: {
1549
+ if (hasScopeFlag(result, ScopeFlags.RenderSlot)) {
1550
+ return "";
1551
+ }
1552
+ break;
1553
+ }
1554
+ case ScopeFlags.RenderSlot | ScopeFlags.Astro:
1555
+ case ScopeFlags.RenderSlot | ScopeFlags.Astro | ScopeFlags.JSX:
1556
+ case ScopeFlags.RenderSlot | ScopeFlags.Astro | ScopeFlags.JSX | ScopeFlags.HeadBuffer: {
1557
+ return "";
1346
1558
  }
1347
1559
  }
1348
- out += chunk.toString();
1349
- return out;
1560
+ return renderAllHeadContent(result);
1561
+ }
1562
+ }
1563
+ } else {
1564
+ if (isSlotString(chunk)) {
1565
+ let out = "";
1566
+ const c = chunk;
1567
+ if (c.instructions) {
1568
+ for (const instr of c.instructions) {
1569
+ out += stringifyChunk(result, instr);
1570
+ }
1350
1571
  }
1351
- return chunk.toString();
1572
+ out += chunk.toString();
1573
+ return out;
1352
1574
  }
1575
+ return chunk.toString();
1353
1576
  }
1354
1577
  }
1355
1578
  class HTMLParts {
@@ -1374,7 +1597,8 @@ function chunkToByteArray(result, chunk) {
1374
1597
  if (chunk instanceof Uint8Array) {
1375
1598
  return chunk;
1376
1599
  }
1377
- return encoder.encode(stringifyChunk(result, chunk));
1600
+ let stringified = stringifyChunk(result, chunk);
1601
+ return encoder.encode(stringified.toString());
1378
1602
  }
1379
1603
 
1380
1604
  const ClientOnlyPlaceholder = "astro-client-only";
@@ -1445,12 +1669,14 @@ Did you forget to import the component or is it possible there is a typo?`);
1445
1669
  props[key] = value;
1446
1670
  }
1447
1671
  }
1448
- return markHTMLString(await renderToString(result, vnode.type, props, slots));
1672
+ const scoped = createScopedResult(result, ScopeFlags.JSX);
1673
+ const html = markHTMLString(await renderToString(scoped, vnode.type, props, slots));
1674
+ return html;
1449
1675
  }
1450
1676
  case (!vnode.type && vnode.type !== 0):
1451
1677
  return "";
1452
1678
  case (typeof vnode.type === "string" && vnode.type !== ClientOnlyPlaceholder):
1453
- return markHTMLString(await renderElement$1(result, vnode.type, vnode.props ?? {}));
1679
+ return markHTMLString(await renderElement(result, vnode.type, vnode.props ?? {}));
1454
1680
  }
1455
1681
  if (vnode.type) {
1456
1682
  let extractSlots2 = function(child) {
@@ -1555,7 +1781,7 @@ Did you forget to import the component or is it possible there is a typo?`);
1555
1781
  }
1556
1782
  return markHTMLString(`${vnode}`);
1557
1783
  }
1558
- async function renderElement$1(result, tag, { children, ...props }) {
1784
+ async function renderElement(result, tag, { children, ...props }) {
1559
1785
  return markHTMLString(
1560
1786
  `<${tag}${spreadAttributes(props)}${markHTMLString(
1561
1787
  (children == null || children == "") && voidElementNames.test(tag) ? `/>` : `>${children == null ? "" : await renderJSX(result, children)}</${tag}>`
@@ -1644,93 +1870,6 @@ function shorthash(text) {
1644
1870
  return sign + result;
1645
1871
  }
1646
1872
 
1647
- const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
1648
- const htmlBooleanAttributes = /^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
1649
- const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
1650
- const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
1651
- const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
1652
- const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
1653
- if (/[^\w]|\s/.test(match))
1654
- return "";
1655
- return index === 0 ? match : match.toUpperCase();
1656
- });
1657
- const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&#38;").replace(/"/g, "&#34;") : value;
1658
- const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
1659
- const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => `${kebab(k)}:${v}`).join(";");
1660
- function defineScriptVars(vars) {
1661
- let output = "";
1662
- for (const [key, value] of Object.entries(vars)) {
1663
- output += `const ${toIdent(key)} = ${JSON.stringify(value)};
1664
- `;
1665
- }
1666
- return markHTMLString(output);
1667
- }
1668
- function formatList(values) {
1669
- if (values.length === 1) {
1670
- return values[0];
1671
- }
1672
- return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
1673
- }
1674
- function addAttribute(value, key, shouldEscape = true) {
1675
- if (value == null) {
1676
- return "";
1677
- }
1678
- if (value === false) {
1679
- if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
1680
- return markHTMLString(` ${key}="false"`);
1681
- }
1682
- return "";
1683
- }
1684
- if (STATIC_DIRECTIVES.has(key)) {
1685
- console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
1686
-
1687
- Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
1688
- return "";
1689
- }
1690
- if (key === "class:list") {
1691
- const listValue = toAttributeString(serializeListValue(value), shouldEscape);
1692
- if (listValue === "") {
1693
- return "";
1694
- }
1695
- return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
1696
- }
1697
- if (key === "style" && !(value instanceof HTMLString) && typeof value === "object") {
1698
- return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
1699
- }
1700
- if (key === "className") {
1701
- return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
1702
- }
1703
- if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
1704
- return markHTMLString(` ${key}`);
1705
- } else {
1706
- return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
1707
- }
1708
- }
1709
- function internalSpreadAttributes(values, shouldEscape = true) {
1710
- let output = "";
1711
- for (const [key, value] of Object.entries(values)) {
1712
- output += addAttribute(value, key, shouldEscape);
1713
- }
1714
- return markHTMLString(output);
1715
- }
1716
- function renderElement(name, { props: _props, children = "" }, shouldEscape = true) {
1717
- const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
1718
- if (defineVars) {
1719
- if (name === "style") {
1720
- delete props["is:global"];
1721
- delete props["is:scoped"];
1722
- }
1723
- if (name === "script") {
1724
- delete props.hoist;
1725
- children = defineScriptVars(defineVars) + "\n" + children;
1726
- }
1727
- }
1728
- if ((children == null || children == "") && voidElementNames.test(name)) {
1729
- return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
1730
- }
1731
- return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
1732
- }
1733
-
1734
1873
  function componentIsHTMLElement(Component) {
1735
1874
  return typeof HTMLElement !== "undefined" && HTMLElement.isPrototypeOf(Component);
1736
1875
  }
@@ -1769,7 +1908,8 @@ function guessRenderers(componentUrl) {
1769
1908
  "@astrojs/preact",
1770
1909
  "@astrojs/solid-js",
1771
1910
  "@astrojs/vue",
1772
- "@astrojs/svelte"
1911
+ "@astrojs/svelte",
1912
+ "@astrojs/lit"
1773
1913
  ];
1774
1914
  }
1775
1915
  }
@@ -1943,8 +2083,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
1943
2083
  }
1944
2084
  if (isPage || (renderer == null ? void 0 : renderer.name) === "astro:jsx") {
1945
2085
  yield html;
1946
- } else {
2086
+ } else if (html && html.length > 0) {
1947
2087
  yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, ""));
2088
+ } else {
2089
+ yield "";
1948
2090
  }
1949
2091
  }();
1950
2092
  }
@@ -1984,7 +2126,7 @@ ${serializeProps(
1984
2126
  yield* slotInstructions;
1985
2127
  }
1986
2128
  yield { type: "directive", hydration, result };
1987
- yield markHTMLString(renderElement("astro-island", island, false));
2129
+ yield markHTMLString(renderElement$1("astro-island", island, false));
1988
2130
  }
1989
2131
  return renderAll();
1990
2132
  }
@@ -2032,43 +2174,6 @@ function renderComponentToIterable(result, displayName, Component, props, slots
2032
2174
  return renderResult;
2033
2175
  }
2034
2176
 
2035
- const uniqueElements = (item, index, all) => {
2036
- const props = JSON.stringify(item.props);
2037
- const children = item.children;
2038
- return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
2039
- };
2040
- async function* renderExtraHead(result, base) {
2041
- yield base;
2042
- for (const part of result.extraHead) {
2043
- yield* renderChild(part);
2044
- }
2045
- }
2046
- function renderAllHeadContent(result) {
2047
- const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement("style", style));
2048
- result.styles.clear();
2049
- const scripts = Array.from(result.scripts).filter(uniqueElements).map((script, i) => {
2050
- return renderElement("script", script, false);
2051
- });
2052
- const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement("link", link, false));
2053
- const baseHeadContent = markHTMLString(links.join("\n") + styles.join("\n") + scripts.join("\n"));
2054
- if (result.extraHead.length > 0) {
2055
- return renderExtraHead(result, baseHeadContent);
2056
- } else {
2057
- return baseHeadContent;
2058
- }
2059
- }
2060
- function createRenderHead(result) {
2061
- result._metadata.hasRenderedHead = true;
2062
- return renderAllHeadContent.bind(null, result);
2063
- }
2064
- const renderHead = createRenderHead;
2065
- async function* maybeRenderHead(result) {
2066
- if (result._metadata.hasRenderedHead) {
2067
- return;
2068
- }
2069
- yield createRenderHead(result)();
2070
- }
2071
-
2072
2177
  var __accessCheck$2 = (obj, member, msg) => {
2073
2178
  if (!member.has(obj))
2074
2179
  throw TypeError("Cannot " + msg);
@@ -2172,12 +2277,13 @@ async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
2172
2277
  }
2173
2278
  async function bufferHeadContent(result) {
2174
2279
  const iterator = result.propagators.values();
2280
+ const scoped = createScopedResult(result, ScopeFlags.HeadBuffer);
2175
2281
  while (true) {
2176
2282
  const { value, done } = iterator.next();
2177
2283
  if (done) {
2178
2284
  break;
2179
2285
  }
2180
- const returnValue = await value.init();
2286
+ const returnValue = await value.init(scoped);
2181
2287
  if (isHeadAndContent(returnValue)) {
2182
2288
  result.extraHead.push(returnValue.head);
2183
2289
  }
@@ -2513,6 +2619,7 @@ class Slots {
2513
2619
  async render(name, args = []) {
2514
2620
  if (!__privateGet$1(this, _slots) || !this.has(name))
2515
2621
  return;
2622
+ const scoped = createScopedResult(__privateGet$1(this, _result), ScopeFlags.RenderSlot);
2516
2623
  if (!Array.isArray(args)) {
2517
2624
  warn(
2518
2625
  __privateGet$1(this, _loggingOpts),
@@ -2521,22 +2628,20 @@ class Slots {
2521
2628
  );
2522
2629
  } else if (args.length > 0) {
2523
2630
  const slotValue = __privateGet$1(this, _slots)[name];
2524
- const component = typeof slotValue === "function" ? await slotValue() : await slotValue;
2631
+ const component = typeof slotValue === "function" ? await slotValue(scoped) : await slotValue;
2525
2632
  const expression = getFunctionExpression(component);
2526
2633
  if (expression) {
2527
- const slot = expression(...args);
2528
- return await renderSlot(__privateGet$1(this, _result), slot).then(
2529
- (res) => res != null ? String(res) : res
2530
- );
2634
+ const slot = () => expression(...args);
2635
+ return await renderSlot(scoped, slot).then((res) => res != null ? String(res) : res);
2531
2636
  }
2532
2637
  if (typeof component === "function") {
2533
- return await renderJSX(__privateGet$1(this, _result), component(...args)).then(
2638
+ return await renderJSX(scoped, component(...args)).then(
2534
2639
  (res) => res != null ? String(res) : res
2535
2640
  );
2536
2641
  }
2537
2642
  }
2538
- const content = await renderSlot(__privateGet$1(this, _result), __privateGet$1(this, _slots)[name]);
2539
- const outHTML = stringifyChunk(__privateGet$1(this, _result), content);
2643
+ const content = await renderSlot(scoped, __privateGet$1(this, _slots)[name]);
2644
+ const outHTML = stringifyChunk(scoped, content);
2540
2645
  return outHTML;
2541
2646
  }
2542
2647
  }
@@ -2567,6 +2672,7 @@ function createResult(args) {
2567
2672
  propagation: args.propagation ?? /* @__PURE__ */ new Map(),
2568
2673
  propagators: /* @__PURE__ */ new Map(),
2569
2674
  extraHead: [],
2675
+ scope: 0,
2570
2676
  cookies,
2571
2677
  createAstro(astroGlobal, props, slots) {
2572
2678
  const astroSlots = new Slots(result, slots, args.logging);
@@ -2652,10 +2758,10 @@ function generatePaginateFunction(routeMatch) {
2652
2758
  } else if (routeMatch.params.includes(`${paramName}`)) {
2653
2759
  includesFirstPageNumber = true;
2654
2760
  } else {
2655
- throw new Error(
2656
- `[paginate()] page number param \`${paramName}\` not found in your filepath.
2657
- Rename your file to \`[...page].astro\` or customize the param name via the \`paginate([], {param: '...'}\` option.`
2658
- );
2761
+ throw new AstroError({
2762
+ ...AstroErrorData.PageNumberParamNotFound,
2763
+ message: AstroErrorData.PageNumberParamNotFound.message(paramName)
2764
+ });
2659
2765
  }
2660
2766
  const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
2661
2767
  const result = [...Array(lastPage).keys()].map((num) => {
@@ -2683,7 +2789,7 @@ Rename your file to \`[...page].astro\` or customize the param name via the \`pa
2683
2789
  next: pageNum === lastPage ? void 0 : routeMatch.generate({ ...params, page: String(pageNum + 1) }),
2684
2790
  prev: pageNum === 1 ? void 0 : routeMatch.generate({
2685
2791
  ...params,
2686
- page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
2792
+ page: !includesFirstPageNumber && pageNum - 1 === 1 ? "" : String(pageNum - 1)
2687
2793
  })
2688
2794
  }
2689
2795
  }
@@ -3237,6 +3343,7 @@ renderPage_fn = async function(request, routeData, mod, status = 200) {
3237
3343
  request,
3238
3344
  origin: url.origin,
3239
3345
  pathname,
3346
+ propagation: __privateGet(this, _manifest).propagation,
3240
3347
  scripts,
3241
3348
  links,
3242
3349
  route: routeData,
@@ -3375,4 +3482,4 @@ var server_default = {
3375
3482
  renderToStaticMarkup
3376
3483
  };
3377
3484
 
3378
- export { Fragment as F, NodeApp as N, createComponent as a, addAttribute as b, createAstro as c, renderComponent as d, renderSlot as e, renderHead as f, server_default as g, deserializeManifest as h, maybeRenderHead as m, renderTemplate as r, spreadAttributes as s, unescapeHTML as u };
3485
+ export { Fragment as F, NodeApp as N, createComponent as a, addAttribute as b, createAstro as c, renderSlot as d, renderComponent as e, renderHead as f, server_default as g, deserializeManifest as h, maybeRenderHead as m, renderTemplate as r, spreadAttributes as s, unescapeHTML as u };