@timber-js/app 0.2.0-alpha.186 → 0.2.0-alpha.188
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-C-Rw9vPc.js → actions-35jnMdeJ.js} +4 -3
- package/dist/_chunks/{actions-C-Rw9vPc.js.map → actions-35jnMdeJ.js.map} +1 -1
- package/dist/_chunks/als-registry-C6kcfprT.js +41 -0
- package/dist/_chunks/als-registry-C6kcfprT.js.map +1 -0
- package/dist/_chunks/{als-slots-mFweg276.js → als-slots-BEEIPKYm.js} +3 -4
- package/dist/_chunks/{als-slots-mFweg276.js.map → als-slots-BEEIPKYm.js.map} +1 -1
- package/dist/_chunks/{cache-api-Cd0VZ_Pd.js → cache-api-DjNrIWRR.js} +7 -13
- package/dist/_chunks/cache-api-DjNrIWRR.js.map +1 -0
- package/dist/_chunks/cli-check-CpmN7Nh-.js +256 -0
- package/dist/_chunks/cli-check-CpmN7Nh-.js.map +1 -0
- package/dist/_chunks/cli-schema-sync-CGMp_Psg.js +298 -0
- package/dist/_chunks/cli-schema-sync-CGMp_Psg.js.map +1 -0
- package/dist/_chunks/{cloudflare-Cs0uZXea.js → cloudflare-CGP6BZKO.js} +4 -3
- package/dist/_chunks/{cloudflare-Cs0uZXea.js.map → cloudflare-CGP6BZKO.js.map} +1 -1
- package/dist/_chunks/convention-lint-kXsgc_-7.js +784 -0
- package/dist/_chunks/convention-lint-kXsgc_-7.js.map +1 -0
- package/dist/_chunks/{error-boundary-DpYRI_I1.js → error-boundary-D-ODYX41.js} +25 -2
- package/dist/_chunks/error-boundary-D-ODYX41.js.map +1 -0
- package/dist/_chunks/file-cache-DmX7OqZP.js +454 -0
- package/dist/_chunks/file-cache-DmX7OqZP.js.map +1 -0
- package/dist/_chunks/{logger-N7e5auP0.js → logger-D8xJZXIN.js} +27 -40
- package/dist/_chunks/logger-D8xJZXIN.js.map +1 -0
- package/dist/_chunks/mdx-file-C005ay-P.js +25 -0
- package/dist/_chunks/mdx-file-C005ay-P.js.map +1 -0
- package/dist/_chunks/{plugin-context-DEGLSJs3.js → plugin-context-rCinWLiE.js} +7 -2
- package/dist/_chunks/{plugin-context-DEGLSJs3.js.map → plugin-context-rCinWLiE.js.map} +1 -1
- package/dist/_chunks/purge-store-Byr8XOjU.js +14 -0
- package/dist/_chunks/purge-store-Byr8XOjU.js.map +1 -0
- package/dist/_chunks/{resolve-schema-Dz3fcFUo.js → resolve-schema-5ma5pp1b.js} +2 -2
- package/dist/_chunks/{resolve-schema-Dz3fcFUo.js.map → resolve-schema-5ma5pp1b.js.map} +1 -1
- package/dist/_chunks/rsc-media-type-DRqE_lD_.js +46 -0
- package/dist/_chunks/rsc-media-type-DRqE_lD_.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-CKgHC2MB.js → scanner-C8b0Gcw3.js} +5 -298
- package/dist/_chunks/scanner-C8b0Gcw3.js.map +1 -0
- package/dist/_chunks/schema-bridge-Cc2Gngu1.js +199 -0
- package/dist/_chunks/schema-bridge-Cc2Gngu1.js.map +1 -0
- package/dist/_chunks/segment-classify-C539Pa2O.js.map +1 -1
- package/dist/_chunks/{param-value-C8TNYchQ.js → segment-context-CjOlyB8Y.js} +33 -2
- package/dist/_chunks/segment-context-CjOlyB8Y.js.map +1 -0
- package/dist/_chunks/segment-keys-BawYuNFO.js.map +1 -1
- package/dist/_chunks/{use-query-states-DFvWd-EA.js → use-query-states-BbU5Ge1V.js} +74 -26
- package/dist/_chunks/use-query-states-BbU5Ge1V.js.map +1 -0
- package/dist/_chunks/{navigation-root-B29qg0_T.js → use-segment-params-C4r4BD9T.js} +129 -5
- package/dist/_chunks/use-segment-params-C4r4BD9T.js.map +1 -0
- package/dist/_chunks/walkers-RzN6AFjr.js +141 -0
- package/dist/_chunks/walkers-RzN6AFjr.js.map +1 -0
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/compress-module.d.ts +12 -0
- package/dist/adapters/compress-module.d.ts.map +1 -1
- package/dist/adapters/nitro.js +54 -2
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cdn/cloudflare-purge.js +30 -0
- package/dist/cdn/cloudflare-purge.js.map +1 -0
- package/dist/cdn/fastly-purge.js +33 -0
- package/dist/cdn/fastly-purge.js.map +1 -0
- package/dist/cdn/index.js +94 -0
- package/dist/cdn/index.js.map +1 -0
- package/dist/cdn/workers-cache-purge.js +35 -0
- package/dist/cdn/workers-cache-purge.js.map +1 -0
- package/dist/cli-check.d.ts +153 -0
- package/dist/cli-check.d.ts.map +1 -0
- package/dist/cli.d.ts +34 -8
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +46 -21
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/index.d.ts +1 -1
- package/dist/client/browser-entry/index.d.ts.map +1 -1
- package/dist/client/error-boundary.d.ts +6 -0
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +27 -33
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +33 -17
- package/dist/client/internal.js.map +1 -1
- package/dist/client/link.d.ts +1 -7
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/navigation-commit.d.ts +16 -0
- package/dist/client/navigation-commit.d.ts.map +1 -1
- package/dist/client/router-pipeline.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +9 -1
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +14 -0
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/use-query-states.d.ts +9 -3
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/codec.js +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +2 -2
- package/dist/cookies/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -477
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +1 -1
- package/dist/plugin-context.d.ts +15 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts +0 -9
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +24 -0
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/codegen-shared.d.ts +3 -44
- package/dist/routing/codegen-shared.d.ts.map +1 -1
- package/dist/routing/codegen-types.d.ts +10 -31
- package/dist/routing/codegen-types.d.ts.map +1 -1
- package/dist/routing/codegen-write.d.ts +51 -0
- package/dist/routing/codegen-write.d.ts.map +1 -0
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts +18 -4
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/export-detect.d.ts +16 -0
- package/dist/routing/export-detect.d.ts.map +1 -1
- package/dist/routing/index.js +3 -2
- package/dist/routing/link-codegen.d.ts +19 -4
- package/dist/routing/link-codegen.d.ts.map +1 -1
- package/dist/routing/manifest-codegen.d.ts +1 -7
- package/dist/routing/manifest-codegen.d.ts.map +1 -1
- package/dist/routing/segment-keys.d.ts +22 -0
- package/dist/routing/segment-keys.d.ts.map +1 -1
- package/dist/routing/types.d.ts +0 -6
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/schema-bridge.d.ts +60 -9
- package/dist/schema-bridge.d.ts.map +1 -1
- package/dist/search-params/define.d.ts +62 -8
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.d.ts +0 -1
- package/dist/search-params/index.d.ts.map +1 -1
- package/dist/search-params/index.js +66 -29
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/parse-total.d.ts +70 -0
- package/dist/search-params/parse-total.d.ts.map +1 -0
- package/dist/search-params/wrappers.d.ts +26 -3
- package/dist/search-params/wrappers.d.ts.map +1 -1
- package/dist/server/access-gate.d.ts +19 -8
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +16 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/chain-url-parts.d.ts +2 -3
- package/dist/server/chain-url-parts.d.ts.map +1 -1
- package/dist/server/compress.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts +148 -15
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/deny-renderer.d.ts +2 -2
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/error-boundary-wrapper.d.ts +85 -15
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.d.ts +3 -1
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +344 -237
- package/dist/server/internal.js.map +1 -1
- package/dist/server/metadata-collector.d.ts +52 -0
- package/dist/server/metadata-collector.d.ts.map +1 -0
- package/dist/server/param-coercion.d.ts +12 -5
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-helpers.d.ts.map +1 -1
- package/dist/server/pipeline-outcome.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +23 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +1 -12
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-cache-key-guard.d.ts.map +1 -1
- package/dist/server/rsc-entry/deny-fallback.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +0 -7
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts +0 -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/revalidate-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +1 -3
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +12 -0
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +0 -2
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/skippable-prefix.d.ts +3 -0
- package/dist/server/skippable-prefix.d.ts.map +1 -1
- package/dist/server/slot-resolver.d.ts +18 -19
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-bridge-types.d.ts +11 -0
- package/dist/server/ssr-bridge-types.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts +0 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/state-tree-diff.d.ts +9 -16
- package/dist/server/state-tree-diff.d.ts.map +1 -1
- package/dist/server/static-generator.d.ts.map +1 -1
- package/dist/server/status-code-resolver.d.ts +8 -1
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/tree-builder.d.ts +28 -43
- package/dist/server/tree-builder.d.ts.map +1 -1
- package/dist/server/types.d.ts +12 -7
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/utils/element-type.d.ts +40 -0
- package/dist/server/utils/element-type.d.ts.map +1 -0
- package/dist/shared/rsc-media-type.d.ts +40 -0
- package/dist/shared/rsc-media-type.d.ts.map +1 -0
- package/dist/shared/segment-info.d.ts +7 -0
- package/dist/shared/segment-info.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +1 -1
- package/docs/api/33-api-search-params.mdx +38 -16
- package/docs/api/35-api-typescript.mdx +3 -3
- package/docs/api/36-cli.mdx +34 -7
- package/docs/learn/00-introduction.mdx +1 -1
- package/docs/learn/02-pages-and-layouts.mdx +1 -1
- package/docs/learn/05-typed-params.mdx +8 -8
- package/docs/learn/07-typed-routes.mdx +12 -7
- package/docs/learn/11-error-handling.mdx +16 -0
- package/docs/more/01-advanced-routing.mdx +1 -1
- package/docs/more/03-coming-from-nextjs.mdx +2 -2
- package/docs/more/50-ai-agent-instructions.mdx +6 -4
- package/package.json +8 -5
- package/src/adapters/cloudflare.ts +4 -1
- package/src/adapters/compress-module.ts +79 -1
- package/src/cli-check.ts +458 -0
- package/src/cli.ts +59 -24
- package/src/client/browser-entry/action-dispatch.ts +2 -1
- package/src/client/browser-entry/index.ts +0 -5
- package/src/client/error-boundary.tsx +65 -1
- package/src/client/index.ts +14 -3
- package/src/client/link.tsx +65 -64
- package/src/client/navigation-commit.ts +27 -4
- package/src/client/params-context.ts +4 -4
- package/src/client/router-pipeline.ts +4 -0
- package/src/client/router.ts +1 -0
- package/src/client/rsc-fetch.ts +14 -4
- package/src/client/segment-cache.ts +26 -5
- package/src/client/use-query-states.ts +102 -39
- package/src/cookies/define-cookie.ts +6 -1
- package/src/index.ts +20 -3
- package/src/plugin-context.ts +26 -0
- package/src/plugins/routing.ts +84 -146
- package/src/plugins/shims.ts +0 -1
- package/src/plugins/static-build.ts +78 -24
- package/src/routing/codegen-shared.ts +3 -79
- package/src/routing/codegen-types.ts +10 -31
- package/src/routing/codegen-write.ts +139 -0
- package/src/routing/codegen.ts +56 -182
- package/src/routing/convention-lint.ts +139 -40
- package/src/routing/export-detect.ts +151 -7
- package/src/routing/link-codegen.ts +32 -65
- package/src/routing/manifest-codegen.ts +1 -59
- package/src/routing/scanner.ts +3 -3
- package/src/routing/segment-keys.ts +37 -0
- package/src/routing/types.ts +0 -6
- package/src/schema-bridge.ts +180 -58
- package/src/search-params/define.ts +102 -37
- package/src/search-params/index.ts +0 -1
- package/src/search-params/parse-total.ts +78 -0
- package/src/search-params/wrappers.ts +60 -11
- package/src/server/access-gate.tsx +61 -68
- package/src/server/action-handler.ts +1 -4
- package/src/server/als-registry.ts +16 -0
- package/src/server/chain-url-parts.ts +2 -3
- package/src/server/compress.ts +9 -1
- package/src/server/deny-boundary.ts +269 -41
- package/src/server/deny-renderer.ts +32 -21
- package/src/server/error-boundary-wrapper.ts +166 -79
- package/src/server/index.ts +1 -3
- package/src/server/internal.ts +2 -2
- package/src/server/metadata-collector.ts +115 -0
- package/src/server/param-coercion.ts +13 -61
- package/src/server/pipeline-helpers.ts +2 -2
- package/src/server/pipeline-outcome.ts +2 -1
- package/src/server/pipeline-phases.ts +9 -9
- package/src/server/primitives.ts +25 -0
- package/src/server/route-element-builder.ts +169 -194
- package/src/server/rsc-cache-key-guard.ts +2 -8
- package/src/server/rsc-entry/deny-fallback.ts +3 -2
- package/src/server/rsc-entry/error-renderer.ts +31 -11
- package/src/server/rsc-entry/helpers.ts +3 -12
- package/src/server/rsc-entry/index.ts +0 -5
- package/src/server/rsc-entry/render-route.ts +14 -11
- package/src/server/rsc-entry/revalidate-renderer.ts +2 -1
- package/src/server/rsc-entry/rsc-payload.ts +104 -20
- package/src/server/rsc-entry/rsc-stream.ts +25 -2
- package/src/server/rsc-entry/ssr-renderer.ts +28 -16
- package/src/server/skippable-prefix.ts +21 -39
- package/src/server/slot-resolver.ts +69 -189
- package/src/server/ssr-bridge-types.ts +12 -0
- package/src/server/ssr-entry.ts +8 -6
- package/src/server/state-tree-diff.ts +11 -62
- package/src/server/static-generator.ts +3 -2
- package/src/server/status-code-resolver.ts +28 -11
- package/src/server/tree-builder.ts +35 -228
- package/src/server/types.ts +12 -7
- package/src/server/utils/element-type.ts +72 -0
- package/src/shared/rsc-media-type.ts +43 -0
- package/src/shared/segment-info.ts +7 -0
- package/dist/_chunks/cache-api-Cd0VZ_Pd.js.map +0 -1
- package/dist/_chunks/cli-schema-sync-CKgHC2MB.js.map +0 -1
- package/dist/_chunks/error-boundary-DpYRI_I1.js.map +0 -1
- package/dist/_chunks/logger-N7e5auP0.js.map +0 -1
- package/dist/_chunks/navigation-root-B29qg0_T.js.map +0 -1
- package/dist/_chunks/param-value-C8TNYchQ.js.map +0 -1
- package/dist/_chunks/registry-DbJPKoBp.js +0 -20
- package/dist/_chunks/registry-DbJPKoBp.js.map +0 -1
- package/dist/_chunks/schema-bridge-DT_Tn0Xf.js +0 -119
- package/dist/_chunks/schema-bridge-DT_Tn0Xf.js.map +0 -1
- package/dist/_chunks/segment-context-ZDnXDkbz.js +0 -34
- package/dist/_chunks/segment-context-ZDnXDkbz.js.map +0 -1
- package/dist/_chunks/use-query-states-DFvWd-EA.js.map +0 -1
- package/dist/_chunks/use-segment-params-ClyUNq4d.js +0 -128
- package/dist/_chunks/use-segment-params-ClyUNq4d.js.map +0 -1
- package/dist/_chunks/walkers-BhhwI9TD.js +0 -936
- package/dist/_chunks/walkers-BhhwI9TD.js.map +0 -1
- package/dist/search-params/registry.d.ts +0 -20
- package/dist/search-params/registry.d.ts.map +0 -1
- package/dist/segment-params/define.d.ts +0 -83
- package/dist/segment-params/define.d.ts.map +0 -1
- package/dist/segment-params/index.d.ts +0 -3
- package/dist/segment-params/index.d.ts.map +0 -1
- package/dist/segment-params/index.js +0 -70
- package/dist/segment-params/index.js.map +0 -1
- package/src/search-params/registry.ts +0 -31
- package/src/segment-params/define.ts +0 -226
- package/src/segment-params/index.ts +0 -9
|
@@ -67,8 +67,15 @@ export interface SlotDeniedResolution<TFile> {
|
|
|
67
67
|
* @param status - The HTTP status code (4xx or 5xx).
|
|
68
68
|
* @param segments - The matched segment chain from root (index 0) to leaf (last).
|
|
69
69
|
* @param format - The response format family ('component' or 'json'). Defaults to 'component'.
|
|
70
|
+
* @param maxIndex - Optional upper bound on the segment index to search.
|
|
71
|
+
* When set, the resolver only considers segments `0..maxIndex` (inclusive),
|
|
72
|
+
* skipping any segments deeper in the tree. Used by the deny renderers to
|
|
73
|
+
* prevent resolving a status file below a denied segment — matching
|
|
74
|
+
* `buildDenyPageChain`'s start-at-i semantics. The error renderers omit
|
|
75
|
+
* this parameter, so the full chain is searched — a 500 from a leaf page
|
|
76
|
+
* should use the leaf's own `5xx.tsx`. See TIM-1358.
|
|
70
77
|
*/
|
|
71
|
-
export declare function resolveStatusFile<TFile>(status: number, segments: ReadonlyArray<SegmentNode<TFile>>, format?: StatusFileFormat): StatusFileResolution<TFile> | null;
|
|
78
|
+
export declare function resolveStatusFile<TFile>(status: number, segments: ReadonlyArray<SegmentNode<TFile>>, format?: StatusFileFormat, maxIndex?: number): StatusFileResolution<TFile> | null;
|
|
72
79
|
/**
|
|
73
80
|
* Resolve the denial file for a parallel route slot.
|
|
74
81
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-code-resolver.d.ts","sourceRoot":"","sources":["../../src/server/status-code-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,UAAU,GACV,OAAO,CAAC;AAEZ,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,MAAM,CAAC;AAEpD,kEAAkE;AAClE,MAAM,WAAW,oBAAoB,CAAC,KAAK;IACzC,8BAA8B;IAC9B,IAAI,EAAE,KAAK,CAAC;IACZ,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,IAAI,EAAE,cAAc,CAAC;IACrB,8DAA8D;IAC9D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAElD,8CAA8C;AAC9C,MAAM,WAAW,oBAAoB,CAAC,KAAK;IACzC,0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K,CAAC,GAAG,IAAI,CAKpC;AA6FD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EACrC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,GAC3B,oBAAoB,CAAC,KAAK,CAAC,GAAG,IAAI,CAYpC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { ReactNode } from 'react';
|
|
13
13
|
import type { RouteFile, SegmentNode } from '../routing/types.js';
|
|
14
|
+
import type { LoadedComponent } from './utils/element-type.js';
|
|
14
15
|
/** A loaded module for a route file convention. */
|
|
15
16
|
export interface LoadedModule {
|
|
16
17
|
/** The default export (component, access function, etc.) */
|
|
@@ -20,18 +21,6 @@ export interface LoadedModule {
|
|
|
20
21
|
}
|
|
21
22
|
/** Function that loads a route file's module. */
|
|
22
23
|
export type ModuleLoader = (file: RouteFile) => LoadedModule | Promise<LoadedModule>;
|
|
23
|
-
/**
|
|
24
|
-
* A React component reference loaded from a route module's default export.
|
|
25
|
-
*
|
|
26
|
-
* Loaded modules' `default` is typed as `unknown` (modules are dynamic), so
|
|
27
|
-
* call sites narrow it through `isValidElementType` (below) before treating
|
|
28
|
-
* it as a component. The signature is a callable returning `ReactNode` —
|
|
29
|
-
* TypeScript's view of every valid React component shape, including exotic
|
|
30
|
-
* components (`memo`, `forwardRef`, `lazy`) which the type system treats as
|
|
31
|
-
* callable even though their runtime values are objects with `$$typeof`
|
|
32
|
-
* markers rather than functions.
|
|
33
|
-
*/
|
|
34
|
-
export type LoadedComponent = (...args: unknown[]) => ReactNode;
|
|
35
24
|
/**
|
|
36
25
|
* Function that creates a React element. Matches React.createElement signature.
|
|
37
26
|
*
|
|
@@ -77,19 +66,41 @@ export interface AccessGateProps {
|
|
|
77
66
|
/** Segment name for dev logging (e.g. "authenticated", "dashboard"). */
|
|
78
67
|
segmentName?: string;
|
|
79
68
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
69
|
+
* Segment key of the gated segment (`computeSegmentKeys`). Decides whether
|
|
70
|
+
* a matched deny page renders here or is hoisted to the segment that owns
|
|
71
|
+
* it. Omitted by construction sites that build no deny chains — with no
|
|
72
|
+
* chain there is nothing to place. See TIM-1356.
|
|
73
|
+
*/
|
|
74
|
+
segmentKey?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Index of this segment in the matched segment chain. Recorded in ALS
|
|
77
|
+
* when the gate catches a DenySignal so post-render consumers
|
|
78
|
+
* (buildSegmentInfo, X-Timber-Segments) can bound the segment list
|
|
79
|
+
* without a pre-render access pass. See TIM-1363.
|
|
84
80
|
*/
|
|
85
|
-
|
|
81
|
+
segmentIndex?: number;
|
|
86
82
|
/**
|
|
87
83
|
* Deny page fallback chain. When provided and a DenySignal is caught,
|
|
88
84
|
* AccessGate renders the matching deny page in-tree instead of throwing.
|
|
89
85
|
* This prevents the error from reaching React Flight, eliminating the
|
|
90
86
|
* second render pass. See TIM-666.
|
|
87
|
+
*
|
|
88
|
+
* Omitted for skipped segments — a deny there must hard-navigate to
|
|
89
|
+
* avoid rendering the deny page inside cached layout chrome (TIM-1074).
|
|
91
90
|
*/
|
|
92
91
|
denyPages?: import('./deny-boundary.js').DenyPageEntry[];
|
|
92
|
+
/**
|
|
93
|
+
* When true, this gate wraps a skipped segment. On deny, the gate
|
|
94
|
+
* records the deny in ALS and rethrows so the response path can
|
|
95
|
+
* return rscErrorEnvelope for a client hard-navigate.
|
|
96
|
+
*/
|
|
97
|
+
skippedSegment?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Shell settlement callback. Called when the gate finishes (pass or
|
|
100
|
+
* deny). Tracked by shellSettled so the HTTP status is not committed
|
|
101
|
+
* before async access checks complete. See TIM-1045, TIM-1363.
|
|
102
|
+
*/
|
|
103
|
+
onSettled?: () => void;
|
|
93
104
|
children: ReactNode;
|
|
94
105
|
}
|
|
95
106
|
/**
|
|
@@ -110,32 +121,6 @@ export interface SlotAccessGateProps {
|
|
|
110
121
|
createElement: CreateElement;
|
|
111
122
|
defaultFallback: ReactNode;
|
|
112
123
|
children: ReactNode;
|
|
113
|
-
/**
|
|
114
|
-
* Pre-computed verdict from eager access evaluation. When provided,
|
|
115
|
-
* SlotAccessGate replays it synchronously instead of re-calling accessFn.
|
|
116
|
-
* 'pass' → render children. DenySignal → graceful degradation.
|
|
117
|
-
* undefined → call accessFn during render (backward compat, error re-run).
|
|
118
|
-
*/
|
|
119
|
-
verdict?: 'pass' | import('./primitives.js').DenySignal | import('./primitives.js').RedirectSignal;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Framework-injected error boundary wrapper.
|
|
123
|
-
* Wraps content with status-code error boundary handling.
|
|
124
|
-
*
|
|
125
|
-
* Field types must agree with `TimberErrorBoundaryProps` in
|
|
126
|
-
* `client/error-boundary.tsx`. The two are kept structurally compatible by
|
|
127
|
-
* convention rather than by direct type import — tree-builder.ts is the
|
|
128
|
-
* server-side construction site and may not import types from a 'use client'
|
|
129
|
-
* module to keep the server barrel free of client coupling.
|
|
130
|
-
*/
|
|
131
|
-
export interface ErrorBoundaryProps {
|
|
132
|
-
/** The component to render when an error is caught (TSX status files). */
|
|
133
|
-
fallbackComponent?: LoadedComponent;
|
|
134
|
-
/** Pre-rendered fallback element (MDX status files — see TIM-503). */
|
|
135
|
-
fallbackElement?: ReactNode;
|
|
136
|
-
/** Status code filter: 400 = any 4xx, 500 = any 5xx, specific number = exact match. */
|
|
137
|
-
status?: number;
|
|
138
|
-
children: ReactNode;
|
|
139
124
|
}
|
|
140
125
|
/**
|
|
141
126
|
* Result of building the element tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-builder.d.ts","sourceRoot":"","sources":["../../src/server/tree-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MA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AAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,oBAAoB,EAAE,aAAa,EAAE,CAAC;IACzD;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,wFAAwF;IACxF,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,SAAS,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAID;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAkF1F"}
|
package/dist/server/types.d.ts
CHANGED
|
@@ -24,21 +24,26 @@ export interface MiddlewareContext {
|
|
|
24
24
|
* `req` is the original incoming Request; `headers` is the response-headers
|
|
25
25
|
* container the framework will apply to the final Response.
|
|
26
26
|
*
|
|
27
|
-
* Segment params and query parameters are NOT on this context — they are
|
|
28
|
-
*
|
|
27
|
+
* Segment params and query parameters are NOT on this context — they are read
|
|
28
|
+
* the same way pages read them:
|
|
29
29
|
*
|
|
30
30
|
* ```ts
|
|
31
|
-
* // app/
|
|
32
|
-
* export
|
|
31
|
+
* // app/schema.ts — every dynamic segment's codec, keyed by bracket name
|
|
32
|
+
* export default defineSchema({ segmentParams: { '[id]': z.coerce.number() } });
|
|
33
|
+
*
|
|
33
34
|
* // app/api/users/[id]/route.ts
|
|
34
|
-
* import {
|
|
35
|
+
* import { getSegmentParams } from '@timber-js/app/server';
|
|
36
|
+
* import { SEGMENT_PATH } from './$segment';
|
|
35
37
|
* export async function GET() {
|
|
36
|
-
* const { id } =
|
|
38
|
+
* const { id } = getSegmentParams(SEGMENT_PATH); // typed number — 404 on bad input
|
|
37
39
|
* }
|
|
38
40
|
* ```
|
|
39
41
|
*
|
|
42
|
+
* For query parameters, import a `defineSearchParams` definition and call
|
|
43
|
+
* `.get()` on it.
|
|
44
|
+
*
|
|
40
45
|
* See design/07-routing.md §"RouteContext", design/23-search-params.md,
|
|
41
|
-
* design/
|
|
46
|
+
* design/41-global-params.md.
|
|
42
47
|
*/
|
|
43
48
|
export interface RouteContext {
|
|
44
49
|
req: Request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,gBAAgB,EAAE,GAClB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAAE,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,OAAO,CAAC;IACb,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACjD,wEAAwE;IACxE,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;CAC1C;AAED
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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CAAC,CAAC;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IACD;;;;;;OAMG;IACH,KAAY,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAAC,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,cAAc,GAAG,cAAc,IAAI,MAC3E,OAAO,GACP,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component-type validation for values loaded from route modules.
|
|
3
|
+
*
|
|
4
|
+
* Route modules are loaded dynamically, so their `default` export is
|
|
5
|
+
* `unknown`. Every construction site that wants to pass one to
|
|
6
|
+
* `createElement` narrows it through `isValidElementType` first.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactNode } from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* A React component reference loaded from a route module's default export.
|
|
11
|
+
*
|
|
12
|
+
* Loaded modules' `default` is typed as `unknown` (modules are dynamic), so
|
|
13
|
+
* call sites narrow it through `isValidElementType` (below) before treating
|
|
14
|
+
* it as a component. The signature is a callable returning `ReactNode` —
|
|
15
|
+
* TypeScript's view of every valid React component shape, including exotic
|
|
16
|
+
* components (`memo`, `forwardRef`, `lazy`) which the type system treats as
|
|
17
|
+
* callable even though their runtime values are objects with `$$typeof`
|
|
18
|
+
* markers rather than functions.
|
|
19
|
+
*/
|
|
20
|
+
export type LoadedComponent = (...args: unknown[]) => ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Validate that a loaded module's `default` export is something React
|
|
23
|
+
* accepts as the first argument to `createElement` — i.e. a valid component
|
|
24
|
+
* type. React doesn't export `isValidElementType` (only `isValidElement`,
|
|
25
|
+
* which checks for *elements*, not *component types*), so this mirrors
|
|
26
|
+
* React's internal check:
|
|
27
|
+
*
|
|
28
|
+
* - functions → function or class components
|
|
29
|
+
* - objects with a `$$typeof` matching one of React's known component
|
|
30
|
+
* markers → exotic components (`memo`, `forwardRef`, `lazy`, context,
|
|
31
|
+
* suspense, client references via `@vitejs/plugin-rsc`)
|
|
32
|
+
*
|
|
33
|
+
* Strings (HTML tag names) are valid for `createElement` but never appear
|
|
34
|
+
* as a route module's default export, so they're not recognized here.
|
|
35
|
+
*
|
|
36
|
+
* Anything else (numbers, plain config objects, JSON, etc.) is rejected so
|
|
37
|
+
* the boundary wrapper is skipped rather than crashing inside React.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isValidElementType(value: unknown): value is LoadedComponent;
|
|
40
|
+
//# sourceMappingURL=element-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-type.d.ts","sourceRoot":"","sources":["../../../src/server/utils/element-type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,SAAS,CAAC;AA2BhE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAK3E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The RSC Flight media type, and the request predicate over it.
|
|
3
|
+
*
|
|
4
|
+
* One module owns the string because two independently-written spellings of
|
|
5
|
+
* "is this an RSC request?" must agree, and the consequence of them
|
|
6
|
+
* disagreeing is cache poisoning rather than a visible bug. The Cloudflare
|
|
7
|
+
* adapter's `isRsc` decides what may enter the edge cache; the origin's
|
|
8
|
+
* pipeline decides which headers may vary the response. TIM-1269 made the
|
|
9
|
+
* adapter's `VARY_HONORED` allowlist exempt `Accept` *because* `isRsc`
|
|
10
|
+
* excludes Flight responses from the cache, and exempt the `X-Timber-*`
|
|
11
|
+
* headers *because* the origin reads them only behind its own RSC check. If
|
|
12
|
+
* one predicate is ever tightened (a real media-type parse, a
|
|
13
|
+
* parameter-aware match) and the other is not, the adapter can classify a
|
|
14
|
+
* request as a document while the origin treats it as RSC, and store a
|
|
15
|
+
* Flight payload under the document's key — the class
|
|
16
|
+
* `design/48-payload-addressing.md` exists to prevent.
|
|
17
|
+
*
|
|
18
|
+
* `tests/rsc-media-type-single-source.test.ts` fails if the literal reappears
|
|
19
|
+
* in executable source outside this file.
|
|
20
|
+
*
|
|
21
|
+
* Isomorphic: zero imports, so `adapters/cloudflare.ts` — which Node's native
|
|
22
|
+
* ESM loader evaluates before Vite's resolver exists — can load it and
|
|
23
|
+
* interpolate the value into the generated worker. Same precedent as
|
|
24
|
+
* `shared/rsc-cache-key.ts`.
|
|
25
|
+
*
|
|
26
|
+
* See design/19-client-navigation.md, design/25-production-deployments.md
|
|
27
|
+
* §"`Vary` and the Workers Cache API".
|
|
28
|
+
*/
|
|
29
|
+
/** Media type of a React Flight payload. */
|
|
30
|
+
export declare const RSC_CONTENT_TYPE = "text/x-component";
|
|
31
|
+
/**
|
|
32
|
+
* Is this request asking for an RSC payload rather than a full document?
|
|
33
|
+
*
|
|
34
|
+
* Substring containment, deliberately: `Accept` is a list, and a client may
|
|
35
|
+
* send `text/x-component;charset=utf-8` or list it alongside other types.
|
|
36
|
+
* Tightening this to a real media-type parse is a behaviour change that has
|
|
37
|
+
* to move the adapter's generated `isRsc` in the same commit — see above.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isRscRequest(req: Request): boolean;
|
|
40
|
+
//# sourceMappingURL=rsc-media-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-media-type.d.ts","sourceRoot":"","sources":["../../src/shared/rsc-media-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
|
@@ -38,6 +38,13 @@ export interface SegmentInfo {
|
|
|
38
38
|
denied?: boolean;
|
|
39
39
|
/** True when the slot was skipped (cached content reused). Payloads with skipped slots are not replayable. */
|
|
40
40
|
skipped?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Content key for slot entries — encodes owner parts, slot name, matched
|
|
43
|
+
* entry file, and slot params. The client stores and advertises this key;
|
|
44
|
+
* the server computes the destination key and checks membership.
|
|
45
|
+
* Replaces URL-based departing/destination diffing (TIM-1370).
|
|
46
|
+
*/
|
|
47
|
+
contentKey?: string;
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
50
|
* The client's `X-Timber-State-Tree` request header.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment-info.d.ts","sourceRoot":"","sources":["../../src/shared/segment-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mFAAmF;IACnF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8GAA8G;IAC9G,OAAO,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"segment-info.d.ts","sourceRoot":"","sources":["../../src/shared/segment-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mFAAmF;IACnF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8GAA8G;IAC9G,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
|
@@ -161,7 +161,7 @@ interface RouteContext {
|
|
|
161
161
|
}
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
Segment params and query params are **not** on `RouteContext`. Read them
|
|
164
|
+
Segment params and query params are **not** on `RouteContext`. Read them the same way pages do — `getSegmentParams(SEGMENT_PATH)` (importing `SEGMENT_PATH` from the route's `./$segment` module) and `searchParams.get()` on an imported definition. For the raw query string, use `new URL(ctx.req.url).searchParams`.
|
|
165
165
|
|
|
166
166
|
### `MiddlewareContext`
|
|
167
167
|
|
|
@@ -45,9 +45,8 @@ Note: `z.coerce.*` schemas declare input `unknown`, so a coerce schema without `
|
|
|
45
45
|
| `.useQueryStates(opts?)` | Client hook — read and update typed search params |
|
|
46
46
|
| `.extend(codecs)` | Add additional params |
|
|
47
47
|
| `.pick(...keys)` | Create a subset |
|
|
48
|
-
| `.serialize(values)` | Convert typed values to URL search string |
|
|
49
48
|
| `.href(base, values)` | Build a full URL with params |
|
|
50
|
-
| `.
|
|
49
|
+
| `.buildSearchParams(values)` | Serialize to a query string — pass to `<Link searchParams>` |
|
|
51
50
|
| `.codecs` | Read-only codec map |
|
|
52
51
|
| `.urlKeys` | Read-only URL key alias map |
|
|
53
52
|
|
|
@@ -110,31 +109,52 @@ The codec protocol shared across search params, segment params, and cookies. See
|
|
|
110
109
|
interface SearchParamCodec<T> {
|
|
111
110
|
parse(value: string | string[] | undefined): T;
|
|
112
111
|
serialize(value: T): string | null;
|
|
112
|
+
urlKey?: string;
|
|
113
|
+
// optional total entry point — preferred over parse when present
|
|
114
|
+
parseServerSide?(value: string | string[] | undefined): T;
|
|
113
115
|
}
|
|
114
116
|
```
|
|
115
117
|
|
|
118
|
+
`parse` receives the **raw** URL value — `string | string[] | undefined` — because a param may be absent (`/products`) or repeated (`?q=a&q=b`). A codec must handle all three.
|
|
119
|
+
|
|
120
|
+
If handling all three in `parse` is awkward — as it is for a nuqs parser, whose `parse` is written for a present scalar — publish `parseServerSide` instead. Timber calls it wherever it invokes the codec, and its return type is the field's type: a codec that answers `null` for an absent param is a `SearchParamCodec<T | null>`.
|
|
121
|
+
|
|
116
122
|
Compatible codecs:
|
|
117
123
|
|
|
118
|
-
- **Zod/Valibot/ArkType schemas** — auto-detected via Standard Schema
|
|
119
|
-
- **nuqs parsers** — `parseAsInteger`, `parseAsString`, `parseAsBoolean`
|
|
124
|
+
- **Zod/Valibot/ArkType schemas** — auto-detected via Standard Schema. Total over absent and repeated input, so this is the safe default.
|
|
120
125
|
- **Custom** — any object implementing the interface
|
|
126
|
+
- **nuqs parsers** — total through timber, with one exception. See below.
|
|
127
|
+
|
|
128
|
+
## Parsers come from nuqs
|
|
129
|
+
|
|
130
|
+
Timber does not ship or re-export `parseAs*` parsers. Import them from [nuqs](https://nuqs.47ng.com/), which is a peer dependency; timber ships the wrappers (`withDefault`, `withUrlKey`) and the schema bridge.
|
|
131
|
+
|
|
132
|
+
nuqs checks whether a param is present before calling `parse`, so a parser's `parse` assumes a present scalar. Timber calls the parser's `parseServerSide` instead — nuqs's own adapter for the raw URL value — so every **single**-value parser is total:
|
|
133
|
+
|
|
134
|
+
| Raw value | Result |
|
|
135
|
+
| --------------------- | ------------------------------------------------------------- |
|
|
136
|
+
| absent (`/products`) | `null`, or the parser's own default if it declares one |
|
|
137
|
+
| repeated (`?v=a&v=b`) | the **first** value, matching `URLSearchParams.get()` |
|
|
138
|
+
| present | whatever the parser returns; if it **throws**, `null` |
|
|
121
139
|
|
|
122
|
-
|
|
140
|
+
So `?page=1&page=2` gives `1`, `parseAsBoolean` on a missing `?debug=` gives `null` rather than an HTTP 500, and `parseAsString` on `?q=a&q=b` gives `'a'` rather than an array its type forbids.
|
|
123
141
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
A present value is not validated for you — each parser decides. `parseAsBoolean` on `?v=maybe` is `false`, and `parseAsInteger` on `?v=12abc` is `12`. Use a schema when you need the value rejected rather than coerced.
|
|
143
|
+
|
|
144
|
+
The exception is `parseAsNativeArrayOf`, nuqs's *multi*-value parser for repeated keys. It is **not usable in `defineSearchParams`**: its `parse` is declared over `readonly string[]`, so the field is a compile error, and forcing it through leaves the client hook reading it as empty. Use an array schema for repeated keys. Tracked as TIM-1355.
|
|
145
|
+
|
|
146
|
+
Two consequences worth knowing:
|
|
147
|
+
|
|
148
|
+
- **`parseAsArrayOf` reads one key, not repeated keys.** It is a comma-separated list inside a single value, so `?tags=a,b` gives `['a','b']` but `?tags=a&tags=b` gives `['a']`. For repeated keys use an array schema — `tags: z.array(z.string()).default([])` reads both `?tags=a` and `?tags=a&tags=b`.
|
|
149
|
+
- **`parseAsJson` requires a validator argument** — `parseAsJson(z.object({ … }).parse)`. Called bare it does not type-check, and at runtime returns `null` for every value.
|
|
150
|
+
|
|
151
|
+
A field typed by a bare parser is nullable (`parseAsString` → `string | null`). Use `withDefault()` — timber's or the parser's own — to make it non-nullable.
|
|
132
152
|
|
|
133
153
|
## Codec Wrappers
|
|
134
154
|
|
|
135
155
|
### `withDefault(codec, value)`
|
|
136
156
|
|
|
137
|
-
Wrap a codec to
|
|
157
|
+
Wrap a codec to supply a value whenever the inner codec produces none — `null` or `undefined`. The field is non-nullable.
|
|
138
158
|
|
|
139
159
|
```ts
|
|
140
160
|
import { withDefault } from '@timber-js/app/search-params';
|
|
@@ -142,13 +162,15 @@ import { parseAsInteger } from 'nuqs';
|
|
|
142
162
|
const page = withDefault(parseAsInteger, 1); // number (never null)
|
|
143
163
|
```
|
|
144
164
|
|
|
165
|
+
A **present** value is left alone, including a falsy one: `?page=0` is `0`, and `?q=` is `''`, not the default.
|
|
166
|
+
|
|
145
167
|
### `withUrlKey(codec, key)`
|
|
146
168
|
|
|
147
169
|
Attach a URL key alias to a codec.
|
|
148
170
|
|
|
149
171
|
```ts
|
|
150
172
|
import { withUrlKey } from '@timber-js/app/search-params';
|
|
151
|
-
import {
|
|
152
|
-
const query = withUrlKey(
|
|
173
|
+
import { z } from 'zod/v4';
|
|
174
|
+
const query = withUrlKey(z.string().nullable().default(null), 'q');
|
|
153
175
|
// ?q=shoes → { query: 'shoes' }
|
|
154
176
|
```
|
|
@@ -107,10 +107,10 @@ Without `SEGMENT_PATH`, params are `Partial<AllSegmentParams>` — all optional.
|
|
|
107
107
|
|
|
108
108
|
## Typed Search Params
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
Search params are typed by the definition you create and import — there is no convention file:
|
|
111
111
|
|
|
112
112
|
```ts
|
|
113
|
-
// app/products/params.ts
|
|
113
|
+
// app/products/search-params.ts — any module you like
|
|
114
114
|
import { defineSearchParams } from '@timber-js/app/search-params';
|
|
115
115
|
import { z } from 'zod/v4';
|
|
116
116
|
|
|
@@ -135,7 +135,7 @@ export async function GET(ctx: RouteContext) {
|
|
|
135
135
|
}
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
Query params are read via `searchParams.get()` on an imported definition — the same accessor pages use. Segment params come from `getSegmentParams(SEGMENT_PATH)`. For the raw query string, use `new URL(ctx.req.url).searchParams`.
|
|
139
139
|
|
|
140
140
|
### `MiddlewareContext`
|
|
141
141
|
|
package/docs/api/36-cli.mdx
CHANGED
|
@@ -9,7 +9,7 @@ slug: 'cli'
|
|
|
9
9
|
timber.js provides four commands. All are thin wrappers around Vite with timber-specific behavior.
|
|
10
10
|
|
|
11
11
|
```tsx
|
|
12
|
-
timber < command > [--config<path>];
|
|
12
|
+
timber < command > [--config<path>][--project<path>];
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Commands
|
|
@@ -40,7 +40,7 @@ To override the default, use any of the following (highest precedence first):
|
|
|
40
40
|
1. `server.port` in `vite.config.ts`
|
|
41
41
|
2. `PORT=4000 timber dev` — the `PORT` environment variable
|
|
42
42
|
|
|
43
|
-
> **Note:** `timber dev --port 4000` is an error, not a silent no-op.
|
|
43
|
+
> **Note:** `timber dev --port 4000` is an error, not a silent no-op. `timber dev` accepts only `--config` — use `PORT` or `server.port` to change the port.
|
|
44
44
|
|
|
45
45
|
When you set the port explicitly, timber **does not** auto-bump — a conflict produces an `EADDRINUSE` error so you find out immediately rather than connecting to the wrong port. This same behavior applies to `timber preview` and the production Node preview server.
|
|
46
46
|
|
|
@@ -84,13 +84,39 @@ Always run `timber build` before `timber preview`.
|
|
|
84
84
|
|
|
85
85
|
### `timber check`
|
|
86
86
|
|
|
87
|
-
Validate
|
|
87
|
+
Validate routes and types without producing build output.
|
|
88
88
|
|
|
89
89
|
```bash
|
|
90
90
|
timber check
|
|
91
|
+
timber check --config ./custom-vite.config.ts --project ./tsconfig.build.json
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
Two passes, in order:
|
|
95
|
+
|
|
96
|
+
1. **Routes.** Resolves your project through Vite exactly as `timber build` does — same root, app directory and `pageExtensions`, same `production` mode and `NODE_ENV`, and including config passed inline to `timber()` in `vite.config.ts`. A config that branches on `mode` or reads `.env.production` therefore resolves the same way under both commands. It then scans, runs the route convention linter, and regenerates the route types (`.timber/timber-routes.d.ts`, `.timber/segment-types.d.ts`, `timber-env.d.ts`). Convention *errors* — the proven-fatal misconfigurations that also fail `timber build`, such as an `error.tsx` that is a server component — fail the command. Warnings print and do not.
|
|
97
|
+
2. **Types.** `tsgo --noEmit`, run from the root the route pass resolved — so it type-checks the same project whose routes were just validated, and finds the declarations that pass just wrote. A relative `--project` is interpreted from the directory you ran the command in.
|
|
98
|
+
|
|
99
|
+
Codegen runs first on purpose: the generated declarations are what type `<Link href>`, `useSegmentParams()`, and `MiddlewareContext`. On a fresh clone that has never run `timber dev` or `timber build` they do not exist yet, so a bare type check would report errors about correct code.
|
|
100
|
+
|
|
101
|
+
Your `tsconfig.json` must pull in `timber-env.d.ts` — that file is what references the generated route map. If your `include` lists only source directories, add it:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"include": ["app", "*.config.ts", "timber-env.d.ts"]
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`timber check` warns when the generated types are not part of the resolved program, because the type check would otherwise pass while measuring `<Link href>` against an empty placeholder. Projects created with `create-timber-app` are configured correctly.
|
|
110
|
+
|
|
111
|
+
`timber check` requires **`@typescript/native-preview`** (which provides `tsgo`). It is an optional peer dependency — install it as a dev dependency:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pnpm add -D @typescript/native-preview
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
If it is missing, `timber check` fails with that instruction. It never passes by skipping the type check.
|
|
118
|
+
|
|
119
|
+
Useful in CI pipelines and pre-commit hooks to catch type and routing errors without a full build.
|
|
94
120
|
|
|
95
121
|
### `timber init`
|
|
96
122
|
|
|
@@ -108,11 +134,12 @@ The generated `AGENTS.md` includes project structure, key imports, common patter
|
|
|
108
134
|
|
|
109
135
|
| Flag | Short | Description |
|
|
110
136
|
| ----------------- | ----- | --------------------------------------------------------------------------------------------------------- |
|
|
111
|
-
| `--config <path>`
|
|
137
|
+
| `--config <path>` | `-c` | Path to a custom Vite config file. Means the same thing for every command, `check` included. |
|
|
138
|
+
| `--project <path>` | | `timber check` only — the `tsconfig.json` to type-check. |
|
|
112
139
|
|
|
113
|
-
> **Note:**
|
|
140
|
+
> **Note:** `timber check` resolves your app through Vite, so `--config` names the Vite config there too, exactly as it does for `dev` and `build`. The tsconfig has its own flag, `--project`, spelled the way `tsc` and `tsgo` spell it. `check` needs a Vite config that lists the timber plugin and fails with an actionable message if it cannot find one.
|
|
114
141
|
|
|
115
|
-
|
|
142
|
+
Those are the only flags. Any other produces an error rather than being silently ignored, with a hint at the supported alternative (e.g. `--port` points you to the `PORT` env var or `server.port` in `vite.config.ts`). Passing `--project` to a command with no type pass is an error too, pointing you at `--config`.
|
|
116
143
|
|
|
117
144
|
## Package Manager Scripts
|
|
118
145
|
|
|
@@ -69,7 +69,7 @@ const [sp, setSearchParams] = searchParams.useQueryStates();
|
|
|
69
69
|
All routing in timber is fully typed and integrated. So you can write a `<Link>` as:
|
|
70
70
|
|
|
71
71
|
```tsx
|
|
72
|
-
<Link href="/blog/[slug]" segmentParams={{ slug: 'a-post' }}
|
|
72
|
+
<Link href="/blog/[slug]" segmentParams={{ slug: 'a-post' }}>Page</Link>
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
Or just normal `<a>` tags work too.
|
|
@@ -94,7 +94,7 @@ Each directory is called a **segment** and can contain these files:
|
|
|
94
94
|
| `layout.tsx` | Persistent UI shell — wraps children, survives navigation |
|
|
95
95
|
| `access.ts` | Authorization gate — runs before the layout renders |
|
|
96
96
|
| `middleware.ts` | Pre-render hook for headers, redirects, and cache warming |
|
|
97
|
-
| `
|
|
97
|
+
| _(none)_ | Segment param codecs live in `app/schema.ts`; search params in any module you import — see [Typed Params](/docs/typed-params) |
|
|
98
98
|
| `error.tsx` | Error boundary catching failures in this subtree |
|
|
99
99
|
| `404.tsx` | Denial page for 404 status code (must be a client component) |
|
|
100
100
|
|
|
@@ -112,9 +112,9 @@ const params = getSegmentParams();
|
|
|
112
112
|
|
|
113
113
|
## Search Params
|
|
114
114
|
|
|
115
|
-
Declare typed search params with `defineSearchParams
|
|
115
|
+
Declare typed search params with `defineSearchParams` in any module, then import it where you need it. Unlike segment params, there is no convention file and nothing is scanned:
|
|
116
116
|
|
|
117
|
-
```ts title="app/products/params.ts" id="search-params"
|
|
117
|
+
```ts title="app/products/search-params.ts" id="search-params"
|
|
118
118
|
import { defineSearchParams, withDefault } from '@timber-js/app/search-params';
|
|
119
119
|
import { parseAsInteger } from 'nuqs';
|
|
120
120
|
import { z } from 'zod/v4';
|
|
@@ -129,7 +129,7 @@ export const searchParams = defineSearchParams({
|
|
|
129
129
|
### Server Usage
|
|
130
130
|
|
|
131
131
|
```tsx title="app/products/page.tsx" use="search-params"
|
|
132
|
-
import { searchParams } from './params';
|
|
132
|
+
import { searchParams } from './search-params';
|
|
133
133
|
|
|
134
134
|
export default async function ProductsPage() {
|
|
135
135
|
const { page, sort, q } = searchParams.get();
|
|
@@ -142,7 +142,7 @@ export default async function ProductsPage() {
|
|
|
142
142
|
|
|
143
143
|
```tsx title="app/products/filters.tsx" use="search-params"
|
|
144
144
|
'use client';
|
|
145
|
-
import { searchParams } from './params';
|
|
145
|
+
import { searchParams } from './search-params';
|
|
146
146
|
|
|
147
147
|
export function ProductFilters() {
|
|
148
148
|
const [params, setParams] = searchParams.useQueryStates();
|
|
@@ -231,7 +231,7 @@ For segment params, use the `codec` namespace:
|
|
|
231
231
|
| `codec.catchAll(inner)` | `T[]` | Wraps scalar codec for catch-all segments |
|
|
232
232
|
| `codec.optionalCatchAll(inner)` | `T[] \| undefined` | Wraps scalar codec for optional catch-all segments |
|
|
233
233
|
|
|
234
|
-
Use `withDefault()` to get a non-nullable type for search params. [nuqs](https://nuqs.47ng.com/) parsers
|
|
234
|
+
Use `withDefault()` to get a non-nullable type for search params. [nuqs](https://nuqs.47ng.com/) parsers all work as codecs: an absent param is `null` and a repeated one takes the first value. Note that `parseAsArrayOf` reads a comma-separated list from a single key — for repeated keys (`?ids=1&ids=2`) use an array schema, e.g. `z.array(z.string()).default([])`. */}
|
|
235
235
|
|
|
236
236
|
## Composition
|
|
237
237
|
|
|
@@ -247,7 +247,7 @@ export const pagination = {
|
|
|
247
247
|
};
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
-
```ts title="app/products/params.ts"
|
|
250
|
+
```ts title="app/products/search-params.ts"
|
|
251
251
|
import { defineSearchParams } from '@timber-js/app/search-params';
|
|
252
252
|
import { pagination } from '@/lib/search-params/pagination';
|
|
253
253
|
import { z } from 'zod/v4';
|
|
@@ -264,10 +264,10 @@ Map a property name to a different URL key with `withUrlKey`:
|
|
|
264
264
|
|
|
265
265
|
```ts
|
|
266
266
|
import { defineSearchParams, withUrlKey } from '@timber-js/app/search-params';
|
|
267
|
-
import {
|
|
267
|
+
import { z } from 'zod/v4';
|
|
268
268
|
|
|
269
269
|
export const searchParams = defineSearchParams({
|
|
270
|
-
query: withUrlKey(
|
|
270
|
+
query: withUrlKey(z.string().nullable().default(null), 'q'),
|
|
271
271
|
});
|
|
272
272
|
// ?q=shoes → { query: 'shoes' }
|
|
273
273
|
```
|