astro 5.10.1 → 5.11.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/components/Image.astro +1 -1
- package/components/Picture.astro +1 -1
- package/dist/actions/integration.js +2 -2
- package/dist/actions/runtime/virtual/server.d.ts +1 -1
- package/dist/actions/runtime/virtual/server.js +1 -1
- package/dist/actions/runtime/virtual/shared.d.ts +1 -1
- package/dist/actions/runtime/virtual/shared.js +1 -1
- package/dist/assets/endpoint/node.js +1 -1
- package/dist/assets/fonts/definitions.d.ts +1 -2
- package/dist/assets/fonts/vite-plugin-fonts.js +1 -1
- package/dist/assets/internal.js +2 -2
- package/dist/assets/utils/index.d.ts +4 -4
- package/dist/assets/utils/index.js +4 -4
- package/dist/assets/utils/remotePattern.d.ts +1 -1
- package/dist/config/entrypoint.d.ts +4 -4
- package/dist/config/entrypoint.js +3 -3
- package/dist/content/config.d.ts +1 -1
- package/dist/content/config.js +15 -0
- package/dist/content/content-layer.js +4 -4
- package/dist/content/loaders/file.js +1 -1
- package/dist/content/loaders/glob.js +1 -1
- package/dist/content/mutable-data-store.js +1 -1
- package/dist/content/runtime-assets.d.ts +2 -2
- package/dist/content/runtime.js +1 -1
- package/dist/content/utils.d.ts +5 -5
- package/dist/content/utils.js +2 -2
- package/dist/core/app/common.d.ts +1 -1
- package/dist/core/app/index.d.ts +9 -1
- package/dist/core/app/index.js +17 -4
- package/dist/core/app/node.d.ts +5 -3
- package/dist/core/app/node.js +6 -2
- package/dist/core/app/pipeline.js +1 -1
- package/dist/core/app/types.d.ts +7 -0
- package/dist/core/build/generate.js +22 -12
- package/dist/core/build/index.js +3 -4
- package/dist/core/build/pipeline.js +1 -1
- package/dist/core/build/plugins/plugin-css.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +5 -1
- package/dist/core/compile/index.d.ts +1 -1
- package/dist/core/config/schemas/base.d.ts +1 -1
- package/dist/core/config/schemas/index.d.ts +2 -2
- package/dist/core/config/schemas/index.js +3 -3
- package/dist/core/config/settings.js +1 -1
- package/dist/core/config/tsconfig.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/index.d.ts +1 -1
- package/dist/core/create-vite.js +1 -1
- package/dist/core/csp/common.js +2 -2
- package/dist/core/dev/container.d.ts +2 -2
- package/dist/core/dev/dev.js +2 -2
- package/dist/core/errors/dev/vite.js +1 -1
- package/dist/core/errors/index.d.ts +2 -2
- package/dist/core/errors/index.js +4 -4
- package/dist/core/logger/console.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/sequence.js +7 -2
- package/dist/core/module-loader/index.d.ts +1 -1
- package/dist/core/render-context.js +22 -6
- package/dist/core/routing/default.js +2 -2
- package/dist/core/routing/manifest/create.d.ts +1 -1
- package/dist/core/routing/rewrite.d.ts +2 -2
- package/dist/core/routing/rewrite.js +14 -2
- package/dist/core/viteUtils.js +1 -1
- package/dist/env/runtime.d.ts +1 -1
- package/dist/env/runtime.js +1 -1
- package/dist/env/setup.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/integrations/hooks.d.ts +2 -2
- package/dist/jsx-runtime/index.js +1 -1
- package/dist/runtime/client/dev-toolbar/ui-library/index.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/ui-library/index.js +1 -1
- package/dist/runtime/compiler/index.d.ts +1 -1
- package/dist/runtime/compiler/index.js +1 -1
- package/dist/runtime/server/endpoint.js +1 -1
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +3 -3
- package/dist/runtime/server/jsx.js +1 -1
- package/dist/runtime/server/render/astro/index.d.ts +3 -3
- package/dist/runtime/server/render/astro/index.js +1 -1
- package/dist/runtime/server/render/astro/instance.d.ts +2 -2
- package/dist/runtime/server/render/component.js +5 -5
- package/dist/runtime/server/render/index.d.ts +4 -4
- package/dist/runtime/server/render/index.js +2 -2
- package/dist/runtime/server/render/server-islands.d.ts +7 -0
- package/dist/runtime/server/render/server-islands.js +64 -26
- package/dist/runtime/server/render/slot.d.ts +2 -2
- package/dist/runtime/server/render/slot.js +1 -1
- package/dist/runtime/server/render/util.d.ts +1 -1
- package/dist/runtime/server/scripts.js +2 -2
- package/dist/template/4xx.js +1 -1
- package/dist/transitions/router.js +1 -1
- package/dist/types/public/context.d.ts +7 -7
- package/dist/types/public/index.d.ts +16 -16
- package/dist/types/public/integrations.d.ts +6 -1
- package/dist/types/public/internal.d.ts +1 -1
- package/dist/virtual-modules/i18n.d.ts +1 -1
- package/dist/vite-plugin-astro-server/base.d.ts +1 -1
- package/dist/vite-plugin-astro-server/error.d.ts +1 -1
- package/dist/vite-plugin-astro-server/pipeline.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +3 -3
- package/dist/vite-plugin-head/index.d.ts +1 -1
- package/dist/vite-plugin-html/transform/slots.d.ts +1 -1
- package/package.json +1 -1
package/components/Image.astro
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { type LocalImageProps, type RemoteImageProps
|
|
2
|
+
import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
|
3
3
|
import type { UnresolvedImageTransform } from '../dist/assets/types';
|
|
4
4
|
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
|
5
5
|
import type { HTMLAttributes } from '../types';
|
package/components/Picture.astro
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { type LocalImageProps, type RemoteImageProps
|
|
2
|
+
import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
|
3
3
|
import * as mime from 'mrmime';
|
|
4
4
|
import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind.js';
|
|
5
5
|
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ActionsWithoutServerOutputError } from "../core/errors/errors-data.js";
|
|
2
1
|
import { AstroError } from "../core/errors/errors.js";
|
|
2
|
+
import { ActionsWithoutServerOutputError } from "../core/errors/errors-data.js";
|
|
3
3
|
import { viteID } from "../core/util.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ACTION_RPC_ROUTE_PATTERN, ACTIONS_TYPES_FILE, VIRTUAL_MODULE_ID } from "./consts.js";
|
|
5
5
|
function astroIntegrationActionsRouteHandler({
|
|
6
6
|
settings,
|
|
7
7
|
filename
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { APIContext } from '../../../types/public/index.js';
|
|
3
3
|
import { type ActionAPIContext, type ErrorInferenceObject, type MaybePromise } from '../utils.js';
|
|
4
|
-
import { type SafeResult, type SerializedActionResult,
|
|
4
|
+
import { deserializeActionResult, type SafeResult, type SerializedActionResult, serializeActionResult } from './shared.js';
|
|
5
5
|
export * from './shared.js';
|
|
6
6
|
export type ActionAccept = 'form' | 'json';
|
|
7
7
|
export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z.infer<TInputSchema>, context: ActionAPIContext) => MaybePromise<TOutput> : (input: any, context: ActionAPIContext) => MaybePromise<TOutput>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { shouldAppendForwardSlash } from "../../../core/build/util.js";
|
|
3
|
-
import { ActionCalledFromServerError } from "../../../core/errors/errors-data.js";
|
|
4
3
|
import { AstroError } from "../../../core/errors/errors.js";
|
|
4
|
+
import { ActionCalledFromServerError } from "../../../core/errors/errors-data.js";
|
|
5
5
|
import { removeTrailingForwardSlash } from "../../../core/path.js";
|
|
6
6
|
import { apiContextRoutesSymbol } from "../../../core/render-context.js";
|
|
7
7
|
import { ACTION_RPC_ROUTE_PATTERN } from "../../consts.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import { AstroError } from '../../../core/errors/errors.js';
|
|
3
3
|
import { appendForwardSlash as _appendForwardSlash } from '../../../core/path.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ActionAPIContext as _ActionAPIContext, ErrorInferenceObject, MaybePromise } from '../utils.js';
|
|
5
5
|
export type ActionAPIContext = _ActionAPIContext;
|
|
6
6
|
export declare const ACTION_QUERY_PARAMS: {
|
|
7
7
|
actionName: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parse as devalueParse, stringify as devalueStringify } from "devalue";
|
|
2
2
|
import { REDIRECT_STATUS_CODES } from "../../../core/constants.js";
|
|
3
|
+
import { AstroError } from "../../../core/errors/errors.js";
|
|
3
4
|
import {
|
|
4
5
|
ActionCalledFromServerError,
|
|
5
6
|
ActionsReturnedInvalidDataError
|
|
6
7
|
} from "../../../core/errors/errors-data.js";
|
|
7
|
-
import { AstroError } from "../../../core/errors/errors.js";
|
|
8
8
|
import { appendForwardSlash as _appendForwardSlash } from "../../../core/path.js";
|
|
9
9
|
import { ACTION_QUERY_PARAMS as _ACTION_QUERY_PARAMS } from "../../consts.js";
|
|
10
10
|
const ACTION_QUERY_PARAMS = _ACTION_QUERY_PARAMS;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { assetsDir, imageConfig, outDir } from "astro:assets";
|
|
1
2
|
import { readFile } from "node:fs/promises";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
import { isAbsolute } from "node:path";
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
-
import { assetsDir, imageConfig, outDir } from "astro:assets";
|
|
6
6
|
import { isRemotePath, removeQueryString } from "@astrojs/internal-helpers/path";
|
|
7
7
|
import { isRemoteAllowed } from "@astrojs/internal-helpers/remote";
|
|
8
8
|
import * as mime from "mrmime";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type * as unifont from 'unifont';
|
|
2
2
|
import type { CollectedFontForMetrics } from './logic/optimize-fallbacks.js';
|
|
3
|
-
import type { AstroFontProvider, FontFileData, FontType, PreloadData, ResolvedFontProvider, Style } from './types.js';
|
|
4
|
-
import type { FontFaceMetrics, GenericFallbackName } from './types.js';
|
|
3
|
+
import type { AstroFontProvider, FontFaceMetrics, FontFileData, FontType, GenericFallbackName, PreloadData, ResolvedFontProvider, Style } from './types.js';
|
|
5
4
|
export interface Hasher {
|
|
6
5
|
hashString: (input: string) => string;
|
|
7
6
|
hashObject: (input: Record<string, any>) => string;
|
|
@@ -30,11 +30,11 @@ import {
|
|
|
30
30
|
import { createRemoteFontProviderResolver } from "./implementations/remote-font-provider-resolver.js";
|
|
31
31
|
import { createFsStorage } from "./implementations/storage.js";
|
|
32
32
|
import { createSystemFallbacksProvider } from "./implementations/system-fallbacks-provider.js";
|
|
33
|
+
import { createUrlProxy } from "./implementations/url-proxy.js";
|
|
33
34
|
import {
|
|
34
35
|
createLocalUrlProxyContentResolver,
|
|
35
36
|
createRemoteUrlProxyContentResolver
|
|
36
37
|
} from "./implementations/url-proxy-content-resolver.js";
|
|
37
|
-
import { createUrlProxy } from "./implementations/url-proxy.js";
|
|
38
38
|
import { createBuildUrlResolver, createDevUrlResolver } from "./implementations/url-resolver.js";
|
|
39
39
|
import { orchestrate } from "./orchestrate.js";
|
|
40
40
|
function fontsPlugin({ settings, sync, logger }) {
|
package/dist/assets/internal.js
CHANGED
|
@@ -3,9 +3,9 @@ import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
|
3
3
|
import { DEFAULT_HASH_PROPS } from "./consts.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_RESOLUTIONS,
|
|
6
|
-
LIMITED_RESOLUTIONS,
|
|
7
6
|
getSizesAttribute,
|
|
8
|
-
getWidths
|
|
7
|
+
getWidths,
|
|
8
|
+
LIMITED_RESOLUTIONS
|
|
9
9
|
} from "./layout.js";
|
|
10
10
|
import { isLocalService } from "./services/service.js";
|
|
11
11
|
import {
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* If some functions don't need to be exposed, just import the file that contains the functions.
|
|
6
6
|
*/
|
|
7
|
+
export { isESMImportedImage, isRemoteImage } from './imageKind.js';
|
|
8
|
+
export { imageMetadata } from './metadata.js';
|
|
7
9
|
export {
|
|
8
10
|
/**
|
|
9
11
|
* @deprecated
|
|
10
12
|
*/
|
|
11
13
|
emitESMImage, emitImageMetadata, } from './node/emitAsset.js';
|
|
12
|
-
export { isESMImportedImage, isRemoteImage } from './imageKind.js';
|
|
13
|
-
export { imageMetadata } from './metadata.js';
|
|
14
14
|
export { getOrigQueryParams } from './queryParams.js';
|
|
15
|
-
export { hashTransform, propsToFilename } from './transformToPath.js';
|
|
16
|
-
export { inferRemoteSize } from './remoteProbe.js';
|
|
17
15
|
export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from './remotePattern.js';
|
|
16
|
+
export { inferRemoteSize } from './remoteProbe.js';
|
|
17
|
+
export { hashTransform, propsToFilename } from './transformToPath.js';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { isESMImportedImage, isRemoteImage } from "./imageKind.js";
|
|
2
|
+
import { imageMetadata } from "./metadata.js";
|
|
1
3
|
import {
|
|
2
4
|
emitESMImage,
|
|
3
5
|
emitImageMetadata
|
|
4
6
|
} from "./node/emitAsset.js";
|
|
5
|
-
import { isESMImportedImage, isRemoteImage } from "./imageKind.js";
|
|
6
|
-
import { imageMetadata } from "./metadata.js";
|
|
7
7
|
import { getOrigQueryParams } from "./queryParams.js";
|
|
8
|
-
import { hashTransform, propsToFilename } from "./transformToPath.js";
|
|
9
|
-
import { inferRemoteSize } from "./remoteProbe.js";
|
|
10
8
|
import {
|
|
11
9
|
isRemoteAllowed,
|
|
12
10
|
matchHostname,
|
|
@@ -15,6 +13,8 @@ import {
|
|
|
15
13
|
matchPort,
|
|
16
14
|
matchProtocol
|
|
17
15
|
} from "./remotePattern.js";
|
|
16
|
+
import { inferRemoteSize } from "./remoteProbe.js";
|
|
17
|
+
import { hashTransform, propsToFilename } from "./transformToPath.js";
|
|
18
18
|
export {
|
|
19
19
|
emitESMImage,
|
|
20
20
|
emitImageMetadata,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern } from '@astrojs/internal-helpers/remote';
|
|
2
2
|
export { isRemoteAllowed, matchHostname, matchPort, matchPathname, matchProtocol, matchPattern };
|
|
3
3
|
export type { RemotePattern };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { SharpImageServiceConfig } from '../assets/services/sharp.js';
|
|
2
2
|
import type { ImageServiceConfig } from '../types/public/index.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { defineAstroFontProvider, fontProviders } from '../assets/fonts/providers/index.js';
|
|
4
|
+
export type { AstroFontProvider } from '../assets/fonts/types.js';
|
|
5
5
|
export { mergeConfig } from '../core/config/merge.js';
|
|
6
6
|
export { validateConfig } from '../core/config/validate.js';
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
7
|
+
export { envField } from '../env/config.js';
|
|
8
|
+
export { defineConfig, getViteConfig } from './index.js';
|
|
9
9
|
/**
|
|
10
10
|
* Return the configuration needed to use the Sharp-based image service
|
|
11
11
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { envField } from "../env/config.js";
|
|
1
|
+
import { defineAstroFontProvider, fontProviders } from "../assets/fonts/providers/index.js";
|
|
3
2
|
import { mergeConfig } from "../core/config/merge.js";
|
|
4
3
|
import { validateConfig } from "../core/config/validate.js";
|
|
5
|
-
import {
|
|
4
|
+
import { envField } from "../env/config.js";
|
|
5
|
+
import { defineConfig, getViteConfig } from "./index.js";
|
|
6
6
|
function sharpImageService(config = {}) {
|
|
7
7
|
return {
|
|
8
8
|
entrypoint: "astro/assets/services/sharp",
|
package/dist/content/config.d.ts
CHANGED
package/dist/content/config.js
CHANGED
|
@@ -21,6 +21,7 @@ function defineLiveCollection(config) {
|
|
|
21
21
|
)
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
config.type ??= LIVE_CONTENT_TYPE;
|
|
24
25
|
if (config.type !== LIVE_CONTENT_TYPE) {
|
|
25
26
|
throw new AstroError({
|
|
26
27
|
...AstroErrorData.LiveContentConfigError,
|
|
@@ -39,6 +40,15 @@ function defineLiveCollection(config) {
|
|
|
39
40
|
)
|
|
40
41
|
});
|
|
41
42
|
}
|
|
43
|
+
if (!config.loader.loadCollection || !config.loader.loadEntry) {
|
|
44
|
+
throw new AstroError({
|
|
45
|
+
...AstroErrorData.LiveContentConfigError,
|
|
46
|
+
message: AstroErrorData.LiveContentConfigError.message(
|
|
47
|
+
"Live collection loaders must have `loadCollection()` and `loadEntry()` methods. Please check that you are not using a loader intended for build-time collections",
|
|
48
|
+
importerFilename
|
|
49
|
+
)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
42
52
|
if (typeof config.schema === "function") {
|
|
43
53
|
throw new AstroError({
|
|
44
54
|
...AstroErrorData.LiveContentConfigError,
|
|
@@ -67,6 +77,11 @@ function defineCollection(config) {
|
|
|
67
77
|
`Collections that use the Content Layer API must have a \`loader\` defined and no \`type\` set. Check your collection definitions in ${importerFilename ?? "your content config file"}.`
|
|
68
78
|
);
|
|
69
79
|
}
|
|
80
|
+
if (typeof config.loader === "object" && typeof config.loader.load !== "function" && ("loadEntry" in config.loader || "loadCollection" in config.loader)) {
|
|
81
|
+
throw new AstroUserError(
|
|
82
|
+
`Live content collections must be defined in "src/live.config.ts" file. Check your collection definitions in "${importerFilename ?? "your content config file"}" to ensure you are not using a live loader.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
70
85
|
config.type = CONTENT_LAYER_TYPE;
|
|
71
86
|
}
|
|
72
87
|
if (!config.type) config.type = "content";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { promises as fs
|
|
1
|
+
import { existsSync, promises as fs } from "node:fs";
|
|
2
2
|
import { createMarkdownProcessor } from "@astrojs/markdown-remark";
|
|
3
3
|
import PQueue from "p-queue";
|
|
4
4
|
import xxhash from "xxhash-wasm";
|
|
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
|
|
|
164
164
|
logger.info("Content config changed");
|
|
165
165
|
shouldClear = true;
|
|
166
166
|
}
|
|
167
|
-
if (previousAstroVersion && previousAstroVersion !== "5.
|
|
167
|
+
if (previousAstroVersion && previousAstroVersion !== "5.11.0") {
|
|
168
168
|
logger.info("Astro version changed");
|
|
169
169
|
shouldClear = true;
|
|
170
170
|
}
|
|
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
|
|
|
172
172
|
logger.info("Clearing content store");
|
|
173
173
|
this.#store.clearAll();
|
|
174
174
|
}
|
|
175
|
-
if ("5.
|
|
176
|
-
await this.#store.metaStore().set("astro-version", "5.
|
|
175
|
+
if ("5.11.0") {
|
|
176
|
+
await this.#store.metaStore().set("astro-version", "5.11.0");
|
|
177
177
|
}
|
|
178
178
|
if (currentConfigDigest) {
|
|
179
179
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { promises as fs
|
|
1
|
+
import { existsSync, promises as fs } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import yaml from "js-yaml";
|
|
4
4
|
import { FileGlobNotSupported, FileParserNotFound } from "../../core/errors/errors-data.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { promises as fs
|
|
1
|
+
import { existsSync, promises as fs } from "node:fs";
|
|
2
2
|
import * as devalue from "devalue";
|
|
3
3
|
import { Traverse } from "neotraverse/modern";
|
|
4
4
|
import { imageSrcToImportId, importIdToSymbolName } from "../assets/utils/resolveImports.js";
|
|
@@ -2,10 +2,10 @@ import type { PluginContext } from 'rollup';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string, experimentalSvgEnabled: boolean): () => z.ZodEffects<z.ZodString, z.ZodNever | {
|
|
4
4
|
ASTRO_ASSET: string;
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
5
|
src: string;
|
|
8
6
|
format: import("../assets/types.js").ImageInputFormat;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
9
|
fsPath: string;
|
|
10
10
|
orientation?: number | undefined;
|
|
11
11
|
}, string>;
|
package/dist/content/runtime.js
CHANGED
|
@@ -5,7 +5,6 @@ import { ZodIssueCode, z } from "zod";
|
|
|
5
5
|
import { imageSrcToImportId } from "../assets/utils/resolveImports.js";
|
|
6
6
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
7
7
|
import { prependForwardSlash } from "../core/path.js";
|
|
8
|
-
import { defineCollection as defineCollectionOrig } from "./config.js";
|
|
9
8
|
import {
|
|
10
9
|
createComponent,
|
|
11
10
|
createHeadAndContent,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
render as serverRender,
|
|
17
16
|
unescapeHTML
|
|
18
17
|
} from "../runtime/server/index.js";
|
|
18
|
+
import { defineCollection as defineCollectionOrig } from "./config.js";
|
|
19
19
|
import { IMAGE_IMPORT_PREFIX } from "./consts.js";
|
|
20
20
|
import { globalDataStore } from "./data-store.js";
|
|
21
21
|
import {
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
|
|
|
177
177
|
schema?: any;
|
|
178
178
|
_legacy?: boolean | undefined;
|
|
179
179
|
}>, z.ZodObject<{
|
|
180
|
-
type: z.ZodLiteral<"live"
|
|
180
|
+
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"live">>>;
|
|
181
181
|
schema: z.ZodOptional<z.ZodAny>;
|
|
182
182
|
loader: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
|
|
183
183
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -185,8 +185,8 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
|
|
|
185
185
|
loader: (...args: unknown[]) => unknown;
|
|
186
186
|
schema?: any;
|
|
187
187
|
}, {
|
|
188
|
-
type: "live";
|
|
189
188
|
loader: (...args: unknown[]) => unknown;
|
|
189
|
+
type?: "live" | undefined;
|
|
190
190
|
schema?: any;
|
|
191
191
|
}>]>;
|
|
192
192
|
declare const contentConfigParser: z.ZodObject<{
|
|
@@ -334,7 +334,7 @@ declare const contentConfigParser: z.ZodObject<{
|
|
|
334
334
|
schema?: any;
|
|
335
335
|
_legacy?: boolean | undefined;
|
|
336
336
|
}>, z.ZodObject<{
|
|
337
|
-
type: z.ZodLiteral<"live"
|
|
337
|
+
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"live">>>;
|
|
338
338
|
schema: z.ZodOptional<z.ZodAny>;
|
|
339
339
|
loader: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
|
|
340
340
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -342,8 +342,8 @@ declare const contentConfigParser: z.ZodObject<{
|
|
|
342
342
|
loader: (...args: unknown[]) => unknown;
|
|
343
343
|
schema?: any;
|
|
344
344
|
}, {
|
|
345
|
-
type: "live";
|
|
346
345
|
loader: (...args: unknown[]) => unknown;
|
|
346
|
+
type?: "live" | undefined;
|
|
347
347
|
schema?: any;
|
|
348
348
|
}>]>>;
|
|
349
349
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -410,8 +410,8 @@ declare const contentConfigParser: z.ZodObject<{
|
|
|
410
410
|
schema?: any;
|
|
411
411
|
_legacy?: boolean | undefined;
|
|
412
412
|
} | {
|
|
413
|
-
type: "live";
|
|
414
413
|
loader: (...args: unknown[]) => unknown;
|
|
414
|
+
type?: "live" | undefined;
|
|
415
415
|
schema?: any;
|
|
416
416
|
}>;
|
|
417
417
|
}>;
|
package/dist/content/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ import { slug as githubSlug } from "github-slugger";
|
|
|
6
6
|
import { green } from "kleur/colors";
|
|
7
7
|
import xxhash from "xxhash-wasm";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
import { AstroError, AstroErrorData,
|
|
9
|
+
import { AstroError, AstroErrorData, errorMap, MarkdownError } from "../core/errors/index.js";
|
|
10
10
|
import { isYAMLException } from "../core/errors/utils.js";
|
|
11
11
|
import { appendForwardSlash } from "../core/path.js";
|
|
12
12
|
import { normalizePath } from "../core/viteUtils.js";
|
|
@@ -81,7 +81,7 @@ const collectionConfigParser = z.union([
|
|
|
81
81
|
_legacy: z.boolean().optional()
|
|
82
82
|
}),
|
|
83
83
|
z.object({
|
|
84
|
-
type: z.literal(LIVE_CONTENT_TYPE),
|
|
84
|
+
type: z.literal(LIVE_CONTENT_TYPE).optional().default(LIVE_CONTENT_TYPE),
|
|
85
85
|
schema: z.any().optional(),
|
|
86
86
|
loader: z.function()
|
|
87
87
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SerializedSSRManifest, SSRManifest } from './types.js';
|
|
2
2
|
export declare function deserializeManifest(serializedManifest: SerializedSSRManifest): SSRManifest;
|
package/dist/core/app/index.d.ts
CHANGED
|
@@ -67,7 +67,15 @@ export declare class App {
|
|
|
67
67
|
getAdapterLogger(): AstroIntegrationLogger;
|
|
68
68
|
set setManifestData(newManifestData: RoutesList);
|
|
69
69
|
removeBase(pathname: string): string;
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Given a `Request`, it returns the `RouteData` that matches its `pathname`. By default, prerendered
|
|
72
|
+
* routes aren't returned, even if they are matched.
|
|
73
|
+
*
|
|
74
|
+
* When `allowPrerenderedRoutes` is `true`, the function returns matched prerendered routes too.
|
|
75
|
+
* @param request
|
|
76
|
+
* @param allowPrerenderedRoutes
|
|
77
|
+
*/
|
|
78
|
+
match(request: Request, allowPrerenderedRoutes?: boolean): RouteData | undefined;
|
|
71
79
|
render(request: Request, renderOptions?: RenderOptions): Promise<Response>;
|
|
72
80
|
setCookieHeaders(response: Response): Generator<string, string[], any>;
|
|
73
81
|
/**
|
package/dist/core/app/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { collapseDuplicateTrailingSlashes, hasFileExtension } from "@astrojs/internal-helpers/path";
|
|
2
2
|
import { normalizeTheLocale } from "../../i18n/index.js";
|
|
3
3
|
import {
|
|
4
|
+
clientAddressSymbol,
|
|
4
5
|
DEFAULT_404_COMPONENT,
|
|
5
6
|
REROUTABLE_STATUS_CODES,
|
|
6
7
|
REROUTE_DIRECTIVE_HEADER,
|
|
7
|
-
clientAddressSymbol,
|
|
8
8
|
responseSentSymbol
|
|
9
9
|
} from "../constants.js";
|
|
10
10
|
import { getSetCookiesFromResponse } from "../cookies/index.js";
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
prependForwardSlash,
|
|
19
19
|
removeTrailingForwardSlash
|
|
20
20
|
} from "../path.js";
|
|
21
|
-
import { RenderContext } from "../render-context.js";
|
|
22
21
|
import { createAssetLink } from "../render/ssr-element.js";
|
|
22
|
+
import { RenderContext } from "../render-context.js";
|
|
23
23
|
import { redirectTemplate } from "../routing/3xx.js";
|
|
24
24
|
import { ensure404Route } from "../routing/astro-designed-error-pages.js";
|
|
25
25
|
import { createDefaultRoutes } from "../routing/default.js";
|
|
@@ -107,7 +107,15 @@ class App {
|
|
|
107
107
|
return pathname;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Given a `Request`, it returns the `RouteData` that matches its `pathname`. By default, prerendered
|
|
112
|
+
* routes aren't returned, even if they are matched.
|
|
113
|
+
*
|
|
114
|
+
* When `allowPrerenderedRoutes` is `true`, the function returns matched prerendered routes too.
|
|
115
|
+
* @param request
|
|
116
|
+
* @param allowPrerenderedRoutes
|
|
117
|
+
*/
|
|
118
|
+
match(request, allowPrerenderedRoutes = false) {
|
|
111
119
|
const url = new URL(request.url);
|
|
112
120
|
if (this.#manifest.assets.has(url.pathname)) return void 0;
|
|
113
121
|
let pathname = this.#computePathnameFromDomain(request);
|
|
@@ -115,7 +123,12 @@ class App {
|
|
|
115
123
|
pathname = prependForwardSlash(this.removeBase(url.pathname));
|
|
116
124
|
}
|
|
117
125
|
let routeData = matchRoute(decodeURI(pathname), this.#manifestData);
|
|
118
|
-
if (!routeData
|
|
126
|
+
if (!routeData) return void 0;
|
|
127
|
+
if (allowPrerenderedRoutes) {
|
|
128
|
+
return routeData;
|
|
129
|
+
} else if (routeData.prerender) {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
119
132
|
return routeData;
|
|
120
133
|
}
|
|
121
134
|
#computePathnameFromDomain(request) {
|
package/dist/core/app/node.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import type { RouteData } from '../../types/public/internal.js';
|
|
3
|
-
import { App } from './index.js';
|
|
4
3
|
import type { RenderOptions } from './index.js';
|
|
5
|
-
import
|
|
4
|
+
import { App } from './index.js';
|
|
5
|
+
import type { NodeAppHeadersJson, SSRManifest } from './types.js';
|
|
6
6
|
export { apply as applyPolyfills } from '../polyfill.js';
|
|
7
7
|
/**
|
|
8
8
|
* Allow the request body to be explicitly overridden. For example, this
|
|
@@ -12,7 +12,9 @@ interface NodeRequest extends IncomingMessage {
|
|
|
12
12
|
body?: unknown;
|
|
13
13
|
}
|
|
14
14
|
export declare class NodeApp extends App {
|
|
15
|
-
|
|
15
|
+
headersMap: NodeAppHeadersJson | undefined;
|
|
16
|
+
setHeadersMap(headers: NodeAppHeadersJson): void;
|
|
17
|
+
match(req: NodeRequest | Request, allowPrerenderedRoutes?: boolean): RouteData | undefined;
|
|
16
18
|
render(request: NodeRequest | Request, options?: RenderOptions): Promise<Response>;
|
|
17
19
|
/**
|
|
18
20
|
* @deprecated Instead of passing `RouteData` and locals individually, pass an object with `routeData` and `locals` properties.
|
package/dist/core/app/node.js
CHANGED
|
@@ -6,13 +6,17 @@ import { createOutgoingHttpHeaders } from "./createOutgoingHttpHeaders.js";
|
|
|
6
6
|
import { App } from "./index.js";
|
|
7
7
|
import { apply } from "../polyfill.js";
|
|
8
8
|
class NodeApp extends App {
|
|
9
|
-
|
|
9
|
+
headersMap = void 0;
|
|
10
|
+
setHeadersMap(headers) {
|
|
11
|
+
this.headersMap = headers;
|
|
12
|
+
}
|
|
13
|
+
match(req, allowPrerenderedRoutes = false) {
|
|
10
14
|
if (!(req instanceof Request)) {
|
|
11
15
|
req = NodeApp.createRequest(req, {
|
|
12
16
|
skipBody: true
|
|
13
17
|
});
|
|
14
18
|
}
|
|
15
|
-
return super.match(req);
|
|
19
|
+
return super.match(req, allowPrerenderedRoutes);
|
|
16
20
|
}
|
|
17
21
|
render(req, routeDataOrOptions, maybeLocals) {
|
|
18
22
|
if (!(req instanceof Request)) {
|
|
@@ -66,7 +66,7 @@ class AppPipeline extends Pipeline {
|
|
|
66
66
|
trailingSlash: this.manifest.trailingSlash,
|
|
67
67
|
buildFormat: this.manifest.buildFormat,
|
|
68
68
|
base: this.manifest.base,
|
|
69
|
-
outDir: this.manifest.outDir
|
|
69
|
+
outDir: this.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
|
|
70
70
|
});
|
|
71
71
|
const componentInstance = await this.getComponentByRoute(routeData);
|
|
72
72
|
return { newUrl, pathname, componentInstance, routeData };
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -110,4 +110,11 @@ export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' |
|
|
|
110
110
|
serverIslandNameMap: [string, string][];
|
|
111
111
|
key: string;
|
|
112
112
|
};
|
|
113
|
+
export type NodeAppHeadersJson = {
|
|
114
|
+
pathname: string;
|
|
115
|
+
headers: {
|
|
116
|
+
key: string;
|
|
117
|
+
value: string;
|
|
118
|
+
}[];
|
|
119
|
+
}[];
|
|
113
120
|
export {};
|
|
@@ -34,16 +34,15 @@ import { NoPrerenderedRoutesWithDomains } from "../errors/errors-data.js";
|
|
|
34
34
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
35
35
|
import { NOOP_MIDDLEWARE_FN } from "../middleware/noop-middleware.js";
|
|
36
36
|
import { getRedirectLocationOrThrow, routeIsRedirect } from "../redirects/index.js";
|
|
37
|
-
import { RenderContext } from "../render-context.js";
|
|
38
37
|
import { callGetStaticPaths } from "../render/route-cache.js";
|
|
38
|
+
import { RenderContext } from "../render-context.js";
|
|
39
39
|
import { createRequest } from "../request.js";
|
|
40
40
|
import { redirectTemplate } from "../routing/3xx.js";
|
|
41
41
|
import { matchRoute } from "../routing/match.js";
|
|
42
42
|
import { stringifyParams } from "../routing/params.js";
|
|
43
43
|
import { getOutputFilename } from "../util.js";
|
|
44
44
|
import { getOutFile, getOutFolder } from "./common.js";
|
|
45
|
-
import { hasPrerenderedPages } from "./internal.js";
|
|
46
|
-
import { cssOrder, mergeInlineCss } from "./internal.js";
|
|
45
|
+
import { cssOrder, hasPrerenderedPages, mergeInlineCss } from "./internal.js";
|
|
47
46
|
import { BuildPipeline } from "./pipeline.js";
|
|
48
47
|
import { getTimeStat, shouldAppendForwardSlash } from "./util.js";
|
|
49
48
|
async function generatePages(options, internals) {
|
|
@@ -147,7 +146,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline, routeToHea
|
|
|
147
146
|
styles,
|
|
148
147
|
mod: pageModule
|
|
149
148
|
};
|
|
150
|
-
async function generatePathWithLogs(path, route, index, paths, isConcurrent) {
|
|
149
|
+
async function generatePathWithLogs(path, route, integrationRoute, index, paths, isConcurrent) {
|
|
151
150
|
const timeStart = performance.now();
|
|
152
151
|
pipeline.logger.debug("build", `Generating: ${path}`);
|
|
153
152
|
const filePath = getOutputFilename(config, path, pageData.route);
|
|
@@ -155,7 +154,14 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline, routeToHea
|
|
|
155
154
|
if (!isConcurrent) {
|
|
156
155
|
logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false);
|
|
157
156
|
}
|
|
158
|
-
const created = await generatePath(
|
|
157
|
+
const created = await generatePath(
|
|
158
|
+
path,
|
|
159
|
+
pipeline,
|
|
160
|
+
generationOptions,
|
|
161
|
+
route,
|
|
162
|
+
integrationRoute,
|
|
163
|
+
routeToHeaders
|
|
164
|
+
);
|
|
159
165
|
const timeEnd = performance.now();
|
|
160
166
|
const isSlow = timeEnd - timeStart > THRESHOLD_SLOW_RENDER_TIME_MS;
|
|
161
167
|
const timeIncrease = (isSlow ? red : dim)(`(+${getTimeStat(timeStart, timeEnd)})`);
|
|
@@ -167,6 +173,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline, routeToHea
|
|
|
167
173
|
}
|
|
168
174
|
}
|
|
169
175
|
for (const route of eachRouteInRouteData(pageData)) {
|
|
176
|
+
const integrationRoute = toIntegrationResolvedRoute(route);
|
|
170
177
|
const icon = route.type === "page" || route.type === "redirect" || route.type === "fallback" ? green("\u25B6") : magenta("\u03BB");
|
|
171
178
|
logger.info(null, `${icon} ${getPrettyRouteName(route)}`);
|
|
172
179
|
const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths);
|
|
@@ -175,13 +182,15 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline, routeToHea
|
|
|
175
182
|
const promises = [];
|
|
176
183
|
for (let i = 0; i < paths.length; i++) {
|
|
177
184
|
const path = paths[i];
|
|
178
|
-
promises.push(
|
|
185
|
+
promises.push(
|
|
186
|
+
limit(() => generatePathWithLogs(path, route, integrationRoute, i, paths, true))
|
|
187
|
+
);
|
|
179
188
|
}
|
|
180
189
|
await Promise.all(promises);
|
|
181
190
|
} else {
|
|
182
191
|
for (let i = 0; i < paths.length; i++) {
|
|
183
192
|
const path = paths[i];
|
|
184
|
-
await generatePathWithLogs(path, route, i, paths, false);
|
|
193
|
+
await generatePathWithLogs(path, route, integrationRoute, i, paths, false);
|
|
185
194
|
}
|
|
186
195
|
}
|
|
187
196
|
}
|
|
@@ -292,7 +301,7 @@ function getUrlForPath(pathname, base, origin, format, trailingSlash, routeType)
|
|
|
292
301
|
}
|
|
293
302
|
return new URL(buildPathname, origin);
|
|
294
303
|
}
|
|
295
|
-
async function generatePath(pathname, pipeline, gopts, route, routeToHeaders) {
|
|
304
|
+
async function generatePath(pathname, pipeline, gopts, route, integrationRoute, routeToHeaders) {
|
|
296
305
|
const { mod } = gopts;
|
|
297
306
|
const { config, logger, options } = pipeline;
|
|
298
307
|
logger.debug("build", `Generating: ${pathname}`);
|
|
@@ -346,14 +355,12 @@ async function generatePath(pathname, pipeline, gopts, route, routeToHeaders) {
|
|
|
346
355
|
}
|
|
347
356
|
throw err;
|
|
348
357
|
}
|
|
349
|
-
|
|
350
|
-
routeToHeaders.set(toIntegrationResolvedRoute(route), response.headers);
|
|
351
|
-
}
|
|
358
|
+
const responseHeaders = response.headers;
|
|
352
359
|
if (response.status >= 300 && response.status < 400) {
|
|
353
360
|
if (routeIsRedirect(route) && !config.build.redirects) {
|
|
354
361
|
return void 0;
|
|
355
362
|
}
|
|
356
|
-
const locationSite = getRedirectLocationOrThrow(
|
|
363
|
+
const locationSite = getRedirectLocationOrThrow(responseHeaders);
|
|
357
364
|
const siteURL = config.site;
|
|
358
365
|
const location = siteURL ? new URL(locationSite, siteURL) : locationSite;
|
|
359
366
|
const fromPath = new URL(request.url).pathname;
|
|
@@ -381,6 +388,9 @@ async function generatePath(pathname, pipeline, gopts, route, routeToHeaders) {
|
|
|
381
388
|
} else {
|
|
382
389
|
route.distURL = [outFile];
|
|
383
390
|
}
|
|
391
|
+
if (pipeline.settings.adapter?.adapterFeatures?.experimentalStaticHeaders && pipeline.settings.config.experimental?.csp) {
|
|
392
|
+
routeToHeaders.set(pathname, { headers: responseHeaders, route: integrationRoute });
|
|
393
|
+
}
|
|
384
394
|
await fs.promises.mkdir(outFolder, { recursive: true });
|
|
385
395
|
await fs.promises.writeFile(outFile, body);
|
|
386
396
|
return true;
|