astro 5.5.6 → 5.6.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.
- package/client.d.ts +1 -16
- package/dist/actions/plugins.js +1 -1
- package/dist/assets/runtime.js +5 -29
- package/dist/assets/utils/svg.d.ts +1 -4
- package/dist/assets/utils/svg.js +2 -2
- package/dist/assets/vite-plugin-assets.js +31 -30
- package/dist/container/index.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -9
- package/dist/core/app/index.d.ts +15 -0
- package/dist/core/app/index.js +27 -7
- package/dist/core/build/index.js +2 -2
- package/dist/core/build/plugins/plugin-component-entry.js +3 -1
- package/dist/core/build/plugins/plugin-manifest.js +1 -1
- package/dist/core/build/plugins/plugin-pages.js +1 -1
- package/dist/core/build/plugins/plugin-prerender.js +3 -0
- package/dist/core/build/plugins/plugin-renderers.js +3 -3
- package/dist/core/build/plugins/plugin-ssr.js +2 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/schemas/base.d.ts +1110 -0
- package/dist/core/config/{schema.js → schemas/base.js} +9 -254
- package/dist/core/config/schemas/index.d.ts +3 -0
- package/dist/core/config/schemas/index.js +9 -0
- package/dist/core/config/schemas/refined.d.ts +3 -0
- package/dist/core/config/schemas/refined.js +141 -0
- package/dist/core/config/schemas/relative.d.ts +1462 -0
- package/dist/core/config/schemas/relative.js +93 -0
- package/dist/core/config/validate.d.ts +6 -0
- package/dist/core/config/validate.js +9 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +3 -3
- package/dist/core/server-islands/vite-plugin-server-islands.js +1 -1
- package/dist/core/session.d.ts +8 -0
- package/dist/core/session.js +13 -0
- package/dist/env/vite-plugin-env.js +3 -3
- package/dist/events/session.js +1 -1
- package/dist/integrations/hooks.d.ts +4 -4
- package/dist/integrations/hooks.js +276 -280
- package/dist/manifest/virtual-module.js +2 -2
- package/dist/prefetch/index.d.ts +8 -0
- package/dist/prefetch/index.js +6 -4
- package/dist/prefetch/vite-plugin-prefetch.js +1 -1
- package/dist/toolbar/vite-plugin-dev-toolbar.js +41 -39
- package/dist/transitions/vite-plugin-transitions.js +22 -18
- package/dist/types/public/config.d.ts +3 -25
- package/dist/vite-plugin-load-fallback/index.js +4 -2
- package/dist/vite-plugin-scripts/index.js +9 -3
- package/dist/vite-plugin-ssr-manifest/index.js +4 -3
- package/package.json +4 -4
- package/dist/core/config/schema.d.ts +0 -3402
|
@@ -28,7 +28,7 @@ function virtualModulePlugin({
|
|
|
28
28
|
message: CantUseAstroConfigModuleError.message(VIRTUAL_CLIENT_ID)
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return { code: serializeClientConfig(manifest) };
|
|
32
32
|
} else if (id == RESOLVED_VIRTUAL_SERVER_ID) {
|
|
33
33
|
if (!settings.config.experimental.serializeConfig) {
|
|
34
34
|
throw new AstroError({
|
|
@@ -42,7 +42,7 @@ function virtualModulePlugin({
|
|
|
42
42
|
message: AstroErrorData.ServerOnlyModule.message(VIRTUAL_SERVER_ID)
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return { code: serializeServerConfig(manifest) };
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
};
|
package/dist/prefetch/index.d.ts
CHANGED
|
@@ -23,6 +23,14 @@ export interface PrefetchOptions {
|
|
|
23
23
|
* Should prefetch even on data saver mode or slow connection. (default `false`)
|
|
24
24
|
*/
|
|
25
25
|
ignoreSlowConnection?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* A string providing a hint to the browser as to how eagerly it should prefetch/prerender link targets in order to balance performance advantages against resource overheads. (default `immediate`)
|
|
28
|
+
* Only works if `clientPrerender` is enabled and browser supports Speculation Rules API.
|
|
29
|
+
* The browser takes this hint into consideration along with its own heuristics, so it may select a link that the author has hinted as less eager than another, if the less eager candidate is considered a better choice.
|
|
30
|
+
*
|
|
31
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules#eagerness
|
|
32
|
+
*/
|
|
33
|
+
eagerness?: 'immediate' | 'eager' | 'moderate' | 'conservative';
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* Prefetch a URL so it's cached when the user navigates to it.
|
package/dist/prefetch/index.js
CHANGED
|
@@ -125,7 +125,7 @@ function prefetch(url, opts) {
|
|
|
125
125
|
prefetchedUrls.add(url);
|
|
126
126
|
if (clientPrerender && HTMLScriptElement.supports?.("speculationrules")) {
|
|
127
127
|
debug?.(`[astro] Prefetching ${url} with <script type="speculationrules">`);
|
|
128
|
-
appendSpeculationRules(url);
|
|
128
|
+
appendSpeculationRules(url, opts?.eagerness ?? "immediate");
|
|
129
129
|
} else if (document.createElement("link").relList?.supports?.("prefetch") && opts?.with !== "fetch") {
|
|
130
130
|
debug?.(`[astro] Prefetching ${url} with <link rel="prefetch">`);
|
|
131
131
|
const link = document.createElement("link");
|
|
@@ -182,14 +182,15 @@ function onPageLoad(cb) {
|
|
|
182
182
|
cb();
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
|
-
function appendSpeculationRules(url) {
|
|
185
|
+
function appendSpeculationRules(url, eagerness) {
|
|
186
186
|
const script = document.createElement("script");
|
|
187
187
|
script.type = "speculationrules";
|
|
188
188
|
script.textContent = JSON.stringify({
|
|
189
189
|
prerender: [
|
|
190
190
|
{
|
|
191
191
|
source: "list",
|
|
192
|
-
urls: [url]
|
|
192
|
+
urls: [url],
|
|
193
|
+
eagerness
|
|
193
194
|
}
|
|
194
195
|
],
|
|
195
196
|
// Currently, adding `prefetch` is required to fallback if `prerender` fails.
|
|
@@ -198,7 +199,8 @@ function appendSpeculationRules(url) {
|
|
|
198
199
|
prefetch: [
|
|
199
200
|
{
|
|
200
201
|
source: "list",
|
|
201
|
-
urls: [url]
|
|
202
|
+
urls: [url],
|
|
203
|
+
eagerness
|
|
202
204
|
}
|
|
203
205
|
]
|
|
204
206
|
});
|
|
@@ -25,7 +25,7 @@ function astroPrefetch({ settings }) {
|
|
|
25
25
|
load(id) {
|
|
26
26
|
if (id === resolvedVirtualModuleId) {
|
|
27
27
|
if (!prefetch) throwPrefetchNotEnabledError();
|
|
28
|
-
return `export { prefetch } from "astro/virtual-modules/prefetch.js"
|
|
28
|
+
return { code: `export { prefetch } from "astro/virtual-modules/prefetch.js";` };
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
transform(code, id) {
|
|
@@ -50,58 +50,60 @@ ${args.error}`
|
|
|
50
50
|
},
|
|
51
51
|
async load(id) {
|
|
52
52
|
if (id === resolvedPrivateVirtualModuleId) {
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
plugin
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
return {
|
|
54
|
+
code: `
|
|
55
|
+
export const loadDevToolbarApps = async () => {
|
|
56
|
+
return (await Promise.all([${settings.devToolbarApps.map(
|
|
57
|
+
(plugin) => `safeLoadPlugin(${JSON.stringify(
|
|
58
|
+
plugin
|
|
59
|
+
)}, async () => (await import(${JSON.stringify(
|
|
60
|
+
typeof plugin === "string" ? plugin : plugin.entrypoint.toString()
|
|
61
|
+
)})).default, ${JSON.stringify(
|
|
62
|
+
typeof plugin === "string" ? plugin : plugin.entrypoint.toString()
|
|
63
|
+
)})`
|
|
64
|
+
).join(",")}]));
|
|
65
|
+
};
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
async function safeLoadPlugin(appDefinition, importEntrypoint, entrypoint) {
|
|
68
|
+
try {
|
|
69
|
+
let app;
|
|
70
|
+
if (typeof appDefinition === 'string') {
|
|
71
|
+
app = await importEntrypoint();
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
if (typeof app !== 'object' || !app.id || !app.name) {
|
|
74
|
+
throw new Error("Apps must default export an object with an id, and a name.");
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
app = appDefinition;
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
if (typeof app !== 'object' || !app.id || !app.name || !app.entrypoint) {
|
|
80
|
+
throw new Error("Apps must be an object with an id, a name and an entrypoint.");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const loadedApp = await importEntrypoint();
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
if (typeof loadedApp !== 'object') {
|
|
86
|
+
throw new Error("App entrypoint must default export an object.");
|
|
87
|
+
}
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
throw new Error("App entrypoint must default export an object.");
|
|
89
|
+
app = { ...app, ...loadedApp };
|
|
86
90
|
}
|
|
87
91
|
|
|
88
|
-
|
|
89
|
-
}
|
|
92
|
+
return app;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.error(\`Failed to load dev toolbar app from \${entrypoint}: \${err.message}\`);
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
if (import.meta.hot) {
|
|
97
|
+
import.meta.hot.send('astro:devtoolbar:error:load', { entrypoint: entrypoint, error: err.message })
|
|
98
|
+
}
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
import.meta.hot.send('astro:devtoolbar:error:load', { entrypoint: entrypoint, error: err.message })
|
|
100
|
+
return undefined;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
return undefined;
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
105
|
+
`
|
|
106
|
+
};
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
};
|
|
@@ -22,26 +22,30 @@ function astroTransitions({ settings }) {
|
|
|
22
22
|
},
|
|
23
23
|
load(id) {
|
|
24
24
|
if (id === resolvedVirtualModuleId) {
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
return {
|
|
26
|
+
code: `
|
|
27
|
+
export * from "astro/virtual-modules/transitions.js";
|
|
28
|
+
export {
|
|
29
|
+
default as ViewTransitions,
|
|
30
|
+
default as ClientRouter
|
|
31
|
+
} from "astro/components/ClientRouter.astro";
|
|
32
|
+
`
|
|
33
|
+
};
|
|
32
34
|
}
|
|
33
35
|
if (id === resolvedVirtualClientModuleId) {
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
return {
|
|
37
|
+
code: `
|
|
38
|
+
export { navigate, supportsViewTransitions, transitionEnabledOnThisPage } from "astro/virtual-modules/transitions-router.js";
|
|
39
|
+
export * from "astro/virtual-modules/transitions-types.js";
|
|
40
|
+
export {
|
|
41
|
+
TRANSITION_BEFORE_PREPARATION, isTransitionBeforePreparationEvent, TransitionBeforePreparationEvent,
|
|
42
|
+
TRANSITION_AFTER_PREPARATION,
|
|
43
|
+
TRANSITION_BEFORE_SWAP, isTransitionBeforeSwapEvent, TransitionBeforeSwapEvent,
|
|
44
|
+
TRANSITION_AFTER_SWAP, TRANSITION_PAGE_LOAD
|
|
45
|
+
} from "astro/virtual-modules/transitions-events.js";
|
|
46
|
+
export { swapFunctions } from "astro/virtual-modules/transitions-swap-functions.js";
|
|
47
|
+
`
|
|
48
|
+
};
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
51
|
transform(code, id) {
|
|
@@ -4,9 +4,8 @@ import type { RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig, SyntaxHig
|
|
|
4
4
|
import type { BuiltinDriverName, BuiltinDriverOptions, Driver, Storage } from 'unstorage';
|
|
5
5
|
import type { UserConfig as OriginalViteUserConfig, SSROptions as ViteSSROptions } from 'vite';
|
|
6
6
|
import type { ImageFit, ImageLayout } from '../../assets/types.js';
|
|
7
|
-
import type { SvgRenderMode } from '../../assets/utils/svg.js';
|
|
8
7
|
import type { AssetsPrefix } from '../../core/app/types.js';
|
|
9
|
-
import type { AstroConfigType } from '../../core/config/
|
|
8
|
+
import type { AstroConfigType } from '../../core/config/schemas/index.js';
|
|
10
9
|
import type { REDIRECT_STATUS_CODES } from '../../core/constants.js';
|
|
11
10
|
import type { AstroCookieSetOptions } from '../../core/cookies/cookies.js';
|
|
12
11
|
import type { LoggerLevel } from '../../core/logger/core.js';
|
|
@@ -1978,7 +1977,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
|
|
|
1978
1977
|
/**
|
|
1979
1978
|
*
|
|
1980
1979
|
* @name experimental.svg
|
|
1981
|
-
* @type {boolean
|
|
1980
|
+
* @type {boolean}
|
|
1982
1981
|
* @default `undefined`
|
|
1983
1982
|
* @version 5.x
|
|
1984
1983
|
* @description
|
|
@@ -2009,28 +2008,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
|
|
|
2009
2008
|
* For a complete overview, and to give feedback on this experimental API,
|
|
2010
2009
|
* see the [Feature RFC](https://github.com/withastro/roadmap/pull/1035).
|
|
2011
2010
|
*/
|
|
2012
|
-
svg?: boolean
|
|
2013
|
-
/**
|
|
2014
|
-
*
|
|
2015
|
-
* @name experimental.svg.mode
|
|
2016
|
-
* @type {string}
|
|
2017
|
-
* @default 'inline'
|
|
2018
|
-
*
|
|
2019
|
-
* The default technique for handling imported SVG files. Astro will inline the SVG content into your HTML output if not specified.
|
|
2020
|
-
*
|
|
2021
|
-
* - `inline`: Astro will inline the SVG content into your HTML output.
|
|
2022
|
-
* - `sprite`: Astro will generate a sprite sheet with all imported SVG files.
|
|
2023
|
-
*
|
|
2024
|
-
* ```astro
|
|
2025
|
-
* ---
|
|
2026
|
-
* import Logo from './path/to/svg/file.svg';
|
|
2027
|
-
* ---
|
|
2028
|
-
*
|
|
2029
|
-
* <Logo size={24} mode="sprite" />
|
|
2030
|
-
* ```
|
|
2031
|
-
*/
|
|
2032
|
-
mode: SvgRenderMode;
|
|
2033
|
-
};
|
|
2011
|
+
svg?: boolean;
|
|
2034
2012
|
/**
|
|
2035
2013
|
* @name experimental.serializeConfig
|
|
2036
2014
|
* @type {boolean}
|
|
@@ -17,13 +17,19 @@ function astroScriptsPlugin({ settings }) {
|
|
|
17
17
|
},
|
|
18
18
|
async load(id) {
|
|
19
19
|
if (id === BEFORE_HYDRATION_SCRIPT_ID) {
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
code: settings.scripts.filter((s) => s.stage === "before-hydration").map((s) => s.content).join("\n")
|
|
22
|
+
};
|
|
21
23
|
}
|
|
22
24
|
if (id === PAGE_SCRIPT_ID) {
|
|
23
|
-
return
|
|
25
|
+
return {
|
|
26
|
+
code: settings.scripts.filter((s) => s.stage === "page").map((s) => s.content).join("\n")
|
|
27
|
+
};
|
|
24
28
|
}
|
|
25
29
|
if (id === PAGE_SSR_SCRIPT_ID) {
|
|
26
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
code: settings.scripts.filter((s) => s.stage === "page-ssr").map((s) => s.content).join("\n")
|
|
32
|
+
};
|
|
27
33
|
}
|
|
28
34
|
return null;
|
|
29
35
|
},
|
|
@@ -11,12 +11,13 @@ function vitePluginSSRManifest() {
|
|
|
11
11
|
},
|
|
12
12
|
load(id) {
|
|
13
13
|
if (id === resolvedManifestVirtualModuleId) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
code: `export let manifest = {};
|
|
15
16
|
export function _privateSetManifestDontUseThis(ssrManifest) {
|
|
16
17
|
manifest = ssrManifest;
|
|
17
|
-
}
|
|
18
|
+
}`
|
|
19
|
+
};
|
|
18
20
|
}
|
|
19
|
-
return void 0;
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.1",
|
|
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",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"tinyexec": "^0.3.2",
|
|
146
146
|
"tinyglobby": "^0.2.12",
|
|
147
147
|
"tsconfck": "^3.1.5",
|
|
148
|
-
"ultrahtml": "^1.
|
|
148
|
+
"ultrahtml": "^1.6.0",
|
|
149
149
|
"unist-util-visit": "^5.0.0",
|
|
150
150
|
"unstorage": "^1.15.0",
|
|
151
151
|
"vfile": "^6.0.3",
|
|
@@ -157,9 +157,9 @@
|
|
|
157
157
|
"zod": "^3.24.2",
|
|
158
158
|
"zod-to-json-schema": "^3.24.5",
|
|
159
159
|
"zod-to-ts": "^1.2.0",
|
|
160
|
-
"@astrojs/internal-helpers": "0.6.1",
|
|
161
160
|
"@astrojs/markdown-remark": "6.3.1",
|
|
162
|
-
"@astrojs/telemetry": "3.2.0"
|
|
161
|
+
"@astrojs/telemetry": "3.2.0",
|
|
162
|
+
"@astrojs/internal-helpers": "0.6.1"
|
|
163
163
|
},
|
|
164
164
|
"optionalDependencies": {
|
|
165
165
|
"sharp": "^0.33.3"
|