astro 7.2.2 → 7.2.3
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/handler.d.ts +6 -12
- package/dist/actions/handler.js +30 -40
- package/dist/actions/load.d.ts +12 -0
- package/dist/actions/load.js +55 -0
- package/dist/actions/runtime/entrypoints/server.js +5 -4
- package/dist/actions/runtime/server.js +8 -6
- package/dist/assets/fonts/providers/index.d.ts +1 -1
- package/dist/assets/fonts/providers/index.js +2 -12
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/environment.d.ts +20 -0
- package/dist/container/environment.js +106 -0
- package/dist/container/index.js +65 -32
- package/dist/content/content-layer.js +3 -3
- package/dist/content/data-store-writer.d.ts +7 -10
- package/dist/content/data-store-writer.js +62 -27
- package/dist/content/data-store.d.ts +20 -3
- package/dist/content/data-store.js +28 -7
- package/dist/content/mutable-data-store.js +15 -10
- package/dist/content/runtime.d.ts +3 -2
- package/dist/content/runtime.js +43 -26
- package/dist/core/app/app.d.ts +0 -2
- package/dist/core/app/app.js +0 -7
- package/dist/core/app/base.d.ts +32 -20
- package/dist/core/app/base.js +76 -66
- package/dist/core/app/dev-facade.d.ts +27 -0
- package/dist/core/app/dev-facade.js +51 -0
- package/dist/core/app/entrypoints/index.d.ts +0 -1
- package/dist/core/app/entrypoints/index.js +0 -2
- package/dist/core/app/entrypoints/virtual/dev.js +24 -19
- package/dist/core/app/node.js +13 -14
- package/dist/core/app/prepare-response.d.ts +1 -1
- package/dist/core/app/validate-headers.js +7 -3
- package/dist/core/build/app.d.ts +31 -6
- package/dist/core/build/app.js +31 -13
- package/dist/core/build/environment.d.ts +25 -0
- package/dist/core/build/environment.js +157 -0
- package/dist/core/cache/handler.d.ts +13 -7
- package/dist/core/cache/handler.js +55 -51
- package/dist/core/cache/provider.d.ts +4 -0
- package/dist/core/cache/provider.js +15 -0
- package/dist/core/constants.d.ts +0 -11
- package/dist/core/constants.js +1 -5
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/environment/dev-nonrunnable.d.ts +6 -0
- package/dist/core/environment/dev-nonrunnable.js +170 -0
- package/dist/core/environment/index.d.ts +90 -0
- package/dist/core/environment/index.js +12 -0
- package/dist/core/environment/production.d.ts +6 -0
- package/dist/core/environment/production.js +117 -0
- package/dist/core/errors/build-handler.d.ts +5 -10
- package/dist/core/errors/build-handler.js +11 -17
- package/dist/core/errors/default-handler.d.ts +4 -9
- package/dist/core/errors/default-handler.js +92 -107
- package/dist/core/errors/dev-handler.d.ts +7 -11
- package/dist/core/errors/dev-handler.js +71 -69
- package/dist/core/errors/errors-data.d.ts +18 -0
- package/dist/core/errors/errors-data.js +7 -0
- package/dist/core/errors/handler.d.ts +22 -3
- package/dist/core/errors/handler.js +25 -0
- package/dist/core/fetch/default-handler.d.ts +15 -8
- package/dist/core/fetch/default-handler.js +12 -34
- package/dist/core/fetch/features.d.ts +23 -0
- package/dist/core/fetch/features.js +27 -0
- package/dist/core/fetch/fetch-state.d.ts +52 -7
- package/dist/core/fetch/fetch-state.js +92 -81
- package/dist/core/fetch/index.d.ts +9 -2
- package/dist/core/fetch/index.js +18 -79
- package/dist/core/fetch/vite-plugin.js +2 -1
- package/dist/core/i18n/handler.d.ts +28 -13
- package/dist/core/i18n/handler.js +100 -100
- package/dist/core/logger/manifest-logger.d.ts +31 -0
- package/dist/core/logger/manifest-logger.js +37 -0
- package/dist/core/manifest/ambient-source.d.ts +2 -0
- package/dist/core/manifest/ambient-source.js +4 -0
- package/dist/core/manifest/ambient.d.ts +16 -0
- package/dist/core/manifest/ambient.js +22 -0
- package/dist/core/manifest/derived.d.ts +3 -0
- package/dist/core/manifest/derived.js +10 -0
- package/dist/core/manifest/memo.d.ts +31 -0
- package/dist/core/manifest/memo.js +47 -0
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/astro-middleware.d.ts +25 -35
- package/dist/core/middleware/astro-middleware.js +61 -81
- package/dist/core/middleware/load.d.ts +19 -0
- package/dist/core/middleware/load.js +36 -0
- package/dist/core/middleware/sequence.js +15 -7
- package/dist/core/pages/handler.d.ts +18 -25
- package/dist/core/pages/handler.js +68 -84
- package/dist/core/redirects/render.js +3 -8
- package/dist/core/render/index.d.ts +0 -1
- package/dist/core/render/index.js +0 -2
- package/dist/core/render/route-cache.d.ts +6 -1
- package/dist/core/render/route-cache.js +11 -1
- package/dist/core/rewrites/handler.d.ts +4 -6
- package/dist/core/rewrites/handler.js +19 -20
- package/dist/core/routing/default.d.ts +2 -0
- package/dist/core/routing/default.js +7 -1
- package/dist/core/routing/dev.d.ts +1 -3
- package/dist/core/routing/dev.js +12 -5
- package/dist/core/routing/handler.d.ts +6 -16
- package/dist/core/routing/handler.js +126 -164
- package/dist/core/routing/helpers.d.ts +7 -1
- package/dist/core/routing/helpers.js +21 -0
- package/dist/core/routing/match-request.d.ts +10 -0
- package/dist/core/routing/match-request.js +57 -0
- package/dist/core/routing/route-table.d.ts +34 -0
- package/dist/core/routing/route-table.js +41 -0
- package/dist/core/routing/trailing-slash-handler.d.ts +4 -14
- package/dist/core/routing/trailing-slash-handler.js +39 -50
- package/dist/core/server-islands/mappings.d.ts +6 -0
- package/dist/core/server-islands/mappings.js +12 -0
- package/dist/core/session/driver.d.ts +4 -0
- package/dist/core/session/driver.js +14 -0
- package/dist/core/session/handler.d.ts +1 -1
- package/dist/core/session/handler.js +8 -8
- package/dist/core/session/provider-disabled.js +2 -2
- package/dist/entrypoints/prerender.js +5 -1
- package/dist/i18n/middleware.d.ts +4 -4
- package/dist/i18n/middleware.js +3 -3
- package/dist/manifest/serialized.d.ts +1 -0
- package/dist/manifest/serialized.js +9 -2
- package/dist/runtime/prerender/static-paths.d.ts +14 -2
- package/dist/runtime/prerender/static-paths.js +4 -3
- package/dist/types/public/config.d.ts +433 -241
- package/dist/vite-plugin-app/createAstroServerApp.js +22 -18
- package/dist/vite-plugin-app/environment.d.ts +18 -0
- package/dist/vite-plugin-app/environment.js +210 -0
- package/dist/vite-plugin-app/handle-request.d.ts +30 -0
- package/dist/vite-plugin-app/handle-request.js +129 -0
- package/dist/vite-plugin-app/index.d.ts +1 -1
- package/dist/vite-plugin-app/index.js +1 -1
- package/package.json +14 -7
- package/src/core/README.md +37 -0
- package/src/core/manifest/ambient-source.ts +9 -0
- package/src/types/README.md +5 -0
- package/dist/container/pipeline.d.ts +0 -14
- package/dist/container/pipeline.js +0 -78
- package/dist/core/app/dev/app.d.ts +0 -31
- package/dist/core/app/dev/app.js +0 -80
- package/dist/core/app/dev/pipeline.d.ts +0 -17
- package/dist/core/app/dev/pipeline.js +0 -133
- package/dist/core/app/pipeline.d.ts +0 -14
- package/dist/core/app/pipeline.js +0 -123
- package/dist/core/base-pipeline.d.ts +0 -183
- package/dist/core/base-pipeline.js +0 -293
- package/dist/core/build/pipeline.d.ts +0 -38
- package/dist/core/build/pipeline.js +0 -202
- package/dist/vite-plugin-app/app.d.ts +0 -62
- package/dist/vite-plugin-app/app.js +0 -237
- package/dist/vite-plugin-app/pipeline.d.ts +0 -25
- package/dist/vite-plugin-app/pipeline.js +0 -189
|
@@ -1377,6 +1377,24 @@ export declare const LoggerConfigurationNotSerializable: {
|
|
|
1377
1377
|
name: string;
|
|
1378
1378
|
title: string;
|
|
1379
1379
|
};
|
|
1380
|
+
/**
|
|
1381
|
+
* @docs
|
|
1382
|
+
* @description
|
|
1383
|
+
* `new FetchState(request)` can only be used inside an Astro server — the built
|
|
1384
|
+
* server output or the dev server — where Astro provides the manifest describing
|
|
1385
|
+
* your site. This error means it was called somewhere else, for example in a
|
|
1386
|
+
* plain Node script that imports `astro/fetch`.
|
|
1387
|
+
*
|
|
1388
|
+
* If this error occurs inside an Astro-built server, please [open an issue](https://astro.build/issues/).
|
|
1389
|
+
* @message
|
|
1390
|
+
* `new FetchState(request)` was called outside of an Astro server, so no manifest is available.
|
|
1391
|
+
*/
|
|
1392
|
+
export declare const NoManifestAvailable: {
|
|
1393
|
+
name: string;
|
|
1394
|
+
title: string;
|
|
1395
|
+
message: string;
|
|
1396
|
+
hint: string;
|
|
1397
|
+
};
|
|
1380
1398
|
/**
|
|
1381
1399
|
* @docs
|
|
1382
1400
|
* @kind heading
|
|
@@ -527,6 +527,12 @@ const LoggerConfigurationNotSerializable = {
|
|
|
527
527
|
name: "LoggerConfigurationNotSerializable",
|
|
528
528
|
title: "The configuration of the logger is not serializable."
|
|
529
529
|
};
|
|
530
|
+
const NoManifestAvailable = {
|
|
531
|
+
name: "NoManifestAvailableError",
|
|
532
|
+
title: "No manifest available.",
|
|
533
|
+
message: "`new FetchState(request)` was called outside of an Astro server, so no manifest is available.",
|
|
534
|
+
hint: "Make sure this code runs as part of your Astro app, such as its fetch entrypoint. If this error occurred inside an Astro-built server, please open an issue at https://github.com/withastro/astro/issues."
|
|
535
|
+
};
|
|
530
536
|
const UnknownCSSError = {
|
|
531
537
|
name: "UnknownCSSError",
|
|
532
538
|
title: "Unknown CSS error."
|
|
@@ -896,6 +902,7 @@ export {
|
|
|
896
902
|
NoClientEntrypoint,
|
|
897
903
|
NoClientOnlyHint,
|
|
898
904
|
NoImageMetadata,
|
|
905
|
+
NoManifestAvailable,
|
|
899
906
|
NoMatchingImport,
|
|
900
907
|
NoMatchingRenderer,
|
|
901
908
|
NoMatchingStaticPathFound,
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import type { RenderErrorOptions } from '../app/base.js';
|
|
2
2
|
import type { RouteData } from '../../types/public/index.js';
|
|
3
|
+
import type { SSRManifest } from '../app/types.js';
|
|
4
|
+
import type { FetchState } from '../fetch/fetch-state.js';
|
|
3
5
|
/**
|
|
4
|
-
* A strategy for rendering error responses (404, 500, etc.).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* A strategy for rendering error responses (404, 500, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Internal shape of `BaseApp`'s `#errorHandler` (whose default wraps
|
|
9
|
+
* {@link renderErrorPage}); external `BaseApp` subclasses may return their
|
|
10
|
+
* own implementation from the protected `createErrorHandler()`.
|
|
7
11
|
*/
|
|
8
12
|
export interface ErrorHandler {
|
|
9
13
|
renderError(request: Request, options: RenderErrorOptions): Promise<Response>;
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Renders the error page (404.astro / 500.astro or a plain response) for a
|
|
17
|
+
* request, dispatching to the strategy the manifest's environment selects:
|
|
18
|
+
* production/container default, dev (overlay + custom error routes, with or
|
|
19
|
+
* without CSP meta-tag injection), or build (500s throw so the build fails).
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderErrorPage(manifest: SSRManifest, request: Request, options: RenderErrorOptions): Promise<Response>;
|
|
22
|
+
/**
|
|
23
|
+
* Dispatches an internal error render for a request flowing through the
|
|
24
|
+
* handler chain: through the facade's late-bound `renderError` hook when the
|
|
25
|
+
* state was built by `BaseApp.render`'s fast path (preserving instance
|
|
26
|
+
* overrides/reassignments, e.g. cloudflare's prerender-error propagation),
|
|
27
|
+
* else through the environment's strategy via {@link renderErrorPage}.
|
|
28
|
+
*/
|
|
29
|
+
export declare function renderErrorFromState(state: FetchState, request: Request, options: RenderErrorOptions): Promise<Response>;
|
|
11
30
|
/**
|
|
12
31
|
* Whether a middleware rewrite (`ctx.rewrite()` / `next(payload)`) issued while
|
|
13
32
|
* rendering the error page dead-ended in another empty reroutable (404/500)
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { REROUTABLE_STATUS_CODES } from "../constants.js";
|
|
2
|
+
import { getEnvironment } from "../environment/index.js";
|
|
3
|
+
import { renderBuildError } from "./build-handler.js";
|
|
4
|
+
import { renderDefaultError } from "./default-handler.js";
|
|
5
|
+
import { renderDevError } from "./dev-handler.js";
|
|
6
|
+
function renderErrorPage(manifest, request, options) {
|
|
7
|
+
const env = getEnvironment(manifest);
|
|
8
|
+
switch (env.errorStrategy) {
|
|
9
|
+
case "dev":
|
|
10
|
+
return renderDevError(manifest, request, options, {
|
|
11
|
+
shouldInjectCspMetaTags: env.injectCspMetaTagsOnErrorPages
|
|
12
|
+
});
|
|
13
|
+
case "build":
|
|
14
|
+
return renderBuildError(manifest, request, options);
|
|
15
|
+
case "default":
|
|
16
|
+
return renderDefaultError(manifest, request, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function renderErrorFromState(state, request, options) {
|
|
20
|
+
if (state.renderError) {
|
|
21
|
+
return state.renderError(request, options);
|
|
22
|
+
}
|
|
23
|
+
return renderErrorPage(state.manifest, request, options);
|
|
24
|
+
}
|
|
2
25
|
function rewroteToEmptyErrorResponse(skipMiddleware, errorRouteData, renderedRouteData, response) {
|
|
3
26
|
return skipMiddleware === false && renderedRouteData !== errorRouteData && response.body === null && REROUTABLE_STATUS_CODES.includes(response.status);
|
|
4
27
|
}
|
|
5
28
|
export {
|
|
29
|
+
renderErrorFromState,
|
|
30
|
+
renderErrorPage,
|
|
6
31
|
rewroteToEmptyErrorResponse
|
|
7
32
|
};
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Pipeline } from '../base-pipeline.js';
|
|
1
|
+
import type { SSRManifest } from '../app/types.js';
|
|
3
2
|
import type { FetchHandler } from './types.js';
|
|
4
3
|
/**
|
|
5
|
-
* The default request handler for `BaseApp`.
|
|
6
|
-
* `FetchState` and delegates to
|
|
4
|
+
* The default request handler for `BaseApp`. Stateless: builds the
|
|
5
|
+
* per-request `FetchState` from the manifest and delegates to
|
|
6
|
+
* `handleRequest`.
|
|
7
|
+
*
|
|
8
|
+
* The export path (`astro/app/fetch/default-handler`), the class name, and
|
|
9
|
+
* no-arg constructibility are baked into generated builds
|
|
10
|
+
* (`core/fetch/vite-plugin.ts` emits `new DefaultFetchHandler()`), so all
|
|
11
|
+
* three survive.
|
|
7
12
|
*/
|
|
8
13
|
export declare class DefaultFetchHandler {
|
|
9
14
|
#private;
|
|
10
|
-
constructor(app?: BaseApp<Pipeline>);
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
16
|
+
* `BaseApp` passes itself so states resolve that app's manifest ahead of
|
|
17
|
+
* the ambient one; generated builds construct the handler with no
|
|
18
|
+
* arguments and use the ambient manifest.
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
constructor(app?: {
|
|
21
|
+
manifest: SSRManifest;
|
|
22
|
+
});
|
|
16
23
|
fetch: FetchHandler;
|
|
17
24
|
}
|
|
@@ -1,43 +1,21 @@
|
|
|
1
|
+
import { getAmbientManifest } from "../manifest/ambient.js";
|
|
2
|
+
import { getRenderOptions } from "../app/render-options.js";
|
|
3
|
+
import { handleRequest } from "../routing/handler.js";
|
|
1
4
|
import { FetchState } from "./fetch-state.js";
|
|
2
|
-
import { appSymbol } from "../constants.js";
|
|
3
|
-
import { AstroHandler } from "../routing/handler.js";
|
|
4
5
|
class DefaultFetchHandler {
|
|
5
|
-
#
|
|
6
|
-
#handler;
|
|
7
|
-
constructor(app) {
|
|
8
|
-
this.#app = app ?? null;
|
|
9
|
-
this.#handler = app ? new AstroHandler(app) : null;
|
|
10
|
-
}
|
|
6
|
+
#manifest;
|
|
11
7
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* `BaseApp` passes itself so states resolve that app's manifest ahead of
|
|
9
|
+
* the ambient one; generated builds construct the handler with no
|
|
10
|
+
* arguments and use the ambient manifest.
|
|
14
11
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const app = Reflect.get(request, appSymbol);
|
|
18
|
-
if (!app) {
|
|
19
|
-
throw new Error("No fetch handler provided.");
|
|
20
|
-
}
|
|
21
|
-
this.#app = app;
|
|
22
|
-
this.#handler = new AstroHandler(app);
|
|
23
|
-
}
|
|
24
|
-
const state = new FetchState(this.#app.pipeline, request, options);
|
|
25
|
-
return this.#handler.handle(state);
|
|
12
|
+
constructor(app) {
|
|
13
|
+
this.#manifest = app?.manifest;
|
|
26
14
|
}
|
|
27
15
|
fetch = (request) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new Error("No fetch handler provided.");
|
|
32
|
-
}
|
|
33
|
-
this.#app = app;
|
|
34
|
-
this.#handler = new AstroHandler(app);
|
|
35
|
-
}
|
|
36
|
-
const state = new FetchState(this.#app.pipeline, request);
|
|
37
|
-
if (!this.#handler) {
|
|
38
|
-
throw new Error("No fetch handler provided.");
|
|
39
|
-
}
|
|
40
|
-
return this.#handler.handle(state);
|
|
16
|
+
const options = getRenderOptions(request);
|
|
17
|
+
const manifest = this.#manifest ?? getAmbientManifest();
|
|
18
|
+
return handleRequest(new FetchState(manifest, request, options));
|
|
41
19
|
};
|
|
42
20
|
}
|
|
43
21
|
export {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SSRManifest } from '../app/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bit flags for features that handler functions register as "used" when a
|
|
4
|
+
* custom `src/fetch.ts` fetch handler is in play. After the first request
|
|
5
|
+
* (dev) or at runtime (prod SSR), we compare against the manifest to warn
|
|
6
|
+
* about features the user configured but forgot to include in their custom
|
|
7
|
+
* fetch handler.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FetchFeatures: {
|
|
10
|
+
readonly redirects: number;
|
|
11
|
+
readonly sessions: number;
|
|
12
|
+
readonly actions: number;
|
|
13
|
+
readonly middleware: number;
|
|
14
|
+
readonly i18n: number;
|
|
15
|
+
readonly cache: number;
|
|
16
|
+
};
|
|
17
|
+
/** All feature bits ORed together. Keep next to `FetchFeatures` so
|
|
18
|
+
* new flags are hard to forget. */
|
|
19
|
+
export declare const ALL_FETCH_FEATURES: number;
|
|
20
|
+
/** ORs a feature bit into the manifest's used-features bitmask. */
|
|
21
|
+
export declare function markFeatureUsed(manifest: SSRManifest, feature: number): void;
|
|
22
|
+
/** The used-features bitmask for a manifest; `0` when nothing was marked. */
|
|
23
|
+
export declare function getUsedFeatures(manifest: SSRManifest): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const FetchFeatures = {
|
|
2
|
+
redirects: 1 << 0,
|
|
3
|
+
sessions: 1 << 1,
|
|
4
|
+
actions: 1 << 2,
|
|
5
|
+
middleware: 1 << 3,
|
|
6
|
+
i18n: 1 << 4,
|
|
7
|
+
cache: 1 << 5
|
|
8
|
+
};
|
|
9
|
+
const ALL_FETCH_FEATURES = FetchFeatures.redirects | FetchFeatures.sessions | FetchFeatures.actions | FetchFeatures.middleware | FetchFeatures.i18n | FetchFeatures.cache;
|
|
10
|
+
const usedFeatures = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
function markFeatureUsed(manifest, feature) {
|
|
12
|
+
const entry = usedFeatures.get(manifest);
|
|
13
|
+
if (entry) {
|
|
14
|
+
entry.bits |= feature;
|
|
15
|
+
} else {
|
|
16
|
+
usedFeatures.set(manifest, { bits: feature });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function getUsedFeatures(manifest) {
|
|
20
|
+
return usedFeatures.get(manifest)?.bits ?? 0;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
ALL_FETCH_FEATURES,
|
|
24
|
+
FetchFeatures,
|
|
25
|
+
getUsedFeatures,
|
|
26
|
+
markFeatureUsed
|
|
27
|
+
};
|
|
@@ -4,8 +4,33 @@ import type { Params, Props, RewritePayload } from '../../types/public/common.js
|
|
|
4
4
|
import type { APIContext, AstroGlobal } from '../../types/public/context.js';
|
|
5
5
|
import type { RouteData, SSRResult } from '../../types/public/internal.js';
|
|
6
6
|
import { AstroCookies } from '../cookies/index.js';
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
7
|
+
import type { RenderErrorOptions, ResolvedRenderOptions } from '../app/base.js';
|
|
8
|
+
import type { SSRManifest } from '../app/types.js';
|
|
9
|
+
import { type RequestLogPayload } from '../environment/index.js';
|
|
10
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
11
|
+
/**
|
|
12
|
+
* Per-render facade inputs passed by `BaseApp.render`'s fast path to the
|
|
13
|
+
* internal `FetchState` constructor and stored as plain state fields.
|
|
14
|
+
*
|
|
15
|
+
* MEMBERSHIP CLAMP: frozen at `{ streaming?, renderError?, logRequest? }`.
|
|
16
|
+
* Any addition must be facade-INSTANCE behavior — something a public
|
|
17
|
+
* overridable/reassignable method dispatches — never static or per-manifest
|
|
18
|
+
* data. This type is never exported from a public entrypoint;
|
|
19
|
+
* only `BaseApp.render` constructs it; only the `FetchState` constructor
|
|
20
|
+
* consumes it; it is never stored on a request, in a registry, or passed to
|
|
21
|
+
* any other function.
|
|
22
|
+
*/
|
|
23
|
+
export interface FacadeHooks {
|
|
24
|
+
/** Overrides the environment's `defaultStreaming` for this render. */
|
|
25
|
+
streaming?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Late-bound `app.renderError` dispatch for deep chain-internal error
|
|
28
|
+
* reroutes (preserves cloudflare's instance-property reassignment).
|
|
29
|
+
*/
|
|
30
|
+
renderError?: (request: Request, options: RenderErrorOptions) => Promise<Response>;
|
|
31
|
+
/** Late-bound `app.logThisRequest` dispatch (dev request lines). */
|
|
32
|
+
logRequest?: (payload: RequestLogPayload) => void;
|
|
33
|
+
}
|
|
9
34
|
/**
|
|
10
35
|
* The public contract of {@link FetchState} exposed to user-land code
|
|
11
36
|
* (custom fetch handlers, Hono middleware, etc.).
|
|
@@ -65,7 +90,27 @@ export declare function getFetchStateFromAPIContext(context: APIContext): FetchS
|
|
|
65
90
|
*/
|
|
66
91
|
export declare class FetchState implements AstroFetchState {
|
|
67
92
|
#private;
|
|
68
|
-
|
|
93
|
+
/** The manifest — the single ambient source of static, build-time data. */
|
|
94
|
+
manifest: SSRManifest;
|
|
95
|
+
/** The manifest's identity-stable logger, captured once at construction. */
|
|
96
|
+
logger: AstroLogger;
|
|
97
|
+
/**
|
|
98
|
+
* Whether page renders stream. From the facade hooks on the fast path,
|
|
99
|
+
* else the environment's default.
|
|
100
|
+
*/
|
|
101
|
+
streaming: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Internal facade hook: late-bound `app.renderError` dispatch. Undefined on
|
|
104
|
+
* bare and custom-handler paths — those fall through to the environment's
|
|
105
|
+
* error strategy (`renderErrorPage`).
|
|
106
|
+
*/
|
|
107
|
+
renderError: ((request: Request, options: RenderErrorOptions) => Promise<Response>) | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Internal facade hook: late-bound `app.logThisRequest` dispatch. Undefined
|
|
110
|
+
* on bare and custom-handler paths — those fall through to the
|
|
111
|
+
* environment's `logRequest` behavior.
|
|
112
|
+
*/
|
|
113
|
+
logRequest: ((payload: RequestLogPayload) => void) | undefined;
|
|
69
114
|
/**
|
|
70
115
|
* The request to render. Mutated during rewrites so subsequent renders
|
|
71
116
|
* see the rewritten URL.
|
|
@@ -75,7 +120,7 @@ export declare class FetchState implements AstroFetchState {
|
|
|
75
120
|
/**
|
|
76
121
|
* The pathname to use for routing and rendering. Starts out as the raw,
|
|
77
122
|
* base-stripped, decoded pathname from the request. May be further
|
|
78
|
-
* normalized by `
|
|
123
|
+
* normalized by `handleRequest` after routeData is known (in dev, when
|
|
79
124
|
* the matched route has no `.html` extension, `.html` / `/index.html`
|
|
80
125
|
* suffixes are stripped).
|
|
81
126
|
*/
|
|
@@ -102,7 +147,7 @@ export declare class FetchState implements AstroFetchState {
|
|
|
102
147
|
response: Response | undefined;
|
|
103
148
|
/**
|
|
104
149
|
* Default HTTP status for the rendered response. Callers override
|
|
105
|
-
* before rendering runs (e.g. `
|
|
150
|
+
* before rendering runs (e.g. `handleRequest` sets this from
|
|
106
151
|
* `BaseApp.getDefaultStatusCode`; error handlers set `404` / `500`).
|
|
107
152
|
*/
|
|
108
153
|
status: number;
|
|
@@ -150,9 +195,9 @@ export declare class FetchState implements AstroFetchState {
|
|
|
150
195
|
result: SSRResult | undefined;
|
|
151
196
|
/** Initial props (from container/error handler). */
|
|
152
197
|
initialProps: Props;
|
|
153
|
-
constructor(
|
|
198
|
+
constructor(manifest: SSRManifest, request: Request, options?: ResolvedRenderOptions, hooks?: FacadeHooks);
|
|
154
199
|
/**
|
|
155
|
-
* Triggers a rewrite. Delegates to the
|
|
200
|
+
* Triggers a rewrite. Delegates to the rewrites handler module.
|
|
156
201
|
*/
|
|
157
202
|
rewrite(payload: RewritePayload): Promise<Response>;
|
|
158
203
|
/**
|