@timber-js/app 0.2.0-alpha.146 → 0.2.0-alpha.148
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/_chunks/{actions-OIZ8siQu.js → actions-a0RczDnB.js} +8 -34
- package/dist/_chunks/{actions-OIZ8siQu.js.map → actions-a0RczDnB.js.map} +1 -1
- package/dist/_chunks/cache-api-Co-yI-gP.js +424 -0
- package/dist/_chunks/cache-api-Co-yI-gP.js.map +1 -0
- package/dist/_chunks/{metadata-routes-BjepjefT.js → canonicalize-P41GR6tY.js} +65 -2
- package/dist/_chunks/canonicalize-P41GR6tY.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-D2IpXicg.js → cli-schema-sync-DJDdyEae.js} +157 -313
- package/dist/_chunks/cli-schema-sync-DJDdyEae.js.map +1 -0
- package/dist/_chunks/cli-schema-sync-D_IhHEUW.js +2 -0
- package/dist/_chunks/{define-DMVhsipD.js → define-Bssfp6ot.js} +3 -33
- package/dist/_chunks/define-Bssfp6ot.js.map +1 -0
- package/dist/_chunks/{define-C3RvHQPK.js → define-CFmvb4Bt.js} +15 -7
- package/dist/_chunks/define-CFmvb4Bt.js.map +1 -0
- package/dist/_chunks/{href-validation-DyZIzfMJ.js → href-validation-FiA_rToW.js} +2 -1
- package/dist/_chunks/{href-validation-DyZIzfMJ.js.map → href-validation-FiA_rToW.js.map} +1 -1
- package/dist/_chunks/{tracing-M_zKubhk.js → logger-CM0clugc.js} +394 -107
- package/dist/_chunks/logger-CM0clugc.js.map +1 -0
- package/dist/_chunks/navigation-root-bUDZLw74.js.map +1 -1
- package/dist/_chunks/plugin-context-DurqFBuY.js +2 -0
- package/dist/_chunks/plugin-context-GfDWsdd2.js +268 -0
- package/dist/_chunks/plugin-context-GfDWsdd2.js.map +1 -0
- package/dist/_chunks/{resolve-schema-Dj8tQloi.js → resolve-schema-3iUvBV5T.js} +3 -30
- package/dist/_chunks/resolve-schema-3iUvBV5T.js.map +1 -0
- package/dist/_chunks/{schema-bridge-DK_89h8O.js → schema-bridge-BY3QLBL7.js} +35 -2
- package/dist/_chunks/schema-bridge-BY3QLBL7.js.map +1 -0
- package/dist/_chunks/tree-match-D2l830j2.js +102 -0
- package/dist/_chunks/tree-match-D2l830j2.js.map +1 -0
- package/dist/_chunks/use-segment-params-D1CzlgBo.js.map +1 -1
- package/dist/_chunks/{walkers-7FBPM-hX.js → walkers-DvWDj453.js} +154 -88
- package/dist/_chunks/walkers-DvWDj453.js.map +1 -0
- package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +36 -14
- package/dist/adapters/cloudflare-kv-cache.js.map +1 -1
- package/dist/adapters/compress-module.d.ts +5 -4
- package/dist/adapters/compress-module.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts +1 -3
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +14 -134
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/cache/cache-api.d.ts.map +1 -1
- package/dist/cache/index.d.ts +3 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +20 -235
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/invalidation-epoch.d.ts +43 -0
- package/dist/cache/invalidation-epoch.d.ts.map +1 -0
- package/dist/cache/redis-handler.d.ts +13 -0
- package/dist/cache/redis-handler.d.ts.map +1 -1
- package/dist/cache/timber-cache.d.ts +17 -9
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cli-schema-sync.d.ts +21 -1
- package/dist/cli-schema-sync.d.ts.map +1 -1
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +26 -31
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-entry/hmr.d.ts.map +1 -1
- package/dist/client/browser-entry/hydrate.d.ts.map +1 -1
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +13 -4
- package/dist/client/error-boundary.js.map +1 -1
- package/dist/client/error-reconstituter.d.ts +8 -1
- package/dist/client/error-reconstituter.d.ts.map +1 -1
- package/dist/client/history.d.ts +10 -17
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +30 -33
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-api.d.ts +9 -2
- package/dist/client/navigation-api.d.ts.map +1 -1
- package/dist/client/navigation-context.d.ts +0 -11
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/navigation-root.d.ts +0 -5
- package/dist/client/navigation-root.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/use-search-params.d.ts +10 -5
- package/dist/client/use-search-params.d.ts.map +1 -1
- package/dist/codec.js +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +2 -4
- package/dist/cookies/index.js.map +1 -1
- package/dist/dev-tools/dev-page-shell.d.ts +1 -0
- package/dist/dev-tools/dev-page-shell.d.ts.map +1 -1
- package/dist/dev-tools/hydration-overlay.d.ts +11 -0
- package/dist/dev-tools/hydration-overlay.d.ts.map +1 -0
- package/dist/dev-tools/index.d.ts +1 -2
- package/dist/dev-tools/index.d.ts.map +1 -1
- package/dist/fonts/ast-walk.d.ts +68 -0
- package/dist/fonts/ast-walk.d.ts.map +1 -0
- package/dist/fonts/ast.d.ts +23 -11
- package/dist/fonts/ast.d.ts.map +1 -1
- package/dist/fonts/bundle.d.ts +3 -1
- package/dist/fonts/bundle.d.ts.map +1 -1
- package/dist/fonts/dev-middleware.d.ts +1 -1
- package/dist/fonts/dev-middleware.d.ts.map +1 -1
- package/dist/fonts/fallbacks.d.ts +0 -7
- package/dist/fonts/fallbacks.d.ts.map +1 -1
- package/dist/fonts/google.d.ts +4 -2
- package/dist/fonts/google.d.ts.map +1 -1
- package/dist/fonts/local.d.ts +3 -3
- package/dist/fonts/local.d.ts.map +1 -1
- package/dist/fonts/paths.d.ts +43 -0
- package/dist/fonts/paths.d.ts.map +1 -0
- package/dist/fonts/pipeline.d.ts +7 -21
- package/dist/fonts/pipeline.d.ts.map +1 -1
- package/dist/fonts/transform.d.ts.map +1 -1
- package/dist/fonts/virtual-modules.d.ts +1 -18
- package/dist/fonts/virtual-modules.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +609 -406
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +1 -1
- package/dist/params/resolve-schema.d.ts.map +1 -1
- package/dist/plugin-context.d.ts +28 -5
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/cache.d.ts +13 -5
- package/dist/plugins/cache.d.ts.map +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts +1 -2
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/routing/codegen-types.d.ts +4 -0
- package/dist/routing/codegen-types.d.ts.map +1 -1
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/file-cache.d.ts +8 -0
- package/dist/routing/file-cache.d.ts.map +1 -0
- package/dist/routing/index.js +2 -2
- package/dist/routing/interception.d.ts +0 -5
- package/dist/routing/interception.d.ts.map +1 -1
- package/dist/routing/manifest-codegen.d.ts +32 -0
- package/dist/routing/manifest-codegen.d.ts.map +1 -0
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/schema-bridge.d.ts +15 -0
- package/dist/schema-bridge.d.ts.map +1 -1
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.js +7 -3
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/wrappers.d.ts.map +1 -1
- package/dist/segment-params/define.d.ts.map +1 -1
- package/dist/segment-params/index.js +1 -1
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/actions.d.ts +0 -14
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +0 -29
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +10 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts +27 -2
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/deny-renderer.d.ts +1 -1
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/html-injector-core.d.ts +8 -0
- package/dist/server/html-injector-core.d.ts.map +1 -1
- package/dist/server/html-injectors.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.d.ts +1 -5
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +238 -349
- package/dist/server/internal.js.map +1 -1
- package/dist/server/node-stream-transforms.d.ts +0 -11
- package/dist/server/node-stream-transforms.d.ts.map +1 -1
- package/dist/server/render-utils.d.ts +25 -0
- package/dist/server/render-utils.d.ts.map +1 -0
- package/dist/server/route-element-builder.d.ts +11 -25
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +2 -18
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/dist/server/status-code-resolver.d.ts +6 -0
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/utils/mdx-file.d.ts +15 -0
- package/dist/server/utils/mdx-file.d.ts.map +1 -0
- package/dist/shared/href-validation.d.ts.map +1 -1
- package/dist/shims/image.d.ts +15 -15
- package/package.json +3 -3
- package/src/adapters/cloudflare-kv-cache.ts +56 -19
- package/src/adapters/compress-module.ts +27 -118
- package/src/adapters/nitro.ts +3 -41
- package/src/adapters/raw-imports.d.ts +5 -0
- package/src/cache/cache-api.ts +9 -1
- package/src/cache/index.ts +5 -2
- package/src/cache/invalidation-epoch.ts +93 -0
- package/src/cache/redis-handler.ts +33 -2
- package/src/cache/timber-cache.ts +109 -53
- package/src/cli-schema-sync.ts +123 -30
- package/src/cli.ts +33 -37
- package/src/client/browser-entry/hmr.ts +0 -11
- package/src/client/browser-entry/hydrate.ts +39 -5
- package/src/client/browser-entry/post-hydration.ts +6 -15
- package/src/client/browser-entry/router-init.ts +98 -3
- package/src/client/error-boundary.tsx +14 -0
- package/src/client/error-reconstituter.tsx +15 -1
- package/src/client/history.ts +10 -24
- package/src/client/navigation-api.ts +14 -9
- package/src/client/navigation-context.ts +1 -21
- package/src/client/navigation-root.tsx +0 -8
- package/src/client/router.ts +18 -8
- package/src/client/rsc-fetch.ts +7 -2
- package/src/client/use-search-params.ts +10 -5
- package/src/config-validation.ts +33 -25
- package/src/cookies/define-cookie.ts +2 -18
- package/src/dev-tools/dev-page-shell.ts +6 -2
- package/src/dev-tools/hydration-overlay.ts +158 -0
- package/src/dev-tools/index.ts +3 -16
- package/src/fonts/ast-walk.ts +235 -0
- package/src/fonts/ast.ts +91 -249
- package/src/fonts/bundle.ts +16 -9
- package/src/fonts/dev-middleware.ts +16 -5
- package/src/fonts/fallbacks.ts +0 -23
- package/src/fonts/google.ts +7 -3
- package/src/fonts/local.ts +7 -6
- package/src/fonts/paths.ts +58 -0
- package/src/fonts/pipeline.ts +27 -48
- package/src/fonts/transform.ts +27 -0
- package/src/fonts/virtual-modules.ts +1 -57
- package/src/index.ts +5 -11
- package/src/params/resolve-schema.ts +2 -34
- package/src/plugin-context.ts +95 -17
- package/src/plugins/cache.ts +64 -17
- package/src/plugins/dev-server.ts +61 -9
- package/src/plugins/fonts.ts +21 -6
- package/src/plugins/routing.ts +5 -348
- package/src/routing/codegen-types.ts +4 -0
- package/src/routing/codegen.ts +66 -8
- package/src/routing/convention-lint.ts +4 -3
- package/src/routing/file-cache.ts +23 -0
- package/src/routing/interception.ts +2 -21
- package/src/routing/manifest-codegen.ts +290 -0
- package/src/routing/scanner.ts +85 -80
- package/src/routing/schema-validation.ts +2 -2
- package/src/schema-bridge.ts +63 -2
- package/src/search-params/define.ts +34 -2
- package/src/search-params/wrappers.ts +21 -3
- package/src/segment-params/define.ts +2 -62
- package/src/server/access-gate.tsx +8 -0
- package/src/server/actions.ts +8 -31
- package/src/server/build-manifest.ts +0 -56
- package/src/server/canonicalize.ts +6 -3
- package/src/server/deny-boundary.ts +106 -13
- package/src/server/deny-renderer.ts +46 -10
- package/src/server/error-boundary-wrapper.ts +1 -14
- package/src/server/html-injector-core.ts +19 -0
- package/src/server/html-injectors.ts +14 -4
- package/src/server/internal.ts +1 -18
- package/src/server/node-stream-transforms.ts +5 -72
- package/src/server/render-utils.ts +31 -0
- package/src/server/route-element-builder.ts +77 -47
- package/src/server/route-matcher.ts +22 -6
- package/src/server/rsc-entry/error-renderer.ts +2 -12
- package/src/server/rsc-entry/helpers.ts +6 -34
- package/src/server/rsc-entry/index.ts +11 -0
- package/src/server/rsc-entry/render-route.ts +7 -9
- package/src/server/rsc-entry/rsc-payload.ts +2 -1
- package/src/server/rsc-entry/ssr-renderer.ts +2 -2
- package/src/server/ssr-render.ts +1 -11
- package/src/server/status-code-resolver.ts +3 -2
- package/src/server/tree-match.ts +15 -5
- package/src/server/utils/mdx-file.ts +22 -0
- package/src/shared/href-validation.ts +8 -0
- package/dist/_chunks/cli-schema-sync-D2IpXicg.js.map +0 -1
- package/dist/_chunks/cli-schema-sync-DH-M8Poy.js +0 -2
- package/dist/_chunks/define-C3RvHQPK.js.map +0 -1
- package/dist/_chunks/define-DMVhsipD.js.map +0 -1
- package/dist/_chunks/handler-store-BVDgyTh7.js +0 -78
- package/dist/_chunks/handler-store-BVDgyTh7.js.map +0 -1
- package/dist/_chunks/logger-Dt-jQaBO.js +0 -291
- package/dist/_chunks/logger-Dt-jQaBO.js.map +0 -1
- package/dist/_chunks/metadata-routes-BjepjefT.js.map +0 -1
- package/dist/_chunks/resolve-schema-Dj8tQloi.js.map +0 -1
- package/dist/_chunks/schema-bridge-DK_89h8O.js.map +0 -1
- package/dist/_chunks/tracing-M_zKubhk.js.map +0 -1
- package/dist/_chunks/walkers-7FBPM-hX.js.map +0 -1
- package/dist/_chunks/warnings-CNPXaypM.js +0 -125
- package/dist/_chunks/warnings-CNPXaypM.js.map +0 -1
- package/dist/client/link-pending-store.d.ts +0 -65
- package/dist/client/link-pending-store.d.ts.map +0 -1
- package/dist/client/nav-link-store.d.ts +0 -27
- package/dist/client/nav-link-store.d.ts.map +0 -1
- package/dist/dev-tools/warnings.d.ts +0 -109
- package/dist/dev-tools/warnings.d.ts.map +0 -1
- package/dist/server/flush.d.ts +0 -74
- package/dist/server/flush.d.ts.map +0 -1
- package/src/client/link-pending-store.ts +0 -116
- package/src/client/nav-link-store.ts +0 -37
- package/src/dev-tools/warnings.ts +0 -238
- package/src/server/flush.ts +0 -183
package/dist/server/internal.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as warnRedirectInSuspense, c as warnSuspenseWrappingChildren, i as warnRedirectInAccess, n as setViteServer, o as warnSlowSlotWithoutSuspense, r as warnDenyInSuspense, s as warnStaticRequestApi, t as WarningId } from "../_chunks/warnings-CNPXaypM.js";
|
|
3
|
-
import { i as getMetadataRouteServePath, n as classifyMetadataRoute, r as getMetadataRouteAutoLink, t as METADATA_ROUTE_CONVENTIONS } from "../_chunks/metadata-routes-BjepjefT.js";
|
|
1
|
+
import { a as classifyMetadataRoute, i as METADATA_ROUTE_CONVENTIONS, o as getMetadataRouteAutoLink, r as canonicalize, s as getMetadataRouteServePath } from "../_chunks/canonicalize-P41GR6tY.js";
|
|
4
2
|
import { n as classifyUrlSegment } from "../_chunks/segment-classify-CDDRVKs7.js";
|
|
5
|
-
import { a as logProxyError, c as logRequestReceived, d as logSwrRefetchFailed, f as logWaitUntilRejected, h as swallow, i as logMiddlewareShortCircuit, l as logRouteError, m as setLogger, n as logCacheMiss, o as logRenderError, p as logWaitUntilUnsupported, r as logMiddlewareError, s as logRequestCompleted, t as getLogger, u as logSlowRequest } from "../_chunks/logger-
|
|
6
|
-
import { C as
|
|
3
|
+
import { A as requestContextAls, C as getTraceId, D as withSpan, E as setSpanAttribute, M as timingAls, O as earlyHintsSenderAls, T as runWithTraceId, a as logProxyError, b as generateTraceId, c as logRequestReceived, d as logSwrRefetchFailed, f as logWaitUntilRejected, g as isDebug, h as swallow, i as logMiddlewareShortCircuit, l as logRouteError, m as setLogger, n as logCacheMiss, o as logRenderError, p as logWaitUntilUnsupported, r as logMiddlewareError, s as logRequestCompleted, t as getLogger, u as logSlowRequest, w as replaceTraceId, x as getOtelTraceId } from "../_chunks/logger-CM0clugc.js";
|
|
4
|
+
import { C as setSegmentParams, E as getSetCookieHeaders, S as setMutableCookieContext, _ as getSearchParams, b as runWithRequestContext, c as RenderError, h as getHeader, i as coerce, m as applyRequestHeaderOverlay, o as DenySignal, s as RedirectSignal, t as executeAction, v as getSegmentParams, w as getCookie, x as setMatchedSegmentPath, y as markResponseFlushed } from "../_chunks/actions-a0RczDnB.js";
|
|
7
5
|
import "../client/error-boundary.js";
|
|
8
|
-
import { n as toBracketKey } from "../_chunks/resolve-schema-
|
|
6
|
+
import { n as toBracketKey } from "../_chunks/resolve-schema-3iUvBV5T.js";
|
|
9
7
|
import "../_chunks/segment-context-ZDnXDkbz.js";
|
|
10
8
|
import { readFile } from "node:fs/promises";
|
|
11
9
|
import "node:crypto";
|
|
@@ -291,66 +289,6 @@ async function fireOnRequestError(error, req, phase) {
|
|
|
291
289
|
});
|
|
292
290
|
}
|
|
293
291
|
//#endregion
|
|
294
|
-
//#region src/server/canonicalize.ts
|
|
295
|
-
/**
|
|
296
|
-
* Encoded separators that produce a 400 rejection.
|
|
297
|
-
* %2f (/) and %5c (\) cause path-confusion attacks.
|
|
298
|
-
*/
|
|
299
|
-
var ENCODED_SEPARATOR_RE = /%2f|%5c/i;
|
|
300
|
-
/** Null byte — rejected. */
|
|
301
|
-
var NULL_BYTE_RE = /%00/i;
|
|
302
|
-
/**
|
|
303
|
-
* Canonicalize a URL pathname.
|
|
304
|
-
*
|
|
305
|
-
* 1. Reject encoded separators (%2f, %5c) and null bytes (%00)
|
|
306
|
-
* 2. Single percent-decode
|
|
307
|
-
* 3. Collapse // → /
|
|
308
|
-
* 4. Resolve .. segments (reject if escaping root)
|
|
309
|
-
* 5. Strip trailing slash (except root "/")
|
|
310
|
-
*
|
|
311
|
-
* @param rawPathname - The raw pathname from the request URL (percent-encoded)
|
|
312
|
-
* @param stripTrailingSlash - Whether to strip trailing slashes. Default: true.
|
|
313
|
-
*/
|
|
314
|
-
function canonicalize(rawPathname, stripTrailingSlash = true) {
|
|
315
|
-
if (ENCODED_SEPARATOR_RE.test(rawPathname)) return {
|
|
316
|
-
ok: false,
|
|
317
|
-
status: 400
|
|
318
|
-
};
|
|
319
|
-
if (NULL_BYTE_RE.test(rawPathname)) return {
|
|
320
|
-
ok: false,
|
|
321
|
-
status: 400
|
|
322
|
-
};
|
|
323
|
-
let decoded;
|
|
324
|
-
try {
|
|
325
|
-
decoded = decodeURIComponent(rawPathname);
|
|
326
|
-
} catch {
|
|
327
|
-
return {
|
|
328
|
-
ok: false,
|
|
329
|
-
status: 400
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
if (decoded.includes("\0")) return {
|
|
333
|
-
ok: false,
|
|
334
|
-
status: 400
|
|
335
|
-
};
|
|
336
|
-
let pathname = decoded.replace(/\/\/+/g, "/");
|
|
337
|
-
const segments = pathname.split("/");
|
|
338
|
-
const resolved = [];
|
|
339
|
-
for (const seg of segments) if (seg === "..") {
|
|
340
|
-
if (resolved.length <= 1) return {
|
|
341
|
-
ok: false,
|
|
342
|
-
status: 400
|
|
343
|
-
};
|
|
344
|
-
resolved.pop();
|
|
345
|
-
} else if (seg !== ".") resolved.push(seg);
|
|
346
|
-
pathname = resolved.join("/") || "/";
|
|
347
|
-
if (stripTrailingSlash && pathname.length > 1 && pathname.endsWith("/")) pathname = pathname.slice(0, -1);
|
|
348
|
-
return {
|
|
349
|
-
ok: true,
|
|
350
|
-
pathname
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
//#endregion
|
|
354
292
|
//#region src/server/proxy.ts
|
|
355
293
|
/**
|
|
356
294
|
* Run the proxy pipeline.
|
|
@@ -1119,6 +1057,39 @@ function resolveMetadataUrls(metadata) {
|
|
|
1119
1057
|
return result;
|
|
1120
1058
|
}
|
|
1121
1059
|
//#endregion
|
|
1060
|
+
//#region src/client/error-reconstituter.tsx
|
|
1061
|
+
/**
|
|
1062
|
+
* Reconstitutes a SerializableError into a real Error instance before
|
|
1063
|
+
* passing to the user's error component.
|
|
1064
|
+
*
|
|
1065
|
+
* TSX error pages are 'use client' components that receive { error: Error, digest, reset }.
|
|
1066
|
+
* Error objects are not RSC-serializable (React Flight throws "Only plain objects
|
|
1067
|
+
* can be passed to Client Components"). This wrapper receives the error as a plain
|
|
1068
|
+
* SerializableError object, reconstitutes a real Error instance, and passes it
|
|
1069
|
+
* to the user's error component — ensuring error instanceof Error works correctly.
|
|
1070
|
+
*
|
|
1071
|
+
* See design/spike-TIM-565-unify-error-pages.md §"Edge Case B"
|
|
1072
|
+
* See design/10-error-handling.md §"RSC → SSR for Error Pages via SerializableError"
|
|
1073
|
+
*/
|
|
1074
|
+
/**
|
|
1075
|
+
* Reconstitute a SerializableError into a real Error instance and render
|
|
1076
|
+
* the user's error component with the proper props.
|
|
1077
|
+
*/
|
|
1078
|
+
function ErrorReconstituter({ error: serialized, digest, reset, component, status, dangerouslyPassData }) {
|
|
1079
|
+
return createElement(component, {
|
|
1080
|
+
error: Object.assign(new Error(serialized.message), {
|
|
1081
|
+
name: serialized.name,
|
|
1082
|
+
...serialized.stack != null ? { stack: serialized.stack } : {}
|
|
1083
|
+
}),
|
|
1084
|
+
digest,
|
|
1085
|
+
reset,
|
|
1086
|
+
...status != null ? {
|
|
1087
|
+
status,
|
|
1088
|
+
dangerouslyPassData
|
|
1089
|
+
} : {}
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
//#endregion
|
|
1122
1093
|
//#region src/server/safe-load.ts
|
|
1123
1094
|
/**
|
|
1124
1095
|
* Custom error class for module load failures.
|
|
@@ -1160,6 +1131,165 @@ async function loadModule(loader) {
|
|
|
1160
1131
|
throw new ModuleLoadError(loader.filePath, error);
|
|
1161
1132
|
}
|
|
1162
1133
|
}
|
|
1134
|
+
/** Reverse index: status code → legacy file name. Built once at module load. */
|
|
1135
|
+
var STATUS_TO_LEGACY_FILE = Object.fromEntries(Object.entries({
|
|
1136
|
+
"not-found": 404,
|
|
1137
|
+
"forbidden": 403,
|
|
1138
|
+
"unauthorized": 401
|
|
1139
|
+
}).map(([name, status]) => [status, name]));
|
|
1140
|
+
/**
|
|
1141
|
+
* Look up `{statusStr}` then `{categoryKey}` (e.g. "4xx" / "5xx") in a
|
|
1142
|
+
* status-file group on a single segment. Shared by all three fallback
|
|
1143
|
+
* chains — the only structural difference between component 4xx,
|
|
1144
|
+
* component 5xx, and JSON resolution is *which* group is searched and
|
|
1145
|
+
* how the per-segment loop is layered around it.
|
|
1146
|
+
*/
|
|
1147
|
+
function lookupInGroup(group, statusStr, categoryKey, segmentIndex, status) {
|
|
1148
|
+
if (!group) return null;
|
|
1149
|
+
const exact = group[statusStr];
|
|
1150
|
+
if (exact) return {
|
|
1151
|
+
file: exact,
|
|
1152
|
+
status,
|
|
1153
|
+
kind: "exact",
|
|
1154
|
+
segmentIndex
|
|
1155
|
+
};
|
|
1156
|
+
const category = group[categoryKey];
|
|
1157
|
+
if (category) return {
|
|
1158
|
+
file: category,
|
|
1159
|
+
status,
|
|
1160
|
+
kind: "category",
|
|
1161
|
+
segmentIndex
|
|
1162
|
+
};
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Look up the legacy convention file (`not-found.tsx` / `forbidden.tsx` /
|
|
1167
|
+
* `unauthorized.tsx`) for `status` on a single segment. Returns null if
|
|
1168
|
+
* `status` has no legacy mapping or the file isn't present.
|
|
1169
|
+
*/
|
|
1170
|
+
function lookupLegacy(group, status, segmentIndex) {
|
|
1171
|
+
if (!group) return null;
|
|
1172
|
+
const name = STATUS_TO_LEGACY_FILE[status];
|
|
1173
|
+
if (!name) return null;
|
|
1174
|
+
const file = group[name];
|
|
1175
|
+
return file ? {
|
|
1176
|
+
file,
|
|
1177
|
+
status,
|
|
1178
|
+
kind: "legacy",
|
|
1179
|
+
segmentIndex
|
|
1180
|
+
} : null;
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Resolve the status-code file to render for a given HTTP status code.
|
|
1184
|
+
*
|
|
1185
|
+
* Walks the segment chain from leaf to root following the fallback chain
|
|
1186
|
+
* defined in design/10-error-handling.md. Returns null if no file is found
|
|
1187
|
+
* (caller should render the framework default).
|
|
1188
|
+
*
|
|
1189
|
+
* @param status - The HTTP status code (4xx or 5xx).
|
|
1190
|
+
* @param segments - The matched segment chain from root (index 0) to leaf (last).
|
|
1191
|
+
* @param format - The response format family ('component' or 'json'). Defaults to 'component'.
|
|
1192
|
+
*/
|
|
1193
|
+
function resolveStatusFile(status, segments, format = "component") {
|
|
1194
|
+
if (status < 400 || status > 599) return null;
|
|
1195
|
+
if (format === "json") return resolveJson(status, segments);
|
|
1196
|
+
if (status <= 499) return resolve4xx(status, segments);
|
|
1197
|
+
return resolve5xx(status, segments);
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* 4xx component fallback chain — three separate full passes leaf→root.
|
|
1201
|
+
*
|
|
1202
|
+
* The passes must be separate (not interleaved per-segment) so that a
|
|
1203
|
+
* root-level `404.tsx` beats a leaf-level `error.tsx`. The 5xx chain
|
|
1204
|
+
* inverts this and is per-segment: a leaf's `error.tsx` beats a root's
|
|
1205
|
+
* `5xx.tsx`. This asymmetry is the only reason these two functions exist
|
|
1206
|
+
* separately.
|
|
1207
|
+
*
|
|
1208
|
+
* Pass 1 — {status}.tsx → 4xx.tsx (statusFiles)
|
|
1209
|
+
* Pass 2 — not-found / forbidden / unauthorized (legacyStatusFiles)
|
|
1210
|
+
* Pass 3 — error.tsx (error)
|
|
1211
|
+
*/
|
|
1212
|
+
function resolve4xx(status, segments) {
|
|
1213
|
+
const statusStr = String(status);
|
|
1214
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1215
|
+
const r = lookupInGroup(segments[i].statusFiles, statusStr, "4xx", i, status);
|
|
1216
|
+
if (r) return r;
|
|
1217
|
+
}
|
|
1218
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1219
|
+
const r = lookupLegacy(segments[i].legacyStatusFiles, status, i);
|
|
1220
|
+
if (r) return r;
|
|
1221
|
+
}
|
|
1222
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1223
|
+
const errorFile = segments[i].error;
|
|
1224
|
+
if (errorFile) return {
|
|
1225
|
+
file: errorFile,
|
|
1226
|
+
status,
|
|
1227
|
+
kind: "error",
|
|
1228
|
+
segmentIndex: i
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* 5xx component fallback chain — single pass, per-segment leaf→root.
|
|
1235
|
+
*
|
|
1236
|
+
* At each segment: {status}.tsx → 5xx.tsx → error.tsx. A leaf's
|
|
1237
|
+
* `error.tsx` therefore beats a root's `5xx.tsx`, which is the
|
|
1238
|
+
* intentional inverse of the 4xx chain.
|
|
1239
|
+
*/
|
|
1240
|
+
function resolve5xx(status, segments) {
|
|
1241
|
+
const statusStr = String(status);
|
|
1242
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1243
|
+
const segment = segments[i];
|
|
1244
|
+
const r = lookupInGroup(segment.statusFiles, statusStr, "5xx", i, status);
|
|
1245
|
+
if (r) return r;
|
|
1246
|
+
if (segment.error) return {
|
|
1247
|
+
file: segment.error,
|
|
1248
|
+
status,
|
|
1249
|
+
kind: "error",
|
|
1250
|
+
segmentIndex: i
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
return null;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* JSON fallback chain (for both 4xx and 5xx) — single pass leaf→root.
|
|
1257
|
+
*
|
|
1258
|
+
* At each segment: {status}.json → {category}.json. No legacy compat,
|
|
1259
|
+
* no error.tsx — the JSON chain terminates at the category catch-all
|
|
1260
|
+
* and the caller falls back to a bare-JSON framework default.
|
|
1261
|
+
*/
|
|
1262
|
+
function resolveJson(status, segments) {
|
|
1263
|
+
const statusStr = String(status);
|
|
1264
|
+
const categoryKey = status >= 500 ? "5xx" : "4xx";
|
|
1265
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1266
|
+
const r = lookupInGroup(segments[i].jsonStatusFiles, statusStr, categoryKey, i, status);
|
|
1267
|
+
if (r) return r;
|
|
1268
|
+
}
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Resolve the denial file for a parallel route slot.
|
|
1273
|
+
*
|
|
1274
|
+
* Slot denial is graceful degradation — no HTTP status on the wire.
|
|
1275
|
+
* Fallback chain: denied.tsx → default.tsx → null.
|
|
1276
|
+
*
|
|
1277
|
+
* @param slotNode - The segment node for the slot (segmentType === 'slot').
|
|
1278
|
+
*/
|
|
1279
|
+
function resolveSlotDenied(slotNode) {
|
|
1280
|
+
const slotName = slotNode.segmentName.replace(/^@/, "");
|
|
1281
|
+
if (slotNode.denied) return {
|
|
1282
|
+
file: slotNode.denied,
|
|
1283
|
+
slotName,
|
|
1284
|
+
kind: "denied"
|
|
1285
|
+
};
|
|
1286
|
+
if (slotNode.default) return {
|
|
1287
|
+
file: slotNode.default,
|
|
1288
|
+
slotName,
|
|
1289
|
+
kind: "default"
|
|
1290
|
+
};
|
|
1291
|
+
return null;
|
|
1292
|
+
}
|
|
1163
1293
|
//#endregion
|
|
1164
1294
|
//#region src/server/deny-boundary.ts
|
|
1165
1295
|
/**
|
|
@@ -1197,28 +1327,45 @@ async function loadModule(loader) {
|
|
|
1197
1327
|
* Returns a React element for the matching component, or null if no match.
|
|
1198
1328
|
*/
|
|
1199
1329
|
function renderMatchingDenyPage(chain, status, data) {
|
|
1200
|
-
const h = createElement;
|
|
1201
1330
|
for (const entry of chain) {
|
|
1202
|
-
if (entry.status === status) return
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
if (entry.status === 400 && status >= 400 && status <= 499) return h(entry.component, {
|
|
1207
|
-
status,
|
|
1208
|
-
dangerouslyPassData: data
|
|
1209
|
-
});
|
|
1210
|
-
if (entry.status === 500 && status >= 500 && status <= 599) return h(entry.component, {
|
|
1211
|
-
status,
|
|
1212
|
-
dangerouslyPassData: data
|
|
1213
|
-
});
|
|
1214
|
-
if (entry.status === null) return h(entry.component, {
|
|
1215
|
-
status,
|
|
1216
|
-
dangerouslyPassData: data
|
|
1217
|
-
});
|
|
1331
|
+
if (entry.status === status) return renderDenyEntry(entry, status, data);
|
|
1332
|
+
if (entry.status === 400 && status >= 400 && status <= 499) return renderDenyEntry(entry, status, data);
|
|
1333
|
+
if (entry.status === 500 && status >= 500 && status <= 599) return renderDenyEntry(entry, status, data);
|
|
1334
|
+
if (entry.status === null) return renderDenyEntry(entry, status, data);
|
|
1218
1335
|
}
|
|
1219
1336
|
return null;
|
|
1220
1337
|
}
|
|
1221
1338
|
/**
|
|
1339
|
+
* Build the element for a matched deny chain entry with the props contract
|
|
1340
|
+
* the file's convention documents:
|
|
1341
|
+
*
|
|
1342
|
+
* - Status-code and legacy files: { status, dangerouslyPassData }
|
|
1343
|
+
* - error.tsx (TSX): { error, digest, reset } via ErrorReconstituter, plus
|
|
1344
|
+
* { status, dangerouslyPassData } for dual-shape implementations. Without
|
|
1345
|
+
* the Error prop, any error.tsx written per the docs (reading
|
|
1346
|
+
* error.message) crashes — turning a clean deny(404) into a 500. TIM-1081.
|
|
1347
|
+
* - error.mdx: plain { status } — server component, static content.
|
|
1348
|
+
*/
|
|
1349
|
+
function renderDenyEntry(entry, status, data) {
|
|
1350
|
+
const h = createElement;
|
|
1351
|
+
if (entry.kind !== "error") return h(entry.component, {
|
|
1352
|
+
status,
|
|
1353
|
+
dangerouslyPassData: data
|
|
1354
|
+
});
|
|
1355
|
+
if (entry.isMdx) return h(entry.component, { status });
|
|
1356
|
+
return h(ErrorReconstituter, {
|
|
1357
|
+
error: {
|
|
1358
|
+
message: `Access denied with status ${status}`,
|
|
1359
|
+
name: "DenySignal"
|
|
1360
|
+
},
|
|
1361
|
+
digest: null,
|
|
1362
|
+
reset: void 0,
|
|
1363
|
+
component: entry.component,
|
|
1364
|
+
status,
|
|
1365
|
+
dangerouslyPassData: data
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1222
1369
|
* Set the deny status in the request context ALS.
|
|
1223
1370
|
* Called from AccessGate / PageDenyBoundary when a DenySignal is caught.
|
|
1224
1371
|
* The pipeline reads this after render to set the HTTP status code.
|
|
@@ -1261,6 +1408,13 @@ function AccessGate(props) {
|
|
|
1261
1408
|
const { accessFn, segmentName, verdict, denyPages, children } = props;
|
|
1262
1409
|
if (verdict !== void 0) {
|
|
1263
1410
|
if (verdict === "pass") return children;
|
|
1411
|
+
if (verdict instanceof DenySignal && denyPages) {
|
|
1412
|
+
const denyElement = renderMatchingDenyPage(denyPages, verdict.status, verdict.data);
|
|
1413
|
+
if (denyElement) {
|
|
1414
|
+
setDenyStatus(verdict.status);
|
|
1415
|
+
return denyElement;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1264
1418
|
throw verdict;
|
|
1265
1419
|
}
|
|
1266
1420
|
return accessGateFallback(accessFn, segmentName, denyPages, children);
|
|
@@ -2589,271 +2743,6 @@ async function wrapWithErrorBoundaries(segment, element, loadModule, createEleme
|
|
|
2589
2743
|
return element;
|
|
2590
2744
|
}
|
|
2591
2745
|
//#endregion
|
|
2592
|
-
//#region src/server/status-code-resolver.ts
|
|
2593
|
-
/** Reverse index: status code → legacy file name. Built once at module load. */
|
|
2594
|
-
var STATUS_TO_LEGACY_FILE = Object.fromEntries(Object.entries({
|
|
2595
|
-
"not-found": 404,
|
|
2596
|
-
"forbidden": 403,
|
|
2597
|
-
"unauthorized": 401
|
|
2598
|
-
}).map(([name, status]) => [status, name]));
|
|
2599
|
-
/**
|
|
2600
|
-
* Look up `{statusStr}` then `{categoryKey}` (e.g. "4xx" / "5xx") in a
|
|
2601
|
-
* status-file group on a single segment. Shared by all three fallback
|
|
2602
|
-
* chains — the only structural difference between component 4xx,
|
|
2603
|
-
* component 5xx, and JSON resolution is *which* group is searched and
|
|
2604
|
-
* how the per-segment loop is layered around it.
|
|
2605
|
-
*/
|
|
2606
|
-
function lookupInGroup(group, statusStr, categoryKey, segmentIndex, status) {
|
|
2607
|
-
if (!group) return null;
|
|
2608
|
-
const exact = group[statusStr];
|
|
2609
|
-
if (exact) return {
|
|
2610
|
-
file: exact,
|
|
2611
|
-
status,
|
|
2612
|
-
kind: "exact",
|
|
2613
|
-
segmentIndex
|
|
2614
|
-
};
|
|
2615
|
-
const category = group[categoryKey];
|
|
2616
|
-
if (category) return {
|
|
2617
|
-
file: category,
|
|
2618
|
-
status,
|
|
2619
|
-
kind: "category",
|
|
2620
|
-
segmentIndex
|
|
2621
|
-
};
|
|
2622
|
-
return null;
|
|
2623
|
-
}
|
|
2624
|
-
/**
|
|
2625
|
-
* Look up the legacy convention file (`not-found.tsx` / `forbidden.tsx` /
|
|
2626
|
-
* `unauthorized.tsx`) for `status` on a single segment. Returns null if
|
|
2627
|
-
* `status` has no legacy mapping or the file isn't present.
|
|
2628
|
-
*/
|
|
2629
|
-
function lookupLegacy(group, status, segmentIndex) {
|
|
2630
|
-
if (!group) return null;
|
|
2631
|
-
const name = STATUS_TO_LEGACY_FILE[status];
|
|
2632
|
-
if (!name) return null;
|
|
2633
|
-
const file = group[name];
|
|
2634
|
-
return file ? {
|
|
2635
|
-
file,
|
|
2636
|
-
status,
|
|
2637
|
-
kind: "legacy",
|
|
2638
|
-
segmentIndex
|
|
2639
|
-
} : null;
|
|
2640
|
-
}
|
|
2641
|
-
/**
|
|
2642
|
-
* Resolve the status-code file to render for a given HTTP status code.
|
|
2643
|
-
*
|
|
2644
|
-
* Walks the segment chain from leaf to root following the fallback chain
|
|
2645
|
-
* defined in design/10-error-handling.md. Returns null if no file is found
|
|
2646
|
-
* (caller should render the framework default).
|
|
2647
|
-
*
|
|
2648
|
-
* @param status - The HTTP status code (4xx or 5xx).
|
|
2649
|
-
* @param segments - The matched segment chain from root (index 0) to leaf (last).
|
|
2650
|
-
* @param format - The response format family ('component' or 'json'). Defaults to 'component'.
|
|
2651
|
-
*/
|
|
2652
|
-
function resolveStatusFile(status, segments, format = "component") {
|
|
2653
|
-
if (status < 400 || status > 599) return null;
|
|
2654
|
-
if (format === "json") return resolveJson(status, segments);
|
|
2655
|
-
if (status <= 499) return resolve4xx(status, segments);
|
|
2656
|
-
return resolve5xx(status, segments);
|
|
2657
|
-
}
|
|
2658
|
-
/**
|
|
2659
|
-
* 4xx component fallback chain — three separate full passes leaf→root.
|
|
2660
|
-
*
|
|
2661
|
-
* The passes must be separate (not interleaved per-segment) so that a
|
|
2662
|
-
* root-level `404.tsx` beats a leaf-level `error.tsx`. The 5xx chain
|
|
2663
|
-
* inverts this and is per-segment: a leaf's `error.tsx` beats a root's
|
|
2664
|
-
* `5xx.tsx`. This asymmetry is the only reason these two functions exist
|
|
2665
|
-
* separately.
|
|
2666
|
-
*
|
|
2667
|
-
* Pass 1 — {status}.tsx → 4xx.tsx (statusFiles)
|
|
2668
|
-
* Pass 2 — not-found / forbidden / unauthorized (legacyStatusFiles)
|
|
2669
|
-
* Pass 3 — error.tsx (error)
|
|
2670
|
-
*/
|
|
2671
|
-
function resolve4xx(status, segments) {
|
|
2672
|
-
const statusStr = String(status);
|
|
2673
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
2674
|
-
const r = lookupInGroup(segments[i].statusFiles, statusStr, "4xx", i, status);
|
|
2675
|
-
if (r) return r;
|
|
2676
|
-
}
|
|
2677
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
2678
|
-
const r = lookupLegacy(segments[i].legacyStatusFiles, status, i);
|
|
2679
|
-
if (r) return r;
|
|
2680
|
-
}
|
|
2681
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
2682
|
-
const errorFile = segments[i].error;
|
|
2683
|
-
if (errorFile) return {
|
|
2684
|
-
file: errorFile,
|
|
2685
|
-
status,
|
|
2686
|
-
kind: "error",
|
|
2687
|
-
segmentIndex: i
|
|
2688
|
-
};
|
|
2689
|
-
}
|
|
2690
|
-
return null;
|
|
2691
|
-
}
|
|
2692
|
-
/**
|
|
2693
|
-
* 5xx component fallback chain — single pass, per-segment leaf→root.
|
|
2694
|
-
*
|
|
2695
|
-
* At each segment: {status}.tsx → 5xx.tsx → error.tsx. A leaf's
|
|
2696
|
-
* `error.tsx` therefore beats a root's `5xx.tsx`, which is the
|
|
2697
|
-
* intentional inverse of the 4xx chain.
|
|
2698
|
-
*/
|
|
2699
|
-
function resolve5xx(status, segments) {
|
|
2700
|
-
const statusStr = String(status);
|
|
2701
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
2702
|
-
const segment = segments[i];
|
|
2703
|
-
const r = lookupInGroup(segment.statusFiles, statusStr, "5xx", i, status);
|
|
2704
|
-
if (r) return r;
|
|
2705
|
-
if (segment.error) return {
|
|
2706
|
-
file: segment.error,
|
|
2707
|
-
status,
|
|
2708
|
-
kind: "error",
|
|
2709
|
-
segmentIndex: i
|
|
2710
|
-
};
|
|
2711
|
-
}
|
|
2712
|
-
return null;
|
|
2713
|
-
}
|
|
2714
|
-
/**
|
|
2715
|
-
* JSON fallback chain (for both 4xx and 5xx) — single pass leaf→root.
|
|
2716
|
-
*
|
|
2717
|
-
* At each segment: {status}.json → {category}.json. No legacy compat,
|
|
2718
|
-
* no error.tsx — the JSON chain terminates at the category catch-all
|
|
2719
|
-
* and the caller falls back to a bare-JSON framework default.
|
|
2720
|
-
*/
|
|
2721
|
-
function resolveJson(status, segments) {
|
|
2722
|
-
const statusStr = String(status);
|
|
2723
|
-
const categoryKey = status >= 500 ? "5xx" : "4xx";
|
|
2724
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
2725
|
-
const r = lookupInGroup(segments[i].jsonStatusFiles, statusStr, categoryKey, i, status);
|
|
2726
|
-
if (r) return r;
|
|
2727
|
-
}
|
|
2728
|
-
return null;
|
|
2729
|
-
}
|
|
2730
|
-
/**
|
|
2731
|
-
* Resolve the denial file for a parallel route slot.
|
|
2732
|
-
*
|
|
2733
|
-
* Slot denial is graceful degradation — no HTTP status on the wire.
|
|
2734
|
-
* Fallback chain: denied.tsx → default.tsx → null.
|
|
2735
|
-
*
|
|
2736
|
-
* @param slotNode - The segment node for the slot (segmentType === 'slot').
|
|
2737
|
-
*/
|
|
2738
|
-
function resolveSlotDenied(slotNode) {
|
|
2739
|
-
const slotName = slotNode.segmentName.replace(/^@/, "");
|
|
2740
|
-
if (slotNode.denied) return {
|
|
2741
|
-
file: slotNode.denied,
|
|
2742
|
-
slotName,
|
|
2743
|
-
kind: "denied"
|
|
2744
|
-
};
|
|
2745
|
-
if (slotNode.default) return {
|
|
2746
|
-
file: slotNode.default,
|
|
2747
|
-
slotName,
|
|
2748
|
-
kind: "default"
|
|
2749
|
-
};
|
|
2750
|
-
return null;
|
|
2751
|
-
}
|
|
2752
|
-
//#endregion
|
|
2753
|
-
//#region src/server/flush.ts
|
|
2754
|
-
/**
|
|
2755
|
-
* Flush controller for timber.js rendering.
|
|
2756
|
-
*
|
|
2757
|
-
* Holds the response until `onShellReady` fires, then commits the HTTP status
|
|
2758
|
-
* code and flushes the shell. Render-phase signals (deny, redirect, unhandled
|
|
2759
|
-
* throws) caught before flush produce correct HTTP status codes.
|
|
2760
|
-
*
|
|
2761
|
-
* See design/02-rendering-pipeline.md §"The Flush Point" and §"The Hold Window"
|
|
2762
|
-
*/
|
|
2763
|
-
/**
|
|
2764
|
-
* Execute a render and hold the response until the shell is ready.
|
|
2765
|
-
*
|
|
2766
|
-
* The flush controller:
|
|
2767
|
-
* 1. Calls the render function to start renderToReadableStream
|
|
2768
|
-
* 2. Waits for shellReady (onShellReady)
|
|
2769
|
-
* 3. If a render-phase signal was thrown (deny, redirect, error), produces
|
|
2770
|
-
* the correct HTTP status code
|
|
2771
|
-
* 4. If the shell rendered successfully, commits the status and streams
|
|
2772
|
-
*
|
|
2773
|
-
* Render-phase signals caught before flush:
|
|
2774
|
-
* - `DenySignal` → HTTP 4xx with appropriate status code
|
|
2775
|
-
* - `RedirectSignal` → HTTP 3xx with Location header
|
|
2776
|
-
* - `RenderError` → HTTP status from error (default 500)
|
|
2777
|
-
* - Unhandled error → HTTP 500
|
|
2778
|
-
*
|
|
2779
|
-
* @param renderFn - Function that starts the React render.
|
|
2780
|
-
* @param options - Flush configuration.
|
|
2781
|
-
* @returns The committed HTTP Response.
|
|
2782
|
-
*/
|
|
2783
|
-
async function flushResponse(renderFn, options = {}) {
|
|
2784
|
-
const { responseHeaders = new Headers(), defaultStatus = 200 } = options;
|
|
2785
|
-
let renderResult;
|
|
2786
|
-
try {
|
|
2787
|
-
renderResult = await renderFn();
|
|
2788
|
-
} catch (error) {
|
|
2789
|
-
return handleSignal(error, responseHeaders);
|
|
2790
|
-
}
|
|
2791
|
-
try {
|
|
2792
|
-
await renderResult.shellReady;
|
|
2793
|
-
} catch (error) {
|
|
2794
|
-
return handleSignal(error, responseHeaders);
|
|
2795
|
-
}
|
|
2796
|
-
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
|
|
2797
|
-
return {
|
|
2798
|
-
response: new Response(renderResult.stream, {
|
|
2799
|
-
status: defaultStatus,
|
|
2800
|
-
headers: responseHeaders
|
|
2801
|
-
}),
|
|
2802
|
-
status: defaultStatus,
|
|
2803
|
-
isRedirect: false,
|
|
2804
|
-
isDenial: false
|
|
2805
|
-
};
|
|
2806
|
-
}
|
|
2807
|
-
/**
|
|
2808
|
-
* Handle a render-phase signal and produce the correct HTTP response.
|
|
2809
|
-
*/
|
|
2810
|
-
function handleSignal(error, responseHeaders) {
|
|
2811
|
-
if (error instanceof RedirectSignal) {
|
|
2812
|
-
responseHeaders.set("Location", error.location);
|
|
2813
|
-
return {
|
|
2814
|
-
response: new Response(null, {
|
|
2815
|
-
status: error.status,
|
|
2816
|
-
headers: responseHeaders
|
|
2817
|
-
}),
|
|
2818
|
-
status: error.status,
|
|
2819
|
-
isRedirect: true,
|
|
2820
|
-
isDenial: false
|
|
2821
|
-
};
|
|
2822
|
-
}
|
|
2823
|
-
if (error instanceof DenySignal) return {
|
|
2824
|
-
response: new Response(null, {
|
|
2825
|
-
status: error.status,
|
|
2826
|
-
headers: responseHeaders
|
|
2827
|
-
}),
|
|
2828
|
-
status: error.status,
|
|
2829
|
-
isRedirect: false,
|
|
2830
|
-
isDenial: true
|
|
2831
|
-
};
|
|
2832
|
-
if (error instanceof RenderError) return {
|
|
2833
|
-
response: new Response(null, {
|
|
2834
|
-
status: error.status,
|
|
2835
|
-
headers: responseHeaders
|
|
2836
|
-
}),
|
|
2837
|
-
status: error.status,
|
|
2838
|
-
isRedirect: false,
|
|
2839
|
-
isDenial: false
|
|
2840
|
-
};
|
|
2841
|
-
logRenderError({
|
|
2842
|
-
method: "",
|
|
2843
|
-
path: "",
|
|
2844
|
-
error
|
|
2845
|
-
});
|
|
2846
|
-
return {
|
|
2847
|
-
response: new Response(null, {
|
|
2848
|
-
status: 500,
|
|
2849
|
-
headers: responseHeaders
|
|
2850
|
-
}),
|
|
2851
|
-
status: 500,
|
|
2852
|
-
isRedirect: false,
|
|
2853
|
-
isDenial: false
|
|
2854
|
-
};
|
|
2855
|
-
}
|
|
2856
|
-
//#endregion
|
|
2857
2746
|
//#region src/server/csrf.ts
|
|
2858
2747
|
/** HTTP methods that are considered safe (no mutation). */
|
|
2859
2748
|
var SAFE_METHODS = new Set([
|
|
@@ -3121,6 +3010,6 @@ var RenderTimeoutError = class extends Error {
|
|
|
3121
3010
|
}
|
|
3122
3011
|
};
|
|
3123
3012
|
//#endregion
|
|
3124
|
-
export { AccessGate, DEFAULT_LIMITS, DenySignal, METADATA_ROUTE_CONVENTIONS, RedirectSignal, RenderError, RenderTimeoutError, SlotAccessGate,
|
|
3013
|
+
export { AccessGate, DEFAULT_LIMITS, DenySignal, METADATA_ROUTE_CONVENTIONS, RedirectSignal, RenderError, RenderTimeoutError, SlotAccessGate, buildElementTree, callOnRequestError, canonicalize, classifyMetadataRoute, coerce, collectEarlyHintHeaders, createPipeline, enforceBodyLimits, executeAction, formatLinkHeader, generateTraceId, getCookie, getHeader, getLogger, getMetadataRouteAutoLink, getMetadataRouteServePath, getSearchParams, getSegmentParams, getSetCookieHeaders, handleRouteRequest, hasOnRequestError, loadInstrumentation, logCacheMiss, logMiddlewareError, logMiddlewareShortCircuit, logProxyError, logRenderError, logRequestCompleted, logRequestReceived, logSlowRequest, logSwrRefetchFailed, logWaitUntilRejected, logWaitUntilUnsupported, markResponseFlushed, parseBodySize, renderMetadataToElements, replaceTraceId, resolveAllowedMethods, resolveMetadata, resolveMetadataUrls, resolveSlotDenied, resolveStatusFile, resolveTitle, runMiddleware, runProxy, runWithEarlyHintsSender, runWithRequestContext, runWithTraceId, sendEarlyHints103, setLogger, setMutableCookieContext, setSegmentParams, validateCsrf };
|
|
3125
3014
|
|
|
3126
3015
|
//# sourceMappingURL=internal.js.map
|