@rangojs/router 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/bin/rango.js +343 -125
- package/dist/types/browser/event-controller.d.ts +6 -0
- package/dist/types/browser/react/use-router.d.ts +10 -3
- package/dist/types/browser/react/use-search-params.d.ts +57 -10
- package/dist/types/browser/types.d.ts +22 -0
- package/dist/types/build/merge-full-manifests.d.ts +3 -0
- package/dist/types/build/route-trie.d.ts +4 -73
- package/dist/types/build/route-types/per-module-writer.d.ts +6 -4
- package/dist/types/build/route-types/router-processing.d.ts +2 -3
- package/dist/types/cache/cache-exec-scope.d.ts +31 -0
- package/dist/types/cache/cf/cf-cache-constants.d.ts +8 -1
- package/dist/types/cache/cf/cf-cache-store.d.ts +15 -1
- package/dist/types/cache/cf/cf-cache-types.d.ts +1 -1
- package/dist/types/cache/cf/cf-kv-utils.d.ts +21 -0
- package/dist/types/cache/taint.d.ts +12 -6
- package/dist/types/client-urls/client-root.d.ts +38 -0
- package/dist/types/client-urls/client-urls.d.ts +5 -0
- package/dist/types/client-urls/navigation.d.ts +38 -0
- package/dist/types/client-urls/revalidation-protocol.d.ts +25 -0
- package/dist/types/client-urls/server-projection.d.ts +62 -0
- package/dist/types/client-urls/types.d.ts +144 -0
- package/dist/types/client.d.ts +12 -4
- package/dist/types/client.rsc.d.ts +4 -1
- package/dist/types/decode-loader-results.d.ts +37 -0
- package/dist/types/errors.d.ts +1 -0
- package/dist/types/handles/is-thenable.d.ts +2 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/loader-redirect.d.ts +27 -0
- package/dist/types/outlet-context.d.ts +12 -0
- package/dist/types/outlet-provider.d.ts +3 -1
- package/dist/types/redirect-origin.d.ts +4 -0
- package/dist/types/route-content-wrapper.d.ts +42 -1
- package/dist/types/route-definition/helpers-types.d.ts +13 -2
- package/dist/types/router/error-handling.d.ts +35 -1
- package/dist/types/router/intercept-resolution.d.ts +12 -0
- package/dist/types/router/loader-resolution.d.ts +24 -2
- package/dist/types/router/revalidation.d.ts +7 -0
- package/dist/{types.backup/build/route-trie.d.ts → types/router/route-trie-builder.d.ts} +4 -16
- package/dist/types/router/router-interfaces.d.ts +20 -0
- package/dist/types/router/segment-resolution/helpers.d.ts +1 -1
- package/dist/types/router/trie-matching.d.ts +1 -1
- package/dist/types/rsc/helpers.d.ts +3 -0
- package/dist/types/rsc/manifest-init.d.ts +5 -5
- package/dist/types/rsc/render-pipeline.d.ts +9 -0
- package/dist/types/rsc/routine-plan.d.ts +124 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +17 -0
- package/dist/types/rsc/shell-capture.d.ts +9 -0
- package/dist/types/rsc/shell-serve.d.ts +11 -0
- package/dist/types/rsc/types.d.ts +30 -0
- package/dist/types/segment-system.d.ts +2 -0
- package/dist/types/server/context.d.ts +10 -0
- package/dist/types/server/handle-store.d.ts +34 -3
- package/dist/types/server/request-context.d.ts +14 -1
- package/dist/types/server.d.ts +1 -0
- package/dist/types/ssr/index.d.ts +22 -0
- package/dist/types/ssr/ssr-root.d.ts +10 -0
- package/dist/types/testing/dom.entry.d.ts +1 -1
- package/dist/types/testing/render-route.d.ts +16 -6
- package/dist/types/testing/run-loader.d.ts +9 -0
- package/dist/types/types/boundaries.d.ts +22 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/loader-types.d.ts +57 -5
- package/dist/types/types/segments.d.ts +7 -0
- package/dist/types/urls/path-helper-types.d.ts +10 -4
- package/dist/types/vite/discovery/client-urls-projection.d.ts +53 -0
- package/dist/types/vite/discovery/discover-routers.d.ts +1 -1
- package/dist/types/vite/discovery/state.d.ts +8 -1
- package/dist/types/vite/encryption-key.d.ts +2 -0
- package/dist/types/vite/plugins/expose-internal-ids.d.ts +10 -0
- package/dist/types/vite/plugins/server-ref-hashing.d.ts +24 -0
- package/dist/types/vite/plugins/server-reference-pattern.d.ts +1 -0
- package/dist/types/vite/utils/shared-utils.d.ts +12 -0
- package/dist/vite/index.js +5101 -2056
- package/package.json +3 -3
- package/skills/breadcrumbs/SKILL.md +39 -9
- package/skills/caching/SKILL.md +1 -1
- package/skills/catalog.json +7 -1
- package/skills/client-urls/SKILL.md +338 -0
- package/skills/comparison/references/framework-comparison.md +23 -9
- package/skills/hooks/SKILL.md +2 -2
- package/skills/hooks/data.md +11 -2
- package/skills/hooks/handle-and-actions.md +7 -0
- package/skills/hooks/outlets.md +26 -5
- package/skills/hooks/urls.md +40 -3
- package/skills/loader/SKILL.md +132 -20
- package/skills/migrate-nextjs/SKILL.md +70 -10
- package/skills/migrate-react-router/SKILL.md +49 -13
- package/skills/migrate-react-router/component-migration.md +18 -13
- package/skills/migrate-react-router/data-and-actions.md +14 -3
- package/skills/migrate-react-router/route-mapping.md +15 -2
- package/skills/mime-routes/SKILL.md +3 -1
- package/skills/parallel/SKILL.md +32 -1
- package/skills/ppr/SKILL.md +16 -6
- package/skills/prerender/SKILL.md +8 -4
- package/skills/rango/SKILL.md +21 -17
- package/skills/react-compiler/SKILL.md +3 -3
- package/skills/response-routes/SKILL.md +4 -2
- package/skills/route/SKILL.md +5 -2
- package/skills/router-setup/SKILL.md +16 -2
- package/skills/scripts/SKILL.md +16 -6
- package/skills/shell-manifest/SKILL.md +16 -7
- package/skills/testing/SKILL.md +2 -2
- package/skills/testing/client-components.md +6 -0
- package/skills/testing/handles.md +30 -8
- package/skills/testing/loader.md +51 -49
- package/skills/testing/middleware.md +1 -1
- package/skills/theme/SKILL.md +8 -5
- package/skills/typesafety/generated-files-and-cli.md +16 -9
- package/skills/typesafety/route-types.md +5 -1
- package/skills/use-cache/SKILL.md +47 -0
- package/src/bin/rango.ts +7 -3
- package/src/browser/event-controller.ts +40 -15
- package/src/browser/navigation-bridge.ts +6 -0
- package/src/browser/navigation-client.ts +5 -0
- package/src/browser/partial-update.ts +77 -10
- package/src/browser/react/NavigationProvider.tsx +7 -0
- package/src/browser/react/use-router.ts +40 -11
- package/src/browser/react/use-search-params.ts +140 -17
- package/src/browser/rsc-router.tsx +59 -0
- package/src/browser/server-action-bridge.ts +26 -0
- package/src/browser/types.ts +22 -0
- package/src/build/merge-full-manifests.ts +161 -0
- package/src/build/route-trie.ts +9 -332
- package/src/build/route-types/include-resolution.ts +66 -11
- package/src/build/route-types/per-module-writer.ts +11 -6
- package/src/build/route-types/router-processing.ts +184 -153
- package/src/build/runtime-discovery.ts +23 -12
- package/src/cache/cache-exec-scope.ts +47 -0
- package/src/cache/cache-runtime.ts +113 -40
- package/src/cache/cf/cf-cache-constants.ts +8 -1
- package/src/cache/cf/cf-cache-store.ts +41 -64
- package/src/cache/cf/cf-cache-types.ts +1 -1
- package/src/cache/cf/cf-kv-utils.ts +38 -0
- package/src/cache/segment-codec.ts +21 -5
- package/src/cache/taint.ts +28 -9
- package/src/client-urls/client-root.tsx +168 -0
- package/src/client-urls/client-urls.ts +698 -0
- package/src/client-urls/navigation.ts +237 -0
- package/src/client-urls/revalidation-protocol.ts +56 -0
- package/src/client-urls/server-projection.ts +579 -0
- package/src/client-urls/types.ts +195 -0
- package/src/client.rsc.tsx +12 -0
- package/src/client.tsx +49 -6
- package/src/decode-loader-results.ts +113 -0
- package/src/errors.ts +14 -0
- package/src/handles/deferred-resolution.ts +14 -7
- package/src/handles/is-thenable.ts +2 -4
- package/src/index.ts +1 -0
- package/src/loader-redirect.tsx +64 -0
- package/src/outlet-context.ts +12 -0
- package/src/outlet-provider.tsx +15 -1
- package/src/redirect-origin.ts +29 -0
- package/src/route-content-wrapper.tsx +96 -3
- package/src/route-definition/dsl-helpers.ts +28 -3
- package/src/route-definition/helpers-types.ts +13 -0
- package/src/route-definition/redirect.ts +17 -18
- package/src/router/error-handling.ts +65 -11
- package/src/router/intercept-resolution.ts +29 -0
- package/src/router/loader-resolution.ts +261 -28
- package/src/router/match-middleware/cache-lookup.ts +24 -15
- package/src/router/match-result.ts +7 -0
- package/src/router/revalidation.ts +24 -11
- package/src/router/route-trie-builder.ts +334 -0
- package/src/router/router-interfaces.ts +38 -0
- package/src/router/segment-resolution/fresh.ts +47 -0
- package/src/router/segment-resolution/helpers.ts +9 -11
- package/src/router/segment-resolution/loader-cache.ts +14 -24
- package/src/router/segment-resolution/revalidation.ts +20 -1
- package/src/router/trie-matching.ts +3 -3
- package/src/router.ts +46 -1
- package/src/rsc/full-payload.ts +6 -0
- package/src/rsc/handler.ts +36 -12
- package/src/rsc/helpers.ts +13 -0
- package/src/rsc/loader-fetch.ts +2 -2
- package/src/rsc/manifest-init.ts +28 -9
- package/src/rsc/progressive-enhancement.ts +247 -70
- package/src/rsc/render-pipeline.ts +68 -24
- package/src/rsc/routine-plan.ts +359 -0
- package/src/rsc/rsc-rendering.ts +569 -302
- package/src/rsc/server-action.ts +180 -71
- package/src/rsc/shell-capture-constants.ts +18 -0
- package/src/rsc/shell-capture.ts +104 -21
- package/src/rsc/shell-serve.ts +15 -2
- package/src/rsc/ssr-setup.ts +10 -1
- package/src/rsc/types.ts +31 -2
- package/src/segment-system.tsx +83 -26
- package/src/server/context.ts +10 -0
- package/src/server/cookie-store.ts +19 -19
- package/src/server/handle-store.ts +185 -48
- package/src/server/request-context.ts +36 -6
- package/src/server.ts +7 -0
- package/src/ssr/index.tsx +37 -2
- package/src/ssr/ssr-root.tsx +30 -2
- package/src/testing/dom.entry.ts +1 -1
- package/src/testing/render-route.tsx +22 -8
- package/src/testing/run-loader.ts +51 -13
- package/src/types/boundaries.ts +19 -0
- package/src/types/index.ts +1 -0
- package/src/types/loader-types.ts +60 -5
- package/src/types/segments.ts +7 -0
- package/src/urls/include-helper.ts +22 -4
- package/src/urls/path-helper-types.ts +14 -1
- package/src/use-loader.tsx +67 -6
- package/src/vite/discovery/client-urls-projection.ts +322 -0
- package/src/vite/discovery/discover-routers.ts +43 -17
- package/src/vite/discovery/state.ts +11 -1
- package/src/vite/discovery/virtual-module-codegen.ts +20 -0
- package/src/vite/encryption-key.ts +29 -0
- package/src/vite/plugins/expose-action-id.ts +2 -2
- package/src/vite/plugins/expose-internal-ids.ts +46 -0
- package/src/vite/plugins/server-ref-hashing.ts +74 -0
- package/src/vite/plugins/server-reference-pattern.ts +10 -0
- package/src/vite/plugins/virtual-entries.ts +12 -3
- package/src/vite/rango.ts +9 -0
- package/src/vite/router-discovery.ts +184 -14
- package/src/vite/utils/shared-utils.ts +12 -7
- package/dist/types.backup/__internal.d.ts +0 -127
- package/dist/types.backup/bin/rango.d.ts +0 -1
- package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
- package/dist/types.backup/browser/action-fence.d.ts +0 -33
- package/dist/types.backup/browser/app-shell.d.ts +0 -34
- package/dist/types.backup/browser/app-version.d.ts +0 -6
- package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
- package/dist/types.backup/browser/cookie-name.d.ts +0 -66
- package/dist/types.backup/browser/event-controller.d.ts +0 -221
- package/dist/types.backup/browser/history-state.d.ts +0 -26
- package/dist/types.backup/browser/index.d.ts +0 -1
- package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
- package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
- package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
- package/dist/types.backup/browser/logging.d.ts +0 -33
- package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
- package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
- package/dist/types.backup/browser/navigation-client.d.ts +0 -17
- package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
- package/dist/types.backup/browser/navigation-store.d.ts +0 -95
- package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
- package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
- package/dist/types.backup/browser/partial-update.d.ts +0 -61
- package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
- package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
- package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
- package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
- package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
- package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
- package/dist/types.backup/browser/rango-state.d.ts +0 -52
- package/dist/types.backup/browser/react/Link.d.ts +0 -140
- package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
- package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
- package/dist/types.backup/browser/react/context.d.ts +0 -54
- package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
- package/dist/types.backup/browser/react/index.d.ts +0 -1
- package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
- package/dist/types.backup/browser/react/location-state.d.ts +0 -29
- package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
- package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
- package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
- package/dist/types.backup/browser/react/use-action.d.ts +0 -61
- package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
- package/dist/types.backup/browser/react/use-href.d.ts +0 -32
- package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
- package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
- package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
- package/dist/types.backup/browser/react/use-params.d.ts +0 -21
- package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
- package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
- package/dist/types.backup/browser/react/use-router.d.ts +0 -23
- package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
- package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
- package/dist/types.backup/browser/response-adapter.d.ts +0 -58
- package/dist/types.backup/browser/rsc-router.d.ts +0 -141
- package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
- package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
- package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
- package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
- package/dist/types.backup/browser/types.d.ts +0 -530
- package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
- package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
- package/dist/types.backup/build/generate-manifest.d.ts +0 -100
- package/dist/types.backup/build/generate-route-types.d.ts +0 -8
- package/dist/types.backup/build/index.d.ts +0 -21
- package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
- package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
- package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
- package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
- package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
- package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
- package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
- package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
- package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
- package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
- package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
- package/dist/types.backup/cache/background-task.d.ts +0 -21
- package/dist/types.backup/cache/cache-error.d.ts +0 -71
- package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
- package/dist/types.backup/cache/cache-policy.d.ts +0 -59
- package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
- package/dist/types.backup/cache/cache-scope.d.ts +0 -134
- package/dist/types.backup/cache/cache-tag.d.ts +0 -79
- package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
- package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
- package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
- package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
- package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
- package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
- package/dist/types.backup/cache/cf/index.d.ts +0 -3
- package/dist/types.backup/cache/document-cache.d.ts +0 -69
- package/dist/types.backup/cache/handle-capture.d.ts +0 -23
- package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
- package/dist/types.backup/cache/index.d.ts +0 -7
- package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
- package/dist/types.backup/cache/profile-registry.d.ts +0 -40
- package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
- package/dist/types.backup/cache/segment-codec.d.ts +0 -78
- package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
- package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
- package/dist/types.backup/cache/taint.d.ts +0 -71
- package/dist/types.backup/cache/types.d.ts +0 -407
- package/dist/types.backup/cache/vercel/index.d.ts +0 -1
- package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
- package/dist/types.backup/client.d.ts +0 -184
- package/dist/types.backup/client.rsc.d.ts +0 -39
- package/dist/types.backup/cloudflare/index.d.ts +0 -7
- package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
- package/dist/types.backup/component-utils.d.ts +0 -46
- package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
- package/dist/types.backup/context-var.d.ts +0 -84
- package/dist/types.backup/debug.d.ts +0 -57
- package/dist/types.backup/decode-loader-results.d.ts +0 -5
- package/dist/types.backup/default-error-boundary.d.ts +0 -10
- package/dist/types.backup/defer.d.ts +0 -89
- package/dist/types.backup/deps/browser.d.ts +0 -1
- package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
- package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
- package/dist/types.backup/deps/rsc.d.ts +0 -1
- package/dist/types.backup/deps/ssr.d.ts +0 -1
- package/dist/types.backup/encode-kv.d.ts +0 -35
- package/dist/types.backup/errors.d.ts +0 -226
- package/dist/types.backup/escape-script.d.ts +0 -44
- package/dist/types.backup/handle.d.ts +0 -93
- package/dist/types.backup/handles/MetaTags.d.ts +0 -17
- package/dist/types.backup/handles/Scripts.d.ts +0 -38
- package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
- package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
- package/dist/types.backup/handles/is-thenable.d.ts +0 -12
- package/dist/types.backup/handles/meta.d.ts +0 -43
- package/dist/types.backup/handles/script.d.ts +0 -139
- package/dist/types.backup/host/cookie-handler.d.ts +0 -8
- package/dist/types.backup/host/errors.d.ts +0 -40
- package/dist/types.backup/host/index.d.ts +0 -33
- package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
- package/dist/types.backup/host/router.d.ts +0 -12
- package/dist/types.backup/host/testing.d.ts +0 -41
- package/dist/types.backup/host/types.d.ts +0 -148
- package/dist/types.backup/host/utils.d.ts +0 -20
- package/dist/types.backup/href-client.d.ts +0 -214
- package/dist/types.backup/index.d.ts +0 -112
- package/dist/types.backup/index.rsc.d.ts +0 -51
- package/dist/types.backup/internal-debug.d.ts +0 -1
- package/dist/types.backup/loader-store.d.ts +0 -193
- package/dist/types.backup/loader.d.ts +0 -18
- package/dist/types.backup/loader.rsc.d.ts +0 -18
- package/dist/types.backup/missing-id-error.d.ts +0 -1
- package/dist/types.backup/outlet-context.d.ts +0 -12
- package/dist/types.backup/outlet-provider.d.ts +0 -12
- package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
- package/dist/types.backup/prerender/param-hash.d.ts +0 -6
- package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
- package/dist/types.backup/prerender/store.d.ts +0 -62
- package/dist/types.backup/prerender.d.ts +0 -292
- package/dist/types.backup/redirect-origin.d.ts +0 -55
- package/dist/types.backup/regex-escape.d.ts +0 -6
- package/dist/types.backup/render-error-thrower.d.ts +0 -13
- package/dist/types.backup/response-utils.d.ts +0 -35
- package/dist/types.backup/reverse.d.ts +0 -206
- package/dist/types.backup/root-error-boundary.d.ts +0 -32
- package/dist/types.backup/route-content-wrapper.d.ts +0 -40
- package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
- package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
- package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
- package/dist/types.backup/route-definition/index.d.ts +0 -7
- package/dist/types.backup/route-definition/redirect.d.ts +0 -48
- package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
- package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
- package/dist/types.backup/route-definition.d.ts +0 -1
- package/dist/types.backup/route-map-builder.d.ts +0 -127
- package/dist/types.backup/route-name.d.ts +0 -27
- package/dist/types.backup/route-types.d.ts +0 -172
- package/dist/types.backup/router/basename.d.ts +0 -10
- package/dist/types.backup/router/content-negotiation.d.ts +0 -91
- package/dist/types.backup/router/debug-manifest.d.ts +0 -7
- package/dist/types.backup/router/error-handling.d.ts +0 -76
- package/dist/types.backup/router/find-match.d.ts +0 -19
- package/dist/types.backup/router/handler-context.d.ts +0 -41
- package/dist/types.backup/router/instrument.d.ts +0 -161
- package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
- package/dist/types.backup/router/lazy-includes.d.ts +0 -26
- package/dist/types.backup/router/loader-resolution.d.ts +0 -63
- package/dist/types.backup/router/logging.d.ts +0 -41
- package/dist/types.backup/router/manifest.d.ts +0 -8
- package/dist/types.backup/router/match-api.d.ts +0 -19
- package/dist/types.backup/router/match-context.d.ts +0 -184
- package/dist/types.backup/router/match-handlers.d.ts +0 -49
- package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
- package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
- package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
- package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
- package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
- package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
- package/dist/types.backup/router/match-pipelines.d.ts +0 -103
- package/dist/types.backup/router/match-result.d.ts +0 -114
- package/dist/types.backup/router/metrics.d.ts +0 -6
- package/dist/types.backup/router/middleware-types.d.ts +0 -74
- package/dist/types.backup/router/middleware.d.ts +0 -116
- package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
- package/dist/types.backup/router/params-util.d.ts +0 -8
- package/dist/types.backup/router/parse-pattern.d.ts +0 -38
- package/dist/types.backup/router/pattern-matching.d.ts +0 -169
- package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
- package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
- package/dist/types.backup/router/prerender-match.d.ts +0 -50
- package/dist/types.backup/router/preview-match.d.ts +0 -22
- package/dist/types.backup/router/request-classification.d.ts +0 -104
- package/dist/types.backup/router/revalidation.d.ts +0 -57
- package/dist/types.backup/router/route-snapshot.d.ts +0 -112
- package/dist/types.backup/router/router-context.d.ts +0 -137
- package/dist/types.backup/router/router-interfaces.d.ts +0 -432
- package/dist/types.backup/router/router-options.d.ts +0 -738
- package/dist/types.backup/router/router-registry.d.ts +0 -15
- package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
- package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
- package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
- package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
- package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
- package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
- package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
- package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
- package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
- package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
- package/dist/types.backup/router/segment-resolution.d.ts +0 -3
- package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
- package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
- package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
- package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
- package/dist/types.backup/router/telemetry.d.ts +0 -215
- package/dist/types.backup/router/timeout.d.ts +0 -68
- package/dist/types.backup/router/tracing.d.ts +0 -125
- package/dist/types.backup/router/trie-matching.d.ts +0 -32
- package/dist/types.backup/router/types.d.ts +0 -98
- package/dist/types.backup/router/url-params.d.ts +0 -26
- package/dist/types.backup/router.d.ts +0 -7
- package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
- package/dist/types.backup/rsc/full-payload.d.ts +0 -22
- package/dist/types.backup/rsc/handler-context.d.ts +0 -31
- package/dist/types.backup/rsc/handler.d.ts +0 -9
- package/dist/types.backup/rsc/helpers.d.ts +0 -213
- package/dist/types.backup/rsc/index.d.ts +0 -17
- package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
- package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
- package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
- package/dist/types.backup/rsc/nonce.d.ts +0 -28
- package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
- package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
- package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
- package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
- package/dist/types.backup/rsc/response-error.d.ts +0 -19
- package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
- package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
- package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
- package/dist/types.backup/rsc/server-action.d.ts +0 -68
- package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
- package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
- package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
- package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
- package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
- package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
- package/dist/types.backup/rsc/types.d.ts +0 -290
- package/dist/types.backup/runtime-env.d.ts +0 -1
- package/dist/types.backup/search-params.d.ts +0 -125
- package/dist/types.backup/segment-content-promise.d.ts +0 -13
- package/dist/types.backup/segment-fragments.d.ts +0 -56
- package/dist/types.backup/segment-loader-promise.d.ts +0 -22
- package/dist/types.backup/segment-system.d.ts +0 -84
- package/dist/types.backup/serialize.d.ts +0 -164
- package/dist/types.backup/server/context.d.ts +0 -494
- package/dist/types.backup/server/cookie-parse.d.ts +0 -10
- package/dist/types.backup/server/cookie-store.d.ts +0 -107
- package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
- package/dist/types.backup/server/handle-store.d.ts +0 -100
- package/dist/types.backup/server/loader-registry.d.ts +0 -32
- package/dist/types.backup/server/request-context.d.ts +0 -596
- package/dist/types.backup/server/root-layout.d.ts +0 -3
- package/dist/types.backup/server.d.ts +0 -15
- package/dist/types.backup/ssr/index.d.ts +0 -233
- package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
- package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
- package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
- package/dist/types.backup/static-handler.d.ts +0 -57
- package/dist/types.backup/testing/cache-status.d.ts +0 -63
- package/dist/types.backup/testing/collect-handle.d.ts +0 -20
- package/dist/types.backup/testing/dispatch.d.ts +0 -123
- package/dist/types.backup/testing/dom.entry.d.ts +0 -15
- package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
- package/dist/types.backup/testing/e2e/index.d.ts +0 -30
- package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
- package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
- package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
- package/dist/types.backup/testing/e2e/server.d.ts +0 -35
- package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
- package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
- package/dist/types.backup/testing/flight-tree.d.ts +0 -192
- package/dist/types.backup/testing/flight.d.ts +0 -115
- package/dist/types.backup/testing/flight.entry.d.ts +0 -27
- package/dist/types.backup/testing/generated-routes.d.ts +0 -66
- package/dist/types.backup/testing/index.d.ts +0 -52
- package/dist/types.backup/testing/internal/context.d.ts +0 -225
- package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
- package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
- package/dist/types.backup/testing/render-handler.d.ts +0 -160
- package/dist/types.backup/testing/render-route.d.ts +0 -246
- package/dist/types.backup/testing/run-loader.d.ts +0 -186
- package/dist/types.backup/testing/run-middleware.d.ts +0 -132
- package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
- package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
- package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
- package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
- package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
- package/dist/types.backup/testing/vitest.d.ts +0 -205
- package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
- package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
- package/dist/types.backup/theme/constants.d.ts +0 -39
- package/dist/types.backup/theme/index.d.ts +0 -29
- package/dist/types.backup/theme/theme-context.d.ts +0 -21
- package/dist/types.backup/theme/theme-script.d.ts +0 -26
- package/dist/types.backup/theme/types.d.ts +0 -162
- package/dist/types.backup/theme/use-theme.d.ts +0 -8
- package/dist/types.backup/types/boundaries.d.ts +0 -93
- package/dist/types.backup/types/cache-types.d.ts +0 -191
- package/dist/types.backup/types/error-types.d.ts +0 -114
- package/dist/types.backup/types/global-namespace.d.ts +0 -90
- package/dist/types.backup/types/handler-context.d.ts +0 -658
- package/dist/types.backup/types/index.d.ts +0 -11
- package/dist/types.backup/types/loader-types.d.ts +0 -182
- package/dist/types.backup/types/request-scope.d.ts +0 -93
- package/dist/types.backup/types/route-config.d.ts +0 -105
- package/dist/types.backup/types/route-entry.d.ts +0 -95
- package/dist/types.backup/types/segments.d.ts +0 -234
- package/dist/types.backup/types.d.ts +0 -1
- package/dist/types.backup/urls/include-helper.d.ts +0 -17
- package/dist/types.backup/urls/include-provider.d.ts +0 -27
- package/dist/types.backup/urls/index.d.ts +0 -6
- package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
- package/dist/types.backup/urls/path-helper.d.ts +0 -12
- package/dist/types.backup/urls/pattern-types.d.ts +0 -166
- package/dist/types.backup/urls/response-types.d.ts +0 -67
- package/dist/types.backup/urls/type-extraction.d.ts +0 -157
- package/dist/types.backup/urls/urls-function.d.ts +0 -24
- package/dist/types.backup/urls.d.ts +0 -1
- package/dist/types.backup/use-loader.d.ts +0 -150
- package/dist/types.backup/vercel/index.d.ts +0 -10
- package/dist/types.backup/vercel/tracing.d.ts +0 -70
- package/dist/types.backup/vite/debug.d.ts +0 -80
- package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
- package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
- package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
- package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
- package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
- package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
- package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
- package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
- package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
- package/dist/types.backup/vite/discovery/state.d.ts +0 -162
- package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
- package/dist/types.backup/vite/index.d.ts +0 -11
- package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
- package/dist/types.backup/vite/plugin-types.d.ts +0 -298
- package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
- package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
- package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
- package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
- package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
- package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
- package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
- package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
- package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
- package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
- package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
- package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
- package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
- package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
- package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
- package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
- package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
- package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
- package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
- package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
- package/dist/types.backup/vite/rango.d.ts +0 -29
- package/dist/types.backup/vite/router-discovery.d.ts +0 -23
- package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
- package/dist/types.backup/vite/utils/banner.d.ts +0 -2
- package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
- package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
- package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
- package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
- package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
- package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
- package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
- package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build-time utilities for @rangojs/router
|
|
3
|
-
*
|
|
4
|
-
* Note: Route manifest is automatically generated at runtime on first request.
|
|
5
|
-
* These build-time utilities are only needed for advanced use cases like
|
|
6
|
-
* custom tooling or pre-generating manifests.
|
|
7
|
-
*
|
|
8
|
-
* @example Generate manifest programmatically (for custom tooling)
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { generateManifest } from "@rangojs/router/build";
|
|
11
|
-
* import { urlpatterns } from "./urls";
|
|
12
|
-
*
|
|
13
|
-
* // Async: generateManifest awaits any async include() providers
|
|
14
|
-
* // (`() => import("./routes")`) so the split groups appear in the manifest.
|
|
15
|
-
* const manifest = await generateManifest(urlpatterns);
|
|
16
|
-
* console.log(manifest.routeManifest); // { home: "/", about: "/about", ... }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export { generateManifest, generateManifestFull, generateManifestCode, type GeneratedManifest, } from "./generate-manifest.js";
|
|
20
|
-
export { writePerModuleRouteTypes, extractRoutesFromSource, generatePerModuleTypesSource, createScanFilter, type ScanFilter, } from "./generate-route-types.js";
|
|
21
|
-
export { hashParams } from "../prerender/param-hash.js";
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure prefix-tree walks shared by the build/discovery layer and the runtime
|
|
3
|
-
* trie builder. Kept in `build/` (not `vite/utils`) so runtime code
|
|
4
|
-
* (rsc/manifest-init via build/route-trie) can consume them without importing
|
|
5
|
-
* from the vite layer. `vite/utils/manifest-utils` re-exports them so existing
|
|
6
|
-
* vite-side imports stay unchanged.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Flatten prefix tree leaf nodes into precomputed route entries.
|
|
10
|
-
* Leaf nodes have no children (no nested includes), so their routes can be
|
|
11
|
-
* used directly by evaluateLazyEntry() without running the handler.
|
|
12
|
-
* Non-leaf nodes are skipped because they have nested lazy includes that
|
|
13
|
-
* require the handler to run for discovery.
|
|
14
|
-
*
|
|
15
|
-
* A leaf is also skipped when its staticPrefix collides with an ancestor
|
|
16
|
-
* include node's staticPrefix. That happens when a dynamic param collapses the
|
|
17
|
-
* staticPrefix of nested includes onto the parent's (e.g. `/m/:id/edit` -> sp
|
|
18
|
-
* `/m`): precomputing such a leaf under the collapsed prefix would let the
|
|
19
|
-
* ancestor's lazy entry claim a route it cannot register (the route is behind
|
|
20
|
-
* further nested lazy includes), producing a RouteNotFoundError at request time
|
|
21
|
-
* (issue #506). Those routes are resolved via the handler chain instead.
|
|
22
|
-
*/
|
|
23
|
-
export declare function flattenLeafEntries(prefixTree: Record<string, any>, routeManifest: Record<string, string>, result: Array<{
|
|
24
|
-
staticPrefix: string;
|
|
25
|
-
routes: Record<string, string>;
|
|
26
|
-
}>): void;
|
|
27
|
-
/**
|
|
28
|
-
* Build the staticPrefix -> routes lookup the runtime shortcut consumes from a
|
|
29
|
-
* flat precomputed-entry array.
|
|
30
|
-
*
|
|
31
|
-
* A staticPrefix owned by MORE THAN ONE leaf include cannot be collapsed to a
|
|
32
|
-
* single routes object: `new Map(entries.map(e => [e.staticPrefix, e.routes]))`
|
|
33
|
-
* is last-wins, so one include's routes are silently dropped and mis-assigned
|
|
34
|
-
* to whichever entry evaluates first. Two distinct includes legitimately share a
|
|
35
|
-
* staticPrefix when a dynamic param collapses their literal prefixes onto the
|
|
36
|
-
* same value (e.g. `include("/shop/:cat", ...)` and a nested
|
|
37
|
-
* `include("/shop/:brand", ...)` both extract "/shop/"). Merging them is also
|
|
38
|
-
* wrong — assigning the merged set to the first matching entry makes findMatch
|
|
39
|
-
* pick the wrong handler for routes belonging to the other include, which then
|
|
40
|
-
* fails its `Store.manifest.has(routeKey)` invariant at render (500 on a valid
|
|
41
|
-
* route, dev/prod identical).
|
|
42
|
-
*
|
|
43
|
-
* So any shared staticPrefix is OMITTED from the shortcut entirely. Those
|
|
44
|
-
* includes fall through to the handler path in evaluateLazyEntry(), which is the
|
|
45
|
-
* ground truth (identical to pre-precomputed behavior). The shortcut is purely an
|
|
46
|
-
* optimization, so dropping a prefix can only cost a handler run, never change a
|
|
47
|
-
* result.
|
|
48
|
-
*/
|
|
49
|
-
export declare function buildPrecomputedByPrefix(entries: Array<{
|
|
50
|
-
staticPrefix: string;
|
|
51
|
-
routes: Record<string, string>;
|
|
52
|
-
}>): Map<string, Record<string, string>>;
|
|
53
|
-
/**
|
|
54
|
-
* Walk prefix tree to map each route name to its scope's staticPrefix.
|
|
55
|
-
*/
|
|
56
|
-
export declare function buildRouteToStaticPrefix(prefixTree: Record<string, any>, result: Record<string, string>): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
/**
|
|
3
|
-
* Extract route definitions from source code by walking the TypeScript AST.
|
|
4
|
-
* Finds path() and path.json(), path.md(), etc. call expressions and extracts
|
|
5
|
-
* the pattern, name, params, and optional search schema from each.
|
|
6
|
-
* Skips unnamed paths (no { name: "..." }).
|
|
7
|
-
*/
|
|
8
|
-
export declare function extractRoutesFromSource(code: string, sourceFileArg?: ts.SourceFile): Array<{
|
|
9
|
-
name: string;
|
|
10
|
-
pattern: string;
|
|
11
|
-
params?: Record<string, string>;
|
|
12
|
-
search?: Record<string, string>;
|
|
13
|
-
}>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a per-module types file from extracted routes.
|
|
3
|
-
* Output has zero imports, preventing circular references.
|
|
4
|
-
*/
|
|
5
|
-
export declare function generatePerModuleTypesSource(routes: Array<{
|
|
6
|
-
name: string;
|
|
7
|
-
pattern: string;
|
|
8
|
-
params?: Record<string, string>;
|
|
9
|
-
search?: Record<string, string>;
|
|
10
|
-
}>): string;
|
|
11
|
-
/**
|
|
12
|
-
* Generates a .ts file that augments Rango.GeneratedRouteMap
|
|
13
|
-
* with route name -> pattern mappings. This enables Handler<"routeName">
|
|
14
|
-
* without circular references since the file has no imports from the app.
|
|
15
|
-
*/
|
|
16
|
-
export declare function generateRouteTypesSource(routeManifest: Record<string, string>, searchSchemas?: Record<string, Record<string, string>>): string;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
export type UnresolvableReason = "factory-call" | "dynamic-expression" | "unresolvable-import" | "file-not-found";
|
|
3
|
-
export interface UnresolvableInclude {
|
|
4
|
-
pathPrefix: string;
|
|
5
|
-
namePrefix: string | null;
|
|
6
|
-
reason: UnresolvableReason;
|
|
7
|
-
sourceFile: string;
|
|
8
|
-
detail: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Per-scan memo shared across the include-resolution recursion. Keys are
|
|
12
|
-
* absolute file paths; values cache the readFileSync result and the
|
|
13
|
-
* ts.SourceFile parsed from the FULL file source. A separate blockSources map
|
|
14
|
-
* caches parses of extracted sub-blocks (urls() call text), keyed by the exact
|
|
15
|
-
* block string, so the two extractors (routes + includes) for the same block
|
|
16
|
-
* share a single parse.
|
|
17
|
-
*
|
|
18
|
-
* The memo is purely a performance accelerator: same input -> same parse, so
|
|
19
|
-
* generated output is identical to the un-memoized path. A fresh memo is
|
|
20
|
-
* created per top-level scan entry, so stale file edits between scans are never
|
|
21
|
-
* served.
|
|
22
|
-
*/
|
|
23
|
-
export interface ScanMemo {
|
|
24
|
-
files: Map<string, string>;
|
|
25
|
-
blockSourceFiles: Map<string, ts.SourceFile>;
|
|
26
|
-
}
|
|
27
|
-
export declare function createScanMemo(): ScanMemo;
|
|
28
|
-
/**
|
|
29
|
-
* Extract include() calls with diagnostics for unresolvable ones.
|
|
30
|
-
* Returns both resolved includes (identifier second args) and unresolvable
|
|
31
|
-
* includes (factory calls, etc.) with reasons.
|
|
32
|
-
*/
|
|
33
|
-
export declare function extractIncludesWithDiagnostics(code: string, sourceFileArg?: ts.SourceFile): {
|
|
34
|
-
resolved: Array<{
|
|
35
|
-
pathPrefix: string;
|
|
36
|
-
variableName?: string;
|
|
37
|
-
moduleSpecifier?: string;
|
|
38
|
-
namePrefix: string | null;
|
|
39
|
-
}>;
|
|
40
|
-
unresolvable: Array<{
|
|
41
|
-
pathPrefix: string;
|
|
42
|
-
namePrefix: string | null;
|
|
43
|
-
reason: UnresolvableReason;
|
|
44
|
-
detail: string;
|
|
45
|
-
}>;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Find the import statement for a local variable name.
|
|
49
|
-
* Returns the import specifier and the exported name from the source module.
|
|
50
|
-
*/
|
|
51
|
-
export declare function resolveImportedVariable(code: string, localName: string): {
|
|
52
|
-
specifier: string;
|
|
53
|
-
exportedName: string;
|
|
54
|
-
} | null;
|
|
55
|
-
/**
|
|
56
|
-
* Resolve an import specifier relative to the importing file.
|
|
57
|
-
* Strips .js/.mjs/.jsx extensions and tries .ts/.tsx/.js/.jsx candidates.
|
|
58
|
-
*/
|
|
59
|
-
export declare function resolveImportPath(importSpec: string, fromFile: string): string | null;
|
|
60
|
-
/**
|
|
61
|
-
* Build route map and search schemas together.
|
|
62
|
-
* Internal helper used by the include resolution path.
|
|
63
|
-
*
|
|
64
|
-
* @param inlineBlock - Optional pre-extracted code block (e.g. from an inline
|
|
65
|
-
* builder function). When provided, variableName is ignored and the block
|
|
66
|
-
* is parsed directly for path()/include() calls.
|
|
67
|
-
* @param memo - Per-scan readFileSync/parse memo. A fresh one is created at the
|
|
68
|
-
* top-level entry and threaded through the recursion so each file is read and
|
|
69
|
-
* parsed once per scan. Behavior-preserving (same input -> same output).
|
|
70
|
-
*/
|
|
71
|
-
export declare function buildCombinedRouteMapWithSearch(filePath: string, variableName?: string, visited?: Set<string>, diagnosticsOut?: UnresolvableInclude[], inlineBlock?: string, memo?: ScanMemo): {
|
|
72
|
-
routes: Record<string, string>;
|
|
73
|
-
searchSchemas: Record<string, Record<string, string>>;
|
|
74
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract typed params from a route pattern string.
|
|
3
|
-
* Matches `:paramName` and `:paramName?` (optional).
|
|
4
|
-
* Custom regex constraints like `:id(\d+)` are ignored for type purposes.
|
|
5
|
-
*/
|
|
6
|
-
export declare function extractParamsFromPattern(pattern: string): Record<string, string> | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Format a single route entry for codegen output.
|
|
9
|
-
* Routes without search remain plain strings (params are extracted from
|
|
10
|
-
* the pattern at the type level by ExtractParams).
|
|
11
|
-
* Routes with search become objects with path and search fields.
|
|
12
|
-
*/
|
|
13
|
-
export declare function formatRouteEntry(key: string, pattern: string, _params?: Record<string, string>, search?: Record<string, string>): string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ScanFilter } from "./scan-filter.js";
|
|
2
|
-
/**
|
|
3
|
-
* Generate per-module route type files by statically parsing url module source.
|
|
4
|
-
* Scans for files containing `urls(` and writes a sibling `.gen.ts` with the
|
|
5
|
-
* extracted route name/pattern pairs. Only writes when content has changed.
|
|
6
|
-
*/
|
|
7
|
-
export declare function writePerModuleRouteTypes(root: string, filter?: ScanFilter): void;
|
|
8
|
-
/**
|
|
9
|
-
* Find all variable names assigned to urls() calls in source code.
|
|
10
|
-
* e.g. `export const patterns = urls(...)` -> ["patterns"]
|
|
11
|
-
*/
|
|
12
|
-
export declare function findUrlsVariableNames(code: string): string[];
|
|
13
|
-
/**
|
|
14
|
-
* Generate per-module route types for a single url module file.
|
|
15
|
-
* Follows include() calls recursively to produce the full route tree.
|
|
16
|
-
* No-ops if the file doesn't contain `urls(` or has no named routes.
|
|
17
|
-
*/
|
|
18
|
-
export declare function writePerModuleRouteTypesForFile(filePath: string): void;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { ScanFilter } from "./scan-filter.js";
|
|
2
|
-
import { type UnresolvableInclude } from "./include-resolution.js";
|
|
3
|
-
export declare function findNestedRouterConflict(routerFiles: string[]): {
|
|
4
|
-
ancestor: string;
|
|
5
|
-
nested: string;
|
|
6
|
-
} | null;
|
|
7
|
-
export declare function formatNestedRouterConflictError(conflict: {
|
|
8
|
-
ancestor: string;
|
|
9
|
-
nested: string;
|
|
10
|
-
}, prefix?: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Result of extracting URL patterns from a router file.
|
|
13
|
-
* - "variable": a named variable reference (e.g., `.routes(patterns)` or `urls: patterns`)
|
|
14
|
-
* - "inline": an inline builder function (e.g., `.routes(({ path }) => [...])` or `urls: ({ path }) => [...]`)
|
|
15
|
-
*/
|
|
16
|
-
export type UrlsExtractionResult = {
|
|
17
|
-
kind: "variable";
|
|
18
|
-
name: string;
|
|
19
|
-
} | {
|
|
20
|
-
kind: "inline";
|
|
21
|
-
block: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Extract the url patterns from a router file using AST.
|
|
25
|
-
* Detects four patterns:
|
|
26
|
-
* 1. createRouter(...).routes(variableName)
|
|
27
|
-
* 2. createRouter({ urls: variableName, ... })
|
|
28
|
-
* 3. createRouter(...).routes(({ path, ... }) => [...])
|
|
29
|
-
* 4. createRouter({ urls: ({ path, ... }) => [...], ... })
|
|
30
|
-
* Returns either a variable name or an inline code block.
|
|
31
|
-
*/
|
|
32
|
-
export declare function extractUrlsFromRouter(code: string): UrlsExtractionResult | null;
|
|
33
|
-
/**
|
|
34
|
-
* Extract the `basename` string literal from createRouter({ basename: "..." }).
|
|
35
|
-
* Returns the basename value or undefined if not present.
|
|
36
|
-
*/
|
|
37
|
-
export declare function extractBasenameFromRouter(code: string): string | undefined;
|
|
38
|
-
export declare function genFileTsPath(sourceFile: string): string;
|
|
39
|
-
export declare function resolveSearchSchemas(publicRouteNames: string[], runtimeSchemas: Record<string, Record<string, string>> | undefined, sourceFile: string): Record<string, Record<string, string>> | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Resolve routes and search schemas from a router source file by following the
|
|
42
|
-
* variable passed to `.routes(...)` or `urls: ...` in createRouter options,
|
|
43
|
-
* or by parsing an inline builder function directly.
|
|
44
|
-
*/
|
|
45
|
-
export declare function buildCombinedRouteMapForRouterFile(routerFilePath: string): {
|
|
46
|
-
routes: Record<string, string>;
|
|
47
|
-
searchSchemas: Record<string, Record<string, string>>;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Walk the full include tree starting from a router file and detect
|
|
51
|
-
* all includes that the static parser cannot resolve.
|
|
52
|
-
* Returns an array of diagnostics; empty means fully resolvable.
|
|
53
|
-
*/
|
|
54
|
-
export declare function detectUnresolvableIncludes(routerFilePath: string): UnresolvableInclude[];
|
|
55
|
-
/**
|
|
56
|
-
* Walk the include tree for a standalone urls() module file and detect
|
|
57
|
-
* all unresolvable includes. Mirrors detectUnresolvableIncludes() but
|
|
58
|
-
* operates on urls() variable declarations instead of going through
|
|
59
|
-
* createRouter().
|
|
60
|
-
*/
|
|
61
|
-
export declare function detectUnresolvableIncludesForUrlsFile(filePath: string): UnresolvableInclude[];
|
|
62
|
-
/**
|
|
63
|
-
* Scan for files containing createRouter() and return their paths.
|
|
64
|
-
* Call once at startup; the result can be reused on subsequent watcher triggers.
|
|
65
|
-
*/
|
|
66
|
-
export declare function findRouterFiles(root: string, filter?: ScanFilter): string[];
|
|
67
|
-
/**
|
|
68
|
-
* Scan for files containing createHostRouter() and return their paths. Unlike
|
|
69
|
-
* findRouterFiles, this does NOT stop at the first router-root directory -- a host
|
|
70
|
-
* entry typically sits above the sub-app router roots, so the whole tree is scanned.
|
|
71
|
-
*/
|
|
72
|
-
export declare function findHostRouterFiles(root: string, filter?: ScanFilter): string[];
|
|
73
|
-
/**
|
|
74
|
-
* Write named-routes.gen.ts files from static source parsing.
|
|
75
|
-
* Dev-only: provides initial .gen.ts files for IDE types before runtime
|
|
76
|
-
* discovery runs. Must NOT be called during production builds -- runtime
|
|
77
|
-
* discovery in buildStart produces the definitive file.
|
|
78
|
-
*/
|
|
79
|
-
export declare function writeCombinedRouteTypes(root: string, knownRouterFiles?: string[], opts?: {
|
|
80
|
-
preserveIfLarger?: boolean;
|
|
81
|
-
onWrite?: (outPath: string, content: string) => void;
|
|
82
|
-
}): void;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Default exclude patterns for route type scanning. */
|
|
2
|
-
export declare const DEFAULT_EXCLUDE_PATTERNS: string[];
|
|
3
|
-
export type ScanFilter = (absolutePath: string) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Compile include/exclude glob patterns into a single predicate.
|
|
6
|
-
* Paths are made root-relative before matching.
|
|
7
|
-
* Returns undefined when no filtering is needed (no include, default exclude).
|
|
8
|
-
*/
|
|
9
|
-
export declare function createScanFilter(root: string, opts: {
|
|
10
|
-
include?: string[];
|
|
11
|
-
exclude?: string[];
|
|
12
|
-
}): ScanFilter | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Recursively find .ts/.tsx files under a directory, skipping node_modules
|
|
15
|
-
* and .gen. files.
|
|
16
|
-
*/
|
|
17
|
-
export declare function findTsFiles(dir: string, filter?: ScanFilter): string[];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Index of the first match of `pattern` that occurs in code (not in a comment
|
|
3
|
-
* or string), or -1. `pattern` MUST be a global (`/g`) regex. Single native
|
|
4
|
-
* regex sweep with early-exit; O(1) extra memory.
|
|
5
|
-
*/
|
|
6
|
-
export declare function firstCodeMatchIndex(code: string, pattern: RegExp): number;
|
|
7
|
-
/**
|
|
8
|
-
* Byte offsets of every match of `pattern` that occurs in code (not in a
|
|
9
|
-
* comment or string). `pattern` MUST be a global (`/g`) regex. Each offset is
|
|
10
|
-
* the match start — the same byte offset a raw `pattern.exec` reports. O(n)
|
|
11
|
-
* time, O(#matches) memory.
|
|
12
|
-
*/
|
|
13
|
-
export declare function codeMatchIndices(code: string, pattern: RegExp): number[];
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface RuntimeDiscoveryOptions {
|
|
2
|
-
/** Project root directory (where package.json / node_modules live). */
|
|
3
|
-
root: string;
|
|
4
|
-
/** Path to vite.config.ts. Auto-detected from root if omitted. */
|
|
5
|
-
configFile?: string;
|
|
6
|
-
/** Absolute path to the router entry file. */
|
|
7
|
-
entry: string;
|
|
8
|
-
/** Override resolve.alias (skips loading from vite config when provided). */
|
|
9
|
-
resolveAlias?: Record<string, string>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Standalone Vite-based route discovery for the CLI.
|
|
13
|
-
* Creates a temporary Vite server with the RSC plugin, imports the entry via
|
|
14
|
-
* the module runner, reads the RouterRegistry, generates manifests, and writes
|
|
15
|
-
* named-routes.gen.ts files.
|
|
16
|
-
*
|
|
17
|
-
* This mirrors the logic in the Vite plugin's discoverRouters() + writeRouteTypesFiles()
|
|
18
|
-
* but without coupling to plugin closure state.
|
|
19
|
-
*/
|
|
20
|
-
export declare function discoverAndWriteRouteTypes(opts: RuntimeDiscoveryOptions): Promise<{
|
|
21
|
-
routerCount: number;
|
|
22
|
-
routeCount: number;
|
|
23
|
-
outputFiles: string[];
|
|
24
|
-
}>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Background Task Runner
|
|
3
|
-
*
|
|
4
|
-
* Unified helper for scheduling async work via waitUntil.
|
|
5
|
-
* When waitUntil is unavailable, falls back to blocking or skipping.
|
|
6
|
-
*/
|
|
7
|
-
interface WaitUntilHost {
|
|
8
|
-
waitUntil?: (fn: () => Promise<void>) => void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Schedule an async task in the background via waitUntil.
|
|
12
|
-
*
|
|
13
|
-
* @param host - Object with optional waitUntil (request context or similar)
|
|
14
|
-
* @param task - Async function to execute
|
|
15
|
-
* @param blockWhenNoWaitUntil - If true, awaits the task when waitUntil is
|
|
16
|
-
* unavailable (e.g., Node.js dev server). If false (default), the task
|
|
17
|
-
* is silently skipped when waitUntil is unavailable.
|
|
18
|
-
* @returns A promise when blocking fallback is used, void otherwise.
|
|
19
|
-
*/
|
|
20
|
-
export declare function runBackground(host: WaitUntilHost | null | undefined, task: () => Promise<void>, blockWhenNoWaitUntil?: boolean): Promise<void> | void;
|
|
21
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache error reporting.
|
|
3
|
-
*
|
|
4
|
-
* Caches are best-effort: a read failure degrades to a miss (render fresh) and a
|
|
5
|
-
* write failure degrades to a no-op - they MUST NOT throw up and fail the
|
|
6
|
-
* request. But the failure must still be LOUD: it is logged to the console (so
|
|
7
|
-
* it is visible even in a background waitUntil task or when no hook is wired)
|
|
8
|
-
* AND routed through the router's onError callback (via the request context's
|
|
9
|
-
* deduped _reportBackgroundError) so consumers can observe cache degradation in
|
|
10
|
-
* their own telemetry.
|
|
11
|
-
*
|
|
12
|
-
* The one deliberate exception is the invalidation WRITE verb (updateTag ->
|
|
13
|
-
* store.invalidateTags): a failed durable marker write is rejected so an awaited
|
|
14
|
-
* updateTag() surfaces it (read-your-own-writes honesty). That is not a data
|
|
15
|
-
* read/write and does not go through this helper's swallow-and-degrade path.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Minimal shape of a request context for error reporting. Passed explicitly by
|
|
19
|
-
* background tasks (waitUntil) where the ALS context is already gone, so the
|
|
20
|
-
* error can still reach the router's onError. Structural to avoid importing the
|
|
21
|
-
* full RequestContext type (request-context.ts imports CacheErrorCategory from
|
|
22
|
-
* here - a mutual type-only reference).
|
|
23
|
-
*/
|
|
24
|
-
export interface CacheErrorReporter {
|
|
25
|
-
_reportBackgroundError?: (error: unknown, category: CacheErrorCategory) => void;
|
|
26
|
-
}
|
|
27
|
-
export type CacheErrorCategory =
|
|
28
|
-
/** A read failed (transient infra: KV/Cache API error). Degrade to a miss. */
|
|
29
|
-
"cache-read"
|
|
30
|
-
/** A write failed. Degrade to a no-op (entry simply not cached). */
|
|
31
|
-
| "cache-write"
|
|
32
|
-
/** A delete/eviction failed. Best-effort. */
|
|
33
|
-
| "cache-delete"
|
|
34
|
-
/**
|
|
35
|
-
* A STORED entry could not be parsed/deserialized (partial KV read, truncated
|
|
36
|
-
* Cache API body, malformed envelope/RSC payload). The entry is faulty and is
|
|
37
|
-
* evicted so subsequent reads do not keep failing on it. Distinct from
|
|
38
|
-
* cache-read so consumers can tell corruption from a transient outage.
|
|
39
|
-
*/
|
|
40
|
-
| "cache-corrupt"
|
|
41
|
-
/** A tag-invalidation side effect failed (e.g. the eager CDN purge hook). */
|
|
42
|
-
| "cache-invalidate"
|
|
43
|
-
/**
|
|
44
|
-
* A background stale-while-revalidate refresh failed (the `"use cache"`
|
|
45
|
-
* read-through path). The stale value was already served; the refresh that
|
|
46
|
-
* would have replaced it errored.
|
|
47
|
-
*/
|
|
48
|
-
| "stale-revalidation";
|
|
49
|
-
/**
|
|
50
|
-
* Report a non-fatal cache error loudly without failing the request: always logs
|
|
51
|
-
* (label + error) and, when a request context is available, routes the error
|
|
52
|
-
* through the router's onError callback. Never throws.
|
|
53
|
-
*
|
|
54
|
-
* `ctx` is for callers running in a detached background task (waitUntil), where
|
|
55
|
-
* the ALS request context is already gone (so `_getRequestContext()` is null):
|
|
56
|
-
* they capture the context up front and pass it here so onError still fires.
|
|
57
|
-
* Foreground callers omit it and fall back to the ALS context.
|
|
58
|
-
*/
|
|
59
|
-
export declare function reportCacheError(error: unknown, category: CacheErrorCategory, label: string, ctx?: CacheErrorReporter): void;
|
|
60
|
-
/**
|
|
61
|
-
* Run a best-effort async cache task (typically scheduled via waitUntil), catching
|
|
62
|
-
* any rejection and routing it through reportCacheError so background cache work
|
|
63
|
-
* (non-blocking L1 writes, KV persistence, L1 promotion) reports failures via
|
|
64
|
-
* onError instead of throwing or silently swallowing. Never rejects.
|
|
65
|
-
*
|
|
66
|
-
* Pass `ctx` when the task runs detached (the ALS context is gone) and the
|
|
67
|
-
* failure should still reach onError; omit it to fall back to the ALS context.
|
|
68
|
-
*
|
|
69
|
-
* @example this.waitUntil(() => reportingAsync(() => cache.put(req, res), "cache-write", "[CFCacheStore] L1 write"))
|
|
70
|
-
*/
|
|
71
|
-
export declare function reportingAsync(task: () => Promise<unknown>, category: CacheErrorCategory, label: string, ctx?: CacheErrorReporter): Promise<void>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared Cache Key Utilities
|
|
3
|
-
*
|
|
4
|
-
* Deterministic normalization of search params and route params
|
|
5
|
-
* for cache key generation. Used by cache-runtime, cache-scope,
|
|
6
|
-
* document-cache, and loader-cache.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Build a sorted, deterministic query string from URLSearchParams,
|
|
10
|
-
* excluding the router's reserved params (see isReservedSearchParam).
|
|
11
|
-
*
|
|
12
|
-
* Returns empty string when no user-facing params exist.
|
|
13
|
-
*/
|
|
14
|
-
export declare function sortedSearchString(searchParams: URLSearchParams): string;
|
|
15
|
-
/**
|
|
16
|
-
* Build a sorted, deterministic string from route params.
|
|
17
|
-
*
|
|
18
|
-
* Returns empty string when params is empty or undefined.
|
|
19
|
-
*/
|
|
20
|
-
export declare function sortedRouteParams(params: Record<string, string> | undefined): string;
|
|
21
|
-
/**
|
|
22
|
-
* Host-namespaced cache key base: `${host}${pathname}[:params][?search]`.
|
|
23
|
-
*
|
|
24
|
-
* The ONE composition of the host-namespacing rule, shared by the segment tier
|
|
25
|
-
* (cache-scope.ts) and the document tier (document-cache.ts) so the rule cannot
|
|
26
|
-
* drift between them. Host prefixing matters because VercelCacheStore /
|
|
27
|
-
* MemorySegmentCacheStore key by the raw string (only CFCacheStore adds host
|
|
28
|
-
* internally) -- on a single function serving multiple domains an
|
|
29
|
-
* un-namespaced key bleeds tenant A's cached response to tenant B.
|
|
30
|
-
*
|
|
31
|
-
* Output is BYTE-STABLE by contract: changing the composition silently
|
|
32
|
-
* invalidates every persisted cache entry on upgrade. Callers append their own
|
|
33
|
-
* tier-specific suffixes (`:rsc`/`:html`, segment hash) after this base.
|
|
34
|
-
*/
|
|
35
|
-
export declare function cacheKeyBase(host: string, pathname: string, searchParams?: URLSearchParams, params?: Record<string, string>): string;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared Cache Policy Utilities
|
|
3
|
-
*
|
|
4
|
-
* Resolution cascades for TTL, SWR, cache key, and cache store.
|
|
5
|
-
* Consolidates the multi-tier resolution pattern:
|
|
6
|
-
* explicit option → store defaults → fallback constant
|
|
7
|
-
*/
|
|
8
|
-
import type { CacheDefaults, SegmentCacheStore } from "./types.js";
|
|
9
|
-
import type { RequestContext } from "../server/request-context.js";
|
|
10
|
-
/**
|
|
11
|
-
* Default TTL for route-level cache() DSL and loader cache.
|
|
12
|
-
* Applied when neither the cache options nor the store defaults specify a TTL.
|
|
13
|
-
*/
|
|
14
|
-
export declare const DEFAULT_ROUTE_TTL = 60;
|
|
15
|
-
/**
|
|
16
|
-
* Default TTL for function-level "use cache" (setItem).
|
|
17
|
-
* Applied when neither the item options nor the store defaults specify a TTL.
|
|
18
|
-
*/
|
|
19
|
-
export declare const DEFAULT_FUNCTION_TTL = 900;
|
|
20
|
-
/**
|
|
21
|
-
* A finite, non-negative seconds value? A NaN/Infinity ttl/swr (from a bad
|
|
22
|
-
* cache() option or store defaults) flows into computeExpiration ->
|
|
23
|
-
* staleAt/expiresAt = NaN, where every `now > NaN` is false so the entry never
|
|
24
|
-
* evicts and is served fresh forever; a negative value makes every read a miss.
|
|
25
|
-
* Shared with cache-scope.ts (the segment getters) so every cache path validates
|
|
26
|
-
* the same way. profile-registry.ts uses the same predicate but fails fast at
|
|
27
|
-
* config time; the resolvers here degrade because they run on the live path.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isFiniteNonNegativeSeconds(value: number): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Resolve effective TTL from the 3-tier cascade:
|
|
32
|
-
* explicit → store defaults → fallback. A non-finite/negative resolved value
|
|
33
|
-
* degrades to the fallback (loader cache and "use cache" setItem both resolve
|
|
34
|
-
* ttl here, so this is where those paths are guarded; the segment cache is
|
|
35
|
-
* guarded in cache-scope.ts).
|
|
36
|
-
*/
|
|
37
|
-
export declare function resolveTtl(explicit: number | undefined, defaults: CacheDefaults | undefined, fallback: number): number;
|
|
38
|
-
/**
|
|
39
|
-
* Resolve effective SWR window from the 2-tier cascade:
|
|
40
|
-
* explicit → store defaults.
|
|
41
|
-
* Returns 0 when unset (no SWR window) or when the resolved value is
|
|
42
|
-
* non-finite/negative (degrade rather than feed bad math into expiry).
|
|
43
|
-
*/
|
|
44
|
-
export declare function resolveSwrWindow(explicit: number | undefined, defaults: CacheDefaults | undefined): number;
|
|
45
|
-
/**
|
|
46
|
-
* Compute staleAt and expiresAt timestamps from TTL and SWR window.
|
|
47
|
-
*
|
|
48
|
-
* - staleAt: when the entry becomes stale (TTL boundary)
|
|
49
|
-
* - expiresAt: when the entry should be evicted (TTL + SWR)
|
|
50
|
-
*
|
|
51
|
-
* When swrWindow is 0, staleAt === expiresAt (no SWR).
|
|
52
|
-
*/
|
|
53
|
-
export declare function computeExpiration(ttlSeconds: number, swrSeconds?: number): {
|
|
54
|
-
staleAt: number;
|
|
55
|
-
expiresAt: number;
|
|
56
|
-
};
|
|
57
|
-
export declare function resolveCacheKey(keyFn: ((ctx: RequestContext) => string | Promise<string>) | undefined, store: SegmentCacheStore | null, defaultKey: string, _label: string): Promise<string>;
|
|
58
|
-
export declare function resolveTagsOption<TEnv>(tags: string[] | ((ctx: RequestContext<TEnv>) => string[]) | undefined, ctx: RequestContext<TEnv> | undefined, label: string): string[] | undefined;
|
|
59
|
-
export declare function resolveCacheStore(explicitStore: SegmentCacheStore | undefined): SegmentCacheStore | null;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* "use cache" Runtime
|
|
3
|
-
*
|
|
4
|
-
* Provides the runtime wrapper for functions marked with "use cache" directive.
|
|
5
|
-
* The Vite transform plugin wraps exports with registerCachedFunction().
|
|
6
|
-
*
|
|
7
|
-
* On cache miss: executes the function, serializes the result via RSC Flight
|
|
8
|
-
* protocol, captures handle data if tainted ctx is detected, and stores in
|
|
9
|
-
* the SegmentCacheStore.
|
|
10
|
-
*
|
|
11
|
-
* On cache hit: deserializes the cached result, restores handle data if present.
|
|
12
|
-
*
|
|
13
|
-
* On stale hit: returns stale data immediately, triggers background
|
|
14
|
-
* re-execution via waitUntil().
|
|
15
|
-
*/
|
|
16
|
-
import { isCachedFunction } from "./taint.js";
|
|
17
|
-
export { isCachedFunction };
|
|
18
|
-
/**
|
|
19
|
-
* Convert encodeReply result to a stable string key.
|
|
20
|
-
*
|
|
21
|
-
* encodeReply may return a string or FormData. A plain string is already
|
|
22
|
-
* deterministic for a given arg set, so return it verbatim. FormData (emitted
|
|
23
|
-
* whenever a key arg is a typed array / Blob / File / a large object React
|
|
24
|
-
* lazily chunks) carries a per-call RANDOM multipart boundary
|
|
25
|
-
* (`formdata-undici-<random>`); stringifying the whole body via
|
|
26
|
-
* `new Response(formData).text()` would therefore produce a DIFFERENT key on
|
|
27
|
-
* every call, so the cached function would always miss and the store would
|
|
28
|
-
* accumulate one duplicate entry per call (unbounded growth).
|
|
29
|
-
*
|
|
30
|
-
* Instead derive the key from the entries themselves, independent of the
|
|
31
|
-
* boundary: iterate in sorted-key order and, for each value, emit a
|
|
32
|
-
* boundary-free token — `s:<value>` for strings, `b:<size>:<type>:<name>:<hash>`
|
|
33
|
-
* for Blob/File (bytes folded via djb2 so distinct payloads of equal
|
|
34
|
-
* size/type/name still differ). Strings carry an `s:` type tag so a string whose
|
|
35
|
-
* value happens to equal a blob token (e.g. the literal `b:4::a:b:<hash>`) cannot
|
|
36
|
-
* collide with an actual Blob/File entry under the same FormData key. The
|
|
37
|
-
* user-controlled `type`/`name` are percent-encoded before joining so an embedded
|
|
38
|
-
* `:` cannot shift the field boundaries and collide two distinct files (e.g.
|
|
39
|
-
* {name:"a:b",type:""} vs {name:"b",type:":a"}). The result is stable across
|
|
40
|
-
* identical arg sets.
|
|
41
|
-
*/
|
|
42
|
-
export declare function replyToCacheKey(encoded: string | FormData): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Register a function as a cached function.
|
|
45
|
-
* Called by the Vite transform for each "use cache" function.
|
|
46
|
-
*
|
|
47
|
-
* @param fn - The original async function
|
|
48
|
-
* @param id - Stable identifier (module path + export name)
|
|
49
|
-
* @param profileName - Cache profile name (from "use cache: profileName" or "default")
|
|
50
|
-
*/
|
|
51
|
-
export declare function registerCachedFunction<T extends (...args: any[]) => any>(fn: T, id: string, profileName: string): T;
|