astro 4.0.0-beta.7 → 4.0.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.
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/runtime/client/dev-overlay/entrypoint.js +1 -1
- package/dist/runtime/client/dev-overlay/overlay.js +10 -6
- package/dist/runtime/client/dev-overlay/plugins/audit/index.js +7 -3
- package/dist/runtime/client/dev-overlay/plugins/utils/highlight.d.ts +1 -2
- package/dist/runtime/client/dev-overlay/plugins/utils/highlight.js +3 -12
- package/dist/runtime/client/dev-overlay/plugins/xray.js +7 -7
- package/dist/runtime/client/dev-overlay/ui-library/highlight.js +1 -0
- package/dist/runtime/client/dev-overlay/ui-library/tooltip.js +1 -1
- package/package.json +2 -2
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -21,7 +21,7 @@ async function dev(inlineConfig) {
|
|
|
21
21
|
base: restart.container.settings.config.base
|
|
22
22
|
})
|
|
23
23
|
);
|
|
24
|
-
const currentVersion = "4.0.0
|
|
24
|
+
const currentVersion = "4.0.0";
|
|
25
25
|
if (currentVersion.includes("-")) {
|
|
26
26
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
27
27
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.0.0
|
|
39
|
+
const version = "4.0.0";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -258,7 +258,7 @@ function printHelp({
|
|
|
258
258
|
message.push(
|
|
259
259
|
linebreak(),
|
|
260
260
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
261
|
-
`v${"4.0.0
|
|
261
|
+
`v${"4.0.0"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -101,7 +101,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
101
101
|
box-shadow: 0px 0px 0px 0px rgba(19, 21, 26, 0.30), 0px 1px 2px 0px rgba(19, 21, 26, 0.29), 0px 4px 4px 0px rgba(19, 21, 26, 0.26), 0px 10px 6px 0px rgba(19, 21, 26, 0.15), 0px 17px 7px 0px rgba(19, 21, 26, 0.04), 0px 26px 7px 0px rgba(19, 21, 26, 0.01);
|
|
102
102
|
width: 192px;
|
|
103
103
|
padding: 8px;
|
|
104
|
-
z-index:
|
|
104
|
+
z-index: 2000000010;
|
|
105
105
|
transform: translate(-50%, 0%);
|
|
106
106
|
position: fixed;
|
|
107
107
|
bottom: 72px;
|
|
@@ -40,7 +40,7 @@ class AstroDevOverlay extends HTMLElement {
|
|
|
40
40
|
bottom: 0px;
|
|
41
41
|
left: 50%;
|
|
42
42
|
transform: translate(-50%, 0%);
|
|
43
|
-
z-index:
|
|
43
|
+
z-index: 2000000010;
|
|
44
44
|
display: flex;
|
|
45
45
|
flex-direction: column;
|
|
46
46
|
align-items: center;
|
|
@@ -239,9 +239,12 @@ class AstroDevOverlay extends HTMLElement {
|
|
|
239
239
|
this.shadowRoot?.append(pluginCanvas);
|
|
240
240
|
});
|
|
241
241
|
if ("requestIdleCallback" in window) {
|
|
242
|
-
window.requestIdleCallback(
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
window.requestIdleCallback(
|
|
243
|
+
async () => {
|
|
244
|
+
this.plugins.map((plugin) => this.initPlugin(plugin));
|
|
245
|
+
},
|
|
246
|
+
{ timeout: 300 }
|
|
247
|
+
);
|
|
245
248
|
} else {
|
|
246
249
|
setTimeout(async () => {
|
|
247
250
|
this.plugins.map((plugin) => this.initPlugin(plugin));
|
|
@@ -263,8 +266,8 @@ class AstroDevOverlay extends HTMLElement {
|
|
|
263
266
|
attachEvents() {
|
|
264
267
|
const items = this.shadowRoot.querySelectorAll(".item");
|
|
265
268
|
items.forEach((item) => {
|
|
266
|
-
item.addEventListener("click", async (
|
|
267
|
-
const target =
|
|
269
|
+
item.addEventListener("click", async (event) => {
|
|
270
|
+
const target = event.currentTarget;
|
|
268
271
|
if (!target || !(target instanceof HTMLElement))
|
|
269
272
|
return;
|
|
270
273
|
const id = target.dataset.pluginId;
|
|
@@ -273,6 +276,7 @@ class AstroDevOverlay extends HTMLElement {
|
|
|
273
276
|
const plugin = this.getPluginById(id);
|
|
274
277
|
if (!plugin)
|
|
275
278
|
return;
|
|
279
|
+
event.stopPropagation();
|
|
276
280
|
await this.togglePluginStatus(plugin);
|
|
277
281
|
});
|
|
278
282
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachTooltipToHighlight,
|
|
3
3
|
createHighlight,
|
|
4
|
+
getElementsPositionInDocument,
|
|
4
5
|
positionHighlight
|
|
5
6
|
} from "../utils/highlight.js";
|
|
6
7
|
import { createWindowElement } from "../utils/window.js";
|
|
@@ -104,7 +105,7 @@ var audit_default = {
|
|
|
104
105
|
margin: 0;
|
|
105
106
|
font-size: 22px;
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
|
|
108
109
|
astro-dev-toolbar-icon {
|
|
109
110
|
width: 1em;
|
|
110
111
|
height: 1em;
|
|
@@ -143,15 +144,18 @@ var audit_default = {
|
|
|
143
144
|
const computedStyle = window.getComputedStyle(originalElement);
|
|
144
145
|
const targetedElement = originalElement.children[0] || originalElement;
|
|
145
146
|
if (targetedElement.offsetParent === null || computedStyle.display === "none") {
|
|
146
|
-
audits.push();
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
if (originalElement.nodeName === "IMG" && !originalElement.complete) {
|
|
150
|
-
|
|
150
|
+
return;
|
|
151
151
|
}
|
|
152
152
|
const rect = originalElement.getBoundingClientRect();
|
|
153
153
|
const highlight = createHighlight(rect, "warning");
|
|
154
154
|
const tooltip = buildAuditTooltip(rule, originalElement);
|
|
155
|
+
const { isFixed } = getElementsPositionInDocument(originalElement);
|
|
156
|
+
if (isFixed) {
|
|
157
|
+
tooltip.style.position = highlight.style.position = "fixed";
|
|
158
|
+
}
|
|
155
159
|
attachTooltipToHighlight(highlight, tooltip, originalElement);
|
|
156
160
|
canvas.append(highlight);
|
|
157
161
|
audits.push({ highlightElement: highlight, auditedElement: originalElement });
|
|
@@ -2,8 +2,7 @@ import type { DevOverlayHighlight } from '../../ui-library/highlight.js';
|
|
|
2
2
|
import type { Icon } from '../../ui-library/icons.js';
|
|
3
3
|
export declare function createHighlight(rect: DOMRect, icon?: Icon): DevOverlayHighlight;
|
|
4
4
|
export declare function getElementsPositionInDocument(el: Element): {
|
|
5
|
-
|
|
6
|
-
fixed: boolean;
|
|
5
|
+
isFixed: boolean;
|
|
7
6
|
};
|
|
8
7
|
export declare function positionHighlight(highlight: DevOverlayHighlight, rect: DOMRect): void;
|
|
9
8
|
export declare function attachTooltipToHighlight(highlight: DevOverlayHighlight, tooltip: HTMLElement, originalElement: Element): void;
|
|
@@ -11,23 +11,17 @@ function createHighlight(rect, icon) {
|
|
|
11
11
|
return highlight;
|
|
12
12
|
}
|
|
13
13
|
function getElementsPositionInDocument(el) {
|
|
14
|
-
let
|
|
15
|
-
let fixed = false;
|
|
14
|
+
let isFixed = false;
|
|
16
15
|
let current = el;
|
|
17
16
|
while (current instanceof Element) {
|
|
18
17
|
let style = getComputedStyle(current);
|
|
19
|
-
let zIndex = Number(style.zIndex);
|
|
20
|
-
if (!Number.isNaN(zIndex) && zIndex > highestZIndex) {
|
|
21
|
-
highestZIndex = zIndex;
|
|
22
|
-
}
|
|
23
18
|
if (style.position === "fixed") {
|
|
24
|
-
|
|
19
|
+
isFixed = true;
|
|
25
20
|
}
|
|
26
21
|
current = current.parentNode;
|
|
27
22
|
}
|
|
28
23
|
return {
|
|
29
|
-
|
|
30
|
-
fixed
|
|
24
|
+
isFixed
|
|
31
25
|
};
|
|
32
26
|
}
|
|
33
27
|
function positionHighlight(highlight, rect) {
|
|
@@ -40,10 +34,8 @@ function positionHighlight(highlight, rect) {
|
|
|
40
34
|
}
|
|
41
35
|
function attachTooltipToHighlight(highlight, tooltip, originalElement) {
|
|
42
36
|
highlight.shadowRoot.append(tooltip);
|
|
43
|
-
const originalZIndex = highlight.style.zIndex;
|
|
44
37
|
["mouseover", "focus"].forEach((event) => {
|
|
45
38
|
highlight.addEventListener(event, () => {
|
|
46
|
-
highlight.style.zIndex = "9999999999";
|
|
47
39
|
tooltip.dataset.show = "true";
|
|
48
40
|
const originalRect = originalElement.getBoundingClientRect();
|
|
49
41
|
const dialogRect = tooltip.getBoundingClientRect();
|
|
@@ -57,7 +49,6 @@ function attachTooltipToHighlight(highlight, tooltip, originalElement) {
|
|
|
57
49
|
["mouseout", "blur"].forEach((event) => {
|
|
58
50
|
highlight.addEventListener(event, () => {
|
|
59
51
|
tooltip.dataset.show = "false";
|
|
60
|
-
highlight.style.zIndex = originalZIndex;
|
|
61
52
|
});
|
|
62
53
|
});
|
|
63
54
|
}
|
|
@@ -92,9 +92,8 @@ var xray_default = {
|
|
|
92
92
|
const rect = islandElement.getBoundingClientRect();
|
|
93
93
|
const highlight = createHighlight(rect);
|
|
94
94
|
const tooltip = buildIslandTooltip(island);
|
|
95
|
-
const {
|
|
96
|
-
|
|
97
|
-
if (fixed) {
|
|
95
|
+
const { isFixed } = getElementsPositionInDocument(islandElement);
|
|
96
|
+
if (isFixed) {
|
|
98
97
|
tooltip.style.position = highlight.style.position = "fixed";
|
|
99
98
|
}
|
|
100
99
|
attachTooltipToHighlight(highlight, tooltip, islandElement);
|
|
@@ -122,13 +121,14 @@ var xray_default = {
|
|
|
122
121
|
inlineTitle: `<code>client:${islandClientDirective}</code>`
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
const islandPropsEntries = Object.entries(islandProps).filter(
|
|
125
|
+
(prop) => !prop[0].startsWith("data-astro-cid-")
|
|
126
|
+
);
|
|
127
|
+
if (islandPropsEntries.length > 0) {
|
|
126
128
|
tooltip.sections.push({
|
|
127
129
|
title: "Props",
|
|
128
130
|
content: `<pre><code>${JSON.stringify(
|
|
129
|
-
Object.fromEntries(
|
|
130
|
-
Object.entries(islandProps).map((prop) => [prop[0], prop[1][1]])
|
|
131
|
-
),
|
|
131
|
+
Object.fromEntries(islandPropsEntries.map((prop) => [prop[0], prop[1][1]])),
|
|
132
132
|
void 0,
|
|
133
133
|
2
|
|
134
134
|
)}</code></pre>`
|
|
@@ -20,7 +20,7 @@ class DevOverlayTooltip extends HTMLElement {
|
|
|
20
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
21
|
font-size: 14px;
|
|
22
22
|
margin: 0;
|
|
23
|
-
z-index:
|
|
23
|
+
z-index: 2000000001;
|
|
24
24
|
max-width: 45ch;
|
|
25
25
|
width: fit-content;
|
|
26
26
|
min-width: 30ch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"yargs-parser": "^21.1.1",
|
|
159
159
|
"zod": "^3.22.4",
|
|
160
160
|
"@astrojs/internal-helpers": "0.2.1",
|
|
161
|
-
"@astrojs/markdown-remark": "4.0.0
|
|
161
|
+
"@astrojs/markdown-remark": "4.0.0",
|
|
162
162
|
"@astrojs/telemetry": "3.0.4"
|
|
163
163
|
},
|
|
164
164
|
"optionalDependencies": {
|