astro 4.7.1 → 4.8.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 (222) hide show
  1. package/client.d.ts +1 -0
  2. package/content-module.template.mjs +2 -0
  3. package/dist/@types/astro.d.ts +219 -3
  4. package/dist/actions/consts.d.ts +3 -0
  5. package/dist/actions/consts.js +8 -0
  6. package/dist/actions/index.d.ts +2 -0
  7. package/dist/actions/index.js +72 -0
  8. package/dist/actions/runtime/middleware.d.ts +7 -0
  9. package/dist/actions/runtime/middleware.js +38 -0
  10. package/dist/actions/runtime/route.d.ts +2 -0
  11. package/dist/actions/runtime/route.js +37 -0
  12. package/dist/actions/runtime/store.d.ts +6 -0
  13. package/dist/actions/runtime/store.js +18 -0
  14. package/dist/actions/runtime/utils.d.ts +4 -0
  15. package/dist/actions/runtime/utils.js +23 -0
  16. package/dist/actions/runtime/virtual/client.d.ts +4 -0
  17. package/dist/actions/runtime/virtual/client.js +20 -0
  18. package/dist/actions/runtime/virtual/server.d.ts +21 -0
  19. package/dist/actions/runtime/virtual/server.js +98 -0
  20. package/dist/actions/runtime/virtual/shared.d.ts +37 -0
  21. package/dist/actions/runtime/virtual/shared.js +104 -0
  22. package/dist/actions/utils.d.ts +2 -0
  23. package/dist/actions/utils.js +18 -0
  24. package/dist/assets/build/generate.js +1 -1
  25. package/dist/assets/internal.js +1 -2
  26. package/dist/assets/services/service.js +2 -4
  27. package/dist/assets/services/sharp.js +2 -4
  28. package/dist/assets/services/squoosh.js +2 -4
  29. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +34 -68
  30. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +39 -78
  31. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +32 -64
  32. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +32 -64
  33. package/dist/assets/services/vendor/squoosh/png/squoosh_png.js +2 -4
  34. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +29 -58
  35. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +29 -58
  36. package/dist/assets/utils/getAssetsPrefix.js +2 -4
  37. package/dist/assets/utils/remotePattern.js +1 -2
  38. package/dist/assets/utils/remoteProbe.js +1 -2
  39. package/dist/assets/utils/vendor/image-size/types/cur.js +1 -2
  40. package/dist/assets/utils/vendor/image-size/types/icns.js +1 -2
  41. package/dist/assets/utils/vendor/image-size/types/ico.js +2 -4
  42. package/dist/assets/utils/vendor/image-size/types/jp2.js +2 -4
  43. package/dist/assets/utils/vendor/image-size/types/utils.js +4 -8
  44. package/dist/assets/vite-plugin-assets.js +1 -1
  45. package/dist/cli/add/babel.d.ts +1 -1
  46. package/dist/cli/add/imports.js +4 -8
  47. package/dist/cli/add/index.js +23 -46
  48. package/dist/cli/add/wrapper.js +1 -2
  49. package/dist/cli/index.js +1 -2
  50. package/dist/cli/info/index.js +1 -2
  51. package/dist/cli/install-package.js +3 -6
  52. package/dist/cli/throw-and-exit.js +1 -2
  53. package/dist/config/index.d.ts +2 -2
  54. package/dist/config/index.js +2 -2
  55. package/dist/content/index.d.ts +1 -1
  56. package/dist/content/index.js +1 -7
  57. package/dist/content/runtime.d.ts +2 -1
  58. package/dist/content/runtime.js +11 -20
  59. package/dist/content/server-listeners.js +5 -10
  60. package/dist/content/types-generator.js +5 -10
  61. package/dist/content/utils.d.ts +0 -4
  62. package/dist/content/utils.js +4 -15
  63. package/dist/content/vite-plugin-content-assets.d.ts +1 -1
  64. package/dist/content/vite-plugin-content-assets.js +14 -47
  65. package/dist/content/vite-plugin-content-imports.js +6 -11
  66. package/dist/content/vite-plugin-content-virtual-mod.js +7 -14
  67. package/dist/core/app/index.js +11 -46
  68. package/dist/core/app/node.js +4 -3
  69. package/dist/core/app/pipeline.d.ts +7 -2
  70. package/dist/core/app/pipeline.js +70 -2
  71. package/dist/core/app/types.d.ts +1 -0
  72. package/dist/core/base-pipeline.d.ts +16 -1
  73. package/dist/core/build/generate.js +15 -61
  74. package/dist/core/build/index.js +2 -4
  75. package/dist/core/build/internal.d.ts +39 -9
  76. package/dist/core/build/internal.js +43 -54
  77. package/dist/core/build/page-data.js +6 -6
  78. package/dist/core/build/pipeline.d.ts +7 -3
  79. package/dist/core/build/pipeline.js +134 -23
  80. package/dist/core/build/plugins/plugin-analyzer.js +11 -32
  81. package/dist/core/build/plugins/plugin-content.d.ts +1 -0
  82. package/dist/core/build/plugins/plugin-content.js +34 -32
  83. package/dist/core/build/plugins/plugin-css.js +23 -51
  84. package/dist/core/build/plugins/plugin-manifest.js +7 -8
  85. package/dist/core/build/plugins/plugin-pages.d.ts +0 -1
  86. package/dist/core/build/plugins/plugin-pages.js +10 -12
  87. package/dist/core/build/plugins/plugin-ssr.js +15 -13
  88. package/dist/core/build/plugins/util.d.ts +26 -11
  89. package/dist/core/build/plugins/util.js +22 -6
  90. package/dist/core/build/static-build.js +30 -25
  91. package/dist/core/build/types.d.ts +6 -6
  92. package/dist/core/client-directive/build.js +1 -2
  93. package/dist/core/config/config.js +2 -7
  94. package/dist/core/config/logging.js +1 -2
  95. package/dist/core/config/schema.d.ts +92 -60
  96. package/dist/core/config/schema.js +6 -2
  97. package/dist/core/config/settings.js +1 -2
  98. package/dist/core/config/timer.js +4 -8
  99. package/dist/core/constants.js +1 -1
  100. package/dist/core/cookies/cookies.js +3 -6
  101. package/dist/core/dev/dev.js +1 -1
  102. package/dist/core/dev/restart.js +1 -2
  103. package/dist/core/errors/errors-data.d.ts +24 -0
  104. package/dist/core/errors/errors-data.js +13 -2
  105. package/dist/core/errors/errors.js +1 -2
  106. package/dist/core/errors/overlay.js +1 -2
  107. package/dist/core/errors/printer.js +2 -4
  108. package/dist/core/errors/zod-error-map.js +2 -4
  109. package/dist/core/fs/index.js +2 -4
  110. package/dist/core/logger/vite.js +9 -18
  111. package/dist/core/messages.js +2 -2
  112. package/dist/core/middleware/callMiddleware.d.ts +3 -2
  113. package/dist/core/middleware/callMiddleware.js +13 -3
  114. package/dist/core/middleware/index.js +12 -8
  115. package/dist/core/middleware/sequence.js +22 -4
  116. package/dist/core/module-loader/vite.js +1 -2
  117. package/dist/core/render/params-and-props.js +2 -4
  118. package/dist/core/render/slots.js +4 -8
  119. package/dist/core/render-context.d.ts +15 -5
  120. package/dist/core/render-context.js +134 -28
  121. package/dist/core/request.js +1 -2
  122. package/dist/core/routing/manifest/create.js +3 -6
  123. package/dist/core/sync/index.js +10 -3
  124. package/dist/core/util.d.ts +2 -0
  125. package/dist/core/util.js +18 -19
  126. package/dist/i18n/index.js +2 -4
  127. package/dist/i18n/middleware.js +1 -2
  128. package/dist/i18n/utils.js +1 -2
  129. package/dist/i18n/vite-plugin-i18n.js +1 -2
  130. package/dist/integrations/hooks.js +5 -1
  131. package/dist/jsx/babel.d.ts +3 -0
  132. package/dist/jsx/babel.js +9 -18
  133. package/dist/jsx/rehype.d.ts +11 -0
  134. package/dist/jsx/rehype.js +197 -0
  135. package/dist/jsx/server.js +20 -14
  136. package/dist/jsx/transform-options.d.ts +3 -0
  137. package/dist/jsx-runtime/index.js +8 -16
  138. package/dist/preferences/index.js +3 -6
  139. package/dist/preferences/store.js +3 -6
  140. package/dist/prefetch/index.js +8 -16
  141. package/dist/prefetch/vite-plugin-prefetch.js +2 -4
  142. package/dist/prerender/metadata.js +1 -2
  143. package/dist/prerender/routing.js +1 -1
  144. package/dist/prerender/utils.d.ts +0 -1
  145. package/dist/prerender/utils.js +2 -5
  146. package/dist/runtime/client/dev-toolbar/apps/astro.js +5 -10
  147. package/dist/runtime/client/dev-toolbar/apps/audit/index.js +5 -10
  148. package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +45 -90
  149. package/dist/runtime/client/dev-toolbar/apps/audit/rules/index.js +1 -2
  150. package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +16 -32
  151. package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-list-window.js +2 -4
  152. package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.js +3 -6
  153. package/dist/runtime/client/dev-toolbar/apps/utils/highlight.js +1 -2
  154. package/dist/runtime/client/dev-toolbar/apps/utils/window.js +4 -8
  155. package/dist/runtime/client/dev-toolbar/entrypoint.js +8 -11
  156. package/dist/runtime/client/dev-toolbar/helpers.js +2 -4
  157. package/dist/runtime/client/dev-toolbar/toolbar.js +11 -22
  158. package/dist/runtime/client/dev-toolbar/ui-library/badge.js +1 -2
  159. package/dist/runtime/client/dev-toolbar/ui-library/button.d.ts +5 -0
  160. package/dist/runtime/client/dev-toolbar/ui-library/button.js +26 -5
  161. package/dist/runtime/client/dev-toolbar/ui-library/index.d.ts +1 -0
  162. package/dist/runtime/client/dev-toolbar/ui-library/index.js +2 -0
  163. package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.d.ts +13 -0
  164. package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.js +109 -0
  165. package/dist/runtime/client/visible.js +1 -2
  166. package/dist/runtime/server/astro-component.js +2 -4
  167. package/dist/runtime/server/astro-island.js +7 -14
  168. package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
  169. package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
  170. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  171. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  172. package/dist/runtime/server/index.js +3 -6
  173. package/dist/runtime/server/jsx.js +1 -2
  174. package/dist/runtime/server/render/any.js +1 -2
  175. package/dist/runtime/server/render/astro/instance.js +1 -2
  176. package/dist/runtime/server/render/astro/render.js +5 -10
  177. package/dist/runtime/server/render/component.js +6 -11
  178. package/dist/runtime/server/render/dom.js +1 -2
  179. package/dist/runtime/server/render/page.js +1 -2
  180. package/dist/runtime/server/render/script.js +1 -2
  181. package/dist/runtime/server/render/slot.js +1 -2
  182. package/dist/runtime/server/render/tags.js +2 -4
  183. package/dist/runtime/server/render/util.js +2 -4
  184. package/dist/runtime/server/shorthash.js +1 -2
  185. package/dist/runtime/server/transition.js +4 -8
  186. package/dist/runtime/server/util.js +1 -2
  187. package/dist/transitions/events.d.ts +3 -3
  188. package/dist/transitions/events.js +5 -4
  189. package/dist/transitions/router.js +22 -113
  190. package/dist/transitions/swap-functions.d.ts +12 -0
  191. package/dist/transitions/swap-functions.js +105 -0
  192. package/dist/vite-plugin-astro/compile.js +1 -2
  193. package/dist/vite-plugin-astro/hmr.js +5 -10
  194. package/dist/vite-plugin-astro/index.js +2 -4
  195. package/dist/vite-plugin-astro-server/pipeline.d.ts +8 -3
  196. package/dist/vite-plugin-astro-server/pipeline.js +59 -11
  197. package/dist/vite-plugin-astro-server/plugin.js +6 -6
  198. package/dist/vite-plugin-astro-server/response.js +1 -2
  199. package/dist/vite-plugin-astro-server/route.js +36 -42
  200. package/dist/vite-plugin-astro-server/vite.js +1 -2
  201. package/dist/vite-plugin-config-alias/index.js +7 -14
  202. package/dist/vite-plugin-head/index.js +3 -6
  203. package/dist/vite-plugin-html/index.js +1 -2
  204. package/dist/vite-plugin-html/transform/escape.js +2 -4
  205. package/dist/vite-plugin-html/transform/slots.js +1 -2
  206. package/dist/vite-plugin-html/transform/utils.js +1 -2
  207. package/dist/vite-plugin-inject-env-ts/index.js +37 -11
  208. package/dist/vite-plugin-integrations-container/index.js +3 -6
  209. package/dist/vite-plugin-load-fallback/index.js +1 -2
  210. package/dist/vite-plugin-markdown/index.js +1 -2
  211. package/dist/vite-plugin-mdx/index.d.ts +3 -0
  212. package/dist/vite-plugin-mdx/tag.d.ts +2 -0
  213. package/dist/vite-plugin-mdx/tag.js +3 -6
  214. package/dist/vite-plugin-mdx/transform-jsx.d.ts +3 -0
  215. package/dist/vite-plugin-mdx/transform-jsx.js +1 -2
  216. package/dist/vite-plugin-scanner/index.js +4 -6
  217. package/dist/vite-plugin-scanner/scan.js +2 -4
  218. package/dist/vite-plugin-scripts/page-ssr.js +3 -6
  219. package/package.json +18 -14
  220. package/templates/actions.mjs +61 -0
  221. package/types/actions.d.ts +3 -0
  222. package/types/content.d.ts +2 -2
@@ -208,8 +208,7 @@ const a11y = [
208
208
  message: "Element with the `aria-activedescendant` attribute must either have an inherent `tabindex` or declare `tabindex` as an attribute.",
209
209
  selector: "[aria-activedescendant]",
210
210
  match(element) {
211
- if (!element.tabIndex && !element.hasAttribute("tabindex"))
212
- return true;
211
+ if (!element.tabIndex && !element.hasAttribute("tabindex")) return true;
213
212
  }
214
213
  },
215
214
  {
@@ -219,8 +218,7 @@ const a11y = [
219
218
  selector: ":is(meta, html, script, style)[role]",
220
219
  match(element) {
221
220
  for (const attribute of element.attributes) {
222
- if (attribute.name.startsWith("aria-"))
223
- return true;
221
+ if (attribute.name.startsWith("aria-")) return true;
224
222
  }
225
223
  }
226
224
  },
@@ -256,10 +254,8 @@ const a11y = [
256
254
  selector: "[aria-hidden]",
257
255
  match(element) {
258
256
  const value = element.getAttribute("aria-hidden");
259
- if (!value)
260
- return true;
261
- if (!["true", "false"].includes(value))
262
- return true;
257
+ if (!value) return true;
258
+ if (!["true", "false"].includes(value)) return true;
263
259
  }
264
260
  },
265
261
  {
@@ -276,11 +272,9 @@ const a11y = [
276
272
  match(element) {
277
273
  const hasFor = element.hasAttribute("for");
278
274
  const nestedLabellableElement = element.querySelector(`${labellableElements.join(", ")}`);
279
- if (!hasFor && !nestedLabellableElement)
280
- return true;
275
+ if (!hasFor && !nestedLabellableElement) return true;
281
276
  const innerText = element.innerText.trim();
282
- if (innerText === "")
283
- return true;
277
+ if (innerText === "") return true;
284
278
  }
285
279
  },
286
280
  {
@@ -290,8 +284,7 @@ const a11y = [
290
284
  selector: "video:not([muted])",
291
285
  match(element) {
292
286
  const tracks = element.querySelectorAll("track");
293
- if (!tracks.length)
294
- return true;
287
+ if (!tracks.length) return true;
295
288
  const hasCaptionTrack = Array.from(tracks).some(
296
289
  (track) => track.getAttribute("kind") === "captions"
297
290
  );
@@ -318,11 +311,9 @@ const a11y = [
318
311
  selector: Object.keys(a11y_required_attributes).join(","),
319
312
  match(element) {
320
313
  const requiredAttributes = a11y_required_attributes[element.localName];
321
- if (!requiredAttributes)
322
- return true;
314
+ if (!requiredAttributes) return true;
323
315
  for (const attribute of requiredAttributes) {
324
- if (!element.hasAttribute(attribute))
325
- return true;
316
+ if (!element.hasAttribute(attribute)) return true;
326
317
  }
327
318
  return false;
328
319
  }
@@ -334,54 +325,45 @@ const a11y = [
334
325
  selector: a11y_required_content.join(","),
335
326
  match(element) {
336
327
  const innerText = element.innerText?.trim();
337
- if (innerText && innerText !== "")
338
- return false;
328
+ if (innerText && innerText !== "") return false;
339
329
  const ariaLabel = element.getAttribute("aria-label")?.trim();
340
- if (ariaLabel && ariaLabel !== "")
341
- return false;
330
+ if (ariaLabel && ariaLabel !== "") return false;
342
331
  const ariaLabelledby = element.getAttribute("aria-labelledby")?.trim();
343
332
  if (ariaLabelledby) {
344
333
  const ids = ariaLabelledby.split(" ");
345
334
  for (const id of ids) {
346
335
  const referencedElement = document.getElementById(id);
347
- if (referencedElement && referencedElement.innerText.trim() !== "")
348
- return false;
336
+ if (referencedElement && referencedElement.innerText.trim() !== "") return false;
349
337
  }
350
338
  }
351
339
  const imgElements = element.querySelectorAll("img");
352
340
  for (const img of imgElements) {
353
341
  const altAttribute = img.getAttribute("alt");
354
- if (altAttribute && altAttribute.trim() !== "")
355
- return false;
342
+ if (altAttribute && altAttribute.trim() !== "") return false;
356
343
  }
357
344
  const svgElements = element.querySelectorAll("svg");
358
345
  for (const svg of svgElements) {
359
346
  const titleText = svg.querySelector("title");
360
- if (titleText && titleText.textContent && titleText.textContent.trim() !== "")
361
- return false;
347
+ if (titleText && titleText.textContent && titleText.textContent.trim() !== "") return false;
362
348
  }
363
349
  const inputElements = element.querySelectorAll("input");
364
350
  for (const input of inputElements) {
365
351
  if (input.type === "image") {
366
352
  const altAttribute = input.getAttribute("alt");
367
- if (altAttribute && altAttribute.trim() !== "")
368
- return false;
353
+ if (altAttribute && altAttribute.trim() !== "") return false;
369
354
  }
370
355
  const inputAriaLabel = input.getAttribute("aria-label")?.trim();
371
- if (inputAriaLabel && inputAriaLabel !== "")
372
- return false;
356
+ if (inputAriaLabel && inputAriaLabel !== "") return false;
373
357
  const inputAriaLabelledby = input.getAttribute("aria-labelledby")?.trim();
374
358
  if (inputAriaLabelledby) {
375
359
  const ids = inputAriaLabelledby.split(" ");
376
360
  for (const id of ids) {
377
361
  const referencedElement = document.getElementById(id);
378
- if (referencedElement && referencedElement.innerText.trim() !== "")
379
- return false;
362
+ if (referencedElement && referencedElement.innerText.trim() !== "") return false;
380
363
  }
381
364
  }
382
365
  const title = input.getAttribute("title")?.trim();
383
- if (title && title !== "")
384
- return false;
366
+ if (title && title !== "") return false;
385
367
  }
386
368
  return true;
387
369
  }
@@ -395,19 +377,14 @@ const a11y = [
395
377
  const role = element.getAttribute("role");
396
378
  if (element.localName === "input") {
397
379
  const type = element.getAttribute("type");
398
- if (!type)
399
- return true;
380
+ if (!type) return true;
400
381
  const implicitRoleForType = input_type_to_implicit_role.get(type);
401
- if (!implicitRoleForType)
402
- return true;
403
- if (role === implicitRoleForType)
404
- return false;
382
+ if (!implicitRoleForType) return true;
383
+ if (role === implicitRoleForType) return false;
405
384
  }
406
385
  const implicitRole = a11y_implicit_semantics.get(element.localName);
407
- if (!implicitRole)
408
- return true;
409
- if (role === implicitRole)
410
- return false;
386
+ if (!implicitRole) return true;
387
+ if (role === implicitRole) return false;
411
388
  }
412
389
  },
413
390
  {
@@ -416,17 +393,12 @@ const a11y = [
416
393
  message: "Interactive HTML elements like `<a>` and `<button>` cannot use non-interactive roles like `heading`, `list`, `menu`, and `toolbar`.",
417
394
  selector: `[role]:is(${interactiveElements.join(",")})`,
418
395
  match(element) {
419
- if (!isInteractive(element))
420
- return false;
396
+ if (!isInteractive(element)) return false;
421
397
  const role = element.getAttribute("role");
422
- if (!role)
423
- return false;
424
- if (!ariaRoles.has(role))
425
- return false;
426
- if (roleless_elements.includes(element.localName))
427
- return false;
428
- if (aria_non_interactive_roles.includes(role))
429
- return true;
398
+ if (!role) return false;
399
+ if (!ariaRoles.has(role)) return false;
400
+ if (roleless_elements.includes(element.localName)) return false;
401
+ if (aria_non_interactive_roles.includes(role)) return true;
430
402
  }
431
403
  },
432
404
  {
@@ -435,20 +407,14 @@ const a11y = [
435
407
  message: "Interactive roles should not be used to convert a non-interactive element to an interactive element",
436
408
  selector: `[role]:not(${interactiveElements.join(",")})`,
437
409
  match(element) {
438
- if (!isInteractive(element))
439
- return false;
410
+ if (!isInteractive(element)) return false;
440
411
  const role = element.getAttribute("role");
441
- if (!role)
442
- return false;
443
- if (!ariaRoles.has(role))
444
- return false;
412
+ if (!role) return false;
413
+ if (!ariaRoles.has(role)) return false;
445
414
  const exceptions = a11y_non_interactive_element_to_interactive_role_exceptions[element.localName];
446
- if (exceptions?.includes(role))
447
- return false;
448
- if (roleless_elements.includes(element.localName))
449
- return false;
450
- if (!aria_non_interactive_roles.includes(role))
451
- return true;
415
+ if (exceptions?.includes(role)) return false;
416
+ if (roleless_elements.includes(element.localName)) return false;
417
+ if (!aria_non_interactive_roles.includes(role)) return true;
452
418
  }
453
419
  },
454
420
  {
@@ -459,10 +425,8 @@ const a11y = [
459
425
  selector: "[tabindex]",
460
426
  match(element) {
461
427
  const isScrollable = element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
462
- if (isScrollable)
463
- return false;
464
- if (!isInteractive(element))
465
- return false;
428
+ if (isScrollable) return false;
429
+ if (!isInteractive(element)) return false;
466
430
  if (!interactiveElements.includes(element.localName) && !roleless_elements.includes(element.localName))
467
431
  return true;
468
432
  }
@@ -483,8 +447,7 @@ const a11y = [
483
447
  selector: "*",
484
448
  match(element) {
485
449
  const role = getRole(element);
486
- if (!role)
487
- return false;
450
+ if (!role) return false;
488
451
  if (is_semantic_role_element(role, element.localName, getAttributeObject(element))) {
489
452
  return;
490
453
  }
@@ -513,8 +476,7 @@ const a11y = [
513
476
  selector: "*",
514
477
  match(element) {
515
478
  const role = getRole(element);
516
- if (!role)
517
- return false;
479
+ if (!role) return false;
518
480
  const elementRoles = role.split(WHITESPACE_REGEX);
519
481
  for (const elementRole of elementRoles) {
520
482
  const { props } = roles.get(elementRole);
@@ -545,8 +507,7 @@ const a11y = [
545
507
  match(element) {
546
508
  for (const attribute of element.attributes) {
547
509
  if (attribute.name.startsWith("aria-")) {
548
- if (!ariaAttributes.has(attribute.name.slice("aria-".length)))
549
- return true;
510
+ if (!ariaAttributes.has(attribute.name.slice("aria-".length))) return true;
550
511
  }
551
512
  }
552
513
  }
@@ -558,10 +519,8 @@ const a11y = [
558
519
  selector: "[role]",
559
520
  match(element) {
560
521
  const role = element.getAttribute("role");
561
- if (!role)
562
- return true;
563
- if (!ariaRoles.has(role))
564
- return true;
522
+ if (!role) return true;
523
+ if (!ariaRoles.has(role)) return true;
565
524
  }
566
525
  }
567
526
  ];
@@ -585,22 +544,18 @@ const a11y_non_interactive_element_to_interactive_role_exceptions = {
585
544
  };
586
545
  const combobox_if_list = ["email", "search", "tel", "text", "url"];
587
546
  function input_implicit_role(attributes) {
588
- if (!("type" in attributes))
589
- return;
547
+ if (!("type" in attributes)) return;
590
548
  const { type, list } = attributes;
591
- if (!type)
592
- return;
549
+ if (!type) return;
593
550
  if (list && combobox_if_list.includes(type)) {
594
551
  return "combobox";
595
552
  }
596
553
  return input_type_to_implicit_role.get(type);
597
554
  }
598
555
  function menuitem_implicit_role(attributes) {
599
- if (!("type" in attributes))
600
- return;
556
+ if (!("type" in attributes)) return;
601
557
  const { type } = attributes;
602
- if (!type)
603
- return;
558
+ if (!type) return;
604
559
  return menuitem_type_to_implicit_role.get(type);
605
560
  }
606
561
  function getRole(element) {
@@ -10,8 +10,7 @@ function resolveAuditRule(rule, element) {
10
10
  let resolved = { ...rule };
11
11
  for (const key of dynamicAuditRuleKeys) {
12
12
  const value = rule[key];
13
- if (typeof value === "string")
14
- continue;
13
+ if (typeof value === "string") continue;
15
14
  try {
16
15
  if (!value) {
17
16
  resolved[key] = "";
@@ -7,14 +7,11 @@ const perf = [
7
7
  selector: "img:not([data-image-component])",
8
8
  async match(element) {
9
9
  const src = element.getAttribute("src");
10
- if (!src)
11
- return false;
12
- if (src.startsWith("data:"))
13
- return false;
10
+ if (!src) return false;
11
+ if (src.startsWith("data:")) return false;
14
12
  if (!EXTERNAL_URL_REGEX.test(src)) {
15
13
  const imageData = await fetch(src).then((response) => response.blob());
16
- if (imageData.size < 20480)
17
- return false;
14
+ if (imageData.size < 20480) return false;
18
15
  }
19
16
  return true;
20
17
  }
@@ -26,10 +23,8 @@ const perf = [
26
23
  selector: 'img:not([loading]), img[loading="eager"], iframe:not([loading]), iframe[loading="eager"]',
27
24
  match(element) {
28
25
  const htmlElement = element;
29
- if (htmlElement.offsetTop < window.innerHeight)
30
- return false;
31
- if (htmlElement.src.startsWith("data:"))
32
- return false;
26
+ if (htmlElement.offsetTop < window.innerHeight) return false;
27
+ if (htmlElement.src.startsWith("data:")) return false;
33
28
  return true;
34
29
  }
35
30
  },
@@ -40,10 +35,8 @@ const perf = [
40
35
  selector: 'img[loading="lazy"], iframe[loading="lazy"]',
41
36
  match(element) {
42
37
  const htmlElement = element;
43
- if (htmlElement.offsetTop > window.innerHeight)
44
- return false;
45
- if (htmlElement.src.startsWith("data:"))
46
- return false;
38
+ if (htmlElement.offsetTop > window.innerHeight) return false;
39
+ if (htmlElement.src.startsWith("data:")) return false;
47
40
  return true;
48
41
  }
49
42
  },
@@ -54,14 +47,11 @@ const perf = [
54
47
  selector: 'img[src$=".gif"]',
55
48
  async match(element) {
56
49
  const src = element.getAttribute("src");
57
- if (!src)
58
- return false;
59
- if (EXTERNAL_URL_REGEX.test(src))
60
- return false;
50
+ if (!src) return false;
51
+ if (EXTERNAL_URL_REGEX.test(src)) return false;
61
52
  if (!EXTERNAL_URL_REGEX.test(src)) {
62
53
  const imageData = await fetch(src).then((response) => response.blob());
63
- if (imageData.size < 102400)
64
- return false;
54
+ if (imageData.size < 102400) return false;
65
55
  }
66
56
  return true;
67
57
  }
@@ -75,11 +65,9 @@ const perf = [
75
65
  selector: "astro-island[server-render-time]",
76
66
  match(element) {
77
67
  const serverRenderTime = element.getAttribute("server-render-time");
78
- if (!serverRenderTime)
79
- return false;
68
+ if (!serverRenderTime) return false;
80
69
  const renderingTime = parseFloat(serverRenderTime);
81
- if (Number.isNaN(renderingTime))
82
- return false;
70
+ if (Number.isNaN(renderingTime)) return false;
83
71
  return renderingTime > 500;
84
72
  }
85
73
  },
@@ -92,21 +80,17 @@ const perf = [
92
80
  selector: "astro-island[client-render-time]",
93
81
  match(element) {
94
82
  const clientRenderTime = element.getAttribute("client-render-time");
95
- if (!clientRenderTime)
96
- return false;
83
+ if (!clientRenderTime) return false;
97
84
  const renderingTime = parseFloat(clientRenderTime);
98
- if (Number.isNaN(renderingTime))
99
- return false;
85
+ if (Number.isNaN(renderingTime)) return false;
100
86
  return renderingTime > 500;
101
87
  }
102
88
  }
103
89
  ];
104
90
  function getCleanRenderingTime(time) {
105
- if (!time)
106
- return "unknown";
91
+ if (!time) return "unknown";
107
92
  const renderingTime = parseFloat(time);
108
- if (Number.isNaN(renderingTime))
109
- return "unknown";
93
+ if (Number.isNaN(renderingTime)) return "unknown";
110
94
  return renderingTime.toFixed(2) + "s";
111
95
  }
112
96
  export {
@@ -331,8 +331,7 @@ class DevToolbarAuditListWindow extends HTMLElement {
331
331
  const template = this.shadowRoot.getElementById(
332
332
  "category-template"
333
333
  );
334
- if (!template)
335
- return;
334
+ if (!template) return;
336
335
  const clone = document.importNode(template.content, true);
337
336
  const categoryContainer = clone.querySelector("div");
338
337
  const categoryHeader = clone.querySelector(".category-header");
@@ -343,8 +342,7 @@ class DevToolbarAuditListWindow extends HTMLElement {
343
342
  (audit) => getAuditCategory(audit.rule) === category.code
344
343
  );
345
344
  for (const audit of categoryAudits) {
346
- if (audit.card)
347
- categoryContent.append(audit.card);
345
+ if (audit.card) categoryContent.append(audit.card);
348
346
  }
349
347
  categoryContainer.append(categoryContent);
350
348
  auditListContainer.append(categoryContainer);
@@ -19,11 +19,9 @@ function createAuditUI(audit, audits) {
19
19
  highlight.addEventListener(event, () => {
20
20
  if (event === "focus") {
21
21
  audits.forEach((adt) => {
22
- if (adt.card)
23
- adt.card.toggleAttribute("active", false);
22
+ if (adt.card) adt.card.toggleAttribute("active", false);
24
23
  });
25
- if (!card.isManualFocus)
26
- card.scrollIntoView();
24
+ if (!card.isManualFocus) card.scrollIntoView();
27
25
  card.toggleAttribute("active", true);
28
26
  } else {
29
27
  card.toggleAttribute(attribute, true);
@@ -74,8 +72,7 @@ function buildAuditCard(rule, highlightElement, auditedElement, audits) {
74
72
  "astro-dev-toolbar-audit-list-item"
75
73
  );
76
74
  card.clickAction = () => {
77
- if (card.hasAttribute("active"))
78
- return;
75
+ if (card.hasAttribute("active")) return;
79
76
  audits.forEach((audit) => {
80
77
  audit.card?.toggleAttribute("active", false);
81
78
  });
@@ -1,7 +1,6 @@
1
1
  function createHighlight(rect, icon, additionalAttributes) {
2
2
  const highlight = document.createElement("astro-dev-toolbar-highlight");
3
- if (icon)
4
- highlight.icon = icon;
3
+ if (icon) highlight.icon = icon;
5
4
  if (additionalAttributes) {
6
5
  for (const [key, value] of Object.entries(additionalAttributes)) {
7
6
  highlight.setAttribute(key, value);
@@ -8,14 +8,10 @@ function createWindowElement(content, placement = settings.config.placement) {
8
8
  function closeOnOutsideClick(eventTarget, additionalCheck) {
9
9
  function onPageClick(event) {
10
10
  const target = event.target;
11
- if (!target)
12
- return;
13
- if (!target.closest)
14
- return;
15
- if (target.closest("astro-dev-toolbar"))
16
- return;
17
- if (additionalCheck && additionalCheck(target))
18
- return;
11
+ if (!target) return;
12
+ if (!target.closest) return;
13
+ if (target.closest("astro-dev-toolbar")) return;
14
+ if (additionalCheck && additionalCheck(target)) return;
19
15
  eventTarget.dispatchEvent(
20
16
  new CustomEvent("toggle-app", {
21
17
  detail: {
@@ -19,7 +19,8 @@ document.addEventListener("DOMContentLoaded", async () => {
19
19
  DevToolbarButton,
20
20
  DevToolbarBadge,
21
21
  DevToolbarIcon,
22
- DevToolbarSelect
22
+ DevToolbarSelect,
23
+ DevToolbarRadioCheckbox
23
24
  }
24
25
  ] = await Promise.all([
25
26
  loadDevToolbarApps(),
@@ -41,6 +42,7 @@ document.addEventListener("DOMContentLoaded", async () => {
41
42
  customElements.define("astro-dev-toolbar-badge", DevToolbarBadge);
42
43
  customElements.define("astro-dev-toolbar-icon", DevToolbarIcon);
43
44
  customElements.define("astro-dev-toolbar-select", DevToolbarSelect);
45
+ customElements.define("astro-dev-toolbar-radio-checkbox", DevToolbarRadioCheckbox);
44
46
  const deprecated = (Parent) => class extends Parent {
45
47
  };
46
48
  customElements.define("astro-dev-overlay", deprecated(AstroDevToolbar));
@@ -71,17 +73,14 @@ document.addEventListener("DOMContentLoaded", async () => {
71
73
  eventTarget
72
74
  };
73
75
  eventTarget.addEventListener("toggle-notification", (evt) => {
74
- if (!(evt instanceof CustomEvent))
75
- return;
76
+ if (!(evt instanceof CustomEvent)) return;
76
77
  const target = overlay.shadowRoot?.querySelector(`[data-app-id="${app.id}"]`);
77
78
  const notificationElement = target?.querySelector(".notification");
78
- if (!target || !notificationElement)
79
- return;
79
+ if (!target || !notificationElement) return;
80
80
  let newState = evt.detail.state ?? true;
81
81
  let level = notificationLevels.includes(evt?.detail?.level) ? evt.detail.level : "error";
82
82
  app.notification.state = newState;
83
- if (newState)
84
- app.notification.level = level;
83
+ if (newState) app.notification.level = level;
85
84
  notificationElement.toggleAttribute("data-active", newState);
86
85
  if (newState) {
87
86
  notificationElement.setAttribute("data-level", level);
@@ -204,8 +203,7 @@ document.addEventListener("DOMContentLoaded", async () => {
204
203
  buttonContainer.append(button);
205
204
  dropdown.append(buttonContainer);
206
205
  app.eventTarget.addEventListener("toggle-notification", (evt) => {
207
- if (!(evt instanceof CustomEvent))
208
- return;
206
+ if (!(evt instanceof CustomEvent)) return;
209
207
  let newState = evt.detail.state ?? true;
210
208
  let level = notificationLevels.includes(evt?.detail?.level) ? evt.detail.level : "error";
211
209
  notification.toggleAttribute("data-active", newState);
@@ -214,8 +212,7 @@ document.addEventListener("DOMContentLoaded", async () => {
214
212
  notification.innerHTML = notificationSVGs[level];
215
213
  }
216
214
  app.notification.state = newState;
217
- if (newState)
218
- app.notification.level = level;
215
+ if (newState) app.notification.level = level;
219
216
  eventTarget.dispatchEvent(
220
217
  new CustomEvent("toggle-notification", {
221
218
  detail: {
@@ -38,8 +38,7 @@ class ToolbarAppEventTarget extends EventTarget {
38
38
  */
39
39
  onToggled(callback) {
40
40
  this.addEventListener("app-toggled", (evt) => {
41
- if (!(evt instanceof CustomEvent))
42
- return;
41
+ if (!(evt instanceof CustomEvent)) return;
43
42
  callback(evt.detail);
44
43
  });
45
44
  }
@@ -49,8 +48,7 @@ class ToolbarAppEventTarget extends EventTarget {
49
48
  */
50
49
  onToolbarPlacementUpdated(callback) {
51
50
  this.addEventListener("placement-updated", (evt) => {
52
- if (!(evt instanceof CustomEvent))
53
- return;
51
+ if (!(evt instanceof CustomEvent)) return;
54
52
  callback(evt.detail);
55
53
  });
56
54
  }
@@ -294,14 +294,11 @@ class AstroDevToolbar extends HTMLElement {
294
294
  items.forEach((item) => {
295
295
  item.addEventListener("click", async (event) => {
296
296
  const target = event.currentTarget;
297
- if (!target || !(target instanceof HTMLElement))
298
- return;
297
+ if (!target || !(target instanceof HTMLElement)) return;
299
298
  const id = target.dataset.appId;
300
- if (!id)
301
- return;
299
+ if (!id) return;
302
300
  const app = this.getAppById(id);
303
- if (!app)
304
- return;
301
+ if (!app) return;
305
302
  event.stopPropagation();
306
303
  await this.toggleAppStatus(app);
307
304
  });
@@ -324,10 +321,8 @@ class AstroDevToolbar extends HTMLElement {
324
321
  });
325
322
  });
326
323
  document.addEventListener("keyup", (event) => {
327
- if (event.key !== "Escape")
328
- return;
329
- if (this.isHidden())
330
- return;
324
+ if (event.key !== "Escape") return;
325
+ if (this.isHidden()) return;
331
326
  const activeApp = this.getActiveApp();
332
327
  if (activeApp) {
333
328
  this.toggleAppStatus(activeApp);
@@ -385,11 +380,9 @@ class AstroDevToolbar extends HTMLElement {
385
380
  const activeApp = this.getActiveApp();
386
381
  if (activeApp) {
387
382
  const closeApp = await this.setAppStatus(activeApp, false);
388
- if (!closeApp)
389
- return;
383
+ if (!closeApp) return;
390
384
  }
391
- if (app.status !== "ready")
392
- return;
385
+ if (app.status !== "ready") return;
393
386
  if (app !== activeApp) {
394
387
  await this.setAppStatus(app, true);
395
388
  if (import.meta.hot && app.id !== "astro:more") {
@@ -401,12 +394,10 @@ class AstroDevToolbar extends HTMLElement {
401
394
  }
402
395
  async setAppStatus(app, newStatus) {
403
396
  const appCanvas = this.getAppCanvasById(app.id);
404
- if (!appCanvas)
405
- return false;
397
+ if (!appCanvas) return false;
406
398
  if (app.active && !newStatus && app.beforeTogglingOff) {
407
399
  const shouldToggleOff = await app.beforeTogglingOff(appCanvas.shadowRoot);
408
- if (!shouldToggleOff)
409
- return false;
400
+ if (!shouldToggleOff) return false;
410
401
  }
411
402
  app.active = newStatus ?? !app.active;
412
403
  const mainBarButton = this.getAppButtonById(app.id);
@@ -474,16 +465,14 @@ class AstroDevToolbar extends HTMLElement {
474
465
  this.devToolbarContainer?.removeAttribute("data-hidden");
475
466
  barContainer?.removeAttribute("inert");
476
467
  devBar?.removeAttribute("tabindex");
477
- if (devBarHitboxAbove)
478
- devBarHitboxAbove.style.height = "0";
468
+ if (devBarHitboxAbove) devBarHitboxAbove.style.height = "0";
479
469
  return;
480
470
  }
481
471
  if (newStatus === false) {
482
472
  this.devToolbarContainer?.setAttribute("data-hidden", "");
483
473
  barContainer?.setAttribute("inert", "");
484
474
  devBar?.setAttribute("tabindex", "0");
485
- if (devBarHitboxAbove)
486
- devBarHitboxAbove.style.height = `${DEVBAR_HITBOX_ABOVE}px`;
475
+ if (devBarHitboxAbove) devBarHitboxAbove.style.height = `${DEVBAR_HITBOX_ABOVE}px`;
487
476
  return;
488
477
  }
489
478
  }
@@ -86,8 +86,7 @@ class DevToolbarBadge extends HTMLElement {
86
86
  attributeChangedCallback() {
87
87
  if (this.hasAttribute("badge-style"))
88
88
  this.badgeStyle = this.getAttribute("badge-style");
89
- if (this.hasAttribute("size"))
90
- this.size = this.getAttribute("size");
89
+ if (this.hasAttribute("size")) this.size = this.getAttribute("size");
91
90
  }
92
91
  updateStyle() {
93
92
  const style = this.shadowRoot.querySelector("#selected-style");
@@ -1,14 +1,19 @@
1
1
  declare const sizes: readonly ["small", "medium", "large"];
2
2
  declare const styles: readonly ["ghost", "outline", "purple", "gray", "red", "green", "yellow", "blue"];
3
+ declare const borderRadii: readonly ["normal", "rounded"];
3
4
  type ButtonSize = (typeof sizes)[number];
4
5
  type ButtonStyle = (typeof styles)[number];
6
+ type ButtonBorderRadius = (typeof borderRadii)[number];
5
7
  export declare class DevToolbarButton extends HTMLElement {
6
8
  _size: ButtonSize;
7
9
  _buttonStyle: ButtonStyle;
10
+ _buttonBorderRadius: ButtonBorderRadius;
8
11
  get size(): "small" | "large" | "medium";
9
12
  set size(value: "small" | "large" | "medium");
10
13
  get buttonStyle(): "red" | "purple" | "gray" | "green" | "yellow" | "blue" | "ghost" | "outline";
11
14
  set buttonStyle(value: "red" | "purple" | "gray" | "green" | "yellow" | "blue" | "ghost" | "outline");
15
+ get buttonBorderRadius(): "normal" | "rounded";
16
+ set buttonBorderRadius(value: "normal" | "rounded");
12
17
  static observedAttributes: string[];
13
18
  shadowRoot: ShadowRoot;
14
19
  constructor();