astro 3.3.3 → 3.3.4
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
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.3.
|
|
23
|
+
const currentVersion = "3.3.4";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.3.
|
|
53
|
+
const version = "3.3.4";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.3.
|
|
238
|
+
`v${"3.3.4"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -16,7 +16,7 @@ function renderAllHeadContent(result) {
|
|
|
16
16
|
return renderElement("script", script, false);
|
|
17
17
|
});
|
|
18
18
|
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement("link", link, false));
|
|
19
|
-
let content =
|
|
19
|
+
let content = styles.join("\n") + links.join("\n") + scripts.join("\n");
|
|
20
20
|
if (result._metadata.extraHead.length > 0) {
|
|
21
21
|
for (const part of result._metadata.extraHead) {
|
|
22
22
|
content += part;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const updateScrollPosition = (positions) => history.state && history.replaceState({ ...history.state, ...positions }, "");
|
|
2
2
|
const inBrowser = import.meta.env.SSR === false;
|
|
3
3
|
const supportsViewTransitions = inBrowser && !!document.startViewTransition;
|
|
4
4
|
const transitionEnabledOnThisPage = () => inBrowser && !!document.querySelector('[name="astro-view-transitions-enabled"]');
|
|
@@ -80,11 +80,6 @@ function getFallback() {
|
|
|
80
80
|
}
|
|
81
81
|
return "animate";
|
|
82
82
|
}
|
|
83
|
-
function markScriptsExec() {
|
|
84
|
-
for (const script of document.scripts) {
|
|
85
|
-
script.dataset.astroExec = "";
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
83
|
function runScripts() {
|
|
89
84
|
let wait = Promise.resolve();
|
|
90
85
|
for (const script of Array.from(document.scripts)) {
|
|
@@ -113,7 +108,7 @@ function isInfinite(animation) {
|
|
|
113
108
|
const style = window.getComputedStyle(effect.target, effect.pseudoElement);
|
|
114
109
|
return style.animationIterationCount === "infinite";
|
|
115
110
|
}
|
|
116
|
-
const
|
|
111
|
+
const moveToLocation = (toLocation, replace, intraPage) => {
|
|
117
112
|
const fresh = !samePage(toLocation);
|
|
118
113
|
let scrolledToTop = false;
|
|
119
114
|
if (toLocation.href !== location.href) {
|
|
@@ -140,11 +135,31 @@ const updateHistoryAndScrollPosition = (toLocation, replace, intraPage) => {
|
|
|
140
135
|
}
|
|
141
136
|
}
|
|
142
137
|
};
|
|
138
|
+
function stylePreloadLinks(newDocument) {
|
|
139
|
+
const links = [];
|
|
140
|
+
for (const el of newDocument.querySelectorAll("head link[rel=stylesheet]")) {
|
|
141
|
+
if (!document.querySelector(
|
|
142
|
+
`[${PERSIST_ATTR}="${el.getAttribute(
|
|
143
|
+
PERSIST_ATTR
|
|
144
|
+
)}"], link[rel=stylesheet][href="${el.getAttribute("href")}"]`
|
|
145
|
+
)) {
|
|
146
|
+
const c = document.createElement("link");
|
|
147
|
+
c.setAttribute("rel", "preload");
|
|
148
|
+
c.setAttribute("as", "style");
|
|
149
|
+
c.setAttribute("href", el.getAttribute("href"));
|
|
150
|
+
links.push(
|
|
151
|
+
new Promise((resolve) => {
|
|
152
|
+
["load", "error"].forEach((evName) => c.addEventListener(evName, resolve));
|
|
153
|
+
document.head.append(c);
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return links;
|
|
159
|
+
}
|
|
143
160
|
async function updateDOM(newDocument, toLocation, options, popState, fallback) {
|
|
144
161
|
const persistedHeadElement = (el) => {
|
|
145
162
|
const id = el.getAttribute(PERSIST_ATTR);
|
|
146
|
-
if (id === "")
|
|
147
|
-
return void 0;
|
|
148
163
|
const newEl = id && newDocument.head.querySelector(`[${PERSIST_ATTR}="${id}"]`);
|
|
149
164
|
if (newEl) {
|
|
150
165
|
return newEl;
|
|
@@ -201,7 +216,7 @@ async function updateDOM(newDocument, toLocation, options, popState, fallback) {
|
|
|
201
216
|
const newEl = persistedHeadElement(el);
|
|
202
217
|
if (newEl) {
|
|
203
218
|
newEl.remove();
|
|
204
|
-
} else
|
|
219
|
+
} else {
|
|
205
220
|
el.remove();
|
|
206
221
|
}
|
|
207
222
|
}
|
|
@@ -220,41 +235,20 @@ async function updateDOM(newDocument, toLocation, options, popState, fallback) {
|
|
|
220
235
|
if (popState) {
|
|
221
236
|
scrollTo(popState.scrollX, popState.scrollY);
|
|
222
237
|
} else {
|
|
223
|
-
|
|
238
|
+
moveToLocation(toLocation, options.history === "replace", false);
|
|
224
239
|
}
|
|
225
240
|
triggerEvent("astro:after-swap");
|
|
226
241
|
};
|
|
227
|
-
const links =
|
|
228
|
-
for (const el of newDocument.querySelectorAll("head link[rel=stylesheet]")) {
|
|
229
|
-
if (!document.querySelector(
|
|
230
|
-
`[${PERSIST_ATTR}="${el.getAttribute(
|
|
231
|
-
PERSIST_ATTR
|
|
232
|
-
)}"], link[rel=stylesheet][href="${el.getAttribute("href")}"]`
|
|
233
|
-
)) {
|
|
234
|
-
const c = document.createElement("link");
|
|
235
|
-
c.setAttribute("rel", "preload");
|
|
236
|
-
c.setAttribute("as", "style");
|
|
237
|
-
c.setAttribute("href", el.getAttribute("href"));
|
|
238
|
-
links.push(
|
|
239
|
-
new Promise((resolve) => {
|
|
240
|
-
["load", "error"].forEach((evName) => c.addEventListener(evName, resolve));
|
|
241
|
-
document.head.append(c);
|
|
242
|
-
})
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
242
|
+
const links = stylePreloadLinks(newDocument);
|
|
246
243
|
links.length && await Promise.all(links);
|
|
247
244
|
if (fallback === "animate") {
|
|
248
245
|
const currentAnimations = document.getAnimations();
|
|
249
246
|
document.documentElement.dataset.astroTransitionFallback = "old";
|
|
250
247
|
const newAnimations = document.getAnimations().filter((a) => !currentAnimations.includes(a) && !isInfinite(a));
|
|
251
248
|
const finished = Promise.all(newAnimations.map((a) => a.finished));
|
|
252
|
-
const fallbackSwap = () => {
|
|
253
|
-
swap();
|
|
254
|
-
document.documentElement.dataset.astroTransitionFallback = "new";
|
|
255
|
-
};
|
|
256
249
|
await finished;
|
|
257
|
-
|
|
250
|
+
swap();
|
|
251
|
+
document.documentElement.dataset.astroTransitionFallback = "new";
|
|
258
252
|
} else {
|
|
259
253
|
swap();
|
|
260
254
|
}
|
|
@@ -294,7 +288,6 @@ async function transition(direction, toLocation, options, popState) {
|
|
|
294
288
|
await finished;
|
|
295
289
|
} finally {
|
|
296
290
|
await runScripts();
|
|
297
|
-
markScriptsExec();
|
|
298
291
|
onPageLoad();
|
|
299
292
|
announce();
|
|
300
293
|
}
|
|
@@ -318,7 +311,7 @@ function navigate(href, options) {
|
|
|
318
311
|
}
|
|
319
312
|
const toLocation = new URL(href, location.href);
|
|
320
313
|
if (location.origin === toLocation.origin && samePage(toLocation)) {
|
|
321
|
-
|
|
314
|
+
moveToLocation(toLocation, options?.history === "replace", true);
|
|
322
315
|
} else {
|
|
323
316
|
transition("forward", toLocation, options ?? {});
|
|
324
317
|
}
|
|
@@ -350,18 +343,20 @@ function onPopState(ev) {
|
|
|
350
343
|
transition(direction, new URL(location.href), {}, state);
|
|
351
344
|
}
|
|
352
345
|
}
|
|
346
|
+
const onScroll = () => {
|
|
347
|
+
updateScrollPosition({ scrollX, scrollY });
|
|
348
|
+
};
|
|
353
349
|
if (inBrowser) {
|
|
354
350
|
if (supportsViewTransitions || getFallback() !== "none") {
|
|
355
351
|
addEventListener("popstate", onPopState);
|
|
356
352
|
addEventListener("load", onPageLoad);
|
|
357
|
-
const updateState = () => {
|
|
358
|
-
persistState({ ...history.state, scrollX, scrollY });
|
|
359
|
-
};
|
|
360
353
|
if ("onscrollend" in window)
|
|
361
|
-
addEventListener("scrollend",
|
|
354
|
+
addEventListener("scrollend", onScroll);
|
|
362
355
|
else
|
|
363
|
-
addEventListener("scroll", throttle(
|
|
364
|
-
|
|
356
|
+
addEventListener("scroll", throttle(onScroll, 300));
|
|
357
|
+
}
|
|
358
|
+
for (const script of document.scripts) {
|
|
359
|
+
script.dataset.astroExec = "";
|
|
365
360
|
}
|
|
366
361
|
}
|
|
367
362
|
async function prepareForClientOnlyComponents(newDocument, toLocation) {
|
|
@@ -380,7 +375,7 @@ async function prepareForClientOnlyComponents(newDocument, toLocation) {
|
|
|
380
375
|
viteIds.forEach((id) => {
|
|
381
376
|
const style = document.head.querySelector(`style[${VITE_ID}="${id}"]`);
|
|
382
377
|
if (style && !newDocument.head.querySelector(`style[${VITE_ID}="${id}"]`)) {
|
|
383
|
-
|
|
378
|
+
newDocument.head.appendChild(style);
|
|
384
379
|
}
|
|
385
380
|
});
|
|
386
381
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
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",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"zod": "3.21.1",
|
|
163
163
|
"@astrojs/internal-helpers": "0.2.1",
|
|
164
164
|
"@astrojs/markdown-remark": "3.3.0",
|
|
165
|
-
"@astrojs/telemetry": "3.0.
|
|
165
|
+
"@astrojs/telemetry": "3.0.4"
|
|
166
166
|
},
|
|
167
167
|
"optionalDependencies": {
|
|
168
168
|
"sharp": "^0.32.5"
|