astro 2.9.7 → 3.0.0-beta.0
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 +2 -2
- package/components/ViewTransitions.astro +65 -12
- package/dist/@types/astro.d.ts +68 -7
- package/dist/@types/astro.js +1 -0
- package/dist/assets/generate.js +7 -3
- package/dist/assets/image-endpoint.d.ts +1 -1
- package/dist/assets/image-endpoint.js +3 -3
- package/dist/assets/internal.js +1 -2
- package/dist/assets/services/noop.d.ts +3 -0
- package/dist/assets/services/noop.js +17 -0
- package/dist/assets/services/vendor/squoosh/image_data.js +3 -0
- package/dist/assets/services/vendor/squoosh/impl.js +2 -3
- package/dist/assets/services/vendor/squoosh/utils/workerPool.js +4 -0
- package/dist/assets/vendor/image-size/types/tiff.js +1 -1
- package/dist/assets/vendor/queue/queue.d.ts +3 -3
- package/dist/assets/vite-plugin-assets.d.ts +1 -1
- package/dist/assets/vite-plugin-assets.js +1 -23
- package/dist/cli/add/index.js +6 -9
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/check/index.d.ts +2 -78
- package/dist/cli/check/index.js +23 -275
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/index.js +7 -13
- package/dist/cli/info/index.js +3 -4
- package/dist/cli/install-package.d.ts +7 -0
- package/dist/cli/install-package.js +102 -0
- package/dist/cli/preview/index.js +1 -1
- package/dist/cli/sync/index.js +1 -1
- package/dist/content/runtime-assets.js +1 -2
- package/dist/content/runtime.js +3 -5
- package/dist/content/server-listeners.js +1 -2
- package/dist/content/types-generator.js +8 -8
- package/dist/content/utils.js +3 -4
- package/dist/content/vite-plugin-content-assets.js +4 -6
- package/dist/content/vite-plugin-content-imports.js +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +5 -6
- package/dist/core/app/index.js +5 -3
- package/dist/core/app/node.d.ts +1 -1
- package/dist/core/app/node.js +7 -2
- package/dist/core/build/css-asset-name.js +2 -4
- package/dist/core/build/generate.js +10 -17
- package/dist/core/build/graph.js +3 -4
- package/dist/core/build/index.js +8 -1
- package/dist/core/build/internal.js +2 -2
- package/dist/core/build/plugin.js +2 -4
- package/dist/core/build/plugins/plugin-analyzer.js +6 -9
- package/dist/core/build/plugins/plugin-component-entry.js +2 -4
- package/dist/core/build/plugins/plugin-css.js +6 -9
- package/dist/core/build/plugins/plugin-hoisted-scripts.js +2 -3
- package/dist/core/build/plugins/plugin-internals.js +1 -2
- package/dist/core/build/plugins/plugin-pages.js +5 -1
- package/dist/core/build/plugins/plugin-ssr.js +12 -8
- package/dist/core/build/static-build.js +8 -12
- package/dist/core/client-directive/build.js +1 -2
- package/dist/core/compile/compile.js +2 -1
- package/dist/core/compile/style.js +2 -3
- package/dist/core/config/schema.d.ts +8 -0
- package/dist/core/config/schema.js +11 -3
- package/dist/core/config/settings.js +3 -3
- package/dist/core/config/timer.js +5 -6
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.d.ts +5 -5
- package/dist/core/cookies/cookies.js +9 -9
- package/dist/core/create-vite.js +6 -28
- package/dist/core/dev/container.d.ts +0 -1
- package/dist/core/dev/container.js +0 -5
- package/dist/core/dev/dev.js +2 -3
- package/dist/core/dev/index.d.ts +1 -1
- package/dist/core/dev/index.js +1 -2
- package/dist/core/dev/restart.d.ts +1 -4
- package/dist/core/dev/restart.js +15 -19
- package/dist/core/endpoint/dev/index.js +1 -1
- package/dist/core/endpoint/index.js +3 -4
- package/dist/core/errors/dev/utils.js +12 -16
- package/dist/core/errors/dev/vite.js +11 -13
- package/dist/core/errors/errors-data.d.ts +21 -0
- package/dist/core/errors/errors-data.js +21 -0
- package/dist/core/errors/errors.js +12 -17
- package/dist/core/errors/overlay.js +7 -8
- package/dist/core/errors/utils.js +1 -1
- package/dist/core/fs/index.js +1 -1
- package/dist/core/logger/console.js +1 -1
- package/dist/core/logger/core.d.ts +26 -6
- package/dist/core/logger/core.js +54 -8
- package/dist/core/logger/node.d.ts +4 -4
- package/dist/core/logger/node.js +6 -6
- package/dist/core/messages.js +4 -5
- package/dist/core/module-loader/vite.js +2 -2
- package/dist/core/polyfill.js +12 -4
- package/dist/core/redirects/helpers.js +3 -3
- package/dist/core/render/core.js +1 -4
- package/dist/core/render/params-and-props.js +2 -3
- package/dist/core/render/result.js +1 -2
- package/dist/core/render/route-cache.d.ts +1 -2
- package/dist/core/render/route-cache.js +6 -11
- package/dist/core/routing/manifest/create.js +2 -6
- package/dist/core/routing/params.js +1 -1
- package/dist/core/routing/validation.js +7 -8
- package/dist/core/sync/index.js +1 -1
- package/dist/core/util.js +1 -1
- package/dist/events/error.js +1 -1
- package/dist/events/session.js +12 -13
- package/dist/integrations/astroFeaturesValidation.d.ts +14 -0
- package/dist/integrations/astroFeaturesValidation.js +109 -0
- package/dist/integrations/index.d.ts +3 -1
- package/dist/integrations/index.js +96 -31
- package/dist/jsx/babel.js +1 -2
- package/dist/prerender/metadata.js +1 -2
- package/dist/runtime/client/hmr.js +1 -2
- package/dist/runtime/server/astro-component.js +1 -2
- package/dist/runtime/server/astro-island.js +53 -55
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/endpoint.d.ts +2 -1
- package/dist/runtime/server/endpoint.js +21 -27
- package/dist/runtime/server/hydration.js +9 -0
- package/dist/runtime/server/jsx.js +3 -2
- package/dist/runtime/server/render/astro/instance.js +6 -3
- package/dist/runtime/server/render/astro/render-template.js +4 -3
- package/dist/runtime/server/render/astro/render.js +3 -3
- package/dist/runtime/server/render/common.js +1 -1
- package/dist/runtime/server/render/component.js +11 -13
- package/dist/runtime/server/render/dom.js +1 -1
- package/dist/runtime/server/render/page.js +2 -3
- package/dist/runtime/server/render/slot.js +2 -1
- package/dist/runtime/server/render/util.js +1 -2
- package/dist/runtime/server/transition.d.ts +1 -0
- package/dist/runtime/server/transition.js +1 -0
- package/dist/transitions/vite-plugin-transitions.js +1 -0
- package/dist/vite-plugin-astro/compile.js +2 -3
- package/dist/vite-plugin-astro/hmr.js +3 -5
- package/dist/vite-plugin-astro/index.js +1 -1
- package/dist/vite-plugin-astro/metadata.js +1 -2
- package/dist/vite-plugin-astro-postprocess/index.js +1 -1
- package/dist/vite-plugin-astro-server/base.js +1 -2
- package/dist/vite-plugin-astro-server/controller.js +2 -3
- package/dist/vite-plugin-astro-server/css.js +1 -1
- package/dist/vite-plugin-astro-server/request.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +1 -2
- package/dist/vite-plugin-astro-server/scripts.js +2 -3
- package/dist/vite-plugin-astro-server/vite.js +1 -1
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-env/index.js +2 -2
- package/dist/vite-plugin-head/index.js +4 -6
- package/dist/vite-plugin-html/index.js +1 -2
- package/dist/vite-plugin-html/transform/index.js +1 -1
- package/dist/vite-plugin-html/transform/slots.js +5 -6
- package/dist/vite-plugin-html/transform/utils.js +1 -2
- package/dist/vite-plugin-jsx/import-source.js +1 -2
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-jsx/tag.js +4 -6
- package/dist/vite-plugin-markdown/index.js +1 -2
- package/dist/vite-plugin-scanner/index.js +2 -1
- package/dist/vite-plugin-scanner/scan.js +1 -1
- package/dist/vite-plugin-scripts/index.js +1 -1
- package/dist/vite-plugin-scripts/page-ssr.js +2 -2
- package/package.json +13 -22
- package/tsconfigs/base.json +8 -6
- package/tsconfigs/strict.json +2 -3
- package/dist/cli/check/print.d.ts +0 -2
- package/dist/cli/check/print.js +0 -95
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "
|
|
50
|
+
const version = "3.0.0-beta.0";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -162,7 +162,6 @@ ${errorList.join(
|
|
|
162
162
|
)}`;
|
|
163
163
|
}
|
|
164
164
|
function formatErrorMessage(err, args = []) {
|
|
165
|
-
var _a, _b, _c;
|
|
166
165
|
const isOurError = AstroError.is(err) || CompilerError.is(err);
|
|
167
166
|
args.push(
|
|
168
167
|
`${bgRed(black(` error `))}${red(
|
|
@@ -175,11 +174,11 @@ function formatErrorMessage(err, args = []) {
|
|
|
175
174
|
yellow(padMultilineString(isOurError ? renderErrorMarkdown(err.hint, "cli") : err.hint, 4))
|
|
176
175
|
);
|
|
177
176
|
}
|
|
178
|
-
if (err.id ||
|
|
177
|
+
if (err.id || err.loc?.file) {
|
|
179
178
|
args.push(` ${bold("File:")}`);
|
|
180
179
|
args.push(
|
|
181
180
|
red(
|
|
182
|
-
` ${err.id ??
|
|
181
|
+
` ${err.id ?? err.loc?.file}${err.loc?.line && err.loc.column ? `:${err.loc.line}:${err.loc.column}` : ""}`
|
|
183
182
|
)
|
|
184
183
|
);
|
|
185
184
|
}
|
|
@@ -233,7 +232,7 @@ function printHelp({
|
|
|
233
232
|
message.push(
|
|
234
233
|
linebreak(),
|
|
235
234
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"
|
|
235
|
+
`v${"3.0.0-beta.0"}`
|
|
237
236
|
)} ${headline}`
|
|
238
237
|
);
|
|
239
238
|
}
|
|
@@ -5,7 +5,7 @@ function createViteLoader(viteServer) {
|
|
|
5
5
|
viteServer.watcher.on("unlink", (...args) => events.emit("file-unlink", args));
|
|
6
6
|
viteServer.watcher.on("change", (...args) => events.emit("file-change", args));
|
|
7
7
|
wrapMethod(viteServer.ws, "send", (msg) => {
|
|
8
|
-
if (
|
|
8
|
+
if (msg?.type === "error") {
|
|
9
9
|
events.emit("hmr-error", msg);
|
|
10
10
|
}
|
|
11
11
|
});
|
|
@@ -15,7 +15,7 @@ function createViteLoader(viteServer) {
|
|
|
15
15
|
},
|
|
16
16
|
async resolveId(spec, parent) {
|
|
17
17
|
const ret = await viteServer.pluginContainer.resolveId(spec, parent);
|
|
18
|
-
return ret
|
|
18
|
+
return ret?.id;
|
|
19
19
|
},
|
|
20
20
|
getModuleById(id) {
|
|
21
21
|
return viteServer.moduleGraph.getModuleById(id);
|
package/dist/core/polyfill.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { File } from "node:buffer";
|
|
2
|
+
import crypto from "node:crypto";
|
|
2
3
|
function apply() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
if (!globalThis.crypto) {
|
|
5
|
+
Object.defineProperty(globalThis, "crypto", {
|
|
6
|
+
value: crypto.webcrypto
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
if (!globalThis.File) {
|
|
10
|
+
Object.defineProperty(globalThis, "File", {
|
|
11
|
+
value: File
|
|
12
|
+
});
|
|
13
|
+
}
|
|
6
14
|
}
|
|
7
15
|
export {
|
|
8
16
|
apply
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
function routeIsRedirect(route) {
|
|
2
|
-
return
|
|
2
|
+
return route?.type === "redirect";
|
|
3
3
|
}
|
|
4
4
|
function redirectRouteGenerate(redirectRoute, data) {
|
|
5
5
|
const routeData = redirectRoute.redirectRoute;
|
|
6
6
|
const route = redirectRoute.redirect;
|
|
7
7
|
if (typeof routeData !== "undefined") {
|
|
8
|
-
return
|
|
8
|
+
return routeData?.generate(data) || routeData?.pathname || "/";
|
|
9
9
|
} else if (typeof route === "string") {
|
|
10
10
|
return route;
|
|
11
11
|
} else if (typeof route === "undefined") {
|
|
@@ -15,7 +15,7 @@ function redirectRouteGenerate(redirectRoute, data) {
|
|
|
15
15
|
}
|
|
16
16
|
function redirectRouteStatus(redirectRoute, method = "GET") {
|
|
17
17
|
const routeData = redirectRoute.redirectRoute;
|
|
18
|
-
if (typeof
|
|
18
|
+
if (typeof routeData?.redirect === "object") {
|
|
19
19
|
return routeData.redirect.status;
|
|
20
20
|
} else if (method !== "GET") {
|
|
21
21
|
return 308;
|
package/dist/core/render/core.js
CHANGED
|
@@ -37,10 +37,7 @@ async function renderPage({ mod, renderContext, env, cookies }) {
|
|
|
37
37
|
cookies,
|
|
38
38
|
locals: renderContext.locals ?? {}
|
|
39
39
|
});
|
|
40
|
-
|
|
41
|
-
Object.assign(renderContext.props, { components: mod.components });
|
|
42
|
-
}
|
|
43
|
-
let response = await runtimeRenderPage(
|
|
40
|
+
const response = await runtimeRenderPage(
|
|
44
41
|
result,
|
|
45
42
|
Component,
|
|
46
43
|
renderContext.props,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
2
2
|
import { getParams } from "../routing/params.js";
|
|
3
|
-
import { callGetStaticPaths, findPathItemByKey } from "./route-cache.js";
|
|
3
|
+
import { RouteCache, callGetStaticPaths, findPathItemByKey } from "./route-cache.js";
|
|
4
4
|
async function getParamsAndProps(opts) {
|
|
5
5
|
const { logging, mod, route, routeCache, pathname, ssr } = opts;
|
|
6
6
|
if (!route || route.pathname) {
|
|
@@ -12,7 +12,6 @@ async function getParamsAndProps(opts) {
|
|
|
12
12
|
mod,
|
|
13
13
|
route,
|
|
14
14
|
routeCache,
|
|
15
|
-
isValidate: true,
|
|
16
15
|
logging,
|
|
17
16
|
ssr
|
|
18
17
|
});
|
|
@@ -24,7 +23,7 @@ async function getParamsAndProps(opts) {
|
|
|
24
23
|
hint: AstroErrorData.NoMatchingStaticPathFound.hint([route.component])
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
|
-
const props =
|
|
26
|
+
const props = matchedStaticPath?.props ? { ...matchedStaticPath.props } : {};
|
|
28
27
|
return [params, props];
|
|
29
28
|
}
|
|
30
29
|
function getRouteParams(route, pathname) {
|
|
@@ -7,10 +7,9 @@ import { warn } from "../logger/core.js";
|
|
|
7
7
|
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
8
8
|
const responseSentSymbol = Symbol.for("astro.responseSent");
|
|
9
9
|
function getFunctionExpression(slot) {
|
|
10
|
-
var _a;
|
|
11
10
|
if (!slot)
|
|
12
11
|
return;
|
|
13
|
-
if (
|
|
12
|
+
if (slot.expressions?.length !== 1)
|
|
14
13
|
return;
|
|
15
14
|
return slot.expressions[0];
|
|
16
15
|
}
|
|
@@ -4,11 +4,10 @@ interface CallGetStaticPathsOptions {
|
|
|
4
4
|
mod: ComponentInstance;
|
|
5
5
|
route: RouteData;
|
|
6
6
|
routeCache: RouteCache;
|
|
7
|
-
isValidate: boolean;
|
|
8
7
|
logging: LogOptions;
|
|
9
8
|
ssr: boolean;
|
|
10
9
|
}
|
|
11
|
-
export declare function callGetStaticPaths({ mod, route, routeCache,
|
|
10
|
+
export declare function callGetStaticPaths({ mod, route, routeCache, logging, ssr, }: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed>;
|
|
12
11
|
interface RouteCacheEntry {
|
|
13
12
|
staticPaths: GetStaticPathsResultKeyed;
|
|
14
13
|
}
|
|
@@ -7,12 +7,11 @@ async function callGetStaticPaths({
|
|
|
7
7
|
mod,
|
|
8
8
|
route,
|
|
9
9
|
routeCache,
|
|
10
|
-
isValidate,
|
|
11
10
|
logging,
|
|
12
11
|
ssr
|
|
13
12
|
}) {
|
|
14
13
|
const cached = routeCache.get(route);
|
|
15
|
-
if (cached
|
|
14
|
+
if (cached?.staticPaths)
|
|
16
15
|
return cached.staticPaths;
|
|
17
16
|
validateDynamicRouteModule(mod, { ssr, route });
|
|
18
17
|
if (ssr && !route.prerender) {
|
|
@@ -30,12 +29,7 @@ async function callGetStaticPaths({
|
|
|
30
29
|
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
|
-
|
|
34
|
-
staticPaths = staticPaths.flat();
|
|
35
|
-
}
|
|
36
|
-
if (isValidate) {
|
|
37
|
-
validateGetStaticPathsResult(staticPaths, logging, route);
|
|
38
|
-
}
|
|
32
|
+
validateGetStaticPathsResult(staticPaths, logging, route);
|
|
39
33
|
const keyedStaticPaths = staticPaths;
|
|
40
34
|
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
41
35
|
for (const sp of keyedStaticPaths) {
|
|
@@ -46,8 +40,10 @@ async function callGetStaticPaths({
|
|
|
46
40
|
return keyedStaticPaths;
|
|
47
41
|
}
|
|
48
42
|
class RouteCache {
|
|
43
|
+
logging;
|
|
44
|
+
cache = {};
|
|
45
|
+
mode;
|
|
49
46
|
constructor(logging, mode = "production") {
|
|
50
|
-
this.cache = {};
|
|
51
47
|
this.logging = logging;
|
|
52
48
|
this.mode = mode;
|
|
53
49
|
}
|
|
@@ -56,8 +52,7 @@ class RouteCache {
|
|
|
56
52
|
this.cache = {};
|
|
57
53
|
}
|
|
58
54
|
set(route, entry) {
|
|
59
|
-
|
|
60
|
-
if (this.mode === "production" && ((_a = this.cache[route.component]) == null ? void 0 : _a.staticPaths)) {
|
|
55
|
+
if (this.mode === "production" && this.cache[route.component]?.staticPaths) {
|
|
61
56
|
warn(
|
|
62
57
|
this.logging,
|
|
63
58
|
"routeCache",
|
|
@@ -132,7 +132,6 @@ function injectedRouteToItem({ config, cwd }, { pattern, entryPoint }) {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
function createRouteManifest({ settings, cwd, fsMod }, logging) {
|
|
135
|
-
var _a;
|
|
136
135
|
const components = [];
|
|
137
136
|
const routes = [];
|
|
138
137
|
const validPageExtensions = /* @__PURE__ */ new Set([
|
|
@@ -245,7 +244,7 @@ function createRouteManifest({ settings, cwd, fsMod }, logging) {
|
|
|
245
244
|
const pagesDirRootRelative = pages.href.slice(settings.config.root.href.length);
|
|
246
245
|
warn(logging, "astro", `Missing pages directory: ${pagesDirRootRelative}`);
|
|
247
246
|
}
|
|
248
|
-
|
|
247
|
+
settings.injectedRoutes?.sort(
|
|
249
248
|
(a, b) => (
|
|
250
249
|
// sort injected routes in the same way as user-defined routes
|
|
251
250
|
comparator(injectedRouteToItem({ config, cwd }, a), injectedRouteToItem({ config, cwd }, b))
|
|
@@ -313,10 +312,7 @@ This route collides with: "${collision.component}".`
|
|
|
313
312
|
redirect: to,
|
|
314
313
|
redirectRoute: routes.find((r) => r.route === to)
|
|
315
314
|
};
|
|
316
|
-
const lastSegmentIsDynamic = (r) =>
|
|
317
|
-
var _a2, _b;
|
|
318
|
-
return !!((_b = (_a2 = r.segments.at(-1)) == null ? void 0 : _a2.at(-1)) == null ? void 0 : _b.dynamic);
|
|
319
|
-
};
|
|
315
|
+
const lastSegmentIsDynamic = (r) => !!r.segments.at(-1)?.at(-1)?.dynamic;
|
|
320
316
|
const redirBase = path.posix.dirname(route);
|
|
321
317
|
const dynamicRedir = lastSegmentIsDynamic(routeData);
|
|
322
318
|
let i = 0;
|
|
@@ -17,7 +17,7 @@ function stringifyParams(params, route) {
|
|
|
17
17
|
const validatedParams = Object.entries(params).reduce((acc, next) => {
|
|
18
18
|
validateGetStaticPathsParameter(next, route.component);
|
|
19
19
|
const [key, value] = next;
|
|
20
|
-
acc[key] = value
|
|
20
|
+
acc[key] = value?.toString();
|
|
21
21
|
return acc;
|
|
22
22
|
}, {});
|
|
23
23
|
return JSON.stringify(route.generate(validatedParams));
|
|
@@ -34,18 +34,17 @@ function validateGetStaticPathsResult(result, logging, route) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
result.forEach((pathObject) => {
|
|
37
|
-
if (
|
|
37
|
+
if (typeof pathObject === "object" && Array.isArray(pathObject) || pathObject === null) {
|
|
38
38
|
throw new AstroError({
|
|
39
|
-
...AstroErrorData.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
...AstroErrorData.InvalidGetStaticPathsEntry,
|
|
40
|
+
message: AstroErrorData.InvalidGetStaticPathsEntry.message(
|
|
41
|
+
Array.isArray(pathObject) ? "array" : typeof pathObject
|
|
42
|
+
)
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
45
|
+
if (pathObject.params === void 0 || pathObject.params === null || pathObject.params && Object.keys(pathObject.params).length === 0) {
|
|
46
46
|
throw new AstroError({
|
|
47
|
-
...AstroErrorData.
|
|
48
|
-
message: AstroErrorData.InvalidGetStaticPathParam.message(typeof pathObject.params),
|
|
47
|
+
...AstroErrorData.GetStaticPathsExpectedParams,
|
|
49
48
|
location: {
|
|
50
49
|
file: route.component
|
|
51
50
|
}
|
package/dist/core/sync/index.js
CHANGED
|
@@ -26,7 +26,7 @@ async function sync(inlineConfig, options) {
|
|
|
26
26
|
logging,
|
|
27
27
|
command: "build"
|
|
28
28
|
});
|
|
29
|
-
return await syncInternal(settings, { logging, fs: options
|
|
29
|
+
return await syncInternal(settings, { logging, fs: options?.fs });
|
|
30
30
|
}
|
|
31
31
|
async function syncInternal(settings, { logging, fs }) {
|
|
32
32
|
const timerStart = performance.now();
|
package/dist/core/util.js
CHANGED
|
@@ -12,7 +12,7 @@ function isURL(value) {
|
|
|
12
12
|
return Object.prototype.toString.call(value) === "[object URL]";
|
|
13
13
|
}
|
|
14
14
|
function isMarkdownFile(fileId, option) {
|
|
15
|
-
const _suffix =
|
|
15
|
+
const _suffix = option?.suffix ?? "";
|
|
16
16
|
for (let markdownFileExtension of SUPPORTED_MARKDOWN_FILE_EXTENSIONS) {
|
|
17
17
|
if (fileId.endsWith(`${markdownFileExtension}${_suffix}`))
|
|
18
18
|
return true;
|
package/dist/events/error.js
CHANGED
|
@@ -3,7 +3,7 @@ const EVENT_ERROR = "ASTRO_CLI_ERROR";
|
|
|
3
3
|
const ANONYMIZE_MESSAGE_REGEX = /^(\w| )+/;
|
|
4
4
|
function anonymizeErrorMessage(msg) {
|
|
5
5
|
const matchedMessage = msg.match(ANONYMIZE_MESSAGE_REGEX);
|
|
6
|
-
if (!
|
|
6
|
+
if (!matchedMessage?.[0]) {
|
|
7
7
|
return void 0;
|
|
8
8
|
}
|
|
9
9
|
return matchedMessage[0].trim().substring(0, 20);
|
package/dist/events/session.js
CHANGED
|
@@ -33,25 +33,24 @@ function configKeys(obj, parentKey) {
|
|
|
33
33
|
}).flat(1);
|
|
34
34
|
}
|
|
35
35
|
function eventCliSession(cliCommand, userConfig, flags) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
36
|
const configValues = userConfig ? {
|
|
38
37
|
markdownPlugins: [
|
|
39
|
-
...
|
|
38
|
+
...userConfig?.markdown?.remarkPlugins?.map(
|
|
40
39
|
(p) => typeof p === "string" ? p : typeof p
|
|
41
|
-
)
|
|
42
|
-
...
|
|
40
|
+
) ?? [],
|
|
41
|
+
...userConfig?.markdown?.rehypePlugins?.map(
|
|
43
42
|
(p) => typeof p === "string" ? p : typeof p
|
|
44
|
-
)
|
|
43
|
+
) ?? []
|
|
45
44
|
],
|
|
46
|
-
adapter:
|
|
47
|
-
integrations: (
|
|
48
|
-
trailingSlash: userConfig
|
|
49
|
-
build:
|
|
50
|
-
format:
|
|
45
|
+
adapter: userConfig?.adapter?.name ?? null,
|
|
46
|
+
integrations: (userConfig?.integrations ?? []).filter(Boolean).flat().map((i) => i?.name),
|
|
47
|
+
trailingSlash: userConfig?.trailingSlash,
|
|
48
|
+
build: userConfig?.build ? {
|
|
49
|
+
format: userConfig?.build?.format
|
|
51
50
|
} : void 0,
|
|
52
|
-
markdown:
|
|
53
|
-
drafts:
|
|
54
|
-
syntaxHighlight:
|
|
51
|
+
markdown: userConfig?.markdown ? {
|
|
52
|
+
drafts: userConfig.markdown?.drafts,
|
|
53
|
+
syntaxHighlight: userConfig.markdown?.syntaxHighlight
|
|
55
54
|
} : void 0
|
|
56
55
|
} : void 0;
|
|
57
56
|
const cliFlags = flags ? Object.keys(flags).filter((name) => name != "_") : void 0;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AstroConfig, AstroFeatureMap } from '../@types/astro';
|
|
2
|
+
import { type LogOptions } from '../core/logger/core.js';
|
|
3
|
+
type ValidationResult = {
|
|
4
|
+
[Property in keyof AstroFeatureMap]: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Checks whether an adapter supports certain features that are enabled via Astro configuration.
|
|
8
|
+
*
|
|
9
|
+
* If a configuration is enabled and "unlocks" a feature, but the adapter doesn't support, the function
|
|
10
|
+
* will throw a runtime error.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateSupportedFeatures(adapterName: string, featureMap: AstroFeatureMap | undefined, config: AstroConfig, logging: LogOptions): ValidationResult;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { error, warn } from "../core/logger/core.js";
|
|
2
|
+
const STABLE = "stable";
|
|
3
|
+
const DEPRECATED = "deprecated";
|
|
4
|
+
const UNSUPPORTED = "unsupported";
|
|
5
|
+
const EXPERIMENTAL = "experimental";
|
|
6
|
+
const UNSUPPORTED_ASSETS_FEATURE = {
|
|
7
|
+
supportKind: UNSUPPORTED,
|
|
8
|
+
isSquooshCompatible: false,
|
|
9
|
+
isSharpCompatible: false
|
|
10
|
+
};
|
|
11
|
+
const ALL_UNSUPPORTED = {
|
|
12
|
+
serverOutput: UNSUPPORTED,
|
|
13
|
+
staticOutput: UNSUPPORTED,
|
|
14
|
+
hybridOutput: UNSUPPORTED,
|
|
15
|
+
assets: UNSUPPORTED_ASSETS_FEATURE
|
|
16
|
+
};
|
|
17
|
+
function validateSupportedFeatures(adapterName, featureMap = ALL_UNSUPPORTED, config, logging) {
|
|
18
|
+
const {
|
|
19
|
+
assets = UNSUPPORTED_ASSETS_FEATURE,
|
|
20
|
+
serverOutput = UNSUPPORTED,
|
|
21
|
+
staticOutput = UNSUPPORTED,
|
|
22
|
+
hybridOutput = UNSUPPORTED
|
|
23
|
+
} = featureMap;
|
|
24
|
+
const validationResult = {};
|
|
25
|
+
validationResult.staticOutput = validateSupportKind(
|
|
26
|
+
staticOutput,
|
|
27
|
+
adapterName,
|
|
28
|
+
logging,
|
|
29
|
+
"staticOutput",
|
|
30
|
+
() => config?.output === "static"
|
|
31
|
+
);
|
|
32
|
+
validationResult.hybridOutput = validateSupportKind(
|
|
33
|
+
hybridOutput,
|
|
34
|
+
adapterName,
|
|
35
|
+
logging,
|
|
36
|
+
"hybridOutput",
|
|
37
|
+
() => config?.output === "hybrid"
|
|
38
|
+
);
|
|
39
|
+
validationResult.serverOutput = validateSupportKind(
|
|
40
|
+
serverOutput,
|
|
41
|
+
adapterName,
|
|
42
|
+
logging,
|
|
43
|
+
"serverOutput",
|
|
44
|
+
() => config?.output === "server"
|
|
45
|
+
);
|
|
46
|
+
validationResult.assets = validateAssetsFeature(assets, adapterName, config, logging);
|
|
47
|
+
return validationResult;
|
|
48
|
+
}
|
|
49
|
+
function validateSupportKind(supportKind, adapterName, logging, featureName, hasCorrectConfig) {
|
|
50
|
+
if (supportKind === STABLE) {
|
|
51
|
+
return true;
|
|
52
|
+
} else if (supportKind === DEPRECATED) {
|
|
53
|
+
featureIsDeprecated(adapterName, logging);
|
|
54
|
+
} else if (supportKind === EXPERIMENTAL) {
|
|
55
|
+
featureIsExperimental(adapterName, logging);
|
|
56
|
+
}
|
|
57
|
+
if (hasCorrectConfig() && supportKind === UNSUPPORTED) {
|
|
58
|
+
featureIsUnsupported(adapterName, logging, featureName);
|
|
59
|
+
return false;
|
|
60
|
+
} else {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function featureIsUnsupported(adapterName, logging, featureName) {
|
|
65
|
+
error(
|
|
66
|
+
logging,
|
|
67
|
+
`${adapterName}`,
|
|
68
|
+
`The feature ${featureName} is not supported by the adapter ${adapterName}.`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function featureIsExperimental(adapterName, logging) {
|
|
72
|
+
warn(logging, `${adapterName}`, "The feature is experimental and subject to issues or changes.");
|
|
73
|
+
}
|
|
74
|
+
function featureIsDeprecated(adapterName, logging) {
|
|
75
|
+
warn(
|
|
76
|
+
logging,
|
|
77
|
+
`${adapterName}`,
|
|
78
|
+
"The feature is deprecated and will be moved in the next release."
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const SHARP_SERVICE = "astro/assets/services/sharp";
|
|
82
|
+
const SQUOOSH_SERVICE = "astro/assets/services/squoosh";
|
|
83
|
+
function validateAssetsFeature(assets, adapterName, config, logging) {
|
|
84
|
+
const {
|
|
85
|
+
supportKind = UNSUPPORTED,
|
|
86
|
+
isSharpCompatible = false,
|
|
87
|
+
isSquooshCompatible = false
|
|
88
|
+
} = assets;
|
|
89
|
+
if (config?.image?.service?.entrypoint === SHARP_SERVICE && !isSharpCompatible) {
|
|
90
|
+
error(
|
|
91
|
+
logging,
|
|
92
|
+
"astro",
|
|
93
|
+
`The currently selected adapter \`${adapterName}\` is not compatible with the image service "Sharp".`
|
|
94
|
+
);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (config?.image?.service?.entrypoint === SQUOOSH_SERVICE && !isSquooshCompatible) {
|
|
98
|
+
error(
|
|
99
|
+
logging,
|
|
100
|
+
"astro",
|
|
101
|
+
`The currently selected adapter \`${adapterName}\` is not compatible with the image service "Squoosh".`
|
|
102
|
+
);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return validateSupportKind(supportKind, adapterName, logging, "assets", () => true);
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
validateSupportedFeatures
|
|
109
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { AddressInfo } from 'node:net';
|
|
3
3
|
import type { InlineConfig, ViteDevServer } from 'vite';
|
|
4
|
-
import type { AstroConfig, AstroSettings, RouteData } from '../@types/astro.js';
|
|
4
|
+
import type { AstroAdapter, AstroConfig, AstroSettings, RouteData } from '../@types/astro.js';
|
|
5
5
|
import type { SerializedSSRManifest } from '../core/app/types';
|
|
6
6
|
import type { PageBuildData } from '../core/build/types';
|
|
7
7
|
import { type LogOptions } from '../core/logger/core.js';
|
|
@@ -59,4 +59,6 @@ type RunHookBuildDone = {
|
|
|
59
59
|
logging: LogOptions;
|
|
60
60
|
};
|
|
61
61
|
export declare function runHookBuildDone({ config, pages, routes, logging }: RunHookBuildDone): Promise<void>;
|
|
62
|
+
export declare function isFunctionPerRouteEnabled(adapter: AstroAdapter | undefined): boolean;
|
|
63
|
+
export declare function isEdgeMiddlewareEnabled(adapter: AstroAdapter | undefined): boolean;
|
|
62
64
|
export {};
|