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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } from "../../path.js";
|
|
5
|
+
import { ASTRO_CONFIG_DEFAULTS, AstroConfigSchema } from "./base.js";
|
|
6
|
+
function resolveDirAsUrl(dir, root) {
|
|
7
|
+
let resolvedDir = path.resolve(root, dir);
|
|
8
|
+
if (!resolvedDir.endsWith(path.sep)) {
|
|
9
|
+
resolvedDir += path.sep;
|
|
10
|
+
}
|
|
11
|
+
return pathToFileURL(resolvedDir);
|
|
12
|
+
}
|
|
13
|
+
function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
14
|
+
let originalBuildClient;
|
|
15
|
+
let originalBuildServer;
|
|
16
|
+
const AstroConfigRelativeSchema = AstroConfigSchema.extend({
|
|
17
|
+
root: z.string().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
18
|
+
srcDir: z.string().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
19
|
+
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
|
|
20
|
+
publicDir: z.string().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
21
|
+
outDir: z.string().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
22
|
+
cacheDir: z.string().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
23
|
+
build: z.object({
|
|
24
|
+
format: z.union([z.literal("file"), z.literal("directory"), z.literal("preserve")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
|
|
25
|
+
// NOTE: `client` and `server` are transformed relative to the default outDir first,
|
|
26
|
+
// later we'll fix this to be relative to the actual `outDir`
|
|
27
|
+
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => {
|
|
28
|
+
originalBuildClient = val;
|
|
29
|
+
return resolveDirAsUrl(
|
|
30
|
+
val,
|
|
31
|
+
path.resolve(fileProtocolRoot, ASTRO_CONFIG_DEFAULTS.outDir)
|
|
32
|
+
);
|
|
33
|
+
}),
|
|
34
|
+
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => {
|
|
35
|
+
originalBuildServer = val;
|
|
36
|
+
return resolveDirAsUrl(
|
|
37
|
+
val,
|
|
38
|
+
path.resolve(fileProtocolRoot, ASTRO_CONFIG_DEFAULTS.outDir)
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
|
+
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
|
|
42
|
+
assetsPrefix: z.string().optional().or(z.object({ fallback: z.string() }).and(z.record(z.string())).optional()),
|
|
43
|
+
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
|
|
44
|
+
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
|
|
45
|
+
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets),
|
|
46
|
+
concurrency: z.number().min(1).optional().default(ASTRO_CONFIG_DEFAULTS.build.concurrency)
|
|
47
|
+
}).optional().default({}),
|
|
48
|
+
server: z.preprocess(
|
|
49
|
+
// preprocess
|
|
50
|
+
(val) => {
|
|
51
|
+
if (typeof val === "function") {
|
|
52
|
+
return val({ command: cmd === "dev" ? "dev" : "preview" });
|
|
53
|
+
} else {
|
|
54
|
+
return val;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// validate
|
|
58
|
+
z.object({
|
|
59
|
+
open: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.open),
|
|
60
|
+
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
|
|
61
|
+
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
|
|
62
|
+
headers: z.custom().optional(),
|
|
63
|
+
streaming: z.boolean().optional().default(true),
|
|
64
|
+
allowedHosts: z.union([z.array(z.string()), z.literal(true)]).optional().default(ASTRO_CONFIG_DEFAULTS.server.allowedHosts)
|
|
65
|
+
}).optional().default({})
|
|
66
|
+
)
|
|
67
|
+
}).transform((config) => {
|
|
68
|
+
if (config.outDir.toString() !== resolveDirAsUrl(ASTRO_CONFIG_DEFAULTS.outDir, fileProtocolRoot).toString()) {
|
|
69
|
+
const outDirPath = fileURLToPath(config.outDir);
|
|
70
|
+
config.build.client = resolveDirAsUrl(originalBuildClient, outDirPath);
|
|
71
|
+
config.build.server = resolveDirAsUrl(originalBuildServer, outDirPath);
|
|
72
|
+
}
|
|
73
|
+
if (config.trailingSlash === "never") {
|
|
74
|
+
config.base = prependForwardSlash(removeTrailingForwardSlash(config.base));
|
|
75
|
+
config.image.endpoint.route = prependForwardSlash(
|
|
76
|
+
removeTrailingForwardSlash(config.image.endpoint.route)
|
|
77
|
+
);
|
|
78
|
+
} else if (config.trailingSlash === "always") {
|
|
79
|
+
config.base = prependForwardSlash(appendForwardSlash(config.base));
|
|
80
|
+
config.image.endpoint.route = prependForwardSlash(
|
|
81
|
+
appendForwardSlash(config.image.endpoint.route)
|
|
82
|
+
);
|
|
83
|
+
} else {
|
|
84
|
+
config.base = prependForwardSlash(config.base);
|
|
85
|
+
config.image.endpoint.route = prependForwardSlash(config.image.endpoint.route);
|
|
86
|
+
}
|
|
87
|
+
return config;
|
|
88
|
+
});
|
|
89
|
+
return AstroConfigRelativeSchema;
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
createRelativeSchema
|
|
93
|
+
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
2
2
|
/** Turn raw config values into normalized values */
|
|
3
3
|
export declare function validateConfig(userConfig: any, root: string, cmd: string): Promise<AstroConfig>;
|
|
4
|
+
/**
|
|
5
|
+
* Used twice:
|
|
6
|
+
* - To validate the user config
|
|
7
|
+
* - To validate the config after all integrations (that may have updated it)
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateConfigRefined(updatedConfig: AstroConfig): Promise<AstroConfig>;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { errorMap } from "../errors/index.js";
|
|
2
|
-
import { createRelativeSchema } from "./
|
|
2
|
+
import { AstroConfigRefinedSchema, createRelativeSchema } from "./schemas/index.js";
|
|
3
3
|
async function validateConfig(userConfig, root, cmd) {
|
|
4
4
|
const AstroConfigRelativeSchema = createRelativeSchema(cmd, root);
|
|
5
|
-
return await
|
|
5
|
+
return await validateConfigRefined(
|
|
6
|
+
await AstroConfigRelativeSchema.parseAsync(userConfig, { errorMap })
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
async function validateConfigRefined(updatedConfig) {
|
|
10
|
+
return await AstroConfigRefinedSchema.parseAsync(updatedConfig, { errorMap });
|
|
6
11
|
}
|
|
7
12
|
export {
|
|
8
|
-
validateConfig
|
|
13
|
+
validateConfig,
|
|
14
|
+
validateConfigRefined
|
|
9
15
|
};
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.
|
|
25
|
+
const currentVersion = "5.6.1";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.
|
|
41
|
+
const version = "5.6.1";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -282,7 +282,7 @@ function printHelp({
|
|
|
282
282
|
message.push(
|
|
283
283
|
linebreak(),
|
|
284
284
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
285
|
-
`v${"5.
|
|
285
|
+
`v${"5.6.1"}`
|
|
286
286
|
)} ${headline}`
|
|
287
287
|
);
|
|
288
288
|
}
|
|
@@ -36,14 +36,14 @@ function vitePluginMiddleware({ settings }) {
|
|
|
36
36
|
if (!userMiddlewareIsPresent && settings.config.i18n?.routing === "manual") {
|
|
37
37
|
throw new AstroError(MissingMiddlewareForInternationalization);
|
|
38
38
|
}
|
|
39
|
-
return "export const onRequest = (_, next) => next()";
|
|
39
|
+
return { code: "export const onRequest = (_, next) => next()" };
|
|
40
40
|
} else if (id === MIDDLEWARE_MODULE_ID) {
|
|
41
41
|
if (!userMiddlewareIsPresent && settings.config.i18n?.routing === "manual") {
|
|
42
42
|
throw new AstroError(MissingMiddlewareForInternationalization);
|
|
43
43
|
}
|
|
44
44
|
const preMiddleware = createMiddlewareImports(settings.middlewares.pre, "pre");
|
|
45
45
|
const postMiddleware = createMiddlewareImports(settings.middlewares.post, "post");
|
|
46
|
-
const
|
|
46
|
+
const code = `
|
|
47
47
|
${userMiddlewareIsPresent ? `import { onRequest as userOnRequest } from '${resolvedMiddlewareId}';` : ""}
|
|
48
48
|
import { sequence } from 'astro:middleware';
|
|
49
49
|
${preMiddleware.importsCode}${postMiddleware.importsCode}
|
|
@@ -54,7 +54,7 @@ export const onRequest = sequence(
|
|
|
54
54
|
${postMiddleware.sequenceCode}
|
|
55
55
|
);
|
|
56
56
|
`.trim();
|
|
57
|
-
return
|
|
57
|
+
return { code };
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
};
|
|
@@ -22,7 +22,7 @@ function vitePluginServerIslands({ settings, logger }) {
|
|
|
22
22
|
},
|
|
23
23
|
load(id) {
|
|
24
24
|
if (id === RESOLVED_VIRTUAL_ISLAND_MAP_ID) {
|
|
25
|
-
return `export const serverIslandMap = ${serverIslandPlaceholder}
|
|
25
|
+
return { code: `export const serverIslandMap = ${serverIslandPlaceholder};` };
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
transform(_code, id) {
|
package/dist/core/session.d.ts
CHANGED
|
@@ -45,6 +45,14 @@ export declare class AstroSession<TDriver extends SessionDriverName = any> {
|
|
|
45
45
|
regenerate(): Promise<void>;
|
|
46
46
|
[PERSIST_SYMBOL](): Promise<void>;
|
|
47
47
|
get sessionID(): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Loads a session from storage with the given ID, and replaces the current session.
|
|
50
|
+
* Any changes made to the current session will be lost.
|
|
51
|
+
* This is not normally needed, as the session is automatically loaded using the cookie.
|
|
52
|
+
* However it can be used to restore a session where the ID has been recorded somewhere
|
|
53
|
+
* else (e.g. in a database).
|
|
54
|
+
*/
|
|
55
|
+
load(sessionID: string): Promise<void>;
|
|
48
56
|
}
|
|
49
57
|
export declare function resolveSessionDriver(driver: string | undefined): Promise<string | null>;
|
|
50
58
|
export declare function validateSessionConfig(settings: AstroSettings): void;
|
package/dist/core/session.js
CHANGED
|
@@ -221,6 +221,19 @@ class AstroSession {
|
|
|
221
221
|
get sessionID() {
|
|
222
222
|
return this.#sessionID;
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Loads a session from storage with the given ID, and replaces the current session.
|
|
226
|
+
* Any changes made to the current session will be lost.
|
|
227
|
+
* This is not normally needed, as the session is automatically loaded using the cookie.
|
|
228
|
+
* However it can be used to restore a session where the ID has been recorded somewhere
|
|
229
|
+
* else (e.g. in a database).
|
|
230
|
+
*/
|
|
231
|
+
async load(sessionID) {
|
|
232
|
+
this.#sessionID = sessionID;
|
|
233
|
+
this.#data = void 0;
|
|
234
|
+
await this.#setCookie();
|
|
235
|
+
await this.#ensureData();
|
|
236
|
+
}
|
|
224
237
|
/**
|
|
225
238
|
* Sets the session cookie.
|
|
226
239
|
*/
|
|
@@ -54,12 +54,12 @@ function astroEnv({ settings, sync, envLoader }) {
|
|
|
54
54
|
load(id, options) {
|
|
55
55
|
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.client)) {
|
|
56
56
|
ensureTemplateAreLoaded();
|
|
57
|
-
return templates.client;
|
|
57
|
+
return { code: templates.client };
|
|
58
58
|
}
|
|
59
59
|
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.server)) {
|
|
60
60
|
if (options?.ssr) {
|
|
61
61
|
ensureTemplateAreLoaded();
|
|
62
|
-
return templates.server;
|
|
62
|
+
return { code: templates.server };
|
|
63
63
|
}
|
|
64
64
|
throw new AstroError({
|
|
65
65
|
...AstroErrorData.ServerOnlyModule,
|
|
@@ -68,7 +68,7 @@ function astroEnv({ settings, sync, envLoader }) {
|
|
|
68
68
|
}
|
|
69
69
|
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.internal)) {
|
|
70
70
|
ensureTemplateAreLoaded();
|
|
71
|
-
return templates.internal;
|
|
71
|
+
return { code: templates.internal };
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
};
|
package/dist/events/session.js
CHANGED
|
@@ -64,9 +64,9 @@ export declare function runHookServerDone({ config, logger, }: {
|
|
|
64
64
|
config: AstroConfig;
|
|
65
65
|
logger: Logger;
|
|
66
66
|
}): Promise<void>;
|
|
67
|
-
export declare function runHookBuildStart({ config,
|
|
67
|
+
export declare function runHookBuildStart({ config, logger, }: {
|
|
68
68
|
config: AstroConfig;
|
|
69
|
-
|
|
69
|
+
logger: Logger;
|
|
70
70
|
}): Promise<void>;
|
|
71
71
|
export declare function runHookBuildSetup({ config, vite, pages, target, logger, }: {
|
|
72
72
|
config: AstroConfig;
|
|
@@ -91,9 +91,9 @@ type RunHookBuildDone = {
|
|
|
91
91
|
settings: AstroSettings;
|
|
92
92
|
pages: string[];
|
|
93
93
|
routes: RouteData[];
|
|
94
|
-
|
|
94
|
+
logger: Logger;
|
|
95
95
|
};
|
|
96
|
-
export declare function runHookBuildDone({ settings, pages, routes,
|
|
96
|
+
export declare function runHookBuildDone({ settings, pages, routes, logger }: RunHookBuildDone): Promise<void>;
|
|
97
97
|
export declare function runHookRouteSetup({ route, settings, logger, }: {
|
|
98
98
|
route: RouteOptions;
|
|
99
99
|
settings: AstroSettings;
|