@rangojs/router 0.5.1 → 0.6.0
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/README.md +5 -1
- package/dist/bin/rango.js +343 -125
- package/dist/types/browser/event-controller.d.ts +6 -0
- package/dist/types/browser/react/use-router.d.ts +10 -3
- package/dist/types/browser/react/use-search-params.d.ts +57 -10
- package/dist/types/browser/types.d.ts +22 -0
- package/dist/types/build/merge-full-manifests.d.ts +3 -0
- package/dist/types/build/route-trie.d.ts +4 -73
- package/dist/types/build/route-types/per-module-writer.d.ts +6 -4
- package/dist/types/build/route-types/router-processing.d.ts +2 -3
- package/dist/types/cache/cache-exec-scope.d.ts +31 -0
- package/dist/types/cache/cf/cf-cache-constants.d.ts +8 -1
- package/dist/types/cache/cf/cf-cache-store.d.ts +15 -1
- package/dist/types/cache/cf/cf-cache-types.d.ts +1 -1
- package/dist/types/cache/cf/cf-kv-utils.d.ts +21 -0
- package/dist/types/cache/taint.d.ts +12 -6
- package/dist/types/client-urls/client-root.d.ts +38 -0
- package/dist/types/client-urls/client-urls.d.ts +5 -0
- package/dist/types/client-urls/navigation.d.ts +38 -0
- package/dist/types/client-urls/revalidation-protocol.d.ts +25 -0
- package/dist/types/client-urls/server-projection.d.ts +62 -0
- package/dist/types/client-urls/types.d.ts +144 -0
- package/dist/types/client.d.ts +12 -4
- package/dist/types/client.rsc.d.ts +4 -1
- package/dist/types/decode-loader-results.d.ts +37 -0
- package/dist/types/errors.d.ts +1 -0
- package/dist/types/handles/is-thenable.d.ts +2 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/loader-redirect.d.ts +27 -0
- package/dist/types/outlet-context.d.ts +12 -0
- package/dist/types/outlet-provider.d.ts +3 -1
- package/dist/types/redirect-origin.d.ts +4 -0
- package/dist/types/route-content-wrapper.d.ts +42 -1
- package/dist/types/route-definition/helpers-types.d.ts +13 -2
- package/dist/types/router/error-handling.d.ts +35 -1
- package/dist/types/router/intercept-resolution.d.ts +12 -0
- package/dist/types/router/loader-resolution.d.ts +24 -2
- package/dist/types/router/revalidation.d.ts +7 -0
- package/dist/{types.backup/build/route-trie.d.ts → types/router/route-trie-builder.d.ts} +4 -16
- package/dist/types/router/router-interfaces.d.ts +20 -0
- package/dist/types/router/segment-resolution/helpers.d.ts +1 -1
- package/dist/types/router/trie-matching.d.ts +1 -1
- package/dist/types/rsc/helpers.d.ts +3 -0
- package/dist/types/rsc/manifest-init.d.ts +5 -5
- package/dist/types/rsc/render-pipeline.d.ts +9 -0
- package/dist/types/rsc/routine-plan.d.ts +124 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +17 -0
- package/dist/types/rsc/shell-capture.d.ts +9 -0
- package/dist/types/rsc/shell-serve.d.ts +11 -0
- package/dist/types/rsc/types.d.ts +30 -0
- package/dist/types/segment-system.d.ts +2 -0
- package/dist/types/server/context.d.ts +10 -0
- package/dist/types/server/handle-store.d.ts +34 -3
- package/dist/types/server/request-context.d.ts +14 -1
- package/dist/types/server.d.ts +1 -0
- package/dist/types/ssr/index.d.ts +22 -0
- package/dist/types/ssr/ssr-root.d.ts +10 -0
- package/dist/types/testing/dom.entry.d.ts +1 -1
- package/dist/types/testing/render-route.d.ts +16 -6
- package/dist/types/testing/run-loader.d.ts +9 -0
- package/dist/types/types/boundaries.d.ts +22 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/loader-types.d.ts +57 -5
- package/dist/types/types/segments.d.ts +7 -0
- package/dist/types/urls/path-helper-types.d.ts +10 -4
- package/dist/types/vite/discovery/client-urls-projection.d.ts +53 -0
- package/dist/types/vite/discovery/discover-routers.d.ts +1 -1
- package/dist/types/vite/discovery/state.d.ts +8 -1
- package/dist/types/vite/encryption-key.d.ts +2 -0
- package/dist/types/vite/plugins/expose-internal-ids.d.ts +10 -0
- package/dist/types/vite/plugins/server-ref-hashing.d.ts +24 -0
- package/dist/types/vite/plugins/server-reference-pattern.d.ts +1 -0
- package/dist/types/vite/utils/shared-utils.d.ts +12 -0
- package/dist/vite/index.js +5101 -2056
- package/package.json +3 -3
- package/skills/breadcrumbs/SKILL.md +39 -9
- package/skills/caching/SKILL.md +1 -1
- package/skills/catalog.json +7 -1
- package/skills/client-urls/SKILL.md +338 -0
- package/skills/comparison/references/framework-comparison.md +23 -9
- package/skills/hooks/SKILL.md +2 -2
- package/skills/hooks/data.md +11 -2
- package/skills/hooks/handle-and-actions.md +7 -0
- package/skills/hooks/outlets.md +26 -5
- package/skills/hooks/urls.md +40 -3
- package/skills/loader/SKILL.md +132 -20
- package/skills/migrate-nextjs/SKILL.md +70 -10
- package/skills/migrate-react-router/SKILL.md +49 -13
- package/skills/migrate-react-router/component-migration.md +18 -13
- package/skills/migrate-react-router/data-and-actions.md +14 -3
- package/skills/migrate-react-router/route-mapping.md +15 -2
- package/skills/mime-routes/SKILL.md +3 -1
- package/skills/parallel/SKILL.md +32 -1
- package/skills/ppr/SKILL.md +16 -6
- package/skills/prerender/SKILL.md +8 -4
- package/skills/rango/SKILL.md +21 -17
- package/skills/react-compiler/SKILL.md +3 -3
- package/skills/response-routes/SKILL.md +4 -2
- package/skills/route/SKILL.md +5 -2
- package/skills/router-setup/SKILL.md +16 -2
- package/skills/scripts/SKILL.md +16 -6
- package/skills/shell-manifest/SKILL.md +16 -7
- package/skills/testing/SKILL.md +2 -2
- package/skills/testing/client-components.md +6 -0
- package/skills/testing/handles.md +30 -8
- package/skills/testing/loader.md +51 -49
- package/skills/testing/middleware.md +1 -1
- package/skills/theme/SKILL.md +8 -5
- package/skills/typesafety/generated-files-and-cli.md +16 -9
- package/skills/typesafety/route-types.md +5 -1
- package/skills/use-cache/SKILL.md +47 -0
- package/src/bin/rango.ts +7 -3
- package/src/browser/event-controller.ts +40 -15
- package/src/browser/navigation-bridge.ts +6 -0
- package/src/browser/navigation-client.ts +5 -0
- package/src/browser/partial-update.ts +77 -10
- package/src/browser/react/NavigationProvider.tsx +7 -0
- package/src/browser/react/use-router.ts +40 -11
- package/src/browser/react/use-search-params.ts +140 -17
- package/src/browser/rsc-router.tsx +59 -0
- package/src/browser/server-action-bridge.ts +26 -0
- package/src/browser/types.ts +22 -0
- package/src/build/merge-full-manifests.ts +161 -0
- package/src/build/route-trie.ts +9 -332
- package/src/build/route-types/include-resolution.ts +66 -11
- package/src/build/route-types/per-module-writer.ts +11 -6
- package/src/build/route-types/router-processing.ts +184 -153
- package/src/build/runtime-discovery.ts +23 -12
- package/src/cache/cache-exec-scope.ts +47 -0
- package/src/cache/cache-runtime.ts +113 -40
- package/src/cache/cf/cf-cache-constants.ts +8 -1
- package/src/cache/cf/cf-cache-store.ts +41 -64
- package/src/cache/cf/cf-cache-types.ts +1 -1
- package/src/cache/cf/cf-kv-utils.ts +38 -0
- package/src/cache/segment-codec.ts +21 -5
- package/src/cache/taint.ts +28 -9
- package/src/client-urls/client-root.tsx +168 -0
- package/src/client-urls/client-urls.ts +698 -0
- package/src/client-urls/navigation.ts +237 -0
- package/src/client-urls/revalidation-protocol.ts +56 -0
- package/src/client-urls/server-projection.ts +579 -0
- package/src/client-urls/types.ts +195 -0
- package/src/client.rsc.tsx +12 -0
- package/src/client.tsx +49 -6
- package/src/decode-loader-results.ts +113 -0
- package/src/errors.ts +14 -0
- package/src/handles/deferred-resolution.ts +14 -7
- package/src/handles/is-thenable.ts +2 -4
- package/src/index.ts +1 -0
- package/src/loader-redirect.tsx +64 -0
- package/src/outlet-context.ts +12 -0
- package/src/outlet-provider.tsx +15 -1
- package/src/redirect-origin.ts +29 -0
- package/src/route-content-wrapper.tsx +96 -3
- package/src/route-definition/dsl-helpers.ts +28 -3
- package/src/route-definition/helpers-types.ts +13 -0
- package/src/route-definition/redirect.ts +17 -18
- package/src/router/error-handling.ts +65 -11
- package/src/router/intercept-resolution.ts +29 -0
- package/src/router/loader-resolution.ts +261 -28
- package/src/router/match-middleware/cache-lookup.ts +24 -15
- package/src/router/match-result.ts +7 -0
- package/src/router/revalidation.ts +24 -11
- package/src/router/route-trie-builder.ts +334 -0
- package/src/router/router-interfaces.ts +38 -0
- package/src/router/segment-resolution/fresh.ts +47 -0
- package/src/router/segment-resolution/helpers.ts +9 -11
- package/src/router/segment-resolution/loader-cache.ts +14 -24
- package/src/router/segment-resolution/revalidation.ts +20 -1
- package/src/router/trie-matching.ts +3 -3
- package/src/router.ts +46 -1
- package/src/rsc/full-payload.ts +6 -0
- package/src/rsc/handler.ts +36 -12
- package/src/rsc/helpers.ts +13 -0
- package/src/rsc/loader-fetch.ts +2 -2
- package/src/rsc/manifest-init.ts +28 -9
- package/src/rsc/progressive-enhancement.ts +247 -70
- package/src/rsc/render-pipeline.ts +68 -24
- package/src/rsc/routine-plan.ts +359 -0
- package/src/rsc/rsc-rendering.ts +569 -302
- package/src/rsc/server-action.ts +180 -71
- package/src/rsc/shell-capture-constants.ts +18 -0
- package/src/rsc/shell-capture.ts +104 -21
- package/src/rsc/shell-serve.ts +15 -2
- package/src/rsc/ssr-setup.ts +10 -1
- package/src/rsc/types.ts +31 -2
- package/src/segment-system.tsx +83 -26
- package/src/server/context.ts +10 -0
- package/src/server/cookie-store.ts +19 -19
- package/src/server/handle-store.ts +185 -48
- package/src/server/request-context.ts +36 -6
- package/src/server.ts +7 -0
- package/src/ssr/index.tsx +37 -2
- package/src/ssr/ssr-root.tsx +30 -2
- package/src/testing/dom.entry.ts +1 -1
- package/src/testing/render-route.tsx +22 -8
- package/src/testing/run-loader.ts +51 -13
- package/src/types/boundaries.ts +19 -0
- package/src/types/index.ts +1 -0
- package/src/types/loader-types.ts +60 -5
- package/src/types/segments.ts +7 -0
- package/src/urls/include-helper.ts +22 -4
- package/src/urls/path-helper-types.ts +14 -1
- package/src/use-loader.tsx +67 -6
- package/src/vite/discovery/client-urls-projection.ts +322 -0
- package/src/vite/discovery/discover-routers.ts +43 -17
- package/src/vite/discovery/state.ts +11 -1
- package/src/vite/discovery/virtual-module-codegen.ts +20 -0
- package/src/vite/encryption-key.ts +29 -0
- package/src/vite/plugins/expose-action-id.ts +2 -2
- package/src/vite/plugins/expose-internal-ids.ts +46 -0
- package/src/vite/plugins/server-ref-hashing.ts +74 -0
- package/src/vite/plugins/server-reference-pattern.ts +10 -0
- package/src/vite/plugins/virtual-entries.ts +12 -3
- package/src/vite/rango.ts +9 -0
- package/src/vite/router-discovery.ts +184 -14
- package/src/vite/utils/shared-utils.ts +12 -7
- package/dist/types.backup/__internal.d.ts +0 -127
- package/dist/types.backup/bin/rango.d.ts +0 -1
- package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
- package/dist/types.backup/browser/action-fence.d.ts +0 -33
- package/dist/types.backup/browser/app-shell.d.ts +0 -34
- package/dist/types.backup/browser/app-version.d.ts +0 -6
- package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
- package/dist/types.backup/browser/cookie-name.d.ts +0 -66
- package/dist/types.backup/browser/event-controller.d.ts +0 -221
- package/dist/types.backup/browser/history-state.d.ts +0 -26
- package/dist/types.backup/browser/index.d.ts +0 -1
- package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
- package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
- package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
- package/dist/types.backup/browser/logging.d.ts +0 -33
- package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
- package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
- package/dist/types.backup/browser/navigation-client.d.ts +0 -17
- package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
- package/dist/types.backup/browser/navigation-store.d.ts +0 -95
- package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
- package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
- package/dist/types.backup/browser/partial-update.d.ts +0 -61
- package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
- package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
- package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
- package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
- package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
- package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
- package/dist/types.backup/browser/rango-state.d.ts +0 -52
- package/dist/types.backup/browser/react/Link.d.ts +0 -140
- package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
- package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
- package/dist/types.backup/browser/react/context.d.ts +0 -54
- package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
- package/dist/types.backup/browser/react/index.d.ts +0 -1
- package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
- package/dist/types.backup/browser/react/location-state.d.ts +0 -29
- package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
- package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
- package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
- package/dist/types.backup/browser/react/use-action.d.ts +0 -61
- package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
- package/dist/types.backup/browser/react/use-href.d.ts +0 -32
- package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
- package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
- package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
- package/dist/types.backup/browser/react/use-params.d.ts +0 -21
- package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
- package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
- package/dist/types.backup/browser/react/use-router.d.ts +0 -23
- package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
- package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
- package/dist/types.backup/browser/response-adapter.d.ts +0 -58
- package/dist/types.backup/browser/rsc-router.d.ts +0 -141
- package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
- package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
- package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
- package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
- package/dist/types.backup/browser/types.d.ts +0 -530
- package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
- package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
- package/dist/types.backup/build/generate-manifest.d.ts +0 -100
- package/dist/types.backup/build/generate-route-types.d.ts +0 -8
- package/dist/types.backup/build/index.d.ts +0 -21
- package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
- package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
- package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
- package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
- package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
- package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
- package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
- package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
- package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
- package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
- package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
- package/dist/types.backup/cache/background-task.d.ts +0 -21
- package/dist/types.backup/cache/cache-error.d.ts +0 -71
- package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
- package/dist/types.backup/cache/cache-policy.d.ts +0 -59
- package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
- package/dist/types.backup/cache/cache-scope.d.ts +0 -134
- package/dist/types.backup/cache/cache-tag.d.ts +0 -79
- package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
- package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
- package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
- package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
- package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
- package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
- package/dist/types.backup/cache/cf/index.d.ts +0 -3
- package/dist/types.backup/cache/document-cache.d.ts +0 -69
- package/dist/types.backup/cache/handle-capture.d.ts +0 -23
- package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
- package/dist/types.backup/cache/index.d.ts +0 -7
- package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
- package/dist/types.backup/cache/profile-registry.d.ts +0 -40
- package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
- package/dist/types.backup/cache/segment-codec.d.ts +0 -78
- package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
- package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
- package/dist/types.backup/cache/taint.d.ts +0 -71
- package/dist/types.backup/cache/types.d.ts +0 -407
- package/dist/types.backup/cache/vercel/index.d.ts +0 -1
- package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
- package/dist/types.backup/client.d.ts +0 -184
- package/dist/types.backup/client.rsc.d.ts +0 -39
- package/dist/types.backup/cloudflare/index.d.ts +0 -7
- package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
- package/dist/types.backup/component-utils.d.ts +0 -46
- package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
- package/dist/types.backup/context-var.d.ts +0 -84
- package/dist/types.backup/debug.d.ts +0 -57
- package/dist/types.backup/decode-loader-results.d.ts +0 -5
- package/dist/types.backup/default-error-boundary.d.ts +0 -10
- package/dist/types.backup/defer.d.ts +0 -89
- package/dist/types.backup/deps/browser.d.ts +0 -1
- package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
- package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
- package/dist/types.backup/deps/rsc.d.ts +0 -1
- package/dist/types.backup/deps/ssr.d.ts +0 -1
- package/dist/types.backup/encode-kv.d.ts +0 -35
- package/dist/types.backup/errors.d.ts +0 -226
- package/dist/types.backup/escape-script.d.ts +0 -44
- package/dist/types.backup/handle.d.ts +0 -93
- package/dist/types.backup/handles/MetaTags.d.ts +0 -17
- package/dist/types.backup/handles/Scripts.d.ts +0 -38
- package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
- package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
- package/dist/types.backup/handles/is-thenable.d.ts +0 -12
- package/dist/types.backup/handles/meta.d.ts +0 -43
- package/dist/types.backup/handles/script.d.ts +0 -139
- package/dist/types.backup/host/cookie-handler.d.ts +0 -8
- package/dist/types.backup/host/errors.d.ts +0 -40
- package/dist/types.backup/host/index.d.ts +0 -33
- package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
- package/dist/types.backup/host/router.d.ts +0 -12
- package/dist/types.backup/host/testing.d.ts +0 -41
- package/dist/types.backup/host/types.d.ts +0 -148
- package/dist/types.backup/host/utils.d.ts +0 -20
- package/dist/types.backup/href-client.d.ts +0 -214
- package/dist/types.backup/index.d.ts +0 -112
- package/dist/types.backup/index.rsc.d.ts +0 -51
- package/dist/types.backup/internal-debug.d.ts +0 -1
- package/dist/types.backup/loader-store.d.ts +0 -193
- package/dist/types.backup/loader.d.ts +0 -18
- package/dist/types.backup/loader.rsc.d.ts +0 -18
- package/dist/types.backup/missing-id-error.d.ts +0 -1
- package/dist/types.backup/outlet-context.d.ts +0 -12
- package/dist/types.backup/outlet-provider.d.ts +0 -12
- package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
- package/dist/types.backup/prerender/param-hash.d.ts +0 -6
- package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
- package/dist/types.backup/prerender/store.d.ts +0 -62
- package/dist/types.backup/prerender.d.ts +0 -292
- package/dist/types.backup/redirect-origin.d.ts +0 -55
- package/dist/types.backup/regex-escape.d.ts +0 -6
- package/dist/types.backup/render-error-thrower.d.ts +0 -13
- package/dist/types.backup/response-utils.d.ts +0 -35
- package/dist/types.backup/reverse.d.ts +0 -206
- package/dist/types.backup/root-error-boundary.d.ts +0 -32
- package/dist/types.backup/route-content-wrapper.d.ts +0 -40
- package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
- package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
- package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
- package/dist/types.backup/route-definition/index.d.ts +0 -7
- package/dist/types.backup/route-definition/redirect.d.ts +0 -48
- package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
- package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
- package/dist/types.backup/route-definition.d.ts +0 -1
- package/dist/types.backup/route-map-builder.d.ts +0 -127
- package/dist/types.backup/route-name.d.ts +0 -27
- package/dist/types.backup/route-types.d.ts +0 -172
- package/dist/types.backup/router/basename.d.ts +0 -10
- package/dist/types.backup/router/content-negotiation.d.ts +0 -91
- package/dist/types.backup/router/debug-manifest.d.ts +0 -7
- package/dist/types.backup/router/error-handling.d.ts +0 -76
- package/dist/types.backup/router/find-match.d.ts +0 -19
- package/dist/types.backup/router/handler-context.d.ts +0 -41
- package/dist/types.backup/router/instrument.d.ts +0 -161
- package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
- package/dist/types.backup/router/lazy-includes.d.ts +0 -26
- package/dist/types.backup/router/loader-resolution.d.ts +0 -63
- package/dist/types.backup/router/logging.d.ts +0 -41
- package/dist/types.backup/router/manifest.d.ts +0 -8
- package/dist/types.backup/router/match-api.d.ts +0 -19
- package/dist/types.backup/router/match-context.d.ts +0 -184
- package/dist/types.backup/router/match-handlers.d.ts +0 -49
- package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
- package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
- package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
- package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
- package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
- package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
- package/dist/types.backup/router/match-pipelines.d.ts +0 -103
- package/dist/types.backup/router/match-result.d.ts +0 -114
- package/dist/types.backup/router/metrics.d.ts +0 -6
- package/dist/types.backup/router/middleware-types.d.ts +0 -74
- package/dist/types.backup/router/middleware.d.ts +0 -116
- package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
- package/dist/types.backup/router/params-util.d.ts +0 -8
- package/dist/types.backup/router/parse-pattern.d.ts +0 -38
- package/dist/types.backup/router/pattern-matching.d.ts +0 -169
- package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
- package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
- package/dist/types.backup/router/prerender-match.d.ts +0 -50
- package/dist/types.backup/router/preview-match.d.ts +0 -22
- package/dist/types.backup/router/request-classification.d.ts +0 -104
- package/dist/types.backup/router/revalidation.d.ts +0 -57
- package/dist/types.backup/router/route-snapshot.d.ts +0 -112
- package/dist/types.backup/router/router-context.d.ts +0 -137
- package/dist/types.backup/router/router-interfaces.d.ts +0 -432
- package/dist/types.backup/router/router-options.d.ts +0 -738
- package/dist/types.backup/router/router-registry.d.ts +0 -15
- package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
- package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
- package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
- package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
- package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
- package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
- package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
- package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
- package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
- package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
- package/dist/types.backup/router/segment-resolution.d.ts +0 -3
- package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
- package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
- package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
- package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
- package/dist/types.backup/router/telemetry.d.ts +0 -215
- package/dist/types.backup/router/timeout.d.ts +0 -68
- package/dist/types.backup/router/tracing.d.ts +0 -125
- package/dist/types.backup/router/trie-matching.d.ts +0 -32
- package/dist/types.backup/router/types.d.ts +0 -98
- package/dist/types.backup/router/url-params.d.ts +0 -26
- package/dist/types.backup/router.d.ts +0 -7
- package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
- package/dist/types.backup/rsc/full-payload.d.ts +0 -22
- package/dist/types.backup/rsc/handler-context.d.ts +0 -31
- package/dist/types.backup/rsc/handler.d.ts +0 -9
- package/dist/types.backup/rsc/helpers.d.ts +0 -213
- package/dist/types.backup/rsc/index.d.ts +0 -17
- package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
- package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
- package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
- package/dist/types.backup/rsc/nonce.d.ts +0 -28
- package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
- package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
- package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
- package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
- package/dist/types.backup/rsc/response-error.d.ts +0 -19
- package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
- package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
- package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
- package/dist/types.backup/rsc/server-action.d.ts +0 -68
- package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
- package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
- package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
- package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
- package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
- package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
- package/dist/types.backup/rsc/types.d.ts +0 -290
- package/dist/types.backup/runtime-env.d.ts +0 -1
- package/dist/types.backup/search-params.d.ts +0 -125
- package/dist/types.backup/segment-content-promise.d.ts +0 -13
- package/dist/types.backup/segment-fragments.d.ts +0 -56
- package/dist/types.backup/segment-loader-promise.d.ts +0 -22
- package/dist/types.backup/segment-system.d.ts +0 -84
- package/dist/types.backup/serialize.d.ts +0 -164
- package/dist/types.backup/server/context.d.ts +0 -494
- package/dist/types.backup/server/cookie-parse.d.ts +0 -10
- package/dist/types.backup/server/cookie-store.d.ts +0 -107
- package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
- package/dist/types.backup/server/handle-store.d.ts +0 -100
- package/dist/types.backup/server/loader-registry.d.ts +0 -32
- package/dist/types.backup/server/request-context.d.ts +0 -596
- package/dist/types.backup/server/root-layout.d.ts +0 -3
- package/dist/types.backup/server.d.ts +0 -15
- package/dist/types.backup/ssr/index.d.ts +0 -233
- package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
- package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
- package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
- package/dist/types.backup/static-handler.d.ts +0 -57
- package/dist/types.backup/testing/cache-status.d.ts +0 -63
- package/dist/types.backup/testing/collect-handle.d.ts +0 -20
- package/dist/types.backup/testing/dispatch.d.ts +0 -123
- package/dist/types.backup/testing/dom.entry.d.ts +0 -15
- package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
- package/dist/types.backup/testing/e2e/index.d.ts +0 -30
- package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
- package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
- package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
- package/dist/types.backup/testing/e2e/server.d.ts +0 -35
- package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
- package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
- package/dist/types.backup/testing/flight-tree.d.ts +0 -192
- package/dist/types.backup/testing/flight.d.ts +0 -115
- package/dist/types.backup/testing/flight.entry.d.ts +0 -27
- package/dist/types.backup/testing/generated-routes.d.ts +0 -66
- package/dist/types.backup/testing/index.d.ts +0 -52
- package/dist/types.backup/testing/internal/context.d.ts +0 -225
- package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
- package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
- package/dist/types.backup/testing/render-handler.d.ts +0 -160
- package/dist/types.backup/testing/render-route.d.ts +0 -246
- package/dist/types.backup/testing/run-loader.d.ts +0 -186
- package/dist/types.backup/testing/run-middleware.d.ts +0 -132
- package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
- package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
- package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
- package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
- package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
- package/dist/types.backup/testing/vitest.d.ts +0 -205
- package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
- package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
- package/dist/types.backup/theme/constants.d.ts +0 -39
- package/dist/types.backup/theme/index.d.ts +0 -29
- package/dist/types.backup/theme/theme-context.d.ts +0 -21
- package/dist/types.backup/theme/theme-script.d.ts +0 -26
- package/dist/types.backup/theme/types.d.ts +0 -162
- package/dist/types.backup/theme/use-theme.d.ts +0 -8
- package/dist/types.backup/types/boundaries.d.ts +0 -93
- package/dist/types.backup/types/cache-types.d.ts +0 -191
- package/dist/types.backup/types/error-types.d.ts +0 -114
- package/dist/types.backup/types/global-namespace.d.ts +0 -90
- package/dist/types.backup/types/handler-context.d.ts +0 -658
- package/dist/types.backup/types/index.d.ts +0 -11
- package/dist/types.backup/types/loader-types.d.ts +0 -182
- package/dist/types.backup/types/request-scope.d.ts +0 -93
- package/dist/types.backup/types/route-config.d.ts +0 -105
- package/dist/types.backup/types/route-entry.d.ts +0 -95
- package/dist/types.backup/types/segments.d.ts +0 -234
- package/dist/types.backup/types.d.ts +0 -1
- package/dist/types.backup/urls/include-helper.d.ts +0 -17
- package/dist/types.backup/urls/include-provider.d.ts +0 -27
- package/dist/types.backup/urls/index.d.ts +0 -6
- package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
- package/dist/types.backup/urls/path-helper.d.ts +0 -12
- package/dist/types.backup/urls/pattern-types.d.ts +0 -166
- package/dist/types.backup/urls/response-types.d.ts +0 -67
- package/dist/types.backup/urls/type-extraction.d.ts +0 -157
- package/dist/types.backup/urls/urls-function.d.ts +0 -24
- package/dist/types.backup/urls.d.ts +0 -1
- package/dist/types.backup/use-loader.d.ts +0 -150
- package/dist/types.backup/vercel/index.d.ts +0 -10
- package/dist/types.backup/vercel/tracing.d.ts +0 -70
- package/dist/types.backup/vite/debug.d.ts +0 -80
- package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
- package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
- package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
- package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
- package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
- package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
- package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
- package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
- package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
- package/dist/types.backup/vite/discovery/state.d.ts +0 -162
- package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
- package/dist/types.backup/vite/index.d.ts +0 -11
- package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
- package/dist/types.backup/vite/plugin-types.d.ts +0 -298
- package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
- package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
- package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
- package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
- package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
- package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
- package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
- package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
- package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
- package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
- package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
- package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
- package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
- package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
- package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
- package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
- package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
- package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
- package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
- package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
- package/dist/types.backup/vite/rango.d.ts +0 -29
- package/dist/types.backup/vite/router-discovery.d.ts +0 -23
- package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
- package/dist/types.backup/vite/utils/banner.d.ts +0 -2
- package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
- package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
- package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
- package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
- package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
- package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
- package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
- package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integrated PPR shell serving (Axis 2, see docs/design/ppr-shell-resume.md).
|
|
3
|
-
*
|
|
4
|
-
* PPR is opt-in per PAGE ROUTE via the `ppr` path option
|
|
5
|
-
* (`path(pattern, Handler, { name, ppr: true | PartialPrerenderProps })`) and the
|
|
6
|
-
* serving logic is INTEGRAL to the render pipeline — there is no middleware to
|
|
7
|
-
* mount. This module owns the config/key/store plumbing the render layer
|
|
8
|
-
* (rsc-rendering.ts) uses at its COMMIT POINT, which sits after the WHOLE
|
|
9
|
-
* middleware chain (global `router.use()` chain AND route DSL `middleware()`,
|
|
10
|
-
* both of which wrap the render pass): any middleware rejection/redirect wins
|
|
11
|
-
* before a single shell byte is written.
|
|
12
|
-
*
|
|
13
|
-
* The shell store is the app-level `createRouter({ cache })` store
|
|
14
|
-
* (`requestCtx._cacheStore`). A store without the `getShell`/`putShell` family
|
|
15
|
-
* degrades a ppr route to axis 1 with a once-per-key warning (the declared
|
|
16
|
-
* intent cannot be honored — unlike an undeclared route, which is silent).
|
|
17
|
-
*/
|
|
18
|
-
import { type EntryData } from "../server/context.js";
|
|
19
|
-
import type { ShellCacheEntry, SegmentCacheStore } from "../cache/types.js";
|
|
20
|
-
/** Debug/status header the browser (and e2e assertions) can read: HIT | MISS. */
|
|
21
|
-
export declare const SHELL_STATUS_HEADER = "x-rango-shell";
|
|
22
|
-
/**
|
|
23
|
-
* Default shell ttl (seconds) for `ppr: true` and for a PartialPrerenderProps
|
|
24
|
-
* that omits `ttl`.
|
|
25
|
-
*/
|
|
26
|
-
export declare const DEFAULT_PPR_TTL_SECONDS = 300;
|
|
27
|
-
/**
|
|
28
|
-
* Timeout for the dev /__rsc_shell endpoint's sequential /__rsc_prerender
|
|
29
|
-
* pre-flight probe (vite/router-discovery.ts). Hoisted here so the client-side
|
|
30
|
-
* fetch bound (shell-build-manifest.ts devShellFetchTimeoutMs) enumerates the
|
|
31
|
-
* SAME term of the endpoint's worst-case envelope — the two cannot drift.
|
|
32
|
-
*/
|
|
33
|
-
export declare const DEV_SHELL_PROBE_TIMEOUT_MS: number;
|
|
34
|
-
/** The route's ppr option normalized to a concrete policy. */
|
|
35
|
-
export interface ResolvedPprConfig {
|
|
36
|
-
ttl: number;
|
|
37
|
-
swr?: number;
|
|
38
|
-
tags?: string[];
|
|
39
|
-
/**
|
|
40
|
-
* Snapshot size cap, passed through undefaulted (like swr/tags): the single
|
|
41
|
-
* defaulting site is captureAndStoreShell (DEFAULT_PPR_MAX_SNAPSHOT_BYTES in
|
|
42
|
-
* shell-capture.ts), so direct descriptor callers and resolved configs
|
|
43
|
-
* cannot drift.
|
|
44
|
-
*/
|
|
45
|
-
maxSnapshotBytes?: number;
|
|
46
|
-
/**
|
|
47
|
-
* Capture settle budget in ms (`ppr.captureTimeout`). Undefined = the
|
|
48
|
-
* capture default (SHELL_CAPTURE_MAX_WAIT_MS, 15_000) — the default's single
|
|
49
|
-
* owner stays shell-capture.ts so build/runtime producers cannot drift.
|
|
50
|
-
*/
|
|
51
|
-
captureTimeout?: number;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Validate the raw `ppr.captureTimeout` option: a finite number >= 1ms passes
|
|
55
|
-
* through; anything else (including 0/negative/NaN/Infinity/non-number)
|
|
56
|
-
* resolves to undefined, which means "use the capture default" downstream.
|
|
57
|
-
* Mirrors the prefetch-limit option policy: invalid values silently fall back
|
|
58
|
-
* to the default rather than throwing at request time. Also the boundary
|
|
59
|
-
* re-normalizer for the dev /__rsc_shell endpoint (vite/router-discovery.ts),
|
|
60
|
-
* whose param crossed an HTTP query string.
|
|
61
|
-
*/
|
|
62
|
-
export declare function normalizeCaptureTimeout(value: unknown): number | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Normalize the matched page route's `ppr` path option. Returns null when the
|
|
65
|
-
* route does not declare `ppr` (or declares `ppr: false`) — the caller then does
|
|
66
|
-
* NOTHING: no store read, no capture, no logs. Pure axis 1, zero cost.
|
|
67
|
-
*
|
|
68
|
-
* The route's NAME is irrelevant here (and everywhere on the shell lane):
|
|
69
|
-
* nameless `path()` routes register their EntryData under a synthesized
|
|
70
|
-
* `$path_*` manifest key with the `ppr` option intact (urls/path-helper.ts),
|
|
71
|
-
* so a nameless entry resolves exactly like a named one — pinned by the
|
|
72
|
-
* nameless-ppr e2e in both apps (issue #714).
|
|
73
|
-
*
|
|
74
|
-
* PPR is a DOCUMENT-level property of the page route; there is no subtree
|
|
75
|
-
* inheritance (declaring it on a layout is not supported — a follow-up).
|
|
76
|
-
*/
|
|
77
|
-
export declare function resolvePprConfig(entry: EntryData | undefined | null): ResolvedPprConfig | null;
|
|
78
|
-
/**
|
|
79
|
-
* Shell cache key: host + pathname + sorted search + a `:shell` namespace suffix
|
|
80
|
-
* (so it can never collide with a document-cache key; the store further isolates
|
|
81
|
-
* the shell family internally).
|
|
82
|
-
*
|
|
83
|
-
* The key includes the request HOST: in a multi-tenant host-router deployment
|
|
84
|
-
* (one worker, one shared KV/runtime-cache store) a host-less key would serve
|
|
85
|
-
* tenant A's captured shell to tenant B's users.
|
|
86
|
-
*/
|
|
87
|
-
export declare function buildShellKey(url: URL): string;
|
|
88
|
-
/**
|
|
89
|
-
* Version gates for a stored shell: reactVersion AND buildVersion must both
|
|
90
|
-
* match the running server. The postponed blob encodes hole positions against
|
|
91
|
-
* one exact tree, so resuming it under a different React OR a different app
|
|
92
|
-
* build tree-mismatches inside resume() — after the 200 + prelude committed,
|
|
93
|
-
* with no recovery. Either mismatch is a miss: the recapture overwrites the
|
|
94
|
-
* same key (self-healing) and the entry otherwise ages out via TTL. An entry
|
|
95
|
-
* with no buildVersion (stored before the field existed) is a miss for the
|
|
96
|
-
* same reason — its build is unknown, so it cannot be proven resumable.
|
|
97
|
-
*/
|
|
98
|
-
export declare function isValidShellHit(entry: ShellCacheEntry, buildVersion: string): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Payload integrity gate, run BEFORE the HIT response commits: a stored entry
|
|
101
|
-
* whose prelude is not decodable base64 or whose postponed blob is not
|
|
102
|
-
* parseable JSON would otherwise throw AFTER the 200 + full static prelude
|
|
103
|
-
* flushed (`serveShellHit` decodes at stream construction, `resumeShellHTML`
|
|
104
|
-
* parses in the tail) — the client gets a visually complete page that never
|
|
105
|
-
* hydrates, re-served on every request until the entry ages out (no eviction
|
|
106
|
-
* path exists; failure schedules no recapture by itself). Checking here turns
|
|
107
|
-
* a corrupt entry (store-layer fault) into a plain MISS the recapture
|
|
108
|
-
* overwrites. Cost: one duplicate decode/parse per HIT, sub-ms against a
|
|
109
|
-
* prelude flush that dominates the path.
|
|
110
|
-
*/
|
|
111
|
-
export declare function hasIntactShellPayload(entry: ShellCacheEntry): boolean;
|
|
112
|
-
/** Decode a base64 prelude back into bytes for stream composition. */
|
|
113
|
-
export declare function base64ToBytes(b64: string): Uint8Array;
|
|
114
|
-
/** True when the store implements the shell entry family. */
|
|
115
|
-
export declare function hasShellFamily(store: SegmentCacheStore | undefined): store is SegmentCacheStore & {
|
|
116
|
-
getShell: NonNullable<SegmentCacheStore["getShell"]>;
|
|
117
|
-
putShell: NonNullable<SegmentCacheStore["putShell"]>;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Warn once per key that a route declared `ppr` but the app-level cache store
|
|
121
|
-
* does not implement the shell family (getShell/putShell), so the route stays on
|
|
122
|
-
* axis 1. Unlike an undeclared route (silent), a declared route that cannot be
|
|
123
|
-
* honored deserves a diagnostic.
|
|
124
|
-
*/
|
|
125
|
-
export declare function warnShellStoreMissingOnce(key: string): void;
|
|
126
|
-
/**
|
|
127
|
-
* Warn once per key that a route declared `ppr` but a per-request CSP nonce is
|
|
128
|
-
* active for the request, so the route stays on axis 1 (a shared shell would
|
|
129
|
-
* freeze one request's nonce for every visitor — useNonce() renders it into every
|
|
130
|
-
* nonced script/style/meta and the browser's CSP would then reject the frozen
|
|
131
|
-
* nonce for all but the capture request). The nonce blocks capture whether it came
|
|
132
|
-
* from the `createRouter({ nonce })` provider or from a direct `ctx.set(nonce, …)`
|
|
133
|
-
* token write in middleware. Same declared-intent-cannot-be-honored doctrine as
|
|
134
|
-
* the missing-store warning above (an undeclared route stays silent).
|
|
135
|
-
*/
|
|
136
|
-
export declare function warnPprNonceActiveOnce(key: string): void;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSR Setup Utilities
|
|
3
|
-
*
|
|
4
|
-
* Manages early kickoff and retrieval of SSR module loading and stream mode
|
|
5
|
-
* resolution. Both operations are request-scoped but independent of route
|
|
6
|
-
* matching, so they can run in parallel with segment resolution.
|
|
7
|
-
*/
|
|
8
|
-
import type { HandlerContext } from "./handler-context.js";
|
|
9
|
-
import type { SSRModule } from "./types.js";
|
|
10
|
-
import type { SSRStreamMode } from "../router/router-options.js";
|
|
11
|
-
import type { MetricsStore } from "../server/context.js";
|
|
12
|
-
export type SSRSetup = readonly [SSRModule, SSRStreamMode];
|
|
13
|
-
/**
|
|
14
|
-
* Key used to stash the early SSR setup promise on request variables.
|
|
15
|
-
* Read back via `getSSRSetup`.
|
|
16
|
-
*/
|
|
17
|
-
export declare const SSR_SETUP_VAR = "__ssrSetup";
|
|
18
|
-
/**
|
|
19
|
-
* Start loading the SSR module and resolving the stream mode in parallel.
|
|
20
|
-
* When a `getMetricsStore` getter is provided, records individual
|
|
21
|
-
* `ssr:module-load` and `ssr:stream-mode` metrics (the getter is called
|
|
22
|
-
* lazily so stores created after kickoff are still captured). Without a
|
|
23
|
-
* getter the promises run bare — no `.then()` microtasks, no
|
|
24
|
-
* `performance.now()` calls — keeping the non-debug hot path lean.
|
|
25
|
-
*/
|
|
26
|
-
export declare function startSSRSetup<TEnv>(ctx: HandlerContext<TEnv>, request: Request, env: TEnv, url: URL, getMetricsStore?: () => MetricsStore | undefined): Promise<SSRSetup>;
|
|
27
|
-
/**
|
|
28
|
-
* Retrieve the SSR setup result. Returns the early-kicked-off promise
|
|
29
|
-
* when available (stashed on request variables), otherwise starts a
|
|
30
|
-
* fresh setup.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getSSRSetup<TEnv>(ctx: HandlerContext<TEnv>, request: Request, env: TEnv, url: URL, metricsStore: MetricsStore | undefined): Promise<SSRSetup>;
|
|
33
|
-
/**
|
|
34
|
-
* Classify whether a request may require SSR (HTML rendering).
|
|
35
|
-
*
|
|
36
|
-
* Returns false for requests that are definitively RSC-only: transport
|
|
37
|
-
* params (partial/action/loader/__rsc), prerender collection, or an explicit
|
|
38
|
-
* Accept: text/x-component. Must never return false for a request whose
|
|
39
|
-
* render-time decision (isRscRequest) will be HTML — the two share
|
|
40
|
-
* acceptsFlightExplicitly so the Accept rule cannot drift. document-cache.ts
|
|
41
|
-
* keys its HTML/RSC response slots off this function, so any divergence from
|
|
42
|
-
* the render decision poisons a cache slot with the wrong representation.
|
|
43
|
-
*
|
|
44
|
-
* Note: response/mime routes are excluded by the caller — this function
|
|
45
|
-
* runs after classifyRequest() determines the request mode.
|
|
46
|
-
*/
|
|
47
|
-
export declare function mayNeedSSR(request: Request, url: URL): boolean;
|
|
48
|
-
export declare function isRscRequest(request: Request, url: URL, isPartial: boolean): boolean;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { MatchResult } from "../types.js";
|
|
2
|
-
import type { getRequestContext } from "../server/request-context.js";
|
|
3
|
-
import type { OnErrorCallback } from "../types/error-types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Apply transition({ when }) gates to a payload's segments.
|
|
6
|
-
*
|
|
7
|
-
* The predicates were collected during resolution (keyed by segment id) and
|
|
8
|
-
* stripped from the serialized config; here — after handlers ran and outside any
|
|
9
|
-
* cache scope — we evaluate each and drop the segment's transition when the
|
|
10
|
-
* predicate does not hold, so the navigation streams its loading fallback
|
|
11
|
-
* instead of holding the previous content. A predicate that throws is reported
|
|
12
|
-
* to the router's onError (phase "rendering") and then treated as "do not hold"
|
|
13
|
-
* (conservative), so a buggy predicate degrades to no transition rather than
|
|
14
|
-
* failing the response.
|
|
15
|
-
*
|
|
16
|
-
* Mutating the segments here is safe: the segment cache stores a serialized copy
|
|
17
|
-
* (segment-codec), written during match() BEFORE this gate runs, so dropping a
|
|
18
|
-
* transition never corrupts a cache entry. The flip side is that a cache hit
|
|
19
|
-
* skips resolution, collects no predicate, and replays the cached transition
|
|
20
|
-
* as-is (it was serialized before the gate) — combining transition({ when })
|
|
21
|
-
* with cache() on the same segment freezes the gate to its cached state, so
|
|
22
|
-
* avoid caching a route whose transition decision is request-dependent.
|
|
23
|
-
*
|
|
24
|
-
* Returns the same array (mutated) for inline use at the payload's `segments`
|
|
25
|
-
* field.
|
|
26
|
-
*/
|
|
27
|
-
export declare function gateTransitions(segments: MatchResult["segments"], ctx: ReturnType<typeof getRequestContext>, onError?: OnErrorCallback): MatchResult["segments"];
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RSC Handler Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for the RSC request handler, payload structures,
|
|
5
|
-
* and SSR integration.
|
|
6
|
-
*/
|
|
7
|
-
import type { ResolvedSegment, SlotState } from "../types.js";
|
|
8
|
-
import type { HandleData } from "../server/handle-store.js";
|
|
9
|
-
import type { RangoInternal } from "../router/router-interfaces.js";
|
|
10
|
-
import type { ResolvedThemeConfig, Theme } from "../theme/types.js";
|
|
11
|
-
/**
|
|
12
|
-
* RSC payload sent to the client.
|
|
13
|
-
* The tree is always reconstructed from metadata.segments by consumers
|
|
14
|
-
* (SSR via renderSegments, browser via renderSegments in bridges).
|
|
15
|
-
*/
|
|
16
|
-
export interface RscPayload {
|
|
17
|
-
metadata?: {
|
|
18
|
-
pathname: string;
|
|
19
|
-
segments: ResolvedSegment[];
|
|
20
|
-
/** Router instance ID. When this changes between navigations, the client
|
|
21
|
-
* discards cached segments and does a full tree replacement (app switch). */
|
|
22
|
-
routerId?: string;
|
|
23
|
-
isPartial?: boolean;
|
|
24
|
-
isError?: boolean;
|
|
25
|
-
matched?: string[];
|
|
26
|
-
diff?: string[];
|
|
27
|
-
/**
|
|
28
|
-
* All segment ids re-resolved on the server, including null-component
|
|
29
|
-
* ones excluded from `segments`/`diff`. Drives client-side handle-bucket
|
|
30
|
-
* cleanup. Superset of `diff`. See MatchResult.resolvedIds.
|
|
31
|
-
*/
|
|
32
|
-
resolvedIds?: string[];
|
|
33
|
-
/** Merged route params from the matched route */
|
|
34
|
-
params?: Record<string, string>;
|
|
35
|
-
slots?: Record<string, SlotState>;
|
|
36
|
-
/** Root layout component for browser-side re-renders (client component reference) */
|
|
37
|
-
rootLayout?: React.ComponentType<{
|
|
38
|
-
children: React.ReactNode;
|
|
39
|
-
}>;
|
|
40
|
-
/** Handle data accumulated across route segments (async generator that yields on each push) */
|
|
41
|
-
handles?: AsyncGenerator<HandleData, void, unknown>;
|
|
42
|
-
/** RSC version string for cache invalidation */
|
|
43
|
-
version?: string;
|
|
44
|
-
/** TTL in milliseconds for the client-side in-memory prefetch cache */
|
|
45
|
-
prefetchCacheTTL?: number;
|
|
46
|
-
/** Max entries in the client-side in-memory prefetch cache (FIFO eviction) */
|
|
47
|
-
prefetchCacheSize?: number;
|
|
48
|
-
/** Max concurrent speculative prefetch requests on the client */
|
|
49
|
-
prefetchConcurrency?: number;
|
|
50
|
-
/** Server-resolved rango state cookie name; the client reads it verbatim. */
|
|
51
|
-
stateCookieName?: string;
|
|
52
|
-
/** Theme configuration for FOUC prevention */
|
|
53
|
-
themeConfig?: ResolvedThemeConfig | null;
|
|
54
|
-
/** Initial theme from cookie (for SSR hydration) */
|
|
55
|
-
initialTheme?: Theme;
|
|
56
|
-
/** URL prefix for all routes (from createRouter({ basename })). */
|
|
57
|
-
basename?: string;
|
|
58
|
-
/** Whether connection warmup is enabled */
|
|
59
|
-
warmupEnabled?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Whether the client should hydrate inside React.StrictMode. Carried on
|
|
62
|
-
* the initial full-render payload only; the browser entry reads it once at
|
|
63
|
-
* hydration. Absent on partial (navigation) payloads. Defaults to true on
|
|
64
|
-
* the client when omitted.
|
|
65
|
-
*/
|
|
66
|
-
strictMode?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Server-side redirect with optional state (for partial requests).
|
|
69
|
-
* `external: true` (from redirect(url, { external: true })) tells the client
|
|
70
|
-
* to hard-navigate to an off-host target instead of validating same-origin.
|
|
71
|
-
*/
|
|
72
|
-
redirect?: {
|
|
73
|
-
url: string;
|
|
74
|
-
external?: boolean;
|
|
75
|
-
};
|
|
76
|
-
/** Server-set location state to include in history.pushState */
|
|
77
|
-
locationState?: Record<string, unknown>;
|
|
78
|
-
};
|
|
79
|
-
returnValue?: {
|
|
80
|
-
ok: boolean;
|
|
81
|
-
data: unknown;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* React form state type for useActionState progressive enhancement
|
|
86
|
-
*/
|
|
87
|
-
export type ReactFormState = unknown;
|
|
88
|
-
/**
|
|
89
|
-
* RSC dependencies from @vitejs/plugin-rsc/rsc
|
|
90
|
-
*/
|
|
91
|
-
export interface RSCDependencies {
|
|
92
|
-
/**
|
|
93
|
-
* renderToReadableStream from @vitejs/plugin-rsc/rsc
|
|
94
|
-
*/
|
|
95
|
-
renderToReadableStream: <T>(payload: T, options?: {
|
|
96
|
-
temporaryReferences?: unknown;
|
|
97
|
-
onError?: (error: unknown) => string | void;
|
|
98
|
-
}) => ReadableStream<Uint8Array>;
|
|
99
|
-
/**
|
|
100
|
-
* decodeReply from @vitejs/plugin-rsc/rsc
|
|
101
|
-
*/
|
|
102
|
-
decodeReply: (body: FormData | string, options?: {
|
|
103
|
-
temporaryReferences?: unknown;
|
|
104
|
-
}) => Promise<unknown[]>;
|
|
105
|
-
/**
|
|
106
|
-
* createTemporaryReferenceSet from @vitejs/plugin-rsc/rsc
|
|
107
|
-
*/
|
|
108
|
-
createTemporaryReferenceSet: () => unknown;
|
|
109
|
-
/**
|
|
110
|
-
* loadServerAction from @vitejs/plugin-rsc/rsc
|
|
111
|
-
*/
|
|
112
|
-
loadServerAction: (actionId: string) => Promise<Function>;
|
|
113
|
-
/**
|
|
114
|
-
* decodeAction from @vitejs/plugin-rsc/rsc
|
|
115
|
-
* Decodes a FormData into a bound action function (for useActionState forms)
|
|
116
|
-
*/
|
|
117
|
-
decodeAction: (body: FormData) => Promise<() => Promise<unknown>>;
|
|
118
|
-
/**
|
|
119
|
-
* decodeFormState from @vitejs/plugin-rsc/rsc
|
|
120
|
-
* Decodes the action result into a ReactFormState for useActionState progressive enhancement
|
|
121
|
-
*/
|
|
122
|
-
decodeFormState: (actionResult: unknown, body: FormData) => Promise<ReactFormState | null>;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Options for SSR HTML rendering
|
|
126
|
-
*/
|
|
127
|
-
export interface SSRRenderOptions {
|
|
128
|
-
/**
|
|
129
|
-
* Form state for useActionState progressive enhancement.
|
|
130
|
-
* This is the result of decodeFormState() and should be passed to
|
|
131
|
-
* react-dom's renderToReadableStream to enable useActionState to
|
|
132
|
-
* receive the action result during SSR.
|
|
133
|
-
*/
|
|
134
|
-
formState?: ReactFormState | null;
|
|
135
|
-
/**
|
|
136
|
-
* Nonce for Content Security Policy (CSP)
|
|
137
|
-
*/
|
|
138
|
-
nonce?: string;
|
|
139
|
-
/**
|
|
140
|
-
* SSR stream mode.
|
|
141
|
-
*
|
|
142
|
-
* - `"stream"` (default) — start flushing HTML immediately.
|
|
143
|
-
* - `"allReady"` — await `stream.allReady` before returning.
|
|
144
|
-
*/
|
|
145
|
-
streamMode?: import("../router/router-options.js").SSRStreamMode;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* SSR module interface for HTML rendering
|
|
149
|
-
*/
|
|
150
|
-
export interface SSRModule {
|
|
151
|
-
renderHTML: (rscStream: ReadableStream<Uint8Array>, options?: SSRRenderOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
152
|
-
/**
|
|
153
|
-
* PPR shell CAPTURE strategy (Axis 2). Prerenders the loader-masked shell over
|
|
154
|
-
* the Flight stream, aborts once quiescent, and returns the prelude bytes plus
|
|
155
|
-
* the postponed resume state — or null when the prelude degraded and must not
|
|
156
|
-
* be stored. Present only when the SSR virtual entry wires
|
|
157
|
-
* createShellCaptureHandler; the render layer feature-detects it. See
|
|
158
|
-
* docs/design/ppr-shell-resume.md.
|
|
159
|
-
*/
|
|
160
|
-
captureShellHTML?: (rscStream: ReadableStream<Uint8Array>, options: {
|
|
161
|
-
quiesce: Promise<void>;
|
|
162
|
-
maxWaitMs?: number;
|
|
163
|
-
}) => Promise<{
|
|
164
|
-
prelude: Uint8Array;
|
|
165
|
-
postponed: string | null;
|
|
166
|
-
} | null>;
|
|
167
|
-
/**
|
|
168
|
-
* PPR shell RESUME strategy (Axis 2). Produces the per-request live portion of
|
|
169
|
-
* the document: resumes fizz over a fresh SsrRoot to emit only the postponed
|
|
170
|
-
* holes (or, for the DATA variant with postponed === null, just the fresh Flight
|
|
171
|
-
* payload scripts). The caller prepends the stored prelude bytes to form the
|
|
172
|
-
* composite response. Present only when the SSR virtual entry wires
|
|
173
|
-
* createShellResumeHandler; the render layer feature-detects it.
|
|
174
|
-
*/
|
|
175
|
-
resumeShellHTML?: (rscStream: ReadableStream<Uint8Array>, options: {
|
|
176
|
-
postponed: string | null;
|
|
177
|
-
nonce?: string;
|
|
178
|
-
}) => Promise<ReadableStream<Uint8Array>>;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Function to load SSR module dynamically
|
|
182
|
-
*/
|
|
183
|
-
export type LoadSSRModule = () => Promise<SSRModule>;
|
|
184
|
-
/**
|
|
185
|
-
* Cache configuration for handler.
|
|
186
|
-
* TTL is configured via store.defaults or cache() boundaries.
|
|
187
|
-
*/
|
|
188
|
-
export interface HandlerCacheConfig {
|
|
189
|
-
/** Cache store implementation */
|
|
190
|
-
store: import("../cache/types.js").SegmentCacheStore;
|
|
191
|
-
/** Enable/disable caching (default: true) */
|
|
192
|
-
enabled?: boolean;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Nonce provider function type.
|
|
196
|
-
* Can return a nonce string, or true to auto-generate one.
|
|
197
|
-
*/
|
|
198
|
-
export type NonceProvider<TEnv = unknown> = (request: Request, env: TEnv) => string | true | Promise<string | true>;
|
|
199
|
-
/**
|
|
200
|
-
* Options for creating an RSC handler
|
|
201
|
-
*/
|
|
202
|
-
export interface CreateRSCHandlerOptions<TEnv = unknown, TRoutes extends Record<string, string> = Record<string, string>> {
|
|
203
|
-
/**
|
|
204
|
-
* The RSC router instance
|
|
205
|
-
*/
|
|
206
|
-
router: RangoInternal<TEnv, TRoutes>;
|
|
207
|
-
/**
|
|
208
|
-
* RSC dependencies from @vitejs/plugin-rsc/rsc.
|
|
209
|
-
* Defaults to the exports from @vitejs/plugin-rsc/rsc.
|
|
210
|
-
*/
|
|
211
|
-
deps?: RSCDependencies;
|
|
212
|
-
/**
|
|
213
|
-
* Function to load the SSR module for HTML rendering.
|
|
214
|
-
* Defaults to: () => import.meta.viteRsc.loadModule("ssr", "index")
|
|
215
|
-
*/
|
|
216
|
-
loadSSRModule?: LoadSSRModule;
|
|
217
|
-
/**
|
|
218
|
-
* Cache configuration for segment caching.
|
|
219
|
-
*
|
|
220
|
-
* Can be a static config object or a function that receives the env
|
|
221
|
-
* (useful for accessing Cloudflare bindings).
|
|
222
|
-
*
|
|
223
|
-
* If not provided, caching is disabled. TTL is configured via store.defaults
|
|
224
|
-
* or cache() boundaries in the route definition.
|
|
225
|
-
*
|
|
226
|
-
* @example Static config
|
|
227
|
-
* ```typescript
|
|
228
|
-
* cache: {
|
|
229
|
-
* store: new MemorySegmentCacheStore({ defaults: { ttl: 60 } }),
|
|
230
|
-
* }
|
|
231
|
-
* ```
|
|
232
|
-
*
|
|
233
|
-
* @example Dynamic config with env
|
|
234
|
-
* ```typescript
|
|
235
|
-
* cache: (env) => ({
|
|
236
|
-
* store: new KVSegmentCacheStore(env.Bindings.MY_CACHE, { defaults: { ttl: 60 } }),
|
|
237
|
-
* })
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
cache?: HandlerCacheConfig | ((env: TEnv) => HandlerCacheConfig);
|
|
241
|
-
/**
|
|
242
|
-
* RSC version string included in metadata.
|
|
243
|
-
* The browser sends this back on partial requests to detect version mismatches.
|
|
244
|
-
*
|
|
245
|
-
* Defaults to the auto-generated VERSION from `rsc-router:version` virtual module.
|
|
246
|
-
* Only set this if you need a custom versioning strategy.
|
|
247
|
-
*
|
|
248
|
-
* @default VERSION from rsc-router:version
|
|
249
|
-
*/
|
|
250
|
-
version?: string;
|
|
251
|
-
/**
|
|
252
|
-
* Nonce provider for Content Security Policy (CSP).
|
|
253
|
-
*
|
|
254
|
-
* Can be:
|
|
255
|
-
* - A function that returns a nonce string
|
|
256
|
-
* - A function that returns `true` to auto-generate a nonce
|
|
257
|
-
* - Undefined to disable nonce (default)
|
|
258
|
-
*
|
|
259
|
-
* The nonce will be applied to inline scripts injected by the RSC payload.
|
|
260
|
-
* It's also available to middleware via the typed `nonce` token:
|
|
261
|
-
* `import { nonce } from "@rangojs/router"; ctx.get(nonce)`
|
|
262
|
-
*
|
|
263
|
-
* @example Auto-generate nonce
|
|
264
|
-
* ```tsx
|
|
265
|
-
* createRSCHandler({
|
|
266
|
-
* router,
|
|
267
|
-
* nonce: () => true,
|
|
268
|
-
* });
|
|
269
|
-
* ```
|
|
270
|
-
*
|
|
271
|
-
* @example Custom nonce from request context
|
|
272
|
-
* ```tsx
|
|
273
|
-
* createRSCHandler({
|
|
274
|
-
* router,
|
|
275
|
-
* nonce: (request, env) => env.nonce,
|
|
276
|
-
* });
|
|
277
|
-
* ```
|
|
278
|
-
*
|
|
279
|
-
* @example Access nonce in middleware
|
|
280
|
-
* ```tsx
|
|
281
|
-
* import { nonce } from "@rangojs/router";
|
|
282
|
-
*
|
|
283
|
-
* const cspMiddleware: Middleware = async (ctx, next) => {
|
|
284
|
-
* const value = ctx.get(nonce); // string | undefined
|
|
285
|
-
* await next();
|
|
286
|
-
* };
|
|
287
|
-
* ```
|
|
288
|
-
*/
|
|
289
|
-
nonce?: NonceProvider<TEnv>;
|
|
290
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUnderTestRunner(): boolean;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Search parameter schema types and runtime utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides a lightweight schema system for typed query parameters.
|
|
5
|
-
* When a route defines a `search` schema, ctx.search provides a typed
|
|
6
|
-
* object with parsed values. ctx.searchParams always remains a standard
|
|
7
|
-
* URLSearchParams instance.
|
|
8
|
-
*/
|
|
9
|
-
/** Supported scalar types for search params (append ? for optional). */
|
|
10
|
-
export type SearchSchemaValue = "string" | "number" | "boolean" | "string?" | "number?" | "boolean?";
|
|
11
|
-
/** A search schema maps param names to their type descriptors. */
|
|
12
|
-
export type SearchSchema = Record<string, SearchSchemaValue>;
|
|
13
|
-
/** Strip trailing `?` from a schema value to get the base type. */
|
|
14
|
-
type BaseType<T extends string> = T extends `${infer B}?` ? B : T;
|
|
15
|
-
/** Map a base type string to its TypeScript type. */
|
|
16
|
-
type ResolveBaseType<T extends string> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : never;
|
|
17
|
-
/** Keys whose schema value does NOT end with `?`. */
|
|
18
|
-
type RequiredKeys<T extends SearchSchema> = {
|
|
19
|
-
[K in keyof T]: T[K] extends `${string}?` ? never : K;
|
|
20
|
-
}[keyof T];
|
|
21
|
-
/** Keys whose schema value ends with `?`. */
|
|
22
|
-
type OptionalKeys<T extends SearchSchema> = {
|
|
23
|
-
[K in keyof T]: T[K] extends `${string}?` ? K : never;
|
|
24
|
-
}[keyof T];
|
|
25
|
-
/** Flatten an intersection type into a single object type. */
|
|
26
|
-
type Simplify<T> = {
|
|
27
|
-
[K in keyof T]: T[K];
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Resolve a SearchSchema to its typed object.
|
|
31
|
-
*
|
|
32
|
-
* Both required and optional params resolve to `T | undefined` at the handler
|
|
33
|
-
* level. The required/optional distinction is a consumer-facing contract
|
|
34
|
-
* (e.g., for href() and reverse() autocomplete) — it tells callers which
|
|
35
|
-
* params the route expects, but the handler must still check for undefined
|
|
36
|
-
* since the framework cannot trust the client to send all required params.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* type S = { q: "string"; page: "number?"; sort: "string?" };
|
|
40
|
-
* type R = ResolveSearchSchema<S>;
|
|
41
|
-
* // { q: string | undefined; page?: number; sort?: string }
|
|
42
|
-
*/
|
|
43
|
-
export type ResolveSearchSchema<T extends SearchSchema> = Simplify<{
|
|
44
|
-
[K in RequiredKeys<T> & string]: ResolveBaseType<BaseType<T[K]>> | undefined;
|
|
45
|
-
} & {
|
|
46
|
-
[K in OptionalKeys<T> & string]?: ResolveBaseType<BaseType<T[K]>>;
|
|
47
|
-
}>;
|
|
48
|
-
/** Resolve the global route map from RegisteredRoutes or GeneratedRouteMap. */
|
|
49
|
-
type GlobalRouteMap = keyof Rango.RegisteredRoutes extends never ? keyof Rango.GeneratedRouteMap extends never ? Record<string, string> : Rango.GeneratedRouteMap : Rango.RegisteredRoutes;
|
|
50
|
-
/**
|
|
51
|
-
* Extract the resolved search params type for a named route.
|
|
52
|
-
* Looks up the search schema from the route map and resolves it.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* // Given: path("/search", handler, { name: "search", search: { q: "string", page: "number?" } })
|
|
57
|
-
* type Params = RouteSearchParams<"search">;
|
|
58
|
-
* // { q: string; page?: number }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export type RouteSearchParams<TName extends string, TRouteMap = never> = [
|
|
62
|
-
TRouteMap
|
|
63
|
-
] extends [never] ? ExtractAndResolveSearch<GlobalRouteMap, TName> : ExtractAndResolveSearch<TRouteMap, TName>;
|
|
64
|
-
type ExtractAndResolveSearch<TRouteMap, TName> = TName extends keyof TRouteMap ? TRouteMap[TName] extends {
|
|
65
|
-
readonly search: infer S extends SearchSchema;
|
|
66
|
-
} ? ResolveSearchSchema<S> : {} : {};
|
|
67
|
-
/**
|
|
68
|
-
* Extract the route params type for a named route.
|
|
69
|
-
* Looks up the path pattern from the route map and extracts params.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```typescript
|
|
73
|
-
* // Given: path("/blog/:slug", handler, { name: "blogPost" })
|
|
74
|
-
* type Params = RouteParams<"blogPost">;
|
|
75
|
-
* // { slug: string }
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export type RouteParams<TName extends string, TRouteMap = never> = [
|
|
79
|
-
TRouteMap
|
|
80
|
-
] extends [never] ? ExtractRouteParamsFromMap<GlobalRouteMap, TName> : ExtractRouteParamsFromMap<TRouteMap, TName>;
|
|
81
|
-
type ExtractRouteParamsFromMap<TRouteMap, TName> = TName extends keyof TRouteMap ? TRouteMap[TName] extends string ? ExtractParamsFromPattern<TRouteMap[TName]> : TRouteMap[TName] extends {
|
|
82
|
-
readonly path: infer P extends string;
|
|
83
|
-
} ? ExtractParamsFromPattern<P> : {} : {};
|
|
84
|
-
/** Parse "a|b|c" into "a" | "b" | "c" */
|
|
85
|
-
type ParseConstraint<T extends string> = T extends `${infer First}|${infer Rest}` ? First | ParseConstraint<Rest> : T;
|
|
86
|
-
/** Minimal inline param extraction (avoids importing from types.ts to prevent circular deps). */
|
|
87
|
-
type ExtractParamsFromPattern<T extends string> = T extends `${string}:${infer Param}/${infer Rest}` ? Param extends `${infer Name}(${infer C})?` ? {
|
|
88
|
-
[K in Name]?: ParseConstraint<C>;
|
|
89
|
-
} & ExtractParamsFromPattern<`/${Rest}`> : Param extends `${infer Name}(${infer C})` ? {
|
|
90
|
-
[K in Name]: ParseConstraint<C>;
|
|
91
|
-
} & ExtractParamsFromPattern<`/${Rest}`> : Param extends `${infer Name}?` ? {
|
|
92
|
-
[K in Name]?: string;
|
|
93
|
-
} & ExtractParamsFromPattern<`/${Rest}`> : {
|
|
94
|
-
[K in Param]: string;
|
|
95
|
-
} & ExtractParamsFromPattern<`/${Rest}`> : T extends `${string}:${infer Param}` ? Param extends `${infer Name}(${infer C})?` ? {
|
|
96
|
-
[K in Name]?: ParseConstraint<C>;
|
|
97
|
-
} : Param extends `${infer Name}(${infer C})` ? {
|
|
98
|
-
[K in Name]: ParseConstraint<C>;
|
|
99
|
-
} : Param extends `${infer Name}?` ? {
|
|
100
|
-
[K in Name]?: string;
|
|
101
|
-
} : {
|
|
102
|
-
[K in Param]: string;
|
|
103
|
-
} : {};
|
|
104
|
-
/**
|
|
105
|
-
* Parse URLSearchParams into a typed object using the given schema.
|
|
106
|
-
*
|
|
107
|
-
* - `"string"` / `"string?"` - kept as-is
|
|
108
|
-
* - `"number"` / `"number?"` - parsed as a finite decimal number. Accepts an
|
|
109
|
-
* optional sign, digits with optional fraction, and optional exponent
|
|
110
|
-
* (e.g. `42`, `-3.5`, `1e3`). Empty/whitespace-only, non-decimal forms
|
|
111
|
-
* (`0x10`), and non-finite (`Infinity`) are treated as missing (omitted),
|
|
112
|
-
* NOT coerced to `0`/`16`/`Infinity`.
|
|
113
|
-
* - `"boolean"` / `"boolean?"` - `"true"` / `"1"` -> true, `"false"` / `"0"` / `""` -> false
|
|
114
|
-
*
|
|
115
|
-
* Missing params (both required and optional) are omitted from the result
|
|
116
|
-
* (undefined). The required/optional distinction is a consumer-facing contract
|
|
117
|
-
* only — the handler must check for undefined.
|
|
118
|
-
*/
|
|
119
|
-
export declare function parseSearchParams<T extends SearchSchema>(searchParams: URLSearchParams, schema: T): ResolveSearchSchema<T>;
|
|
120
|
-
/**
|
|
121
|
-
* Serialize a typed search params object to a query string (without leading `?`).
|
|
122
|
-
* Skips `undefined` and `null` values. Preserves insertion order (no sort).
|
|
123
|
-
*/
|
|
124
|
-
export declare function serializeSearchParams(params: Record<string, unknown>): string;
|
|
125
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Return a stable Promise wrapping `component`, memoized on the component ref.
|
|
4
|
-
*
|
|
5
|
-
* A fresh `Promise.resolve(component)` each render would suspend for one
|
|
6
|
-
* microtask and briefly commit the loading fallback inside Suspender — the
|
|
7
|
-
* intercept / parallel-slot flicker this indirection prevents. Reusing the
|
|
8
|
-
* same Promise ref keeps React's `use()` in "known fulfilled" state after
|
|
9
|
-
* the first observation.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare function getMemoizedContentPromise(component: ReactNode): Promise<ReactNode>;
|