astro 7.0.0-alpha.2 → 7.0.0-beta.4
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/assets/build/generate.js +4 -3
- package/dist/assets/fonts/core/collect-font-data.js +1 -0
- package/dist/assets/fonts/types.d.ts +1 -0
- package/dist/cli/add/index.js +1 -44
- package/dist/cli/dev/background.js +1 -1
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/flags.js +4 -6
- package/dist/cli/help/index.js +1 -2
- package/dist/cli/index.js +1 -15
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/index.d.ts +3 -3
- package/dist/container/index.js +1 -4
- package/dist/content/content-layer.js +3 -3
- package/dist/content/runtime.d.ts +1 -1
- package/dist/content/runtime.js +1 -0
- package/dist/content/vite-plugin-content-virtual-mod.js +27 -0
- package/dist/core/app/base.d.ts +1 -1
- package/dist/core/app/base.js +14 -24
- package/dist/core/app/dev/pipeline.js +0 -9
- package/dist/core/app/manifest.d.ts +0 -2
- package/dist/core/app/manifest.js +0 -8
- package/dist/core/app/types.d.ts +1 -8
- package/dist/core/base-pipeline.d.ts +3 -9
- package/dist/core/base-pipeline.js +4 -23
- package/dist/core/build/app.d.ts +0 -2
- package/dist/core/build/app.js +0 -5
- package/dist/core/build/generate.js +0 -14
- package/dist/core/build/pipeline.js +0 -9
- package/dist/core/build/plugins/plugin-css.js +1 -0
- package/dist/core/build/plugins/plugin-manifest.js +4 -9
- package/dist/core/config/config.js +3 -2
- package/dist/core/config/schemas/base.d.ts +9 -22
- package/dist/core/config/schemas/base.js +11 -27
- package/dist/core/config/schemas/relative.d.ts +15 -36
- package/dist/core/config/validate.js +10 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/default-handler.js +21 -8
- package/dist/core/fetch/fetch-state.js +3 -16
- package/dist/core/fetch/types.d.ts +1 -1
- package/dist/core/fetch/vite-plugin.js +4 -6
- package/dist/core/hono/index.d.ts +1 -0
- package/dist/core/hono/index.js +1 -0
- package/dist/core/logger/impls/node.js +0 -1
- package/dist/core/logger/load.js +3 -2
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/index.js +8 -1
- package/dist/core/middleware/vite-plugin.d.ts +1 -0
- package/dist/core/middleware/vite-plugin.js +5 -1
- package/dist/core/util/normalized-url.js +2 -5
- package/dist/core/util/pathname.d.ts +13 -7
- package/dist/core/util/pathname.js +9 -6
- package/dist/i18n/index.js +6 -2
- package/dist/manifest/serialized.js +4 -5
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +4 -0
- package/dist/runtime/server/jsx.js +2 -1
- package/dist/runtime/server/render/astro/render-template.d.ts +1 -1
- package/dist/runtime/server/render/astro/render.d.ts +0 -4
- package/dist/runtime/server/render/astro/render.js +76 -68
- package/dist/runtime/server/render/head.js +2 -1
- package/dist/runtime/server/render/index.d.ts +1 -0
- package/dist/runtime/server/render/index.js +2 -0
- package/dist/runtime/server/render/page.js +9 -44
- package/dist/runtime/server/render/streaming.d.ts +23 -0
- package/dist/runtime/server/render/streaming.js +238 -0
- package/dist/runtime/server/render/util.js +5 -1
- package/dist/types/public/config.d.ts +115 -123
- package/dist/types/public/context.d.ts +1 -1
- package/dist/types/public/internal.d.ts +0 -15
- package/dist/vite-plugin-app/app.js +1 -1
- package/dist/vite-plugin-app/pipeline.js +0 -9
- package/dist/vite-plugin-hmr-reload/index.js +19 -6
- package/dist/vite-plugin-html/transform/slots.js +4 -1
- package/dist/vite-plugin-pages/pages.d.ts +11 -0
- package/dist/vite-plugin-pages/pages.js +1 -3
- package/package.json +13 -7
- package/dist/cli/db/index.d.ts +0 -4
- package/dist/cli/db/index.js +0 -25
- package/dist/jsx/rehype.d.ts +0 -5
- package/dist/jsx/rehype.js +0 -241
- package/dist/runtime/server/html-string-cache.d.ts +0 -48
- package/dist/runtime/server/html-string-cache.js +0 -119
- package/dist/runtime/server/render/queue/builder.d.ts +0 -14
- package/dist/runtime/server/render/queue/builder.js +0 -182
- package/dist/runtime/server/render/queue/jsx-builder.d.ts +0 -33
- package/dist/runtime/server/render/queue/jsx-builder.js +0 -146
- package/dist/runtime/server/render/queue/pool.d.ts +0 -123
- package/dist/runtime/server/render/queue/pool.js +0 -203
- package/dist/runtime/server/render/queue/renderer.d.ts +0 -12
- package/dist/runtime/server/render/queue/renderer.js +0 -103
- package/dist/runtime/server/render/queue/types.d.ts +0 -81
- package/dist/runtime/server/render/queue/types.js +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs, { readFileSync } from "node:fs";
|
|
2
2
|
import { basename } from "node:path/posix";
|
|
3
3
|
import colors from "piccolore";
|
|
4
|
-
import { getOutDirWithinCwd } from "../../core/build/common.js";
|
|
5
4
|
import { getTimeStat } from "../../core/build/util.js";
|
|
6
5
|
import { AstroError } from "../../core/errors/errors.js";
|
|
7
6
|
import { AstroErrorData } from "../../core/errors/index.js";
|
|
8
7
|
import { isRemotePath, removeLeadingForwardSlash } from "../../core/path.js";
|
|
8
|
+
import { getClientOutputDirectory } from "../../prerender/utils.js";
|
|
9
9
|
import { getConfiguredImageService } from "../internal.js";
|
|
10
10
|
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
11
11
|
import { loadRemoteImage, revalidateRemoteImage } from "./remote.js";
|
|
@@ -29,8 +29,9 @@ async function prepareAssetsGenerationEnv(options, totalCount) {
|
|
|
29
29
|
serverRoot = new URL(".prerender/", settings.config.build.server);
|
|
30
30
|
clientRoot = settings.config.build.client;
|
|
31
31
|
} else {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const clientOutputDir = getClientOutputDirectory(settings);
|
|
33
|
+
serverRoot = clientOutputDir;
|
|
34
|
+
clientRoot = clientOutputDir;
|
|
34
35
|
}
|
|
35
36
|
return {
|
|
36
37
|
logger,
|
package/dist/cli/add/index.js
CHANGED
|
@@ -46,22 +46,9 @@ export default {
|
|
|
46
46
|
`,
|
|
47
47
|
LIT_NPMRC: `# Lit libraries are required to be hoisted due to dependency issues.
|
|
48
48
|
public-hoist-pattern[]=*lit*
|
|
49
|
-
`,
|
|
50
|
-
DB_CONFIG: `import { defineDb } from 'astro:db';
|
|
51
|
-
|
|
52
|
-
// https://astro.build/db/config
|
|
53
|
-
export default defineDb({
|
|
54
|
-
tables: {}
|
|
55
|
-
});
|
|
56
|
-
`,
|
|
57
|
-
DB_SEED: `import { db } from 'astro:db';
|
|
58
|
-
|
|
59
|
-
// https://astro.build/db/seed
|
|
60
|
-
export default async function seed() {
|
|
61
|
-
// TODO
|
|
62
|
-
}
|
|
63
49
|
`,
|
|
64
50
|
CLOUDFLARE_WRANGLER_CONFIG: (name, compatibilityDate) => `{
|
|
51
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
65
52
|
"compatibility_date": ${JSON.stringify(compatibilityDate)},
|
|
66
53
|
"compatibility_flags": ["global_fetch_strictly_public"],
|
|
67
54
|
"name": ${JSON.stringify(name)},
|
|
@@ -113,7 +100,6 @@ async function add(names, { flags }) {
|
|
|
113
100
|
["node", "astro add node"]
|
|
114
101
|
],
|
|
115
102
|
Others: [
|
|
116
|
-
["db", "astro add db"],
|
|
117
103
|
["tailwind", "astro add tailwind"],
|
|
118
104
|
["mdx", "astro add mdx"],
|
|
119
105
|
["markdoc", "astro add markdoc"],
|
|
@@ -235,35 +221,6 @@ async function add(names, { flags }) {
|
|
|
235
221
|
defaultConfigContent: STUBS.SVELTE_CONFIG
|
|
236
222
|
});
|
|
237
223
|
}
|
|
238
|
-
if (integrations.find((integration) => integration.id === "db")) {
|
|
239
|
-
if (!existsSync(new URL("./db/", root))) {
|
|
240
|
-
logger.info(
|
|
241
|
-
"SKIP_FORMAT",
|
|
242
|
-
`
|
|
243
|
-
${magenta(
|
|
244
|
-
`Astro will scaffold ${green("./db/config.ts")}${magenta(" and ")}${green(
|
|
245
|
-
"./db/seed.ts"
|
|
246
|
-
)}${magenta(" files.")}`
|
|
247
|
-
)}
|
|
248
|
-
`
|
|
249
|
-
);
|
|
250
|
-
if (await askToContinue({ flags, logger })) {
|
|
251
|
-
await fs.mkdir(new URL("./db", root));
|
|
252
|
-
await Promise.all([
|
|
253
|
-
fs.writeFile(new URL("./db/config.ts", root), STUBS.DB_CONFIG, { encoding: "utf-8" }),
|
|
254
|
-
fs.writeFile(new URL("./db/seed.ts", root), STUBS.DB_SEED, { encoding: "utf-8" })
|
|
255
|
-
]);
|
|
256
|
-
} else {
|
|
257
|
-
logger.info(
|
|
258
|
-
"SKIP_FORMAT",
|
|
259
|
-
`
|
|
260
|
-
Astro DB requires additional configuration. Please refer to https://astro.build/db/config`
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
logger.debug("add", `Using existing db configuration`);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
224
|
if (integrations.find((integration) => integration.id === "lit") && (await detect({ cwd: fileURLToPath(root) }))?.name === "pnpm") {
|
|
268
225
|
await setupIntegrationConfig({
|
|
269
226
|
root,
|
|
@@ -60,7 +60,7 @@ async function background({
|
|
|
60
60
|
if (flags.config) args.push("--config", String(flags.config));
|
|
61
61
|
if (flags.root) args.push("--root", String(flags.root));
|
|
62
62
|
if (flags.allowedHosts) args.push("--allowed-hosts", String(flags.allowedHosts));
|
|
63
|
-
if (flags.
|
|
63
|
+
if (flags.json) args.push("--json");
|
|
64
64
|
const logFileURL = getLogFileURL(root);
|
|
65
65
|
const logFilePath = fileURLToPath(logFileURL);
|
|
66
66
|
const dotAstroDir = fileURLToPath(new URL(".astro/", root));
|
package/dist/cli/dev/index.js
CHANGED
|
@@ -47,7 +47,7 @@ async function dev({ flags }) {
|
|
|
47
47
|
}
|
|
48
48
|
const agentDetected = !process.env.ASTRO_DEV_BACKGROUND && isRunByAgent();
|
|
49
49
|
if (agentDetected) {
|
|
50
|
-
flags.
|
|
50
|
+
flags.json = true;
|
|
51
51
|
}
|
|
52
52
|
const logger = createLoggerFromFlags(flags);
|
|
53
53
|
const subcommand = flags._[3]?.toString();
|
package/dist/cli/flags.js
CHANGED
|
@@ -19,11 +19,9 @@ function flagsToAstroInlineConfig(flags) {
|
|
|
19
19
|
allowedHosts: typeof flags.allowedHosts === "string" ? flags.allowedHosts.split(",") : typeof flags.allowedHosts === "boolean" && flags.allowedHosts === true ? flags.allowedHosts : []
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
if (flags.
|
|
23
|
-
inlineConfig.
|
|
24
|
-
|
|
25
|
-
entrypoint: "astro/logger/json"
|
|
26
|
-
}
|
|
22
|
+
if (flags.json) {
|
|
23
|
+
inlineConfig.logger = {
|
|
24
|
+
entrypoint: "astro/logger/json"
|
|
27
25
|
};
|
|
28
26
|
}
|
|
29
27
|
return inlineConfig;
|
|
@@ -35,7 +33,7 @@ function createLoggerFromFlags(flags) {
|
|
|
35
33
|
} else if (flags.silent) {
|
|
36
34
|
logLevel = "silent";
|
|
37
35
|
}
|
|
38
|
-
if (flags.
|
|
36
|
+
if (flags.json) {
|
|
39
37
|
return createJsonLoggerFromFlags({ logLevel });
|
|
40
38
|
} else {
|
|
41
39
|
return createNodeLoggerFromFlags({ logLevel });
|
package/dist/cli/help/index.js
CHANGED
|
@@ -8,7 +8,6 @@ const DEFAULT_HELP_PAYLOAD = {
|
|
|
8
8
|
["build", "Build your project and write it to disk."],
|
|
9
9
|
["check", "Check your project for errors."],
|
|
10
10
|
["create-key", "Create a cryptography key"],
|
|
11
|
-
["db", "Manage your Astro database."],
|
|
12
11
|
["dev", "Start the development server."],
|
|
13
12
|
["docs", "Open documentation in your web browser."],
|
|
14
13
|
["info", "List info about your current Astro setup."],
|
|
@@ -26,7 +25,7 @@ const DEFAULT_HELP_PAYLOAD = {
|
|
|
26
25
|
["--silent", "Disable all logging."],
|
|
27
26
|
["--version", "Show the version number and exit."],
|
|
28
27
|
["--help", "Show this help message."],
|
|
29
|
-
["--
|
|
28
|
+
["--json", "Enables JSON logging."]
|
|
30
29
|
]
|
|
31
30
|
}
|
|
32
31
|
};
|
package/dist/cli/index.js
CHANGED
|
@@ -13,12 +13,7 @@ function resolveCommand(flags) {
|
|
|
13
13
|
"check",
|
|
14
14
|
"create-key",
|
|
15
15
|
"docs",
|
|
16
|
-
"
|
|
17
|
-
"info",
|
|
18
|
-
"login",
|
|
19
|
-
"logout",
|
|
20
|
-
"link",
|
|
21
|
-
"init"
|
|
16
|
+
"info"
|
|
22
17
|
]);
|
|
23
18
|
if (supportedCommands.has(cmd)) {
|
|
24
19
|
return cmd;
|
|
@@ -183,15 +178,6 @@ async function runCommand(cmd, flags) {
|
|
|
183
178
|
await add(packages, { flags });
|
|
184
179
|
return;
|
|
185
180
|
}
|
|
186
|
-
case "db":
|
|
187
|
-
case "login":
|
|
188
|
-
case "logout":
|
|
189
|
-
case "link":
|
|
190
|
-
case "init": {
|
|
191
|
-
const { db } = await import("./db/index.js");
|
|
192
|
-
await db({ flags });
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
181
|
case "dev": {
|
|
196
182
|
const { dev } = await import("./dev/index.js");
|
|
197
183
|
const server = await dev({ flags });
|
|
@@ -67,7 +67,7 @@ export type ContainerRenderOptions = {
|
|
|
67
67
|
*/
|
|
68
68
|
routeType?: RouteType;
|
|
69
69
|
/**
|
|
70
|
-
* Allows
|
|
70
|
+
* Allows passing `Astro.props` to an Astro component:
|
|
71
71
|
*
|
|
72
72
|
* ```js
|
|
73
73
|
* container.renderToString(Endpoint, { props: { "lorem": "ipsum" } });
|
|
@@ -75,9 +75,9 @@ export type ContainerRenderOptions = {
|
|
|
75
75
|
*/
|
|
76
76
|
props?: Props;
|
|
77
77
|
/**
|
|
78
|
-
* When `false`, it forces to render
|
|
78
|
+
* When `false`, it forces the component to render as if it were a full-fledged page.
|
|
79
79
|
*
|
|
80
|
-
* By default, the container API
|
|
80
|
+
* By default, the container API renders components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials).
|
|
81
81
|
*
|
|
82
82
|
*/
|
|
83
83
|
partial?: boolean;
|
package/dist/container/index.js
CHANGED
|
@@ -63,10 +63,7 @@ function createManifest(manifest, renderers, middleware) {
|
|
|
63
63
|
placement: void 0
|
|
64
64
|
},
|
|
65
65
|
logLevel: "silent",
|
|
66
|
-
|
|
67
|
-
enabled: false
|
|
68
|
-
},
|
|
69
|
-
experimentalLogger: manifest?.experimentalLogger ?? void 0
|
|
66
|
+
loggerConfig: manifest?.loggerConfig ?? void 0
|
|
70
67
|
};
|
|
71
68
|
}
|
|
72
69
|
class experimental_AstroContainer {
|
|
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
|
|
|
197
197
|
logger.info("Content config changed");
|
|
198
198
|
shouldClear = true;
|
|
199
199
|
}
|
|
200
|
-
if (previousAstroVersion && previousAstroVersion !== "7.0.0-
|
|
200
|
+
if (previousAstroVersion && previousAstroVersion !== "7.0.0-beta.4") {
|
|
201
201
|
logger.info("Astro version changed");
|
|
202
202
|
shouldClear = true;
|
|
203
203
|
}
|
|
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
|
|
|
205
205
|
logger.info("Clearing content store");
|
|
206
206
|
this.#store.clearAll();
|
|
207
207
|
}
|
|
208
|
-
if ("7.0.0-
|
|
209
|
-
this.#store.metaStore().set("astro-version", "7.0.0-
|
|
208
|
+
if ("7.0.0-beta.4") {
|
|
209
|
+
this.#store.metaStore().set("astro-version", "7.0.0-beta.4");
|
|
210
210
|
}
|
|
211
211
|
if (currentConfigDigest) {
|
|
212
212
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -70,7 +70,7 @@ type RenderResult = {
|
|
|
70
70
|
};
|
|
71
71
|
export declare function updateImageReferencesInData<T extends Record<string, unknown>>(data: T, fileName?: string, imageAssetMap?: Map<string, ImageMetadata>): T;
|
|
72
72
|
export declare function renderEntry(entry: DataEntry): Promise<RenderResult>;
|
|
73
|
-
export declare function createReference(): (collection: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
73
|
+
export declare function createReference(): (collection: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>, z.ZodString, z.ZodObject<{
|
|
74
74
|
id: z.ZodString;
|
|
75
75
|
collection: z.ZodString;
|
|
76
76
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/content/runtime.js
CHANGED
|
@@ -23,6 +23,25 @@ import {
|
|
|
23
23
|
} from "./consts.js";
|
|
24
24
|
import { getDataStoreFile } from "./content-layer.js";
|
|
25
25
|
import { getContentPaths, isDeferredModule } from "./utils.js";
|
|
26
|
+
function invalidateAssetImports(viteServer, filePath) {
|
|
27
|
+
const timestamp = Date.now();
|
|
28
|
+
for (const environment of Object.values(viteServer.environments)) {
|
|
29
|
+
const modules = environment.moduleGraph.getModulesByFile(filePath);
|
|
30
|
+
if (modules) {
|
|
31
|
+
for (const module of modules) {
|
|
32
|
+
environment.moduleGraph.invalidateModule(module, void 0, timestamp, true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (isRunnableDevEnvironment(environment)) {
|
|
36
|
+
const runnerModules = environment.runner.evaluatedModules.getModulesByFile(filePath);
|
|
37
|
+
if (runnerModules) {
|
|
38
|
+
for (const runnerModule of runnerModules) {
|
|
39
|
+
environment.runner.evaluatedModules.invalidateModule(runnerModule);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
26
45
|
function invalidateDataStore(viteServer) {
|
|
27
46
|
const environment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
|
|
28
47
|
const module = environment.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
|
|
@@ -67,8 +86,11 @@ function astroContentVirtualModPlugin({
|
|
|
67
86
|
},
|
|
68
87
|
buildStart() {
|
|
69
88
|
if (devServer) {
|
|
89
|
+
const assetImportsPath = fileURLToPath(new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir));
|
|
70
90
|
devServer.watcher.add(fileURLToPath(dataStoreFile));
|
|
91
|
+
devServer.watcher.add(assetImportsPath);
|
|
71
92
|
invalidateDataStore(devServer);
|
|
93
|
+
invalidateAssetImports(devServer, assetImportsPath);
|
|
72
94
|
}
|
|
73
95
|
},
|
|
74
96
|
resolveId: {
|
|
@@ -175,14 +197,19 @@ function astroContentVirtualModPlugin({
|
|
|
175
197
|
configureServer(server) {
|
|
176
198
|
devServer = server;
|
|
177
199
|
const dataStorePath = fileURLToPath(dataStoreFile);
|
|
200
|
+
const assetImportsPath = fileURLToPath(new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir));
|
|
178
201
|
server.watcher.on("add", (addedPath) => {
|
|
179
202
|
if (addedPath === dataStorePath) {
|
|
180
203
|
invalidateDataStore(server);
|
|
204
|
+
invalidateAssetImports(server, assetImportsPath);
|
|
181
205
|
}
|
|
182
206
|
});
|
|
183
207
|
server.watcher.on("change", (changedPath) => {
|
|
184
208
|
if (changedPath === dataStorePath) {
|
|
185
209
|
invalidateDataStore(server);
|
|
210
|
+
invalidateAssetImports(server, assetImportsPath);
|
|
211
|
+
} else if (changedPath === assetImportsPath) {
|
|
212
|
+
invalidateAssetImports(server, assetImportsPath);
|
|
186
213
|
}
|
|
187
214
|
});
|
|
188
215
|
}
|
package/dist/core/app/base.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
101
101
|
/**
|
|
102
102
|
* Override the fetch handler used to dispatch requests. Entrypoints
|
|
103
103
|
* call this with the default export of `virtual:astro:fetchable` to
|
|
104
|
-
* plug in a user-authored handler from `src/
|
|
104
|
+
* plug in a user-authored handler from `src/fetch.ts`.
|
|
105
105
|
*/
|
|
106
106
|
setFetchHandler(handler: {
|
|
107
107
|
fetch: FetchHandler;
|
package/dist/core/app/base.js
CHANGED
|
@@ -14,7 +14,6 @@ import { DefaultFetchHandler } from "../fetch/default-handler.js";
|
|
|
14
14
|
import { appSymbol } from "../constants.js";
|
|
15
15
|
import { DefaultErrorHandler } from "../errors/default-handler.js";
|
|
16
16
|
import { setRenderOptions } from "./render-options.js";
|
|
17
|
-
import { MultiLevelEncodingError } from "../util/pathname.js";
|
|
18
17
|
class BaseApp {
|
|
19
18
|
manifest;
|
|
20
19
|
manifestData;
|
|
@@ -30,7 +29,7 @@ class BaseApp {
|
|
|
30
29
|
#fetchHandler;
|
|
31
30
|
#errorHandler;
|
|
32
31
|
/**
|
|
33
|
-
* Whether a custom fetch handler (from `src/
|
|
32
|
+
* Whether a custom fetch handler (from `src/fetch.ts`) has been set
|
|
34
33
|
* via `setFetchHandler`. When false, the `DefaultFetchHandler` is
|
|
35
34
|
* in use and all features are implicitly active.
|
|
36
35
|
*/
|
|
@@ -44,11 +43,9 @@ class BaseApp {
|
|
|
44
43
|
return this.pipeline.logger;
|
|
45
44
|
}
|
|
46
45
|
get adapterLogger() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.manifest.adapterName
|
|
51
|
-
);
|
|
46
|
+
const currentOptions = this.logger.options;
|
|
47
|
+
if (!this.#adapterLogger || this.#adapterLogger.options !== currentOptions) {
|
|
48
|
+
this.#adapterLogger = new AstroIntegrationLogger(currentOptions, this.manifest.adapterName);
|
|
52
49
|
}
|
|
53
50
|
return this.#adapterLogger;
|
|
54
51
|
}
|
|
@@ -63,7 +60,7 @@ class BaseApp {
|
|
|
63
60
|
/**
|
|
64
61
|
* Override the fetch handler used to dispatch requests. Entrypoints
|
|
65
62
|
* call this with the default export of `virtual:astro:fetchable` to
|
|
66
|
-
* plug in a user-authored handler from `src/
|
|
63
|
+
* plug in a user-authored handler from `src/fetch.ts`.
|
|
67
64
|
*/
|
|
68
65
|
setFetchHandler(handler) {
|
|
69
66
|
this.#fetchHandler = handler;
|
|
@@ -239,20 +236,13 @@ class BaseApp {
|
|
|
239
236
|
waitUntil
|
|
240
237
|
};
|
|
241
238
|
let response;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
response = await this.#fetchHandler.fetch(request);
|
|
250
|
-
}
|
|
251
|
-
} catch (err) {
|
|
252
|
-
if (err instanceof MultiLevelEncodingError) {
|
|
253
|
-
return new Response("Bad Request", { status: 400 });
|
|
254
|
-
}
|
|
255
|
-
throw err;
|
|
239
|
+
if (this.#fetchHandler instanceof DefaultFetchHandler) {
|
|
240
|
+
Reflect.set(request, appSymbol, this);
|
|
241
|
+
response = await this.#fetchHandler.renderWithOptions(request, resolvedOptions);
|
|
242
|
+
} else {
|
|
243
|
+
setRenderOptions(request, resolvedOptions);
|
|
244
|
+
Reflect.set(request, appSymbol, this);
|
|
245
|
+
response = await this.#fetchHandler.fetch(request);
|
|
256
246
|
}
|
|
257
247
|
this.#warnMissingFeatures();
|
|
258
248
|
if (response.headers.get(ASTRO_ERROR_HEADER)) {
|
|
@@ -298,7 +288,7 @@ class BaseApp {
|
|
|
298
288
|
return this.#errorHandler.renderError(request, options);
|
|
299
289
|
}
|
|
300
290
|
/**
|
|
301
|
-
* One-shot check: after the first request with a custom `src/
|
|
291
|
+
* One-shot check: after the first request with a custom `src/fetch.ts`,
|
|
302
292
|
* compare `usedFeatures` against the manifest and warn about any
|
|
303
293
|
* configured features the user's pipeline doesn't call.
|
|
304
294
|
*/
|
|
@@ -329,7 +319,7 @@ class BaseApp {
|
|
|
329
319
|
for (const feature of missing) {
|
|
330
320
|
this.logger.warn(
|
|
331
321
|
"router",
|
|
332
|
-
`Your project uses ${feature}, but your custom src/
|
|
322
|
+
`Your project uses ${feature}, but your custom src/fetch.ts does not call the ${feature}() handler. This feature will not work unless you add it to your fetch.ts pipeline.`
|
|
333
323
|
);
|
|
334
324
|
}
|
|
335
325
|
}
|
|
@@ -2,9 +2,6 @@ import { Pipeline } from "../../base-pipeline.js";
|
|
|
2
2
|
import { ASTRO_VERSION } from "../../constants.js";
|
|
3
3
|
import { createModuleScriptElement, createStylesheetElementSet } from "../../render/ssr-element.js";
|
|
4
4
|
import { findRouteToRewrite } from "../../routing/rewrite.js";
|
|
5
|
-
import { newNodePool } from "../../../runtime/server/render/queue/pool.js";
|
|
6
|
-
import { HTMLStringCache } from "../../../runtime/server/html-string-cache.js";
|
|
7
|
-
import { queueRenderingEnabled } from "../manifest.js";
|
|
8
5
|
class NonRunnablePipeline extends Pipeline {
|
|
9
6
|
getName() {
|
|
10
7
|
return "NonRunnablePipeline";
|
|
@@ -33,12 +30,6 @@ class NonRunnablePipeline extends Pipeline {
|
|
|
33
30
|
void 0,
|
|
34
31
|
void 0
|
|
35
32
|
);
|
|
36
|
-
if (queueRenderingEnabled(manifest.experimentalQueuedRendering)) {
|
|
37
|
-
pipeline.nodePool = newNodePool(manifest.experimentalQueuedRendering);
|
|
38
|
-
if (manifest.experimentalQueuedRendering.contentCache) {
|
|
39
|
-
pipeline.htmlStringCache = new HTMLStringCache(1e3);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
33
|
return pipeline;
|
|
43
34
|
}
|
|
44
35
|
async headElements(routeData) {
|
|
@@ -8,5 +8,3 @@ export declare function serializeRouteData(routeData: RouteData, trailingSlash:
|
|
|
8
8
|
export declare function deserializeRouteData(rawRouteData: SerializedRouteData): RouteData;
|
|
9
9
|
export declare function serializeRouteInfo(routeInfo: RouteInfo, trailingSlash: AstroConfig['trailingSlash']): SerializedRouteInfo;
|
|
10
10
|
export declare function deserializeRouteInfo(rawRouteInfo: SerializedRouteInfo): RouteInfo;
|
|
11
|
-
export declare function queuePoolSize(config: NonNullable<SSRManifest['experimentalQueuedRendering']>): number;
|
|
12
|
-
export declare function queueRenderingEnabled(config: SSRManifest['experimentalQueuedRendering']): boolean;
|
|
@@ -100,18 +100,10 @@ function deserializeRouteInfo(rawRouteInfo) {
|
|
|
100
100
|
routeData: deserializeRouteData(rawRouteInfo.routeData)
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
function queuePoolSize(config) {
|
|
104
|
-
return config?.poolSize ?? 1e3;
|
|
105
|
-
}
|
|
106
|
-
function queueRenderingEnabled(config) {
|
|
107
|
-
return config?.enabled ?? false;
|
|
108
|
-
}
|
|
109
103
|
export {
|
|
110
104
|
deserializeManifest,
|
|
111
105
|
deserializeRouteData,
|
|
112
106
|
deserializeRouteInfo,
|
|
113
|
-
queuePoolSize,
|
|
114
|
-
queueRenderingEnabled,
|
|
115
107
|
serializeRouteData,
|
|
116
108
|
serializeRouteInfo
|
|
117
109
|
};
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -61,13 +61,6 @@ export type SSRManifest = {
|
|
|
61
61
|
trailingSlash: AstroConfig['trailingSlash'];
|
|
62
62
|
buildFormat: NonNullable<AstroConfig['build']>['format'];
|
|
63
63
|
compressHTML: boolean | 'jsx';
|
|
64
|
-
experimentalQueuedRendering: {
|
|
65
|
-
enabled: boolean;
|
|
66
|
-
/** Node pool size for memory reuse (default: 1000, set to 0 to disable pooling) */
|
|
67
|
-
poolSize?: number;
|
|
68
|
-
/** Whether to enable HTMLString caching for deduplicating repeated HTML fragments (default: true) */
|
|
69
|
-
contentCache?: boolean;
|
|
70
|
-
};
|
|
71
64
|
assetsPrefix?: AssetsPrefix;
|
|
72
65
|
renderers: SSRLoadedRenderer[];
|
|
73
66
|
/**
|
|
@@ -145,7 +138,7 @@ export type SSRManifest = {
|
|
|
145
138
|
};
|
|
146
139
|
internalFetchHeaders?: Record<string, string>;
|
|
147
140
|
logLevel: AstroLoggerLevel;
|
|
148
|
-
|
|
141
|
+
loggerConfig: LoggerHandlerConfig | undefined;
|
|
149
142
|
};
|
|
150
143
|
export type SSRActions = {
|
|
151
144
|
server: Record<string, ActionClient<any, any, any>>;
|
|
@@ -12,11 +12,9 @@ import { type DefaultRouteParams } from './routing/default.js';
|
|
|
12
12
|
import type { CacheProvider, CacheProviderFactory } from './cache/types.js';
|
|
13
13
|
import type { CompiledCacheRoute } from './cache/runtime/route-matching.js';
|
|
14
14
|
import type { SessionDriverFactory } from './session/types.js';
|
|
15
|
-
import { NodePool } from '../runtime/server/render/queue/pool.js';
|
|
16
|
-
import { HTMLStringCache } from '../runtime/server/html-string-cache.js';
|
|
17
15
|
/**
|
|
18
16
|
* Bit flags for pipeline features that handler classes register as
|
|
19
|
-
* "used" when a custom `src/
|
|
17
|
+
* "used" when a custom `src/fetch.ts` fetch handler is in play. After the
|
|
20
18
|
* first request (dev) or at runtime (prod SSR), we compare against the
|
|
21
19
|
* manifest to warn about features the user configured but forgot to
|
|
22
20
|
* include in their custom pipeline.
|
|
@@ -47,12 +45,10 @@ export declare abstract class Pipeline {
|
|
|
47
45
|
resolvedSessionDriver: SessionDriverFactory | null | undefined;
|
|
48
46
|
resolvedCacheProvider: CacheProvider | null | undefined;
|
|
49
47
|
compiledCacheRoutes: CompiledCacheRoute[] | undefined;
|
|
50
|
-
nodePool: NodePool | undefined;
|
|
51
|
-
htmlStringCache: HTMLStringCache | undefined;
|
|
52
48
|
/**
|
|
53
49
|
* Bit mask of pipeline features activated by handler classes.
|
|
54
50
|
* Each handler sets its bit via `|=`. Only meaningful when a
|
|
55
|
-
* custom `src/
|
|
51
|
+
* custom `src/fetch.ts` fetch handler is in use.
|
|
56
52
|
*/
|
|
57
53
|
usedFeatures: number;
|
|
58
54
|
logger: AstroLogger;
|
|
@@ -166,7 +162,7 @@ export declare abstract class Pipeline {
|
|
|
166
162
|
clearMiddleware(): void;
|
|
167
163
|
/**
|
|
168
164
|
* Resolves the logger destination from the manifest and updates the pipeline logger.
|
|
169
|
-
* If the user configured `
|
|
165
|
+
* If the user configured `logger`, the bundled logger factory is loaded
|
|
170
166
|
* and replaces the default console destination. This is lazy and only resolves once.
|
|
171
167
|
*/
|
|
172
168
|
getLogger(): Promise<AstroLogger>;
|
|
@@ -176,8 +172,6 @@ export declare abstract class Pipeline {
|
|
|
176
172
|
getServerIslands(): Promise<ServerIslandMappings>;
|
|
177
173
|
getAction(path: string): Promise<ActionClient<unknown, ActionAccept, $ZodType>>;
|
|
178
174
|
getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
|
|
179
|
-
createNodePool(poolSize: number, stats: boolean): NodePool;
|
|
180
|
-
createStringCache(): HTMLStringCache;
|
|
181
175
|
}
|
|
182
176
|
export interface HeadElements extends Pick<SSRResult, 'scripts' | 'styles' | 'links'> {
|
|
183
177
|
}
|
|
@@ -9,8 +9,6 @@ import { RouteCache } from "./render/route-cache.js";
|
|
|
9
9
|
import { createDefaultRoutes } from "./routing/default.js";
|
|
10
10
|
import { ensure404Route } from "./routing/astro-designed-error-pages.js";
|
|
11
11
|
import { Router } from "./routing/router.js";
|
|
12
|
-
import { NodePool } from "../runtime/server/render/queue/pool.js";
|
|
13
|
-
import { HTMLStringCache } from "../runtime/server/html-string-cache.js";
|
|
14
12
|
import { FORBIDDEN_PATH_KEYS } from "@astrojs/internal-helpers/object";
|
|
15
13
|
import { loadLogger } from "./logger/load.js";
|
|
16
14
|
const PipelineFeatures = {
|
|
@@ -30,12 +28,10 @@ class Pipeline {
|
|
|
30
28
|
resolvedSessionDriver = void 0;
|
|
31
29
|
resolvedCacheProvider = void 0;
|
|
32
30
|
compiledCacheRoutes = void 0;
|
|
33
|
-
nodePool;
|
|
34
|
-
htmlStringCache;
|
|
35
31
|
/**
|
|
36
32
|
* Bit mask of pipeline features activated by handler classes.
|
|
37
33
|
* Each handler sets its bit via `|=`. Only meaningful when a
|
|
38
|
-
* custom `src/
|
|
34
|
+
* custom `src/fetch.ts` fetch handler is in use.
|
|
39
35
|
*/
|
|
40
36
|
usedFeatures = 0;
|
|
41
37
|
logger;
|
|
@@ -104,15 +100,6 @@ class Pipeline {
|
|
|
104
100
|
buildFormat: manifest.buildFormat
|
|
105
101
|
});
|
|
106
102
|
this.internalMiddleware = [];
|
|
107
|
-
if (manifest.experimentalQueuedRendering.enabled) {
|
|
108
|
-
this.nodePool = this.createNodePool(
|
|
109
|
-
manifest.experimentalQueuedRendering.poolSize ?? 1e3,
|
|
110
|
-
false
|
|
111
|
-
);
|
|
112
|
-
if (manifest.experimentalQueuedRendering.contentCache) {
|
|
113
|
-
this.htmlStringCache = this.createStringCache();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
103
|
}
|
|
117
104
|
/**
|
|
118
105
|
* Low-level route matching against the manifest routes. Returns the
|
|
@@ -175,7 +162,7 @@ class Pipeline {
|
|
|
175
162
|
}
|
|
176
163
|
/**
|
|
177
164
|
* Resolves the logger destination from the manifest and updates the pipeline logger.
|
|
178
|
-
* If the user configured `
|
|
165
|
+
* If the user configured `logger`, the bundled logger factory is loaded
|
|
179
166
|
* and replaces the default console destination. This is lazy and only resolves once.
|
|
180
167
|
*/
|
|
181
168
|
async getLogger() {
|
|
@@ -183,8 +170,8 @@ class Pipeline {
|
|
|
183
170
|
return this.logger;
|
|
184
171
|
}
|
|
185
172
|
this.resolvedLogger = true;
|
|
186
|
-
if (this.manifest.
|
|
187
|
-
this.logger = await loadLogger(this.manifest.
|
|
173
|
+
if (this.manifest.loggerConfig) {
|
|
174
|
+
this.logger = await loadLogger(this.manifest.loggerConfig);
|
|
188
175
|
}
|
|
189
176
|
return this.logger;
|
|
190
177
|
}
|
|
@@ -288,12 +275,6 @@ class Pipeline {
|
|
|
288
275
|
);
|
|
289
276
|
}
|
|
290
277
|
}
|
|
291
|
-
createNodePool(poolSize, stats) {
|
|
292
|
-
return new NodePool(poolSize, stats);
|
|
293
|
-
}
|
|
294
|
-
createStringCache() {
|
|
295
|
-
return new HTMLStringCache(1e3);
|
|
296
|
-
}
|
|
297
278
|
}
|
|
298
279
|
export {
|
|
299
280
|
ALL_PIPELINE_FEATURES,
|
package/dist/core/build/app.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { BuildPipeline } from './pipeline.js';
|
|
|
5
5
|
import type { StaticBuildOptions } from './types.js';
|
|
6
6
|
import type { LogRequestPayload } from '../app/base.js';
|
|
7
7
|
import type { ErrorHandler } from '../errors/handler.js';
|
|
8
|
-
import type { PoolStatsReport } from '../../runtime/server/render/queue/pool.js';
|
|
9
8
|
export declare class BuildApp extends BaseApp<BuildPipeline> {
|
|
10
9
|
createPipeline(_streaming: boolean, manifest: SSRManifest, ..._args: any[]): BuildPipeline;
|
|
11
10
|
isDev(): boolean;
|
|
@@ -14,6 +13,5 @@ export declare class BuildApp extends BaseApp<BuildPipeline> {
|
|
|
14
13
|
getOptions(): StaticBuildOptions;
|
|
15
14
|
getSettings(): import("../../types/astro.js").AstroSettings;
|
|
16
15
|
protected createErrorHandler(): ErrorHandler;
|
|
17
|
-
getQueueStats(): PoolStatsReport | undefined;
|
|
18
16
|
logRequest(_options: LogRequestPayload): void;
|
|
19
17
|
}
|
package/dist/core/build/app.js
CHANGED