vinext 1.2.1 → 1.3.1
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 +12 -9
- package/dist/_virtual/_rolldown/runtime.js +1 -1
- package/dist/build/action-owner-manifest.d.ts +3 -2
- package/dist/build/action-owner-manifest.js +18 -2
- package/dist/build/app-page-static-eligibility.d.ts +17 -1
- package/dist/build/app-page-static-eligibility.js +80 -13
- package/dist/build/clean-output.d.ts +2 -1
- package/dist/build/client-build-config.d.ts +77 -6
- package/dist/build/client-build-config.js +176 -12
- package/dist/build/client-reference-async.d.ts +48 -0
- package/dist/build/client-reference-async.js +123 -0
- package/dist/build/client-reference-chunks.d.ts +32 -0
- package/dist/build/client-reference-chunks.js +111 -0
- package/dist/build/client-reference-groups.d.ts +171 -0
- package/dist/build/client-reference-groups.js +572 -0
- package/dist/build/css-url-assets.d.ts +2 -1
- package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
- package/dist/build/google-fonts/font-metadata.d.ts +2 -1
- package/dist/build/google-fonts/validate.d.ts +2 -1
- package/dist/build/inline-css.d.ts +2 -1
- package/dist/build/layout-classification.d.ts +2 -1
- package/dist/build/module-dependency-cache.d.ts +33 -1
- package/dist/build/module-dependency-cache.js +51 -1
- package/dist/build/next-client-runtime-manifests.d.ts +12 -2
- package/dist/build/next-client-runtime-manifests.js +19 -4
- package/dist/build/nitro-public-files.d.ts +24 -0
- package/dist/build/nitro-public-files.js +60 -0
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.d.ts +2 -1
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.d.ts +2 -1
- package/dist/build/prerender-paths.js +5 -2
- package/dist/build/prerender-phase.d.ts +2 -1
- package/dist/build/prerender-server-pool.js +1 -1
- package/dist/build/prerender.d.ts +3 -2
- package/dist/build/prerender.js +5 -4
- package/dist/build/report.d.ts +2 -1
- package/dist/build/route-classification-injector.d.ts +2 -1
- package/dist/build/route-classification-manifest.d.ts +2 -1
- package/dist/build/run-prerender.d.ts +2 -1
- package/dist/build/server-actions-encryption-key.d.ts +24 -0
- package/dist/build/server-actions-encryption-key.js +101 -0
- package/dist/build/ssr-manifest.d.ts +3 -0
- package/dist/build/ssr-manifest.js +34 -2
- package/dist/build/standalone.d.ts +2 -1
- package/dist/cache/cache-adapters-virtual.d.ts +2 -1
- package/dist/cache.js +1 -2
- package/dist/check.d.ts +2 -1
- package/dist/check.js +4 -0
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli.js +2 -0
- package/dist/client/client-redirect-matcher.js +2 -1
- package/dist/client/client-redirects.d.ts +4 -3
- package/dist/client/client-redirects.js +2 -1
- package/dist/client/client-rewrite-params.d.ts +9 -0
- package/dist/client/client-rewrite-params.js +20 -0
- package/dist/client/client-rewrites.d.ts +2 -1
- package/dist/client/dev-error-overlay-store.d.ts +2 -1
- package/dist/client/dev-error-overlay.js +2 -1
- package/dist/client/index.js +1 -2
- package/dist/client/instrumentation-client-state.js +5 -5
- package/dist/client/navigation-runtime.d.ts +28 -3
- package/dist/client/navigation-runtime.js +42 -11
- package/dist/client/pages-router-link-navigation.d.ts +2 -1
- package/dist/client/vinext-next-data.d.ts +25 -2
- package/dist/client/window-next.d.ts +2 -1
- package/dist/config/config-matchers.d.ts +27 -41
- package/dist/config/config-matchers.js +293 -270
- package/dist/config/config-source.d.ts +34 -0
- package/dist/config/config-source.js +141 -0
- package/dist/config/dotenv.d.ts +2 -1
- package/dist/config/header-params.d.ts +29 -0
- package/dist/config/header-params.js +106 -0
- package/dist/config/next-config.d.ts +20 -6
- package/dist/config/next-config.js +149 -11
- package/dist/config/tsconfig-paths.d.ts +2 -1
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
- package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
- package/dist/entries/app-browser-entry.d.ts +34 -6
- package/dist/entries/app-browser-entry.js +103 -40
- package/dist/entries/app-rsc-entry.d.ts +4 -1
- package/dist/entries/app-rsc-entry.js +131 -66
- package/dist/entries/app-rsc-manifest.d.ts +12 -1
- package/dist/entries/app-rsc-manifest.js +73 -1
- package/dist/entries/app-ssr-entry.d.ts +4 -1
- package/dist/entries/app-ssr-entry.js +9 -2
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +6 -6
- package/dist/entries/pages-entry-helpers.js +1 -2
- package/dist/entries/pages-server-entry.d.ts +2 -1
- package/dist/entries/pages-server-entry.js +18 -15
- package/dist/entries/runtime-entry-module.d.ts +1 -0
- package/dist/entries/runtime-entry-module.js +4 -1
- package/dist/image/image-adapters-virtual.d.ts +2 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +340 -116
- package/dist/init.js +17 -0
- package/dist/plugins/client-compile-hints.d.ts +30 -0
- package/dist/plugins/client-compile-hints.js +88 -0
- package/dist/plugins/client-reference-dedup.d.ts +2 -1
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
- package/dist/plugins/dynamic-preload-metadata.js +1 -1
- package/dist/plugins/environment.d.ts +2 -1
- package/dist/plugins/fonts.js +9 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
- package/dist/plugins/import-meta-url.d.ts +2 -1
- package/dist/plugins/og-assets.d.ts +2 -1
- package/dist/plugins/og-assets.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +27 -3
- package/dist/plugins/optimize-imports.js +106 -20
- package/dist/plugins/pages-node-externals.d.ts +2 -1
- package/dist/plugins/remove-console.d.ts +2 -1
- package/dist/plugins/require-condition-resolution.d.ts +2 -1
- package/dist/plugins/rsc-client-reference-loaders.d.ts +53 -1
- package/dist/plugins/rsc-client-reference-loaders.js +447 -27
- package/dist/plugins/rsc-client-shim-excludes.js +2 -0
- package/dist/plugins/sass.d.ts +2 -1
- package/dist/plugins/strip-server-exports.d.ts +2 -1
- package/dist/plugins/styled-jsx.d.ts +2 -1
- package/dist/plugins/transform-result.d.ts +2 -1
- package/dist/plugins/typeof-window.d.ts +2 -1
- package/dist/plugins/use-cache-callable.d.ts +5 -0
- package/dist/plugins/use-cache-callable.js +30 -8
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +2 -2
- package/dist/plugins/worker-use-server.d.ts +2 -1
- package/dist/routing/app-route-graph.d.ts +41 -1
- package/dist/routing/app-route-graph.js +122 -50
- package/dist/routing/browser-route-manifest.d.ts +44 -0
- package/dist/routing/browser-route-manifest.js +195 -0
- package/dist/routing/hashed-route-patterns.d.ts +4 -0
- package/dist/routing/hashed-route-patterns.js +22 -0
- package/dist/routing/optimistic-route-trie.d.ts +28 -0
- package/dist/routing/optimistic-route-trie.js +102 -0
- package/dist/routing/route-matching.d.ts +2 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-validation.d.ts +6 -1
- package/dist/routing/route-validation.js +26 -10
- package/dist/server/accept-encoding.d.ts +2 -1
- package/dist/server/app-action-forwarding.d.ts +10 -1
- package/dist/server/app-action-forwarding.js +15 -1
- package/dist/server/app-bfcache-identity.d.ts +2 -1
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -1
- package/dist/server/app-browser-entry.js +175 -64
- package/dist/server/app-browser-error.d.ts +5 -2
- package/dist/server/app-browser-error.js +7 -2
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-hydration.d.ts +2 -1
- package/dist/server/app-browser-interception-context.d.ts +4 -3
- package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
- package/dist/server/app-browser-mpa-navigation.js +6 -5
- package/dist/server/app-browser-navigation-controller.d.ts +17 -6
- package/dist/server/app-browser-navigation-controller.js +103 -36
- package/dist/server/app-browser-popstate.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-server-action-client.d.ts +2 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-stream.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.d.ts +6 -5
- package/dist/server/app-client-reference-manifest.d.ts +31 -0
- package/dist/server/app-client-reference-manifest.js +46 -0
- package/dist/server/app-client-reference-preloader.d.ts +45 -2
- package/dist/server/app-client-reference-preloader.js +48 -10
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-elements.d.ts +2 -0
- package/dist/server/app-elements.js +3 -1
- package/dist/server/app-fallback-renderer.d.ts +9 -2
- package/dist/server/app-fallback-renderer.js +6 -2
- package/dist/server/app-history-state.d.ts +2 -1
- package/dist/server/app-inline-css-client.d.ts +2 -1
- package/dist/server/app-layout-param-observation.d.ts +2 -1
- package/dist/server/app-metadata-tracing.d.ts +2 -1
- package/dist/server/app-middleware.d.ts +6 -0
- package/dist/server/app-middleware.js +8 -10
- package/dist/server/app-optimistic-routing.d.ts +26 -11
- package/dist/server/app-optimistic-routing.js +38 -96
- package/dist/server/app-page-boundary-render.d.ts +20 -2
- package/dist/server/app-page-boundary-render.js +229 -39
- package/dist/server/app-page-boundary.d.ts +34 -5
- package/dist/server/app-page-boundary.js +40 -7
- package/dist/server/app-page-cache-finalizer.d.ts +2 -1
- package/dist/server/app-page-cache-finalizer.js +1 -1
- package/dist/server/app-page-cache-render.d.ts +10 -2
- package/dist/server/app-page-cache-render.js +15 -2
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +34 -1
- package/dist/server/app-page-dispatch.js +165 -34
- package/dist/server/app-page-element-builder.d.ts +17 -1
- package/dist/server/app-page-element-builder.js +187 -66
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +114 -5
- package/dist/server/app-page-head.d.ts +95 -3
- package/dist/server/app-page-head.js +307 -152
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +48 -2
- package/dist/server/app-page-http-access-fallback-metadata.js +76 -1
- package/dist/server/app-page-method.d.ts +2 -1
- package/dist/server/app-page-probe.d.ts +2 -1
- package/dist/server/app-page-render-identity.d.ts +2 -1
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +38 -11
- package/dist/server/app-page-request.d.ts +14 -1
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-route-wiring.d.ts +52 -2
- package/dist/server/app-page-route-wiring.js +197 -47
- package/dist/server/app-page-rsc-render-status.d.ts +3 -1
- package/dist/server/app-page-rsc-render-status.js +1 -0
- package/dist/server/app-page-search-params-observation.d.ts +8 -6
- package/dist/server/app-page-search-params-observation.js +16 -11
- package/dist/server/app-page-segment-plan.d.ts +2 -1
- package/dist/server/app-page-stream.d.ts +38 -1
- package/dist/server/app-page-stream.js +24 -4
- package/dist/server/app-pages-bridge.d.ts +4 -2
- package/dist/server/app-pages-bridge.js +11 -7
- package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
- package/dist/server/app-prerender-endpoints.d.ts +2 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-dependency.d.ts +11 -1
- package/dist/server/app-render-dependency.js +65 -6
- package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
- package/dist/server/app-request-stage-independent-entry.js +2 -2
- package/dist/server/app-response-stage-entry.d.ts +2 -1
- package/dist/server/app-response-stage-entry.js +3 -3
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.js +4 -2
- package/dist/server/app-route-handler-execution.d.ts +4 -1
- package/dist/server/app-route-handler-execution.js +9 -2
- package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
- package/dist/server/app-route-handler-middleware-context.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +4 -2
- package/dist/server/app-route-handler-response.js +2 -2
- package/dist/server/app-route-handler-runtime.d.ts +4 -1
- package/dist/server/app-route-handler-runtime.js +20 -3
- package/dist/server/app-route-module-loader.d.ts +18 -1
- package/dist/server/app-route-module-loader.js +15 -6
- package/dist/server/app-route-tree-prefetch.d.ts +2 -1
- package/dist/server/app-route-tree.d.ts +20 -0
- package/dist/server/app-route-tree.js +18 -0
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-combined-handler.js +8 -1
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-errors.d.ts +9 -1
- package/dist/server/app-rsc-errors.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +6 -2
- package/dist/server/app-rsc-handler.js +152 -140
- package/dist/server/app-rsc-response-finalizer.d.ts +7 -1
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.js +3 -1
- package/dist/server/app-rsc-route-matching.d.ts +39 -1
- package/dist/server/app-rsc-route-matching.js +25 -1
- package/dist/server/app-segment-config.d.ts +2 -1
- package/dist/server/app-segment-config.js +1 -14
- package/dist/server/app-server-action-execution.d.ts +25 -7
- package/dist/server/app-server-action-execution.js +53 -59
- package/dist/server/app-ssr-entry.d.ts +12 -0
- package/dist/server/app-ssr-entry.js +104 -48
- package/dist/server/app-ssr-error-meta.d.ts +2 -1
- package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
- package/dist/server/app-ssr-stream.d.ts +29 -10
- package/dist/server/app-ssr-stream.js +311 -67
- package/dist/server/app-static-generation.d.ts +2 -1
- package/dist/server/app-streamed-client-references.d.ts +39 -0
- package/dist/server/app-streamed-client-references.js +156 -0
- package/dist/server/app-visited-response-cache.d.ts +2 -1
- package/dist/server/app-worker-stages.d.ts +2 -1
- package/dist/server/artifact-compatibility.d.ts +2 -1
- package/dist/server/bfcache-identity.d.ts +2 -1
- package/dist/server/cache-headers.d.ts +2 -1
- package/dist/server/cacheability-request.d.ts +2 -1
- package/dist/server/client-reuse-manifest.d.ts +2 -1
- package/dist/server/config-headers.d.ts +2 -1
- package/dist/server/config-headers.js +12 -3
- package/dist/server/csp.d.ts +2 -1
- package/dist/server/default-global-not-found-module.d.ts +2 -1
- package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
- package/dist/server/default-http-access-fallback-modules.js +31 -0
- package/dist/server/defer-until-stream-consumed.d.ts +34 -0
- package/dist/server/defer-until-stream-consumed.js +154 -21
- package/dist/server/dev-lockfile.d.ts +32 -2
- package/dist/server/dev-lockfile.js +46 -2
- package/dist/server/dev-module-runner.d.ts +2 -1
- package/dist/server/dev-server.js +10 -3
- package/dist/server/fetch-handler.js +1 -2
- package/dist/server/file-based-metadata.d.ts +2 -1
- package/dist/server/framework-tracer.d.ts +2 -1
- package/dist/server/html.d.ts +1 -0
- package/dist/server/html.js +19 -1
- package/dist/server/http-conditional.d.ts +2 -1
- package/dist/server/http-error-responses.d.ts +2 -1
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/isolate-shared-promise.d.ts +10 -0
- package/dist/server/isolate-shared-promise.js +33 -0
- package/dist/server/isr-cache.js +3 -2
- package/dist/server/metadata-route-build-data.d.ts +2 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-response.d.ts +2 -1
- package/dist/server/metadata-route-response.js +1 -1
- package/dist/server/metadata-routes.d.ts +2 -1
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher-pattern.js +11 -140
- package/dist/server/middleware-matcher.js +5 -6
- package/dist/server/middleware-response-headers.d.ts +31 -0
- package/dist/server/middleware-response-headers.js +57 -1
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/middleware-runtime.js +26 -13
- package/dist/server/navigation-planner.d.ts +2 -2
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/next-error-digest.d.ts +2 -1
- package/dist/server/nitro-public-files-plugin.d.ts +39 -0
- package/dist/server/nitro-public-files-plugin.js +106 -0
- package/dist/server/nitro-public-files.d.ts +22 -0
- package/dist/server/nitro-public-files.js +39 -0
- package/dist/server/opentelemetry-api.d.ts +2 -1
- package/dist/server/operation-token.d.ts +2 -1
- package/dist/server/pages-api-route.d.ts +2 -1
- package/dist/server/pages-asset-tags.d.ts +7 -1
- package/dist/server/pages-asset-tags.js +9 -2
- package/dist/server/pages-body-parser-config.d.ts +2 -1
- package/dist/server/pages-client-assets.d.ts +8 -1
- package/dist/server/pages-data-route.d.ts +2 -1
- package/dist/server/pages-document-asset-props.d.ts +2 -1
- package/dist/server/pages-document-initial-props.d.ts +2 -1
- package/dist/server/pages-execution-tracing.d.ts +2 -1
- package/dist/server/pages-execution-tracing.js +1 -1
- package/dist/server/pages-get-initial-props.d.ts +2 -1
- package/dist/server/pages-i18n.d.ts +18 -0
- package/dist/server/pages-i18n.js +18 -2
- package/dist/server/pages-node-compat.d.ts +5 -3
- package/dist/server/pages-node-compat.js +35 -16
- package/dist/server/pages-page-data.d.ts +7 -1
- package/dist/server/pages-page-data.js +35 -12
- package/dist/server/pages-page-handler.d.ts +3 -2
- package/dist/server/pages-page-handler.js +16 -7
- package/dist/server/pages-page-method.d.ts +2 -1
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-preview.d.ts +2 -1
- package/dist/server/pages-readiness.d.ts +2 -1
- package/dist/server/pages-request-pipeline.d.ts +8 -2
- package/dist/server/pages-request-pipeline.js +35 -40
- package/dist/server/pages-request-stage-entry.d.ts +2 -1
- package/dist/server/pages-request-stage-entry.js +16 -6
- package/dist/server/pages-response-stage-entry.d.ts +2 -1
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +1 -0
- package/dist/server/pages-route-data-kind.d.ts +2 -1
- package/dist/server/pages-router-entry.js +1 -1
- package/dist/server/prerender-cache-life-header.d.ts +2 -1
- package/dist/server/prerender-route-params.d.ts +2 -1
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +80 -36
- package/dist/server/proxy-trust.d.ts +6 -0
- package/dist/server/proxy-trust.js +12 -6
- package/dist/server/request-log.d.ts +2 -1
- package/dist/server/request-pipeline.d.ts +5 -0
- package/dist/server/request-pipeline.js +12 -1
- package/dist/server/request-tracing.d.ts +2 -1
- package/dist/server/request-tracing.js +1 -1
- package/dist/server/response-start-tracing.js +7 -29
- package/dist/server/rsc-render-stream.d.ts +4 -0
- package/dist/server/rsc-render-stream.js +25 -0
- package/dist/server/seed-cache.d.ts +2 -1
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.d.ts +2 -1
- package/dist/server/static-file-cache.js +16 -3
- package/dist/server/static-layout-client-reuse-proof.d.ts +2 -1
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-stages.d.ts +2 -1
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/app.d.ts +2 -1
- package/dist/shims/cache-callable-runtime.d.ts +2 -1
- package/dist/shims/cache-handler.d.ts +8 -3
- package/dist/shims/cache-handler.js +32 -11
- package/dist/shims/cache-request-state.d.ts +40 -3
- package/dist/shims/cache-request-state.js +70 -5
- package/dist/shims/cache-runtime.js +47 -19
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +17 -8
- package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
- package/dist/shims/caught-not-found-boundaries.js +48 -0
- package/dist/shims/cdn-purge-routes.d.ts +25 -0
- package/dist/shims/cdn-purge-routes.js +77 -0
- package/dist/shims/client-locale.js +2 -1
- package/dist/shims/client-page-root.d.ts +2 -1
- package/dist/shims/config.d.ts +2 -1
- package/dist/shims/default-forbidden.d.ts +4 -0
- package/dist/shims/default-forbidden.js +18 -0
- package/dist/shims/default-not-found.d.ts +0 -5
- package/dist/shims/default-not-found.js +5 -41
- package/dist/shims/default-unauthorized.d.ts +4 -0
- package/dist/shims/default-unauthorized.js +18 -0
- package/dist/shims/dynamic.js +17 -4
- package/dist/shims/error-boundary.d.ts +39 -3
- package/dist/shims/error-boundary.js +31 -16
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-utils.d.ts +3 -2
- package/dist/shims/font-utils.js +5 -3
- package/dist/shims/form.js +9 -4
- package/dist/shims/http-access-error-fallback.d.ts +7 -0
- package/dist/shims/http-access-error-fallback.js +47 -0
- package/dist/shims/image-props.d.ts +93 -0
- package/dist/shims/image-props.js +323 -0
- package/dist/shims/image.d.ts +4 -39
- package/dist/shims/image.js +4 -319
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
- package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
- package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
- package/dist/shims/internal/client-reference-loader.d.ts +7 -0
- package/dist/shims/internal/client-reference-loader.js +91 -0
- package/dist/shims/internal/cookie-serialize.d.ts +2 -1
- package/dist/shims/internal/cookies.js +1 -2
- package/dist/shims/internal/headers-state.d.ts +9 -0
- package/dist/shims/internal/headers-state.js +19 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +31 -14
- package/dist/shims/internal/hybrid-client-route-owner.js +8 -8
- package/dist/shims/internal/interpolate-as.d.ts +2 -1
- package/dist/shims/internal/pages-data-target.d.ts +2 -1
- package/dist/shims/internal/pages-data-url.d.ts +2 -1
- package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
- package/dist/shims/link.js +198 -53
- package/dist/shims/metadata.d.ts +32 -11
- package/dist/shims/metadata.js +88 -26
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation.d.ts +23 -3
- package/dist/shims/navigation.js +91 -25
- package/dist/shims/og.js +35 -10
- package/dist/shims/pages-router-runtime.d.ts +2 -1
- package/dist/shims/ppr-fallback-shell.d.ts +2 -1
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +33 -43
- package/dist/shims/server.d.ts +31 -4
- package/dist/shims/server.js +58 -10
- package/dist/shims/thenable-params.d.ts +6 -1
- package/dist/shims/thenable-params.js +11 -2
- package/dist/shims/unified-request-context.d.ts +5 -0
- package/dist/shims/unified-request-context.js +5 -3
- package/dist/typegen.d.ts +2 -1
- package/dist/utils/asset-prefix.d.ts +7 -0
- package/dist/utils/asset-prefix.js +10 -1
- package/dist/utils/client-build-manifest.d.ts +4 -1
- package/dist/utils/client-build-manifest.js +20 -6
- package/dist/utils/client-entry-manifest.d.ts +13 -0
- package/dist/utils/client-entry-manifest.js +20 -1
- package/dist/utils/client-reference-chunks.d.ts +45 -0
- package/dist/utils/client-reference-chunks.js +30 -0
- package/dist/utils/client-runtime-metadata.d.ts +10 -1
- package/dist/utils/client-runtime-metadata.js +53 -9
- package/dist/utils/compare.d.ts +9 -0
- package/dist/utils/compare.js +15 -1
- package/dist/utils/lazy-chunks.d.ts +18 -0
- package/dist/utils/lazy-chunks.js +27 -1
- package/dist/utils/manifest-paths.d.ts +14 -0
- package/dist/utils/manifest-paths.js +22 -1
- package/dist/utils/middleware-request-headers.d.ts +2 -1
- package/dist/utils/path-to-regexp.d.ts +21 -0
- package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
- package/dist/utils/plugin-react-version.d.ts +15 -0
- package/dist/utils/plugin-react-version.js +64 -0
- package/dist/utils/project.d.ts +2 -1
- package/dist/utils/project.js +9 -1
- package/dist/utils/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/dist/utils/query.d.ts +2 -1
- package/dist/utils/sorted-array.d.ts +2 -1
- package/dist/utils/vite-cli-invocation.d.ts +2 -1
- package/package.json +5 -5
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
- package/dist/server/default-not-found-module.d.ts +0 -19
- package/dist/server/default-not-found-module.js +0 -18
- package/dist/server/middleware-path-to-regexp.d.ts +0 -13
- package/dist/server/rsc-stream-hints.d.ts +0 -21
- package/dist/server/rsc-stream-hints.js +0 -227
- package/dist/utils/regex-safety.d.ts +0 -17
- package/dist/utils/regex-safety.js +0 -789
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createNonceAttribute, escapeHtmlAttr, htmlTokenListContains, safeJsonStringify, scriptSafeJsonStringify } from "./html.js";
|
|
2
|
+
import { getVinextRscCompatibilityId } from "./app-rsc-cache-busting.js";
|
|
2
3
|
import { bytesToBase64, concatUint8Arrays } from "./app-rsc-embedded-chunks.js";
|
|
3
4
|
import { NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION } from "../client/browser-globals.js";
|
|
5
|
+
import { Buffer, isUtf8 } from "node:buffer";
|
|
4
6
|
//#region src/server/app-ssr-stream.ts
|
|
5
|
-
const
|
|
7
|
+
const RSC_EMBED_TEXT_BATCH_MAX_BYTES = 65536;
|
|
6
8
|
function waitAtLeastOneReactRenderTask() {
|
|
7
9
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
8
10
|
}
|
|
@@ -14,6 +16,17 @@ function createNavigationRuntimeRscMetadataScript(params, nav, dynamicStaleTimeS
|
|
|
14
16
|
return "Object.assign(" + navigationRuntimeRscBootstrapExpression() + ",{params:" + safeJsonStringify(params) + ",nav:" + safeJsonStringify(nav) + (searchParamsFromBrowser === void 0 ? "" : ",searchParamsFromBrowser:" + safeJsonStringify(searchParamsFromBrowser)) + (dynamicStaleTimeSeconds === void 0 ? "" : ",dynamicStaleTimeSeconds:" + safeJsonStringify(dynamicStaleTimeSeconds)) + "})";
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
19
|
+
* The compatibility ID of the server rendering this page. The browser compares
|
|
20
|
+
* RSC responses against it, so it is sent with the page rather than inlined
|
|
21
|
+
* into the client bundle, where a per-build value would rename chunks on every
|
|
22
|
+
* build. Static export skips the check, so its pages omit it.
|
|
23
|
+
*/
|
|
24
|
+
function createNavigationRuntimeRscCompatibilityScript() {
|
|
25
|
+
const compatibilityId = getVinextRscCompatibilityId();
|
|
26
|
+
if (compatibilityId === null || process.env.NODE_ENV === "production" && process.env.__NEXT_CONFIG_OUTPUT === "export") return "";
|
|
27
|
+
return "Object.assign(" + navigationRuntimeRscBootstrapExpression() + ",{compatibilityId:" + safeJsonStringify(compatibilityId) + "})";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
17
30
|
* The query a client page read during SSR, for a render that turned dynamic
|
|
18
31
|
* after its head told the browser to read the query from its own URL.
|
|
19
32
|
*/
|
|
@@ -21,7 +34,30 @@ function createNavigationRuntimeRenderedSearchScript(search) {
|
|
|
21
34
|
return "Object.assign(" + navigationRuntimeRscBootstrapExpression() + ",{renderedSearch:" + safeJsonStringify(search) + "})";
|
|
22
35
|
}
|
|
23
36
|
function createNavigationRuntimeRscChunkScript(chunk) {
|
|
24
|
-
return navigationRuntimeRscBootstrapExpression() + ".rsc.push(" +
|
|
37
|
+
return navigationRuntimeRscBootstrapExpression() + ".rsc.push(" + scriptSafeJsonStringify(chunk) + ")";
|
|
38
|
+
}
|
|
39
|
+
const SCRIPT_UNSAFE_BYTE_STRING_RE = /<(?=!--|\/?[Ss][Cc][Rr][Ii][Pp][Tt])|\u00e2\u0080[\u00a8\u00a9]/g;
|
|
40
|
+
function escapeScriptUnsafeByteString(match) {
|
|
41
|
+
if (match === "<") return "\\u003c";
|
|
42
|
+
return match.charCodeAt(2) === 168 ? "\\u2028" : "\\u2029";
|
|
43
|
+
}
|
|
44
|
+
function bytesToByteString(bytes) {
|
|
45
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("latin1");
|
|
46
|
+
}
|
|
47
|
+
const NON_ASCII_RE = /[\u0080-\uffff]/;
|
|
48
|
+
function textToByteString(text) {
|
|
49
|
+
return NON_ASCII_RE.test(text) ? Buffer.from(text, "utf8").toString("latin1") : text;
|
|
50
|
+
}
|
|
51
|
+
function byteStringToBytes(byteString) {
|
|
52
|
+
const bytes = Buffer.allocUnsafeSlow(byteString.length);
|
|
53
|
+
bytes.write(byteString, "latin1");
|
|
54
|
+
return bytes;
|
|
55
|
+
}
|
|
56
|
+
const NAVIGATION_RUNTIME_RSC_PUSH_PREFIX = textToByteString(navigationRuntimeRscBootstrapExpression() + ".rsc.push(");
|
|
57
|
+
/** createNavigationRuntimeRscChunkScript for valid UTF-8 text, as a byte string. */
|
|
58
|
+
function createNavigationRuntimeRscTextChunkByteScript(text) {
|
|
59
|
+
const json = JSON.stringify(bytesToByteString(text)).replace(SCRIPT_UNSAFE_BYTE_STRING_RE, escapeScriptUnsafeByteString);
|
|
60
|
+
return NAVIGATION_RUNTIME_RSC_PUSH_PREFIX + json + ")";
|
|
25
61
|
}
|
|
26
62
|
function createNavigationRuntimeRscDoneScript(metadata) {
|
|
27
63
|
const bootstrap = navigationRuntimeRscBootstrapExpression();
|
|
@@ -40,6 +76,18 @@ function createNextFlightChunkScript(chunk) {
|
|
|
40
76
|
function createNextFlightCleanupScript() {
|
|
41
77
|
return "self.addEventListener(\"DOMContentLoaded\",()=>{if(self.__next_f?.push===Array.prototype.push)self.__next_f.length=0},{once:true})";
|
|
42
78
|
}
|
|
79
|
+
function utf8CharacterLength(byte) {
|
|
80
|
+
return byte >= 248 ? 1 : byte >= 240 ? 4 : byte >= 224 ? 3 : byte >= 192 ? 2 : 1;
|
|
81
|
+
}
|
|
82
|
+
function utf8CompleteEnd(bytes) {
|
|
83
|
+
const length = bytes.byteLength;
|
|
84
|
+
for (let index = length - 1; index >= 0 && index >= length - 3; index--) {
|
|
85
|
+
const byte = bytes[index];
|
|
86
|
+
if ((byte & 192) === 128) continue;
|
|
87
|
+
return index + utf8CharacterLength(byte) > length ? index : length;
|
|
88
|
+
}
|
|
89
|
+
return length;
|
|
90
|
+
}
|
|
43
91
|
/**
|
|
44
92
|
* Create a helper that progressively embeds RSC chunks as inline <script> tags.
|
|
45
93
|
* The browser entry turns the embedded chunks back into Uint8Array data.
|
|
@@ -48,34 +96,115 @@ function createRscEmbedTransform(embedStream, optionsOrNonce = {}) {
|
|
|
48
96
|
const options = typeof optionsOrNonce === "string" ? { scriptNonce: optionsOrNonce } : optionsOrNonce;
|
|
49
97
|
const reader = embedStream.getReader();
|
|
50
98
|
let pendingChunks = [];
|
|
99
|
+
let pendingRawChunkCount = 0;
|
|
51
100
|
const rawChunks = [];
|
|
52
101
|
let embeddedRawChunkCount = 0;
|
|
53
102
|
let rawBufferTaken = false;
|
|
103
|
+
let rawChunksReleased = false;
|
|
54
104
|
let finalized = false;
|
|
55
105
|
let reading = false;
|
|
106
|
+
let readDone = false;
|
|
107
|
+
let readError = null;
|
|
108
|
+
const replays = [];
|
|
56
109
|
let mirroredNextFlightBootstrap = false;
|
|
57
|
-
const textDecoder = new TextDecoder("utf-8", {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
110
|
+
const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
111
|
+
const nonceAttribute = textToByteString(createNonceAttribute(options.scriptNonce));
|
|
112
|
+
function toBinaryChunk(bytes) {
|
|
113
|
+
return [3, bytesToBase64(bytes)];
|
|
114
|
+
}
|
|
115
|
+
function splitChunk(bytes, chunks) {
|
|
116
|
+
if (isUtf8(bytes)) {
|
|
117
|
+
chunks.push(bytes);
|
|
118
|
+
return;
|
|
66
119
|
}
|
|
120
|
+
const pushRange = (start, end, text) => {
|
|
121
|
+
const range = bytes.subarray(start, end);
|
|
122
|
+
chunks.push(text ? range : toBinaryChunk(range));
|
|
123
|
+
};
|
|
124
|
+
let rangeStart = 0;
|
|
125
|
+
let rangeIsText = false;
|
|
126
|
+
let start = 0;
|
|
127
|
+
while (start < bytes.byteLength) {
|
|
128
|
+
const newline = bytes.indexOf(10, start);
|
|
129
|
+
const end = newline === -1 ? bytes.byteLength : newline + 1;
|
|
130
|
+
const isText = isUtf8(bytes.subarray(start, end));
|
|
131
|
+
if (start > rangeStart && isText !== rangeIsText) {
|
|
132
|
+
pushRange(rangeStart, start, rangeIsText);
|
|
133
|
+
rangeStart = start;
|
|
134
|
+
}
|
|
135
|
+
rangeIsText = isText;
|
|
136
|
+
start = end;
|
|
137
|
+
}
|
|
138
|
+
pushRange(rangeStart, bytes.byteLength, rangeIsText);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* React cuts its output into fixed-size chunks wherever they fall, even
|
|
142
|
+
* inside a character, so a chunk's last incomplete character is decoded with
|
|
143
|
+
* the next chunk, which React writes in the same flush. Bytes are never held
|
|
144
|
+
* past an embed flush, though: they may be the end of a binary row, which the
|
|
145
|
+
* browser needs before React writes anything else. They're embedded as
|
|
146
|
+
* binary then, and so are the bytes that complete them.
|
|
147
|
+
*/
|
|
148
|
+
function createChunkDecoder() {
|
|
149
|
+
let carry = null;
|
|
150
|
+
let missing = 0;
|
|
151
|
+
return {
|
|
152
|
+
decode(raw, chunks) {
|
|
153
|
+
let bytes = raw;
|
|
154
|
+
if (missing > 0) {
|
|
155
|
+
let count = 0;
|
|
156
|
+
while (count < missing && count < bytes.byteLength && (bytes[count] & 192) === 128) count++;
|
|
157
|
+
missing = 0;
|
|
158
|
+
if (count > 0) {
|
|
159
|
+
chunks.push(toBinaryChunk(bytes.subarray(0, count)));
|
|
160
|
+
bytes = bytes.subarray(count);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (carry) {
|
|
164
|
+
bytes = concatUint8Arrays([carry, bytes]);
|
|
165
|
+
carry = null;
|
|
166
|
+
}
|
|
167
|
+
const end = utf8CompleteEnd(bytes);
|
|
168
|
+
if (end < bytes.byteLength) {
|
|
169
|
+
carry = bytes.slice(end);
|
|
170
|
+
bytes = bytes.subarray(0, end);
|
|
171
|
+
}
|
|
172
|
+
if (bytes.byteLength > 0) splitChunk(bytes, chunks);
|
|
173
|
+
},
|
|
174
|
+
flush(chunks) {
|
|
175
|
+
if (!carry) return;
|
|
176
|
+
chunks.push(toBinaryChunk(carry));
|
|
177
|
+
missing = utf8CharacterLength(carry[0]) - carry.byteLength;
|
|
178
|
+
carry = null;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const chunkDecoder = createChunkDecoder();
|
|
183
|
+
function inlineScript(byteScript) {
|
|
184
|
+
return "<script" + nonceAttribute + ">" + byteScript + "<\/script>";
|
|
67
185
|
}
|
|
68
186
|
function releaseRawChunks() {
|
|
69
187
|
const mayStartMirror = typeof options.mirrorNextFlight === "function" && !mirroredNextFlightBootstrap && !finalized;
|
|
70
|
-
if (rawBufferTaken && !mayStartMirror)
|
|
188
|
+
if (rawBufferTaken && !mayStartMirror) {
|
|
189
|
+
rawChunks.length = 0;
|
|
190
|
+
rawChunksReleased = true;
|
|
191
|
+
}
|
|
71
192
|
}
|
|
193
|
+
/** The mirror's opening scripts, as a byte string. */
|
|
72
194
|
function startNextFlightMirror() {
|
|
73
195
|
if (mirroredNextFlightBootstrap) return "";
|
|
74
196
|
const mirror = options.mirrorNextFlight;
|
|
75
197
|
if (mirror !== true && (typeof mirror !== "function" || !mirror())) return "";
|
|
76
198
|
mirroredNextFlightBootstrap = true;
|
|
77
|
-
let scripts =
|
|
78
|
-
|
|
199
|
+
let scripts = inlineScript(createNextFlightBootstrapScript()) + inlineScript(createNextFlightCleanupScript());
|
|
200
|
+
const embeddedChunks = [];
|
|
201
|
+
const replayDecoder = createChunkDecoder();
|
|
202
|
+
for (let index = 0; index < embeddedRawChunkCount; index++) replayDecoder.decode(rawChunks[index], embeddedChunks);
|
|
203
|
+
replayDecoder.flush(embeddedChunks);
|
|
204
|
+
for (const chunk of embeddedChunks) {
|
|
205
|
+
const nextChunk = chunk instanceof Uint8Array ? textDecoder.decode(chunk) : chunk;
|
|
206
|
+
scripts += inlineScript(textToByteString(createNextFlightChunkScript(nextChunk)));
|
|
207
|
+
}
|
|
79
208
|
releaseRawChunks();
|
|
80
209
|
return scripts;
|
|
81
210
|
}
|
|
@@ -87,56 +216,67 @@ function createRscEmbedTransform(embedStream, optionsOrNonce = {}) {
|
|
|
87
216
|
const result = await reader.read();
|
|
88
217
|
if (result.done) break;
|
|
89
218
|
rawChunks.push(result.value);
|
|
90
|
-
|
|
219
|
+
for (const replay of replays) replay.controller.enqueue(result.value);
|
|
220
|
+
chunkDecoder.decode(result.value, pendingChunks);
|
|
221
|
+
pendingRawChunkCount++;
|
|
91
222
|
}
|
|
223
|
+
readDone = true;
|
|
224
|
+
for (const replay of replays.splice(0)) if (!replay.keepOpen) replay.controller.close();
|
|
92
225
|
} catch (error) {
|
|
93
226
|
if (process.env.NODE_ENV !== "production") console.warn("[vinext] RSC embed stream read error:", error);
|
|
227
|
+
readError = { error };
|
|
228
|
+
for (const replay of replays.splice(0)) replay.controller.error(error);
|
|
94
229
|
throw error;
|
|
95
230
|
} finally {
|
|
96
231
|
reading = false;
|
|
97
232
|
}
|
|
98
233
|
}
|
|
99
234
|
const pumpPromise = pumpReader();
|
|
235
|
+
/** Scripts for the chunks read since the last flush, as a byte string. */
|
|
236
|
+
function flushByteScripts() {
|
|
237
|
+
chunkDecoder.flush(pendingChunks);
|
|
238
|
+
if (pendingChunks.length === 0) return "";
|
|
239
|
+
const mirrorScripts = startNextFlightMirror();
|
|
240
|
+
const chunks = pendingChunks;
|
|
241
|
+
pendingChunks = [];
|
|
242
|
+
embeddedRawChunkCount += pendingRawChunkCount;
|
|
243
|
+
pendingRawChunkCount = 0;
|
|
244
|
+
let scripts = mirrorScripts;
|
|
245
|
+
let textChunks = [];
|
|
246
|
+
let textBytes = 0;
|
|
247
|
+
const flushTextChunks = () => {
|
|
248
|
+
if (textChunks.length === 0) return;
|
|
249
|
+
const text = textChunks.length === 1 ? textChunks[0] : concatUint8Arrays(textChunks);
|
|
250
|
+
textChunks = [];
|
|
251
|
+
textBytes = 0;
|
|
252
|
+
scripts += inlineScript(createNavigationRuntimeRscTextChunkByteScript(text));
|
|
253
|
+
if (mirroredNextFlightBootstrap) scripts += inlineScript(textToByteString(createNextFlightChunkScript(textDecoder.decode(text))));
|
|
254
|
+
};
|
|
255
|
+
for (const chunk of chunks) if (chunk instanceof Uint8Array) {
|
|
256
|
+
if (textBytes > 0 && textBytes + chunk.byteLength > RSC_EMBED_TEXT_BATCH_MAX_BYTES) flushTextChunks();
|
|
257
|
+
textChunks.push(chunk);
|
|
258
|
+
textBytes += chunk.byteLength;
|
|
259
|
+
} else {
|
|
260
|
+
flushTextChunks();
|
|
261
|
+
scripts += inlineScript(textToByteString(createNavigationRuntimeRscChunkScript(chunk)));
|
|
262
|
+
if (mirroredNextFlightBootstrap) scripts += inlineScript(textToByteString(createNextFlightChunkScript(chunk)));
|
|
263
|
+
}
|
|
264
|
+
flushTextChunks();
|
|
265
|
+
return scripts;
|
|
266
|
+
}
|
|
100
267
|
return {
|
|
101
268
|
flush() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const chunks = pendingChunks;
|
|
105
|
-
pendingChunks = [];
|
|
106
|
-
embeddedRawChunkCount += chunks.length;
|
|
107
|
-
const embeddedChunks = [];
|
|
108
|
-
let textChunks = [];
|
|
109
|
-
let textLength = 0;
|
|
110
|
-
const flushTextChunks = () => {
|
|
111
|
-
if (textChunks.length === 0) return;
|
|
112
|
-
embeddedChunks.push(textChunks.join(""));
|
|
113
|
-
textChunks = [];
|
|
114
|
-
textLength = 0;
|
|
115
|
-
};
|
|
116
|
-
for (const chunk of chunks) if (typeof chunk === "string") {
|
|
117
|
-
if (textLength > 0 && textLength + chunk.length > RSC_EMBED_TEXT_BATCH_MAX_LENGTH) flushTextChunks();
|
|
118
|
-
textChunks.push(chunk);
|
|
119
|
-
textLength += chunk.length;
|
|
120
|
-
} else {
|
|
121
|
-
flushTextChunks();
|
|
122
|
-
embeddedChunks.push(chunk);
|
|
123
|
-
}
|
|
124
|
-
flushTextChunks();
|
|
125
|
-
let scripts = mirrorScripts;
|
|
126
|
-
for (const chunk of embeddedChunks) {
|
|
127
|
-
scripts += createInlineScriptTag(createNavigationRuntimeRscChunkScript(chunk), options.scriptNonce);
|
|
128
|
-
if (mirroredNextFlightBootstrap) scripts += createInlineScriptTag(createNextFlightChunkScript(chunk), options.scriptNonce);
|
|
129
|
-
}
|
|
130
|
-
return scripts;
|
|
269
|
+
const scripts = flushByteScripts();
|
|
270
|
+
return scripts ? byteStringToBytes(scripts) : null;
|
|
131
271
|
},
|
|
132
272
|
async finalize() {
|
|
133
273
|
await pumpPromise;
|
|
134
|
-
let scripts =
|
|
274
|
+
let scripts = flushByteScripts();
|
|
135
275
|
scripts += startNextFlightMirror();
|
|
136
276
|
finalized = true;
|
|
137
277
|
releaseRawChunks();
|
|
138
|
-
scripts +=
|
|
139
|
-
return scripts;
|
|
278
|
+
scripts += inlineScript(textToByteString(createNavigationRuntimeRscDoneScript(options.getInitialNavigationCacheMetadata?.())));
|
|
279
|
+
return byteStringToBytes(scripts);
|
|
140
280
|
},
|
|
141
281
|
async getRawBuffer() {
|
|
142
282
|
await pumpPromise;
|
|
@@ -144,17 +284,33 @@ function createRscEmbedTransform(embedStream, optionsOrNonce = {}) {
|
|
|
144
284
|
rawBufferTaken = true;
|
|
145
285
|
releaseRawChunks();
|
|
146
286
|
return buffer.buffer;
|
|
287
|
+
},
|
|
288
|
+
replay(replayOptions) {
|
|
289
|
+
if (rawChunksReleased) return null;
|
|
290
|
+
const keepOpen = replayOptions?.keepOpen === true;
|
|
291
|
+
let replay;
|
|
292
|
+
return new ReadableStream({
|
|
293
|
+
start(controller) {
|
|
294
|
+
for (const chunk of rawChunks) controller.enqueue(chunk);
|
|
295
|
+
if (readError) controller.error(readError.error);
|
|
296
|
+
else if (readDone) {
|
|
297
|
+
if (!keepOpen) controller.close();
|
|
298
|
+
} else {
|
|
299
|
+
replay = {
|
|
300
|
+
controller,
|
|
301
|
+
keepOpen
|
|
302
|
+
};
|
|
303
|
+
replays.push(replay);
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
cancel() {
|
|
307
|
+
const index = replay ? replays.indexOf(replay) : -1;
|
|
308
|
+
if (index !== -1) replays.splice(index, 1);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
147
311
|
}
|
|
148
312
|
};
|
|
149
313
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Fix invalid preload "as" values in server-rendered HTML.
|
|
152
|
-
* React Fizz emits <link rel="preload" as="stylesheet"> for CSS, but the
|
|
153
|
-
* HTML spec requires as="style" for <link rel="preload">.
|
|
154
|
-
*/
|
|
155
|
-
function fixPreloadAs(html) {
|
|
156
|
-
return html.replace(/<link(?=[^>]*\srel="preload")[^>]*>/g, (tag) => tag.replace(" as=\"stylesheet\"", " as=\"style\""));
|
|
157
|
-
}
|
|
158
314
|
const LINK_TAG_RE = /<link\b[^>]*>/gi;
|
|
159
315
|
const HTML_REWRITE_EXCLUDED_REGION_RE = /<!--[\s\S]*?-->|<(script|style|textarea|title)\b[^>]*>[\s\S]*?<\/\1\s*>/gi;
|
|
160
316
|
const HTML_REWRITE_EXCLUDED_REGION_START_RE = /<!--|<(script|style|textarea|title)\b[^>]*>/gi;
|
|
@@ -306,6 +462,42 @@ const HEAD_OPEN_RE = /<head\b[^>]*>/;
|
|
|
306
462
|
* (see `createMoveSuffixStream` and `CLOSE_TAG`)
|
|
307
463
|
*/
|
|
308
464
|
const DOCUMENT_CLOSE_SUFFIX = "</body></html>";
|
|
465
|
+
const DOCUMENT_CLOSE_SUFFIX_BYTES = new TextEncoder().encode(DOCUMENT_CLOSE_SUFFIX);
|
|
466
|
+
const HEAD_CLOSE_BYTES = new TextEncoder().encode("</head>");
|
|
467
|
+
/**
|
|
468
|
+
* Whether `chunks` end partway through a UTF-8 character, i.e. whether a
|
|
469
|
+
* streaming TextDecoder may still be holding back their last bytes. Errs
|
|
470
|
+
* towards true: when the batch has too few bytes to tell, the previous
|
|
471
|
+
* batch's answer carries over.
|
|
472
|
+
*/
|
|
473
|
+
function endsWithIncompleteUtf8Character(chunks, previousBatchEndedIncomplete) {
|
|
474
|
+
let continuationBytes = 0;
|
|
475
|
+
for (let chunkIndex = chunks.length - 1; chunkIndex >= 0; chunkIndex--) {
|
|
476
|
+
const chunk = chunks[chunkIndex];
|
|
477
|
+
for (let index = chunk.byteLength - 1; index >= 0; index--) {
|
|
478
|
+
const byte = chunk[index];
|
|
479
|
+
if ((byte & 192) !== 128) {
|
|
480
|
+
const length = byte >= 240 ? 4 : byte >= 224 ? 3 : byte >= 192 ? 2 : 1;
|
|
481
|
+
return continuationBytes + 1 < length;
|
|
482
|
+
}
|
|
483
|
+
if (++continuationBytes === 3) return false;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return previousBatchEndedIncomplete;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Find an ASCII `pattern` in UTF-8 `bytes`, starting at `from`. ASCII bytes
|
|
490
|
+
* never occur inside a multi-byte character, so every byte match is a match
|
|
491
|
+
* in the decoded text too.
|
|
492
|
+
*/
|
|
493
|
+
function indexOfAsciiBytes(bytes, pattern, from) {
|
|
494
|
+
const last = bytes.byteLength - pattern.byteLength;
|
|
495
|
+
search: for (let index = from; index <= last; index++) {
|
|
496
|
+
for (let offset = 0; offset < pattern.byteLength; offset++) if (bytes[index + offset] !== pattern[offset]) continue search;
|
|
497
|
+
return index;
|
|
498
|
+
}
|
|
499
|
+
return -1;
|
|
500
|
+
}
|
|
309
501
|
/**
|
|
310
502
|
* Create the tick-buffered HTML transform that injects RSC scripts between
|
|
311
503
|
* React Fizz flush cycles without corrupting split HTML chunks.
|
|
@@ -341,10 +533,44 @@ function createTickBufferedTransform(rscEmbed, injectHTML = "", injectAfterHeadO
|
|
|
341
533
|
let preHeadInjected = false;
|
|
342
534
|
let suffixStripped = false;
|
|
343
535
|
let buffered = [];
|
|
536
|
+
let bufferedBytes = [];
|
|
537
|
+
let decoderMayHoldBytes = false;
|
|
344
538
|
let pendingHtml = "";
|
|
345
539
|
let timeoutId = null;
|
|
346
540
|
const hasInlineCssManifest = inlineCssManifest !== void 0 && Object.keys(inlineCssManifest).length > 0;
|
|
347
541
|
/**
|
|
542
|
+
* Return this batch's bytes when they are exactly the UTF-8 encoding of its
|
|
543
|
+
* decoded text, so they can stand in for re-encoding that text. That needs
|
|
544
|
+
* the batch to start and end on character boundaries (the decoder holds no
|
|
545
|
+
* bytes across it) and to contain no invalid UTF-8, which the decoder would
|
|
546
|
+
* have replaced with U+FFFD.
|
|
547
|
+
*/
|
|
548
|
+
const takeBufferedBytes = (html) => {
|
|
549
|
+
if (hasInlineCssManifest) return null;
|
|
550
|
+
const chunks = bufferedBytes;
|
|
551
|
+
bufferedBytes = [];
|
|
552
|
+
const startsMidCharacter = decoderMayHoldBytes;
|
|
553
|
+
decoderMayHoldBytes = endsWithIncompleteUtf8Character(chunks, decoderMayHoldBytes);
|
|
554
|
+
if (startsMidCharacter || decoderMayHoldBytes || html.includes("�")) return null;
|
|
555
|
+
return chunks.length === 1 ? chunks[0] : concatUint8Arrays(chunks);
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Byte form of `stripDocumentCloseSuffix(html.slice(htmlStart))` for a batch
|
|
559
|
+
* whose bytes encode `html`: returns the bytes from `byteStart` (the byte
|
|
560
|
+
* offset of `htmlStart`) with the first suffix removed.
|
|
561
|
+
*/
|
|
562
|
+
const stripDocumentCloseSuffixBytes = (bytes, byteStart, html, htmlStart) => {
|
|
563
|
+
const rest = bytes.subarray(byteStart);
|
|
564
|
+
if (suffixStripped) return rest;
|
|
565
|
+
const index = html.indexOf(DOCUMENT_CLOSE_SUFFIX, htmlStart);
|
|
566
|
+
if (index === -1) return rest;
|
|
567
|
+
suffixStripped = true;
|
|
568
|
+
const byteIndex = indexOfAsciiBytes(bytes, DOCUMENT_CLOSE_SUFFIX_BYTES, byteStart + index - htmlStart);
|
|
569
|
+
const before = bytes.subarray(byteStart, byteIndex);
|
|
570
|
+
const after = bytes.subarray(byteIndex + DOCUMENT_CLOSE_SUFFIX_BYTES.byteLength);
|
|
571
|
+
return after.byteLength === 0 ? before : concatUint8Arrays([before, after]);
|
|
572
|
+
};
|
|
573
|
+
/**
|
|
348
574
|
* Strip the first occurrence of `</body></html>` from `chunk` so it can be
|
|
349
575
|
* re-emitted at the very end of the stream. Returns the rewritten chunk and
|
|
350
576
|
* a flag indicating whether a suffix was found. If `suffixStripped` is
|
|
@@ -385,22 +611,26 @@ function createTickBufferedTransform(rscEmbed, injectHTML = "", injectAfterHeadO
|
|
|
385
611
|
const spliceAfterHeadOpen = (chunk) => {
|
|
386
612
|
if (preHeadInjected) return {
|
|
387
613
|
chunk,
|
|
388
|
-
spliced: false
|
|
614
|
+
spliced: false,
|
|
615
|
+
insertionEnd: 0
|
|
389
616
|
};
|
|
390
617
|
const insertion = readPreHeadInsertion();
|
|
391
618
|
if (!insertion) return {
|
|
392
619
|
chunk,
|
|
393
|
-
spliced: false
|
|
620
|
+
spliced: false,
|
|
621
|
+
insertionEnd: 0
|
|
394
622
|
};
|
|
395
623
|
const match = HEAD_OPEN_RE.exec(chunk);
|
|
396
624
|
if (!match) return {
|
|
397
625
|
chunk,
|
|
398
|
-
spliced: false
|
|
626
|
+
spliced: false,
|
|
627
|
+
insertionEnd: 0
|
|
399
628
|
};
|
|
400
629
|
const insertAt = match.index + match[0].length;
|
|
401
630
|
return {
|
|
402
631
|
chunk: chunk.slice(0, insertAt) + insertion + chunk.slice(insertAt),
|
|
403
|
-
spliced: true
|
|
632
|
+
spliced: true,
|
|
633
|
+
insertionEnd: insertAt + insertion.length
|
|
404
634
|
};
|
|
405
635
|
};
|
|
406
636
|
const flushBuffered = (controller, final = false) => {
|
|
@@ -408,6 +638,7 @@ function createTickBufferedTransform(rscEmbed, injectHTML = "", injectAfterHeadO
|
|
|
408
638
|
const rawHtml = pendingHtml + buffered.join("");
|
|
409
639
|
buffered = [];
|
|
410
640
|
pendingHtml = "";
|
|
641
|
+
const rawBytes = takeBufferedBytes(rawHtml);
|
|
411
642
|
const split = final || !hasInlineCssManifest ? {
|
|
412
643
|
complete: rawHtml,
|
|
413
644
|
trailing: ""
|
|
@@ -415,29 +646,42 @@ function createTickBufferedTransform(rscEmbed, injectHTML = "", injectAfterHeadO
|
|
|
415
646
|
if (split.trailing) pendingHtml = split.trailing;
|
|
416
647
|
if (!split.complete) return;
|
|
417
648
|
if (injected && insertsPerFlush) emitInsertion(controller);
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
html: preparedHtml,
|
|
649
|
+
const inlineCssResult = hasInlineCssManifest ? rewriteInlineCssStylesheetLinks(split.complete, inlineCssManifest, inlineCssPrependCss, inlineCssScriptNonce) : {
|
|
650
|
+
html: split.complete,
|
|
421
651
|
consumedPrependCss: false
|
|
422
652
|
};
|
|
423
653
|
if (inlineCssResult.consumedPrependCss) inlineCssPrependCss = "";
|
|
424
654
|
let working = inlineCssResult.html;
|
|
655
|
+
const unchangedBytes = working === rawHtml ? rawBytes : null;
|
|
656
|
+
let rawTextStart = 0;
|
|
425
657
|
if (!preHeadInjected) {
|
|
426
658
|
const result = spliceAfterHeadOpen(working);
|
|
427
659
|
if (result.spliced) {
|
|
428
660
|
working = result.chunk;
|
|
429
661
|
preHeadInjected = true;
|
|
662
|
+
rawTextStart = result.insertionEnd;
|
|
430
663
|
}
|
|
431
664
|
}
|
|
432
665
|
if (!injected) {
|
|
433
666
|
const headEnd = working.indexOf("</head>");
|
|
434
667
|
if (headEnd !== -1) {
|
|
435
668
|
const before = working.slice(0, headEnd);
|
|
669
|
+
if (unchangedBytes && headEnd >= rawTextStart) {
|
|
670
|
+
const rawHeadEnd = headEnd - (working.length - rawHtml.length);
|
|
671
|
+
const byteHeadEnd = indexOfAsciiBytes(unchangedBytes, HEAD_CLOSE_BYTES, rawHeadEnd);
|
|
672
|
+
controller.enqueue(encoder.encode(before + readInlineCssPrependFallback() + readInsertion()));
|
|
673
|
+
controller.enqueue(stripDocumentCloseSuffixBytes(unchangedBytes, byteHeadEnd, rawHtml, rawHeadEnd));
|
|
674
|
+
injected = true;
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
436
677
|
const after = stripDocumentCloseSuffix(working.slice(headEnd));
|
|
437
678
|
controller.enqueue(encoder.encode(before + readInlineCssPrependFallback() + readInsertion() + after));
|
|
438
679
|
injected = true;
|
|
439
680
|
return;
|
|
440
681
|
}
|
|
682
|
+
} else if (unchangedBytes && rawTextStart === 0) {
|
|
683
|
+
controller.enqueue(stripDocumentCloseSuffixBytes(unchangedBytes, 0, rawHtml, 0));
|
|
684
|
+
return;
|
|
441
685
|
}
|
|
442
686
|
working = stripDocumentCloseSuffix(working);
|
|
443
687
|
controller.enqueue(encoder.encode(working));
|
|
@@ -445,12 +689,13 @@ function createTickBufferedTransform(rscEmbed, injectHTML = "", injectAfterHeadO
|
|
|
445
689
|
return new TransformStream({
|
|
446
690
|
transform(chunk, controller) {
|
|
447
691
|
buffered.push(decoder.decode(chunk, { stream: true }));
|
|
692
|
+
if (!hasInlineCssManifest) bufferedBytes.push(chunk);
|
|
448
693
|
if (timeoutId !== null) return;
|
|
449
694
|
timeoutId = setTimeout(() => {
|
|
450
695
|
try {
|
|
451
696
|
flushBuffered(controller);
|
|
452
697
|
const rscScripts = rscEmbed.flush();
|
|
453
|
-
if (rscScripts) controller.enqueue(
|
|
698
|
+
if (rscScripts) controller.enqueue(rscScripts);
|
|
454
699
|
} catch {}
|
|
455
700
|
timeoutId = null;
|
|
456
701
|
}, 0);
|
|
@@ -467,11 +712,10 @@ function createTickBufferedTransform(rscEmbed, injectHTML = "", injectAfterHeadO
|
|
|
467
712
|
emitInsertion(controller);
|
|
468
713
|
injected = true;
|
|
469
714
|
} else if (insertsPerFlush) emitInsertion(controller);
|
|
470
|
-
|
|
471
|
-
if (finalScripts) controller.enqueue(encoder.encode(finalScripts));
|
|
715
|
+
controller.enqueue(await rscEmbed.finalize());
|
|
472
716
|
controller.enqueue(encoder.encode(DOCUMENT_CLOSE_SUFFIX));
|
|
473
717
|
}
|
|
474
718
|
});
|
|
475
719
|
}
|
|
476
720
|
//#endregion
|
|
477
|
-
export { createNavigationRuntimeRenderedSearchScript, createNavigationRuntimeRscMetadataScript, createRscEmbedTransform, createTickBufferedTransform,
|
|
721
|
+
export { createNavigationRuntimeRenderedSearchScript, createNavigationRuntimeRscCompatibilityScript, createNavigationRuntimeRscMetadataScript, createRscEmbedTransform, createTickBufferedTransform, navigationRuntimeRscBootstrapExpression, rewriteInlineCssStylesheetLinks, waitAtLeastOneReactRenderTask };
|
|
@@ -11,4 +11,5 @@ type CreateStaticGenerationHeadersContextOptions = {
|
|
|
11
11
|
export declare function getAppPageStaticGenerationErrorMessage(): string;
|
|
12
12
|
export declare function getAppRouteStaticGenerationErrorMessage(routePattern?: string, expression?: string): string;
|
|
13
13
|
export declare function createStaticGenerationHeadersContext(options: CreateStaticGenerationHeadersContextOptions): HeadersContext;
|
|
14
|
-
//#endregion
|
|
14
|
+
//#endregion
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AssetCrossOrigin } from "./pages-client-assets.js";
|
|
2
|
+
import { RouteClientReferenceSet } from "./app-client-reference-preloader.js";
|
|
3
|
+
//#region src/server/app-streamed-client-references.d.ts
|
|
4
|
+
type ClientReferenceLoader = () => Promise<unknown>;
|
|
5
|
+
/** A render's streamed references, and the stylesheets the render linked. */
|
|
6
|
+
export type StreamedClientReferences = {
|
|
7
|
+
/** The render's CSP nonce for the scripts it hints. */
|
|
8
|
+
nonce: string | undefined;
|
|
9
|
+
/** next.config's crossOrigin for the assets it links; "" when unset. */
|
|
10
|
+
crossOrigin: AssetCrossOrigin;
|
|
11
|
+
streamed: ReadonlySet<string>;
|
|
12
|
+
/** Each of the route's references' position in import order. */
|
|
13
|
+
positions: ReadonlyMap<string, number>;
|
|
14
|
+
/** Streamed references whose stylesheets aren't linked yet, in import order. */
|
|
15
|
+
unlinked: string[];
|
|
16
|
+
linkedStylesheets: Set<string>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Wrap plugin-rsc's client-reference loader before any client reference
|
|
20
|
+
* loads; a production build calls this as its SSR entry starts. `asyncIds` are
|
|
21
|
+
* the references any route may stream, and `getLoader` returns a reference's
|
|
22
|
+
* own loader from the client-references module.
|
|
23
|
+
*/
|
|
24
|
+
export declare function wrapClientReferenceRequire(asyncIds: ReadonlySet<string>, getLoader: (id: string) => ClientReferenceLoader | undefined): void;
|
|
25
|
+
export declare function createStreamedClientReferences(route: RouteClientReferenceSet | undefined, nonce: string | undefined, crossOrigin: AssetCrossOrigin): StreamedClientReferences;
|
|
26
|
+
/**
|
|
27
|
+
* Forget the stylesheets a discarded render linked, so the render that
|
|
28
|
+
* replaces it links them again.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resetStreamedClientReferences(render: StreamedClientReferences | null, route: RouteClientReferenceSet | undefined): void;
|
|
31
|
+
/** Run a render, and the Flight stream it reads, with its streamed references. */
|
|
32
|
+
export declare function runWithStreamedClientReferences<R>(render: StreamedClientReferences, fn: () => R): R;
|
|
33
|
+
/**
|
|
34
|
+
* The `<head>` links of the streamed stylesheets a render's shell left
|
|
35
|
+
* unlinked, those of streamed references after every reference it rendered.
|
|
36
|
+
*/
|
|
37
|
+
export declare function renderStreamedStylesheets(render: StreamedClientReferences): string;
|
|
38
|
+
//#endregion
|
|
39
|
+
export {};
|