@timber-js/app 0.2.0-alpha.184 → 0.2.0-alpha.185
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/{cli-schema-sync-D3naS3eH.js → cli-schema-sync-BTWEKJXo.js} +1 -21
- package/dist/_chunks/cli-schema-sync-BTWEKJXo.js.map +1 -0
- package/dist/_chunks/logger-AWfuX-KJ.js.map +1 -1
- package/dist/_chunks/plugin-context---kTF5v8.js.map +1 -1
- package/dist/_chunks/segment-classify-Byy425ng.js.map +1 -1
- package/dist/_chunks/{walkers-BtTlKviE.js → walkers-_6zKFlch.js} +2 -2
- package/dist/_chunks/{walkers-BtTlKviE.js.map → walkers-_6zKFlch.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/internal.js +36 -28
- package/dist/client/internal.js.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +11 -1
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/index.js +25 -15
- package/dist/index.js.map +1 -1
- package/dist/plugin-context.d.ts +2 -1
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +19 -6
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/routing/manifest-codegen.d.ts.map +1 -1
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/types.d.ts +1 -3
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts +4 -7
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/internal.js +135 -161
- package/dist/server/internal.js.map +1 -1
- package/dist/server/prebuilt-builder.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +0 -12
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/sitemap-generator.d.ts.map +1 -1
- package/dist/server/static-generator.d.ts.map +1 -1
- package/dist/server/status-code-resolver.d.ts +3 -10
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/shims/navigation-client.d.ts +8 -19
- package/dist/shims/navigation-client.d.ts.map +1 -1
- package/dist/shims/navigation.d.ts +0 -1
- package/dist/shims/navigation.d.ts.map +1 -1
- package/docs/learn/11-error-handling.mdx +2 -3
- package/package.json +1 -1
- package/src/client/router.ts +24 -7
- package/src/client/rsc-fetch.ts +37 -46
- package/src/plugin-context.ts +2 -1
- package/src/plugins/routing.ts +1 -1
- package/src/plugins/static-build.ts +47 -19
- package/src/routing/manifest-codegen.ts +1 -6
- package/src/routing/scanner.ts +0 -24
- package/src/routing/types.ts +1 -3
- package/src/server/deny-boundary.ts +5 -31
- package/src/server/deny-renderer.ts +2 -2
- package/src/server/pipeline-outcome.ts +1 -1
- package/src/server/prebuilt-builder.ts +1 -7
- package/src/server/primitives.ts +0 -18
- package/src/server/rsc-entry/render-route.ts +3 -3
- package/src/server/sitemap-generator.ts +1 -7
- package/src/server/static-generator.ts +2 -18
- package/src/server/status-code-resolver.ts +4 -47
- package/src/shims/navigation-client.ts +8 -26
- package/src/shims/navigation.ts +0 -4
- package/dist/_chunks/cli-schema-sync-D3naS3eH.js.map +0 -1
package/dist/plugin-context.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { BuildManifest } from './server/build-manifest';
|
|
|
12
12
|
import type { CaptureSummary } from './server/prebuilt-builder';
|
|
13
13
|
import type { StartupTimer } from './utils/startup-timer';
|
|
14
14
|
import type { TimberUserConfig } from './config-types.js';
|
|
15
|
+
import type { RscManifest } from './plugins/static-build.js';
|
|
15
16
|
import type { HoldingServer } from './dev-tools/holding-server.js';
|
|
16
17
|
import type { ProgramNode } from './plugins/callsite-ast.js';
|
|
17
18
|
export type { TimberUserConfig, ClientJavascriptConfig } from './config-types.js';
|
|
@@ -142,7 +143,7 @@ export interface PluginContext {
|
|
|
142
143
|
* Populated during static generation, consumed by adapters to set
|
|
143
144
|
* immutable cache headers for `_rsc/` files. See TIM-1254.
|
|
144
145
|
*/
|
|
145
|
-
rscManifest?:
|
|
146
|
+
rscManifest?: RscManifest;
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
148
149
|
* Content-keyed LRU memo for `parseAst`. Transforms for the same module run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-context.d.ts","sourceRoot":"","sources":["../src/plugin-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAIlF,qEAAqE;AACrE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,wBAAwB,CAc1F;AAID;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,gBAAgB,CAAC;IACzB,+CAA+C;IAC/C,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,uFAAuF;IACvF,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,GAAG,EAAE,OAAO,CAAC;IACb,gFAAgF;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G;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAkC;IAE/C;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAgB/B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAID;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBzE;AAID,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAiB3F;AAID,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,QAA0B,CAAC;AAEzD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,EACvB,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,CAQR;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CA6B9E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAqB1E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,gBAAgB,GAC3B,MAAM,EAAE,CAgBV;AAWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,gBAAgB,GAC3B,gBAAgB,CAiBlB"}
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
import type { Plugin } from 'vite';
|
|
11
11
|
import type { PluginContext } from '../plugin-context.js';
|
|
12
12
|
import type { StaticPageEntry, StaticRedirectEntry } from '../server/static-generator.js';
|
|
13
|
+
/**
|
|
14
|
+
* A single entry in the RSC manifest injected into static HTML.
|
|
15
|
+
* Maps an unhashed `/_rsc/*.rsc` path to its hashed URL, with
|
|
16
|
+
* optional route params inlined to avoid a sidecar fetch.
|
|
17
|
+
*/
|
|
18
|
+
export interface RscManifestEntry {
|
|
19
|
+
url: string;
|
|
20
|
+
params?: Record<string, string | string[]>;
|
|
21
|
+
}
|
|
22
|
+
export type RscManifest = Record<string, RscManifestEntry>;
|
|
13
23
|
export interface StaticValidationError {
|
|
14
24
|
type: 'dynamic-api';
|
|
15
25
|
file: string;
|
|
@@ -44,21 +54,24 @@ export declare function staticOutputPath(entry: StaticPageEntry): string;
|
|
|
44
54
|
*/
|
|
45
55
|
export declare function contentHash(data: Buffer | Uint8Array): string;
|
|
46
56
|
/**
|
|
47
|
-
* Hash all RSC flight payloads
|
|
48
|
-
*
|
|
57
|
+
* Hash all RSC flight payloads in `_rsc/`, rename them with content
|
|
58
|
+
* hashes, and build a manifest with optional inlined route params.
|
|
49
59
|
*
|
|
50
60
|
* Before: `_rsc/index.rsc`, `_rsc/about.rsc`
|
|
51
61
|
* After: `_rsc/index-B7YxEKdN.rsc`, `_rsc/about-C8ZzFLfO.rsc`
|
|
52
62
|
*
|
|
53
|
-
* The manifest maps the original `_rsc/` URL to
|
|
54
|
-
* `{"/_rsc/index.rsc":"/_rsc/index-B7YxEKdN.rsc", ...}`
|
|
63
|
+
* The manifest maps the original `_rsc/` URL to an entry object:
|
|
64
|
+
* `{"/_rsc/index.rsc":{"url":"/_rsc/index-B7YxEKdN.rsc"}, ...}`
|
|
65
|
+
*
|
|
66
|
+
* Route params (from `routeParams`) are inlined into the manifest
|
|
67
|
+
* entry, eliminating the need for .params.json sidecar files. TIM-1255.
|
|
55
68
|
*
|
|
56
69
|
* Injected into HTML as:
|
|
57
70
|
* `<script>window.__TIMBER_RSC_MANIFEST__={...}</script>`
|
|
58
71
|
*
|
|
59
72
|
* @internal Exported for testing.
|
|
60
73
|
*/
|
|
61
|
-
export declare function hashRscPayloads(staticDir: string
|
|
74
|
+
export declare function hashRscPayloads(staticDir: string, routeParams?: Record<string, Record<string, string | string[]>>): Promise<RscManifest>;
|
|
62
75
|
/**
|
|
63
76
|
* Inject the RSC manifest into all HTML files as a `<script>` tag
|
|
64
77
|
* before `</head>`. This lets the client resolve hashed RSC URLs
|
|
@@ -66,7 +79,7 @@ export declare function hashRscPayloads(staticDir: string): Promise<Record<strin
|
|
|
66
79
|
*
|
|
67
80
|
* @internal Exported for testing.
|
|
68
81
|
*/
|
|
69
|
-
export declare function injectRscManifestIntoHtml(staticDir: string, manifest:
|
|
82
|
+
export declare function injectRscManifestIntoHtml(staticDir: string, manifest: RscManifest): Promise<void>;
|
|
70
83
|
/**
|
|
71
84
|
* Read a user-authored `_redirects` file from the project's `public/`
|
|
72
85
|
* directory. Returns `null` if no file exists.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-build.d.ts","sourceRoot":"","sources":["../../src/plugins/static-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAMnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAGV,eAAe,EACf,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAQvC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,CA2BvF;AAMD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAG9E;AAaD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eA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EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAC9D,OAAO,CAAC,WAAW,CAAC,CA2BtB;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CAkBf;AAMD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAU5E;AAMD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA8D5D"}
|
package/dist/routing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as INTERCEPTION_MARKERS, n as classifyUrlSegment, r as DEFAULT_PAGE_EXTENSIONS, t as classifySegment } from "../_chunks/segment-classify-Byy425ng.js";
|
|
2
|
-
import { i as scanRoutes } from "../_chunks/cli-schema-sync-
|
|
3
|
-
import { a as generateRouteMap, i as validateSchemaAgainstRoutes, n as collectInterceptionRewrites, r as collectDynamicSegmentsFromTree, t as collectLeafRoutes } from "../_chunks/walkers-
|
|
2
|
+
import { i as scanRoutes } from "../_chunks/cli-schema-sync-BTWEKJXo.js";
|
|
3
|
+
import { a as generateRouteMap, i as validateSchemaAgainstRoutes, n as collectInterceptionRewrites, r as collectDynamicSegmentsFromTree, t as collectLeafRoutes } from "../_chunks/walkers-_6zKFlch.js";
|
|
4
4
|
export { DEFAULT_PAGE_EXTENSIONS, INTERCEPTION_MARKERS, classifySegment, classifyUrlSegment, collectDynamicSegmentsFromTree, collectInterceptionRewrites, collectLeafRoutes, generateRouteMap, scanRoutes, validateSchemaAgainstRoutes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-codegen.d.ts","sourceRoot":"","sources":["../../src/routing/manifest-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,SAAS,EAA0B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest-codegen.d.ts","sourceRoot":"","sources":["../../src/routing/manifest-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,SAAS,EAA0B,MAAM,YAAY,CAAC;AAyBpE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CA+IhF;AAID;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAuC1E;AAQD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA8B3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/routing/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,SAAS,EAIT,aAAa,EAEd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/routing/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,SAAS,EAIT,aAAa,EAEd,MAAM,YAAY,CAAC;AAwBpB;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,aAAkB,GAAG,SAAS,CA4ChF"}
|
package/dist/routing/types.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* `SegmentNode` (Map-based) and `ManifestSegmentNode` (object-based).
|
|
15
15
|
*
|
|
16
16
|
* Keyed groups (`slots`, `statusFiles`, `jsonStatusFiles`,
|
|
17
|
-
* `
|
|
17
|
+
* `metadataRoutes`) are plain `Record<string, …>`
|
|
18
18
|
* objects rather than `Map`s so that the build-time tree can be
|
|
19
19
|
* serialized into the virtual route manifest with no shape transform.
|
|
20
20
|
*
|
|
@@ -95,8 +95,6 @@ export interface SegmentNode<TFile = RouteFile> {
|
|
|
95
95
|
jsonStatusFiles?: Record<string, TFile>;
|
|
96
96
|
/** denied.tsx — slot-only denial rendering */
|
|
97
97
|
denied?: TFile;
|
|
98
|
-
/** Legacy compat: not-found.tsx (maps to 404), forbidden.tsx (403), unauthorized.tsx (401) */
|
|
99
|
-
legacyStatusFiles?: Record<string, TFile>;
|
|
100
98
|
/** Metadata route files (sitemap.ts, robots.ts, icon.tsx, etc.) keyed by base name */
|
|
101
99
|
metadataRoutes?: Record<string, TFile>;
|
|
102
100
|
children: SegmentNode<TFile>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/routing/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,kCAAkC;AAClC,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,SAAS,GACT,WAAW,GACX,oBAAoB,GACpB,OAAO,GACP,MAAM,GACN,cAAc,GACd,SAAS,CAAC;AAEd;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAEvE,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,EAAyC,CAAC;AAE/F;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,GAAG,SAAS;IAC5C,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAA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AM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK,GAAG,SAAS;IAC1C,gDAAgD;IAChD,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,qEAAqE;IACrE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,8BAA8B;AAC9B,eAAO,MAAM,uBAAuB,UAA6B,CAAC"}
|
|
@@ -36,12 +36,11 @@ export interface DenyPageEntry {
|
|
|
36
36
|
/** The component to render (server or client — both work). */
|
|
37
37
|
component: (...args: unknown[]) => unknown;
|
|
38
38
|
/**
|
|
39
|
-
* How the entry matched: a status-code file (404.tsx/4xx.tsx)
|
|
40
|
-
* compat file (not-found.tsx/forbidden.tsx/unauthorized.tsx), or the
|
|
39
|
+
* How the entry matched: a status-code file (404.tsx/4xx.tsx) or the
|
|
41
40
|
* error.tsx catch-all. error.tsx entries render with their documented
|
|
42
41
|
* { error, digest, reset } contract, not bare deny props. See TIM-1081.
|
|
43
42
|
*/
|
|
44
|
-
kind: 'status' | '
|
|
43
|
+
kind: 'status' | 'error';
|
|
45
44
|
/** MDX files are server components — rendered with plain props, never ErrorReconstituter. */
|
|
46
45
|
isMdx: boolean;
|
|
47
46
|
}
|
|
@@ -52,9 +51,7 @@ export interface DenyPageEntry {
|
|
|
52
51
|
* status-code file components in fallback order:
|
|
53
52
|
* 1. Specific status files (403.tsx, 404.tsx) — exact match
|
|
54
53
|
* 2. Category catch-alls (4xx.tsx) — matches any 4xx
|
|
55
|
-
* 3.
|
|
56
|
-
* unauthorized.tsx → 401) — exact match
|
|
57
|
-
* 4. error.tsx — catches everything
|
|
54
|
+
* 3. error.tsx — catches everything
|
|
58
55
|
*
|
|
59
56
|
* Each segment is checked in this order. The chain is ordered so the
|
|
60
57
|
* FIRST match wins at catch time. This mirrors resolveStatusFile's 4xx
|
|
@@ -71,7 +68,7 @@ export declare function renderMatchingDenyPage(chain: DenyPageEntry[], status: n
|
|
|
71
68
|
* Build the element for a matched deny chain entry with the props contract
|
|
72
69
|
* the file's convention documents:
|
|
73
70
|
*
|
|
74
|
-
* - Status-code
|
|
71
|
+
* - Status-code files: { status, dangerouslyPassData }
|
|
75
72
|
* - error.tsx (TSX): { error, digest, reset } via ErrorReconstituter, plus
|
|
76
73
|
* { status, dangerouslyPassData } for dual-shape implementations. Without
|
|
77
74
|
* the Error prop, any error.tsx written per the docs (reading
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deny-boundary.d.ts","sourceRoot":"","sources":["../../src/server/deny-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;
|
|
1
|
+
{"version":3,"file":"deny-boundary.d.ts","sourceRoot":"","sources":["../../src/server/deny-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAWH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,yFAAyF;IACzF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8DAA8D;IAC9D,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IAC3C;;;;OAIG;IACH,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,6FAA6F;IAC7F,KAAK,EAAE,OAAO,CAAC;CAChB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,EAAE,CAAC,CAiE1B;AAID;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GACZ,KAAK,CAAC,YAAY,GAAG,IAAI,CAgB3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GACZ,KAAK,CAAC,YAAY,CA2BpB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,KAAK,EACL,SAAS,EACT,SAAS,GACV,EAAE;IACD,0CAA0C;IAC1C,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IACtC,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAgB9B;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMlD;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD"}
|
package/dist/server/internal.js
CHANGED
|
@@ -1163,165 +1163,6 @@ async function loadModule(loader) {
|
|
|
1163
1163
|
throw new ModuleLoadError(loader.filePath, error);
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
|
-
/** Reverse index: status code → legacy file name. Built once at module load. */
|
|
1167
|
-
var STATUS_TO_LEGACY_FILE = Object.fromEntries(Object.entries({
|
|
1168
|
-
"not-found": 404,
|
|
1169
|
-
"forbidden": 403,
|
|
1170
|
-
"unauthorized": 401
|
|
1171
|
-
}).map(([name, status]) => [status, name]));
|
|
1172
|
-
/**
|
|
1173
|
-
* Look up `{statusStr}` then `{categoryKey}` (e.g. "4xx" / "5xx") in a
|
|
1174
|
-
* status-file group on a single segment. Shared by all three fallback
|
|
1175
|
-
* chains — the only structural difference between component 4xx,
|
|
1176
|
-
* component 5xx, and JSON resolution is *which* group is searched and
|
|
1177
|
-
* how the per-segment loop is layered around it.
|
|
1178
|
-
*/
|
|
1179
|
-
function lookupInGroup(group, statusStr, categoryKey, segmentIndex, status) {
|
|
1180
|
-
if (!group) return null;
|
|
1181
|
-
const exact = group[statusStr];
|
|
1182
|
-
if (exact) return {
|
|
1183
|
-
file: exact,
|
|
1184
|
-
status,
|
|
1185
|
-
kind: "exact",
|
|
1186
|
-
segmentIndex
|
|
1187
|
-
};
|
|
1188
|
-
const category = group[categoryKey];
|
|
1189
|
-
if (category) return {
|
|
1190
|
-
file: category,
|
|
1191
|
-
status,
|
|
1192
|
-
kind: "category",
|
|
1193
|
-
segmentIndex
|
|
1194
|
-
};
|
|
1195
|
-
return null;
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Look up the legacy convention file (`not-found.tsx` / `forbidden.tsx` /
|
|
1199
|
-
* `unauthorized.tsx`) for `status` on a single segment. Returns null if
|
|
1200
|
-
* `status` has no legacy mapping or the file isn't present.
|
|
1201
|
-
*/
|
|
1202
|
-
function lookupLegacy(group, status, segmentIndex) {
|
|
1203
|
-
if (!group) return null;
|
|
1204
|
-
const name = STATUS_TO_LEGACY_FILE[status];
|
|
1205
|
-
if (!name) return null;
|
|
1206
|
-
const file = group[name];
|
|
1207
|
-
return file ? {
|
|
1208
|
-
file,
|
|
1209
|
-
status,
|
|
1210
|
-
kind: "legacy",
|
|
1211
|
-
segmentIndex
|
|
1212
|
-
} : null;
|
|
1213
|
-
}
|
|
1214
|
-
/**
|
|
1215
|
-
* Resolve the status-code file to render for a given HTTP status code.
|
|
1216
|
-
*
|
|
1217
|
-
* Walks the segment chain from leaf to root following the fallback chain
|
|
1218
|
-
* defined in design/10-error-handling.md. Returns null if no file is found
|
|
1219
|
-
* (caller should render the framework default).
|
|
1220
|
-
*
|
|
1221
|
-
* @param status - The HTTP status code (4xx or 5xx).
|
|
1222
|
-
* @param segments - The matched segment chain from root (index 0) to leaf (last).
|
|
1223
|
-
* @param format - The response format family ('component' or 'json'). Defaults to 'component'.
|
|
1224
|
-
*/
|
|
1225
|
-
function resolveStatusFile(status, segments, format = "component") {
|
|
1226
|
-
if (status < 400 || status > 599) return null;
|
|
1227
|
-
if (format === "json") return resolveJson(status, segments);
|
|
1228
|
-
if (status <= 499) return resolve4xx(status, segments);
|
|
1229
|
-
return resolve5xx(status, segments);
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* 4xx component fallback chain — three separate full passes leaf→root.
|
|
1233
|
-
*
|
|
1234
|
-
* The passes must be separate (not interleaved per-segment) so that a
|
|
1235
|
-
* root-level `404.tsx` beats a leaf-level `error.tsx`. The 5xx chain
|
|
1236
|
-
* inverts this and is per-segment: a leaf's `error.tsx` beats a root's
|
|
1237
|
-
* `5xx.tsx`. This asymmetry is the only reason these two functions exist
|
|
1238
|
-
* separately.
|
|
1239
|
-
*
|
|
1240
|
-
* Pass 1 — {status}.tsx → 4xx.tsx (statusFiles)
|
|
1241
|
-
* Pass 2 — not-found / forbidden / unauthorized (legacyStatusFiles)
|
|
1242
|
-
* Pass 3 — error.tsx (error)
|
|
1243
|
-
*/
|
|
1244
|
-
function resolve4xx(status, segments) {
|
|
1245
|
-
const statusStr = String(status);
|
|
1246
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1247
|
-
const r = lookupInGroup(segments[i].statusFiles, statusStr, "4xx", i, status);
|
|
1248
|
-
if (r) return r;
|
|
1249
|
-
}
|
|
1250
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1251
|
-
const r = lookupLegacy(segments[i].legacyStatusFiles, status, i);
|
|
1252
|
-
if (r) return r;
|
|
1253
|
-
}
|
|
1254
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1255
|
-
const errorFile = segments[i].error;
|
|
1256
|
-
if (errorFile) return {
|
|
1257
|
-
file: errorFile,
|
|
1258
|
-
status,
|
|
1259
|
-
kind: "error",
|
|
1260
|
-
segmentIndex: i
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
return null;
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* 5xx component fallback chain — single pass, per-segment leaf→root.
|
|
1267
|
-
*
|
|
1268
|
-
* At each segment: {status}.tsx → 5xx.tsx → error.tsx. A leaf's
|
|
1269
|
-
* `error.tsx` therefore beats a root's `5xx.tsx`, which is the
|
|
1270
|
-
* intentional inverse of the 4xx chain.
|
|
1271
|
-
*/
|
|
1272
|
-
function resolve5xx(status, segments) {
|
|
1273
|
-
const statusStr = String(status);
|
|
1274
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1275
|
-
const segment = segments[i];
|
|
1276
|
-
const r = lookupInGroup(segment.statusFiles, statusStr, "5xx", i, status);
|
|
1277
|
-
if (r) return r;
|
|
1278
|
-
if (segment.error) return {
|
|
1279
|
-
file: segment.error,
|
|
1280
|
-
status,
|
|
1281
|
-
kind: "error",
|
|
1282
|
-
segmentIndex: i
|
|
1283
|
-
};
|
|
1284
|
-
}
|
|
1285
|
-
return null;
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* JSON fallback chain (for both 4xx and 5xx) — single pass leaf→root.
|
|
1289
|
-
*
|
|
1290
|
-
* At each segment: {status}.json → {category}.json. No legacy compat,
|
|
1291
|
-
* no error.tsx — the JSON chain terminates at the category catch-all
|
|
1292
|
-
* and the caller falls back to a bare-JSON framework default.
|
|
1293
|
-
*/
|
|
1294
|
-
function resolveJson(status, segments) {
|
|
1295
|
-
const statusStr = String(status);
|
|
1296
|
-
const categoryKey = status >= 500 ? "5xx" : "4xx";
|
|
1297
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
1298
|
-
const r = lookupInGroup(segments[i].jsonStatusFiles, statusStr, categoryKey, i, status);
|
|
1299
|
-
if (r) return r;
|
|
1300
|
-
}
|
|
1301
|
-
return null;
|
|
1302
|
-
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Resolve the denial file for a parallel route slot.
|
|
1305
|
-
*
|
|
1306
|
-
* Slot denial is graceful degradation — no HTTP status on the wire.
|
|
1307
|
-
* Fallback chain: denied.tsx → default.tsx → null.
|
|
1308
|
-
*
|
|
1309
|
-
* @param slotNode - The segment node for the slot (segmentType === 'slot').
|
|
1310
|
-
*/
|
|
1311
|
-
function resolveSlotDenied(slotNode) {
|
|
1312
|
-
const slotName = slotNode.segmentName.replace(/^@/, "");
|
|
1313
|
-
if (slotNode.denied) return {
|
|
1314
|
-
file: slotNode.denied,
|
|
1315
|
-
slotName,
|
|
1316
|
-
kind: "denied"
|
|
1317
|
-
};
|
|
1318
|
-
if (slotNode.default) return {
|
|
1319
|
-
file: slotNode.default,
|
|
1320
|
-
slotName,
|
|
1321
|
-
kind: "default"
|
|
1322
|
-
};
|
|
1323
|
-
return null;
|
|
1324
|
-
}
|
|
1325
1166
|
//#endregion
|
|
1326
1167
|
//#region src/server/deny-boundary.ts
|
|
1327
1168
|
/**
|
|
@@ -1371,7 +1212,7 @@ function renderMatchingDenyPage(chain, status, data) {
|
|
|
1371
1212
|
* Build the element for a matched deny chain entry with the props contract
|
|
1372
1213
|
* the file's convention documents:
|
|
1373
1214
|
*
|
|
1374
|
-
* - Status-code
|
|
1215
|
+
* - Status-code files: { status, dangerouslyPassData }
|
|
1375
1216
|
* - error.tsx (TSX): { error, digest, reset } via ErrorReconstituter, plus
|
|
1376
1217
|
* { status, dangerouslyPassData } for dual-shape implementations. Without
|
|
1377
1218
|
* the Error prop, any error.tsx written per the docs (reading
|
|
@@ -2243,7 +2084,7 @@ async function outcomeToResponse(config, outcome, ctx) {
|
|
|
2243
2084
|
await fireOnRequestError(denyRenderError, ctx.req, "render");
|
|
2244
2085
|
if (config.onPipelineError && denyRenderError instanceof Error) config.onPipelineError(denyRenderError, "render");
|
|
2245
2086
|
}
|
|
2246
|
-
if (isDebug()) console.warn(`[timber] DenySignal(${outcome.signal.status}) from ${outcome.phase} phase — no renderDenyFallback configured, returning bare ${outcome.signal.status} response\n Request: ${ctx.method} ${ctx.path}\n Add a
|
|
2087
|
+
if (isDebug()) console.warn(`[timber] DenySignal(${outcome.signal.status}) from ${outcome.phase} phase — no renderDenyFallback configured, returning bare ${outcome.signal.status} response\n Request: ${ctx.method} ${ctx.path}\n Add a status-code file (e.g. 404.tsx) or error.tsx to render a custom deny page.`);
|
|
2247
2088
|
return new Response(null, {
|
|
2248
2089
|
status: outcome.signal.status,
|
|
2249
2090
|
headers
|
|
@@ -3122,6 +2963,139 @@ async function wrapWithErrorBoundaries(segment, element, loadModule, createEleme
|
|
|
3122
2963
|
return element;
|
|
3123
2964
|
}
|
|
3124
2965
|
//#endregion
|
|
2966
|
+
//#region src/server/status-code-resolver.ts
|
|
2967
|
+
/**
|
|
2968
|
+
* Look up `{statusStr}` then `{categoryKey}` (e.g. "4xx" / "5xx") in a
|
|
2969
|
+
* status-file group on a single segment. Shared by all three fallback
|
|
2970
|
+
* chains — the only structural difference between component 4xx,
|
|
2971
|
+
* component 5xx, and JSON resolution is *which* group is searched and
|
|
2972
|
+
* how the per-segment loop is layered around it.
|
|
2973
|
+
*/
|
|
2974
|
+
function lookupInGroup(group, statusStr, categoryKey, segmentIndex, status) {
|
|
2975
|
+
if (!group) return null;
|
|
2976
|
+
const exact = group[statusStr];
|
|
2977
|
+
if (exact) return {
|
|
2978
|
+
file: exact,
|
|
2979
|
+
status,
|
|
2980
|
+
kind: "exact",
|
|
2981
|
+
segmentIndex
|
|
2982
|
+
};
|
|
2983
|
+
const category = group[categoryKey];
|
|
2984
|
+
if (category) return {
|
|
2985
|
+
file: category,
|
|
2986
|
+
status,
|
|
2987
|
+
kind: "category",
|
|
2988
|
+
segmentIndex
|
|
2989
|
+
};
|
|
2990
|
+
return null;
|
|
2991
|
+
}
|
|
2992
|
+
/**
|
|
2993
|
+
* Resolve the status-code file to render for a given HTTP status code.
|
|
2994
|
+
*
|
|
2995
|
+
* Walks the segment chain from leaf to root following the fallback chain
|
|
2996
|
+
* defined in design/10-error-handling.md. Returns null if no file is found
|
|
2997
|
+
* (caller should render the framework default).
|
|
2998
|
+
*
|
|
2999
|
+
* @param status - The HTTP status code (4xx or 5xx).
|
|
3000
|
+
* @param segments - The matched segment chain from root (index 0) to leaf (last).
|
|
3001
|
+
* @param format - The response format family ('component' or 'json'). Defaults to 'component'.
|
|
3002
|
+
*/
|
|
3003
|
+
function resolveStatusFile(status, segments, format = "component") {
|
|
3004
|
+
if (status < 400 || status > 599) return null;
|
|
3005
|
+
if (format === "json") return resolveJson(status, segments);
|
|
3006
|
+
if (status <= 499) return resolve4xx(status, segments);
|
|
3007
|
+
return resolve5xx(status, segments);
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* 4xx component fallback chain — two separate full passes leaf→root.
|
|
3011
|
+
*
|
|
3012
|
+
* The passes must be separate (not interleaved per-segment) so that a
|
|
3013
|
+
* root-level `404.tsx` beats a leaf-level `error.tsx`. The 5xx chain
|
|
3014
|
+
* inverts this and is per-segment: a leaf's `error.tsx` beats a root's
|
|
3015
|
+
* `5xx.tsx`. This asymmetry is the only reason these two functions exist
|
|
3016
|
+
* separately.
|
|
3017
|
+
*
|
|
3018
|
+
* Pass 1 — {status}.tsx → 4xx.tsx (statusFiles)
|
|
3019
|
+
* Pass 2 — error.tsx (error)
|
|
3020
|
+
*/
|
|
3021
|
+
function resolve4xx(status, segments) {
|
|
3022
|
+
const statusStr = String(status);
|
|
3023
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
3024
|
+
const r = lookupInGroup(segments[i].statusFiles, statusStr, "4xx", i, status);
|
|
3025
|
+
if (r) return r;
|
|
3026
|
+
}
|
|
3027
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
3028
|
+
const errorFile = segments[i].error;
|
|
3029
|
+
if (errorFile) return {
|
|
3030
|
+
file: errorFile,
|
|
3031
|
+
status,
|
|
3032
|
+
kind: "error",
|
|
3033
|
+
segmentIndex: i
|
|
3034
|
+
};
|
|
3035
|
+
}
|
|
3036
|
+
return null;
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* 5xx component fallback chain — single pass, per-segment leaf→root.
|
|
3040
|
+
*
|
|
3041
|
+
* At each segment: {status}.tsx → 5xx.tsx → error.tsx. A leaf's
|
|
3042
|
+
* `error.tsx` therefore beats a root's `5xx.tsx`, which is the
|
|
3043
|
+
* intentional inverse of the 4xx chain.
|
|
3044
|
+
*/
|
|
3045
|
+
function resolve5xx(status, segments) {
|
|
3046
|
+
const statusStr = String(status);
|
|
3047
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
3048
|
+
const segment = segments[i];
|
|
3049
|
+
const r = lookupInGroup(segment.statusFiles, statusStr, "5xx", i, status);
|
|
3050
|
+
if (r) return r;
|
|
3051
|
+
if (segment.error) return {
|
|
3052
|
+
file: segment.error,
|
|
3053
|
+
status,
|
|
3054
|
+
kind: "error",
|
|
3055
|
+
segmentIndex: i
|
|
3056
|
+
};
|
|
3057
|
+
}
|
|
3058
|
+
return null;
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* JSON fallback chain (for both 4xx and 5xx) — single pass leaf→root.
|
|
3062
|
+
*
|
|
3063
|
+
* At each segment: {status}.json → {category}.json. No legacy compat,
|
|
3064
|
+
* no error.tsx — the JSON chain terminates at the category catch-all
|
|
3065
|
+
* and the caller falls back to a bare-JSON framework default.
|
|
3066
|
+
*/
|
|
3067
|
+
function resolveJson(status, segments) {
|
|
3068
|
+
const statusStr = String(status);
|
|
3069
|
+
const categoryKey = status >= 500 ? "5xx" : "4xx";
|
|
3070
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
3071
|
+
const r = lookupInGroup(segments[i].jsonStatusFiles, statusStr, categoryKey, i, status);
|
|
3072
|
+
if (r) return r;
|
|
3073
|
+
}
|
|
3074
|
+
return null;
|
|
3075
|
+
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Resolve the denial file for a parallel route slot.
|
|
3078
|
+
*
|
|
3079
|
+
* Slot denial is graceful degradation — no HTTP status on the wire.
|
|
3080
|
+
* Fallback chain: denied.tsx → default.tsx → null.
|
|
3081
|
+
*
|
|
3082
|
+
* @param slotNode - The segment node for the slot (segmentType === 'slot').
|
|
3083
|
+
*/
|
|
3084
|
+
function resolveSlotDenied(slotNode) {
|
|
3085
|
+
const slotName = slotNode.segmentName.replace(/^@/, "");
|
|
3086
|
+
if (slotNode.denied) return {
|
|
3087
|
+
file: slotNode.denied,
|
|
3088
|
+
slotName,
|
|
3089
|
+
kind: "denied"
|
|
3090
|
+
};
|
|
3091
|
+
if (slotNode.default) return {
|
|
3092
|
+
file: slotNode.default,
|
|
3093
|
+
slotName,
|
|
3094
|
+
kind: "default"
|
|
3095
|
+
};
|
|
3096
|
+
return null;
|
|
3097
|
+
}
|
|
3098
|
+
//#endregion
|
|
3125
3099
|
//#region src/server/csrf.ts
|
|
3126
3100
|
/** HTTP methods that are considered safe (no mutation). */
|
|
3127
3101
|
var SAFE_METHODS = /* @__PURE__ */ new Set([
|