cloudcommerce 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/package.json +8 -8
  3. package/packages/api/package.json +1 -1
  4. package/packages/apps/correios/package.json +2 -2
  5. package/packages/apps/custom-payment/package.json +1 -1
  6. package/packages/apps/custom-shipping/package.json +1 -1
  7. package/packages/apps/datafrete/package.json +3 -3
  8. package/packages/apps/discounts/package.json +1 -1
  9. package/packages/apps/emails/package.json +1 -1
  10. package/packages/apps/fb-conversions/package.json +2 -2
  11. package/packages/apps/frenet/package.json +3 -3
  12. package/packages/apps/galaxpay/package.json +3 -3
  13. package/packages/apps/google-analytics/package.json +3 -3
  14. package/packages/apps/infinitepay/lib/ip-create-transaction.js +1 -1
  15. package/packages/apps/infinitepay/lib/ip-create-transaction.js.map +1 -1
  16. package/packages/apps/infinitepay/package.json +3 -3
  17. package/packages/apps/infinitepay/src/ip-create-transaction.ts +1 -1
  18. package/packages/apps/jadlog/package.json +2 -2
  19. package/packages/apps/loyalty-points/package.json +1 -1
  20. package/packages/apps/melhor-envio/package.json +3 -3
  21. package/packages/apps/mercadopago/package.json +3 -3
  22. package/packages/apps/pagarme/package.json +3 -3
  23. package/packages/apps/paghiper/package.json +3 -3
  24. package/packages/apps/pix/package.json +3 -3
  25. package/packages/apps/tiny-erp/package.json +3 -3
  26. package/packages/apps/webhooks/CHANGELOG.md +1 -0
  27. package/packages/apps/webhooks/README.md +1 -0
  28. package/packages/apps/webhooks/lib/app-webhooks.js +9 -0
  29. package/packages/apps/webhooks/lib/app-webhooks.js.map +1 -0
  30. package/packages/apps/webhooks/lib/events-to-webhooks-app.js +127 -0
  31. package/packages/apps/webhooks/lib/events-to-webhooks-app.js.map +1 -0
  32. package/packages/apps/webhooks/lib/index.js +2 -0
  33. package/packages/apps/webhooks/lib/index.js.map +1 -0
  34. package/packages/apps/webhooks/package.json +32 -0
  35. package/packages/apps/webhooks/src/app-webhooks.ts +14 -0
  36. package/packages/apps/webhooks/src/events-to-webhooks-app.ts +178 -0
  37. package/packages/apps/webhooks/src/index.ts +1 -0
  38. package/packages/apps/webhooks/tsconfig.json +3 -0
  39. package/packages/cli/lib/setup-gcloud.js +120 -20
  40. package/packages/cli/package.json +1 -1
  41. package/packages/cli/src/cli.ts +1 -1
  42. package/packages/cli/src/setup-gcloud.ts +146 -21
  43. package/packages/config/package.json +1 -1
  44. package/packages/emails/package.json +2 -2
  45. package/packages/emails/tests/assets/order.json +1 -1
  46. package/packages/events/lib/firebase.js +2 -0
  47. package/packages/events/lib/firebase.js.map +1 -1
  48. package/packages/events/package.json +3 -2
  49. package/packages/events/src/firebase.ts +2 -0
  50. package/packages/firebase/lib/config.d.ts +4 -0
  51. package/packages/firebase/lib/config.js +10 -1
  52. package/packages/firebase/lib/config.js.map +1 -1
  53. package/packages/firebase/lib/handlers/check-store-events.js +13 -4
  54. package/packages/firebase/lib/handlers/check-store-events.js.map +1 -1
  55. package/packages/firebase/package.json +2 -2
  56. package/packages/firebase/src/config.ts +10 -7
  57. package/packages/firebase/src/handlers/check-store-events.ts +14 -4
  58. package/packages/i18n/package.json +1 -1
  59. package/packages/modules/lib/firebase/checkout.js +4 -4
  60. package/packages/modules/lib/firebase/checkout.js.map +1 -1
  61. package/packages/modules/package.json +3 -3
  62. package/packages/modules/schemas/@checkout.cjs +0 -5
  63. package/packages/modules/schemas/create_transaction.cjs +6 -1
  64. package/packages/modules/src/firebase/checkout.ts +4 -4
  65. package/packages/passport/package.json +2 -2
  66. package/packages/ssr/package.json +7 -7
  67. package/packages/storefront/dist/client/_astro/PitchBar.004b6ea4.js +1 -0
  68. package/packages/storefront/dist/client/_astro/Prices.f311909a.js +1 -0
  69. package/packages/storefront/dist/client/_astro/Prices.vue_vue_type_script_setup_true_lang.ef47de70.js +1 -0
  70. package/packages/storefront/dist/client/_astro/ProductCard.34de5097.js +1 -0
  71. package/packages/storefront/dist/client/_astro/ShopHeader.cbfee289.js +1 -0
  72. package/packages/storefront/dist/client/_astro/{_...slug_.32968ccf.css → _...slug_.bcc33d9d.css} +1 -1
  73. package/packages/storefront/dist/client/_astro/{client.5a46cc02.js → client.56d86c9b.js} +1 -1
  74. package/packages/storefront/dist/client/_astro/index.0c833781.css +1 -0
  75. package/packages/storefront/dist/client/_astro/index.2d12be6c.js +1 -0
  76. package/packages/storefront/dist/client/_astro/{modules-info.d9373e21.js → modules-info.0debb0b0.js} +1 -1
  77. package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.a0432a8e.js +1 -0
  78. package/packages/storefront/dist/client/_astro/{runtime-dom.esm-bundler.00313542.js → runtime-dom.esm-bundler.0e5774ce.js} +1 -1
  79. package/packages/storefront/dist/client/fallback/index.html +10 -10
  80. package/packages/storefront/dist/client/sw.js +1 -1
  81. package/packages/storefront/dist/server/chunks/{astro.89bd9221.mjs → astro.0f5b754a.mjs} +871 -826
  82. package/packages/storefront/dist/server/chunks/pages/{all.23de4e5c.mjs → all.671e6bc1.mjs} +367 -466
  83. package/packages/storefront/dist/server/chunks/{prerender.f40361a3.mjs → prerender.fd8cdc24.mjs} +0 -0
  84. package/packages/storefront/dist/server/entry.mjs +20 -12
  85. package/packages/storefront/package.json +11 -11
  86. package/packages/storefront/src/lib/components/Drawer.vue +48 -45
  87. package/packages/storefront/src/lib/components/ProductCard.vue +1 -1
  88. package/packages/storefront/src/lib/components/ShopHeader.vue +42 -13
  89. package/packages/storefront/src/lib/components/ShopSidenav.vue +26 -0
  90. package/packages/storefront/src/lib/composables/use-pitch-bar.ts +27 -0
  91. package/packages/storefront/src/lib/composables/use-sticky-header.ts +111 -0
  92. package/packages/storefront/src/lib/layouts/BaseBody.astro +3 -1
  93. package/packages/storefront/src/lib/layouts/PagesHeader.astro +16 -25
  94. package/packages/types/index.ts +1 -0
  95. package/packages/types/modules/@checkout:params.d.ts +1 -5
  96. package/packages/types/modules/apply_discount:params.d.ts +1 -1
  97. package/packages/types/modules/apply_discount:response.d.ts +1 -1
  98. package/packages/types/modules/calculate_shipping:params.d.ts +1 -1
  99. package/packages/types/modules/calculate_shipping:response.d.ts +1 -1
  100. package/packages/types/modules/create_transaction:params.d.ts +6 -2
  101. package/packages/types/modules/create_transaction:response.d.ts +1 -1
  102. package/packages/types/modules/list_payments:params.d.ts +1 -1
  103. package/packages/types/modules/list_payments:response.d.ts +1 -1
  104. package/packages/types/package.json +1 -1
  105. package/packages/storefront/dist/client/_astro/PitchBar.209c6645.js +0 -1
  106. package/packages/storefront/dist/client/_astro/Prices.6fbcb5ac.js +0 -1
  107. package/packages/storefront/dist/client/_astro/Prices.vue_vue_type_script_setup_true_lang.44f23680.js +0 -1
  108. package/packages/storefront/dist/client/_astro/ProductCard.ee5eee91.js +0 -1
  109. package/packages/storefront/dist/client/_astro/ShopHeader.b801c785.js +0 -1
  110. package/packages/storefront/dist/client/_astro/index.844a4059.js +0 -1
  111. package/packages/storefront/dist/client/_astro/index.90df622b.css +0 -1
  112. package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.f04cee62.js +0 -1
  113. package/packages/storefront/dist/client/_astro/use-component-variant.58788b6e.js +0 -1
  114. package/packages/storefront/src/lib/components/PitchBar.vue +0 -66
  115. package/packages/storefront/src/lib/components/Prices.vue +0 -176
  116. package/packages/storefront/src/lib/components/StickyHeader.vue +0 -84
  117. package/packages/storefront/src/lib/composables/use-component-variant.ts +0 -17
@@ -235,748 +235,902 @@ function* getSetCookiesFromResponse(response) {
235
235
  }
236
236
  }
237
237
 
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
- }
238
+ const defineErrors = (errs) => errs;
239
+ const AstroErrorData = defineErrors({
240
+ UnknownCompilerError: {
241
+ title: "Unknown compiler error.",
242
+ code: 1e3,
243
+ hint: "This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler."
244
+ },
245
+ StaticRedirectNotAvailable: {
246
+ title: "`Astro.redirect` is not available in static mode.",
247
+ code: 3001,
248
+ message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
249
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
250
+ },
251
+ ClientAddressNotAvailable: {
252
+ title: "`Astro.clientAddress` is not available in current adapter.",
253
+ code: 3002,
254
+ message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
255
+ },
256
+ StaticClientAddressNotAvailable: {
257
+ title: "`Astro.clientAddress` is not available in static mode.",
258
+ code: 3003,
259
+ message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
260
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
261
+ },
262
+ NoMatchingStaticPathFound: {
263
+ title: "No static path found for requested path.",
264
+ code: 3004,
265
+ message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
266
+ hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
267
+ },
268
+ OnlyResponseCanBeReturned: {
269
+ title: "Invalid type returned by Astro page.",
270
+ code: 3005,
271
+ 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.`,
272
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
273
+ },
274
+ MissingMediaQueryDirective: {
275
+ title: "Missing value for `client:media` directive.",
276
+ code: 3006,
277
+ message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
278
+ },
279
+ NoMatchingRenderer: {
280
+ title: "No matching renderer found.",
281
+ code: 3007,
282
+ message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
327
283
 
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
- }
284
+ ${validRenderersCount > 0 ? `There ${plural ? "are." : "is."} ${validRenderersCount} renderer${plural ? "s." : ""} configured in your \`astro.config.mjs\` file,
285
+ 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.`}`}`,
286
+ hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
337
287
 
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
- }
288
+ See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`
289
+ },
290
+ NoClientEntrypoint: {
291
+ title: "No client entrypoint specified in renderer.",
292
+ code: 3008,
293
+ message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
294
+ hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
295
+ },
296
+ NoClientOnlyHint: {
297
+ title: "Missing hint on client:only directive.",
298
+ code: 3009,
299
+ message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
300
+ 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`
301
+ },
302
+ InvalidGetStaticPathParam: {
303
+ title: "Invalid value returned by a `getStaticPaths` path.",
304
+ code: 3010,
305
+ message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
306
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
307
+ },
308
+ InvalidGetStaticPathsReturn: {
309
+ title: "Invalid value returned by getStaticPaths.",
310
+ code: 3011,
311
+ message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
312
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
313
+ },
314
+ GetStaticPathsRemovedRSSHelper: {
315
+ title: "getStaticPaths RSS helper is not available anymore.",
316
+ code: 3012,
317
+ message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
318
+ hint: "See https://docs.astro.build/en/guides/rss/ for more information."
319
+ },
320
+ GetStaticPathsExpectedParams: {
321
+ title: "Missing params property on `getStaticPaths` route.",
322
+ code: 3013,
323
+ message: "Missing or empty required `params` property on `getStaticPaths` route.",
324
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
325
+ },
326
+ GetStaticPathsInvalidRouteParam: {
327
+ title: "Invalid value for `getStaticPaths` route parameter.",
328
+ code: 3014,
329
+ message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
330
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
331
+ },
332
+ GetStaticPathsRequired: {
333
+ title: "`getStaticPaths()` function required for dynamic routes.",
334
+ code: 3015,
335
+ message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
336
+ hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
376
337
 
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";
338
+ 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;\`.
339
+ See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
340
+ },
341
+ ReservedSlotName: {
342
+ title: "Invalid slot name.",
343
+ code: 3016,
344
+ message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
345
+ },
346
+ NoAdapterInstalled: {
347
+ title: "Cannot use Server-side Rendering without an adapter.",
348
+ code: 3017,
349
+ message: `Cannot use \`output: 'server'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
350
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
351
+ },
352
+ NoMatchingImport: {
353
+ title: "No import found for component.",
354
+ code: 3018,
355
+ message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
356
+ hint: "Please make sure the component is properly imported."
357
+ },
358
+ InvalidPrerenderExport: {
359
+ title: "Invalid prerender export.",
360
+ code: 3019,
361
+ message: (prefix, suffix) => {
362
+ let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
363
+ if (prefix !== "const")
364
+ msg += `
365
+ Expected \`const\` declaration but got \`${prefix}\`.`;
366
+ if (suffix !== "true")
367
+ msg += `
368
+ Expected \`true\` value but got \`${suffix}\`.`;
369
+ return msg;
370
+ },
371
+ hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."
372
+ },
373
+ InvalidComponentArgs: {
374
+ title: "Invalid component arguments.",
375
+ code: 3020,
376
+ message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
377
+ hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
378
+ },
379
+ UnknownViteError: {
380
+ title: "Unknown Vite Error.",
381
+ code: 4e3
382
+ },
383
+ FailedToLoadModuleSSR: {
384
+ title: "Could not import file.",
385
+ code: 4001,
386
+ message: (importName) => `Could not import \`${importName}\`.`,
387
+ hint: "This is often caused by a typo in the import path. Please make sure the file exists."
388
+ },
389
+ InvalidGlob: {
390
+ title: "Invalid glob pattern.",
391
+ code: 4002,
392
+ message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
393
+ hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
394
+ },
395
+ UnknownCSSError: {
396
+ title: "Unknown CSS Error.",
397
+ code: 5e3
398
+ },
399
+ CSSSyntaxError: {
400
+ title: "CSS Syntax Error.",
401
+ code: 5001
402
+ },
403
+ UnknownMarkdownError: {
404
+ title: "Unknown Markdown Error.",
405
+ code: 6e3
406
+ },
407
+ MarkdownFrontmatterParseError: {
408
+ title: "Failed to parse Markdown frontmatter.",
409
+ code: 6001
410
+ },
411
+ InvalidFrontmatterInjectionError: {
412
+ title: "Invalid frontmatter injection.",
413
+ code: 6003,
414
+ 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`.',
415
+ hint: "See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."
416
+ },
417
+ MdxIntegrationMissingError: {
418
+ title: "MDX integration missing.",
419
+ code: 6004,
420
+ message: (file) => `Unable to render ${file}. Ensure that the \`@astrojs/mdx\` integration is installed.`,
421
+ hint: "See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"
422
+ },
423
+ UnknownConfigError: {
424
+ title: "Unknown configuration error.",
425
+ code: 7e3
426
+ },
427
+ ConfigNotFound: {
428
+ title: "Specified configuration file not found.",
429
+ code: 7001,
430
+ message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
431
+ },
432
+ ConfigLegacyKey: {
433
+ title: "Legacy configuration detected.",
434
+ code: 7002,
435
+ message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
436
+ hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
437
+ },
438
+ UnknownCLIError: {
439
+ title: "Unknown CLI Error.",
440
+ code: 8e3
441
+ },
442
+ GenerateContentTypesError: {
443
+ title: "Failed to generate content types.",
444
+ code: 8001,
445
+ message: "`astro sync` command failed to generate content collection types.",
446
+ hint: "Check your `src/content/config.*` file for typos."
447
+ },
448
+ UnknownContentCollectionError: {
449
+ title: "Unknown Content Collection Error.",
450
+ code: 9e3
451
+ },
452
+ InvalidContentEntryFrontmatterError: {
453
+ title: "Content entry frontmatter does not match schema.",
454
+ code: 9001,
455
+ message: (collection, entryId, error) => {
456
+ return [
457
+ `${String(collection)} \u2192 ${String(entryId)} frontmatter does not match collection schema.`,
458
+ ...error.errors.map((zodError) => zodError.message)
459
+ ].join("\n");
460
+ },
461
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."
462
+ },
463
+ InvalidContentEntrySlugError: {
464
+ title: "Invalid content entry slug.",
465
+ code: 9002,
466
+ message: (collection, entryId) => {
467
+ return `${String(collection)} \u2192 ${String(
468
+ entryId
469
+ )} has an invalid slug. \`slug\` must be a string.`;
470
+ },
471
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
472
+ },
473
+ ContentSchemaContainsSlugError: {
474
+ title: "Content Schema should not contain `slug`.",
475
+ code: 9003,
476
+ message: (collection) => {
477
+ return `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collection} collection schema.`;
478
+ },
479
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
480
+ },
481
+ UnknownError: {
482
+ title: "Unknown Error.",
483
+ code: 99999
484
+ }
485
+ });
486
+
487
+ function normalizeLF(code) {
488
+ return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
407
489
  }
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
- }
490
+ function getErrorDataByCode(code) {
491
+ const entry = Object.entries(AstroErrorData).find((data) => data[1].code === code);
492
+ if (entry) {
493
+ return {
494
+ name: entry[0],
495
+ data: entry[1]
496
+ };
417
497
  }
418
498
  }
419
- function* unescapeChunks(iterable) {
420
- for (const chunk of iterable) {
421
- yield unescapeHTML(chunk);
499
+
500
+ function codeFrame(src, loc) {
501
+ if (!loc || loc.line === void 0 || loc.column === void 0) {
502
+ return "";
503
+ }
504
+ const lines = normalizeLF(src).split("\n").map((ln) => ln.replace(/\t/g, " "));
505
+ const visibleLines = [];
506
+ for (let n = -2; n <= 2; n++) {
507
+ if (lines[loc.line + n])
508
+ visibleLines.push(loc.line + n);
509
+ }
510
+ let gutterWidth = 0;
511
+ for (const lineNo of visibleLines) {
512
+ let w = `> ${lineNo}`;
513
+ if (w.length > gutterWidth)
514
+ gutterWidth = w.length;
515
+ }
516
+ let output = "";
517
+ for (const lineNo of visibleLines) {
518
+ const isFocusedLine = lineNo === loc.line - 1;
519
+ output += isFocusedLine ? "> " : " ";
520
+ output += `${lineNo + 1} | ${lines[lineNo]}
521
+ `;
522
+ if (isFocusedLine)
523
+ output += `${Array.from({ length: gutterWidth }).join(" ")} | ${Array.from({
524
+ length: loc.column
525
+ }).join(" ")}^
526
+ `;
422
527
  }
528
+ return output;
423
529
  }
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);
530
+
531
+ class AstroError extends Error {
532
+ constructor(props, ...params) {
533
+ var _a;
534
+ super(...params);
535
+ this.type = "AstroError";
536
+ const { code, name, title, message, stack, location, hint, frame } = props;
537
+ this.errorCode = code;
538
+ if (name && name !== "Error") {
539
+ this.name = name;
540
+ } else {
541
+ this.name = ((_a = getErrorDataByCode(this.errorCode)) == null ? void 0 : _a.name) ?? "UnknownError";
439
542
  }
543
+ this.title = title;
544
+ if (message)
545
+ this.message = message;
546
+ this.stack = stack ? stack : this.stack;
547
+ this.loc = location;
548
+ this.hint = hint;
549
+ this.frame = frame;
550
+ }
551
+ setErrorCode(errorCode) {
552
+ this.errorCode = errorCode;
553
+ }
554
+ setLocation(location) {
555
+ this.loc = location;
556
+ }
557
+ setName(name) {
558
+ this.name = name;
559
+ }
560
+ setMessage(message) {
561
+ this.message = message;
562
+ }
563
+ setHint(hint) {
564
+ this.hint = hint;
565
+ }
566
+ setFrame(source, location) {
567
+ this.frame = codeFrame(source, location);
568
+ }
569
+ static is(err) {
570
+ return err.type === "AstroError";
440
571
  }
441
- return markHTMLString(str);
442
572
  }
443
573
 
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];
574
+ function validateArgs(args) {
575
+ if (args.length !== 3)
576
+ return false;
577
+ if (!args[0] || typeof args[0] !== "object")
578
+ return false;
579
+ return true;
449
580
  }
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);
581
+ function baseCreateComponent(cb, moduleId) {
582
+ var _a;
583
+ const name = ((_a = moduleId == null ? void 0 : moduleId.split("/").pop()) == null ? void 0 : _a.replace(".astro", "")) ?? "";
584
+ const fn = (...args) => {
585
+ if (!validateArgs(args)) {
586
+ throw new AstroError({
587
+ ...AstroErrorData.InvalidComponentArgs,
588
+ message: AstroErrorData.InvalidComponentArgs.message(name)
589
+ });
590
+ }
591
+ return cb(...args);
592
+ };
593
+ Object.defineProperty(fn, "name", { value: name, writable: false });
594
+ fn.isAstroComponentFactory = true;
595
+ fn.moduleId = moduleId;
596
+ return fn;
484
597
  }
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;
598
+ function createComponentWithOptions(opts) {
599
+ const cb = baseCreateComponent(opts.factory, opts.moduleId);
600
+ cb.propagation = opts.propagation;
601
+ return cb;
491
602
  }
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;
603
+ function createComponent(arg1, moduleId) {
604
+ if (typeof arg1 === "function") {
605
+ return baseCreateComponent(arg1, moduleId);
606
+ } else {
607
+ return createComponentWithOptions(arg1);
506
608
  }
507
609
  }
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
610
 
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"));`;
611
+ const ASTRO_VERSION = "2.0.6";
529
612
 
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))}`;
613
+ function createAstroGlobFn() {
614
+ const globHandler = (importMetaGlobResult, globValue) => {
615
+ let allEntries = [...Object.values(importMetaGlobResult)];
616
+ if (allEntries.length === 0) {
617
+ throw new Error(`Astro.glob(${JSON.stringify(globValue())}) - no matches found.`);
618
+ }
619
+ return Promise.all(allEntries.map((fn) => fn()));
620
+ };
621
+ return globHandler;
622
+ }
623
+ function createAstro(site) {
624
+ return {
625
+ site: site ? new URL(site) : void 0,
626
+ generator: `Astro v${ASTRO_VERSION}`,
627
+ glob: createAstroGlobFn()
628
+ };
629
+ }
531
630
 
532
- function determineIfNeedsHydrationScript(result) {
533
- if (result._metadata.hasHydrationScript) {
534
- return false;
631
+ function getHandlerFromModule(mod, method) {
632
+ if (mod[method]) {
633
+ return mod[method];
535
634
  }
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;
635
+ if (method === "delete" && mod["del"]) {
636
+ return mod["del"];
548
637
  }
549
- result._metadata.hasDirectives.add(directive);
550
- return true;
638
+ if (mod["all"]) {
639
+ return mod["all"];
640
+ }
641
+ return void 0;
551
642
  }
552
- function getDirectiveScriptText(directive) {
553
- if (!(directive in hydrationScripts)) {
554
- throw new Error(`Unknown directive: ${directive}`);
643
+ async function renderEndpoint(mod, context, ssr) {
644
+ var _a;
645
+ const { request, params } = context;
646
+ const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
647
+ const handler = getHandlerFromModule(mod, chosenMethod);
648
+ if (!ssr && ssr === false && chosenMethod && chosenMethod !== "get") {
649
+ console.warn(`
650
+ ${chosenMethod} requests are not available when building a static site. Update your config to output: 'server' to handle ${chosenMethod} requests.`);
555
651
  }
556
- const directiveScriptText = hydrationScripts[directive];
557
- return directiveScriptText;
652
+ if (!handler || typeof handler !== "function") {
653
+ let response = new Response(null, {
654
+ status: 404,
655
+ headers: {
656
+ "X-Astro-Response": "Not-Found"
657
+ }
658
+ });
659
+ return response;
660
+ }
661
+ if (handler.length > 1) {
662
+ console.warn(`
663
+ API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of:
664
+
665
+ export function get({ params, request }) {
666
+ //...
558
667
  }
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>`;
668
+
669
+ Update your code to remove this warning.`);
565
670
  }
566
- return "";
671
+ const proxy = new Proxy(context, {
672
+ get(target, prop) {
673
+ if (prop in target) {
674
+ return Reflect.get(target, prop);
675
+ } else if (prop in params) {
676
+ console.warn(`
677
+ API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of:
678
+
679
+ export function get({ params }) {
680
+ // ...
567
681
  }
568
682
 
569
- const headAndContentSym = Symbol.for("astro.headAndContent");
570
- function isHeadAndContent(obj) {
571
- return typeof obj === "object" && !!obj[headAndContentSym];
683
+ Update your code to remove this warning.`);
684
+ return Reflect.get(params, prop);
685
+ } else {
686
+ return void 0;
687
+ }
688
+ }
689
+ });
690
+ return handler.call(mod, proxy, request);
572
691
  }
573
692
 
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
- }
693
+ function serializeListValue(value) {
694
+ const hash = {};
695
+ push(value);
696
+ return Object.keys(hash).join(" ");
697
+ function push(item) {
698
+ if (item && typeof item.forEach === "function")
699
+ item.forEach(push);
700
+ else if (item === Object(item))
701
+ Object.keys(item).forEach((name) => {
702
+ if (item[name])
703
+ push(name);
704
+ });
705
+ else {
706
+ item = item === false || item == null ? "" : String(item).trim();
707
+ if (item) {
708
+ item.split(/\s+/).forEach((name) => {
709
+ hash[name] = true;
588
710
  });
589
711
  }
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
712
  }
601
713
  }
602
714
  }
603
- function isRenderTemplateResult(obj) {
604
- return typeof obj === "object" && !!obj[renderTemplateResultSym];
715
+ function isPromise(value) {
716
+ return !!value && typeof value === "object" && typeof value.then === "function";
605
717
  }
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
- }
718
+ async function* streamAsyncIterator(stream) {
719
+ const reader = stream.getReader();
720
+ try {
721
+ while (true) {
722
+ const { done, value } = await reader.read();
723
+ if (done)
724
+ return;
725
+ yield value;
621
726
  }
727
+ } finally {
728
+ reader.releaseLock();
622
729
  }
623
730
  }
624
- function renderTemplate(htmlParts, ...expressions) {
625
- return new RenderTemplateResult(htmlParts, expressions);
626
- }
627
731
 
628
- function isAstroComponentFactory(obj) {
629
- return obj == null ? false : obj.isAstroComponentFactory === true;
732
+ const escapeHTML = escape;
733
+ class HTMLBytes extends Uint8Array {
630
734
  }
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;
735
+ Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
736
+ get() {
737
+ return "HTMLBytes";
636
738
  }
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);
739
+ });
740
+ class HTMLString extends String {
741
+ get [Symbol.toStringTag]() {
742
+ return "HTMLString";
641
743
  }
642
- return parts.toString();
643
744
  }
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);
745
+ const markHTMLString = (value) => {
746
+ if (value instanceof HTMLString) {
747
+ return value;
648
748
  }
649
- return hint === "in-tree" || hint === "self";
749
+ if (typeof value === "string") {
750
+ return new HTMLString(value);
751
+ }
752
+ return value;
753
+ };
754
+ function isHTMLString(value) {
755
+ return Object.prototype.toString.call(value) === "[object HTMLString]";
650
756
  }
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
757
+ function markHTMLBytes(bytes) {
758
+ return new HTMLBytes(bytes);
759
+ }
760
+ function hasGetReader(obj) {
761
+ return typeof obj.getReader === "function";
762
+ }
763
+ async function* unescapeChunksAsync(iterable) {
764
+ if (hasGetReader(iterable)) {
765
+ for await (const chunk of streamAsyncIterator(iterable)) {
766
+ yield unescapeHTML(chunk);
767
+ }
768
+ } else {
769
+ for await (const chunk of iterable) {
770
+ yield unescapeHTML(chunk);
771
+ }
892
772
  }
893
- });
773
+ }
774
+ function* unescapeChunks(iterable) {
775
+ for (const chunk of iterable) {
776
+ yield unescapeHTML(chunk);
777
+ }
778
+ }
779
+ function unescapeHTML(str) {
780
+ if (!!str && typeof str === "object") {
781
+ if (str instanceof Uint8Array) {
782
+ return markHTMLBytes(str);
783
+ } else if (str instanceof Response && str.body) {
784
+ const body = str.body;
785
+ return unescapeChunksAsync(body);
786
+ } else if (typeof str.then === "function") {
787
+ return Promise.resolve(str).then((value) => {
788
+ return unescapeHTML(value);
789
+ });
790
+ } else if (Symbol.iterator in str) {
791
+ return unescapeChunks(str);
792
+ } else if (Symbol.asyncIterator in str || hasGetReader(str)) {
793
+ return unescapeChunksAsync(str);
794
+ }
795
+ }
796
+ return markHTMLString(str);
797
+ }
894
798
 
895
- function normalizeLF(code) {
896
- return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
799
+ const AstroJSX = "astro:jsx";
800
+ const Empty = Symbol("empty");
801
+ const toSlotName = (slotAttr) => slotAttr;
802
+ function isVNode(vnode) {
803
+ return vnode && typeof vnode === "object" && vnode[AstroJSX];
897
804
  }
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
- };
805
+ function transformSlots(vnode) {
806
+ if (typeof vnode.type === "string")
807
+ return vnode;
808
+ const slots = {};
809
+ if (isVNode(vnode.props.children)) {
810
+ const child = vnode.props.children;
811
+ if (!isVNode(child))
812
+ return;
813
+ if (!("slot" in child.props))
814
+ return;
815
+ const name = toSlotName(child.props.slot);
816
+ slots[name] = [child];
817
+ slots[name]["$$slot"] = true;
818
+ delete child.props.slot;
819
+ delete vnode.props.children;
820
+ }
821
+ if (Array.isArray(vnode.props.children)) {
822
+ vnode.props.children = vnode.props.children.map((child) => {
823
+ if (!isVNode(child))
824
+ return child;
825
+ if (!("slot" in child.props))
826
+ return child;
827
+ const name = toSlotName(child.props.slot);
828
+ if (Array.isArray(slots[name])) {
829
+ slots[name].push(child);
830
+ } else {
831
+ slots[name] = [child];
832
+ slots[name]["$$slot"] = true;
833
+ }
834
+ delete child.props.slot;
835
+ return Empty;
836
+ }).filter((v) => v !== Empty);
837
+ }
838
+ Object.assign(vnode.props, slots);
839
+ }
840
+ function markRawChildren(child) {
841
+ if (typeof child === "string")
842
+ return markHTMLString(child);
843
+ if (Array.isArray(child))
844
+ return child.map((c) => markRawChildren(c));
845
+ return child;
846
+ }
847
+ function transformSetDirectives(vnode) {
848
+ if (!("set:html" in vnode.props || "set:text" in vnode.props))
849
+ return;
850
+ if ("set:html" in vnode.props) {
851
+ const children = markRawChildren(vnode.props["set:html"]);
852
+ delete vnode.props["set:html"];
853
+ Object.assign(vnode.props, { children });
854
+ return;
905
855
  }
856
+ if ("set:text" in vnode.props) {
857
+ const children = vnode.props["set:text"];
858
+ delete vnode.props["set:text"];
859
+ Object.assign(vnode.props, { children });
860
+ return;
861
+ }
862
+ }
863
+ function createVNode(type, props) {
864
+ const vnode = {
865
+ [Renderer]: "astro:jsx",
866
+ [AstroJSX]: true,
867
+ type,
868
+ props: props ?? {}
869
+ };
870
+ transformSetDirectives(vnode);
871
+ transformSlots(vnode);
872
+ return vnode;
906
873
  }
907
874
 
908
- function codeFrame(src, loc) {
909
- if (!loc || loc.line === void 0 || loc.column === void 0) {
910
- return "";
875
+ 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"));`;
876
+
877
+ var load_prebuilt_default = `(self.Astro=self.Astro||{}).load=a=>{(async()=>await(await a())())()},window.dispatchEvent(new Event("astro:load"));`;
878
+
879
+ 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"));`;
880
+
881
+ var only_prebuilt_default = `(self.Astro=self.Astro||{}).only=t=>{(async()=>await(await t())())()},window.dispatchEvent(new Event("astro:only"));`;
882
+
883
+ 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"));`;
884
+
885
+ 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))}`;
886
+
887
+ function determineIfNeedsHydrationScript(result) {
888
+ if (result._metadata.hasHydrationScript) {
889
+ return false;
911
890
  }
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);
891
+ return result._metadata.hasHydrationScript = true;
892
+ }
893
+ const hydrationScripts = {
894
+ idle: idle_prebuilt_default,
895
+ load: load_prebuilt_default,
896
+ only: only_prebuilt_default,
897
+ media: media_prebuilt_default,
898
+ visible: visible_prebuilt_default
899
+ };
900
+ function determinesIfNeedsDirectiveScript(result, directive) {
901
+ if (result._metadata.hasDirectives.has(directive)) {
902
+ return false;
917
903
  }
918
- let gutterWidth = 0;
919
- for (const lineNo of visibleLines) {
920
- let w = `> ${lineNo}`;
921
- if (w.length > gutterWidth)
922
- gutterWidth = w.length;
904
+ result._metadata.hasDirectives.add(directive);
905
+ return true;
906
+ }
907
+ function getDirectiveScriptText(directive) {
908
+ if (!(directive in hydrationScripts)) {
909
+ throw new Error(`Unknown directive: ${directive}`);
910
+ }
911
+ const directiveScriptText = hydrationScripts[directive];
912
+ return directiveScriptText;
913
+ }
914
+ function getPrescripts(type, directive) {
915
+ switch (type) {
916
+ case "both":
917
+ return `<style>astro-island,astro-slot{display:contents}</style><script>${getDirectiveScriptText(directive) + astro_island_prebuilt_default}<\/script>`;
918
+ case "directive":
919
+ return `<script>${getDirectiveScriptText(directive)}<\/script>`;
923
920
  }
921
+ return "";
922
+ }
923
+
924
+ const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
925
+ 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;
926
+ const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
927
+ const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
928
+ const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
929
+ const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
930
+ if (/[^\w]|\s/.test(match))
931
+ return "";
932
+ return index === 0 ? match : match.toUpperCase();
933
+ });
934
+ const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&#38;").replace(/"/g, "&#34;") : value;
935
+ const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
936
+ const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => `${kebab(k)}:${v}`).join(";");
937
+ function defineScriptVars(vars) {
924
938
  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(" ")}^
939
+ for (const [key, value] of Object.entries(vars)) {
940
+ output += `const ${toIdent(key)} = ${JSON.stringify(value)};
934
941
  `;
935
942
  }
936
- return output;
943
+ return markHTMLString(output);
944
+ }
945
+ function formatList(values) {
946
+ if (values.length === 1) {
947
+ return values[0];
948
+ }
949
+ return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
950
+ }
951
+ function addAttribute(value, key, shouldEscape = true) {
952
+ if (value == null) {
953
+ return "";
954
+ }
955
+ if (value === false) {
956
+ if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
957
+ return markHTMLString(` ${key}="false"`);
958
+ }
959
+ return "";
960
+ }
961
+ if (STATIC_DIRECTIVES.has(key)) {
962
+ console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
963
+
964
+ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
965
+ return "";
966
+ }
967
+ if (key === "class:list") {
968
+ const listValue = toAttributeString(serializeListValue(value), shouldEscape);
969
+ if (listValue === "") {
970
+ return "";
971
+ }
972
+ return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
973
+ }
974
+ if (key === "style" && !(value instanceof HTMLString) && typeof value === "object") {
975
+ return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
976
+ }
977
+ if (key === "className") {
978
+ return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
979
+ }
980
+ if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
981
+ return markHTMLString(` ${key}`);
982
+ } else {
983
+ return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
984
+ }
985
+ }
986
+ function internalSpreadAttributes(values, shouldEscape = true) {
987
+ let output = "";
988
+ for (const [key, value] of Object.entries(values)) {
989
+ output += addAttribute(value, key, shouldEscape);
990
+ }
991
+ return markHTMLString(output);
992
+ }
993
+ function renderElement$1(name, { props: _props, children = "" }, shouldEscape = true) {
994
+ const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
995
+ if (defineVars) {
996
+ if (name === "style") {
997
+ delete props["is:global"];
998
+ delete props["is:scoped"];
999
+ }
1000
+ if (name === "script") {
1001
+ delete props.hoist;
1002
+ children = defineScriptVars(defineVars) + "\n" + children;
1003
+ }
1004
+ }
1005
+ if ((children == null || children == "") && voidElementNames.test(name)) {
1006
+ return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
1007
+ }
1008
+ return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
937
1009
  }
1010
+ const ScopeFlags = {
1011
+ Astro: 1 << 0,
1012
+ JSX: 1 << 1,
1013
+ Slot: 1 << 2
1014
+ };
938
1015
 
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";
1016
+ const uniqueElements = (item, index, all) => {
1017
+ const props = JSON.stringify(item.props);
1018
+ const children = item.children;
1019
+ return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
1020
+ };
1021
+ function renderAllHeadContent(result) {
1022
+ result._metadata.hasRenderedHead = true;
1023
+ const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement$1("style", style));
1024
+ result.styles.clear();
1025
+ const scripts = Array.from(result.scripts).filter(uniqueElements).map((script, i) => {
1026
+ return renderElement$1("script", script, false);
1027
+ });
1028
+ const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement$1("link", link, false));
1029
+ let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
1030
+ if (result.extraHead.length > 0) {
1031
+ for (const part of result.extraHead) {
1032
+ content += part;
950
1033
  }
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
1034
  }
959
- setErrorCode(errorCode) {
960
- this.errorCode = errorCode;
1035
+ return markHTMLString(content);
1036
+ }
1037
+ function* renderHead(result) {
1038
+ yield { type: "head", result };
1039
+ }
1040
+ function* maybeRenderHead(result) {
1041
+ if (result._metadata.hasRenderedHead) {
1042
+ return;
961
1043
  }
962
- setLocation(location) {
963
- this.loc = location;
1044
+ switch (result.scope) {
1045
+ case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro: {
1046
+ return;
1047
+ }
964
1048
  }
965
- setName(name) {
966
- this.name = name;
1049
+ yield { type: "head", result };
1050
+ }
1051
+
1052
+ const headAndContentSym = Symbol.for("astro.headAndContent");
1053
+ function isHeadAndContent(obj) {
1054
+ return typeof obj === "object" && !!obj[headAndContentSym];
1055
+ }
1056
+
1057
+ var _a$1;
1058
+ const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
1059
+ class RenderTemplateResult {
1060
+ constructor(htmlParts, expressions) {
1061
+ this[_a$1] = true;
1062
+ this.htmlParts = htmlParts;
1063
+ this.error = void 0;
1064
+ this.expressions = expressions.map((expression) => {
1065
+ if (isPromise(expression)) {
1066
+ return Promise.resolve(expression).catch((err) => {
1067
+ if (!this.error) {
1068
+ this.error = err;
1069
+ throw err;
1070
+ }
1071
+ });
1072
+ }
1073
+ return expression;
1074
+ });
967
1075
  }
968
- setMessage(message) {
969
- this.message = message;
1076
+ async *[(_a$1 = renderTemplateResultSym, Symbol.asyncIterator)]() {
1077
+ const { htmlParts, expressions } = this;
1078
+ for (let i = 0; i < htmlParts.length; i++) {
1079
+ const html = htmlParts[i];
1080
+ const expression = expressions[i];
1081
+ yield markHTMLString(html);
1082
+ yield* renderChild(expression);
1083
+ }
970
1084
  }
971
- setHint(hint) {
972
- this.hint = hint;
1085
+ }
1086
+ function isRenderTemplateResult(obj) {
1087
+ return typeof obj === "object" && !!obj[renderTemplateResultSym];
1088
+ }
1089
+ async function* renderAstroTemplateResult(component) {
1090
+ for await (const value of component) {
1091
+ if (value || value === 0) {
1092
+ for await (const chunk of renderChild(value)) {
1093
+ switch (chunk.type) {
1094
+ case "directive": {
1095
+ yield chunk;
1096
+ break;
1097
+ }
1098
+ default: {
1099
+ yield markHTMLString(chunk);
1100
+ break;
1101
+ }
1102
+ }
1103
+ }
1104
+ }
973
1105
  }
974
- setFrame(source, location) {
975
- this.frame = codeFrame(source, location);
1106
+ }
1107
+ function renderTemplate(htmlParts, ...expressions) {
1108
+ return new RenderTemplateResult(htmlParts, expressions);
1109
+ }
1110
+
1111
+ function isAstroComponentFactory(obj) {
1112
+ return obj == null ? false : obj.isAstroComponentFactory === true;
1113
+ }
1114
+ async function renderToString(result, componentFactory, props, children) {
1115
+ result.scope |= ScopeFlags.Astro;
1116
+ const factoryResult = await componentFactory(result, props, children);
1117
+ if (factoryResult instanceof Response) {
1118
+ const response = factoryResult;
1119
+ throw response;
976
1120
  }
977
- static is(err) {
978
- return err.type === "AstroError";
1121
+ let parts = new HTMLParts();
1122
+ const templateResult = isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
1123
+ for await (const chunk of renderAstroTemplateResult(templateResult)) {
1124
+ parts.append(chunk, result);
1125
+ }
1126
+ return parts.toString();
1127
+ }
1128
+ function isAPropagatingComponent(result, factory) {
1129
+ let hint = factory.propagation || "none";
1130
+ if (factory.moduleId && result.propagation.has(factory.moduleId) && hint === "none") {
1131
+ hint = result.propagation.get(factory.moduleId);
979
1132
  }
1133
+ return hint === "in-tree" || hint === "self";
980
1134
  }
981
1135
 
982
1136
  const PROP_TYPE = {
@@ -1278,13 +1432,14 @@ class SlotString extends HTMLString {
1278
1432
  function isSlotString(str) {
1279
1433
  return !!str[slotString];
1280
1434
  }
1281
- async function renderSlot(_result, slotted, fallback) {
1435
+ async function renderSlot(result, slotted, fallback) {
1282
1436
  if (slotted) {
1437
+ result.scope |= ScopeFlags.Slot;
1283
1438
  let iterator = renderChild(slotted);
1284
1439
  let content = "";
1285
1440
  let instructions = null;
1286
1441
  for await (const chunk of iterator) {
1287
- if (chunk.type === "directive") {
1442
+ if (typeof chunk.type === "string") {
1288
1443
  if (instructions === null) {
1289
1444
  instructions = [];
1290
1445
  }
@@ -1293,6 +1448,7 @@ async function renderSlot(_result, slotted, fallback) {
1293
1448
  content += chunk;
1294
1449
  }
1295
1450
  }
1451
+ result.scope &= ~ScopeFlags.Slot;
1296
1452
  return markHTMLString(new SlotString(content, instructions));
1297
1453
  }
1298
1454
  return fallback;
@@ -1323,33 +1479,41 @@ const Renderer = Symbol.for("astro:renderer");
1323
1479
  const encoder = new TextEncoder();
1324
1480
  const decoder = new TextDecoder();
1325
1481
  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 "";
1482
+ if (typeof chunk.type === "string") {
1483
+ const instruction = chunk;
1484
+ switch (instruction.type) {
1485
+ case "directive": {
1486
+ const { hydration } = instruction;
1487
+ let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
1488
+ let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
1489
+ let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
1490
+ if (prescriptType) {
1491
+ let prescripts = getPrescripts(prescriptType, hydration.directive);
1492
+ return markHTMLString(prescripts);
1493
+ } else {
1494
+ return "";
1495
+ }
1496
+ }
1497
+ case "head": {
1498
+ if (result._metadata.hasRenderedHead) {
1499
+ return "";
1500
+ }
1501
+ return renderAllHeadContent(result);
1337
1502
  }
1338
1503
  }
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);
1346
- }
1504
+ } else {
1505
+ if (isSlotString(chunk)) {
1506
+ let out = "";
1507
+ const c = chunk;
1508
+ if (c.instructions) {
1509
+ for (const instr of c.instructions) {
1510
+ out += stringifyChunk(result, instr);
1347
1511
  }
1348
- out += chunk.toString();
1349
- return out;
1350
1512
  }
1351
- return chunk.toString();
1513
+ out += chunk.toString();
1514
+ return out;
1352
1515
  }
1516
+ return chunk.toString();
1353
1517
  }
1354
1518
  }
1355
1519
  class HTMLParts {
@@ -1374,7 +1538,8 @@ function chunkToByteArray(result, chunk) {
1374
1538
  if (chunk instanceof Uint8Array) {
1375
1539
  return chunk;
1376
1540
  }
1377
- return encoder.encode(stringifyChunk(result, chunk));
1541
+ let stringified = stringifyChunk(result, chunk);
1542
+ return encoder.encode(stringified.toString());
1378
1543
  }
1379
1544
 
1380
1545
  const ClientOnlyPlaceholder = "astro-client-only";
@@ -1445,12 +1610,13 @@ Did you forget to import the component or is it possible there is a typo?`);
1445
1610
  props[key] = value;
1446
1611
  }
1447
1612
  }
1613
+ result.scope |= ScopeFlags.JSX;
1448
1614
  return markHTMLString(await renderToString(result, vnode.type, props, slots));
1449
1615
  }
1450
1616
  case (!vnode.type && vnode.type !== 0):
1451
1617
  return "";
1452
1618
  case (typeof vnode.type === "string" && vnode.type !== ClientOnlyPlaceholder):
1453
- return markHTMLString(await renderElement$1(result, vnode.type, vnode.props ?? {}));
1619
+ return markHTMLString(await renderElement(result, vnode.type, vnode.props ?? {}));
1454
1620
  }
1455
1621
  if (vnode.type) {
1456
1622
  let extractSlots2 = function(child) {
@@ -1555,7 +1721,7 @@ Did you forget to import the component or is it possible there is a typo?`);
1555
1721
  }
1556
1722
  return markHTMLString(`${vnode}`);
1557
1723
  }
1558
- async function renderElement$1(result, tag, { children, ...props }) {
1724
+ async function renderElement(result, tag, { children, ...props }) {
1559
1725
  return markHTMLString(
1560
1726
  `<${tag}${spreadAttributes(props)}${markHTMLString(
1561
1727
  (children == null || children == "") && voidElementNames.test(tag) ? `/>` : `>${children == null ? "" : await renderJSX(result, children)}</${tag}>`
@@ -1644,93 +1810,6 @@ function shorthash(text) {
1644
1810
  return sign + result;
1645
1811
  }
1646
1812
 
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
1813
  function componentIsHTMLElement(Component) {
1735
1814
  return typeof HTMLElement !== "undefined" && HTMLElement.isPrototypeOf(Component);
1736
1815
  }
@@ -1943,8 +2022,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
1943
2022
  }
1944
2023
  if (isPage || (renderer == null ? void 0 : renderer.name) === "astro:jsx") {
1945
2024
  yield html;
1946
- } else {
2025
+ } else if (html && html.length > 0) {
1947
2026
  yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, ""));
2027
+ } else {
2028
+ yield "";
1948
2029
  }
1949
2030
  }();
1950
2031
  }
@@ -1984,7 +2065,7 @@ ${serializeProps(
1984
2065
  yield* slotInstructions;
1985
2066
  }
1986
2067
  yield { type: "directive", hydration, result };
1987
- yield markHTMLString(renderElement("astro-island", island, false));
2068
+ yield markHTMLString(renderElement$1("astro-island", island, false));
1988
2069
  }
1989
2070
  return renderAll();
1990
2071
  }
@@ -2032,43 +2113,6 @@ function renderComponentToIterable(result, displayName, Component, props, slots
2032
2113
  return renderResult;
2033
2114
  }
2034
2115
 
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
2116
  var __accessCheck$2 = (obj, member, msg) => {
2073
2117
  if (!member.has(obj))
2074
2118
  throw TypeError("Cannot " + msg);
@@ -2567,6 +2611,7 @@ function createResult(args) {
2567
2611
  propagation: args.propagation ?? /* @__PURE__ */ new Map(),
2568
2612
  propagators: /* @__PURE__ */ new Map(),
2569
2613
  extraHead: [],
2614
+ scope: 0,
2570
2615
  cookies,
2571
2616
  createAstro(astroGlobal, props, slots) {
2572
2617
  const astroSlots = new Slots(result, slots, args.logging);