astro 6.0.0-beta.16 → 6.0.0-beta.18
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/dist/actions/runtime/server.js +7 -7
- package/dist/actions/runtime/types.d.ts +1 -1
- package/dist/assets/utils/proxy.js +1 -1
- package/dist/assets/utils/svg.js +11 -1
- package/dist/assets/vite-plugin-assets.js +15 -1
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/config/entrypoint.d.ts +7 -0
- package/dist/config/entrypoint.js +8 -0
- package/dist/container/index.js +2 -0
- package/dist/content/content-layer.d.ts +5 -9
- package/dist/content/content-layer.js +22 -30
- package/dist/content/instance.d.ts +17 -0
- package/dist/content/instance.js +20 -0
- package/dist/content/runtime.js +7 -1
- package/dist/content/vite-plugin-content-assets.js +7 -4
- package/dist/core/app/base.d.ts +11 -7
- package/dist/core/app/base.js +118 -54
- package/dist/core/app/dev/app.d.ts +1 -1
- package/dist/core/app/dev/app.js +11 -6
- package/dist/core/app/node.js +2 -1
- package/dist/core/app/types.d.ts +13 -0
- package/dist/core/base-pipeline.d.ts +12 -1
- package/dist/core/base-pipeline.js +21 -3
- package/dist/core/build/common.js +2 -1
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +11 -1
- package/dist/core/build/static-build.js +2 -1
- package/dist/core/cache/config.d.ts +29 -0
- package/dist/core/cache/config.js +20 -0
- package/dist/core/cache/memory-provider.d.ts +56 -0
- package/dist/core/cache/memory-provider.js +305 -0
- package/dist/core/cache/runtime/cache.d.ts +36 -0
- package/dist/core/cache/runtime/cache.js +98 -0
- package/dist/core/cache/runtime/noop.d.ts +19 -0
- package/dist/core/cache/runtime/noop.js +33 -0
- package/dist/core/cache/runtime/route-matching.d.ts +20 -0
- package/dist/core/cache/runtime/route-matching.js +28 -0
- package/dist/core/cache/runtime/utils.d.ts +8 -0
- package/dist/core/cache/runtime/utils.js +34 -0
- package/dist/core/cache/types.d.ts +64 -0
- package/dist/core/cache/types.js +0 -0
- package/dist/core/cache/utils.d.ts +16 -0
- package/dist/core/cache/utils.js +47 -0
- package/dist/core/cache/vite-plugin.d.ts +6 -0
- package/dist/core/cache/vite-plugin.js +56 -0
- package/dist/core/config/schemas/base.d.ts +16 -0
- package/dist/core/config/schemas/base.js +6 -1
- package/dist/core/config/schemas/relative.d.ts +45 -4
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -0
- package/dist/core/dev/container.js +3 -3
- package/dist/core/dev/dev.js +3 -2
- package/dist/core/dev/restart.js +1 -1
- package/dist/core/errors/errors-data.d.ts +46 -3
- package/dist/core/errors/errors-data.js +26 -5
- package/dist/core/logger/core.d.ts +1 -1
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/index.js +2 -0
- package/dist/core/redirects/render.js +5 -2
- package/dist/core/render-context.d.ts +2 -0
- package/dist/core/render-context.js +36 -1
- package/dist/core/routing/generator.js +2 -1
- package/dist/core/server-islands/endpoint.d.ts +6 -0
- package/dist/core/server-islands/endpoint.js +1 -0
- package/dist/core/session/runtime.js +20 -1
- package/dist/core/sync/index.js +2 -1
- package/dist/i18n/fallback.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/integrations/adapter-utils.d.ts +19 -0
- package/dist/integrations/adapter-utils.js +12 -0
- package/dist/integrations/hooks.js +3 -2
- package/dist/manifest/serialized.js +13 -0
- package/dist/prerender/utils.js +5 -1
- package/dist/runtime/server/astro-global.js +3 -0
- package/dist/runtime/server/render/util.js +0 -12
- package/dist/types/public/config.d.ts +94 -14
- package/dist/types/public/context.d.ts +10 -0
- package/dist/types/public/index.d.ts +1 -0
- package/dist/types/public/integrations.d.ts +21 -3
- package/dist/vite-plugin-app/app.d.ts +1 -1
- package/dist/vite-plugin-app/app.js +11 -6
- package/dist/vite-plugin-astro-server/plugin.js +4 -0
- package/package.json +8 -7
- package/tsconfigs/base.json +3 -1
|
@@ -99,9 +99,10 @@ function getActionContext(context) {
|
|
|
99
99
|
}
|
|
100
100
|
throw error;
|
|
101
101
|
}
|
|
102
|
+
const bodySizeLimit = pipeline.manifest.actionBodySizeLimit;
|
|
102
103
|
let input;
|
|
103
104
|
try {
|
|
104
|
-
input = await parseRequestBody(context.request);
|
|
105
|
+
input = await parseRequestBody(context.request, bodySizeLimit);
|
|
105
106
|
} catch (e) {
|
|
106
107
|
if (e instanceof ActionError) {
|
|
107
108
|
return { data: void 0, error: e };
|
|
@@ -149,22 +150,21 @@ function getCallerInfo(ctx) {
|
|
|
149
150
|
}
|
|
150
151
|
return void 0;
|
|
151
152
|
}
|
|
152
|
-
|
|
153
|
-
async function parseRequestBody(request) {
|
|
153
|
+
async function parseRequestBody(request, bodySizeLimit) {
|
|
154
154
|
const contentType = request.headers.get("content-type");
|
|
155
155
|
const contentLengthHeader = request.headers.get("content-length");
|
|
156
156
|
const contentLength = contentLengthHeader ? Number.parseInt(contentLengthHeader, 10) : void 0;
|
|
157
157
|
const hasContentLength = typeof contentLength === "number" && Number.isFinite(contentLength);
|
|
158
158
|
if (!contentType) return void 0;
|
|
159
|
-
if (hasContentLength && contentLength >
|
|
159
|
+
if (hasContentLength && contentLength > bodySizeLimit) {
|
|
160
160
|
throw new ActionError({
|
|
161
161
|
code: "CONTENT_TOO_LARGE",
|
|
162
|
-
message: `Request body exceeds ${
|
|
162
|
+
message: `Request body exceeds ${bodySizeLimit} bytes`
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
if (hasContentType(contentType, formContentTypes)) {
|
|
166
166
|
if (!hasContentLength) {
|
|
167
|
-
const body = await readRequestBodyWithLimit(request.clone(),
|
|
167
|
+
const body = await readRequestBodyWithLimit(request.clone(), bodySizeLimit);
|
|
168
168
|
const formRequest = new Request(request.url, {
|
|
169
169
|
method: request.method,
|
|
170
170
|
headers: request.headers,
|
|
@@ -177,7 +177,7 @@ async function parseRequestBody(request) {
|
|
|
177
177
|
if (hasContentType(contentType, ["application/json"])) {
|
|
178
178
|
if (contentLength === 0) return void 0;
|
|
179
179
|
if (!hasContentLength) {
|
|
180
|
-
const body = await readRequestBodyWithLimit(request.clone(),
|
|
180
|
+
const body = await readRequestBodyWithLimit(request.clone(), bodySizeLimit);
|
|
181
181
|
if (body.byteLength === 0) return void 0;
|
|
182
182
|
return JSON.parse(new TextDecoder().decode(body));
|
|
183
183
|
}
|
|
@@ -49,7 +49,7 @@ export interface ActionsLocals {
|
|
|
49
49
|
actionName: string;
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
export type ActionAPIContext = Pick<APIContext, 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'csp'>;
|
|
52
|
+
export type ActionAPIContext = Pick<APIContext, 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'cache' | 'csp'>;
|
|
53
53
|
export type MaybePromise<T> = T | Promise<T>;
|
|
54
54
|
/**
|
|
55
55
|
* Used to preserve the input schema type in the error object.
|
|
@@ -9,7 +9,7 @@ function getProxyCode(options, isSSR) {
|
|
|
9
9
|
if (name === 'fsPath') {
|
|
10
10
|
return ${stringifiedFSPath};
|
|
11
11
|
}
|
|
12
|
-
${!isSSR ? `if (target[name] !== undefined && globalThis.astroAsset) globalThis.astroAsset?.referencedImages
|
|
12
|
+
${!isSSR ? `if (target[name] !== undefined && globalThis.astroAsset) globalThis.astroAsset?.referencedImages?.add(${stringifiedFSPath});` : ""}
|
|
13
13
|
return target[name];
|
|
14
14
|
}
|
|
15
15
|
})
|
package/dist/assets/utils/svg.js
CHANGED
|
@@ -49,6 +49,16 @@ function makeSvgComponent(meta, contents, svgoConfig) {
|
|
|
49
49
|
return `import { createSvgComponent } from 'astro/assets/runtime';
|
|
50
50
|
export default createSvgComponent(${JSON.stringify(props)})`;
|
|
51
51
|
}
|
|
52
|
+
function parseSvgComponentData(meta, contents, svgoConfig) {
|
|
53
|
+
const file = typeof contents === "string" ? contents : contents.toString("utf-8");
|
|
54
|
+
const { attributes, body: children } = parseSvg({
|
|
55
|
+
path: meta.fsPath,
|
|
56
|
+
contents: file,
|
|
57
|
+
svgoConfig
|
|
58
|
+
});
|
|
59
|
+
return { attributes: dropAttributes(attributes), children };
|
|
60
|
+
}
|
|
52
61
|
export {
|
|
53
|
-
makeSvgComponent
|
|
62
|
+
makeSvgComponent,
|
|
63
|
+
parseSvgComponentData
|
|
54
64
|
};
|
|
@@ -29,7 +29,7 @@ import { hashTransform, propsToFilename } from "./utils/hash.js";
|
|
|
29
29
|
import { emitImageMetadata } from "./utils/node.js";
|
|
30
30
|
import { CONTENT_IMAGE_FLAG } from "../content/consts.js";
|
|
31
31
|
import { getProxyCode } from "./utils/proxy.js";
|
|
32
|
-
import { makeSvgComponent } from "./utils/svg.js";
|
|
32
|
+
import { makeSvgComponent, parseSvgComponentData } from "./utils/svg.js";
|
|
33
33
|
import { createPlaceholderURL, stringifyPlaceholderURL } from "./utils/url.js";
|
|
34
34
|
const assetRegex = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})`, "i");
|
|
35
35
|
const assetRegexEnds = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})$`, "i");
|
|
@@ -252,6 +252,20 @@ function assets({ fs, settings, sync, logger }) {
|
|
|
252
252
|
if (isSSROnlyEnvironment) {
|
|
253
253
|
globalThis.astroAsset.referencedImages.add(imageMetadata.fsPath);
|
|
254
254
|
}
|
|
255
|
+
if (id.endsWith(".svg") && isContentImage) {
|
|
256
|
+
const contents = await fs.promises.readFile(imageMetadata.fsPath, {
|
|
257
|
+
encoding: "utf8"
|
|
258
|
+
});
|
|
259
|
+
const svgData = parseSvgComponentData(
|
|
260
|
+
imageMetadata,
|
|
261
|
+
contents,
|
|
262
|
+
settings.config.experimental.svgo
|
|
263
|
+
);
|
|
264
|
+
const metadataWithSvg = { ...imageMetadata, __svgData: svgData };
|
|
265
|
+
return {
|
|
266
|
+
code: `export default ${getProxyCode(metadataWithSvg, isSSROnlyEnvironment)}`
|
|
267
|
+
};
|
|
268
|
+
}
|
|
255
269
|
return {
|
|
256
270
|
code: `export default ${getProxyCode(imageMetadata, isSSROnlyEnvironment)}`
|
|
257
271
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { SharpImageServiceConfig } from '../assets/services/sharp.js';
|
|
2
|
+
import type { MemoryCacheProviderOptions } from '../core/cache/memory-provider.js';
|
|
3
|
+
import type { CacheProviderConfig } from '../core/cache/types.js';
|
|
2
4
|
import type { ImageServiceConfig } from '../types/public/index.js';
|
|
3
5
|
export { fontProviders } from '../assets/fonts/providers/index.js';
|
|
4
6
|
export { mergeConfig } from '../core/config/merge.js';
|
|
@@ -17,3 +19,8 @@ export declare function sharpImageService(config?: SharpImageServiceConfig): Ima
|
|
|
17
19
|
* See: https://docs.astro.build/en/guides/images/#configure-no-op-passthrough-service
|
|
18
20
|
*/
|
|
19
21
|
export declare function passthroughImageService(): ImageServiceConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Return the configuration needed to use the built-in in-memory LRU cache provider.
|
|
24
|
+
* This is a runtime-agnostic provider suitable for single-instance deployments.
|
|
25
|
+
*/
|
|
26
|
+
export declare function memoryCache(config?: MemoryCacheProviderOptions): CacheProviderConfig<MemoryCacheProviderOptions>;
|
|
@@ -16,11 +16,19 @@ function passthroughImageService() {
|
|
|
16
16
|
config: {}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
function memoryCache(config = {}) {
|
|
20
|
+
return {
|
|
21
|
+
name: "memory",
|
|
22
|
+
entrypoint: "astro/cache/memory",
|
|
23
|
+
config
|
|
24
|
+
};
|
|
25
|
+
}
|
|
19
26
|
export {
|
|
20
27
|
defineConfig,
|
|
21
28
|
envField,
|
|
22
29
|
fontProviders,
|
|
23
30
|
getViteConfig,
|
|
31
|
+
memoryCache,
|
|
24
32
|
mergeConfig,
|
|
25
33
|
passthroughImageService,
|
|
26
34
|
sessionDrivers,
|
package/dist/container/index.js
CHANGED
|
@@ -33,6 +33,7 @@ function createManifest(manifest, renderers, middleware) {
|
|
|
33
33
|
compressHTML: manifest?.compressHTML ?? ASTRO_CONFIG_DEFAULTS.compressHTML,
|
|
34
34
|
assetsDir: manifest?.assetsDir ?? ASTRO_CONFIG_DEFAULTS.build.assets,
|
|
35
35
|
serverLike: manifest?.serverLike ?? true,
|
|
36
|
+
middlewareMode: manifest?.middlewareMode ?? "classic",
|
|
36
37
|
assets: manifest?.assets ?? /* @__PURE__ */ new Set(),
|
|
37
38
|
assetsPrefix: manifest?.assetsPrefix ?? void 0,
|
|
38
39
|
entryModules: manifest?.entryModules ?? {},
|
|
@@ -47,6 +48,7 @@ function createManifest(manifest, renderers, middleware) {
|
|
|
47
48
|
i18n: manifest?.i18n,
|
|
48
49
|
checkOrigin: false,
|
|
49
50
|
allowedDomains: manifest?.allowedDomains ?? [],
|
|
51
|
+
actionBodySizeLimit: 1024 * 1024,
|
|
50
52
|
middleware: manifest?.middleware ?? middlewareInstance,
|
|
51
53
|
key: createKey(),
|
|
52
54
|
csp: manifest?.csp,
|
|
@@ -3,15 +3,17 @@ import type { Logger } from '../core/logger/core.js';
|
|
|
3
3
|
import type { AstroSettings } from '../types/astro.js';
|
|
4
4
|
import type { RefreshContentOptions } from '../types/public/content.js';
|
|
5
5
|
import type { MutableDataStore } from './mutable-data-store.js';
|
|
6
|
-
|
|
6
|
+
import { type ContentObservable } from './utils.js';
|
|
7
|
+
export interface ContentLayerOptions {
|
|
7
8
|
store: MutableDataStore;
|
|
8
9
|
settings: AstroSettings;
|
|
9
10
|
logger: Logger;
|
|
10
11
|
watcher?: FSWatcher;
|
|
12
|
+
contentConfigObserver?: ContentObservable;
|
|
11
13
|
}
|
|
12
|
-
declare class ContentLayer {
|
|
14
|
+
export declare class ContentLayer {
|
|
13
15
|
#private;
|
|
14
|
-
constructor({ settings, logger, store, watcher }: ContentLayerOptions);
|
|
16
|
+
constructor({ settings, logger, store, watcher, contentConfigObserver, }: ContentLayerOptions);
|
|
15
17
|
/**
|
|
16
18
|
* Whether the content layer is currently loading content
|
|
17
19
|
*/
|
|
@@ -37,9 +39,3 @@ declare class ContentLayer {
|
|
|
37
39
|
* In production, it's in the cache directory so that it's preserved between builds.
|
|
38
40
|
*/
|
|
39
41
|
export declare function getDataStoreFile(settings: AstroSettings, isDev: boolean): URL;
|
|
40
|
-
export declare const globalContentLayer: {
|
|
41
|
-
init: (options: ContentLayerOptions) => ContentLayer;
|
|
42
|
-
get: () => ContentLayer | null;
|
|
43
|
-
dispose: () => void;
|
|
44
|
-
};
|
|
45
|
-
export {};
|
|
@@ -30,12 +30,20 @@ class ContentLayer {
|
|
|
30
30
|
#unsubscribe;
|
|
31
31
|
#markdownProcessor;
|
|
32
32
|
#generateDigest;
|
|
33
|
+
#contentConfigObserver;
|
|
33
34
|
#queue;
|
|
34
|
-
constructor({
|
|
35
|
+
constructor({
|
|
36
|
+
settings,
|
|
37
|
+
logger,
|
|
38
|
+
store,
|
|
39
|
+
watcher,
|
|
40
|
+
contentConfigObserver = globalContentConfigObserver
|
|
41
|
+
}) {
|
|
35
42
|
watcher?.setMaxListeners(50);
|
|
36
43
|
this.#logger = logger;
|
|
37
44
|
this.#store = store;
|
|
38
45
|
this.#settings = settings;
|
|
46
|
+
this.#contentConfigObserver = contentConfigObserver;
|
|
39
47
|
if (watcher) {
|
|
40
48
|
this.#watcher = createWatcherWrapper(watcher);
|
|
41
49
|
}
|
|
@@ -52,7 +60,7 @@ class ContentLayer {
|
|
|
52
60
|
*/
|
|
53
61
|
watchContentConfig() {
|
|
54
62
|
this.#unsubscribe?.();
|
|
55
|
-
this.#unsubscribe =
|
|
63
|
+
this.#unsubscribe = this.#contentConfigObserver.subscribe(async (ctx) => {
|
|
56
64
|
if (ctx.status === "loaded" && ctx.config.digest !== this.#lastConfigDigest) {
|
|
57
65
|
this.sync();
|
|
58
66
|
}
|
|
@@ -122,12 +130,12 @@ class ContentLayer {
|
|
|
122
130
|
return this.#queue.add(() => this.#doSync(options));
|
|
123
131
|
}
|
|
124
132
|
async #doSync(options) {
|
|
125
|
-
let contentConfig =
|
|
133
|
+
let contentConfig = this.#contentConfigObserver.get();
|
|
126
134
|
const logger = this.#logger.forkIntegrationLogger("content");
|
|
127
135
|
if (contentConfig?.status === "loading") {
|
|
128
136
|
contentConfig = await Promise.race([
|
|
129
137
|
new Promise((resolve) => {
|
|
130
|
-
const unsub =
|
|
138
|
+
const unsub = this.#contentConfigObserver.subscribe((ctx) => {
|
|
131
139
|
unsub();
|
|
132
140
|
resolve(ctx);
|
|
133
141
|
});
|
|
@@ -170,9 +178,9 @@ ${contentConfig.error.message}`
|
|
|
170
178
|
const { digest: currentConfigDigest } = contentConfig.config;
|
|
171
179
|
this.#lastConfigDigest = currentConfigDigest;
|
|
172
180
|
let shouldClear = false;
|
|
173
|
-
const previousConfigDigest =
|
|
174
|
-
const previousAstroConfigDigest =
|
|
175
|
-
const previousAstroVersion =
|
|
181
|
+
const previousConfigDigest = this.#store.metaStore().get("content-config-digest");
|
|
182
|
+
const previousAstroConfigDigest = this.#store.metaStore().get("astro-config-digest");
|
|
183
|
+
const previousAstroVersion = this.#store.metaStore().get("astro-version");
|
|
176
184
|
if (previousAstroConfigDigest && previousAstroConfigDigest !== astroConfigDigest) {
|
|
177
185
|
logger.info("Astro config changed");
|
|
178
186
|
shouldClear = true;
|
|
@@ -181,7 +189,7 @@ ${contentConfig.error.message}`
|
|
|
181
189
|
logger.info("Content config changed");
|
|
182
190
|
shouldClear = true;
|
|
183
191
|
}
|
|
184
|
-
if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.
|
|
192
|
+
if (previousAstroVersion && previousAstroVersion !== "6.0.0-beta.18") {
|
|
185
193
|
logger.info("Astro version changed");
|
|
186
194
|
shouldClear = true;
|
|
187
195
|
}
|
|
@@ -189,14 +197,14 @@ ${contentConfig.error.message}`
|
|
|
189
197
|
logger.info("Clearing content store");
|
|
190
198
|
this.#store.clearAll();
|
|
191
199
|
}
|
|
192
|
-
if ("6.0.0-beta.
|
|
193
|
-
|
|
200
|
+
if ("6.0.0-beta.18") {
|
|
201
|
+
this.#store.metaStore().set("astro-version", "6.0.0-beta.18");
|
|
194
202
|
}
|
|
195
203
|
if (currentConfigDigest) {
|
|
196
|
-
|
|
204
|
+
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
197
205
|
}
|
|
198
206
|
if (astroConfigDigest) {
|
|
199
|
-
|
|
207
|
+
this.#store.metaStore().set("astro-config-digest", astroConfigDigest);
|
|
200
208
|
}
|
|
201
209
|
if (!options?.loaders?.length) {
|
|
202
210
|
this.#watcher?.removeAllTrackedListeners();
|
|
@@ -354,23 +362,7 @@ ${JSON.stringify({ ...raw, id: void 0 }, null, 2)}`
|
|
|
354
362
|
function getDataStoreFile(settings, isDev) {
|
|
355
363
|
return new URL(DATA_STORE_FILE, isDev ? settings.dotAstroDir : settings.config.cacheDir);
|
|
356
364
|
}
|
|
357
|
-
function contentLayerSingleton() {
|
|
358
|
-
let instance = null;
|
|
359
|
-
return {
|
|
360
|
-
init: (options) => {
|
|
361
|
-
instance?.dispose();
|
|
362
|
-
instance = new ContentLayer(options);
|
|
363
|
-
return instance;
|
|
364
|
-
},
|
|
365
|
-
get: () => instance,
|
|
366
|
-
dispose: () => {
|
|
367
|
-
instance?.dispose();
|
|
368
|
-
instance = null;
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
const globalContentLayer = contentLayerSingleton();
|
|
373
365
|
export {
|
|
374
|
-
|
|
375
|
-
|
|
366
|
+
ContentLayer,
|
|
367
|
+
getDataStoreFile
|
|
376
368
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FSWatcher } from 'vite';
|
|
2
|
+
import { ContentLayer } from './content-layer.js';
|
|
3
|
+
import type { Logger } from '../core/logger/core.js';
|
|
4
|
+
import type { AstroSettings } from '../types/astro.js';
|
|
5
|
+
import type { MutableDataStore } from './mutable-data-store.js';
|
|
6
|
+
interface ContentLayerOptions {
|
|
7
|
+
store: MutableDataStore;
|
|
8
|
+
settings: AstroSettings;
|
|
9
|
+
logger: Logger;
|
|
10
|
+
watcher?: FSWatcher;
|
|
11
|
+
}
|
|
12
|
+
export declare const globalContentLayer: {
|
|
13
|
+
init: (options: ContentLayerOptions) => ContentLayer;
|
|
14
|
+
get: () => ContentLayer | null;
|
|
15
|
+
dispose: () => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContentLayer } from "./content-layer.js";
|
|
2
|
+
function contentLayerSingleton() {
|
|
3
|
+
let instance = null;
|
|
4
|
+
return {
|
|
5
|
+
init: (options) => {
|
|
6
|
+
instance?.dispose();
|
|
7
|
+
instance = new ContentLayer(options);
|
|
8
|
+
return instance;
|
|
9
|
+
},
|
|
10
|
+
get: () => instance,
|
|
11
|
+
dispose: () => {
|
|
12
|
+
instance?.dispose();
|
|
13
|
+
instance = null;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const globalContentLayer = contentLayerSingleton();
|
|
18
|
+
export {
|
|
19
|
+
globalContentLayer
|
|
20
|
+
};
|
package/dist/content/runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { escape } from "html-escaper";
|
|
2
2
|
import { Traverse } from "neotraverse/modern";
|
|
3
3
|
import * as z from "zod/v4";
|
|
4
|
+
import { createSvgComponent } from "../assets/runtime.js";
|
|
4
5
|
import { imageSrcToImportId } from "../assets/utils/resolveImports.js";
|
|
5
6
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
6
7
|
import { isRemotePath, prependForwardSlash } from "../core/path.js";
|
|
@@ -363,7 +364,12 @@ function updateImageReferencesInData(data, fileName, imageAssetMap) {
|
|
|
363
364
|
}
|
|
364
365
|
const imported = imageAssetMap?.get(id);
|
|
365
366
|
if (imported) {
|
|
366
|
-
|
|
367
|
+
if (imported.__svgData) {
|
|
368
|
+
const { __svgData: svgData, ...meta } = imported;
|
|
369
|
+
ctx.update(createSvgComponent({ meta, ...svgData }));
|
|
370
|
+
} else {
|
|
371
|
+
ctx.update(imported);
|
|
372
|
+
}
|
|
367
373
|
} else {
|
|
368
374
|
ctx.update(src);
|
|
369
375
|
}
|
|
@@ -60,10 +60,12 @@ function astroContentAssetPropagationPlugin({
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
configureServer(server) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const ssrEnv = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
|
|
64
|
+
if (isRunnableDevEnvironment(ssrEnv)) {
|
|
65
|
+
environment = ssrEnv;
|
|
66
|
+
} else if (isRunnableDevEnvironment(server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.astro])) {
|
|
67
|
+
environment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.astro];
|
|
65
68
|
}
|
|
66
|
-
environment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
|
|
67
69
|
},
|
|
68
70
|
transform: {
|
|
69
71
|
filter: {
|
|
@@ -75,7 +77,8 @@ function astroContentAssetPropagationPlugin({
|
|
|
75
77
|
let stringifiedLinks, stringifiedStyles;
|
|
76
78
|
if (isAstroServerEnvironment(this.environment) && environment) {
|
|
77
79
|
if (!environment.moduleGraph.getModuleById(basePath)?.ssrModule) {
|
|
78
|
-
await environment.runner.import(basePath)
|
|
80
|
+
await environment.runner.import(basePath).catch(() => {
|
|
81
|
+
});
|
|
79
82
|
}
|
|
80
83
|
const {
|
|
81
84
|
styles,
|
package/dist/core/app/base.d.ts
CHANGED
|
@@ -51,9 +51,15 @@ export interface RenderOptions {
|
|
|
51
51
|
*/
|
|
52
52
|
routeData?: RouteData;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
type RequiredRenderOptions = Required<RenderOptions>;
|
|
55
|
+
interface ResolvedRenderOptions {
|
|
56
|
+
addCookieHeader: RequiredRenderOptions['addCookieHeader'];
|
|
57
|
+
clientAddress: RequiredRenderOptions['clientAddress'] | undefined;
|
|
58
|
+
prerenderedErrorPageFetch: RequiredRenderOptions['prerenderedErrorPageFetch'] | undefined;
|
|
59
|
+
locals: RequiredRenderOptions['locals'] | undefined;
|
|
60
|
+
routeData: RequiredRenderOptions['routeData'] | undefined;
|
|
61
|
+
}
|
|
62
|
+
export interface RenderErrorOptions extends ResolvedRenderOptions {
|
|
57
63
|
response?: Response;
|
|
58
64
|
status: 404 | 500;
|
|
59
65
|
/**
|
|
@@ -64,8 +70,6 @@ export interface RenderErrorOptions {
|
|
|
64
70
|
* Allows passing an error to 500.astro. It will be available through `Astro.props.error`.
|
|
65
71
|
*/
|
|
66
72
|
error?: unknown;
|
|
67
|
-
clientAddress: string | undefined;
|
|
68
|
-
prerenderedErrorPageFetch: ((url: ErrorPagePath) => Promise<Response>) | undefined;
|
|
69
73
|
}
|
|
70
74
|
type ErrorPagePath = `${string}/404` | `${string}/500` | `${string}/404/` | `${string}/500/` | `${string}404.html` | `${string}500.html`;
|
|
71
75
|
export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
@@ -120,7 +124,7 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
120
124
|
devMatch(pathname?: string): Promise<DevMatch | undefined> | undefined;
|
|
121
125
|
private computePathnameFromDomain;
|
|
122
126
|
private redirectTrailingSlash;
|
|
123
|
-
render(request: Request,
|
|
127
|
+
render(request: Request, { addCookieHeader, clientAddress, locals, prerenderedErrorPageFetch, routeData, }?: RenderOptions): Promise<Response>;
|
|
124
128
|
setCookieHeaders(response: Response): Generator<string, string[], any>;
|
|
125
129
|
/**
|
|
126
130
|
* Reads all the cookies written by `Astro.cookie.set()` onto the passed response.
|
|
@@ -138,7 +142,7 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
138
142
|
* If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
|
|
139
143
|
* This also handles pre-rendered /404 or /500 routes
|
|
140
144
|
*/
|
|
141
|
-
renderError(request: Request, {
|
|
145
|
+
renderError(request: Request, { status, response: originalResponse, skipMiddleware, error, ...resolvedRenderOptions }: RenderErrorOptions): Promise<Response>;
|
|
142
146
|
private mergeResponses;
|
|
143
147
|
getDefaultStatusCode(routeData: RouteData, pathname: string): number;
|
|
144
148
|
getManifest(): SSRManifest;
|