astro 3.2.3 → 3.2.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/astro.js +7 -0
- package/dist/assets/internal.js +1 -1
- package/dist/cli/add/index.js +3 -4
- package/dist/core/build/css-asset-name.d.ts +1 -0
- package/dist/core/build/css-asset-name.js +29 -7
- package/dist/core/build/plugins/plugin-css.js +1 -13
- 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/server/hydration.d.ts +4 -2
- package/dist/runtime/server/hydration.js +6 -1
- package/dist/runtime/server/render/component.js +6 -3
- package/dist/transitions/router.js +10 -13
- package/package.json +1 -1
package/astro.js
CHANGED
|
@@ -32,6 +32,13 @@ async function main() {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// windows drive letters can sometimes be lowercase, which vite cannot process
|
|
36
|
+
if (process.platform === 'win32') {
|
|
37
|
+
const cwd = process.cwd();
|
|
38
|
+
const correctedCwd = cwd.slice(0, 1).toUpperCase() + cwd.slice(1);
|
|
39
|
+
if (correctedCwd !== cwd) process.chdir(correctedCwd);
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
return import('./dist/cli/index.js')
|
|
36
43
|
.then(({ cli }) => cli(process.argv))
|
|
37
44
|
.catch((error) => {
|
package/dist/assets/internal.js
CHANGED
|
@@ -65,7 +65,7 @@ async function getImage(options, imageConfig) {
|
|
|
65
65
|
rawOptions: resolvedOptions,
|
|
66
66
|
options: validatedOptions,
|
|
67
67
|
src: imageURL,
|
|
68
|
-
attributes: service.getHTMLAttributes !== void 0 ? service.getHTMLAttributes(validatedOptions, imageConfig) : {}
|
|
68
|
+
attributes: service.getHTMLAttributes !== void 0 ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
export {
|
package/dist/cli/add/index.js
CHANGED
|
@@ -37,7 +37,7 @@ const ASTRO_CONFIG_STUB = `import { defineConfig } from 'astro/config';
|
|
|
37
37
|
|
|
38
38
|
export default defineConfig({});`;
|
|
39
39
|
const TAILWIND_CONFIG_STUB = `/** @type {import('tailwindcss').Config} */
|
|
40
|
-
|
|
40
|
+
export default {
|
|
41
41
|
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
|
|
42
42
|
theme: {
|
|
43
43
|
extend: {},
|
|
@@ -58,8 +58,7 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
|
58
58
|
netlify: "@astrojs/netlify/functions",
|
|
59
59
|
vercel: "@astrojs/vercel/serverless",
|
|
60
60
|
cloudflare: "@astrojs/cloudflare",
|
|
61
|
-
node: "@astrojs/node"
|
|
62
|
-
deno: "@astrojs/deno"
|
|
61
|
+
node: "@astrojs/node"
|
|
63
62
|
};
|
|
64
63
|
async function getRegistry() {
|
|
65
64
|
const packageManager = (await preferredPM(process.cwd()))?.name || "npm";
|
|
@@ -134,7 +133,7 @@ async function add(names, { flags }) {
|
|
|
134
133
|
"./tailwind.config.mjs",
|
|
135
134
|
"./tailwind.config.js"
|
|
136
135
|
],
|
|
137
|
-
defaultConfigFile: "./tailwind.config.
|
|
136
|
+
defaultConfigFile: "./tailwind.config.mjs",
|
|
138
137
|
defaultConfigContent: TAILWIND_CONFIG_STUB
|
|
139
138
|
});
|
|
140
139
|
}
|
|
@@ -3,6 +3,7 @@ import type { AstroSettings } from '../../@types/astro.js';
|
|
|
3
3
|
export declare function shortHashedName(id: string, ctx: {
|
|
4
4
|
getModuleInfo: GetModuleInfo;
|
|
5
5
|
}): string;
|
|
6
|
+
export declare function createNameHash(baseId: string | undefined, hashIds: string[]): string;
|
|
6
7
|
export declare function createSlugger(settings: AstroSettings): (id: string, ctx: {
|
|
7
8
|
getModuleInfo: GetModuleInfo;
|
|
8
9
|
}) => string;
|
|
@@ -2,16 +2,22 @@ import crypto from "node:crypto";
|
|
|
2
2
|
import npath from "node:path";
|
|
3
3
|
import { viteID } from "../util.js";
|
|
4
4
|
import { getTopLevelPages } from "./graph.js";
|
|
5
|
+
const confusingBaseNames = ["404", "500"];
|
|
5
6
|
function shortHashedName(id, ctx) {
|
|
6
7
|
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
return createNameHash(
|
|
9
|
+
getFirstParentId(parents),
|
|
10
|
+
parents.map(([page]) => page.id)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function createNameHash(baseId, hashIds) {
|
|
14
|
+
const baseName = baseId ? prettifyBaseName(npath.parse(baseId).name) : "index";
|
|
9
15
|
const hash = crypto.createHash("sha256");
|
|
10
|
-
for (const
|
|
11
|
-
hash.update(
|
|
16
|
+
for (const id of hashIds) {
|
|
17
|
+
hash.update(id, "utf-8");
|
|
12
18
|
}
|
|
13
19
|
const h = hash.digest("hex").slice(0, 8);
|
|
14
|
-
const proposedName =
|
|
20
|
+
const proposedName = baseName + "." + h;
|
|
15
21
|
return proposedName;
|
|
16
22
|
}
|
|
17
23
|
function createSlugger(settings) {
|
|
@@ -22,7 +28,7 @@ function createSlugger(settings) {
|
|
|
22
28
|
return function(id, ctx) {
|
|
23
29
|
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
24
30
|
const allParentsKey = parents.map(([page]) => page.id).sort().join("-");
|
|
25
|
-
const firstParentId = parents
|
|
31
|
+
const firstParentId = getFirstParentId(parents) || indexPage;
|
|
26
32
|
let dir = firstParentId;
|
|
27
33
|
let key = "";
|
|
28
34
|
let i = 0;
|
|
@@ -30,7 +36,7 @@ function createSlugger(settings) {
|
|
|
30
36
|
if (dir === pagesDir) {
|
|
31
37
|
break;
|
|
32
38
|
}
|
|
33
|
-
const name2 = npath.parse(npath.basename(dir)).name;
|
|
39
|
+
const name2 = prettifyBaseName(npath.parse(npath.basename(dir)).name);
|
|
34
40
|
key = key.length ? name2 + sep + key : name2;
|
|
35
41
|
dir = npath.dirname(dir);
|
|
36
42
|
i++;
|
|
@@ -54,7 +60,23 @@ function createSlugger(settings) {
|
|
|
54
60
|
return name;
|
|
55
61
|
};
|
|
56
62
|
}
|
|
63
|
+
function getFirstParentId(parents) {
|
|
64
|
+
for (const parent of parents) {
|
|
65
|
+
const id = parent[0].id;
|
|
66
|
+
const baseName = npath.parse(id).name;
|
|
67
|
+
if (!confusingBaseNames.includes(baseName)) {
|
|
68
|
+
return id;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return parents[0]?.[0].id;
|
|
72
|
+
}
|
|
73
|
+
const charsToReplaceRe = /[.\[\]]/g;
|
|
74
|
+
const underscoresRe = /_+/g;
|
|
75
|
+
function prettifyBaseName(str) {
|
|
76
|
+
return str.replace(charsToReplaceRe, "_").replace(underscoresRe, "_");
|
|
77
|
+
}
|
|
57
78
|
export {
|
|
79
|
+
createNameHash,
|
|
58
80
|
createSlugger,
|
|
59
81
|
shortHashedName
|
|
60
82
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as crypto from "node:crypto";
|
|
2
|
-
import * as npath from "node:path";
|
|
3
1
|
import {} from "vite";
|
|
4
2
|
import { isBuildableCSSRequest } from "../../../vite-plugin-astro-server/util.js";
|
|
5
3
|
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
@@ -52,7 +50,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
52
50
|
getModuleInfo: meta.getModuleInfo
|
|
53
51
|
})) {
|
|
54
52
|
if (new URL(pageInfo.id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG)) {
|
|
55
|
-
const chunkId2 = createNameHash(id, [id]);
|
|
53
|
+
const chunkId2 = assetName.createNameHash(id, [id]);
|
|
56
54
|
internals.cssModuleToChunkIdMap.set(id, chunkId2);
|
|
57
55
|
return chunkId2;
|
|
58
56
|
}
|
|
@@ -189,16 +187,6 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
189
187
|
};
|
|
190
188
|
return [cssBuildPlugin, singleCssPlugin, inlineStylesheetsPlugin];
|
|
191
189
|
}
|
|
192
|
-
function createNameHash(baseId, hashIds) {
|
|
193
|
-
const baseName = baseId ? npath.parse(baseId).name : "index";
|
|
194
|
-
const hash = crypto.createHash("sha256");
|
|
195
|
-
for (const id of hashIds) {
|
|
196
|
-
hash.update(id, "utf-8");
|
|
197
|
-
}
|
|
198
|
-
const h = hash.digest("hex").slice(0, 8);
|
|
199
|
-
const proposedName = baseName + "." + h;
|
|
200
|
-
return proposedName;
|
|
201
|
-
}
|
|
202
190
|
function* getParentClientOnlys(id, ctx, internals) {
|
|
203
191
|
for (const [info] of walkParentInfos(id, ctx)) {
|
|
204
192
|
yield* getPageDatasByClientOnlyID(internals, info.id);
|
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.2.
|
|
23
|
+
const currentVersion = "3.2.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.2.
|
|
53
|
+
const version = "3.2.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.2.
|
|
238
|
+
`v${"3.2.4"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -7,12 +7,14 @@ export interface HydrationMetadata {
|
|
|
7
7
|
value: string;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
type Props = Record<string | number | symbol, any>;
|
|
10
11
|
interface ExtractedProps {
|
|
11
12
|
isPage: boolean;
|
|
12
13
|
hydration: HydrationMetadata | null;
|
|
13
|
-
props:
|
|
14
|
+
props: Props;
|
|
15
|
+
propsWithoutTransitionAttributes: Props;
|
|
14
16
|
}
|
|
15
|
-
export declare function extractDirectives(inputProps:
|
|
17
|
+
export declare function extractDirectives(inputProps: Props, clientDirectives: SSRResult['clientDirectives']): ExtractedProps;
|
|
16
18
|
interface HydrateScriptOptions {
|
|
17
19
|
renderer: SSRLoadedRenderer;
|
|
18
20
|
result: SSRResult;
|
|
@@ -9,7 +9,8 @@ function extractDirectives(inputProps, clientDirectives) {
|
|
|
9
9
|
let extracted = {
|
|
10
10
|
isPage: false,
|
|
11
11
|
hydration: null,
|
|
12
|
-
props: {}
|
|
12
|
+
props: {},
|
|
13
|
+
propsWithoutTransitionAttributes: {}
|
|
13
14
|
};
|
|
14
15
|
for (const [key, value] of Object.entries(inputProps)) {
|
|
15
16
|
if (key.startsWith("server:")) {
|
|
@@ -58,10 +59,14 @@ function extractDirectives(inputProps, clientDirectives) {
|
|
|
58
59
|
}
|
|
59
60
|
} else {
|
|
60
61
|
extracted.props[key] = value;
|
|
62
|
+
if (!transitionDirectivesToCopyOnIsland.includes(key)) {
|
|
63
|
+
extracted.propsWithoutTransitionAttributes[key] = value;
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
for (const sym of Object.getOwnPropertySymbols(inputProps)) {
|
|
64
68
|
extracted.props[sym] = inputProps[sym];
|
|
69
|
+
extracted.propsWithoutTransitionAttributes[sym] = inputProps[sym];
|
|
65
70
|
}
|
|
66
71
|
return extracted;
|
|
67
72
|
}
|
|
@@ -67,7 +67,10 @@ Did you forget to import the component or is it possible there is a typo?`
|
|
|
67
67
|
astroStaticSlot: true,
|
|
68
68
|
displayName
|
|
69
69
|
};
|
|
70
|
-
const { hydration, isPage, props } = extractDirectives(
|
|
70
|
+
const { hydration, isPage, props, propsWithoutTransitionAttributes } = extractDirectives(
|
|
71
|
+
_props,
|
|
72
|
+
clientDirectives
|
|
73
|
+
);
|
|
71
74
|
let html = "";
|
|
72
75
|
let attrs = void 0;
|
|
73
76
|
if (hydration) {
|
|
@@ -169,7 +172,7 @@ Did you forget to import the component or is it possible there is a typo?`
|
|
|
169
172
|
({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
|
|
170
173
|
{ result },
|
|
171
174
|
Component,
|
|
172
|
-
|
|
175
|
+
propsWithoutTransitionAttributes,
|
|
173
176
|
children,
|
|
174
177
|
metadata
|
|
175
178
|
));
|
|
@@ -194,7 +197,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|
|
194
197
|
({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
|
|
195
198
|
{ result },
|
|
196
199
|
Component,
|
|
197
|
-
|
|
200
|
+
propsWithoutTransitionAttributes,
|
|
198
201
|
children,
|
|
199
202
|
metadata
|
|
200
203
|
));
|
|
@@ -26,10 +26,6 @@ const announce = () => {
|
|
|
26
26
|
};
|
|
27
27
|
const PERSIST_ATTR = "data-astro-transition-persist";
|
|
28
28
|
const parser = new DOMParser();
|
|
29
|
-
let noopEl;
|
|
30
|
-
if (import.meta.env.DEV) {
|
|
31
|
-
noopEl = document.createElement("div");
|
|
32
|
-
}
|
|
33
29
|
let currentHistoryIndex = 0;
|
|
34
30
|
if (history.state) {
|
|
35
31
|
currentHistoryIndex = history.state.index;
|
|
@@ -115,21 +111,29 @@ function isInfinite(animation) {
|
|
|
115
111
|
}
|
|
116
112
|
const updateHistoryAndScrollPosition = (toLocation, replace, intraPage) => {
|
|
117
113
|
const fresh = !samePage(toLocation);
|
|
114
|
+
let scrolledToTop = false;
|
|
118
115
|
if (toLocation.href !== location.href) {
|
|
119
116
|
if (replace) {
|
|
120
117
|
history.replaceState({ ...history.state }, "", toLocation.href);
|
|
121
118
|
} else {
|
|
122
119
|
history.replaceState({ ...history.state, intraPage }, "");
|
|
123
|
-
history.pushState(
|
|
120
|
+
history.pushState(
|
|
121
|
+
{ index: ++currentHistoryIndex, scrollX: 0, scrollY: 0 },
|
|
122
|
+
"",
|
|
123
|
+
toLocation.href
|
|
124
|
+
);
|
|
124
125
|
}
|
|
125
126
|
if (fresh) {
|
|
126
127
|
scrollTo({ left: 0, top: 0, behavior: "instant" });
|
|
128
|
+
scrolledToTop = true;
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
if (toLocation.hash) {
|
|
130
132
|
location.href = toLocation.href;
|
|
131
133
|
} else {
|
|
132
|
-
|
|
134
|
+
if (!scrolledToTop) {
|
|
135
|
+
scrollTo({ left: 0, top: 0, behavior: "instant" });
|
|
136
|
+
}
|
|
133
137
|
}
|
|
134
138
|
};
|
|
135
139
|
async function updateDOM(newDocument, toLocation, options, popState, fallback) {
|
|
@@ -143,13 +147,6 @@ async function updateDOM(newDocument, toLocation, options, popState, fallback) {
|
|
|
143
147
|
const href = el.getAttribute("href");
|
|
144
148
|
return newDocument.head.querySelector(`link[rel=stylesheet][href="${href}"]`);
|
|
145
149
|
}
|
|
146
|
-
if (import.meta.env.DEV) {
|
|
147
|
-
if (el.tagName === "STYLE" && el.dataset.viteDevId) {
|
|
148
|
-
const devId = el.dataset.viteDevId;
|
|
149
|
-
return newDocument.querySelector(`style[data-vite-dev-id="${devId}"]`) || // Otherwise, keep it anyways. This is client:only styles.
|
|
150
|
-
noopEl;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
150
|
return null;
|
|
154
151
|
};
|
|
155
152
|
const swap = () => {
|