astro 2.9.7 → 3.0.0-beta.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 (161) hide show
  1. package/astro.js +2 -2
  2. package/components/ViewTransitions.astro +65 -12
  3. package/dist/@types/astro.d.ts +68 -7
  4. package/dist/@types/astro.js +1 -0
  5. package/dist/assets/generate.js +7 -3
  6. package/dist/assets/image-endpoint.d.ts +1 -1
  7. package/dist/assets/image-endpoint.js +3 -3
  8. package/dist/assets/internal.js +1 -2
  9. package/dist/assets/services/noop.d.ts +3 -0
  10. package/dist/assets/services/noop.js +17 -0
  11. package/dist/assets/services/vendor/squoosh/image_data.js +3 -0
  12. package/dist/assets/services/vendor/squoosh/impl.js +2 -3
  13. package/dist/assets/services/vendor/squoosh/utils/workerPool.js +4 -0
  14. package/dist/assets/vendor/image-size/types/tiff.js +1 -1
  15. package/dist/assets/vendor/queue/queue.d.ts +3 -3
  16. package/dist/assets/vite-plugin-assets.d.ts +1 -1
  17. package/dist/assets/vite-plugin-assets.js +1 -23
  18. package/dist/cli/add/index.js +6 -9
  19. package/dist/cli/build/index.js +1 -1
  20. package/dist/cli/check/index.d.ts +2 -78
  21. package/dist/cli/check/index.js +23 -275
  22. package/dist/cli/dev/index.js +1 -1
  23. package/dist/cli/index.js +7 -13
  24. package/dist/cli/info/index.js +3 -4
  25. package/dist/cli/install-package.d.ts +7 -0
  26. package/dist/cli/install-package.js +102 -0
  27. package/dist/cli/preview/index.js +1 -1
  28. package/dist/cli/sync/index.js +1 -1
  29. package/dist/content/runtime-assets.js +1 -2
  30. package/dist/content/runtime.js +3 -5
  31. package/dist/content/server-listeners.js +1 -2
  32. package/dist/content/types-generator.js +8 -8
  33. package/dist/content/utils.js +3 -4
  34. package/dist/content/vite-plugin-content-assets.js +4 -6
  35. package/dist/content/vite-plugin-content-imports.js +1 -1
  36. package/dist/content/vite-plugin-content-virtual-mod.js +5 -6
  37. package/dist/core/app/index.js +5 -3
  38. package/dist/core/app/node.d.ts +1 -1
  39. package/dist/core/app/node.js +7 -2
  40. package/dist/core/build/css-asset-name.js +2 -4
  41. package/dist/core/build/generate.js +10 -17
  42. package/dist/core/build/graph.js +3 -4
  43. package/dist/core/build/index.js +8 -1
  44. package/dist/core/build/internal.js +2 -2
  45. package/dist/core/build/plugin.js +2 -4
  46. package/dist/core/build/plugins/plugin-analyzer.js +6 -9
  47. package/dist/core/build/plugins/plugin-component-entry.js +2 -4
  48. package/dist/core/build/plugins/plugin-css.js +6 -9
  49. package/dist/core/build/plugins/plugin-hoisted-scripts.js +2 -3
  50. package/dist/core/build/plugins/plugin-internals.js +1 -2
  51. package/dist/core/build/plugins/plugin-pages.js +5 -1
  52. package/dist/core/build/plugins/plugin-ssr.js +12 -8
  53. package/dist/core/build/static-build.js +8 -12
  54. package/dist/core/client-directive/build.js +1 -2
  55. package/dist/core/compile/compile.js +2 -1
  56. package/dist/core/compile/style.js +2 -3
  57. package/dist/core/config/schema.d.ts +8 -0
  58. package/dist/core/config/schema.js +11 -3
  59. package/dist/core/config/settings.js +3 -3
  60. package/dist/core/config/timer.js +5 -6
  61. package/dist/core/constants.js +1 -1
  62. package/dist/core/cookies/cookies.d.ts +5 -5
  63. package/dist/core/cookies/cookies.js +9 -9
  64. package/dist/core/create-vite.js +6 -28
  65. package/dist/core/dev/container.d.ts +0 -1
  66. package/dist/core/dev/container.js +0 -5
  67. package/dist/core/dev/dev.js +2 -3
  68. package/dist/core/dev/index.d.ts +1 -1
  69. package/dist/core/dev/index.js +1 -2
  70. package/dist/core/dev/restart.d.ts +1 -4
  71. package/dist/core/dev/restart.js +15 -19
  72. package/dist/core/endpoint/dev/index.js +1 -1
  73. package/dist/core/endpoint/index.js +3 -4
  74. package/dist/core/errors/dev/utils.js +12 -16
  75. package/dist/core/errors/dev/vite.js +11 -13
  76. package/dist/core/errors/errors-data.d.ts +21 -0
  77. package/dist/core/errors/errors-data.js +21 -0
  78. package/dist/core/errors/errors.js +12 -17
  79. package/dist/core/errors/overlay.js +7 -8
  80. package/dist/core/errors/utils.js +1 -1
  81. package/dist/core/fs/index.js +1 -1
  82. package/dist/core/logger/console.js +1 -1
  83. package/dist/core/logger/core.d.ts +26 -6
  84. package/dist/core/logger/core.js +54 -8
  85. package/dist/core/logger/node.d.ts +4 -4
  86. package/dist/core/logger/node.js +6 -6
  87. package/dist/core/messages.js +4 -5
  88. package/dist/core/module-loader/vite.js +2 -2
  89. package/dist/core/polyfill.js +12 -4
  90. package/dist/core/redirects/helpers.js +3 -3
  91. package/dist/core/render/core.js +1 -4
  92. package/dist/core/render/params-and-props.js +2 -3
  93. package/dist/core/render/result.js +1 -2
  94. package/dist/core/render/route-cache.d.ts +1 -2
  95. package/dist/core/render/route-cache.js +6 -11
  96. package/dist/core/routing/manifest/create.js +2 -6
  97. package/dist/core/routing/params.js +1 -1
  98. package/dist/core/routing/validation.js +7 -8
  99. package/dist/core/sync/index.js +1 -1
  100. package/dist/core/util.js +1 -1
  101. package/dist/events/error.js +1 -1
  102. package/dist/events/session.js +12 -13
  103. package/dist/integrations/astroFeaturesValidation.d.ts +14 -0
  104. package/dist/integrations/astroFeaturesValidation.js +109 -0
  105. package/dist/integrations/index.d.ts +3 -1
  106. package/dist/integrations/index.js +96 -31
  107. package/dist/jsx/babel.js +1 -2
  108. package/dist/prerender/metadata.js +1 -2
  109. package/dist/runtime/client/hmr.js +1 -2
  110. package/dist/runtime/server/astro-component.js +1 -2
  111. package/dist/runtime/server/astro-island.js +53 -55
  112. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  113. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  114. package/dist/runtime/server/endpoint.d.ts +2 -1
  115. package/dist/runtime/server/endpoint.js +21 -27
  116. package/dist/runtime/server/hydration.js +9 -0
  117. package/dist/runtime/server/jsx.js +3 -2
  118. package/dist/runtime/server/render/astro/instance.js +6 -3
  119. package/dist/runtime/server/render/astro/render-template.js +4 -3
  120. package/dist/runtime/server/render/astro/render.js +3 -3
  121. package/dist/runtime/server/render/common.js +1 -1
  122. package/dist/runtime/server/render/component.js +11 -13
  123. package/dist/runtime/server/render/dom.js +1 -1
  124. package/dist/runtime/server/render/page.js +2 -3
  125. package/dist/runtime/server/render/slot.js +2 -1
  126. package/dist/runtime/server/render/util.js +1 -2
  127. package/dist/runtime/server/transition.d.ts +1 -0
  128. package/dist/runtime/server/transition.js +1 -0
  129. package/dist/transitions/vite-plugin-transitions.js +1 -0
  130. package/dist/vite-plugin-astro/compile.js +2 -3
  131. package/dist/vite-plugin-astro/hmr.js +3 -5
  132. package/dist/vite-plugin-astro/index.js +1 -1
  133. package/dist/vite-plugin-astro/metadata.js +1 -2
  134. package/dist/vite-plugin-astro-postprocess/index.js +1 -1
  135. package/dist/vite-plugin-astro-server/base.js +1 -2
  136. package/dist/vite-plugin-astro-server/controller.js +2 -3
  137. package/dist/vite-plugin-astro-server/css.js +1 -1
  138. package/dist/vite-plugin-astro-server/request.js +1 -1
  139. package/dist/vite-plugin-astro-server/route.js +1 -2
  140. package/dist/vite-plugin-astro-server/scripts.js +2 -3
  141. package/dist/vite-plugin-astro-server/vite.js +1 -1
  142. package/dist/vite-plugin-config-alias/index.js +1 -1
  143. package/dist/vite-plugin-env/index.js +2 -2
  144. package/dist/vite-plugin-head/index.js +4 -6
  145. package/dist/vite-plugin-html/index.js +1 -2
  146. package/dist/vite-plugin-html/transform/index.js +1 -1
  147. package/dist/vite-plugin-html/transform/slots.js +5 -6
  148. package/dist/vite-plugin-html/transform/utils.js +1 -2
  149. package/dist/vite-plugin-jsx/import-source.js +1 -2
  150. package/dist/vite-plugin-jsx/index.js +1 -1
  151. package/dist/vite-plugin-jsx/tag.js +4 -6
  152. package/dist/vite-plugin-markdown/index.js +1 -2
  153. package/dist/vite-plugin-scanner/index.js +2 -1
  154. package/dist/vite-plugin-scanner/scan.js +1 -1
  155. package/dist/vite-plugin-scripts/index.js +1 -1
  156. package/dist/vite-plugin-scripts/page-ssr.js +2 -2
  157. package/package.json +13 -22
  158. package/tsconfigs/base.json +8 -6
  159. package/tsconfigs/strict.json +2 -3
  160. package/dist/cli/check/print.d.ts +0 -2
  161. package/dist/cli/check/print.js +0 -95
@@ -1,11 +1,13 @@
1
- var _a;
2
1
  import { markHTMLString } from "../../escape.js";
3
2
  import { isPromise } from "../../util.js";
4
3
  import { renderChild } from "../any.js";
5
4
  const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
6
5
  class RenderTemplateResult {
6
+ [renderTemplateResultSym] = true;
7
+ htmlParts;
8
+ expressions;
9
+ error;
7
10
  constructor(htmlParts, expressions) {
8
- this[_a] = true;
9
11
  this.htmlParts = htmlParts;
10
12
  this.error = void 0;
11
13
  this.expressions = expressions.map((expression) => {
@@ -31,7 +33,6 @@ class RenderTemplateResult {
31
33
  }
32
34
  }
33
35
  }
34
- _a = renderTemplateResultSym;
35
36
  function isRenderTemplateResult(obj) {
36
37
  return typeof obj === "object" && !!obj[renderTemplateResultSym];
37
38
  }
@@ -72,7 +72,7 @@ async function renderToReadableStream(result, componentFactory, props, children,
72
72
  } catch (e) {
73
73
  if (AstroError.is(e) && !e.loc) {
74
74
  e.setLocation({
75
- file: route == null ? void 0 : route.component
75
+ file: route?.component
76
76
  });
77
77
  }
78
78
  setTimeout(() => controller.error(e), 0);
@@ -88,9 +88,9 @@ async function callComponentAsTemplateResultOrResponse(result, componentFactory,
88
88
  } else if (!isRenderTemplateResult(factoryResult)) {
89
89
  throw new AstroError({
90
90
  ...AstroErrorData.OnlyResponseCanBeReturned,
91
- message: AstroErrorData.OnlyResponseCanBeReturned.message(route == null ? void 0 : route.route, typeof factoryResult),
91
+ message: AstroErrorData.OnlyResponseCanBeReturned.message(route?.route, typeof factoryResult),
92
92
  location: {
93
- file: route == null ? void 0 : route.component
93
+ file: route?.component
94
94
  }
95
95
  });
96
96
  }
@@ -1,4 +1,4 @@
1
- import { markHTMLString } from "../escape.js";
1
+ import { HTMLBytes, HTMLString, markHTMLString } from "../escape.js";
2
2
  import {
3
3
  determineIfNeedsHydrationScript,
4
4
  determinesIfNeedsDirectiveScript,
@@ -1,5 +1,5 @@
1
1
  import { AstroError, AstroErrorData } from "../../../core/errors/index.js";
2
- import { markHTMLString } from "../escape.js";
2
+ import { HTMLBytes, markHTMLString } from "../escape.js";
3
3
  import { extractDirectives, generateHydrateScript } from "../hydration.js";
4
4
  import { serializeProps } from "../serialize.js";
5
5
  import { shorthash } from "../shorthash.js";
@@ -21,7 +21,7 @@ import { formatList, internalSpreadAttributes, renderElement, voidElementNames }
21
21
  const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
22
22
  const rendererAliases = /* @__PURE__ */ new Map([["solid", "solid-js"]]);
23
23
  function guessRenderers(componentUrl) {
24
- const extname = componentUrl == null ? void 0 : componentUrl.split(".").pop();
24
+ const extname = componentUrl?.split(".").pop();
25
25
  switch (extname) {
26
26
  case "svelte":
27
27
  return ["@astrojs/svelte"];
@@ -54,7 +54,6 @@ function removeStaticAstroSlot(html, supportsAstroStaticSlot) {
54
54
  return html.replace(exp, "");
55
55
  }
56
56
  async function renderFrameworkComponent(result, displayName, Component, _props, slots = {}) {
57
- var _a, _b, _c;
58
57
  if (!Component && !_props["client:only"]) {
59
58
  throw new Error(
60
59
  `Unable to render ${displayName} because it is ${Component}!
@@ -130,7 +129,7 @@ Did you forget to import the component or is it possible there is a typo?`
130
129
  renderer = validRenderers[0];
131
130
  }
132
131
  if (!renderer) {
133
- const extname = (_a = metadata.componentUrl) == null ? void 0 : _a.split(".").pop();
132
+ const extname = metadata.componentUrl?.split(".").pop();
134
133
  renderer = renderers.filter(
135
134
  ({ name }) => name === `@astrojs/${extname}` || name === extname
136
135
  )[0];
@@ -155,7 +154,7 @@ Did you forget to import the component or is it possible there is a typo?`
155
154
  ...AstroErrorData.NoMatchingRenderer,
156
155
  message: AstroErrorData.NoMatchingRenderer.message(
157
156
  metadata.displayName,
158
- (_b = metadata == null ? void 0 : metadata.componentUrl) == null ? void 0 : _b.split(".").pop(),
157
+ metadata?.componentUrl?.split(".").pop(),
159
158
  plural,
160
159
  validRenderers.length
161
160
  ),
@@ -188,7 +187,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
188
187
  }
189
188
  } else {
190
189
  if (metadata.hydrate === "only") {
191
- html = await renderSlotToString(result, slots == null ? void 0 : slots.fallback);
190
+ html = await renderSlotToString(result, slots?.fallback);
192
191
  } else {
193
192
  ({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
194
193
  { result },
@@ -230,18 +229,17 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
230
229
  if (!hydration) {
231
230
  return {
232
231
  render(destination) {
233
- var _a2;
234
232
  if (slotInstructions) {
235
233
  for (const instruction of slotInstructions) {
236
234
  destination.write(instruction);
237
235
  }
238
236
  }
239
- if (isPage || (renderer == null ? void 0 : renderer.name) === "astro:jsx") {
237
+ if (isPage || renderer?.name === "astro:jsx") {
240
238
  destination.write(html);
241
239
  } else if (html && html.length > 0) {
242
240
  destination.write(
243
241
  markHTMLString(
244
- removeStaticAstroSlot(html, ((_a2 = renderer == null ? void 0 : renderer.ssr) == null ? void 0 : _a2.supportsAstroStaticSlot) ?? false)
242
+ removeStaticAstroSlot(html, renderer?.ssr?.supportsAstroStaticSlot ?? false)
245
243
  )
246
244
  );
247
245
  }
@@ -264,7 +262,7 @@ ${serializeProps(
264
262
  if (html) {
265
263
  if (Object.keys(children).length > 0) {
266
264
  for (const key of Object.keys(children)) {
267
- let tagName = ((_c = renderer == null ? void 0 : renderer.ssr) == null ? void 0 : _c.supportsAstroStaticSlot) ? !!metadata.hydrate ? "astro-slot" : "astro-static-slot" : "astro-slot";
265
+ let tagName = renderer?.ssr?.supportsAstroStaticSlot ? !!metadata.hydrate ? "astro-slot" : "astro-static-slot" : "astro-slot";
268
266
  let expectedHTML = key === "default" ? `<${tagName}>` : `<${tagName} name="${key}">`;
269
267
  if (!html.includes(expectedHTML)) {
270
268
  unrenderedSlots.push(key);
@@ -300,7 +298,7 @@ function sanitizeElementName(tag) {
300
298
  return tag.trim().split(unsafe)[0].trim();
301
299
  }
302
300
  async function renderFragmentComponent(result, slots = {}) {
303
- const children = await renderSlotToString(result, slots == null ? void 0 : slots.default);
301
+ const children = await renderSlotToString(result, slots?.default);
304
302
  return {
305
303
  render(destination) {
306
304
  if (children == null)
@@ -381,7 +379,7 @@ async function renderComponentToString(result, displayName, Component, props, sl
381
379
  } catch (e) {
382
380
  if (AstroError.is(e) && !e.loc) {
383
381
  e.setLocation({
384
- file: route == null ? void 0 : route.component
382
+ file: route?.component
385
383
  });
386
384
  }
387
385
  throw e;
@@ -389,7 +387,7 @@ async function renderComponentToString(result, displayName, Component, props, sl
389
387
  return str;
390
388
  }
391
389
  function nonAstroPageNeedsHeadInjection(pageComponent) {
392
- return !!(pageComponent == null ? void 0 : pageComponent[needsHeadRenderingSymbol]);
390
+ return !!pageComponent?.[needsHeadRenderingSymbol];
393
391
  }
394
392
  export {
395
393
  renderComponent,
@@ -11,7 +11,7 @@ async function renderHTMLElement(result, constructor, props, slots) {
11
11
  attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
12
12
  }
13
13
  return markHTMLString(
14
- `<${name}${attrHTML}>${await renderSlotToString(result, slots == null ? void 0 : slots.default)}</${name}>`
14
+ `<${name}${attrHTML}>${await renderSlotToString(result, slots?.default)}</${name}>`
15
15
  );
16
16
  }
17
17
  function getHTMLElementName(constructor) {
@@ -4,9 +4,8 @@ import { isAstroComponentFactory } from "./astro/index.js";
4
4
  import { renderToReadableStream, renderToString } from "./astro/render.js";
5
5
  import { encoder } from "./common.js";
6
6
  async function renderPage(result, componentFactory, props, children, streaming, route) {
7
- var _a, _b;
8
7
  if (!isAstroComponentFactory(componentFactory)) {
9
- result._metadata.headInTree = ((_a = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _a.containsHead) ?? false;
8
+ result._metadata.headInTree = result.componentMetadata.get(componentFactory.moduleId)?.containsHead ?? false;
10
9
  const pageProps = { ...props ?? {}, "server:root": true };
11
10
  const str = await renderComponentToString(
12
11
  result,
@@ -25,7 +24,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
25
24
  ])
26
25
  });
27
26
  }
28
- result._metadata.headInTree = ((_b = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _b.containsHead) ?? false;
27
+ result._metadata.headInTree = result.componentMetadata.get(componentFactory.moduleId)?.containsHead ?? false;
29
28
  let body;
30
29
  if (streaming) {
31
30
  body = await renderToReadableStream(result, componentFactory, props, children, true, route);
@@ -3,13 +3,14 @@ import { renderChild } from "./any.js";
3
3
  import { chunkToString } from "./common.js";
4
4
  const slotString = Symbol.for("astro:slot-string");
5
5
  class SlotString extends HTMLString {
6
+ instructions;
7
+ [slotString];
6
8
  constructor(content, instructions) {
7
9
  super(content);
8
10
  this.instructions = instructions;
9
11
  this[slotString] = true;
10
12
  }
11
13
  }
12
- slotString;
13
14
  function isSlotString(str) {
14
15
  return !!str[slotString];
15
16
  }
@@ -20,10 +20,9 @@ const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => {
20
20
  return `${k}:${v}`;
21
21
  }).join(";");
22
22
  function defineScriptVars(vars) {
23
- var _a;
24
23
  let output = "";
25
24
  for (const [key, value] of Object.entries(vars)) {
26
- output += `const ${toIdent(key)} = ${(_a = JSON.stringify(value)) == null ? void 0 : _a.replace(
25
+ output += `const ${toIdent(key)} = ${JSON.stringify(value)?.replace(
27
26
  /<\/script>/g,
28
27
  "\\x3C/script>"
29
28
  )};
@@ -1,2 +1,3 @@
1
1
  import type { SSRResult, TransitionAnimationValue } from '../../@types/astro';
2
+ export declare function createTransitionScope(result: SSRResult, hash: string): string;
2
3
  export declare function renderTransition(result: SSRResult, hash: string, animationName: TransitionAnimationValue | undefined, transitionName: string): string;
@@ -129,5 +129,6 @@ function toTimeValue(num) {
129
129
  return typeof num === "number" ? num + "ms" : num;
130
130
  }
131
131
  export {
132
+ createTransitionScope,
132
133
  renderTransition
133
134
  };
@@ -1,3 +1,4 @@
1
+ import * as vite from "vite";
1
2
  import { AstroError } from "../core/errors/index.js";
2
3
  const virtualModuleId = "astro:transitions";
3
4
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
@@ -65,8 +65,7 @@ async function enhanceCompileError({
65
65
  id,
66
66
  source
67
67
  }) {
68
- var _a;
69
- const lineText = (_a = err.loc) == null ? void 0 : _a.lineText;
68
+ const lineText = err.loc?.lineText;
70
69
  const scannedFrontmatter = FRONTMATTER_PARSE_REGEXP.exec(source);
71
70
  if (scannedFrontmatter) {
72
71
  const frontmatter = scannedFrontmatter[1].replace(/\breturn\b/g, "throw");
@@ -79,7 +78,7 @@ async function enhanceCompileError({
79
78
  sourcemap: false
80
79
  });
81
80
  } catch (frontmatterErr) {
82
- if (frontmatterErr == null ? void 0 : frontmatterErr.message) {
81
+ if (frontmatterErr?.message) {
83
82
  frontmatterErr.message = frontmatterErr.message.replace(
84
83
  "end of file",
85
84
  "end of frontmatter"
@@ -1,5 +1,6 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  import {
3
+ cachedCompilation,
3
4
  invalidateCompilation,
4
5
  isCached
5
6
  } from "../core/compile/index.js";
@@ -9,7 +10,7 @@ import { isAstroScript } from "./query.js";
9
10
  const PKG_PREFIX = fileURLToPath(new URL("../../", import.meta.url));
10
11
  const E2E_PREFIX = fileURLToPath(new URL("../../e2e", import.meta.url));
11
12
  const isPkgFile = (id) => {
12
- return (id == null ? void 0 : id.startsWith(PKG_PREFIX)) && !id.startsWith(E2E_PREFIX);
13
+ return id?.startsWith(PKG_PREFIX) && !id.startsWith(E2E_PREFIX);
13
14
  };
14
15
  async function handleHotUpdate(ctx, { config, logging, compile, source }) {
15
16
  let isStyleOnlyChange = false;
@@ -58,10 +59,7 @@ async function handleHotUpdate(ctx, { config, logging, compile, source }) {
58
59
  const file = ctx.file.replace(config.root.pathname, "/");
59
60
  if (isStyleOnlyChange) {
60
61
  info(logging, "astro", msg.hmr({ file, style: true }));
61
- return mods.filter((mod) => {
62
- var _a;
63
- return mod.id !== ctx.file && !((_a = mod.id) == null ? void 0 : _a.endsWith(".ts"));
64
- });
62
+ return mods.filter((mod) => mod.id !== ctx.file && !mod.id?.endsWith(".ts"));
65
63
  }
66
64
  for (const mod of mods) {
67
65
  for (const imp of mod.importedModules) {
@@ -54,7 +54,7 @@ function astro({ settings, logging }) {
54
54
  if (typeof query.index === "undefined") {
55
55
  throw new Error(`Requests for hoisted scripts must include an index`);
56
56
  }
57
- if (opts == null ? void 0 : opts.ssr) {
57
+ if (opts?.ssr) {
58
58
  return {
59
59
  code: `/* client hoisted script, empty in SSR: ${id} */`
60
60
  };
@@ -1,6 +1,5 @@
1
1
  function getAstroMetadata(modInfo) {
2
- var _a;
3
- if ((_a = modInfo.meta) == null ? void 0 : _a.astro) {
2
+ if (modInfo.meta?.astro) {
4
3
  return modInfo.meta.astro;
5
4
  }
6
5
  return void 0;
@@ -37,7 +37,7 @@ function astro() {
37
37
  if (s) {
38
38
  return {
39
39
  code: s.toString(),
40
- map: s.generateMap({ hires: true })
40
+ map: s.generateMap({ hires: "boundary" })
41
41
  };
42
42
  }
43
43
  }
@@ -10,7 +10,6 @@ function baseMiddleware(settings, logging) {
10
10
  const devRoot = site ? site.pathname : devRootURL.pathname;
11
11
  const devRootReplacement = devRoot.endsWith("/") ? "/" : "";
12
12
  return function devBaseMiddleware(req, res, next) {
13
- var _a;
14
13
  const url = req.url;
15
14
  const pathname = decodeURI(new URL(url, "http://localhost").pathname);
16
15
  if (pathname.startsWith(devRoot)) {
@@ -22,7 +21,7 @@ function baseMiddleware(settings, logging) {
22
21
  const html = subpathNotUsedTemplate(devRoot, pathname);
23
22
  return writeHtmlResponse(res, 404, html);
24
23
  }
25
- if ((_a = req.headers.accept) == null ? void 0 : _a.includes("text/html")) {
24
+ if (req.headers.accept?.includes("text/html")) {
26
25
  log404(logging, pathname);
27
26
  const html = notFoundTemplate({
28
27
  statusCode: 404,
@@ -19,9 +19,8 @@ function createBaseController({ reload }) {
19
19
  }
20
20
  };
21
21
  const onHMRError = (payload) => {
22
- var _a, _b;
23
- let msg = ((_a = payload == null ? void 0 : payload.err) == null ? void 0 : _a.message) ?? "Unknown error";
24
- let stack = ((_b = payload == null ? void 0 : payload.err) == null ? void 0 : _b.stack) ?? "Unknown stack";
22
+ let msg = payload?.err?.message ?? "Unknown error";
23
+ let stack = payload?.err?.stack ?? "Unknown stack";
25
24
  let error = new Error(msg);
26
25
  Object.defineProperty(error, "stack", {
27
26
  value: stack
@@ -13,7 +13,7 @@ async function getStylesForURL(filePath, loader, mode) {
13
13
  continue;
14
14
  }
15
15
  if (mode === "development" && // only inline in development
16
- typeof (ssrModule == null ? void 0 : ssrModule.default) === "string") {
16
+ typeof ssrModule?.default === "string") {
17
17
  importedStylesMap.set(importedModule.url, ssrModule.default);
18
18
  } else {
19
19
  importedCssUrls.add(importedModule.url);
@@ -50,7 +50,7 @@ async function handleRequest({
50
50
  pathname,
51
51
  async run() {
52
52
  const matchedRoute = await matchRoute(pathname, env, manifestData);
53
- const resolvedPathname = (matchedRoute == null ? void 0 : matchedRoute.resolvedPathname) ?? pathname;
53
+ const resolvedPathname = matchedRoute?.resolvedPathname ?? pathname;
54
54
  return await handleRoute({
55
55
  matchedRoute,
56
56
  url,
@@ -98,7 +98,6 @@ async function handleRoute({
98
98
  incomingResponse,
99
99
  manifest
100
100
  }) {
101
- var _a;
102
101
  const { logging, settings } = env;
103
102
  if (!matchedRoute) {
104
103
  return handle404Response(origin, incomingRequest, incomingResponse);
@@ -150,7 +149,7 @@ async function handleRoute({
150
149
  mod,
151
150
  env
152
151
  });
153
- const onRequest = (_a = options.middleware) == null ? void 0 : _a.onRequest;
152
+ const onRequest = options.middleware?.onRequest;
154
153
  const result = await tryRenderRoute(route.type, renderContext, env, mod, onRequest);
155
154
  if (isEndpointResult(result, route.type)) {
156
155
  if (result.type === "response") {
@@ -16,12 +16,11 @@ async function getScriptsForURL(filePath, root, loader) {
16
16
  return elements;
17
17
  }
18
18
  function addHoistedScripts(set, info, root) {
19
- var _a, _b;
20
- if (!((_a = info == null ? void 0 : info.meta) == null ? void 0 : _a.astro)) {
19
+ if (!info?.meta?.astro) {
21
20
  return;
22
21
  }
23
22
  let id = info.id;
24
- const astro = (_b = info == null ? void 0 : info.meta) == null ? void 0 : _b.astro;
23
+ const astro = info?.meta?.astro;
25
24
  for (let i = 0; i < astro.scripts.length; i++) {
26
25
  let scriptId = `${id}?astro&type=script&index=${i}&lang.ts`;
27
26
  scriptId = rootRelativePath(root, scriptId);
@@ -37,7 +37,7 @@ async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ ne
37
37
  if (isFileTypeNeedingSSR && // Should not SSR a module with ?astroPropagatedAssets
38
38
  !isPropagationStoppingPoint) {
39
39
  const mod = loader.getModuleById(importedModule.id);
40
- if (!(mod == null ? void 0 : mod.ssrModule)) {
40
+ if (!mod?.ssrModule) {
41
41
  try {
42
42
  await loader.import(importedModule.id);
43
43
  } catch {
@@ -64,7 +64,7 @@ function patchCreateResolver(config, prePlugin) {
64
64
  const id = args2[0];
65
65
  const importer = args2[1];
66
66
  const ssr = args2[3];
67
- if (importer == null ? void 0 : importer.includes("node_modules")) {
67
+ if (importer?.includes("node_modules")) {
68
68
  return resolver.apply(_createResolver, args2);
69
69
  }
70
70
  const fakePluginContext = {
@@ -63,7 +63,7 @@ function envVitePlugin({ settings }) {
63
63
  viteConfig = resolvedConfig;
64
64
  },
65
65
  async transform(source, id, options) {
66
- if (!(options == null ? void 0 : options.ssr) || !source.includes("import.meta.env")) {
66
+ if (!options?.ssr || !source.includes("import.meta.env")) {
67
67
  return;
68
68
  }
69
69
  let s;
@@ -98,7 +98,7 @@ function envVitePlugin({ settings }) {
98
98
  if (s) {
99
99
  return {
100
100
  code: s.toString(),
101
- map: s.generateMap({ hires: true })
101
+ map: s.generateMap({ hires: "boundary" })
102
102
  };
103
103
  }
104
104
  }
@@ -9,13 +9,13 @@ function configHeadVitePlugin() {
9
9
  seen.add(id);
10
10
  const mod = server.moduleGraph.getModuleById(id);
11
11
  const info = this.getModuleInfo(id);
12
- if (info == null ? void 0 : info.meta.astro) {
12
+ if (info?.meta.astro) {
13
13
  const astroMetadata = getAstroMetadata(info);
14
14
  if (astroMetadata) {
15
15
  Reflect.set(astroMetadata, prop, value);
16
16
  }
17
17
  }
18
- for (const parent of (mod == null ? void 0 : mod.importers) || []) {
18
+ for (const parent of mod?.importers || []) {
19
19
  if (parent.id) {
20
20
  propagateMetadata.call(this, parent.id, prop, value, seen);
21
21
  }
@@ -27,12 +27,11 @@ function configHeadVitePlugin() {
27
27
  server = _server;
28
28
  },
29
29
  transform(source, id) {
30
- var _a;
31
30
  if (!server) {
32
31
  return;
33
32
  }
34
33
  let info = this.getModuleInfo(id);
35
- if (info && ((_a = getAstroMetadata(info)) == null ? void 0 : _a.containsHead)) {
34
+ if (info && getAstroMetadata(info)?.containsHead) {
36
35
  propagateMetadata.call(this, id, "containsHead", true);
37
36
  }
38
37
  if (injectExp.test(source)) {
@@ -50,7 +49,6 @@ function astroHeadBuildPlugin(internals) {
50
49
  vitePlugin: {
51
50
  name: "astro:head-metadata-build",
52
51
  generateBundle(_opts, bundle) {
53
- var _a;
54
52
  const map = internals.componentMetadata;
55
53
  function getOrCreateMetadata(id) {
56
54
  if (map.has(id))
@@ -67,7 +65,7 @@ function astroHeadBuildPlugin(internals) {
67
65
  continue;
68
66
  for (const [id, mod] of Object.entries(output.modules)) {
69
67
  const modinfo = this.getModuleInfo(id);
70
- if (modinfo && ((_a = getAstroMetadata(modinfo)) == null ? void 0 : _a.containsHead)) {
68
+ if (modinfo && getAstroMetadata(modinfo)?.containsHead) {
71
69
  for (const [pageInfo] of getTopLevelPages(id, this)) {
72
70
  let metadata = getOrCreateMetadata(pageInfo.id);
73
71
  metadata.containsHead = true;
@@ -3,8 +3,7 @@ function html() {
3
3
  return {
4
4
  name: "astro:html",
5
5
  options(options) {
6
- var _a;
7
- options.plugins = (_a = options.plugins) == null ? void 0 : _a.filter((p) => p.name !== "vite:build-html");
6
+ options.plugins = options.plugins?.filter((p) => p.name !== "vite:build-html");
8
7
  },
9
8
  async transform(source, id) {
10
9
  if (!id.endsWith(".html"))
@@ -13,7 +13,7 @@ async function transform(code, id) {
13
13
  s.append('`\n }\nrender["astro:html"] = true;\nexport default render;');
14
14
  return {
15
15
  code: s.toString(),
16
- map: s.generateMap()
16
+ map: s.generateMap({ hires: "boundary" })
17
17
  };
18
18
  }
19
19
  export {
@@ -3,16 +3,15 @@ import { escape } from "./utils.js";
3
3
  const rehypeSlots = ({ s }) => {
4
4
  return (tree, file) => {
5
5
  visit(tree, (node) => {
6
- var _a, _b, _c, _d, _e, _f;
7
6
  if (node.type === "element" && node.tagName === "slot") {
8
- if (typeof ((_a = node.properties) == null ? void 0 : _a["is:inline"]) !== "undefined")
7
+ if (typeof node.properties?.["is:inline"] !== "undefined")
9
8
  return;
10
- const name = ((_b = node.properties) == null ? void 0 : _b["name"]) ?? "default";
11
- const start = ((_c = node.position) == null ? void 0 : _c.start.offset) ?? 0;
12
- const end = ((_d = node.position) == null ? void 0 : _d.end.offset) ?? 0;
9
+ const name = node.properties?.["name"] ?? "default";
10
+ const start = node.position?.start.offset ?? 0;
11
+ const end = node.position?.end.offset ?? 0;
13
12
  const first = node.children.at(0) ?? node;
14
13
  const last = node.children.at(-1) ?? node;
15
- const text = file.value.slice(((_e = first.position) == null ? void 0 : _e.start.offset) ?? 0, ((_f = last.position) == null ? void 0 : _f.end.offset) ?? 0).toString();
14
+ const text = file.value.slice(first.position?.start.offset ?? 0, last.position?.end.offset ?? 0).toString();
16
15
  s.overwrite(start, end, `\${${SLOT_PREFIX}["${name}"] ?? \`${escape(text).trim()}\`}`);
17
16
  }
18
17
  });
@@ -1,8 +1,7 @@
1
1
  const splitAttrsTokenizer = /([\$\{\}\@a-z0-9_\:\-]*)\s*?=\s*?(['"]?)(.*?)\2\s+/gim;
2
2
  function replaceAttribute(s, node, key, newValue) {
3
- var _a, _b;
4
3
  splitAttrsTokenizer.lastIndex = 0;
5
- const text = s.original.slice(((_a = node.position) == null ? void 0 : _a.start.offset) ?? 0, ((_b = node.position) == null ? void 0 : _b.end.offset) ?? 0).toString();
4
+ const text = s.original.slice(node.position?.start.offset ?? 0, node.position?.end.offset ?? 0).toString();
6
5
  const offset = text.indexOf(key);
7
6
  if (offset === -1)
8
7
  return;
@@ -1,12 +1,11 @@
1
1
  import { parseNpmName } from "../core/util.js";
2
2
  async function detectImportSource(code, jsxRenderers, tsConfig) {
3
- var _a;
4
3
  let importSource = detectImportSourceFromComments(code);
5
4
  if (!importSource && /import/.test(code)) {
6
5
  importSource = await detectImportSourceFromImports(code, jsxRenderers);
7
6
  }
8
7
  if (!importSource && tsConfig) {
9
- importSource = (_a = tsConfig.compilerOptions) == null ? void 0 : _a.jsxImportSource;
8
+ importSource = tsConfig.compilerOptions?.jsxImportSource;
10
9
  }
11
10
  return importSource;
12
11
  }
@@ -104,7 +104,7 @@ function jsx({ settings, logging }) {
104
104
  defaultJSXRendererEntry = [...jsxRenderersIntegrationOnly.entries()][0];
105
105
  },
106
106
  async transform(code, id, opts) {
107
- const ssr = Boolean(opts == null ? void 0 : opts.ssr);
107
+ const ssr = Boolean(opts?.ssr);
108
108
  if (SPECIAL_QUERY_REGEX.test(id) || id.startsWith(astroEntryPrefix)) {
109
109
  return null;
110
110
  }
@@ -45,7 +45,6 @@ async function tagExportsWithRenderer({
45
45
  * @returns
46
46
  */
47
47
  enter(path) {
48
- var _a;
49
48
  const node = path.node;
50
49
  if (!t.isExportDefaultDeclaration(node))
51
50
  return;
@@ -58,13 +57,12 @@ async function tagExportsWithRenderer({
58
57
  ])
59
58
  );
60
59
  node.declaration = uidIdentifier;
61
- } else if (t.isFunctionDeclaration(node.declaration) && !((_a = node.declaration.id) == null ? void 0 : _a.name)) {
60
+ } else if (t.isFunctionDeclaration(node.declaration) && !node.declaration.id?.name) {
62
61
  const uidIdentifier = path.scope.generateUidIdentifier("_function");
63
62
  node.declaration.id = uidIdentifier;
64
63
  }
65
64
  },
66
65
  exit(path, state) {
67
- var _a, _b, _c;
68
66
  const node = path.node;
69
67
  if (node.exportKind === "type")
70
68
  return;
@@ -77,16 +75,16 @@ async function tagExportsWithRenderer({
77
75
  if (t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node)) {
78
76
  if (t.isIdentifier(node.declaration)) {
79
77
  addTag(node.declaration.name);
80
- } else if (t.isFunctionDeclaration(node.declaration) && ((_a = node.declaration.id) == null ? void 0 : _a.name)) {
78
+ } else if (t.isFunctionDeclaration(node.declaration) && node.declaration.id?.name) {
81
79
  addTag(node.declaration.id.name);
82
80
  } else if (t.isVariableDeclaration(node.declaration)) {
83
- (_b = node.declaration.declarations) == null ? void 0 : _b.forEach((declaration) => {
81
+ node.declaration.declarations?.forEach((declaration) => {
84
82
  if (t.isArrowFunctionExpression(declaration.init) && t.isIdentifier(declaration.id)) {
85
83
  addTag(declaration.id.name);
86
84
  }
87
85
  });
88
86
  } else if (t.isObjectExpression(node.declaration)) {
89
- (_c = node.declaration.properties) == null ? void 0 : _c.forEach((property) => {
87
+ node.declaration.properties?.forEach((property) => {
90
88
  if (t.isProperty(property) && t.isIdentifier(property.key)) {
91
89
  addTag(property.key.name);
92
90
  }
@@ -52,7 +52,6 @@ function markdown({ settings, logging }) {
52
52
  // passing to the transform hook. This lets us get the truly raw value
53
53
  // to escape "import.meta.env" ourselves.
54
54
  async load(id) {
55
- var _a;
56
55
  if (isMarkdownFile(id)) {
57
56
  const { fileId, fileUrl } = getFileInfo(id, settings.config);
58
57
  const rawFile = await fs.promises.readFile(fileId, "utf-8");
@@ -70,7 +69,7 @@ function markdown({ settings, logging }) {
70
69
  for (let imagePath of renderResult.vfile.data.imagePaths.values()) {
71
70
  imagePaths.push({
72
71
  raw: imagePath,
73
- resolved: ((_a = await this.resolve(imagePath, id)) == null ? void 0 : _a.id) ?? path.join(path.dirname(id), imagePath)
72
+ resolved: (await this.resolve(imagePath, id))?.id ?? path.join(path.dirname(id), imagePath)
74
73
  });
75
74
  }
76
75
  }
@@ -1,3 +1,4 @@
1
+ import {} from "../core/logger/core.js";
1
2
  import { bold } from "kleur/colors";
2
3
  import { extname } from "node:path";
3
4
  import { normalizePath } from "vite";
@@ -14,7 +15,7 @@ function astroScannerPlugin({
14
15
  name: "astro:scanner",
15
16
  enforce: "post",
16
17
  async transform(code, id, options) {
17
- if (!(options == null ? void 0 : options.ssr))
18
+ if (!options?.ssr)
18
19
  return;
19
20
  const filename = normalizePath(id);
20
21
  let fileURL;