@rangojs/router 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/types/browser/event-controller.d.ts +6 -0
- package/dist/types/cache/cf/cf-cache-constants.d.ts +8 -1
- package/dist/types/cache/cf/cf-cache-store.d.ts +15 -1
- package/dist/types/cache/cf/cf-cache-types.d.ts +1 -1
- package/dist/types/cache/cf/cf-kv-utils.d.ts +21 -0
- package/dist/types/handles/is-thenable.d.ts +2 -4
- package/dist/types/rsc/helpers.d.ts +3 -0
- package/dist/types/rsc/render-pipeline.d.ts +9 -0
- package/dist/types/rsc/routine-plan.d.ts +124 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +17 -0
- package/dist/types/server/request-context.d.ts +4 -1
- package/dist/types/vite/encryption-key.d.ts +2 -0
- package/dist/types/vite/plugins/expose-internal-ids.d.ts +10 -0
- package/dist/types/vite/plugins/server-ref-hashing.d.ts +24 -0
- package/dist/types/vite/plugins/server-reference-pattern.d.ts +1 -0
- package/dist/types/vite/utils/shared-utils.d.ts +12 -0
- package/dist/vite/index.js +154 -57
- package/package.json +3 -3
- package/skills/caching/SKILL.md +1 -1
- package/skills/mime-routes/SKILL.md +3 -1
- package/skills/response-routes/SKILL.md +4 -2
- package/skills/typesafety/generated-files-and-cli.md +16 -9
- package/skills/typesafety/route-types.md +5 -1
- package/skills/use-cache/SKILL.md +47 -0
- package/src/browser/event-controller.ts +40 -15
- package/src/browser/partial-update.ts +26 -11
- package/src/browser/react/NavigationProvider.tsx +7 -0
- package/src/cache/cache-runtime.ts +89 -15
- package/src/cache/cf/cf-cache-constants.ts +8 -1
- package/src/cache/cf/cf-cache-store.ts +41 -64
- package/src/cache/cf/cf-cache-types.ts +1 -1
- package/src/cache/cf/cf-kv-utils.ts +38 -0
- package/src/cache/segment-codec.ts +21 -5
- package/src/handles/is-thenable.ts +2 -4
- package/src/router/match-middleware/cache-lookup.ts +24 -15
- package/src/rsc/handler.ts +26 -5
- package/src/rsc/helpers.ts +13 -0
- package/src/rsc/progressive-enhancement.ts +247 -70
- package/src/rsc/render-pipeline.ts +68 -24
- package/src/rsc/routine-plan.ts +359 -0
- package/src/rsc/rsc-rendering.ts +555 -302
- package/src/rsc/server-action.ts +180 -71
- package/src/rsc/shell-capture-constants.ts +18 -0
- package/src/rsc/shell-capture.ts +92 -21
- package/src/server/request-context.ts +6 -0
- package/src/ssr/ssr-root.tsx +1 -0
- package/src/vite/encryption-key.ts +29 -0
- package/src/vite/plugins/expose-action-id.ts +2 -2
- package/src/vite/plugins/expose-internal-ids.ts +46 -0
- package/src/vite/plugins/server-ref-hashing.ts +74 -0
- package/src/vite/plugins/server-reference-pattern.ts +10 -0
- package/src/vite/rango.ts +9 -0
- package/src/vite/router-discovery.ts +21 -2
- package/src/vite/utils/shared-utils.ts +12 -7
- package/dist/types.backup/__internal.d.ts +0 -127
- package/dist/types.backup/bin/rango.d.ts +0 -1
- package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
- package/dist/types.backup/browser/action-fence.d.ts +0 -33
- package/dist/types.backup/browser/app-shell.d.ts +0 -34
- package/dist/types.backup/browser/app-version.d.ts +0 -6
- package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
- package/dist/types.backup/browser/cookie-name.d.ts +0 -66
- package/dist/types.backup/browser/event-controller.d.ts +0 -221
- package/dist/types.backup/browser/history-state.d.ts +0 -26
- package/dist/types.backup/browser/index.d.ts +0 -1
- package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
- package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
- package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
- package/dist/types.backup/browser/logging.d.ts +0 -33
- package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
- package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
- package/dist/types.backup/browser/navigation-client.d.ts +0 -17
- package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
- package/dist/types.backup/browser/navigation-store.d.ts +0 -95
- package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
- package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
- package/dist/types.backup/browser/partial-update.d.ts +0 -61
- package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
- package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
- package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
- package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
- package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
- package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
- package/dist/types.backup/browser/rango-state.d.ts +0 -52
- package/dist/types.backup/browser/react/Link.d.ts +0 -140
- package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
- package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
- package/dist/types.backup/browser/react/context.d.ts +0 -54
- package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
- package/dist/types.backup/browser/react/index.d.ts +0 -1
- package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
- package/dist/types.backup/browser/react/location-state.d.ts +0 -29
- package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
- package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
- package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
- package/dist/types.backup/browser/react/use-action.d.ts +0 -61
- package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
- package/dist/types.backup/browser/react/use-href.d.ts +0 -32
- package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
- package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
- package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
- package/dist/types.backup/browser/react/use-params.d.ts +0 -21
- package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
- package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
- package/dist/types.backup/browser/react/use-router.d.ts +0 -23
- package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
- package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
- package/dist/types.backup/browser/response-adapter.d.ts +0 -58
- package/dist/types.backup/browser/rsc-router.d.ts +0 -141
- package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
- package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
- package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
- package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
- package/dist/types.backup/browser/types.d.ts +0 -530
- package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
- package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
- package/dist/types.backup/build/generate-manifest.d.ts +0 -100
- package/dist/types.backup/build/generate-route-types.d.ts +0 -8
- package/dist/types.backup/build/index.d.ts +0 -21
- package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
- package/dist/types.backup/build/route-trie.d.ts +0 -89
- package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
- package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
- package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
- package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
- package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
- package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
- package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
- package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
- package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
- package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
- package/dist/types.backup/cache/background-task.d.ts +0 -21
- package/dist/types.backup/cache/cache-error.d.ts +0 -71
- package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
- package/dist/types.backup/cache/cache-policy.d.ts +0 -59
- package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
- package/dist/types.backup/cache/cache-scope.d.ts +0 -134
- package/dist/types.backup/cache/cache-tag.d.ts +0 -79
- package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
- package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
- package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
- package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
- package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
- package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
- package/dist/types.backup/cache/cf/index.d.ts +0 -3
- package/dist/types.backup/cache/document-cache.d.ts +0 -69
- package/dist/types.backup/cache/handle-capture.d.ts +0 -23
- package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
- package/dist/types.backup/cache/index.d.ts +0 -7
- package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
- package/dist/types.backup/cache/profile-registry.d.ts +0 -40
- package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
- package/dist/types.backup/cache/segment-codec.d.ts +0 -78
- package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
- package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
- package/dist/types.backup/cache/taint.d.ts +0 -71
- package/dist/types.backup/cache/types.d.ts +0 -407
- package/dist/types.backup/cache/vercel/index.d.ts +0 -1
- package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
- package/dist/types.backup/client.d.ts +0 -184
- package/dist/types.backup/client.rsc.d.ts +0 -39
- package/dist/types.backup/cloudflare/index.d.ts +0 -7
- package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
- package/dist/types.backup/component-utils.d.ts +0 -46
- package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
- package/dist/types.backup/context-var.d.ts +0 -84
- package/dist/types.backup/debug.d.ts +0 -57
- package/dist/types.backup/decode-loader-results.d.ts +0 -5
- package/dist/types.backup/default-error-boundary.d.ts +0 -10
- package/dist/types.backup/defer.d.ts +0 -89
- package/dist/types.backup/deps/browser.d.ts +0 -1
- package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
- package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
- package/dist/types.backup/deps/rsc.d.ts +0 -1
- package/dist/types.backup/deps/ssr.d.ts +0 -1
- package/dist/types.backup/encode-kv.d.ts +0 -35
- package/dist/types.backup/errors.d.ts +0 -226
- package/dist/types.backup/escape-script.d.ts +0 -44
- package/dist/types.backup/handle.d.ts +0 -93
- package/dist/types.backup/handles/MetaTags.d.ts +0 -17
- package/dist/types.backup/handles/Scripts.d.ts +0 -38
- package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
- package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
- package/dist/types.backup/handles/is-thenable.d.ts +0 -12
- package/dist/types.backup/handles/meta.d.ts +0 -43
- package/dist/types.backup/handles/script.d.ts +0 -139
- package/dist/types.backup/host/cookie-handler.d.ts +0 -8
- package/dist/types.backup/host/errors.d.ts +0 -40
- package/dist/types.backup/host/index.d.ts +0 -33
- package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
- package/dist/types.backup/host/router.d.ts +0 -12
- package/dist/types.backup/host/testing.d.ts +0 -41
- package/dist/types.backup/host/types.d.ts +0 -148
- package/dist/types.backup/host/utils.d.ts +0 -20
- package/dist/types.backup/href-client.d.ts +0 -214
- package/dist/types.backup/index.d.ts +0 -112
- package/dist/types.backup/index.rsc.d.ts +0 -51
- package/dist/types.backup/internal-debug.d.ts +0 -1
- package/dist/types.backup/loader-store.d.ts +0 -193
- package/dist/types.backup/loader.d.ts +0 -18
- package/dist/types.backup/loader.rsc.d.ts +0 -18
- package/dist/types.backup/missing-id-error.d.ts +0 -1
- package/dist/types.backup/outlet-context.d.ts +0 -12
- package/dist/types.backup/outlet-provider.d.ts +0 -12
- package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
- package/dist/types.backup/prerender/param-hash.d.ts +0 -6
- package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
- package/dist/types.backup/prerender/store.d.ts +0 -62
- package/dist/types.backup/prerender.d.ts +0 -292
- package/dist/types.backup/redirect-origin.d.ts +0 -55
- package/dist/types.backup/regex-escape.d.ts +0 -6
- package/dist/types.backup/render-error-thrower.d.ts +0 -13
- package/dist/types.backup/response-utils.d.ts +0 -35
- package/dist/types.backup/reverse.d.ts +0 -206
- package/dist/types.backup/root-error-boundary.d.ts +0 -32
- package/dist/types.backup/route-content-wrapper.d.ts +0 -40
- package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
- package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
- package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
- package/dist/types.backup/route-definition/index.d.ts +0 -7
- package/dist/types.backup/route-definition/redirect.d.ts +0 -48
- package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
- package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
- package/dist/types.backup/route-definition.d.ts +0 -1
- package/dist/types.backup/route-map-builder.d.ts +0 -127
- package/dist/types.backup/route-name.d.ts +0 -27
- package/dist/types.backup/route-types.d.ts +0 -172
- package/dist/types.backup/router/basename.d.ts +0 -10
- package/dist/types.backup/router/content-negotiation.d.ts +0 -91
- package/dist/types.backup/router/debug-manifest.d.ts +0 -7
- package/dist/types.backup/router/error-handling.d.ts +0 -76
- package/dist/types.backup/router/find-match.d.ts +0 -19
- package/dist/types.backup/router/handler-context.d.ts +0 -41
- package/dist/types.backup/router/instrument.d.ts +0 -161
- package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
- package/dist/types.backup/router/lazy-includes.d.ts +0 -26
- package/dist/types.backup/router/loader-resolution.d.ts +0 -63
- package/dist/types.backup/router/logging.d.ts +0 -41
- package/dist/types.backup/router/manifest.d.ts +0 -8
- package/dist/types.backup/router/match-api.d.ts +0 -19
- package/dist/types.backup/router/match-context.d.ts +0 -184
- package/dist/types.backup/router/match-handlers.d.ts +0 -49
- package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
- package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
- package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
- package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
- package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
- package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
- package/dist/types.backup/router/match-pipelines.d.ts +0 -103
- package/dist/types.backup/router/match-result.d.ts +0 -114
- package/dist/types.backup/router/metrics.d.ts +0 -6
- package/dist/types.backup/router/middleware-types.d.ts +0 -74
- package/dist/types.backup/router/middleware.d.ts +0 -116
- package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
- package/dist/types.backup/router/params-util.d.ts +0 -8
- package/dist/types.backup/router/parse-pattern.d.ts +0 -38
- package/dist/types.backup/router/pattern-matching.d.ts +0 -169
- package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
- package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
- package/dist/types.backup/router/prerender-match.d.ts +0 -50
- package/dist/types.backup/router/preview-match.d.ts +0 -22
- package/dist/types.backup/router/request-classification.d.ts +0 -104
- package/dist/types.backup/router/revalidation.d.ts +0 -57
- package/dist/types.backup/router/route-snapshot.d.ts +0 -112
- package/dist/types.backup/router/router-context.d.ts +0 -137
- package/dist/types.backup/router/router-interfaces.d.ts +0 -432
- package/dist/types.backup/router/router-options.d.ts +0 -738
- package/dist/types.backup/router/router-registry.d.ts +0 -15
- package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
- package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
- package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
- package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
- package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
- package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
- package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
- package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
- package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
- package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
- package/dist/types.backup/router/segment-resolution.d.ts +0 -3
- package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
- package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
- package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
- package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
- package/dist/types.backup/router/telemetry.d.ts +0 -215
- package/dist/types.backup/router/timeout.d.ts +0 -68
- package/dist/types.backup/router/tracing.d.ts +0 -125
- package/dist/types.backup/router/trie-matching.d.ts +0 -32
- package/dist/types.backup/router/types.d.ts +0 -98
- package/dist/types.backup/router/url-params.d.ts +0 -26
- package/dist/types.backup/router.d.ts +0 -7
- package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
- package/dist/types.backup/rsc/full-payload.d.ts +0 -22
- package/dist/types.backup/rsc/handler-context.d.ts +0 -31
- package/dist/types.backup/rsc/handler.d.ts +0 -9
- package/dist/types.backup/rsc/helpers.d.ts +0 -213
- package/dist/types.backup/rsc/index.d.ts +0 -17
- package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
- package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
- package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
- package/dist/types.backup/rsc/nonce.d.ts +0 -28
- package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
- package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
- package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
- package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
- package/dist/types.backup/rsc/response-error.d.ts +0 -19
- package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
- package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
- package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
- package/dist/types.backup/rsc/server-action.d.ts +0 -68
- package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
- package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
- package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
- package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
- package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
- package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
- package/dist/types.backup/rsc/types.d.ts +0 -290
- package/dist/types.backup/runtime-env.d.ts +0 -1
- package/dist/types.backup/search-params.d.ts +0 -125
- package/dist/types.backup/segment-content-promise.d.ts +0 -13
- package/dist/types.backup/segment-fragments.d.ts +0 -56
- package/dist/types.backup/segment-loader-promise.d.ts +0 -22
- package/dist/types.backup/segment-system.d.ts +0 -84
- package/dist/types.backup/serialize.d.ts +0 -164
- package/dist/types.backup/server/context.d.ts +0 -494
- package/dist/types.backup/server/cookie-parse.d.ts +0 -10
- package/dist/types.backup/server/cookie-store.d.ts +0 -107
- package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
- package/dist/types.backup/server/handle-store.d.ts +0 -100
- package/dist/types.backup/server/loader-registry.d.ts +0 -32
- package/dist/types.backup/server/request-context.d.ts +0 -596
- package/dist/types.backup/server/root-layout.d.ts +0 -3
- package/dist/types.backup/server.d.ts +0 -15
- package/dist/types.backup/ssr/index.d.ts +0 -233
- package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
- package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
- package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
- package/dist/types.backup/static-handler.d.ts +0 -57
- package/dist/types.backup/testing/cache-status.d.ts +0 -63
- package/dist/types.backup/testing/collect-handle.d.ts +0 -20
- package/dist/types.backup/testing/dispatch.d.ts +0 -123
- package/dist/types.backup/testing/dom.entry.d.ts +0 -15
- package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
- package/dist/types.backup/testing/e2e/index.d.ts +0 -30
- package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
- package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
- package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
- package/dist/types.backup/testing/e2e/server.d.ts +0 -35
- package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
- package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
- package/dist/types.backup/testing/flight-tree.d.ts +0 -192
- package/dist/types.backup/testing/flight.d.ts +0 -115
- package/dist/types.backup/testing/flight.entry.d.ts +0 -27
- package/dist/types.backup/testing/generated-routes.d.ts +0 -66
- package/dist/types.backup/testing/index.d.ts +0 -52
- package/dist/types.backup/testing/internal/context.d.ts +0 -225
- package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
- package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
- package/dist/types.backup/testing/render-handler.d.ts +0 -160
- package/dist/types.backup/testing/render-route.d.ts +0 -246
- package/dist/types.backup/testing/run-loader.d.ts +0 -186
- package/dist/types.backup/testing/run-middleware.d.ts +0 -132
- package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
- package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
- package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
- package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
- package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
- package/dist/types.backup/testing/vitest.d.ts +0 -205
- package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
- package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
- package/dist/types.backup/theme/constants.d.ts +0 -39
- package/dist/types.backup/theme/index.d.ts +0 -29
- package/dist/types.backup/theme/theme-context.d.ts +0 -21
- package/dist/types.backup/theme/theme-script.d.ts +0 -26
- package/dist/types.backup/theme/types.d.ts +0 -162
- package/dist/types.backup/theme/use-theme.d.ts +0 -8
- package/dist/types.backup/types/boundaries.d.ts +0 -93
- package/dist/types.backup/types/cache-types.d.ts +0 -191
- package/dist/types.backup/types/error-types.d.ts +0 -114
- package/dist/types.backup/types/global-namespace.d.ts +0 -90
- package/dist/types.backup/types/handler-context.d.ts +0 -658
- package/dist/types.backup/types/index.d.ts +0 -11
- package/dist/types.backup/types/loader-types.d.ts +0 -182
- package/dist/types.backup/types/request-scope.d.ts +0 -93
- package/dist/types.backup/types/route-config.d.ts +0 -105
- package/dist/types.backup/types/route-entry.d.ts +0 -95
- package/dist/types.backup/types/segments.d.ts +0 -234
- package/dist/types.backup/types.d.ts +0 -1
- package/dist/types.backup/urls/include-helper.d.ts +0 -17
- package/dist/types.backup/urls/include-provider.d.ts +0 -27
- package/dist/types.backup/urls/index.d.ts +0 -6
- package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
- package/dist/types.backup/urls/path-helper.d.ts +0 -12
- package/dist/types.backup/urls/pattern-types.d.ts +0 -166
- package/dist/types.backup/urls/response-types.d.ts +0 -67
- package/dist/types.backup/urls/type-extraction.d.ts +0 -157
- package/dist/types.backup/urls/urls-function.d.ts +0 -24
- package/dist/types.backup/urls.d.ts +0 -1
- package/dist/types.backup/use-loader.d.ts +0 -150
- package/dist/types.backup/vercel/index.d.ts +0 -10
- package/dist/types.backup/vercel/tracing.d.ts +0 -70
- package/dist/types.backup/vite/debug.d.ts +0 -80
- package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
- package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
- package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
- package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
- package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
- package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
- package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
- package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
- package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
- package/dist/types.backup/vite/discovery/state.d.ts +0 -162
- package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
- package/dist/types.backup/vite/index.d.ts +0 -11
- package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
- package/dist/types.backup/vite/plugin-types.d.ts +0 -298
- package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
- package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
- package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
- package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
- package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
- package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
- package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
- package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
- package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
- package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
- package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
- package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
- package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
- package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
- package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
- package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
- package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
- package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
- package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
- package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
- package/dist/types.backup/vite/rango.d.ts +0 -29
- package/dist/types.backup/vite/router-discovery.d.ts +0 -23
- package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
- package/dist/types.backup/vite/utils/banner.d.ts +0 -2
- package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
- package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
- package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
- package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
- package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
- package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
- package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
- package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
|
@@ -18,6 +18,12 @@ import {
|
|
|
18
18
|
} from "@vitejs/plugin-rsc/rsc";
|
|
19
19
|
import { createFromReadableStream } from "@vitejs/plugin-rsc/rsc";
|
|
20
20
|
|
|
21
|
+
// Preserve embedded server references on a cache/prerender HIT so they
|
|
22
|
+
// re-serialize to the client instead of resolving to a raw function React
|
|
23
|
+
// refuses to pass to a Client Component. Shared across the deserialize sites so
|
|
24
|
+
// the decode policy has a single owner.
|
|
25
|
+
const PRESERVE_SERVER_REFS = { preserveServerReferences: true } as const;
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* Convert a ReadableStream to a string.
|
|
23
29
|
*/
|
|
@@ -81,7 +87,11 @@ export async function rscDeserialize<T>(
|
|
|
81
87
|
|
|
82
88
|
const temporaryReferences = createTemporaryReferenceSet();
|
|
83
89
|
const stream = stringToStream(encoded);
|
|
84
|
-
return createFromReadableStream<T>(
|
|
90
|
+
return createFromReadableStream<T>(
|
|
91
|
+
stream,
|
|
92
|
+
{ temporaryReferences },
|
|
93
|
+
PRESERVE_SERVER_REFS,
|
|
94
|
+
);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
/**
|
|
@@ -116,7 +126,11 @@ export async function serializeResult(value: unknown): Promise<string | null> {
|
|
|
116
126
|
export async function deserializeResult<T>(encoded: string): Promise<T> {
|
|
117
127
|
const temporaryReferences = createTemporaryReferenceSet();
|
|
118
128
|
const stream = stringToStream(encoded);
|
|
119
|
-
return createFromReadableStream<T>(
|
|
129
|
+
return createFromReadableStream<T>(
|
|
130
|
+
stream,
|
|
131
|
+
{ temporaryReferences },
|
|
132
|
+
PRESERVE_SERVER_REFS,
|
|
133
|
+
);
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
/**
|
|
@@ -271,9 +285,11 @@ export async function deserializeSegments(
|
|
|
271
285
|
|
|
272
286
|
const [component, layout, loaderData, loaderDataPromise, loadingData] =
|
|
273
287
|
await Promise.all([
|
|
274
|
-
createFromReadableStream(
|
|
275
|
-
|
|
276
|
-
|
|
288
|
+
createFromReadableStream(
|
|
289
|
+
stringToStream(item.encoded),
|
|
290
|
+
{ temporaryReferences },
|
|
291
|
+
PRESERVE_SERVER_REFS,
|
|
292
|
+
),
|
|
277
293
|
rscDeserialize(item.encodedLayout),
|
|
278
294
|
rscDeserialize(item.encodedLoaderData),
|
|
279
295
|
rscDeserialize(item.encodedLoaderDataPromise),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* handle entries are deferred (`Promise`) values to await before any consumer
|
|
5
|
-
* sees them, and which pass through verbatim.
|
|
2
|
+
* Shared thenable predicate for framework orchestration. It decides which values
|
|
3
|
+
* participate in promise lifecycles and which pass through synchronously.
|
|
6
4
|
*
|
|
7
5
|
* Requires a CALLABLE `then` (`typeof obj.then === "function"`), not merely a
|
|
8
6
|
* `"then" in obj` membership check, so a non-promise carrying a `then` field
|
|
@@ -450,21 +450,30 @@ export function withCacheLookup<TEnv>(
|
|
|
450
450
|
resolveLoadersOnly,
|
|
451
451
|
} = getRouterContext<TEnv>();
|
|
452
452
|
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
)
|
|
467
|
-
|
|
453
|
+
if (prerenderStoreShortCircuits(ctx.matched.pr, ctx.request)) {
|
|
454
|
+
// Actions normally re-render fresh and skip the prerender store. But a pure
|
|
455
|
+
// Prerender route's handler is evicted at build, so there is no fresh
|
|
456
|
+
// handler to run on an action re-render -- without the fallback the
|
|
457
|
+
// re-render falls through to the evicted handler and throws "No prerender
|
|
458
|
+
// data found". Serve the prerendered entry instead (the action ran already;
|
|
459
|
+
// its result is applied client-side via useActionState). Passthrough routes
|
|
460
|
+
// keep a liveHandler, so they still re-render fresh on actions.
|
|
461
|
+
const isPassthroughPrerenderRoute = ctx.entries.some(
|
|
462
|
+
(entry) => entry.type === "route" && entry.isPassthrough === true,
|
|
463
|
+
);
|
|
464
|
+
if (!ctx.isAction || !isPassthroughPrerenderRoute) {
|
|
465
|
+
await ensurePrerenderDeps();
|
|
466
|
+
if (prerenderStoreInstance) {
|
|
467
|
+
const served = yield* tryPrerenderLookup(
|
|
468
|
+
ctx,
|
|
469
|
+
state,
|
|
470
|
+
pipelineStart,
|
|
471
|
+
pipelineReqCtx,
|
|
472
|
+
resolveLoadersOnly,
|
|
473
|
+
resolveLoadersOnlyWithRevalidation,
|
|
474
|
+
);
|
|
475
|
+
if (served) return;
|
|
476
|
+
}
|
|
468
477
|
}
|
|
469
478
|
}
|
|
470
479
|
|
package/src/rsc/handler.ts
CHANGED
|
@@ -110,6 +110,7 @@ import {
|
|
|
110
110
|
type RequestPlan,
|
|
111
111
|
type ExecutableRequestPlan,
|
|
112
112
|
} from "../router/request-classification.js";
|
|
113
|
+
import { INTERNAL_RANGO_DEBUG } from "../internal-debug.js";
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
116
|
* Create an RSC request handler.
|
|
@@ -247,7 +248,8 @@ export function createRSCHandler<
|
|
|
247
248
|
actionId?: string,
|
|
248
249
|
): Promise<Response> {
|
|
249
250
|
const timeoutError = new RouterTimeoutError(phase, durationMs);
|
|
250
|
-
const
|
|
251
|
+
const requestContext = _getRequestContext<TEnv>();
|
|
252
|
+
const cursor = requestContext?._renderForeground;
|
|
251
253
|
const render: RenderTimeoutContext | undefined =
|
|
252
254
|
phase === "render-start" && cursor
|
|
253
255
|
? {
|
|
@@ -261,11 +263,29 @@ export function createRSCHandler<
|
|
|
261
263
|
}),
|
|
262
264
|
}
|
|
263
265
|
: undefined;
|
|
266
|
+
const trace =
|
|
267
|
+
phase === "render-start" ? requestContext?._activeRoutine : undefined;
|
|
268
|
+
const activeEntries = trace?.active() ?? [];
|
|
269
|
+
const activeStep = activeEntries.at(-1);
|
|
270
|
+
const activeAt = performance.now();
|
|
271
|
+
const routineSnapshot =
|
|
272
|
+
trace && activeStep
|
|
273
|
+
? {
|
|
274
|
+
name: trace.name,
|
|
275
|
+
path: activeEntries.map((entry) => entry.name),
|
|
276
|
+
durationMs: activeAt - activeStep.startedAt,
|
|
277
|
+
}
|
|
278
|
+
: undefined;
|
|
279
|
+
|
|
280
|
+
if (INTERNAL_RANGO_DEBUG && trace && activeStep) {
|
|
281
|
+
console.log(
|
|
282
|
+
`[routine] TIMEOUT ${request.method} ${url.pathname} (${trace.name})\n${trace.formatActive(activeEntries, activeAt)}`,
|
|
283
|
+
);
|
|
284
|
+
}
|
|
264
285
|
|
|
265
|
-
// Each surface gets its OWN shallow
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
// other two observe.
|
|
286
|
+
// Each surface gets its OWN shallow render snapshot. A consumer that mutates
|
|
287
|
+
// its copy must not corrupt what the other two observe. The internal-debug
|
|
288
|
+
// routine snapshot is bounded metadata sent only to onError.
|
|
269
289
|
callOnError(timeoutError, phase === "action" ? "action" : "handler", {
|
|
270
290
|
request,
|
|
271
291
|
url,
|
|
@@ -278,6 +298,7 @@ export function createRSCHandler<
|
|
|
278
298
|
phase,
|
|
279
299
|
durationMs,
|
|
280
300
|
...(render && { render: { ...render } }),
|
|
301
|
+
...(routineSnapshot && { routine: routineSnapshot }),
|
|
281
302
|
},
|
|
282
303
|
});
|
|
283
304
|
|
package/src/rsc/helpers.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import {
|
|
8
8
|
_getRequestContext,
|
|
9
9
|
getLocationState,
|
|
10
|
+
setRequestContextParams,
|
|
10
11
|
} from "../server/request-context.js";
|
|
11
12
|
import type { RequestContext } from "../server/request-context.js";
|
|
12
13
|
import { resolveLocationStateEntries } from "../browser/react/location-state-shared.js";
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
import type { MiddlewareEntry, MiddlewareFn } from "../router/middleware.js";
|
|
24
25
|
import { formatCacheSignalHeader } from "../router/telemetry.js";
|
|
25
26
|
import type { RscPayload } from "./types.js";
|
|
27
|
+
import type { HandlerContext } from "./handler-context.js";
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* DEVELOPMENT/TEST ONLY. When the debug cache signal gate is on,
|
|
@@ -381,3 +383,14 @@ export function finalizeResponse(response: Response): Response {
|
|
|
381
383
|
if (!ctx) return response;
|
|
382
384
|
return drainOnResponseCallbacks(ctx, response);
|
|
383
385
|
}
|
|
386
|
+
|
|
387
|
+
/** Match and stamp params/routeName on the request context as one operation. */
|
|
388
|
+
export async function matchAndRecordParams<TEnv>(
|
|
389
|
+
ctx: HandlerContext<TEnv>,
|
|
390
|
+
request: Request,
|
|
391
|
+
env: TEnv,
|
|
392
|
+
): Promise<Awaited<ReturnType<HandlerContext<TEnv>["router"]["match"]>>> {
|
|
393
|
+
const match = await ctx.router.match(request, { env });
|
|
394
|
+
setRequestContextParams(match.params, match.routeName);
|
|
395
|
+
return match;
|
|
396
|
+
}
|
|
@@ -22,12 +22,23 @@ import {
|
|
|
22
22
|
finalizeResponse,
|
|
23
23
|
buildRouteMiddlewareEntries,
|
|
24
24
|
} from "./helpers.js";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
createRenderStageTraceBridge,
|
|
27
|
+
renderRscResponse,
|
|
28
|
+
} from "./render-pipeline.js";
|
|
29
|
+
import {
|
|
30
|
+
createRoutineTrace,
|
|
31
|
+
runRoutine,
|
|
32
|
+
step,
|
|
33
|
+
type RoutinePlan,
|
|
34
|
+
type RoutineTrace,
|
|
35
|
+
} from "./routine-plan.js";
|
|
26
36
|
import type { HandlerContext } from "./handler-context.js";
|
|
27
37
|
import {
|
|
28
38
|
extractRedirectResponse,
|
|
29
39
|
warnNonRedirectPeResponse,
|
|
30
40
|
} from "./runtime-warnings.js";
|
|
41
|
+
import { INTERNAL_RANGO_DEBUG } from "../internal-debug.js";
|
|
31
42
|
|
|
32
43
|
export interface PeRouteMiddlewareInfo {
|
|
33
44
|
routeMiddleware?: Array<{
|
|
@@ -61,6 +72,40 @@ export async function handleProgressiveEnhancement<TEnv>(
|
|
|
61
72
|
return null;
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
// Flow trace: shared by every plan this request drives (error-boundary
|
|
76
|
+
// renders and the re-render), so a PE request prints ONE tree. A non-PE form
|
|
77
|
+
// POST (no $ACTION fields) drives no plan and stays silent.
|
|
78
|
+
const trace = INTERNAL_RANGO_DEBUG ? createRoutineTrace("pe") : undefined;
|
|
79
|
+
try {
|
|
80
|
+
return await handleProgressiveEnhancementInner(
|
|
81
|
+
ctx,
|
|
82
|
+
request,
|
|
83
|
+
env,
|
|
84
|
+
url,
|
|
85
|
+
handleStore,
|
|
86
|
+
nonce,
|
|
87
|
+
routeMwInfo,
|
|
88
|
+
trace,
|
|
89
|
+
);
|
|
90
|
+
} finally {
|
|
91
|
+
if (trace && trace.entries.length > 0) {
|
|
92
|
+
console.log(
|
|
93
|
+
`[routine] ${request.method} ${url.pathname} (${trace.name})\n${trace.format()}`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function handleProgressiveEnhancementInner<TEnv>(
|
|
100
|
+
ctx: HandlerContext<TEnv>,
|
|
101
|
+
request: Request,
|
|
102
|
+
env: TEnv,
|
|
103
|
+
url: URL,
|
|
104
|
+
handleStore: ReturnType<typeof getRequestContext>["_handleStore"],
|
|
105
|
+
nonce: string | undefined,
|
|
106
|
+
routeMwInfo: PeRouteMiddlewareInfo | undefined,
|
|
107
|
+
trace: RoutineTrace | undefined,
|
|
108
|
+
): Promise<Response | null> {
|
|
64
109
|
// Clone the request to read FormData without consuming it.
|
|
65
110
|
// Wrap in try-catch so malformed POST bodies are reported as action
|
|
66
111
|
// errors, not routing errors from the outer catch in handler.ts.
|
|
@@ -77,6 +122,7 @@ export async function handleProgressiveEnhancement<TEnv>(
|
|
|
77
122
|
error,
|
|
78
123
|
handleStore,
|
|
79
124
|
nonce,
|
|
125
|
+
trace,
|
|
80
126
|
);
|
|
81
127
|
if (errorHtml) {
|
|
82
128
|
ctx.callOnError(error, "action", {
|
|
@@ -154,6 +200,7 @@ export async function handleProgressiveEnhancement<TEnv>(
|
|
|
154
200
|
error,
|
|
155
201
|
handleStore,
|
|
156
202
|
nonce,
|
|
203
|
+
trace,
|
|
157
204
|
useActionStateId,
|
|
158
205
|
true, // an action ran and threw
|
|
159
206
|
);
|
|
@@ -208,6 +255,7 @@ export async function handleProgressiveEnhancement<TEnv>(
|
|
|
208
255
|
error,
|
|
209
256
|
handleStore,
|
|
210
257
|
nonce,
|
|
258
|
+
trace,
|
|
211
259
|
directActionId,
|
|
212
260
|
true, // an action ran and threw
|
|
213
261
|
);
|
|
@@ -287,79 +335,20 @@ export async function handleProgressiveEnhancement<TEnv>(
|
|
|
287
335
|
peReqCtx._gateActionResult = actionResult;
|
|
288
336
|
peReqCtx._gateFormData = formData;
|
|
289
337
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (match.redirect) {
|
|
293
|
-
return createResponseWithMergedHeaders(null, {
|
|
294
|
-
status: 308,
|
|
295
|
-
headers: { Location: match.redirect },
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const payload: RscPayload = {
|
|
300
|
-
metadata: {
|
|
301
|
-
pathname: url.pathname,
|
|
302
|
-
routerId: ctx.router.id,
|
|
303
|
-
basename: ctx.router.basename,
|
|
304
|
-
segments: gateTransitions(
|
|
305
|
-
match.segments,
|
|
306
|
-
getRequestContext(),
|
|
307
|
-
ctx.router.onError,
|
|
308
|
-
),
|
|
309
|
-
matched: match.matched,
|
|
310
|
-
diff: match.diff,
|
|
311
|
-
resolvedIds: match.resolvedIds,
|
|
312
|
-
params: match.params,
|
|
313
|
-
isPartial: false,
|
|
314
|
-
rootLayout: ctx.router.rootLayout,
|
|
315
|
-
// PE full render: resolve deferred handle values server-side.
|
|
316
|
-
handles: resolvedHandleStream(handleStore),
|
|
317
|
-
version: ctx.version,
|
|
318
|
-
stateCookieName: ctx.router.resolvedStateCookieName,
|
|
319
|
-
themeConfig: ctx.router.themeConfig,
|
|
320
|
-
warmupEnabled: ctx.router.warmupEnabled,
|
|
321
|
-
strictMode: ctx.router.strictMode,
|
|
322
|
-
initialTheme: getRequestContext().theme,
|
|
323
|
-
},
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const stageTracking = {
|
|
327
|
-
mode: "progressive-enhancement" as const,
|
|
328
|
-
routeKey: getRequestContext()._routeName,
|
|
329
|
-
actionId: directActionId ?? undefined,
|
|
330
|
-
};
|
|
331
|
-
return renderRscResponse(
|
|
332
|
-
{
|
|
338
|
+
return runRoutine(
|
|
339
|
+
peRenderPlan({
|
|
333
340
|
ctx,
|
|
334
341
|
request,
|
|
335
342
|
env,
|
|
336
343
|
url,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
: {}),
|
|
346
|
-
headers: { "content-type": "text/html;charset=utf-8" },
|
|
347
|
-
},
|
|
348
|
-
tracking: stageTracking,
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
// metricsStore=undefined is safe: the handler already stashed the early
|
|
352
|
-
// SSR setup promise, so this reuses it instead of starting setup again.
|
|
353
|
-
// reactFormState travels through the SSR option, not RscPayload.
|
|
354
|
-
html: createSsrHtmlStage({
|
|
355
|
-
ctx,
|
|
356
|
-
request,
|
|
357
|
-
env,
|
|
358
|
-
url,
|
|
359
|
-
metricsStore: undefined,
|
|
360
|
-
render: { formState: reactFormState, nonce },
|
|
361
|
-
}),
|
|
362
|
-
},
|
|
344
|
+
renderRequest,
|
|
345
|
+
handleStore,
|
|
346
|
+
nonce,
|
|
347
|
+
reactFormState,
|
|
348
|
+
boundarylessErrorStatus,
|
|
349
|
+
directActionId,
|
|
350
|
+
}),
|
|
351
|
+
{ trace, owner: getRequestContext() },
|
|
363
352
|
);
|
|
364
353
|
};
|
|
365
354
|
|
|
@@ -382,6 +371,142 @@ export async function handleProgressiveEnhancement<TEnv>(
|
|
|
382
371
|
return renderPage();
|
|
383
372
|
}
|
|
384
373
|
|
|
374
|
+
interface PeRenderInput<TEnv> {
|
|
375
|
+
ctx: HandlerContext<TEnv>;
|
|
376
|
+
request: Request;
|
|
377
|
+
env: TEnv;
|
|
378
|
+
url: URL;
|
|
379
|
+
renderRequest: Request;
|
|
380
|
+
handleStore: ReturnType<typeof getRequestContext>["_handleStore"];
|
|
381
|
+
nonce: string | undefined;
|
|
382
|
+
reactFormState: ReactFormState | null;
|
|
383
|
+
boundarylessErrorStatus: number | undefined;
|
|
384
|
+
directActionId: string | null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** PE re-render: match the bodyless GET mirror, then render full HTML. */
|
|
388
|
+
function* peRenderPlan<TEnv>(
|
|
389
|
+
input: PeRenderInput<TEnv>,
|
|
390
|
+
): RoutinePlan<Response> {
|
|
391
|
+
const { ctx, env, renderRequest } = input;
|
|
392
|
+
|
|
393
|
+
const match = yield* step("match", () =>
|
|
394
|
+
ctx.router.match(renderRequest, { env }),
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
if (match.redirect) {
|
|
398
|
+
return createResponseWithMergedHeaders(null, {
|
|
399
|
+
status: 308,
|
|
400
|
+
headers: { Location: match.redirect },
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return yield* step("render", () => renderPeResponse(input, match));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** Build the PE full-document payload and render it through the stage driver. */
|
|
408
|
+
function renderPeResponse<TEnv>(
|
|
409
|
+
input: PeRenderInput<TEnv>,
|
|
410
|
+
match: Awaited<ReturnType<HandlerContext<TEnv>["router"]["match"]>>,
|
|
411
|
+
): Promise<Response> {
|
|
412
|
+
const {
|
|
413
|
+
ctx,
|
|
414
|
+
request,
|
|
415
|
+
env,
|
|
416
|
+
url,
|
|
417
|
+
handleStore,
|
|
418
|
+
nonce,
|
|
419
|
+
reactFormState,
|
|
420
|
+
boundarylessErrorStatus,
|
|
421
|
+
directActionId,
|
|
422
|
+
} = input;
|
|
423
|
+
|
|
424
|
+
const payload: RscPayload = {
|
|
425
|
+
metadata: {
|
|
426
|
+
pathname: url.pathname,
|
|
427
|
+
routerId: ctx.router.id,
|
|
428
|
+
basename: ctx.router.basename,
|
|
429
|
+
segments: gateTransitions(
|
|
430
|
+
match.segments,
|
|
431
|
+
getRequestContext(),
|
|
432
|
+
ctx.router.onError,
|
|
433
|
+
),
|
|
434
|
+
matched: match.matched,
|
|
435
|
+
diff: match.diff,
|
|
436
|
+
resolvedIds: match.resolvedIds,
|
|
437
|
+
params: match.params,
|
|
438
|
+
isPartial: false,
|
|
439
|
+
rootLayout: ctx.router.rootLayout,
|
|
440
|
+
// PE full render: resolve deferred handle values server-side.
|
|
441
|
+
handles: resolvedHandleStream(handleStore),
|
|
442
|
+
version: ctx.version,
|
|
443
|
+
stateCookieName: ctx.router.resolvedStateCookieName,
|
|
444
|
+
themeConfig: ctx.router.themeConfig,
|
|
445
|
+
warmupEnabled: ctx.router.warmupEnabled,
|
|
446
|
+
strictMode: ctx.router.strictMode,
|
|
447
|
+
initialTheme: getRequestContext().theme,
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const trace = getRequestContext()._activeRoutine;
|
|
452
|
+
|
|
453
|
+
const stageTracking = {
|
|
454
|
+
mode: "progressive-enhancement" as const,
|
|
455
|
+
routeKey: getRequestContext()._routeName,
|
|
456
|
+
actionId: directActionId ?? undefined,
|
|
457
|
+
onEvent: trace && createRenderStageTraceBridge(trace),
|
|
458
|
+
};
|
|
459
|
+
return renderRscResponse(
|
|
460
|
+
{
|
|
461
|
+
ctx,
|
|
462
|
+
request,
|
|
463
|
+
env,
|
|
464
|
+
url,
|
|
465
|
+
payload,
|
|
466
|
+
init: {
|
|
467
|
+
// boundarylessErrorStatus is set only when the action threw and no error
|
|
468
|
+
// boundary matched; it makes the re-render carry 500 like the JS path.
|
|
469
|
+
// The redirect branch in peRenderPlan returns before this, so a redirect
|
|
470
|
+
// re-render keeps its 308 and is never overridden.
|
|
471
|
+
...(boundarylessErrorStatus !== undefined
|
|
472
|
+
? { status: boundarylessErrorStatus }
|
|
473
|
+
: {}),
|
|
474
|
+
headers: { "content-type": "text/html;charset=utf-8" },
|
|
475
|
+
},
|
|
476
|
+
tracking: stageTracking,
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
// metricsStore=undefined is safe: the handler already stashed the early
|
|
480
|
+
// SSR setup promise, so this reuses it instead of starting setup again.
|
|
481
|
+
// reactFormState travels through the SSR option, not RscPayload.
|
|
482
|
+
html: createSsrHtmlStage({
|
|
483
|
+
ctx,
|
|
484
|
+
request,
|
|
485
|
+
env,
|
|
486
|
+
url,
|
|
487
|
+
metricsStore: undefined,
|
|
488
|
+
render: { formState: reactFormState, nonce },
|
|
489
|
+
}),
|
|
490
|
+
},
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
interface PeErrorBoundaryInput<TEnv> {
|
|
495
|
+
ctx: HandlerContext<TEnv>;
|
|
496
|
+
request: Request;
|
|
497
|
+
env: TEnv;
|
|
498
|
+
url: URL;
|
|
499
|
+
error: unknown;
|
|
500
|
+
handleStore: ReturnType<typeof getRequestContext>["_handleStore"];
|
|
501
|
+
nonce: string | undefined;
|
|
502
|
+
actionId: string | null | undefined;
|
|
503
|
+
actionRan: boolean;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
type PeErrorMatch<TEnv> = NonNullable<
|
|
507
|
+
Awaited<ReturnType<HandlerContext<TEnv>["router"]["matchError"]>>
|
|
508
|
+
>;
|
|
509
|
+
|
|
385
510
|
/**
|
|
386
511
|
* Attempt to render an error boundary as full HTML for the PE path.
|
|
387
512
|
* Returns null if no error boundary is found (caller falls through to
|
|
@@ -395,6 +520,7 @@ async function renderPeErrorBoundary<TEnv>(
|
|
|
395
520
|
error: unknown,
|
|
396
521
|
handleStore: ReturnType<typeof getRequestContext>["_handleStore"],
|
|
397
522
|
nonce: string | undefined,
|
|
523
|
+
trace: RoutineTrace | undefined,
|
|
398
524
|
actionId?: string | null,
|
|
399
525
|
// True when an action actually ran and threw (vs a malformed form body, where
|
|
400
526
|
// no action executed). Drives _inActionRevalidation for JS/PE parity — it must
|
|
@@ -402,6 +528,44 @@ async function renderPeErrorBoundary<TEnv>(
|
|
|
402
528
|
// and throw with no $$id (actionId === undefined) yet still be an action error.
|
|
403
529
|
actionRan = false,
|
|
404
530
|
): Promise<Response | null> {
|
|
531
|
+
return runRoutine(
|
|
532
|
+
peErrorBoundaryPlan({
|
|
533
|
+
ctx,
|
|
534
|
+
request,
|
|
535
|
+
env,
|
|
536
|
+
url,
|
|
537
|
+
error,
|
|
538
|
+
handleStore,
|
|
539
|
+
nonce,
|
|
540
|
+
actionId,
|
|
541
|
+
actionRan,
|
|
542
|
+
}),
|
|
543
|
+
{ trace, owner: getRequestContext() },
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** PE error boundary: match a boundary for the thrown error, then render it. */
|
|
548
|
+
function* peErrorBoundaryPlan<TEnv>(
|
|
549
|
+
input: PeErrorBoundaryInput<TEnv>,
|
|
550
|
+
): RoutinePlan<Response | null> {
|
|
551
|
+
const boundary = yield* step("match:error", () =>
|
|
552
|
+
matchPeErrorBoundary(input),
|
|
553
|
+
);
|
|
554
|
+
if (!boundary) return null;
|
|
555
|
+
return yield* step("render", () => renderPeErrorResponse(input, boundary));
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Match an error boundary for the PE path, owning the reporting protocol:
|
|
560
|
+
* a matchError failure reports the ORIGINAL error as unhandled and rethrows
|
|
561
|
+
* the match failure; a miss returns null; a hit reports handled and stamps
|
|
562
|
+
* params + action gate context before the render.
|
|
563
|
+
*/
|
|
564
|
+
async function matchPeErrorBoundary<TEnv>(
|
|
565
|
+
input: PeErrorBoundaryInput<TEnv>,
|
|
566
|
+
): Promise<PeErrorMatch<TEnv> | null> {
|
|
567
|
+
const { ctx, request, env, url, error, actionId, actionRan } = input;
|
|
568
|
+
|
|
405
569
|
// JS/PE parity for an action-triggered error re-render: a stale
|
|
406
570
|
// `foregroundOnAction` cache entry inside the error boundary must foreground
|
|
407
571
|
// too, exactly as the JS path (revalidateAfterAction sets this unconditionally
|
|
@@ -448,6 +612,16 @@ async function renderPeErrorBoundary<TEnv>(
|
|
|
448
612
|
peErrCtx._gateActionUrl = new URL(url);
|
|
449
613
|
}
|
|
450
614
|
|
|
615
|
+
return errorResult;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** Render the matched PE error boundary as a full HTML document. */
|
|
619
|
+
function renderPeErrorResponse<TEnv>(
|
|
620
|
+
input: PeErrorBoundaryInput<TEnv>,
|
|
621
|
+
errorResult: PeErrorMatch<TEnv>,
|
|
622
|
+
): Promise<Response> {
|
|
623
|
+
const { ctx, request, env, url, handleStore, nonce, actionId } = input;
|
|
624
|
+
|
|
451
625
|
const payload: RscPayload = {
|
|
452
626
|
metadata: {
|
|
453
627
|
pathname: url.pathname,
|
|
@@ -476,10 +650,13 @@ async function renderPeErrorBoundary<TEnv>(
|
|
|
476
650
|
},
|
|
477
651
|
};
|
|
478
652
|
|
|
653
|
+
const trace = getRequestContext()._activeRoutine;
|
|
654
|
+
|
|
479
655
|
const stageTracking = {
|
|
480
656
|
mode: "progressive-enhancement-error" as const,
|
|
481
657
|
routeKey: getRequestContext()._routeName,
|
|
482
658
|
actionId: actionId ?? undefined,
|
|
659
|
+
onEvent: trace && createRenderStageTraceBridge(trace),
|
|
483
660
|
};
|
|
484
661
|
return renderRscResponse(
|
|
485
662
|
{
|