@rangojs/router 0.0.0-experimental.ea6d5eec → 0.0.0-experimental.ea9f40f2
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 +8 -4
- package/README.md +303 -741
- 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 +724 -183
- package/dist/bin/rango.js.map +1 -0
- package/dist/browser/event-controller.d.ts +191 -0
- package/dist/browser/event-controller.d.ts.map +1 -0
- package/dist/browser/event-controller.js +559 -0
- package/dist/browser/event-controller.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/link-interceptor.d.ts +38 -0
- package/dist/browser/link-interceptor.d.ts.map +1 -0
- package/dist/browser/link-interceptor.js +99 -0
- package/dist/browser/link-interceptor.js.map +1 -0
- package/dist/browser/logging.d.ts +10 -0
- package/dist/browser/logging.d.ts.map +1 -0
- package/dist/browser/logging.js +29 -0
- package/dist/browser/logging.js.map +1 -0
- package/dist/browser/lru-cache.d.ts +17 -0
- package/dist/browser/lru-cache.d.ts.map +1 -0
- package/dist/browser/lru-cache.js +50 -0
- package/dist/browser/lru-cache.js.map +1 -0
- package/dist/browser/merge-segment-loaders.d.ts +39 -0
- package/dist/browser/merge-segment-loaders.d.ts.map +1 -0
- package/dist/browser/merge-segment-loaders.js +102 -0
- package/dist/browser/merge-segment-loaders.js.map +1 -0
- package/dist/browser/navigation-bridge.d.ts +102 -0
- package/dist/browser/navigation-bridge.d.ts.map +1 -0
- package/dist/browser/navigation-bridge.js +708 -0
- package/dist/browser/navigation-bridge.js.map +1 -0
- package/dist/browser/navigation-client.d.ts +25 -0
- package/dist/browser/navigation-client.d.ts.map +1 -0
- package/dist/browser/navigation-client.js +157 -0
- package/dist/browser/navigation-client.js.map +1 -0
- package/dist/browser/navigation-store.d.ts +101 -0
- package/dist/browser/navigation-store.d.ts.map +1 -0
- package/dist/browser/navigation-store.js +625 -0
- package/dist/browser/navigation-store.js.map +1 -0
- package/dist/browser/partial-update.d.ts +75 -0
- package/dist/browser/partial-update.d.ts.map +1 -0
- package/dist/browser/partial-update.js +426 -0
- package/dist/browser/partial-update.js.map +1 -0
- package/dist/browser/react/Link.d.ts +86 -0
- package/dist/browser/react/Link.d.ts.map +1 -0
- package/dist/browser/react/Link.js +128 -0
- package/dist/browser/react/Link.js.map +1 -0
- package/dist/browser/react/NavigationProvider.d.ts +63 -0
- package/dist/browser/react/NavigationProvider.d.ts.map +1 -0
- package/dist/browser/react/NavigationProvider.js +216 -0
- package/dist/browser/react/NavigationProvider.js.map +1 -0
- package/dist/browser/react/ScrollRestoration.d.ts +75 -0
- package/dist/browser/react/ScrollRestoration.d.ts.map +1 -0
- package/dist/browser/react/ScrollRestoration.js +57 -0
- package/dist/browser/react/ScrollRestoration.js.map +1 -0
- package/dist/browser/react/context.d.ts +46 -0
- package/dist/browser/react/context.d.ts.map +1 -0
- package/dist/browser/react/context.js +10 -0
- package/dist/browser/react/context.js.map +1 -0
- package/dist/browser/react/index.d.ts +11 -0
- package/dist/browser/react/index.d.ts.map +1 -0
- package/dist/browser/react/index.js +22 -0
- package/dist/browser/react/index.js.map +1 -0
- package/dist/browser/react/location-state-shared.d.ts +63 -0
- package/dist/browser/react/location-state-shared.d.ts.map +1 -0
- package/dist/browser/react/location-state-shared.js +81 -0
- package/dist/browser/react/location-state-shared.js.map +1 -0
- package/dist/browser/react/location-state.d.ts +23 -0
- package/dist/browser/react/location-state.d.ts.map +1 -0
- package/dist/browser/react/location-state.js +29 -0
- package/dist/browser/react/location-state.js.map +1 -0
- package/dist/browser/react/mount-context.d.ts +24 -0
- package/dist/browser/react/mount-context.d.ts.map +1 -0
- package/dist/browser/react/mount-context.js +24 -0
- package/dist/browser/react/mount-context.js.map +1 -0
- package/dist/browser/react/use-action.d.ts +64 -0
- package/dist/browser/react/use-action.d.ts.map +1 -0
- package/dist/browser/react/use-action.js +134 -0
- package/dist/browser/react/use-action.js.map +1 -0
- package/dist/browser/react/use-client-cache.d.ts +41 -0
- package/dist/browser/react/use-client-cache.d.ts.map +1 -0
- package/{src/browser/react/use-client-cache.ts → dist/browser/react/use-client-cache.js} +9 -28
- 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/{src/handles/index.ts → dist/handles/index.d.ts} +1 -2
- 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/dist/href-context.d.ts +29 -0
- package/dist/href-context.d.ts.map +1 -0
- package/dist/href-context.js +21 -0
- package/dist/href-context.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/index.rsc.d.ts +32 -0
- package/dist/index.rsc.d.ts.map +1 -0
- package/dist/index.rsc.js +40 -0
- package/dist/index.rsc.js.map +1 -0
- package/dist/internal-debug.d.ts +2 -0
- package/dist/internal-debug.d.ts.map +1 -0
- package/dist/internal-debug.js +5 -0
- package/dist/internal-debug.js.map +1 -0
- package/dist/loader.d.ts +14 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +20 -0
- package/dist/loader.js.map +1 -0
- package/dist/loader.rsc.d.ts +19 -0
- package/dist/loader.rsc.d.ts.map +1 -0
- package/dist/loader.rsc.js +99 -0
- package/dist/loader.rsc.js.map +1 -0
- package/{src/network-error-thrower.tsx → dist/network-error-thrower.d.ts} +4 -10
- package/dist/network-error-thrower.d.ts.map +1 -0
- package/dist/network-error-thrower.js +14 -0
- package/dist/network-error-thrower.js.map +1 -0
- package/dist/outlet-context.d.ts +13 -0
- package/dist/outlet-context.d.ts.map +1 -0
- package/dist/outlet-context.js +3 -0
- package/dist/outlet-context.js.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts +2 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.js +148 -0
- package/dist/prerender/__tests__/param-hash.test.js.map +1 -0
- package/dist/prerender/param-hash.d.ts +16 -0
- package/dist/prerender/param-hash.d.ts.map +1 -0
- package/dist/prerender/param-hash.js +36 -0
- package/dist/prerender/param-hash.js.map +1 -0
- package/dist/prerender/store.d.ts +38 -0
- package/dist/prerender/store.d.ts.map +1 -0
- package/dist/prerender/store.js +61 -0
- package/dist/prerender/store.js.map +1 -0
- package/dist/prerender.d.ts +66 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +57 -0
- package/dist/prerender.js.map +1 -0
- package/dist/reverse.d.ts +196 -0
- package/dist/reverse.d.ts.map +1 -0
- package/dist/reverse.js +78 -0
- package/dist/reverse.js.map +1 -0
- package/dist/root-error-boundary.d.ts +33 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/root-error-boundary.js +165 -0
- package/dist/root-error-boundary.js.map +1 -0
- package/dist/route-content-wrapper.d.ts +46 -0
- package/dist/route-content-wrapper.d.ts.map +1 -0
- package/dist/route-content-wrapper.js +77 -0
- package/dist/route-content-wrapper.js.map +1 -0
- package/dist/route-definition.d.ts +421 -0
- package/dist/route-definition.d.ts.map +1 -0
- package/dist/route-definition.js +868 -0
- package/dist/route-definition.js.map +1 -0
- package/dist/route-map-builder.d.ts +155 -0
- package/dist/route-map-builder.d.ts.map +1 -0
- package/dist/route-map-builder.js +237 -0
- package/dist/route-map-builder.js.map +1 -0
- package/dist/route-types.d.ts +165 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +7 -0
- package/dist/route-types.js.map +1 -0
- package/dist/router/__tests__/handler-context.test.d.ts +2 -0
- package/dist/router/__tests__/handler-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/handler-context.test.js +65 -0
- package/dist/router/__tests__/handler-context.test.js.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts +2 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js +221 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js.map +1 -0
- package/dist/router/__tests__/match-context.test.d.ts +2 -0
- package/dist/router/__tests__/match-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-context.test.js +92 -0
- package/dist/router/__tests__/match-context.test.js.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts +2 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.js +417 -0
- package/dist/router/__tests__/match-pipelines.test.js.map +1 -0
- package/dist/router/__tests__/match-result.test.d.ts +2 -0
- package/dist/router/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-result.test.js +457 -0
- package/dist/router/__tests__/match-result.test.js.map +1 -0
- package/dist/router/__tests__/on-error.test.d.ts +2 -0
- package/dist/router/__tests__/on-error.test.d.ts.map +1 -0
- package/dist/router/__tests__/on-error.test.js +678 -0
- package/dist/router/__tests__/on-error.test.js.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts +2 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.js +629 -0
- package/dist/router/__tests__/pattern-matching.test.js.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +2 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +155 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +1 -0
- package/dist/router/error-handling.d.ts +77 -0
- package/dist/router/error-handling.d.ts.map +1 -0
- package/dist/router/error-handling.js +202 -0
- package/dist/router/error-handling.js.map +1 -0
- package/dist/router/handler-context.d.ts +20 -0
- package/dist/router/handler-context.d.ts.map +1 -0
- package/dist/router/handler-context.js +198 -0
- package/dist/router/handler-context.js.map +1 -0
- package/dist/router/intercept-resolution.d.ts +66 -0
- package/dist/router/intercept-resolution.d.ts.map +1 -0
- package/dist/router/intercept-resolution.js +246 -0
- package/dist/router/intercept-resolution.js.map +1 -0
- package/dist/router/loader-resolution.d.ts +64 -0
- package/dist/router/loader-resolution.d.ts.map +1 -0
- package/dist/router/loader-resolution.js +284 -0
- package/dist/router/loader-resolution.js.map +1 -0
- package/dist/router/logging.d.ts +15 -0
- package/dist/router/logging.d.ts.map +1 -0
- package/dist/router/logging.js +99 -0
- package/dist/router/logging.js.map +1 -0
- package/dist/router/manifest.d.ts +22 -0
- package/dist/router/manifest.d.ts.map +1 -0
- package/dist/router/manifest.js +181 -0
- package/dist/router/manifest.js.map +1 -0
- package/dist/router/match-api.d.ts +35 -0
- package/dist/router/match-api.d.ts.map +1 -0
- package/dist/router/match-api.js +406 -0
- package/dist/router/match-api.js.map +1 -0
- package/dist/router/match-context.d.ts +206 -0
- package/dist/router/match-context.d.ts.map +1 -0
- package/dist/router/match-context.js +17 -0
- package/dist/router/match-context.js.map +1 -0
- package/dist/router/match-middleware/background-revalidation.d.ts +127 -0
- package/dist/router/match-middleware/background-revalidation.d.ts.map +1 -0
- package/dist/router/match-middleware/background-revalidation.js +75 -0
- package/dist/router/match-middleware/background-revalidation.js.map +1 -0
- package/dist/router/match-middleware/cache-lookup.d.ts +112 -0
- package/dist/router/match-middleware/cache-lookup.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-lookup.js +257 -0
- package/dist/router/match-middleware/cache-lookup.js.map +1 -0
- package/dist/router/match-middleware/cache-store.d.ts +113 -0
- package/dist/router/match-middleware/cache-store.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-store.js +108 -0
- package/dist/router/match-middleware/cache-store.js.map +1 -0
- package/dist/router/match-middleware/index.d.ts +81 -0
- package/dist/router/match-middleware/index.d.ts.map +1 -0
- package/dist/router/match-middleware/index.js +80 -0
- package/dist/router/match-middleware/index.js.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts +117 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.js +134 -0
- package/dist/router/match-middleware/intercept-resolution.js.map +1 -0
- package/dist/router/match-middleware/segment-resolution.d.ts +99 -0
- package/dist/router/match-middleware/segment-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/segment-resolution.js +53 -0
- package/dist/router/match-middleware/segment-resolution.js.map +1 -0
- package/dist/router/match-pipelines.d.ts +147 -0
- package/dist/router/match-pipelines.d.ts.map +1 -0
- package/dist/router/match-pipelines.js +82 -0
- package/dist/router/match-pipelines.js.map +1 -0
- package/dist/router/match-result.d.ts +126 -0
- package/dist/router/match-result.d.ts.map +1 -0
- package/dist/router/match-result.js +93 -0
- package/dist/router/match-result.js.map +1 -0
- package/dist/router/metrics.d.ts +20 -0
- package/dist/router/metrics.d.ts.map +1 -0
- package/dist/router/metrics.js +47 -0
- package/dist/router/metrics.js.map +1 -0
- package/dist/router/middleware.d.ts +249 -0
- package/dist/router/middleware.d.ts.map +1 -0
- package/dist/router/middleware.js +434 -0
- package/dist/router/middleware.js.map +1 -0
- package/dist/router/middleware.test.d.ts +2 -0
- package/dist/router/middleware.test.d.ts.map +1 -0
- package/dist/router/middleware.test.js +816 -0
- package/dist/router/middleware.test.js.map +1 -0
- package/dist/router/pattern-matching.d.ts +149 -0
- package/dist/router/pattern-matching.d.ts.map +1 -0
- package/dist/router/pattern-matching.js +349 -0
- package/dist/router/pattern-matching.js.map +1 -0
- package/dist/router/revalidation.d.ts +44 -0
- package/dist/router/revalidation.d.ts.map +1 -0
- package/dist/router/revalidation.js +147 -0
- package/dist/router/revalidation.js.map +1 -0
- package/dist/router/router-context.d.ts +135 -0
- package/dist/router/router-context.d.ts.map +1 -0
- package/dist/router/router-context.js +36 -0
- package/dist/router/router-context.js.map +1 -0
- package/dist/router/segment-resolution.d.ts +127 -0
- package/dist/router/segment-resolution.d.ts.map +1 -0
- package/dist/router/segment-resolution.js +919 -0
- package/dist/router/segment-resolution.js.map +1 -0
- package/dist/router/trie-matching.d.ts +40 -0
- package/dist/router/trie-matching.d.ts.map +1 -0
- package/dist/router/trie-matching.js +127 -0
- package/dist/router/trie-matching.js.map +1 -0
- package/dist/router/types.d.ts +136 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +7 -0
- package/dist/router/types.js.map +1 -0
- package/dist/router.d.ts +753 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.gen.d.ts +6 -0
- package/dist/router.gen.d.ts.map +1 -0
- package/dist/router.gen.js +6 -0
- package/dist/router.gen.js.map +1 -0
- package/dist/router.js +1304 -0
- package/dist/router.js.map +1 -0
- package/dist/rsc/__tests__/helpers.test.d.ts +2 -0
- package/dist/rsc/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/rsc/__tests__/helpers.test.js +140 -0
- package/dist/rsc/__tests__/helpers.test.js.map +1 -0
- package/dist/rsc/handler.d.ts +45 -0
- package/dist/rsc/handler.d.ts.map +1 -0
- package/dist/rsc/handler.js +1172 -0
- package/dist/rsc/handler.js.map +1 -0
- package/dist/rsc/helpers.d.ts +16 -0
- package/dist/rsc/helpers.d.ts.map +1 -0
- package/dist/rsc/helpers.js +55 -0
- package/dist/rsc/helpers.js.map +1 -0
- package/dist/rsc/index.d.ts +22 -0
- package/dist/rsc/index.d.ts.map +1 -0
- package/dist/rsc/index.js +23 -0
- package/dist/rsc/index.js.map +1 -0
- package/dist/rsc/nonce.d.ts +9 -0
- package/dist/rsc/nonce.d.ts.map +1 -0
- package/dist/rsc/nonce.js +18 -0
- package/dist/rsc/nonce.js.map +1 -0
- package/dist/rsc/types.d.ts +206 -0
- package/dist/rsc/types.d.ts.map +1 -0
- package/dist/rsc/types.js +8 -0
- package/dist/rsc/types.js.map +1 -0
- package/dist/search-params.d.ts +103 -0
- package/dist/search-params.d.ts.map +1 -0
- package/dist/search-params.js +74 -0
- package/dist/search-params.js.map +1 -0
- package/dist/segment-system.d.ts +75 -0
- package/dist/segment-system.d.ts.map +1 -0
- package/dist/segment-system.js +336 -0
- package/dist/segment-system.js.map +1 -0
- package/dist/server/context.d.ts +245 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +197 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/fetchable-loader-store.d.ts +18 -0
- package/dist/server/fetchable-loader-store.d.ts.map +1 -0
- package/dist/server/fetchable-loader-store.js +18 -0
- package/dist/server/fetchable-loader-store.js.map +1 -0
- package/dist/server/handle-store.d.ts +85 -0
- package/dist/server/handle-store.d.ts.map +1 -0
- package/dist/server/handle-store.js +142 -0
- package/dist/server/handle-store.js.map +1 -0
- package/dist/server/loader-registry.d.ts +55 -0
- package/dist/server/loader-registry.d.ts.map +1 -0
- package/dist/server/loader-registry.js +132 -0
- package/dist/server/loader-registry.js.map +1 -0
- package/dist/server/request-context.d.ts +226 -0
- package/dist/server/request-context.d.ts.map +1 -0
- package/dist/server/request-context.js +290 -0
- package/dist/server/request-context.js.map +1 -0
- package/dist/server/root-layout.d.ts +4 -0
- package/dist/server/root-layout.d.ts.map +1 -0
- package/dist/server/root-layout.js +5 -0
- package/dist/server/root-layout.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +20 -0
- package/dist/server.js.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts +2 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.js +132 -0
- package/dist/ssr/__tests__/ssr-handler.test.js.map +1 -0
- package/dist/ssr/index.d.ts +98 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +158 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/static-handler.d.ts +50 -0
- package/dist/static-handler.d.ts.map +1 -0
- package/dist/static-handler.gen.d.ts +5 -0
- package/dist/static-handler.gen.d.ts.map +1 -0
- package/dist/static-handler.gen.js +5 -0
- package/dist/static-handler.gen.js.map +1 -0
- package/dist/static-handler.js +29 -0
- package/dist/static-handler.js.map +1 -0
- package/dist/testing/vitest.js +82 -0
- package/dist/theme/ThemeProvider.d.ts +20 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +240 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/ThemeScript.d.ts +48 -0
- package/dist/theme/ThemeScript.d.ts.map +1 -0
- package/dist/theme/ThemeScript.js +13 -0
- package/dist/theme/ThemeScript.js.map +1 -0
- package/dist/theme/__tests__/theme.test.d.ts +2 -0
- package/dist/theme/__tests__/theme.test.d.ts.map +1 -0
- package/dist/theme/__tests__/theme.test.js +103 -0
- package/dist/theme/__tests__/theme.test.js.map +1 -0
- package/dist/theme/constants.d.ts +29 -0
- package/dist/theme/constants.d.ts.map +1 -0
- package/dist/theme/constants.js +48 -0
- package/dist/theme/constants.js.map +1 -0
- package/dist/theme/index.d.ts +31 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +36 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/theme-context.d.ts +40 -0
- package/dist/theme/theme-context.d.ts.map +1 -0
- package/dist/theme/theme-context.js +60 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/theme/theme-script.d.ts +27 -0
- package/dist/theme/theme-script.d.ts.map +1 -0
- package/dist/theme/theme-script.js +147 -0
- package/dist/theme/theme-script.js.map +1 -0
- package/dist/theme/types.d.ts +163 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +11 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme/use-theme.d.ts +12 -0
- package/dist/theme/use-theme.d.ts.map +1 -0
- package/dist/theme/use-theme.js +40 -0
- package/dist/theme/use-theme.js.map +1 -0
- package/dist/types.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 +4279 -1209
- package/dist/vite/index.js.bak +5448 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/index.named-routes.gen.ts +103 -0
- package/dist/vite/package-resolution.d.ts +43 -0
- package/dist/vite/package-resolution.d.ts.map +1 -0
- package/dist/vite/package-resolution.js +112 -0
- package/dist/vite/package-resolution.js.map +1 -0
- package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/dist/vite/virtual-entries.d.ts +25 -0
- package/dist/vite/virtual-entries.d.ts.map +1 -0
- package/dist/vite/virtual-entries.js +110 -0
- package/dist/vite/virtual-entries.js.map +1 -0
- package/package.json +86 -15
- package/skills/api-client/SKILL.md +211 -0
- package/skills/breadcrumbs/SKILL.md +85 -6
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +251 -24
- package/skills/caching/SKILL.md +338 -13
- package/skills/catalog.json +271 -0
- package/skills/comparison/SKILL.md +50 -0
- package/skills/comparison/agents/openai.yaml +4 -0
- package/skills/comparison/references/framework-comparison.md +837 -0
- package/skills/composability/SKILL.md +110 -4
- package/skills/css/SKILL.md +76 -0
- package/skills/debug-manifest/SKILL.md +5 -3
- package/skills/defer-hydration/SKILL.md +235 -0
- package/skills/document-cache/SKILL.md +87 -56
- package/skills/fonts/SKILL.md +1 -1
- package/skills/handler-use/SKILL.md +364 -0
- package/skills/hooks/SKILL.md +73 -691
- package/skills/hooks/data.md +273 -0
- package/skills/hooks/handle-and-actions.md +103 -0
- package/skills/hooks/navigation.md +110 -0
- package/skills/hooks/outlets.md +41 -0
- package/skills/hooks/state.md +228 -0
- package/skills/hooks/urls.md +135 -0
- package/skills/host-router/SKILL.md +129 -27
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +94 -18
- package/skills/layout/SKILL.md +62 -19
- package/skills/links/SKILL.md +249 -17
- package/skills/loader/SKILL.md +302 -54
- package/skills/middleware/SKILL.md +59 -16
- package/skills/migrate-nextjs/SKILL.md +745 -0
- package/skills/migrate-react-router/SKILL.md +153 -0
- package/skills/migrate-react-router/cloudflare-workers.md +129 -0
- package/skills/migrate-react-router/component-migration.md +196 -0
- package/skills/migrate-react-router/data-and-actions.md +225 -0
- package/skills/migrate-react-router/route-mapping.md +271 -0
- package/skills/mime-routes/SKILL.md +29 -2
- package/skills/observability/SKILL.md +202 -0
- package/skills/parallel/SKILL.md +225 -10
- package/skills/ppr/SKILL.md +622 -0
- package/skills/prerender/SKILL.md +178 -124
- package/skills/rango/SKILL.md +318 -24
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +138 -49
- package/skills/route/SKILL.md +172 -9
- package/skills/router-setup/SKILL.md +131 -11
- package/skills/scripts/SKILL.md +179 -0
- package/skills/server-actions/SKILL.md +776 -0
- package/skills/shell-manifest/SKILL.md +185 -0
- package/skills/streams-and-websockets/SKILL.md +283 -0
- package/skills/tailwind/SKILL.md +28 -4
- package/skills/testing/SKILL.md +130 -0
- package/skills/testing/bindings.md +103 -0
- package/skills/testing/cache-prerender.md +127 -0
- package/skills/testing/client-components.md +124 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +91 -0
- package/skills/testing/handles.md +131 -0
- package/skills/testing/loader.md +128 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +122 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +85 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +123 -0
- package/skills/theme/SKILL.md +1 -1
- package/skills/typesafety/SKILL.md +45 -616
- package/skills/typesafety/env-and-bindings.md +254 -0
- package/skills/typesafety/generated-files-and-cli.md +335 -0
- package/skills/typesafety/params-and-search.md +153 -0
- package/skills/typesafety/route-types.md +209 -0
- package/skills/use-cache/SKILL.md +74 -15
- package/skills/vercel/SKILL.md +128 -0
- package/skills/view-transitions/SKILL.md +337 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +116 -0
- package/src/__internal.ts +1 -66
- package/src/browser/action-coordinator.ts +53 -36
- package/src/browser/action-fence.ts +47 -0
- package/src/browser/app-shell.ts +39 -0
- package/src/browser/app-version.ts +14 -0
- package/src/browser/connection-warmup.ts +134 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/event-controller.ts +257 -158
- package/src/browser/history-state.ts +21 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/invalidate-client-cache.ts +52 -0
- package/src/browser/logging.ts +28 -0
- package/src/browser/merge-segment-loaders.ts +6 -4
- package/src/browser/navigation-bridge.ts +131 -30
- package/src/browser/navigation-client.ts +202 -105
- package/src/browser/navigation-store-handle.ts +38 -0
- package/src/browser/navigation-store.ts +203 -80
- package/src/browser/navigation-transaction.ts +9 -59
- package/src/browser/network-error-handler.ts +34 -7
- package/src/browser/partial-update.ts +205 -121
- package/src/browser/prefetch/cache.ts +247 -72
- package/src/browser/prefetch/fetch.ts +359 -42
- package/src/browser/prefetch/queue.ts +113 -32
- package/src/browser/prefetch/resource-ready.ts +77 -0
- package/src/browser/rango-state.ts +158 -76
- package/src/browser/react/Link.tsx +112 -15
- package/src/browser/react/NavigationProvider.tsx +213 -122
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/context.ts +7 -2
- package/src/browser/react/filter-segment-order.ts +66 -7
- package/src/browser/react/index.ts +0 -48
- package/src/browser/react/location-state-shared.ts +178 -8
- package/src/browser/react/location-state.ts +39 -14
- package/src/browser/react/use-action.ts +6 -15
- package/src/browser/react/use-handle.ts +23 -69
- package/src/browser/react/use-href.tsx +8 -1
- package/src/browser/react/use-link-status.ts +33 -8
- package/src/browser/react/use-navigation.ts +32 -7
- package/src/browser/react/use-params.ts +20 -10
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +46 -11
- package/src/browser/react/use-search-params.ts +0 -5
- package/src/browser/react/use-segments.ts +11 -21
- package/src/browser/response-adapter.ts +99 -8
- package/src/browser/rsc-router.tsx +186 -27
- package/src/browser/scroll-restoration.ts +44 -27
- package/src/browser/segment-reconciler.ts +44 -7
- package/src/browser/segment-structure-assert.ts +2 -2
- package/src/browser/server-action-bridge.ts +244 -71
- package/src/browser/types.ts +127 -12
- package/src/browser/validate-redirect-origin.ts +43 -16
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +207 -158
- package/src/build/generate-route-types.ts +6 -1
- package/src/build/index.ts +11 -3
- package/src/build/prefix-tree-utils.ts +123 -0
- package/src/build/route-trie.ts +198 -41
- package/src/build/route-types/ast-route-extraction.ts +15 -8
- package/src/build/route-types/codegen.ts +16 -5
- package/src/build/route-types/include-resolution.ts +464 -63
- package/src/build/route-types/param-extraction.ts +6 -3
- package/src/build/route-types/per-module-writer.ts +22 -6
- package/src/build/route-types/router-processing.ts +333 -117
- package/src/build/route-types/scan-filter.ts +9 -2
- package/src/build/route-types/source-scan.ts +216 -0
- package/src/build/runtime-discovery.ts +13 -21
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-key-utils.ts +58 -13
- package/src/cache/cache-policy.ts +108 -34
- package/src/cache/cache-runtime.ts +454 -97
- package/src/cache/cache-scope.ts +233 -101
- package/src/cache/cache-tag.ts +149 -0
- package/src/cache/cf/cf-base64.ts +33 -0
- package/src/cache/cf/cf-cache-constants.ts +127 -0
- package/src/cache/cf/cf-cache-store.ts +2206 -372
- package/src/cache/cf/cf-cache-types.ts +349 -0
- package/src/cache/cf/cf-kv-utils.ts +46 -0
- package/src/cache/cf/cf-tag-marker-memo.ts +105 -0
- package/src/cache/cf/index.ts +6 -16
- package/src/cache/document-cache.ts +144 -49
- package/src/cache/handle-snapshot.ts +70 -0
- package/src/cache/index.ts +23 -20
- package/src/cache/memory-segment-store.ts +243 -37
- package/src/cache/profile-registry.ts +46 -31
- package/src/cache/read-through-swr.ts +56 -12
- package/src/cache/segment-codec.ts +13 -21
- package/src/cache/shell-snapshot.ts +417 -0
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/taint.ts +55 -0
- package/src/cache/types.ts +194 -99
- package/src/cache/vercel/index.ts +11 -0
- package/src/cache/vercel/vercel-cache-store.ts +1132 -0
- package/src/client.rsc.tsx +41 -21
- package/src/client.tsx +116 -290
- package/src/cloudflare/index.ts +11 -0
- package/src/cloudflare/tracing.ts +108 -0
- package/src/component-utils.ts +19 -0
- package/src/components/DefaultDocument.tsx +8 -2
- package/src/context-var.ts +84 -2
- package/src/debug.ts +2 -2
- package/src/decode-loader-results.ts +52 -0
- package/src/defer.ts +185 -0
- package/src/deps/ssr.ts +0 -1
- package/src/encode-kv.ts +49 -0
- package/src/errors.ts +30 -4
- package/src/escape-script.ts +52 -0
- package/src/handle.ts +104 -34
- package/src/handles/MetaTags.tsx +24 -53
- package/src/handles/Scripts.tsx +183 -0
- package/src/handles/breadcrumbs.ts +35 -8
- package/src/handles/deferred-resolution.ts +127 -0
- package/src/handles/is-thenable.ts +18 -0
- package/src/handles/meta.ts +14 -40
- package/src/handles/script.ts +244 -0
- package/src/host/cookie-handler.ts +9 -60
- package/src/host/errors.ts +13 -22
- package/src/host/index.ts +9 -2
- package/src/host/pattern-matcher.ts +23 -52
- package/src/host/router.ts +107 -99
- package/src/host/testing.ts +40 -27
- package/src/host/types.ts +37 -4
- package/src/host/utils.ts +1 -1
- package/src/href-client.ts +137 -22
- package/src/index.rsc.ts +100 -13
- package/src/index.ts +143 -19
- package/src/internal-debug.ts +11 -10
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +20 -13
- package/src/loader.ts +12 -11
- package/src/missing-id-error.ts +68 -0
- package/src/outlet-context.ts +1 -1
- package/src/outlet-provider.tsx +1 -5
- package/src/prerender/param-hash.ts +16 -16
- package/src/prerender/store.ts +37 -41
- package/src/prerender.ts +215 -86
- package/src/redirect-origin.ts +114 -0
- package/src/regex-escape.ts +8 -0
- package/src/render-error-thrower.tsx +20 -0
- package/src/response-utils.ts +62 -0
- package/src/reverse.ts +65 -15
- package/src/root-error-boundary.tsx +1 -19
- package/src/route-content-wrapper.tsx +19 -77
- package/src/route-definition/dsl-helpers.ts +485 -303
- package/src/route-definition/helper-factories.ts +28 -140
- package/src/route-definition/helpers-types.ts +153 -77
- package/src/route-definition/index.ts +4 -2
- package/src/route-definition/redirect.ts +51 -10
- package/src/route-definition/resolve-handler-use.ts +160 -0
- package/src/route-definition/use-item-types.ts +29 -0
- package/src/route-map-builder.ts +41 -20
- package/src/route-types.ts +37 -46
- package/src/router/basename.ts +14 -0
- package/src/router/content-negotiation.ts +164 -17
- package/src/router/error-handling.ts +45 -18
- package/src/router/find-match.ts +129 -30
- package/src/router/handler-context.ts +83 -39
- package/src/router/instrument.ts +355 -0
- package/src/router/intercept-resolution.ts +48 -24
- package/src/router/lazy-includes.ts +87 -63
- package/src/router/loader-resolution.ts +286 -56
- package/src/router/logging.ts +1 -7
- package/src/router/manifest.ts +102 -55
- package/src/router/match-api.ts +178 -218
- package/src/router/match-context.ts +0 -22
- package/src/router/match-handlers.ts +211 -165
- package/src/router/match-middleware/background-revalidation.ts +66 -22
- package/src/router/match-middleware/cache-lookup.ts +214 -263
- package/src/router/match-middleware/cache-store.ts +105 -50
- package/src/router/match-middleware/intercept-resolution.ts +8 -28
- package/src/router/match-middleware/segment-resolution.ts +51 -18
- package/src/router/match-pipelines.ts +1 -42
- package/src/router/match-result.ts +128 -44
- package/src/router/metrics.ts +5 -34
- package/src/router/middleware-types.ts +13 -142
- package/src/router/middleware.ts +300 -177
- package/src/router/navigation-snapshot.ts +133 -0
- package/src/router/params-util.ts +23 -0
- package/src/router/parse-pattern.ts +115 -0
- package/src/router/pattern-matching.ts +181 -150
- package/src/router/prefetch-cache-ttl.ts +51 -0
- package/src/router/prefetch-limits.ts +37 -0
- package/src/router/prerender-match.ts +203 -58
- package/src/router/preview-match.ts +35 -103
- package/src/router/request-classification.ts +291 -0
- package/src/router/revalidation.ts +123 -73
- package/src/router/route-snapshot.ts +256 -0
- package/src/router/router-context.ts +6 -28
- package/src/router/router-interfaces.ts +146 -35
- package/src/router/router-options.ts +202 -15
- package/src/router/router-registry.ts +2 -5
- package/src/router/segment-resolution/fresh.ts +301 -78
- package/src/router/segment-resolution/helpers.ts +115 -30
- package/src/router/segment-resolution/loader-cache.ts +156 -39
- package/src/router/segment-resolution/loader-mask.ts +60 -0
- package/src/router/segment-resolution/loader-snapshot.ts +259 -0
- package/src/router/segment-resolution/mask-nested.ts +83 -0
- package/src/router/segment-resolution/revalidation.ts +473 -384
- package/src/router/segment-resolution/static-store.ts +19 -5
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution/view-transition-default.ts +56 -0
- package/src/router/segment-resolution.ts +5 -1
- package/src/router/segment-wrappers.ts +6 -5
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/substitute-pattern-params.ts +75 -0
- package/src/router/telemetry-otel.ts +160 -200
- package/src/router/telemetry.ts +105 -20
- package/src/router/timeout.ts +0 -20
- package/src/router/tracing.ts +215 -0
- package/src/router/trie-matching.ts +171 -59
- package/src/router/types.ts +10 -63
- package/src/router/url-params.ts +57 -0
- package/src/router.ts +206 -71
- package/src/rsc/full-payload.ts +70 -0
- package/src/rsc/handler-context.ts +3 -2
- package/src/rsc/handler.ts +682 -508
- package/src/rsc/helpers.ts +168 -46
- package/src/rsc/index.ts +2 -5
- package/src/rsc/json-route-result.ts +38 -0
- package/src/rsc/loader-fetch.ts +127 -31
- package/src/rsc/manifest-init.ts +33 -42
- package/src/rsc/nonce.ts +10 -1
- package/src/rsc/origin-guard.ts +39 -25
- package/src/rsc/progressive-enhancement.ts +138 -15
- package/src/rsc/redirect-guard.ts +100 -0
- package/src/rsc/response-cache-serve.ts +238 -0
- package/src/rsc/response-error.ts +79 -12
- package/src/rsc/response-route-handler.ts +99 -189
- package/src/rsc/rsc-rendering.ts +498 -73
- package/src/rsc/runtime-warnings.ts +23 -10
- package/src/rsc/server-action.ts +287 -113
- package/src/rsc/shell-capture.ts +1190 -0
- package/src/rsc/shell-serve.ts +181 -0
- package/src/rsc/ssr-setup.ts +18 -2
- package/src/rsc/transition-gate.ts +89 -0
- package/src/rsc/types.ts +62 -6
- package/src/runtime-env.ts +18 -0
- package/src/search-params.ts +35 -30
- package/src/segment-content-promise.ts +67 -0
- package/src/segment-loader-promise.ts +167 -0
- package/src/segment-system.tsx +418 -131
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +367 -61
- package/src/server/cookie-parse.ts +32 -0
- package/src/server/cookie-store.ts +152 -5
- package/src/server/handle-store.ts +40 -38
- package/src/server/loader-registry.ts +38 -46
- package/src/server/request-context.ts +550 -171
- package/src/ssr/index.tsx +467 -174
- package/src/ssr/inject-rsc-eager.ts +167 -0
- package/src/ssr/ssr-root.tsx +228 -0
- package/src/static-handler.ts +27 -18
- package/src/testing/cache-status.ts +162 -0
- package/src/testing/collect-handle.ts +46 -0
- package/src/testing/dispatch.ts +813 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +128 -0
- package/src/testing/e2e/matchers.ts +35 -0
- package/src/testing/e2e/page-helpers.ts +272 -0
- package/src/testing/e2e/parity.ts +387 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +97 -0
- package/src/testing/flight-normalize.ts +11 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +257 -0
- package/src/testing/generated-routes.ts +199 -0
- package/src/testing/index.ts +105 -0
- package/src/testing/internal/context.ts +371 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +54 -0
- package/src/testing/render-handler.ts +357 -0
- package/src/testing/render-route.tsx +584 -0
- package/src/testing/run-loader.ts +385 -0
- package/src/testing/run-middleware.ts +205 -0
- package/src/testing/run-transition-when.ts +164 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/theme/ThemeProvider.tsx +56 -84
- package/src/theme/ThemeScript.tsx +7 -9
- package/src/theme/constants.ts +52 -13
- package/src/theme/index.ts +0 -7
- package/src/theme/theme-context.ts +1 -5
- package/src/theme/theme-script.ts +22 -21
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +0 -35
- package/src/types/cache-types.ts +17 -8
- package/src/types/error-types.ts +30 -90
- package/src/types/global-namespace.ts +54 -41
- package/src/types/handler-context.ts +234 -82
- package/src/types/index.ts +3 -10
- package/src/types/loader-types.ts +44 -15
- package/src/types/request-scope.ts +112 -0
- package/src/types/route-config.ts +20 -52
- package/src/types/route-entry.ts +12 -7
- package/src/types/segments.ts +137 -14
- package/src/urls/include-helper.ts +40 -75
- package/src/urls/include-provider.ts +71 -0
- package/src/urls/index.ts +2 -11
- package/src/urls/path-helper-types.ts +102 -23
- package/src/urls/path-helper.ts +62 -111
- package/src/urls/pattern-types.ts +84 -19
- package/src/urls/response-types.ts +25 -22
- package/src/urls/type-extraction.ts +98 -154
- package/src/urls/urls-function.ts +1 -19
- package/src/use-loader.tsx +346 -89
- package/src/vercel/index.ts +11 -0
- package/src/vercel/tracing.ts +88 -0
- package/src/vite/debug.ts +185 -0
- package/src/vite/discovery/bundle-postprocess.ts +36 -38
- package/src/vite/discovery/dev-prerender-cache.ts +117 -0
- package/src/vite/discovery/discover-routers.ts +130 -85
- package/src/vite/discovery/discovery-errors.ts +255 -0
- package/src/vite/discovery/gate-state.ts +171 -0
- package/src/vite/discovery/prerender-collection.ts +214 -132
- package/src/vite/discovery/route-types-writer.ts +40 -84
- package/src/vite/discovery/self-gen-tracking.ts +27 -1
- package/src/vite/discovery/state.ts +57 -4
- package/src/vite/discovery/virtual-module-codegen.ts +14 -34
- package/src/vite/index.ts +15 -0
- package/src/vite/inject-client-debug.ts +88 -0
- package/src/vite/plugin-types.ts +261 -6
- package/src/vite/plugins/cjs-to-esm.ts +16 -19
- package/src/vite/plugins/client-ref-dedup.ts +16 -11
- package/src/vite/plugins/client-ref-hashing.ts +28 -15
- package/src/vite/plugins/cloudflare-protocol-loader-hook.d.mts +23 -0
- package/src/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/src/vite/plugins/cloudflare-protocol-stub.ts +194 -0
- package/src/vite/plugins/expose-action-id.ts +48 -95
- package/src/vite/plugins/expose-id-utils.ts +96 -51
- package/src/vite/plugins/expose-ids/export-analysis.ts +101 -34
- package/src/vite/plugins/expose-ids/handler-transform.ts +15 -64
- package/src/vite/plugins/expose-ids/loader-transform.ts +14 -24
- package/src/vite/plugins/expose-ids/router-transform.ts +118 -29
- package/src/vite/plugins/expose-internal-ids.ts +553 -317
- package/src/vite/plugins/performance-tracks.ts +89 -0
- package/src/vite/plugins/refresh-cmd.ts +89 -27
- package/src/vite/plugins/use-cache-transform.ts +73 -83
- package/src/vite/plugins/vercel-output.ts +384 -0
- package/src/vite/plugins/version-injector.ts +40 -29
- package/src/vite/plugins/version-plugin.ts +37 -40
- package/src/vite/plugins/virtual-entries.ts +138 -27
- package/src/vite/rango.ts +247 -132
- package/src/vite/router-discovery.ts +1091 -159
- package/src/vite/utils/ast-handler-extract.ts +26 -35
- package/src/vite/utils/banner.ts +4 -4
- package/src/vite/utils/bundle-analysis.ts +10 -15
- package/src/vite/utils/client-chunks.ts +184 -0
- package/src/vite/utils/directive-prologue.ts +40 -0
- package/src/vite/utils/forward-user-plugins.ts +171 -0
- package/src/vite/utils/manifest-utils.ts +4 -59
- package/src/vite/utils/package-resolution.ts +20 -52
- package/src/vite/utils/prerender-utils.ts +98 -38
- package/src/vite/utils/shared-utils.ts +144 -44
- package/src/browser/action-response-classifier.ts +0 -99
- package/src/browser/shallow.ts +0 -40
- package/src/router/middleware-cookies.ts +0 -55
|
@@ -0,0 +1,1190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PPR shell capture orchestration (Axis 2, see docs/design/ppr-shell-resume.md).
|
|
3
|
+
*
|
|
4
|
+
* Capture does NOT flow through the HTTP middleware pipeline. The integrated PPR
|
|
5
|
+
* serve path (rsc-rendering.ts + shell-serve.ts) builds a ShellCaptureDescriptor
|
|
6
|
+
* from the route's `ppr` path option after the served response is built and calls
|
|
7
|
+
* scheduleShellCapture. The capture then runs as a background task that re-derives
|
|
8
|
+
* the page via `ctx.router.match()` under its OWN derived request context — fresh
|
|
9
|
+
* handle store, `_shellCaptureRun: true` so loaders mask (loader-mask.ts) and every
|
|
10
|
+
* loading() subtree postpones. The render is MIXED-CHAIN: cache()'d segments replay
|
|
11
|
+
* from ring 3, uncached segments execute their handlers fresh. It drives the static
|
|
12
|
+
* prerender to a quiescent shell, aborts to freeze the prelude + postponed state,
|
|
13
|
+
* and stores the pair via putShell. Because it uses match() rather than the HTTP
|
|
14
|
+
* pipeline, the middleware chain (auth, logging) never re-runs — it already ran for
|
|
15
|
+
* the triggering request, and the derived context inherits its post-middleware
|
|
16
|
+
* state (variables, cache store). Guarding is serve-time.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import React from "react";
|
|
20
|
+
import { bufferToBase64 } from "../cache/cf/cf-base64.js";
|
|
21
|
+
import { reportCacheError } from "../cache/cache-error.js";
|
|
22
|
+
import { runBackground } from "../cache/background-task.js";
|
|
23
|
+
import { observePhase, PHASES } from "../router/instrument.js";
|
|
24
|
+
import {
|
|
25
|
+
runWithRequestContext,
|
|
26
|
+
setRequestContextParams,
|
|
27
|
+
UNTRACKED_BACKGROUND_TASK,
|
|
28
|
+
type RequestContext,
|
|
29
|
+
} from "../server/request-context.js";
|
|
30
|
+
import { createHandleStore, type HandleStore } from "../server/handle-store.js";
|
|
31
|
+
import { maskNestedContainerThenables } from "../router/segment-resolution/mask-nested.js";
|
|
32
|
+
import { isThenable } from "../handles/is-thenable.js";
|
|
33
|
+
import type {
|
|
34
|
+
ShellCacheEntry,
|
|
35
|
+
SegmentCacheStore,
|
|
36
|
+
ShellSnapshotRecord,
|
|
37
|
+
} from "../cache/types.js";
|
|
38
|
+
import {
|
|
39
|
+
elideLoaderContainer,
|
|
40
|
+
isLoaderHoleMarker,
|
|
41
|
+
} from "../router/segment-resolution/loader-snapshot.js";
|
|
42
|
+
import {
|
|
43
|
+
RecordingShellStore,
|
|
44
|
+
getRecordingStore,
|
|
45
|
+
} from "../cache/shell-snapshot.js";
|
|
46
|
+
import type { HandlerContext } from "./handler-context.js";
|
|
47
|
+
import type { RscPayload, SSRModule } from "./types.js";
|
|
48
|
+
import { buildFullPayload } from "./full-payload.js";
|
|
49
|
+
import { resolveDeferredHandleValues } from "../handles/deferred-resolution.js";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Task-quantized quiesce: the number of consecutive macrotask hops with zero new
|
|
53
|
+
* Flight bytes that marks the shell "quiet". This replaces the old 50ms
|
|
54
|
+
* wall-clock debounce.
|
|
55
|
+
*
|
|
56
|
+
* The capture Flight render is a REGULAR renderToReadableStream (not a static
|
|
57
|
+
* prerender), so React schedules both its retries and its byte-flush on
|
|
58
|
+
* setTimeout(0) MACROTASKS (verified against the vendored edge production
|
|
59
|
+
* react-server-dom build: pingTask uses scheduleMicrotask only when
|
|
60
|
+
* request.type === PRERENDER, otherwise setTimeout; enqueueFlush is always
|
|
61
|
+
* setTimeout). Masked loaders are the live lane — their rows never emit — so once
|
|
62
|
+
* the shell rows finish flushing the stream goes permanently byte-silent, and K
|
|
63
|
+
* consecutive quiet macrotask hops after the last observed byte declare quiesce.
|
|
64
|
+
*
|
|
65
|
+
* K=2 gives a race window of ~two event-loop turns: shell work still producing
|
|
66
|
+
* bytes keeps resetting the counter; anything not producing bytes within the
|
|
67
|
+
* window (the masked loaders, and any genuinely pending I/O) becomes a hole. The
|
|
68
|
+
* only residual is raw per-request I/O rendered directly in shell (not via a
|
|
69
|
+
* loader) that resolves inside the window — a documented shell anti-pattern; put
|
|
70
|
+
* per-request data in loaders. See docs/design/ppr-shell-resume.md.
|
|
71
|
+
*/
|
|
72
|
+
const FLIGHT_QUIET_HOPS = 2;
|
|
73
|
+
|
|
74
|
+
/** Default upper bound on the capture prerender wait before forcing the abort. */
|
|
75
|
+
const SHELL_CAPTURE_MAX_WAIT_MS = 5000;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Upper bound on waiting for the capture's DEFERRED cache writes to settle before
|
|
79
|
+
* draining the snapshot. Cache writes run under waitUntil (fire-and-forget on
|
|
80
|
+
* Node, executionContext on workerd), so a MISS-at-capture value's setItem/set —
|
|
81
|
+
* hence its snapshot record — can land after the shell has quiesced. We collect
|
|
82
|
+
* those write promises and await them here so the written value is pinned. Kept
|
|
83
|
+
* short: a pathological slow write must never stall the background capture; a key
|
|
84
|
+
* that does not settle in time is simply left unpinned (it drifts, the
|
|
85
|
+
* pre-snapshot behavior) rather than hanging. Reads that HIT are recorded
|
|
86
|
+
* synchronously during the render and do not depend on this.
|
|
87
|
+
*/
|
|
88
|
+
const SHELL_SNAPSHOT_WRITE_SETTLE_MS = 1000;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Upper bound on the pre-render WRITE BARRIER: before the capture's match/render,
|
|
92
|
+
* settle the background tasks the FOREGROUND request already scheduled — its
|
|
93
|
+
* deferred ring-3 cacheRoute and ring-1 setItem writes all go through
|
|
94
|
+
* reqCtx.waitUntil, and every one of them is scheduled BEFORE scheduleShellCapture
|
|
95
|
+
* runs (the response, and its onResponse callbacks, are committed first). Draining
|
|
96
|
+
* them turns the capture's cache reads from a RACE into an ORDERING EDGE: the
|
|
97
|
+
* capture deterministically observes the foreground's cache generation, replays it
|
|
98
|
+
* (handler skipped, module-level side effects untouched), and records THAT
|
|
99
|
+
* generation into the snapshot — so prelude, snapshot, and ring-3 all agree on the
|
|
100
|
+
* foreground's generation and the capture can never clobber a foreground-produced
|
|
101
|
+
* entry with a re-render of its own. Scar tissue: without this, the capture's
|
|
102
|
+
* ring-3 lookup could land between the foreground write chain's serialization and
|
|
103
|
+
* its store.set, MISS, re-execute the route handler (bumping module-level
|
|
104
|
+
* counters), and — via the synthetic onResponse fire below — overwrite the
|
|
105
|
+
* foreground's entry (the mini shell-manifest regression). Bounded: a slow
|
|
106
|
+
* consumer waitUntil task must never stall the background capture; on timeout the
|
|
107
|
+
* capture proceeds with the pre-barrier (racy) behavior.
|
|
108
|
+
*/
|
|
109
|
+
const SHELL_CAPTURE_WRITE_BARRIER_MS = 1500;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Settle the tracked background tasks on `reqCtx._pendingBackgroundTasks`,
|
|
113
|
+
* ITERATIVELY: a settled task can have scheduled a nested one (cache-store's
|
|
114
|
+
* cacheRoute outer task schedules the actual store.set in a second waitUntil), so
|
|
115
|
+
* each awaited batch may append more. Loop until no new tasks appear or the
|
|
116
|
+
* deadline passes. The capture's own task never enters the list
|
|
117
|
+
* (UNTRACKED_BACKGROUND_TASK), so the loop terminates.
|
|
118
|
+
*/
|
|
119
|
+
async function settleTrackedBackgroundTasks(
|
|
120
|
+
reqCtx: RequestContext<any>,
|
|
121
|
+
timeoutMs: number,
|
|
122
|
+
): Promise<void> {
|
|
123
|
+
const tasks = reqCtx._pendingBackgroundTasks;
|
|
124
|
+
if (!tasks) return;
|
|
125
|
+
const deadline = Date.now() + timeoutMs;
|
|
126
|
+
let seen = 0;
|
|
127
|
+
while (tasks.length > seen) {
|
|
128
|
+
const remaining = deadline - Date.now();
|
|
129
|
+
if (remaining <= 0) return;
|
|
130
|
+
const batch = tasks.slice(seen);
|
|
131
|
+
seen = tasks.length;
|
|
132
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
133
|
+
const guard = new Promise<void>((resolve) => {
|
|
134
|
+
timer = setTimeout(resolve, remaining);
|
|
135
|
+
(timer as { unref?: () => void }).unref?.();
|
|
136
|
+
});
|
|
137
|
+
await Promise.race([Promise.allSettled(batch).then(() => {}), guard]);
|
|
138
|
+
if (timer) clearTimeout(timer);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Delay before the in-place retry of a capture that produced no usable shell.
|
|
144
|
+
*
|
|
145
|
+
* The dominant reason a first capture comes back with a trivial prelude is a
|
|
146
|
+
* COLD render: in dev the module transform graph (route modules, the SSR/Flight
|
|
147
|
+
* transforms) is being built lazily and outlasts the task-quantized quiesce, so
|
|
148
|
+
* the shell has not finished rendering when we freeze it; on a cold worker the
|
|
149
|
+
* first invocation pays the same one-time cost. The first attempt WARMS that
|
|
150
|
+
* graph, so a second attempt a short beat later usually completes the shell in
|
|
151
|
+
* the SAME background task — no extra HTTP request needed. Short enough to feel
|
|
152
|
+
* instant, long enough for the module graph to settle. See
|
|
153
|
+
* docs/design/ppr-shell-resume.md ("Capture retry-in-place").
|
|
154
|
+
*/
|
|
155
|
+
const SHELL_CAPTURE_RETRY_DELAY_MS = 400;
|
|
156
|
+
|
|
157
|
+
/** Sleep `ms`, unref'd so a Node dev process is never kept alive by the timer. */
|
|
158
|
+
function delay(ms: number): Promise<void> {
|
|
159
|
+
return new Promise((resolve) => {
|
|
160
|
+
const t = setTimeout(resolve, ms);
|
|
161
|
+
(t as { unref?: () => void }).unref?.();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Module-level in-flight key set: the stampede guard for background captures, and
|
|
167
|
+
* its single owner. One capture runs per key per isolate; concurrent MISS/stale
|
|
168
|
+
* requests for the same key coalesce onto the first (the rest see the key present
|
|
169
|
+
* in scheduleShellCapture and skip). Added when a capture is scheduled and cleared
|
|
170
|
+
* in the task's finally once it settles, so a later request can recapture when TTL
|
|
171
|
+
* rolls. Living here (not split across the middleware) keeps the add/clear
|
|
172
|
+
* lifecycle in one layer.
|
|
173
|
+
*/
|
|
174
|
+
const inFlightCaptures = new Set<string>();
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Refused-capture backoff bounds. The window is EXPONENTIAL in the consecutive
|
|
178
|
+
* failure count: `min(BASE * 2^(failures-1), ceiling)` — 1s, 2s, 4s, … up to the
|
|
179
|
+
* mode's ceiling (60s in production, {@link REFUSED_CAPTURE_DEV_MAX_MS} in dev).
|
|
180
|
+
*
|
|
181
|
+
* Why exponential and not a flat 60s: a flat long window conflates two very
|
|
182
|
+
* different failures. A STRUCTURALLY ineligible route (no loading(), a cookie
|
|
183
|
+
* reader) fails forever and wants the long 60s cap. But a cold-but-ELIGIBLE route
|
|
184
|
+
* can also fail the in-place retry under a truly cold graph (dev module transform,
|
|
185
|
+
* or a cold worker under parallel load) — and it must recover FAST, on the next
|
|
186
|
+
* request or two, not be frozen for 60s (that would re-break the very cold-start DX
|
|
187
|
+
* the retry fixes; it bit the cloudflare dev e2e). Escalating from 1s means the
|
|
188
|
+
* eligible route re-probes almost immediately (warm now → HIT and clear), while the
|
|
189
|
+
* doomed route ramps to the ceiling within a handful of failures. Either way an
|
|
190
|
+
* app-wide mount never re-renders a doomed route on EVERY request.
|
|
191
|
+
*/
|
|
192
|
+
const REFUSED_CAPTURE_BASE_MS = 1_000;
|
|
193
|
+
const REFUSED_CAPTURE_MAX_MS = 60_000;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* DEV-only backoff ceiling. In dev the 60s production cap is pure harm: the
|
|
197
|
+
* dominant no-shell cause is a COLD module graph (route modules, SSR/Flight
|
|
198
|
+
* transforms built lazily), and the very attempt that failed WARMS that graph, so
|
|
199
|
+
* the next attempt a beat later usually completes the shell. Capping the dev window
|
|
200
|
+
* low keeps a cold-but-eligible route re-probing every ~2s instead of freezing for
|
|
201
|
+
* up to 60s once the exponential climbs (1s→2s→4s→…→60s). A 60s freeze outlasts the
|
|
202
|
+
* e2e warm windows on cold CI runners: the capture races an unfinished shell,
|
|
203
|
+
* escalates the backoff past the poll window, and every subsequent request inside
|
|
204
|
+
* that window is skipped as backed-off — an eternal MISS for the test even though
|
|
205
|
+
* the modules are warm by then. Production keeps the full 60s cap: there the
|
|
206
|
+
* no-shell cause is far more likely to be a genuinely ineligible route (no
|
|
207
|
+
* loading()), which SHOULD be re-probed rarely. See #652 (item 3) and
|
|
208
|
+
* docs/design/ppr-shell-resume.md ("Refused-capture backoff").
|
|
209
|
+
*/
|
|
210
|
+
const REFUSED_CAPTURE_DEV_MAX_MS = 2_000;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Dev signal, matching the rest of the RSC runtime (handler.ts, server-action.ts,
|
|
214
|
+
* progressive-enhancement.ts): treat anything but an explicit production build as
|
|
215
|
+
* dev. The build folds `process.env.NODE_ENV` to a literal, so this is a compile-
|
|
216
|
+
* time constant in the shipped worker — no runtime probe.
|
|
217
|
+
*/
|
|
218
|
+
function isDevMode(): boolean {
|
|
219
|
+
return process.env.NODE_ENV !== "production";
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** The active backoff ceiling for the current mode (dev capped low, prod at 60s). */
|
|
223
|
+
function refusedCaptureCeilingMs(): number {
|
|
224
|
+
return isDevMode() ? REFUSED_CAPTURE_DEV_MAX_MS : REFUSED_CAPTURE_MAX_MS;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Refused-capture backoff: key -> { consecutive failure count, epoch ms until which
|
|
229
|
+
* the key is not re-probed }. A key enters backoff only after runShellCapture's
|
|
230
|
+
* in-place retry ALSO failed (or a genuine error). A successful capture clears the
|
|
231
|
+
* entry outright (failure count resets). Module-level (same lifetime as
|
|
232
|
+
* inFlightCaptures) so the whole lifecycle lives in one layer.
|
|
233
|
+
*/
|
|
234
|
+
const refusedCaptures = new Map<string, { failures: number; until: number }>();
|
|
235
|
+
|
|
236
|
+
/** True iff `key` is still inside its (exponential) backoff window. */
|
|
237
|
+
function isCaptureBackedOff(key: string): boolean {
|
|
238
|
+
const entry = refusedCaptures.get(key);
|
|
239
|
+
if (entry === undefined) return false;
|
|
240
|
+
// Window elapsed: allow a re-probe. Keep the entry (its failure count drives the
|
|
241
|
+
// NEXT window's escalation if the re-probe also fails); a success clears it.
|
|
242
|
+
return Date.now() < entry.until;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Record a refused/failed capture, escalating the backoff window exponentially up
|
|
247
|
+
* to the current mode's ceiling. The failure count keeps climbing across attempts
|
|
248
|
+
* (so a genuinely doomed route still ramps toward its cap), but the WINDOW is
|
|
249
|
+
* clamped: 60s in production, {@link REFUSED_CAPTURE_DEV_MAX_MS} in dev so a
|
|
250
|
+
* cold-but-eligible route re-probes fast instead of freezing out the e2e warm
|
|
251
|
+
* window on a cold CI runner (#652 item 3).
|
|
252
|
+
*/
|
|
253
|
+
function markCaptureBackoff(key: string): void {
|
|
254
|
+
const failures = (refusedCaptures.get(key)?.failures ?? 0) + 1;
|
|
255
|
+
const window = Math.min(
|
|
256
|
+
REFUSED_CAPTURE_BASE_MS * 2 ** (failures - 1),
|
|
257
|
+
refusedCaptureCeilingMs(),
|
|
258
|
+
);
|
|
259
|
+
refusedCaptures.set(key, { failures, until: Date.now() + window });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Clear any backoff for a key that just captured successfully. */
|
|
263
|
+
function clearCaptureBackoff(key: string): void {
|
|
264
|
+
refusedCaptures.delete(key);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Keys already warned about a refused (null) capture, so the eternal-MISS shape
|
|
269
|
+
* logs once per key per isolate instead of on every request.
|
|
270
|
+
*/
|
|
271
|
+
const warnedNullCaptures = new Set<string>();
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Warn once per key that a capture produced no usable shell EVEN AFTER the
|
|
275
|
+
* in-place retry (runShellCapture attempt 2). Naming both causes with the
|
|
276
|
+
* distinguishing signal — does the route ever flip to HIT — is the whole point:
|
|
277
|
+
* the pre-retry version blamed "a loader route without loading()" unconditionally
|
|
278
|
+
* and misled users whose route DID have loading() and was merely cold. Because the
|
|
279
|
+
* retry already absorbs the cold-start case, by the time this fires cold-start has
|
|
280
|
+
* usually healed, so a firing warning leans toward the structural cause — but we
|
|
281
|
+
* still name both so a cold-start straggler is not misdiagnosed.
|
|
282
|
+
*
|
|
283
|
+
* The pointer is shipped-path-safe (a05c8251 convention): the /ppr skill ships in
|
|
284
|
+
* the npm tarball, but docs/design/ is repo-only, so link it by absolute GitHub URL
|
|
285
|
+
* rather than a relative path that dead-ends for consumers.
|
|
286
|
+
*/
|
|
287
|
+
function warnNullCaptureOnce(key: string): void {
|
|
288
|
+
if (warnedNullCaptures.has(key)) return;
|
|
289
|
+
warnedNullCaptures.add(key);
|
|
290
|
+
console.warn(
|
|
291
|
+
`[rango] Shell capture for "${key}" produced no usable shell after an in-place ` +
|
|
292
|
+
"retry; nothing was stored, so this request stays on MISS. Causes, told apart " +
|
|
293
|
+
"by whether the route ever flips to HIT:\n" +
|
|
294
|
+
" 1. Cold-start warmup (dev module transform, or a cold worker): the capture raced " +
|
|
295
|
+
"an unfinished shell render. This SELF-HEALS — the route flips to HIT once a later " +
|
|
296
|
+
"request warms the modules. Usually nothing to do.\n" +
|
|
297
|
+
" 2. Something suspends above <body> with no Suspense boundary and never settles " +
|
|
298
|
+
"within the capture window: a slower-than-the-capture-guard bake-lane loader " +
|
|
299
|
+
"(loaders on entries WITHOUT loading() execute at capture and their containers " +
|
|
300
|
+
"bake — the boundary-less await must settle for a shell to exist), or a pending " +
|
|
301
|
+
"promise consumed without a <Suspense> above it. The boundary belongs on the " +
|
|
302
|
+
"entry/component that OWNS the data: loading() on the entry that registers the " +
|
|
303
|
+
"loader (a child route's loading() does not unpin a parent layout's loaders), or " +
|
|
304
|
+
"a <Suspense> above the consuming component.\n" +
|
|
305
|
+
'See the /ppr skill (node_modules/@rangojs/router/skills/ppr/SKILL.md), "The hole ' +
|
|
306
|
+
'doctrine" and "The layout-with-loaders playbook", or the design docs: ' +
|
|
307
|
+
"https://github.com/ivogt/vite-rsc/blob/main/packages/rangojs-router/docs/design/ppr-shell-resume.md",
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Keys already warned about a deterministic capture refusal (once per key). */
|
|
312
|
+
const warnedRefusedCaptures = new Set<string>();
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Warn once per key that the capture was REFUSED for a deterministic reason
|
|
316
|
+
* (identity-guard trip or a rejected bake-lane loader). Distinct from
|
|
317
|
+
* warnNullCaptureOnce: these are not cold-start shapes, the retry is skipped,
|
|
318
|
+
* and the message carries the concrete cause instead of a differential.
|
|
319
|
+
*/
|
|
320
|
+
function warnCaptureRefusedOnce(key: string, reason: string): void {
|
|
321
|
+
if (warnedRefusedCaptures.has(key)) return;
|
|
322
|
+
warnedRefusedCaptures.add(key);
|
|
323
|
+
console.warn(
|
|
324
|
+
`[rango] Shell capture for "${key}" was refused: ${reason}\n` +
|
|
325
|
+
"The route stays on MISS (axis 1) — the page keeps working, only the shell " +
|
|
326
|
+
"cache is off. See the /ppr skill " +
|
|
327
|
+
"(node_modules/@rangojs/router/skills/ppr/SKILL.md) and " +
|
|
328
|
+
"docs/design/loader-container-bake.md.",
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** Keys already warned about untagged bake-lane data baked into the shell. */
|
|
333
|
+
const warnedUntaggedShellBakes = new Set<string>();
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Warn once per shell key that a bake-lane loader baked material into the shell
|
|
337
|
+
* but the capture recorded ZERO tags (no render-collected _requestTags, no
|
|
338
|
+
* static ppr.tags). Such data is frozen in the shared shell until TTL and is
|
|
339
|
+
* un-evictable by tag: a server action refreshes the CLIENT only (rotates Rango
|
|
340
|
+
* state, busts the browser HTTP cache) and never touches the server shell store,
|
|
341
|
+
* and updateTag()/revalidateTag() cannot drop data that was baked WITHOUT a tag.
|
|
342
|
+
*
|
|
343
|
+
* Coarse per-shell-key signal, not per-loader attribution — the tag set is
|
|
344
|
+
* unioned globally at the write barrier, not tracked per loader, so we cannot
|
|
345
|
+
* name the offending loader without adding attribution plumbing (deliberately
|
|
346
|
+
* not done). Dev-only + once-per-key so it never spams production or fires on
|
|
347
|
+
* every capture.
|
|
348
|
+
*/
|
|
349
|
+
function warnUntaggedShellBakeOnce(key: string): void {
|
|
350
|
+
if (warnedUntaggedShellBakes.has(key)) return;
|
|
351
|
+
warnedUntaggedShellBakes.add(key);
|
|
352
|
+
console.warn(
|
|
353
|
+
`[rango] Shell capture for "${key}" baked bake-lane loader data into the ` +
|
|
354
|
+
"shell with NO cache tag. That data is frozen in the shared shell until " +
|
|
355
|
+
"TTL and cannot be tag-invalidated: a server action refresh touches the " +
|
|
356
|
+
"client only (not the server shell store), and updateTag() cannot evict " +
|
|
357
|
+
"data that was baked without a tag.\n" +
|
|
358
|
+
'Fix: tag the data (cacheTag() / "use cache" / cache({ tags })) so ' +
|
|
359
|
+
"updateTag() drops the shell, or move the volatile read under a loading() " +
|
|
360
|
+
"hole so it stays on the live lane and is never baked. See the /ppr skill " +
|
|
361
|
+
"(node_modules/@rangojs/router/skills/ppr/SKILL.md).",
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export interface FlightCaptureGate {
|
|
366
|
+
/** Identity passthrough of the source stream; feed this to captureShellHTML. */
|
|
367
|
+
stream: ReadableStream<Uint8Array>;
|
|
368
|
+
/**
|
|
369
|
+
* Resolves once the source has been byte-quiet for FLIGHT_QUIET_HOPS macrotask
|
|
370
|
+
* hops (or has closed — the DATA variant). At that instant the gate FREEZES:
|
|
371
|
+
* no further source byte reaches the fizz side, and the readable is left open
|
|
372
|
+
* (never closed / errored) so fizz postpones the still-pending references
|
|
373
|
+
* instead of seeing "Connection closed".
|
|
374
|
+
*/
|
|
375
|
+
quiesce: Promise<void>;
|
|
376
|
+
/**
|
|
377
|
+
* Stop the internal macrotask-hop loop. captureShellHTML's maxWaitMs bounds the
|
|
378
|
+
* overall wait; dispose() is the clean shutdown for the pathological case where
|
|
379
|
+
* the source never goes byte-quiet (quiesce never fires), so the hop loop would
|
|
380
|
+
* otherwise keep rescheduling after captureShellHTML has already aborted and
|
|
381
|
+
* returned.
|
|
382
|
+
*/
|
|
383
|
+
dispose(): void;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Wrap the capture Flight stream so the fizz shell prerender reads a stream that
|
|
388
|
+
* (a) forwards the shell rows unchanged, (b) resolves `quiesce` after the rows go
|
|
389
|
+
* byte-silent for FLIGHT_QUIET_HOPS macrotask hops, and (c) FREEZES at that
|
|
390
|
+
* instant — dropping any later byte without closing or erroring the readable, so
|
|
391
|
+
* the pending masked-loader references stay pending and fizz postpones them (the
|
|
392
|
+
* "unclosing stream" property, here for free because the masked rows never emit).
|
|
393
|
+
* Freezing also guarantees no post-quiesce byte — including an error row from any
|
|
394
|
+
* later abort/cancel of the underlying render — can corrupt the frozen prelude.
|
|
395
|
+
*
|
|
396
|
+
* Quiet is measured in TASKS, not wall-clock: after the first byte a macrotask
|
|
397
|
+
* hop loop compares a byte counter each turn and fires after K quiet turns. The
|
|
398
|
+
* hop timers are unref'd so they never keep a Node process alive, and the source
|
|
399
|
+
* closing (no holes) fires quiesce immediately for the DATA variant — the
|
|
400
|
+
* TransformStream then closes the readable, so fizz completes with postponed null.
|
|
401
|
+
*
|
|
402
|
+
* `holdUntil` keeps the gate from FREEZING before shell material with real latency
|
|
403
|
+
* has emitted. The hole doctrine bakes TOP-LEVEL pushed handle promises into the
|
|
404
|
+
* shell (resolvedHandleStream awaits them before the handles row emits), but a
|
|
405
|
+
* pushed promise that takes longer than the quiet window would otherwise be frozen
|
|
406
|
+
* out — the handles row would never reach fizz and the prelude would come back
|
|
407
|
+
* trivial. While `holdUntil` is pending, byte-quiet detection keeps running but the
|
|
408
|
+
* gate neither fires nor freezes; once it resolves, the quiet counter restarts so a
|
|
409
|
+
* burst of rows unblocked by it (the resolved handles row) is still captured. It
|
|
410
|
+
* never delays a HOLE from postponing: holes are pending promises that emit no
|
|
411
|
+
* bytes, so holding the gate open longer only ever admits shell rows. Bounded by
|
|
412
|
+
* captureShellHTML's maxWaitMs like every other quiesce input.
|
|
413
|
+
*/
|
|
414
|
+
export function gateFlightForCapture(
|
|
415
|
+
source: ReadableStream<Uint8Array>,
|
|
416
|
+
quietHops: number = FLIGHT_QUIET_HOPS,
|
|
417
|
+
holdUntil?: Promise<unknown>,
|
|
418
|
+
): FlightCaptureGate {
|
|
419
|
+
let resolveQuiet!: () => void;
|
|
420
|
+
const quiesce = new Promise<void>((resolve) => {
|
|
421
|
+
resolveQuiet = resolve;
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
let bytesSeen = 0;
|
|
425
|
+
let armed = false;
|
|
426
|
+
let settled = false;
|
|
427
|
+
let disposed = false;
|
|
428
|
+
let frozen = false;
|
|
429
|
+
let held = holdUntil !== undefined;
|
|
430
|
+
let heldFirePending = false;
|
|
431
|
+
|
|
432
|
+
if (holdUntil !== undefined) {
|
|
433
|
+
const release = (): void => {
|
|
434
|
+
held = false;
|
|
435
|
+
if (heldFirePending && !settled && !disposed) {
|
|
436
|
+
// Quiet elapsed while held: restart the quiet count instead of firing
|
|
437
|
+
// immediately, so rows unblocked by the hold (the baked handles row)
|
|
438
|
+
// still flow before the freeze.
|
|
439
|
+
heldFirePending = false;
|
|
440
|
+
armed = false;
|
|
441
|
+
arm();
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
// Resolve OR reject releases the hold (a rejected handle value is dropped by
|
|
445
|
+
// resolveDeferredHandleValues; the capture must not hang on it).
|
|
446
|
+
holdUntil.then(release, release);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const fire = (): void => {
|
|
450
|
+
if (settled) return;
|
|
451
|
+
if (held) {
|
|
452
|
+
heldFirePending = true;
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
settled = true;
|
|
456
|
+
frozen = true;
|
|
457
|
+
resolveQuiet();
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
const scheduleHop = (fn: () => void): void => {
|
|
461
|
+
const t = setTimeout(fn, 0);
|
|
462
|
+
// Never let the quiet-detection hop alone keep a Node process alive
|
|
463
|
+
// (no-op on workerd).
|
|
464
|
+
(t as { unref?: () => void }).unref?.();
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// The hop loop starts only after the first byte, so it can never declare
|
|
468
|
+
// quiesce before fizz has begun pulling rows through the transform.
|
|
469
|
+
const arm = (): void => {
|
|
470
|
+
if (armed || settled || disposed) return;
|
|
471
|
+
armed = true;
|
|
472
|
+
let lastSeen = bytesSeen;
|
|
473
|
+
let quiet = 0;
|
|
474
|
+
const hop = (): void => {
|
|
475
|
+
if (settled || disposed) return;
|
|
476
|
+
if (bytesSeen === lastSeen) {
|
|
477
|
+
quiet += 1;
|
|
478
|
+
if (quiet >= quietHops) {
|
|
479
|
+
fire();
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
lastSeen = bytesSeen;
|
|
484
|
+
quiet = 0;
|
|
485
|
+
}
|
|
486
|
+
scheduleHop(hop);
|
|
487
|
+
};
|
|
488
|
+
scheduleHop(hop);
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
const monitor = new TransformStream<Uint8Array, Uint8Array>({
|
|
492
|
+
transform(chunk, controller) {
|
|
493
|
+
// Post-quiesce: drop the byte. Do NOT enqueue and do NOT close/error — the
|
|
494
|
+
// frozen fizz input must stay a fixed byte set behind an open (unclosing)
|
|
495
|
+
// readable so still-pending references postpone.
|
|
496
|
+
if (frozen) return;
|
|
497
|
+
bytesSeen += chunk.length;
|
|
498
|
+
arm();
|
|
499
|
+
controller.enqueue(chunk);
|
|
500
|
+
},
|
|
501
|
+
flush() {
|
|
502
|
+
// Source closed with no freeze => DATA variant (no holes): quiet
|
|
503
|
+
// immediately. The TransformStream then closes the readable, so fizz
|
|
504
|
+
// completes and postponed comes back null.
|
|
505
|
+
fire();
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
return {
|
|
510
|
+
stream: source.pipeThrough(monitor),
|
|
511
|
+
quiesce,
|
|
512
|
+
dispose(): void {
|
|
513
|
+
disposed = true;
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* The background shell-capture descriptor: everything the capture task needs to
|
|
520
|
+
* store the shell. Built by the integrated PPR serve path (rsc-rendering.ts) from
|
|
521
|
+
* the route's `ppr` path option (`PartialPrerenderProps`) and the app-level cache
|
|
522
|
+
* store, and passed to scheduleShellCapture directly — it is NOT threaded through
|
|
523
|
+
* the request context. `tags` carries the route's OPERATIONAL `ppr.tags`; the
|
|
524
|
+
* capture UNIONS them with the shell's own auto-collected (non-loader) request
|
|
525
|
+
* tags from its derived render (the collected set stays authoritative). That
|
|
526
|
+
* union happens at the putShell WRITE BARRIER in captureAndStoreShell — after the
|
|
527
|
+
* capture quiesces — not at stream construction, so a tag recorded after an await
|
|
528
|
+
* in async shell content is still collected (issue #676). `store` is the same
|
|
529
|
+
* store the serve path resolved for its getShell read (requestCtx._cacheStore),
|
|
530
|
+
* so the capture writes where the serve reads.
|
|
531
|
+
*/
|
|
532
|
+
export interface ShellCaptureDescriptor {
|
|
533
|
+
key: string;
|
|
534
|
+
/**
|
|
535
|
+
* The RSC handler's build version (HandlerContext.version), stamped into the
|
|
536
|
+
* stored entry as ShellCacheEntry.buildVersion — the serve-side
|
|
537
|
+
* isValidShellHit gate compares it against the running build so a persistent
|
|
538
|
+
* store can never resume a stale build's postponed blob.
|
|
539
|
+
*/
|
|
540
|
+
buildVersion: string;
|
|
541
|
+
ttl?: number;
|
|
542
|
+
swr?: number;
|
|
543
|
+
tags?: string[];
|
|
544
|
+
store?: SegmentCacheStore<any>;
|
|
545
|
+
/** Gates the concise per-attempt capture breadcrumbs (INTERNAL_RANGO_DEBUG). */
|
|
546
|
+
debug?: boolean;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Schedule the background shell capture for a served document. Stampede-guarded:
|
|
551
|
+
* one capture per key per isolate. Runs via runBackground (waitUntil on workerd,
|
|
552
|
+
* fire-and-forget in Node dev), so the served response is never blocked on it. Any
|
|
553
|
+
* error is routed through reportCacheError — capture is best-effort; a failure just
|
|
554
|
+
* means the next request recaptures.
|
|
555
|
+
*
|
|
556
|
+
* Eligibility (nonce/allReady/partial/status/strategy) is decided by the caller
|
|
557
|
+
* (rsc-rendering.ts maybeScheduleShellCapture); this function only owns the
|
|
558
|
+
* stampede guard and the background dispatch.
|
|
559
|
+
*/
|
|
560
|
+
export function scheduleShellCapture(
|
|
561
|
+
ctx: HandlerContext<any>,
|
|
562
|
+
request: Request,
|
|
563
|
+
env: any,
|
|
564
|
+
url: URL,
|
|
565
|
+
reqCtx: RequestContext<any>,
|
|
566
|
+
ssrModule: SSRModule,
|
|
567
|
+
descriptor: ShellCaptureDescriptor,
|
|
568
|
+
): void {
|
|
569
|
+
const key = descriptor.key;
|
|
570
|
+
if (inFlightCaptures.has(key)) return;
|
|
571
|
+
// Refused/failed within the window → skip the doomed re-render (one probe per
|
|
572
|
+
// key per window per isolate). Expired entries self-evict inside the check.
|
|
573
|
+
if (isCaptureBackedOff(key)) return;
|
|
574
|
+
inFlightCaptures.add(key);
|
|
575
|
+
const captureTask = async () => {
|
|
576
|
+
try {
|
|
577
|
+
const outcome = await runShellCapture(
|
|
578
|
+
ctx,
|
|
579
|
+
request,
|
|
580
|
+
env,
|
|
581
|
+
url,
|
|
582
|
+
reqCtx,
|
|
583
|
+
ssrModule,
|
|
584
|
+
descriptor,
|
|
585
|
+
);
|
|
586
|
+
// Update the negative cache off the terminal outcome. A stored shell clears
|
|
587
|
+
// any prior backoff; a `no-shell` (after the in-place retry) backs the key
|
|
588
|
+
// off so the next requests don't re-probe it. A `redirect` has no shell but
|
|
589
|
+
// is not a doomed render — leave the backoff untouched.
|
|
590
|
+
if (outcome === "stored") clearCaptureBackoff(key);
|
|
591
|
+
else if (outcome === "no-shell") markCaptureBackoff(key);
|
|
592
|
+
} catch (error) {
|
|
593
|
+
// Detached background task — pass reqCtx so onError still fires when the ALS
|
|
594
|
+
// context is gone. A genuine failure recurs, so back it off too (re-probe
|
|
595
|
+
// once per window, not every request) and report it once.
|
|
596
|
+
markCaptureBackoff(key);
|
|
597
|
+
reportCacheError(error, "cache-write", "[ShellCache] capture", reqCtx);
|
|
598
|
+
} finally {
|
|
599
|
+
inFlightCaptures.delete(key);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
// The capture's own task must NOT enter reqCtx._pendingBackgroundTasks: the
|
|
603
|
+
// capture drains that list before rendering (the write-barrier ordering edge),
|
|
604
|
+
// and awaiting its own still-running promise would burn the whole barrier
|
|
605
|
+
// deadline on every capture.
|
|
606
|
+
(captureTask as { [UNTRACKED_BACKGROUND_TASK]?: boolean })[
|
|
607
|
+
UNTRACKED_BACKGROUND_TASK
|
|
608
|
+
] = true;
|
|
609
|
+
runBackground(reqCtx, captureTask);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* The outcome of one capture attempt.
|
|
614
|
+
* - `stored`: a usable shell was captured (and a putShell was attempted; a store
|
|
615
|
+
* I/O failure is reported separately and does NOT make the attempt retryable —
|
|
616
|
+
* the capture itself worked).
|
|
617
|
+
* - `redirect`: the matched route redirects, so there is no shell to capture.
|
|
618
|
+
* - `no-shell`: the prelude came back trivial (no <body>) OR captureShellHTML
|
|
619
|
+
* rejected with our own abort. This is the only RETRYABLE outcome.
|
|
620
|
+
*/
|
|
621
|
+
type CaptureAttemptOutcome = "stored" | "redirect" | "no-shell" | "refused";
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Run the shell capture with a single in-place retry, then store the result.
|
|
625
|
+
*
|
|
626
|
+
* Each attempt re-derives EVERYTHING (fresh context, fresh router.match, fresh
|
|
627
|
+
* Flight render) via {@link attemptCapture} — a capture consumes its handle store,
|
|
628
|
+
* its request-tag set, and its one-shot Flight stream, so none of them are
|
|
629
|
+
* reusable across attempts. A first attempt that comes back `no-shell` is almost
|
|
630
|
+
* always a cold render (dev module transform / cold worker) that had not finished
|
|
631
|
+
* when we froze the shell; the attempt itself warmed the module graph, so a second
|
|
632
|
+
* attempt a short beat later usually completes the shell in the SAME background
|
|
633
|
+
* task. That kills the old multi-request warmup where the caller had to re-issue
|
|
634
|
+
* several HTTP requests before a capture stuck. We retry ONLY on `no-shell` (and a
|
|
635
|
+
* defensively-caught abort); a genuine render error is NOT retried — it propagates
|
|
636
|
+
* to scheduleShellCapture's reportCacheError. See docs/design/ppr-shell-resume.md.
|
|
637
|
+
*
|
|
638
|
+
* `retryDelayMs` is a parameter (defaulting to the module const) so unit tests can
|
|
639
|
+
* drive the retry without a real 400ms wall-clock wait.
|
|
640
|
+
*/
|
|
641
|
+
async function runShellCapture(
|
|
642
|
+
ctx: HandlerContext<any>,
|
|
643
|
+
request: Request,
|
|
644
|
+
env: any,
|
|
645
|
+
url: URL,
|
|
646
|
+
reqCtx: RequestContext<any>,
|
|
647
|
+
ssrModule: SSRModule,
|
|
648
|
+
descriptor: ShellCaptureDescriptor,
|
|
649
|
+
retryDelayMs: number = SHELL_CAPTURE_RETRY_DELAY_MS,
|
|
650
|
+
): Promise<CaptureAttemptOutcome> {
|
|
651
|
+
const log = descriptor.debug
|
|
652
|
+
? (message: string) => console.log(message)
|
|
653
|
+
: () => {};
|
|
654
|
+
|
|
655
|
+
const first = await attemptCapture(
|
|
656
|
+
ctx,
|
|
657
|
+
request,
|
|
658
|
+
env,
|
|
659
|
+
url,
|
|
660
|
+
reqCtx,
|
|
661
|
+
ssrModule,
|
|
662
|
+
descriptor,
|
|
663
|
+
);
|
|
664
|
+
// "refused" is deterministic (identity guard / rejected bake-lane loader —
|
|
665
|
+
// its own warning already fired): no retry, and the caller backs the key off
|
|
666
|
+
// exactly like a structural no-shell.
|
|
667
|
+
if (first === "refused") return "no-shell";
|
|
668
|
+
// "stored" (success) or "redirect" (no shell exists): nothing to retry.
|
|
669
|
+
if (first !== "no-shell") return first;
|
|
670
|
+
|
|
671
|
+
// Attempt 1 produced no usable shell. Retry ONCE in place — the first attempt
|
|
672
|
+
// warmed the dev transform graph / cold worker, so attempt 2 typically completes
|
|
673
|
+
// the shell without another HTTP request. The concise line is gated on the
|
|
674
|
+
// middleware's debug flag (threaded via the descriptor) so it replaces the old
|
|
675
|
+
// full DOMException dump with one readable breadcrumb.
|
|
676
|
+
log(
|
|
677
|
+
`[ShellCache] capture attempt 1/2 for ${descriptor.key} aborted before shell completed (cold modules?) — retrying`,
|
|
678
|
+
);
|
|
679
|
+
await delay(retryDelayMs);
|
|
680
|
+
const second = await attemptCapture(
|
|
681
|
+
ctx,
|
|
682
|
+
request,
|
|
683
|
+
env,
|
|
684
|
+
url,
|
|
685
|
+
reqCtx,
|
|
686
|
+
ssrModule,
|
|
687
|
+
descriptor,
|
|
688
|
+
);
|
|
689
|
+
if (second === "refused") return "no-shell";
|
|
690
|
+
if (second !== "no-shell") return second;
|
|
691
|
+
|
|
692
|
+
// Both attempts came back with no usable shell. Cold-start would have healed by
|
|
693
|
+
// now, so the eternal-MISS structural shape (a loader route without loading()) is
|
|
694
|
+
// the likely cause — warn once per key. Ordering matters: because the retry
|
|
695
|
+
// absorbs cold-start, cold-start routes almost never reach this warning. The
|
|
696
|
+
// caller (scheduleShellCapture) reads this `no-shell` return to back the key off.
|
|
697
|
+
log(
|
|
698
|
+
`[ShellCache] capture attempt 2/2 for ${descriptor.key} aborted — giving up until next request`,
|
|
699
|
+
);
|
|
700
|
+
warnNullCaptureOnce(descriptor.key);
|
|
701
|
+
return "no-shell";
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* One capture attempt in a DERIVED request context.
|
|
706
|
+
*
|
|
707
|
+
* The derived context is `Object.create(reqCtx)` so it inherits the foreground's
|
|
708
|
+
* post-middleware state (variables, cache store, env/request/url, waitUntil) while
|
|
709
|
+
* overriding the render-scoped accumulators as own properties:
|
|
710
|
+
* - _handleStore: a fresh store. The foreground store is already drained to
|
|
711
|
+
* completion (its stream() flipped `completed` on settle) and would throw
|
|
712
|
+
* LateHandlePushError on any re-push. Every downstream reader resolves the
|
|
713
|
+
* store off the ambient context (setupLoaderAccess captures
|
|
714
|
+
* _getRequestContext()._handleStore; trackHandler reads it), so the fresh
|
|
715
|
+
* store on the derived context is what the capture match() writes handles to.
|
|
716
|
+
* - _requestTags: a fresh Set. The capture collects its OWN shell tags here —
|
|
717
|
+
* non-loader tags only, since loaders are masked — which is exactly the tag
|
|
718
|
+
* set a shell entry should be invalidatable by (loader tags belong to holes).
|
|
719
|
+
* - _transitionWhen: a fresh [] so the capture's transition gating is its own.
|
|
720
|
+
* - _shellCaptureRun: true — the switch loaders/cookies/headers guards read.
|
|
721
|
+
* - _metricsStore: undefined so the capture never appends to the foreground's
|
|
722
|
+
* (already-finalized) metrics.
|
|
723
|
+
*
|
|
724
|
+
* The capture is MIXED-CHAIN: its match() behaves like a normal render with
|
|
725
|
+
* respect to the segment cache — cache()'d segments replay from ring 3, UNCACHED
|
|
726
|
+
* segments execute their handlers fresh (which is why the cookies()/headers()
|
|
727
|
+
* capture guard is load-bearing). Middleware is NOT re-run: it already ran for the
|
|
728
|
+
* triggering request, and the derived context inherits its post-middleware state
|
|
729
|
+
* (guarding is serve-time; the shell is never served without the full chain).
|
|
730
|
+
*
|
|
731
|
+
* A FRESH context (and match/render) per attempt is what makes the retry sound:
|
|
732
|
+
* the second attempt is a clean capture, not a resumption of the first.
|
|
733
|
+
*/
|
|
734
|
+
async function attemptCapture(
|
|
735
|
+
ctx: HandlerContext<any>,
|
|
736
|
+
request: Request,
|
|
737
|
+
env: any,
|
|
738
|
+
url: URL,
|
|
739
|
+
reqCtx: RequestContext<any>,
|
|
740
|
+
ssrModule: SSRModule,
|
|
741
|
+
descriptor: ShellCaptureDescriptor,
|
|
742
|
+
): Promise<CaptureAttemptOutcome> {
|
|
743
|
+
// WRITE BARRIER (ordering edge, not a narrower race): settle the foreground's
|
|
744
|
+
// already-scheduled background tasks — its deferred ring-3/ring-1 cache writes —
|
|
745
|
+
// BEFORE this attempt's match/render, so the capture's cache reads observe the
|
|
746
|
+
// foreground's generation deterministically. Contract: a capture must never
|
|
747
|
+
// clobber a ring-3 entry the foreground produced; with the barrier, the
|
|
748
|
+
// capture's ring-3 lookup HITs the foreground's entry and REPLAYS it (handler
|
|
749
|
+
// skipped, cache-store middleware's write path gated off by state.cacheHit), so
|
|
750
|
+
// prelude, snapshot, and ring-3 agree on the foreground's generation. Runs per
|
|
751
|
+
// attempt (the retry re-checks; already-settled promises are free).
|
|
752
|
+
await settleTrackedBackgroundTasks(reqCtx, SHELL_CAPTURE_WRITE_BARRIER_MS);
|
|
753
|
+
|
|
754
|
+
const freshHandleStore = createHandleStore();
|
|
755
|
+
freshHandleStore.onError = reqCtx._handleStore.onError;
|
|
756
|
+
// Shape = liveness for handles, exactly as for bake-lane loader containers
|
|
757
|
+
// (mask-nested.ts): nested thenables in a pushed handle container are
|
|
758
|
+
// per-request by declaration, so the CAPTURE's copy masks them — the
|
|
759
|
+
// consuming boundary postpones as a hole regardless of settle timing,
|
|
760
|
+
// instead of a fast-settling nested value baking into the shared shell. A
|
|
761
|
+
// TOP-LEVEL promise push keeps its documented bake contract (awaited
|
|
762
|
+
// pre-SSR, gate held open for it), but the container it RESOLVES to gets
|
|
763
|
+
// the same nested masking. Wrapping THIS store's push is the single funnel:
|
|
764
|
+
// the store exists only for this capture attempt, so every push wrapper
|
|
765
|
+
// (setupLoaderAccess, createUseFunction, prerender) inherits the policy and
|
|
766
|
+
// the foreground store is untouched.
|
|
767
|
+
const rawCapturePush = freshHandleStore.push.bind(freshHandleStore);
|
|
768
|
+
freshHandleStore.push = (
|
|
769
|
+
handleName: string,
|
|
770
|
+
segmentId: string,
|
|
771
|
+
value: unknown,
|
|
772
|
+
) => {
|
|
773
|
+
const masked = isThenable(value)
|
|
774
|
+
? value.then((v: unknown) => maskNestedContainerThenables(v))
|
|
775
|
+
: maskNestedContainerThenables(value);
|
|
776
|
+
rawCapturePush(handleName, segmentId, masked);
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
const derivedCtx: RequestContext = Object.create(reqCtx);
|
|
780
|
+
derivedCtx._handleStore = freshHandleStore;
|
|
781
|
+
derivedCtx._requestTags = new Set<string>();
|
|
782
|
+
derivedCtx._transitionWhen = [];
|
|
783
|
+
derivedCtx._shellCaptureRun = true;
|
|
784
|
+
derivedCtx._metricsStore = undefined;
|
|
785
|
+
// Spans, like perf metrics above, are a FOREGROUND surface: the capture
|
|
786
|
+
// re-render must not emit a second rango.render/loader/ssr set after the
|
|
787
|
+
// foreground rango.request span ended (orphan spans in the trace).
|
|
788
|
+
// _tracing is otherwise inherited through Object.create(reqCtx).
|
|
789
|
+
derivedCtx._tracing = undefined;
|
|
790
|
+
// Bake-lane loader containers (loaders on entries with no renderable
|
|
791
|
+
// loading() execute during capture — docs/design/loader-container-bake.md).
|
|
792
|
+
// resolveLoaderData registers each container promise here; the drain in
|
|
793
|
+
// captureAndStoreShell elides + pins them into the snapshot's loader family.
|
|
794
|
+
derivedCtx._shellCaptureLoaderRecords = new Map();
|
|
795
|
+
// Own onResponse list so the capture's match-middleware callbacks (the ring-3
|
|
796
|
+
// segment cache write registers here) are ISOLATED from the foreground's shared
|
|
797
|
+
// array AND can be fired by captureAndStoreShell. The segment write is gated
|
|
798
|
+
// behind onResponse, which the capture never triggers (it builds no Response) —
|
|
799
|
+
// without firing it, a ring-3 cache() MISS at capture renders fresh into the
|
|
800
|
+
// prelude but is never written, so it is never recorded and drifts on a HIT.
|
|
801
|
+
derivedCtx._onResponseCallbacks = [];
|
|
802
|
+
|
|
803
|
+
// Capture data snapshot: read every cache-store hit/write through a recording
|
|
804
|
+
// wrapper on the DERIVED context's store (own property, so the shared
|
|
805
|
+
// reqCtx._cacheStore is untouched — the snapshot is per-capture). Its records
|
|
806
|
+
// ride inside the ShellCacheEntry so a HIT can reproduce the shell's cached
|
|
807
|
+
// content byte-identically. See cache/shell-snapshot.ts and the design doc.
|
|
808
|
+
//
|
|
809
|
+
// Cache writes are deferred (waitUntil): a MISS-at-capture value's setItem/set
|
|
810
|
+
// — hence its record — would otherwise land after the shell quiesces. Override
|
|
811
|
+
// the derived context's waitUntil to COLLECT those write promises (still
|
|
812
|
+
// forwarding to the parent so the write persists and the worker stays alive),
|
|
813
|
+
// then captureAndStoreShell awaits them before draining. Reads that HIT are
|
|
814
|
+
// recorded synchronously during the render and need none of this.
|
|
815
|
+
if (reqCtx._cacheStore) {
|
|
816
|
+
const recordingStore = new RecordingShellStore(reqCtx._cacheStore);
|
|
817
|
+
derivedCtx._cacheStore = recordingStore;
|
|
818
|
+
derivedCtx.waitUntil = (fn: () => Promise<void>): void => {
|
|
819
|
+
const p = Promise.resolve().then(fn);
|
|
820
|
+
recordingStore.trackWrite(p);
|
|
821
|
+
reqCtx.waitUntil(() => p);
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
return runWithRequestContext(derivedCtx, async () => {
|
|
826
|
+
const match = await ctx.router.match(request, { env });
|
|
827
|
+
// A route that redirects has no shell to capture — bail (no store write, no
|
|
828
|
+
// retry: a redirect is deterministic).
|
|
829
|
+
if (match.redirect) return "redirect";
|
|
830
|
+
|
|
831
|
+
setRequestContextParams(match.params, match.routeName);
|
|
832
|
+
|
|
833
|
+
const payload = buildFullPayload(
|
|
834
|
+
match,
|
|
835
|
+
ctx,
|
|
836
|
+
url,
|
|
837
|
+
derivedCtx,
|
|
838
|
+
freshHandleStore,
|
|
839
|
+
);
|
|
840
|
+
const rscStream = ctx.renderToReadableStream<RscPayload>(payload, {
|
|
841
|
+
onError: (error: unknown) => {
|
|
842
|
+
ctx.callOnError(error, "rendering", { request, url, env });
|
|
843
|
+
},
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
// Pass the descriptor with its STATIC ppr.tags unchanged. The shell's own
|
|
847
|
+
// render-recorded tags are snapshotted at the putShell WRITE BARRIER inside
|
|
848
|
+
// captureAndStoreShell, not here: a tag recorded AFTER an await in async shell
|
|
849
|
+
// content (and tags propagated by async cache()/"use cache" reads) lands after
|
|
850
|
+
// this synchronous construction point, so snapshotting here dropped it — the
|
|
851
|
+
// shell-tag snapshot must sit behind the quiesce gate (issue #676).
|
|
852
|
+
return captureAndStoreShell(
|
|
853
|
+
ssrModule,
|
|
854
|
+
rscStream,
|
|
855
|
+
freshHandleStore,
|
|
856
|
+
derivedCtx,
|
|
857
|
+
descriptor,
|
|
858
|
+
);
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Seal handles, derive the quiesce signal, prerender + abort via the SSR module's
|
|
864
|
+
* captureShellHTML, and store the result. Returns the attempt outcome (the caller
|
|
865
|
+
* owns retry/warn decisions — this function no longer warns). Never throws out of
|
|
866
|
+
* the store write: a failed putShell is routed through reportCacheError so the
|
|
867
|
+
* background task stays best-effort, and the attempt still counts as `stored` (the
|
|
868
|
+
* capture worked; only the store I/O failed). `ssrModule.captureShellHTML` MUST be
|
|
869
|
+
* present (eligibility is checked before scheduling).
|
|
870
|
+
*
|
|
871
|
+
* A `no-shell` result (trivial prelude, or a defensively-caught abort) is the only
|
|
872
|
+
* retryable outcome; a genuine (non-abort) captureShellHTML error propagates so it
|
|
873
|
+
* reaches reportCacheError and is NOT retried.
|
|
874
|
+
*/
|
|
875
|
+
async function captureAndStoreShell(
|
|
876
|
+
ssrModule: SSRModule,
|
|
877
|
+
rscStream: ReadableStream<Uint8Array>,
|
|
878
|
+
handleStore: HandleStore,
|
|
879
|
+
reqCtx: RequestContext<any>,
|
|
880
|
+
capture: ShellCaptureDescriptor,
|
|
881
|
+
): Promise<Exclude<CaptureAttemptOutcome, "redirect">> {
|
|
882
|
+
const captureShellHTML = ssrModule.captureShellHTML!;
|
|
883
|
+
|
|
884
|
+
// Seal the handle store so the payload's handles generator (resolvedHandleStream
|
|
885
|
+
// -> handleStore.stream()) converges and completes even though masked loaders
|
|
886
|
+
// never resolve. handleStore.settled gates ONLY on tracked HANDLER promises
|
|
887
|
+
// (handleStore.track, via trackHandler) — NOT on deferred handle VALUES pushed
|
|
888
|
+
// through ctx.use(Handle).defer(), which are plain pushed promises. So seal()
|
|
889
|
+
// does not reject or hang on outstanding defers: settled resolves once the
|
|
890
|
+
// handlers settle, and each deferred slot resolves on its own createDeferred
|
|
891
|
+
// timeout (defer.ts, default 10s) or when its resolver fires. A defer whose
|
|
892
|
+
// resolver depends on a masked loader can never fire, so it stays pending until
|
|
893
|
+
// that 10s timeout — longer than maxWaitMs (5s). At the abort the handles
|
|
894
|
+
// generator has not yielded, SsrRoot suspends at the root (consumeAsyncGenerator
|
|
895
|
+
// sits above every boundary), the prelude comes back trivial, and
|
|
896
|
+
// captureShellHTML's sanity gate returns null: the designed fail-safe no-op, not
|
|
897
|
+
// an error. This mirrors the __prerender_collect seal+settled regime, which also
|
|
898
|
+
// excludes loaders. See docs/design/ppr-shell-resume.md ("Loaders and handles").
|
|
899
|
+
handleStore.seal();
|
|
900
|
+
|
|
901
|
+
// Handles contract, shell half ("nesting = liveness"): TOP-LEVEL pushed handle
|
|
902
|
+
// promises are BAKED into the shell — resolvedHandleStream awaits them before
|
|
903
|
+
// the payload's handles row emits. A pushed promise with real latency would lose
|
|
904
|
+
// the byte-quiet race (the pending handles row emits no bytes, the gate freezes,
|
|
905
|
+
// the row is dropped, SsrRoot suspends at the root), so the gate is HELD open
|
|
906
|
+
// until the same await completes: handlesBaked mirrors resolvedHandleStream's
|
|
907
|
+
// resolution (getData waits the tracked-handler barrier; resolveDeferredHandleValues
|
|
908
|
+
// awaits the top-level thenables). NESTED promises inside pushed containers are
|
|
909
|
+
// shallow-skipped by isThenable and never hold the gate — they stay holes.
|
|
910
|
+
// Bounded by maxWaitMs like every quiesce input (a defer hanging on a masked
|
|
911
|
+
// loader still ends in the sanity-gate refusal).
|
|
912
|
+
const handlesBaked = handleStore.getData().then(resolveDeferredHandleValues);
|
|
913
|
+
// Bake-lane loader containers hold the gate the same way (loader-container-
|
|
914
|
+
// bake): a boundary-less container with real latency (a 100ms layout loader)
|
|
915
|
+
// would otherwise lose the 2-hop byte-quiet race — the pending loaderData row
|
|
916
|
+
// emits no bytes, the gate freezes, and the awaiting tree pins above <body>.
|
|
917
|
+
// The records map is fully populated before this point (loader promises are
|
|
918
|
+
// created during the capture's match()), so the hold covers every bake-lane
|
|
919
|
+
// container. allSettled: a REJECTED container releases the hold (the drain
|
|
920
|
+
// below refuses the capture); nested promises INSIDE a container never hold
|
|
921
|
+
// the gate — they stay holes. Bounded by maxWaitMs like every quiesce input.
|
|
922
|
+
const loaderRecordsForHold = reqCtx._shellCaptureLoaderRecords;
|
|
923
|
+
const holdUntil =
|
|
924
|
+
loaderRecordsForHold && loaderRecordsForHold.size > 0
|
|
925
|
+
? Promise.allSettled([handlesBaked, ...loaderRecordsForHold.values()])
|
|
926
|
+
: handlesBaked;
|
|
927
|
+
const gate = gateFlightForCapture(rscStream, undefined, holdUntil);
|
|
928
|
+
// Quiesce = handles settled AND the Flight shell rows went task-quiet. Either
|
|
929
|
+
// half stalling is bounded by captureShellHTML's maxWaitMs.
|
|
930
|
+
const quiesce = Promise.all([handleStore.settled, gate.quiesce]).then(
|
|
931
|
+
() => {},
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
// Deterministic identity-guard refusal, checked at BOTH exits below: the
|
|
935
|
+
// guard error either rejects the prerender itself (boundary-less segment —
|
|
936
|
+
// lands in the catch) or is swallowed into per-loader error UI (the render
|
|
937
|
+
// completes — caught after the try). One helper so the message and the
|
|
938
|
+
// "refused" mapping cannot drift between the two sites.
|
|
939
|
+
const refuseOnGuardTrip = (): "refused" | undefined => {
|
|
940
|
+
const fnName = reqCtx._shellCaptureGuardTripped;
|
|
941
|
+
if (!fnName) return undefined;
|
|
942
|
+
// Name the recorded source instead of hardcoding a lane. Under the
|
|
943
|
+
// consumption-lane rule, handler-INVOKED loader bodies are exempt from
|
|
944
|
+
// the guard (their value is a baked shared copy, mirroring cache()), so a
|
|
945
|
+
// trip can only come from a bake-lane SEGMENT loader or from non-loader
|
|
946
|
+
// handler/render code — the old blanket "bake-lane loader" attribution
|
|
947
|
+
// sent a live-lane debugging session down the wrong lane (issue #672).
|
|
948
|
+
const loaderId = reqCtx._shellCaptureGuardTrippedLoaderId;
|
|
949
|
+
const origin = loaderId
|
|
950
|
+
? `segment loader "${loaderId}"`
|
|
951
|
+
: "handler/render code (no loader body was executing)";
|
|
952
|
+
warnCaptureRefusedOnce(
|
|
953
|
+
capture.key,
|
|
954
|
+
`${origin} called ${fnName}() during capture. Identity must not bake into a shared shell. ` +
|
|
955
|
+
"For a segment loader (bake lane, no loading()): give its entry a loading() boundary " +
|
|
956
|
+
"(the live lane, masked at capture) or move the identity-dependent part into a nested " +
|
|
957
|
+
"promise. For handler/render code: keep the value live by consuming a loader " +
|
|
958
|
+
'client-side (useLoader in a "use client" component). Note: `await ctx.use(loader)` ' +
|
|
959
|
+
"inside a HANDLER is exempt from this guard — its value bakes into the shared shell " +
|
|
960
|
+
"as a capture-time copy, mirroring cache() semantics (the consumption-lane rule).",
|
|
961
|
+
);
|
|
962
|
+
return "refused";
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
try {
|
|
966
|
+
// captureShellHTML CONSUMES the (gated) stream — it is not also SSR'd.
|
|
967
|
+
let result: Awaited<ReturnType<typeof captureShellHTML>>;
|
|
968
|
+
try {
|
|
969
|
+
result = await observePhase(PHASES.ssr, () =>
|
|
970
|
+
captureShellHTML(gate.stream, {
|
|
971
|
+
quiesce,
|
|
972
|
+
maxWaitMs: SHELL_CAPTURE_MAX_WAIT_MS,
|
|
973
|
+
}),
|
|
974
|
+
);
|
|
975
|
+
} catch (error) {
|
|
976
|
+
// Guard-tripped rejection arrives here (not at the drain) — refuse
|
|
977
|
+
// BEFORE the AbortError-vs-rethrow decision below.
|
|
978
|
+
const refused = refuseOnGuardTrip();
|
|
979
|
+
if (refused) return refused;
|
|
980
|
+
// captureShellHTML normally converts its OWN deliberate abort to a null
|
|
981
|
+
// return (index.tsx). This catch is defensive: if an AbortError still escapes
|
|
982
|
+
// (a runtime where the abort surfaces as a stream rejection outside its
|
|
983
|
+
// guard), treat it as the same retryable "no usable shell" degradation rather
|
|
984
|
+
// than a failure — do NOT report it as an error. A genuine (non-abort) render
|
|
985
|
+
// error is a real failure: rethrow so it reaches reportCacheError (no retry).
|
|
986
|
+
if ((error as { name?: string } | null)?.name === "AbortError") {
|
|
987
|
+
return "no-shell";
|
|
988
|
+
}
|
|
989
|
+
throw error;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// null = sanity gate refused (trivial/empty prelude, no <body>). Store nothing
|
|
993
|
+
// and report `no-shell` so the caller (runShellCapture) can retry once and, if
|
|
994
|
+
// that also fails, warn once per key. On a cold render this is the shell not
|
|
995
|
+
// yet finished; on a loader route WITHOUT a route-level loading() boundary it is
|
|
996
|
+
// the structural eternal-MISS shape (the masked loader pins the tree above
|
|
997
|
+
// <body> at tree-build). The caller's warning names both.
|
|
998
|
+
// Guard check first — BEFORE the trivial-prelude retry path. A guard trip
|
|
999
|
+
// is deterministic (retrying re-trips it), and when the tripping loader's
|
|
1000
|
+
// error UI still completed a shell, storing it would bake the failure into
|
|
1001
|
+
// a shared page.
|
|
1002
|
+
const refused = refuseOnGuardTrip();
|
|
1003
|
+
if (refused) return refused;
|
|
1004
|
+
|
|
1005
|
+
if (result === null) {
|
|
1006
|
+
return "no-shell";
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// Store per the flag's key/ttl/swr/tags, into the flag's store: the middleware
|
|
1010
|
+
// threads the SAME store it resolved for its getShell read (options.store ??
|
|
1011
|
+
// _cacheStore), so a store-attached middleware writes captures where it reads
|
|
1012
|
+
// them. The _cacheStore fallback covers a flag armed without a store (tests).
|
|
1013
|
+
// reactVersion is read from the same React.version import the middleware
|
|
1014
|
+
// validates reads against, so capture and serve always agree.
|
|
1015
|
+
// Fire the capture's isolated onResponse callbacks with a synthetic 200 so
|
|
1016
|
+
// the ring-3 segment cache write (cacheScope.cacheRoute, registered via
|
|
1017
|
+
// onResponse by the cache-store match-middleware and gated on a 200) runs
|
|
1018
|
+
// DURING capture, routed through the recording store. The foreground path
|
|
1019
|
+
// never fires for the capture — it builds no Response — so without this a
|
|
1020
|
+
// cache() SEGMENT that MISSED at capture would be rendered fresh into the
|
|
1021
|
+
// prelude yet never written, hence never recorded, and would drift on a HIT
|
|
1022
|
+
// (an item-family "use cache" write already runs inline during the render, so
|
|
1023
|
+
// it needs none of this; only segment writes are onResponse-gated). The
|
|
1024
|
+
// derived context's own _onResponseCallbacks holds only capture match-
|
|
1025
|
+
// middleware callbacks (HTTP middleware never runs for a capture), so firing
|
|
1026
|
+
// them is safe. Best-effort: a throwing callback must not fail the capture.
|
|
1027
|
+
const responseCallbacks = reqCtx._onResponseCallbacks;
|
|
1028
|
+
if (responseCallbacks && responseCallbacks.length > 0) {
|
|
1029
|
+
const synthetic = new Response(null, { status: 200 });
|
|
1030
|
+
for (const cb of responseCallbacks) {
|
|
1031
|
+
try {
|
|
1032
|
+
cb(synthetic);
|
|
1033
|
+
} catch {
|
|
1034
|
+
// A capture-time cache write that throws is degradation, not failure.
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// Drain the capture data snapshot from the recording store on the derived
|
|
1040
|
+
// context. Await the deferred cache writes first so a MISS-at-capture value
|
|
1041
|
+
// (setItem/set scheduled under waitUntil, including the segment write just
|
|
1042
|
+
// fired) is pinned, not just read-hits. When no recording store is installed
|
|
1043
|
+
// (unit tests that call this directly), there is simply no snapshot.
|
|
1044
|
+
const recording = getRecordingStore(reqCtx._cacheStore);
|
|
1045
|
+
let snapshot: ShellSnapshotRecord[] | undefined;
|
|
1046
|
+
if (recording) {
|
|
1047
|
+
await recording.settleWrites(SHELL_SNAPSHOT_WRITE_SETTLE_MS);
|
|
1048
|
+
snapshot = recording.drainSnapshot();
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// Pin the bake-lane loader containers (loader family). Settled containers
|
|
1052
|
+
// are promise-elided (a still-pending nested promise is a hole marker, not
|
|
1053
|
+
// shell material) and Flight-serialized; a REJECTED container refuses the
|
|
1054
|
+
// capture — per-loader error UI must never bake into the shared shell. A
|
|
1055
|
+
// container still pending here either pinned the tree (the trivial-prelude
|
|
1056
|
+
// gate above already returned no-shell) or postponed under an ANCESTOR
|
|
1057
|
+
// boundary (it is a hole; omitting the record keeps it live).
|
|
1058
|
+
const loaderRecords = reqCtx._shellCaptureLoaderRecords;
|
|
1059
|
+
// Set once a bake-lane loader settles with real (non-hole) material: its data
|
|
1060
|
+
// is frozen into the shell prelude regardless of whether snapshot
|
|
1061
|
+
// serialization succeeds. Drives the untagged-bake dev warning below.
|
|
1062
|
+
let bakedLoaderMaterial = false;
|
|
1063
|
+
if (loaderRecords && loaderRecords.size > 0) {
|
|
1064
|
+
// The codec import is deferred past the elide probes: a rejected record
|
|
1065
|
+
// refuses and a never-settled record is omitted WITHOUT touching Flight
|
|
1066
|
+
// (also keeps the virtual @vitejs/plugin-rsc import out of unit configs).
|
|
1067
|
+
let serializeContainer:
|
|
1068
|
+
| typeof import("../cache/segment-codec.js").serializeResult
|
|
1069
|
+
| undefined;
|
|
1070
|
+
for (const [segmentKey, containerPromise] of loaderRecords) {
|
|
1071
|
+
const elided = await elideLoaderContainer(containerPromise);
|
|
1072
|
+
if (elided.state === "rejected") {
|
|
1073
|
+
warnCaptureRefusedOnce(
|
|
1074
|
+
capture.key,
|
|
1075
|
+
`the loader for segment "${segmentKey}" rejected during capture; its error UI must not bake into the shared shell. ` +
|
|
1076
|
+
"Fix the loader, or give its entry a loading() boundary so it stays on the live lane.",
|
|
1077
|
+
);
|
|
1078
|
+
return "refused";
|
|
1079
|
+
}
|
|
1080
|
+
// The container itself never settled: it is a hole (under an ancestor
|
|
1081
|
+
// boundary) or the trivial-prelude gate already fired. Omit — no pin.
|
|
1082
|
+
if (isLoaderHoleMarker(elided.value)) continue;
|
|
1083
|
+
// Past the hole check: this container settled with real material that
|
|
1084
|
+
// bakes into the shell prelude (independent of the snapshot pin below).
|
|
1085
|
+
bakedLoaderMaterial = true;
|
|
1086
|
+
try {
|
|
1087
|
+
// serializeResult (not rscSerialize): null is a valid container and
|
|
1088
|
+
// must round-trip; serializeResult preserves it through Flight.
|
|
1089
|
+
serializeContainer ??= (await import("../cache/segment-codec.js"))
|
|
1090
|
+
.serializeResult;
|
|
1091
|
+
const serialized = await serializeContainer(elided.value);
|
|
1092
|
+
if (serialized !== null) {
|
|
1093
|
+
(snapshot ??= []).push({
|
|
1094
|
+
family: "loader",
|
|
1095
|
+
key: segmentKey,
|
|
1096
|
+
value: { value: serialized },
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
} catch {
|
|
1100
|
+
// Non-serializable container: leave it unpinned (it drifts on a HIT,
|
|
1101
|
+
// the pre-snapshot behavior) rather than failing the capture.
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// Shell tags snapshot at the WRITE BARRIER, not at stream construction: by
|
|
1107
|
+
// here the capture has quiesced and the deferred cache writes were awaited, so
|
|
1108
|
+
// tags recorded AFTER an await in async shell content (and by async
|
|
1109
|
+
// cache()/"use cache" reads propagating through recordRequestTags) are
|
|
1110
|
+
// included — issue #676. Loaders are masked, so loader cache tags — which
|
|
1111
|
+
// belong to the holes, not the shell — never execute during capture and cannot
|
|
1112
|
+
// contribute. Union with the route's static ppr.tags (capture.tags); the
|
|
1113
|
+
// collected set is authoritative, the option only adds what the render cannot
|
|
1114
|
+
// know.
|
|
1115
|
+
const collected = [...reqCtx._requestTags];
|
|
1116
|
+
const union = new Set<string>([...(capture.tags ?? []), ...collected]);
|
|
1117
|
+
const shellTags = union.size > 0 ? [...union] : undefined;
|
|
1118
|
+
|
|
1119
|
+
// Untagged-bake diagnostic: a bake-lane loader froze mutable data into the
|
|
1120
|
+
// shell but nothing tags the entry, so it is un-invalidatable except by TTL —
|
|
1121
|
+
// a read-your-own-writes gap on the document channel (an action refresh skips
|
|
1122
|
+
// the server shell; updateTag cannot drop untagged data). Coarse per-shell-key
|
|
1123
|
+
// signal; dev-only and once-per-key so it never spams production.
|
|
1124
|
+
if (isDevMode() && bakedLoaderMaterial && shellTags === undefined) {
|
|
1125
|
+
warnUntaggedShellBakeOnce(capture.key);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
const store = capture.store ?? reqCtx._cacheStore;
|
|
1129
|
+
if (store?.putShell) {
|
|
1130
|
+
try {
|
|
1131
|
+
const entry: ShellCacheEntry = {
|
|
1132
|
+
// slice() copies just this view's bytes into a fresh ArrayBuffer, so a
|
|
1133
|
+
// prelude that is a subarray of a larger backing buffer encodes only its
|
|
1134
|
+
// own region — bufferToBase64 reads the whole ArrayBuffer it is handed.
|
|
1135
|
+
prelude: bufferToBase64(result.prelude.slice().buffer as ArrayBuffer),
|
|
1136
|
+
postponed: result.postponed,
|
|
1137
|
+
reactVersion: React.version,
|
|
1138
|
+
buildVersion: capture.buildVersion,
|
|
1139
|
+
// The theme this capture's payload was built with (buildFullPayload
|
|
1140
|
+
// reads reqCtx.theme off the derived context). The serve tail replays
|
|
1141
|
+
// it so the resume tree matches the frozen prelude — see
|
|
1142
|
+
// ShellCacheEntry.initialTheme.
|
|
1143
|
+
initialTheme: reqCtx.theme,
|
|
1144
|
+
snapshot,
|
|
1145
|
+
createdAt: Date.now(),
|
|
1146
|
+
};
|
|
1147
|
+
await store.putShell(
|
|
1148
|
+
capture.key,
|
|
1149
|
+
entry,
|
|
1150
|
+
capture.ttl,
|
|
1151
|
+
capture.swr,
|
|
1152
|
+
shellTags,
|
|
1153
|
+
);
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
// Best-effort: a failed put must never throw out of the background task.
|
|
1156
|
+
reportCacheError(
|
|
1157
|
+
error,
|
|
1158
|
+
"cache-write",
|
|
1159
|
+
"[ShellCache] capture put",
|
|
1160
|
+
reqCtx,
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
// A shell was captured (the store I/O may have failed, but that is reported,
|
|
1165
|
+
// not retried) — so this attempt is `stored` and the caller does not retry.
|
|
1166
|
+
return "stored";
|
|
1167
|
+
} finally {
|
|
1168
|
+
// Stop the hop loop for the pathological never-quiets path (quiesce never
|
|
1169
|
+
// fired, capture returned via maxWaitMs). On the normal path the loop already
|
|
1170
|
+
// stopped when it fired quiesce; dispose() is then a no-op.
|
|
1171
|
+
gate.dispose();
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// Exported for unit tests that drive the capture core directly.
|
|
1176
|
+
export { runShellCapture, captureAndStoreShell };
|
|
1177
|
+
|
|
1178
|
+
// Exported for unit tests that pin the refused-capture backoff policy directly
|
|
1179
|
+
// (dev cap vs production exponential growth, stored-clears, cold-start re-probe).
|
|
1180
|
+
// These are the same module-level functions the schedule path uses; a test that
|
|
1181
|
+
// drove them through a real capture round-trip could not assert the exact window
|
|
1182
|
+
// arithmetic without a full cold render.
|
|
1183
|
+
export {
|
|
1184
|
+
isCaptureBackedOff,
|
|
1185
|
+
markCaptureBackoff,
|
|
1186
|
+
clearCaptureBackoff,
|
|
1187
|
+
REFUSED_CAPTURE_BASE_MS,
|
|
1188
|
+
REFUSED_CAPTURE_MAX_MS,
|
|
1189
|
+
REFUSED_CAPTURE_DEV_MAX_MS,
|
|
1190
|
+
};
|