@rangojs/router 0.0.0-experimental.8 → 0.0.0-experimental.80daa23e
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/AGENTS.md +13 -0
- package/README.md +472 -7
- package/dist/__internal.d.ts +83 -0
- package/dist/__internal.d.ts.map +1 -0
- package/dist/__internal.js +19 -0
- package/dist/__internal.js.map +1 -0
- package/dist/__mocks__/version.d.ts +7 -0
- package/dist/__mocks__/version.d.ts.map +1 -0
- package/dist/__mocks__/version.js +7 -0
- package/dist/__mocks__/version.js.map +1 -0
- package/dist/__tests__/client-href.test.d.ts +2 -0
- package/dist/__tests__/client-href.test.d.ts.map +1 -0
- package/dist/__tests__/client-href.test.js +74 -0
- package/dist/__tests__/client-href.test.js.map +1 -0
- package/dist/__tests__/component-utils.test.d.ts +2 -0
- package/dist/__tests__/component-utils.test.d.ts.map +1 -0
- package/dist/__tests__/component-utils.test.js +51 -0
- package/dist/__tests__/component-utils.test.js.map +1 -0
- package/dist/__tests__/event-controller.test.d.ts +2 -0
- package/dist/__tests__/event-controller.test.d.ts.map +1 -0
- package/dist/__tests__/event-controller.test.js +538 -0
- package/dist/__tests__/event-controller.test.js.map +1 -0
- package/dist/__tests__/helpers/route-tree.d.ts +118 -0
- package/dist/__tests__/helpers/route-tree.d.ts.map +1 -0
- package/dist/__tests__/helpers/route-tree.js +374 -0
- package/dist/__tests__/helpers/route-tree.js.map +1 -0
- package/dist/__tests__/match-result.test.d.ts +2 -0
- package/dist/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/__tests__/match-result.test.js +154 -0
- package/dist/__tests__/match-result.test.js.map +1 -0
- package/dist/__tests__/navigation-store.test.d.ts +2 -0
- package/dist/__tests__/navigation-store.test.d.ts.map +1 -0
- package/dist/__tests__/navigation-store.test.js +440 -0
- package/dist/__tests__/navigation-store.test.js.map +1 -0
- package/dist/__tests__/partial-update.test.d.ts +2 -0
- package/dist/__tests__/partial-update.test.d.ts.map +1 -0
- package/dist/__tests__/partial-update.test.js +1009 -0
- package/dist/__tests__/partial-update.test.js.map +1 -0
- package/dist/__tests__/reverse-types.test.d.ts +8 -0
- package/dist/__tests__/reverse-types.test.d.ts.map +1 -0
- package/dist/__tests__/reverse-types.test.js +656 -0
- package/dist/__tests__/reverse-types.test.js.map +1 -0
- package/dist/__tests__/route-definition.test.d.ts +2 -0
- package/dist/__tests__/route-definition.test.d.ts.map +1 -0
- package/dist/__tests__/route-definition.test.js +55 -0
- package/dist/__tests__/route-definition.test.js.map +1 -0
- package/dist/__tests__/router-helpers.test.d.ts +2 -0
- package/dist/__tests__/router-helpers.test.d.ts.map +1 -0
- package/dist/__tests__/router-helpers.test.js +377 -0
- package/dist/__tests__/router-helpers.test.js.map +1 -0
- package/dist/__tests__/router-integration-2.test.d.ts +2 -0
- package/dist/__tests__/router-integration-2.test.d.ts.map +1 -0
- package/dist/__tests__/router-integration-2.test.js +426 -0
- package/dist/__tests__/router-integration-2.test.js.map +1 -0
- package/dist/__tests__/router-integration.test.d.ts +2 -0
- package/dist/__tests__/router-integration.test.d.ts.map +1 -0
- package/dist/__tests__/router-integration.test.js +1051 -0
- package/dist/__tests__/router-integration.test.js.map +1 -0
- package/dist/__tests__/search-params.test.d.ts +5 -0
- package/dist/__tests__/search-params.test.d.ts.map +1 -0
- package/dist/__tests__/search-params.test.js +306 -0
- package/dist/__tests__/search-params.test.js.map +1 -0
- package/dist/__tests__/segment-system.test.d.ts +2 -0
- package/dist/__tests__/segment-system.test.d.ts.map +1 -0
- package/dist/__tests__/segment-system.test.js +627 -0
- package/dist/__tests__/segment-system.test.js.map +1 -0
- package/dist/__tests__/static-handler-types.test.d.ts +8 -0
- package/dist/__tests__/static-handler-types.test.d.ts.map +1 -0
- package/dist/__tests__/static-handler-types.test.js +63 -0
- package/dist/__tests__/static-handler-types.test.js.map +1 -0
- package/dist/__tests__/urls.test.d.ts +2 -0
- package/dist/__tests__/urls.test.d.ts.map +1 -0
- package/dist/__tests__/urls.test.js +421 -0
- package/dist/__tests__/urls.test.js.map +1 -0
- package/dist/__tests__/use-mount.test.d.ts +2 -0
- package/dist/__tests__/use-mount.test.d.ts.map +1 -0
- package/dist/__tests__/use-mount.test.js +35 -0
- package/dist/__tests__/use-mount.test.js.map +1 -0
- package/dist/bin/rango.d.ts +2 -0
- package/dist/bin/rango.d.ts.map +1 -0
- package/dist/bin/rango.js +2343 -0
- package/dist/bin/rango.js.map +1 -0
- package/dist/browser/event-controller.d.ts +191 -0
- package/dist/browser/event-controller.d.ts.map +1 -0
- package/dist/browser/event-controller.js +559 -0
- package/dist/browser/event-controller.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/link-interceptor.d.ts +38 -0
- package/dist/browser/link-interceptor.d.ts.map +1 -0
- package/dist/browser/link-interceptor.js +99 -0
- package/dist/browser/link-interceptor.js.map +1 -0
- package/dist/browser/logging.d.ts +10 -0
- package/dist/browser/logging.d.ts.map +1 -0
- package/dist/browser/logging.js +29 -0
- package/dist/browser/logging.js.map +1 -0
- package/dist/browser/lru-cache.d.ts +17 -0
- package/dist/browser/lru-cache.d.ts.map +1 -0
- package/dist/browser/lru-cache.js +50 -0
- package/dist/browser/lru-cache.js.map +1 -0
- package/dist/browser/merge-segment-loaders.d.ts +39 -0
- package/dist/browser/merge-segment-loaders.d.ts.map +1 -0
- package/dist/browser/merge-segment-loaders.js +102 -0
- package/dist/browser/merge-segment-loaders.js.map +1 -0
- package/dist/browser/navigation-bridge.d.ts +102 -0
- package/dist/browser/navigation-bridge.d.ts.map +1 -0
- package/dist/browser/navigation-bridge.js +708 -0
- package/dist/browser/navigation-bridge.js.map +1 -0
- package/dist/browser/navigation-client.d.ts +25 -0
- package/dist/browser/navigation-client.d.ts.map +1 -0
- package/dist/browser/navigation-client.js +157 -0
- package/dist/browser/navigation-client.js.map +1 -0
- package/dist/browser/navigation-store.d.ts +101 -0
- package/dist/browser/navigation-store.d.ts.map +1 -0
- package/dist/browser/navigation-store.js +625 -0
- package/dist/browser/navigation-store.js.map +1 -0
- package/dist/browser/partial-update.d.ts +75 -0
- package/dist/browser/partial-update.d.ts.map +1 -0
- package/dist/browser/partial-update.js +426 -0
- package/dist/browser/partial-update.js.map +1 -0
- package/dist/browser/react/Link.d.ts +86 -0
- package/dist/browser/react/Link.d.ts.map +1 -0
- package/dist/browser/react/Link.js +128 -0
- package/dist/browser/react/Link.js.map +1 -0
- package/dist/browser/react/NavigationProvider.d.ts +63 -0
- package/dist/browser/react/NavigationProvider.d.ts.map +1 -0
- package/dist/browser/react/NavigationProvider.js +216 -0
- package/dist/browser/react/NavigationProvider.js.map +1 -0
- package/dist/browser/react/ScrollRestoration.d.ts +75 -0
- package/dist/browser/react/ScrollRestoration.d.ts.map +1 -0
- package/dist/browser/react/ScrollRestoration.js +57 -0
- package/dist/browser/react/ScrollRestoration.js.map +1 -0
- package/dist/browser/react/context.d.ts +46 -0
- package/dist/browser/react/context.d.ts.map +1 -0
- package/dist/browser/react/context.js +10 -0
- package/dist/browser/react/context.js.map +1 -0
- package/dist/browser/react/index.d.ts +11 -0
- package/dist/browser/react/index.d.ts.map +1 -0
- package/dist/browser/react/index.js +22 -0
- package/dist/browser/react/index.js.map +1 -0
- package/dist/browser/react/location-state-shared.d.ts +63 -0
- package/dist/browser/react/location-state-shared.d.ts.map +1 -0
- package/dist/browser/react/location-state-shared.js +81 -0
- package/dist/browser/react/location-state-shared.js.map +1 -0
- package/dist/browser/react/location-state.d.ts +23 -0
- package/dist/browser/react/location-state.d.ts.map +1 -0
- package/dist/browser/react/location-state.js +29 -0
- package/dist/browser/react/location-state.js.map +1 -0
- package/dist/browser/react/mount-context.d.ts +24 -0
- package/dist/browser/react/mount-context.d.ts.map +1 -0
- package/dist/browser/react/mount-context.js +24 -0
- package/dist/browser/react/mount-context.js.map +1 -0
- package/dist/browser/react/use-action.d.ts +64 -0
- package/dist/browser/react/use-action.d.ts.map +1 -0
- package/dist/browser/react/use-action.js +134 -0
- package/dist/browser/react/use-action.js.map +1 -0
- package/dist/browser/react/use-client-cache.d.ts +41 -0
- package/dist/browser/react/use-client-cache.d.ts.map +1 -0
- package/{src/browser/react/use-client-cache.ts → dist/browser/react/use-client-cache.js} +9 -26
- package/dist/browser/react/use-client-cache.js.map +1 -0
- package/dist/browser/react/use-handle.d.ts +31 -0
- package/dist/browser/react/use-handle.d.ts.map +1 -0
- package/dist/browser/react/use-handle.js +144 -0
- package/dist/browser/react/use-handle.js.map +1 -0
- package/dist/browser/react/use-href.d.ts +33 -0
- package/dist/browser/react/use-href.d.ts.map +1 -0
- package/dist/browser/react/use-href.js +39 -0
- package/dist/browser/react/use-href.js.map +1 -0
- package/dist/browser/react/use-link-status.d.ts +37 -0
- package/dist/browser/react/use-link-status.d.ts.map +1 -0
- package/dist/browser/react/use-link-status.js +99 -0
- package/dist/browser/react/use-link-status.js.map +1 -0
- package/dist/browser/react/use-mount.d.ts +25 -0
- package/dist/browser/react/use-mount.d.ts.map +1 -0
- package/dist/browser/react/use-mount.js +30 -0
- package/dist/browser/react/use-mount.js.map +1 -0
- package/dist/browser/react/use-navigation.d.ts +27 -0
- package/dist/browser/react/use-navigation.d.ts.map +1 -0
- package/dist/browser/react/use-navigation.js +87 -0
- package/dist/browser/react/use-navigation.js.map +1 -0
- package/dist/browser/react/use-segments.d.ts +38 -0
- package/dist/browser/react/use-segments.d.ts.map +1 -0
- package/dist/browser/react/use-segments.js +130 -0
- package/dist/browser/react/use-segments.js.map +1 -0
- package/dist/browser/request-controller.d.ts +26 -0
- package/dist/browser/request-controller.d.ts.map +1 -0
- package/dist/browser/request-controller.js +147 -0
- package/dist/browser/request-controller.js.map +1 -0
- package/dist/browser/rsc-router.d.ts +129 -0
- package/dist/browser/rsc-router.d.ts.map +1 -0
- package/dist/browser/rsc-router.js +195 -0
- package/dist/browser/rsc-router.js.map +1 -0
- package/dist/browser/scroll-restoration.d.ts +93 -0
- package/dist/browser/scroll-restoration.d.ts.map +1 -0
- package/dist/browser/scroll-restoration.js +321 -0
- package/dist/browser/scroll-restoration.js.map +1 -0
- package/dist/browser/segment-structure-assert.d.ts +17 -0
- package/dist/browser/segment-structure-assert.d.ts.map +1 -0
- package/dist/browser/segment-structure-assert.js +59 -0
- package/dist/browser/segment-structure-assert.js.map +1 -0
- package/dist/browser/server-action-bridge.d.ts +26 -0
- package/dist/browser/server-action-bridge.d.ts.map +1 -0
- package/dist/browser/server-action-bridge.js +668 -0
- package/dist/browser/server-action-bridge.js.map +1 -0
- package/dist/browser/shallow.d.ts +12 -0
- package/dist/browser/shallow.d.ts.map +1 -0
- package/dist/browser/shallow.js +34 -0
- package/dist/browser/shallow.js.map +1 -0
- package/dist/browser/types.d.ts +369 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/build/__tests__/generate-cli.test.d.ts +2 -0
- package/dist/build/__tests__/generate-cli.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-cli.test.js +237 -0
- package/dist/build/__tests__/generate-cli.test.js.map +1 -0
- package/dist/build/__tests__/generate-manifest.test.d.ts +2 -0
- package/dist/build/__tests__/generate-manifest.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-manifest.test.js +119 -0
- package/dist/build/__tests__/generate-manifest.test.js.map +1 -0
- package/dist/build/__tests__/generate-route-types.test.d.ts +2 -0
- package/dist/build/__tests__/generate-route-types.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-route-types.test.js +620 -0
- package/dist/build/__tests__/generate-route-types.test.js.map +1 -0
- package/dist/build/__tests__/per-router-manifest.test.d.ts +2 -0
- package/dist/build/__tests__/per-router-manifest.test.d.ts.map +1 -0
- package/dist/build/__tests__/per-router-manifest.test.js +308 -0
- package/dist/build/__tests__/per-router-manifest.test.js.map +1 -0
- package/dist/build/generate-manifest.d.ts +81 -0
- package/dist/build/generate-manifest.d.ts.map +1 -0
- package/dist/build/generate-manifest.js +276 -0
- package/dist/build/generate-manifest.js.map +1 -0
- package/dist/build/generate-route-types.d.ts +115 -0
- package/dist/build/generate-route-types.d.ts.map +1 -0
- package/dist/build/generate-route-types.js +740 -0
- package/dist/build/generate-route-types.js.map +1 -0
- package/dist/build/index.d.ts +21 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +21 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/route-trie.d.ts +71 -0
- package/dist/build/route-trie.d.ts.map +1 -0
- package/dist/build/route-trie.js +175 -0
- package/dist/build/route-trie.js.map +1 -0
- package/dist/cache/__tests__/cache-scope.test.d.ts +2 -0
- package/dist/cache/__tests__/cache-scope.test.d.ts.map +1 -0
- package/dist/cache/__tests__/cache-scope.test.js +208 -0
- package/dist/cache/__tests__/cache-scope.test.js.map +1 -0
- package/dist/cache/__tests__/document-cache.test.d.ts +2 -0
- package/dist/cache/__tests__/document-cache.test.d.ts.map +1 -0
- package/dist/cache/__tests__/document-cache.test.js +345 -0
- package/dist/cache/__tests__/document-cache.test.js.map +1 -0
- package/dist/cache/__tests__/memory-segment-store.test.d.ts +2 -0
- package/dist/cache/__tests__/memory-segment-store.test.d.ts.map +1 -0
- package/dist/cache/__tests__/memory-segment-store.test.js +425 -0
- package/dist/cache/__tests__/memory-segment-store.test.js.map +1 -0
- package/dist/cache/__tests__/memory-store.test.d.ts +2 -0
- package/dist/cache/__tests__/memory-store.test.d.ts.map +1 -0
- package/dist/cache/__tests__/memory-store.test.js +367 -0
- package/dist/cache/__tests__/memory-store.test.js.map +1 -0
- package/dist/cache/cache-scope.d.ts +102 -0
- package/dist/cache/cache-scope.d.ts.map +1 -0
- package/dist/cache/cache-scope.js +440 -0
- package/dist/cache/cache-scope.js.map +1 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts +2 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts.map +1 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.js +330 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.js.map +1 -0
- package/dist/cache/cf/cf-cache-store.d.ts +165 -0
- package/dist/cache/cf/cf-cache-store.d.ts.map +1 -0
- package/dist/cache/cf/cf-cache-store.js +242 -0
- package/dist/cache/cf/cf-cache-store.js.map +1 -0
- package/dist/cache/cf/index.d.ts +14 -0
- package/dist/cache/cf/index.d.ts.map +1 -0
- package/dist/cache/cf/index.js +17 -0
- package/dist/cache/cf/index.js.map +1 -0
- package/dist/cache/document-cache.d.ts +64 -0
- package/dist/cache/document-cache.d.ts.map +1 -0
- package/dist/cache/document-cache.js +228 -0
- package/dist/cache/document-cache.js.map +1 -0
- package/dist/cache/index.d.ts +19 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +21 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/memory-segment-store.d.ts +110 -0
- package/dist/cache/memory-segment-store.d.ts.map +1 -0
- package/dist/cache/memory-segment-store.js +117 -0
- package/dist/cache/memory-segment-store.js.map +1 -0
- package/dist/cache/memory-store.d.ts +41 -0
- package/dist/cache/memory-store.d.ts.map +1 -0
- package/dist/cache/memory-store.js +191 -0
- package/dist/cache/memory-store.js.map +1 -0
- package/dist/cache/types.d.ts +317 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +12 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/client.d.ts +248 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +367 -0
- package/dist/client.js.map +1 -0
- package/dist/client.rsc.d.ts +26 -0
- package/dist/client.rsc.d.ts.map +1 -0
- package/dist/client.rsc.js +46 -0
- package/dist/client.rsc.js.map +1 -0
- package/dist/component-utils.d.ts +36 -0
- package/dist/component-utils.d.ts.map +1 -0
- package/dist/component-utils.js +61 -0
- package/dist/component-utils.js.map +1 -0
- package/dist/components/DefaultDocument.d.ts +13 -0
- package/dist/components/DefaultDocument.d.ts.map +1 -0
- package/dist/components/DefaultDocument.js +15 -0
- package/dist/components/DefaultDocument.js.map +1 -0
- package/dist/debug.d.ts +58 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +157 -0
- package/dist/debug.js.map +1 -0
- package/dist/default-error-boundary.d.ts +11 -0
- package/dist/default-error-boundary.d.ts.map +1 -0
- package/dist/default-error-boundary.js +45 -0
- package/dist/default-error-boundary.js.map +1 -0
- package/dist/deps/browser.d.ts +2 -0
- package/dist/deps/browser.d.ts.map +1 -0
- package/dist/deps/browser.js +3 -0
- package/dist/deps/browser.js.map +1 -0
- package/dist/deps/html-stream-client.d.ts +2 -0
- package/dist/deps/html-stream-client.d.ts.map +1 -0
- package/dist/deps/html-stream-client.js +3 -0
- package/dist/deps/html-stream-client.js.map +1 -0
- package/dist/deps/html-stream-server.d.ts +2 -0
- package/dist/deps/html-stream-server.d.ts.map +1 -0
- package/dist/deps/html-stream-server.js +3 -0
- package/dist/deps/html-stream-server.js.map +1 -0
- package/dist/deps/rsc.d.ts +2 -0
- package/dist/deps/rsc.d.ts.map +1 -0
- package/dist/deps/rsc.js +4 -0
- package/dist/deps/rsc.js.map +1 -0
- package/dist/deps/ssr.d.ts +2 -0
- package/dist/deps/ssr.d.ts.map +1 -0
- package/dist/deps/ssr.js +3 -0
- package/dist/deps/ssr.js.map +1 -0
- package/dist/errors.d.ts +174 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +241 -0
- package/dist/errors.js.map +1 -0
- package/dist/handle.d.ts +78 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +82 -0
- package/dist/handle.js.map +1 -0
- package/dist/handles/MetaTags.d.ts +14 -0
- package/dist/handles/MetaTags.d.ts.map +1 -0
- package/dist/handles/MetaTags.js +136 -0
- package/dist/handles/MetaTags.js.map +1 -0
- package/dist/handles/index.d.ts +6 -0
- package/dist/handles/index.d.ts.map +1 -0
- package/{src/handles/index.ts → dist/handles/index.js} +1 -1
- package/dist/handles/index.js.map +1 -0
- package/dist/handles/meta.d.ts +39 -0
- package/dist/handles/meta.d.ts.map +1 -0
- package/dist/handles/meta.js +202 -0
- package/dist/handles/meta.js.map +1 -0
- package/dist/host/__tests__/errors.test.d.ts +2 -0
- package/dist/host/__tests__/errors.test.d.ts.map +1 -0
- package/dist/host/__tests__/errors.test.js +76 -0
- package/dist/host/__tests__/errors.test.js.map +1 -0
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts +2 -0
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts.map +1 -0
- package/dist/host/__tests__/pattern-comprehensive.test.js +732 -0
- package/dist/host/__tests__/pattern-comprehensive.test.js.map +1 -0
- package/dist/host/__tests__/pattern-matcher.test.d.ts +2 -0
- package/dist/host/__tests__/pattern-matcher.test.d.ts.map +1 -0
- package/dist/host/__tests__/pattern-matcher.test.js +251 -0
- package/dist/host/__tests__/pattern-matcher.test.js.map +1 -0
- package/dist/host/__tests__/router.test.d.ts +2 -0
- package/dist/host/__tests__/router.test.d.ts.map +1 -0
- package/dist/host/__tests__/router.test.js +241 -0
- package/dist/host/__tests__/router.test.js.map +1 -0
- package/dist/host/__tests__/testing.test.d.ts +2 -0
- package/dist/host/__tests__/testing.test.d.ts.map +1 -0
- package/dist/host/__tests__/testing.test.js +64 -0
- package/dist/host/__tests__/testing.test.js.map +1 -0
- package/dist/host/__tests__/utils.test.d.ts +2 -0
- package/dist/host/__tests__/utils.test.d.ts.map +1 -0
- package/dist/host/__tests__/utils.test.js +29 -0
- package/dist/host/__tests__/utils.test.js.map +1 -0
- package/dist/host/cookie-handler.d.ts +34 -0
- package/dist/host/cookie-handler.d.ts.map +1 -0
- package/dist/host/cookie-handler.js +124 -0
- package/dist/host/cookie-handler.js.map +1 -0
- package/dist/host/errors.d.ts +56 -0
- package/dist/host/errors.d.ts.map +1 -0
- package/dist/host/errors.js +79 -0
- package/dist/host/errors.js.map +1 -0
- package/dist/host/index.d.ts +29 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +32 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/pattern-matcher.d.ts +36 -0
- package/dist/host/pattern-matcher.d.ts.map +1 -0
- package/dist/host/pattern-matcher.js +172 -0
- package/dist/host/pattern-matcher.js.map +1 -0
- package/dist/host/router.d.ts +26 -0
- package/dist/host/router.d.ts.map +1 -0
- package/dist/host/router.js +218 -0
- package/dist/host/router.js.map +1 -0
- package/dist/host/testing.d.ts +36 -0
- package/dist/host/testing.d.ts.map +1 -0
- package/dist/host/testing.js +55 -0
- package/dist/host/testing.js.map +1 -0
- package/dist/host/types.d.ts +115 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +7 -0
- package/dist/host/types.js.map +1 -0
- package/dist/host/utils.d.ts +21 -0
- package/dist/host/utils.d.ts.map +1 -0
- package/dist/host/utils.js +23 -0
- package/dist/host/utils.js.map +1 -0
- package/dist/href-client.d.ts +131 -0
- package/dist/href-client.d.ts.map +1 -0
- package/dist/href-client.js +64 -0
- package/dist/href-client.js.map +1 -0
- package/{src/href-context.ts → dist/href-context.d.ts} +7 -11
- package/dist/href-context.d.ts.map +1 -0
- package/dist/href-context.js +21 -0
- package/dist/href-context.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/index.rsc.d.ts +32 -0
- package/dist/index.rsc.d.ts.map +1 -0
- package/dist/index.rsc.js +40 -0
- package/dist/index.rsc.js.map +1 -0
- package/dist/internal-debug.d.ts +2 -0
- package/dist/internal-debug.d.ts.map +1 -0
- package/dist/internal-debug.js +5 -0
- package/dist/internal-debug.js.map +1 -0
- package/dist/loader.d.ts +14 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +20 -0
- package/dist/loader.js.map +1 -0
- package/dist/loader.rsc.d.ts +19 -0
- package/dist/loader.rsc.d.ts.map +1 -0
- package/dist/loader.rsc.js +99 -0
- package/dist/loader.rsc.js.map +1 -0
- package/{src/network-error-thrower.tsx → dist/network-error-thrower.d.ts} +4 -8
- package/dist/network-error-thrower.d.ts.map +1 -0
- package/dist/network-error-thrower.js +14 -0
- package/dist/network-error-thrower.js.map +1 -0
- package/dist/outlet-context.d.ts +13 -0
- package/dist/outlet-context.d.ts.map +1 -0
- package/dist/outlet-context.js +3 -0
- package/dist/outlet-context.js.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts +2 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.js +148 -0
- package/dist/prerender/__tests__/param-hash.test.js.map +1 -0
- package/dist/prerender/param-hash.d.ts +16 -0
- package/dist/prerender/param-hash.d.ts.map +1 -0
- package/dist/prerender/param-hash.js +36 -0
- package/dist/prerender/param-hash.js.map +1 -0
- package/dist/prerender/store.d.ts +38 -0
- package/dist/prerender/store.d.ts.map +1 -0
- package/dist/prerender/store.js +61 -0
- package/dist/prerender/store.js.map +1 -0
- package/dist/prerender.d.ts +66 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +57 -0
- package/dist/prerender.js.map +1 -0
- package/dist/reverse.d.ts +196 -0
- package/dist/reverse.d.ts.map +1 -0
- package/dist/reverse.js +78 -0
- package/dist/reverse.js.map +1 -0
- package/dist/root-error-boundary.d.ts +33 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/root-error-boundary.js +165 -0
- package/dist/root-error-boundary.js.map +1 -0
- package/dist/route-content-wrapper.d.ts +46 -0
- package/dist/route-content-wrapper.d.ts.map +1 -0
- package/dist/route-content-wrapper.js +77 -0
- package/dist/route-content-wrapper.js.map +1 -0
- package/dist/route-definition.d.ts +421 -0
- package/dist/route-definition.d.ts.map +1 -0
- package/dist/route-definition.js +868 -0
- package/dist/route-definition.js.map +1 -0
- package/dist/route-map-builder.d.ts +155 -0
- package/dist/route-map-builder.d.ts.map +1 -0
- package/dist/route-map-builder.js +237 -0
- package/dist/route-map-builder.js.map +1 -0
- package/dist/route-types.d.ts +165 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +7 -0
- package/dist/route-types.js.map +1 -0
- package/dist/router/__tests__/handler-context.test.d.ts +2 -0
- package/dist/router/__tests__/handler-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/handler-context.test.js +65 -0
- package/dist/router/__tests__/handler-context.test.js.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts +2 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js +221 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js.map +1 -0
- package/dist/router/__tests__/match-context.test.d.ts +2 -0
- package/dist/router/__tests__/match-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-context.test.js +92 -0
- package/dist/router/__tests__/match-context.test.js.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts +2 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.js +417 -0
- package/dist/router/__tests__/match-pipelines.test.js.map +1 -0
- package/dist/router/__tests__/match-result.test.d.ts +2 -0
- package/dist/router/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-result.test.js +457 -0
- package/dist/router/__tests__/match-result.test.js.map +1 -0
- package/dist/router/__tests__/on-error.test.d.ts +2 -0
- package/dist/router/__tests__/on-error.test.d.ts.map +1 -0
- package/dist/router/__tests__/on-error.test.js +678 -0
- package/dist/router/__tests__/on-error.test.js.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts +2 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.js +629 -0
- package/dist/router/__tests__/pattern-matching.test.js.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +2 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +155 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +1 -0
- package/dist/router/error-handling.d.ts +77 -0
- package/dist/router/error-handling.d.ts.map +1 -0
- package/dist/router/error-handling.js +202 -0
- package/dist/router/error-handling.js.map +1 -0
- package/dist/router/handler-context.d.ts +20 -0
- package/dist/router/handler-context.d.ts.map +1 -0
- package/dist/router/handler-context.js +198 -0
- package/dist/router/handler-context.js.map +1 -0
- package/dist/router/intercept-resolution.d.ts +66 -0
- package/dist/router/intercept-resolution.d.ts.map +1 -0
- package/dist/router/intercept-resolution.js +246 -0
- package/dist/router/intercept-resolution.js.map +1 -0
- package/dist/router/loader-resolution.d.ts +64 -0
- package/dist/router/loader-resolution.d.ts.map +1 -0
- package/dist/router/loader-resolution.js +284 -0
- package/dist/router/loader-resolution.js.map +1 -0
- package/dist/router/logging.d.ts +15 -0
- package/dist/router/logging.d.ts.map +1 -0
- package/dist/router/logging.js +99 -0
- package/dist/router/logging.js.map +1 -0
- package/dist/router/manifest.d.ts +22 -0
- package/dist/router/manifest.d.ts.map +1 -0
- package/dist/router/manifest.js +181 -0
- package/dist/router/manifest.js.map +1 -0
- package/dist/router/match-api.d.ts +35 -0
- package/dist/router/match-api.d.ts.map +1 -0
- package/dist/router/match-api.js +406 -0
- package/dist/router/match-api.js.map +1 -0
- package/dist/router/match-context.d.ts +206 -0
- package/dist/router/match-context.d.ts.map +1 -0
- package/dist/router/match-context.js +17 -0
- package/dist/router/match-context.js.map +1 -0
- package/dist/router/match-middleware/background-revalidation.d.ts +127 -0
- package/dist/router/match-middleware/background-revalidation.d.ts.map +1 -0
- package/dist/router/match-middleware/background-revalidation.js +75 -0
- package/dist/router/match-middleware/background-revalidation.js.map +1 -0
- package/dist/router/match-middleware/cache-lookup.d.ts +112 -0
- package/dist/router/match-middleware/cache-lookup.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-lookup.js +257 -0
- package/dist/router/match-middleware/cache-lookup.js.map +1 -0
- package/dist/router/match-middleware/cache-store.d.ts +113 -0
- package/dist/router/match-middleware/cache-store.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-store.js +108 -0
- package/dist/router/match-middleware/cache-store.js.map +1 -0
- package/dist/router/match-middleware/index.d.ts +81 -0
- package/dist/router/match-middleware/index.d.ts.map +1 -0
- package/dist/router/match-middleware/index.js +80 -0
- package/dist/router/match-middleware/index.js.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts +117 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.js +134 -0
- package/dist/router/match-middleware/intercept-resolution.js.map +1 -0
- package/dist/router/match-middleware/segment-resolution.d.ts +99 -0
- package/dist/router/match-middleware/segment-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/segment-resolution.js +53 -0
- package/dist/router/match-middleware/segment-resolution.js.map +1 -0
- package/dist/router/match-pipelines.d.ts +147 -0
- package/dist/router/match-pipelines.d.ts.map +1 -0
- package/dist/router/match-pipelines.js +82 -0
- package/dist/router/match-pipelines.js.map +1 -0
- package/dist/router/match-result.d.ts +126 -0
- package/dist/router/match-result.d.ts.map +1 -0
- package/dist/router/match-result.js +93 -0
- package/dist/router/match-result.js.map +1 -0
- package/dist/router/metrics.d.ts +20 -0
- package/dist/router/metrics.d.ts.map +1 -0
- package/dist/router/metrics.js +47 -0
- package/dist/router/metrics.js.map +1 -0
- package/dist/router/middleware.d.ts +249 -0
- package/dist/router/middleware.d.ts.map +1 -0
- package/dist/router/middleware.js +434 -0
- package/dist/router/middleware.js.map +1 -0
- package/dist/router/middleware.test.d.ts +2 -0
- package/dist/router/middleware.test.d.ts.map +1 -0
- package/dist/router/middleware.test.js +816 -0
- package/dist/router/middleware.test.js.map +1 -0
- package/dist/router/pattern-matching.d.ts +149 -0
- package/dist/router/pattern-matching.d.ts.map +1 -0
- package/dist/router/pattern-matching.js +349 -0
- package/dist/router/pattern-matching.js.map +1 -0
- package/dist/router/revalidation.d.ts +44 -0
- package/dist/router/revalidation.d.ts.map +1 -0
- package/dist/router/revalidation.js +147 -0
- package/dist/router/revalidation.js.map +1 -0
- package/dist/router/router-context.d.ts +135 -0
- package/dist/router/router-context.d.ts.map +1 -0
- package/dist/router/router-context.js +36 -0
- package/dist/router/router-context.js.map +1 -0
- package/dist/router/segment-resolution.d.ts +127 -0
- package/dist/router/segment-resolution.d.ts.map +1 -0
- package/dist/router/segment-resolution.js +919 -0
- package/dist/router/segment-resolution.js.map +1 -0
- package/dist/router/trie-matching.d.ts +40 -0
- package/dist/router/trie-matching.d.ts.map +1 -0
- package/dist/router/trie-matching.js +127 -0
- package/dist/router/trie-matching.js.map +1 -0
- package/dist/router/types.d.ts +136 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +7 -0
- package/dist/router/types.js.map +1 -0
- package/dist/router.d.ts +753 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.gen.d.ts +6 -0
- package/dist/router.gen.d.ts.map +1 -0
- package/dist/router.gen.js +6 -0
- package/dist/router.gen.js.map +1 -0
- package/dist/router.js +1304 -0
- package/dist/router.js.map +1 -0
- package/dist/rsc/__tests__/helpers.test.d.ts +2 -0
- package/dist/rsc/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/rsc/__tests__/helpers.test.js +140 -0
- package/dist/rsc/__tests__/helpers.test.js.map +1 -0
- package/dist/rsc/handler.d.ts +45 -0
- package/dist/rsc/handler.d.ts.map +1 -0
- package/dist/rsc/handler.js +1172 -0
- package/dist/rsc/handler.js.map +1 -0
- package/dist/rsc/helpers.d.ts +16 -0
- package/dist/rsc/helpers.d.ts.map +1 -0
- package/dist/rsc/helpers.js +55 -0
- package/dist/rsc/helpers.js.map +1 -0
- package/dist/rsc/index.d.ts +22 -0
- package/dist/rsc/index.d.ts.map +1 -0
- package/dist/rsc/index.js +23 -0
- package/dist/rsc/index.js.map +1 -0
- package/dist/rsc/nonce.d.ts +9 -0
- package/dist/rsc/nonce.d.ts.map +1 -0
- package/dist/rsc/nonce.js +18 -0
- package/dist/rsc/nonce.js.map +1 -0
- package/dist/rsc/types.d.ts +206 -0
- package/dist/rsc/types.d.ts.map +1 -0
- package/dist/rsc/types.js +8 -0
- package/dist/rsc/types.js.map +1 -0
- package/dist/search-params.d.ts +103 -0
- package/dist/search-params.d.ts.map +1 -0
- package/dist/search-params.js +74 -0
- package/dist/search-params.js.map +1 -0
- package/dist/segment-system.d.ts +75 -0
- package/dist/segment-system.d.ts.map +1 -0
- package/dist/segment-system.js +336 -0
- package/dist/segment-system.js.map +1 -0
- package/dist/server/context.d.ts +245 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +197 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/fetchable-loader-store.d.ts +18 -0
- package/dist/server/fetchable-loader-store.d.ts.map +1 -0
- package/dist/server/fetchable-loader-store.js +18 -0
- package/dist/server/fetchable-loader-store.js.map +1 -0
- package/dist/server/handle-store.d.ts +85 -0
- package/dist/server/handle-store.d.ts.map +1 -0
- package/dist/server/handle-store.js +142 -0
- package/dist/server/handle-store.js.map +1 -0
- package/dist/server/loader-registry.d.ts +55 -0
- package/dist/server/loader-registry.d.ts.map +1 -0
- package/dist/server/loader-registry.js +132 -0
- package/dist/server/loader-registry.js.map +1 -0
- package/dist/server/request-context.d.ts +226 -0
- package/dist/server/request-context.d.ts.map +1 -0
- package/dist/server/request-context.js +290 -0
- package/dist/server/request-context.js.map +1 -0
- package/dist/server/root-layout.d.ts +4 -0
- package/dist/server/root-layout.d.ts.map +1 -0
- package/dist/server/root-layout.js +5 -0
- package/dist/server/root-layout.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +20 -0
- package/dist/server.js.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts +2 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.js +132 -0
- package/dist/ssr/__tests__/ssr-handler.test.js.map +1 -0
- package/dist/ssr/index.d.ts +98 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +158 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/static-handler.d.ts +50 -0
- package/dist/static-handler.d.ts.map +1 -0
- package/dist/static-handler.gen.d.ts +5 -0
- package/dist/static-handler.gen.d.ts.map +1 -0
- package/dist/static-handler.gen.js +5 -0
- package/dist/static-handler.gen.js.map +1 -0
- package/dist/static-handler.js +29 -0
- package/dist/static-handler.js.map +1 -0
- package/dist/testing/vitest.js +82 -0
- package/dist/theme/ThemeProvider.d.ts +20 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +240 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/ThemeScript.d.ts +48 -0
- package/dist/theme/ThemeScript.d.ts.map +1 -0
- package/dist/theme/ThemeScript.js +13 -0
- package/dist/theme/ThemeScript.js.map +1 -0
- package/dist/theme/__tests__/theme.test.d.ts +2 -0
- package/dist/theme/__tests__/theme.test.d.ts.map +1 -0
- package/dist/theme/__tests__/theme.test.js +103 -0
- package/dist/theme/__tests__/theme.test.js.map +1 -0
- package/dist/theme/constants.d.ts +29 -0
- package/dist/theme/constants.d.ts.map +1 -0
- package/dist/theme/constants.js +48 -0
- package/dist/theme/constants.js.map +1 -0
- package/dist/theme/index.d.ts +31 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +36 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/theme-context.d.ts +40 -0
- package/dist/theme/theme-context.d.ts.map +1 -0
- package/dist/theme/theme-context.js +60 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/theme/theme-script.d.ts +27 -0
- package/dist/theme/theme-script.d.ts.map +1 -0
- package/dist/theme/theme-script.js +147 -0
- package/dist/theme/theme-script.js.map +1 -0
- package/dist/theme/types.d.ts +163 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +11 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme/use-theme.d.ts +12 -0
- package/dist/theme/use-theme.d.ts.map +1 -0
- package/dist/theme/use-theme.js +40 -0
- package/dist/theme/use-theme.js.map +1 -0
- package/dist/types/__internal.d.ts +127 -0
- package/dist/types/bin/rango.d.ts +1 -0
- package/dist/types/browser/action-coordinator.d.ts +57 -0
- package/dist/types/browser/action-fence.d.ts +33 -0
- package/dist/types/browser/app-shell.d.ts +34 -0
- package/dist/types/browser/app-version.d.ts +6 -0
- package/dist/types/browser/connection-warmup.d.ts +31 -0
- package/dist/types/browser/cookie-name.d.ts +66 -0
- package/dist/types/browser/dev-discovery.d.ts +11 -0
- package/dist/types/browser/event-controller.d.ts +231 -0
- package/dist/types/browser/history-state.d.ts +26 -0
- package/dist/types/browser/index.d.ts +1 -0
- package/dist/types/browser/intercept-utils.d.ts +30 -0
- package/dist/types/browser/invalidate-client-cache.d.ts +17 -0
- package/dist/types/browser/link-interceptor.d.ts +53 -0
- package/dist/types/browser/logging.d.ts +33 -0
- package/dist/types/browser/merge-segment-loaders.d.ts +38 -0
- package/dist/types/browser/navigation-bridge.d.ts +39 -0
- package/dist/types/browser/navigation-client.d.ts +17 -0
- package/dist/types/browser/navigation-store-handle.d.ts +25 -0
- package/dist/types/browser/navigation-store.d.ts +85 -0
- package/dist/types/browser/navigation-transaction.d.ts +75 -0
- package/dist/types/browser/network-error-handler.d.ts +35 -0
- package/dist/types/browser/notify-listeners.d.ts +2 -0
- package/dist/types/browser/partial-update.d.ts +61 -0
- package/dist/types/browser/prefetch/cache.d.ts +224 -0
- package/dist/types/browser/prefetch/default-strategy.d.ts +31 -0
- package/dist/types/browser/prefetch/fetch.d.ts +52 -0
- package/dist/types/browser/prefetch/invalidation.d.ts +6 -0
- package/dist/types/browser/prefetch/loader.d.ts +12 -0
- package/dist/types/browser/prefetch/observer.d.ts +24 -0
- package/dist/types/browser/prefetch/policy.d.ts +13 -0
- package/dist/types/browser/prefetch/queue.d.ts +48 -0
- package/dist/types/browser/prefetch/resource-ready.d.ts +28 -0
- package/dist/types/browser/prefetch/runtime.d.ts +2 -0
- package/dist/types/browser/rango-state.d.ts +56 -0
- package/dist/types/browser/react/Link.d.ts +132 -0
- package/dist/types/browser/react/NavigationProvider.d.ts +88 -0
- package/dist/types/browser/react/ScrollRestoration.d.ts +78 -0
- package/dist/types/browser/react/context.d.ts +57 -0
- package/dist/types/browser/react/filter-segment-order.d.ts +35 -0
- package/dist/types/browser/react/index.d.ts +1 -0
- package/dist/types/browser/react/location-state-shared.d.ts +162 -0
- package/dist/types/browser/react/location-state.d.ts +29 -0
- package/dist/types/browser/react/mount-context.d.ts +23 -0
- package/dist/types/browser/react/nonce-context.d.ts +14 -0
- package/dist/types/browser/react/shallow-equal.d.ts +5 -0
- package/dist/types/browser/react/use-action.d.ts +61 -0
- package/dist/types/browser/react/use-handle.d.ts +21 -0
- package/dist/types/browser/react/use-href.d.ts +32 -0
- package/dist/types/browser/react/use-link-status.d.ts +36 -0
- package/dist/types/browser/react/use-mount.d.ts +24 -0
- package/dist/types/browser/react/use-navigation.d.ts +15 -0
- package/dist/types/browser/react/use-params.d.ts +21 -0
- package/dist/types/browser/react/use-pathname.d.ts +13 -0
- package/dist/types/browser/react/use-reverse.d.ts +40 -0
- package/dist/types/browser/react/use-router.d.ts +30 -0
- package/dist/types/browser/react/use-search-params.d.ts +66 -0
- package/dist/types/browser/react/use-segments.d.ts +29 -0
- package/dist/types/browser/response-adapter.d.ts +58 -0
- package/dist/types/browser/rsc-router.d.ts +146 -0
- package/dist/types/browser/scroll-restoration.d.ts +103 -0
- package/dist/types/browser/segment-reconciler.d.ts +74 -0
- package/dist/types/browser/segment-structure-assert.d.ts +16 -0
- package/dist/types/browser/server-action-bridge.d.ts +29 -0
- package/dist/types/browser/types.d.ts +546 -0
- package/dist/types/browser/validate-redirect-origin.d.ts +28 -0
- package/dist/types/build/collect-fallback-refs.d.ts +5 -0
- package/dist/types/build/generate-manifest.d.ts +106 -0
- package/dist/types/build/generate-route-types.d.ts +8 -0
- package/dist/types/build/index.d.ts +21 -0
- package/dist/types/build/merge-full-manifests.d.ts +3 -0
- package/dist/types/build/prefix-tree-utils.d.ts +56 -0
- package/dist/types/build/route-trie.d.ts +20 -0
- package/dist/types/build/route-types/ast-helpers.d.ts +3 -0
- package/dist/types/build/route-types/ast-route-extraction.d.ts +13 -0
- package/dist/types/build/route-types/codegen.d.ts +16 -0
- package/dist/types/build/route-types/include-resolution.d.ts +74 -0
- package/dist/types/build/route-types/param-extraction.d.ts +13 -0
- package/dist/types/build/route-types/per-module-writer.d.ts +20 -0
- package/dist/types/build/route-types/router-processing.d.ts +81 -0
- package/dist/types/build/route-types/scan-filter.d.ts +17 -0
- package/dist/types/build/route-types/source-scan.d.ts +13 -0
- package/dist/types/build/runtime-discovery.d.ts +24 -0
- package/dist/types/cache/background-task.d.ts +21 -0
- package/dist/types/cache/cache-error.d.ts +71 -0
- package/dist/types/cache/cache-exec-scope.d.ts +31 -0
- package/dist/types/cache/cache-key-utils.d.ts +43 -0
- package/dist/types/cache/cache-policy.d.ts +59 -0
- package/dist/types/cache/cache-runtime.d.ts +51 -0
- package/dist/types/cache/cache-scope.d.ts +215 -0
- package/dist/types/cache/cache-tag.d.ts +79 -0
- package/dist/types/cache/cf/cf-base64.d.ts +4 -0
- package/dist/types/cache/cf/cf-cache-constants.d.ts +112 -0
- package/dist/types/cache/cf/cf-cache-store.d.ts +630 -0
- package/dist/types/cache/cf/cf-cache-types.d.ts +365 -0
- package/dist/types/cache/cf/cf-kv-utils.d.ts +43 -0
- package/dist/types/cache/cf/cf-tag-marker-memo.d.ts +15 -0
- package/dist/types/cache/cf/cf-zone-purge.d.ts +31 -0
- package/dist/types/cache/cf/index.d.ts +4 -0
- package/dist/types/cache/document-cache.d.ts +71 -0
- package/dist/types/cache/handle-capture.d.ts +23 -0
- package/dist/types/cache/handle-snapshot.d.ts +39 -0
- package/dist/types/cache/index.d.ts +9 -0
- package/dist/types/cache/memory-segment-store.d.ts +163 -0
- package/dist/types/cache/profile-registry.d.ts +40 -0
- package/dist/types/cache/read-through-swr.d.ts +61 -0
- package/dist/types/cache/search-params-filter.d.ts +64 -0
- package/dist/types/cache/segment-codec.d.ts +78 -0
- package/dist/types/cache/shell-snapshot.d.ts +186 -0
- package/dist/types/cache/tag-invalidation.d.ts +74 -0
- package/dist/types/cache/taint.d.ts +77 -0
- package/dist/types/cache/types.d.ts +522 -0
- package/dist/types/cache/vercel/index.d.ts +1 -0
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +268 -0
- 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 +71 -0
- package/dist/types/client-urls/types.d.ts +148 -0
- package/dist/types/client.d.ts +192 -0
- package/dist/types/client.rsc.d.ts +42 -0
- package/dist/types/cloudflare/index.d.ts +7 -0
- package/dist/types/cloudflare/tracing.d.ts +57 -0
- package/dist/types/component-utils.d.ts +46 -0
- package/dist/types/components/DefaultDocument.d.ts +13 -0
- package/dist/types/context-var.d.ts +84 -0
- package/dist/types/debug.d.ts +57 -0
- package/dist/types/decode-loader-results.d.ts +42 -0
- package/dist/types/default-error-boundary.d.ts +10 -0
- package/dist/types/defer.d.ts +89 -0
- package/dist/types/deps/browser.d.ts +1 -0
- package/dist/types/deps/html-stream-client.d.ts +1 -0
- package/dist/types/deps/html-stream-server.d.ts +1 -0
- package/dist/types/deps/rsc.d.ts +1 -0
- package/dist/types/deps/ssr.d.ts +1 -0
- package/dist/types/dev-discovery-protocol.d.ts +5 -0
- package/dist/types/encode-kv.d.ts +35 -0
- package/dist/types/errors.d.ts +227 -0
- package/dist/types/escape-script.d.ts +44 -0
- package/dist/types/handle.d.ts +93 -0
- package/dist/types/handles/MetaTags.d.ts +17 -0
- package/dist/types/handles/Scripts.d.ts +38 -0
- package/dist/types/handles/breadcrumbs.d.ts +43 -0
- package/dist/types/handles/deferred-resolution.d.ts +53 -0
- package/dist/types/handles/is-thenable.d.ts +10 -0
- package/dist/types/handles/meta.d.ts +43 -0
- package/dist/types/handles/script.d.ts +139 -0
- package/dist/types/host/cookie-handler.d.ts +8 -0
- package/dist/types/host/errors.d.ts +40 -0
- package/dist/types/host/index.d.ts +33 -0
- package/dist/types/host/pattern-matcher.d.ts +30 -0
- package/dist/types/host/router.d.ts +12 -0
- package/dist/types/host/testing.d.ts +41 -0
- package/dist/types/host/types.d.ts +148 -0
- package/dist/types/host/utils.d.ts +20 -0
- package/dist/types/href-client.d.ts +214 -0
- package/dist/types/index.d.ts +113 -0
- package/dist/types/index.rsc.d.ts +52 -0
- package/dist/types/internal-debug.d.ts +1 -0
- package/dist/types/loader-redirect.d.ts +27 -0
- package/dist/types/loader-store.d.ts +193 -0
- package/dist/types/loader.d.ts +18 -0
- package/dist/types/loader.rsc.d.ts +18 -0
- package/dist/types/missing-id-error.d.ts +1 -0
- package/dist/types/outlet-context.d.ts +32 -0
- package/dist/types/outlet-provider.d.ts +15 -0
- package/dist/types/prerender/build-shell-capture.d.ts +104 -0
- package/dist/types/prerender/param-hash.d.ts +6 -0
- package/dist/types/prerender/shell-manifest-key.d.ts +18 -0
- package/dist/types/prerender/store.d.ts +63 -0
- package/dist/types/prerender.d.ts +292 -0
- package/dist/types/redirect-origin.d.ts +71 -0
- package/dist/types/regex-escape.d.ts +6 -0
- package/dist/types/render-error-thrower.d.ts +13 -0
- package/dist/types/response-utils.d.ts +35 -0
- package/dist/types/reverse.d.ts +206 -0
- package/dist/types/root-error-boundary.d.ts +32 -0
- package/dist/types/route-content-wrapper.d.ts +84 -0
- package/dist/types/route-definition/dsl-helpers.d.ts +130 -0
- package/dist/types/route-definition/helper-factories.d.ts +22 -0
- package/dist/types/route-definition/helpers-types.d.ts +405 -0
- package/dist/types/route-definition/index.d.ts +7 -0
- package/dist/types/route-definition/redirect.d.ts +48 -0
- package/dist/types/route-definition/resolve-handler-use.d.ts +19 -0
- package/dist/types/route-definition/use-item-types.d.ts +1 -0
- package/dist/types/route-definition.d.ts +1 -0
- package/dist/types/route-map-builder.d.ts +102 -0
- package/dist/types/route-name.d.ts +27 -0
- package/dist/types/route-types.d.ts +172 -0
- package/dist/types/router/basename.d.ts +10 -0
- package/dist/types/router/content-negotiation.d.ts +91 -0
- package/dist/types/router/debug-manifest.d.ts +7 -0
- package/dist/types/router/error-handling.d.ts +110 -0
- package/dist/types/router/find-match.d.ts +19 -0
- package/dist/types/router/handler-context.d.ts +41 -0
- package/dist/types/router/instrument.d.ts +191 -0
- package/dist/types/router/intercept-resolution.d.ts +91 -0
- package/dist/types/router/lazy-includes.d.ts +26 -0
- package/dist/types/router/loader-resolution.d.ts +85 -0
- package/dist/types/router/logging.d.ts +41 -0
- package/dist/types/router/manifest.d.ts +8 -0
- package/dist/types/router/match-api.d.ts +19 -0
- package/dist/types/router/match-context.d.ts +184 -0
- package/dist/types/router/match-handlers.d.ts +48 -0
- package/dist/types/router/match-middleware/background-revalidation.d.ts +113 -0
- package/dist/types/router/match-middleware/cache-lookup.d.ts +126 -0
- package/dist/types/router/match-middleware/cache-store.d.ts +112 -0
- package/dist/types/router/match-middleware/index.d.ts +80 -0
- package/dist/types/router/match-middleware/intercept-resolution.d.ts +116 -0
- package/dist/types/router/match-middleware/segment-resolution.d.ts +94 -0
- package/dist/types/router/match-pipelines.d.ts +103 -0
- package/dist/types/router/match-result.d.ts +114 -0
- package/dist/types/router/metrics.d.ts +6 -0
- package/dist/types/router/middleware-types.d.ts +74 -0
- package/dist/types/router/middleware.d.ts +116 -0
- package/dist/types/router/navigation-snapshot.d.ts +51 -0
- package/dist/types/router/params-util.d.ts +8 -0
- package/dist/types/router/parse-pattern.d.ts +38 -0
- package/dist/types/router/pattern-matching.d.ts +169 -0
- package/dist/types/router/prefetch-cache-ttl.d.ts +27 -0
- package/dist/types/router/prefetch-default.d.ts +28 -0
- package/dist/types/router/prefetch-limits.d.ts +20 -0
- package/dist/types/router/prerender-match.d.ts +53 -0
- package/dist/types/router/preview-match.d.ts +22 -0
- package/dist/types/router/request-classification.d.ts +104 -0
- package/dist/types/router/revalidation.d.ts +64 -0
- package/dist/types/router/route-snapshot.d.ts +112 -0
- package/dist/types/router/route-trie-builder.d.ts +77 -0
- package/dist/types/router/router-context.d.ts +137 -0
- package/dist/types/router/router-interfaces.d.ts +461 -0
- package/dist/types/router/router-options.d.ts +792 -0
- package/dist/types/router/router-registry.d.ts +15 -0
- package/dist/types/router/segment-resolution/fresh.d.ts +55 -0
- package/dist/types/router/segment-resolution/helpers.d.ts +93 -0
- package/dist/types/router/segment-resolution/loader-cache.d.ts +33 -0
- package/dist/types/router/segment-resolution/loader-mask.d.ts +44 -0
- package/dist/types/router/segment-resolution/loader-snapshot.d.ts +90 -0
- package/dist/types/router/segment-resolution/mask-nested.d.ts +53 -0
- package/dist/types/router/segment-resolution/revalidation.d.ts +85 -0
- package/dist/types/router/segment-resolution/static-store.d.ts +17 -0
- package/dist/types/router/segment-resolution/streamed-handler-telemetry.d.ts +16 -0
- package/dist/types/router/segment-resolution/view-transition-default.d.ts +27 -0
- package/dist/types/router/segment-resolution.d.ts +3 -0
- package/dist/types/router/segment-wrappers.d.ts +53 -0
- package/dist/types/router/state-cookie-name.d.ts +1 -0
- package/dist/types/router/substitute-pattern-params.d.ts +23 -0
- package/dist/types/router/telemetry-otel.d.ts +113 -0
- package/dist/types/router/telemetry.d.ts +216 -0
- package/dist/types/router/timeout.d.ts +107 -0
- package/dist/types/router/tracing.d.ts +139 -0
- package/dist/types/router/transition-when.d.ts +13 -0
- package/dist/types/router/trie-matching.d.ts +32 -0
- package/dist/types/router/types.d.ts +98 -0
- package/dist/types/router/url-params.d.ts +26 -0
- package/dist/types/router.d.ts +7 -0
- package/dist/types/rsc/capture-queue.d.ts +49 -0
- package/dist/types/rsc/full-payload.d.ts +22 -0
- package/dist/types/rsc/handler-context.d.ts +32 -0
- package/dist/types/rsc/handler.d.ts +9 -0
- package/dist/types/rsc/helpers.d.ts +127 -0
- package/dist/types/rsc/index.d.ts +17 -0
- package/dist/types/rsc/json-route-result.d.ts +20 -0
- package/dist/types/rsc/loader-fetch.d.ts +14 -0
- package/dist/types/rsc/manifest-init.d.ts +18 -0
- package/dist/types/rsc/nonce.d.ts +38 -0
- package/dist/types/rsc/origin-guard.d.ts +50 -0
- package/dist/types/rsc/progressive-enhancement.d.ts +19 -0
- package/dist/types/rsc/redirect-guard.d.ts +37 -0
- package/dist/types/rsc/render-pipeline.d.ts +148 -0
- package/dist/types/rsc/response-cache-serve.d.ts +46 -0
- package/dist/types/rsc/response-error.d.ts +19 -0
- package/dist/types/rsc/response-route-handler.d.ts +29 -0
- package/dist/types/rsc/routine-plan.d.ts +124 -0
- package/dist/types/rsc/rsc-rendering.d.ts +18 -0
- package/dist/types/rsc/runtime-warnings.d.ts +22 -0
- package/dist/types/rsc/server-action.d.ts +68 -0
- package/dist/types/rsc/shell-build-manifest.d.ts +90 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +44 -0
- package/dist/types/rsc/shell-capture.d.ts +425 -0
- package/dist/types/rsc/shell-serve.d.ts +200 -0
- package/dist/types/rsc/ssr-setup.d.ts +73 -0
- package/dist/types/rsc/stream-idle.d.ts +60 -0
- package/dist/types/rsc/transition-gate.d.ts +23 -0
- package/dist/types/rsc/types.d.ts +353 -0
- package/dist/types/runtime-env.d.ts +1 -0
- package/dist/types/search-params.d.ts +125 -0
- package/dist/types/segment-content-promise.d.ts +13 -0
- package/dist/types/segment-fragments.d.ts +79 -0
- package/dist/types/segment-loader-promise.d.ts +22 -0
- package/dist/types/segment-system.d.ts +86 -0
- package/dist/types/serialize.d.ts +164 -0
- package/dist/types/server/context.d.ts +520 -0
- package/dist/types/server/cookie-parse.d.ts +10 -0
- package/dist/types/server/cookie-store.d.ts +107 -0
- package/dist/types/server/fetchable-loader-store.d.ts +20 -0
- package/dist/types/server/handle-store.d.ts +131 -0
- package/dist/types/server/loader-registry.d.ts +32 -0
- package/dist/types/server/request-context.d.ts +717 -0
- package/dist/types/server/root-layout.d.ts +3 -0
- package/dist/types/server.d.ts +16 -0
- package/dist/types/ssr/index.d.ts +271 -0
- package/dist/types/ssr/inject-rsc-eager.d.ts +3 -0
- package/dist/types/ssr/preinit-client-references.d.ts +71 -0
- package/dist/types/ssr/ssr-root.d.ts +84 -0
- package/dist/types/ssr-suspension-warning.d.ts +19 -0
- package/dist/types/static-handler.d.ts +71 -0
- package/dist/types/testing/cache-status.d.ts +63 -0
- package/dist/types/testing/collect-handle.d.ts +20 -0
- package/dist/types/testing/dispatch.d.ts +127 -0
- package/dist/types/testing/dom.entry.d.ts +15 -0
- package/dist/types/testing/e2e/fixture.d.ts +37 -0
- package/dist/types/testing/e2e/index.d.ts +31 -0
- package/dist/types/testing/e2e/matchers.d.ts +17 -0
- package/dist/types/testing/e2e/page-helpers.d.ts +86 -0
- package/dist/types/testing/e2e/parity.d.ts +111 -0
- package/dist/types/testing/e2e/server.d.ts +35 -0
- package/dist/types/testing/flight-matchers.d.ts +55 -0
- package/dist/types/testing/flight-normalize.d.ts +1 -0
- package/dist/types/testing/flight-tree.d.ts +192 -0
- package/dist/types/testing/flight.d.ts +115 -0
- package/dist/types/testing/flight.entry.d.ts +27 -0
- package/dist/types/testing/generated-routes.d.ts +66 -0
- package/dist/types/testing/index.d.ts +54 -0
- package/dist/types/testing/internal/context.d.ts +225 -0
- package/dist/types/testing/internal/flight-client-globals.d.ts +1 -0
- package/dist/types/testing/internal/seed-vars.d.ts +30 -0
- package/dist/types/testing/render-handler.d.ts +160 -0
- package/dist/types/testing/render-route.d.ts +265 -0
- package/dist/types/testing/run-loader.d.ts +195 -0
- package/dist/types/testing/run-middleware.d.ts +132 -0
- package/dist/types/testing/run-transition-when.d.ts +78 -0
- package/dist/types/testing/shell-status.d.ts +81 -0
- package/dist/types/testing/vitest-stubs/cloudflare-email.d.ts +6 -0
- package/dist/types/testing/vitest-stubs/cloudflare-workers.d.ts +13 -0
- package/dist/types/testing/vitest-stubs/plugin-rsc.d.ts +7 -0
- package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types/testing/vitest.d.ts +205 -0
- package/dist/types/theme/ThemeProvider.d.ts +13 -0
- package/dist/types/theme/ThemeScript.d.ts +45 -0
- package/dist/types/theme/constants.d.ts +39 -0
- package/dist/types/theme/index.d.ts +29 -0
- package/dist/types/theme/theme-context.d.ts +21 -0
- package/dist/types/theme/theme-script.d.ts +26 -0
- package/dist/types/theme/types.d.ts +162 -0
- package/dist/types/theme/use-theme.d.ts +8 -0
- package/dist/types/types/boundaries.d.ts +115 -0
- package/dist/types/types/cache-types.d.ts +191 -0
- package/dist/types/types/error-types.d.ts +114 -0
- package/dist/types/types/global-namespace.d.ts +90 -0
- package/dist/types/types/handler-context.d.ts +658 -0
- package/dist/types/types/index.d.ts +11 -0
- package/dist/types/types/loader-types.d.ts +240 -0
- package/dist/types/types/request-scope.d.ts +93 -0
- package/dist/types/types/route-config.d.ts +105 -0
- package/dist/types/types/route-entry.d.ts +98 -0
- package/dist/types/types/segments.d.ts +254 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/urls/include-helper.d.ts +17 -0
- package/dist/types/urls/include-provider.d.ts +27 -0
- package/dist/types/urls/index.d.ts +6 -0
- package/dist/types/urls/path-helper-types.d.ts +207 -0
- package/dist/types/urls/path-helper.d.ts +12 -0
- package/dist/types/urls/pattern-types.d.ts +166 -0
- package/dist/types/urls/response-types.d.ts +67 -0
- package/dist/types/urls/type-extraction.d.ts +157 -0
- package/dist/types/urls/urls-function.d.ts +24 -0
- package/dist/types/urls.d.ts +1 -0
- package/dist/types/use-loader.d.ts +150 -0
- package/dist/types/vercel/index.d.ts +10 -0
- package/dist/types/vercel/tracing.d.ts +71 -0
- package/dist/types/vite/debug.d.ts +80 -0
- package/dist/types/vite/discovery/bundle-postprocess.d.ts +12 -0
- package/dist/types/vite/discovery/client-urls-projection.d.ts +53 -0
- package/dist/types/vite/discovery/dev-prerender-cache.d.ts +65 -0
- package/dist/types/vite/discovery/discover-routers.d.ts +17 -0
- package/dist/types/vite/discovery/discovery-errors.d.ts +113 -0
- package/dist/types/vite/discovery/gate-state.d.ts +79 -0
- package/dist/types/vite/discovery/prerender-collection.d.ts +24 -0
- package/dist/types/vite/discovery/route-types-writer.d.ts +32 -0
- package/dist/types/vite/discovery/self-gen-tracking.d.ts +22 -0
- package/dist/types/vite/discovery/shell-prerender-phase.d.ts +40 -0
- package/dist/types/vite/discovery/state.d.ts +170 -0
- package/dist/types/vite/discovery/virtual-module-codegen.d.ts +15 -0
- package/dist/types/vite/encryption-key.d.ts +2 -0
- package/dist/types/vite/index.d.ts +11 -0
- package/dist/types/vite/inject-client-debug.d.ts +56 -0
- package/dist/types/vite/plugin-types.d.ts +298 -0
- package/dist/types/vite/plugins/cjs-to-esm.d.ts +6 -0
- package/dist/types/vite/plugins/client-ref-dedup.d.ts +29 -0
- package/dist/types/vite/plugins/client-ref-hashing.d.ts +35 -0
- package/dist/types/vite/plugins/cloudflare-protocol-stub.d.ts +64 -0
- package/dist/types/vite/plugins/expose-action-id.d.ts +18 -0
- package/dist/types/vite/plugins/expose-id-utils.d.ts +37 -0
- package/dist/types/vite/plugins/expose-ids/export-analysis.d.ts +19 -0
- package/dist/types/vite/plugins/expose-ids/handler-transform.d.ts +10 -0
- package/dist/types/vite/plugins/expose-ids/loader-transform.d.ts +8 -0
- package/dist/types/vite/plugins/expose-ids/router-transform.d.ts +13 -0
- package/dist/types/vite/plugins/expose-ids/types.d.ts +29 -0
- package/dist/types/vite/plugins/expose-internal-ids.d.ts +16 -0
- package/dist/types/vite/plugins/performance-tracks.d.ts +25 -0
- package/dist/types/vite/plugins/refresh-cmd.d.ts +20 -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/plugins/use-cache-transform.d.ts +20 -0
- package/dist/types/vite/plugins/vercel-output.d.ts +85 -0
- package/dist/types/vite/plugins/version-injector.d.ts +21 -0
- package/dist/types/vite/plugins/version-plugin.d.ts +19 -0
- package/dist/types/vite/plugins/virtual-entries.d.ts +36 -0
- package/dist/types/vite/plugins/virtual-stub-plugin.d.ts +7 -0
- package/dist/types/vite/rango.d.ts +29 -0
- package/dist/types/vite/router-discovery.d.ts +23 -0
- package/dist/types/vite/utils/ast-handler-extract.d.ts +64 -0
- package/dist/types/vite/utils/banner.d.ts +2 -0
- package/dist/types/vite/utils/bundle-analysis.d.ts +28 -0
- package/dist/types/vite/utils/client-chunks.d.ts +55 -0
- package/dist/types/vite/utils/directive-prologue.d.ts +16 -0
- package/dist/types/vite/utils/forward-user-plugins.d.ts +37 -0
- package/dist/types/vite/utils/manifest-utils.d.ts +7 -0
- package/dist/types/vite/utils/package-resolution.d.ts +6 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +32 -0
- package/dist/types/vite/utils/shared-utils.d.ts +67 -0
- package/dist/types.d.ts +1479 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/urls.d.ts +441 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.gen.d.ts +8 -0
- package/dist/urls.gen.d.ts.map +1 -0
- package/dist/urls.gen.js +8 -0
- package/dist/urls.gen.js.map +1 -0
- package/dist/urls.js +443 -0
- package/dist/urls.js.map +1 -0
- package/dist/use-loader.d.ts +127 -0
- package/dist/use-loader.d.ts.map +1 -0
- package/dist/use-loader.js +237 -0
- package/dist/use-loader.js.map +1 -0
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts +2 -0
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts.map +1 -0
- package/dist/vite/__tests__/ast-handler-extract.test.js +294 -0
- package/dist/vite/__tests__/ast-handler-extract.test.js.map +1 -0
- package/dist/vite/__tests__/expose-id-utils.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-id-utils.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-id-utils.test.js +224 -0
- package/dist/vite/__tests__/expose-id-utils.test.js.map +1 -0
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-internal-ids.test.js +647 -0
- package/dist/vite/__tests__/expose-internal-ids.test.js.map +1 -0
- package/dist/vite/__tests__/expose-router-id.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-router-id.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-router-id.test.js +39 -0
- package/dist/vite/__tests__/expose-router-id.test.js.map +1 -0
- package/dist/vite/ast-handler-extract.d.ts +49 -0
- package/dist/vite/ast-handler-extract.d.ts.map +1 -0
- package/dist/vite/ast-handler-extract.js +249 -0
- package/dist/vite/ast-handler-extract.js.map +1 -0
- package/dist/vite/expose-action-id.d.ts +19 -0
- package/dist/vite/expose-action-id.d.ts.map +1 -0
- package/dist/vite/expose-action-id.js +250 -0
- package/dist/vite/expose-action-id.js.map +1 -0
- package/dist/vite/expose-id-utils.d.ts +69 -0
- package/dist/vite/expose-id-utils.d.ts.map +1 -0
- package/dist/vite/expose-id-utils.js +289 -0
- package/dist/vite/expose-id-utils.js.map +1 -0
- package/dist/vite/expose-internal-ids.d.ts +22 -0
- package/dist/vite/expose-internal-ids.d.ts.map +1 -0
- package/dist/vite/expose-internal-ids.js +886 -0
- package/dist/vite/expose-internal-ids.js.map +1 -0
- package/dist/vite/index.d.ts +149 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +12042 -1346
- package/dist/vite/index.js.bak +5448 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/index.named-routes.gen.ts +103 -0
- package/dist/vite/package-resolution.d.ts +43 -0
- package/dist/vite/package-resolution.d.ts.map +1 -0
- package/{src/vite/package-resolution.ts → dist/vite/package-resolution.js} +53 -66
- package/dist/vite/package-resolution.js.map +1 -0
- package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/dist/vite/virtual-entries.d.ts +25 -0
- package/dist/vite/virtual-entries.d.ts.map +1 -0
- package/{src/vite/virtual-entries.ts → dist/vite/virtual-entries.js} +12 -16
- package/dist/vite/virtual-entries.js.map +1 -0
- package/package.json +170 -77
- package/skills/api-client/SKILL.md +211 -0
- package/skills/breadcrumbs/SKILL.md +359 -0
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +492 -0
- package/skills/caching/SKILL.md +452 -26
- package/skills/catalog.json +289 -0
- package/skills/client-urls/SKILL.md +339 -0
- package/skills/cloudflare/SKILL.md +153 -0
- package/skills/cloudflare/agents/openai.yaml +4 -0
- package/skills/cloudflare/references/d1-and-local-dev.md +131 -0
- package/skills/cloudflare/references/streaming-and-deploy.md +107 -0
- package/skills/cloudflare/references/webhooks-and-crypto.md +147 -0
- package/skills/comparison/SKILL.md +50 -0
- package/skills/comparison/agents/openai.yaml +4 -0
- package/skills/comparison/references/framework-comparison.md +858 -0
- package/skills/composability/SKILL.md +292 -0
- package/skills/css/SKILL.md +76 -0
- package/skills/debug-manifest/SKILL.md +16 -18
- package/skills/defer-hydration/SKILL.md +235 -0
- package/skills/deployment-caching/SKILL.md +176 -0
- package/skills/document-cache/SKILL.md +125 -65
- package/skills/fonts/SKILL.md +167 -0
- package/skills/handler-use/SKILL.md +364 -0
- package/skills/hooks/SKILL.md +76 -432
- package/skills/hooks/data.md +282 -0
- package/skills/hooks/handle-and-actions.md +110 -0
- package/skills/hooks/navigation.md +110 -0
- package/skills/hooks/outlets.md +62 -0
- package/skills/hooks/state.md +228 -0
- package/skills/hooks/urls.md +172 -0
- package/skills/host-router/SKILL.md +320 -0
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +215 -16
- package/skills/layout/SKILL.md +147 -7
- package/skills/links/SKILL.md +360 -33
- package/skills/loader/SKILL.md +762 -51
- package/skills/middleware/SKILL.md +251 -38
- package/skills/migrate-nextjs/SKILL.md +854 -0
- package/skills/migrate-nextjs/backend-host-swap.md +120 -0
- package/skills/migrate-react-router/SKILL.md +189 -0
- package/skills/migrate-react-router/component-migration.md +201 -0
- package/skills/migrate-react-router/data-and-actions.md +236 -0
- package/skills/migrate-react-router/route-mapping.md +284 -0
- package/skills/mime-routes/SKILL.md +165 -0
- package/skills/observability/SKILL.md +231 -0
- package/skills/parallel/SKILL.md +327 -4
- package/skills/ppr/SKILL.md +918 -0
- package/skills/prerender/SKILL.md +751 -0
- package/skills/rango/SKILL.md +387 -17
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +539 -0
- package/skills/route/SKILL.md +399 -15
- package/skills/router-setup/SKILL.md +270 -34
- package/skills/scripts/SKILL.md +189 -0
- package/skills/server-actions/SKILL.md +776 -0
- package/skills/shell-manifest/SKILL.md +194 -0
- package/skills/streams-and-websockets/SKILL.md +283 -0
- package/skills/tailwind/SKILL.md +153 -0
- package/skills/testing/SKILL.md +131 -0
- package/skills/testing/bindings.md +103 -0
- package/skills/testing/cache-prerender.md +172 -0
- package/skills/testing/client-components.md +131 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +91 -0
- package/skills/testing/handles.md +153 -0
- package/skills/testing/loader.md +130 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +122 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +85 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +123 -0
- package/skills/theme/SKILL.md +16 -12
- package/skills/typesafety/SKILL.md +45 -387
- package/skills/typesafety/env-and-bindings.md +254 -0
- package/skills/typesafety/generated-files-and-cli.md +342 -0
- package/skills/typesafety/params-and-search.md +153 -0
- package/skills/typesafety/route-types.md +213 -0
- package/skills/use-cache/SKILL.md +430 -0
- package/skills/vercel/SKILL.md +149 -0
- package/skills/view-transitions/SKILL.md +341 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +116 -0
- package/src/__internal.ts +77 -44
- package/src/bin/rango.ts +325 -0
- package/src/browser/action-coordinator.ts +114 -0
- package/src/browser/action-fence.ts +47 -0
- package/src/browser/app-shell.ts +39 -0
- package/src/browser/app-version.ts +14 -0
- package/src/browser/connection-warmup.ts +134 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/dev-discovery.ts +66 -0
- package/src/browser/event-controller.ts +477 -217
- package/src/browser/history-state.ts +101 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/intercept-utils.ts +52 -0
- package/src/browser/invalidate-client-cache.ts +52 -0
- package/src/browser/link-interceptor.ts +487 -18
- package/src/browser/logging.ts +83 -0
- package/src/browser/merge-segment-loaders.ts +23 -13
- package/src/browser/navigation-bridge.ts +471 -570
- package/src/browser/navigation-client.ts +343 -79
- package/src/browser/navigation-store-handle.ts +38 -0
- package/src/browser/navigation-store.ts +228 -366
- package/src/browser/navigation-transaction.ts +247 -0
- package/src/browser/network-error-handler.ts +88 -0
- package/src/browser/notify-listeners.ts +22 -0
- package/src/browser/partial-update.ts +491 -365
- package/src/browser/prefetch/cache.ts +457 -0
- package/src/browser/prefetch/default-strategy.ts +74 -0
- package/src/browser/prefetch/fetch.ts +548 -0
- package/src/browser/prefetch/invalidation.ts +30 -0
- package/src/browser/prefetch/loader.ts +111 -0
- package/src/browser/prefetch/observer.ts +93 -0
- package/src/browser/prefetch/policy.ts +48 -0
- package/src/browser/prefetch/queue.ts +209 -0
- package/src/browser/prefetch/resource-ready.ts +77 -0
- package/src/browser/prefetch/runtime.ts +6 -0
- package/src/browser/rango-state.ts +215 -0
- package/src/browser/react/Link.tsx +332 -85
- package/src/browser/react/NavigationProvider.tsx +275 -109
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/context.ts +15 -0
- package/src/browser/react/filter-segment-order.ts +70 -0
- package/src/browser/react/index.ts +0 -48
- package/src/browser/react/location-state-shared.ts +272 -60
- package/src/browser/react/location-state.ts +90 -20
- package/src/browser/react/mount-context.ts +6 -1
- package/src/browser/react/nonce-context.ts +23 -0
- package/src/browser/react/shallow-equal.ts +27 -0
- package/src/browser/react/use-action.ts +35 -66
- package/src/browser/react/use-handle.ts +39 -132
- package/src/browser/react/use-href.tsx +9 -2
- package/src/browser/react/use-link-status.ts +39 -13
- package/src/browser/react/use-navigation.ts +53 -69
- package/src/browser/react/use-params.ts +75 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +127 -0
- package/src/browser/react/use-search-params.ts +174 -0
- package/src/browser/react/use-segments.ts +72 -99
- package/src/browser/response-adapter.ts +164 -0
- package/src/browser/rsc-router.tsx +446 -74
- package/src/browser/scroll-restoration.ts +140 -50
- package/src/browser/segment-reconciler.ts +253 -0
- package/src/browser/segment-structure-assert.ts +17 -1
- package/src/browser/server-action-bridge.ts +707 -603
- package/src/browser/types.ts +266 -75
- package/src/browser/validate-redirect-origin.ts +56 -0
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +324 -84
- package/src/build/generate-route-types.ts +41 -0
- package/src/build/index.ts +22 -1
- package/src/build/merge-full-manifests.ts +161 -0
- package/src/build/prefix-tree-utils.ts +123 -0
- package/src/build/route-trie.ts +54 -0
- package/src/build/route-types/ast-helpers.ts +25 -0
- package/src/build/route-types/ast-route-extraction.ts +105 -0
- package/src/build/route-types/codegen.ts +113 -0
- package/src/build/route-types/include-resolution.ts +867 -0
- package/src/build/route-types/param-extraction.ts +51 -0
- package/src/build/route-types/per-module-writer.ts +149 -0
- package/src/build/route-types/router-processing.ts +726 -0
- package/src/build/route-types/scan-filter.ts +85 -0
- package/src/build/route-types/source-scan.ts +216 -0
- package/src/build/runtime-discovery.ts +234 -0
- package/src/cache/background-task.ts +34 -0
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-exec-scope.ts +47 -0
- package/src/cache/cache-key-utils.ts +102 -0
- package/src/cache/cache-policy.ts +199 -0
- package/src/cache/cache-runtime.ts +787 -0
- package/src/cache/cache-scope.ts +478 -342
- package/src/cache/cache-tag.ts +149 -0
- package/src/cache/cf/cf-base64.ts +33 -0
- package/src/cache/cf/cf-cache-constants.ts +134 -0
- package/src/cache/cf/cf-cache-store.ts +3397 -152
- package/src/cache/cf/cf-cache-types.ts +417 -0
- package/src/cache/cf/cf-kv-utils.ts +84 -0
- package/src/cache/cf/cf-tag-marker-memo.ts +108 -0
- package/src/cache/cf/cf-zone-purge.ts +101 -0
- package/src/cache/cf/index.ts +21 -16
- package/src/cache/document-cache.ts +275 -105
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +132 -0
- package/src/cache/index.ts +33 -35
- package/src/cache/memory-segment-store.ts +457 -30
- package/src/cache/profile-registry.ts +88 -0
- package/src/cache/read-through-swr.ts +184 -0
- package/src/cache/search-params-filter.ts +118 -0
- package/src/cache/segment-codec.ts +311 -0
- package/src/cache/shell-snapshot.ts +516 -0
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/taint.ts +172 -0
- package/src/cache/types.ts +405 -212
- package/src/cache/vercel/index.ts +11 -0
- package/src/cache/vercel/vercel-cache-store.ts +1264 -0
- package/src/client-urls/client-root.tsx +168 -0
- package/src/client-urls/client-urls.ts +779 -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 +670 -0
- package/src/client-urls/types.ts +202 -0
- package/src/client.rsc.tsx +55 -21
- package/src/client.tsx +179 -330
- package/src/cloudflare/index.ts +11 -0
- package/src/cloudflare/tracing.ts +112 -0
- package/src/component-utils.ts +23 -4
- package/src/components/DefaultDocument.tsx +13 -3
- package/src/context-var.ts +168 -0
- package/src/debug.ts +19 -9
- package/src/decode-loader-results.ts +165 -0
- package/src/defer.ts +185 -0
- package/src/deps/ssr.ts +4 -2
- package/src/dev-discovery-protocol.ts +11 -0
- package/src/encode-kv.ts +49 -0
- package/src/errors.ts +149 -3
- package/src/escape-script.ts +52 -0
- package/src/handle.ts +111 -55
- package/src/handles/MetaTags.tsx +83 -59
- package/src/handles/Scripts.tsx +183 -0
- package/src/handles/breadcrumbs.ts +93 -0
- package/src/handles/deferred-resolution.ts +134 -0
- package/src/handles/is-thenable.ts +16 -0
- package/src/handles/meta.ts +44 -53
- package/src/handles/script.ts +244 -0
- package/src/host/cookie-handler.ts +20 -65
- package/src/host/errors.ts +21 -30
- package/src/host/index.ts +13 -9
- package/src/host/pattern-matcher.ts +50 -79
- package/src/host/router.ts +151 -121
- package/src/host/testing.ts +45 -32
- package/src/host/types.ts +52 -11
- package/src/host/utils.ts +2 -2
- package/src/href-client.ts +236 -31
- package/src/index.rsc.ts +252 -20
- package/src/index.ts +343 -30
- package/src/internal-debug.ts +12 -0
- package/src/loader-redirect.tsx +64 -0
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +39 -163
- package/src/loader.ts +31 -13
- package/src/missing-id-error.ts +68 -0
- package/src/outlet-context.ts +21 -1
- package/src/outlet-provider.tsx +59 -0
- package/src/prerender/build-shell-capture.ts +453 -0
- package/src/prerender/param-hash.ts +37 -0
- package/src/prerender/shell-manifest-key.ts +20 -0
- package/src/prerender/store.ts +195 -0
- package/src/prerender.ts +592 -0
- package/src/redirect-origin.ts +172 -0
- package/src/regex-escape.ts +8 -0
- package/src/render-error-thrower.tsx +20 -0
- package/src/response-utils.ts +62 -0
- package/src/reverse.ts +380 -0
- package/src/root-error-boundary.tsx +42 -48
- package/src/route-content-wrapper.tsx +123 -78
- package/src/route-definition/dsl-helpers.ts +1150 -0
- package/src/route-definition/helper-factories.ts +88 -0
- package/src/route-definition/helpers-types.ts +522 -0
- package/src/route-definition/index.ts +54 -0
- package/src/route-definition/redirect.ts +133 -0
- package/src/route-definition/resolve-handler-use.ts +160 -0
- package/src/route-definition/use-item-types.ts +29 -0
- package/src/route-definition.ts +1 -1428
- package/src/route-map-builder.ts +249 -127
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +87 -45
- package/src/router/basename.ts +14 -0
- package/src/router/content-negotiation.ts +305 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +119 -38
- package/src/router/find-match.ts +259 -0
- package/src/router/handler-context.ts +439 -86
- package/src/router/instrument.ts +401 -0
- package/src/router/intercept-resolution.ts +479 -0
- package/src/router/lazy-includes.ts +261 -0
- package/src/router/loader-resolution.ts +714 -142
- package/src/router/logging.ts +245 -0
- package/src/router/manifest.ts +225 -63
- package/src/router/match-api.ts +591 -0
- package/src/router/match-context.ts +5 -25
- package/src/router/match-handlers.ts +537 -0
- package/src/router/match-middleware/background-revalidation.ts +128 -97
- package/src/router/match-middleware/cache-lookup.ts +537 -73
- package/src/router/match-middleware/cache-store.ts +214 -60
- package/src/router/match-middleware/intercept-resolution.ts +56 -38
- package/src/router/match-middleware/segment-resolution.ts +71 -19
- package/src/router/match-pipelines.ts +11 -87
- package/src/router/match-result.ts +150 -53
- package/src/router/metrics.ts +235 -29
- package/src/router/middleware-types.ts +110 -0
- package/src/router/middleware.ts +526 -441
- package/src/router/navigation-snapshot.ts +173 -0
- package/src/router/params-util.ts +23 -0
- package/src/router/parse-pattern.ts +115 -0
- package/src/router/pattern-matching.ts +348 -149
- package/src/router/prefetch-cache-ttl.ts +51 -0
- package/src/router/prefetch-default.ts +59 -0
- package/src/router/prefetch-limits.ts +37 -0
- package/src/router/prerender-match.ts +592 -0
- package/src/router/preview-match.ts +102 -0
- package/src/router/request-classification.ts +291 -0
- package/src/router/revalidation.ts +252 -90
- package/src/router/route-snapshot.ts +256 -0
- package/src/router/route-trie-builder.ts +334 -0
- package/src/router/router-context.ts +45 -48
- package/src/router/router-interfaces.ts +614 -0
- package/src/router/router-options.ts +842 -0
- package/src/router/router-registry.ts +21 -0
- package/src/router/segment-resolution/fresh.ts +879 -0
- package/src/router/segment-resolution/helpers.ts +346 -0
- package/src/router/segment-resolution/loader-cache.ts +368 -0
- package/src/router/segment-resolution/loader-mask.ts +60 -0
- package/src/router/segment-resolution/loader-snapshot.ts +259 -0
- package/src/router/segment-resolution/mask-nested.ts +99 -0
- package/src/router/segment-resolution/revalidation.ts +1376 -0
- package/src/router/segment-resolution/static-store.ts +107 -0
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution/view-transition-default.ts +60 -0
- package/src/router/segment-resolution.ts +25 -0
- package/src/router/segment-wrappers.ts +292 -0
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/substitute-pattern-params.ts +75 -0
- package/src/router/telemetry-otel.ts +270 -0
- package/src/router/telemetry.ts +386 -0
- package/src/router/timeout.ts +179 -0
- package/src/router/tracing.ts +235 -0
- package/src/router/transition-when.ts +76 -0
- package/src/router/trie-matching.ts +351 -0
- package/src/router/types.ts +60 -39
- package/src/router/url-params.ts +57 -0
- package/src/router.ts +911 -4253
- package/src/rsc/capture-queue.ts +218 -0
- package/src/rsc/full-payload.ts +77 -0
- package/src/rsc/handler-context.ts +47 -0
- package/src/rsc/handler.ts +1226 -834
- package/src/rsc/helpers.ts +351 -19
- package/src/rsc/index.ts +2 -25
- package/src/rsc/json-route-result.ts +38 -0
- package/src/rsc/loader-fetch.ts +305 -0
- package/src/rsc/manifest-init.ts +89 -0
- package/src/rsc/nonce.ts +39 -0
- package/src/rsc/origin-guard.ts +155 -0
- package/src/rsc/progressive-enhancement.ts +686 -0
- package/src/rsc/redirect-guard.ts +102 -0
- package/src/rsc/render-pipeline.ts +611 -0
- package/src/rsc/response-cache-serve.ts +259 -0
- package/src/rsc/response-error.ts +104 -0
- package/src/rsc/response-route-handler.ts +221 -0
- package/src/rsc/routine-plan.ts +359 -0
- package/src/rsc/rsc-rendering.ts +1729 -0
- package/src/rsc/runtime-warnings.ts +55 -0
- package/src/rsc/server-action.ts +639 -0
- package/src/rsc/shell-build-manifest.ts +343 -0
- package/src/rsc/shell-capture-constants.ts +45 -0
- package/src/rsc/shell-capture.ts +2135 -0
- package/src/rsc/shell-serve.ts +350 -0
- package/src/rsc/ssr-setup.ts +236 -0
- package/src/rsc/stream-idle.ts +137 -0
- package/src/rsc/transition-gate.ts +86 -0
- package/src/rsc/types.ts +167 -14
- package/src/runtime-env.ts +18 -0
- package/src/search-params.ts +235 -0
- package/src/segment-content-promise.ts +67 -0
- package/src/segment-fragments.ts +165 -0
- package/src/segment-loader-promise.ts +167 -0
- package/src/segment-system.tsx +544 -136
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +741 -90
- package/src/server/cookie-parse.ts +32 -0
- package/src/server/cookie-store.ts +337 -0
- package/src/server/fetchable-loader-store.ts +37 -0
- package/src/server/handle-store.ts +278 -60
- package/src/server/loader-registry.ts +51 -100
- package/src/server/request-context.ts +1296 -161
- package/src/server.ts +38 -128
- package/src/ssr/index.tsx +716 -140
- package/src/ssr/inject-rsc-eager.ts +167 -0
- package/src/ssr/preinit-client-references.ts +106 -0
- package/src/ssr/ssr-root.tsx +305 -0
- package/src/ssr-suspension-warning.ts +67 -0
- package/src/static-handler.ts +139 -0
- package/src/testing/cache-status.ts +162 -0
- package/src/testing/collect-handle.ts +46 -0
- package/src/testing/dispatch.ts +951 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +147 -0
- package/src/testing/e2e/matchers.ts +35 -0
- package/src/testing/e2e/page-helpers.ts +319 -0
- package/src/testing/e2e/parity.ts +400 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +97 -0
- package/src/testing/flight-normalize.ts +11 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +257 -0
- package/src/testing/generated-routes.ts +199 -0
- package/src/testing/index.ts +121 -0
- package/src/testing/internal/context.ts +380 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +54 -0
- package/src/testing/render-handler.ts +371 -0
- package/src/testing/render-route.tsx +667 -0
- package/src/testing/run-loader.ts +423 -0
- package/src/testing/run-middleware.ts +219 -0
- package/src/testing/run-transition-when.ts +197 -0
- package/src/testing/shell-status.ts +206 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/theme/ThemeProvider.tsx +76 -98
- package/src/theme/ThemeScript.tsx +12 -14
- package/src/theme/constants.ts +57 -15
- package/src/theme/index.ts +3 -20
- package/src/theme/theme-context.ts +5 -35
- package/src/theme/theme-script.ts +43 -39
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +142 -0
- package/src/types/cache-types.ts +207 -0
- package/src/types/error-types.ts +132 -0
- package/src/types/global-namespace.ts +113 -0
- package/src/types/handler-context.ts +850 -0
- package/src/types/index.ts +82 -0
- package/src/types/loader-types.ts +273 -0
- package/src/types/request-scope.ts +112 -0
- package/src/types/route-config.ts +138 -0
- package/src/types/route-entry.ts +117 -0
- package/src/types/segments.ts +291 -0
- package/src/types.ts +1 -1623
- package/src/urls/include-helper.ts +181 -0
- package/src/urls/include-provider.ts +71 -0
- package/src/urls/index.ts +44 -0
- package/src/urls/path-helper-types.ts +435 -0
- package/src/urls/path-helper.ts +284 -0
- package/src/urls/pattern-types.ts +189 -0
- package/src/urls/response-types.ts +109 -0
- package/src/urls/type-extraction.ts +316 -0
- package/src/urls/urls-function.ts +80 -0
- package/src/urls.ts +1 -802
- package/src/use-loader.tsx +487 -138
- package/src/vercel/index.ts +11 -0
- package/src/vercel/tracing.ts +89 -0
- package/src/vite/debug.ts +185 -0
- package/src/vite/discovery/bundle-postprocess.ts +185 -0
- package/src/vite/discovery/client-urls-projection.ts +322 -0
- package/src/vite/discovery/dev-prerender-cache.ts +117 -0
- package/src/vite/discovery/discover-routers.ts +375 -0
- package/src/vite/discovery/discovery-errors.ts +255 -0
- package/src/vite/discovery/gate-state.ts +171 -0
- package/src/vite/discovery/prerender-collection.ts +494 -0
- package/src/vite/discovery/route-types-writer.ts +214 -0
- package/src/vite/discovery/self-gen-tracking.ts +73 -0
- package/src/vite/discovery/shell-prerender-phase.ts +397 -0
- package/src/vite/discovery/state.ts +215 -0
- package/src/vite/discovery/virtual-module-codegen.ts +342 -0
- package/src/vite/encryption-key.ts +29 -0
- package/src/vite/index.ts +31 -1137
- package/src/vite/inject-client-debug.ts +88 -0
- package/src/vite/plugin-types.ts +336 -0
- package/src/vite/plugins/cjs-to-esm.ts +90 -0
- package/src/vite/plugins/client-ref-dedup.ts +382 -0
- package/src/vite/plugins/client-ref-hashing.ts +118 -0
- package/src/vite/plugins/cloudflare-protocol-loader-hook.d.mts +23 -0
- package/src/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/src/vite/plugins/cloudflare-protocol-stub.ts +194 -0
- package/src/vite/{expose-action-id.ts → plugins/expose-action-id.ts} +130 -136
- package/src/vite/plugins/expose-id-utils.ts +332 -0
- package/src/vite/plugins/expose-ids/export-analysis.ts +363 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +130 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +64 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +199 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +851 -0
- package/src/vite/plugins/performance-tracks.ts +89 -0
- package/src/vite/plugins/refresh-cmd.ts +127 -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/use-cache-transform.ts +313 -0
- package/src/vite/plugins/vercel-output.ts +384 -0
- package/src/vite/plugins/version-injector.ts +93 -0
- package/src/vite/plugins/version-plugin.ts +271 -0
- package/src/vite/plugins/virtual-entries.ts +286 -0
- package/src/vite/plugins/virtual-stub-plugin.ts +29 -0
- package/src/vite/rango.ts +609 -0
- package/src/vite/router-discovery.ts +2400 -0
- package/src/vite/utils/ast-handler-extract.ts +508 -0
- package/src/vite/utils/banner.ts +36 -0
- package/src/vite/utils/bundle-analysis.ts +132 -0
- package/src/vite/utils/client-chunks.ts +184 -0
- package/src/vite/utils/directive-prologue.ts +40 -0
- package/src/vite/utils/forward-user-plugins.ts +171 -0
- package/src/vite/utils/manifest-utils.ts +12 -0
- package/src/vite/utils/package-resolution.ts +90 -0
- package/src/vite/utils/prerender-utils.ts +268 -0
- package/src/vite/utils/shared-utils.ts +283 -0
- package/CLAUDE.md +0 -43
- package/src/browser/lru-cache.ts +0 -69
- package/src/browser/request-controller.ts +0 -164
- package/src/browser/shallow.ts +0 -35
- package/src/cache/memory-store.ts +0 -253
- package/src/href.ts +0 -255
- package/src/server/route-manifest-cache.ts +0 -173
- package/src/vite/expose-handle-id.ts +0 -209
- package/src/vite/expose-loader-id.ts +0 -426
- package/src/vite/expose-location-state-id.ts +0 -177
- /package/src/vite/{version.d.ts → plugins/version.d.ts} +0 -0
package/src/rsc/handler.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="@vitejs/plugin-rsc/types" />
|
|
2
|
-
/// <reference path="../vite/version.d.ts" />
|
|
2
|
+
/// <reference path="../vite/plugins/version.d.ts" />
|
|
3
3
|
/**
|
|
4
4
|
* RSC Request Handler
|
|
5
5
|
*
|
|
@@ -7,37 +7,112 @@
|
|
|
7
7
|
* and progressive enhancement (no-JS form submissions).
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { RouteNotFoundError } from "../errors.js";
|
|
13
|
-
import { getLoaderLazy } from "../server/loader-registry.js";
|
|
14
|
-
import {
|
|
15
|
-
matchMiddleware,
|
|
16
|
-
executeMiddleware,
|
|
17
|
-
executeLoaderMiddleware,
|
|
18
|
-
} from "../router/middleware.js";
|
|
10
|
+
import { isRouteNotFoundError } from "../errors.js";
|
|
11
|
+
import { matchMiddleware, executeMiddleware } from "../router/middleware.js";
|
|
19
12
|
import {
|
|
20
13
|
runWithRequestContext,
|
|
21
14
|
setRequestContextParams,
|
|
22
|
-
|
|
15
|
+
getRequestContext,
|
|
16
|
+
_getRequestContext,
|
|
23
17
|
createRequestContext,
|
|
24
|
-
type ExecutionContext,
|
|
25
18
|
} from "../server/request-context.js";
|
|
26
19
|
import * as rscDeps from "@vitejs/plugin-rsc/rsc";
|
|
27
|
-
|
|
28
20
|
import type {
|
|
29
21
|
RscPayload,
|
|
30
|
-
ReactFormState,
|
|
31
22
|
CreateRSCHandlerOptions,
|
|
23
|
+
LoadSSRModule,
|
|
24
|
+
SSRModule,
|
|
32
25
|
} from "./types.js";
|
|
33
|
-
import {
|
|
34
|
-
|
|
26
|
+
import {
|
|
27
|
+
createResponseWithMergedHeaders,
|
|
28
|
+
finalizeResponse,
|
|
29
|
+
interceptRedirectForPartial,
|
|
30
|
+
buildRouteMiddlewareEntries,
|
|
31
|
+
} from "./helpers.js";
|
|
32
|
+
import { renderRscFlightStage, renderRscResponse } from "./render-pipeline.js";
|
|
33
|
+
import { guardOutgoingRedirect } from "./redirect-guard.js";
|
|
34
|
+
import {
|
|
35
|
+
resolveSoftRedirectUrl,
|
|
36
|
+
resolveExternalRedirect,
|
|
37
|
+
safeSameOriginLanding,
|
|
38
|
+
} from "../redirect-origin.js";
|
|
39
|
+
import { resolvedHandleStream } from "../handles/deferred-resolution.js";
|
|
40
|
+
import {
|
|
41
|
+
isWebSocketUpgradeResponse,
|
|
42
|
+
appendVaryAccept,
|
|
43
|
+
} from "../response-utils.js";
|
|
44
|
+
import {
|
|
45
|
+
handleResponseRoute,
|
|
46
|
+
type ResponseRouteMatch,
|
|
47
|
+
} from "./response-route-handler.js";
|
|
48
|
+
import { nonce as nonceToken, resolveProviderNonce } from "./nonce.js";
|
|
35
49
|
import { VERSION } from "@rangojs/router:version";
|
|
36
50
|
import type { ErrorPhase } from "../types.js";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
import type { RouterRequestInput } from "../router/router-interfaces.js";
|
|
52
|
+
import {
|
|
53
|
+
invokeOnError,
|
|
54
|
+
resolveDefaultNotFound,
|
|
55
|
+
} from "../router/error-handling.js";
|
|
56
|
+
import {
|
|
57
|
+
createReverseFunction,
|
|
58
|
+
stripInternalParams,
|
|
59
|
+
} from "../router/handler-context.js";
|
|
60
|
+
import { contextSet } from "../context-var.js";
|
|
61
|
+
import {
|
|
62
|
+
hasCachedManifest,
|
|
63
|
+
waitForManifestReady,
|
|
64
|
+
getRouterManifest,
|
|
65
|
+
getRouterTrie,
|
|
66
|
+
} from "../route-map-builder.js";
|
|
67
|
+
import type { HandlerContext } from "./handler-context.js";
|
|
68
|
+
import type { CacheErrorCategory } from "../cache/cache-error.js";
|
|
69
|
+
import {
|
|
70
|
+
compileSearchParamsFilter,
|
|
71
|
+
type SearchParamsFilter,
|
|
72
|
+
} from "../cache/search-params-filter.js";
|
|
73
|
+
import type { SegmentCacheStore } from "../cache/types.js";
|
|
74
|
+
import { buildRouterTrieFromUrlpatterns } from "./manifest-init.js";
|
|
75
|
+
import { handleProgressiveEnhancement } from "./progressive-enhancement.js";
|
|
76
|
+
import {
|
|
77
|
+
executeServerAction,
|
|
78
|
+
revalidateAfterAction,
|
|
79
|
+
type ActionContinuation,
|
|
80
|
+
} from "./server-action.js";
|
|
81
|
+
import { handleLoaderFetch } from "./loader-fetch.js";
|
|
82
|
+
import { applyStreamIdleTimeout } from "./stream-idle.js";
|
|
83
|
+
import {
|
|
84
|
+
checkRequestOrigin,
|
|
85
|
+
ORIGIN_CHECK_PHASE_BY_MODE,
|
|
86
|
+
} from "./origin-guard.js";
|
|
87
|
+
import { handleRscRendering } from "./rsc-rendering.js";
|
|
88
|
+
import {
|
|
89
|
+
withTimeout,
|
|
90
|
+
isTimeoutEnabled,
|
|
91
|
+
RouterTimeoutError,
|
|
92
|
+
createDefaultTimeoutResponse,
|
|
93
|
+
type TimeoutPhase,
|
|
94
|
+
type RenderTimeoutContext,
|
|
95
|
+
} from "../router/timeout.js";
|
|
96
|
+
import {
|
|
97
|
+
createMetricsStore,
|
|
98
|
+
appendMetric,
|
|
99
|
+
buildMetricsTiming,
|
|
100
|
+
} from "../router/metrics.js";
|
|
101
|
+
import { observePhase, PHASES } from "../router/instrument.js";
|
|
102
|
+
import { safeEmit, resolveSink, getRequestId } from "../router/telemetry.js";
|
|
103
|
+
import {
|
|
104
|
+
startSSRSetup,
|
|
105
|
+
createSsrHtmlStage,
|
|
106
|
+
mayNeedSSR,
|
|
107
|
+
isRscRequest,
|
|
108
|
+
SSR_SETUP_VAR,
|
|
109
|
+
} from "./ssr-setup.js";
|
|
110
|
+
import {
|
|
111
|
+
classifyRequest,
|
|
112
|
+
type RequestPlan,
|
|
113
|
+
type ExecutableRequestPlan,
|
|
114
|
+
} from "../router/request-classification.js";
|
|
115
|
+
import { INTERNAL_RANGO_DEBUG } from "../internal-debug.js";
|
|
41
116
|
|
|
42
117
|
/**
|
|
43
118
|
* Create an RSC request handler.
|
|
@@ -72,12 +147,35 @@ import { generateManifest } from "../build/generate-manifest.js";
|
|
|
72
147
|
* });
|
|
73
148
|
* ```
|
|
74
149
|
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Response that tells the client to do a full document navigation. Shared by
|
|
153
|
+
* the terminal reload plans (version-mismatch and app-switch): an empty 200
|
|
154
|
+
* carrying X-RSC-Reload, which the client turns into window.location.href.
|
|
155
|
+
*/
|
|
156
|
+
function createReloadResponse(reloadUrl: string) {
|
|
157
|
+
return createResponseWithMergedHeaders(null, {
|
|
158
|
+
status: 200,
|
|
159
|
+
headers: {
|
|
160
|
+
"X-RSC-Reload": reloadUrl,
|
|
161
|
+
"content-type": "text/x-component;charset=utf-8",
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
75
166
|
export function createRSCHandler<
|
|
76
167
|
TEnv = unknown,
|
|
77
168
|
TRoutes extends Record<string, string> = Record<string, string>,
|
|
78
169
|
>(options: CreateRSCHandlerOptions<TEnv, TRoutes>) {
|
|
79
170
|
const { router, version = VERSION, nonce: nonceProvider } = options;
|
|
80
171
|
|
|
172
|
+
// Handler-owned registry of explicit per-scope stores from cache({ store }).
|
|
173
|
+
// Lives in the closure so it is scoped per handler (multi-router deployments
|
|
174
|
+
// get separate registries) and accumulates every explicit store this handler
|
|
175
|
+
// resolves across requests. updateTag()/revalidateTag() iterate it to reach
|
|
176
|
+
// stores not covered by the app-level ctx._cacheStore.
|
|
177
|
+
const explicitTaggedStores = new Set<SegmentCacheStore>();
|
|
178
|
+
|
|
81
179
|
// Use provided deps or default to @vitejs/plugin-rsc/rsc exports
|
|
82
180
|
const deps = options.deps ?? rscDeps;
|
|
83
181
|
const {
|
|
@@ -89,104 +187,426 @@ export function createRSCHandler<
|
|
|
89
187
|
decodeFormState,
|
|
90
188
|
} = deps;
|
|
91
189
|
|
|
92
|
-
// Use provided loadSSRModule or default to vite RSC module loader
|
|
93
|
-
|
|
190
|
+
// Use provided loadSSRModule or default to vite RSC module loader.
|
|
191
|
+
// In production the SSR module is stable across requests, so memoize
|
|
192
|
+
// the dynamic import to avoid repeated module resolution overhead.
|
|
193
|
+
// In dev mode Vite may hot-reload the module, so skip memoization.
|
|
194
|
+
const rawLoadSSRModule: LoadSSRModule =
|
|
94
195
|
options.loadSSRModule ??
|
|
95
196
|
(() => import.meta.viteRsc.loadModule("ssr", "index"));
|
|
197
|
+
let _ssrModulePromise: Promise<SSRModule> | undefined;
|
|
198
|
+
const loadSSRModule: LoadSSRModule =
|
|
199
|
+
process.env.NODE_ENV === "production"
|
|
200
|
+
? () =>
|
|
201
|
+
(_ssrModulePromise ??= rawLoadSSRModule().catch((err) => {
|
|
202
|
+
_ssrModulePromise = undefined;
|
|
203
|
+
throw err;
|
|
204
|
+
}))
|
|
205
|
+
: rawLoadSSRModule;
|
|
96
206
|
|
|
97
207
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
208
|
+
* Per-request error reporter that deduplicates via the ALS request context.
|
|
209
|
+
*
|
|
210
|
+
* Uses the same _reportedErrors WeakSet as the router layer so errors
|
|
211
|
+
* that propagate across layers are only reported once per request.
|
|
100
212
|
*/
|
|
101
213
|
function callOnError(
|
|
102
214
|
error: unknown,
|
|
103
215
|
phase: ErrorPhase,
|
|
104
216
|
context: Parameters<typeof invokeOnError<TEnv>>[3],
|
|
105
217
|
): void {
|
|
218
|
+
// Guard: abort signal handlers fire asynchronously outside the ALS
|
|
219
|
+
// request scope, so the context may be gone. Skip dedup in that
|
|
220
|
+
// case — the error is from a cancelled stream, not a real failure.
|
|
221
|
+
const reqCtx = _getRequestContext();
|
|
222
|
+
if (error != null && typeof error === "object" && reqCtx) {
|
|
223
|
+
if (reqCtx._reportedErrors.has(error)) return;
|
|
224
|
+
reqCtx._reportedErrors.add(error);
|
|
225
|
+
}
|
|
106
226
|
invokeOnError(router.onError, error, phase, context, "RSC");
|
|
107
227
|
}
|
|
108
228
|
|
|
109
|
-
|
|
229
|
+
function getRequiredRouteMap(): Record<string, string> {
|
|
230
|
+
const routeMap = getRouterManifest(router.id);
|
|
231
|
+
if (!routeMap) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
`Route manifest for router "${router.id}" is not available.`,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
return routeMap;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Handle a timeout by reporting the error, emitting telemetry,
|
|
241
|
+
* and returning either the custom onTimeout response or a default 504.
|
|
242
|
+
*/
|
|
243
|
+
async function handleTimeoutResponse(
|
|
110
244
|
request: Request,
|
|
111
|
-
env: TEnv
|
|
112
|
-
|
|
245
|
+
env: TEnv,
|
|
246
|
+
url: URL,
|
|
247
|
+
phase: TimeoutPhase,
|
|
248
|
+
durationMs: number,
|
|
249
|
+
routeKey?: string,
|
|
250
|
+
actionId?: string,
|
|
251
|
+
): Promise<Response> {
|
|
252
|
+
const timeoutError = new RouterTimeoutError(phase, durationMs);
|
|
253
|
+
const requestContext = _getRequestContext<TEnv>();
|
|
254
|
+
const cursor = requestContext?._renderForeground;
|
|
255
|
+
const render: RenderTimeoutContext | undefined =
|
|
256
|
+
phase === "render-start" && cursor
|
|
257
|
+
? {
|
|
258
|
+
mode: cursor.mode,
|
|
259
|
+
phase: cursor.phase,
|
|
260
|
+
state: cursor.state,
|
|
261
|
+
completed: cursor.completed,
|
|
262
|
+
total: cursor.total,
|
|
263
|
+
...(cursor.phaseStartedAt !== undefined && {
|
|
264
|
+
phaseDurationMs: performance.now() - cursor.phaseStartedAt,
|
|
265
|
+
}),
|
|
266
|
+
}
|
|
267
|
+
: undefined;
|
|
268
|
+
const trace =
|
|
269
|
+
phase === "render-start" ? requestContext?._activeRoutine : undefined;
|
|
270
|
+
const activeEntries = trace?.active() ?? [];
|
|
271
|
+
const activeStep = activeEntries.at(-1);
|
|
272
|
+
const activeAt = performance.now();
|
|
273
|
+
const routineSnapshot =
|
|
274
|
+
trace && activeStep
|
|
275
|
+
? {
|
|
276
|
+
name: trace.name,
|
|
277
|
+
path: activeEntries.map((entry) => entry.name),
|
|
278
|
+
durationMs: activeAt - activeStep.startedAt,
|
|
279
|
+
}
|
|
280
|
+
: undefined;
|
|
281
|
+
|
|
282
|
+
if (INTERNAL_RANGO_DEBUG && trace && activeStep) {
|
|
283
|
+
console.log(
|
|
284
|
+
`[routine] TIMEOUT ${request.method} ${url.pathname} (${trace.name})\n${trace.formatActive(activeEntries, activeAt)}`,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Each surface gets its OWN shallow render snapshot. A consumer that mutates
|
|
289
|
+
// its copy must not corrupt what the other two observe. The internal-debug
|
|
290
|
+
// routine snapshot is bounded metadata sent only to onError.
|
|
291
|
+
callOnError(timeoutError, phase === "action" ? "action" : "handler", {
|
|
292
|
+
request,
|
|
293
|
+
url,
|
|
294
|
+
env,
|
|
295
|
+
routeKey,
|
|
296
|
+
actionId,
|
|
297
|
+
handledByBoundary: false,
|
|
298
|
+
metadata: {
|
|
299
|
+
timeout: true,
|
|
300
|
+
phase,
|
|
301
|
+
durationMs,
|
|
302
|
+
...(render && { render: { ...render } }),
|
|
303
|
+
...(routineSnapshot && { routine: routineSnapshot }),
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
if (router.telemetry) {
|
|
308
|
+
safeEmit(resolveSink(router.telemetry), {
|
|
309
|
+
type: "request.timeout",
|
|
310
|
+
timestamp: performance.now(),
|
|
311
|
+
requestId: getRequestId(request),
|
|
312
|
+
phase,
|
|
313
|
+
pathname: url.pathname,
|
|
314
|
+
routeKey,
|
|
315
|
+
actionId,
|
|
316
|
+
durationMs,
|
|
317
|
+
customHandler: !!router.onTimeout,
|
|
318
|
+
...(render && { render: { ...render } }),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (router.onTimeout) {
|
|
323
|
+
try {
|
|
324
|
+
return await router.onTimeout({
|
|
325
|
+
phase,
|
|
326
|
+
request,
|
|
327
|
+
url,
|
|
328
|
+
env,
|
|
329
|
+
routeKey,
|
|
330
|
+
actionId,
|
|
331
|
+
durationMs,
|
|
332
|
+
...(render && { render: { ...render } }),
|
|
333
|
+
});
|
|
334
|
+
} catch (e) {
|
|
335
|
+
if (process.env.NODE_ENV !== "production") {
|
|
336
|
+
console.error("[RSC] onTimeout callback error:", e);
|
|
337
|
+
}
|
|
338
|
+
return createDefaultTimeoutResponse(phase);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return createDefaultTimeoutResponse(phase);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Build a 200 Flight response that carries a redirect URL and optional state.
|
|
347
|
+
* Used when a partial/action request results in a redirect -- fetch
|
|
348
|
+
* auto-follows 3xx so we send the redirect as payload metadata instead.
|
|
349
|
+
*
|
|
350
|
+
* The redirect URL is resolved with {@link resolveSoftRedirectUrl} against
|
|
351
|
+
* the current request origin so an unsafe target never leaves as Flight
|
|
352
|
+
* metadata (client validators remain defense-in-depth).
|
|
353
|
+
*/
|
|
354
|
+
function createRedirectFlightResponse(
|
|
355
|
+
redirectUrl: string,
|
|
356
|
+
locationState?: Record<string, unknown>,
|
|
357
|
+
external?: boolean,
|
|
358
|
+
): Response {
|
|
359
|
+
const reqCtx = _getRequestContext<TEnv>();
|
|
360
|
+
const requestOrigin =
|
|
361
|
+
reqCtx?.url.origin ?? new URL("http://localhost").origin;
|
|
362
|
+
// Resolve with the same policy as 3xx guardOutgoingRedirect. Keep
|
|
363
|
+
// external:true only when the external scheme check passed; a neutralized
|
|
364
|
+
// landing (javascript:/blocked) must not advertise external.
|
|
365
|
+
let resolvedUrl: string;
|
|
366
|
+
let resolvedExternal = false;
|
|
367
|
+
if (external) {
|
|
368
|
+
const ext = resolveExternalRedirect(redirectUrl, requestOrigin);
|
|
369
|
+
if (ext !== null) {
|
|
370
|
+
resolvedUrl = ext;
|
|
371
|
+
resolvedExternal = true;
|
|
372
|
+
} else {
|
|
373
|
+
resolvedUrl = safeSameOriginLanding(router.basename);
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
resolvedUrl = resolveSoftRedirectUrl(
|
|
377
|
+
redirectUrl,
|
|
378
|
+
requestOrigin,
|
|
379
|
+
router.basename,
|
|
380
|
+
false,
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
const redirectPayload: RscPayload = {
|
|
384
|
+
metadata: {
|
|
385
|
+
pathname: resolvedUrl,
|
|
386
|
+
segments: [],
|
|
387
|
+
redirect: {
|
|
388
|
+
url: resolvedUrl,
|
|
389
|
+
...(resolvedExternal && { external: true }),
|
|
390
|
+
},
|
|
391
|
+
...(locationState && { locationState }),
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
const rscStream = reqCtx
|
|
395
|
+
? renderRscFlightStage({
|
|
396
|
+
ctx: { renderToReadableStream, callOnError },
|
|
397
|
+
request: reqCtx.request,
|
|
398
|
+
url: reqCtx.url,
|
|
399
|
+
env: reqCtx.env,
|
|
400
|
+
payload: redirectPayload,
|
|
401
|
+
tracking: {
|
|
402
|
+
mode: reqCtx.url.searchParams.has("_rsc_action")
|
|
403
|
+
? "action-revalidation"
|
|
404
|
+
: "partial",
|
|
405
|
+
routeKey: reqCtx._routeName,
|
|
406
|
+
},
|
|
407
|
+
}).stream
|
|
408
|
+
: renderToReadableStream<RscPayload>(redirectPayload);
|
|
409
|
+
return createResponseWithMergedHeaders(rscStream, {
|
|
410
|
+
status: 200,
|
|
411
|
+
headers: { "content-type": "text/x-component;charset=utf-8" },
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Bundle shared dependencies for extracted handler functions.
|
|
416
|
+
// callOnError reads from ALS so it's inherently per-request scoped.
|
|
417
|
+
const handlerCtx: HandlerContext<TEnv> = {
|
|
418
|
+
router,
|
|
419
|
+
version,
|
|
420
|
+
devDiscoveryEpoch: router.__devDiscoveryEpoch,
|
|
421
|
+
renderToReadableStream,
|
|
422
|
+
decodeReply,
|
|
423
|
+
createTemporaryReferenceSet,
|
|
424
|
+
loadServerAction,
|
|
425
|
+
decodeAction,
|
|
426
|
+
decodeFormState,
|
|
427
|
+
loadSSRModule,
|
|
428
|
+
callOnError,
|
|
429
|
+
getRequiredRouteMap,
|
|
430
|
+
createRedirectFlightResponse,
|
|
431
|
+
resolveStreamMode: async (request, env, url) => {
|
|
432
|
+
const resolver = router.ssr?.resolveStreaming;
|
|
433
|
+
if (!resolver) return "stream";
|
|
434
|
+
return resolver({ request, env, url });
|
|
113
435
|
},
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
return async function handler(
|
|
439
|
+
request: Request,
|
|
440
|
+
input: RouterRequestInput<TEnv> = {},
|
|
114
441
|
): Promise<Response> {
|
|
442
|
+
const handlerStart = performance.now();
|
|
443
|
+
// Create the metrics store at handler start so handler:total has startTime=0
|
|
444
|
+
// and all metrics are relative to the request entry point.
|
|
445
|
+
const earlyMetricsStore = router.debugPerformance
|
|
446
|
+
? createMetricsStore(true, handlerStart)
|
|
447
|
+
: undefined;
|
|
448
|
+
|
|
449
|
+
const { env = {} as TEnv, vars: initialVars, ctx: executionCtx } = input;
|
|
450
|
+
|
|
115
451
|
// Connection warmup: return 204 immediately before any processing
|
|
116
|
-
if (router
|
|
452
|
+
if (router?.warmupEnabled && request.method === "HEAD") {
|
|
117
453
|
const warmupUrl = new URL(request.url);
|
|
118
454
|
if (warmupUrl.searchParams.has("_rsc_warmup")) {
|
|
119
455
|
return new Response(null, { status: 204 });
|
|
120
456
|
}
|
|
121
457
|
}
|
|
122
458
|
|
|
123
|
-
// Resolve nonce if provider is set
|
|
459
|
+
// Resolve nonce if provider is set. false/"" normalize to undefined —
|
|
460
|
+
// the per-request opt-out (resolveProviderNonce).
|
|
461
|
+
const nonceStart = performance.now();
|
|
124
462
|
let nonce: string | undefined;
|
|
125
463
|
if (nonceProvider) {
|
|
126
|
-
|
|
127
|
-
nonce = result === true ? generateNonce() : result;
|
|
464
|
+
nonce = resolveProviderNonce(await nonceProvider(request, env));
|
|
128
465
|
}
|
|
466
|
+
const nonceDur = performance.now() - nonceStart;
|
|
129
467
|
|
|
130
468
|
const url = new URL(request.url);
|
|
131
469
|
|
|
132
470
|
// Match global middleware
|
|
471
|
+
const mwMatchStart = performance.now();
|
|
133
472
|
const matchedMiddleware = matchMiddleware(url.pathname, router.middleware);
|
|
473
|
+
const mwMatchDur = performance.now() - mwMatchStart;
|
|
134
474
|
|
|
135
475
|
// Shared variables between middleware and route handlers
|
|
136
|
-
// Initialize from
|
|
137
|
-
const variables: Record<string, any> =
|
|
138
|
-
|
|
139
|
-
|
|
476
|
+
// Initialize from input.vars if provided (allows pre-seeding from worker entry)
|
|
477
|
+
const variables: Record<string, any> = initialVars
|
|
478
|
+
? { ...initialVars }
|
|
479
|
+
: {};
|
|
140
480
|
|
|
141
|
-
// Store nonce
|
|
481
|
+
// Store nonce via ContextVar token and string key for backward compat
|
|
142
482
|
if (nonce) {
|
|
483
|
+
contextSet(variables, nonceToken, nonce);
|
|
143
484
|
variables.nonce = nonce;
|
|
144
485
|
}
|
|
145
486
|
|
|
146
487
|
// Resolve cache store configuration
|
|
147
488
|
// Priority: options.cache (handler override) > router.cache (router default)
|
|
148
489
|
// Store is enabled only if: config provided, enabled, and no ?__no_cache query param
|
|
149
|
-
let cacheStore
|
|
490
|
+
let cacheStore: SegmentCacheStore | undefined;
|
|
491
|
+
let searchParamsFilter: SearchParamsFilter | undefined;
|
|
150
492
|
const cacheOption = options.cache ?? router.cache;
|
|
151
493
|
if (cacheOption && !url.searchParams.has("__no_cache")) {
|
|
152
494
|
const cacheConfig =
|
|
153
|
-
typeof cacheOption === "function"
|
|
495
|
+
typeof cacheOption === "function"
|
|
496
|
+
? cacheOption(env, executionCtx)
|
|
497
|
+
: cacheOption;
|
|
154
498
|
|
|
155
499
|
if (cacheConfig.enabled !== false) {
|
|
156
500
|
cacheStore = cacheConfig.store;
|
|
501
|
+
searchParamsFilter = compileSearchParamsFilter(
|
|
502
|
+
cacheConfig.searchParams,
|
|
503
|
+
);
|
|
157
504
|
}
|
|
158
505
|
}
|
|
159
506
|
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
507
|
+
// Route manifest is populated at startup via the virtual module
|
|
508
|
+
// (virtual:rsc-router/routes-manifest). In build/production, it's inlined
|
|
509
|
+
// into the bundle. In dev mode (Node), the discovery plugin populates it
|
|
510
|
+
// via setManifestReadyPromise(). In dev mode (Cloudflare), Miniflare runs
|
|
511
|
+
// in a separate isolate where module-level state doesn't carry over, so
|
|
512
|
+
// we generate inline from the router's urlpatterns.
|
|
513
|
+
//
|
|
514
|
+
// In multi-router setups (e.g. createHostRouter), each router must have
|
|
515
|
+
// its own per-router manifest. We check per-router data first: even if
|
|
516
|
+
// the global manifest was set by a different router, this router still
|
|
517
|
+
// needs its own trie and manifest for correct matching.
|
|
518
|
+
const manifestCacheStart = performance.now();
|
|
519
|
+
const hasRouterData = getRouterManifest(router.id) !== undefined;
|
|
520
|
+
if (!hasRouterData) {
|
|
521
|
+
if (!hasCachedManifest()) {
|
|
522
|
+
const readyPromise = waitForManifestReady();
|
|
523
|
+
if (readyPromise) {
|
|
524
|
+
await readyPromise;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (!getRouterManifest(router.id) && router.urlpatterns) {
|
|
528
|
+
// Cloudflare dev: generate manifest inline for this router.
|
|
529
|
+
// Each router generates its own manifest independently so
|
|
530
|
+
// multi-router setups (host routing) work correctly.
|
|
531
|
+
await buildRouterTrieFromUrlpatterns(router);
|
|
532
|
+
}
|
|
533
|
+
if (!getRouterManifest(router.id) && !hasCachedManifest()) {
|
|
534
|
+
throw new Error(
|
|
535
|
+
'Route manifest not available. Ensure "virtual:rsc-router/routes-manifest" is imported in your entry file.',
|
|
536
|
+
);
|
|
537
|
+
}
|
|
173
538
|
}
|
|
174
539
|
|
|
175
|
-
//
|
|
176
|
-
// This
|
|
540
|
+
// Rebuild the trie when the manifest exists but the per-router trie is
|
|
541
|
+
// missing. This happens in dev mode after HMR: the virtual module sets
|
|
542
|
+
// the manifest (from fresh gen files) but the trie is intentionally not
|
|
543
|
+
// injected to avoid stale discovery-time data. Without the trie, route
|
|
544
|
+
// matching falls back to regex iteration which does not handle wildcard
|
|
545
|
+
// priority correctly (catch-all patterns match before specific routes).
|
|
546
|
+
if (!getRouterTrie(router.id) && router.urlpatterns) {
|
|
547
|
+
await buildRouterTrieFromUrlpatterns(router);
|
|
548
|
+
}
|
|
549
|
+
const manifestCacheDur = performance.now() - manifestCacheStart;
|
|
177
550
|
|
|
178
551
|
// Create unified request context with all methods
|
|
179
552
|
// Includes: stub response, handle store, loader memoization, use(), cookies, headers, cache store
|
|
180
553
|
// params starts empty, populated after route matching via setRequestContextParams
|
|
554
|
+
const ctxCreateStart = performance.now();
|
|
181
555
|
const requestContext = createRequestContext({
|
|
182
556
|
env,
|
|
183
557
|
request,
|
|
184
558
|
url,
|
|
185
559
|
variables,
|
|
186
560
|
cacheStore,
|
|
187
|
-
|
|
561
|
+
searchParamsFilter,
|
|
562
|
+
explicitTaggedStores,
|
|
563
|
+
cacheProfiles: router.cacheProfiles,
|
|
564
|
+
executionContext: executionCtx,
|
|
188
565
|
themeConfig: router.themeConfig,
|
|
566
|
+
stateCookieName: router.resolvedStateCookieName,
|
|
567
|
+
version,
|
|
189
568
|
});
|
|
569
|
+
// Gate on the SAME enabled-semantics withTimeout uses (isTimeoutEnabled):
|
|
570
|
+
// a `renderStartMs: 0` / negative opt-out disables the timeout, so the
|
|
571
|
+
// driver's cursor bookkeeping (which only the timeout reads) must be off too.
|
|
572
|
+
requestContext._renderDiagnosticsEnabled = isTimeoutEnabled(
|
|
573
|
+
router.timeouts.renderStartMs,
|
|
574
|
+
);
|
|
575
|
+
// Thread the true request entry timestamp onto the context so a metrics
|
|
576
|
+
// store created MID-request (ctx.debugPerformance() / getMetricsStore) anchors
|
|
577
|
+
// to the real start, not the opt-in moment — phases that began earlier then
|
|
578
|
+
// report non-negative offsets. Set unconditionally: debug may be enabled later.
|
|
579
|
+
requestContext._handlerStart = handlerStart;
|
|
580
|
+
if (earlyMetricsStore) {
|
|
581
|
+
requestContext._debugPerformance = true;
|
|
582
|
+
requestContext._metricsStore = earlyMetricsStore;
|
|
583
|
+
}
|
|
584
|
+
// Wire background error reporting so "use cache" and other subsystems
|
|
585
|
+
// can surface non-fatal errors through the router's onError callback.
|
|
586
|
+
requestContext._reportBackgroundError = (
|
|
587
|
+
error: unknown,
|
|
588
|
+
category: CacheErrorCategory,
|
|
589
|
+
) => {
|
|
590
|
+
callOnError(error, "cache", {
|
|
591
|
+
request,
|
|
592
|
+
url,
|
|
593
|
+
metadata: { category },
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
const ctxCreateDur = performance.now() - ctxCreateStart;
|
|
598
|
+
|
|
599
|
+
// Accumulate handler-level timing for Server-Timing header
|
|
600
|
+
const handlerTiming = [
|
|
601
|
+
`handler-nonce;dur=${nonceDur.toFixed(2)}`,
|
|
602
|
+
`handler-mw-match;dur=${mwMatchDur.toFixed(2)}`,
|
|
603
|
+
`handler-manifest-cache;dur=${manifestCacheDur.toFixed(2)}`,
|
|
604
|
+
`handler-ctx-create;dur=${ctxCreateDur.toFixed(2)}`,
|
|
605
|
+
];
|
|
606
|
+
|
|
607
|
+
// Store timing data in variables for downstream access
|
|
608
|
+
variables.__handlerTiming = handlerTiming;
|
|
609
|
+
variables.__handlerStart = handlerStart;
|
|
190
610
|
|
|
191
611
|
// Wrap entire request handling in request context
|
|
192
612
|
// Makes context available via getRequestContext() throughout:
|
|
@@ -195,885 +615,857 @@ export function createRSCHandler<
|
|
|
195
615
|
// - Server components during rendering
|
|
196
616
|
// - Error boundaries
|
|
197
617
|
// - Streaming
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
618
|
+
// Store basename on request context (scoped per-request via existing ALS)
|
|
619
|
+
requestContext._basename = router.basename;
|
|
620
|
+
requestContext._routerId = router.id;
|
|
621
|
+
|
|
622
|
+
// Resolved span tracing for this request (read at each traced phase).
|
|
623
|
+
requestContext._tracing = router.tracing;
|
|
624
|
+
|
|
625
|
+
// The "rango.request" span is opened inside the request context so the
|
|
626
|
+
// Cloudflare runner can read executionContext.tracing, and so every nested
|
|
627
|
+
// phase span (and the platform's automatic KV/D1/fetch spans) nests under
|
|
628
|
+
// it. Construction-bound: the span ends when the Response is built, never
|
|
629
|
+
// wrapping the streamed body. metric:false — handler:total is metered
|
|
630
|
+
// directly below (a grand total incl. the pre-context bootstrap timings).
|
|
631
|
+
// When tracing is off this is a direct pass-through.
|
|
632
|
+
return runWithRequestContext(requestContext, () =>
|
|
633
|
+
observePhase(PHASES.request, async (span) => {
|
|
634
|
+
span.setAttribute("http.method", request.method);
|
|
635
|
+
// The matched route template is not known until match() runs later, so
|
|
636
|
+
// emit the concrete path as url.path (low-level), NOT http.route — the
|
|
637
|
+
// latter is reserved for the low-cardinality template (OTel convention).
|
|
638
|
+
span.setAttribute("url.path", url.pathname);
|
|
639
|
+
|
|
640
|
+
// Core handler logic (wrapped by middleware)
|
|
641
|
+
const coreHandler = async (): Promise<Response> => {
|
|
642
|
+
return coreRequestHandler(request, env, url, variables, nonce);
|
|
643
|
+
};
|
|
203
644
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
645
|
+
// Execute middleware chain if any, otherwise call core handler
|
|
646
|
+
// directly; the response is finalized below, inside the response span.
|
|
647
|
+
const hasMiddleware = matchedMiddleware.length > 0;
|
|
648
|
+
const downstream = hasMiddleware
|
|
649
|
+
? await executeMiddleware(
|
|
650
|
+
matchedMiddleware,
|
|
651
|
+
request,
|
|
652
|
+
env,
|
|
653
|
+
variables,
|
|
654
|
+
coreHandler,
|
|
655
|
+
createReverseFunction(getRequiredRouteMap()),
|
|
656
|
+
)
|
|
657
|
+
: await coreHandler();
|
|
658
|
+
|
|
659
|
+
// Final response construction + host handoff, wrapped in rango.response
|
|
660
|
+
// — the explicit stream-handoff marker. The callback is synchronous, so
|
|
661
|
+
// the span ends immediately before the handler returns the response to
|
|
662
|
+
// the host; it never reads or wraps response.body. A downstream throw
|
|
663
|
+
// skips it entirely (no response exists to hand off).
|
|
664
|
+
return observePhase(PHASES.response, (responseSpan) => {
|
|
665
|
+
let response: Response;
|
|
666
|
+
if (hasMiddleware) {
|
|
667
|
+
if (
|
|
668
|
+
url.searchParams.has("_rsc_partial") ||
|
|
669
|
+
url.searchParams.has("_rsc_action")
|
|
670
|
+
) {
|
|
671
|
+
const intercepted = interceptRedirectForPartial(
|
|
672
|
+
downstream,
|
|
673
|
+
createRedirectFlightResponse,
|
|
674
|
+
{ requestOrigin: url.origin, basename: router.basename },
|
|
675
|
+
);
|
|
676
|
+
response = intercepted ?? finalizeResponse(downstream);
|
|
677
|
+
} else {
|
|
678
|
+
response = finalizeResponse(downstream);
|
|
679
|
+
}
|
|
680
|
+
} else {
|
|
681
|
+
response = downstream;
|
|
682
|
+
}
|
|
214
683
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
684
|
+
// Finalize metrics after all middleware (including post-next work)
|
|
685
|
+
// has completed so :post spans are captured in the timeline.
|
|
686
|
+
// Handler timing parts are always emitted (even without debug metrics)
|
|
687
|
+
// so non-debug requests still get bootstrap Server-Timing entries.
|
|
688
|
+
const handlerTimingArr: string[] = variables.__handlerTiming || [];
|
|
689
|
+
// Preserve any existing Server-Timing set by response routes or middleware
|
|
690
|
+
const existingTiming = response.headers.get("Server-Timing");
|
|
691
|
+
const timingParts = existingTiming
|
|
692
|
+
? [existingTiming, ...handlerTimingArr]
|
|
693
|
+
: [...handlerTimingArr];
|
|
694
|
+
|
|
695
|
+
const metricsStore = requestContext._metricsStore;
|
|
696
|
+
if (metricsStore) {
|
|
697
|
+
// When the store was created at handler start (earlyMetricsStore),
|
|
698
|
+
// handler:total covers the full request. When ctx.debugPerformance()
|
|
699
|
+
// created the store mid-request its requestStart is now the threaded
|
|
700
|
+
// _handlerStart (== handlerStart), so both branches yield the true
|
|
701
|
+
// request entry; reading the store's own anchor keeps this correct even
|
|
702
|
+
// if a store ever lands without the threading (falls back to its start).
|
|
703
|
+
const totalStart = earlyMetricsStore
|
|
704
|
+
? handlerStart
|
|
705
|
+
: metricsStore.requestStart;
|
|
706
|
+
appendMetric(
|
|
707
|
+
metricsStore,
|
|
708
|
+
"handler:total",
|
|
709
|
+
totalStart,
|
|
710
|
+
performance.now() - totalStart,
|
|
711
|
+
);
|
|
712
|
+
const metricsTiming = buildMetricsTiming(
|
|
713
|
+
request.method,
|
|
714
|
+
url.pathname,
|
|
715
|
+
metricsStore,
|
|
716
|
+
);
|
|
717
|
+
if (metricsTiming) timingParts.push(metricsTiming);
|
|
718
|
+
}
|
|
218
719
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (preview?.routeMiddleware && preview.routeMiddleware.length > 0) {
|
|
230
|
-
// Convert route middleware to app middleware format for execution
|
|
231
|
-
const middlewareEntries = preview.routeMiddleware.map((mw) => ({
|
|
232
|
-
entry: {
|
|
233
|
-
pattern: null,
|
|
234
|
-
regex: null,
|
|
235
|
-
paramNames: [],
|
|
236
|
-
handler: mw.handler,
|
|
237
|
-
mountPrefix: null,
|
|
238
|
-
},
|
|
239
|
-
params: mw.params,
|
|
240
|
-
}));
|
|
720
|
+
const fullTiming = timingParts.join(", ");
|
|
721
|
+
if (fullTiming && !isWebSocketUpgradeResponse(response)) {
|
|
722
|
+
try {
|
|
723
|
+
response.headers.set("Server-Timing", fullTiming);
|
|
724
|
+
} catch {
|
|
725
|
+
// Immutable headers (e.g. a passed-through platform Response) — drop
|
|
726
|
+
// the timing header, never the response. Instrumentation must not
|
|
727
|
+
// 500 a request.
|
|
728
|
+
}
|
|
729
|
+
}
|
|
241
730
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
731
|
+
// Single open-redirect chokepoint: every response (PE, full-page,
|
|
732
|
+
// middleware short-circuit, response-route) funnels through here, so
|
|
733
|
+
// guarding browser-followed (3xx) redirects once covers them all and any
|
|
734
|
+
// future redirect exit. Soft SPA/Flight redirects are 200/204 and pass
|
|
735
|
+
// through untouched (validated client-side instead).
|
|
736
|
+
const guarded = guardOutgoingRedirect(
|
|
737
|
+
response,
|
|
738
|
+
url.origin,
|
|
739
|
+
router.basename,
|
|
740
|
+
);
|
|
247
741
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
742
|
+
// Stream-idle watchdog (opt-in via timeouts.streamIdleMs): bounds
|
|
743
|
+
// end-to-end idle flow on the streamed body — see rsc/stream-idle.ts
|
|
744
|
+
// for the semantics. Applied at this finalization chokepoint so every
|
|
745
|
+
// streaming exit is covered; websocket upgrades must never be
|
|
746
|
+
// reconstructed and bodiless responses have nothing to bound. The
|
|
747
|
+
// trip fires POST-handoff (the request ALS may be gone), so it
|
|
748
|
+
// reports via the eagerly captured surfaces — callOnError +
|
|
749
|
+
// router.telemetry directly — mirroring handleStore.onError.
|
|
750
|
+
// onTimeout does NOT apply: the response already left the handler,
|
|
751
|
+
// so no replacement Response can be served mid-stream.
|
|
752
|
+
let finalResponse = guarded;
|
|
753
|
+
const streamIdleMs = router.timeouts.streamIdleMs;
|
|
754
|
+
// Websocket check FIRST: a workerd upgrade response must never have
|
|
755
|
+
// its body getter poked (same invariant as the body_kind attribute
|
|
756
|
+
// below).
|
|
757
|
+
if (
|
|
758
|
+
isTimeoutEnabled(streamIdleMs) &&
|
|
759
|
+
!isWebSocketUpgradeResponse(guarded) &&
|
|
760
|
+
guarded.body
|
|
761
|
+
) {
|
|
762
|
+
const routeKey = requestContext._routeName;
|
|
763
|
+
finalResponse = applyStreamIdleTimeout(
|
|
764
|
+
guarded,
|
|
765
|
+
streamIdleMs!,
|
|
766
|
+
(tripInfo) => {
|
|
767
|
+
callOnError(tripInfo.error, "handler", {
|
|
768
|
+
request,
|
|
769
|
+
url,
|
|
770
|
+
env,
|
|
771
|
+
routeKey,
|
|
772
|
+
handledByBoundary: false,
|
|
773
|
+
metadata: {
|
|
774
|
+
timeout: true,
|
|
775
|
+
phase: "stream-idle",
|
|
776
|
+
durationMs: tripInfo.totalMs,
|
|
777
|
+
},
|
|
778
|
+
});
|
|
779
|
+
if (router.telemetry) {
|
|
780
|
+
safeEmit(resolveSink(router.telemetry), {
|
|
781
|
+
type: "request.timeout",
|
|
782
|
+
timestamp: performance.now(),
|
|
783
|
+
requestId: getRequestId(request),
|
|
784
|
+
phase: "stream-idle",
|
|
785
|
+
pathname: url.pathname,
|
|
786
|
+
routeKey,
|
|
787
|
+
durationMs: tripInfo.totalMs,
|
|
788
|
+
customHandler: false,
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// Attributes describe the response actually handed to the host (after
|
|
796
|
+
// unsafe-redirect replacement), low-cardinality only. body_kind checks
|
|
797
|
+
// the websocket marker before the body getter so a workerd upgrade
|
|
798
|
+
// Response is never poked; `.body` is a getter access, not a read of
|
|
799
|
+
// the stream.
|
|
800
|
+
responseSpan.setAttribute(
|
|
801
|
+
"http.response.status_code",
|
|
802
|
+
finalResponse.status,
|
|
803
|
+
);
|
|
804
|
+
responseSpan.setAttribute(
|
|
805
|
+
"rango.response.mode",
|
|
806
|
+
requestContext._requestMode ?? "middleware-short-circuit",
|
|
807
|
+
);
|
|
808
|
+
responseSpan.setAttribute(
|
|
809
|
+
"rango.response.body_kind",
|
|
810
|
+
isWebSocketUpgradeResponse(finalResponse)
|
|
811
|
+
? "websocket"
|
|
812
|
+
: finalResponse.body === null
|
|
813
|
+
? "empty"
|
|
814
|
+
: "stream",
|
|
815
|
+
);
|
|
816
|
+
return finalResponse;
|
|
817
|
+
});
|
|
818
|
+
}),
|
|
819
|
+
);
|
|
820
|
+
};
|
|
251
821
|
|
|
252
|
-
//
|
|
253
|
-
|
|
822
|
+
// Core request handling logic (separated for middleware wrapping).
|
|
823
|
+
// Uses the classify → execute model: classifyRequest produces a RequestPlan,
|
|
824
|
+
// then execution dispatches on the plan mode.
|
|
825
|
+
async function coreRequestHandler(
|
|
254
826
|
request: Request,
|
|
255
827
|
env: TEnv,
|
|
256
828
|
url: URL,
|
|
257
829
|
variables: Record<string, any>,
|
|
258
830
|
nonce: string | undefined,
|
|
259
831
|
): Promise<Response> {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
832
|
+
const handlerTiming: string[] = variables.__handlerTiming || [];
|
|
833
|
+
|
|
834
|
+
// ---- 1. Classify ----
|
|
835
|
+
// classifyRequest may throw RouteNotFoundError for unknown routes.
|
|
836
|
+
// In that case, fall through to a full-render plan so the pipeline
|
|
837
|
+
// can render the 404 page via the existing error handling path.
|
|
838
|
+
const classifyStart = performance.now();
|
|
839
|
+
let plan: RequestPlan<TEnv>;
|
|
840
|
+
try {
|
|
841
|
+
plan = await classifyRequest<TEnv>(request, url, {
|
|
842
|
+
findMatch: router.findMatch,
|
|
843
|
+
routerVersion: version,
|
|
844
|
+
routerId: router.id,
|
|
270
845
|
});
|
|
846
|
+
} catch (error) {
|
|
847
|
+
if (isRouteNotFoundError(error)) {
|
|
848
|
+
// Let the render path handle 404 — match()/matchPartial() will
|
|
849
|
+
// re-throw RouteNotFoundError and the catch block in
|
|
850
|
+
// executeRenderWithMiddleware renders the not-found page.
|
|
851
|
+
plan = {
|
|
852
|
+
mode: "full-render",
|
|
853
|
+
route: {
|
|
854
|
+
matched: null as any,
|
|
855
|
+
manifestEntry: null as any,
|
|
856
|
+
entries: [],
|
|
857
|
+
routeKey: "",
|
|
858
|
+
localRouteName: "",
|
|
859
|
+
params: {},
|
|
860
|
+
routeMiddleware: [],
|
|
861
|
+
cacheScope: null,
|
|
862
|
+
isPassthrough: false,
|
|
863
|
+
},
|
|
864
|
+
negotiated: false,
|
|
865
|
+
};
|
|
866
|
+
} else {
|
|
867
|
+
throw error;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const classifyDur = performance.now() - classifyStart;
|
|
871
|
+
handlerTiming.push(`handler-classify;dur=${classifyDur.toFixed(2)}`);
|
|
872
|
+
|
|
873
|
+
// Stash the classified mode for the rango.response span (rango.response.mode)
|
|
874
|
+
// — the outer handler tail cannot see the plan. Stays unset when middleware
|
|
875
|
+
// short-circuits before core execution runs (reported as
|
|
876
|
+
// "middleware-short-circuit").
|
|
877
|
+
getRequestContext()._requestMode = plan.mode;
|
|
878
|
+
|
|
879
|
+
// ---- 2. Terminal plans (no execution needed) ----
|
|
880
|
+
if (plan.mode === "redirect") {
|
|
881
|
+
// Redirects are handled by the pipeline (match/matchPartial),
|
|
882
|
+
// but for partial requests we short-circuit with a Flight redirect.
|
|
883
|
+
if (url.searchParams.has("_rsc_partial")) {
|
|
884
|
+
return createRedirectFlightResponse(plan.redirectUrl);
|
|
885
|
+
}
|
|
886
|
+
// Full requests: let the pipeline handle the redirect via match()
|
|
887
|
+
// which returns { redirect: url }. Fall through to full-render.
|
|
271
888
|
}
|
|
272
889
|
|
|
273
|
-
|
|
274
|
-
const isAction =
|
|
275
|
-
request.headers.has("rsc-action") || url.searchParams.has("_rsc_action");
|
|
276
|
-
const actionId =
|
|
277
|
-
request.headers.get("rsc-action") || url.searchParams.get("_rsc_action");
|
|
278
|
-
|
|
279
|
-
// Version mismatch detection - client may have stale code after HMR/deployment
|
|
280
|
-
// If versions don't match, tell the client to reload
|
|
281
|
-
const clientVersion = url.searchParams.get("_rsc_v");
|
|
282
|
-
if (version && clientVersion && clientVersion !== version) {
|
|
890
|
+
if (plan.mode === "version-mismatch") {
|
|
283
891
|
console.log(
|
|
284
|
-
`[RSC] Version mismatch: client=${
|
|
892
|
+
`[RSC] Version mismatch: client=${url.searchParams.get("_rsc_v")}, server=${version}. Forcing reload.`,
|
|
285
893
|
);
|
|
286
|
-
|
|
287
|
-
// Clean URL by removing RSC params
|
|
288
|
-
const cleanUrl = new URL(url);
|
|
289
|
-
cleanUrl.searchParams.delete("_rsc_partial");
|
|
290
|
-
cleanUrl.searchParams.delete("_rsc_segments");
|
|
291
|
-
cleanUrl.searchParams.delete("_rsc_v");
|
|
292
|
-
cleanUrl.searchParams.delete("_rsc_stale");
|
|
293
|
-
cleanUrl.searchParams.delete("_rsc_action");
|
|
294
|
-
cleanUrl.searchParams.delete("_rsc_prev");
|
|
295
|
-
|
|
296
|
-
// For actions, reload current page (referer)
|
|
297
|
-
// For navigation, load the target URL
|
|
298
|
-
const reloadUrl = isAction
|
|
299
|
-
? request.headers.get("referer") || cleanUrl.toString()
|
|
300
|
-
: cleanUrl.toString();
|
|
301
|
-
|
|
302
|
-
// Return special response that tells client to reload
|
|
303
|
-
return createResponseWithMergedHeaders(null, {
|
|
304
|
-
status: 200,
|
|
305
|
-
headers: {
|
|
306
|
-
"X-RSC-Reload": reloadUrl,
|
|
307
|
-
"content-type": "text/x-component;charset=utf-8",
|
|
308
|
-
},
|
|
309
|
-
});
|
|
894
|
+
return createReloadResponse(plan.reloadUrl);
|
|
310
895
|
}
|
|
311
896
|
|
|
312
|
-
|
|
313
|
-
|
|
897
|
+
if (plan.mode === "app-switch") {
|
|
898
|
+
// Cross-app SPA navigation crossed a host-router app boundary. Force a
|
|
899
|
+
// real document navigation so the target app's document is re-established
|
|
900
|
+
// (stylesheets, theme, warmup, prefetch-TTL). See request-classification.
|
|
901
|
+
return createReloadResponse(plan.reloadUrl);
|
|
902
|
+
}
|
|
314
903
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const progressiveResult = await handleProgressiveEnhancement(
|
|
904
|
+
// ---- 3. Origin guard (gate for action/loader/PE modes) ----
|
|
905
|
+
const originPhase = ORIGIN_CHECK_PHASE_BY_MODE[plan.mode];
|
|
906
|
+
if (originPhase) {
|
|
907
|
+
const originResult = await checkRequestOrigin(
|
|
320
908
|
request,
|
|
321
|
-
env,
|
|
322
909
|
url,
|
|
323
|
-
|
|
324
|
-
handleStore,
|
|
325
|
-
nonce,
|
|
326
|
-
);
|
|
327
|
-
if (progressiveResult) {
|
|
328
|
-
return progressiveResult;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// ============================================================================
|
|
332
|
-
// SERVER ACTION EXECUTION (JavaScript-enabled client)
|
|
333
|
-
// ============================================================================
|
|
334
|
-
if (isAction && actionId) {
|
|
335
|
-
return handleServerAction(request, env, url, actionId, handleStore);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ============================================================================
|
|
339
|
-
// LOADER FETCH EXECUTION (data fetching with RSC serialization)
|
|
340
|
-
// ============================================================================
|
|
341
|
-
const isLoaderRequest = url.searchParams.has("_rsc_loader");
|
|
342
|
-
if (isLoaderRequest) {
|
|
343
|
-
return handleLoaderFetch(request, env, url, variables);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// ============================================================================
|
|
347
|
-
// REGULAR RSC RENDERING (Navigation)
|
|
348
|
-
// ============================================================================
|
|
349
|
-
// Note: Must use "return await" for try/catch to catch async rejections
|
|
350
|
-
return await handleRscRendering(
|
|
351
|
-
request,
|
|
910
|
+
router.originCheck,
|
|
352
911
|
env,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
handleStore,
|
|
356
|
-
nonce,
|
|
912
|
+
router.id,
|
|
913
|
+
originPhase,
|
|
357
914
|
);
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
915
|
+
if (originResult) {
|
|
916
|
+
const originError = new Error(
|
|
917
|
+
`Origin check rejected: ${request.headers.get("origin") ?? "none"} vs ${request.headers.get("host") ?? "none"}`,
|
|
918
|
+
);
|
|
919
|
+
originError.name = "OriginCheckError";
|
|
363
920
|
|
|
364
|
-
|
|
365
|
-
// Check both instanceof and error.name for cross-bundle compatibility
|
|
366
|
-
const isRouteNotFound =
|
|
367
|
-
error instanceof RouteNotFoundError ||
|
|
368
|
-
(error instanceof Error && error.name === "RouteNotFoundError");
|
|
369
|
-
if (isRouteNotFound) {
|
|
370
|
-
callOnError(error, "routing", {
|
|
921
|
+
callOnError(originError, "origin", {
|
|
371
922
|
request,
|
|
372
923
|
url,
|
|
373
924
|
env,
|
|
374
|
-
handledByBoundary:
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// Get notFound component from router options or use default
|
|
378
|
-
const notFoundOption = router.notFound;
|
|
379
|
-
const notFoundComponent =
|
|
380
|
-
typeof notFoundOption === "function"
|
|
381
|
-
? notFoundOption({ pathname: url.pathname })
|
|
382
|
-
: (notFoundOption ?? createElement("h1", null, "Not Found"));
|
|
383
|
-
|
|
384
|
-
// Create a simple segment for the 404 page
|
|
385
|
-
const notFoundSegment = {
|
|
386
|
-
id: "notFound",
|
|
387
|
-
namespace: "notFound",
|
|
388
|
-
type: "route" as const,
|
|
389
|
-
index: 0,
|
|
390
|
-
component: notFoundComponent,
|
|
391
|
-
params: {},
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
// Render with rootLayout to maintain app shell
|
|
395
|
-
const root = await renderSegments([notFoundSegment], {
|
|
396
|
-
rootLayout: router.rootLayout,
|
|
397
|
-
// No routeName for not-found routes
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
const payload: RscPayload = {
|
|
401
|
-
root,
|
|
925
|
+
handledByBoundary: false,
|
|
402
926
|
metadata: {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
diff: [],
|
|
407
|
-
isPartial: false,
|
|
408
|
-
handles: handleStore.stream(),
|
|
409
|
-
version,
|
|
410
|
-
themeConfig: router.themeConfig,
|
|
411
|
-
warmupEnabled: router.warmupEnabled,
|
|
412
|
-
initialTheme: requireRequestContext().theme,
|
|
413
|
-
// No routeName for not-found routes
|
|
927
|
+
phase: originPhase,
|
|
928
|
+
origin: request.headers.get("origin"),
|
|
929
|
+
host: request.headers.get("host"),
|
|
414
930
|
},
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
const rscStream = renderToReadableStream(payload);
|
|
418
|
-
|
|
419
|
-
// Determine if this is an RSC request or HTML request
|
|
420
|
-
const isRscRequest =
|
|
421
|
-
(!request.headers.get("accept")?.includes("text/html") &&
|
|
422
|
-
!url.searchParams.has("__html")) ||
|
|
423
|
-
url.searchParams.has("__rsc");
|
|
931
|
+
});
|
|
424
932
|
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
933
|
+
if (router.telemetry) {
|
|
934
|
+
safeEmit(resolveSink(router.telemetry), {
|
|
935
|
+
type: "request.origin-rejected",
|
|
936
|
+
timestamp: performance.now(),
|
|
937
|
+
requestId: getRequestId(request),
|
|
938
|
+
method: request.method,
|
|
939
|
+
pathname: url.pathname,
|
|
940
|
+
phase: originPhase,
|
|
941
|
+
origin: request.headers.get("origin"),
|
|
942
|
+
host: request.headers.get("host"),
|
|
429
943
|
});
|
|
430
944
|
}
|
|
431
945
|
|
|
432
|
-
|
|
433
|
-
const ssrModule = await loadSSRModule();
|
|
434
|
-
const htmlStream = await ssrModule.renderHTML(rscStream, { nonce });
|
|
435
|
-
|
|
436
|
-
return createResponseWithMergedHeaders(htmlStream, {
|
|
437
|
-
status: 404,
|
|
438
|
-
headers: { "content-type": "text/html;charset=utf-8" },
|
|
439
|
-
});
|
|
946
|
+
return originResult;
|
|
440
947
|
}
|
|
441
|
-
|
|
442
|
-
// Report unhandled errors
|
|
443
|
-
callOnError(error, "routing", {
|
|
444
|
-
request,
|
|
445
|
-
url,
|
|
446
|
-
env,
|
|
447
|
-
handledByBoundary: false,
|
|
448
|
-
});
|
|
449
|
-
console.error(`[RSC] Error:`, error);
|
|
450
|
-
throw error;
|
|
451
948
|
}
|
|
949
|
+
|
|
950
|
+
// ---- 4. Execute ----
|
|
951
|
+
return executeRequest(
|
|
952
|
+
plan as ExecutableRequestPlan<TEnv>,
|
|
953
|
+
request,
|
|
954
|
+
env,
|
|
955
|
+
url,
|
|
956
|
+
variables,
|
|
957
|
+
nonce,
|
|
958
|
+
);
|
|
452
959
|
}
|
|
453
960
|
|
|
454
|
-
//
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
async function handleProgressiveEnhancement(
|
|
961
|
+
// Execute a classified request plan. Dispatches to the appropriate handler
|
|
962
|
+
// based on plan.mode. Lives in the createRSCHandler closure for access to
|
|
963
|
+
// handlerCtx, router, callOnError, etc.
|
|
964
|
+
// Only receives executable plans (version-mismatch is handled above).
|
|
965
|
+
async function executeRequest(
|
|
966
|
+
plan: ExecutableRequestPlan<TEnv>,
|
|
461
967
|
request: Request,
|
|
462
968
|
env: TEnv,
|
|
463
969
|
url: URL,
|
|
464
|
-
|
|
465
|
-
handleStore: ReturnType<typeof requireRequestContext>["_handleStore"],
|
|
970
|
+
variables: Record<string, any>,
|
|
466
971
|
nonce: string | undefined,
|
|
467
|
-
): Promise<Response
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
contentType.includes("multipart/form-data") ||
|
|
471
|
-
contentType.includes("application/x-www-form-urlencoded");
|
|
472
|
-
|
|
473
|
-
if (request.method !== "POST" || isAction || !isFormSubmission) {
|
|
474
|
-
return null;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// Clone the request to read FormData without consuming it
|
|
478
|
-
const formData = await request.clone().formData();
|
|
479
|
-
|
|
480
|
-
// Look for React's progressive enhancement hidden fields
|
|
481
|
-
let isDirectAction = false;
|
|
482
|
-
let isUseActionState = false;
|
|
483
|
-
let directActionId: string | null = null;
|
|
972
|
+
): Promise<Response> {
|
|
973
|
+
// Common setup
|
|
974
|
+
const handleStore = getRequestContext()._handleStore;
|
|
484
975
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
976
|
+
// Wire up error reporting for late streaming-handle failures
|
|
977
|
+
handleStore.onError = (error: Error) => {
|
|
978
|
+
const reqCtx = getRequestContext();
|
|
979
|
+
callOnError(error, "handler", {
|
|
980
|
+
request,
|
|
981
|
+
url,
|
|
982
|
+
routeKey: reqCtx._routeName,
|
|
983
|
+
params: reqCtx.params as Record<string, string>,
|
|
984
|
+
handledByBoundary: true,
|
|
985
|
+
});
|
|
986
|
+
if (router.telemetry) {
|
|
987
|
+
safeEmit(resolveSink(router.telemetry), {
|
|
988
|
+
type: "handler.error",
|
|
989
|
+
timestamp: performance.now(),
|
|
990
|
+
requestId: getRequestId(request),
|
|
991
|
+
error,
|
|
992
|
+
handledByBoundary: true,
|
|
993
|
+
pathname: url.pathname,
|
|
994
|
+
routeKey: reqCtx._routeName,
|
|
995
|
+
params: reqCtx.params as Record<string, string>,
|
|
996
|
+
});
|
|
491
997
|
}
|
|
492
|
-
}
|
|
998
|
+
};
|
|
493
999
|
|
|
494
|
-
|
|
495
|
-
|
|
1000
|
+
// Set route params early so all execution paths can access ctx.params.
|
|
1001
|
+
// Also store the classified snapshot so match/matchPartial can reuse it
|
|
1002
|
+
// instead of calling resolveRoute again.
|
|
1003
|
+
if (plan.mode !== "redirect") {
|
|
1004
|
+
setRequestContextParams(plan.route.params, plan.route.routeKey);
|
|
1005
|
+
getRequestContext()._classifiedRoute = plan.route;
|
|
496
1006
|
}
|
|
497
1007
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
1008
|
+
const routeReverse = createReverseFunction(getRequiredRouteMap());
|
|
1009
|
+
|
|
1010
|
+
// ---- Response route: skip entire RSC pipeline ----
|
|
1011
|
+
if (plan.mode === "response") {
|
|
1012
|
+
// Build ResponseRouteMatch from plan fields. handleResponseRoute
|
|
1013
|
+
// expects a flat object with params at the top level.
|
|
1014
|
+
const responseMatch: ResponseRouteMatch = {
|
|
1015
|
+
responseType: plan.responseType,
|
|
1016
|
+
handler: plan.handler,
|
|
1017
|
+
params: plan.route.params,
|
|
1018
|
+
negotiated: plan.negotiated,
|
|
1019
|
+
manifestEntry: plan.manifestEntry,
|
|
1020
|
+
routeMiddleware: plan.routeMiddleware,
|
|
1021
|
+
};
|
|
1022
|
+
const responseOutcome = await withTimeout(
|
|
1023
|
+
handleResponseRoute(
|
|
1024
|
+
handlerCtx,
|
|
1025
|
+
responseMatch,
|
|
508
1026
|
request,
|
|
509
|
-
url,
|
|
510
1027
|
env,
|
|
511
|
-
handledByBoundary: false,
|
|
512
|
-
});
|
|
513
|
-
console.error("[RSC] Progressive enhancement action error:", error);
|
|
514
|
-
}
|
|
515
|
-
} else if (isDirectAction && directActionId) {
|
|
516
|
-
const temporaryReferences = createTemporaryReferenceSet();
|
|
517
|
-
|
|
518
|
-
let args: unknown[] = [];
|
|
519
|
-
try {
|
|
520
|
-
args = await decodeReply(formData, { temporaryReferences });
|
|
521
|
-
} catch {
|
|
522
|
-
args = [formData];
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
try {
|
|
526
|
-
const loadedAction = await loadServerAction(directActionId);
|
|
527
|
-
actionResult = await loadedAction.apply(null, args);
|
|
528
|
-
} catch (error) {
|
|
529
|
-
callOnError(error, "action", {
|
|
530
|
-
request,
|
|
531
1028
|
url,
|
|
1029
|
+
variables,
|
|
1030
|
+
),
|
|
1031
|
+
router.timeouts.renderStartMs,
|
|
1032
|
+
"render-start",
|
|
1033
|
+
);
|
|
1034
|
+
if (responseOutcome.timedOut) {
|
|
1035
|
+
return handleTimeoutResponse(
|
|
1036
|
+
request,
|
|
532
1037
|
env,
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
1038
|
+
url,
|
|
1039
|
+
"render-start",
|
|
1040
|
+
responseOutcome.durationMs,
|
|
1041
|
+
plan.route.routeKey,
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
const response = responseOutcome.result;
|
|
1045
|
+
if (plan.negotiated && !isWebSocketUpgradeResponse(response)) {
|
|
1046
|
+
// handleResponseRoute (callHandlerWithVary) already appends Vary: Accept
|
|
1047
|
+
// for negotiated responses; dedup so we don't emit Vary: Accept, Accept.
|
|
1048
|
+
appendVaryAccept(response);
|
|
537
1049
|
}
|
|
1050
|
+
return response;
|
|
538
1051
|
}
|
|
539
1052
|
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
1053
|
+
// SSR setup: kick off in parallel for modes that need HTML rendering.
|
|
1054
|
+
// Placed after response-route short-circuit so response/mime routes
|
|
1055
|
+
// never pay for SSR work.
|
|
1056
|
+
//
|
|
1057
|
+
// Only kick off when the request will actually render HTML, so the
|
|
1058
|
+
// eager loadSSRModule() + user resolveStreaming() are not started (and
|
|
1059
|
+
// never consumed) for a request that returns an RSC stream — that wasted
|
|
1060
|
+
// work also leaves an orphaned Promise.all that can reject (D7). PE form
|
|
1061
|
+
// submissions always render HTML (handleProgressiveEnhancement renders via
|
|
1062
|
+
// getSSRSetup regardless of Accept). For full/partial-render and action,
|
|
1063
|
+
// the render-time HTML decision is exactly !isRscRequest — mayNeedSSR is
|
|
1064
|
+
// the coarse transport pre-filter, isRscRequest adds the partial/__rsc
|
|
1065
|
+
// flags; both share the same Accept rule (acceptsFlightExplicitly in
|
|
1066
|
+
// ssr-setup.ts), so the Accept call cannot drift between them. Both must
|
|
1067
|
+
// pass.
|
|
1068
|
+
const willRenderHtml =
|
|
1069
|
+
plan.mode === "pe-render" ||
|
|
1070
|
+
(mayNeedSSR(request, url) &&
|
|
1071
|
+
!isRscRequest(request, url, plan.mode === "partial-render"));
|
|
1072
|
+
if (plan.mode !== "loader" && willRenderHtml) {
|
|
1073
|
+
const ssrSetup = startSSRSetup(
|
|
1074
|
+
handlerCtx,
|
|
545
1075
|
request,
|
|
546
|
-
url,
|
|
547
1076
|
env,
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
return new Response(null, {
|
|
563
|
-
status: 308,
|
|
564
|
-
headers: { Location: match.redirect },
|
|
565
|
-
});
|
|
1077
|
+
url,
|
|
1078
|
+
router.debugPerformance
|
|
1079
|
+
? () => getRequestContext()._metricsStore
|
|
1080
|
+
: undefined,
|
|
1081
|
+
);
|
|
1082
|
+
variables[SSR_SETUP_VAR] = ssrSetup;
|
|
1083
|
+
|
|
1084
|
+
// A handler can short-circuit before HTML rendering consumes this promise
|
|
1085
|
+
// (for example, by returning a redirect). Workerd cancels untracked dynamic
|
|
1086
|
+
// imports at the request boundary; retaining that cancelled promise in the
|
|
1087
|
+
// production SSR module memo makes every later document request hang.
|
|
1088
|
+
// Extending the request lifetime lets the shared setup settle without
|
|
1089
|
+
// delaying the short-circuit response.
|
|
1090
|
+
getRequestContext().executionContext?.waitUntil(ssrSetup);
|
|
566
1091
|
}
|
|
567
1092
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const payload: RscPayload = {
|
|
573
|
-
root,
|
|
574
|
-
metadata: {
|
|
575
|
-
pathname: url.pathname,
|
|
576
|
-
segments: match.segments,
|
|
577
|
-
matched: match.matched,
|
|
578
|
-
diff: match.diff,
|
|
579
|
-
isPartial: false,
|
|
580
|
-
rootLayout: router.rootLayout,
|
|
581
|
-
handles: handleStore.stream(),
|
|
582
|
-
version,
|
|
583
|
-
themeConfig: router.themeConfig,
|
|
584
|
-
warmupEnabled: router.warmupEnabled,
|
|
585
|
-
initialTheme: requireRequestContext().theme,
|
|
586
|
-
},
|
|
587
|
-
formState: actionResult,
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
const rscStream = renderToReadableStream<RscPayload>(payload);
|
|
591
|
-
const ssrModule = await loadSSRModule();
|
|
592
|
-
const htmlStream = await ssrModule.renderHTML(rscStream, {
|
|
593
|
-
formState: reactFormState,
|
|
594
|
-
nonce,
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
return new Response(htmlStream, {
|
|
598
|
-
headers: { "content-type": "text/html;charset=utf-8" },
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// ============================================================================
|
|
603
|
-
// SERVER ACTION HANDLER
|
|
604
|
-
// ============================================================================
|
|
605
|
-
async function handleServerAction(
|
|
606
|
-
request: Request,
|
|
607
|
-
env: TEnv,
|
|
608
|
-
url: URL,
|
|
609
|
-
actionId: string,
|
|
610
|
-
handleStore: ReturnType<typeof requireRequestContext>["_handleStore"],
|
|
611
|
-
): Promise<Response> {
|
|
612
|
-
const temporaryReferences = createTemporaryReferenceSet();
|
|
613
|
-
|
|
614
|
-
// Decode action arguments from request body
|
|
615
|
-
const contentType = request.headers.get("content-type") || "";
|
|
616
|
-
let args: unknown[] = [];
|
|
617
|
-
let actionFormData: FormData | undefined;
|
|
618
|
-
|
|
619
|
-
try {
|
|
620
|
-
const body = contentType.includes("multipart/form-data")
|
|
621
|
-
? await request.formData()
|
|
622
|
-
: await request.text();
|
|
623
|
-
|
|
624
|
-
if (body instanceof FormData) {
|
|
625
|
-
actionFormData = body;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
if (hasBodyContent(body)) {
|
|
629
|
-
args = await decodeReply(body, { temporaryReferences });
|
|
630
|
-
}
|
|
631
|
-
} catch (error) {
|
|
632
|
-
callOnError(error, "action", {
|
|
1093
|
+
// ---- Loader fetch ----
|
|
1094
|
+
if (plan.mode === "loader") {
|
|
1095
|
+
return handleLoaderFetch(
|
|
1096
|
+
handlerCtx,
|
|
633
1097
|
request,
|
|
634
|
-
url,
|
|
635
1098
|
env,
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
cause: error,
|
|
641
|
-
});
|
|
1099
|
+
url,
|
|
1100
|
+
variables,
|
|
1101
|
+
plan.route.params,
|
|
1102
|
+
);
|
|
642
1103
|
}
|
|
643
1104
|
|
|
644
|
-
//
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
try {
|
|
650
|
-
loadedAction = await loadServerAction(actionId);
|
|
651
|
-
const data = await loadedAction!.apply(null, args);
|
|
652
|
-
returnValue = { ok: true, data };
|
|
653
|
-
} catch (error) {
|
|
654
|
-
returnValue = { ok: false, data: error };
|
|
655
|
-
actionStatus = 500;
|
|
656
|
-
|
|
657
|
-
// Try to render error boundary
|
|
658
|
-
const errorResult = await router.matchError(request, env, error, "route");
|
|
659
|
-
|
|
660
|
-
// Report the action error (handledByBoundary indicates if error boundary will render)
|
|
661
|
-
callOnError(error, "action", {
|
|
1105
|
+
// ---- Progressive enhancement ----
|
|
1106
|
+
if (plan.mode === "pe-render") {
|
|
1107
|
+
const peResult = await handleProgressiveEnhancement(
|
|
1108
|
+
handlerCtx,
|
|
662
1109
|
request,
|
|
663
|
-
url,
|
|
664
1110
|
env,
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
isPartial: true,
|
|
678
|
-
matched: errorResult.matched,
|
|
679
|
-
diff: errorResult.diff,
|
|
680
|
-
isError: true,
|
|
681
|
-
handles: handleStore.stream(),
|
|
682
|
-
version,
|
|
683
|
-
},
|
|
684
|
-
returnValue,
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
const rscStream = renderToReadableStream<RscPayload>(payload, {
|
|
688
|
-
temporaryReferences,
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
return createResponseWithMergedHeaders(rscStream, {
|
|
692
|
-
status: actionStatus,
|
|
693
|
-
headers: { "content-type": "text/x-component;charset=utf-8" },
|
|
694
|
-
});
|
|
695
|
-
}
|
|
1111
|
+
url,
|
|
1112
|
+
false, // isAction = false for PE
|
|
1113
|
+
handleStore,
|
|
1114
|
+
nonce,
|
|
1115
|
+
{
|
|
1116
|
+
routeMiddleware: plan.route.routeMiddleware,
|
|
1117
|
+
variables,
|
|
1118
|
+
routeReverse,
|
|
1119
|
+
},
|
|
1120
|
+
);
|
|
1121
|
+
if (peResult) return peResult;
|
|
1122
|
+
// PE handler returned null (not a PE form) — fall through to render
|
|
696
1123
|
}
|
|
697
1124
|
|
|
698
|
-
//
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
1125
|
+
// ---- Action: execute action, then revalidate wrapped in route middleware ----
|
|
1126
|
+
if (plan.mode === "action") {
|
|
1127
|
+
let actionContinuation: ActionContinuation | undefined;
|
|
1128
|
+
try {
|
|
1129
|
+
// Instrument the action execution as its own phase (action:<actionId> +
|
|
1130
|
+
// rango.action), so a POST shows the mutation time AND which action ran,
|
|
1131
|
+
// not just the downstream revalidation render. The action's own
|
|
1132
|
+
// loaders/fetches nest under rango.action.
|
|
1133
|
+
const actionOutcome = await withTimeout(
|
|
1134
|
+
observePhase(PHASES.action(plan.actionId), () =>
|
|
1135
|
+
executeServerAction(
|
|
1136
|
+
handlerCtx,
|
|
1137
|
+
request,
|
|
1138
|
+
env,
|
|
1139
|
+
url,
|
|
1140
|
+
plan.actionId,
|
|
1141
|
+
handleStore,
|
|
1142
|
+
),
|
|
1143
|
+
),
|
|
1144
|
+
router.timeouts.actionMs,
|
|
1145
|
+
"action",
|
|
1146
|
+
);
|
|
1147
|
+
if (actionOutcome.timedOut) {
|
|
1148
|
+
return handleTimeoutResponse(
|
|
1149
|
+
request,
|
|
1150
|
+
env,
|
|
1151
|
+
url,
|
|
1152
|
+
"action",
|
|
1153
|
+
actionOutcome.durationMs,
|
|
1154
|
+
plan.route.routeKey,
|
|
1155
|
+
plan.actionId,
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
const result = actionOutcome.result;
|
|
1159
|
+
// Response means redirect or error boundary — done.
|
|
1160
|
+
if (result instanceof Response) return result;
|
|
1161
|
+
actionContinuation = result;
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
callOnError(error, "action", {
|
|
1164
|
+
request,
|
|
1165
|
+
url,
|
|
1166
|
+
env,
|
|
1167
|
+
actionId: plan.actionId,
|
|
1168
|
+
handledByBoundary: false,
|
|
721
1169
|
});
|
|
1170
|
+
console.error(`[RSC] Action error:`, error);
|
|
1171
|
+
throw error;
|
|
722
1172
|
}
|
|
723
1173
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
},
|
|
744
|
-
returnValue,
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
const rscStream = renderToReadableStream<RscPayload>(payload, {
|
|
748
|
-
temporaryReferences,
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
const headers: Record<string, string> = {
|
|
752
|
-
"content-type": "text/x-component;charset=utf-8",
|
|
753
|
-
};
|
|
754
|
-
if (serverTiming) {
|
|
755
|
-
headers["Server-Timing"] = serverTiming;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
return createResponseWithMergedHeaders(rscStream, {
|
|
759
|
-
status: actionStatus,
|
|
760
|
-
headers,
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
// Return updated segments
|
|
765
|
-
setRequestContextParams(matchResult.params);
|
|
766
|
-
|
|
767
|
-
const renderStart = performance.now();
|
|
768
|
-
|
|
769
|
-
const renderDuration = performance.now() - renderStart;
|
|
770
|
-
const serverTiming = matchResult.serverTiming
|
|
771
|
-
? `${matchResult.serverTiming}, rendering;dur=${renderDuration.toFixed(2)}`
|
|
772
|
-
: `rendering;dur=${renderDuration.toFixed(2)}`;
|
|
773
|
-
|
|
774
|
-
const payload: RscPayload = {
|
|
775
|
-
root: null,
|
|
776
|
-
metadata: {
|
|
777
|
-
pathname: url.pathname,
|
|
778
|
-
segments: matchResult.segments,
|
|
779
|
-
isPartial: true,
|
|
780
|
-
matched: matchResult.matched,
|
|
781
|
-
diff: matchResult.diff,
|
|
782
|
-
slots: matchResult.slots,
|
|
783
|
-
handles: handleStore.stream(),
|
|
784
|
-
version,
|
|
785
|
-
},
|
|
786
|
-
returnValue,
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
const rscStream = renderToReadableStream<RscPayload>(payload, {
|
|
790
|
-
temporaryReferences,
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
const actionHeaders: Record<string, string> = {
|
|
794
|
-
"content-type": "text/x-component;charset=utf-8",
|
|
795
|
-
};
|
|
796
|
-
if (serverTiming) {
|
|
797
|
-
actionHeaders["Server-Timing"] = serverTiming;
|
|
1174
|
+
// Revalidation render wrapped in route middleware.
|
|
1175
|
+
// Actions from client-side navigation include _rsc_partial — preserve
|
|
1176
|
+
// the partial flag so the revalidation returns a Flight stream, not HTML.
|
|
1177
|
+
// App-switch is already excluded by classifyRequest (would be full-render).
|
|
1178
|
+
const isPartialAction = url.searchParams.has("_rsc_partial");
|
|
1179
|
+
return executeRenderWithMiddleware(
|
|
1180
|
+
plan.route.routeMiddleware,
|
|
1181
|
+
plan.negotiated,
|
|
1182
|
+
plan.route.routeKey,
|
|
1183
|
+
routeReverse,
|
|
1184
|
+
request,
|
|
1185
|
+
env,
|
|
1186
|
+
url,
|
|
1187
|
+
variables,
|
|
1188
|
+
nonce,
|
|
1189
|
+
handleStore,
|
|
1190
|
+
isPartialAction,
|
|
1191
|
+
actionContinuation,
|
|
1192
|
+
);
|
|
798
1193
|
}
|
|
799
1194
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1195
|
+
// Full render, partial render, fallen-through PE, and full-page redirect all
|
|
1196
|
+
// render through the same middleware-wrapped path. Only full/partial-render
|
|
1197
|
+
// carry negotiation + the partial flag; pe/redirect render plainly.
|
|
1198
|
+
const isPartial = plan.mode === "partial-render";
|
|
1199
|
+
const negotiated =
|
|
1200
|
+
plan.mode === "full-render" || plan.mode === "partial-render"
|
|
1201
|
+
? plan.negotiated
|
|
1202
|
+
: false;
|
|
1203
|
+
return executeRenderWithMiddleware(
|
|
1204
|
+
plan.route.routeMiddleware,
|
|
1205
|
+
negotiated,
|
|
1206
|
+
plan.route.routeKey,
|
|
1207
|
+
routeReverse,
|
|
1208
|
+
request,
|
|
1209
|
+
env,
|
|
1210
|
+
url,
|
|
1211
|
+
variables,
|
|
1212
|
+
nonce,
|
|
1213
|
+
handleStore,
|
|
1214
|
+
isPartial,
|
|
1215
|
+
);
|
|
804
1216
|
}
|
|
805
1217
|
|
|
806
|
-
//
|
|
807
|
-
//
|
|
808
|
-
//
|
|
809
|
-
|
|
810
|
-
|
|
1218
|
+
// Shared render execution: wraps handleRscRendering (or revalidateAfterAction)
|
|
1219
|
+
// in route middleware and timeout handling. Consolidates the pattern used by
|
|
1220
|
+
// action-revalidate, full-render, and partial-render modes.
|
|
1221
|
+
async function executeRenderWithMiddleware(
|
|
1222
|
+
routeMiddleware: import("../router/middleware-types.js").CollectedMiddleware[],
|
|
1223
|
+
negotiated: boolean,
|
|
1224
|
+
routeKey: string,
|
|
1225
|
+
routeReverse: ReturnType<typeof createReverseFunction>,
|
|
811
1226
|
request: Request,
|
|
812
1227
|
env: TEnv,
|
|
813
1228
|
url: URL,
|
|
814
1229
|
variables: Record<string, any>,
|
|
1230
|
+
nonce: string | undefined,
|
|
1231
|
+
handleStore: ReturnType<typeof getRequestContext>["_handleStore"],
|
|
1232
|
+
isPartial: boolean,
|
|
1233
|
+
actionContinuation?: ActionContinuation,
|
|
815
1234
|
): Promise<Response> {
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
if (!loaderId) {
|
|
819
|
-
return createResponseWithMergedHeaders("Missing _rsc_loader parameter", {
|
|
820
|
-
status: 400,
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// Look up loader lazily
|
|
825
|
-
const registeredLoader = await getLoaderLazy(loaderId);
|
|
826
|
-
if (!registeredLoader) {
|
|
827
|
-
return createResponseWithMergedHeaders(
|
|
828
|
-
`Loader "${loaderId}" not found in registry`,
|
|
829
|
-
{ status: 404 },
|
|
830
|
-
);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
// Parse params and body based on request method
|
|
834
|
-
let loaderParams: Record<string, string> = {};
|
|
835
|
-
let loaderBody: unknown = undefined;
|
|
836
|
-
const isBodyMethod = request.method !== "GET" && request.method !== "HEAD";
|
|
837
|
-
|
|
838
|
-
if (isBodyMethod) {
|
|
1235
|
+
const renderHandler = async (): Promise<Response> => {
|
|
839
1236
|
try {
|
|
840
|
-
|
|
841
|
-
if (
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
} catch {
|
|
860
|
-
return createResponseWithMergedHeaders(
|
|
861
|
-
"Invalid _rsc_loader_params JSON",
|
|
862
|
-
{ status: 400 },
|
|
1237
|
+
let response: Response;
|
|
1238
|
+
if (actionContinuation) {
|
|
1239
|
+
response = await revalidateAfterAction(
|
|
1240
|
+
handlerCtx,
|
|
1241
|
+
request,
|
|
1242
|
+
env,
|
|
1243
|
+
url,
|
|
1244
|
+
handleStore,
|
|
1245
|
+
actionContinuation,
|
|
1246
|
+
);
|
|
1247
|
+
} else {
|
|
1248
|
+
response = await handleRscRendering(
|
|
1249
|
+
handlerCtx,
|
|
1250
|
+
request,
|
|
1251
|
+
env,
|
|
1252
|
+
url,
|
|
1253
|
+
isPartial,
|
|
1254
|
+
handleStore,
|
|
1255
|
+
nonce,
|
|
863
1256
|
);
|
|
864
1257
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
1258
|
+
if (negotiated && !isWebSocketUpgradeResponse(response)) {
|
|
1259
|
+
// handleRscRendering bakes `accept` into the RSC response's Vary list;
|
|
1260
|
+
// dedup so the negotiated append does not list accept twice.
|
|
1261
|
+
appendVaryAccept(response);
|
|
1262
|
+
}
|
|
1263
|
+
return response;
|
|
1264
|
+
} catch (error) {
|
|
1265
|
+
// Check if middleware/handler returned Response
|
|
1266
|
+
if (error instanceof Response) {
|
|
1267
|
+
// An action revalidation render is delivered to the client over the
|
|
1268
|
+
// same Flight-parsing path as a partial navigation, so a Response
|
|
1269
|
+
// thrown during it must be converted exactly like a partial one
|
|
1270
|
+
// (raw 200 -> hard-nav hint, 3xx -> Flight redirect). Without this,
|
|
1271
|
+
// the no-middleware path returns the raw Response (the with-middleware
|
|
1272
|
+
// path is already covered by the isPartial || actionContinuation
|
|
1273
|
+
// guard below).
|
|
1274
|
+
const treatAsPartial = isPartial || actionContinuation != null;
|
|
1275
|
+
|
|
1276
|
+
// During partial (client-side navigation), a 200 Response from a handler
|
|
1277
|
+
// means the route serves raw content (JSON, text, etc.), not JSX.
|
|
1278
|
+
// Signal the browser to hard-navigate so it renders the raw response.
|
|
1279
|
+
if (treatAsPartial && error.status === 200) {
|
|
1280
|
+
console.warn(
|
|
1281
|
+
`[RSC] Route handler at ${url.pathname} returned a Response during client-side navigation. ` +
|
|
1282
|
+
`Falling back to hard navigation. Use data-external on the <Link> to avoid the extra round-trip.`,
|
|
1283
|
+
);
|
|
1284
|
+
return createResponseWithMergedHeaders(null, {
|
|
1285
|
+
status: 200,
|
|
1286
|
+
headers: {
|
|
1287
|
+
"X-RSC-Reload": stripInternalParams(url).toString(),
|
|
1288
|
+
"content-type": "text/x-component;charset=utf-8",
|
|
1289
|
+
},
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
887
1292
|
|
|
888
|
-
|
|
889
|
-
|
|
1293
|
+
if (treatAsPartial) {
|
|
1294
|
+
const intercepted = interceptRedirectForPartial(
|
|
1295
|
+
error,
|
|
1296
|
+
createRedirectFlightResponse,
|
|
1297
|
+
{ requestOrigin: url.origin, basename: router.basename },
|
|
1298
|
+
);
|
|
1299
|
+
if (intercepted) return intercepted;
|
|
890
1300
|
}
|
|
891
|
-
const loaderPayload: LoaderPayload = { loaderResult: result };
|
|
892
|
-
const rscStream =
|
|
893
|
-
renderToReadableStream<LoaderPayload>(loaderPayload);
|
|
894
1301
|
|
|
895
|
-
return
|
|
896
|
-
|
|
897
|
-
});
|
|
898
|
-
},
|
|
899
|
-
);
|
|
900
|
-
} catch (error) {
|
|
901
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
902
|
-
const isDev = process.env.NODE_ENV !== "production";
|
|
1302
|
+
return error;
|
|
1303
|
+
}
|
|
903
1304
|
|
|
904
|
-
|
|
1305
|
+
// Render 404 page for unmatched routes
|
|
1306
|
+
if (isRouteNotFoundError(error)) {
|
|
1307
|
+
callOnError(error, "routing", {
|
|
1308
|
+
request,
|
|
1309
|
+
url,
|
|
1310
|
+
env,
|
|
1311
|
+
handledByBoundary: true,
|
|
1312
|
+
});
|
|
905
1313
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
});
|
|
1314
|
+
// No boundary to consult: an unmatched route has no entry chain, so
|
|
1315
|
+
// this always lands on the router option or the shared default.
|
|
1316
|
+
const notFoundComponent = resolveDefaultNotFound(
|
|
1317
|
+
router.notFound,
|
|
1318
|
+
url.pathname,
|
|
1319
|
+
);
|
|
913
1320
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1321
|
+
const notFoundSegment = {
|
|
1322
|
+
id: "notFound",
|
|
1323
|
+
namespace: "notFound",
|
|
1324
|
+
type: "route" as const,
|
|
1325
|
+
index: 0,
|
|
1326
|
+
component: notFoundComponent,
|
|
1327
|
+
params: {},
|
|
1328
|
+
};
|
|
922
1329
|
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1330
|
+
const payload: RscPayload = {
|
|
1331
|
+
metadata: {
|
|
1332
|
+
pathname: url.pathname,
|
|
1333
|
+
routerId: router.id,
|
|
1334
|
+
basename: router.basename,
|
|
1335
|
+
segments: [notFoundSegment],
|
|
1336
|
+
matched: [],
|
|
1337
|
+
diff: [],
|
|
1338
|
+
// Shape parity with buildFullPayload (rsc-rendering.ts): the 404
|
|
1339
|
+
// payload carries params/resolvedIds/prefetchCacheTTL the same way a
|
|
1340
|
+
// matched full render does. resolvedIds mirrors the rendered segment
|
|
1341
|
+
// list (the single notFound segment) like the error-boundary path
|
|
1342
|
+
// (match-api.ts) does for its boundary segment.
|
|
1343
|
+
resolvedIds: [notFoundSegment.id],
|
|
1344
|
+
params: {},
|
|
1345
|
+
isPartial: false,
|
|
1346
|
+
rootLayout: router.rootLayout,
|
|
1347
|
+
// Full (404) render: resolve deferred handle values server-side.
|
|
1348
|
+
handles: resolvedHandleStream(handleStore),
|
|
1349
|
+
version,
|
|
1350
|
+
prefetchCacheTTL: router.prefetchCacheTTL,
|
|
1351
|
+
prefetchCacheSize: router.prefetchCacheSize,
|
|
1352
|
+
prefetchConcurrency: router.prefetchConcurrency,
|
|
1353
|
+
defaultPrefetch: router.defaultPrefetch,
|
|
1354
|
+
stateCookieName: router.resolvedStateCookieName,
|
|
1355
|
+
themeConfig: router.themeConfig,
|
|
1356
|
+
warmupEnabled: router.warmupEnabled,
|
|
1357
|
+
strictMode: router.strictMode,
|
|
1358
|
+
initialTheme: getRequestContext().theme,
|
|
1359
|
+
},
|
|
1360
|
+
};
|
|
929
1361
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1362
|
+
const isNotFoundFlightResponse = isRscRequest(
|
|
1363
|
+
request,
|
|
1364
|
+
url,
|
|
1365
|
+
isPartial,
|
|
1366
|
+
);
|
|
1367
|
+
const notFoundStageTracking = {
|
|
1368
|
+
mode: isPartial ? ("partial" as const) : ("full" as const),
|
|
1369
|
+
routeKey,
|
|
1370
|
+
};
|
|
1371
|
+
return renderRscResponse(
|
|
1372
|
+
{
|
|
1373
|
+
ctx: handlerCtx,
|
|
1374
|
+
request,
|
|
1375
|
+
url,
|
|
1376
|
+
env,
|
|
1377
|
+
payload,
|
|
1378
|
+
// The 404 path historically records no rsc-serialize metric (it
|
|
1379
|
+
// used the standalone Flight constructor, whose gate was opt-in);
|
|
1380
|
+
// opt out explicitly since renderRscResponse defaults the gate on.
|
|
1381
|
+
recordSerializeMetric: false,
|
|
1382
|
+
init: isNotFoundFlightResponse
|
|
1383
|
+
? {
|
|
1384
|
+
status: 404,
|
|
1385
|
+
headers: {
|
|
1386
|
+
"content-type": "text/x-component;charset=utf-8",
|
|
1387
|
+
// Router identity for the client's pre-decode integrity
|
|
1388
|
+
// check; a same-app 404 applies in place.
|
|
1389
|
+
"X-RSC-Router-Id": router.id,
|
|
1390
|
+
},
|
|
1391
|
+
}
|
|
1392
|
+
: {
|
|
1393
|
+
status: 404,
|
|
1394
|
+
headers: {
|
|
1395
|
+
"content-type": "text/html;charset=utf-8",
|
|
1396
|
+
},
|
|
1397
|
+
},
|
|
1398
|
+
tracking: notFoundStageTracking,
|
|
1399
|
+
},
|
|
1400
|
+
isNotFoundFlightResponse
|
|
1401
|
+
? undefined
|
|
1402
|
+
: {
|
|
1403
|
+
html: createSsrHtmlStage({
|
|
1404
|
+
ctx: handlerCtx,
|
|
1405
|
+
request,
|
|
1406
|
+
env,
|
|
1407
|
+
url,
|
|
1408
|
+
metricsStore: getRequestContext()._metricsStore,
|
|
1409
|
+
render: { nonce },
|
|
1410
|
+
}),
|
|
1411
|
+
},
|
|
1412
|
+
);
|
|
958
1413
|
}
|
|
959
1414
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
? `${match.serverTiming}, rendering;dur=${renderDuration.toFixed(2)}`
|
|
967
|
-
: `rendering;dur=${renderDuration.toFixed(2)}`;
|
|
968
|
-
|
|
969
|
-
payload = {
|
|
970
|
-
root,
|
|
971
|
-
metadata: {
|
|
972
|
-
pathname: url.pathname,
|
|
973
|
-
segments: match.segments,
|
|
974
|
-
matched: match.matched,
|
|
975
|
-
diff: match.diff,
|
|
976
|
-
isPartial: false,
|
|
977
|
-
handles: handleStore.stream(),
|
|
978
|
-
version,
|
|
979
|
-
themeConfig: router.themeConfig,
|
|
980
|
-
initialTheme: requireRequestContext().theme,
|
|
981
|
-
},
|
|
982
|
-
};
|
|
983
|
-
} else {
|
|
984
|
-
setRequestContextParams(result.params);
|
|
985
|
-
serverTiming = result.serverTiming;
|
|
986
|
-
|
|
987
|
-
payload = {
|
|
988
|
-
root: null,
|
|
989
|
-
metadata: {
|
|
990
|
-
pathname: url.pathname,
|
|
991
|
-
segments: result.segments,
|
|
992
|
-
matched: result.matched,
|
|
993
|
-
diff: result.diff,
|
|
994
|
-
isPartial: true,
|
|
995
|
-
slots: result.slots,
|
|
996
|
-
handles: handleStore.stream(),
|
|
997
|
-
version,
|
|
998
|
-
},
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
} else {
|
|
1002
|
-
// Full render (initial page load)
|
|
1003
|
-
const match = await router.match(request, env);
|
|
1004
|
-
setRequestContextParams(match.params);
|
|
1005
|
-
|
|
1006
|
-
if (match.redirect) {
|
|
1007
|
-
return createResponseWithMergedHeaders(null, {
|
|
1008
|
-
status: 308,
|
|
1009
|
-
headers: { Location: match.redirect },
|
|
1415
|
+
// Report unhandled errors
|
|
1416
|
+
callOnError(error, "routing", {
|
|
1417
|
+
request,
|
|
1418
|
+
url,
|
|
1419
|
+
env,
|
|
1420
|
+
handledByBoundary: false,
|
|
1010
1421
|
});
|
|
1422
|
+
console.error(`[RSC] Error:`, error);
|
|
1423
|
+
throw error;
|
|
1011
1424
|
}
|
|
1425
|
+
};
|
|
1012
1426
|
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
payload = {
|
|
1026
|
-
root,
|
|
1027
|
-
metadata: {
|
|
1028
|
-
pathname: url.pathname,
|
|
1029
|
-
segments: match.segments,
|
|
1030
|
-
matched: match.matched,
|
|
1031
|
-
diff: match.diff,
|
|
1032
|
-
isPartial: false,
|
|
1033
|
-
rootLayout: router.rootLayout,
|
|
1034
|
-
handles: handleStore.stream(),
|
|
1035
|
-
version,
|
|
1036
|
-
themeConfig: router.themeConfig,
|
|
1037
|
-
initialTheme: requireRequestContext().theme,
|
|
1038
|
-
},
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// Serialize to RSC stream
|
|
1043
|
-
const rscStream = renderToReadableStream<RscPayload>(payload);
|
|
1427
|
+
// Wrap the render path in a renderStartMs timeout
|
|
1428
|
+
const executeRender = async (): Promise<Response> => {
|
|
1429
|
+
if (routeMiddleware.length > 0) {
|
|
1430
|
+
const mwResponse = await executeMiddleware(
|
|
1431
|
+
buildRouteMiddlewareEntries<TEnv>(routeMiddleware),
|
|
1432
|
+
request,
|
|
1433
|
+
env,
|
|
1434
|
+
variables,
|
|
1435
|
+
renderHandler,
|
|
1436
|
+
routeReverse,
|
|
1437
|
+
);
|
|
1044
1438
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1439
|
+
if (isPartial || actionContinuation) {
|
|
1440
|
+
const intercepted = interceptRedirectForPartial(
|
|
1441
|
+
mwResponse,
|
|
1442
|
+
createRedirectFlightResponse,
|
|
1443
|
+
{ requestOrigin: url.origin, basename: router.basename },
|
|
1444
|
+
);
|
|
1445
|
+
if (intercepted) return intercepted;
|
|
1446
|
+
}
|
|
1050
1447
|
|
|
1051
|
-
|
|
1052
|
-
const rscHeaders: Record<string, string> = {
|
|
1053
|
-
"content-type": "text/x-component;charset=utf-8",
|
|
1054
|
-
vary: "accept",
|
|
1055
|
-
};
|
|
1056
|
-
if (serverTiming) {
|
|
1057
|
-
rscHeaders["Server-Timing"] = serverTiming;
|
|
1448
|
+
return finalizeResponse(mwResponse);
|
|
1058
1449
|
}
|
|
1059
|
-
return createResponseWithMergedHeaders(rscStream, {
|
|
1060
|
-
headers: rscHeaders,
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// Delegate to SSR for HTML response
|
|
1065
|
-
const ssrModule = await loadSSRModule();
|
|
1066
|
-
const htmlStream = await ssrModule.renderHTML(rscStream, { nonce });
|
|
1067
1450
|
|
|
1068
|
-
|
|
1069
|
-
"content-type": "text/html;charset=utf-8",
|
|
1451
|
+
return renderHandler();
|
|
1070
1452
|
};
|
|
1071
|
-
if (serverTiming) {
|
|
1072
|
-
htmlHeaders["Server-Timing"] = serverTiming;
|
|
1073
|
-
}
|
|
1074
1453
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1454
|
+
const renderOutcome = await withTimeout(
|
|
1455
|
+
executeRender(),
|
|
1456
|
+
router.timeouts.renderStartMs,
|
|
1457
|
+
"render-start",
|
|
1458
|
+
);
|
|
1459
|
+
if (renderOutcome.timedOut) {
|
|
1460
|
+
return handleTimeoutResponse(
|
|
1461
|
+
request,
|
|
1462
|
+
env,
|
|
1463
|
+
url,
|
|
1464
|
+
"render-start",
|
|
1465
|
+
renderOutcome.durationMs,
|
|
1466
|
+
routeKey,
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
return renderOutcome.result;
|
|
1078
1470
|
}
|
|
1079
1471
|
}
|