@nifrajs/web 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -0
- package/dist/boundary.d.ts +67 -7
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +6 -4
- package/dist/boundary.js.map +1 -1
- package/dist/build-plan.d.ts +3 -0
- package/dist/build-plan.d.ts.map +1 -1
- package/dist/build-plan.js.map +1 -1
- package/dist/build-vite.d.ts.map +1 -1
- package/dist/build-vite.js +2 -0
- package/dist/build-vite.js.map +1 -1
- package/dist/build.d.ts +9 -2
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +9 -0
- package/dist/build.js.map +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +140 -12
- package/dist/client.js.map +1 -1
- package/dist/csp.d.ts +8 -0
- package/dist/csp.d.ts.map +1 -1
- package/dist/csp.js +11 -2
- package/dist/csp.js.map +1 -1
- package/dist/deferred.d.ts +6 -4
- package/dist/deferred.d.ts.map +1 -1
- package/dist/deferred.js +10 -6
- package/dist/deferred.js.map +1 -1
- package/dist/dev-feed.d.ts.map +1 -1
- package/dist/dev-feed.js +11 -2
- package/dist/dev-feed.js.map +1 -1
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +13 -6
- package/dist/dev-session.js.map +1 -1
- package/dist/dev.d.ts +4 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +12 -5
- package/dist/dev.js.map +1 -1
- package/dist/diagnostic-catalog.d.ts +4 -0
- package/dist/diagnostic-catalog.d.ts.map +1 -1
- package/dist/diagnostic-catalog.js +48 -0
- package/dist/diagnostic-catalog.js.map +1 -1
- package/dist/diagnostic.d.ts +1 -1
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +1 -1
- package/dist/diagnostic.js.map +1 -1
- package/dist/fn.d.ts +5 -3
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +20 -5
- package/dist/fn.js.map +1 -1
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +13 -3
- package/dist/fs.js.map +1 -1
- package/dist/identity.d.ts +22 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +60 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/cdn/cloudflare.d.ts +2 -1
- package/dist/internal/cdn/cloudflare.d.ts.map +1 -1
- package/dist/internal/cdn/cloudflare.js +2 -1
- package/dist/internal/cdn/cloudflare.js.map +1 -1
- package/dist/internal/certified-components.d.ts +1 -1
- package/dist/internal/certified-components.js +1 -1
- package/dist/internal/codegen.d.ts +11 -10
- package/dist/internal/codegen.d.ts.map +1 -1
- package/dist/internal/codegen.js +65 -8
- package/dist/internal/codegen.js.map +1 -1
- package/dist/internal/dev-websocket.d.ts +73 -0
- package/dist/internal/dev-websocket.d.ts.map +1 -0
- package/dist/internal/dev-websocket.js +145 -0
- package/dist/internal/dev-websocket.js.map +1 -0
- package/dist/internal/hole-runtime.d.ts +66 -0
- package/dist/internal/hole-runtime.d.ts.map +1 -0
- package/dist/internal/hole-runtime.js +211 -0
- package/dist/internal/hole-runtime.js.map +1 -0
- package/dist/internal/identity-epoch.d.ts +50 -0
- package/dist/internal/identity-epoch.d.ts.map +1 -0
- package/dist/internal/identity-epoch.js +179 -0
- package/dist/internal/identity-epoch.js.map +1 -0
- package/dist/internal/invalidation-contract.d.ts +23 -0
- package/dist/internal/invalidation-contract.d.ts.map +1 -0
- package/dist/internal/invalidation-contract.js +11 -0
- package/dist/internal/invalidation-contract.js.map +1 -0
- package/dist/internal/invalidation.d.ts +62 -0
- package/dist/internal/invalidation.d.ts.map +1 -0
- package/dist/internal/invalidation.js +149 -0
- package/dist/internal/invalidation.js.map +1 -0
- package/dist/internal/island-bindings.d.ts +51 -0
- package/dist/internal/island-bindings.d.ts.map +1 -0
- package/dist/internal/island-bindings.js +147 -0
- package/dist/internal/island-bindings.js.map +1 -0
- package/dist/internal/island-list.d.ts +26 -0
- package/dist/internal/island-list.d.ts.map +1 -0
- package/dist/internal/island-list.js +78 -0
- package/dist/internal/island-list.js.map +1 -0
- package/dist/internal/island-mount.d.ts +4 -0
- package/dist/internal/island-mount.d.ts.map +1 -0
- package/dist/internal/island-mount.js +66 -0
- package/dist/internal/island-mount.js.map +1 -0
- package/dist/internal/island-owner.d.ts +5 -0
- package/dist/internal/island-owner.d.ts.map +1 -0
- package/dist/internal/island-owner.js +20 -0
- package/dist/internal/island-owner.js.map +1 -0
- package/dist/internal/island-resource.d.ts +30 -0
- package/dist/internal/island-resource.d.ts.map +1 -0
- package/dist/internal/island-resource.js +57 -0
- package/dist/internal/island-resource.js.map +1 -0
- package/dist/internal/island-signals.d.ts +51 -0
- package/dist/internal/island-signals.d.ts.map +1 -0
- package/dist/internal/island-signals.js +220 -0
- package/dist/internal/island-signals.js.map +1 -0
- package/dist/internal/keep-alive-table.d.ts +23 -0
- package/dist/internal/keep-alive-table.d.ts.map +1 -0
- package/dist/internal/keep-alive-table.js +53 -0
- package/dist/internal/keep-alive-table.js.map +1 -0
- package/dist/internal/live-contract.d.ts +96 -0
- package/dist/internal/live-contract.d.ts.map +1 -0
- package/dist/internal/live-contract.js +5 -0
- package/dist/internal/live-contract.js.map +1 -0
- package/dist/internal/live-queries.d.ts +22 -0
- package/dist/internal/live-queries.d.ts.map +1 -0
- package/dist/internal/live-queries.js +54 -0
- package/dist/internal/live-queries.js.map +1 -0
- package/dist/internal/page-events.d.ts +10 -0
- package/dist/internal/page-events.d.ts.map +1 -0
- package/dist/internal/page-events.js +26 -0
- package/dist/internal/page-events.js.map +1 -0
- package/dist/internal/page-execution.d.ts +14 -1
- package/dist/internal/page-execution.d.ts.map +1 -1
- package/dist/internal/page-execution.js +415 -31
- package/dist/internal/page-execution.js.map +1 -1
- package/dist/internal/ppr/admission.d.ts +83 -0
- package/dist/internal/ppr/admission.d.ts.map +1 -0
- package/dist/internal/ppr/admission.js +221 -0
- package/dist/internal/ppr/admission.js.map +1 -0
- package/dist/internal/ppr/canary.d.ts +24 -0
- package/dist/internal/ppr/canary.d.ts.map +1 -0
- package/dist/internal/ppr/canary.js +102 -0
- package/dist/internal/ppr/canary.js.map +1 -0
- package/dist/internal/ppr/compile-shell.d.ts +39 -0
- package/dist/internal/ppr/compile-shell.d.ts.map +1 -0
- package/dist/internal/ppr/compile-shell.js +298 -0
- package/dist/internal/ppr/compile-shell.js.map +1 -0
- package/dist/internal/ppr/contract.d.ts +177 -0
- package/dist/internal/ppr/contract.d.ts.map +1 -0
- package/dist/internal/ppr/contract.js +80 -0
- package/dist/internal/ppr/contract.js.map +1 -0
- package/dist/internal/ppr/frames.d.ts +71 -0
- package/dist/internal/ppr/frames.d.ts.map +1 -0
- package/dist/internal/ppr/frames.js +119 -0
- package/dist/internal/ppr/frames.js.map +1 -0
- package/dist/internal/ppr/integration.d.ts +19 -0
- package/dist/internal/ppr/integration.d.ts.map +1 -0
- package/dist/internal/ppr/integration.js +106 -0
- package/dist/internal/ppr/integration.js.map +1 -0
- package/dist/internal/ppr/options.d.ts +96 -0
- package/dist/internal/ppr/options.d.ts.map +1 -0
- package/dist/internal/ppr/options.js +125 -0
- package/dist/internal/ppr/options.js.map +1 -0
- package/dist/internal/ppr/route-rules.d.ts +12 -0
- package/dist/internal/ppr/route-rules.d.ts.map +1 -0
- package/dist/internal/ppr/route-rules.js +53 -0
- package/dist/internal/ppr/route-rules.js.map +1 -0
- package/dist/internal/ppr/runtime.d.ts +29 -0
- package/dist/internal/ppr/runtime.d.ts.map +1 -0
- package/dist/internal/ppr/runtime.js +32 -0
- package/dist/internal/ppr/runtime.js.map +1 -0
- package/dist/internal/ppr/server.d.ts +29 -0
- package/dist/internal/ppr/server.d.ts.map +1 -0
- package/dist/internal/ppr/server.js +1407 -0
- package/dist/internal/ppr/server.js.map +1 -0
- package/dist/internal/ppr/shell-store.d.ts +38 -0
- package/dist/internal/ppr/shell-store.d.ts.map +1 -0
- package/dist/internal/ppr/shell-store.js +90 -0
- package/dist/internal/ppr/shell-store.js.map +1 -0
- package/dist/internal/prerendered-pages.d.ts +1 -1
- package/dist/internal/prerendered-pages.d.ts.map +1 -1
- package/dist/internal/prerendered-pages.js +7 -4
- package/dist/internal/prerendered-pages.js.map +1 -1
- package/dist/internal/query-digest.d.ts +9 -0
- package/dist/internal/query-digest.d.ts.map +1 -0
- package/dist/internal/query-digest.js +23 -0
- package/dist/internal/query-digest.js.map +1 -0
- package/dist/internal/query-runtime.d.ts +6 -1
- package/dist/internal/query-runtime.d.ts.map +1 -1
- package/dist/internal/query-runtime.js +9 -0
- package/dist/internal/query-runtime.js.map +1 -1
- package/dist/internal/query-seam.d.ts +29 -0
- package/dist/internal/query-seam.d.ts.map +1 -0
- package/dist/internal/query-seam.js +23 -0
- package/dist/internal/query-seam.js.map +1 -0
- package/dist/internal/render-document.d.ts +28 -1
- package/dist/internal/render-document.d.ts.map +1 -1
- package/dist/internal/render-document.js +83 -18
- package/dist/internal/render-document.js.map +1 -1
- package/dist/internal/request-abort.d.ts +8 -0
- package/dist/internal/request-abort.d.ts.map +1 -0
- package/dist/internal/request-abort.js +22 -0
- package/dist/internal/request-abort.js.map +1 -0
- package/dist/internal/server-boundary.d.ts +2 -0
- package/dist/internal/server-boundary.d.ts.map +1 -1
- package/dist/internal/server-boundary.js +8 -1
- package/dist/internal/server-boundary.js.map +1 -1
- package/dist/internal/share-data.d.ts +10 -0
- package/dist/internal/share-data.d.ts.map +1 -0
- package/dist/internal/share-data.js +135 -0
- package/dist/internal/share-data.js.map +1 -0
- package/dist/internal/store-signature.d.ts +15 -0
- package/dist/internal/store-signature.d.ts.map +1 -0
- package/dist/internal/store-signature.js +114 -0
- package/dist/internal/store-signature.js.map +1 -0
- package/dist/internal/vite-plugin-compat.d.ts +2 -2
- package/dist/internal/vite-plugin-compat.js +2 -2
- package/dist/internal/web-app.d.ts +25 -0
- package/dist/internal/web-app.d.ts.map +1 -1
- package/dist/internal/web-app.js +78 -3
- package/dist/internal/web-app.js.map +1 -1
- package/dist/islands-swap.d.ts +41 -0
- package/dist/islands-swap.d.ts.map +1 -0
- package/dist/islands-swap.js +270 -0
- package/dist/islands-swap.js.map +1 -0
- package/dist/islands.d.ts +86 -24
- package/dist/islands.d.ts.map +1 -1
- package/dist/islands.js +138 -78
- package/dist/islands.js.map +1 -1
- package/dist/isr.d.ts +67 -13
- package/dist/isr.d.ts.map +1 -1
- package/dist/isr.js +247 -99
- package/dist/isr.js.map +1 -1
- package/dist/keep-alive.d.ts +147 -0
- package/dist/keep-alive.d.ts.map +1 -0
- package/dist/keep-alive.js +1069 -0
- package/dist/keep-alive.js.map +1 -0
- package/dist/live/bus.d.ts +56 -0
- package/dist/live/bus.d.ts.map +1 -0
- package/dist/live/bus.js +32 -0
- package/dist/live/bus.js.map +1 -0
- package/dist/live/core.d.ts +25 -0
- package/dist/live/core.d.ts.map +1 -0
- package/dist/live/core.js +29 -0
- package/dist/live/core.js.map +1 -0
- package/dist/live/history.d.ts +38 -0
- package/dist/live/history.d.ts.map +1 -0
- package/dist/live/history.js +104 -0
- package/dist/live/history.js.map +1 -0
- package/dist/live/hub-protocol.d.ts +46 -0
- package/dist/live/hub-protocol.d.ts.map +1 -0
- package/dist/live/hub-protocol.js +108 -0
- package/dist/live/hub-protocol.js.map +1 -0
- package/dist/live/hub.d.ts +181 -0
- package/dist/live/hub.d.ts.map +1 -0
- package/dist/live/hub.js +539 -0
- package/dist/live/hub.js.map +1 -0
- package/dist/live/keyring.d.ts +87 -0
- package/dist/live/keyring.d.ts.map +1 -0
- package/dist/live/keyring.js +260 -0
- package/dist/live/keyring.js.map +1 -0
- package/dist/live/read-capped.d.ts +6 -0
- package/dist/live/read-capped.d.ts.map +1 -0
- package/dist/live/read-capped.js +42 -0
- package/dist/live/read-capped.js.map +1 -0
- package/dist/live/revocations.d.ts +52 -0
- package/dist/live/revocations.d.ts.map +1 -0
- package/dist/live/revocations.js +116 -0
- package/dist/live/revocations.js.map +1 -0
- package/dist/live/settings.d.ts +14 -0
- package/dist/live/settings.d.ts.map +1 -0
- package/dist/live/settings.js +38 -0
- package/dist/live/settings.js.map +1 -0
- package/dist/live-client.d.ts +34 -0
- package/dist/live-client.d.ts.map +1 -0
- package/dist/live-client.js +840 -0
- package/dist/live-client.js.map +1 -0
- package/dist/live-hub.d.ts +130 -0
- package/dist/live-hub.d.ts.map +1 -0
- package/dist/live-hub.js +507 -0
- package/dist/live-hub.js.map +1 -0
- package/dist/live-redis.d.ts +48 -0
- package/dist/live-redis.d.ts.map +1 -0
- package/dist/live-redis.js +201 -0
- package/dist/live-redis.js.map +1 -0
- package/dist/live.d.ts +94 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +869 -0
- package/dist/live.js.map +1 -0
- package/dist/manifest.d.ts +113 -2
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +109 -5
- package/dist/manifest.js.map +1 -1
- package/dist/navigation.d.ts +9 -3
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +13 -3
- package/dist/navigation.js.map +1 -1
- package/dist/plugins/vite-zone-guard.d.ts +6 -0
- package/dist/plugins/vite-zone-guard.d.ts.map +1 -1
- package/dist/plugins/vite-zone-guard.js +8 -2
- package/dist/plugins/vite-zone-guard.js.map +1 -1
- package/dist/ppr.d.ts +73 -0
- package/dist/ppr.d.ts.map +1 -0
- package/dist/ppr.js +76 -0
- package/dist/ppr.js.map +1 -0
- package/dist/query.d.ts +8 -13
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +112 -18
- package/dist/query.js.map +1 -1
- package/dist/render-seam.d.ts +30 -0
- package/dist/render-seam.d.ts.map +1 -1
- package/dist/render-seam.js +5 -0
- package/dist/render-seam.js.map +1 -1
- package/dist/route-types.d.ts.map +1 -1
- package/dist/route-types.js +2 -2
- package/dist/route-types.js.map +1 -1
- package/dist/router.d.ts +72 -4
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +374 -99
- package/dist/router.js.map +1 -1
- package/dist/server-components/build.d.ts.map +1 -1
- package/dist/server-components/build.js +3 -3
- package/dist/server-components/build.js.map +1 -1
- package/dist/server-components/client.d.ts +23 -1
- package/dist/server-components/client.d.ts.map +1 -1
- package/dist/server-components/client.js +92 -5
- package/dist/server-components/client.js.map +1 -1
- package/dist/server-components/hole.d.ts +8 -0
- package/dist/server-components/hole.d.ts.map +1 -0
- package/dist/server-components/hole.js +20 -0
- package/dist/server-components/hole.js.map +1 -0
- package/dist/server-components/html-policy.d.ts.map +1 -1
- package/dist/server-components/html-policy.js +62 -4
- package/dist/server-components/html-policy.js.map +1 -1
- package/dist/server-components/html-scan.d.ts +17 -0
- package/dist/server-components/html-scan.d.ts.map +1 -0
- package/dist/server-components/html-scan.js +180 -0
- package/dist/server-components/html-scan.js.map +1 -0
- package/dist/server-components/html.d.ts.map +1 -1
- package/dist/server-components/html.js +19 -4
- package/dist/server-components/html.js.map +1 -1
- package/dist/server-components/router-integration.d.ts +4 -1
- package/dist/server-components/router-integration.d.ts.map +1 -1
- package/dist/server-components/router-integration.js +23 -2
- package/dist/server-components/router-integration.js.map +1 -1
- package/dist/server-components/runtime.d.ts +6 -1
- package/dist/server-components/runtime.d.ts.map +1 -1
- package/dist/server-components/runtime.js +86 -28
- package/dist/server-components/runtime.js.map +1 -1
- package/dist/server-components/state.d.ts +3 -1
- package/dist/server-components/state.d.ts.map +1 -1
- package/dist/server-components/state.js +50 -38
- package/dist/server-components/state.js.map +1 -1
- package/dist/server-components/types.d.ts +9 -0
- package/dist/server-components/types.d.ts.map +1 -1
- package/dist/vite.d.ts +5 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +58 -4
- package/dist/vite.js.map +1 -1
- package/package.json +48 -8
- package/src/boundary.ts +77 -5
- package/src/build-plan.ts +3 -0
- package/src/build-vite.ts +2 -0
- package/src/build.ts +19 -1
- package/src/client.ts +147 -10
- package/src/csp.ts +16 -2
- package/src/deferred.ts +11 -5
- package/src/dev-feed.ts +11 -2
- package/src/dev-session.ts +22 -11
- package/src/dev.ts +29 -8
- package/src/diagnostic-catalog.ts +53 -0
- package/src/diagnostic.ts +1 -0
- package/src/fn.ts +24 -7
- package/src/fs.ts +22 -8
- package/src/identity.ts +61 -0
- package/src/index.ts +19 -0
- package/src/internal/cdn/cloudflare.ts +2 -1
- package/src/internal/certified-components.ts +1 -1
- package/src/internal/codegen.ts +87 -8
- package/src/internal/dev-websocket.ts +230 -0
- package/src/internal/hole-runtime.ts +286 -0
- package/src/internal/identity-epoch.ts +235 -0
- package/src/internal/invalidation-contract.ts +35 -0
- package/src/internal/invalidation.ts +213 -0
- package/src/internal/island-bindings.ts +191 -0
- package/src/internal/island-list.ts +92 -0
- package/src/internal/island-mount.ts +68 -0
- package/src/internal/island-owner.ts +20 -0
- package/src/internal/island-resource.ts +76 -0
- package/src/internal/island-signals.ts +249 -0
- package/src/internal/keep-alive-table.ts +72 -0
- package/src/internal/live-contract.ts +106 -0
- package/src/internal/live-queries.ts +60 -0
- package/src/internal/page-events.ts +27 -0
- package/src/internal/page-execution.ts +579 -40
- package/src/internal/ppr/admission.ts +300 -0
- package/src/internal/ppr/canary.ts +122 -0
- package/src/internal/ppr/compile-shell.ts +379 -0
- package/src/internal/ppr/contract.ts +265 -0
- package/src/internal/ppr/frames.ts +170 -0
- package/src/internal/ppr/integration.ts +137 -0
- package/src/internal/ppr/options.ts +221 -0
- package/src/internal/ppr/route-rules.ts +77 -0
- package/src/internal/ppr/runtime.ts +36 -0
- package/src/internal/ppr/server.ts +1764 -0
- package/src/internal/ppr/shell-store.ts +139 -0
- package/src/internal/prerendered-pages.ts +7 -4
- package/src/internal/query-digest.ts +34 -0
- package/src/internal/query-runtime.ts +14 -1
- package/src/internal/query-seam.ts +48 -0
- package/src/internal/render-document.ts +149 -22
- package/src/internal/request-abort.ts +26 -0
- package/src/internal/server-boundary.ts +10 -1
- package/src/internal/share-data.ts +136 -0
- package/src/internal/store-signature.ts +149 -0
- package/src/internal/vite-plugin-compat.ts +2 -2
- package/src/internal/web-app.ts +121 -3
- package/src/islands-swap.ts +283 -0
- package/src/islands.ts +169 -72
- package/src/isr.ts +348 -106
- package/src/keep-alive.ts +1315 -0
- package/src/live/bus.ts +77 -0
- package/src/live/core.ts +52 -0
- package/src/live/history.ts +109 -0
- package/src/live/hub-protocol.ts +133 -0
- package/src/live/hub.ts +615 -0
- package/src/live/keyring.ts +379 -0
- package/src/live/read-capped.ts +36 -0
- package/src/live/revocations.ts +155 -0
- package/src/live/settings.ts +46 -0
- package/src/live-client.ts +973 -0
- package/src/live-hub.ts +658 -0
- package/src/live-redis.ts +259 -0
- package/src/live.ts +1096 -0
- package/src/manifest.ts +274 -6
- package/src/navigation.ts +14 -2
- package/src/plugins/vite-zone-guard.ts +15 -2
- package/src/ppr.ts +153 -0
- package/src/query.ts +147 -20
- package/src/render-seam.ts +35 -0
- package/src/route-types.ts +3 -1
- package/src/router.ts +494 -101
- package/src/server-components/build.ts +9 -3
- package/src/server-components/client.ts +89 -5
- package/src/server-components/hole.ts +23 -0
- package/src/server-components/html-policy.ts +63 -4
- package/src/server-components/html-scan.ts +159 -0
- package/src/server-components/html.ts +18 -4
- package/src/server-components/router-integration.ts +21 -2
- package/src/server-components/runtime.ts +112 -30
- package/src/server-components/state.ts +66 -44
- package/src/server-components/types.ts +16 -0
- package/src/vite.ts +75 -6
- package/dist/nano.d.ts +0 -125
- package/dist/nano.d.ts.map +0 -1
- package/dist/nano.js +0 -190
- package/dist/nano.js.map +0 -1
- package/src/nano.ts +0 -246
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the page executor and `createWebApp` know of partial prerendering. Everything here is small and
|
|
3
|
+
* imports no runtime code: the server, its options and the hole HTML validator load only through
|
|
4
|
+
* `partialPrerendering` (`@nifrajs/web/ppr`), so an app without it carries none of them.
|
|
5
|
+
*/
|
|
6
|
+
import type { BoundaryRegistration, BoundaryRequestCtx, BoundaryStates, ShellCtx } from "../../boundary.js";
|
|
7
|
+
import type { CspPolicy } from "../../csp.js";
|
|
8
|
+
import type { RevalidateTags } from "../../isr.js";
|
|
9
|
+
import type { RouteEntry, RouteModule } from "../../manifest.js";
|
|
10
|
+
import type { RenderAdapter } from "../../render-seam.js";
|
|
11
|
+
import type { LoadedLayoutModules } from "../render-document.js";
|
|
12
|
+
import type { PprAdmissionStats } from "./admission.js";
|
|
13
|
+
import type { ResolvedPprOptions } from "./options.js";
|
|
14
|
+
/** An app built with `experimental.ppr` carries its {@link PprServer} under this key. */
|
|
15
|
+
export declare const PPR_SERVER: unique symbol;
|
|
16
|
+
/** The key of a {@link PprSetup}'s factory. */
|
|
17
|
+
export declare const PPR_SETUP: unique symbol;
|
|
18
|
+
/** Where the runtime's cancel beacon goes, under the app's base path. */
|
|
19
|
+
export declare const PPR_CANCEL_PATH = "/__nifra/ppr/cancel";
|
|
20
|
+
interface HoleFields {
|
|
21
|
+
readonly interactive?: boolean;
|
|
22
|
+
readonly timeout?: number;
|
|
23
|
+
}
|
|
24
|
+
/** A hole filled per visitor. */
|
|
25
|
+
export type DynamicHole = Extract<BoundaryRegistration, {
|
|
26
|
+
readonly mode: "dynamic";
|
|
27
|
+
}> & HoleFields;
|
|
28
|
+
/** A hole built once for every visitor, with its loader entry's freshness merged in. */
|
|
29
|
+
export type SharedHole = Extract<BoundaryRegistration, {
|
|
30
|
+
readonly mode: "shared";
|
|
31
|
+
}> & HoleFields & {
|
|
32
|
+
readonly revalidate: number;
|
|
33
|
+
readonly revalidateTags?: RevalidateTags | undefined;
|
|
34
|
+
};
|
|
35
|
+
/** The boundary fields partial prerendering reads beyond the neutral registration. */
|
|
36
|
+
export type HoleRegistration = DynamicHole | SharedHole;
|
|
37
|
+
export declare const isHole: (boundary: BoundaryRegistration) => boundary is HoleRegistration;
|
|
38
|
+
/** The key `serverHole()` stores a hole's server component under, on the hole's `render`. */
|
|
39
|
+
export declare const SERVER_HOLE: unique symbol;
|
|
40
|
+
/** The server component a hole's `render` names, or `undefined` for an ordinary `render`. */
|
|
41
|
+
export declare const serverHoleComponent: (render: unknown) => object | undefined;
|
|
42
|
+
/** What the page executor hands over for one PPR request. */
|
|
43
|
+
export interface PprRequest {
|
|
44
|
+
readonly routeId: string;
|
|
45
|
+
/** The request's pathname, without search: the shell renders it, so it is part of the key. */
|
|
46
|
+
readonly path: string;
|
|
47
|
+
readonly locale: string | undefined;
|
|
48
|
+
/** The declared variations this request selected, by name; part of the shell key. */
|
|
49
|
+
readonly variations: Readonly<Record<string, string>>;
|
|
50
|
+
readonly request: Request;
|
|
51
|
+
/** The route's dynamic and shared boundaries, in declaration order, with their merged (guarded)
|
|
52
|
+
* loaders. */
|
|
53
|
+
readonly holes: readonly HoleRegistration[];
|
|
54
|
+
readonly holeContext: Omit<BoundaryRequestCtx, "signal" | "live">;
|
|
55
|
+
/** What the shell loader and every shared hole loader get, but the build's signal. */
|
|
56
|
+
readonly shellContext: Omit<ShellCtx, "signal">;
|
|
57
|
+
readonly loadShell: (signal: AbortSignal) => Promise<unknown>;
|
|
58
|
+
/** Render the full document for `shellData` with every hole pending, under no nonce. */
|
|
59
|
+
readonly renderShellDocument: (shellData: unknown, states: BoundaryStates) => Promise<string>;
|
|
60
|
+
/** The route's `revalidate`, in seconds: an older shell is served while one rebuild runs. */
|
|
61
|
+
readonly revalidate: number | undefined;
|
|
62
|
+
/** The route's `revalidateTags` for this request, read only when a shell is built. */
|
|
63
|
+
readonly tags: () => readonly string[];
|
|
64
|
+
/** A shared hole's `revalidateTags` for this request, read only when its entry is built. */
|
|
65
|
+
readonly holeTags: (hole: SharedHole) => readonly string[];
|
|
66
|
+
/** Keeps the platform alive for work that outlives the response, where the platform needs it. */
|
|
67
|
+
readonly waitUntil?: ((promise: Promise<unknown>) => void) | undefined;
|
|
68
|
+
/** The holes the client holds as hosts: a data request sends each one's fill. A hole that shows a
|
|
69
|
+
* server component always gets its fill. */
|
|
70
|
+
readonly fill?: ReadonlySet<string>;
|
|
71
|
+
/** Render a hole's server component for this visitor, when the app's server components list it. */
|
|
72
|
+
readonly component?: (hole: string, component: object, input: unknown, signal: AbortSignal) => Promise<{
|
|
73
|
+
readonly html: string;
|
|
74
|
+
}>;
|
|
75
|
+
/** Holes the client keeps: none of them loads, and each state says it was kept. */
|
|
76
|
+
readonly kept?: ReadonlySet<string>;
|
|
77
|
+
/** A live load: each hole's keys, and which holes loaded. */
|
|
78
|
+
readonly live?: HoleLive;
|
|
79
|
+
}
|
|
80
|
+
/** A live load's view of one response's holes. Owners are named by hole. */
|
|
81
|
+
export interface HoleLive {
|
|
82
|
+
/** `ctx.live` for one hole's loader. */
|
|
83
|
+
collector(hole: string): (...keys: string[]) => void;
|
|
84
|
+
/** Close one hole's collector once its loader settled. */
|
|
85
|
+
seal(hole: string): void;
|
|
86
|
+
/** Called once, after every hole that ran settled, with the holes that loaded. */
|
|
87
|
+
done(loaded: readonly string[]): void;
|
|
88
|
+
}
|
|
89
|
+
/** The shell cannot be served now; the caller renders the page whole for this request. */
|
|
90
|
+
export declare class PprShellUnavailable extends Error {
|
|
91
|
+
constructor(message: string);
|
|
92
|
+
}
|
|
93
|
+
/** Thrown when a route's shell has no passing import-check record. */
|
|
94
|
+
export declare class PprShellUnchecked extends PprShellUnavailable {
|
|
95
|
+
constructor(routeId: string);
|
|
96
|
+
}
|
|
97
|
+
/** Thrown when a route already runs `shellBuildConcurrency` shell builds: no request waits on one. */
|
|
98
|
+
export declare class PprShellBusy extends PprShellUnavailable {
|
|
99
|
+
constructor(routeId: string);
|
|
100
|
+
}
|
|
101
|
+
/** Thrown for a key seen fewer than `shellAfterRequests` times in a full store: the page streams whole. */
|
|
102
|
+
export declare class PprShellCold extends PprShellUnavailable {
|
|
103
|
+
constructor(routeId: string);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* How a response that is not a streamed document gets its holes. `"deferred"`: each hole runs under
|
|
107
|
+
* admission and its own deadline, and its state carries the result as a deferred value (a soft
|
|
108
|
+
* navigation's data request). `"settled"`: the same, awaited (the blocking render). `"omitted"`: no
|
|
109
|
+
* hole runs and every state is an empty host (a prefetch, which must not start work its navigation
|
|
110
|
+
* cannot cancel).
|
|
111
|
+
*/
|
|
112
|
+
export type HoleStatesMode = "deferred" | "settled" | "omitted";
|
|
113
|
+
export interface PprServerStats extends PprAdmissionStats {
|
|
114
|
+
/** Responses aborted because unsent bytes went over `maxUnsentBytes` (`ppr.slow_aborted`). */
|
|
115
|
+
readonly slowAborted: number;
|
|
116
|
+
/** Frame bytes queued for clients across every live PPR stream. */
|
|
117
|
+
readonly unsentBytes: number;
|
|
118
|
+
}
|
|
119
|
+
export interface PprServer {
|
|
120
|
+
/** Stream one PPR document: the shared shell at once, then each hole as it settles. */
|
|
121
|
+
respond(request: PprRequest): Promise<Response>;
|
|
122
|
+
/** The shell data a soft navigation's data request carries. */
|
|
123
|
+
shellData(request: PprRequest): Promise<unknown>;
|
|
124
|
+
/** The hole states of a data request or a blocking render; `signal` is the request's. */
|
|
125
|
+
holeStates(request: PprRequest, mode: HoleStatesMode, signal: AbortSignal): Promise<BoundaryStates>;
|
|
126
|
+
/** Abort the response that printed `token`. Unknown tokens do nothing. */
|
|
127
|
+
cancel(token: string): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Drop every shell and shared hole frame carrying `tag`. A build of either that started before the
|
|
130
|
+
* call is not stored when it finishes, so an entry built from data read before the purge never
|
|
131
|
+
* outlives it.
|
|
132
|
+
*/
|
|
133
|
+
invalidateTag(tag: string): Promise<void>;
|
|
134
|
+
stats(): PprServerStats;
|
|
135
|
+
}
|
|
136
|
+
/** What `createWebApp` gives a {@link PprSetup}: the parts of the app a PPR server depends on. */
|
|
137
|
+
export interface PprEnvironment {
|
|
138
|
+
readonly adapter: RenderAdapter;
|
|
139
|
+
readonly csp?: CspPolicy;
|
|
140
|
+
/** Part of every shell key, so a shell built by one deployment is never served by another. */
|
|
141
|
+
readonly deployment: string;
|
|
142
|
+
/** The app authorizes scripts with a per-request nonce, which would make every shell unique. */
|
|
143
|
+
readonly perRequestNonce: boolean;
|
|
144
|
+
}
|
|
145
|
+
/** One app's partial prerendering, as the page executor uses it. */
|
|
146
|
+
export interface PprIntegration {
|
|
147
|
+
readonly server: PprServer;
|
|
148
|
+
/** The configured public origin a shell may use; never a visitor's Host. */
|
|
149
|
+
readonly origin?: string;
|
|
150
|
+
/** Where the runtime's cancel beacon posts, and its handler. */
|
|
151
|
+
readonly cancelPath: string;
|
|
152
|
+
cancel(request: Request): Promise<Response>;
|
|
153
|
+
/**
|
|
154
|
+
* The streamed document, with the headers middleware and gates wrote, or how this request renders
|
|
155
|
+
* whole instead: `"settled"` for a listed bot or a shell that is unchecked or at its build limit,
|
|
156
|
+
* `"deferred"`, each hole streamed as it settles, for a key with no shell yet.
|
|
157
|
+
*/
|
|
158
|
+
stream(request: PprRequest, written: () => Readonly<Record<string, string>> | undefined): Promise<Response | "settled" | "deferred">;
|
|
159
|
+
/** The shell data, or the shell loader's own output when the shell cannot be served now. */
|
|
160
|
+
shellData(request: PprRequest, signal: AbortSignal): Promise<unknown>;
|
|
161
|
+
/** `variations` as the shell's own query string. */
|
|
162
|
+
variationQuery(variations: Readonly<Record<string, string>>): string;
|
|
163
|
+
/** Throws for a route the PPR rules keep off the PPR path: its layouts, holes and their limits. */
|
|
164
|
+
assertRoute(route: RouteEntry, layouts: LoadedLayoutModules, boundaries: readonly BoundaryRegistration[]): void;
|
|
165
|
+
/** The declared variations `search` selects. */
|
|
166
|
+
variationsOf(declared: RouteModule["shellVariations"], search: string): Readonly<Record<string, string>>;
|
|
167
|
+
}
|
|
168
|
+
/** What `partialPrerendering()` returns for `createWebApp({ experimental: { ppr } })`. */
|
|
169
|
+
export interface PprSetup {
|
|
170
|
+
readonly [PPR_SETUP]: (environment: PprEnvironment) => PprIntegration;
|
|
171
|
+
}
|
|
172
|
+
/** `variations` as a query string, sorted by name: the shell key part and the shell's own search. */
|
|
173
|
+
export declare const variationQuery: (variations: Readonly<Record<string, string>>) => string;
|
|
174
|
+
/** Whether `request` gets the blocking render under `options`. */
|
|
175
|
+
export declare function wantsBlockingRender(options: ResolvedPprOptions, request: Request): boolean;
|
|
176
|
+
export {};
|
|
177
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/internal/ppr/contract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,yFAAyF;AACzF,eAAO,MAAM,UAAU,EAAE,OAAO,MAAoC,CAAA;AAEpE,+CAA+C;AAC/C,eAAO,MAAM,SAAS,EAAE,OAAO,MAA0C,CAAA;AAEzE,yEAAyE;AACzE,eAAO,MAAM,eAAe,wBAAwB,CAAA;AAEpD,UAAU,UAAU;IAClB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,iCAAiC;AACjC,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,EAAE;IAAE,QAAQ,CA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AC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACpC;AAED,0FAA0F;AAC1F,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,cAAc,KAAK,cAAc,CAAA;CACtE;AAED,qGAAqG;AACrG,eAAO,MAAM,cAAc,GAAI,YAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAG,MAM7E,CAAA;AAQD,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAmB1F"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** An app built with `experimental.ppr` carries its {@link PprServer} under this key. */
|
|
2
|
+
export const PPR_SERVER = Symbol.for("nifra.web.ppr");
|
|
3
|
+
/** The key of a {@link PprSetup}'s factory. */
|
|
4
|
+
export const PPR_SETUP = Symbol.for("nifra.web.ppr.setup");
|
|
5
|
+
/** Where the runtime's cancel beacon goes, under the app's base path. */
|
|
6
|
+
export const PPR_CANCEL_PATH = "/__nifra/ppr/cancel";
|
|
7
|
+
export const isHole = (boundary) => boundary.mode === "dynamic" || boundary.mode === "shared";
|
|
8
|
+
/** The key `serverHole()` stores a hole's server component under, on the hole's `render`. */
|
|
9
|
+
export const SERVER_HOLE = Symbol.for("nifra.web.server-hole");
|
|
10
|
+
/** The server component a hole's `render` names, or `undefined` for an ordinary `render`. */
|
|
11
|
+
export const serverHoleComponent = (render) => {
|
|
12
|
+
if (typeof render !== "function")
|
|
13
|
+
return undefined;
|
|
14
|
+
const component = Reflect.get(render, SERVER_HOLE);
|
|
15
|
+
return typeof component === "object" && component !== null ? component : undefined;
|
|
16
|
+
};
|
|
17
|
+
/** The shell cannot be served now; the caller renders the page whole for this request. */
|
|
18
|
+
export class PprShellUnavailable extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "PprShellUnavailable";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Thrown when a route's shell has no passing import-check record. */
|
|
25
|
+
export class PprShellUnchecked extends PprShellUnavailable {
|
|
26
|
+
constructor(routeId) {
|
|
27
|
+
super(`[nifra/web] ppr: route "${routeId}" has no passing shell import check; rendered blocking`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Thrown when a route already runs `shellBuildConcurrency` shell builds: no request waits on one. */
|
|
31
|
+
export class PprShellBusy extends PprShellUnavailable {
|
|
32
|
+
constructor(routeId) {
|
|
33
|
+
super(`[nifra/web] ppr: route "${routeId}" is at its shell build limit; rendered blocking`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Thrown for a key seen fewer than `shellAfterRequests` times in a full store: the page streams whole. */
|
|
37
|
+
export class PprShellCold extends PprShellUnavailable {
|
|
38
|
+
constructor(routeId) {
|
|
39
|
+
super(`[nifra/web] ppr: route "${routeId}" has no shell for this key yet; rendered whole`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** `variations` as a query string, sorted by name: the shell key part and the shell's own search. */
|
|
43
|
+
export const variationQuery = (variations) => {
|
|
44
|
+
let query = "";
|
|
45
|
+
for (const name of Object.keys(variations).sort()) {
|
|
46
|
+
query += `${query === "" ? "" : "&"}${encodeURIComponent(name)}=${encodeURIComponent(variations[name] ?? "")}`;
|
|
47
|
+
}
|
|
48
|
+
return query;
|
|
49
|
+
};
|
|
50
|
+
// A browser's agent took the default rule about 0.5 us to test, and agents repeat. The bounds keep a
|
|
51
|
+
// client that sends a new agent per request from growing the map.
|
|
52
|
+
const MAX_REMEMBERED_AGENT = 256;
|
|
53
|
+
const MAX_REMEMBERED_AGENTS = 1024;
|
|
54
|
+
const agentAnswers = new WeakMap();
|
|
55
|
+
/** Whether `request` gets the blocking render under `options`. */
|
|
56
|
+
export function wantsBlockingRender(options, request) {
|
|
57
|
+
const rule = options.blockingFor;
|
|
58
|
+
if (typeof rule === "function")
|
|
59
|
+
return rule(request);
|
|
60
|
+
const agent = request.headers.get("user-agent");
|
|
61
|
+
if (agent === null)
|
|
62
|
+
return false;
|
|
63
|
+
if (agent.length > MAX_REMEMBERED_AGENT)
|
|
64
|
+
return rule.test(agent);
|
|
65
|
+
let answers = agentAnswers.get(rule);
|
|
66
|
+
if (answers === undefined) {
|
|
67
|
+
answers = new Map();
|
|
68
|
+
agentAnswers.set(rule, answers);
|
|
69
|
+
}
|
|
70
|
+
let answer = answers.get(agent);
|
|
71
|
+
if (answer === undefined) {
|
|
72
|
+
if (answers.size >= MAX_REMEMBERED_AGENTS)
|
|
73
|
+
answers.clear();
|
|
74
|
+
// No `g` or `y` flag (options refuse them), so a test reads no state and an answer holds.
|
|
75
|
+
answer = rule.test(agent);
|
|
76
|
+
answers.set(agent, answer);
|
|
77
|
+
}
|
|
78
|
+
return answer;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/internal/ppr/contract.ts"],"names":[],"mappings":"AAmBA,yFAAyF;AACzF,MAAM,CAAC,MAAM,UAAU,GAAkB,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEpE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAkB,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAEzE,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAA;AAoBpD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAA8B,EAAgC,EAAE,CACrF,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAA;AAE3D,6FAA6F;AAC7F,MAAM,CAAC,MAAM,WAAW,GAAkB,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;AAE7E,6F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C,CAAA;QACzB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC5B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hole name: it becomes a DOM id, an attribute value, a hashed script and part of a renderer's id
|
|
3
|
+
* prefix, so it stays this narrow. No `--` and no trailing `-`: Svelte refuses an id prefix with `--`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const HOLE_NAME: RegExp;
|
|
6
|
+
/** What one hole sends: its server HTML, plus props when it hydrates, or the record of the server
|
|
7
|
+
* component it shows, without that HTML. An error carries the error slot's HTML only, never the
|
|
8
|
+
* thrown message. */
|
|
9
|
+
export type HoleOutcome = {
|
|
10
|
+
readonly html: string;
|
|
11
|
+
readonly props?: unknown;
|
|
12
|
+
readonly component?: unknown;
|
|
13
|
+
readonly error?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
readonly html: string;
|
|
16
|
+
readonly error: true;
|
|
17
|
+
};
|
|
18
|
+
/** A frame's JSON, as the runtime reads it to fill a host. */
|
|
19
|
+
export type HoleFrameBody = {
|
|
20
|
+
readonly v: 1;
|
|
21
|
+
readonly html: string;
|
|
22
|
+
readonly props?: unknown;
|
|
23
|
+
readonly component?: unknown;
|
|
24
|
+
readonly error?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
readonly v: 1;
|
|
27
|
+
readonly html: string;
|
|
28
|
+
readonly error: true;
|
|
29
|
+
};
|
|
30
|
+
export declare const assertHoleName: (name: string) => void;
|
|
31
|
+
/** Refuse hole HTML that could run script or escape its host, with the policy server
|
|
32
|
+
* components already enforce. Throws; the caller sends that hole's error frame instead. */
|
|
33
|
+
export declare const validateHoleHtml: (html: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* The bytes that fill hole `name`: an inert JSON frame and the constant invoker. No `</script>` or
|
|
36
|
+
* comment opener in the HTML or props survives into the element. Throws a `RangeError` when the
|
|
37
|
+
* encoded frame exceeds `maxBytes`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function encodeHoleFrame(name: string, outcome: HoleOutcome, maxBytes: number): string;
|
|
40
|
+
/**
|
|
41
|
+
* The JSON of a frame {@link encodeHoleFrame} wrote: what a data request sends to refill a host. The
|
|
42
|
+
* opening tag holds no `>` before its end, and the escaped JSON no `</script>`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function frameBodyOf(frame: string): HoleFrameBody;
|
|
45
|
+
/**
|
|
46
|
+
* The per-response facts the runtime needs to send a cancel beacon. Inert JSON: never cached. `shared`
|
|
47
|
+
* names the holes whose frames serve every visitor, which the canary check scans with the shell.
|
|
48
|
+
*/
|
|
49
|
+
export declare const encodeRequestScript: (cancelUrl: string, token: string, holes: readonly string[], shared?: readonly string[]) => string;
|
|
50
|
+
/**
|
|
51
|
+
* {@link encodeRequestScript} before and after the token, so a route's script is serialized once and
|
|
52
|
+
* each response adds only its token. Holds for a base64url token, which serializing leaves as it is.
|
|
53
|
+
* An escaped JSON string never holds `"token":"` (each of its quotes follows a backslash), so the
|
|
54
|
+
* key found is the token's.
|
|
55
|
+
*/
|
|
56
|
+
export declare function requestScriptAround(cancelUrl: string, holes: readonly string[], shared?: readonly string[]): readonly [string, string];
|
|
57
|
+
/**
|
|
58
|
+
* Where {@link injectHoleFallbacks} puts each fallback, in document order. One pass over the shell
|
|
59
|
+
* finds every host: a search per hole, and another for its duplicate, read a large shell many times.
|
|
60
|
+
*/
|
|
61
|
+
export declare function holeFallbackInserts(shell: string, fallbacks: ReadonlyMap<string, string>): Array<{
|
|
62
|
+
readonly at: number;
|
|
63
|
+
readonly html: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Put each hole's fallback HTML into its empty host in a rendered shell, once per shell build. Every
|
|
67
|
+
* declared hole must have exactly one host and that host must be empty: the adapter renders
|
|
68
|
+
* it opaque, so anything inside would be framework output the fill would destroy.
|
|
69
|
+
*/
|
|
70
|
+
export declare function injectHoleFallbacks(shell: string, fallbacks: ReadonlyMap<string, string>): string;
|
|
71
|
+
//# sourceMappingURL=frames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../../src/internal/ppr/frames.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAqD,CAAA;AAE7E;;qBAEqB;AACrB,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAC3B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAA;AAEnD,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAA;IACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAC3B,GACD;IAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAA;AAElE,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,IAM7C,CAAA;AAED;2FAC2F;AAC3F,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,IAAmC,CAAA;AAWnF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAmB5F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAIxD;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,OAAO,SAAS,MAAM,EAAE,EACxB,SAAQ,SAAS,MAAM,EAAO,WAEyJ,CAAA;AAIzL;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,GAAE,SAAS,MAAM,EAAO,GAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAI3B;AAID;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,KAAK,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBvD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CASjG"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { validateComponentHTML } from "../../server-components/html.js";
|
|
2
|
+
import { serializeData } from "../render-document.js";
|
|
3
|
+
import { holeInvoker } from "./runtime.js";
|
|
4
|
+
/**
|
|
5
|
+
* A hole name: it becomes a DOM id, an attribute value, a hashed script and part of a renderer's id
|
|
6
|
+
* prefix, so it stays this narrow. No `--` and no trailing `-`: Svelte refuses an id prefix with `--`.
|
|
7
|
+
*/
|
|
8
|
+
export const HOLE_NAME = /^(?=[a-z0-9-]{1,32}$)[a-z](?:-?[a-z0-9])*$/;
|
|
9
|
+
export const assertHoleName = (name) => {
|
|
10
|
+
if (!HOLE_NAME.test(name)) {
|
|
11
|
+
throw new TypeError(`[nifra/web] ppr: hole name "${name}" must match ${HOLE_NAME.source} (it becomes a DOM id and a hashed script)`);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/** Refuse hole HTML that could run script or escape its host, with the policy server
|
|
15
|
+
* components already enforce. Throws; the caller sends that hole's error frame instead. */
|
|
16
|
+
export const validateHoleHtml = (html) => validateComponentHTML(html);
|
|
17
|
+
/**
|
|
18
|
+
* JSON safe inside a `<script>` element. Script data ends only at `</script`, and only `<!--` can
|
|
19
|
+
* move the tokenizer into its escaped states, so escaping `</` and `<!--` is enough; both escapes are
|
|
20
|
+
* plain JSON. Escaping every `<` and `>` instead, as `serializeData` does, made a 100 KB hole's frame
|
|
21
|
+
* 53% larger than its HTML; this makes it about 10% larger.
|
|
22
|
+
*/
|
|
23
|
+
const scriptJson = (value) => JSON.stringify(value).replaceAll("</", "<\\/").replaceAll("<!--", "<\\u0021--");
|
|
24
|
+
/**
|
|
25
|
+
* The bytes that fill hole `name`: an inert JSON frame and the constant invoker. No `</script>` or
|
|
26
|
+
* comment opener in the HTML or props survives into the element. Throws a `RangeError` when the
|
|
27
|
+
* encoded frame exceeds `maxBytes`.
|
|
28
|
+
*/
|
|
29
|
+
export function encodeHoleFrame(name, outcome, maxBytes) {
|
|
30
|
+
const body = outcome.error === true
|
|
31
|
+
? { v: 1, error: true, html: outcome.html }
|
|
32
|
+
: outcome.component !== undefined
|
|
33
|
+
? { v: 1, html: outcome.html, component: outcome.component }
|
|
34
|
+
: outcome.props === undefined
|
|
35
|
+
? { v: 1, html: outcome.html }
|
|
36
|
+
: { v: 1, html: outcome.html, props: outcome.props };
|
|
37
|
+
const frame = `<script type="application/json" id="nifra-ppr:${name}">${scriptJson(body)}</script><script>${holeInvoker(name)}</script>`;
|
|
38
|
+
// UTF-8 needs at least one and at most three bytes per UTF-16 unit, so only a frame between the two
|
|
39
|
+
// bounds is encoded to measure it.
|
|
40
|
+
if (frame.length > maxBytes ||
|
|
41
|
+
(frame.length * 3 > maxBytes && new TextEncoder().encode(frame).length > maxBytes)) {
|
|
42
|
+
throw new RangeError(`[nifra/web] ppr: hole "${name}" frame exceeds ${maxBytes} bytes`);
|
|
43
|
+
}
|
|
44
|
+
return frame;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The JSON of a frame {@link encodeHoleFrame} wrote: what a data request sends to refill a host. The
|
|
48
|
+
* opening tag holds no `>` before its end, and the escaped JSON no `</script>`.
|
|
49
|
+
*/
|
|
50
|
+
export function frameBodyOf(frame) {
|
|
51
|
+
const start = frame.indexOf(">") + 1;
|
|
52
|
+
// biome-ignore lint/plugin/requireSafetyCommentForTypeAssertion: encodeHoleFrame wrote this JSON from a HoleFrameBody.
|
|
53
|
+
return JSON.parse(frame.slice(start, frame.indexOf("</script>", start)));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The per-response facts the runtime needs to send a cancel beacon. Inert JSON: never cached. `shared`
|
|
57
|
+
* names the holes whose frames serve every visitor, which the canary check scans with the shell.
|
|
58
|
+
*/
|
|
59
|
+
export const encodeRequestScript = (cancelUrl, token, holes, shared = []) => `<script type="application/json" id="nifra-ppr-req">${serializeData(shared.length === 0 ? { cancel: cancelUrl, token, holes } : { cancel: cancelUrl, token, holes, shared })}</script>`;
|
|
60
|
+
const TOKEN_KEY = '"token":"';
|
|
61
|
+
/**
|
|
62
|
+
* {@link encodeRequestScript} before and after the token, so a route's script is serialized once and
|
|
63
|
+
* each response adds only its token. Holds for a base64url token, which serializing leaves as it is.
|
|
64
|
+
* An escaped JSON string never holds `"token":"` (each of its quotes follows a backslash), so the
|
|
65
|
+
* key found is the token's.
|
|
66
|
+
*/
|
|
67
|
+
export function requestScriptAround(cancelUrl, holes, shared = []) {
|
|
68
|
+
const script = encodeRequestScript(cancelUrl, "", holes, shared);
|
|
69
|
+
const at = script.indexOf(TOKEN_KEY) + TOKEN_KEY.length;
|
|
70
|
+
return [script.slice(0, at), script.slice(at)];
|
|
71
|
+
}
|
|
72
|
+
const HOST = 'data-nifra-hole="';
|
|
73
|
+
/**
|
|
74
|
+
* Where {@link injectHoleFallbacks} puts each fallback, in document order. One pass over the shell
|
|
75
|
+
* finds every host: a search per hole, and another for its duplicate, read a large shell many times.
|
|
76
|
+
*/
|
|
77
|
+
export function holeFallbackInserts(shell, fallbacks) {
|
|
78
|
+
// A declared hole's host, as the index after its name's closing quote; -1 once it has two.
|
|
79
|
+
const hosts = new Map();
|
|
80
|
+
for (let at = shell.indexOf(HOST); at !== -1; at = shell.indexOf(HOST, at + HOST.length)) {
|
|
81
|
+
const end = shell.indexOf('"', at + HOST.length);
|
|
82
|
+
if (end === -1)
|
|
83
|
+
break;
|
|
84
|
+
const name = shell.slice(at + HOST.length, end);
|
|
85
|
+
if (fallbacks.has(name))
|
|
86
|
+
hosts.set(name, hosts.has(name) ? -1 : end + 1);
|
|
87
|
+
}
|
|
88
|
+
const inserts = [];
|
|
89
|
+
for (const [name, html] of fallbacks) {
|
|
90
|
+
const after = hosts.get(name);
|
|
91
|
+
if (after === undefined)
|
|
92
|
+
throw new TypeError(`[nifra/web] ppr: hole "${name}" has no host in the shell`);
|
|
93
|
+
if (after === -1) {
|
|
94
|
+
throw new TypeError(`[nifra/web] ppr: hole "${name}" has more than one host in the shell`);
|
|
95
|
+
}
|
|
96
|
+
const close = shell.indexOf(">", after);
|
|
97
|
+
if (close === -1 || !shell.startsWith("</", close + 1)) {
|
|
98
|
+
throw new TypeError(`[nifra/web] ppr: hole "${name}"'s host must render empty`);
|
|
99
|
+
}
|
|
100
|
+
inserts.push({ at: close + 1, html });
|
|
101
|
+
}
|
|
102
|
+
return inserts.sort((a, b) => a.at - b.at);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Put each hole's fallback HTML into its empty host in a rendered shell, once per shell build. Every
|
|
106
|
+
* declared hole must have exactly one host and that host must be empty: the adapter renders
|
|
107
|
+
* it opaque, so anything inside would be framework output the fill would destroy.
|
|
108
|
+
*/
|
|
109
|
+
export function injectHoleFallbacks(shell, fallbacks) {
|
|
110
|
+
const inserts = holeFallbackInserts(shell, fallbacks);
|
|
111
|
+
let out = "";
|
|
112
|
+
let from = 0;
|
|
113
|
+
for (const insert of inserts) {
|
|
114
|
+
out += shell.slice(from, insert.at) + insert.html;
|
|
115
|
+
from = insert.at;
|
|
116
|
+
}
|
|
117
|
+
return out + shell.slice(from);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames.js","sourceRoot":"","sources":["../../../src/internal/ppr/frames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAW,4CAA4C,CAAA;AAyB7E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAQ,EAAE;IACnD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CACjB,+BAA+B,IAAI,gBAAgB,SAAS,CAAC,MAAM,4CAA4C,CAChH,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED;2FAC2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAQ,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;AAEnF;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAAU,EAAE,CAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAA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BAA0B,IAAI,4BAA4B,CAAC,CAAA;QACjF,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,SAAsC;IACvF,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACrD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAA;QACjD,IAAI,GAAG,MAAM,CAAC,EAAE,CAAA;IAClB,CAAC;IACD,OAAO,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CacheStore } from "../../isr.js";
|
|
2
|
+
import type { ShellCheckRecord } from "./compile-shell.js";
|
|
3
|
+
import { type PprEnvironment, type PprIntegration } from "./contract.js";
|
|
4
|
+
import type { ResolvedPprOptions } from "./options.js";
|
|
5
|
+
/** Where shells are shared beyond the process, as `partialPrerendering` checked them. */
|
|
6
|
+
export interface PprSharing {
|
|
7
|
+
readonly store: CacheStore | undefined;
|
|
8
|
+
readonly storeSecret: string | undefined;
|
|
9
|
+
readonly deployment: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The deployment every shell key names. The client entry changes with each client build; each route's
|
|
13
|
+
* checked shell hash changes with its shell code, which the client entry does not see; the
|
|
14
|
+
* platform's own name, when given, covers the rest.
|
|
15
|
+
*/
|
|
16
|
+
export declare function shellDeployment(clientEntry: string, shellChecks: ShellCheckRecord | "unchecked-development", named: string | undefined): string;
|
|
17
|
+
/** One app's partial prerendering, made when `createWebApp` reaches its `experimental.ppr`. */
|
|
18
|
+
export declare function createPprIntegration(options: ResolvedPprOptions, shellChecks: ShellCheckRecord | "unchecked-development", origin: string | undefined, environment: PprEnvironment, sharing?: PprSharing): PprIntegration;
|
|
19
|
+
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../src/internal/ppr/integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EAMpB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAetD,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CACxC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,gBAAgB,GAAG,uBAAuB,EACvD,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,CAUR;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,gBAAgB,GAAG,uBAAuB,EACvD,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,WAAW,EAAE,cAAc,EAC3B,OAAO,GAAE,UAAgF,GACxF,cAAc,CAyEhB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { readBoundedBytes, TransportCodecError } from "@nifrajs/core/transport-codec";
|
|
2
|
+
import { PPR_CANCEL_PATH, PprShellCold, PprShellUnavailable, PprShellUnchecked, variationQuery, wantsBlockingRender, } from "./contract.js";
|
|
3
|
+
import { assertPprRoute, variationsOf } from "./route-rules.js";
|
|
4
|
+
import { createPprServer } from "./server.js";
|
|
5
|
+
import { digest, sharedShellStore } from "./shell-store.js";
|
|
6
|
+
// The stream sets its own type, caching and CSP; a middleware or gate header joins the rest.
|
|
7
|
+
const OWN_HEADERS = new Set([
|
|
8
|
+
"content-type",
|
|
9
|
+
"cache-control",
|
|
10
|
+
"content-security-policy",
|
|
11
|
+
"content-length",
|
|
12
|
+
]);
|
|
13
|
+
const MAX_CANCEL_BYTES = 64;
|
|
14
|
+
/**
|
|
15
|
+
* The deployment every shell key names. The client entry changes with each client build; each route's
|
|
16
|
+
* checked shell hash changes with its shell code, which the client entry does not see; the
|
|
17
|
+
* platform's own name, when given, covers the rest.
|
|
18
|
+
*/
|
|
19
|
+
export function shellDeployment(clientEntry, shellChecks, named) {
|
|
20
|
+
if (shellChecks === "unchecked-development" && named === undefined)
|
|
21
|
+
return clientEntry;
|
|
22
|
+
const routes = shellChecks === "unchecked-development"
|
|
23
|
+
? ""
|
|
24
|
+
: Object.keys(shellChecks.routes)
|
|
25
|
+
.sort()
|
|
26
|
+
.map((id) => `${id}=${shellChecks.routes[id]}`)
|
|
27
|
+
.join(",");
|
|
28
|
+
return `${clientEntry}~${digest(`${routes}|${named ?? ""}`)}`;
|
|
29
|
+
}
|
|
30
|
+
/** One app's partial prerendering, made when `createWebApp` reaches its `experimental.ppr`. */
|
|
31
|
+
export function createPprIntegration(options, shellChecks, origin, environment, sharing = { store: undefined, storeSecret: undefined, deployment: undefined }) {
|
|
32
|
+
const { perRequestNonce, ...app } = environment;
|
|
33
|
+
if (perRequestNonce) {
|
|
34
|
+
throw new TypeError("[nifra/web] experimental.ppr needs `csp: createCspPolicy(...)`, not `nonce`: a per-request nonce would make every shell unique");
|
|
35
|
+
}
|
|
36
|
+
const deployment = shellDeployment(app.deployment, shellChecks, sharing.deployment);
|
|
37
|
+
const server = createPprServer({
|
|
38
|
+
...app,
|
|
39
|
+
deployment,
|
|
40
|
+
clientEntry: app.deployment,
|
|
41
|
+
options,
|
|
42
|
+
cancelUrl: PPR_CANCEL_PATH,
|
|
43
|
+
shellChecks,
|
|
44
|
+
shared: sharing.store === undefined || sharing.storeSecret === undefined
|
|
45
|
+
? undefined
|
|
46
|
+
: sharedShellStore(sharing.store, sharing.storeSecret, deployment),
|
|
47
|
+
});
|
|
48
|
+
const uncheckedWarned = new Set();
|
|
49
|
+
return {
|
|
50
|
+
server,
|
|
51
|
+
// biome-ignore lint/plugin/noConditionalEmptyObjectSpread: an app with no configured origin has none, which shell meta reads as absent.
|
|
52
|
+
...(origin === undefined ? {} : { origin }),
|
|
53
|
+
cancelPath: PPR_CANCEL_PATH,
|
|
54
|
+
// A beacon carries one 22-character token; anything longer is not one. The token is unguessable,
|
|
55
|
+
// so the answer is the same whether it named a live response or not.
|
|
56
|
+
async cancel(request) {
|
|
57
|
+
const length = Number(request.headers.get("content-length") ?? "NaN");
|
|
58
|
+
if (!(length > 0 && length <= MAX_CANCEL_BYTES))
|
|
59
|
+
return new Response(null, { status: 400 });
|
|
60
|
+
let token;
|
|
61
|
+
try {
|
|
62
|
+
// The header is a claim; the cap holds on the bytes that arrive.
|
|
63
|
+
token = await readBoundedBytes(new Response(request.body, { headers: request.headers }), {
|
|
64
|
+
maxBytes: MAX_CANCEL_BYTES,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof TransportCodecError)
|
|
69
|
+
return new Response(null, { status: 400 });
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
server.cancel(new TextDecoder().decode(token));
|
|
73
|
+
return new Response(null, { status: 204 });
|
|
74
|
+
},
|
|
75
|
+
async stream(request, written) {
|
|
76
|
+
if (wantsBlockingRender(options, request.request))
|
|
77
|
+
return "settled";
|
|
78
|
+
let response;
|
|
79
|
+
try {
|
|
80
|
+
response = await server.respond(request);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (!(error instanceof PprShellUnavailable))
|
|
84
|
+
throw error;
|
|
85
|
+
if (error instanceof PprShellCold)
|
|
86
|
+
return "deferred";
|
|
87
|
+
if (error instanceof PprShellUnchecked && !uncheckedWarned.has(request.routeId)) {
|
|
88
|
+
uncheckedWarned.add(request.routeId);
|
|
89
|
+
console.warn(error.message);
|
|
90
|
+
}
|
|
91
|
+
return "settled";
|
|
92
|
+
}
|
|
93
|
+
for (const [name, value] of Object.entries(written() ?? {}))
|
|
94
|
+
if (!OWN_HEADERS.has(name))
|
|
95
|
+
response.headers.set(name, value);
|
|
96
|
+
return response;
|
|
97
|
+
},
|
|
98
|
+
shellData: (request, signal) => server
|
|
99
|
+
.shellData(request)
|
|
100
|
+
.catch((error) => error instanceof PprShellUnavailable ? request.loadShell(signal) : Promise.reject(error)),
|
|
101
|
+
variationQuery,
|
|
102
|
+
assertRoute: (route, layouts, boundaries) => assertPprRoute(route, layouts, boundaries, options),
|
|
103
|
+
variationsOf,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/internal/ppr/integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAGrF,OAAO,EACL,eAAe,EAGf,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,E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