astro 4.13.1 → 4.13.3
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-jsx.d.ts +0 -1
- package/astro.js +2 -1
- package/client.d.ts +1 -1
- package/components/Picture.astro +2 -2
- package/components/ViewTransitions.astro +1 -1
- package/config.d.ts +1 -1
- package/dist/@types/astro.d.ts +12 -8
- package/dist/actions/consts.d.ts +5 -0
- package/dist/actions/consts.js +6 -0
- package/dist/actions/runtime/middleware.d.ts +6 -6
- package/dist/actions/runtime/middleware.js +71 -77
- package/dist/actions/runtime/route.js +12 -19
- package/dist/actions/runtime/utils.d.ts +0 -8
- package/dist/actions/runtime/utils.js +0 -15
- package/dist/actions/runtime/virtual/get-action.d.ts +8 -0
- package/dist/actions/runtime/virtual/get-action.js +17 -0
- package/dist/actions/runtime/virtual/server.d.ts +1 -1
- package/dist/actions/runtime/virtual/shared.d.ts +23 -1
- package/dist/actions/runtime/virtual/shared.js +60 -9
- package/dist/actions/utils.d.ts +3 -2
- package/dist/actions/utils.js +13 -20
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/endpoint/generic.js +1 -1
- package/dist/assets/endpoint/node.js +3 -3
- package/dist/assets/services/sharp.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +1 -1
- package/dist/assets/utils/metadata.js +1 -1
- package/dist/assets/utils/node/emitAsset.js +1 -1
- package/dist/assets/utils/remoteProbe.js +1 -1
- package/dist/assets/utils/vendor/image-size/lookup.js +1 -1
- package/dist/assets/utils/vendor/image-size/types/svg.js +4 -4
- package/dist/cli/info/index.js +2 -2
- package/dist/cli/install-package.js +2 -2
- package/dist/core/app/index.js +1 -1
- package/dist/core/build/css-asset-name.d.ts +3 -3
- package/dist/core/build/css-asset-name.js +15 -8
- package/dist/core/build/generate.js +3 -3
- package/dist/core/build/index.js +7 -1
- package/dist/core/build/plugins/plugin-css.js +2 -2
- package/dist/core/config/schema.d.ts +55 -55
- package/dist/core/config/tsconfig.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +2 -2
- package/dist/core/errors/dev/vite.js +4 -4
- package/dist/core/errors/errors-data.d.ts +5 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.js +1 -1
- package/dist/core/render-context.js +8 -5
- package/dist/core/routing/manifest/create.js +2 -2
- package/dist/events/error.js +1 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/index.js +1 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +4 -2
- package/dist/runtime/server/render/component.js +1 -3
- package/dist/transitions/router.js +2 -2
- package/dist/type-utils.d.ts +1 -1
- package/dist/vite-plugin-astro-server/vite.js +1 -2
- package/dist/vite-plugin-env/index.js +0 -1
- package/dist/vite-plugin-load-fallback/index.js +3 -3
- package/dist/vite-plugin-scanner/index.js +1 -1
- package/dist/vite-plugin-scripts/page-ssr.js +1 -1
- package/package.json +6 -9
- package/templates/actions.mjs +34 -20
- package/templates/content/types.d.ts +12 -10
- package/types/content.d.ts +1 -1
package/dist/actions/utils.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {} from "./runtime/utils.js";
|
|
2
|
+
import { deserializeActionResult, getActionQueryString } from "./runtime/virtual/shared.js";
|
|
3
|
+
function hasActionPayload(locals) {
|
|
4
|
+
return "_actionPayload" in locals;
|
|
4
5
|
}
|
|
5
6
|
function createGetActionResult(locals) {
|
|
6
7
|
return (actionFn) => {
|
|
7
|
-
if (!
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
hint: "See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags"
|
|
12
|
-
});
|
|
13
|
-
return locals._actionsInternal.getActionResult(actionFn);
|
|
8
|
+
if (!hasActionPayload(locals) || actionFn.toString() !== getActionQueryString(locals._actionPayload.actionName)) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
return deserializeActionResult(locals._actionPayload.actionResult);
|
|
14
12
|
};
|
|
15
13
|
}
|
|
16
|
-
function createCallAction(
|
|
17
|
-
return (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
name: "AstroActionError",
|
|
21
|
-
message: "Experimental actions are not enabled in your project.",
|
|
22
|
-
hint: "See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags"
|
|
23
|
-
});
|
|
24
|
-
return locals._actionsInternal.callAction(actionFn, input);
|
|
14
|
+
function createCallAction(context) {
|
|
15
|
+
return (baseAction, input) => {
|
|
16
|
+
const action = baseAction.bind(context);
|
|
17
|
+
return action(input);
|
|
25
18
|
};
|
|
26
19
|
}
|
|
27
20
|
export {
|
|
28
21
|
createCallAction,
|
|
29
22
|
createGetActionResult,
|
|
30
|
-
|
|
23
|
+
hasActionPayload
|
|
31
24
|
};
|
|
@@ -63,7 +63,7 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
|
|
|
63
63
|
);
|
|
64
64
|
await fs.promises.unlink(getFullImagePath(originalFilePath, env));
|
|
65
65
|
}
|
|
66
|
-
} catch
|
|
66
|
+
} catch {
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
async function generateImage(originalImage, filepath, options) {
|
|
@@ -23,14 +23,14 @@ async function loadLocalImage(src, url) {
|
|
|
23
23
|
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
|
|
24
24
|
return void 0;
|
|
25
25
|
}
|
|
26
|
-
} catch
|
|
26
|
+
} catch {
|
|
27
27
|
return void 0;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
let buffer = void 0;
|
|
31
31
|
try {
|
|
32
32
|
buffer = await readFile(fileUrl);
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
try {
|
|
35
35
|
const sourceUrl = new URL(src, url.origin);
|
|
36
36
|
buffer = await loadRemoteImage(sourceUrl);
|
|
@@ -48,7 +48,7 @@ async function loadRemoteImage(src) {
|
|
|
48
48
|
return void 0;
|
|
49
49
|
}
|
|
50
50
|
return Buffer.from(await res.arrayBuffer());
|
|
51
|
-
} catch
|
|
51
|
+
} catch {
|
|
52
52
|
return void 0;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1332,7 +1332,7 @@ var Module = /* @__PURE__ */ function() {
|
|
|
1332
1332
|
wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
|
|
1333
1333
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
1334
1334
|
return 1;
|
|
1335
|
-
} catch
|
|
1335
|
+
} catch {
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
1338
|
function _emscripten_resize_heap(requestedSize) {
|
|
@@ -1473,7 +1473,7 @@ var Module = /* @__PURE__ */ function() {
|
|
|
1473
1473
|
wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
|
|
1474
1474
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
1475
1475
|
return 1;
|
|
1476
|
-
} catch
|
|
1476
|
+
} catch {
|
|
1477
1477
|
}
|
|
1478
1478
|
}
|
|
1479
1479
|
function _emscripten_resize_heap(requestedSize) {
|
|
@@ -1336,7 +1336,7 @@ var Module = /* @__PURE__ */ function() {
|
|
|
1336
1336
|
wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
|
|
1337
1337
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
1338
1338
|
return 1;
|
|
1339
|
-
} catch
|
|
1339
|
+
} catch {
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
1342
1342
|
function _emscripten_resize_heap(requestedSize) {
|
|
@@ -1439,7 +1439,7 @@ var Module = /* @__PURE__ */ function() {
|
|
|
1439
1439
|
wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
|
|
1440
1440
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
1441
1441
|
return 1;
|
|
1442
|
-
} catch
|
|
1442
|
+
} catch {
|
|
1443
1443
|
}
|
|
1444
1444
|
}
|
|
1445
1445
|
function _emscripten_resize_heap(requestedSize) {
|
|
@@ -1310,7 +1310,7 @@ var Module = /* @__PURE__ */ function() {
|
|
|
1310
1310
|
wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
|
|
1311
1311
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
1312
1312
|
return 1;
|
|
1313
|
-
} catch
|
|
1313
|
+
} catch {
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
1316
|
function _emscripten_resize_heap(requestedSize) {
|
|
@@ -1472,7 +1472,7 @@ var Module = /* @__PURE__ */ function() {
|
|
|
1472
1472
|
wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
|
|
1473
1473
|
updateGlobalBufferAndViews(wasmMemory.buffer);
|
|
1474
1474
|
return 1;
|
|
1475
|
-
} catch
|
|
1475
|
+
} catch {
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
1478
|
function _emscripten_resize_heap(requestedSize) {
|
|
@@ -6,7 +6,7 @@ const globalOptions = {
|
|
|
6
6
|
function lookup(input) {
|
|
7
7
|
const type = detector(input);
|
|
8
8
|
if (typeof type !== "undefined") {
|
|
9
|
-
if (globalOptions.disabledTypes.
|
|
9
|
+
if (globalOptions.disabledTypes.includes(type)) {
|
|
10
10
|
throw new TypeError("disabled file type: " + type);
|
|
11
11
|
}
|
|
12
12
|
const size = typeHandlers.get(type).calculate(input);
|
|
@@ -36,9 +36,9 @@ function parseViewbox(viewbox) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
function parseAttributes(root) {
|
|
39
|
-
const width =
|
|
40
|
-
const height =
|
|
41
|
-
const viewbox =
|
|
39
|
+
const width = extractorRegExps.width.exec(root);
|
|
40
|
+
const height = extractorRegExps.height.exec(root);
|
|
41
|
+
const viewbox = extractorRegExps.viewbox.exec(root);
|
|
42
42
|
return {
|
|
43
43
|
height: height && parseLength(height[2]),
|
|
44
44
|
viewbox: viewbox && parseViewbox(viewbox[2]),
|
|
@@ -74,7 +74,7 @@ const SVG = {
|
|
|
74
74
|
// Scan only the first kilo-byte to speed up the check on larger files
|
|
75
75
|
validate: (input) => svgReg.test(toUTF8String(input, 0, 1e3)),
|
|
76
76
|
calculate(input) {
|
|
77
|
-
const root = toUTF8String(input)
|
|
77
|
+
const root = extractorRegExps.root.exec(toUTF8String(input));
|
|
78
78
|
if (root) {
|
|
79
79
|
const attrs = parseAttributes(root[0]);
|
|
80
80
|
if (attrs.width && attrs.height) {
|
package/dist/cli/info/index.js
CHANGED
|
@@ -49,7 +49,7 @@ async function copyToClipboard(text) {
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
command = "xclip -sel clipboard -l 1";
|
|
52
|
-
} catch
|
|
52
|
+
} catch {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -66,7 +66,7 @@ async function copyToClipboard(text) {
|
|
|
66
66
|
input: text.trim(),
|
|
67
67
|
encoding: "utf8"
|
|
68
68
|
});
|
|
69
|
-
} catch
|
|
69
|
+
} catch {
|
|
70
70
|
console.error(
|
|
71
71
|
colors.red(`
|
|
72
72
|
Sorry, something went wrong!`) + ` Please copy the text above manually.`
|
|
@@ -13,7 +13,7 @@ async function getPackage(packageName, logger, options, otherDeps = []) {
|
|
|
13
13
|
require2.resolve(packageName, { paths: [options.cwd ?? process.cwd()] });
|
|
14
14
|
const packageImport = await import(packageName);
|
|
15
15
|
return packageImport;
|
|
16
|
-
} catch
|
|
16
|
+
} catch {
|
|
17
17
|
if (options.optional) return void 0;
|
|
18
18
|
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
|
|
19
19
|
packageName
|
|
@@ -156,7 +156,7 @@ async function getRegistry() {
|
|
|
156
156
|
const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
|
|
157
157
|
_registry = stdout?.trim()?.replace(/\/$/, "") || fallback;
|
|
158
158
|
if (!new URL(_registry).host) _registry = fallback;
|
|
159
|
-
} catch
|
|
159
|
+
} catch {
|
|
160
160
|
_registry = fallback;
|
|
161
161
|
}
|
|
162
162
|
return _registry;
|
package/dist/core/app/index.js
CHANGED
|
@@ -362,7 +362,7 @@ class App {
|
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
#getDefaultStatusCode(routeData, pathname) {
|
|
365
|
-
if (!routeData.pattern.
|
|
365
|
+
if (!routeData.pattern.test(pathname)) {
|
|
366
366
|
for (const fallbackRoute of routeData.fallbackRoutes) {
|
|
367
367
|
if (fallbackRoute.pattern.test(pathname)) {
|
|
368
368
|
return 302;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { GetModuleInfo } from 'rollup';
|
|
2
2
|
import type { AstroSettings } from '../../@types/astro.js';
|
|
3
|
-
export declare function shortHashedName(id: string, ctx: {
|
|
3
|
+
export declare function shortHashedName(settings: AstroSettings): (id: string, ctx: {
|
|
4
4
|
getModuleInfo: GetModuleInfo;
|
|
5
|
-
})
|
|
6
|
-
export declare function createNameHash(baseId: string | undefined, hashIds: string[]): string;
|
|
5
|
+
}) => string;
|
|
6
|
+
export declare function createNameHash(baseId: string | undefined, hashIds: string[], settings: AstroSettings): string;
|
|
7
7
|
export declare function createSlugger(settings: AstroSettings): (id: string, ctx: {
|
|
8
8
|
getModuleInfo: GetModuleInfo;
|
|
9
9
|
}) => string;
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import npath from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { normalizePath } from "vite";
|
|
3
5
|
import { viteID } from "../util.js";
|
|
4
6
|
import { getTopLevelPageModuleInfos } from "./graph.js";
|
|
5
7
|
const confusingBaseNames = ["404", "500"];
|
|
6
|
-
function shortHashedName(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function shortHashedName(settings) {
|
|
9
|
+
return function(id, ctx) {
|
|
10
|
+
const parents = getTopLevelPageModuleInfos(id, ctx);
|
|
11
|
+
return createNameHash(
|
|
12
|
+
getFirstParentId(parents),
|
|
13
|
+
parents.map((page) => page.id),
|
|
14
|
+
settings
|
|
15
|
+
);
|
|
16
|
+
};
|
|
12
17
|
}
|
|
13
|
-
function createNameHash(baseId, hashIds) {
|
|
18
|
+
function createNameHash(baseId, hashIds, settings) {
|
|
14
19
|
const baseName = baseId ? prettifyBaseName(npath.parse(baseId).name) : "index";
|
|
15
20
|
const hash = crypto.createHash("sha256");
|
|
21
|
+
const root = fileURLToPath(settings.config.root);
|
|
16
22
|
for (const id of hashIds) {
|
|
17
|
-
|
|
23
|
+
const relativePath = npath.relative(root, id);
|
|
24
|
+
hash.update(normalizePath(relativePath), "utf-8");
|
|
18
25
|
}
|
|
19
26
|
const h = hash.digest("hex").slice(0, 8);
|
|
20
27
|
const proposedName = baseName + "." + h;
|
|
@@ -223,7 +223,7 @@ async function getPathsForRoute(route, mod, pipeline, builtPaths) {
|
|
|
223
223
|
return paths;
|
|
224
224
|
}
|
|
225
225
|
function getInvalidRouteSegmentError(e, route, staticPath) {
|
|
226
|
-
const invalidParam =
|
|
226
|
+
const invalidParam = /^Expected "([^"]+)"/.exec(e.message)?.[1];
|
|
227
227
|
const received = invalidParam ? staticPath.params[invalidParam] : void 0;
|
|
228
228
|
let hint = "Learn about dynamic routes at https://docs.astro.build/en/core-concepts/routing/#dynamic-routes";
|
|
229
229
|
if (invalidParam && typeof received === "string") {
|
|
@@ -287,7 +287,7 @@ async function generatePath(pathname, pipeline, gopts, route) {
|
|
|
287
287
|
if (route.type === "fallback" && // If route is index page, continue rendering. The index page should
|
|
288
288
|
// always be rendered
|
|
289
289
|
route.pathname !== "/" && // Check if there is a translated page with the same path
|
|
290
|
-
Object.values(options.allPages).some((val) =>
|
|
290
|
+
Object.values(options.allPages).some((val) => val.route.pattern.test(pathname))) {
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
293
|
const url = getUrlForPath(
|
|
@@ -353,7 +353,7 @@ function getPrettyRouteName(route) {
|
|
|
353
353
|
if (isRelativePath(route.component)) {
|
|
354
354
|
return route.route;
|
|
355
355
|
} else if (route.component.includes("node_modules/")) {
|
|
356
|
-
return
|
|
356
|
+
return /.*node_modules\/(.+)/.exec(route.component)?.[1] ?? route.component;
|
|
357
357
|
} else {
|
|
358
358
|
return route.component;
|
|
359
359
|
}
|
package/dist/core/build/index.js
CHANGED
|
@@ -86,7 +86,13 @@ class AstroBuilder {
|
|
|
86
86
|
middlewareMode: true
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
{
|
|
89
|
+
{
|
|
90
|
+
settings: this.settings,
|
|
91
|
+
logger: this.logger,
|
|
92
|
+
mode: "build",
|
|
93
|
+
command: "build",
|
|
94
|
+
sync: false
|
|
95
|
+
}
|
|
90
96
|
);
|
|
91
97
|
await runHookConfigDone({ settings: this.settings, logger });
|
|
92
98
|
const { syncInternal } = await import("../sync/index.js");
|
|
@@ -40,7 +40,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
40
40
|
outputOptions(outputOptions) {
|
|
41
41
|
const assetFileNames = outputOptions.assetFileNames;
|
|
42
42
|
const namingIncludesHash = assetFileNames?.toString().includes("[hash]");
|
|
43
|
-
const createNameForParentPages = namingIncludesHash ? assetName.shortHashedName : assetName.createSlugger(settings);
|
|
43
|
+
const createNameForParentPages = namingIncludesHash ? assetName.shortHashedName(settings) : assetName.createSlugger(settings);
|
|
44
44
|
extendManualChunks(outputOptions, {
|
|
45
45
|
after(id, meta) {
|
|
46
46
|
if (isBuildableCSSRequest(id)) {
|
|
@@ -50,7 +50,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
50
50
|
const ctx = { getModuleInfo: meta.getModuleInfo };
|
|
51
51
|
for (const pageInfo of getParentModuleInfos(id, ctx)) {
|
|
52
52
|
if (hasAssetPropagationFlag(pageInfo.id)) {
|
|
53
|
-
const chunkId2 = assetName.createNameHash(id, [id]);
|
|
53
|
+
const chunkId2 = assetName.createNameHash(id, [id], settings);
|
|
54
54
|
internals.cssModuleToChunkIdMap.set(id, chunkId2);
|
|
55
55
|
return chunkId2;
|
|
56
56
|
}
|