astro 3.3.4 → 3.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 (53) hide show
  1. package/components/viewtransitions.css +13 -0
  2. package/dist/@types/astro.d.ts +48 -1
  3. package/dist/assets/build/generate.d.ts +20 -16
  4. package/dist/assets/build/generate.js +125 -72
  5. package/dist/assets/types.d.ts +5 -4
  6. package/dist/assets/vite-plugin-assets.js +15 -7
  7. package/dist/cli/add/babel.d.ts +1 -1
  8. package/dist/content/utils.d.ts +9 -9
  9. package/dist/core/build/generate.js +21 -33
  10. package/dist/core/config/schema.d.ts +224 -187
  11. package/dist/core/config/schema.js +5 -2
  12. package/dist/core/config/settings.js +1 -0
  13. package/dist/core/constants.js +1 -1
  14. package/dist/core/create-vite.js +3 -1
  15. package/dist/core/dev/dev.js +1 -1
  16. package/dist/core/errors/errors-data.d.ts +2 -3
  17. package/dist/core/errors/errors-data.js +2 -2
  18. package/dist/core/messages.js +2 -2
  19. package/dist/core/render/core.js +1 -0
  20. package/dist/core/render/result.d.ts +1 -0
  21. package/dist/core/render/result.js +1 -0
  22. package/dist/integrations/index.js +3 -10
  23. package/dist/runtime/client/dev-overlay/entrypoint.d.ts +1 -0
  24. package/dist/runtime/client/dev-overlay/entrypoint.js +66 -0
  25. package/dist/runtime/client/dev-overlay/overlay.d.ts +33 -0
  26. package/dist/runtime/client/dev-overlay/overlay.js +415 -0
  27. package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +7 -0
  28. package/dist/runtime/client/dev-overlay/plugins/astro.js +66 -0
  29. package/dist/runtime/client/dev-overlay/plugins/audit.d.ts +7 -0
  30. package/dist/runtime/client/dev-overlay/plugins/audit.js +85 -0
  31. package/dist/runtime/client/dev-overlay/plugins/utils/highlight.d.ts +5 -0
  32. package/dist/runtime/client/dev-overlay/plugins/utils/highlight.js +44 -0
  33. package/dist/runtime/client/dev-overlay/plugins/xray.d.ts +7 -0
  34. package/dist/runtime/client/dev-overlay/plugins/xray.js +82 -0
  35. package/dist/runtime/client/dev-overlay/ui-library/card.d.ts +9 -0
  36. package/dist/runtime/client/dev-overlay/ui-library/card.js +67 -0
  37. package/dist/runtime/client/dev-overlay/ui-library/highlight.d.ts +7 -0
  38. package/dist/runtime/client/dev-overlay/ui-library/highlight.js +60 -0
  39. package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +10 -0
  40. package/dist/runtime/client/dev-overlay/ui-library/icons.js +21 -0
  41. package/dist/runtime/client/dev-overlay/ui-library/tooltip.d.ts +16 -0
  42. package/dist/runtime/client/dev-overlay/ui-library/tooltip.js +137 -0
  43. package/dist/runtime/client/dev-overlay/ui-library/window.d.ts +9 -0
  44. package/dist/runtime/client/dev-overlay/ui-library/window.js +70 -0
  45. package/dist/runtime/server/render/astro/render.js +2 -2
  46. package/dist/runtime/server/render/common.js +2 -2
  47. package/dist/runtime/server/render/component.js +1 -1
  48. package/dist/transitions/router.js +8 -6
  49. package/dist/type-utils.d.ts +1 -0
  50. package/dist/vite-plugin-astro-server/route.js +17 -1
  51. package/dist/vite-plugin-dev-overlay/vite-plugin-dev-overlay.d.ts +3 -0
  52. package/dist/vite-plugin-dev-overlay/vite-plugin-dev-overlay.js +24 -0
  53. package/package.json +4 -2
@@ -0,0 +1,82 @@
1
+ import { attachTooltipToHighlight, createHighlight, positionHighlight } from "./utils/highlight.js";
2
+ const icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#fff" d="M7.9 1.5v-.4a1.1 1.1 0 0 1 2.2 0v.4a1.1 1.1 0 1 1-2.2 0Zm-6.4 8.6a1.1 1.1 0 1 0 0-2.2h-.4a1.1 1.1 0 0 0 0 2.2h.4ZM12 3.7a1.1 1.1 0 0 0 1.4-.7l.4-1.1a1.1 1.1 0 0 0-2.1-.8l-.4 1.2a1.1 1.1 0 0 0 .7 1.4Zm-9.7 7.6-1.2.4a1.1 1.1 0 1 0 .8 2.1l1-.4a1.1 1.1 0 1 0-.6-2ZM20.8 17a1.9 1.9 0 0 1 0 2.6l-1.2 1.2a1.9 1.9 0 0 1-2.6 0l-4.3-4.2-1.6 3.6a1.9 1.9 0 0 1-1.7 1.2A1.9 1.9 0 0 1 7.5 20L2.7 5a1.9 1.9 0 0 1 2.4-2.4l15 5a1.9 1.9 0 0 1 .2 3.4l-3.7 1.6 4.2 4.3ZM19 18.3 14.6 14a1.9 1.9 0 0 1 .6-3l3.2-1.5L5.1 5.1l4.3 13.3 1.5-3.2a1.9 1.9 0 0 1 3-.6l4.4 4.4.7-.7Z"/></svg>';
3
+ var xray_default = {
4
+ id: "astro:xray",
5
+ name: "Xray",
6
+ icon,
7
+ init(canvas) {
8
+ let islandsOverlays = [];
9
+ addIslandsOverlay();
10
+ document.addEventListener("astro:after-swap", addIslandsOverlay);
11
+ document.addEventListener("astro:page-load", refreshIslandsOverlayPositions);
12
+ function addIslandsOverlay() {
13
+ islandsOverlays.forEach(({ highlightElement }) => {
14
+ highlightElement.remove();
15
+ });
16
+ islandsOverlays = [];
17
+ const islands = document.querySelectorAll("astro-island");
18
+ islands.forEach((island) => {
19
+ const computedStyle = window.getComputedStyle(island);
20
+ const islandElement = island.children[0] || island;
21
+ if (islandElement.offsetParent === null || computedStyle.display === "none") {
22
+ return;
23
+ }
24
+ const rect = islandElement.getBoundingClientRect();
25
+ const highlight = createHighlight(rect);
26
+ const tooltip = buildIslandTooltip(island);
27
+ attachTooltipToHighlight(highlight, tooltip, islandElement);
28
+ canvas.append(highlight);
29
+ islandsOverlays.push({ highlightElement: highlight, island: islandElement });
30
+ });
31
+ ["scroll", "resize"].forEach((event) => {
32
+ window.addEventListener(event, refreshIslandsOverlayPositions);
33
+ });
34
+ }
35
+ function refreshIslandsOverlayPositions() {
36
+ islandsOverlays.forEach(({ highlightElement, island: islandElement }) => {
37
+ const rect = islandElement.getBoundingClientRect();
38
+ positionHighlight(highlightElement, rect);
39
+ });
40
+ }
41
+ function buildIslandTooltip(island) {
42
+ const tooltip = document.createElement("astro-dev-overlay-tooltip");
43
+ tooltip.sections = [];
44
+ const islandProps = island.getAttribute("props") ? JSON.parse(island.getAttribute("props")) : {};
45
+ const islandClientDirective = island.getAttribute("client");
46
+ if (islandClientDirective) {
47
+ tooltip.sections.push({
48
+ title: "Client directive",
49
+ inlineTitle: `<code>client:${islandClientDirective}</code>`
50
+ });
51
+ }
52
+ if (Object.keys(islandProps).length > 0) {
53
+ tooltip.sections.push({
54
+ title: "Props",
55
+ content: `${Object.entries(islandProps).map((prop) => `<code>${prop[0]}=${getPropValue(prop[1])}</code>`).join(", ")}`
56
+ });
57
+ }
58
+ const islandComponentPath = island.getAttribute("component-url");
59
+ if (islandComponentPath) {
60
+ tooltip.sections.push({
61
+ content: islandComponentPath,
62
+ clickDescription: "Click to go to file",
63
+ async clickAction() {
64
+ await fetch(
65
+ "/__open-in-editor?file=" + encodeURIComponent(
66
+ window.__astro_dev_overlay__.root + islandComponentPath.slice(1)
67
+ )
68
+ );
69
+ }
70
+ });
71
+ }
72
+ return tooltip;
73
+ }
74
+ function getPropValue(prop) {
75
+ const [_, value] = prop;
76
+ return JSON.stringify(value, null, 2);
77
+ }
78
+ }
79
+ };
80
+ export {
81
+ xray_default as default
82
+ };
@@ -0,0 +1,9 @@
1
+ import { type Icon } from './icons.js';
2
+ export declare class DevOverlayCard extends HTMLElement {
3
+ icon?: Icon;
4
+ link?: string | undefined | null;
5
+ shadowRoot: ShadowRoot;
6
+ constructor();
7
+ connectedCallback(): void;
8
+ getElementForIcon(icon: Icon): string;
9
+ }
@@ -0,0 +1,67 @@
1
+ import { getIconElement, isDefinedIcon } from "./icons.js";
2
+ class DevOverlayCard extends HTMLElement {
3
+ icon;
4
+ link;
5
+ shadowRoot;
6
+ constructor() {
7
+ super();
8
+ this.shadowRoot = this.attachShadow({ mode: "open" });
9
+ this.link = this.getAttribute("link");
10
+ this.icon = this.hasAttribute("icon") ? this.getAttribute("icon") : void 0;
11
+ }
12
+ connectedCallback() {
13
+ const element = this.link ? "a" : "button";
14
+ this.shadowRoot.innerHTML = `
15
+ <style>
16
+ a, button {
17
+ display: block;
18
+ padding: 40px 16px;
19
+ border-radius: 8px;
20
+ border: 1px solid rgba(35, 38, 45, 1);
21
+ color: #fff;
22
+ font-size: 16px;
23
+ font-weight: 600;
24
+ line-height: 19px;
25
+ text-decoration: none;
26
+ }
27
+
28
+ a:hover, button:hover {
29
+ background: rgba(136, 58, 234, 0.33);
30
+ border: 1px solid rgba(113, 24, 226, 1)
31
+ }
32
+
33
+ svg {
34
+ display: block;
35
+ margin: 0 auto;
36
+ }
37
+
38
+ span {
39
+ margin-top: 8px;
40
+ display: block;
41
+ text-align: center;
42
+ }
43
+ </style>
44
+
45
+ <${element}${this.link ? ` href="${this.link}" target="_blank"` : ``}>
46
+ ${this.icon ? this.getElementForIcon(this.icon) : ""}
47
+ <span><slot /></span>
48
+ </${element}>
49
+ `;
50
+ }
51
+ getElementForIcon(icon) {
52
+ let iconElement;
53
+ if (isDefinedIcon(icon)) {
54
+ iconElement = getIconElement(icon);
55
+ } else {
56
+ iconElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
57
+ iconElement.setAttribute("viewBox", "0 0 16 16");
58
+ iconElement.innerHTML = icon;
59
+ }
60
+ iconElement?.style.setProperty("height", "24px");
61
+ iconElement?.style.setProperty("width", "24px");
62
+ return iconElement?.outerHTML ?? "";
63
+ }
64
+ }
65
+ export {
66
+ DevOverlayCard
67
+ };
@@ -0,0 +1,7 @@
1
+ import { type Icon } from './icons.js';
2
+ export declare class DevOverlayHighlight extends HTMLElement {
3
+ icon?: Icon | undefined | null;
4
+ shadowRoot: ShadowRoot;
5
+ constructor();
6
+ connectedCallback(): void;
7
+ }
@@ -0,0 +1,60 @@
1
+ import { getIconElement, isDefinedIcon } from "./icons.js";
2
+ class DevOverlayHighlight extends HTMLElement {
3
+ icon;
4
+ shadowRoot;
5
+ constructor() {
6
+ super();
7
+ this.shadowRoot = this.attachShadow({ mode: "open" });
8
+ this.icon = this.hasAttribute("icon") ? this.getAttribute("icon") : void 0;
9
+ this.shadowRoot.innerHTML = `
10
+ <style>
11
+ :host {
12
+ background: linear-gradient(180deg, rgba(224, 204, 250, 0.33) 0%, rgba(224, 204, 250, 0.0825) 100%);
13
+ border: 1px solid rgba(113, 24, 226, 1);
14
+ border-radius: 4px;
15
+ display: block;
16
+ width: 100%;
17
+ height: 100%;
18
+ position: absolute;
19
+ }
20
+
21
+ .icon {
22
+ width: 24px;
23
+ height: 24px;
24
+ background: linear-gradient(0deg, #B33E66, #B33E66), linear-gradient(0deg, #351722, #351722);
25
+ border: 1px solid rgba(53, 23, 34, 1);
26
+ border-radius: 9999px;
27
+ display: flex;
28
+ justify-content: center;
29
+ align-items: center;
30
+ position: absolute;
31
+ top: -15px;
32
+ right: -15px;
33
+ }
34
+ </style>
35
+ `;
36
+ }
37
+ connectedCallback() {
38
+ if (this.icon) {
39
+ let iconContainer = document.createElement("div");
40
+ iconContainer.classList.add("icon");
41
+ let iconElement;
42
+ if (isDefinedIcon(this.icon)) {
43
+ iconElement = getIconElement(this.icon);
44
+ } else {
45
+ iconElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
46
+ iconElement.setAttribute("viewBox", "0 0 16 16");
47
+ iconElement.innerHTML = this.icon;
48
+ }
49
+ if (iconElement) {
50
+ iconElement?.style.setProperty("width", "16px");
51
+ iconElement?.style.setProperty("height", "16px");
52
+ iconContainer.append(iconElement);
53
+ this.shadowRoot.append(iconContainer);
54
+ }
55
+ }
56
+ }
57
+ }
58
+ export {
59
+ DevOverlayHighlight
60
+ };
@@ -0,0 +1,10 @@
1
+ export type DefinedIcon = keyof typeof icons;
2
+ export type Icon = DefinedIcon | (string & NonNullable<unknown>);
3
+ export declare function isDefinedIcon(icon: Icon): icon is DefinedIcon;
4
+ export declare function getIconElement(name: keyof typeof icons | (string & NonNullable<unknown>)): SVGElement | undefined;
5
+ declare const icons: {
6
+ readonly 'astro:logo': "<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 85 107\"><path fill=\"#fff\" d=\"M27.6 91.1c-4.8-4.4-6.3-13.7-4.2-20.4 3.5 4.2 8.3 5.6 13.3 6.3 7.7 1.2 15.3.8 22.5-2.8l2.5-1.4c.7 2 .9 3.9.6 5.9-.6 4.9-3 8.7-6.9 11.5-1.5 1.2-3.2 2.2-4.8 3.3-4.9 3.3-6.2 7.2-4.4 12.9l.2.6a13 13 0 0 1-5.7-5 13.8 13.8 0 0 1-2.2-7.4c0-1.3 0-2.7-.2-4-.5-3.1-2-4.6-4.8-4.7a5.5 5.5 0 0 0-5.7 4.6l-.2.6Z\"/><path fill=\"url(#a)\" d=\"M27.6 91.1c-4.8-4.4-6.3-13.7-4.2-20.4 3.5 4.2 8.3 5.6 13.3 6.3 7.7 1.2 15.3.8 22.5-2.8l2.5-1.4c.7 2 .9 3.9.6 5.9-.6 4.9-3 8.7-6.9 11.5-1.5 1.2-3.2 2.2-4.8 3.3-4.9 3.3-6.2 7.2-4.4 12.9l.2.6a13 13 0 0 1-5.7-5 13.8 13.8 0 0 1-2.2-7.4c0-1.3 0-2.7-.2-4-.5-3.1-2-4.6-4.8-4.7a5.5 5.5 0 0 0-5.7 4.6l-.2.6Z\"/><path fill=\"#fff\" d=\"M0 69.6s14.3-7 28.7-7l10.8-33.5c.4-1.6 1.6-2.7 3-2.7 1.2 0 2.4 1.1 2.8 2.7l10.9 33.5c17 0 28.6 7 28.6 7L60.5 3.2c-.7-2-2-3.2-3.5-3.2H27.8c-1.6 0-2.7 1.3-3.4 3.2L0 69.6Z\"/><defs><linearGradient id=\"a\" x1=\"22.5\" x2=\"69.1\" y1=\"107\" y2=\"84.9\" gradientUnits=\"userSpaceOnUse\"><stop stop-color=\"#D83333\"/><stop offset=\"1\" stop-color=\"#F041FF\"/></linearGradient></defs></svg>";
7
+ readonly warning: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path fill=\"#fff\" d=\"M8 .40625c-1.5019 0-2.97007.445366-4.21886 1.27978C2.53236 2.52044 1.55905 3.70642.984293 5.094.40954 6.48157.259159 8.00842.552165 9.48147.845172 10.9545 1.56841 12.3076 2.63041 13.3696c1.06201 1.062 2.41508 1.7852 3.88813 2.0782 1.47304.293 2.99989.1427 4.38746-.4321 1.3876-.5747 2.5736-1.5481 3.408-2.7968.8344-1.2488 1.2798-2.717 1.2798-4.2189-.0023-2.0133-.8031-3.9435-2.2267-5.36713C11.9435 1.20925 10.0133.408483 8 .40625ZM8 13.9062c-1.16814 0-2.31006-.3463-3.28133-.9953-.97128-.649-1.7283-1.5715-2.17533-2.6507-.44703-1.0792-.56399-2.26675-.3361-3.41245.22789-1.1457.79041-2.1981 1.61641-3.0241.82601-.826 1.8784-1.38852 3.0241-1.61641 1.1457-.2279 2.33325-.11093 3.41245.3361 1.0793.44703 2.0017 1.20405 2.6507 2.17532.649.97128.9954 2.11319.9954 3.28134-.0017 1.56592-.6245 3.0672-1.7318 4.1745S9.56592 13.9046 8 13.9062Zm-.84375-5.62495V4.625c0-.22378.0889-.43839.24713-.59662.15824-.15824.37285-.24713.59662-.24713.22378 0 .43839.08889.59662.24713.15824.15823.24713.37284.24713.59662v3.65625c0 .22378-.08889.43839-.24713.59662C8.43839 9.03611 8.22378 9.125 8 9.125c-.22377 0-.43838-.08889-.59662-.24713-.15823-.15823-.24713-.37284-.24713-.59662ZM9.125 11.0938c0 .2225-.06598.44-.18959.625-.12362.185-.29932.3292-.50489.4143-.20556.0852-.43176.1074-.64999.064-.21823-.0434-.41869-.1505-.57602-.3079-.15734-.1573-.26448-.3577-.30789-.576-.04341-.2182-.02113-.4444.06402-.65.08515-.2055.22934-.3812.41435-.5049.185-.1236.40251-.18955.62501-.18955.29837 0 .58452.11855.7955.32955.21098.2109.3295.4971.3295.7955Z\"/></svg>";
8
+ readonly 'arrow-down': "<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 12 14\"><path fill=\"#13151A\" d=\"m11.0306 8.53063-4.5 4.49997c-.06968.0699-.15247.1254-.24364.1633-.09116.0378-.1889.0573-.28761.0573-.09871 0-.19645-.0195-.28762-.0573-.09116-.0379-.17395-.0934-.24363-.1633L.968098 8.53063c-.140896-.1409-.220051-.332-.220051-.53125 0-.19926.079155-.39036.220051-.53125.140892-.1409.331992-.22006.531252-.22006.19926 0 .39035.07916.53125.22006l3.21937 3.21937V1.5c0-.19891.07902-.38968.21967-.53033C5.61029.829018 5.80106.75 5.99997.75c.19891 0 .38968.079018.53033.21967.14065.14065.21967.33142.21967.53033v9.1875l3.21938-3.22c.14085-.1409.33195-.22005.53125-.22005.1993 0 .3904.07915.5312.22005.1409.1409.2201.33199.2201.53125s-.0792.39035-.2201.53125l-.0012.00063Z\"/></svg>";
9
+ };
10
+ export {};
@@ -0,0 +1,21 @@
1
+ function isDefinedIcon(icon) {
2
+ return icon in icons;
3
+ }
4
+ function getIconElement(name) {
5
+ const icon = icons[name];
6
+ if (!icon) {
7
+ return void 0;
8
+ }
9
+ const svgFragment = new DocumentFragment();
10
+ svgFragment.append(document.createRange().createContextualFragment(icon));
11
+ return svgFragment.firstElementChild;
12
+ }
13
+ const icons = {
14
+ "astro:logo": `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 85 107"><path fill="#fff" d="M27.6 91.1c-4.8-4.4-6.3-13.7-4.2-20.4 3.5 4.2 8.3 5.6 13.3 6.3 7.7 1.2 15.3.8 22.5-2.8l2.5-1.4c.7 2 .9 3.9.6 5.9-.6 4.9-3 8.7-6.9 11.5-1.5 1.2-3.2 2.2-4.8 3.3-4.9 3.3-6.2 7.2-4.4 12.9l.2.6a13 13 0 0 1-5.7-5 13.8 13.8 0 0 1-2.2-7.4c0-1.3 0-2.7-.2-4-.5-3.1-2-4.6-4.8-4.7a5.5 5.5 0 0 0-5.7 4.6l-.2.6Z"/><path fill="url(#a)" d="M27.6 91.1c-4.8-4.4-6.3-13.7-4.2-20.4 3.5 4.2 8.3 5.6 13.3 6.3 7.7 1.2 15.3.8 22.5-2.8l2.5-1.4c.7 2 .9 3.9.6 5.9-.6 4.9-3 8.7-6.9 11.5-1.5 1.2-3.2 2.2-4.8 3.3-4.9 3.3-6.2 7.2-4.4 12.9l.2.6a13 13 0 0 1-5.7-5 13.8 13.8 0 0 1-2.2-7.4c0-1.3 0-2.7-.2-4-.5-3.1-2-4.6-4.8-4.7a5.5 5.5 0 0 0-5.7 4.6l-.2.6Z"/><path fill="#fff" d="M0 69.6s14.3-7 28.7-7l10.8-33.5c.4-1.6 1.6-2.7 3-2.7 1.2 0 2.4 1.1 2.8 2.7l10.9 33.5c17 0 28.6 7 28.6 7L60.5 3.2c-.7-2-2-3.2-3.5-3.2H27.8c-1.6 0-2.7 1.3-3.4 3.2L0 69.6Z"/><defs><linearGradient id="a" x1="22.5" x2="69.1" y1="107" y2="84.9" gradientUnits="userSpaceOnUse"><stop stop-color="#D83333"/><stop offset="1" stop-color="#F041FF"/></linearGradient></defs></svg>`,
15
+ warning: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="#fff" d="M8 .40625c-1.5019 0-2.97007.445366-4.21886 1.27978C2.53236 2.52044 1.55905 3.70642.984293 5.094.40954 6.48157.259159 8.00842.552165 9.48147.845172 10.9545 1.56841 12.3076 2.63041 13.3696c1.06201 1.062 2.41508 1.7852 3.88813 2.0782 1.47304.293 2.99989.1427 4.38746-.4321 1.3876-.5747 2.5736-1.5481 3.408-2.7968.8344-1.2488 1.2798-2.717 1.2798-4.2189-.0023-2.0133-.8031-3.9435-2.2267-5.36713C11.9435 1.20925 10.0133.408483 8 .40625ZM8 13.9062c-1.16814 0-2.31006-.3463-3.28133-.9953-.97128-.649-1.7283-1.5715-2.17533-2.6507-.44703-1.0792-.56399-2.26675-.3361-3.41245.22789-1.1457.79041-2.1981 1.61641-3.0241.82601-.826 1.8784-1.38852 3.0241-1.61641 1.1457-.2279 2.33325-.11093 3.41245.3361 1.0793.44703 2.0017 1.20405 2.6507 2.17532.649.97128.9954 2.11319.9954 3.28134-.0017 1.56592-.6245 3.0672-1.7318 4.1745S9.56592 13.9046 8 13.9062Zm-.84375-5.62495V4.625c0-.22378.0889-.43839.24713-.59662.15824-.15824.37285-.24713.59662-.24713.22378 0 .43839.08889.59662.24713.15824.15823.24713.37284.24713.59662v3.65625c0 .22378-.08889.43839-.24713.59662C8.43839 9.03611 8.22378 9.125 8 9.125c-.22377 0-.43838-.08889-.59662-.24713-.15823-.15823-.24713-.37284-.24713-.59662ZM9.125 11.0938c0 .2225-.06598.44-.18959.625-.12362.185-.29932.3292-.50489.4143-.20556.0852-.43176.1074-.64999.064-.21823-.0434-.41869-.1505-.57602-.3079-.15734-.1573-.26448-.3577-.30789-.576-.04341-.2182-.02113-.4444.06402-.65.08515-.2055.22934-.3812.41435-.5049.185-.1236.40251-.18955.62501-.18955.29837 0 .58452.11855.7955.32955.21098.2109.3295.4971.3295.7955Z"/></svg>`,
16
+ "arrow-down": '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 12 14"><path fill="#13151A" d="m11.0306 8.53063-4.5 4.49997c-.06968.0699-.15247.1254-.24364.1633-.09116.0378-.1889.0573-.28761.0573-.09871 0-.19645-.0195-.28762-.0573-.09116-.0379-.17395-.0934-.24363-.1633L.968098 8.53063c-.140896-.1409-.220051-.332-.220051-.53125 0-.19926.079155-.39036.220051-.53125.140892-.1409.331992-.22006.531252-.22006.19926 0 .39035.07916.53125.22006l3.21937 3.21937V1.5c0-.19891.07902-.38968.21967-.53033C5.61029.829018 5.80106.75 5.99997.75c.19891 0 .38968.079018.53033.21967.14065.14065.21967.33142.21967.53033v9.1875l3.21938-3.22c.14085-.1409.33195-.22005.53125-.22005.1993 0 .3904.07915.5312.22005.1409.1409.2201.33199.2201.53125s-.0792.39035-.2201.53125l-.0012.00063Z"/></svg>'
17
+ };
18
+ export {
19
+ getIconElement,
20
+ isDefinedIcon
21
+ };
@@ -0,0 +1,16 @@
1
+ import { type Icon } from './icons.js';
2
+ export interface DevOverlayTooltipSection {
3
+ title?: string;
4
+ inlineTitle?: string;
5
+ icon?: Icon;
6
+ content?: string;
7
+ clickAction?: () => void | Promise<void>;
8
+ clickDescription?: string;
9
+ }
10
+ export declare class DevOverlayTooltip extends HTMLElement {
11
+ sections: DevOverlayTooltipSection[];
12
+ shadowRoot: ShadowRoot;
13
+ constructor();
14
+ connectedCallback(): void;
15
+ getElementForIcon(icon: Icon | (string & NonNullable<unknown>)): string;
16
+ }
@@ -0,0 +1,137 @@
1
+ import { getIconElement, isDefinedIcon } from "./icons.js";
2
+ class DevOverlayTooltip extends HTMLElement {
3
+ sections = [];
4
+ shadowRoot;
5
+ constructor() {
6
+ super();
7
+ this.shadowRoot = this.attachShadow({ mode: "open" });
8
+ }
9
+ connectedCallback() {
10
+ this.shadowRoot.innerHTML = `
11
+ <style>
12
+ :host {
13
+ position: absolute;
14
+ display: none;
15
+ color: white;
16
+ background: linear-gradient(0deg, #310A65, #310A65), linear-gradient(0deg, #7118E2, #7118E2);
17
+ border: 1px solid rgba(113, 24, 226, 1);
18
+ border-radius: 4px;
19
+ padding: 0;
20
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
21
+ font-size: 14px;
22
+ margin: 0;
23
+ z-index: 9999999;
24
+ max-width: 45ch;
25
+ width: fit-content;
26
+ min-width: 27ch;
27
+ }
28
+
29
+ :host([data-show="true"]) {
30
+ display: block;
31
+ }
32
+
33
+ svg {
34
+ vertical-align: bottom;
35
+ margin-right: 4px;
36
+ }
37
+
38
+ hr {
39
+ border: 1px solid rgba(136, 58, 234, 0.33);
40
+ padding: 0;
41
+ margin: 0;
42
+ }
43
+
44
+ section {
45
+ padding: 8px;
46
+ }
47
+
48
+ .section-content {
49
+ max-height: 250px;
50
+ overflow-y: auto;
51
+ }
52
+
53
+ .modal-title {
54
+ display: flex;
55
+ justify-content: space-between;
56
+ align-items: center;
57
+ }
58
+
59
+ .modal-main-title {
60
+ font-weight: bold;
61
+ }
62
+
63
+ .modal-title + div {
64
+ margin-top: 8px;
65
+ }
66
+
67
+ .modal-cta {
68
+ display: block;
69
+ font-weight: bold;
70
+ font-size: 0.9em;
71
+ }
72
+
73
+ .clickable-section {
74
+ background: rgba(113, 24, 226, 1);
75
+ padding: 8px;
76
+ border: 0;
77
+ color: white;
78
+ font-family: system-ui, sans-serif;
79
+ text-align: left;
80
+ line-height: 1.2;
81
+ white-space: nowrap;
82
+ text-decoration: none;
83
+ margin: 0;
84
+ width: 100%;
85
+ }
86
+
87
+ .clickable-section:hover {
88
+ cursor: pointer;
89
+ }
90
+
91
+ code {
92
+ background: rgba(136, 58, 234, 0.33);
93
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
94
+ border-radius: 2px;
95
+ font-size: 14px;
96
+ padding: 2px;
97
+ }
98
+ `;
99
+ const fragment = new DocumentFragment();
100
+ this.sections.forEach((section, index) => {
101
+ const sectionElement = section.clickAction ? document.createElement("button") : document.createElement("section");
102
+ if (section.clickAction) {
103
+ sectionElement.classList.add("clickable-section");
104
+ sectionElement.addEventListener("click", async () => {
105
+ await section.clickAction();
106
+ });
107
+ }
108
+ sectionElement.innerHTML = `
109
+ ${section.title ? `<div class="modal-title"><span class="modal-main-title">
110
+ ${section.icon ? this.getElementForIcon(section.icon) : ""}${section.title}</span>${section.inlineTitle ?? ""}</div>` : ""}
111
+ ${section.content ? `<div class="section-content">${section.content}</div>` : ""}
112
+ ${section.clickDescription ? `<span class="modal-cta">${section.clickDescription}</span>` : ""}
113
+ `;
114
+ fragment.append(sectionElement);
115
+ if (index < this.sections.length - 1) {
116
+ fragment.append(document.createElement("hr"));
117
+ }
118
+ });
119
+ this.shadowRoot.append(fragment);
120
+ }
121
+ getElementForIcon(icon) {
122
+ let iconElement;
123
+ if (isDefinedIcon(icon)) {
124
+ iconElement = getIconElement(icon);
125
+ } else {
126
+ iconElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
127
+ iconElement.setAttribute("viewBox", "0 0 16 16");
128
+ iconElement.innerHTML = icon;
129
+ }
130
+ iconElement?.style.setProperty("width", "16px");
131
+ iconElement?.style.setProperty("height", "16px");
132
+ return iconElement?.outerHTML ?? "";
133
+ }
134
+ }
135
+ export {
136
+ DevOverlayTooltip
137
+ };
@@ -0,0 +1,9 @@
1
+ import { type Icon } from './icons.js';
2
+ export declare class DevOverlayWindow extends HTMLElement {
3
+ windowTitle?: string | undefined | null;
4
+ windowIcon?: Icon | undefined | null;
5
+ shadowRoot: ShadowRoot;
6
+ constructor();
7
+ connectedCallback(): Promise<void>;
8
+ getElementForIcon(icon: Icon): string | undefined;
9
+ }
@@ -0,0 +1,70 @@
1
+ import { getIconElement, isDefinedIcon } from "./icons.js";
2
+ class DevOverlayWindow extends HTMLElement {
3
+ windowTitle;
4
+ windowIcon;
5
+ shadowRoot;
6
+ constructor() {
7
+ super();
8
+ this.shadowRoot = this.attachShadow({ mode: "open" });
9
+ this.windowTitle = this.getAttribute("window-title");
10
+ this.windowIcon = this.hasAttribute("window-icon") ? this.getAttribute("window-icon") : void 0;
11
+ }
12
+ async connectedCallback() {
13
+ this.shadowRoot.innerHTML = `
14
+ <style>
15
+ :host {
16
+ display: flex;
17
+ flex-direction: column;
18
+ background: linear-gradient(0deg, #13151A, #13151A), linear-gradient(0deg, #343841, #343841);
19
+ border: 1px solid rgba(52, 56, 65, 1);
20
+ width: 640px;
21
+ height: 480px;
22
+ border-radius: 12px;
23
+ padding: 24px;
24
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
25
+ color: rgba(204, 206, 216, 1);
26
+ position: fixed;
27
+ z-index: 999999999;
28
+ top: 55%;
29
+ left: 50%;
30
+ transform: translate(-50%, -50%);
31
+ }
32
+
33
+ h1 {
34
+ margin: 0;
35
+ font-weight: 600;
36
+ color: #fff;
37
+ }
38
+
39
+ h1 svg {
40
+ vertical-align: text-bottom;
41
+ margin-right: 8px;
42
+ }
43
+
44
+ hr {
45
+ border: 1px solid rgba(27, 30, 36, 1);
46
+ margin: 1em 0;
47
+ }
48
+ </style>
49
+
50
+ <h1>${this.windowIcon ? this.getElementForIcon(this.windowIcon) : ""}${this.windowTitle ?? ""}</h1>
51
+ <hr />
52
+ <slot />
53
+ `;
54
+ }
55
+ getElementForIcon(icon) {
56
+ if (isDefinedIcon(icon)) {
57
+ const iconElement = getIconElement(icon);
58
+ iconElement?.style.setProperty("height", "1em");
59
+ return iconElement?.outerHTML;
60
+ } else {
61
+ const iconElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
62
+ iconElement.setAttribute("viewBox", "0 0 16 16");
63
+ iconElement.innerHTML = icon;
64
+ return iconElement.outerHTML;
65
+ }
66
+ }
67
+ }
68
+ export {
69
+ DevOverlayWindow
70
+ };
@@ -18,7 +18,7 @@ async function renderToString(result, componentFactory, props, children, isPage
18
18
  write(chunk) {
19
19
  if (isPage && !renderedFirstPageChunk) {
20
20
  renderedFirstPageChunk = true;
21
- if (!/<!doctype html/i.test(String(chunk))) {
21
+ if (!result.partial && !/<!doctype html/i.test(String(chunk))) {
22
22
  const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
23
23
  str += doctype;
24
24
  }
@@ -51,7 +51,7 @@ async function renderToReadableStream(result, componentFactory, props, children,
51
51
  write(chunk) {
52
52
  if (isPage && !renderedFirstPageChunk) {
53
53
  renderedFirstPageChunk = true;
54
- if (!/<!doctype html/i.test(String(chunk))) {
54
+ if (!result.partial && !/<!doctype html/i.test(String(chunk))) {
55
55
  const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
56
56
  controller.enqueue(encoder.encode(doctype));
57
57
  }
@@ -28,13 +28,13 @@ function stringifyChunk(result, chunk) {
28
28
  }
29
29
  }
30
30
  case "head": {
31
- if (result._metadata.hasRenderedHead) {
31
+ if (result._metadata.hasRenderedHead || result.partial) {
32
32
  return "";
33
33
  }
34
34
  return renderAllHeadContent(result);
35
35
  }
36
36
  case "maybe-head": {
37
- if (result._metadata.hasRenderedHead || result._metadata.headInTree) {
37
+ if (result._metadata.hasRenderedHead || result._metadata.headInTree || result.partial) {
38
38
  return "";
39
39
  }
40
40
  return renderAllHeadContent(result);
@@ -372,7 +372,7 @@ async function renderComponentToString(result, displayName, Component, props, sl
372
372
  write(chunk) {
373
373
  if (isPage && !renderedFirstPageChunk) {
374
374
  renderedFirstPageChunk = true;
375
- if (!/<!doctype html/i.test(String(chunk))) {
375
+ if (!result.partial && !/<!doctype html/i.test(String(chunk))) {
376
376
  const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
377
377
  str += doctype + head;
378
378
  }
@@ -9,10 +9,7 @@ const announce = () => {
9
9
  let div = document.createElement("div");
10
10
  div.setAttribute("aria-live", "assertive");
11
11
  div.setAttribute("aria-atomic", "true");
12
- div.setAttribute(
13
- "style",
14
- "position:absolute;left:0;top:0;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;white-space:nowrap;width:1px;height:1px"
15
- );
12
+ div.className = "astro-route-announcer";
16
13
  document.body.append(div);
17
14
  setTimeout(
18
15
  () => {
@@ -362,9 +359,14 @@ if (inBrowser) {
362
359
  async function prepareForClientOnlyComponents(newDocument, toLocation) {
363
360
  if (newDocument.body.querySelector(`astro-island[client='only']`)) {
364
361
  const nextPage = document.createElement("iframe");
365
- nextPage.setAttribute("src", toLocation.href);
362
+ nextPage.srcdoc = (newDocument.doctype ? "<!DOCTYPE html>" : "") + newDocument.documentElement.outerHTML;
366
363
  nextPage.style.display = "none";
367
364
  document.body.append(nextPage);
365
+ nextPage.contentWindow.console = Object.keys(console).reduce((acc, key) => {
366
+ acc[key] = () => {
367
+ };
368
+ return acc;
369
+ }, {});
368
370
  await hydrationDone(nextPage);
369
371
  const nextHead = nextPage.contentDocument?.head;
370
372
  if (nextHead) {
@@ -375,7 +377,7 @@ async function prepareForClientOnlyComponents(newDocument, toLocation) {
375
377
  viteIds.forEach((id) => {
376
378
  const style = document.head.querySelector(`style[${VITE_ID}="${id}"]`);
377
379
  if (style && !newDocument.head.querySelector(`style[${VITE_ID}="${id}"]`)) {
378
- newDocument.head.appendChild(style);
380
+ newDocument.head.appendChild(style.cloneNode(true));
379
381
  }
380
382
  });
381
383
  }
@@ -12,3 +12,4 @@ export type KebabKeys<T> = {
12
12
  [K in keyof T as K extends string ? Kebab<K> : K]: T[K];
13
13
  };
14
14
  export type ValueOf<T> = T[keyof T];
15
+ export type MapValue<T> = T extends Map<any, infer V> ? V : never;
@@ -1,9 +1,10 @@
1
+ import { fileURLToPath } from "node:url";
1
2
  import { AstroErrorData, isAstroError } from "../core/errors/index.js";
2
3
  import { loadMiddleware } from "../core/middleware/loadMiddleware.js";
3
4
  import { createRenderContext, getParamsAndProps } from "../core/render/index.js";
4
5
  import { createRequest } from "../core/request.js";
5
6
  import { matchAllRoutes } from "../core/routing/index.js";
6
- import { isPage } from "../core/util.js";
7
+ import { isPage, resolveIdToUrl } from "../core/util.js";
7
8
  import { getSortedPreloadedMatches } from "../prerender/routing.js";
8
9
  import { isServerLikeOutput } from "../prerender/utils.js";
9
10
  import { PAGE_SCRIPT_ID } from "../vite-plugin-scripts/index.js";
@@ -199,6 +200,21 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
199
200
  props: { type: "module", src: "/@vite/client" },
200
201
  children: ""
201
202
  });
203
+ if (settings.config.experimental.devOverlay) {
204
+ scripts.add({
205
+ props: {
206
+ type: "module",
207
+ src: await resolveIdToUrl(moduleLoader, "astro/runtime/client/dev-overlay/entrypoint.js")
208
+ },
209
+ children: ""
210
+ });
211
+ scripts.add({
212
+ props: {},
213
+ children: `window.__astro_dev_overlay__ = {root: ${JSON.stringify(
214
+ fileURLToPath(settings.config.root)
215
+ )}}`
216
+ });
217
+ }
202
218
  }
203
219
  for (const script of settings.scripts) {
204
220
  if (script.stage === "head-inline") {
@@ -0,0 +1,3 @@
1
+ import type * as vite from 'vite';
2
+ import type { AstroPluginOptions } from '../@types/astro.js';
3
+ export default function astroDevOverlay({ settings }: AstroPluginOptions): vite.Plugin;
@@ -0,0 +1,24 @@
1
+ const VIRTUAL_MODULE_ID = "astro:dev-overlay";
2
+ const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
3
+ function astroDevOverlay({ settings }) {
4
+ return {
5
+ name: "astro:dev-overlay",
6
+ resolveId(id) {
7
+ if (id === VIRTUAL_MODULE_ID) {
8
+ return resolvedVirtualModuleId;
9
+ }
10
+ },
11
+ async load(id) {
12
+ if (id === resolvedVirtualModuleId) {
13
+ return `
14
+ export const loadDevOverlayPlugins = async () => {
15
+ return [${settings.devOverlayPlugins.map((plugin) => `(await import('${plugin}')).default`).join(",")}];
16
+ };
17
+ `;
18
+ }
19
+ }
20
+ };
21
+ }
22
+ export {
23
+ astroDevOverlay as default
24
+ };