@timber-js/app 0.2.0-alpha.200 → 0.2.0-alpha.202
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/bin/timber.mjs +15 -1
- package/dist/_chunks/{actions-d1hCqnU3.js → actions-HUdJADAD.js} +3 -3
- package/dist/_chunks/{actions-d1hCqnU3.js.map → actions-HUdJADAD.js.map} +1 -1
- package/dist/_chunks/{build-manifest-DTmSGLRz.js → build-manifest-DWppEdLB.js} +2 -51
- package/dist/_chunks/build-manifest-DWppEdLB.js.map +1 -0
- package/dist/_chunks/{cache-api-ByagcC-J.js → cache-api-CAPbZTga.js} +2 -2
- package/dist/_chunks/{cache-api-ByagcC-J.js.map → cache-api-CAPbZTga.js.map} +1 -1
- package/dist/_chunks/{chains-Bpb0W4ax.js → chains-CBNA0Ozj.js} +3 -3
- package/dist/_chunks/{chains-Bpb0W4ax.js.map → chains-CBNA0Ozj.js.map} +1 -1
- package/dist/_chunks/{cli-check-D6VolrDV.js → cli-check-BzMGuIH6.js} +3 -3
- package/dist/_chunks/{cli-check-D6VolrDV.js.map → cli-check-BzMGuIH6.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-D6rO-VcS.js → cli-schema-sync-DnXqcIIj.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-D6rO-VcS.js.map → cli-schema-sync-DnXqcIIj.js.map} +1 -1
- package/dist/_chunks/{cloudflare-BFb__LYG.js → cloudflare-DxX1SU0g.js} +3 -3
- package/dist/_chunks/{cloudflare-BFb__LYG.js.map → cloudflare-DxX1SU0g.js.map} +1 -1
- package/dist/_chunks/{convention-lint-fRkwVwEH.js → convention-lint-DHOFvX5s.js} +5 -95
- package/dist/_chunks/convention-lint-DHOFvX5s.js.map +1 -0
- package/dist/_chunks/csp-nonce-hOGniaG4.js +227 -0
- package/dist/_chunks/csp-nonce-hOGniaG4.js.map +1 -0
- package/dist/_chunks/dev-server-DioP7tkQ.js +2288 -0
- package/dist/_chunks/dev-server-DioP7tkQ.js.map +1 -0
- package/dist/_chunks/{error-boundary-BfPHZjm0.js → error-boundary-BQKxl6EX.js} +11 -17
- package/dist/_chunks/{error-boundary-BfPHZjm0.js.map → error-boundary-BQKxl6EX.js.map} +1 -1
- package/dist/_chunks/{graph-cache-CP4GEmf9.js → graph-cache-Cv3njEH8.js} +2 -2
- package/dist/_chunks/{graph-cache-CP4GEmf9.js.map → graph-cache-Cv3njEH8.js.map} +1 -1
- package/dist/_chunks/{live-graph-D_2D32Ad.js → live-graph-VjHFF5EV.js} +3 -3
- package/dist/_chunks/{live-graph-D_2D32Ad.js.map → live-graph-VjHFF5EV.js.map} +1 -1
- package/dist/_chunks/{logger-uLBuGKDI.js → logger-DqJ2VoAY.js} +450 -458
- package/dist/_chunks/logger-DqJ2VoAY.js.map +1 -0
- package/dist/_chunks/{segment-keys-lqtdookO.js → metadata-routes-DSDjM_hJ.js} +2 -61
- package/dist/_chunks/metadata-routes-DSDjM_hJ.js.map +1 -0
- package/dist/_chunks/{poison-scan-Bm9Yyqk9.js → poison-scan-lEbz4pQE.js} +2 -2
- package/dist/_chunks/{poison-scan-Bm9Yyqk9.js.map → poison-scan-lEbz4pQE.js.map} +1 -1
- package/dist/_chunks/{scanner-AiazgH_f.js → scanner-B_tnqFcF.js} +37 -137
- package/dist/_chunks/scanner-B_tnqFcF.js.map +1 -0
- package/dist/_chunks/segment-keys-D5hu1hz4.js +62 -0
- package/dist/_chunks/segment-keys-D5hu1hz4.js.map +1 -0
- package/dist/_chunks/tree-match-CdbvYTBz.js +122 -0
- package/dist/_chunks/tree-match-CdbvYTBz.js.map +1 -0
- package/dist/_chunks/{walkers-B6XUtmqK.js → walkers-Cm3PC5JT.js} +2 -2
- package/dist/_chunks/{walkers-B6XUtmqK.js.map → walkers-Cm3PC5JT.js.map} +1 -1
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/analyze/crawl-entry.js +2 -2
- package/dist/analyze/graph-command.js +3 -3
- package/dist/cache/index.js +1 -1
- package/dist/cli.d.ts +7 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +44 -7
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-dev.d.ts +5 -1
- package/dist/client/browser-dev.d.ts.map +1 -1
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/action-queue.d.ts +20 -1
- package/dist/client/browser-entry/action-queue.d.ts.map +1 -1
- package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -1
- package/dist/client/error-boundary.d.ts +3 -15
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/error-reconstituter.d.ts +4 -4
- package/dist/client/error-reconstituter.d.ts.map +1 -1
- package/dist/client/internal.js +1 -1
- package/dist/dev-tools/debug-channel.d.ts +55 -0
- package/dist/dev-tools/debug-channel.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +302 -2245
- package/dist/index.js.map +1 -1
- package/dist/plugins/dev-server.d.ts +7 -0
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/mdx.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/routing/scanner.d.ts +4 -4
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/server/access-gate.d.ts +2 -2
- package/dist/server/deny-boundary.d.ts +3 -5
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/deny-renderer.d.ts +0 -1
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/error-boundary-wrapper.d.ts +5 -12
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +20 -195
- package/dist/server/internal.js.map +1 -1
- package/dist/server/pipeline.d.ts +8 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +15 -13
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts +3 -7
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +6 -27
- 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 +1 -0
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +4 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +1 -0
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/slot-subtree-contain.d.ts +1 -1
- package/dist/server/slot-subtree-contain.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +5 -5
- package/docs/api/34-api-config.mdx +2 -2
- package/docs/api/36-cli.mdx +1 -1
- package/docs/learn/12-error-handling.mdx +7 -8
- package/package.json +2 -3
- package/src/cli.ts +62 -8
- package/src/client/browser-dev.ts +35 -3
- package/src/client/browser-entry/action-dispatch.ts +12 -0
- package/src/client/browser-entry/action-queue.ts +70 -8
- package/src/client/browser-entry/rsc-stream.ts +78 -22
- package/src/client/error-boundary.tsx +13 -39
- package/src/client/error-reconstituter.tsx +5 -5
- package/src/dev-tools/debug-channel.ts +151 -0
- package/src/index.ts +8 -12
- package/src/plugins/dev-server.ts +58 -7
- package/src/plugins/mdx.ts +2 -1
- package/src/routing/convention-lint.ts +4 -111
- package/src/routing/scanner.ts +33 -22
- package/src/server/access-gate.tsx +3 -3
- package/src/server/deny-boundary.ts +5 -23
- package/src/server/deny-renderer.ts +4 -7
- package/src/server/error-boundary-wrapper.ts +11 -35
- package/src/server/pipeline.ts +9 -0
- package/src/server/primitives.ts +20 -26
- package/src/server/rsc-entry/error-renderer.ts +15 -43
- package/src/server/rsc-entry/helpers.ts +10 -67
- package/src/server/rsc-entry/index.ts +1 -0
- package/src/server/rsc-entry/render-route.ts +12 -1
- package/src/server/rsc-entry/rsc-stream.ts +27 -24
- package/src/server/rsc-entry/ssr-renderer.ts +7 -1
- package/src/server/slot-resolver.ts +29 -7
- package/src/server/slot-subtree-contain.ts +13 -4
- package/dist/_chunks/build-manifest-DTmSGLRz.js.map +0 -1
- package/dist/_chunks/convention-lint-fRkwVwEH.js.map +0 -1
- package/dist/_chunks/logger-uLBuGKDI.js.map +0 -1
- package/dist/_chunks/scanner-AiazgH_f.js.map +0 -1
- package/dist/_chunks/segment-keys-lqtdookO.js.map +0 -1
- package/dist/server/utils/mdx-file.d.ts +0 -17
- package/dist/server/utils/mdx-file.d.ts.map +0 -1
- package/src/server/utils/mdx-file.ts +0 -22
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
import type { Plugin } from 'vite';
|
|
15
15
|
import type { IncomingMessage } from 'node:http';
|
|
16
16
|
import type { PluginContext } from '../plugin-context.ts';
|
|
17
|
+
/**
|
|
18
|
+
* Exit code used to signal the CLI supervisor that the dev server needs
|
|
19
|
+
* a full process restart (e.g. timber.config.ts changed). The supervisor
|
|
20
|
+
* in cli.ts respawns the worker on this code. 75 = EX_TEMPFAIL (sysexits).
|
|
21
|
+
* See TIM-1444.
|
|
22
|
+
*/
|
|
23
|
+
export declare const RESTART_EXIT_CODE = 75;
|
|
17
24
|
/**
|
|
18
25
|
* Create the timber-dev-server Vite plugin.
|
|
19
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/plugins/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAC;AAKjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/plugins/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAC;AAKjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA6B1D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AA2BpC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA0J1D;AAuRD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAuC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../../src/plugins/mdx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../../src/plugins/mdx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAelE;AAqED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA4HpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convention-lint.d.ts","sourceRoot":"","sources":["../../src/routing/convention-lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAa,SAAS,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"convention-lint.d.ts","sourceRoot":"","sources":["../../src/routing/convention-lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAa,SAAS,EAAe,MAAM,YAAY,CAAC;AAYpE,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAgCpF;AAiWD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAe1E;AAUD,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAkCR"}
|
package/dist/routing/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as scanRoutes, r as collectInterceptionRewrites } from "../_chunks/scanner-AiazgH_f.js";
|
|
2
1
|
import { a as INTERCEPTION_MARKERS, i as DEFAULT_PAGE_EXTENSIONS, n as classifyUrlSegment, t as classifySegment } from "../_chunks/segment-classify-C539Pa2O.js";
|
|
2
|
+
import { n as scanRoutes, r as collectInterceptionRewrites } from "../_chunks/scanner-B_tnqFcF.js";
|
|
3
3
|
import { n as generateRouteMap } from "../_chunks/file-cache-Dw6BJPG7.js";
|
|
4
|
-
import { n as collectDynamicSegmentsFromTree, r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "../_chunks/walkers-
|
|
4
|
+
import { n as collectDynamicSegmentsFromTree, r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "../_chunks/walkers-Cm3PC5JT.js";
|
|
5
5
|
export { DEFAULT_PAGE_EXTENSIONS, INTERCEPTION_MARKERS, classifySegment, classifyUrlSegment, collectDynamicSegmentsFromTree, collectInterceptionRewrites, collectLeafRoutes, generateRouteMap, scanRoutes, validateSchemaAgainstRoutes };
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
import type { RouteTree, ScannerConfig } from './types.ts';
|
|
11
11
|
/**
|
|
12
12
|
* Whether a basename + extension pair is a route-convention file the
|
|
13
|
-
* framework itself imports: page/layout/
|
|
14
|
-
* global-error on
|
|
15
|
-
* .ts/.tsx/.js/.jsx only, and
|
|
16
|
-
*
|
|
13
|
+
* framework itself imports: page/layout/default/denied on pageExtensions,
|
|
14
|
+
* error/global-error and status-code files on script extensions only,
|
|
15
|
+
* middleware/access/route/proxy on .ts/.tsx/.js/.jsx only, and
|
|
16
|
+
* status-code .json files — mirroring this scanner's own recognition
|
|
17
17
|
* rules per family.
|
|
18
18
|
*
|
|
19
19
|
* Exported for the analyze classifier so its provisional classification
|
|
@@ -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;AA4BpB;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,cAAc,GAAE,SAAS,MAAM,EAA4B,GAC1D,OAAO,CAQT;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,aAAkB,GAAG,SAAS,CAuDhF"}
|
|
@@ -72,7 +72,7 @@ export interface AccessGateProps {
|
|
|
72
72
|
* On denial, renders denied.tsx → default.tsx → null instead of failing the page.
|
|
73
73
|
*
|
|
74
74
|
* DeniedComponent is passed instead of a pre-built element so that
|
|
75
|
-
* SlotAccessGate can forward DenySignal.data as
|
|
75
|
+
* SlotAccessGate can forward DenySignal.data as the data prop
|
|
76
76
|
* and slotName as the slot prop after catching the signal.
|
|
77
77
|
*/
|
|
78
78
|
export interface SlotAccessGateProps {
|
|
@@ -120,7 +120,7 @@ export declare function AccessGate(props: AccessGateProps): Promise<ReactNode>;
|
|
|
120
120
|
* a protocol concern. The parent layout and sibling slots still render.
|
|
121
121
|
*
|
|
122
122
|
* DeniedComponent is passed instead of a pre-built element so that
|
|
123
|
-
* DenySignal.data can be forwarded as the
|
|
123
|
+
* DenySignal.data can be forwarded as the data prop
|
|
124
124
|
* and the slot name can be passed as the slot prop. See TIM-488.
|
|
125
125
|
*
|
|
126
126
|
* redirect() in slot access.ts is a dev-mode error — redirecting from a
|
|
@@ -46,8 +46,6 @@ export interface DenyPageEntry {
|
|
|
46
46
|
* { error, digest, reset } contract, not bare deny props. See TIM-1081.
|
|
47
47
|
*/
|
|
48
48
|
kind: 'status' | 'error';
|
|
49
|
-
/** MDX files are server components — rendered with plain props, never ErrorReconstituter. */
|
|
50
|
-
isMdx: boolean;
|
|
51
49
|
/**
|
|
52
50
|
* Position in the segment chain (0 = root, ascending toward leaf).
|
|
53
51
|
* Used by `matchDenyEntry` to reconstruct per-segment ordering for 5xx
|
|
@@ -89,7 +87,7 @@ export interface DenyPageEntry {
|
|
|
89
87
|
* resolution that already carries the position, and would otherwise have to
|
|
90
88
|
* invent an owner it never reads.
|
|
91
89
|
*/
|
|
92
|
-
export type DenyEntryShape = Pick<DenyPageEntry, 'component' | 'kind'
|
|
90
|
+
export type DenyEntryShape = Pick<DenyPageEntry, 'component' | 'kind'>;
|
|
93
91
|
/**
|
|
94
92
|
* Where a matched deny page must render, relative to the catcher that
|
|
95
93
|
* matched it.
|
|
@@ -169,9 +167,9 @@ export declare function placeDenyPage(chain: DenyPageEntry[], status: number, da
|
|
|
169
167
|
* Build the element for a matched deny chain entry with the props contract
|
|
170
168
|
* the file's convention documents:
|
|
171
169
|
*
|
|
172
|
-
* - Status-code files: { status,
|
|
170
|
+
* - Status-code files: { status, data }
|
|
173
171
|
* - error.tsx (TSX): { error, digest, reset } via ErrorReconstituter, plus
|
|
174
|
-
* { status,
|
|
172
|
+
* { status, data } for dual-shape implementations. Without
|
|
175
173
|
* the Error prop, any error.tsx written per the docs (reading
|
|
176
174
|
* error.message) crashes — turning a clean deny(404) into a 500. TIM-1081.
|
|
177
175
|
* - error.mdx: plain { status } — server component, static content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deny-boundary.d.ts","sourceRoot":"","sources":["../../src/server/deny-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAQH,OAAO,EAAgB,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"deny-boundary.d.ts","sourceRoot":"","sources":["../../src/server/deny-boundary.ts"],"names":[],"mappings":"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"}
|
|
@@ -26,7 +26,6 @@ export interface LayoutEntry {
|
|
|
26
26
|
}
|
|
27
27
|
/** Callback to create a debug channel sink for RSC rendering. */
|
|
28
28
|
export type DebugChannelFactory = () => {
|
|
29
|
-
readable: ReadableStream;
|
|
30
29
|
writable: WritableStream;
|
|
31
30
|
};
|
|
32
31
|
/** Callback to pass RSC stream to SSR for HTML rendering. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deny-renderer.d.ts","sourceRoot":"","sources":["../../src/server/deny-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"deny-renderer.d.ts","sourceRoot":"","sources":["../../src/server/deny-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAc7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAKjE,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,iEAAiE;AACjE,MAAM,MAAM,mBAAmB,GAAG,MAAM;IACtC,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,CACtB,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EACrC,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,QAAQ,CAAC,CAAC;AA+BvB;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;AAEhG;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,gBAAgB,EAAE,WAAW,EAAE,EAC/B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,UAAU,EACjB,eAAe,EAAE,OAAO,EACxB,eAAe,EAAE,qBAAqB,EACtC,sBAAsB,EAAE,mBAAmB,EAC3C,OAAO,EAAE,SAAS,EAClB,WAAW,CAAC,EAAE,mBAAmB,EACjC,gBAAgB,SAAW,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAsInB;AAgBD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,gBAAgB,EAAE,WAAW,EAAE,EAC/B,GAAG,EAAE,OAAO,EACZ,eAAe,EAAE,OAAO,EACxB,sBAAsB,EAAE,mBAAmB,EAC3C,gBAAgB,SAAW,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAiDnB"}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Error boundary wrapper — wraps a React element in the error boundaries
|
|
3
3
|
* declared by a route segment (`{status}.tsx`, `4xx.tsx`/`5xx.tsx`, `error.tsx`).
|
|
4
4
|
*
|
|
5
|
-
* This is the single implementation of that walk. It is driven by
|
|
6
|
-
*
|
|
5
|
+
* This is the single implementation of that walk. It is driven by the
|
|
6
|
+
* request-time renderer walking the runtime manifest (`SegmentNode<ManifestFile>`):
|
|
7
7
|
*
|
|
8
|
-
* - `route-element-builder.ts` / `slot-resolver.ts`
|
|
9
|
-
* renderer, walking the runtime manifest (`SegmentNode<ManifestFile>`).
|
|
8
|
+
* - `route-element-builder.ts` / `slot-resolver.ts`
|
|
10
9
|
*
|
|
11
10
|
* `errorBoundaryComponent` is injected rather than imported: `TimberErrorBoundary`
|
|
12
11
|
* is a `'use client'` module, and importing it here would pull client code into
|
|
@@ -18,10 +17,6 @@
|
|
|
18
17
|
import type { ReactNode } from 'react';
|
|
19
18
|
import type { SegmentNode } from '../routing/types.ts';
|
|
20
19
|
import { type LoadedComponent } from './utils/element-type.ts';
|
|
21
|
-
/** The minimum a route file must carry for the walk: a path to classify as MDX. */
|
|
22
|
-
interface BoundaryFile {
|
|
23
|
-
filePath: string;
|
|
24
|
-
}
|
|
25
20
|
/**
|
|
26
21
|
* Framework-injected error boundary wrapper.
|
|
27
22
|
* Wraps content with status-code error boundary handling.
|
|
@@ -32,10 +27,8 @@ interface BoundaryFile {
|
|
|
32
27
|
* construction site and may not import types from a 'use client' module.
|
|
33
28
|
*/
|
|
34
29
|
export interface ErrorBoundaryProps {
|
|
35
|
-
/** The component to render when an error is caught
|
|
30
|
+
/** The component to render when an error is caught. */
|
|
36
31
|
fallbackComponent?: LoadedComponent;
|
|
37
|
-
/** Pre-rendered fallback element (MDX status files — see TIM-503). */
|
|
38
|
-
fallbackElement?: ReactNode;
|
|
39
32
|
/** Status code filter: 400 = any 4xx, 500 = any 5xx, specific number = exact match. */
|
|
40
33
|
status?: number;
|
|
41
34
|
/**
|
|
@@ -103,6 +96,6 @@ export interface ErrorBoundaryWrapConfig<TFile, TElement> {
|
|
|
103
96
|
*
|
|
104
97
|
* See design/10-error-handling.md §"Format-Aware Fallback Chains".
|
|
105
98
|
*/
|
|
106
|
-
export declare function wrapSegmentWithErrorBoundaries<TFile
|
|
99
|
+
export declare function wrapSegmentWithErrorBoundaries<TFile, TElement extends ReactNode>(segment: SegmentNode<TFile>, element: TElement, config: ErrorBoundaryWrapConfig<TFile, TElement>): Promise<TElement>;
|
|
107
100
|
export {};
|
|
108
101
|
//# sourceMappingURL=error-boundary-wrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary-wrapper.d.ts","sourceRoot":"","sources":["../../src/server/error-boundary-wrapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error-boundary-wrapper.d.ts","sourceRoot":"","sources":["../../src/server/error-boundary-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEnF;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,uFAAuF;IACvF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,iEAAiE;AACjE,KAAK,oBAAoB,CAAC,KAAK,IAAI,CACjC,IAAI,EAAE,KAAK,KACR;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE5D,2DAA2D;AAC3D,MAAM,WAAW,uBAAuB,CAAC,KAAK,EAAE,QAAQ;IACtD,8DAA8D;IAC9D,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,QAAQ,CAAC;IAC1D,2EAA2E;IAC3E,UAAU,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACxC;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA2CD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,QAAQ,SAAS,SAAS,EACpF,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAC3B,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC/C,OAAO,CAAC,QAAQ,CAAC,CAmCnB"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as formFlashAls } from "../_chunks/als-registry-C6kcfprT.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as getSegmentParams, B as isDebug, C as redirect, H as addSpanEvent, K as getSpanId, L as getCookieJar, O as getHeaders, T as waitUntil, V as isDevMode, Z as withSpan, b as isDenySignal, q as getTraceId, w as redirectExternal, x as isRedirectSignal, y as deny } from "../_chunks/logger-DqJ2VoAY.js";
|
|
3
3
|
import { t as formatSize } from "../_chunks/format-BKclgVbk.js";
|
|
4
|
-
import { a as parseFormData, i as coerce, n as revalidatePath, r as revalidateTag } from "../_chunks/actions-
|
|
4
|
+
import { a as parseFormData, i as coerce, n as revalidatePath, r as revalidateTag } from "../_chunks/actions-HUdJADAD.js";
|
|
5
5
|
//#region src/shared/redirect-type.ts
|
|
6
6
|
/**
|
|
7
7
|
* Next.js redirect type discriminator.
|
package/dist/server/internal.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { n as isRscContentType, r as isRscRequest } from "../_chunks/rsc-media-type-DDc7duTD.js";
|
|
2
1
|
import { a as timingAls, r as requestContextAls, t as earlyHintsSenderAls } from "../_chunks/als-registry-C6kcfprT.js";
|
|
3
|
-
import { A as
|
|
2
|
+
import { A as getSegmentParams, B as isDebug, D as getHeader, E as applyRequestHeaderOverlay, F as setSegmentParams, G as getOtelTraceId, I as getCookie, J as replaceTraceId, M as runWithRequestContext, N as setMatchedSegmentPath, P as setMutableCookieContext, R as getSetCookieHeaders, W as generateTraceId, X as setSpanAttribute, Y as runWithTraceId, Z as withSpan, _ as RedirectSignal, a as logProxyError, b as isDenySignal, c as logRequestReceived, d as logSwrRefetchFailed, f as logWaitUntilRejected, g as DenySignal, h as swallow, i as logMiddlewareShortCircuit, j as markResponseFlushed, k as getSearchParams, 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, v as RenderError, x as isRedirectSignal, z as getWaitUntil } from "../_chunks/logger-DqJ2VoAY.js";
|
|
4
3
|
import { i as isRscCacheKeyShape, n as RSC_KEY_PARAM, s as rscCacheKey, t as RSC_KEY_HEADERS } from "../_chunks/rsc-cache-key-ClUiXQnK.js";
|
|
5
|
-
import {
|
|
4
|
+
import { t as computeSegmentTreePaths } from "../_chunks/segment-keys-D5hu1hz4.js";
|
|
5
|
+
import { a as fireOnRequestError, c as callOnRequestError, i as cloneWithMutableHeaders, l as hasOnRequestError, n as applyCookieJar, o as makeProxyResolver, r as buildRedirectResponse, s as mergeMissingHeaders, t as requestCspNonce, u as loadInstrumentation } from "../_chunks/csp-nonce-hOGniaG4.js";
|
|
6
|
+
import { n as isRscContentType, r as isRscRequest } from "../_chunks/rsc-media-type-DDc7duTD.js";
|
|
7
|
+
import { i as getMetadataRouteServePath, n as classifyMetadataRoute, r as getMetadataRouteAutoLink, t as METADATA_ROUTE_CONVENTIONS } from "../_chunks/metadata-routes-DSDjM_hJ.js";
|
|
6
8
|
import { r as canonicalize } from "../_chunks/canonicalize-CgHoscYO.js";
|
|
7
9
|
import { n as classifyUrlSegment, r as effectiveUrlSegment } from "../_chunks/segment-classify-C539Pa2O.js";
|
|
8
|
-
import {
|
|
9
|
-
import { i as coerce, t as executeAction } from "../_chunks/actions-
|
|
10
|
-
import { a as getManifestEntry, b as wasInvalidatedSince, c as lookupPrebuiltPayload, d as checkVersionSkew, i as storeOverlayEntry, l as setPrebuiltPayloadSource, n as lookupOverlay, o as hasPrebuiltPayloadSource, r as overlayKey, s as isParamIndependent, u as applyReloadHeaders, v as currentInvalidationEpoch, y as lastInvalidationEpochFor } from "../_chunks/cache-api-
|
|
10
|
+
import { i as collectRouteModulepreloads, n as collectRouteCss, r as collectRouteFonts } from "../_chunks/build-manifest-DWppEdLB.js";
|
|
11
|
+
import { i as coerce, t as executeAction } from "../_chunks/actions-HUdJADAD.js";
|
|
12
|
+
import { a as getManifestEntry, b as wasInvalidatedSince, c as lookupPrebuiltPayload, d as checkVersionSkew, i as storeOverlayEntry, l as setPrebuiltPayloadSource, n as lookupOverlay, o as hasPrebuiltPayloadSource, r as overlayKey, s as isParamIndependent, u as applyReloadHeaders, v as currentInvalidationEpoch, y as lastInvalidationEpochFor } from "../_chunks/cache-api-CAPbZTga.js";
|
|
11
13
|
import { n as createSingleflight } from "../_chunks/singleflight-2lUWfcAk.js";
|
|
12
14
|
import { n as toBracketKey } from "../_chunks/resolve-schema-CBR6Lm4i.js";
|
|
13
15
|
import { t as normalizeParamValue } from "../_chunks/param-value-C8TNYchQ.js";
|
|
@@ -170,179 +172,6 @@ function wrapResponseWithStreamTiming(body, startTime) {
|
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
174
|
//#endregion
|
|
173
|
-
//#region src/server/instrumentation.ts
|
|
174
|
-
/**
|
|
175
|
-
* Instrumentation — loads and runs the user's instrumentation.ts file.
|
|
176
|
-
*
|
|
177
|
-
* instrumentation.ts is a file convention at the project root that exports:
|
|
178
|
-
* - register() — called once at server startup, before the first request
|
|
179
|
-
* - onRequestError() — called for every unhandled server error
|
|
180
|
-
* - logger — any object with info/warn/error/debug methods
|
|
181
|
-
*
|
|
182
|
-
* See design/17-logging.md §"instrumentation.ts — The Entry Point"
|
|
183
|
-
*/
|
|
184
|
-
var _initialized = false;
|
|
185
|
-
var _onRequestError = null;
|
|
186
|
-
/**
|
|
187
|
-
* Load and initialize the user's instrumentation.ts module.
|
|
188
|
-
*
|
|
189
|
-
* - Awaits register() before returning (server blocks on this).
|
|
190
|
-
* - Picks up the logger export and wires it into the framework logger.
|
|
191
|
-
* - Stores onRequestError for later invocation.
|
|
192
|
-
*
|
|
193
|
-
* @param loader - Function that dynamically imports the user's instrumentation module.
|
|
194
|
-
* Returns null if no instrumentation.ts exists.
|
|
195
|
-
*/
|
|
196
|
-
async function loadInstrumentation(loader) {
|
|
197
|
-
if (_initialized) return;
|
|
198
|
-
_initialized = true;
|
|
199
|
-
let mod;
|
|
200
|
-
try {
|
|
201
|
-
mod = await loader();
|
|
202
|
-
} catch (error) {
|
|
203
|
-
console.error("[timber] Failed to load instrumentation.ts:", error);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (!mod) return;
|
|
207
|
-
if (mod.logger && typeof mod.logger.info === "function") setLogger(mod.logger);
|
|
208
|
-
if (typeof mod.onRequestError === "function") _onRequestError = mod.onRequestError;
|
|
209
|
-
if (typeof mod.register === "function") try {
|
|
210
|
-
await mod.register();
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error("[timber] instrumentation.ts register() threw:", error);
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Call the user's onRequestError hook. Catches and logs any errors thrown
|
|
218
|
-
* by the hook itself — it must not affect the response.
|
|
219
|
-
*/
|
|
220
|
-
async function callOnRequestError(error, request, context) {
|
|
221
|
-
if (!_onRequestError) return;
|
|
222
|
-
try {
|
|
223
|
-
await _onRequestError(error, request, context);
|
|
224
|
-
} catch (hookError) {
|
|
225
|
-
console.error("[timber] onRequestError hook threw:", hookError);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Check if onRequestError is registered.
|
|
230
|
-
*/
|
|
231
|
-
function hasOnRequestError() {
|
|
232
|
-
return _onRequestError !== null;
|
|
233
|
-
}
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/server/pipeline-helpers.ts
|
|
236
|
-
/**
|
|
237
|
-
* Build a proxy resolver closure from the declared source. Called exactly
|
|
238
|
-
* once at `createPipeline` setup time, so the hot path sees only the branch
|
|
239
|
-
* that corresponds to this pipeline's configured variant.
|
|
240
|
-
*
|
|
241
|
-
* Returns `null` when the app has no proxy.ts — the hot path short-circuits
|
|
242
|
-
* around `runProxyPhase` entirely in that case.
|
|
243
|
-
*
|
|
244
|
-
* Accepts the sugar form (a bare `ProxyExport` — function or function array)
|
|
245
|
-
* and normalises it to the static variant. Functions and arrays are
|
|
246
|
-
* structurally distinct from the tagged `{ kind: 'lazy', loader }` object,
|
|
247
|
-
* so discrimination is unambiguous.
|
|
248
|
-
*/
|
|
249
|
-
function makeProxyResolver(proxy) {
|
|
250
|
-
if (proxy === void 0) return null;
|
|
251
|
-
if (typeof proxy === "function" || Array.isArray(proxy)) {
|
|
252
|
-
const exp = proxy;
|
|
253
|
-
return () => exp;
|
|
254
|
-
}
|
|
255
|
-
if (proxy.kind === "static") {
|
|
256
|
-
const exp = proxy.export;
|
|
257
|
-
return () => exp;
|
|
258
|
-
}
|
|
259
|
-
const loader = proxy.loader;
|
|
260
|
-
return async () => (await loader()).default;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Apply all Set-Cookie headers from the cookie jar to a Headers object.
|
|
264
|
-
* Each cookie gets its own Set-Cookie header per RFC 6265 §4.1.
|
|
265
|
-
*/
|
|
266
|
-
function applyCookieJar(headers) {
|
|
267
|
-
for (const value of getSetCookieHeaders()) headers.append("Set-Cookie", value);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Merge framework-managed response headers onto a terminal response without
|
|
271
|
-
* overwriting headers the terminal response already set itself.
|
|
272
|
-
*/
|
|
273
|
-
function mergeMissingHeaders(target, source) {
|
|
274
|
-
const existingKeys = new Set([...target.keys()].map((key) => key.toLowerCase()));
|
|
275
|
-
for (const [key, value] of source.entries()) if (!existingKeys.has(key.toLowerCase())) target.append(key, value);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Clone a Response into a fresh one whose header bag is guaranteed mutable.
|
|
279
|
-
*
|
|
280
|
-
* `Response.redirect()` and some platform-level passthrough responses (notably
|
|
281
|
-
* on Cloudflare Workers) return objects with frozen header bags. Calling
|
|
282
|
-
* `.set()` or `.append()` on them throws `TypeError: immutable`, which the
|
|
283
|
-
* pipeline can hit when it appends Set-Cookie or Server-Timing entries.
|
|
284
|
-
*
|
|
285
|
-
* The pipeline calls this at the producer sites where user-controlled
|
|
286
|
-
* responses enter the framework — `outcomeToResponse` for all phase outcomes,
|
|
287
|
-
* and `handleRequest` for metadata-route and auto-sitemap user handlers — so
|
|
288
|
-
* downstream code can write headers without runtime feature-detection.
|
|
289
|
-
*
|
|
290
|
-
* The clone is unconditional. This is a deliberate trade: we avoid a
|
|
291
|
-
* try/catch + thrown `TypeError` on every request (the previous probe-based
|
|
292
|
-
* approach paid that cost on the hot path) and accept one cheap Response
|
|
293
|
-
* rewrap at the framework boundary instead.
|
|
294
|
-
*/
|
|
295
|
-
function cloneWithMutableHeaders(response) {
|
|
296
|
-
return new Response(response.body, {
|
|
297
|
-
status: response.status,
|
|
298
|
-
statusText: response.statusText,
|
|
299
|
-
headers: new Headers(response.headers)
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Build a redirect Response from a RedirectSignal.
|
|
304
|
-
*
|
|
305
|
-
* For RSC payload requests (client navigation), returns 204 + X-Timber-Redirect
|
|
306
|
-
* so the client router can perform a soft SPA redirect. A raw 302 would be
|
|
307
|
-
* turned into an opaque redirect by fetch({redirect:'manual'}), crashing
|
|
308
|
-
* createFromFetch. See design/19-client-navigation.md.
|
|
309
|
-
*/
|
|
310
|
-
function buildRedirectResponse(signal, req, headers) {
|
|
311
|
-
if (isRscRequest(req)) {
|
|
312
|
-
headers.set("X-Timber-Redirect", signal.location);
|
|
313
|
-
return new Response(null, {
|
|
314
|
-
status: 204,
|
|
315
|
-
headers
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
headers.set("Location", signal.location);
|
|
319
|
-
return new Response(null, {
|
|
320
|
-
status: signal.status,
|
|
321
|
-
headers
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Fire the user's onRequestError hook with request context.
|
|
326
|
-
* Extracts request info from the Request object and calls the instrumentation hook.
|
|
327
|
-
*/
|
|
328
|
-
async function fireOnRequestError(error, req, phase) {
|
|
329
|
-
const url = new URL(req.url);
|
|
330
|
-
const headersObj = {};
|
|
331
|
-
req.headers.forEach((v, k) => {
|
|
332
|
-
headersObj[k] = v;
|
|
333
|
-
});
|
|
334
|
-
await callOnRequestError(error, {
|
|
335
|
-
method: req.method,
|
|
336
|
-
path: url.pathname,
|
|
337
|
-
headers: headersObj
|
|
338
|
-
}, {
|
|
339
|
-
phase,
|
|
340
|
-
routePath: url.pathname,
|
|
341
|
-
routeType: "page",
|
|
342
|
-
traceId: getTraceId()
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
//#endregion
|
|
346
175
|
//#region src/server/proxy.ts
|
|
347
176
|
/**
|
|
348
177
|
* Run the proxy pipeline.
|
|
@@ -1686,7 +1515,7 @@ function sendEarlyHints103(links) {
|
|
|
1686
1515
|
* Reconstitute a SerializableError into a real Error instance and render
|
|
1687
1516
|
* the user's error component with the proper props.
|
|
1688
1517
|
*/
|
|
1689
|
-
function ErrorReconstituter({ error: serialized, digest, reset, component, status,
|
|
1518
|
+
function ErrorReconstituter({ error: serialized, digest, reset, component, status, data }) {
|
|
1690
1519
|
const error = Object.assign(new Error(serialized.message), {
|
|
1691
1520
|
name: serialized.name,
|
|
1692
1521
|
...serialized.stack != null ? { stack: serialized.stack } : {}
|
|
@@ -1697,7 +1526,7 @@ function ErrorReconstituter({ error: serialized, digest, reset, component, statu
|
|
|
1697
1526
|
reset,
|
|
1698
1527
|
...status != null ? {
|
|
1699
1528
|
status,
|
|
1700
|
-
|
|
1529
|
+
data
|
|
1701
1530
|
} : {}
|
|
1702
1531
|
});
|
|
1703
1532
|
}
|
|
@@ -1814,13 +1643,10 @@ function matchDenyEntries5xx(chain, status) {
|
|
|
1814
1643
|
function placeDenyPage(chain, status, data, selfKey) {
|
|
1815
1644
|
const entry = matchDenyEntry(chain, status);
|
|
1816
1645
|
if (!entry) return null;
|
|
1817
|
-
if (entry.ownerKey !== selfKey) {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
ownerKey: entry.ownerKey
|
|
1822
|
-
};
|
|
1823
|
-
}
|
|
1646
|
+
if (entry.ownerKey !== selfKey) return {
|
|
1647
|
+
kind: "hoist",
|
|
1648
|
+
ownerKey: entry.ownerKey
|
|
1649
|
+
};
|
|
1824
1650
|
return {
|
|
1825
1651
|
kind: "render",
|
|
1826
1652
|
element: renderDenyEntry(entry, status, data)
|
|
@@ -1830,9 +1656,9 @@ function placeDenyPage(chain, status, data, selfKey) {
|
|
|
1830
1656
|
* Build the element for a matched deny chain entry with the props contract
|
|
1831
1657
|
* the file's convention documents:
|
|
1832
1658
|
*
|
|
1833
|
-
* - Status-code files: { status,
|
|
1659
|
+
* - Status-code files: { status, data }
|
|
1834
1660
|
* - error.tsx (TSX): { error, digest, reset } via ErrorReconstituter, plus
|
|
1835
|
-
* { status,
|
|
1661
|
+
* { status, data } for dual-shape implementations. Without
|
|
1836
1662
|
* the Error prop, any error.tsx written per the docs (reading
|
|
1837
1663
|
* error.message) crashes — turning a clean deny(404) into a 500. TIM-1081.
|
|
1838
1664
|
* - error.mdx: plain { status } — server component, static content.
|
|
@@ -1844,9 +1670,8 @@ function renderDenyEntry(entry, status, data) {
|
|
|
1844
1670
|
function renderDenyPage(entry, status, data, h) {
|
|
1845
1671
|
if (entry.kind !== "error") return h(entry.component, {
|
|
1846
1672
|
status,
|
|
1847
|
-
|
|
1673
|
+
data
|
|
1848
1674
|
});
|
|
1849
|
-
if (entry.isMdx) return h(entry.component, { status });
|
|
1850
1675
|
return h(ErrorReconstituter, {
|
|
1851
1676
|
error: {
|
|
1852
1677
|
message: `Access denied with status ${status}`,
|
|
@@ -1856,7 +1681,7 @@ function renderDenyPage(entry, status, data, h) {
|
|
|
1856
1681
|
reset: void 0,
|
|
1857
1682
|
component: entry.component,
|
|
1858
1683
|
status,
|
|
1859
|
-
|
|
1684
|
+
data
|
|
1860
1685
|
});
|
|
1861
1686
|
}
|
|
1862
1687
|
/**
|
|
@@ -1996,7 +1821,7 @@ async function accessGateFallback(accessFn, segmentName, segmentKey, segmentInde
|
|
|
1996
1821
|
* a protocol concern. The parent layout and sibling slots still render.
|
|
1997
1822
|
*
|
|
1998
1823
|
* DeniedComponent is passed instead of a pre-built element so that
|
|
1999
|
-
* DenySignal.data can be forwarded as the
|
|
1824
|
+
* DenySignal.data can be forwarded as the data prop
|
|
2000
1825
|
* and the slot name can be passed as the slot prop. See TIM-488.
|
|
2001
1826
|
*
|
|
2002
1827
|
* redirect() in slot access.ts is a dev-mode error — redirecting from a
|
|
@@ -2025,7 +1850,7 @@ function buildDeniedFallback(DeniedComponent, slotName, data, createElement) {
|
|
|
2025
1850
|
if (!DeniedComponent) return null;
|
|
2026
1851
|
return createElement(DeniedComponent, {
|
|
2027
1852
|
slot: slotName,
|
|
2028
|
-
|
|
1853
|
+
data
|
|
2029
1854
|
});
|
|
2030
1855
|
}
|
|
2031
1856
|
//#endregion
|