astro 2.8.5 → 2.9.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-base.d.ts +9 -0
- package/components/ViewTransitions.astro +175 -0
- package/components/index.ts +1 -0
- package/components/viewtransitions.css +56 -0
- package/dist/@types/astro.d.ts +28 -10
- package/dist/assets/services/vendor/squoosh/impl.js +1 -1
- package/dist/content/runtime.js +1 -1
- package/dist/content/vite-plugin-content-assets.js +2 -2
- package/dist/core/app/index.js +115 -95
- package/dist/core/build/generate.js +18 -33
- package/dist/core/build/graph.js +1 -1
- package/dist/core/build/plugins/plugin-analyzer.js +101 -3
- package/dist/core/build/plugins/plugin-css.js +1 -1
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/compile/compile.js +2 -0
- package/dist/core/config/config.js +3 -5
- package/dist/core/config/schema.d.ts +85 -48
- package/dist/core/config/schema.js +36 -10
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +4 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.d.ts +2 -11
- package/dist/core/endpoint/index.d.ts +2 -3
- package/dist/core/endpoint/index.js +1 -11
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/index.js +3 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.d.ts +1 -1
- package/dist/core/render/core.d.ts +9 -3
- package/dist/core/render/core.js +42 -18
- package/dist/core/render/environment.d.ts +7 -2
- package/dist/core/render/index.d.ts +22 -1
- package/dist/core/render/index.js +2 -2
- package/dist/core/render/route-cache.js +1 -1
- package/dist/core/routing/validation.d.ts +2 -3
- package/dist/core/routing/validation.js +0 -9
- package/dist/jsx-runtime/index.d.ts +1 -1
- package/dist/prerender/routing.d.ts +1 -1
- package/dist/prerender/routing.js +1 -1
- package/dist/runtime/server/astro-component.d.ts +1 -1
- package/dist/runtime/server/astro-component.js +5 -5
- package/dist/runtime/server/index.d.ts +2 -1
- package/dist/runtime/server/index.js +3 -1
- package/dist/runtime/server/jsx.js +6 -2
- package/dist/runtime/server/render/astro/factory.d.ts +0 -1
- package/dist/runtime/server/render/astro/factory.js +1 -18
- package/dist/runtime/server/render/astro/index.d.ts +2 -1
- package/dist/runtime/server/render/astro/index.js +3 -1
- package/dist/runtime/server/render/astro/render.d.ts +4 -0
- package/dist/runtime/server/render/astro/render.js +119 -0
- package/dist/runtime/server/render/common.d.ts +8 -0
- package/dist/runtime/server/render/common.js +11 -3
- package/dist/runtime/server/render/component.js +1 -1
- package/dist/runtime/server/render/page.js +18 -89
- package/dist/runtime/server/transition.d.ts +2 -0
- package/dist/runtime/server/transition.js +133 -0
- package/dist/transitions/index.d.ts +7 -0
- package/dist/transitions/index.js +67 -0
- package/dist/transitions/vite-plugin-transitions.d.ts +5 -0
- package/dist/transitions/vite-plugin-transitions.js +36 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/css.d.ts +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/css.js +1 -1
- package/dist/vite-plugin-astro-server/environment.d.ts +5 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/environment.js +3 -3
- package/dist/vite-plugin-astro-server/index.d.ts +6 -0
- package/dist/vite-plugin-astro-server/index.js +21 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/metadata.d.ts +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/metadata.js +2 -2
- package/dist/vite-plugin-astro-server/plugin.js +1 -1
- package/dist/vite-plugin-astro-server/request.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/resolve.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/resolve.js +1 -1
- package/dist/vite-plugin-astro-server/route.d.ts +1 -1
- package/dist/vite-plugin-astro-server/route.js +93 -20
- package/dist/vite-plugin-astro-server/scripts.d.ts +3 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/scripts.js +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/vite.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/vite.js +2 -2
- package/dist/vite-plugin-markdown/index.js +1 -1
- package/dist/vite-plugin-scanner/index.d.ts +6 -3
- package/dist/vite-plugin-scanner/index.js +21 -4
- package/dist/vite-plugin-scanner/scan.d.ts +2 -1
- package/dist/vite-plugin-scanner/scan.js +6 -2
- package/package.json +6 -3
- package/dist/core/render/dev/environment.d.ts +0 -9
- package/dist/core/render/dev/index.d.ts +0 -27
- package/dist/core/render/dev/index.js +0 -112
- package/dist/core/render/dev/scripts.d.ts +0 -3
- /package/dist/{core/render/dev → vite-plugin-astro-server}/util.d.ts +0 -0
- /package/dist/{core/render/dev → vite-plugin-astro-server}/util.js +0 -0
|
@@ -20,15 +20,11 @@ import {
|
|
|
20
20
|
import { runHookBuildGenerated } from "../../integrations/index.js";
|
|
21
21
|
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
22
22
|
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
23
|
-
import { callEndpoint, throwIfRedirectNotAllowed } from "../endpoint/index.js";
|
|
24
23
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
25
24
|
import { debug, info } from "../logger/core.js";
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
routeIsRedirect
|
|
30
|
-
} from "../redirects/index.js";
|
|
31
|
-
import { createEnvironment, createRenderContext, tryRenderPage } from "../render/index.js";
|
|
25
|
+
import { RedirectSinglePageBuiltModule, getRedirectLocationOrThrow } from "../redirects/index.js";
|
|
26
|
+
import { isEndpointResult } from "../render/core.js";
|
|
27
|
+
import { createEnvironment, createRenderContext, tryRenderRoute } from "../render/index.js";
|
|
32
28
|
import { callGetStaticPaths } from "../render/route-cache.js";
|
|
33
29
|
import {
|
|
34
30
|
createAssetLink,
|
|
@@ -165,9 +161,6 @@ async function generateImage(opts, transform, path) {
|
|
|
165
161
|
info(opts.logging, null, ` ${green("\u25B6")} ${path} ${dim(statsText)} ${dim(timeIncrease)}`);
|
|
166
162
|
}
|
|
167
163
|
async function generatePage(opts, internals, pageData, ssrEntry, builtPaths, manifest) {
|
|
168
|
-
if (routeIsRedirect(pageData.route) && !opts.settings.config.experimental.redirects) {
|
|
169
|
-
throw new Error(`To use redirects first set experimental.redirects to \`true\``);
|
|
170
|
-
}
|
|
171
164
|
let timeStart = performance.now();
|
|
172
165
|
const pageInfo = getPageDataByComponent(internals, pageData.route.component);
|
|
173
166
|
const linkIds = [];
|
|
@@ -399,34 +392,26 @@ async function generatePath(pathname, opts, gopts, manifest, onRequest) {
|
|
|
399
392
|
});
|
|
400
393
|
let body;
|
|
401
394
|
let encoding;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
395
|
+
let response;
|
|
396
|
+
try {
|
|
397
|
+
response = await tryRenderRoute(pageData.route.type, renderContext, env, mod, onRequest);
|
|
398
|
+
} catch (err) {
|
|
399
|
+
if (!AstroError.is(err) && !err.id && typeof err === "object") {
|
|
400
|
+
err.id = pageData.component;
|
|
401
|
+
}
|
|
402
|
+
throw err;
|
|
403
|
+
}
|
|
404
|
+
if (isEndpointResult(response, pageData.route.type)) {
|
|
405
|
+
if (response.type === "response") {
|
|
406
|
+
if (!response.response.body)
|
|
413
407
|
return;
|
|
414
|
-
const ab = await
|
|
408
|
+
const ab = await response.response.arrayBuffer();
|
|
415
409
|
body = new Uint8Array(ab);
|
|
416
410
|
} else {
|
|
417
|
-
body =
|
|
418
|
-
encoding =
|
|
411
|
+
body = response.body;
|
|
412
|
+
encoding = response.encoding;
|
|
419
413
|
}
|
|
420
414
|
} else {
|
|
421
|
-
let response;
|
|
422
|
-
try {
|
|
423
|
-
response = await tryRenderPage(renderContext, env, mod, onRequest);
|
|
424
|
-
} catch (err) {
|
|
425
|
-
if (!AstroError.is(err) && !err.id && typeof err === "object") {
|
|
426
|
-
err.id = pageData.component;
|
|
427
|
-
}
|
|
428
|
-
throw err;
|
|
429
|
-
}
|
|
430
415
|
if (response.status >= 300 && response.status < 400) {
|
|
431
416
|
if (!opts.settings.config.build.redirects) {
|
|
432
417
|
return;
|
package/dist/core/build/graph.js
CHANGED
|
@@ -21,7 +21,7 @@ function* walkParentInfos(id, ctx, until, depth = 0, order = 0, seen = /* @__PUR
|
|
|
21
21
|
if (seen.has(imp)) {
|
|
22
22
|
continue;
|
|
23
23
|
}
|
|
24
|
-
yield* walkParentInfos(imp, ctx, until,
|
|
24
|
+
yield* walkParentInfos(imp, ctx, until, depth + 1, order, seen, id);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function moduleIsTopLevelPage(info) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { walk } from "estree-walker";
|
|
1
2
|
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
2
3
|
import { prependForwardSlash } from "../../../core/path.js";
|
|
3
4
|
import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from "../graph.js";
|
|
@@ -9,12 +10,91 @@ function isPropagatedAsset(id) {
|
|
|
9
10
|
return false;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
13
|
+
async function doesParentImportChild(parentInfo, childInfo, childExportNames) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if (!childInfo || !parentInfo.ast || !childExportNames)
|
|
16
|
+
return "no";
|
|
17
|
+
if (childExportNames === "dynamic" || ((_a = parentInfo.dynamicallyImportedIds) == null ? void 0 : _a.includes(childInfo.id))) {
|
|
18
|
+
return "dynamic";
|
|
19
|
+
}
|
|
20
|
+
const imports = [];
|
|
21
|
+
const exports = [];
|
|
22
|
+
walk(parentInfo.ast, {
|
|
23
|
+
enter(node) {
|
|
24
|
+
if (node.type === "ImportDeclaration") {
|
|
25
|
+
imports.push(node);
|
|
26
|
+
} else if (node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration") {
|
|
27
|
+
exports.push(node);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const importNames = [];
|
|
32
|
+
const exportNames = [];
|
|
33
|
+
for (const node of imports) {
|
|
34
|
+
const resolved = await this.resolve(node.source.value, parentInfo.id);
|
|
35
|
+
if (!resolved || resolved.id !== childInfo.id)
|
|
36
|
+
continue;
|
|
37
|
+
for (const specifier of node.specifiers) {
|
|
38
|
+
if (specifier.type === "ImportNamespaceSpecifier")
|
|
39
|
+
continue;
|
|
40
|
+
const name = specifier.type === "ImportDefaultSpecifier" ? "default" : specifier.imported.name;
|
|
41
|
+
if (childExportNames.includes(name)) {
|
|
42
|
+
importNames.push(specifier.local.name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const node of exports) {
|
|
47
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
48
|
+
if (node.declaration.type === "Identifier" && importNames.includes(node.declaration.name)) {
|
|
49
|
+
exportNames.push("default");
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (node.source) {
|
|
53
|
+
const resolved = await this.resolve(node.source.value, parentInfo.id);
|
|
54
|
+
if (!resolved || resolved.id !== childInfo.id)
|
|
55
|
+
continue;
|
|
56
|
+
for (const specifier of node.specifiers) {
|
|
57
|
+
if (childExportNames.includes(specifier.local.name)) {
|
|
58
|
+
importNames.push(specifier.local.name);
|
|
59
|
+
exportNames.push(specifier.exported.name);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (node.declaration) {
|
|
64
|
+
if (node.declaration.type !== "VariableDeclaration")
|
|
65
|
+
continue;
|
|
66
|
+
for (const declarator of node.declaration.declarations) {
|
|
67
|
+
if (((_b = declarator.init) == null ? void 0 : _b.type) !== "Identifier")
|
|
68
|
+
continue;
|
|
69
|
+
if (declarator.id.type !== "Identifier")
|
|
70
|
+
continue;
|
|
71
|
+
if (importNames.includes(declarator.init.name)) {
|
|
72
|
+
exportNames.push(declarator.id.name);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const specifier of node.specifiers) {
|
|
77
|
+
if (importNames.includes(specifier.local.name)) {
|
|
78
|
+
exportNames.push(specifier.exported.name);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!importNames.length)
|
|
84
|
+
return "no";
|
|
85
|
+
if (parentInfo.id.endsWith(".astro")) {
|
|
86
|
+
exportNames.push("default");
|
|
87
|
+
} else if (parentInfo.id.endsWith(".mdx")) {
|
|
88
|
+
exportNames.push("Content");
|
|
89
|
+
}
|
|
90
|
+
return exportNames;
|
|
91
|
+
}
|
|
12
92
|
function vitePluginAnalyzer(internals) {
|
|
13
93
|
function hoistedScriptScanner() {
|
|
14
94
|
const uniqueHoistedIds = /* @__PURE__ */ new Map();
|
|
15
95
|
const pageScripts = /* @__PURE__ */ new Map();
|
|
16
96
|
return {
|
|
17
|
-
scan(scripts, from) {
|
|
97
|
+
async scan(scripts, from) {
|
|
18
98
|
var _a;
|
|
19
99
|
const hoistedScripts = /* @__PURE__ */ new Set();
|
|
20
100
|
for (let i = 0; i < scripts.length; i++) {
|
|
@@ -22,9 +102,27 @@ function vitePluginAnalyzer(internals) {
|
|
|
22
102
|
hoistedScripts.add(hid);
|
|
23
103
|
}
|
|
24
104
|
if (hoistedScripts.size) {
|
|
25
|
-
|
|
105
|
+
const depthsToChildren = /* @__PURE__ */ new Map();
|
|
106
|
+
const depthsToExportNames = /* @__PURE__ */ new Map();
|
|
107
|
+
depthsToExportNames.set(0, ["default"]);
|
|
108
|
+
for (const [parentInfo, depth] of walkParentInfos(from, this, function until(importer) {
|
|
26
109
|
return isPropagatedAsset(importer);
|
|
27
110
|
})) {
|
|
111
|
+
depthsToChildren.set(depth, parentInfo);
|
|
112
|
+
if (depth > 0) {
|
|
113
|
+
const childInfo = depthsToChildren.get(depth - 1);
|
|
114
|
+
const childExportNames = depthsToExportNames.get(depth - 1);
|
|
115
|
+
const doesImport = await doesParentImportChild.call(
|
|
116
|
+
this,
|
|
117
|
+
parentInfo,
|
|
118
|
+
childInfo,
|
|
119
|
+
childExportNames
|
|
120
|
+
);
|
|
121
|
+
if (doesImport === "no") {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
depthsToExportNames.set(depth, doesImport);
|
|
125
|
+
}
|
|
28
126
|
if (isPropagatedAsset(parentInfo.id)) {
|
|
29
127
|
for (const [nestedParentInfo] of walkParentInfos(from, this)) {
|
|
30
128
|
if (moduleIsTopLevelPage(nestedParentInfo)) {
|
|
@@ -114,7 +212,7 @@ function vitePluginAnalyzer(internals) {
|
|
|
114
212
|
internals.discoveredHydratedComponents.set(rid, [c.exportName]);
|
|
115
213
|
}
|
|
116
214
|
}
|
|
117
|
-
hoistScanner.scan.call(this, astro.scripts, id);
|
|
215
|
+
await hoistScanner.scan.call(this, astro.scripts, id);
|
|
118
216
|
if (astro.clientOnlyComponents.length) {
|
|
119
217
|
const clientOnlys = [];
|
|
120
218
|
for (const c of astro.clientOnlyComponents) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
2
|
import * as npath from "node:path";
|
|
3
|
-
import { isBuildableCSSRequest } from "
|
|
3
|
+
import { isBuildableCSSRequest } from "../../../vite-plugin-astro-server/util.js";
|
|
4
4
|
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
5
5
|
import * as assetName from "../css-asset-name.js";
|
|
6
6
|
import { moduleIsTopLevelPage, walkParentInfos } from "../graph.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { default as vite
|
|
1
|
+
import type { InlineConfig, default as vite } from 'vite';
|
|
2
2
|
import type { AstroConfig, AstroSettings, ComponentInstance, ManifestData, MiddlewareHandler, RouteData, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
|
|
3
3
|
import type { LogOptions } from '../logger/core';
|
|
4
4
|
import type { RouteCache } from '../render/route-cache';
|
|
@@ -24,6 +24,8 @@ async function compile({
|
|
|
24
24
|
astroGlobalArgs: JSON.stringify(astroConfig.site),
|
|
25
25
|
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
|
26
26
|
resultScopedSlot: true,
|
|
27
|
+
experimentalTransitions: astroConfig.experimental.viewTransitions,
|
|
28
|
+
transitionsAnimationURL: "astro/components/viewtransitions.css",
|
|
27
29
|
preprocessStyle: createStylePreprocessor({
|
|
28
30
|
filename,
|
|
29
31
|
viteConfig,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as colors from "kleur/colors";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { fileURLToPath
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
6
6
|
import { mergeConfig } from "./merge.js";
|
|
7
7
|
import { createRelativeSchema } from "./schema.js";
|
|
@@ -18,7 +18,6 @@ const LEGACY_ASTRO_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
18
18
|
"devOptions"
|
|
19
19
|
]);
|
|
20
20
|
async function validateConfig(userConfig, root, cmd) {
|
|
21
|
-
const fileProtocolRoot = pathToFileURL(root + path.sep);
|
|
22
21
|
if (userConfig.hasOwnProperty("renderers")) {
|
|
23
22
|
console.error('Astro "renderers" are now "integrations"!');
|
|
24
23
|
console.error("Update your configuration and install new dependencies:");
|
|
@@ -60,7 +59,7 @@ async function validateConfig(userConfig, root, cmd) {
|
|
|
60
59
|
message: AstroErrorData.ConfigLegacyKey.message(legacyConfigKey)
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
|
-
const AstroConfigRelativeSchema = createRelativeSchema(cmd,
|
|
62
|
+
const AstroConfigRelativeSchema = createRelativeSchema(cmd, root);
|
|
64
63
|
const result = await AstroConfigRelativeSchema.parseAsync(userConfig);
|
|
65
64
|
return result;
|
|
66
65
|
}
|
|
@@ -74,8 +73,7 @@ function resolveFlags(flags) {
|
|
|
74
73
|
config: typeof flags.config === "string" ? flags.config : void 0,
|
|
75
74
|
host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
|
|
76
75
|
drafts: typeof flags.drafts === "boolean" ? flags.drafts : void 0,
|
|
77
|
-
experimentalAssets: typeof flags.experimentalAssets === "boolean" ? flags.experimentalAssets : void 0
|
|
78
|
-
experimentalRedirects: typeof flags.experimentalRedirects === "boolean" ? flags.experimentalRedirects : void 0
|
|
76
|
+
experimentalAssets: typeof flags.experimentalAssets === "boolean" ? flags.experimentalAssets : void 0
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
79
|
function resolveRoot(cwd) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { RehypePlugin, RemarkPlugin, RemarkRehype } from '@astrojs/markdown-remark';
|
|
3
4
|
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
|
|
4
5
|
import type { ViteUserConfig } from '../../@types/astro';
|
|
@@ -94,7 +95,16 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
94
95
|
port: number;
|
|
95
96
|
open: boolean;
|
|
96
97
|
}, unknown>;
|
|
97
|
-
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString
|
|
98
|
+
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
99
|
+
status: z.ZodUnion<[z.ZodLiteral<300>, z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<303>, z.ZodLiteral<304>, z.ZodLiteral<307>, z.ZodLiteral<308>]>;
|
|
100
|
+
destination: z.ZodString;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
103
|
+
destination: string;
|
|
104
|
+
}, {
|
|
105
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
106
|
+
destination: string;
|
|
107
|
+
}>]>>>;
|
|
98
108
|
image: z.ZodDefault<z.ZodObject<{
|
|
99
109
|
service: z.ZodObject<{
|
|
100
110
|
entrypoint: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
|
|
@@ -168,19 +178,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
168
178
|
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
|
|
169
179
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
170
180
|
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
171
|
-
|
|
181
|
+
viewTransitions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
172
182
|
}, "passthrough", z.ZodTypeAny, {
|
|
173
183
|
assets: boolean;
|
|
174
|
-
|
|
184
|
+
viewTransitions: boolean;
|
|
175
185
|
}, {
|
|
176
186
|
assets?: boolean | undefined;
|
|
177
|
-
|
|
187
|
+
viewTransitions?: boolean | undefined;
|
|
178
188
|
}>, {
|
|
179
189
|
assets: boolean;
|
|
180
|
-
|
|
190
|
+
viewTransitions: boolean;
|
|
181
191
|
}, {
|
|
182
192
|
assets?: boolean | undefined;
|
|
183
|
-
|
|
193
|
+
viewTransitions?: boolean | undefined;
|
|
184
194
|
}>>>;
|
|
185
195
|
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
|
|
186
196
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -196,7 +206,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
196
206
|
port: number;
|
|
197
207
|
open: boolean;
|
|
198
208
|
};
|
|
199
|
-
redirects: Record<string, string
|
|
209
|
+
redirects: Record<string, string | {
|
|
210
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
211
|
+
destination: string;
|
|
212
|
+
}>;
|
|
200
213
|
root: URL;
|
|
201
214
|
srcDir: URL;
|
|
202
215
|
publicDir: URL;
|
|
@@ -245,13 +258,16 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
245
258
|
vite: ViteUserConfig;
|
|
246
259
|
experimental: {
|
|
247
260
|
assets: boolean;
|
|
248
|
-
|
|
261
|
+
viewTransitions: boolean;
|
|
249
262
|
};
|
|
250
263
|
legacy: {};
|
|
251
264
|
}, {
|
|
252
265
|
output?: "server" | "static" | "hybrid" | undefined;
|
|
253
266
|
server?: unknown;
|
|
254
|
-
redirects?: Record<string, string
|
|
267
|
+
redirects?: Record<string, string | {
|
|
268
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
269
|
+
destination: string;
|
|
270
|
+
}> | undefined;
|
|
255
271
|
root?: string | undefined;
|
|
256
272
|
srcDir?: string | undefined;
|
|
257
273
|
publicDir?: string | undefined;
|
|
@@ -302,13 +318,22 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
302
318
|
vite?: ViteUserConfig | undefined;
|
|
303
319
|
experimental?: {
|
|
304
320
|
assets?: boolean | undefined;
|
|
305
|
-
|
|
321
|
+
viewTransitions?: boolean | undefined;
|
|
306
322
|
} | undefined;
|
|
307
323
|
legacy?: {} | undefined;
|
|
308
324
|
}>;
|
|
309
|
-
export declare function createRelativeSchema(cmd: string, fileProtocolRoot:
|
|
325
|
+
export declare function createRelativeSchema(cmd: string, fileProtocolRoot: string): z.ZodEffects<z.ZodObject<{
|
|
310
326
|
output: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"server">, z.ZodLiteral<"hybrid">]>>>;
|
|
311
|
-
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString
|
|
327
|
+
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
328
|
+
status: z.ZodUnion<[z.ZodLiteral<300>, z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<303>, z.ZodLiteral<304>, z.ZodLiteral<307>, z.ZodLiteral<308>]>;
|
|
329
|
+
destination: z.ZodString;
|
|
330
|
+
}, "strip", z.ZodTypeAny, {
|
|
331
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
332
|
+
destination: string;
|
|
333
|
+
}, {
|
|
334
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
335
|
+
destination: string;
|
|
336
|
+
}>]>>>;
|
|
312
337
|
site: z.ZodOptional<z.ZodString>;
|
|
313
338
|
base: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
314
339
|
trailingSlash: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"never">, z.ZodLiteral<"ignore">]>>>;
|
|
@@ -409,31 +434,31 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
409
434
|
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
|
|
410
435
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
411
436
|
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
412
|
-
|
|
437
|
+
viewTransitions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
413
438
|
}, "passthrough", z.ZodTypeAny, {
|
|
414
439
|
assets: boolean;
|
|
415
|
-
|
|
440
|
+
viewTransitions: boolean;
|
|
416
441
|
}, {
|
|
417
442
|
assets?: boolean | undefined;
|
|
418
|
-
|
|
443
|
+
viewTransitions?: boolean | undefined;
|
|
419
444
|
}>, {
|
|
420
445
|
assets: boolean;
|
|
421
|
-
|
|
446
|
+
viewTransitions: boolean;
|
|
422
447
|
}, {
|
|
423
448
|
assets?: boolean | undefined;
|
|
424
|
-
|
|
449
|
+
viewTransitions?: boolean | undefined;
|
|
425
450
|
}>>>;
|
|
426
451
|
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
|
|
427
|
-
root: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
428
|
-
srcDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
452
|
+
root: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
|
|
453
|
+
srcDir: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
|
|
429
454
|
compressHTML: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
430
|
-
publicDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
431
|
-
outDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
432
|
-
cacheDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
455
|
+
publicDir: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
|
|
456
|
+
outDir: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
|
|
457
|
+
cacheDir: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
|
|
433
458
|
build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
434
459
|
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
|
|
435
|
-
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
436
|
-
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
460
|
+
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, import("url").URL, string | undefined>;
|
|
461
|
+
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, import("url").URL, string | undefined>;
|
|
437
462
|
assets: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
438
463
|
assetsPrefix: z.ZodOptional<z.ZodString>;
|
|
439
464
|
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -444,8 +469,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
444
469
|
}, "strip", z.ZodTypeAny, {
|
|
445
470
|
assetsPrefix?: string | undefined;
|
|
446
471
|
format: "file" | "directory";
|
|
447
|
-
client: URL;
|
|
448
|
-
server: URL;
|
|
472
|
+
client: import("url").URL;
|
|
473
|
+
server: import("url").URL;
|
|
449
474
|
assets: string;
|
|
450
475
|
serverEntry: string;
|
|
451
476
|
redirects: boolean;
|
|
@@ -503,12 +528,15 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
503
528
|
open: boolean;
|
|
504
529
|
streaming: boolean;
|
|
505
530
|
};
|
|
506
|
-
redirects: Record<string, string
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
531
|
+
redirects: Record<string, string | {
|
|
532
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
533
|
+
destination: string;
|
|
534
|
+
}>;
|
|
535
|
+
root: import("url").URL;
|
|
536
|
+
srcDir: import("url").URL;
|
|
537
|
+
publicDir: import("url").URL;
|
|
538
|
+
outDir: import("url").URL;
|
|
539
|
+
cacheDir: import("url").URL;
|
|
512
540
|
compressHTML: boolean;
|
|
513
541
|
base: string;
|
|
514
542
|
trailingSlash: "ignore" | "always" | "never";
|
|
@@ -520,8 +548,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
520
548
|
build: {
|
|
521
549
|
assetsPrefix?: string | undefined;
|
|
522
550
|
format: "file" | "directory";
|
|
523
|
-
client: URL;
|
|
524
|
-
server: URL;
|
|
551
|
+
client: import("url").URL;
|
|
552
|
+
server: import("url").URL;
|
|
525
553
|
assets: string;
|
|
526
554
|
serverEntry: string;
|
|
527
555
|
redirects: boolean;
|
|
@@ -552,13 +580,16 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
552
580
|
vite: ViteUserConfig;
|
|
553
581
|
experimental: {
|
|
554
582
|
assets: boolean;
|
|
555
|
-
|
|
583
|
+
viewTransitions: boolean;
|
|
556
584
|
};
|
|
557
585
|
legacy: {};
|
|
558
586
|
}, {
|
|
559
587
|
output?: "server" | "static" | "hybrid" | undefined;
|
|
560
588
|
server?: unknown;
|
|
561
|
-
redirects?: Record<string, string
|
|
589
|
+
redirects?: Record<string, string | {
|
|
590
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
591
|
+
destination: string;
|
|
592
|
+
}> | undefined;
|
|
562
593
|
root?: string | undefined;
|
|
563
594
|
srcDir?: string | undefined;
|
|
564
595
|
publicDir?: string | undefined;
|
|
@@ -609,7 +640,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
609
640
|
vite?: ViteUserConfig | undefined;
|
|
610
641
|
experimental?: {
|
|
611
642
|
assets?: boolean | undefined;
|
|
612
|
-
|
|
643
|
+
viewTransitions?: boolean | undefined;
|
|
613
644
|
} | undefined;
|
|
614
645
|
legacy?: {} | undefined;
|
|
615
646
|
}>, {
|
|
@@ -626,12 +657,15 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
626
657
|
open: boolean;
|
|
627
658
|
streaming: boolean;
|
|
628
659
|
};
|
|
629
|
-
redirects: Record<string, string
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
660
|
+
redirects: Record<string, string | {
|
|
661
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
662
|
+
destination: string;
|
|
663
|
+
}>;
|
|
664
|
+
root: import("url").URL;
|
|
665
|
+
srcDir: import("url").URL;
|
|
666
|
+
publicDir: import("url").URL;
|
|
667
|
+
outDir: import("url").URL;
|
|
668
|
+
cacheDir: import("url").URL;
|
|
635
669
|
compressHTML: boolean;
|
|
636
670
|
base: string;
|
|
637
671
|
trailingSlash: "ignore" | "always" | "never";
|
|
@@ -643,8 +677,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
643
677
|
build: {
|
|
644
678
|
assetsPrefix?: string | undefined;
|
|
645
679
|
format: "file" | "directory";
|
|
646
|
-
client: URL;
|
|
647
|
-
server: URL;
|
|
680
|
+
client: import("url").URL;
|
|
681
|
+
server: import("url").URL;
|
|
648
682
|
assets: string;
|
|
649
683
|
serverEntry: string;
|
|
650
684
|
redirects: boolean;
|
|
@@ -675,13 +709,16 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
675
709
|
vite: ViteUserConfig;
|
|
676
710
|
experimental: {
|
|
677
711
|
assets: boolean;
|
|
678
|
-
|
|
712
|
+
viewTransitions: boolean;
|
|
679
713
|
};
|
|
680
714
|
legacy: {};
|
|
681
715
|
}, {
|
|
682
716
|
output?: "server" | "static" | "hybrid" | undefined;
|
|
683
717
|
server?: unknown;
|
|
684
|
-
redirects?: Record<string, string
|
|
718
|
+
redirects?: Record<string, string | {
|
|
719
|
+
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
720
|
+
destination: string;
|
|
721
|
+
}> | undefined;
|
|
685
722
|
root?: string | undefined;
|
|
686
723
|
srcDir?: string | undefined;
|
|
687
724
|
publicDir?: string | undefined;
|
|
@@ -732,7 +769,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
732
769
|
vite?: ViteUserConfig | undefined;
|
|
733
770
|
experimental?: {
|
|
734
771
|
assets?: boolean | undefined;
|
|
735
|
-
|
|
772
|
+
viewTransitions?: boolean | undefined;
|
|
736
773
|
} | undefined;
|
|
737
774
|
legacy?: {} | undefined;
|
|
738
775
|
}>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { markdownConfigDefaults } from "@astrojs/markdown-remark";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
2
4
|
import { BUNDLED_THEMES } from "shiki";
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
import { appendForwardSlash, prependForwardSlash, trimSlashes } from "../path.js";
|
|
@@ -37,7 +39,7 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
37
39
|
redirects: {},
|
|
38
40
|
experimental: {
|
|
39
41
|
assets: false,
|
|
40
|
-
|
|
42
|
+
viewTransitions: false
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
const AstroConfigSchema = z.object({
|
|
@@ -84,7 +86,24 @@ const AstroConfigSchema = z.object({
|
|
|
84
86
|
headers: z.custom().optional()
|
|
85
87
|
}).optional().default({})
|
|
86
88
|
),
|
|
87
|
-
redirects: z.record(
|
|
89
|
+
redirects: z.record(
|
|
90
|
+
z.string(),
|
|
91
|
+
z.union([
|
|
92
|
+
z.string(),
|
|
93
|
+
z.object({
|
|
94
|
+
status: z.union([
|
|
95
|
+
z.literal(300),
|
|
96
|
+
z.literal(301),
|
|
97
|
+
z.literal(302),
|
|
98
|
+
z.literal(303),
|
|
99
|
+
z.literal(304),
|
|
100
|
+
z.literal(307),
|
|
101
|
+
z.literal(308)
|
|
102
|
+
]),
|
|
103
|
+
destination: z.string()
|
|
104
|
+
})
|
|
105
|
+
])
|
|
106
|
+
).default(ASTRO_CONFIG_DEFAULTS.redirects),
|
|
88
107
|
image: z.object({
|
|
89
108
|
service: z.object({
|
|
90
109
|
entrypoint: z.union([
|
|
@@ -124,7 +143,7 @@ const AstroConfigSchema = z.object({
|
|
|
124
143
|
vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
|
|
125
144
|
experimental: z.object({
|
|
126
145
|
assets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.assets),
|
|
127
|
-
|
|
146
|
+
viewTransitions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.viewTransitions)
|
|
128
147
|
}).passthrough().refine(
|
|
129
148
|
(d) => {
|
|
130
149
|
const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental);
|
|
@@ -149,16 +168,16 @@ See https://docs.astro.build/en/reference/configuration-reference/#experimental-
|
|
|
149
168
|
});
|
|
150
169
|
function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
151
170
|
const AstroConfigRelativeSchema = AstroConfigSchema.extend({
|
|
152
|
-
root: z.string().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) =>
|
|
153
|
-
srcDir: z.string().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) =>
|
|
171
|
+
root: z.string().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
172
|
+
srcDir: z.string().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
154
173
|
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
|
|
155
|
-
publicDir: z.string().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) =>
|
|
156
|
-
outDir: z.string().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) =>
|
|
157
|
-
cacheDir: z.string().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) =>
|
|
174
|
+
publicDir: z.string().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
175
|
+
outDir: z.string().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
176
|
+
cacheDir: z.string().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
158
177
|
build: z.object({
|
|
159
178
|
format: z.union([z.literal("file"), z.literal("directory")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
|
|
160
|
-
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) =>
|
|
161
|
-
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) =>
|
|
179
|
+
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
180
|
+
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
|
|
162
181
|
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
|
|
163
182
|
assetsPrefix: z.string().optional(),
|
|
164
183
|
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
|
|
@@ -209,6 +228,13 @@ A future version of Astro will stop using the site pathname when producing <link
|
|
|
209
228
|
});
|
|
210
229
|
return AstroConfigRelativeSchema;
|
|
211
230
|
}
|
|
231
|
+
function resolveDirAsUrl(dir, root) {
|
|
232
|
+
let resolvedDir = path.resolve(root, dir);
|
|
233
|
+
if (!resolvedDir.endsWith(path.sep)) {
|
|
234
|
+
resolvedDir += path.sep;
|
|
235
|
+
}
|
|
236
|
+
return pathToFileURL(resolvedDir);
|
|
237
|
+
}
|
|
212
238
|
export {
|
|
213
239
|
AstroConfigSchema,
|
|
214
240
|
createRelativeSchema
|
package/dist/core/constants.js
CHANGED