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
|
@@ -42,7 +42,7 @@ function createWorkerImageImportsPlugin(options = {}) {
|
|
|
42
42
|
let dimensions = dimensionCache.get(imagePath);
|
|
43
43
|
if (!dimensions) {
|
|
44
44
|
try {
|
|
45
|
-
const { imageSize } = await import("../deps/.pnpm/image-size@2.0.
|
|
45
|
+
const { imageSize } = await import("../deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js");
|
|
46
46
|
const result = imageSize(fs.readFileSync(imagePath));
|
|
47
47
|
dimensions = {
|
|
48
48
|
width: result.width ?? 0,
|
|
@@ -128,4 +128,4 @@ function createWorkerImageImportsPlugin(options = {}) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
|
-
export { createWorkerImageImportsPlugin };
|
|
131
|
+
export { WORKER_IMAGE_METADATA_PREFIX, createWorkerImageImportsPlugin };
|
|
@@ -44,6 +44,30 @@ type InterceptingRoute = {
|
|
|
44
44
|
notFoundBranchSegments?: string[];
|
|
45
45
|
/** Tree position relative to the normalized interception branch. */
|
|
46
46
|
notFoundTreePosition?: number | null;
|
|
47
|
+
/** Nearest forbidden convention inside the interception branch. */
|
|
48
|
+
forbiddenPath?: string | null;
|
|
49
|
+
/** Tree position relative to the normalized interception branch. */
|
|
50
|
+
forbiddenTreePosition?: number | null;
|
|
51
|
+
/** Nearest unauthorized convention inside the interception branch. */
|
|
52
|
+
unauthorizedPath?: string | null;
|
|
53
|
+
/** Tree position relative to the normalized interception branch. */
|
|
54
|
+
unauthorizedTreePosition?: number | null;
|
|
55
|
+
/** Every not-found convention inside the interception branch, outermost first. */
|
|
56
|
+
notFoundPaths?: string[];
|
|
57
|
+
/** Tree positions for notFoundPaths in the normalized interception branch. */
|
|
58
|
+
notFoundTreePositions?: number[];
|
|
59
|
+
/** Every forbidden convention inside the interception branch, outermost first. */
|
|
60
|
+
forbiddenPaths?: string[];
|
|
61
|
+
/** Tree positions for forbiddenPaths in the normalized interception branch. */
|
|
62
|
+
forbiddenTreePositions?: number[];
|
|
63
|
+
/** Every unauthorized convention inside the interception branch, outermost first. */
|
|
64
|
+
unauthorizedPaths?: string[];
|
|
65
|
+
/** Tree positions for unauthorizedPaths in the normalized interception branch. */
|
|
66
|
+
unauthorizedTreePositions?: number[];
|
|
67
|
+
/** Every error convention inside the interception branch, outermost first. */
|
|
68
|
+
errorPaths?: string[];
|
|
69
|
+
/** Tree positions for errorPaths in the normalized interception branch. */
|
|
70
|
+
errorTreePositions?: number[];
|
|
47
71
|
/** Parameter names for dynamic segments */
|
|
48
72
|
params: string[];
|
|
49
73
|
/**
|
|
@@ -89,6 +113,10 @@ type ParallelSlot = {
|
|
|
89
113
|
notFoundPath?: string | null;
|
|
90
114
|
/** Tree position of that convention relative to the slot root. */
|
|
91
115
|
notFoundTreePosition?: number | null;
|
|
116
|
+
/** Every not-found convention from the slot root to its active page, outermost first. */
|
|
117
|
+
notFoundPaths?: string[];
|
|
118
|
+
/** Slot-root-relative tree positions aligned with notFoundPaths. */
|
|
119
|
+
notFoundTreePositions?: number[];
|
|
92
120
|
/** Intercepting routes within this slot */
|
|
93
121
|
interceptingRoutes: InterceptingRoute[];
|
|
94
122
|
/**
|
|
@@ -191,6 +219,18 @@ export type AppRoute = {
|
|
|
191
219
|
unauthorizedTreePosition?: number | null;
|
|
192
220
|
/** Unauthorized component paths per layout level (aligned with layouts array). */
|
|
193
221
|
unauthorizedPaths: (string | null)[];
|
|
222
|
+
/**
|
|
223
|
+
* Not-found, forbidden and unauthorized component paths for every segment
|
|
224
|
+
* from app/ to the route's directory, including segments without a layout,
|
|
225
|
+
* aligned with the matching tree positions. A layout's notFound() is caught
|
|
226
|
+
* by the deepest of these above the layout's own segment.
|
|
227
|
+
*/
|
|
228
|
+
segmentNotFoundPaths?: string[];
|
|
229
|
+
segmentNotFoundTreePositions?: number[];
|
|
230
|
+
segmentForbiddenPaths?: string[];
|
|
231
|
+
segmentForbiddenTreePositions?: number[];
|
|
232
|
+
segmentUnauthorizedPaths?: string[];
|
|
233
|
+
segmentUnauthorizedTreePositions?: number[];
|
|
194
234
|
/**
|
|
195
235
|
* Filesystem segments from app/ root to the route's directory.
|
|
196
236
|
* Includes route groups and dynamic segments (as template strings like "[id]").
|
|
@@ -275,7 +315,7 @@ type RouteManifestRouteHandler = {
|
|
|
275
315
|
routeId: string;
|
|
276
316
|
pattern: string;
|
|
277
317
|
};
|
|
278
|
-
type RouteManifestLayout = {
|
|
318
|
+
export type RouteManifestLayout = {
|
|
279
319
|
id: string;
|
|
280
320
|
treePath: string;
|
|
281
321
|
patternParts: readonly string[];
|
|
@@ -131,7 +131,7 @@ function createStaticSegmentGraph(routes) {
|
|
|
131
131
|
treePath
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
addRouteManifestSegmentBoundaryFacts({
|
|
135
135
|
boundaries,
|
|
136
136
|
route
|
|
137
137
|
});
|
|
@@ -303,19 +303,42 @@ function addRouteManifestBoundaryFacts(input) {
|
|
|
303
303
|
addRouteManifestBoundaryFact(input, "forbidden", input.route.forbiddenPaths[input.layoutIndex]);
|
|
304
304
|
addRouteManifestBoundaryFact(input, "unauthorized", input.route.unauthorizedPaths[input.layoutIndex]);
|
|
305
305
|
}
|
|
306
|
-
function
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
306
|
+
function addRouteManifestSegmentBoundaryFacts(input) {
|
|
307
|
+
const { route } = input;
|
|
308
|
+
const segmentBoundaries = [
|
|
309
|
+
[
|
|
310
|
+
"error",
|
|
311
|
+
route.errorPaths,
|
|
312
|
+
route.errorTreePositions
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
"notFound",
|
|
316
|
+
route.segmentNotFoundPaths,
|
|
317
|
+
route.segmentNotFoundTreePositions
|
|
318
|
+
],
|
|
319
|
+
[
|
|
320
|
+
"forbidden",
|
|
321
|
+
route.segmentForbiddenPaths,
|
|
322
|
+
route.segmentForbiddenTreePositions
|
|
323
|
+
],
|
|
324
|
+
[
|
|
325
|
+
"unauthorized",
|
|
326
|
+
route.segmentUnauthorizedPaths,
|
|
327
|
+
route.segmentUnauthorizedTreePositions
|
|
328
|
+
]
|
|
329
|
+
];
|
|
330
|
+
for (const [outcome, boundaryPaths, treePositions] of segmentBoundaries) for (const [index, boundaryPath] of (boundaryPaths ?? []).entries()) {
|
|
331
|
+
const treePosition = treePositions?.[index];
|
|
332
|
+
assertRouteManifestBoundaryTreePosition(route, boundaryPath, treePosition);
|
|
333
|
+
const ownerLayoutId = findRouteManifestOwnerLayoutId(route, treePosition);
|
|
311
334
|
if (ownerLayoutId !== null) continue;
|
|
312
|
-
const treePath = createAppRouteGraphTreePath(
|
|
335
|
+
const treePath = createAppRouteGraphTreePath(route.routeSegments, treePosition);
|
|
313
336
|
addRouteManifestBoundaryFact({
|
|
314
337
|
boundaries: input.boundaries,
|
|
315
|
-
route
|
|
338
|
+
route,
|
|
316
339
|
layoutId: ownerLayoutId,
|
|
317
340
|
treePath
|
|
318
|
-
},
|
|
341
|
+
}, outcome, boundaryPath);
|
|
319
342
|
}
|
|
320
343
|
}
|
|
321
344
|
function addRouteManifestBoundaryFact(input, outcome, boundaryPath) {
|
|
@@ -458,14 +481,11 @@ function discoverSlotSubRoutes(routes, matcher, ghostParents = []) {
|
|
|
458
481
|
const subPage = slotPages.get(slot.key);
|
|
459
482
|
if (subPage !== void 0) {
|
|
460
483
|
const configLayoutPaths = findSlotConfigLayoutPaths(slot.ownerDir, subPage, matcher);
|
|
461
|
-
const notFoundBoundary = findSlotNotFoundBoundary(slot.ownerDir, subPage, matcher);
|
|
462
484
|
return withSlotLoadingEntries({
|
|
463
485
|
...slot,
|
|
464
486
|
pagePath: subPage,
|
|
465
487
|
configLayoutPaths,
|
|
466
488
|
configLayoutTreePositions: findSlotConfigLayoutTreePositions(slot.ownerDir, configLayoutPaths),
|
|
467
|
-
notFoundPath: notFoundBoundary.path,
|
|
468
|
-
notFoundTreePosition: notFoundBoundary.treePosition,
|
|
469
489
|
routeSegments: rawSegments
|
|
470
490
|
}, subPage, matcher);
|
|
471
491
|
}
|
|
@@ -547,14 +567,11 @@ function discoverSlotSubRoutes(routes, matcher, ghostParents = []) {
|
|
|
547
567
|
const subSlots = parentRoute.parallelSlots.map((slot) => {
|
|
548
568
|
const subPage = slotPages.get(slot.key);
|
|
549
569
|
const configLayoutPaths = findSlotConfigLayoutPaths(slot.ownerDir, subPage ?? null, matcher);
|
|
550
|
-
const notFoundBoundary = findSlotNotFoundBoundary(slot.ownerDir, subPage ?? null, matcher);
|
|
551
570
|
return withSlotLoadingEntries({
|
|
552
571
|
...slot,
|
|
553
572
|
pagePath: subPage || null,
|
|
554
573
|
configLayoutPaths,
|
|
555
574
|
configLayoutTreePositions: findSlotConfigLayoutTreePositions(slot.ownerDir, configLayoutPaths),
|
|
556
|
-
notFoundPath: notFoundBoundary.path,
|
|
557
|
-
notFoundTreePosition: notFoundBoundary.treePosition,
|
|
558
575
|
routeSegments: subPage ? rawSegments : null
|
|
559
576
|
}, subPage ?? null, matcher);
|
|
560
577
|
});
|
|
@@ -593,6 +610,12 @@ function discoverSlotSubRoutes(routes, matcher, ghostParents = []) {
|
|
|
593
610
|
unauthorizedPath: parentRoute.unauthorizedPath,
|
|
594
611
|
unauthorizedTreePosition: parentRoute.unauthorizedTreePosition,
|
|
595
612
|
unauthorizedPaths: parentRoute.unauthorizedPaths,
|
|
613
|
+
segmentNotFoundPaths: parentRoute.segmentNotFoundPaths,
|
|
614
|
+
segmentNotFoundTreePositions: parentRoute.segmentNotFoundTreePositions,
|
|
615
|
+
segmentForbiddenPaths: parentRoute.segmentForbiddenPaths,
|
|
616
|
+
segmentForbiddenTreePositions: parentRoute.segmentForbiddenTreePositions,
|
|
617
|
+
segmentUnauthorizedPaths: parentRoute.segmentUnauthorizedPaths,
|
|
618
|
+
segmentUnauthorizedTreePositions: parentRoute.segmentUnauthorizedTreePositions,
|
|
596
619
|
routeSegments: [...parentRoute.routeSegments, ...rawSegments],
|
|
597
620
|
childrenRouteSegments: childrenDefault ? parentRoute.routeSegments : void 0,
|
|
598
621
|
templateTreePositions: parentRoute.templateTreePositions,
|
|
@@ -680,52 +703,52 @@ function findSlotConfigLayoutTreePositions(slotDir, layoutPaths) {
|
|
|
680
703
|
});
|
|
681
704
|
}
|
|
682
705
|
function findSlotLoadingEntries(slotDir, pagePath, matcher) {
|
|
706
|
+
return findSlotSegmentFileEntries(slotDir, pagePath, "loading", matcher);
|
|
707
|
+
}
|
|
708
|
+
/** Find a convention file in each directory from the slot root to the page, outermost first. */
|
|
709
|
+
function findSlotSegmentFileEntries(slotDir, pagePath, fileName, matcher) {
|
|
683
710
|
const pageDir = pagePath ? path.dirname(pagePath) : slotDir;
|
|
684
711
|
if (pageDir !== slotDir && !pageDir.startsWith(`${slotDir}${path.sep}`)) return [];
|
|
685
712
|
const relativeDir = path.relative(slotDir, pageDir);
|
|
686
713
|
const segments = relativeDir ? relativeDir.split(path.sep).filter(Boolean) : [];
|
|
687
|
-
const
|
|
714
|
+
const entries = [];
|
|
688
715
|
let currentDir = slotDir;
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
691
|
-
path:
|
|
716
|
+
const rootEntry = findFile(currentDir, fileName, matcher);
|
|
717
|
+
if (rootEntry) entries.push({
|
|
718
|
+
path: rootEntry,
|
|
692
719
|
treePosition: 0
|
|
693
720
|
});
|
|
694
721
|
for (let index = 0; index < segments.length; index++) {
|
|
695
722
|
currentDir = path.join(currentDir, segments[index]);
|
|
696
|
-
const
|
|
697
|
-
if (
|
|
698
|
-
path:
|
|
723
|
+
const entry = findFile(currentDir, fileName, matcher);
|
|
724
|
+
if (entry) entries.push({
|
|
725
|
+
path: entry,
|
|
699
726
|
treePosition: index + 1
|
|
700
727
|
});
|
|
701
728
|
}
|
|
702
|
-
return
|
|
729
|
+
return entries;
|
|
703
730
|
}
|
|
704
731
|
function withSlotLoadingEntries(slot, pagePath, matcher) {
|
|
705
732
|
const loadingEntries = findSlotLoadingEntries(slot.ownerDir, pagePath, matcher);
|
|
706
733
|
return {
|
|
707
734
|
...slot,
|
|
708
735
|
loadingPaths: loadingEntries.map((entry) => entry.path),
|
|
709
|
-
loadingTreePositions: loadingEntries.map((entry) => entry.treePosition)
|
|
736
|
+
loadingTreePositions: loadingEntries.map((entry) => entry.treePosition),
|
|
737
|
+
...findSlotNotFoundFields(slot.ownerDir, pagePath, matcher)
|
|
710
738
|
};
|
|
711
739
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
path: boundaryPath,
|
|
720
|
-
treePosition: relativeDir ? relativeDir.split(path.sep).filter(Boolean).length : 0
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
if (dir === slotDir) break;
|
|
724
|
-
dir = path.dirname(dir);
|
|
725
|
-
}
|
|
740
|
+
/**
|
|
741
|
+
* Every not-found convention on the slot's active branch, plus the nearest one,
|
|
742
|
+
* which supplies the slot's not-found metadata.
|
|
743
|
+
*/
|
|
744
|
+
function findSlotNotFoundFields(slotDir, pagePath, matcher) {
|
|
745
|
+
const entries = findSlotSegmentFileEntries(slotDir, pagePath, "not-found", matcher);
|
|
746
|
+
const nearest = entries.at(-1);
|
|
726
747
|
return {
|
|
727
|
-
|
|
728
|
-
|
|
748
|
+
notFoundPath: nearest?.path ?? null,
|
|
749
|
+
notFoundTreePosition: nearest?.treePosition ?? null,
|
|
750
|
+
notFoundPaths: entries.map((entry) => entry.path),
|
|
751
|
+
notFoundTreePositions: entries.map((entry) => entry.treePosition)
|
|
729
752
|
};
|
|
730
753
|
}
|
|
731
754
|
/**
|
|
@@ -801,6 +824,10 @@ function directoryToAppRoute(dir, appDir, matcher, pagePath, routePath, includeN
|
|
|
801
824
|
const notFoundPaths = discoverBoundaryFilePerLayout(layouts, "not-found", matcher);
|
|
802
825
|
const forbiddenPaths = discoverBoundaryFilePerLayout(layouts, "forbidden", matcher);
|
|
803
826
|
const unauthorizedPaths = discoverBoundaryFilePerLayout(layouts, "unauthorized", matcher);
|
|
827
|
+
const discoverPageSegmentBoundaryFiles = (fileName) => pagePath === null && routePath !== null ? [] : discoverSegmentBoundaryFiles(segments, appDir, fileName, matcher);
|
|
828
|
+
const segmentNotFounds = discoverPageSegmentBoundaryFiles("not-found");
|
|
829
|
+
const segmentForbiddens = discoverPageSegmentBoundaryFiles("forbidden");
|
|
830
|
+
const segmentUnauthorizeds = discoverPageSegmentBoundaryFiles("unauthorized");
|
|
804
831
|
const parallelSlots = discoverInheritedParallelSlots(segments, appDir, routeDir, matcher, includeNestedOnlySlots);
|
|
805
832
|
return {
|
|
806
833
|
ids: createAppRouteSemanticIds({
|
|
@@ -833,6 +860,12 @@ function directoryToAppRoute(dir, appDir, matcher, pagePath, routePath, includeN
|
|
|
833
860
|
forbiddenTreePosition: forbiddenEntry?.treePosition ?? null,
|
|
834
861
|
unauthorizedPath,
|
|
835
862
|
unauthorizedTreePosition: unauthorizedEntry?.treePosition ?? null,
|
|
863
|
+
segmentNotFoundPaths: segmentNotFounds.map((entry) => entry.path),
|
|
864
|
+
segmentNotFoundTreePositions: segmentNotFounds.map((entry) => entry.treePosition),
|
|
865
|
+
segmentForbiddenPaths: segmentForbiddens.map((entry) => entry.path),
|
|
866
|
+
segmentForbiddenTreePositions: segmentForbiddens.map((entry) => entry.treePosition),
|
|
867
|
+
segmentUnauthorizedPaths: segmentUnauthorizeds.map((entry) => entry.path),
|
|
868
|
+
segmentUnauthorizedTreePositions: segmentUnauthorizeds.map((entry) => entry.treePosition),
|
|
836
869
|
unauthorizedPaths,
|
|
837
870
|
routeSegments: segments,
|
|
838
871
|
templateTreePositions,
|
|
@@ -1034,6 +1067,24 @@ function discoverBoundaryFileEntry(segments, appDir, fileName, matcher) {
|
|
|
1034
1067
|
return null;
|
|
1035
1068
|
}
|
|
1036
1069
|
/**
|
|
1070
|
+
* Discover boundary files (not-found, forbidden, unauthorized) by segment tree
|
|
1071
|
+
* position. As with error.tsx, Next.js wraps each segment's children in its
|
|
1072
|
+
* boundary whether or not the segment has a layout.
|
|
1073
|
+
*/
|
|
1074
|
+
function discoverSegmentBoundaryFiles(segments, appDir, fileName, matcher) {
|
|
1075
|
+
const boundaries = [];
|
|
1076
|
+
let currentDir = appDir;
|
|
1077
|
+
for (let index = 0; index <= segments.length; index++) {
|
|
1078
|
+
if (index > 0) currentDir = path.join(currentDir, segments[index - 1]);
|
|
1079
|
+
const boundary = findFile(currentDir, fileName, matcher);
|
|
1080
|
+
if (boundary) boundaries.push({
|
|
1081
|
+
path: boundary,
|
|
1082
|
+
treePosition: index
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
return boundaries;
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1037
1088
|
* Discover boundary files (not-found, forbidden, unauthorized) at each layout directory.
|
|
1038
1089
|
* Returns an array aligned with the layouts array, where each entry is the boundary
|
|
1039
1090
|
* file at that layout's directory, or null if none exists there.
|
|
@@ -1271,7 +1322,6 @@ function discoverParallelSlots(dir, appDir, matcher, includeNestedOnlySlots = fa
|
|
|
1271
1322
|
const ownerTreePath = createAppRouteGraphTreePath(ownerSegments, ownerSegments.length);
|
|
1272
1323
|
const configLayoutPaths = findSlotConfigLayoutPaths(slotDir, pagePath, matcher);
|
|
1273
1324
|
const loadingEntries = findSlotLoadingEntries(slotDir, pagePath, matcher);
|
|
1274
|
-
const notFoundBoundary = findSlotNotFoundBoundary(slotDir, pagePath, matcher);
|
|
1275
1325
|
slots.push({
|
|
1276
1326
|
id: createAppRouteGraphSlotId(slotName, ownerTreePath),
|
|
1277
1327
|
key: `${slotName}@${path.relative(appDir, slotDir)}`,
|
|
@@ -1289,8 +1339,7 @@ function discoverParallelSlots(dir, appDir, matcher, includeNestedOnlySlots = fa
|
|
|
1289
1339
|
loadingPaths: loadingEntries.map((loading) => loading.path),
|
|
1290
1340
|
loadingTreePositions: loadingEntries.map((loading) => loading.treePosition),
|
|
1291
1341
|
errorPath: findFile(slotDir, "error", matcher),
|
|
1292
|
-
|
|
1293
|
-
notFoundTreePosition: notFoundBoundary.treePosition,
|
|
1342
|
+
...findSlotNotFoundFields(slotDir, pagePath, matcher),
|
|
1294
1343
|
interceptingRoutes,
|
|
1295
1344
|
layoutIndex: -1,
|
|
1296
1345
|
routeSegments: pagePath ? [] : null
|
|
@@ -1440,7 +1489,7 @@ function findOwnerRouteForDir(dir, appDir, routes, routesByDir) {
|
|
|
1440
1489
|
* Recursively scan a directory tree for page.tsx files that are inside
|
|
1441
1490
|
* intercepting route directories.
|
|
1442
1491
|
*/
|
|
1443
|
-
function scanForInterceptingPages(currentDir, slotRootDir, routeDir, appDir, results, matcher, parentLoadingEntries = []) {
|
|
1492
|
+
function scanForInterceptingPages(currentDir, slotRootDir, routeDir, appDir, results, matcher, parentLoadingEntries = [], parentLayoutPaths = []) {
|
|
1444
1493
|
if (!fs.existsSync(currentDir)) return;
|
|
1445
1494
|
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
1446
1495
|
for (const entry of entries) {
|
|
@@ -1450,13 +1499,14 @@ function scanForInterceptingPages(currentDir, slotRootDir, routeDir, appDir, res
|
|
|
1450
1499
|
const interceptDir = path.join(currentDir, entry.name);
|
|
1451
1500
|
if (interceptMatch) {
|
|
1452
1501
|
const restOfName = entry.name.slice(interceptMatch.prefix.length);
|
|
1453
|
-
collectInterceptingPages(interceptDir, interceptDir, interceptMatch.convention, restOfName, routeDir, appDir, currentDir, slotRootDir, results, matcher,
|
|
1502
|
+
collectInterceptingPages(interceptDir, interceptDir, interceptMatch.convention, restOfName, routeDir, appDir, currentDir, slotRootDir, results, matcher, parentLayoutPaths, parentLoadingEntries, path.relative(slotRootDir, currentDir).split(path.sep).filter(Boolean).length);
|
|
1454
1503
|
} else {
|
|
1504
|
+
const layout = findFile(interceptDir, "layout", matcher);
|
|
1455
1505
|
const loading = findFile(interceptDir, "loading", matcher);
|
|
1456
1506
|
scanForInterceptingPages(interceptDir, slotRootDir, routeDir, appDir, results, matcher, loading ? [...parentLoadingEntries, {
|
|
1457
1507
|
path: loading,
|
|
1458
1508
|
treePosition: path.relative(slotRootDir, interceptDir).split(path.sep).filter(Boolean).length
|
|
1459
|
-
}] : parentLoadingEntries);
|
|
1509
|
+
}] : parentLoadingEntries, layout ? [...parentLayoutPaths, layout] : parentLayoutPaths);
|
|
1460
1510
|
}
|
|
1461
1511
|
}
|
|
1462
1512
|
}
|
|
@@ -1486,7 +1536,15 @@ function collectInterceptingPages(currentDir, interceptRoot, convention, interce
|
|
|
1486
1536
|
const targetPattern = computeInterceptTarget(convention, interceptSegment, currentDir, interceptRoot, routeDir, appDir);
|
|
1487
1537
|
if (targetPattern) {
|
|
1488
1538
|
const sourceMatchPattern = computeInterceptSourceMatchPattern(interceptParentDir, appDir);
|
|
1489
|
-
const
|
|
1539
|
+
const notFoundTreePositionOffset = slotRootDir ? 0 : 1;
|
|
1540
|
+
const notFoundFields = findSlotNotFoundFields(slotRootDir ?? interceptRoot, page, matcher);
|
|
1541
|
+
const findInterceptBoundaries = (fileName) => findSlotSegmentFileEntries(slotRootDir ?? interceptRoot, page, fileName, matcher).map((entry) => ({
|
|
1542
|
+
path: entry.path,
|
|
1543
|
+
treePosition: entry.treePosition + notFoundTreePositionOffset
|
|
1544
|
+
}));
|
|
1545
|
+
const forbiddenBoundaries = findInterceptBoundaries("forbidden");
|
|
1546
|
+
const unauthorizedBoundaries = findInterceptBoundaries("unauthorized");
|
|
1547
|
+
const errorBoundaries = findInterceptBoundaries("error");
|
|
1490
1548
|
const slotParentSegments = slotRootDir ? path.relative(slotRootDir, interceptParentDir).split(path.sep).filter(Boolean) : [];
|
|
1491
1549
|
const branchSegments = [
|
|
1492
1550
|
...slotParentSegments,
|
|
@@ -1498,7 +1556,9 @@ function collectInterceptingPages(currentDir, interceptRoot, convention, interce
|
|
|
1498
1556
|
convention,
|
|
1499
1557
|
layoutPaths: [...layoutPaths],
|
|
1500
1558
|
layoutSegments: layoutPaths.map((layoutPath) => {
|
|
1501
|
-
const
|
|
1559
|
+
const layoutDir = path.dirname(layoutPath);
|
|
1560
|
+
if (slotRootDir && layoutDir !== interceptRoot && !layoutDir.startsWith(`${interceptRoot}${path.sep}`)) return path.relative(slotRootDir, layoutDir).split(path.sep).filter(Boolean);
|
|
1561
|
+
const relativeDir = path.relative(interceptRoot, layoutDir);
|
|
1502
1562
|
return [
|
|
1503
1563
|
...slotParentSegments,
|
|
1504
1564
|
interceptSegment,
|
|
@@ -1508,8 +1568,20 @@ function collectInterceptingPages(currentDir, interceptRoot, convention, interce
|
|
|
1508
1568
|
loadingPaths: loadingEntries.map((loading) => loading.path),
|
|
1509
1569
|
loadingTreePositions: loadingEntries.map((loading) => loading.treePosition),
|
|
1510
1570
|
notFoundBranchSegments: branchSegments,
|
|
1511
|
-
notFoundPath:
|
|
1512
|
-
notFoundTreePosition:
|
|
1571
|
+
notFoundPath: notFoundFields.notFoundPath,
|
|
1572
|
+
notFoundTreePosition: notFoundFields.notFoundTreePosition == null ? null : notFoundFields.notFoundTreePosition + notFoundTreePositionOffset,
|
|
1573
|
+
notFoundPaths: notFoundFields.notFoundPaths,
|
|
1574
|
+
notFoundTreePositions: notFoundFields.notFoundTreePositions?.map((treePosition) => treePosition + notFoundTreePositionOffset),
|
|
1575
|
+
forbiddenPath: forbiddenBoundaries.at(-1)?.path ?? null,
|
|
1576
|
+
forbiddenTreePosition: forbiddenBoundaries.at(-1)?.treePosition ?? null,
|
|
1577
|
+
forbiddenPaths: forbiddenBoundaries.map((boundary) => boundary.path),
|
|
1578
|
+
forbiddenTreePositions: forbiddenBoundaries.map((boundary) => boundary.treePosition),
|
|
1579
|
+
unauthorizedPath: unauthorizedBoundaries.at(-1)?.path ?? null,
|
|
1580
|
+
unauthorizedTreePosition: unauthorizedBoundaries.at(-1)?.treePosition ?? null,
|
|
1581
|
+
unauthorizedPaths: unauthorizedBoundaries.map((boundary) => boundary.path),
|
|
1582
|
+
unauthorizedTreePositions: unauthorizedBoundaries.map((boundary) => boundary.treePosition),
|
|
1583
|
+
errorPaths: errorBoundaries.map((boundary) => boundary.path),
|
|
1584
|
+
errorTreePositions: errorBoundaries.map((boundary) => boundary.treePosition),
|
|
1513
1585
|
targetPattern: targetPattern.pattern,
|
|
1514
1586
|
sourceMatchPattern,
|
|
1515
1587
|
pagePath: page,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GraphVersion, RouteManifest, RouteManifestInterception, RouteManifestLayout, RouteManifestRootBoundary, RouteManifestRoute, RouteManifestSlotBinding } from "./app-route-graph.js";
|
|
2
|
+
//#region src/routing/browser-route-manifest.d.ts
|
|
3
|
+
export type BrowserRouteManifestRoute = Pick<RouteManifestRoute, "id" | "patternParts" | "isDynamic" | "paramNames" | "rootBoundaryId" | "pageId" | "layoutIds" | "slotIds">;
|
|
4
|
+
type BrowserRouteManifestLayout = Pick<RouteManifestLayout, "id" | "patternParts" | "rootBoundaryId">;
|
|
5
|
+
type BrowserRouteManifestSlotBinding = Pick<RouteManifestSlotBinding, "id" | "routeId" | "slotId" | "ownerLayoutId" | "state" | "routeSegments" | "slotPatternParts" | "slotParamNames">;
|
|
6
|
+
export type BrowserRouteManifestInterception = Pick<RouteManifestInterception, "id" | "sourcePatternParts" | "targetPatternParts" | "slotId" | "ownerLayoutId" | "targetRouteId">;
|
|
7
|
+
type BrowserRouteManifestRootBoundary = Pick<RouteManifestRootBoundary, "id" | "treePath">;
|
|
8
|
+
/**
|
|
9
|
+
* The part of the RouteManifest the browser navigation runtime reads: the
|
|
10
|
+
* maps and fields the navigation planner, optimistic routing and interception
|
|
11
|
+
* context resolution use.
|
|
12
|
+
*/
|
|
13
|
+
export type BrowserRouteManifest = {
|
|
14
|
+
graphVersion: GraphVersion;
|
|
15
|
+
segmentGraph: {
|
|
16
|
+
routes: ReadonlyMap<string, BrowserRouteManifestRoute>;
|
|
17
|
+
layouts: ReadonlyMap<string, BrowserRouteManifestLayout>;
|
|
18
|
+
slotBindings: ReadonlyMap<string, BrowserRouteManifestSlotBinding>;
|
|
19
|
+
interceptions: ReadonlyMap<string, BrowserRouteManifestInterception>;
|
|
20
|
+
interceptionsBySlotId: ReadonlyMap<string, readonly BrowserRouteManifestInterception[]>;
|
|
21
|
+
rootBoundaries: ReadonlyMap<string, BrowserRouteManifestRootBoundary>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* JSON form of `BrowserRouteManifest`. Every map is keyed by its values' `id`,
|
|
26
|
+
* so maps travel as arrays of values in map order. A route omits `id` when it
|
|
27
|
+
* is `route:` plus its pattern, and `interceptionsBySlotId` lists interception
|
|
28
|
+
* ids instead of repeating the interceptions.
|
|
29
|
+
*/
|
|
30
|
+
export type BrowserRouteManifestWire = {
|
|
31
|
+
graphVersion: string;
|
|
32
|
+
routes: (Omit<BrowserRouteManifestRoute, "id"> & {
|
|
33
|
+
id?: string;
|
|
34
|
+
})[];
|
|
35
|
+
layouts: BrowserRouteManifestLayout[];
|
|
36
|
+
slotBindings: BrowserRouteManifestSlotBinding[];
|
|
37
|
+
interceptions: BrowserRouteManifestInterception[];
|
|
38
|
+
interceptionsBySlotId: [slotId: string, interceptionIds: string[]][];
|
|
39
|
+
rootBoundaries: BrowserRouteManifestRootBoundary[];
|
|
40
|
+
};
|
|
41
|
+
export declare function toBrowserRouteManifestWire(routeManifest: RouteManifest): BrowserRouteManifestWire;
|
|
42
|
+
export declare function decodeBrowserRouteManifest(wire: BrowserRouteManifestWire): BrowserRouteManifest;
|
|
43
|
+
//#endregion
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { buildOptimisticRouteTrie } from "./optimistic-route-trie.js";
|
|
2
|
+
//#region src/routing/browser-route-manifest.ts
|
|
3
|
+
function createRouteIdFromPatternParts(patternParts) {
|
|
4
|
+
return `route:/${patternParts.join("/")}`;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Route matching precedence of one pattern part, lower wins: the URL ending
|
|
8
|
+
* here, then a static, dynamic, catch-all and optional catch-all part.
|
|
9
|
+
*/
|
|
10
|
+
function patternPartRank(part) {
|
|
11
|
+
if (part === void 0) return 0;
|
|
12
|
+
if (!part.startsWith(":")) return 1;
|
|
13
|
+
if (part.endsWith("+")) return 3;
|
|
14
|
+
if (part.endsWith("*")) return 4;
|
|
15
|
+
return 2;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether the router sends a URL pathname that both patterns match to the
|
|
19
|
+
* route handler: it wins at the first part whose kind differs. Two patterns
|
|
20
|
+
* that never differ would be the same route shape, which cannot hold both a
|
|
21
|
+
* handler and a page.
|
|
22
|
+
*/
|
|
23
|
+
function routeHandlerOutranks(handler, rendered) {
|
|
24
|
+
for (let index = 0;; index++) {
|
|
25
|
+
const handlerRank = patternPartRank(handler[index]);
|
|
26
|
+
const renderedRank = patternPartRank(rendered[index]);
|
|
27
|
+
if (handlerRank !== renderedRank) return handlerRank < renderedRank;
|
|
28
|
+
if (handlerRank === 0 || handlerRank >= 3) return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether the optimistic trie of the rendered routes predicts a rendered
|
|
33
|
+
* route that the route handler outranks for some URL pathname the handler
|
|
34
|
+
* pattern matches. The trie match descends one path and only backtracks to a
|
|
35
|
+
* catch-all on its way up, so this follows that path for every URL: a param
|
|
36
|
+
* segment either names one of the node's static children or none of them,
|
|
37
|
+
* and a catch-all takes any number of such segments.
|
|
38
|
+
*/
|
|
39
|
+
function triePredictsOutrankedRoute(trie, handler) {
|
|
40
|
+
const lastPart = handler.at(-1);
|
|
41
|
+
const isCatchAll = lastPart?.startsWith(":") === true && /[+*]$/.test(lastPart);
|
|
42
|
+
const fixedLength = isCatchAll ? handler.length - 1 : handler.length;
|
|
43
|
+
const minLength = lastPart?.endsWith("+") === true ? handler.length : fixedLength;
|
|
44
|
+
const predict = (route) => route === null ? {
|
|
45
|
+
outranked: false,
|
|
46
|
+
unmatched: true
|
|
47
|
+
} : {
|
|
48
|
+
outranked: routeHandlerOutranks(handler, route.patternParts),
|
|
49
|
+
unmatched: false
|
|
50
|
+
};
|
|
51
|
+
const afterOtherSegment = (node, depth) => {
|
|
52
|
+
const dynamic = node.dynamicChild ? predictFrom(node.dynamicChild.node, depth) : {
|
|
53
|
+
outranked: false,
|
|
54
|
+
unmatched: true
|
|
55
|
+
};
|
|
56
|
+
if (!dynamic.unmatched) return dynamic;
|
|
57
|
+
const fallback = predict(node.catchAllChild?.route ?? node.optionalCatchAllChild?.route ?? null);
|
|
58
|
+
return {
|
|
59
|
+
outranked: dynamic.outranked || fallback.outranked,
|
|
60
|
+
unmatched: fallback.unmatched
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const predictFrom = (node, depth) => {
|
|
64
|
+
const predictions = {
|
|
65
|
+
outranked: false,
|
|
66
|
+
unmatched: false
|
|
67
|
+
};
|
|
68
|
+
const add = (more) => {
|
|
69
|
+
predictions.outranked ||= more.outranked;
|
|
70
|
+
predictions.unmatched ||= more.unmatched;
|
|
71
|
+
};
|
|
72
|
+
if (isCatchAll ? depth >= minLength : depth === fixedLength) add(predict(node.route ?? node.optionalCatchAllChild?.route ?? null));
|
|
73
|
+
if (depth < fixedLength && !handler[depth].startsWith(":")) {
|
|
74
|
+
const child = node.staticChildren.get(handler[depth]);
|
|
75
|
+
add(child ? predictFrom(child, depth + 1) : afterOtherSegment(node, depth + 1));
|
|
76
|
+
} else if (depth < fixedLength || isCatchAll) {
|
|
77
|
+
for (const child of node.staticChildren.values()) add(predictFrom(child, depth + 1));
|
|
78
|
+
add(afterOtherSegment(node, depth + 1));
|
|
79
|
+
}
|
|
80
|
+
return predictions;
|
|
81
|
+
};
|
|
82
|
+
return predictFrom(trie, 0).outranked;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The browser only needs a route handler where the optimistic route trie of
|
|
86
|
+
* the rendered routes would predict a route the handler outranks: the matcher
|
|
87
|
+
* must find the handler there instead of rendering that route's shell. Any
|
|
88
|
+
* other handler URL matches no rendered route on the client, or one the
|
|
89
|
+
* router prefers, and its non-Flight response already turns the navigation
|
|
90
|
+
* into a document load, so shipping its path would only publish the app's
|
|
91
|
+
* API surface (issue #3624).
|
|
92
|
+
*/
|
|
93
|
+
function selectBrowserRoutes(routes) {
|
|
94
|
+
const allRoutes = [...routes];
|
|
95
|
+
const renderedTrie = buildOptimisticRouteTrie(allRoutes.filter((route) => route.routeHandlerId === null));
|
|
96
|
+
return allRoutes.filter((route) => route.routeHandlerId === null || triePredictsOutrankedRoute(renderedTrie, route.patternParts));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The graph records the browser receives: the shipped routes, the rendered
|
|
100
|
+
* routes' slot bindings, and the layouts and root boundaries those and the
|
|
101
|
+
* interceptions reach. A shipped route handler only stops an optimistic
|
|
102
|
+
* match, and its non-Flight response never renders a tree, so it ships as a
|
|
103
|
+
* bare pattern; its layouts, slots and root boundary would only name its
|
|
104
|
+
* directories.
|
|
105
|
+
*/
|
|
106
|
+
function selectBrowserGraph(graph) {
|
|
107
|
+
const routes = selectBrowserRoutes(graph.routes.values()).map((route) => route.routeHandlerId === null ? route : {
|
|
108
|
+
...route,
|
|
109
|
+
layoutIds: [],
|
|
110
|
+
rootBoundaryId: null,
|
|
111
|
+
slotIds: []
|
|
112
|
+
});
|
|
113
|
+
const renderedRouteIds = new Set(routes.filter((route) => route.routeHandlerId === null).map((route) => route.id));
|
|
114
|
+
const slotBindings = [...graph.slotBindings.values()].filter((binding) => renderedRouteIds.has(binding.routeId));
|
|
115
|
+
const layoutIds = /* @__PURE__ */ new Set([
|
|
116
|
+
...routes.flatMap((route) => route.layoutIds),
|
|
117
|
+
...slotBindings.flatMap((binding) => binding.ownerLayoutId ?? []),
|
|
118
|
+
...[...graph.interceptions.values()].flatMap((interception) => interception.ownerLayoutId ?? [])
|
|
119
|
+
]);
|
|
120
|
+
const layouts = [...graph.layouts.values()].filter((layout) => layoutIds.has(layout.id));
|
|
121
|
+
const rootBoundaryIds = new Set([...routes, ...layouts].flatMap((record) => record.rootBoundaryId ?? []));
|
|
122
|
+
return {
|
|
123
|
+
routes,
|
|
124
|
+
layouts,
|
|
125
|
+
slotBindings,
|
|
126
|
+
rootBoundaries: [...graph.rootBoundaries.values()].filter((rootBoundary) => rootBoundaryIds.has(rootBoundary.id))
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function toBrowserRouteManifestWire(routeManifest) {
|
|
130
|
+
const graph = routeManifest.segmentGraph;
|
|
131
|
+
const browserGraph = selectBrowserGraph(graph);
|
|
132
|
+
return {
|
|
133
|
+
graphVersion: routeManifest.graphVersion,
|
|
134
|
+
routes: browserGraph.routes.map((route) => ({
|
|
135
|
+
...route.id === createRouteIdFromPatternParts(route.patternParts) ? {} : { id: route.id },
|
|
136
|
+
patternParts: route.patternParts,
|
|
137
|
+
isDynamic: route.isDynamic,
|
|
138
|
+
paramNames: route.paramNames,
|
|
139
|
+
rootBoundaryId: route.rootBoundaryId,
|
|
140
|
+
pageId: route.pageId,
|
|
141
|
+
layoutIds: route.layoutIds,
|
|
142
|
+
slotIds: route.slotIds
|
|
143
|
+
})),
|
|
144
|
+
layouts: browserGraph.layouts.map((layout) => ({
|
|
145
|
+
id: layout.id,
|
|
146
|
+
patternParts: layout.patternParts,
|
|
147
|
+
rootBoundaryId: layout.rootBoundaryId
|
|
148
|
+
})),
|
|
149
|
+
slotBindings: browserGraph.slotBindings.map((binding) => ({
|
|
150
|
+
id: binding.id,
|
|
151
|
+
routeId: binding.routeId,
|
|
152
|
+
slotId: binding.slotId,
|
|
153
|
+
ownerLayoutId: binding.ownerLayoutId,
|
|
154
|
+
state: binding.state,
|
|
155
|
+
routeSegments: binding.routeSegments,
|
|
156
|
+
slotPatternParts: binding.slotPatternParts,
|
|
157
|
+
slotParamNames: binding.slotParamNames
|
|
158
|
+
})),
|
|
159
|
+
interceptions: Array.from(graph.interceptions.values(), (interception) => ({
|
|
160
|
+
id: interception.id,
|
|
161
|
+
sourcePatternParts: interception.sourcePatternParts,
|
|
162
|
+
targetPatternParts: interception.targetPatternParts,
|
|
163
|
+
slotId: interception.slotId,
|
|
164
|
+
ownerLayoutId: interception.ownerLayoutId,
|
|
165
|
+
targetRouteId: interception.targetRouteId
|
|
166
|
+
})),
|
|
167
|
+
interceptionsBySlotId: Array.from(graph.interceptionsBySlotId, ([slotId, interceptions]) => [slotId, interceptions.map((interception) => interception.id)]),
|
|
168
|
+
rootBoundaries: browserGraph.rootBoundaries.map((rootBoundary) => ({
|
|
169
|
+
id: rootBoundary.id,
|
|
170
|
+
treePath: rootBoundary.treePath
|
|
171
|
+
}))
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function mapById(values) {
|
|
175
|
+
return new Map(values.map((value) => [value.id, value]));
|
|
176
|
+
}
|
|
177
|
+
function decodeBrowserRouteManifest(wire) {
|
|
178
|
+
const interceptions = mapById(wire.interceptions);
|
|
179
|
+
return {
|
|
180
|
+
graphVersion: wire.graphVersion,
|
|
181
|
+
segmentGraph: {
|
|
182
|
+
routes: mapById(wire.routes.map((route) => ({
|
|
183
|
+
...route,
|
|
184
|
+
id: route.id ?? createRouteIdFromPatternParts(route.patternParts)
|
|
185
|
+
}))),
|
|
186
|
+
layouts: mapById(wire.layouts),
|
|
187
|
+
slotBindings: mapById(wire.slotBindings),
|
|
188
|
+
interceptions,
|
|
189
|
+
interceptionsBySlotId: new Map(wire.interceptionsBySlotId.map(([slotId, interceptionIds]) => [slotId, interceptionIds.flatMap((id) => interceptions.get(id) ?? [])])),
|
|
190
|
+
rootBoundaries: mapById(wire.rootBoundaries)
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { decodeBrowserRouteManifest, toBrowserRouteManifestWire };
|