astro 7.0.0-alpha.0 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Code.astro +1 -1
- package/dist/actions/handler.d.ts +32 -0
- package/dist/actions/handler.js +45 -0
- package/dist/actions/runtime/server.js +1 -1
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/build/remote.d.ts +3 -2
- package/dist/assets/build/remote.js +16 -9
- package/dist/assets/endpoint/dev.js +1 -1
- package/dist/assets/endpoint/generic.js +8 -20
- package/dist/assets/endpoint/loadImage.d.ts +11 -0
- package/dist/assets/endpoint/loadImage.js +19 -0
- package/dist/assets/endpoint/shared.js +7 -2
- package/dist/assets/fonts/config.d.ts +4 -4
- package/dist/assets/fonts/core/optimize-fallbacks.js +38 -13
- package/dist/assets/fonts/definitions.d.ts +2 -2
- package/dist/assets/fonts/infra/system-fallbacks-provider.d.ts +2 -2
- package/dist/assets/fonts/infra/system-fallbacks-provider.js +46 -9
- package/dist/assets/fonts/types.d.ts +1 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.js +2 -0
- package/dist/assets/internal.js +22 -3
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +9 -9
- package/dist/assets/services/sharp.js +53 -18
- package/dist/assets/utils/generateImageStylesCSS.js +26 -6
- package/dist/assets/utils/index.d.ts +1 -0
- package/dist/assets/utils/index.js +2 -0
- package/dist/assets/utils/inferSourceFormat.d.ts +8 -3
- package/dist/assets/utils/inferSourceFormat.js +15 -4
- package/dist/assets/utils/metadata.js +1 -1
- package/dist/assets/utils/redirectValidation.d.ts +48 -0
- package/dist/assets/utils/redirectValidation.js +48 -0
- package/dist/assets/utils/remoteProbe.js +25 -2
- package/dist/assets/utils/vendor/image-size/types/svg.js +1 -1
- package/dist/cli/add/index.js +7 -58
- package/dist/cli/dev/background.d.ts +16 -0
- package/dist/cli/dev/background.js +116 -0
- package/dist/cli/dev/index.js +82 -3
- package/dist/cli/dev/logs.d.ts +6 -0
- package/dist/cli/dev/logs.js +72 -0
- package/dist/cli/dev/status.d.ts +15 -0
- package/dist/cli/dev/status.js +27 -0
- package/dist/cli/dev/stop.d.ts +12 -0
- package/dist/cli/dev/stop.js +43 -0
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/index.js +18 -14
- package/dist/content/content-layer.js +16 -11
- package/dist/content/data-store.d.ts +1 -1
- package/dist/content/loaders/types.d.ts +1 -1
- package/dist/content/runtime-assets.d.ts +2 -2
- package/dist/content/runtime.d.ts +1 -1
- package/dist/content/runtime.js +9 -4
- package/dist/content/server-listeners.js +0 -4
- package/dist/content/types-generator.js +5 -1
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/utils.js +1 -1
- package/dist/content/vite-plugin-content-assets.js +1 -0
- package/dist/content/vite-plugin-content-virtual-mod.js +9 -1
- package/dist/core/app/base.d.ts +42 -15
- package/dist/core/app/base.js +151 -375
- package/dist/core/app/dev/app.d.ts +3 -2
- package/dist/core/app/dev/app.js +4 -60
- package/dist/core/app/entrypoints/node.d.ts +1 -1
- package/dist/core/app/entrypoints/node.js +2 -0
- package/dist/core/app/entrypoints/virtual/dev.js +2 -0
- package/dist/core/app/entrypoints/virtual/prod.js +4 -1
- package/dist/core/app/node.d.ts +16 -0
- package/dist/core/app/node.js +59 -13
- package/dist/core/app/prepare-response.d.ts +11 -0
- package/dist/core/app/prepare-response.js +18 -0
- package/dist/core/app/render-options.d.ts +11 -0
- package/dist/core/app/render-options.js +11 -0
- package/dist/core/base-pipeline.d.ts +48 -1
- package/dist/core/base-pipeline.js +63 -8
- package/dist/core/build/app.d.ts +3 -4
- package/dist/core/build/app.js +3 -17
- package/dist/core/build/generate.js +8 -1
- package/dist/core/build/index.d.ts +0 -11
- package/dist/core/build/index.js +0 -3
- package/dist/core/build/internal.d.ts +7 -0
- package/dist/core/build/plugins/plugin-chunk-imports.d.ts +6 -0
- package/dist/core/build/plugins/plugin-chunk-imports.js +29 -17
- package/dist/core/build/plugins/plugin-css.js +40 -1
- package/dist/core/build/plugins/plugin-internals.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +11 -1
- package/dist/core/build/static-build.js +22 -141
- package/dist/core/build/types.d.ts +0 -1
- package/dist/core/build/util.js +8 -1
- package/dist/core/build/vite-build-config.d.ts +28 -0
- package/dist/core/build/vite-build-config.js +165 -0
- package/dist/core/cache/handler.d.ts +29 -0
- package/dist/core/cache/handler.js +81 -0
- package/dist/core/compile/style.js +18 -1
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +4 -1
- package/dist/core/config/merge.js +4 -0
- package/dist/core/config/schemas/base.d.ts +25 -13
- package/dist/core/config/schemas/base.js +39 -10
- package/dist/core/config/schemas/relative.d.ts +76 -49
- package/dist/core/config/schemas/relative.js +2 -3
- package/dist/core/config/settings.js +2 -4
- package/dist/core/config/tsconfig.d.ts +24 -9
- package/dist/core/config/tsconfig.js +54 -45
- package/dist/core/config/validate.js +59 -0
- package/dist/core/constants.d.ts +27 -1
- package/dist/core/constants.js +14 -1
- package/dist/core/cookies/cookies.d.ts +7 -2
- package/dist/core/cookies/cookies.js +11 -4
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/cookies/response.js +1 -2
- package/dist/core/create-vite.js +18 -1
- package/dist/core/csp/config.js +17 -5
- package/dist/core/csp/runtime.js +6 -4
- package/dist/core/dev/dev.d.ts +1 -0
- package/dist/core/dev/dev.js +4 -13
- package/dist/core/dev/lockfile.d.ts +54 -0
- package/dist/core/dev/lockfile.js +93 -0
- package/dist/core/errors/build-handler.d.ts +17 -0
- package/dist/core/errors/build-handler.js +22 -0
- package/dist/core/errors/default-handler.d.ts +14 -0
- package/dist/core/errors/default-handler.js +144 -0
- package/dist/core/errors/dev-handler.d.ts +21 -0
- package/dist/core/errors/dev-handler.js +82 -0
- package/dist/core/errors/errors-data.d.ts +43 -38
- package/dist/core/errors/errors-data.js +79 -73
- package/dist/core/errors/handler.d.ts +9 -0
- package/dist/core/errors/handler.js +0 -0
- package/dist/core/errors/zod-error-map.js +30 -1
- package/dist/core/fetch/default-handler.d.ts +17 -0
- package/dist/core/fetch/default-handler.js +45 -0
- package/dist/core/fetch/fetch-state.d.ts +230 -0
- package/dist/core/fetch/fetch-state.js +896 -0
- package/dist/core/fetch/index.d.ts +61 -0
- package/dist/core/fetch/index.js +121 -0
- package/dist/core/fetch/types.d.ts +25 -0
- package/dist/core/fetch/types.js +0 -0
- package/dist/core/fetch/vite-plugin.d.ts +5 -0
- package/dist/core/fetch/vite-plugin.js +76 -0
- package/dist/core/hono/index.d.ts +21 -0
- package/dist/core/hono/index.js +101 -0
- package/dist/core/i18n/domain.d.ts +12 -0
- package/dist/core/i18n/domain.js +66 -0
- package/dist/core/i18n/handler.d.ts +18 -0
- package/dist/core/i18n/handler.js +122 -0
- package/dist/core/logger/core.d.ts +9 -1
- package/dist/core/logger/core.js +17 -1
- package/dist/core/messages/runtime.d.ts +0 -3
- package/dist/core/messages/runtime.js +1 -9
- package/dist/core/middleware/astro-middleware.d.ts +27 -0
- package/dist/core/middleware/astro-middleware.js +51 -0
- package/dist/core/module-loader/vite.js +1 -2
- package/dist/core/pages/handler.d.ts +20 -0
- package/dist/core/pages/handler.js +75 -0
- package/dist/core/preview/index.js +6 -5
- package/dist/core/preview/static-preview-server.js +5 -2
- package/dist/core/redirects/render.d.ts +2 -2
- package/dist/core/redirects/render.js +7 -8
- package/dist/core/render/params-and-props.js +2 -2
- package/dist/core/render/route-cache.d.ts +1 -0
- package/dist/core/render/route-cache.js +4 -4
- package/dist/core/render/slots.js +9 -2
- package/dist/core/rewrites/handler.d.ts +37 -0
- package/dist/core/rewrites/handler.js +67 -0
- package/dist/core/routing/3xx.js +8 -4
- package/dist/core/routing/create-manifest.js +11 -1
- package/dist/core/routing/handler.d.ts +17 -0
- package/dist/core/routing/handler.js +171 -0
- package/dist/core/routing/match.d.ts +0 -7
- package/dist/core/routing/match.js +0 -5
- package/dist/core/routing/parse-route.js +1 -1
- package/dist/core/routing/pattern.js +1 -1
- package/dist/core/routing/rewrite.js +2 -5
- package/dist/core/routing/router.d.ts +8 -0
- package/dist/core/routing/router.js +28 -0
- package/dist/core/routing/trailing-slash-handler.d.ts +18 -0
- package/dist/core/routing/trailing-slash-handler.js +67 -0
- package/dist/core/routing/validation.js +1 -1
- package/dist/core/server-islands/vite-plugin-server-islands.d.ts +6 -1
- package/dist/core/server-islands/vite-plugin-server-islands.js +13 -3
- package/dist/core/session/config.d.ts +1 -1
- package/dist/core/session/drivers.d.ts +1 -1
- package/dist/core/session/handler.d.ts +11 -0
- package/dist/core/session/handler.js +33 -0
- package/dist/core/session/runtime.js +7 -2
- package/dist/core/util/normalized-url.d.ts +10 -0
- package/dist/core/util/normalized-url.js +24 -0
- package/dist/core/util/pathname.d.ts +10 -1
- package/dist/core/util/pathname.js +13 -4
- package/dist/environments.js +1 -1
- package/dist/events/session.d.ts +8 -0
- package/dist/events/session.js +11 -0
- package/dist/i18n/middleware.d.ts +10 -0
- package/dist/i18n/middleware.js +4 -88
- package/dist/i18n/utils.js +2 -2
- package/dist/jsx/rehype.d.ts +1 -1
- package/dist/manifest/virtual-module.js +3 -1
- package/dist/markdown/index.d.ts +4 -0
- package/dist/markdown/index.js +14 -0
- package/dist/prefetch/index.js +12 -7
- package/dist/prerender/utils.js +5 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +9 -0
- package/dist/runtime/server/astro-island.js +57 -20
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/jsx.js +1 -1
- package/dist/runtime/server/render/common.js +10 -4
- package/dist/runtime/server/render/component.js +8 -6
- package/dist/runtime/server/render/head.js +1 -5
- package/dist/runtime/server/render/server-islands.js +2 -1
- package/dist/runtime/server/render/util.js +2 -2
- package/dist/runtime/server/scripts.js +6 -0
- package/dist/runtime/server/transition.d.ts +1 -6
- package/dist/runtime/server/transition.js +0 -8
- package/dist/transitions/events.d.ts +0 -14
- package/dist/transitions/events.js +0 -14
- package/dist/transitions/index.d.ts +0 -1
- package/dist/transitions/index.js +0 -2
- package/dist/transitions/vite-plugin-transitions.js +2 -4
- package/dist/types/public/config.d.ts +96 -14
- package/dist/types/public/content.d.ts +5 -5
- package/dist/types/public/index.d.ts +2 -1
- package/dist/types/public/integrations.d.ts +11 -3
- package/dist/types/public/internal.d.ts +1 -1
- package/dist/types/public/manifest.d.ts +1 -1
- package/dist/virtual-modules/i18n.d.ts +2 -2
- package/dist/virtual-modules/i18n.js +1 -1
- package/dist/vite-plugin-app/app.d.ts +13 -6
- package/dist/vite-plugin-app/app.js +51 -89
- package/dist/vite-plugin-app/createAstroServerApp.d.ts +3 -1
- package/dist/vite-plugin-app/createAstroServerApp.js +4 -3
- package/dist/vite-plugin-astro-server/plugin.js +11 -5
- package/dist/vite-plugin-astro-server/route-guard.d.ts +33 -0
- package/dist/vite-plugin-astro-server/route-guard.js +42 -23
- package/dist/vite-plugin-dev-status/index.d.ts +2 -0
- package/dist/vite-plugin-dev-status/index.js +15 -0
- package/dist/vite-plugin-head/index.js +36 -19
- package/dist/vite-plugin-hmr-reload/index.d.ts +1 -1
- package/dist/vite-plugin-hmr-reload/index.js +23 -1
- package/dist/vite-plugin-integrations-container/index.js +15 -6
- package/dist/vite-plugin-markdown/content-entry-type.js +7 -4
- package/dist/vite-plugin-markdown/images.js +9 -11
- package/dist/vite-plugin-markdown/index.js +12 -11
- package/dist/vite-plugin-utils/index.d.ts +1 -0
- package/dist/vite-plugin-utils/index.js +10 -1
- package/package.json +23 -16
- package/templates/content/types.d.ts +1 -0
- package/types/transitions.d.ts +0 -7
- package/dist/core/render-context.d.ts +0 -77
- package/dist/core/render-context.js +0 -826
|
@@ -2,6 +2,8 @@ import { errorMap } from "../errors/index.js";
|
|
|
2
2
|
import { AstroConfigRefinedSchema, createRelativeSchema } from "./schemas/index.js";
|
|
3
3
|
async function validateConfig(userConfig, root, cmd) {
|
|
4
4
|
const AstroConfigRelativeSchema = createRelativeSchema(cmd, root);
|
|
5
|
+
await coerceLegacyMarkdownPlugins(userConfig);
|
|
6
|
+
warnDeprecatedMarkdownOptions(userConfig);
|
|
5
7
|
return await validateConfigRefined(
|
|
6
8
|
await AstroConfigRelativeSchema.parseAsync(userConfig, {
|
|
7
9
|
error(issue) {
|
|
@@ -17,7 +19,64 @@ See https://docs.astro.build/en/reference/experimental-flags/ for a list of all
|
|
|
17
19
|
})
|
|
18
20
|
);
|
|
19
21
|
}
|
|
22
|
+
let didWarnAboutDeprecatedMarkdownOptions = false;
|
|
23
|
+
function warnDeprecatedMarkdownOptions(config) {
|
|
24
|
+
if (didWarnAboutDeprecatedMarkdownOptions) return;
|
|
25
|
+
const md = config?.markdown;
|
|
26
|
+
if (!md) return;
|
|
27
|
+
const deprecated = ["gfm", "smartypants"].filter((k) => md[k] !== void 0);
|
|
28
|
+
if (deprecated.length === 0) return;
|
|
29
|
+
didWarnAboutDeprecatedMarkdownOptions = true;
|
|
30
|
+
const names = deprecated.map((key) => `\`markdown.${key}\``).join(" and ");
|
|
31
|
+
const isPlural = deprecated.length > 1;
|
|
32
|
+
console.warn(
|
|
33
|
+
`[astro] ${names} ${isPlural ? "are" : "is"} deprecated. Move ${isPlural ? "them" : "it"} onto your processor instead (e.g. \`unified({ gfm: false, smartypants: false })\`). Will be removed in a future major.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
let didWarnAboutLegacyMarkdownPlugins = false;
|
|
37
|
+
let didWarnAboutProcessorMismatch = false;
|
|
38
|
+
const migratedLegacyPluginCounts = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
async function coerceLegacyMarkdownPlugins(config) {
|
|
40
|
+
const md = config?.markdown;
|
|
41
|
+
if (!md) return;
|
|
42
|
+
const remarkPlugins = md.remarkPlugins ?? [];
|
|
43
|
+
const rehypePlugins = md.rehypePlugins ?? [];
|
|
44
|
+
const remarkRehype = md.remarkRehype ?? {};
|
|
45
|
+
if (remarkPlugins.length === 0 && rehypePlugins.length === 0 && Object.keys(remarkRehype).length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { unified, isUnifiedProcessor } = await import("@astrojs/markdown-remark");
|
|
49
|
+
const current = md.processor;
|
|
50
|
+
if (!current || isUnifiedProcessor(current)) {
|
|
51
|
+
const target = current ?? (md.processor = unified());
|
|
52
|
+
const counts = migratedLegacyPluginCounts.get(target.options) ?? { remark: 0, rehype: 0 };
|
|
53
|
+
if (remarkPlugins.length > counts.remark) {
|
|
54
|
+
target.options.remarkPlugins.push(...remarkPlugins.slice(counts.remark));
|
|
55
|
+
}
|
|
56
|
+
if (rehypePlugins.length > counts.rehype) {
|
|
57
|
+
target.options.rehypePlugins.push(...rehypePlugins.slice(counts.rehype));
|
|
58
|
+
}
|
|
59
|
+
Object.assign(target.options.remarkRehype, remarkRehype);
|
|
60
|
+
migratedLegacyPluginCounts.set(target.options, {
|
|
61
|
+
remark: remarkPlugins.length,
|
|
62
|
+
rehype: rehypePlugins.length
|
|
63
|
+
});
|
|
64
|
+
if (!didWarnAboutLegacyMarkdownPlugins) {
|
|
65
|
+
didWarnAboutLegacyMarkdownPlugins = true;
|
|
66
|
+
console.warn(
|
|
67
|
+
"[astro] `markdown.remarkPlugins`, `markdown.rehypePlugins`, and `markdown.remarkRehype` are deprecated. Pass them to `unified({...})` from `@astrojs/markdown-remark` directly instead."
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
} else if (!didWarnAboutProcessorMismatch) {
|
|
71
|
+
didWarnAboutProcessorMismatch = true;
|
|
72
|
+
console.warn(
|
|
73
|
+
`[astro] \`markdown.remarkPlugins\`/\`rehypePlugins\`/\`remarkRehype\` are set, but your \`${current.name}\` processor doesn't run them. Move them to \`unified({...})\` from \`@astrojs/markdown-remark\` and set \`markdown.processor: unified({...})\` if you want them to apply.`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
20
77
|
async function validateConfigRefined(updatedConfig) {
|
|
78
|
+
await coerceLegacyMarkdownPlugins(updatedConfig);
|
|
79
|
+
warnDeprecatedMarkdownOptions(updatedConfig);
|
|
21
80
|
return await AstroConfigRefinedSchema.parseAsync(updatedConfig, { error: errorMap });
|
|
22
81
|
}
|
|
23
82
|
export {
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -35,6 +35,17 @@ export declare const NOOP_MIDDLEWARE_HEADER = "X-Astro-Noop";
|
|
|
35
35
|
* The name for the header used to help i18n middleware, which only needs to act on "page" and "fallback" route types.
|
|
36
36
|
*/
|
|
37
37
|
export declare const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
|
|
38
|
+
/**
|
|
39
|
+
* Internal headers that should be stripped from the response before
|
|
40
|
+
* sending it to the user agent. Add new internal headers here so
|
|
41
|
+
* `prepareResponse` removes them automatically.
|
|
42
|
+
*/
|
|
43
|
+
export declare const INTERNAL_RESPONSE_HEADERS: readonly ["X-Astro-Reroute", "X-Astro-Rewrite", "X-Astro-Noop", "X-Astro-Route-Type"];
|
|
44
|
+
/**
|
|
45
|
+
* Set by internal handlers (e.g. PagesHandler) to signal that a
|
|
46
|
+
* response should be replaced with the corresponding error page.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ASTRO_ERROR_HEADER = "X-Astro-Error";
|
|
38
49
|
/**
|
|
39
50
|
* The value of the `component` field of the default 404 page, which is used when there is no user-provided 404.astro page.
|
|
40
51
|
*/
|
|
@@ -55,7 +66,7 @@ export declare const REROUTABLE_STATUS_CODES: number[];
|
|
|
55
66
|
export declare const clientAddressSymbol: unique symbol;
|
|
56
67
|
/**
|
|
57
68
|
* The symbol used as a field on the request object to store the object to be made available to Astro APIs as `locals`.
|
|
58
|
-
* Use judiciously, as locals are now stored within `
|
|
69
|
+
* Use judiciously, as locals are now stored within `FetchState` by default. Tacking it onto request is no longer necessary.
|
|
59
70
|
*/
|
|
60
71
|
export declare const clientLocalsSymbol: unique symbol;
|
|
61
72
|
/**
|
|
@@ -66,6 +77,21 @@ export declare const originPathnameSymbol: unique symbol;
|
|
|
66
77
|
* Use this symbol to set and retrieve the pipeline.
|
|
67
78
|
*/
|
|
68
79
|
export declare const pipelineSymbol: unique symbol;
|
|
80
|
+
/**
|
|
81
|
+
* Use this symbol to stash the active `FetchState` on an `APIContext`
|
|
82
|
+
* (or `ActionAPIContext`). Consumed by internal shims that need access
|
|
83
|
+
* to per-request state without appearing in the public context shape
|
|
84
|
+
* — e.g. the manual-strategy i18n middleware wrapper in
|
|
85
|
+
* `src/i18n/middleware.ts`.
|
|
86
|
+
*/
|
|
87
|
+
export declare const fetchStateSymbol: unique symbol;
|
|
88
|
+
/**
|
|
89
|
+
* Use this symbol to stash the `BaseApp` on an incoming `Request` at the
|
|
90
|
+
* top of the pipeline. Fetch handlers loaded from `virtual:astro:fetchable`
|
|
91
|
+
* (including `DefaultFetchHandler`) read it to find the app associated
|
|
92
|
+
* with the current request without needing App passed to their constructor.
|
|
93
|
+
*/
|
|
94
|
+
export declare const appSymbol: unique symbol;
|
|
69
95
|
/**
|
|
70
96
|
* Use this symbol to opt into handling prerender routes in Astro core dev middleware.
|
|
71
97
|
*/
|
package/dist/core/constants.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
const ASTRO_VERSION = "7.0.0-alpha.
|
|
1
|
+
const ASTRO_VERSION = "7.0.0-alpha.2";
|
|
2
2
|
const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
|
|
3
3
|
const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
4
4
|
const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
|
|
5
5
|
const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
|
|
6
6
|
const NOOP_MIDDLEWARE_HEADER = "X-Astro-Noop";
|
|
7
7
|
const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
|
|
8
|
+
const INTERNAL_RESPONSE_HEADERS = [
|
|
9
|
+
REROUTE_DIRECTIVE_HEADER,
|
|
10
|
+
REWRITE_DIRECTIVE_HEADER_KEY,
|
|
11
|
+
NOOP_MIDDLEWARE_HEADER,
|
|
12
|
+
ROUTE_TYPE_HEADER
|
|
13
|
+
];
|
|
14
|
+
const ASTRO_ERROR_HEADER = "X-Astro-Error";
|
|
8
15
|
const DEFAULT_404_COMPONENT = "astro-default-404.astro";
|
|
9
16
|
const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308, 300, 304];
|
|
10
17
|
const REROUTABLE_STATUS_CODES = [404, 500];
|
|
@@ -12,6 +19,8 @@ const clientAddressSymbol = /* @__PURE__ */ Symbol.for("astro.clientAddress");
|
|
|
12
19
|
const clientLocalsSymbol = /* @__PURE__ */ Symbol.for("astro.locals");
|
|
13
20
|
const originPathnameSymbol = /* @__PURE__ */ Symbol.for("astro.originPathname");
|
|
14
21
|
const pipelineSymbol = /* @__PURE__ */ Symbol.for("astro.pipeline");
|
|
22
|
+
const fetchStateSymbol = /* @__PURE__ */ Symbol.for("astro.fetchState");
|
|
23
|
+
const appSymbol = /* @__PURE__ */ Symbol.for("astro.app");
|
|
15
24
|
const devPrerenderMiddlewareSymbol = /* @__PURE__ */ Symbol.for("astro.devPrerenderMiddleware");
|
|
16
25
|
const nodeRequestAbortControllerCleanupSymbol = /* @__PURE__ */ Symbol.for(
|
|
17
26
|
"astro.nodeRequestAbortControllerCleanup"
|
|
@@ -43,10 +52,12 @@ const ASTRO_VITE_ENVIRONMENT_NAMES = {
|
|
|
43
52
|
prerender: "prerender"
|
|
44
53
|
};
|
|
45
54
|
export {
|
|
55
|
+
ASTRO_ERROR_HEADER,
|
|
46
56
|
ASTRO_GENERATOR,
|
|
47
57
|
ASTRO_VERSION,
|
|
48
58
|
ASTRO_VITE_ENVIRONMENT_NAMES,
|
|
49
59
|
DEFAULT_404_COMPONENT,
|
|
60
|
+
INTERNAL_RESPONSE_HEADERS,
|
|
50
61
|
MIDDLEWARE_PATH_SEGMENT_NAME,
|
|
51
62
|
NOOP_MIDDLEWARE_HEADER,
|
|
52
63
|
REDIRECT_STATUS_CODES,
|
|
@@ -56,9 +67,11 @@ export {
|
|
|
56
67
|
REWRITE_DIRECTIVE_HEADER_VALUE,
|
|
57
68
|
ROUTE_TYPE_HEADER,
|
|
58
69
|
SUPPORTED_MARKDOWN_FILE_EXTENSIONS,
|
|
70
|
+
appSymbol,
|
|
59
71
|
clientAddressSymbol,
|
|
60
72
|
clientLocalsSymbol,
|
|
61
73
|
devPrerenderMiddlewareSymbol,
|
|
74
|
+
fetchStateSymbol,
|
|
62
75
|
nodeRequestAbortControllerCleanupSymbol,
|
|
63
76
|
originPathnameSymbol,
|
|
64
77
|
pipelineSymbol,
|
|
@@ -72,8 +72,13 @@ declare class AstroCookies implements AstroCookiesInterface {
|
|
|
72
72
|
*/
|
|
73
73
|
headers(): Generator<string, void, unknown>;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
75
|
+
* Marks the cookies as consumed and returns the header values.
|
|
76
|
+
* After consumption, any subsequent `set()` calls will warn.
|
|
77
|
+
*/
|
|
78
|
+
consume(): Generator<string, void, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Use the instance method `cookies.consume()` instead.
|
|
81
|
+
* Kept for backward compatibility with adapters.
|
|
77
82
|
*/
|
|
78
83
|
static consume(cookies: AstroCookies): Generator<string, void, unknown>;
|
|
79
84
|
}
|
|
@@ -173,12 +173,19 @@ class AstroCookies {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
176
|
+
* Marks the cookies as consumed and returns the header values.
|
|
177
|
+
* After consumption, any subsequent `set()` calls will warn.
|
|
178
|
+
*/
|
|
179
|
+
consume() {
|
|
180
|
+
this.#consumed = true;
|
|
181
|
+
return this.headers();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated Use the instance method `cookies.consume()` instead.
|
|
185
|
+
* Kept for backward compatibility with adapters.
|
|
178
186
|
*/
|
|
179
187
|
static consume(cookies) {
|
|
180
|
-
cookies
|
|
181
|
-
return cookies.headers();
|
|
188
|
+
return cookies.consume();
|
|
182
189
|
}
|
|
183
190
|
#ensureParsed() {
|
|
184
191
|
if (!this.#requestValues) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstroCookies } from './cookies.js';
|
|
1
|
+
import type { AstroCookies } from './cookies.js';
|
|
2
2
|
export declare function attachCookiesToResponse(response: Response, cookies: AstroCookies): void;
|
|
3
3
|
export declare function getCookiesFromResponse(response: Response): AstroCookies | undefined;
|
|
4
4
|
export declare function getSetCookiesFromResponse(response: Response): Generator<string, string[]>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AstroCookies } from "./cookies.js";
|
|
2
1
|
const astroCookiesSymbol = /* @__PURE__ */ Symbol.for("astro.cookies");
|
|
3
2
|
function attachCookiesToResponse(response, cookies) {
|
|
4
3
|
Reflect.set(response, astroCookiesSymbol, cookies);
|
|
@@ -16,7 +15,7 @@ function* getSetCookiesFromResponse(response) {
|
|
|
16
15
|
if (!cookies) {
|
|
17
16
|
return [];
|
|
18
17
|
}
|
|
19
|
-
for (const headerValue of
|
|
18
|
+
for (const headerValue of cookies.consume()) {
|
|
20
19
|
yield headerValue;
|
|
21
20
|
}
|
|
22
21
|
return [];
|
package/dist/core/create-vite.js
CHANGED
|
@@ -23,6 +23,7 @@ import astroDevToolbar from "../toolbar/vite-plugin-dev-toolbar.js";
|
|
|
23
23
|
import astroTransitions from "../transitions/vite-plugin-transitions.js";
|
|
24
24
|
import { vitePluginAdapterConfig } from "../vite-plugin-adapter-config/index.js";
|
|
25
25
|
import { vitePluginApp } from "../vite-plugin-app/index.js";
|
|
26
|
+
import { vitePluginFetchable } from "./fetch/vite-plugin.js";
|
|
26
27
|
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
|
27
28
|
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
28
29
|
import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
|
|
@@ -51,6 +52,7 @@ import { isObject } from "./util-runtime.js";
|
|
|
51
52
|
import { vitePluginEnvironment } from "../vite-plugin-environment/index.js";
|
|
52
53
|
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "./constants.js";
|
|
53
54
|
import { vitePluginChromedevtools } from "../vite-plugin-chromedevtools/index.js";
|
|
55
|
+
import { vitePluginDevStatus } from "../vite-plugin-dev-status/index.js";
|
|
54
56
|
import { vitePluginAstroServerClient } from "../vite-plugin-overlay/index.js";
|
|
55
57
|
const _crawlCache = /* @__PURE__ */ new Map();
|
|
56
58
|
function cloneCrawlResult(result) {
|
|
@@ -118,6 +120,19 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
118
120
|
customLogger: createViteLogger(logger, settings.config.vite.logLevel),
|
|
119
121
|
appType: "custom",
|
|
120
122
|
plugins: [
|
|
123
|
+
// Raise the watcher's maxListeners limit before any other plugin's
|
|
124
|
+
// configureServer hook can add listeners. Astro registers 12+ change
|
|
125
|
+
// listeners across its built-in Vite plugins, easily exceeding
|
|
126
|
+
// Node's default limit of 10.
|
|
127
|
+
{
|
|
128
|
+
name: "astro:watcher-max-listeners",
|
|
129
|
+
configureServer(server) {
|
|
130
|
+
const current = server.watcher.getMaxListeners();
|
|
131
|
+
if (current !== 0 && current < 50) {
|
|
132
|
+
server.watcher.setMaxListeners(50);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
121
136
|
serializedManifestPlugin({ settings, command, sync }),
|
|
122
137
|
vitePluginRenderers({
|
|
123
138
|
settings,
|
|
@@ -138,6 +153,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
138
153
|
// The server plugin is for dev only and having it run during the build causes
|
|
139
154
|
// the build to run very slow as the filewatcher is triggered often.
|
|
140
155
|
vitePluginApp(),
|
|
156
|
+
vitePluginFetchable({ settings }),
|
|
141
157
|
command === "dev" && vitePluginAstroServer({ settings, logger }),
|
|
142
158
|
command === "dev" && vitePluginAstroServerClient(),
|
|
143
159
|
astroDevCssPlugin({ routesList, command }),
|
|
@@ -165,7 +181,8 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
165
181
|
vitePluginCacheProvider({ settings }),
|
|
166
182
|
astroContainer(),
|
|
167
183
|
astroHmrReloadPlugin(),
|
|
168
|
-
vitePluginChromedevtools({ settings })
|
|
184
|
+
vitePluginChromedevtools({ settings }),
|
|
185
|
+
command === "dev" && vitePluginDevStatus()
|
|
169
186
|
],
|
|
170
187
|
publicDir: fileURLToPath(settings.config.publicDir),
|
|
171
188
|
root: fileURLToPath(settings.config.root),
|
package/dist/core/csp/config.js
CHANGED
|
@@ -37,13 +37,25 @@ const ALLOWED_DIRECTIVES = [
|
|
|
37
37
|
"upgrade-insecure-requests",
|
|
38
38
|
"worker-src"
|
|
39
39
|
];
|
|
40
|
-
const allowedDirectivesSchema = z.custom((value) => {
|
|
41
|
-
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return ALLOWED_DIRECTIVES.some((allowedValue) => {
|
|
40
|
+
const allowedDirectivesSchema = z.custom((v) => typeof v === "string").superRefine((value, ctx) => {
|
|
41
|
+
const isAllowed = ALLOWED_DIRECTIVES.some((allowedValue) => {
|
|
45
42
|
return value.startsWith(allowedValue);
|
|
46
43
|
});
|
|
44
|
+
if (!isAllowed) {
|
|
45
|
+
if (value.startsWith("script-src") || value.startsWith("style-src")) {
|
|
46
|
+
ctx.addIssue({
|
|
47
|
+
code: z.ZodIssueCode.custom,
|
|
48
|
+
message: `Directives \`script-src\` and \`style-src\` are not allowed in \`security.csp.directives\`. Please use \`security.csp.scriptDirective\` and \`security.csp.styleDirective\` instead.`,
|
|
49
|
+
fatal: true
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
ctx.addIssue({
|
|
53
|
+
code: z.ZodIssueCode.custom,
|
|
54
|
+
message: `Invalid directive: "${value}". Allowed directives are: ${ALLOWED_DIRECTIVES.join(", ")}`,
|
|
55
|
+
fatal: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
47
59
|
});
|
|
48
60
|
export {
|
|
49
61
|
ALGORITHMS,
|
package/dist/core/csp/runtime.js
CHANGED
|
@@ -8,25 +8,27 @@ function deduplicateDirectiveValues(existingDirective, newDirective) {
|
|
|
8
8
|
return `${directiveName} ${finalDirectives.join(" ")}`;
|
|
9
9
|
}
|
|
10
10
|
function pushDirective(directives, newDirective) {
|
|
11
|
-
let deduplicated = false;
|
|
12
11
|
if (directives.length === 0) {
|
|
13
12
|
return [newDirective];
|
|
14
13
|
}
|
|
15
14
|
const finalDirectives = [];
|
|
15
|
+
let matched = false;
|
|
16
16
|
for (const directive of directives) {
|
|
17
|
-
if (
|
|
17
|
+
if (matched) {
|
|
18
18
|
finalDirectives.push(directive);
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
21
|
const result = deduplicateDirectiveValues(directive, newDirective);
|
|
22
22
|
if (result) {
|
|
23
23
|
finalDirectives.push(result);
|
|
24
|
-
|
|
24
|
+
matched = true;
|
|
25
25
|
} else {
|
|
26
26
|
finalDirectives.push(directive);
|
|
27
|
-
finalDirectives.push(newDirective);
|
|
28
27
|
}
|
|
29
28
|
}
|
|
29
|
+
if (!matched) {
|
|
30
|
+
finalDirectives.push(newDirective);
|
|
31
|
+
}
|
|
30
32
|
return finalDirectives;
|
|
31
33
|
}
|
|
32
34
|
export {
|
package/dist/core/dev/dev.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type * as vite from 'vite';
|
|
|
4
4
|
import type { AstroInlineConfig } from '../../types/public/config.js';
|
|
5
5
|
export interface DevServer {
|
|
6
6
|
address: AddressInfo;
|
|
7
|
+
resolvedUrls: vite.ResolvedServerUrls;
|
|
7
8
|
handle: (req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage>) => void;
|
|
8
9
|
watcher: vite.FSWatcher;
|
|
9
10
|
stop(): Promise<void>;
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import { performance } from "node:perf_hooks";
|
|
4
3
|
import colors from "piccolore";
|
|
5
4
|
import { gt, major, minor, patch } from "semver";
|
|
@@ -21,23 +20,13 @@ import {
|
|
|
21
20
|
} from "./update-check.js";
|
|
22
21
|
import { BuildTimeAstroVersionProvider } from "../../cli/infra/build-time-astro-version-provider.js";
|
|
23
22
|
import { piccoloreTextStyler } from "../../cli/infra/piccolore-text-styler.js";
|
|
24
|
-
function warnIfVite8({ root, logger }) {
|
|
25
|
-
try {
|
|
26
|
-
const require2 = createRequire(root);
|
|
27
|
-
const { version } = require2("vite/package.json");
|
|
28
|
-
if (major(version) >= 8) {
|
|
29
|
-
logger.warn("SKIP_FORMAT", msg.vite8Warning({ viteVersion: version }));
|
|
30
|
-
}
|
|
31
|
-
} catch {
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
23
|
async function dev(inlineConfig) {
|
|
35
24
|
ensureProcessNodeEnv("development");
|
|
36
25
|
const devStart = performance.now();
|
|
37
26
|
await telemetry.record([]);
|
|
38
27
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
39
28
|
const logger = restart.container.logger;
|
|
40
|
-
const currentVersion = "7.0.0-alpha.
|
|
29
|
+
const currentVersion = "7.0.0-alpha.2";
|
|
41
30
|
const isPrerelease = currentVersion.includes("-");
|
|
42
31
|
if (!isPrerelease) {
|
|
43
32
|
try {
|
|
@@ -111,10 +100,12 @@ async function dev(inlineConfig) {
|
|
|
111
100
|
if (restart.container.viteServer.config.server?.fs?.strict === false) {
|
|
112
101
|
logger.warn("SKIP_FORMAT", msg.fsStrictWarning());
|
|
113
102
|
}
|
|
114
|
-
setImmediate(() => warnIfVite8({ root: restart.container.settings.config.root, logger }));
|
|
115
103
|
logger.info(null, colors.green("watching for file changes..."));
|
|
116
104
|
return {
|
|
117
105
|
address: devServerAddressInfo,
|
|
106
|
+
get resolvedUrls() {
|
|
107
|
+
return restart.container.viteServer.resolvedUrls || { local: [], network: [] };
|
|
108
|
+
},
|
|
118
109
|
get watcher() {
|
|
119
110
|
return restart.container.viteServer.watcher;
|
|
120
111
|
},
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Maximum time (ms) to wait for a process to exit after SIGTERM before escalating to SIGKILL. */
|
|
2
|
+
export declare const GRACEFUL_SHUTDOWN_TIMEOUT = 5000;
|
|
3
|
+
export interface LockFileData {
|
|
4
|
+
pid: number;
|
|
5
|
+
port: number;
|
|
6
|
+
url: string;
|
|
7
|
+
background: boolean;
|
|
8
|
+
startedAt: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ExistingServer {
|
|
11
|
+
data: LockFileData;
|
|
12
|
+
stale: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the URL of the dev log file for a given project root.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getLogFileURL(root: URL): URL;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a lock file JSON string into a LockFileData object.
|
|
20
|
+
* Returns null if the content is invalid.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseLockFile(content: string): LockFileData | null;
|
|
23
|
+
/**
|
|
24
|
+
* Serialize lock file data to a JSON string.
|
|
25
|
+
*/
|
|
26
|
+
export declare function serializeLockFile(data: LockFileData): string;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a process with the given PID is alive.
|
|
29
|
+
* Signal 0 does not kill the process — it only checks whether the process exists.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Read the lock file from disk. Returns null if it doesn't exist or is invalid.
|
|
34
|
+
*/
|
|
35
|
+
export declare function readLockFile(root: URL): LockFileData | null;
|
|
36
|
+
/**
|
|
37
|
+
* Write the lock file to disk.
|
|
38
|
+
*/
|
|
39
|
+
export declare function writeLockFile(root: URL, data: LockFileData): void;
|
|
40
|
+
/**
|
|
41
|
+
* Remove the lock file from disk. No-op if it doesn't exist.
|
|
42
|
+
*/
|
|
43
|
+
export declare function removeLockFile(root: URL): void;
|
|
44
|
+
/**
|
|
45
|
+
* Given lock file data and a liveness result, determine the state of the existing server.
|
|
46
|
+
* This is the pure decision logic, separated from I/O for testability.
|
|
47
|
+
*/
|
|
48
|
+
export declare function evaluateExistingServer(data: LockFileData | null, alive: boolean): ExistingServer | null;
|
|
49
|
+
/**
|
|
50
|
+
* Check for an existing dev server by reading the lock file and checking process liveness.
|
|
51
|
+
* Automatically cleans up stale lock files.
|
|
52
|
+
* Returns the server info if a live server is found, null otherwise.
|
|
53
|
+
*/
|
|
54
|
+
export declare function checkExistingServer(root: URL): LockFileData | null;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
const GRACEFUL_SHUTDOWN_TIMEOUT = 5e3;
|
|
4
|
+
function getLockFileURL(root) {
|
|
5
|
+
return new URL(".astro/dev.json", root);
|
|
6
|
+
}
|
|
7
|
+
function getLogFileURL(root) {
|
|
8
|
+
return new URL(".astro/dev.log", root);
|
|
9
|
+
}
|
|
10
|
+
function parseLockFile(content) {
|
|
11
|
+
try {
|
|
12
|
+
const data = JSON.parse(content);
|
|
13
|
+
if (typeof data.pid !== "number" || typeof data.port !== "number" || typeof data.url !== "string" || typeof data.background !== "boolean" || typeof data.startedAt !== "string") {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return data;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function serializeLockFile(data) {
|
|
22
|
+
return JSON.stringify(data, null, " ");
|
|
23
|
+
}
|
|
24
|
+
function isProcessAlive(pid) {
|
|
25
|
+
try {
|
|
26
|
+
process.kill(pid, 0);
|
|
27
|
+
return true;
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function readLockFile(root) {
|
|
33
|
+
const lockFileURL = getLockFileURL(root);
|
|
34
|
+
try {
|
|
35
|
+
const content = readFileSync(lockFileURL, "utf-8");
|
|
36
|
+
return parseLockFile(content);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function writeLockFile(root, data) {
|
|
42
|
+
const lockFileURL = getLockFileURL(root);
|
|
43
|
+
const dirPath = fileURLToPath(new URL(".astro/", root));
|
|
44
|
+
try {
|
|
45
|
+
if (!existsSync(dirPath)) {
|
|
46
|
+
mkdirSync(dirPath, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
writeFileSync(lockFileURL, serializeLockFile(data), "utf-8");
|
|
49
|
+
} catch (err) {
|
|
50
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
51
|
+
throw new Error(`Failed to write lock file: ${message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function removeLockFile(root) {
|
|
55
|
+
const lockFileURL = getLockFileURL(root);
|
|
56
|
+
try {
|
|
57
|
+
unlinkSync(lockFileURL);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
if (err?.code !== "ENOENT") {
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function evaluateExistingServer(data, alive) {
|
|
65
|
+
if (data === null) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return { data, stale: !alive };
|
|
69
|
+
}
|
|
70
|
+
function checkExistingServer(root) {
|
|
71
|
+
const data = readLockFile(root);
|
|
72
|
+
const result = evaluateExistingServer(data, data !== null && isProcessAlive(data.pid));
|
|
73
|
+
if (result === null) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (result.stale) {
|
|
77
|
+
removeLockFile(root);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return result.data;
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
GRACEFUL_SHUTDOWN_TIMEOUT,
|
|
84
|
+
checkExistingServer,
|
|
85
|
+
evaluateExistingServer,
|
|
86
|
+
getLogFileURL,
|
|
87
|
+
isProcessAlive,
|
|
88
|
+
parseLockFile,
|
|
89
|
+
readLockFile,
|
|
90
|
+
removeLockFile,
|
|
91
|
+
serializeLockFile,
|
|
92
|
+
writeLockFile
|
|
93
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseApp, RenderErrorOptions } from '../app/base.js';
|
|
2
|
+
import type { Pipeline } from '../base-pipeline.js';
|
|
3
|
+
import type { ErrorHandler } from './handler.js';
|
|
4
|
+
/**
|
|
5
|
+
* The error handler used during static build / prerendering.
|
|
6
|
+
*
|
|
7
|
+
* - For 500 errors, returns the original response if present, otherwise
|
|
8
|
+
* throws so the build surfaces the underlying error to the developer.
|
|
9
|
+
* - For other errors (e.g. 404), delegates to `DefaultErrorHandler` with
|
|
10
|
+
* `prerenderedErrorPageFetch` cleared (the build pipeline can't fetch
|
|
11
|
+
* prerendered pages the way production SSR can).
|
|
12
|
+
*/
|
|
13
|
+
export declare class BuildErrorHandler implements ErrorHandler {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(app: BaseApp<Pipeline>);
|
|
16
|
+
renderError(request: Request, options: RenderErrorOptions): Promise<Response>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DefaultErrorHandler } from "./default-handler.js";
|
|
2
|
+
class BuildErrorHandler {
|
|
3
|
+
#default;
|
|
4
|
+
constructor(app) {
|
|
5
|
+
this.#default = new DefaultErrorHandler(app);
|
|
6
|
+
}
|
|
7
|
+
async renderError(request, options) {
|
|
8
|
+
if (options.status === 500) {
|
|
9
|
+
if (options.response) {
|
|
10
|
+
return options.response;
|
|
11
|
+
}
|
|
12
|
+
throw options.error;
|
|
13
|
+
}
|
|
14
|
+
return this.#default.renderError(request, {
|
|
15
|
+
...options,
|
|
16
|
+
prerenderedErrorPageFetch: void 0
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
BuildErrorHandler
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BaseApp, RenderErrorOptions } from '../app/base.js';
|
|
2
|
+
import type { Pipeline } from '../base-pipeline.js';
|
|
3
|
+
import type { ErrorHandler } from './handler.js';
|
|
4
|
+
/**
|
|
5
|
+
* The default error handler used in production SSR. Attempts to render the
|
|
6
|
+
* matching error route (404.astro / 500.astro), falling back to a plain
|
|
7
|
+
* response with the given status. Handles prerendered error pages via
|
|
8
|
+
* `prerenderedErrorPageFetch`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DefaultErrorHandler implements ErrorHandler {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(app: BaseApp<Pipeline>);
|
|
13
|
+
renderError(request: Request, { status, response: originalResponse, skipMiddleware, error, pathname, ...resolvedRenderOptions }: RenderErrorOptions): Promise<Response>;
|
|
14
|
+
}
|