@timber-js/app 0.2.0-alpha.186 → 0.2.0-alpha.187
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/{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 +21 -14
- 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 +8 -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/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/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 +343 -230
- 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/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/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 -36
- 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/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 +8 -0
- 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/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 +60 -40
- package/src/server/action-handler.ts +1 -4
- package/src/server/als-registry.ts +16 -0
- 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 +167 -170
- 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 +2 -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/slot-resolver.ts +10 -2
- package/src/server/ssr-bridge-types.ts +12 -0
- package/src/server/ssr-entry.ts +8 -6
- package/src/server/static-generator.ts +3 -2
- package/src/server/status-code-resolver.ts +28 -11
- package/src/server/tree-builder.ts +35 -218
- 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/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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/shared/rsc-media-type.ts
|
|
2
|
+
/**
|
|
3
|
+
* The RSC Flight media type, and the request predicate over it.
|
|
4
|
+
*
|
|
5
|
+
* One module owns the string because two independently-written spellings of
|
|
6
|
+
* "is this an RSC request?" must agree, and the consequence of them
|
|
7
|
+
* disagreeing is cache poisoning rather than a visible bug. The Cloudflare
|
|
8
|
+
* adapter's `isRsc` decides what may enter the edge cache; the origin's
|
|
9
|
+
* pipeline decides which headers may vary the response. TIM-1269 made the
|
|
10
|
+
* adapter's `VARY_HONORED` allowlist exempt `Accept` *because* `isRsc`
|
|
11
|
+
* excludes Flight responses from the cache, and exempt the `X-Timber-*`
|
|
12
|
+
* headers *because* the origin reads them only behind its own RSC check. If
|
|
13
|
+
* one predicate is ever tightened (a real media-type parse, a
|
|
14
|
+
* parameter-aware match) and the other is not, the adapter can classify a
|
|
15
|
+
* request as a document while the origin treats it as RSC, and store a
|
|
16
|
+
* Flight payload under the document's key — the class
|
|
17
|
+
* `design/48-payload-addressing.md` exists to prevent.
|
|
18
|
+
*
|
|
19
|
+
* `tests/rsc-media-type-single-source.test.ts` fails if the literal reappears
|
|
20
|
+
* in executable source outside this file.
|
|
21
|
+
*
|
|
22
|
+
* Isomorphic: zero imports, so `adapters/cloudflare.ts` — which Node's native
|
|
23
|
+
* ESM loader evaluates before Vite's resolver exists — can load it and
|
|
24
|
+
* interpolate the value into the generated worker. Same precedent as
|
|
25
|
+
* `shared/rsc-cache-key.ts`.
|
|
26
|
+
*
|
|
27
|
+
* See design/19-client-navigation.md, design/25-production-deployments.md
|
|
28
|
+
* §"`Vary` and the Workers Cache API".
|
|
29
|
+
*/
|
|
30
|
+
/** Media type of a React Flight payload. */
|
|
31
|
+
var RSC_CONTENT_TYPE = "text/x-component";
|
|
32
|
+
/**
|
|
33
|
+
* Is this request asking for an RSC payload rather than a full document?
|
|
34
|
+
*
|
|
35
|
+
* Substring containment, deliberately: `Accept` is a list, and a client may
|
|
36
|
+
* send `text/x-component;charset=utf-8` or list it alongside other types.
|
|
37
|
+
* Tightening this to a real media-type parse is a behaviour change that has
|
|
38
|
+
* to move the adapter's generated `isRsc` in the same commit — see above.
|
|
39
|
+
*/
|
|
40
|
+
function isRscRequest(req) {
|
|
41
|
+
return (req.headers.get("Accept") ?? "").includes(RSC_CONTENT_TYPE);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { isRscRequest as n, RSC_CONTENT_TYPE as t };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=rsc-media-type-DRqE_lD_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-media-type-DRqE_lD_.js","names":[],"sources":["../../src/shared/rsc-media-type.ts"],"sourcesContent":["/**\n * The RSC Flight media type, and the request predicate over it.\n *\n * One module owns the string because two independently-written spellings of\n * \"is this an RSC request?\" must agree, and the consequence of them\n * disagreeing is cache poisoning rather than a visible bug. The Cloudflare\n * adapter's `isRsc` decides what may enter the edge cache; the origin's\n * pipeline decides which headers may vary the response. TIM-1269 made the\n * adapter's `VARY_HONORED` allowlist exempt `Accept` *because* `isRsc`\n * excludes Flight responses from the cache, and exempt the `X-Timber-*`\n * headers *because* the origin reads them only behind its own RSC check. If\n * one predicate is ever tightened (a real media-type parse, a\n * parameter-aware match) and the other is not, the adapter can classify a\n * request as a document while the origin treats it as RSC, and store a\n * Flight payload under the document's key — the class\n * `design/48-payload-addressing.md` exists to prevent.\n *\n * `tests/rsc-media-type-single-source.test.ts` fails if the literal reappears\n * in executable source outside this file.\n *\n * Isomorphic: zero imports, so `adapters/cloudflare.ts` — which Node's native\n * ESM loader evaluates before Vite's resolver exists — can load it and\n * interpolate the value into the generated worker. Same precedent as\n * `shared/rsc-cache-key.ts`.\n *\n * See design/19-client-navigation.md, design/25-production-deployments.md\n * §\"`Vary` and the Workers Cache API\".\n */\n\n/** Media type of a React Flight payload. */\nexport const RSC_CONTENT_TYPE = 'text/x-component';\n\n/**\n * Is this request asking for an RSC payload rather than a full document?\n *\n * Substring containment, deliberately: `Accept` is a list, and a client may\n * send `text/x-component;charset=utf-8` or list it alongside other types.\n * Tightening this to a real media-type parse is a behaviour change that has\n * to move the adapter's generated `isRsc` in the same commit — see above.\n */\nexport function isRscRequest(req: Request): boolean {\n return (req.headers.get('Accept') ?? '').includes(RSC_CONTENT_TYPE);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,mBAAmB;;;;;;;;;AAUhC,SAAgB,aAAa,KAAuB;CAClD,QAAQ,IAAI,QAAQ,IAAI,QAAQ,KAAK,GAAA,CAAI,SAAS,gBAAgB;AACpE"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { o as __exportAll } from "./dist-BA3u1z3W.js";
|
|
2
1
|
import { i as NULL_BYTE_RE, n as treePathDepth, r as ENCODED_SEPARATOR_RE, s as classifyMetadataRoute, t as computeSegmentTreePaths, u as isDynamicMetadataExtension } from "./segment-keys-BawYuNFO.js";
|
|
3
2
|
import { i as DEFAULT_PAGE_EXTENSIONS, n as classifyUrlSegment, r as effectiveUrlSegment, t as classifySegment } from "./segment-classify-C539Pa2O.js";
|
|
4
|
-
import { h as swallow } from "./logger-
|
|
5
|
-
import { a as resolveAppDir } from "./plugin-context-DEGLSJs3.js";
|
|
3
|
+
import { h as swallow } from "./logger-D8xJZXIN.js";
|
|
6
4
|
import { basename, extname, join } from "node:path";
|
|
7
|
-
import {
|
|
5
|
+
import { readdirSync, statSync } from "node:fs";
|
|
8
6
|
//#region src/server/tree-match.ts
|
|
9
7
|
/**
|
|
10
8
|
* Match URL path parts against a segment tree.
|
|
@@ -1200,8 +1198,7 @@ var PAGE_EXT_CONVENTIONS = /* @__PURE__ */ new Set([
|
|
|
1200
1198
|
var FIXED_CONVENTIONS = /* @__PURE__ */ new Set([
|
|
1201
1199
|
"middleware",
|
|
1202
1200
|
"access",
|
|
1203
|
-
"route"
|
|
1204
|
-
"params"
|
|
1201
|
+
"route"
|
|
1205
1202
|
]);
|
|
1206
1203
|
/**
|
|
1207
1204
|
* Status-code file patterns:
|
|
@@ -1562,296 +1559,6 @@ function findPageExtFile(dirPath, name, extSet) {
|
|
|
1562
1559
|
}
|
|
1563
1560
|
}
|
|
1564
1561
|
//#endregion
|
|
1565
|
-
|
|
1566
|
-
/**
|
|
1567
|
-
* `timber schema sync` — scan filesystem for dynamic segments, append
|
|
1568
|
-
* missing entries with `codec.string` defaults, and remove stale entries
|
|
1569
|
-
* whose segments no longer exist in the filesystem.
|
|
1570
|
-
*
|
|
1571
|
-
* Design doc: design/41-global-params.md §Auto-Scaffolding
|
|
1572
|
-
*/
|
|
1573
|
-
var cli_schema_sync_exports = /* @__PURE__ */ __exportAll({
|
|
1574
|
-
collectDynamicSegments: () => collectDynamicSegments,
|
|
1575
|
-
defaultCodecForSegment: () => defaultCodecForSegment,
|
|
1576
|
-
findSchemaFile: () => findSchemaFile,
|
|
1577
|
-
findSegmentParamsBlock: () => findSegmentParamsBlock,
|
|
1578
|
-
parseExistingSchemaKeys: () => parseExistingSchemaKeys,
|
|
1579
|
-
runSchemaSync: () => runSchemaSync
|
|
1580
|
-
});
|
|
1581
|
-
function toBracketKey(node) {
|
|
1582
|
-
if (node.paramPrefix || node.paramSuffix) return `[${node.paramName}]`;
|
|
1583
|
-
switch (node.segmentType) {
|
|
1584
|
-
case "catch-all": return `[...${node.paramName}]`;
|
|
1585
|
-
case "optional-catch-all": return `[[...${node.paramName}]]`;
|
|
1586
|
-
default: return `[${node.paramName}]`;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Collect all unique bracket-keyed dynamic segment names from the route tree.
|
|
1591
|
-
* Returns entries like '[artistSlug]', '[...slug]', '[[...topic]]'.
|
|
1592
|
-
*/
|
|
1593
|
-
function collectDynamicSegments(appDir) {
|
|
1594
|
-
const tree = scanRoutes(appDir);
|
|
1595
|
-
const segments = /* @__PURE__ */ new Set();
|
|
1596
|
-
walkSegments(tree.root, segments);
|
|
1597
|
-
return [...segments].sort();
|
|
1598
|
-
}
|
|
1599
|
-
function walkSegments(node, segments) {
|
|
1600
|
-
if (node.paramName) segments.add(toBracketKey(node));
|
|
1601
|
-
for (const child of node.children) walkSegments(child, segments);
|
|
1602
|
-
for (const slot of Object.values(node.slots)) walkSegments(slot, segments);
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Replace comment bodies (and optionally string contents) with spaces,
|
|
1606
|
-
* preserving length and newlines so every index maps 1:1 to the original.
|
|
1607
|
-
* Lets the structural scanning below ignore `segmentParams` mentions and
|
|
1608
|
-
* braces inside comments/strings without a TS parser (fine pre-alpha,
|
|
1609
|
-
* see TIM-1066).
|
|
1610
|
-
*
|
|
1611
|
-
* With `maskStrings`, string contents are blanked too — except literal
|
|
1612
|
-
* 'segmentParams' strings, kept so a quoted property key stays findable.
|
|
1613
|
-
*/
|
|
1614
|
-
function maskSource(content, maskStrings) {
|
|
1615
|
-
const out = content.split("");
|
|
1616
|
-
const n = content.length;
|
|
1617
|
-
let i = 0;
|
|
1618
|
-
const blank = (from, to) => {
|
|
1619
|
-
for (let j = from; j < to; j++) if (content[j] !== "\n") out[j] = " ";
|
|
1620
|
-
};
|
|
1621
|
-
while (i < n) {
|
|
1622
|
-
const ch = content[i];
|
|
1623
|
-
const next = content[i + 1];
|
|
1624
|
-
if (ch === "/" && next === "/") {
|
|
1625
|
-
const start = i;
|
|
1626
|
-
while (i < n && content[i] !== "\n") i++;
|
|
1627
|
-
blank(start, i);
|
|
1628
|
-
} else if (ch === "/" && next === "*") {
|
|
1629
|
-
const start = i;
|
|
1630
|
-
i += 2;
|
|
1631
|
-
while (i < n && !(content[i] === "*" && content[i + 1] === "/")) i++;
|
|
1632
|
-
i = Math.min(i + 2, n);
|
|
1633
|
-
blank(start, i);
|
|
1634
|
-
} else if (ch === "\"" || ch === "'" || ch === "`") {
|
|
1635
|
-
const start = i;
|
|
1636
|
-
i++;
|
|
1637
|
-
while (i < n && content[i] !== ch) {
|
|
1638
|
-
if (content[i] === "\\") i++;
|
|
1639
|
-
i++;
|
|
1640
|
-
}
|
|
1641
|
-
const end = i;
|
|
1642
|
-
if (maskStrings && content.slice(start + 1, end) !== "segmentParams") blank(start + 1, end);
|
|
1643
|
-
i++;
|
|
1644
|
-
} else i++;
|
|
1645
|
-
}
|
|
1646
|
-
return out.join("");
|
|
1647
|
-
}
|
|
1648
|
-
/**
|
|
1649
|
-
* Locate the `segmentParams: { ... }` block in a schema file.
|
|
1650
|
-
* Returns the indices of the opening and matching closing brace, or null
|
|
1651
|
-
* if no segmentParams property is found. Comments and strings are masked
|
|
1652
|
-
* first, so a JSDoc example mentioning `segmentParams: { ... }` above the
|
|
1653
|
-
* real defineSchema call is not mistaken for the block, and braces inside
|
|
1654
|
-
* comments/strings don't skew the depth count. The search is anchored to
|
|
1655
|
-
* the `defineSchema(` call when present, so helper objects with their own
|
|
1656
|
-
* segmentParams property earlier in the file are skipped.
|
|
1657
|
-
*/
|
|
1658
|
-
function findSegmentParamsBlock(content) {
|
|
1659
|
-
const masked = maskSource(content, true);
|
|
1660
|
-
const defineCall = /\bdefineSchema\s*\(/.exec(masked);
|
|
1661
|
-
const keyRe = /(['"]?)segmentParams\1\s*:\s*\{/g;
|
|
1662
|
-
keyRe.lastIndex = defineCall ? defineCall.index + defineCall[0].length : 0;
|
|
1663
|
-
const keyMatch = keyRe.exec(masked);
|
|
1664
|
-
if (!keyMatch) return null;
|
|
1665
|
-
const openBrace = keyMatch.index + keyMatch[0].length - 1;
|
|
1666
|
-
let depth = 1;
|
|
1667
|
-
let i = openBrace + 1;
|
|
1668
|
-
while (i < masked.length && depth > 0) {
|
|
1669
|
-
if (masked[i] === "{") depth++;
|
|
1670
|
-
else if (masked[i] === "}") depth--;
|
|
1671
|
-
i++;
|
|
1672
|
-
}
|
|
1673
|
-
if (depth > 0) return null;
|
|
1674
|
-
return {
|
|
1675
|
-
openBrace,
|
|
1676
|
-
closeBrace: i - 1
|
|
1677
|
-
};
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* Parse existing bracket keys from an app/schema.ts file.
|
|
1681
|
-
* Scoped to the segmentParams: { ... } block — bracket keys elsewhere in
|
|
1682
|
-
* the file (unrelated objects, comments above defineSchema) are ignored.
|
|
1683
|
-
* Comments inside the block are masked, so a commented-out entry does not
|
|
1684
|
-
* count as registered.
|
|
1685
|
-
*
|
|
1686
|
-
* The key charset matches the route classifier (segment-classify.ts):
|
|
1687
|
-
* any character except `]`, so hyphenated params like '[my-param]' parse.
|
|
1688
|
-
*/
|
|
1689
|
-
function parseExistingSchemaKeys(content) {
|
|
1690
|
-
const block = findSegmentParamsBlock(content);
|
|
1691
|
-
if (!block) return [];
|
|
1692
|
-
const blockContent = maskSource(content, false).slice(block.openBrace, block.closeBrace);
|
|
1693
|
-
const keys = [];
|
|
1694
|
-
const re = /['"](\[{1,2}(?:\.{3})?[^\]]+\]{1,2})['"]\s*:/g;
|
|
1695
|
-
let m;
|
|
1696
|
-
while ((m = re.exec(blockContent)) !== null) keys.push(m[1]);
|
|
1697
|
-
return keys;
|
|
1698
|
-
}
|
|
1699
|
-
/** Schema file extensions to check. */
|
|
1700
|
-
var SCHEMA_EXTENSIONS = [
|
|
1701
|
-
".ts",
|
|
1702
|
-
".tsx",
|
|
1703
|
-
".js",
|
|
1704
|
-
".jsx"
|
|
1705
|
-
];
|
|
1706
|
-
/**
|
|
1707
|
-
* Find the schema file path if it exists.
|
|
1708
|
-
*/
|
|
1709
|
-
function findSchemaFile(appDir) {
|
|
1710
|
-
for (const ext of SCHEMA_EXTENSIONS) {
|
|
1711
|
-
const p = join(appDir, `schema${ext}`);
|
|
1712
|
-
if (existsSync(p)) return p;
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
function defaultCodecForSegment(seg) {
|
|
1716
|
-
if (seg.startsWith("[[...")) return "codec.optionalCatchAll(codec.string)";
|
|
1717
|
-
if (seg.startsWith("[...")) return "codec.stringArray";
|
|
1718
|
-
return "codec.string";
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
* Generate the content for a new app/schema.ts with the given segment keys.
|
|
1722
|
-
*/
|
|
1723
|
-
function generateNewSchema(segments) {
|
|
1724
|
-
const lines = [];
|
|
1725
|
-
lines.push("import { defineSchema } from '@timber-js/app/params';");
|
|
1726
|
-
lines.push("import { codec } from '@timber-js/app/codec';");
|
|
1727
|
-
lines.push("");
|
|
1728
|
-
lines.push("export default defineSchema({");
|
|
1729
|
-
lines.push(" segmentParams: {");
|
|
1730
|
-
for (const seg of segments) lines.push(` '${seg}': ${defaultCodecForSegment(seg)},`);
|
|
1731
|
-
lines.push(" },");
|
|
1732
|
-
lines.push("});");
|
|
1733
|
-
lines.push("");
|
|
1734
|
-
return lines.join("\n");
|
|
1735
|
-
}
|
|
1736
|
-
/**
|
|
1737
|
-
* Append missing segment entries to an existing schema file.
|
|
1738
|
-
* Inserts new entries before the closing `}` of segmentParams.
|
|
1739
|
-
*/
|
|
1740
|
-
var CODEC_IMPORT = "import { codec } from '@timber-js/app/codec';";
|
|
1741
|
-
function hasCodecImport(content) {
|
|
1742
|
-
return /import\s+\{[^}]*\bcodec\b[^}]*\}\s+from\s+['"]@timber-js\/app\/codec['"]/.test(content);
|
|
1743
|
-
}
|
|
1744
|
-
function ensureCodecImport(content) {
|
|
1745
|
-
if (hasCodecImport(content)) return content;
|
|
1746
|
-
const lines = content.split("\n");
|
|
1747
|
-
let lastImportIndex = -1;
|
|
1748
|
-
for (let i = 0; i < lines.length; i++) if (/^\s*import\s/.test(lines[i])) lastImportIndex = i;
|
|
1749
|
-
if (lastImportIndex === -1) return "import { codec } from '@timber-js/app/codec';\n" + content;
|
|
1750
|
-
lines.splice(lastImportIndex + 1, 0, CODEC_IMPORT);
|
|
1751
|
-
return lines.join("\n");
|
|
1752
|
-
}
|
|
1753
|
-
function appendToSchema(content, newSegments) {
|
|
1754
|
-
content = ensureCodecImport(content);
|
|
1755
|
-
const block = findSegmentParamsBlock(content);
|
|
1756
|
-
if (!block) throw new Error("[timber] Could not find segmentParams in schema file. Expected a defineSchema({ segmentParams: { ... } }) call.");
|
|
1757
|
-
const { openBrace, closeBrace } = block;
|
|
1758
|
-
const existingLine = content.slice(openBrace, closeBrace).match(/^(\s+)['"]\[/m);
|
|
1759
|
-
const indent = existingLine ? existingLine[1] : " ";
|
|
1760
|
-
const insertion = newSegments.map((seg) => `${indent}'${seg}': ${defaultCodecForSegment(seg)},`).join("\n");
|
|
1761
|
-
const before = content.slice(0, closeBrace);
|
|
1762
|
-
const after = content.slice(closeBrace);
|
|
1763
|
-
return before + (before.trimEnd().endsWith(",") ? "\n" : "\n") + insertion + "\n" + after;
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Remove entries from the segmentParams block whose keys match `staleSegments`.
|
|
1767
|
-
* Removes the entire entry including trailing comma/whitespace. Scoped to
|
|
1768
|
-
* the segmentParams block — identical keys in unrelated objects elsewhere
|
|
1769
|
-
* in the file are left untouched.
|
|
1770
|
-
*/
|
|
1771
|
-
function removeFromSchema(content, staleSegments) {
|
|
1772
|
-
const block = findSegmentParamsBlock(content);
|
|
1773
|
-
if (!block) return content;
|
|
1774
|
-
let blockContent = content.slice(block.openBrace, block.closeBrace);
|
|
1775
|
-
let blockMasked = maskSource(blockContent, false);
|
|
1776
|
-
for (const seg of staleSegments) {
|
|
1777
|
-
const escaped = seg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1778
|
-
const keyRe = new RegExp(`^[ \t]*['"]${escaped}['"][ \t]*:`, "gm");
|
|
1779
|
-
let m;
|
|
1780
|
-
while ((m = keyRe.exec(blockMasked)) !== null) {
|
|
1781
|
-
const start = m.index;
|
|
1782
|
-
let i = m.index + m[0].length;
|
|
1783
|
-
let depth = 0;
|
|
1784
|
-
let inString = null;
|
|
1785
|
-
while (i < blockMasked.length) {
|
|
1786
|
-
const ch = blockMasked[i];
|
|
1787
|
-
if (inString) {
|
|
1788
|
-
if (ch === "\\") i++;
|
|
1789
|
-
else if (ch === inString) inString = null;
|
|
1790
|
-
} else if (ch === "\"" || ch === "'" || ch === "`") inString = ch;
|
|
1791
|
-
else if (ch === "(" || ch === "{" || ch === "[") depth++;
|
|
1792
|
-
else if (ch === ")" || ch === "}" || ch === "]") depth--;
|
|
1793
|
-
else if (depth === 0 && ch === ",") {
|
|
1794
|
-
i++;
|
|
1795
|
-
break;
|
|
1796
|
-
} else if (depth === 0 && (ch === "\n" || ch === "}")) break;
|
|
1797
|
-
i++;
|
|
1798
|
-
}
|
|
1799
|
-
if (i < blockMasked.length && blockMasked[i] === "\n") i++;
|
|
1800
|
-
blockContent = blockContent.slice(0, start) + blockContent.slice(i);
|
|
1801
|
-
blockMasked = blockMasked.slice(0, start) + blockMasked.slice(i);
|
|
1802
|
-
keyRe.lastIndex = start;
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
return content.slice(0, block.openBrace) + blockContent + content.slice(block.closeBrace);
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* Run the schema sync: scan filesystem, diff against schema, append missing.
|
|
1809
|
-
*/
|
|
1810
|
-
function runSchemaSync(projectRoot) {
|
|
1811
|
-
const appDir = resolveAppDir(projectRoot);
|
|
1812
|
-
const filesystemSegments = collectDynamicSegments(appDir);
|
|
1813
|
-
const schemaPath = findSchemaFile(appDir);
|
|
1814
|
-
if (filesystemSegments.length === 0 && !schemaPath) return {
|
|
1815
|
-
filesystemSegments: [],
|
|
1816
|
-
existingSegments: [],
|
|
1817
|
-
addedSegments: [],
|
|
1818
|
-
removedSegments: [],
|
|
1819
|
-
created: false
|
|
1820
|
-
};
|
|
1821
|
-
if (!schemaPath) {
|
|
1822
|
-
writeFileSync(join(appDir, "schema.ts"), generateNewSchema(filesystemSegments), "utf-8");
|
|
1823
|
-
return {
|
|
1824
|
-
filesystemSegments,
|
|
1825
|
-
existingSegments: [],
|
|
1826
|
-
addedSegments: filesystemSegments,
|
|
1827
|
-
removedSegments: [],
|
|
1828
|
-
created: true
|
|
1829
|
-
};
|
|
1830
|
-
}
|
|
1831
|
-
const content = readFileSync(schemaPath, "utf-8");
|
|
1832
|
-
const existingSegments = parseExistingSchemaKeys(content);
|
|
1833
|
-
const missing = filesystemSegments.filter((seg) => !existingSegments.includes(seg));
|
|
1834
|
-
const stale = existingSegments.filter((seg) => !filesystemSegments.includes(seg));
|
|
1835
|
-
if (missing.length === 0 && stale.length === 0) return {
|
|
1836
|
-
filesystemSegments,
|
|
1837
|
-
existingSegments,
|
|
1838
|
-
addedSegments: [],
|
|
1839
|
-
removedSegments: [],
|
|
1840
|
-
created: false
|
|
1841
|
-
};
|
|
1842
|
-
let updated = content;
|
|
1843
|
-
if (stale.length > 0) updated = removeFromSchema(updated, stale);
|
|
1844
|
-
if (missing.length > 0) updated = appendToSchema(updated, missing);
|
|
1845
|
-
writeFileSync(schemaPath, updated, "utf-8");
|
|
1846
|
-
return {
|
|
1847
|
-
filesystemSegments,
|
|
1848
|
-
existingSegments,
|
|
1849
|
-
addedSegments: missing,
|
|
1850
|
-
removedSegments: stale,
|
|
1851
|
-
created: false
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
//#endregion
|
|
1855
|
-
export { collectInterceptionRewrites as a, scanRoutes as i, findSchemaFile as n, matchUrlParts as o, parseExistingSchemaKeys as r, cli_schema_sync_exports as t };
|
|
1562
|
+
export { collectInterceptionRewrites as n, matchUrlParts as r, scanRoutes as t };
|
|
1856
1563
|
|
|
1857
|
-
//# sourceMappingURL=
|
|
1564
|
+
//# sourceMappingURL=scanner-C8b0Gcw3.js.map
|