@rangojs/router 0.0.0-experimental.8ff1c5d → 0.0.0-experimental.a06372ef
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 +9 -0
- package/README.md +884 -4
- 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 +1601 -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/dist/browser/react/use-client-cache.js +39 -0
- 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/dist/handles/index.js +6 -0
- 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/dist/network-error-thrower.d.ts +17 -0
- 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/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.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 +4484 -826
- 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/dist/vite/package-resolution.js +112 -0
- package/dist/vite/package-resolution.js.map +1 -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 +77 -58
- package/skills/breadcrumbs/SKILL.md +250 -0
- package/skills/cache-guide/SKILL.md +262 -0
- package/skills/caching/SKILL.md +50 -21
- package/skills/composability/SKILL.md +172 -0
- package/skills/debug-manifest/SKILL.md +12 -8
- package/skills/document-cache/SKILL.md +18 -16
- package/skills/fonts/SKILL.md +167 -0
- package/skills/hooks/SKILL.md +334 -72
- package/skills/host-router/SKILL.md +218 -0
- package/skills/intercept/SKILL.md +131 -8
- package/skills/layout/SKILL.md +100 -3
- package/skills/links/SKILL.md +89 -30
- package/skills/loader/SKILL.md +388 -38
- package/skills/middleware/SKILL.md +171 -34
- package/skills/mime-routes/SKILL.md +128 -0
- package/skills/parallel/SKILL.md +78 -1
- package/skills/prerender/SKILL.md +643 -0
- package/skills/rango/SKILL.md +85 -16
- package/skills/response-routes/SKILL.md +411 -0
- package/skills/route/SKILL.md +226 -14
- package/skills/router-setup/SKILL.md +123 -30
- package/skills/tailwind/SKILL.md +129 -0
- package/skills/theme/SKILL.md +9 -8
- package/skills/typesafety/SKILL.md +318 -89
- package/skills/use-cache/SKILL.md +324 -0
- package/src/__internal.ts +102 -4
- package/src/bin/rango.ts +321 -0
- package/src/browser/action-coordinator.ts +97 -0
- package/src/browser/action-response-classifier.ts +99 -0
- package/src/browser/event-controller.ts +87 -64
- package/src/browser/history-state.ts +80 -0
- package/src/browser/intercept-utils.ts +52 -0
- package/src/browser/link-interceptor.ts +24 -4
- package/src/browser/logging.ts +55 -0
- package/src/browser/merge-segment-loaders.ts +20 -12
- package/src/browser/navigation-bridge.ts +281 -554
- package/src/browser/navigation-client.ts +124 -71
- package/src/browser/navigation-store.ts +33 -50
- package/src/browser/navigation-transaction.ts +295 -0
- package/src/browser/network-error-handler.ts +61 -0
- package/src/browser/partial-update.ts +261 -309
- package/src/browser/prefetch/cache.ts +154 -0
- package/src/browser/prefetch/fetch.ts +135 -0
- package/src/browser/prefetch/observer.ts +65 -0
- package/src/browser/prefetch/policy.ts +48 -0
- package/src/browser/prefetch/queue.ts +88 -0
- package/src/browser/rango-state.ts +112 -0
- package/src/browser/react/Link.tsx +185 -73
- package/src/browser/react/NavigationProvider.tsx +51 -11
- package/src/browser/react/context.ts +6 -0
- package/src/browser/react/filter-segment-order.ts +11 -0
- package/src/browser/react/index.ts +12 -12
- package/src/browser/react/location-state-shared.ts +95 -53
- package/src/browser/react/location-state.ts +60 -15
- 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 +29 -51
- package/src/browser/react/use-client-cache.ts +5 -3
- package/src/browser/react/use-handle.ts +32 -79
- package/src/browser/react/use-href.tsx +2 -2
- package/src/browser/react/use-link-status.ts +6 -5
- package/src/browser/react/use-navigation.ts +22 -63
- package/src/browser/react/use-params.ts +65 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-router.ts +63 -0
- package/src/browser/react/use-search-params.ts +56 -0
- package/src/browser/react/use-segments.ts +80 -97
- package/src/browser/response-adapter.ts +73 -0
- package/src/browser/rsc-router.tsx +107 -26
- package/src/browser/scroll-restoration.ts +98 -38
- package/src/browser/segment-reconciler.ts +216 -0
- package/src/browser/segment-structure-assert.ts +16 -0
- package/src/browser/server-action-bridge.ts +504 -599
- package/src/browser/shallow.ts +6 -1
- package/src/browser/types.ts +109 -47
- package/src/browser/validate-redirect-origin.ts +29 -0
- package/src/build/generate-manifest.ts +235 -24
- package/src/build/generate-route-types.ts +36 -0
- package/src/build/index.ts +13 -0
- package/src/build/route-trie.ts +265 -0
- package/src/build/route-types/ast-helpers.ts +25 -0
- package/src/build/route-types/ast-route-extraction.ts +98 -0
- package/src/build/route-types/codegen.ts +102 -0
- package/src/build/route-types/include-resolution.ts +411 -0
- package/src/build/route-types/param-extraction.ts +48 -0
- package/src/build/route-types/per-module-writer.ts +128 -0
- package/src/build/route-types/router-processing.ts +469 -0
- package/src/build/route-types/scan-filter.ts +78 -0
- package/src/build/runtime-discovery.ts +231 -0
- package/src/cache/background-task.ts +34 -0
- package/src/cache/cache-key-utils.ts +44 -0
- package/src/cache/cache-policy.ts +125 -0
- package/src/cache/cache-runtime.ts +338 -0
- package/src/cache/cache-scope.ts +120 -303
- package/src/cache/cf/cf-cache-store.ts +119 -7
- package/src/cache/cf/index.ts +8 -2
- package/src/cache/document-cache.ts +101 -72
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +41 -0
- package/src/cache/index.ts +0 -15
- package/src/cache/memory-segment-store.ts +191 -13
- package/src/cache/profile-registry.ts +73 -0
- package/src/cache/read-through-swr.ts +134 -0
- package/src/cache/segment-codec.ts +256 -0
- package/src/cache/taint.ts +98 -0
- package/src/cache/types.ts +72 -122
- package/src/client.rsc.tsx +3 -1
- package/src/client.tsx +106 -126
- package/src/component-utils.ts +4 -4
- package/src/components/DefaultDocument.tsx +5 -1
- package/src/context-var.ts +86 -0
- package/src/debug.ts +17 -7
- package/src/errors.ts +108 -2
- package/src/handle.ts +15 -29
- package/src/handles/MetaTags.tsx +73 -20
- package/src/handles/breadcrumbs.ts +66 -0
- package/src/handles/index.ts +1 -0
- package/src/handles/meta.ts +30 -13
- package/src/host/cookie-handler.ts +165 -0
- package/src/host/errors.ts +97 -0
- package/src/host/index.ts +53 -0
- package/src/host/pattern-matcher.ts +214 -0
- package/src/host/router.ts +352 -0
- package/src/host/testing.ts +79 -0
- package/src/host/types.ts +146 -0
- package/src/host/utils.ts +25 -0
- package/src/href-client.ts +119 -29
- package/src/index.rsc.ts +153 -19
- package/src/index.ts +211 -30
- package/src/internal-debug.ts +11 -0
- package/src/loader.rsc.ts +26 -157
- package/src/loader.ts +27 -10
- package/src/network-error-thrower.tsx +3 -1
- package/src/outlet-provider.tsx +45 -0
- package/src/prerender/param-hash.ts +37 -0
- package/src/prerender/store.ts +185 -0
- package/src/prerender.ts +463 -0
- package/src/reverse.ts +330 -0
- package/src/root-error-boundary.tsx +41 -29
- package/src/route-content-wrapper.tsx +7 -4
- package/src/route-definition/dsl-helpers.ts +934 -0
- package/src/route-definition/helper-factories.ts +200 -0
- package/src/route-definition/helpers-types.ts +430 -0
- package/src/route-definition/index.ts +52 -0
- package/src/route-definition/redirect.ts +93 -0
- package/src/route-definition.ts +1 -1428
- package/src/route-map-builder.ts +211 -123
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +59 -8
- package/src/router/content-negotiation.ts +116 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +9 -9
- package/src/router/find-match.ts +158 -0
- package/src/router/handler-context.ts +374 -81
- package/src/router/intercept-resolution.ts +397 -0
- package/src/router/lazy-includes.ts +234 -0
- package/src/router/loader-resolution.ts +215 -122
- package/src/router/logging.ts +251 -0
- package/src/router/manifest.ts +148 -35
- package/src/router/match-api.ts +620 -0
- package/src/router/match-context.ts +5 -3
- package/src/router/match-handlers.ts +440 -0
- package/src/router/match-middleware/background-revalidation.ts +80 -93
- package/src/router/match-middleware/cache-lookup.ts +382 -9
- package/src/router/match-middleware/cache-store.ts +51 -22
- package/src/router/match-middleware/intercept-resolution.ts +55 -17
- package/src/router/match-middleware/segment-resolution.ts +25 -6
- package/src/router/match-pipelines.ts +10 -45
- package/src/router/match-result.ts +34 -28
- package/src/router/metrics.ts +235 -15
- package/src/router/middleware-cookies.ts +55 -0
- package/src/router/middleware-types.ts +222 -0
- package/src/router/middleware.ts +324 -367
- package/src/router/pattern-matching.ts +211 -43
- package/src/router/prerender-match.ts +402 -0
- package/src/router/preview-match.ts +170 -0
- package/src/router/revalidation.ts +137 -38
- package/src/router/router-context.ts +40 -21
- package/src/router/router-interfaces.ts +452 -0
- package/src/router/router-options.ts +592 -0
- package/src/router/router-registry.ts +24 -0
- package/src/router/segment-resolution/fresh.ts +570 -0
- package/src/router/segment-resolution/helpers.ts +263 -0
- package/src/router/segment-resolution/loader-cache.ts +198 -0
- package/src/router/segment-resolution/revalidation.ts +1242 -0
- package/src/router/segment-resolution/static-store.ts +67 -0
- package/src/router/segment-resolution.ts +21 -0
- package/src/router/segment-wrappers.ts +291 -0
- package/src/router/telemetry-otel.ts +299 -0
- package/src/router/telemetry.ts +300 -0
- package/src/router/timeout.ts +148 -0
- package/src/router/trie-matching.ts +239 -0
- package/src/router/types.ts +77 -3
- package/src/router.ts +692 -4257
- package/src/rsc/handler-context.ts +45 -0
- package/src/rsc/handler.ts +755 -754
- package/src/rsc/helpers.ts +140 -6
- package/src/rsc/index.ts +0 -20
- package/src/rsc/loader-fetch.ts +209 -0
- package/src/rsc/manifest-init.ts +86 -0
- package/src/rsc/nonce.ts +14 -0
- package/src/rsc/origin-guard.ts +141 -0
- package/src/rsc/progressive-enhancement.ts +379 -0
- package/src/rsc/response-error.ts +37 -0
- package/src/rsc/response-route-handler.ts +347 -0
- package/src/rsc/rsc-rendering.ts +237 -0
- package/src/rsc/runtime-warnings.ts +42 -0
- package/src/rsc/server-action.ts +348 -0
- package/src/rsc/ssr-setup.ts +128 -0
- package/src/rsc/types.ts +38 -11
- package/src/search-params.ts +230 -0
- package/src/segment-system.tsx +25 -13
- package/src/server/context.ts +182 -51
- package/src/server/cookie-store.ts +190 -0
- package/src/server/fetchable-loader-store.ts +37 -0
- package/src/server/handle-store.ts +94 -15
- package/src/server/loader-registry.ts +15 -56
- package/src/server/request-context.ts +430 -70
- package/src/server.ts +35 -130
- package/src/ssr/index.tsx +100 -31
- package/src/static-handler.ts +114 -0
- package/src/theme/ThemeProvider.tsx +21 -15
- package/src/theme/ThemeScript.tsx +5 -5
- package/src/theme/constants.ts +5 -2
- package/src/theme/index.ts +4 -14
- package/src/theme/theme-context.ts +4 -30
- package/src/theme/theme-script.ts +21 -18
- package/src/types/boundaries.ts +158 -0
- package/src/types/cache-types.ts +198 -0
- package/src/types/error-types.ts +192 -0
- package/src/types/global-namespace.ts +100 -0
- package/src/types/handler-context.ts +687 -0
- package/src/types/index.ts +88 -0
- package/src/types/loader-types.ts +183 -0
- package/src/types/route-config.ts +170 -0
- package/src/types/route-entry.ts +102 -0
- package/src/types/segments.ts +148 -0
- package/src/types.ts +1 -1623
- package/src/urls/include-helper.ts +197 -0
- package/src/urls/index.ts +53 -0
- package/src/urls/path-helper-types.ts +339 -0
- package/src/urls/path-helper.ts +329 -0
- package/src/urls/pattern-types.ts +95 -0
- package/src/urls/response-types.ts +106 -0
- package/src/urls/type-extraction.ts +372 -0
- package/src/urls/urls-function.ts +98 -0
- package/src/urls.ts +1 -802
- package/src/use-loader.tsx +85 -77
- package/src/vite/discovery/bundle-postprocess.ts +184 -0
- package/src/vite/discovery/discover-routers.ts +344 -0
- package/src/vite/discovery/prerender-collection.ts +385 -0
- package/src/vite/discovery/route-types-writer.ts +258 -0
- package/src/vite/discovery/self-gen-tracking.ts +47 -0
- package/src/vite/discovery/state.ts +110 -0
- package/src/vite/discovery/virtual-module-codegen.ts +203 -0
- package/src/vite/index.ts +11 -1076
- package/src/vite/plugin-types.ts +131 -0
- package/src/vite/plugins/cjs-to-esm.ts +93 -0
- package/src/vite/plugins/client-ref-dedup.ts +115 -0
- package/src/vite/plugins/client-ref-hashing.ts +105 -0
- package/src/vite/{expose-action-id.ts → plugins/expose-action-id.ts} +72 -51
- package/src/vite/plugins/expose-id-utils.ts +287 -0
- package/src/vite/plugins/expose-ids/export-analysis.ts +296 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +179 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +74 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +110 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +569 -0
- package/src/vite/plugins/refresh-cmd.ts +65 -0
- package/src/vite/plugins/use-cache-transform.ts +323 -0
- package/src/vite/plugins/version-injector.ts +83 -0
- package/src/vite/plugins/version-plugin.ts +254 -0
- package/src/vite/plugins/virtual-entries.ts +123 -0
- package/src/vite/plugins/virtual-stub-plugin.ts +29 -0
- package/src/vite/rango.ts +510 -0
- package/src/vite/router-discovery.ts +785 -0
- package/src/vite/utils/ast-handler-extract.ts +517 -0
- package/src/vite/utils/banner.ts +36 -0
- package/src/vite/utils/bundle-analysis.ts +137 -0
- package/src/vite/utils/manifest-utils.ts +70 -0
- package/src/vite/{package-resolution.ts → utils/package-resolution.ts} +25 -29
- package/src/vite/utils/prerender-utils.ts +189 -0
- package/src/vite/utils/shared-utils.ts +169 -0
- package/CLAUDE.md +0 -43
- package/src/browser/lru-cache.ts +0 -69
- package/src/browser/request-controller.ts +0 -164
- 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
|
*
|
|
@@ -8,36 +8,79 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { createElement } from "react";
|
|
11
|
-
import { renderSegments } from "../segment-system.js";
|
|
12
11
|
import { RouteNotFoundError } from "../errors.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
matchMiddleware,
|
|
16
|
-
executeMiddleware,
|
|
17
|
-
executeLoaderMiddleware,
|
|
18
|
-
} from "../router/middleware.js";
|
|
12
|
+
import { matchMiddleware, executeMiddleware } from "../router/middleware.js";
|
|
19
13
|
import {
|
|
20
14
|
runWithRequestContext,
|
|
21
15
|
setRequestContextParams,
|
|
22
16
|
requireRequestContext,
|
|
23
17
|
createRequestContext,
|
|
24
|
-
type ExecutionContext,
|
|
25
18
|
} from "../server/request-context.js";
|
|
26
19
|
import * as rscDeps from "@vitejs/plugin-rsc/rsc";
|
|
27
20
|
|
|
28
21
|
import type {
|
|
29
22
|
RscPayload,
|
|
30
|
-
ReactFormState,
|
|
31
23
|
CreateRSCHandlerOptions,
|
|
24
|
+
LoadSSRModule,
|
|
32
25
|
} from "./types.js";
|
|
33
|
-
import {
|
|
34
|
-
|
|
26
|
+
import {
|
|
27
|
+
createResponseWithMergedHeaders,
|
|
28
|
+
finalizeResponse,
|
|
29
|
+
interceptRedirectForPartial,
|
|
30
|
+
buildRouteMiddlewareEntries,
|
|
31
|
+
} from "./helpers.js";
|
|
32
|
+
import {
|
|
33
|
+
handleResponseRoute,
|
|
34
|
+
type ResponseRouteMatch,
|
|
35
|
+
} from "./response-route-handler.js";
|
|
36
|
+
import { generateNonce, nonce as nonceToken } from "./nonce.js";
|
|
35
37
|
import { VERSION } from "@rangojs/router:version";
|
|
36
38
|
import type { ErrorPhase } from "../types.js";
|
|
39
|
+
import type { RouterRequestInput } from "../router/router-interfaces.js";
|
|
37
40
|
import { invokeOnError } from "../router/error-handling.js";
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
import {
|
|
42
|
+
createReverseFunction,
|
|
43
|
+
stripInternalParams,
|
|
44
|
+
} from "../router/handler-context.js";
|
|
45
|
+
import { getRouterContext } from "../router/router-context.js";
|
|
46
|
+
import { resolveSink, safeEmit } from "../router/telemetry.js";
|
|
47
|
+
import { contextSet } from "../context-var.js";
|
|
48
|
+
import {
|
|
49
|
+
hasCachedManifest,
|
|
50
|
+
getRouteTrie,
|
|
51
|
+
getPrecomputedEntries,
|
|
52
|
+
waitForManifestReady,
|
|
53
|
+
getRouterManifest,
|
|
54
|
+
getRouterTrie,
|
|
55
|
+
} from "../route-map-builder.js";
|
|
56
|
+
import type { HandlerContext } from "./handler-context.js";
|
|
57
|
+
import { buildRouterTrieFromUrlpatterns } from "./manifest-init.js";
|
|
58
|
+
import { handleProgressiveEnhancement } from "./progressive-enhancement.js";
|
|
59
|
+
import {
|
|
60
|
+
executeServerAction,
|
|
61
|
+
revalidateAfterAction,
|
|
62
|
+
type ActionContinuation,
|
|
63
|
+
} from "./server-action.js";
|
|
64
|
+
import { handleLoaderFetch } from "./loader-fetch.js";
|
|
65
|
+
import { checkRequestOrigin, type OriginCheckPhase } from "./origin-guard.js";
|
|
66
|
+
import { handleRscRendering } from "./rsc-rendering.js";
|
|
67
|
+
import {
|
|
68
|
+
withTimeout,
|
|
69
|
+
RouterTimeoutError,
|
|
70
|
+
createDefaultTimeoutResponse,
|
|
71
|
+
type TimeoutPhase,
|
|
72
|
+
} from "../router/timeout.js";
|
|
73
|
+
import {
|
|
74
|
+
createMetricsStore,
|
|
75
|
+
appendMetric,
|
|
76
|
+
buildMetricsTiming,
|
|
77
|
+
} from "../router/metrics.js";
|
|
78
|
+
import {
|
|
79
|
+
startSSRSetup,
|
|
80
|
+
getSSRSetup,
|
|
81
|
+
mayNeedSSR,
|
|
82
|
+
SSR_SETUP_VAR,
|
|
83
|
+
} from "./ssr-setup.js";
|
|
41
84
|
|
|
42
85
|
/**
|
|
43
86
|
* Create an RSC request handler.
|
|
@@ -89,31 +132,171 @@ export function createRSCHandler<
|
|
|
89
132
|
decodeFormState,
|
|
90
133
|
} = deps;
|
|
91
134
|
|
|
92
|
-
// Use provided loadSSRModule or default to vite RSC module loader
|
|
93
|
-
|
|
135
|
+
// Use provided loadSSRModule or default to vite RSC module loader.
|
|
136
|
+
// No memoization: ES module caching in the runtime already avoids
|
|
137
|
+
// repeated resolution, and memoizing here can break multi-router
|
|
138
|
+
// setups (host routing) where different routers share the same
|
|
139
|
+
// process but need independent SSR module lifecycle.
|
|
140
|
+
const loadSSRModule: LoadSSRModule =
|
|
94
141
|
options.loadSSRModule ??
|
|
95
142
|
(() => import.meta.viteRsc.loadModule("ssr", "index"));
|
|
96
143
|
|
|
97
144
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
145
|
+
* Per-request error reporter that deduplicates via the ALS request context.
|
|
146
|
+
*
|
|
147
|
+
* Uses the same _reportedErrors WeakSet as the router layer so errors
|
|
148
|
+
* that propagate across layers are only reported once per request.
|
|
100
149
|
*/
|
|
101
150
|
function callOnError(
|
|
102
151
|
error: unknown,
|
|
103
152
|
phase: ErrorPhase,
|
|
104
153
|
context: Parameters<typeof invokeOnError<TEnv>>[3],
|
|
105
154
|
): void {
|
|
155
|
+
if (error != null && typeof error === "object") {
|
|
156
|
+
const reportedErrors = requireRequestContext()._reportedErrors;
|
|
157
|
+
if (reportedErrors.has(error)) return;
|
|
158
|
+
reportedErrors.add(error);
|
|
159
|
+
}
|
|
106
160
|
invokeOnError(router.onError, error, phase, context, "RSC");
|
|
107
161
|
}
|
|
108
162
|
|
|
109
|
-
|
|
163
|
+
function getRequiredRouteMap(): Record<string, string> {
|
|
164
|
+
const routeMap = getRouterManifest(router.id);
|
|
165
|
+
if (!routeMap) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Route manifest for router "${router.id}" is not available.`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return routeMap;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Handle a timeout by reporting the error, emitting telemetry,
|
|
175
|
+
* and returning either the custom onTimeout response or a default 504.
|
|
176
|
+
*/
|
|
177
|
+
async function handleTimeoutResponse(
|
|
110
178
|
request: Request,
|
|
111
|
-
env: TEnv
|
|
112
|
-
|
|
179
|
+
env: TEnv,
|
|
180
|
+
url: URL,
|
|
181
|
+
phase: TimeoutPhase,
|
|
182
|
+
durationMs: number,
|
|
183
|
+
routeKey?: string,
|
|
184
|
+
actionId?: string,
|
|
185
|
+
): Promise<Response> {
|
|
186
|
+
const timeoutError = new RouterTimeoutError(phase, durationMs);
|
|
187
|
+
|
|
188
|
+
callOnError(timeoutError, phase === "action" ? "action" : "handler", {
|
|
189
|
+
request,
|
|
190
|
+
url,
|
|
191
|
+
env,
|
|
192
|
+
routeKey,
|
|
193
|
+
actionId,
|
|
194
|
+
handledByBoundary: false,
|
|
195
|
+
metadata: { timeout: true, phase, durationMs },
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
const routerCtx = getRouterContext();
|
|
200
|
+
if (routerCtx?.telemetry) {
|
|
201
|
+
safeEmit(resolveSink(routerCtx.telemetry), {
|
|
202
|
+
type: "request.timeout" as const,
|
|
203
|
+
timestamp: performance.now(),
|
|
204
|
+
requestId: routerCtx.requestId,
|
|
205
|
+
phase,
|
|
206
|
+
pathname: url.pathname,
|
|
207
|
+
routeKey,
|
|
208
|
+
actionId,
|
|
209
|
+
durationMs,
|
|
210
|
+
customHandler: !!router.onTimeout,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
} catch {
|
|
214
|
+
// Router context may not be available
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (router.onTimeout) {
|
|
218
|
+
try {
|
|
219
|
+
return await router.onTimeout({
|
|
220
|
+
phase,
|
|
221
|
+
request,
|
|
222
|
+
url,
|
|
223
|
+
env,
|
|
224
|
+
routeKey,
|
|
225
|
+
actionId,
|
|
226
|
+
durationMs,
|
|
227
|
+
});
|
|
228
|
+
} catch (e) {
|
|
229
|
+
if (process.env.NODE_ENV !== "production") {
|
|
230
|
+
console.error("[RSC] onTimeout callback error:", e);
|
|
231
|
+
}
|
|
232
|
+
return createDefaultTimeoutResponse(phase);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return createDefaultTimeoutResponse(phase);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Build a 200 Flight response that carries a redirect URL and optional state.
|
|
241
|
+
* Used when a partial/action request results in a redirect -- fetch
|
|
242
|
+
* auto-follows 3xx so we send the redirect as payload metadata instead.
|
|
243
|
+
*/
|
|
244
|
+
function createRedirectFlightResponse(
|
|
245
|
+
redirectUrl: string,
|
|
246
|
+
locationState?: Record<string, unknown>,
|
|
247
|
+
): Response {
|
|
248
|
+
const redirectPayload: RscPayload = {
|
|
249
|
+
metadata: {
|
|
250
|
+
pathname: redirectUrl,
|
|
251
|
+
segments: [],
|
|
252
|
+
redirect: { url: redirectUrl },
|
|
253
|
+
...(locationState && { locationState }),
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
const rscStream = renderToReadableStream<RscPayload>(redirectPayload);
|
|
257
|
+
return createResponseWithMergedHeaders(rscStream, {
|
|
258
|
+
status: 200,
|
|
259
|
+
headers: { "content-type": "text/x-component;charset=utf-8" },
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Bundle shared dependencies for extracted handler functions.
|
|
264
|
+
// callOnError reads from ALS so it's inherently per-request scoped.
|
|
265
|
+
const handlerCtx: HandlerContext<TEnv> = {
|
|
266
|
+
router,
|
|
267
|
+
version,
|
|
268
|
+
renderToReadableStream,
|
|
269
|
+
decodeReply,
|
|
270
|
+
createTemporaryReferenceSet,
|
|
271
|
+
loadServerAction,
|
|
272
|
+
decodeAction,
|
|
273
|
+
decodeFormState,
|
|
274
|
+
loadSSRModule,
|
|
275
|
+
callOnError,
|
|
276
|
+
getRequiredRouteMap,
|
|
277
|
+
createRedirectFlightResponse,
|
|
278
|
+
resolveStreamMode: async (request, env, url) => {
|
|
279
|
+
const resolver = router.ssr?.resolveStreaming;
|
|
280
|
+
if (!resolver) return "stream";
|
|
281
|
+
return resolver({ request, env, url });
|
|
113
282
|
},
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return async function handler(
|
|
286
|
+
request: Request,
|
|
287
|
+
input: RouterRequestInput<TEnv> = {},
|
|
114
288
|
): Promise<Response> {
|
|
289
|
+
const handlerStart = performance.now();
|
|
290
|
+
// Create the metrics store at handler start so handler:total has startTime=0
|
|
291
|
+
// and all metrics are relative to the request entry point.
|
|
292
|
+
const earlyMetricsStore = router.debugPerformance
|
|
293
|
+
? createMetricsStore(true, handlerStart)
|
|
294
|
+
: undefined;
|
|
295
|
+
|
|
296
|
+
const { env = {} as TEnv, vars: initialVars, ctx: executionCtx } = input;
|
|
297
|
+
|
|
115
298
|
// Connection warmup: return 204 immediately before any processing
|
|
116
|
-
if (router
|
|
299
|
+
if (router?.warmupEnabled && request.method === "HEAD") {
|
|
117
300
|
const warmupUrl = new URL(request.url);
|
|
118
301
|
if (warmupUrl.searchParams.has("_rsc_warmup")) {
|
|
119
302
|
return new Response(null, { status: 204 });
|
|
@@ -121,25 +304,30 @@ export function createRSCHandler<
|
|
|
121
304
|
}
|
|
122
305
|
|
|
123
306
|
// Resolve nonce if provider is set
|
|
307
|
+
const nonceStart = performance.now();
|
|
124
308
|
let nonce: string | undefined;
|
|
125
309
|
if (nonceProvider) {
|
|
126
310
|
const result = await nonceProvider(request, env);
|
|
127
311
|
nonce = result === true ? generateNonce() : result;
|
|
128
312
|
}
|
|
313
|
+
const nonceDur = performance.now() - nonceStart;
|
|
129
314
|
|
|
130
315
|
const url = new URL(request.url);
|
|
131
316
|
|
|
132
317
|
// Match global middleware
|
|
318
|
+
const mwMatchStart = performance.now();
|
|
133
319
|
const matchedMiddleware = matchMiddleware(url.pathname, router.middleware);
|
|
320
|
+
const mwMatchDur = performance.now() - mwMatchStart;
|
|
134
321
|
|
|
135
322
|
// Shared variables between middleware and route handlers
|
|
136
|
-
// Initialize from
|
|
137
|
-
const variables: Record<string, any> =
|
|
138
|
-
|
|
139
|
-
|
|
323
|
+
// Initialize from input.vars if provided (allows pre-seeding from worker entry)
|
|
324
|
+
const variables: Record<string, any> = initialVars
|
|
325
|
+
? { ...initialVars }
|
|
326
|
+
: {};
|
|
140
327
|
|
|
141
|
-
// Store nonce
|
|
328
|
+
// Store nonce via ContextVar token and string key for backward compat
|
|
142
329
|
if (nonce) {
|
|
330
|
+
contextSet(variables, nonceToken, nonce);
|
|
143
331
|
variables.nonce = nonce;
|
|
144
332
|
}
|
|
145
333
|
|
|
@@ -150,43 +338,103 @@ export function createRSCHandler<
|
|
|
150
338
|
const cacheOption = options.cache ?? router.cache;
|
|
151
339
|
if (cacheOption && !url.searchParams.has("__no_cache")) {
|
|
152
340
|
const cacheConfig =
|
|
153
|
-
typeof cacheOption === "function"
|
|
341
|
+
typeof cacheOption === "function"
|
|
342
|
+
? cacheOption(env, executionCtx)
|
|
343
|
+
: cacheOption;
|
|
154
344
|
|
|
155
345
|
if (cacheConfig.enabled !== false) {
|
|
156
346
|
cacheStore = cacheConfig.store;
|
|
157
347
|
}
|
|
158
348
|
}
|
|
159
349
|
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
350
|
+
// Route manifest is populated at startup via the virtual module
|
|
351
|
+
// (virtual:rsc-router/routes-manifest). In build/production, it's inlined
|
|
352
|
+
// into the bundle. In dev mode (Node), the discovery plugin populates it
|
|
353
|
+
// via setManifestReadyPromise(). In dev mode (Cloudflare), Miniflare runs
|
|
354
|
+
// in a separate isolate where module-level state doesn't carry over, so
|
|
355
|
+
// we generate inline from the router's urlpatterns.
|
|
356
|
+
//
|
|
357
|
+
// In multi-router setups (e.g. createHostRouter), each router must have
|
|
358
|
+
// its own per-router manifest. We check per-router data first: even if
|
|
359
|
+
// the global manifest was set by a different router, this router still
|
|
360
|
+
// needs its own trie and manifest for correct matching.
|
|
361
|
+
const manifestCacheStart = performance.now();
|
|
362
|
+
const hasRouterData = getRouterManifest(router.id) !== undefined;
|
|
363
|
+
if (!hasRouterData) {
|
|
364
|
+
if (!hasCachedManifest()) {
|
|
365
|
+
const readyPromise = waitForManifestReady();
|
|
366
|
+
if (readyPromise) {
|
|
367
|
+
await readyPromise;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!getRouterManifest(router.id) && router.urlpatterns) {
|
|
371
|
+
// Cloudflare dev: generate manifest inline for this router.
|
|
372
|
+
// Each router generates its own manifest independently so
|
|
373
|
+
// multi-router setups (host routing) work correctly.
|
|
374
|
+
await buildRouterTrieFromUrlpatterns(router);
|
|
375
|
+
}
|
|
376
|
+
if (!getRouterManifest(router.id) && !hasCachedManifest()) {
|
|
377
|
+
throw new Error(
|
|
378
|
+
'Route manifest not available. Ensure "virtual:rsc-router/routes-manifest" is imported in your entry file.',
|
|
379
|
+
);
|
|
380
|
+
}
|
|
173
381
|
}
|
|
174
382
|
|
|
175
|
-
//
|
|
176
|
-
// This
|
|
383
|
+
// Rebuild the trie when the manifest exists but the per-router trie is
|
|
384
|
+
// missing. This happens in dev mode after HMR: the virtual module sets
|
|
385
|
+
// the manifest (from fresh gen files) but the trie is intentionally not
|
|
386
|
+
// injected to avoid stale discovery-time data. Without the trie, route
|
|
387
|
+
// matching falls back to regex iteration which does not handle wildcard
|
|
388
|
+
// priority correctly (catch-all patterns match before specific routes).
|
|
389
|
+
if (!getRouterTrie(router.id) && router.urlpatterns) {
|
|
390
|
+
await buildRouterTrieFromUrlpatterns(router);
|
|
391
|
+
}
|
|
392
|
+
const manifestCacheDur = performance.now() - manifestCacheStart;
|
|
177
393
|
|
|
178
394
|
// Create unified request context with all methods
|
|
179
395
|
// Includes: stub response, handle store, loader memoization, use(), cookies, headers, cache store
|
|
180
396
|
// params starts empty, populated after route matching via setRequestContextParams
|
|
397
|
+
const ctxCreateStart = performance.now();
|
|
181
398
|
const requestContext = createRequestContext({
|
|
182
399
|
env,
|
|
183
400
|
request,
|
|
184
401
|
url,
|
|
185
402
|
variables,
|
|
186
403
|
cacheStore,
|
|
187
|
-
|
|
404
|
+
cacheProfiles: router.cacheProfiles,
|
|
405
|
+
executionContext: executionCtx,
|
|
188
406
|
themeConfig: router.themeConfig,
|
|
189
407
|
});
|
|
408
|
+
if (earlyMetricsStore) {
|
|
409
|
+
requestContext._debugPerformance = true;
|
|
410
|
+
requestContext._metricsStore = earlyMetricsStore;
|
|
411
|
+
}
|
|
412
|
+
// Wire background error reporting so "use cache" and other subsystems
|
|
413
|
+
// can surface non-fatal errors through the router's onError callback.
|
|
414
|
+
requestContext._reportBackgroundError = (
|
|
415
|
+
error: unknown,
|
|
416
|
+
category: string,
|
|
417
|
+
) => {
|
|
418
|
+
callOnError(error, "cache", {
|
|
419
|
+
request,
|
|
420
|
+
url,
|
|
421
|
+
metadata: { category },
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const ctxCreateDur = performance.now() - ctxCreateStart;
|
|
426
|
+
|
|
427
|
+
// Accumulate handler-level timing for Server-Timing header
|
|
428
|
+
const handlerTiming = [
|
|
429
|
+
`handler-nonce;dur=${nonceDur.toFixed(2)}`,
|
|
430
|
+
`handler-mw-match;dur=${mwMatchDur.toFixed(2)}`,
|
|
431
|
+
`handler-manifest-cache;dur=${manifestCacheDur.toFixed(2)}`,
|
|
432
|
+
`handler-ctx-create;dur=${ctxCreateDur.toFixed(2)}`,
|
|
433
|
+
];
|
|
434
|
+
|
|
435
|
+
// Store timing data in variables for downstream access
|
|
436
|
+
variables.__handlerTiming = handlerTiming;
|
|
437
|
+
variables.__handlerStart = handlerStart;
|
|
190
438
|
|
|
191
439
|
// Wrap entire request handling in request context
|
|
192
440
|
// Makes context available via getRequestContext() throughout:
|
|
@@ -202,17 +450,71 @@ export function createRSCHandler<
|
|
|
202
450
|
};
|
|
203
451
|
|
|
204
452
|
// Execute middleware chain if any, otherwise call core handler directly
|
|
453
|
+
let response: Response;
|
|
205
454
|
if (matchedMiddleware.length > 0) {
|
|
206
|
-
|
|
455
|
+
const mwResponse = await executeMiddleware(
|
|
207
456
|
matchedMiddleware,
|
|
208
457
|
request,
|
|
209
458
|
env,
|
|
210
459
|
variables,
|
|
211
460
|
coreHandler,
|
|
461
|
+
createReverseFunction(getRequiredRouteMap()),
|
|
212
462
|
);
|
|
463
|
+
|
|
464
|
+
if (
|
|
465
|
+
url.searchParams.has("_rsc_partial") ||
|
|
466
|
+
url.searchParams.has("_rsc_action")
|
|
467
|
+
) {
|
|
468
|
+
const intercepted = interceptRedirectForPartial(
|
|
469
|
+
mwResponse,
|
|
470
|
+
createRedirectFlightResponse,
|
|
471
|
+
);
|
|
472
|
+
response = intercepted ?? finalizeResponse(mwResponse);
|
|
473
|
+
} else {
|
|
474
|
+
response = finalizeResponse(mwResponse);
|
|
475
|
+
}
|
|
476
|
+
} else {
|
|
477
|
+
response = await coreHandler();
|
|
213
478
|
}
|
|
214
479
|
|
|
215
|
-
|
|
480
|
+
// Finalize metrics after all middleware (including post-next work)
|
|
481
|
+
// has completed so :post spans are captured in the timeline.
|
|
482
|
+
// Handler timing parts are always emitted (even without debug metrics)
|
|
483
|
+
// so non-debug requests still get bootstrap Server-Timing entries.
|
|
484
|
+
const handlerTimingArr: string[] = variables.__handlerTiming || [];
|
|
485
|
+
// Preserve any existing Server-Timing set by response routes or middleware
|
|
486
|
+
const existingTiming = response.headers.get("Server-Timing");
|
|
487
|
+
const timingParts = existingTiming
|
|
488
|
+
? [existingTiming, ...handlerTimingArr]
|
|
489
|
+
: [...handlerTimingArr];
|
|
490
|
+
|
|
491
|
+
const metricsStore = requestContext._metricsStore;
|
|
492
|
+
if (metricsStore) {
|
|
493
|
+
// When the store was created at handler start (earlyMetricsStore),
|
|
494
|
+
// handler:total covers the full request. When ctx.debugPerformance()
|
|
495
|
+
// created the store mid-request, use its requestStart to avoid a
|
|
496
|
+
// negative startTime offset.
|
|
497
|
+
const totalStart = earlyMetricsStore
|
|
498
|
+
? handlerStart
|
|
499
|
+
: metricsStore.requestStart;
|
|
500
|
+
appendMetric(
|
|
501
|
+
metricsStore,
|
|
502
|
+
"handler:total",
|
|
503
|
+
totalStart,
|
|
504
|
+
performance.now() - totalStart,
|
|
505
|
+
);
|
|
506
|
+
const metricsTiming = buildMetricsTiming(
|
|
507
|
+
request.method,
|
|
508
|
+
url.pathname,
|
|
509
|
+
metricsStore,
|
|
510
|
+
);
|
|
511
|
+
if (metricsTiming) timingParts.push(metricsTiming);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const fullTiming = timingParts.join(", ");
|
|
515
|
+
if (fullTiming) response.headers.set("Server-Timing", fullTiming);
|
|
516
|
+
|
|
517
|
+
return response;
|
|
216
518
|
});
|
|
217
519
|
};
|
|
218
520
|
|
|
@@ -224,57 +526,314 @@ export function createRSCHandler<
|
|
|
224
526
|
variables: Record<string, any>,
|
|
225
527
|
nonce: string | undefined,
|
|
226
528
|
): Promise<Response> {
|
|
227
|
-
|
|
228
|
-
const preview = await router.previewMatch(request, env);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
529
|
+
const previewStart = performance.now();
|
|
530
|
+
const preview = await router.previewMatch(request, { env });
|
|
531
|
+
const previewDur = performance.now() - previewStart;
|
|
532
|
+
const handlerTiming: string[] = variables.__handlerTiming || [];
|
|
533
|
+
handlerTiming.push(`handler-preview-match;dur=${previewDur.toFixed(2)}`);
|
|
534
|
+
// Response route short-circuit: skip entire RSC pipeline
|
|
535
|
+
if (preview?.responseType && preview.handler) {
|
|
536
|
+
const responseOutcome = await withTimeout(
|
|
537
|
+
handleResponseRoute(
|
|
538
|
+
handlerCtx,
|
|
539
|
+
preview as ResponseRouteMatch,
|
|
540
|
+
request,
|
|
541
|
+
env,
|
|
542
|
+
url,
|
|
543
|
+
variables,
|
|
544
|
+
),
|
|
545
|
+
router.timeouts.renderStartMs,
|
|
546
|
+
"render-start",
|
|
547
|
+
);
|
|
548
|
+
if (responseOutcome.timedOut) {
|
|
549
|
+
return handleTimeoutResponse(
|
|
550
|
+
request,
|
|
551
|
+
env,
|
|
552
|
+
url,
|
|
553
|
+
"render-start",
|
|
554
|
+
responseOutcome.durationMs,
|
|
555
|
+
preview?.routeKey,
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
return responseOutcome.result;
|
|
559
|
+
}
|
|
241
560
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
561
|
+
// Kick off SSR module loading + stream mode resolution in parallel with
|
|
562
|
+
// segment resolution. Placed after the response-route short-circuit so
|
|
563
|
+
// response/mime routes never pay for SSR work.
|
|
564
|
+
if (mayNeedSSR(request, url)) {
|
|
565
|
+
variables[SSR_SETUP_VAR] = startSSRSetup(
|
|
566
|
+
handlerCtx,
|
|
567
|
+
request,
|
|
568
|
+
env,
|
|
569
|
+
url,
|
|
570
|
+
router.debugPerformance
|
|
571
|
+
? () => requireRequestContext()._metricsStore
|
|
572
|
+
: undefined,
|
|
245
573
|
);
|
|
246
574
|
}
|
|
247
575
|
|
|
248
|
-
|
|
249
|
-
|
|
576
|
+
const routeReverse = createReverseFunction(getRequiredRouteMap());
|
|
577
|
+
|
|
578
|
+
const isAction =
|
|
579
|
+
request.headers.has("rsc-action") || url.searchParams.has("_rsc_action");
|
|
580
|
+
const isLoaderFetch = url.searchParams.has("_rsc_loader");
|
|
581
|
+
const actionId =
|
|
582
|
+
request.headers.get("rsc-action") || url.searchParams.get("_rsc_action");
|
|
583
|
+
|
|
584
|
+
// Origin guard: reject cross-origin actions, loader fetches, and
|
|
585
|
+
// PE form submissions before any execution. Regular page navigations
|
|
586
|
+
// (GET without _rsc_loader/_rsc_action) are not affected.
|
|
587
|
+
const originPhase: OriginCheckPhase | null = isAction
|
|
588
|
+
? "action"
|
|
589
|
+
: isLoaderFetch
|
|
590
|
+
? "loader"
|
|
591
|
+
: request.method === "POST"
|
|
592
|
+
? "pe-form"
|
|
593
|
+
: null;
|
|
594
|
+
if (originPhase) {
|
|
595
|
+
const originResult = await checkRequestOrigin(
|
|
596
|
+
request,
|
|
597
|
+
url,
|
|
598
|
+
router.originCheck,
|
|
599
|
+
env,
|
|
600
|
+
router.id,
|
|
601
|
+
originPhase,
|
|
602
|
+
);
|
|
603
|
+
if (originResult) {
|
|
604
|
+
const originError = new Error(
|
|
605
|
+
`Origin check rejected: ${request.headers.get("origin") ?? "none"} vs ${request.headers.get("host") ?? "none"}`,
|
|
606
|
+
);
|
|
607
|
+
originError.name = "OriginCheckError";
|
|
608
|
+
|
|
609
|
+
callOnError(originError, "origin", {
|
|
610
|
+
request,
|
|
611
|
+
url,
|
|
612
|
+
env,
|
|
613
|
+
handledByBoundary: false,
|
|
614
|
+
metadata: {
|
|
615
|
+
phase: originPhase,
|
|
616
|
+
origin: request.headers.get("origin"),
|
|
617
|
+
host: request.headers.get("host"),
|
|
618
|
+
},
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
try {
|
|
622
|
+
const routerCtx = getRouterContext();
|
|
623
|
+
if (routerCtx?.telemetry) {
|
|
624
|
+
safeEmit(resolveSink(routerCtx.telemetry), {
|
|
625
|
+
type: "request.origin-rejected" as const,
|
|
626
|
+
timestamp: performance.now(),
|
|
627
|
+
requestId: routerCtx.requestId,
|
|
628
|
+
method: request.method,
|
|
629
|
+
pathname: url.pathname,
|
|
630
|
+
phase: originPhase,
|
|
631
|
+
origin: request.headers.get("origin"),
|
|
632
|
+
host: request.headers.get("host"),
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
} catch {
|
|
636
|
+
// Router context may not be available
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
return originResult;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// Get handle store from request context
|
|
644
|
+
const handleStore = requireRequestContext()._handleStore;
|
|
645
|
+
|
|
646
|
+
// Wire up error reporting for late streaming-handle failures
|
|
647
|
+
// (LateHandlePushError: handle pushed after stream completion).
|
|
648
|
+
// Without this, these errors are only caught by React's error boundary
|
|
649
|
+
// and never reach the router's onError callback or telemetry.
|
|
650
|
+
handleStore.onError = (error: Error) => {
|
|
651
|
+
const reqCtx = requireRequestContext();
|
|
652
|
+
callOnError(error, "handler", {
|
|
653
|
+
request,
|
|
654
|
+
url,
|
|
655
|
+
routeKey: reqCtx._routeName,
|
|
656
|
+
params: reqCtx.params as Record<string, string>,
|
|
657
|
+
handledByBoundary: true,
|
|
658
|
+
});
|
|
659
|
+
try {
|
|
660
|
+
const routerCtx = getRouterContext();
|
|
661
|
+
if (routerCtx?.telemetry) {
|
|
662
|
+
safeEmit(resolveSink(routerCtx.telemetry), {
|
|
663
|
+
type: "handler.error" as const,
|
|
664
|
+
timestamp: performance.now(),
|
|
665
|
+
requestId: routerCtx.requestId,
|
|
666
|
+
error,
|
|
667
|
+
handledByBoundary: true,
|
|
668
|
+
pathname: url.pathname,
|
|
669
|
+
routeKey: reqCtx._routeName,
|
|
670
|
+
params: reqCtx.params as Record<string, string>,
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
} catch {
|
|
674
|
+
// Router context may not be available (e.g. prerender path)
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// Set route params early so all execution paths can access ctx.params.
|
|
679
|
+
if (preview?.params) {
|
|
680
|
+
setRequestContextParams(preview.params, preview.routeKey);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// Progressive enhancement runs before the normal action/render paths.
|
|
684
|
+
// Route middleware wraps the PE re-render so handlers see the same
|
|
685
|
+
// context variables regardless of JS/no-JS transport.
|
|
686
|
+
const progressiveResult = await handleProgressiveEnhancement(
|
|
687
|
+
handlerCtx,
|
|
688
|
+
request,
|
|
689
|
+
env,
|
|
690
|
+
url,
|
|
691
|
+
isAction,
|
|
692
|
+
handleStore,
|
|
693
|
+
nonce,
|
|
694
|
+
{
|
|
695
|
+
routeMiddleware: preview?.routeMiddleware,
|
|
696
|
+
variables,
|
|
697
|
+
routeReverse,
|
|
698
|
+
},
|
|
699
|
+
);
|
|
700
|
+
if (progressiveResult) {
|
|
701
|
+
return progressiveResult;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// --- Action execution: runs BEFORE route middleware ---
|
|
705
|
+
// Route middleware wraps rendering only. For actions, the action runs
|
|
706
|
+
// first in the global middleware context, then route middleware wraps
|
|
707
|
+
// the revalidation pass (identical to a normal render).
|
|
708
|
+
let actionContinuation: ActionContinuation | undefined;
|
|
709
|
+
if (isAction && actionId) {
|
|
710
|
+
try {
|
|
711
|
+
const actionOutcome = await withTimeout(
|
|
712
|
+
executeServerAction(
|
|
713
|
+
handlerCtx,
|
|
714
|
+
request,
|
|
715
|
+
env,
|
|
716
|
+
url,
|
|
717
|
+
actionId,
|
|
718
|
+
handleStore,
|
|
719
|
+
),
|
|
720
|
+
router.timeouts.actionMs,
|
|
721
|
+
"action",
|
|
722
|
+
);
|
|
723
|
+
if (actionOutcome.timedOut) {
|
|
724
|
+
return handleTimeoutResponse(
|
|
725
|
+
request,
|
|
726
|
+
env,
|
|
727
|
+
url,
|
|
728
|
+
"action",
|
|
729
|
+
actionOutcome.durationMs,
|
|
730
|
+
preview?.routeKey,
|
|
731
|
+
actionId,
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
const result = actionOutcome.result;
|
|
735
|
+
// Response means redirect or error boundary — done.
|
|
736
|
+
if (result instanceof Response) return result;
|
|
737
|
+
actionContinuation = result;
|
|
738
|
+
} catch (error) {
|
|
739
|
+
callOnError(error, "action", {
|
|
740
|
+
request,
|
|
741
|
+
url,
|
|
742
|
+
env,
|
|
743
|
+
actionId,
|
|
744
|
+
handledByBoundary: false,
|
|
745
|
+
});
|
|
746
|
+
console.error(`[RSC] Action error:`, error);
|
|
747
|
+
throw error;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// --- Rendering (action revalidation or navigation) ---
|
|
752
|
+
// Route middleware wraps this — same code path for both cases.
|
|
753
|
+
const renderHandler = async () => {
|
|
754
|
+
const response = await coreRequestHandlerInner(
|
|
755
|
+
request,
|
|
756
|
+
env,
|
|
757
|
+
url,
|
|
758
|
+
variables,
|
|
759
|
+
nonce,
|
|
760
|
+
preview?.params,
|
|
761
|
+
preview?.routeKey,
|
|
762
|
+
handleStore,
|
|
763
|
+
actionContinuation,
|
|
764
|
+
);
|
|
765
|
+
if (preview?.negotiated) {
|
|
766
|
+
response.headers.append("Vary", "Accept");
|
|
767
|
+
}
|
|
768
|
+
return response;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// Wrap the render path (with or without route middleware) in a
|
|
772
|
+
// renderStartMs timeout so slow renders are caught before output.
|
|
773
|
+
const executeRender = async (): Promise<Response> => {
|
|
774
|
+
if (preview?.routeMiddleware && preview.routeMiddleware.length > 0) {
|
|
775
|
+
const mwResponse = await executeMiddleware(
|
|
776
|
+
buildRouteMiddlewareEntries<TEnv>(preview.routeMiddleware),
|
|
777
|
+
request,
|
|
778
|
+
env,
|
|
779
|
+
variables,
|
|
780
|
+
renderHandler,
|
|
781
|
+
routeReverse,
|
|
782
|
+
);
|
|
783
|
+
|
|
784
|
+
if (
|
|
785
|
+
url.searchParams.has("_rsc_partial") ||
|
|
786
|
+
url.searchParams.has("_rsc_action")
|
|
787
|
+
) {
|
|
788
|
+
const intercepted = interceptRedirectForPartial(
|
|
789
|
+
mwResponse,
|
|
790
|
+
createRedirectFlightResponse,
|
|
791
|
+
);
|
|
792
|
+
if (intercepted) return intercepted;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
return finalizeResponse(mwResponse);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// No route middleware, proceed directly
|
|
799
|
+
return renderHandler();
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
const renderOutcome = await withTimeout(
|
|
803
|
+
executeRender(),
|
|
804
|
+
router.timeouts.renderStartMs,
|
|
805
|
+
"render-start",
|
|
806
|
+
);
|
|
807
|
+
if (renderOutcome.timedOut) {
|
|
808
|
+
return handleTimeoutResponse(
|
|
809
|
+
request,
|
|
810
|
+
env,
|
|
811
|
+
url,
|
|
812
|
+
"render-start",
|
|
813
|
+
renderOutcome.durationMs,
|
|
814
|
+
preview?.routeKey,
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
return renderOutcome.result;
|
|
250
818
|
}
|
|
251
819
|
|
|
252
|
-
// Inner request handler
|
|
820
|
+
// Inner request handler: rendering logic wrapped by route middleware.
|
|
821
|
+
// Handles action revalidation (when actionContinuation is present),
|
|
822
|
+
// loader fetches, and regular RSC rendering.
|
|
253
823
|
async function coreRequestHandlerInner(
|
|
254
824
|
request: Request,
|
|
255
825
|
env: TEnv,
|
|
256
826
|
url: URL,
|
|
257
827
|
variables: Record<string, any>,
|
|
258
828
|
nonce: string | undefined,
|
|
829
|
+
routeParams?: Record<string, string>,
|
|
830
|
+
routeKey?: string,
|
|
831
|
+
handleStore?: ReturnType<typeof requireRequestContext>["_handleStore"],
|
|
832
|
+
actionContinuation?: ActionContinuation,
|
|
259
833
|
): Promise<Response> {
|
|
260
|
-
// Early return for static file requests that don't need RSC handling
|
|
261
|
-
if (url.pathname === "/favicon.ico" || url.pathname === "/robots.txt") {
|
|
262
|
-
return new Response(null, { status: 404 });
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Debug endpoint - only in development
|
|
266
|
-
if (url.pathname === "/__debug_manifest" && process.env.NODE_ENV !== "production") {
|
|
267
|
-
const manifest = await router.debugManifest();
|
|
268
|
-
return new Response(JSON.stringify(manifest, null, 2), {
|
|
269
|
-
headers: { "Content-Type": "application/json" },
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
834
|
const isPartial = url.searchParams.has("_rsc_partial");
|
|
274
835
|
const isAction =
|
|
275
836
|
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
837
|
|
|
279
838
|
// Version mismatch detection - client may have stale code after HMR/deployment
|
|
280
839
|
// If versions don't match, tell the client to reload
|
|
@@ -284,20 +843,23 @@ export function createRSCHandler<
|
|
|
284
843
|
`[RSC] Version mismatch: client=${clientVersion}, server=${version}. Forcing reload.`,
|
|
285
844
|
);
|
|
286
845
|
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
846
|
+
// For actions, reload current page (referer) if same origin.
|
|
847
|
+
// For navigation, load the target URL.
|
|
848
|
+
// Validate referer origin to prevent open redirect via crafted header.
|
|
849
|
+
let reloadUrl = stripInternalParams(url).toString();
|
|
850
|
+
if (isAction) {
|
|
851
|
+
const referer = request.headers.get("referer");
|
|
852
|
+
if (referer) {
|
|
853
|
+
try {
|
|
854
|
+
const refererUrl = new URL(referer);
|
|
855
|
+
if (refererUrl.origin === url.origin) {
|
|
856
|
+
reloadUrl = referer;
|
|
857
|
+
}
|
|
858
|
+
} catch {
|
|
859
|
+
// Malformed referer, fall back to cleanUrl
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
301
863
|
|
|
302
864
|
// Return special response that tells client to reload
|
|
303
865
|
return createResponseWithMergedHeaders(null, {
|
|
@@ -308,31 +870,56 @@ export function createRSCHandler<
|
|
|
308
870
|
},
|
|
309
871
|
});
|
|
310
872
|
}
|
|
873
|
+
// Debug manifest endpoint: ?__debug_manifest on any route.
|
|
874
|
+
// Always available in dev, requires allowDebugManifest option in production.
|
|
875
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
876
|
+
if (
|
|
877
|
+
url.searchParams.has("__debug_manifest") &&
|
|
878
|
+
(isDev || router.allowDebugManifest)
|
|
879
|
+
) {
|
|
880
|
+
const trie = getRouterTrie(router.id) ?? getRouteTrie();
|
|
881
|
+
const routeManifest = getRequiredRouteMap();
|
|
882
|
+
const { extractAncestryFromTrie } =
|
|
883
|
+
await import("../build/route-trie.js");
|
|
884
|
+
return new Response(
|
|
885
|
+
JSON.stringify(
|
|
886
|
+
{
|
|
887
|
+
routerId: router.id,
|
|
888
|
+
routeManifest,
|
|
889
|
+
routeAncestry: trie ? extractAncestryFromTrie(trie) : {},
|
|
890
|
+
routeTrie: trie,
|
|
891
|
+
precomputedEntries: getPrecomputedEntries(),
|
|
892
|
+
},
|
|
893
|
+
null,
|
|
894
|
+
2,
|
|
895
|
+
),
|
|
896
|
+
{
|
|
897
|
+
headers: { "Content-Type": "application/json" },
|
|
898
|
+
},
|
|
899
|
+
);
|
|
900
|
+
}
|
|
311
901
|
|
|
312
|
-
|
|
313
|
-
const handleStore = requireRequestContext()._handleStore;
|
|
902
|
+
const store = handleStore ?? requireRequestContext()._handleStore;
|
|
314
903
|
|
|
315
904
|
try {
|
|
316
|
-
//
|
|
317
|
-
//
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
request,
|
|
321
|
-
env,
|
|
322
|
-
url,
|
|
323
|
-
isAction,
|
|
324
|
-
handleStore,
|
|
325
|
-
nonce,
|
|
326
|
-
);
|
|
327
|
-
if (progressiveResult) {
|
|
328
|
-
return progressiveResult;
|
|
905
|
+
// Route params were already set in coreRequestHandler, but set again
|
|
906
|
+
// for callers that enter coreRequestHandlerInner directly.
|
|
907
|
+
if (routeParams) {
|
|
908
|
+
setRequestContextParams(routeParams, routeKey);
|
|
329
909
|
}
|
|
330
910
|
|
|
331
911
|
// ============================================================================
|
|
332
|
-
//
|
|
912
|
+
// ACTION REVALIDATION (action already executed, revalidate segments)
|
|
333
913
|
// ============================================================================
|
|
334
|
-
if (
|
|
335
|
-
return
|
|
914
|
+
if (actionContinuation) {
|
|
915
|
+
return await revalidateAfterAction(
|
|
916
|
+
handlerCtx,
|
|
917
|
+
request,
|
|
918
|
+
env,
|
|
919
|
+
url,
|
|
920
|
+
store,
|
|
921
|
+
actionContinuation,
|
|
922
|
+
);
|
|
336
923
|
}
|
|
337
924
|
|
|
338
925
|
// ============================================================================
|
|
@@ -340,7 +927,14 @@ export function createRSCHandler<
|
|
|
340
927
|
// ============================================================================
|
|
341
928
|
const isLoaderRequest = url.searchParams.has("_rsc_loader");
|
|
342
929
|
if (isLoaderRequest) {
|
|
343
|
-
return handleLoaderFetch(
|
|
930
|
+
return handleLoaderFetch(
|
|
931
|
+
handlerCtx,
|
|
932
|
+
request,
|
|
933
|
+
env,
|
|
934
|
+
url,
|
|
935
|
+
variables,
|
|
936
|
+
routeParams,
|
|
937
|
+
);
|
|
344
938
|
}
|
|
345
939
|
|
|
346
940
|
// ============================================================================
|
|
@@ -348,16 +942,44 @@ export function createRSCHandler<
|
|
|
348
942
|
// ============================================================================
|
|
349
943
|
// Note: Must use "return await" for try/catch to catch async rejections
|
|
350
944
|
return await handleRscRendering(
|
|
945
|
+
handlerCtx,
|
|
351
946
|
request,
|
|
352
947
|
env,
|
|
353
948
|
url,
|
|
354
949
|
isPartial,
|
|
355
|
-
|
|
950
|
+
store,
|
|
356
951
|
nonce,
|
|
357
952
|
);
|
|
358
953
|
} catch (error) {
|
|
359
954
|
// Check if middleware/handler returned Response
|
|
360
955
|
if (error instanceof Response) {
|
|
956
|
+
// During partial (client-side navigation), a 200 Response from a handler
|
|
957
|
+
// means the route serves raw content (JSON, text, etc.), not JSX.
|
|
958
|
+
// Signal the browser to hard-navigate so it renders the raw response.
|
|
959
|
+
// Only for 200 — redirects (3xx) work already because the browser follows
|
|
960
|
+
// them automatically to a URL that serves Flight data.
|
|
961
|
+
if (isPartial && error.status === 200) {
|
|
962
|
+
console.warn(
|
|
963
|
+
`[RSC] Route handler at ${url.pathname} returned a Response during client-side navigation. ` +
|
|
964
|
+
`Falling back to hard navigation. Use data-external on the <Link> to avoid the extra round-trip.`,
|
|
965
|
+
);
|
|
966
|
+
return createResponseWithMergedHeaders(null, {
|
|
967
|
+
status: 200,
|
|
968
|
+
headers: {
|
|
969
|
+
"X-RSC-Reload": stripInternalParams(url).toString(),
|
|
970
|
+
"content-type": "text/x-component;charset=utf-8",
|
|
971
|
+
},
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
if (isPartial) {
|
|
976
|
+
const intercepted = interceptRedirectForPartial(
|
|
977
|
+
error,
|
|
978
|
+
createRedirectFlightResponse,
|
|
979
|
+
);
|
|
980
|
+
if (intercepted) return intercepted;
|
|
981
|
+
}
|
|
982
|
+
|
|
361
983
|
return error;
|
|
362
984
|
}
|
|
363
985
|
|
|
@@ -391,21 +1013,15 @@ export function createRSCHandler<
|
|
|
391
1013
|
params: {},
|
|
392
1014
|
};
|
|
393
1015
|
|
|
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
1016
|
const payload: RscPayload = {
|
|
401
|
-
root,
|
|
402
1017
|
metadata: {
|
|
403
1018
|
pathname: url.pathname,
|
|
404
1019
|
segments: [notFoundSegment],
|
|
405
1020
|
matched: [],
|
|
406
1021
|
diff: [],
|
|
407
1022
|
isPartial: false,
|
|
408
|
-
|
|
1023
|
+
rootLayout: router.rootLayout,
|
|
1024
|
+
handles: store.stream(),
|
|
409
1025
|
version,
|
|
410
1026
|
themeConfig: router.themeConfig,
|
|
411
1027
|
warmupEnabled: router.warmupEnabled,
|
|
@@ -416,8 +1032,10 @@ export function createRSCHandler<
|
|
|
416
1032
|
|
|
417
1033
|
const rscStream = renderToReadableStream(payload);
|
|
418
1034
|
|
|
419
|
-
// Determine if this is an RSC request or HTML request
|
|
1035
|
+
// Determine if this is an RSC request or HTML request.
|
|
1036
|
+
// Partial requests are always RSC (see main isRscRequest comment).
|
|
420
1037
|
const isRscRequest =
|
|
1038
|
+
isPartial ||
|
|
421
1039
|
(!request.headers.get("accept")?.includes("text/html") &&
|
|
422
1040
|
!url.searchParams.has("__html")) ||
|
|
423
1041
|
url.searchParams.has("__rsc");
|
|
@@ -429,9 +1047,18 @@ export function createRSCHandler<
|
|
|
429
1047
|
});
|
|
430
1048
|
}
|
|
431
1049
|
|
|
432
|
-
// Delegate to SSR for HTML response
|
|
433
|
-
const ssrModule = await
|
|
434
|
-
|
|
1050
|
+
// Delegate to SSR for HTML response (reuse early setup if available)
|
|
1051
|
+
const [ssrModule, streamMode] = await getSSRSetup(
|
|
1052
|
+
handlerCtx,
|
|
1053
|
+
request,
|
|
1054
|
+
env,
|
|
1055
|
+
url,
|
|
1056
|
+
requireRequestContext()._metricsStore,
|
|
1057
|
+
);
|
|
1058
|
+
const htmlStream = await ssrModule.renderHTML(rscStream, {
|
|
1059
|
+
nonce,
|
|
1060
|
+
streamMode,
|
|
1061
|
+
});
|
|
435
1062
|
|
|
436
1063
|
return createResponseWithMergedHeaders(htmlStream, {
|
|
437
1064
|
status: 404,
|
|
@@ -450,630 +1077,4 @@ export function createRSCHandler<
|
|
|
450
1077
|
throw error;
|
|
451
1078
|
}
|
|
452
1079
|
}
|
|
453
|
-
|
|
454
|
-
// ============================================================================
|
|
455
|
-
// PROGRESSIVE ENHANCEMENT HANDLER
|
|
456
|
-
// When JavaScript is disabled, React renders forms with hidden fields
|
|
457
|
-
// ($ACTION_REF_*, $ACTION_KEY) containing the action reference.
|
|
458
|
-
// We detect these and return HTML instead of RSC stream.
|
|
459
|
-
// ============================================================================
|
|
460
|
-
async function handleProgressiveEnhancement(
|
|
461
|
-
request: Request,
|
|
462
|
-
env: TEnv,
|
|
463
|
-
url: URL,
|
|
464
|
-
isAction: boolean,
|
|
465
|
-
handleStore: ReturnType<typeof requireRequestContext>["_handleStore"],
|
|
466
|
-
nonce: string | undefined,
|
|
467
|
-
): Promise<Response | null> {
|
|
468
|
-
const contentType = request.headers.get("content-type") || "";
|
|
469
|
-
const isFormSubmission =
|
|
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;
|
|
484
|
-
|
|
485
|
-
formData.forEach((_value, key) => {
|
|
486
|
-
if (key.startsWith("$ACTION_ID_")) {
|
|
487
|
-
isDirectAction = true;
|
|
488
|
-
directActionId = key.slice("$ACTION_ID_".length);
|
|
489
|
-
} else if (key.startsWith("$ACTION_REF_")) {
|
|
490
|
-
isUseActionState = true;
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
if (!isDirectAction && !isUseActionState) {
|
|
495
|
-
return null;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// Execute action and return HTML
|
|
499
|
-
let actionResult: unknown = undefined;
|
|
500
|
-
let reactFormState: ReactFormState | null = null;
|
|
501
|
-
|
|
502
|
-
if (isUseActionState) {
|
|
503
|
-
try {
|
|
504
|
-
const boundAction = await decodeAction(formData);
|
|
505
|
-
actionResult = await boundAction();
|
|
506
|
-
} catch (error) {
|
|
507
|
-
callOnError(error, "action", {
|
|
508
|
-
request,
|
|
509
|
-
url,
|
|
510
|
-
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
|
-
url,
|
|
532
|
-
env,
|
|
533
|
-
actionId: directActionId,
|
|
534
|
-
handledByBoundary: false,
|
|
535
|
-
});
|
|
536
|
-
console.error("[RSC] Progressive enhancement action error:", error);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// Decode form state for useActionState progressive enhancement
|
|
541
|
-
try {
|
|
542
|
-
reactFormState = await decodeFormState(actionResult, formData);
|
|
543
|
-
} catch (error) {
|
|
544
|
-
callOnError(error, "action", {
|
|
545
|
-
request,
|
|
546
|
-
url,
|
|
547
|
-
env,
|
|
548
|
-
handledByBoundary: false,
|
|
549
|
-
});
|
|
550
|
-
console.error("[RSC] Failed to decode form state:", error);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// Re-render the page and return HTML
|
|
554
|
-
const renderRequest = new Request(url.toString(), {
|
|
555
|
-
method: "GET",
|
|
556
|
-
headers: new Headers({ accept: "text/html" }),
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
const match = await router.match(renderRequest, env);
|
|
560
|
-
|
|
561
|
-
if (match.redirect) {
|
|
562
|
-
return new Response(null, {
|
|
563
|
-
status: 308,
|
|
564
|
-
headers: { Location: match.redirect },
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
const root = renderSegments(match.segments, {
|
|
569
|
-
rootLayout: router.rootLayout,
|
|
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", {
|
|
633
|
-
request,
|
|
634
|
-
url,
|
|
635
|
-
env,
|
|
636
|
-
actionId,
|
|
637
|
-
handledByBoundary: false,
|
|
638
|
-
});
|
|
639
|
-
throw new Error(`Failed to decode action arguments: ${error}`, {
|
|
640
|
-
cause: error,
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// Execute the server action
|
|
645
|
-
let returnValue: { ok: boolean; data: unknown };
|
|
646
|
-
let actionStatus = 200;
|
|
647
|
-
let loadedAction: Function | undefined;
|
|
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", {
|
|
662
|
-
request,
|
|
663
|
-
url,
|
|
664
|
-
env,
|
|
665
|
-
actionId,
|
|
666
|
-
handledByBoundary: !!errorResult,
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
if (errorResult) {
|
|
670
|
-
setRequestContextParams(errorResult.params);
|
|
671
|
-
|
|
672
|
-
const payload: RscPayload = {
|
|
673
|
-
root: null,
|
|
674
|
-
metadata: {
|
|
675
|
-
pathname: url.pathname,
|
|
676
|
-
segments: errorResult.segments,
|
|
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
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// Revalidate after action
|
|
699
|
-
const resolvedActionId =
|
|
700
|
-
(loadedAction as { $id?: string; $$id?: string } | undefined)?.$id ??
|
|
701
|
-
(loadedAction as { $$id?: string } | undefined)?.$$id ??
|
|
702
|
-
actionId;
|
|
703
|
-
const actionContext = {
|
|
704
|
-
actionId: resolvedActionId,
|
|
705
|
-
actionUrl: new URL(request.url),
|
|
706
|
-
actionResult: returnValue.data,
|
|
707
|
-
formData: actionFormData,
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
const matchResult = await router.matchPartial(request, env, actionContext);
|
|
711
|
-
|
|
712
|
-
if (!matchResult) {
|
|
713
|
-
// Fall back to full render
|
|
714
|
-
const fullMatch = await router.match(request, env);
|
|
715
|
-
setRequestContextParams(fullMatch.params);
|
|
716
|
-
|
|
717
|
-
if (fullMatch.redirect) {
|
|
718
|
-
return createResponseWithMergedHeaders(null, {
|
|
719
|
-
status: 308,
|
|
720
|
-
headers: { Location: fullMatch.redirect },
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
const renderStart = performance.now();
|
|
725
|
-
const root = renderSegments(fullMatch.segments, {
|
|
726
|
-
rootLayout: router.rootLayout,
|
|
727
|
-
isAction: true,
|
|
728
|
-
});
|
|
729
|
-
const renderDuration = performance.now() - renderStart;
|
|
730
|
-
const serverTiming = fullMatch.serverTiming
|
|
731
|
-
? `${fullMatch.serverTiming}, rendering;dur=${renderDuration.toFixed(2)}`
|
|
732
|
-
: `rendering;dur=${renderDuration.toFixed(2)}`;
|
|
733
|
-
|
|
734
|
-
const payload: RscPayload = {
|
|
735
|
-
root,
|
|
736
|
-
metadata: {
|
|
737
|
-
pathname: url.pathname,
|
|
738
|
-
segments: fullMatch.segments,
|
|
739
|
-
matched: fullMatch.matched,
|
|
740
|
-
diff: fullMatch.diff,
|
|
741
|
-
handles: handleStore.stream(),
|
|
742
|
-
version,
|
|
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;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
return createResponseWithMergedHeaders(rscStream, {
|
|
801
|
-
status: actionStatus,
|
|
802
|
-
headers: actionHeaders,
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
// ============================================================================
|
|
807
|
-
// LOADER FETCH HANDLER
|
|
808
|
-
// Supports GET (params in query string) and POST/PUT/PATCH/DELETE (JSON body)
|
|
809
|
-
// ============================================================================
|
|
810
|
-
async function handleLoaderFetch(
|
|
811
|
-
request: Request,
|
|
812
|
-
env: TEnv,
|
|
813
|
-
url: URL,
|
|
814
|
-
variables: Record<string, any>,
|
|
815
|
-
): Promise<Response> {
|
|
816
|
-
const loaderId = url.searchParams.get("_rsc_loader");
|
|
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) {
|
|
839
|
-
try {
|
|
840
|
-
const contentType = request.headers.get("content-type") || "";
|
|
841
|
-
if (contentType.includes("application/json")) {
|
|
842
|
-
const jsonBody = (await request.json()) as {
|
|
843
|
-
params?: Record<string, string>;
|
|
844
|
-
body?: unknown;
|
|
845
|
-
};
|
|
846
|
-
loaderParams = jsonBody.params ?? {};
|
|
847
|
-
loaderBody = jsonBody.body;
|
|
848
|
-
}
|
|
849
|
-
} catch {
|
|
850
|
-
return createResponseWithMergedHeaders("Invalid JSON body", {
|
|
851
|
-
status: 400,
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
} else {
|
|
855
|
-
const loaderParamsJson = url.searchParams.get("_rsc_loader_params");
|
|
856
|
-
if (loaderParamsJson) {
|
|
857
|
-
try {
|
|
858
|
-
loaderParams = JSON.parse(loaderParamsJson);
|
|
859
|
-
} catch {
|
|
860
|
-
return createResponseWithMergedHeaders(
|
|
861
|
-
"Invalid _rsc_loader_params JSON",
|
|
862
|
-
{ status: 400 },
|
|
863
|
-
);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
// Execute the loader with middleware
|
|
869
|
-
try {
|
|
870
|
-
const { fn, middleware } = registeredLoader;
|
|
871
|
-
|
|
872
|
-
return await executeLoaderMiddleware(
|
|
873
|
-
middleware,
|
|
874
|
-
request,
|
|
875
|
-
env,
|
|
876
|
-
loaderParams,
|
|
877
|
-
variables,
|
|
878
|
-
async () => {
|
|
879
|
-
const ctx = requireRequestContext();
|
|
880
|
-
const loaderCtx: any = {
|
|
881
|
-
...ctx,
|
|
882
|
-
params: loaderParams,
|
|
883
|
-
body: loaderBody,
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
const result = await fn(loaderCtx);
|
|
887
|
-
|
|
888
|
-
interface LoaderPayload {
|
|
889
|
-
loaderResult: unknown;
|
|
890
|
-
}
|
|
891
|
-
const loaderPayload: LoaderPayload = { loaderResult: result };
|
|
892
|
-
const rscStream =
|
|
893
|
-
renderToReadableStream<LoaderPayload>(loaderPayload);
|
|
894
|
-
|
|
895
|
-
return createResponseWithMergedHeaders(rscStream, {
|
|
896
|
-
headers: { "content-type": "text/x-component;charset=utf-8" },
|
|
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";
|
|
903
|
-
|
|
904
|
-
console.error("[RSC] Loader error:", error);
|
|
905
|
-
|
|
906
|
-
callOnError(error, "loader", {
|
|
907
|
-
request,
|
|
908
|
-
url,
|
|
909
|
-
env,
|
|
910
|
-
loaderName: loaderId,
|
|
911
|
-
handledByBoundary: false,
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
const errorPayload = {
|
|
915
|
-
loaderResult: null,
|
|
916
|
-
loaderError: {
|
|
917
|
-
message: isDev ? err.message : "An error occurred",
|
|
918
|
-
name: err.name,
|
|
919
|
-
},
|
|
920
|
-
};
|
|
921
|
-
const rscStream = renderToReadableStream(errorPayload);
|
|
922
|
-
|
|
923
|
-
return createResponseWithMergedHeaders(rscStream, {
|
|
924
|
-
status: 500,
|
|
925
|
-
headers: { "content-type": "text/x-component;charset=utf-8" },
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
// ============================================================================
|
|
931
|
-
// RSC RENDERING HANDLER (Navigation)
|
|
932
|
-
// ============================================================================
|
|
933
|
-
async function handleRscRendering(
|
|
934
|
-
request: Request,
|
|
935
|
-
env: TEnv,
|
|
936
|
-
url: URL,
|
|
937
|
-
isPartial: boolean,
|
|
938
|
-
handleStore: ReturnType<typeof requireRequestContext>["_handleStore"],
|
|
939
|
-
nonce: string | undefined,
|
|
940
|
-
): Promise<Response> {
|
|
941
|
-
let payload: RscPayload;
|
|
942
|
-
let serverTiming: string | undefined;
|
|
943
|
-
|
|
944
|
-
if (isPartial) {
|
|
945
|
-
// Partial render (navigation)
|
|
946
|
-
const result = await router.matchPartial(request, env);
|
|
947
|
-
|
|
948
|
-
if (!result) {
|
|
949
|
-
// Fall back to full render
|
|
950
|
-
const match = await router.match(request, env);
|
|
951
|
-
setRequestContextParams(match.params);
|
|
952
|
-
|
|
953
|
-
if (match.redirect) {
|
|
954
|
-
return createResponseWithMergedHeaders(null, {
|
|
955
|
-
status: 308,
|
|
956
|
-
headers: { Location: match.redirect },
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
const renderStart = performance.now();
|
|
961
|
-
const root = renderSegments(match.segments, {
|
|
962
|
-
rootLayout: router.rootLayout,
|
|
963
|
-
});
|
|
964
|
-
const renderDuration = performance.now() - renderStart;
|
|
965
|
-
serverTiming = match.serverTiming
|
|
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 },
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// Caching is now handled in router.match() via cache provider in request context
|
|
1014
|
-
// match.segments already contains cached or fresh segments as appropriate
|
|
1015
|
-
|
|
1016
|
-
const renderStart = performance.now();
|
|
1017
|
-
const root = renderSegments(match.segments, {
|
|
1018
|
-
rootLayout: router.rootLayout,
|
|
1019
|
-
});
|
|
1020
|
-
const renderDuration = performance.now() - renderStart;
|
|
1021
|
-
serverTiming = match.serverTiming
|
|
1022
|
-
? `${match.serverTiming}, rendering;dur=${renderDuration.toFixed(2)}`
|
|
1023
|
-
: `rendering;dur=${renderDuration.toFixed(2)}`;
|
|
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);
|
|
1044
|
-
|
|
1045
|
-
// Determine if this is an RSC request or HTML request
|
|
1046
|
-
const isRscRequest =
|
|
1047
|
-
(!request.headers.get("accept")?.includes("text/html") &&
|
|
1048
|
-
!url.searchParams.has("__html")) ||
|
|
1049
|
-
url.searchParams.has("__rsc");
|
|
1050
|
-
|
|
1051
|
-
if (isRscRequest) {
|
|
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;
|
|
1058
|
-
}
|
|
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
|
-
|
|
1068
|
-
const htmlHeaders: Record<string, string> = {
|
|
1069
|
-
"content-type": "text/html;charset=utf-8",
|
|
1070
|
-
};
|
|
1071
|
-
if (serverTiming) {
|
|
1072
|
-
htmlHeaders["Server-Timing"] = serverTiming;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
return createResponseWithMergedHeaders(htmlStream, {
|
|
1076
|
-
headers: htmlHeaders,
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
1080
|
}
|