@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
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Route Trie Construction
|
|
3
|
+
*
|
|
4
|
+
* Builds a serializable trie from route manifest data for O(path_length)
|
|
5
|
+
* route matching at runtime.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { parsePattern, type ParsedSegment } from "./parse-pattern.js";
|
|
9
|
+
|
|
10
|
+
// -- Trie data structures (compact keys for JSON serialization) --
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A response-type variant folded into a primary leaf's negotiate list. `pa` is
|
|
14
|
+
* the variant's own positional param-name array, carried so the runtime can
|
|
15
|
+
* re-key the matched params under the variant's names when it wins negotiation
|
|
16
|
+
* (the trie match extracts params under the PRIMARY leaf's pa). Omitted when the
|
|
17
|
+
* variant has no params; absent/identical pa means no re-key is needed.
|
|
18
|
+
*/
|
|
19
|
+
export interface NegotiateVariant {
|
|
20
|
+
routeKey: string;
|
|
21
|
+
responseType: string;
|
|
22
|
+
pa?: string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TrieLeaf {
|
|
26
|
+
/** Route name (e.g., "site.l1_500") */
|
|
27
|
+
n: string;
|
|
28
|
+
/** Static prefix of the entry (e.g., "/site") */
|
|
29
|
+
sp: string;
|
|
30
|
+
/** Constraint validation: paramName -> allowed values */
|
|
31
|
+
cv?: Record<string, string[]>;
|
|
32
|
+
/** Ordered param names for this route (positional) */
|
|
33
|
+
pa?: string[];
|
|
34
|
+
/** Trailing slash mode */
|
|
35
|
+
ts?: string;
|
|
36
|
+
/** Route has pre-rendered data available */
|
|
37
|
+
pr?: true;
|
|
38
|
+
/** Passthrough: handler kept in bundle for live fallback on unknown params */
|
|
39
|
+
pt?: true;
|
|
40
|
+
/** Response type for non-RSC routes (json, text, image, any) */
|
|
41
|
+
rt?: string;
|
|
42
|
+
/** Negotiate variants: response-type routes sharing this path */
|
|
43
|
+
nv?: NegotiateVariant[];
|
|
44
|
+
/** RSC-first: RSC route was defined before response-type variants */
|
|
45
|
+
rf?: true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface TrieNode {
|
|
49
|
+
/** Route terminal at this node */
|
|
50
|
+
r?: TrieLeaf;
|
|
51
|
+
/** Static segment children */
|
|
52
|
+
s?: Record<string, TrieNode>;
|
|
53
|
+
/** Param child: { n: paramName, c: child node } */
|
|
54
|
+
p?: { n: string; c: TrieNode };
|
|
55
|
+
/** Suffix-param children keyed by suffix (e.g., ".html" -> { n: "productId", c: ... }) */
|
|
56
|
+
xp?: Record<string, { n: string; c: TrieNode }>;
|
|
57
|
+
/**
|
|
58
|
+
* Wildcard terminal: leaf + paramName (`pn`). `pn` is "*" for the bare `/*`
|
|
59
|
+
* form and the param name for a named catch-all (`:name+`/`:name*`). `w1`
|
|
60
|
+
* marks a one-or-more catch-all (`:name+`): the runtime walker then rejects
|
|
61
|
+
* the zero-segment/empty-remainder case. Absent `w1` is zero-or-more.
|
|
62
|
+
*/
|
|
63
|
+
w?: TrieLeaf & { pn: string; w1?: true };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Build a route trie from route manifest data.
|
|
68
|
+
*
|
|
69
|
+
* @param routeManifest - Map of route name to full URL pattern
|
|
70
|
+
* @param routeToStaticPrefix - Map of route name to its entry's staticPrefix
|
|
71
|
+
* @param routeTrailingSlash - Optional map of route name to trailing slash mode
|
|
72
|
+
* @param prerenderRouteNames - Optional set of prerendered route names (sets leaf.pr)
|
|
73
|
+
* @param passthroughRouteNames - Optional set of passthrough route names (sets leaf.pt)
|
|
74
|
+
* @param responseTypeRoutes - Optional map of route name to response type (sets leaf.rt)
|
|
75
|
+
*/
|
|
76
|
+
export function buildRouteTrie(
|
|
77
|
+
routeManifest: Record<string, string>,
|
|
78
|
+
routeToStaticPrefix: Record<string, string>,
|
|
79
|
+
routeTrailingSlash?: Record<string, string>,
|
|
80
|
+
prerenderRouteNames?: Set<string>,
|
|
81
|
+
passthroughRouteNames?: Set<string>,
|
|
82
|
+
responseTypeRoutes?: Record<string, string>,
|
|
83
|
+
): TrieNode {
|
|
84
|
+
const root: TrieNode = {};
|
|
85
|
+
|
|
86
|
+
for (const [routeName, pattern] of Object.entries(routeManifest)) {
|
|
87
|
+
const staticPrefix = routeToStaticPrefix[routeName] || "";
|
|
88
|
+
const trailingSlash = routeTrailingSlash?.[routeName];
|
|
89
|
+
const responseType = responseTypeRoutes?.[routeName];
|
|
90
|
+
|
|
91
|
+
// Detect and strip trailing slash from pattern for parsing
|
|
92
|
+
const hasTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
|
|
93
|
+
const normalizedPattern = hasTrailingSlash ? pattern.slice(0, -1) : pattern;
|
|
94
|
+
|
|
95
|
+
const segments = parsePattern(normalizedPattern);
|
|
96
|
+
insertRoute(root, segments, 0, {
|
|
97
|
+
n: routeName,
|
|
98
|
+
sp: staticPrefix,
|
|
99
|
+
...(trailingSlash ? { ts: trailingSlash } : {}),
|
|
100
|
+
...(prerenderRouteNames?.has(routeName) ? { pr: true } : {}),
|
|
101
|
+
...(passthroughRouteNames?.has(routeName) ? { pt: true } : {}),
|
|
102
|
+
...(responseType ? { rt: responseType } : {}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
sortSuffixParams(root);
|
|
107
|
+
return root;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Sort every node's suffix-param map (`node.xp`) by descending suffix length so
|
|
112
|
+
* the matcher tries the most specific suffix first. Overlapping suffixes like
|
|
113
|
+
* `.min.js` and `.js` must resolve by specificity, not route declaration order:
|
|
114
|
+
* a request for `/app.min.js` should match `:file.min.js`, not `:file.js`.
|
|
115
|
+
*
|
|
116
|
+
* This started as a bug - `walkTrie` iterates `node.xp` in object order and
|
|
117
|
+
* returns the first suffix the segment ends with, so the winner depended on
|
|
118
|
+
* which route was declared first. Sorting at build time fixes it allocation-free
|
|
119
|
+
* on the match hot path: the serialized production trie preserves this key order
|
|
120
|
+
* through JSON.parse, so dev (per-request rebuild) and production match
|
|
121
|
+
* identically. Array.prototype.sort is stable (ES2019+), so equal-length
|
|
122
|
+
* suffixes keep their declaration order - the router's existing tiebreak.
|
|
123
|
+
*/
|
|
124
|
+
function sortSuffixParams(node: TrieNode): void {
|
|
125
|
+
if (node.xp) {
|
|
126
|
+
const sorted: Record<string, { n: string; c: TrieNode }> = {};
|
|
127
|
+
for (const suffix of Object.keys(node.xp).sort(
|
|
128
|
+
(a, b) => b.length - a.length,
|
|
129
|
+
)) {
|
|
130
|
+
sorted[suffix] = node.xp[suffix];
|
|
131
|
+
}
|
|
132
|
+
node.xp = sorted;
|
|
133
|
+
for (const child of Object.values(node.xp)) {
|
|
134
|
+
sortSuffixParams(child.c);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (node.s) {
|
|
138
|
+
for (const child of Object.values(node.s)) {
|
|
139
|
+
sortSuffixParams(child);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (node.p) {
|
|
143
|
+
sortSuffixParams(node.p.c);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Insert a route into the trie. Optional params expand into two branches at
|
|
149
|
+
* registration time (skip-first, then present), so each terminal lives at the
|
|
150
|
+
* correct depth for its number of bound params and carries a branch-local
|
|
151
|
+
* `pa` listing only those names. The trie's single-slot `node.p` is reused
|
|
152
|
+
* across branches because matching ignores `node.p.n` - the leaf's `pa` is
|
|
153
|
+
* the source of truth for naming. Skip-first ordering lets `mergeLeaf`'s
|
|
154
|
+
* last-wins rule produce greedy-leftmost semantics for free at any shared
|
|
155
|
+
* terminal depth.
|
|
156
|
+
*/
|
|
157
|
+
function insertRoute(
|
|
158
|
+
node: TrieNode,
|
|
159
|
+
segments: ParsedSegment[],
|
|
160
|
+
index: number,
|
|
161
|
+
leaf: Omit<TrieLeaf, "cv" | "pa">,
|
|
162
|
+
): void {
|
|
163
|
+
// cv (full constraint map) is route-level and identical on every terminal,
|
|
164
|
+
// so compute it once on the shared base.
|
|
165
|
+
const constraints: Record<string, string[]> = {};
|
|
166
|
+
|
|
167
|
+
for (const seg of segments) {
|
|
168
|
+
if (seg.type === "param") {
|
|
169
|
+
if (seg.constraint) {
|
|
170
|
+
constraints[seg.value] = seg.constraint;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const leafBase: Omit<TrieLeaf, "pa"> = {
|
|
176
|
+
...leaf,
|
|
177
|
+
...(Object.keys(constraints).length > 0 ? { cv: constraints } : {}),
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
insertSegments(node, segments, index, leafBase, []);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Build a negotiate-variant entry from a leaf being folded into another leaf's
|
|
185
|
+
* nv list. Carries the variant's positional param names (`pa`) so the runtime
|
|
186
|
+
* can re-key matched params under the variant's names; omitted when the variant
|
|
187
|
+
* has none (the common case where primary and variant share the same names is a
|
|
188
|
+
* no-op re-key regardless).
|
|
189
|
+
*/
|
|
190
|
+
function toVariant(leaf: TrieLeaf, responseType: string): NegotiateVariant {
|
|
191
|
+
return leaf.pa
|
|
192
|
+
? { routeKey: leaf.n, responseType, pa: leaf.pa }
|
|
193
|
+
: { routeKey: leaf.n, responseType };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Merge a new leaf with an existing leaf, handling content negotiation.
|
|
198
|
+
* When an RSC route and response-type routes share the same URL pattern,
|
|
199
|
+
* the RSC route becomes the primary leaf and response-type routes are
|
|
200
|
+
* appended to the nv (negotiate variants) array.
|
|
201
|
+
* Multiple response types on the same path are supported (json + text + xml).
|
|
202
|
+
*/
|
|
203
|
+
function mergeLeaves(existing: TrieLeaf | undefined, leaf: TrieLeaf): TrieLeaf {
|
|
204
|
+
if (!existing) return leaf;
|
|
205
|
+
|
|
206
|
+
if (existing.rt && leaf.rt) {
|
|
207
|
+
// Both are response-type: preserve old as variant
|
|
208
|
+
const merged = leaf;
|
|
209
|
+
merged.nv = existing.nv || [];
|
|
210
|
+
merged.nv.push(toVariant(existing, existing.rt));
|
|
211
|
+
return merged;
|
|
212
|
+
}
|
|
213
|
+
if (leaf.rt && !existing.rt) {
|
|
214
|
+
// RSC primary exists, new leaf is response-type: append variant
|
|
215
|
+
// RSC was defined first (it was already the existing leaf)
|
|
216
|
+
if (!existing.nv) {
|
|
217
|
+
existing.nv = [];
|
|
218
|
+
existing.rf = true;
|
|
219
|
+
}
|
|
220
|
+
existing.nv.push(toVariant(leaf, leaf.rt));
|
|
221
|
+
return existing;
|
|
222
|
+
}
|
|
223
|
+
if (!leaf.rt && existing.rt) {
|
|
224
|
+
// Response-type was primary, new leaf is RSC: swap and move old to variants
|
|
225
|
+
// RSC was defined second (response-type was already the existing leaf)
|
|
226
|
+
if (!leaf.nv) leaf.nv = [];
|
|
227
|
+
if (existing.nv) leaf.nv.push(...existing.nv);
|
|
228
|
+
leaf.nv.push(toVariant(existing, existing.rt));
|
|
229
|
+
// rf intentionally not set - RSC came after response-type variants
|
|
230
|
+
return leaf;
|
|
231
|
+
}
|
|
232
|
+
// Both RSC (last wins): overwrite
|
|
233
|
+
return leaf;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function mergeLeaf(node: TrieNode, leaf: TrieLeaf): void {
|
|
237
|
+
node.r = mergeLeaves(node.r, leaf);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function buildLeaf(
|
|
241
|
+
leafBase: Omit<TrieLeaf, "pa">,
|
|
242
|
+
paramNames: string[],
|
|
243
|
+
): TrieLeaf {
|
|
244
|
+
return paramNames.length > 0
|
|
245
|
+
? { ...leafBase, pa: [...paramNames] }
|
|
246
|
+
: { ...leafBase };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function insertSegments(
|
|
250
|
+
node: TrieNode,
|
|
251
|
+
segments: ParsedSegment[],
|
|
252
|
+
index: number,
|
|
253
|
+
leafBase: Omit<TrieLeaf, "pa">,
|
|
254
|
+
paramNames: string[],
|
|
255
|
+
): void {
|
|
256
|
+
// Base case: all segments consumed, add terminal with branch-local pa
|
|
257
|
+
if (index >= segments.length) {
|
|
258
|
+
mergeLeaf(node, buildLeaf(leafBase, paramNames));
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const segment = segments[index];
|
|
263
|
+
|
|
264
|
+
if (segment.type === "static") {
|
|
265
|
+
if (!node.s) node.s = {};
|
|
266
|
+
if (!node.s[segment.value]) node.s[segment.value] = {};
|
|
267
|
+
insertSegments(
|
|
268
|
+
node.s[segment.value],
|
|
269
|
+
segments,
|
|
270
|
+
index + 1,
|
|
271
|
+
leafBase,
|
|
272
|
+
paramNames,
|
|
273
|
+
);
|
|
274
|
+
} else if (segment.type === "param") {
|
|
275
|
+
if (segment.optional) {
|
|
276
|
+
// SKIP first: continue at the same node without binding this name.
|
|
277
|
+
// Skip-first ordering means the present-branch's TAKE overwrites any
|
|
278
|
+
// shared terminal later, giving greedy-leftmost semantics.
|
|
279
|
+
insertSegments(node, segments, index + 1, leafBase, paramNames);
|
|
280
|
+
}
|
|
281
|
+
if (segment.suffix) {
|
|
282
|
+
// Suffix param: keyed by suffix string (e.g., ".html")
|
|
283
|
+
if (!node.xp) node.xp = {};
|
|
284
|
+
if (!node.xp[segment.suffix]) {
|
|
285
|
+
node.xp[segment.suffix] = { n: segment.value, c: {} };
|
|
286
|
+
}
|
|
287
|
+
insertSegments(node.xp[segment.suffix].c, segments, index + 1, leafBase, [
|
|
288
|
+
...paramNames,
|
|
289
|
+
segment.value,
|
|
290
|
+
]);
|
|
291
|
+
} else {
|
|
292
|
+
if (!node.p) {
|
|
293
|
+
node.p = { n: segment.value, c: {} };
|
|
294
|
+
}
|
|
295
|
+
insertSegments(node.p.c, segments, index + 1, leafBase, [
|
|
296
|
+
...paramNames,
|
|
297
|
+
segment.value,
|
|
298
|
+
]);
|
|
299
|
+
}
|
|
300
|
+
} else if (segment.type === "wildcard") {
|
|
301
|
+
// Wildcard consumes all remaining segments. Carry any params bound before
|
|
302
|
+
// the wildcard in pa so they zip correctly against paramValues at match.
|
|
303
|
+
// `pn` is "*" for the bare `/*` and the param name for a named catch-all;
|
|
304
|
+
// `w1` marks the one-or-more variant (`:name+`) so the walker rejects the
|
|
305
|
+
// empty-remainder case.
|
|
306
|
+
const wildLeaf: TrieLeaf & { pn: string; w1?: true } = {
|
|
307
|
+
...buildLeaf(leafBase, paramNames),
|
|
308
|
+
pn: segment.value,
|
|
309
|
+
...(segment.oneOrMore ? { w1: true as const } : {}),
|
|
310
|
+
};
|
|
311
|
+
const existing = node.w;
|
|
312
|
+
// Merge when there's no existing wildcard, when this is a response-type
|
|
313
|
+
// content-negotiation variant of the same catch-all (one side carries `rt`),
|
|
314
|
+
// or when it's the SAME catch-all identity (same param name + arity).
|
|
315
|
+
// Otherwise two DISTINCT catch-all forms (`/x/*` vs `/x/:p+`) would collide on
|
|
316
|
+
// the single wildcard slot with no non-lossy merge - so keep the first-declared
|
|
317
|
+
// (matching the regex matcher's declaration-order tiebreak) rather than let
|
|
318
|
+
// mergeLeaves' last-wins overwrite silently drop its `pn`/`w1` identity (which
|
|
319
|
+
// stranded the first route and fell through to a corrupt regex-fallback redirect).
|
|
320
|
+
const canMerge =
|
|
321
|
+
existing === undefined ||
|
|
322
|
+
Boolean(existing.rt) ||
|
|
323
|
+
Boolean(wildLeaf.rt) ||
|
|
324
|
+
(existing.pn === wildLeaf.pn &&
|
|
325
|
+
Boolean(existing.w1) === Boolean(wildLeaf.w1));
|
|
326
|
+
if (canMerge) {
|
|
327
|
+
const merged = mergeLeaves(
|
|
328
|
+
existing ? ({ ...existing } as TrieLeaf) : undefined,
|
|
329
|
+
wildLeaf,
|
|
330
|
+
);
|
|
331
|
+
node.w = merged as TrieLeaf & { pn: string; w1?: true };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { ComponentType, ReactNode } from "react";
|
|
|
2
2
|
import type { SerializedManifest } from "../debug.js";
|
|
3
3
|
import type { ReverseFunction } from "../reverse.js";
|
|
4
4
|
import type { UrlPatterns } from "../urls.js";
|
|
5
|
+
import type { ClientUrlPatterns } from "../client-urls/types.js";
|
|
5
6
|
import type { UrlBuilder, EnvCompatible } from "../urls/pattern-types.js";
|
|
6
7
|
import type { EntryData } from "../server/context";
|
|
7
8
|
import type { ErrorInfo, MatchResult } from "../types";
|
|
@@ -29,6 +30,12 @@ export interface RouterRequestInput<TEnv, TVars = DefaultVars> {
|
|
|
29
30
|
ctx?: ExecutionContext;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/** One materialized UrlPatterns registration and its live router mount index. */
|
|
34
|
+
export interface UrlPatternMount<TEnv = any> {
|
|
35
|
+
readonly patterns: UrlPatterns<TEnv, any>;
|
|
36
|
+
readonly mountIndex: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
/**
|
|
33
40
|
* Merge route patterns with response types into a single route map.
|
|
34
41
|
* Routes with response types get { path, response } objects; others stay as strings.
|
|
@@ -100,6 +107,20 @@ export interface Rango<
|
|
|
100
107
|
? MergeRoutesWithResponses<NonNullable<T["_routes"]>, T["_responses"]>
|
|
101
108
|
: Record<string, string>)
|
|
102
109
|
>;
|
|
110
|
+
/**
|
|
111
|
+
* Pure-client mounting shorthand: normalizes to a root include in the
|
|
112
|
+
* canonical urls() tree (`include("/", definition, { name: "" })`) — same
|
|
113
|
+
* lazy materialization as mounting through include() yourself.
|
|
114
|
+
*/
|
|
115
|
+
routes<T extends ClientUrlPatterns<any>>(
|
|
116
|
+
patterns: T,
|
|
117
|
+
): Rango<
|
|
118
|
+
TEnv,
|
|
119
|
+
TRoutes &
|
|
120
|
+
(NonNullable<T["_routes"]> extends Record<string, unknown>
|
|
121
|
+
? NonNullable<T["_routes"]>
|
|
122
|
+
: Record<string, string>)
|
|
123
|
+
>;
|
|
103
124
|
routes(builder: UrlBuilder<TEnv>): Rango<TEnv, TRoutes>;
|
|
104
125
|
|
|
105
126
|
/**
|
|
@@ -230,8 +251,25 @@ export interface RangoInternal<
|
|
|
230
251
|
? MergeRoutesWithResponses<NonNullable<T["_routes"]>, T["_responses"]>
|
|
231
252
|
: Record<string, string>)
|
|
232
253
|
>;
|
|
254
|
+
/**
|
|
255
|
+
* Pure-client mounting shorthand: normalizes to a root include in the
|
|
256
|
+
* canonical urls() tree (`include("/", definition, { name: "" })`) — same
|
|
257
|
+
* lazy materialization as mounting through include() yourself.
|
|
258
|
+
*/
|
|
259
|
+
routes<T extends ClientUrlPatterns<any>>(
|
|
260
|
+
patterns: T,
|
|
261
|
+
): Rango<
|
|
262
|
+
TEnv,
|
|
263
|
+
TRoutes &
|
|
264
|
+
(NonNullable<T["_routes"]> extends Record<string, unknown>
|
|
265
|
+
? NonNullable<T["_routes"]>
|
|
266
|
+
: Record<string, string>)
|
|
267
|
+
>;
|
|
233
268
|
routes(builder: UrlBuilder<TEnv>): Rango<TEnv, TRoutes>;
|
|
234
269
|
|
|
270
|
+
/** Materialized UrlPatterns registrations in registration order. */
|
|
271
|
+
readonly __urlpatternMounts: readonly UrlPatternMount<TEnv>[];
|
|
272
|
+
|
|
235
273
|
/**
|
|
236
274
|
* Add global middleware that runs on all routes
|
|
237
275
|
*/
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
buildLoaderErrorContext,
|
|
34
34
|
} from "./helpers.js";
|
|
35
35
|
import { applyViewTransitionDefault } from "./view-transition-default.js";
|
|
36
|
+
import { _getRequestContext } from "../../server/request-context.js";
|
|
36
37
|
import { getRouterContext } from "../router-context.js";
|
|
37
38
|
import { observeStreamedHandler } from "./streamed-handler-telemetry.js";
|
|
38
39
|
import { observeHandler } from "../instrument.js";
|
|
@@ -63,6 +64,17 @@ export async function resolveLoaders<TEnv>(
|
|
|
63
64
|
if (loaderEntries.length === 0) return [];
|
|
64
65
|
|
|
65
66
|
const shortCode = shortCodeOverride ?? entry.shortCode;
|
|
67
|
+
|
|
68
|
+
// Pin `_currentSegmentId` to the OWNING entry BEFORE the loader kickoffs:
|
|
69
|
+
// createLoaderExecutor captures it synchronously at kickoff for
|
|
70
|
+
// ctx.use(Handle) push attribution (loader writes land in the same bucket
|
|
71
|
+
// as the entry's handler pushes — shortCode is in matched/segmentOrder, so
|
|
72
|
+
// collectHandleData keeps them; an id outside the order is silently
|
|
73
|
+
// dropped). resolveLoaders runs BEFORE the handler-resolution sites assign
|
|
74
|
+
// this (fresh.ts handler-first ordering), so without the pin the captured
|
|
75
|
+
// value is a stale sibling's id (document lane) or undefined (navigation
|
|
76
|
+
// lane — pushes silently vanished).
|
|
77
|
+
(ctx as InternalHandlerContext<any, TEnv>)._currentSegmentId = shortCode;
|
|
66
78
|
const hasLoading = "loading" in entry && entry.loading !== undefined;
|
|
67
79
|
const loadingDisabled = hasLoading && entry.loading === false;
|
|
68
80
|
|
|
@@ -92,6 +104,32 @@ export async function resolveLoaders<TEnv>(
|
|
|
92
104
|
const errorContext = buildLoaderErrorContext(ctx);
|
|
93
105
|
|
|
94
106
|
if (emitStreaming) {
|
|
107
|
+
// awaitBeforeFlush (loader(Def, { stream: "navigation" })): document
|
|
108
|
+
// renders await these loaders before returning, so their data is settled,
|
|
109
|
+
// their handle pushes beat the barrier snapshot, and a thrown notFound()'s
|
|
110
|
+
// status write deterministically precedes Response construction. The ids
|
|
111
|
+
// must register on the request context BEFORE kickoff — rendered() checks
|
|
112
|
+
// the set to fail fast on the barrier cycle (segment resolution awaits the
|
|
113
|
+
// loader, the barrier awaits segment resolution, rendered() awaits the
|
|
114
|
+
// barrier), and the loader body can call rendered() before the await below
|
|
115
|
+
// is reached. Skipped during shell capture: LIVE-lane loaders are masked
|
|
116
|
+
// with never-resolving promises there (loader-mask.ts) and would hang.
|
|
117
|
+
const awaitedIndices: number[] = [];
|
|
118
|
+
if (!isShellCaptureActive()) {
|
|
119
|
+
for (let i = 0; i < loaderEntries.length; i++) {
|
|
120
|
+
if (loaderEntries[i]!.awaitBeforeFlush) awaitedIndices.push(i);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (awaitedIndices.length > 0) {
|
|
124
|
+
const reqCtx = _getRequestContext();
|
|
125
|
+
if (reqCtx) {
|
|
126
|
+
reqCtx._awaitBeforeFlushLoaderIds ??= new Set();
|
|
127
|
+
for (const i of awaitedIndices) {
|
|
128
|
+
reqCtx._awaitBeforeFlushLoaderIds.add(loaderEntries[i]!.loader.$$id);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
95
133
|
// Streaming loaders: promises kick off now, settle during RSC serialization.
|
|
96
134
|
const segments = loaderEntries.map((loaderEntry, i) => {
|
|
97
135
|
const { loader } = loaderEntry;
|
|
@@ -122,6 +160,15 @@ export async function resolveLoaders<TEnv>(
|
|
|
122
160
|
};
|
|
123
161
|
});
|
|
124
162
|
|
|
163
|
+
// Await only the flagged loaders; unflagged siblings keep streaming (their
|
|
164
|
+
// promises were kicked off above and stay pending in the emitted segments).
|
|
165
|
+
// The wrapped promise is contracted to never reject (wrapLoaderPromise), so
|
|
166
|
+
// a flagged loader failure resolves with its error envelope and cannot
|
|
167
|
+
// collapse resolution — same contract the loading-disabled path relies on.
|
|
168
|
+
if (awaitedIndices.length > 0) {
|
|
169
|
+
await Promise.all(awaitedIndices.map((i) => segments[i]!.loaderData));
|
|
170
|
+
}
|
|
171
|
+
|
|
125
172
|
return segments;
|
|
126
173
|
}
|
|
127
174
|
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
* - Error boundary segment creation
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import type { ReactNode } from "react";
|
|
12
|
+
import { isDataNotFoundError } from "../../errors";
|
|
13
13
|
import {
|
|
14
14
|
createErrorInfo,
|
|
15
15
|
createErrorSegment,
|
|
16
16
|
createNotFoundInfo,
|
|
17
17
|
createNotFoundSegment,
|
|
18
|
+
resolveNotFoundFallback,
|
|
18
19
|
} from "../error-handling.js";
|
|
19
20
|
import { getRequestContext } from "../../server/request-context.js";
|
|
20
21
|
import { DefaultErrorFallback } from "../../default-error-boundary.js";
|
|
@@ -252,15 +253,12 @@ export function catchSegmentError<TEnv>(
|
|
|
252
253
|
}
|
|
253
254
|
};
|
|
254
255
|
|
|
255
|
-
if (error
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
? notFoundOption({ pathname: pathname ?? "" })
|
|
262
|
-
: (notFoundOption ?? createElement("h1", null, "Not Found"));
|
|
263
|
-
const effectiveNotFoundFallback = notFoundFallback ?? defaultFallback;
|
|
256
|
+
if (isDataNotFoundError(error)) {
|
|
257
|
+
const effectiveNotFoundFallback = resolveNotFoundFallback(
|
|
258
|
+
deps.findNearestNotFoundBoundary(entry),
|
|
259
|
+
deps.notFoundComponent,
|
|
260
|
+
pathname,
|
|
261
|
+
);
|
|
264
262
|
|
|
265
263
|
const notFoundInfo = createNotFoundInfo(
|
|
266
264
|
error,
|
|
@@ -157,30 +157,20 @@ export function resolveLoaderData<TEnv>(
|
|
|
157
157
|
// shell HIT the recorded container is overlaid onto the fresh run so the
|
|
158
158
|
// payload matches the frozen prelude byte-for-byte.
|
|
159
159
|
if (isShellCaptureActive(reqCtx)) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
// the SHARED shell and the snapshot pinned it for every visitor
|
|
175
|
-
// (per-request basket data served cross-session, found live). The raw
|
|
176
|
-
// container is untouched: handler-side ctx.use consumption (the
|
|
177
|
-
// consumption-lane rule, semantic-matrix PPR3) keeps real values.
|
|
178
|
-
const maskedPromise = containerPromise.then((container: unknown) =>
|
|
179
|
-
maskNestedContainerThenables(container),
|
|
180
|
-
);
|
|
181
|
-
maskedPromise.catch(() => {});
|
|
182
|
-
reqCtx?._shellCaptureLoaderRecords?.set(bakeSegmentKey, maskedPromise);
|
|
183
|
-
return maskedPromise;
|
|
160
|
+
// EXPERIMENT (streaming useLoader, feat/useloader-suspense): route
|
|
161
|
+
// loaders are LIVE at capture UNCONDITIONALLY — the loading()-keyed lane
|
|
162
|
+
// trigger is suspended on this branch. Read-site suspension postpones
|
|
163
|
+
// each masked stream at the consumer's own Suspense boundary, so holes
|
|
164
|
+
// no longer require a route-level loading(); baking route data into a
|
|
165
|
+
// shell is expressed via cache()/"use cache", not by omitting loading().
|
|
166
|
+
// The former bake-at-capture path (execute + nested-thenable mask +
|
|
167
|
+
// snapshot pinning via _shellCaptureLoaderRecords, see git history) is
|
|
168
|
+
// bypassed: with no records registered the serve-side seed overlay is a
|
|
169
|
+
// no-op and every HIT runs loaders fresh. A masked reader with NO
|
|
170
|
+
// Suspense above it root-postpones and the capture's <body> sanity gate
|
|
171
|
+
// refuses the shell (runtime render + eternal-MISS warning), which is
|
|
172
|
+
// the intended degrade for boundary-less ppr routes.
|
|
173
|
+
return createMaskedLoaderPromise();
|
|
184
174
|
}
|
|
185
175
|
|
|
186
176
|
if (bakeSegmentKey) {
|
|
@@ -129,6 +129,14 @@ export async function resolveLoadersWithRevalidation<TEnv>(
|
|
|
129
129
|
|
|
130
130
|
const shortCode = shortCodeOverride ?? entry.shortCode;
|
|
131
131
|
|
|
132
|
+
// Pin `_currentSegmentId` to the OWNING entry before the kickoffs below —
|
|
133
|
+
// createLoaderExecutor captures it synchronously for ctx.use(Handle) push
|
|
134
|
+
// attribution. Same pin as resolveLoaders (fresh.ts); this REVALIDATION
|
|
135
|
+
// funnel is the navigation/action lane's kickoff site, where nothing else
|
|
136
|
+
// assigns the id first (pushes silently vanished: an id outside
|
|
137
|
+
// matched/segmentOrder is dropped by collectHandleData).
|
|
138
|
+
(ctx as InternalHandlerContext<any, TEnv>)._currentSegmentId = shortCode;
|
|
139
|
+
|
|
132
140
|
const loaderMeta = loaderEntries.map((loaderEntry, i) => ({
|
|
133
141
|
loaderEntry,
|
|
134
142
|
loader: loaderEntry.loader,
|
|
@@ -605,7 +613,17 @@ export async function resolveParallelSegmentsWithRevalidation<TEnv>(
|
|
|
605
613
|
// For non-empty client sets, consult user revalidate fns. When the slot
|
|
606
614
|
// is unknown to the client, override the type-derived default so the
|
|
607
615
|
// soft chain seeds with the right "new segment" / "parent-chain" value.
|
|
608
|
-
|
|
616
|
+
//
|
|
617
|
+
// A "new segment" seed is floored: the client has no cached copy of this
|
|
618
|
+
// slot, so a user `false` would render component:null and leave it blank
|
|
619
|
+
// rather than keep anything. Sibling resolvers (loaders, layout/route
|
|
620
|
+
// entries, orphan layouts) get the same guarantee by short-circuiting
|
|
621
|
+
// without consulting user fns at all; #482 made this path consult them so
|
|
622
|
+
// a "skip-parent-chain" seed could still be raised, so floor instead of
|
|
623
|
+
// short-circuiting — user fns run, and may only raise.
|
|
624
|
+
let defaultOverride:
|
|
625
|
+
| { value: boolean; reason: string; floor?: boolean }
|
|
626
|
+
| undefined;
|
|
609
627
|
if (!clientSegmentIds.has(parallelId)) {
|
|
610
628
|
const value =
|
|
611
629
|
parentChainDefault === "force-render"
|
|
@@ -614,6 +632,7 @@ export async function resolveParallelSegmentsWithRevalidation<TEnv>(
|
|
|
614
632
|
defaultOverride = {
|
|
615
633
|
value,
|
|
616
634
|
reason: value ? "new-segment" : "skip-parent-chain",
|
|
635
|
+
floor: value,
|
|
617
636
|
};
|
|
618
637
|
}
|
|
619
638
|
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
TrieNode,
|
|
10
10
|
TrieLeaf,
|
|
11
11
|
NegotiateVariant,
|
|
12
|
-
} from "
|
|
12
|
+
} from "./route-trie-builder.js";
|
|
13
13
|
import { safeDecodeURIComponent } from "./url-params.js";
|
|
14
14
|
|
|
15
15
|
export interface TrieMatchResult {
|
|
@@ -219,8 +219,8 @@ function walkTrie(
|
|
|
219
219
|
|
|
220
220
|
if (node.xp) {
|
|
221
221
|
// node.xp keys are pre-sorted longest-suffix-first at build time
|
|
222
|
-
// (route-trie.ts sortSuffixParams), so the first match is the most
|
|
223
|
-
// suffix: `/app.min.js` matches `:file.min.js` before `:file.js`.
|
|
222
|
+
// (route-trie-builder.ts sortSuffixParams), so the first match is the most
|
|
223
|
+
// specific suffix: `/app.min.js` matches `:file.min.js` before `:file.js`.
|
|
224
224
|
for (const suffix in node.xp) {
|
|
225
225
|
if (segment.endsWith(suffix) && segment.length > suffix.length) {
|
|
226
226
|
const paramValue = segment.slice(0, -suffix.length);
|