astro 4.13.0 → 4.13.2
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 +21 -2
- package/dist/actions/runtime/middleware.d.ts +3 -3
- package/dist/actions/runtime/middleware.js +39 -72
- package/dist/actions/runtime/route.js +16 -23
- package/dist/actions/runtime/utils.d.ts +2 -8
- package/dist/actions/runtime/utils.js +0 -15
- package/dist/actions/runtime/virtual/client.d.ts +0 -1
- package/dist/actions/runtime/virtual/client.js +0 -4
- 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 -4
- package/dist/actions/runtime/virtual/server.js +20 -13
- package/dist/actions/runtime/virtual/shared.d.ts +18 -1
- package/dist/actions/runtime/virtual/shared.js +56 -8
- package/dist/actions/utils.d.ts +2 -0
- package/dist/actions/utils.js +13 -8
- 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/add/index.d.ts +0 -7
- package/dist/cli/add/index.js +1 -2
- package/dist/cli/info/index.js +2 -2
- package/dist/cli/install-package.d.ts +0 -1
- package/dist/cli/install-package.js +3 -4
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/utils.d.ts +2 -11
- package/dist/content/utils.js +0 -8
- 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.d.ts +0 -4
- package/dist/core/build/generate.js +4 -24
- package/dist/core/build/index.js +8 -2
- package/dist/core/build/internal.d.ts +0 -18
- package/dist/core/build/internal.js +0 -17
- package/dist/core/build/page-data.d.ts +1 -1
- package/dist/core/build/page-data.js +1 -18
- package/dist/core/build/plugins/plugin-analyzer.js +0 -4
- package/dist/core/build/plugins/plugin-css.js +2 -2
- package/dist/core/build/plugins/plugin-internals.js +0 -7
- package/dist/core/build/plugins/plugin-manifest.d.ts +0 -10
- package/dist/core/build/plugins/plugin-manifest.js +0 -2
- package/dist/core/build/plugins/plugin-ssr.js +0 -1
- package/dist/core/build/types.d.ts +1 -8
- package/dist/core/compile/index.d.ts +0 -1
- package/dist/core/compile/types.d.ts +0 -7
- 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/dev/restart.d.ts +0 -2
- package/dist/core/dev/restart.js +1 -3
- package/dist/core/errors/dev/vite.d.ts +0 -13
- package/dist/core/errors/dev/vite.js +5 -6
- package/dist/core/errors/errors-data.d.ts +21 -5
- package/dist/core/errors/errors-data.js +13 -6
- package/dist/core/fs/index.d.ts +0 -2
- package/dist/core/fs/index.js +0 -5
- package/dist/core/logger/core.d.ts +0 -1
- package/dist/core/logger/core.js +0 -18
- package/dist/core/messages.d.ts +0 -1
- package/dist/core/messages.js +2 -3
- package/dist/core/middleware/index.js +3 -2
- package/dist/core/render/ssr-element.d.ts +0 -1
- package/dist/core/render/ssr-element.js +0 -6
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +9 -4
- package/dist/core/routing/manifest/create.js +2 -2
- package/dist/core/util.d.ts +0 -2
- package/dist/core/util.js +0 -14
- package/dist/events/error.js +1 -1
- package/dist/preferences/index.d.ts +0 -1
- package/dist/preferences/index.js +0 -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.d.ts +0 -3
- 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/controller.d.ts +0 -4
- package/dist/vite-plugin-astro-server/controller.js +0 -2
- 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 +8 -17
- package/templates/actions.mjs +25 -18
- package/templates/content/types.d.ts +12 -10
- package/types/content.d.ts +1 -1
- package/dist/actions/runtime/store.d.ts +0 -5
- package/dist/actions/runtime/store.js +0 -18
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parse as devalueParse, stringify as devalueStringify } from "devalue";
|
|
1
2
|
const ACTION_ERROR_CODES = [
|
|
2
3
|
"BAD_REQUEST",
|
|
3
4
|
"UNAUTHORIZED",
|
|
@@ -53,22 +54,23 @@ class ActionError extends Error {
|
|
|
53
54
|
static statusToCode(status) {
|
|
54
55
|
return statusToCodeMap[status] ?? "INTERNAL_SERVER_ERROR";
|
|
55
56
|
}
|
|
56
|
-
static
|
|
57
|
-
|
|
58
|
-
if (typeof body === "object" && body?.type === "AstroActionInputError" && Array.isArray(body.issues)) {
|
|
57
|
+
static fromJson(body) {
|
|
58
|
+
if (isInputError(body)) {
|
|
59
59
|
return new ActionInputError(body.issues);
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
61
|
+
if (isActionError(body)) {
|
|
62
62
|
return new ActionError(body);
|
|
63
63
|
}
|
|
64
64
|
return new ActionError({
|
|
65
|
-
|
|
66
|
-
code: ActionError.statusToCode(res.status)
|
|
65
|
+
code: "INTERNAL_SERVER_ERROR"
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
68
|
}
|
|
69
|
+
function isActionError(error) {
|
|
70
|
+
return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionError";
|
|
71
|
+
}
|
|
70
72
|
function isInputError(error) {
|
|
71
|
-
return error
|
|
73
|
+
return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionInputError" && "issues" in error && Array.isArray(error.issues);
|
|
72
74
|
}
|
|
73
75
|
class ActionInputError extends ActionError {
|
|
74
76
|
type = "AstroActionInputError";
|
|
@@ -126,12 +128,58 @@ function getActionProps(action) {
|
|
|
126
128
|
value: actionName
|
|
127
129
|
};
|
|
128
130
|
}
|
|
131
|
+
function serializeActionResult(res) {
|
|
132
|
+
if (res.error) {
|
|
133
|
+
return {
|
|
134
|
+
type: "error",
|
|
135
|
+
status: res.error.status,
|
|
136
|
+
contentType: "application/json",
|
|
137
|
+
body: JSON.stringify({
|
|
138
|
+
...res.error,
|
|
139
|
+
message: res.error.message,
|
|
140
|
+
stack: import.meta.env.PROD ? void 0 : res.error.stack
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (res.data === void 0) {
|
|
145
|
+
return {
|
|
146
|
+
type: "empty",
|
|
147
|
+
status: 204
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
type: "data",
|
|
152
|
+
status: 200,
|
|
153
|
+
contentType: "application/json+devalue",
|
|
154
|
+
body: devalueStringify(res.data, {
|
|
155
|
+
// Add support for URL objects
|
|
156
|
+
URL: (value) => value instanceof URL && value.href
|
|
157
|
+
})
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function deserializeActionResult(res) {
|
|
161
|
+
if (res.type === "error") {
|
|
162
|
+
return { error: ActionError.fromJson(JSON.parse(res.body)), data: void 0 };
|
|
163
|
+
}
|
|
164
|
+
if (res.type === "empty") {
|
|
165
|
+
return { data: void 0, error: void 0 };
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
data: devalueParse(res.body, {
|
|
169
|
+
URL: (href) => new URL(href)
|
|
170
|
+
}),
|
|
171
|
+
error: void 0
|
|
172
|
+
};
|
|
173
|
+
}
|
|
129
174
|
export {
|
|
130
175
|
ACTION_ERROR_CODES,
|
|
131
176
|
ActionError,
|
|
132
177
|
ActionInputError,
|
|
133
178
|
callSafely,
|
|
179
|
+
deserializeActionResult,
|
|
134
180
|
getActionProps,
|
|
135
181
|
getActionQueryString,
|
|
136
|
-
|
|
182
|
+
isActionError,
|
|
183
|
+
isInputError,
|
|
184
|
+
serializeActionResult
|
|
137
185
|
};
|
package/dist/actions/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { APIContext } from '../@types/astro.js';
|
|
2
2
|
import type { Locals } from './runtime/middleware.js';
|
|
3
|
+
import { type ActionAPIContext } from './runtime/utils.js';
|
|
3
4
|
export declare function hasActionsInternal(locals: APIContext['locals']): locals is Locals;
|
|
4
5
|
export declare function createGetActionResult(locals: APIContext['locals']): APIContext['getActionResult'];
|
|
6
|
+
export declare function createCallAction(context: ActionAPIContext): APIContext['callAction'];
|
package/dist/actions/utils.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from "./runtime/utils.js";
|
|
2
|
+
import { deserializeActionResult, getActionQueryString } from "./runtime/virtual/shared.js";
|
|
2
3
|
function hasActionsInternal(locals) {
|
|
3
4
|
return "_actionsInternal" in locals;
|
|
4
5
|
}
|
|
5
6
|
function createGetActionResult(locals) {
|
|
6
7
|
return (actionFn) => {
|
|
7
|
-
if (!hasActionsInternal(locals))
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
if (!hasActionsInternal(locals) || actionFn.toString() !== getActionQueryString(locals._actionsInternal.actionName)) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
return deserializeActionResult(locals._actionsInternal.actionResult);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createCallAction(context) {
|
|
15
|
+
return (baseAction, input) => {
|
|
16
|
+
const action = baseAction.bind(context);
|
|
17
|
+
return action(input);
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
export {
|
|
21
|
+
createCallAction,
|
|
17
22
|
createGetActionResult,
|
|
18
23
|
hasActionsInternal
|
|
19
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/add/index.d.ts
CHANGED
|
@@ -2,12 +2,5 @@ import type yargs from 'yargs-parser';
|
|
|
2
2
|
interface AddOptions {
|
|
3
3
|
flags: yargs.Arguments;
|
|
4
4
|
}
|
|
5
|
-
interface IntegrationInfo {
|
|
6
|
-
id: string;
|
|
7
|
-
packageName: string;
|
|
8
|
-
dependencies: [name: string, version: string][];
|
|
9
|
-
type: 'integration' | 'adapter';
|
|
10
|
-
}
|
|
11
5
|
export declare function add(names: string[], { flags }: AddOptions): Promise<void>;
|
|
12
|
-
export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
|
|
13
6
|
export {};
|
package/dist/cli/add/index.js
CHANGED
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,5 +13,4 @@ export declare function getPackage<T>(packageName: string, logger: Logger, optio
|
|
|
13
13
|
export declare function getExecCommand(packageManager?: string): Promise<string>;
|
|
14
14
|
export declare function fetchPackageJson(scope: string | undefined, name: string, tag: string): Promise<Record<string, any> | Error>;
|
|
15
15
|
export declare function fetchPackageVersions(packageName: string): Promise<string[] | Error>;
|
|
16
|
-
export declare function getRegistry(): Promise<string>;
|
|
17
16
|
export {};
|
|
@@ -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;
|
|
@@ -165,6 +165,5 @@ export {
|
|
|
165
165
|
fetchPackageJson,
|
|
166
166
|
fetchPackageVersions,
|
|
167
167
|
getExecCommand,
|
|
168
|
-
getPackage
|
|
169
|
-
getRegistry
|
|
168
|
+
getPackage
|
|
170
169
|
};
|
|
@@ -2,9 +2,9 @@ import type { PluginContext } from 'rollup';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
|
|
4
4
|
ASTRO_ASSET: string;
|
|
5
|
-
format: import("../assets/types.js").ImageInputFormat;
|
|
6
5
|
width: number;
|
|
7
6
|
height: number;
|
|
7
|
+
format: import("../assets/types.js").ImageInputFormat;
|
|
8
8
|
src: string;
|
|
9
9
|
fsPath: string;
|
|
10
10
|
orientation?: number | undefined;
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type ContentLookupMap = {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
|
|
23
23
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"content">>>;
|
|
24
24
|
schema: z.ZodOptional<z.ZodAny>;
|
|
25
25
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -38,7 +38,7 @@ export declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
|
|
|
38
38
|
type: "data";
|
|
39
39
|
schema?: any;
|
|
40
40
|
}>]>;
|
|
41
|
-
|
|
41
|
+
declare const contentConfigParser: z.ZodObject<{
|
|
42
42
|
collections: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
43
43
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"content">>>;
|
|
44
44
|
schema: z.ZodOptional<z.ZodAny>;
|
|
@@ -81,9 +81,6 @@ type EntryInternal = {
|
|
|
81
81
|
rawData: string | undefined;
|
|
82
82
|
filePath: string;
|
|
83
83
|
};
|
|
84
|
-
export declare const msg: {
|
|
85
|
-
collectionConfigMissing: (collection: string) => string;
|
|
86
|
-
};
|
|
87
84
|
export declare function parseEntrySlug({ id, collection, generatedSlug, frontmatterSlug, }: {
|
|
88
85
|
id: string;
|
|
89
86
|
collection: string;
|
|
@@ -124,7 +121,6 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
|
|
|
124
121
|
slug: string;
|
|
125
122
|
};
|
|
126
123
|
export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored';
|
|
127
|
-
export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean;
|
|
128
124
|
export declare function safeParseFrontmatter(source: string, id?: string): matter.GrayMatterFile<string>;
|
|
129
125
|
/**
|
|
130
126
|
* The content config is loaded separately from other `src/` files.
|
|
@@ -134,11 +130,6 @@ export declare function safeParseFrontmatter(source: string, id?: string): matte
|
|
|
134
130
|
export declare const globalContentConfigObserver: ContentObservable;
|
|
135
131
|
export declare function hasAnyContentFlag(viteId: string): boolean;
|
|
136
132
|
export declare function hasContentFlag(viteId: string, flag: (typeof CONTENT_FLAGS)[number]): boolean;
|
|
137
|
-
export declare function loadContentConfig({ fs, settings, viteServer, }: {
|
|
138
|
-
fs: typeof fsMod;
|
|
139
|
-
settings: AstroSettings;
|
|
140
|
-
viteServer: ViteDevServer;
|
|
141
|
-
}): Promise<ContentConfig | undefined>;
|
|
142
133
|
export declare function reloadContentConfigObserver({ observer, ...loadContentConfigOpts }: {
|
|
143
134
|
fs: typeof fsMod;
|
|
144
135
|
settings: AstroSettings;
|
package/dist/content/utils.js
CHANGED
|
@@ -22,9 +22,6 @@ const collectionConfigParser = z.union([
|
|
|
22
22
|
const contentConfigParser = z.object({
|
|
23
23
|
collections: z.record(collectionConfigParser)
|
|
24
24
|
});
|
|
25
|
-
const msg = {
|
|
26
|
-
collectionConfigMissing: (collection) => `${collection} does not have a config. We suggest adding one for type safety!`
|
|
27
|
-
};
|
|
28
25
|
function parseEntrySlug({
|
|
29
26
|
id,
|
|
30
27
|
collection,
|
|
@@ -387,8 +384,6 @@ function hasAssetPropagationFlag(id) {
|
|
|
387
384
|
}
|
|
388
385
|
}
|
|
389
386
|
export {
|
|
390
|
-
collectionConfigParser,
|
|
391
|
-
contentConfigParser,
|
|
392
387
|
contentObservable,
|
|
393
388
|
getContentEntryExts,
|
|
394
389
|
getContentEntryIdAndSlug,
|
|
@@ -406,9 +401,6 @@ export {
|
|
|
406
401
|
hasAnyContentFlag,
|
|
407
402
|
hasAssetPropagationFlag,
|
|
408
403
|
hasContentFlag,
|
|
409
|
-
hasUnderscoreBelowContentDirectoryPath,
|
|
410
|
-
loadContentConfig,
|
|
411
|
-
msg,
|
|
412
404
|
parseEntrySlug,
|
|
413
405
|
reloadContentConfigObserver,
|
|
414
406
|
reverseSymlink,
|
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;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import type { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
-
import type { AstroSettings } from '../../@types/astro.js';
|
|
3
1
|
import { type BuildInternals } from '../../core/build/internal.js';
|
|
4
2
|
import type { StaticBuildOptions } from './types.js';
|
|
5
|
-
export declare function rootRelativeFacadeId(facadeId: string, settings: AstroSettings): string;
|
|
6
|
-
export declare function chunkIsPage(settings: AstroSettings, output: OutputAsset | OutputChunk, internals: BuildInternals): boolean;
|
|
7
3
|
export declare function generatePages(options: StaticBuildOptions, internals: BuildInternals): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
3
|
import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
|
|
5
4
|
import PQueue from "p-queue";
|
|
6
5
|
import {
|
|
@@ -12,7 +11,6 @@ import { hasPrerenderedPages } from "../../core/build/internal.js";
|
|
|
12
11
|
import {
|
|
13
12
|
isRelativePath,
|
|
14
13
|
joinPaths,
|
|
15
|
-
prependForwardSlash,
|
|
16
14
|
removeLeadingForwardSlash,
|
|
17
15
|
removeTrailingForwardSlash
|
|
18
16
|
} from "../../core/path.js";
|
|
@@ -35,22 +33,6 @@ import { getTimeStat, shouldAppendForwardSlash } from "./util.js";
|
|
|
35
33
|
function createEntryURL(filePath, outFolder) {
|
|
36
34
|
return new URL("./" + filePath + `?time=${Date.now()}`, outFolder);
|
|
37
35
|
}
|
|
38
|
-
function rootRelativeFacadeId(facadeId, settings) {
|
|
39
|
-
return facadeId.slice(fileURLToPath(settings.config.root).length);
|
|
40
|
-
}
|
|
41
|
-
function chunkIsPage(settings, output, internals) {
|
|
42
|
-
if (output.type !== "chunk") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const chunk = output;
|
|
46
|
-
if (chunk.facadeModuleId) {
|
|
47
|
-
const facadeToEntryId = prependForwardSlash(
|
|
48
|
-
rootRelativeFacadeId(chunk.facadeModuleId, settings)
|
|
49
|
-
);
|
|
50
|
-
return internals.entrySpecifierToBundleMap.has(facadeToEntryId);
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
36
|
async function generatePages(options, internals) {
|
|
55
37
|
const generatePagesTimer = performance.now();
|
|
56
38
|
const ssr = isServerLikeOutput(options.settings.config);
|
|
@@ -241,7 +223,7 @@ async function getPathsForRoute(route, mod, pipeline, builtPaths) {
|
|
|
241
223
|
return paths;
|
|
242
224
|
}
|
|
243
225
|
function getInvalidRouteSegmentError(e, route, staticPath) {
|
|
244
|
-
const invalidParam =
|
|
226
|
+
const invalidParam = /^Expected "([^"]+)"/.exec(e.message)?.[1];
|
|
245
227
|
const received = invalidParam ? staticPath.params[invalidParam] : void 0;
|
|
246
228
|
let hint = "Learn about dynamic routes at https://docs.astro.build/en/core-concepts/routing/#dynamic-routes";
|
|
247
229
|
if (invalidParam && typeof received === "string") {
|
|
@@ -305,7 +287,7 @@ async function generatePath(pathname, pipeline, gopts, route) {
|
|
|
305
287
|
if (route.type === "fallback" && // If route is index page, continue rendering. The index page should
|
|
306
288
|
// always be rendered
|
|
307
289
|
route.pathname !== "/" && // Check if there is a translated page with the same path
|
|
308
|
-
Object.values(options.allPages).some((val) =>
|
|
290
|
+
Object.values(options.allPages).some((val) => val.route.pattern.test(pathname))) {
|
|
309
291
|
return;
|
|
310
292
|
}
|
|
311
293
|
const url = getUrlForPath(
|
|
@@ -371,7 +353,7 @@ function getPrettyRouteName(route) {
|
|
|
371
353
|
if (isRelativePath(route.component)) {
|
|
372
354
|
return route.route;
|
|
373
355
|
} else if (route.component.includes("node_modules/")) {
|
|
374
|
-
return
|
|
356
|
+
return /.*node_modules\/(.+)/.exec(route.component)?.[1] ?? route.component;
|
|
375
357
|
} else {
|
|
376
358
|
return route.component;
|
|
377
359
|
}
|
|
@@ -410,7 +392,5 @@ function createBuildManifest(settings, internals, renderers, middleware) {
|
|
|
410
392
|
};
|
|
411
393
|
}
|
|
412
394
|
export {
|
|
413
|
-
|
|
414
|
-
generatePages,
|
|
415
|
-
rootRelativeFacadeId
|
|
395
|
+
generatePages
|
|
416
396
|
};
|
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");
|
|
@@ -108,7 +114,7 @@ class AstroBuilder {
|
|
|
108
114
|
}
|
|
109
115
|
this.logger.info("build", "Collecting build info...");
|
|
110
116
|
this.timer.loadStart = performance.now();
|
|
111
|
-
const { assets, allPages } =
|
|
117
|
+
const { assets, allPages } = collectPagesData({
|
|
112
118
|
settings: this.settings,
|
|
113
119
|
logger: this.logger,
|
|
114
120
|
manifest: this.manifest
|