@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
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
warnInvalidTheme,
|
|
58
58
|
} from "../theme/constants.js";
|
|
59
59
|
import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
|
|
60
|
+
import type { RoutineTrace } from "../rsc/routine-plan.js";
|
|
60
61
|
import { NOCACHE_SYMBOL, assertNotInsideCacheExec } from "../cache/taint.js";
|
|
61
62
|
import {
|
|
62
63
|
assertCachedHeaderWriteAllowed,
|
|
@@ -617,6 +618,17 @@ export interface RequestContext<
|
|
|
617
618
|
*/
|
|
618
619
|
_handlerLoaderDeps?: Set<string>;
|
|
619
620
|
|
|
621
|
+
/**
|
|
622
|
+
* @internal Loader IDs ($$id) whose entries carry `awaitBeforeFlush`
|
|
623
|
+
* (loader(Def, { stream: "navigation" })): segment resolution awaits these
|
|
624
|
+
* before returning, so the render barrier cannot resolve until they settle.
|
|
625
|
+
* rendered() checks this set to fail fast — a flagged loader awaiting the
|
|
626
|
+
* barrier is a guaranteed cycle, not a race. Registered by resolveLoaders
|
|
627
|
+
* (fresh.ts) before loader kickoff; only ever populated on document renders
|
|
628
|
+
* (the flag is stamped per-isSSR at DSL evaluation).
|
|
629
|
+
*/
|
|
630
|
+
_awaitBeforeFlushLoaderIds?: Set<string>;
|
|
631
|
+
|
|
620
632
|
/**
|
|
621
633
|
* @internal Cached HandleData snapshot built at barrier resolution time.
|
|
622
634
|
* Avoids rebuilding the snapshot on every loader ctx.use(handle) call.
|
|
@@ -663,6 +675,9 @@ export interface RequestContext<
|
|
|
663
675
|
*/
|
|
664
676
|
_renderForeground?: RenderForegroundCursor;
|
|
665
677
|
|
|
678
|
+
/** @internal Request routine currently executing, used by timeout diagnostics. */
|
|
679
|
+
_activeRoutine?: RoutineTrace;
|
|
680
|
+
|
|
666
681
|
/** @internal Keep the render cursor active for timeout support. */
|
|
667
682
|
_renderDiagnosticsEnabled?: boolean;
|
|
668
683
|
|
|
@@ -761,12 +776,14 @@ export type PublicRequestContext<
|
|
|
761
776
|
| "_treeHasStreaming"
|
|
762
777
|
| "_renderBarrierWaiters"
|
|
763
778
|
| "_handlerLoaderDeps"
|
|
779
|
+
| "_awaitBeforeFlushLoaderIds"
|
|
764
780
|
| "_renderBarrierHandleSnapshot"
|
|
765
781
|
| "_renderBarrierGuardClosed"
|
|
766
782
|
| "_reportBackgroundError"
|
|
767
783
|
| "_debugPerformance"
|
|
768
784
|
| "_metricsStore"
|
|
769
785
|
| "_renderForeground"
|
|
786
|
+
| "_activeRoutine"
|
|
770
787
|
| "_renderDiagnosticsEnabled"
|
|
771
788
|
| "_handlerStart"
|
|
772
789
|
| "_tracing"
|
|
@@ -1323,6 +1340,7 @@ export function createRequestContext<TEnv>(
|
|
|
1323
1340
|
_reportedErrors: new WeakSet<object>(),
|
|
1324
1341
|
_metricsStore: undefined,
|
|
1325
1342
|
_renderForeground: undefined,
|
|
1343
|
+
_activeRoutine: undefined,
|
|
1326
1344
|
_renderDiagnosticsEnabled: undefined,
|
|
1327
1345
|
_handlerStart: undefined,
|
|
1328
1346
|
|
|
@@ -1378,6 +1396,7 @@ export function wireRenderBarrier(
|
|
|
1378
1396
|
ctx._renderBarrierHandleSnapshot = undefined;
|
|
1379
1397
|
ctx._renderBarrierGuardClosed = undefined;
|
|
1380
1398
|
ctx._handlerLoaderDeps = undefined;
|
|
1399
|
+
ctx._awaitBeforeFlushLoaderIds = undefined;
|
|
1381
1400
|
ctx._treeHasStreaming = undefined;
|
|
1382
1401
|
|
|
1383
1402
|
// Lazy allocation: only create the Promise when a loader calls rendered().
|
|
@@ -1620,12 +1639,23 @@ export function createUseFunction<TEnv>(
|
|
|
1620
1639
|
env: ctx.env as any,
|
|
1621
1640
|
waitUntil: ctx.waitUntil.bind(ctx),
|
|
1622
1641
|
executionContext: ctx.executionContext,
|
|
1623
|
-
get:
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1642
|
+
get: ((keyOrVar: any) => {
|
|
1643
|
+
// Handle READS need the rendered() barrier, which this lane
|
|
1644
|
+
// (action/dispatch-invoked loaders) does not run. Fail with guidance
|
|
1645
|
+
// instead of returning a misleading empty collect.
|
|
1646
|
+
if (isHandle(keyOrVar)) {
|
|
1647
|
+
throw new Error(
|
|
1648
|
+
`ctx.get(handle) is only available in DSL loaders after ` +
|
|
1649
|
+
`"await ctx.rendered()". It cannot be used from request-context ` +
|
|
1650
|
+
`loaders or server actions.`,
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
return (ctx.get as any)(keyOrVar);
|
|
1654
|
+
}) as any,
|
|
1655
|
+
// Pass items through: loaders delegate to the request ctx's loader
|
|
1656
|
+
// executor; a handle yields the ctx's push function (write parity —
|
|
1657
|
+
// ctx.use(Meta)({...}) works in this lane exactly like in a handler).
|
|
1658
|
+
use: ((item: any) => ctx.use(item)) as LoaderContext["use"],
|
|
1629
1659
|
method: "GET",
|
|
1630
1660
|
body: undefined,
|
|
1631
1661
|
reverse: createReverseFunction(
|
package/src/server.ts
CHANGED
|
@@ -47,3 +47,10 @@ export {
|
|
|
47
47
|
|
|
48
48
|
// Component utilities (used internally for server/client boundary checks)
|
|
49
49
|
export { isClientComponent, assertClientComponent } from "./component-utils.js";
|
|
50
|
+
|
|
51
|
+
// Client URL projection registry (Vite discovery/bootstrap bridge)
|
|
52
|
+
export {
|
|
53
|
+
clearClientUrlProjections,
|
|
54
|
+
setClientUrlProjection,
|
|
55
|
+
type ClientUrlProjection,
|
|
56
|
+
} from "./client-urls/server-projection.js";
|
package/src/ssr/index.tsx
CHANGED
|
@@ -105,6 +105,15 @@ export interface SSRRenderOptions {
|
|
|
105
105
|
* - `"allReady"` — await `stream.allReady` before returning.
|
|
106
106
|
*/
|
|
107
107
|
streamMode?: import("../router/router-options.js").SSRStreamMode;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The live request's query string (`?`-prefixed or empty). Seeds the SSR
|
|
111
|
+
* navigation store location so `useSearchParams` carries real values
|
|
112
|
+
* during document renders. Absent on the build-time prerender pass —
|
|
113
|
+
* build shells capture bare pathnames and serve search-less requests
|
|
114
|
+
* only (runtime captures own the search variants, seeded per key).
|
|
115
|
+
*/
|
|
116
|
+
search?: string;
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
/**
|
|
@@ -347,6 +356,13 @@ interface ShellCaptureOptions {
|
|
|
347
356
|
quiesce: Promise<void>;
|
|
348
357
|
/** Upper bound on how long to wait for `quiesce`. Default SHELL_CAPTURE_MAX_WAIT_MS. */
|
|
349
358
|
maxWaitMs?: number;
|
|
359
|
+
/**
|
|
360
|
+
* The SHELL KEY's search string (`?`-prefixed, sorted, cache.searchParams
|
|
361
|
+
* filter applied — shellSearchSeed in rsc/shell-serve.ts), seeding the SSR
|
|
362
|
+
* store so static-part `useSearchParams` reads bake markup consistent with
|
|
363
|
+
* the shell's own key. MUST equal the resume pass's seed for the same key.
|
|
364
|
+
*/
|
|
365
|
+
search?: string;
|
|
350
366
|
}
|
|
351
367
|
|
|
352
368
|
/**
|
|
@@ -368,6 +384,13 @@ interface ShellResumeOptions {
|
|
|
368
384
|
postponed: string | null;
|
|
369
385
|
/** Nonce for CSP. */
|
|
370
386
|
nonce?: string;
|
|
387
|
+
/**
|
|
388
|
+
* The SHELL KEY's search string — same derivation as the capture pass
|
|
389
|
+
* (shellSearchSeed). A HIT shares the capture's key, so seeding the same
|
|
390
|
+
* string keeps the resume tree identical to the captured tree above the
|
|
391
|
+
* postponed holes.
|
|
392
|
+
*/
|
|
393
|
+
search?: string;
|
|
371
394
|
}
|
|
372
395
|
|
|
373
396
|
/**
|
|
@@ -449,7 +472,7 @@ export function createSSRHandler<TEnv = unknown>(deps: SSRDependencies<TEnv>) {
|
|
|
449
472
|
rscStream: ReadableStream<Uint8Array>,
|
|
450
473
|
options?: SSRRenderOptions,
|
|
451
474
|
): Promise<ReadableStream<Uint8Array>> {
|
|
452
|
-
const { nonce, formState, streamMode } = options ?? {};
|
|
475
|
+
const { nonce, formState, streamMode, search } = options ?? {};
|
|
453
476
|
|
|
454
477
|
try {
|
|
455
478
|
// Tee the stream:
|
|
@@ -461,6 +484,12 @@ export function createSSRHandler<TEnv = unknown>(deps: SSRDependencies<TEnv>) {
|
|
|
461
484
|
createFromReadableStream,
|
|
462
485
|
rscStream: rscStream1,
|
|
463
486
|
nonce,
|
|
487
|
+
// Live fizz seeds the request's RAW search. The shell capture pass
|
|
488
|
+
// below and its resume twin seed the SHELL KEY's search instead
|
|
489
|
+
// (sorted, cache.searchParams filter applied — shellSearchSeed):
|
|
490
|
+
// same key => same seed, so the resume tree matches the captured
|
|
491
|
+
// tree while static-part search reads render what the key names.
|
|
492
|
+
search,
|
|
464
493
|
});
|
|
465
494
|
|
|
466
495
|
// Get bootstrap script content
|
|
@@ -562,6 +591,9 @@ export function createShellCaptureHandler<TEnv = unknown>(
|
|
|
562
591
|
createFromReadableStream,
|
|
563
592
|
rscStream,
|
|
564
593
|
onPayloadSettled: settlePayload,
|
|
594
|
+
// The shell key's own search: static-part search reads render what
|
|
595
|
+
// the key names, and the resume pass seeds the identical string.
|
|
596
|
+
search: opts.search,
|
|
565
597
|
});
|
|
566
598
|
|
|
567
599
|
// Bootstrap load raced against the deadline. A load that never resolves
|
|
@@ -735,7 +767,7 @@ export function createShellResumeHandler<TEnv = unknown>(
|
|
|
735
767
|
rscStream: ReadableStream<Uint8Array>,
|
|
736
768
|
opts: ShellResumeOptions,
|
|
737
769
|
): Promise<ReadableStream<Uint8Array>> {
|
|
738
|
-
const { postponed, nonce } = opts;
|
|
770
|
+
const { postponed, nonce, search } = opts;
|
|
739
771
|
|
|
740
772
|
try {
|
|
741
773
|
if (postponed === null) {
|
|
@@ -765,6 +797,9 @@ export function createShellResumeHandler<TEnv = unknown>(
|
|
|
765
797
|
createFromReadableStream,
|
|
766
798
|
rscStream: rscStream1,
|
|
767
799
|
nonce,
|
|
800
|
+
// Same seed as the capture pass for this key: the resume tree must
|
|
801
|
+
// match the captured tree above the holes, search reads included.
|
|
802
|
+
search,
|
|
768
803
|
});
|
|
769
804
|
|
|
770
805
|
// EAGER injection (resume-only): the stored prelude — a complete document
|
package/src/ssr/ssr-root.tsx
CHANGED
|
@@ -63,11 +63,21 @@ async function consumeAsyncGenerator(
|
|
|
63
63
|
*/
|
|
64
64
|
function createSsrEventController(opts: {
|
|
65
65
|
pathname: string;
|
|
66
|
+
/**
|
|
67
|
+
* Query string seeding the store location. Live fizz passes the request's
|
|
68
|
+
* raw search; ppr capture/resume pass the SHELL KEY's search (sorted,
|
|
69
|
+
* cache.searchParams filter applied) so the shell renders what its key
|
|
70
|
+
* names and both passes agree byte-for-byte.
|
|
71
|
+
*/
|
|
72
|
+
search?: string;
|
|
66
73
|
params?: Record<string, string>;
|
|
67
74
|
handleData?: HandleData;
|
|
68
75
|
matched?: string[];
|
|
69
76
|
}): EventController {
|
|
70
|
-
const location = new URL(
|
|
77
|
+
const location = new URL(
|
|
78
|
+
`${opts.pathname}${opts.search ?? ""}`,
|
|
79
|
+
"http://localhost",
|
|
80
|
+
);
|
|
71
81
|
let params = opts.params ?? {};
|
|
72
82
|
const rawMatched = opts.matched ?? [];
|
|
73
83
|
const handleState = {
|
|
@@ -97,6 +107,7 @@ function createSsrEventController(opts: {
|
|
|
97
107
|
}),
|
|
98
108
|
subscribeToAction: () => () => {},
|
|
99
109
|
subscribeToHandles: () => () => {},
|
|
110
|
+
flushRouteState: () => {},
|
|
100
111
|
setHandleData: () => {},
|
|
101
112
|
getHandleState: () => handleState,
|
|
102
113
|
setRouteSegmentIds: () => {},
|
|
@@ -141,6 +152,16 @@ export interface SsrRootOptions {
|
|
|
141
152
|
* they postpone below the root.
|
|
142
153
|
*/
|
|
143
154
|
onPayloadSettled?: () => void;
|
|
155
|
+
/**
|
|
156
|
+
* The query string seeding the SSR store location (`?`-prefixed or
|
|
157
|
+
* empty), so `useSearchParams`/`useNavigation` carry real values during
|
|
158
|
+
* document renders. Live fizz passes the request's raw search. The shell
|
|
159
|
+
* capture and resume passes pass the SHELL KEY's search (sorted,
|
|
160
|
+
* cache.searchParams filter applied — search is part of shell identity):
|
|
161
|
+
* a HIT shares the capture's key, so both passes seed the SAME string and
|
|
162
|
+
* the resume tree matches the captured tree above the postponed holes.
|
|
163
|
+
*/
|
|
164
|
+
search?: string;
|
|
144
165
|
}
|
|
145
166
|
|
|
146
167
|
/**
|
|
@@ -161,7 +182,13 @@ export interface SsrRootOptions {
|
|
|
161
182
|
* re-running the whole segment-tree build unless the promise is memoized.
|
|
162
183
|
*/
|
|
163
184
|
export function createSsrRootComponent(opts: SsrRootOptions): React.FC {
|
|
164
|
-
const {
|
|
185
|
+
const {
|
|
186
|
+
createFromReadableStream,
|
|
187
|
+
rscStream,
|
|
188
|
+
nonce,
|
|
189
|
+
onPayloadSettled,
|
|
190
|
+
search,
|
|
191
|
+
} = opts;
|
|
165
192
|
|
|
166
193
|
let payload: Promise<RscPayload> | undefined;
|
|
167
194
|
let handlesPromise: Promise<HandleData> | undefined;
|
|
@@ -210,6 +237,7 @@ export function createSsrRootComponent(opts: SsrRootOptions): React.FC {
|
|
|
210
237
|
store: null as any,
|
|
211
238
|
eventController: createSsrEventController({
|
|
212
239
|
pathname,
|
|
240
|
+
search,
|
|
213
241
|
params: resolved.metadata?.params,
|
|
214
242
|
handleData,
|
|
215
243
|
matched: resolved.metadata?.matched,
|
package/src/testing/dom.entry.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Component-render testing: `renderRoute`, the React-Testing-Library-style stub
|
|
5
5
|
* for client components that read router context (useParams / useReverse /
|
|
6
|
-
* Outlet / useNavigation / useLoader).
|
|
6
|
+
* Outlet / useOutlet / useNavigation / useLoader).
|
|
7
7
|
*
|
|
8
8
|
* Separate from the main `@rangojs/router/testing` barrel so unit suites that
|
|
9
9
|
* only test loaders, middleware, or `dispatch` never reference React, the
|
|
@@ -19,18 +19,19 @@
|
|
|
19
19
|
* props crossing the RSC boundary), loader execution on the server,
|
|
20
20
|
* middleware, or handler ordering. Those are renderServerTree / renderHandler
|
|
21
21
|
* / e2e territory.
|
|
22
|
-
* - Loader data, location state,
|
|
23
|
-
* client context (see the `loaders` / `locationState` /
|
|
24
|
-
* nothing is executed on the server.
|
|
25
|
-
*
|
|
22
|
+
* - Loader data, location state, handle output, and outlet pending state are
|
|
23
|
+
* SEEDED directly into client context (see the `loaders` / `locationState` /
|
|
24
|
+
* `handles` / `outletPending` options) — nothing is executed on the server.
|
|
25
|
+
* This exercises the context read path, not the run path.
|
|
26
26
|
* - navigate() commits synchronously, so it does NOT drive the navigation
|
|
27
27
|
* lifecycle: useNavigation().state, useLinkStatus().pending, and
|
|
28
28
|
* useAction().state stay "idle". Assert pending/loading/submitting transition
|
|
29
29
|
* states with renderServerTree / e2e instead (navigate() warns once if used).
|
|
30
30
|
* What it DOES cover: client hooks that read NavigationProvider /
|
|
31
31
|
* OutletContext — useParams, useReverse, useHref, useMount, useNavigation,
|
|
32
|
-
* useRouter, usePathname, useSearchParams, Outlet nesting
|
|
33
|
-
*
|
|
32
|
+
* useRouter, usePathname, useSearchParams, Outlet/useOutlet nesting and seeded
|
|
33
|
+
* descendant pending state, useLoader/useFetchLoader (seeded data),
|
|
34
|
+
* useLocationState (seeded), and useHandle (seeded).
|
|
34
35
|
* Basename-mounted apps: pass the `basename` option so useRouter().basename,
|
|
35
36
|
* <Link> prefixing, and useMount/useHref resolve against the mount prefix
|
|
36
37
|
* (without it they resolve at the root "/"). For an include("/shop", ...)
|
|
@@ -149,6 +150,15 @@ export interface RenderRouteOptions {
|
|
|
149
150
|
* the read path is exercised without executing any loader.
|
|
150
151
|
*/
|
|
151
152
|
loaderData?: Record<string, unknown>;
|
|
153
|
+
/**
|
|
154
|
+
* Descendant client-route pending state to seed into each synthetic segment's
|
|
155
|
+
* production OutletProvider, so `useOutlet().pending` can be tested alongside
|
|
156
|
+
* `useOutlet().content`. Defaults to false.
|
|
157
|
+
*
|
|
158
|
+
* This is a seeded outlet-context value only. It does not model arbitrary
|
|
159
|
+
* Suspense, navigation, or action pending state.
|
|
160
|
+
*/
|
|
161
|
+
outletPending?: boolean;
|
|
152
162
|
/**
|
|
153
163
|
* Loaders to seed by REFERENCE — the robust way to test a component that calls
|
|
154
164
|
* `useLoader(loader)`. A real `createLoader()` handle has an empty `$$id` in a
|
|
@@ -560,7 +570,9 @@ export async function renderRoute(
|
|
|
560
570
|
const match = resolve(nextUrl.pathname);
|
|
561
571
|
const segments = buildSegments(routes, match.params, loaderData, mount);
|
|
562
572
|
const metadata = makeMetadata(nextUrl.pathname, segments, match.params);
|
|
563
|
-
const root = await renderSegments(segments
|
|
573
|
+
const root = await renderSegments(segments, {
|
|
574
|
+
outletPending: options.outletPending,
|
|
575
|
+
});
|
|
564
576
|
eventController.setLocation(nextUrl);
|
|
565
577
|
eventController.setParams(match.params);
|
|
566
578
|
store.setCurrentUrl(nextUrl.href);
|
|
@@ -595,7 +607,9 @@ export async function renderRoute(
|
|
|
595
607
|
...makeMetadata(url.pathname, initialSegments, initialMatch.params),
|
|
596
608
|
defaultPrefetch: options.defaultPrefetch,
|
|
597
609
|
};
|
|
598
|
-
const initialTree = await renderSegments(initialSegments
|
|
610
|
+
const initialTree = await renderSegments(initialSegments, {
|
|
611
|
+
outletPending: options.outletPending,
|
|
612
|
+
});
|
|
599
613
|
|
|
600
614
|
// Wrap render in an awaited async act so a tree that suspends (async loaders,
|
|
601
615
|
// loading states, deferred handle entries that arrive as a Promise) settles its
|
|
@@ -42,6 +42,7 @@ import { getFetchableLoader } from "../server/fetchable-loader-store.js";
|
|
|
42
42
|
import type { LoaderContext, LoaderDefinition } from "../types.js";
|
|
43
43
|
import type { ContextVar } from "../context-var.js";
|
|
44
44
|
import { isHandle, type Handle } from "../handle.js";
|
|
45
|
+
import { withDefer } from "../defer.js";
|
|
45
46
|
import { collectHandle } from "./collect-handle.js";
|
|
46
47
|
import type { ThemeConfig } from "../theme/types.js";
|
|
47
48
|
import type { SegmentCacheStore } from "../cache/types.js";
|
|
@@ -74,6 +75,9 @@ export type TestLoaderContext<TEnv = any> = Omit<
|
|
|
74
75
|
) => string;
|
|
75
76
|
get: {
|
|
76
77
|
<T>(contextVar: ContextVar<T>): T | undefined;
|
|
78
|
+
<TData, TAccumulated = TData[]>(
|
|
79
|
+
handle: Handle<TData, TAccumulated>,
|
|
80
|
+
): TAccumulated;
|
|
77
81
|
<T = unknown>(key: string): T | undefined;
|
|
78
82
|
};
|
|
79
83
|
};
|
|
@@ -248,6 +252,7 @@ function runWithLoaderContext<R>(
|
|
|
248
252
|
reqCtx: RequestContext<any>,
|
|
249
253
|
opts: RunLoaderOptions,
|
|
250
254
|
fn: (ctx: TestLoaderContext) => R,
|
|
255
|
+
pushRecorder?: Array<{ handle: Handle<any, any>; value: unknown }>,
|
|
251
256
|
): R {
|
|
252
257
|
const handleSeeds = new Map<unknown, unknown>(opts.handles ?? []);
|
|
253
258
|
const loaderSeeds = new Map<unknown, unknown>(opts.loaders ?? []);
|
|
@@ -275,17 +280,37 @@ function runWithLoaderContext<R>(
|
|
|
275
280
|
env: reqCtx.env,
|
|
276
281
|
waitUntil: reqCtx.waitUntil.bind(reqCtx),
|
|
277
282
|
executionContext: reqCtx.executionContext,
|
|
278
|
-
get:
|
|
283
|
+
get: ((keyOrVar: any) => {
|
|
284
|
+
// Handle READ (mirrors production's ctx.get(handle)): rendered-gated,
|
|
285
|
+
// seeded via the `handles` option.
|
|
286
|
+
if (isHandle(keyOrVar)) {
|
|
287
|
+
if (!renderedResolved) {
|
|
288
|
+
throw new Error(
|
|
289
|
+
`ctx.get(handle) in a loader requires "await ctx.rendered()" first. ` +
|
|
290
|
+
`Handle "${(keyOrVar as Handle<any, any>).$$id}" cannot be read until ` +
|
|
291
|
+
`the render tree has settled.`,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
if (handleSeeds.has(keyOrVar)) return handleSeeds.get(keyOrVar);
|
|
295
|
+
return collectHandle(keyOrVar, []);
|
|
296
|
+
}
|
|
297
|
+
return (reqCtx.get as any)(keyOrVar);
|
|
298
|
+
}) as TestLoaderContext["get"],
|
|
279
299
|
use: ((dep: LoaderDefinition<any, any> | Handle<any, any>) => {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
300
|
+
// Handle WRITE (mirrors production's ctx.use(Meta)({...}) push): the
|
|
301
|
+
// same withDefer wrapper shape, recording into the result envelope's
|
|
302
|
+
// `handlePushes` so tests assert what the loader wrote. Deferred
|
|
303
|
+
// resolvers record their resolved value when called.
|
|
304
|
+
if (isHandle(dep)) {
|
|
305
|
+
const handleDef = dep as Handle<any, any>;
|
|
306
|
+
return withDefer((dataOrFn: unknown) => {
|
|
307
|
+
const value =
|
|
308
|
+
typeof dataOrFn === "function"
|
|
309
|
+
? (dataOrFn as () => unknown)()
|
|
310
|
+
: dataOrFn;
|
|
311
|
+
pushRecorder?.push({ handle: handleDef, value });
|
|
312
|
+
});
|
|
286
313
|
}
|
|
287
|
-
if (handleSeeds.has(dep)) return handleSeeds.get(dep);
|
|
288
|
-
if (isHandle(dep)) return collectHandle(dep, []);
|
|
289
314
|
// Production ctx.use(Loader) ALWAYS returns a Promise (the cached loader
|
|
290
315
|
// promise). The seeded path must match, so a consumer composing on the
|
|
291
316
|
// result (ctx.use(Dep).then(...), Promise.race, etc.) works the same as
|
|
@@ -313,7 +338,7 @@ function runWithLoaderContext<R>(
|
|
|
313
338
|
"requires the DSL render barrier, which only exists during a " +
|
|
314
339
|
"full route match. To unit-test a loader's post-barrier logic, " +
|
|
315
340
|
"pass { rendered: true } to mock the barrier and { handles: " +
|
|
316
|
-
"[[SomeHandle, accumulatedData]] } to seed ctx.
|
|
341
|
+
"[[SomeHandle, accumulatedData]] } to seed ctx.get(SomeHandle). " +
|
|
317
342
|
"For the real push/accumulate/barrier wiring, use an e2e test.",
|
|
318
343
|
);
|
|
319
344
|
},
|
|
@@ -361,6 +386,11 @@ export interface RunLoaderResult<T> {
|
|
|
361
386
|
locationState: Record<string, unknown>;
|
|
362
387
|
/** The resolved rango state cookie name seeded for the run (default `rango-state_router_0`). */
|
|
363
388
|
stateCookieName: string;
|
|
389
|
+
/**
|
|
390
|
+
* Handle writes the loader made via `ctx.use(SomeHandle)({...})`, in push
|
|
391
|
+
* order. A `.defer()` resolver's value is recorded when the resolver runs.
|
|
392
|
+
*/
|
|
393
|
+
handlePushes: Array<{ handle: Handle<any, any>; value: unknown }>;
|
|
364
394
|
}
|
|
365
395
|
|
|
366
396
|
export async function runLoaderResult<T>(
|
|
@@ -372,14 +402,22 @@ export async function runLoaderResult<T>(
|
|
|
372
402
|
buildLoaderCtxOpts(opts),
|
|
373
403
|
);
|
|
374
404
|
const reqCtx = ctx as RequestContext<any>;
|
|
405
|
+
const handlePushes: Array<{ handle: Handle<any, any>; value: unknown }> = [];
|
|
375
406
|
let result: T | undefined;
|
|
376
407
|
let thrown: unknown;
|
|
377
408
|
try {
|
|
378
|
-
result = await runWithLoaderContext(
|
|
379
|
-
|
|
409
|
+
result = await runWithLoaderContext(
|
|
410
|
+
reqCtx,
|
|
411
|
+
opts,
|
|
412
|
+
(loaderCtx) => Promise.resolve(loaderFn(loaderCtx)),
|
|
413
|
+
handlePushes,
|
|
380
414
|
);
|
|
381
415
|
} catch (error) {
|
|
382
416
|
thrown = error;
|
|
383
417
|
}
|
|
384
|
-
return {
|
|
418
|
+
return {
|
|
419
|
+
result,
|
|
420
|
+
handlePushes,
|
|
421
|
+
...buildRunSnapshot(reqCtx, thrown, stateCookieName),
|
|
422
|
+
};
|
|
385
423
|
}
|
package/src/types/boundaries.ts
CHANGED
|
@@ -74,6 +74,25 @@ export type LoaderDataResult<T = unknown> =
|
|
|
74
74
|
ok: false;
|
|
75
75
|
error: ErrorInfo;
|
|
76
76
|
fallback: ReactNode | null;
|
|
77
|
+
/**
|
|
78
|
+
* Loader threw notFound() (DataNotFoundError). `fallback` carries the
|
|
79
|
+
* SERVER-RENDERED not-found UI (nearest notFoundBoundary → router
|
|
80
|
+
* notFound option → default), so the client swaps to 404 presentation
|
|
81
|
+
* with zero extra round trips. Routed by decodeLoaderEntry via
|
|
82
|
+
* LOADER_NOT_FOUND_FALLBACK, not the error-fallback marker.
|
|
83
|
+
*/
|
|
84
|
+
notFound?: true;
|
|
85
|
+
/**
|
|
86
|
+
* Loader threw redirect(...) (a 3xx Response). `to` is resolved through
|
|
87
|
+
* the soft-redirect same-origin rules BEFORE leaving the server
|
|
88
|
+
* (resolveSoftRedirectUrl), so unsafe targets never reach the wire. The
|
|
89
|
+
* client navigates (replace) when the entry decodes. `state` is the
|
|
90
|
+
* resolved `redirect(url, { state })` record (`__rsc_ls_*` keys) — it
|
|
91
|
+
* travels on the marker because a streaming loader settles after
|
|
92
|
+
* payload metadata flushed; the redirect navigation merges it at the
|
|
93
|
+
* target entry.
|
|
94
|
+
*/
|
|
95
|
+
redirect?: { to: string; state?: Record<string, unknown> };
|
|
77
96
|
};
|
|
78
97
|
|
|
79
98
|
export function isLoaderDataResult(value: unknown): value is LoaderDataResult {
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ContextVar } from "../context-var.js";
|
|
2
2
|
import type { Handle } from "../handle.js";
|
|
3
|
+
import type { HandlePush } from "../defer.js";
|
|
3
4
|
import type { MiddlewareFn } from "../router/middleware.js";
|
|
4
5
|
import type { ScopedReverseFunction } from "../reverse.js";
|
|
5
6
|
import type { SearchSchema, ResolveSearchSchema } from "../search-params.js";
|
|
@@ -51,14 +52,42 @@ export type LoaderContext<
|
|
|
51
52
|
*/
|
|
52
53
|
routeParams: Record<string, string>;
|
|
53
54
|
search: {} extends TSearch ? {} : ResolveSearchSchema<TSearch>;
|
|
55
|
+
/**
|
|
56
|
+
* Read a context variable — or READ collected handle data after
|
|
57
|
+
* `await ctx.rendered()` (the rendered-barrier contract; handle reads
|
|
58
|
+
* moved here from ctx.use(handle), which is now the write).
|
|
59
|
+
*/
|
|
54
60
|
get: {
|
|
55
61
|
<T>(contextVar: ContextVar<T>): T | undefined;
|
|
62
|
+
<TData, TAccumulated = TData[]>(
|
|
63
|
+
handle: Handle<TData, TAccumulated>,
|
|
64
|
+
): TAccumulated;
|
|
56
65
|
} & (<K extends keyof DefaultVars>(key: K) => DefaultVars[K]);
|
|
57
66
|
/**
|
|
58
|
-
* Access another loader's data, or
|
|
67
|
+
* Access another loader's data, or WRITE handle data (meta, breadcrumbs, …)
|
|
68
|
+
* — handler parity: `ctx.use(Meta)({ title })` pushes exactly like it does
|
|
69
|
+
* in a handler. Handle READS live on `ctx.get(handle)` (after rendered()).
|
|
59
70
|
*
|
|
60
71
|
* For loaders: returns a promise (loaders run in parallel).
|
|
61
|
-
* For handles: returns
|
|
72
|
+
* For handles: returns the push function, legal for the whole body,
|
|
73
|
+
* streaming loaders included. Delivery is async by the race model: pushes
|
|
74
|
+
* that settle before the handler barrier ride the SSR handle snapshot;
|
|
75
|
+
* later ones stream to the client and apply post-hydration (document lane)
|
|
76
|
+
* or progressively (navigation/action lanes). To guarantee a loader's
|
|
77
|
+
* handles are in the SSR'd document, register it as
|
|
78
|
+
* `loader(Def, { stream: "navigation" })` so the document render awaits it
|
|
79
|
+
* (see {@link LoaderOptions}).
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* export const ProductLoader = createLoader(async (ctx) => {
|
|
84
|
+
* "use server";
|
|
85
|
+
* const product = await getProduct(ctx.params.slug);
|
|
86
|
+
* ctx.use(Meta)({ title: product.name });
|
|
87
|
+
* ctx.use(Breadcrumbs)({ label: product.name });
|
|
88
|
+
* return product;
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
62
91
|
*/
|
|
63
92
|
use: {
|
|
64
93
|
<T, TLoaderParams = any>(
|
|
@@ -66,13 +95,13 @@ export type LoaderContext<
|
|
|
66
95
|
): Promise<T>;
|
|
67
96
|
<TData, TAccumulated = TData[]>(
|
|
68
97
|
handle: Handle<TData, TAccumulated>,
|
|
69
|
-
):
|
|
98
|
+
): HandlePush<TData>;
|
|
70
99
|
};
|
|
71
100
|
/**
|
|
72
101
|
* **Experimental.** Wait for all non-loader segments to settle.
|
|
73
102
|
*
|
|
74
103
|
* After the returned promise resolves, handle data is available via
|
|
75
|
-
* `ctx.
|
|
104
|
+
* `ctx.get(handle)`. Supported in DSL loaders, including on streaming
|
|
76
105
|
* trees that use `loading()` — the barrier waits for the streaming
|
|
77
106
|
* handlers to finish pushing before it resolves. Throws if called from a
|
|
78
107
|
* handler-invoked loader, or if a handler is already awaiting this loader
|
|
@@ -84,7 +113,7 @@ export type LoaderContext<
|
|
|
84
113
|
* const PricesLoader = createLoader(async (ctx) => {
|
|
85
114
|
* "use server";
|
|
86
115
|
* await ctx.rendered();
|
|
87
|
-
* const products = ctx.
|
|
116
|
+
* const products = ctx.get(Products); // reads handle data
|
|
88
117
|
* return pricing.getLive(products.map(p => p.id));
|
|
89
118
|
* });
|
|
90
119
|
* ```
|
|
@@ -144,6 +173,32 @@ export type LoaderFn<
|
|
|
144
173
|
TEnv = DefaultEnv,
|
|
145
174
|
> = (ctx: LoaderContext<TParams, TEnv>) => Promise<T> | T;
|
|
146
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Delivery mode for a DSL-registered loader: `loader(Def, { stream })`.
|
|
178
|
+
*
|
|
179
|
+
* Default (omitted): the loader streams on every render. Its data, its
|
|
180
|
+
* `ctx.use(Handle)` pushes, and any `notFound()`/`redirect()` it throws may land
|
|
181
|
+
* AFTER the document Response is constructed, so none of them are guaranteed to
|
|
182
|
+
* be in the SSR'd HTML.
|
|
183
|
+
*
|
|
184
|
+
* `"navigation"` narrows streaming to client navigations only: on a DOCUMENT
|
|
185
|
+
* request the loader is awaited before first flush. `useLoader` still suspends,
|
|
186
|
+
* but on an already-settled promise, so no fallback paints. This is the
|
|
187
|
+
* SSR-completeness opt-in — the name is about WHERE streaming still applies, not
|
|
188
|
+
* about disabling it. Choose it when the loader feeds something that must exist
|
|
189
|
+
* in the document: `<head>` meta via a handle, or a real 404 status (an awaited
|
|
190
|
+
* `notFound()` deterministically precedes Response construction, where the
|
|
191
|
+
* streamed default only wins that race opportunistically). It does NOT change
|
|
192
|
+
* PPR capture behavior: capture renders mask loaders and skip this await.
|
|
193
|
+
*
|
|
194
|
+
* Scoped per LOADER, not per segment: a baked loader alongside a deliberately
|
|
195
|
+
* dynamic sibling awaits only itself, and the sibling keeps streaming behind its
|
|
196
|
+
* `loading()`/Suspense boundary.
|
|
197
|
+
*/
|
|
198
|
+
export type LoaderOptions = {
|
|
199
|
+
stream?: "navigation";
|
|
200
|
+
};
|
|
201
|
+
|
|
147
202
|
/**
|
|
148
203
|
* Options for fetchable loaders
|
|
149
204
|
*
|
package/src/types/segments.ts
CHANGED
|
@@ -258,6 +258,13 @@ export interface MatchResult {
|
|
|
258
258
|
* Slots are used for intercepting routes during soft navigation
|
|
259
259
|
*/
|
|
260
260
|
slots?: Record<string, SlotState>;
|
|
261
|
+
/**
|
|
262
|
+
* Intercept TARGET route names reachable when this location is a navigation
|
|
263
|
+
* origin (chain walk of the matched entry, when-conditionals included).
|
|
264
|
+
* Shipped in payload metadata so the browser-local clientUrls matcher can
|
|
265
|
+
* decline its optimistic presentation for targets an intercept would claim.
|
|
266
|
+
*/
|
|
267
|
+
interceptTargets?: string[];
|
|
261
268
|
/**
|
|
262
269
|
* Redirect URL for trailing slash normalization.
|
|
263
270
|
* When set, the RSC handler should return a 308 redirect to this URL
|