vinext 0.0.49 → 0.0.50
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/dist/build/client-build-config.js.map +1 -1
- package/dist/build/google-fonts/build-url.js.map +1 -1
- package/dist/build/google-fonts/get-axes.js.map +1 -1
- package/dist/build/google-fonts/sort-variants.js.map +1 -1
- package/dist/build/google-fonts/validate.js.map +1 -1
- package/dist/build/layout-classification.js.map +1 -1
- package/dist/build/nitro-route-rules.js.map +1 -1
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +17 -1
- package/dist/build/prerender.js +77 -16
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.js.map +1 -1
- package/dist/build/route-classification-injector.js.map +1 -1
- package/dist/build/route-classification-manifest.js.map +1 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/server-manifest.js.map +1 -1
- package/dist/build/ssr-manifest.js.map +1 -1
- package/dist/build/standalone.js.map +1 -1
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.js +1 -1
- package/dist/check.js.map +1 -1
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +8 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/instrumentation-client-state.js.map +1 -1
- package/dist/client/validate-module-path.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +5 -1
- package/dist/client/window-next.d.ts +149 -0
- package/dist/client/window-next.js +48 -0
- package/dist/client/window-next.js.map +1 -0
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.js +2 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +3 -1
- package/dist/config/config-matchers.js +5 -4
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +6 -3
- package/dist/config/next-config.js +13 -2
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +13 -5
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +3 -1
- package/dist/entries/app-browser-entry.js +11 -2
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +11 -0
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.js +4 -0
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-entry-helpers.js.map +1 -1
- package/dist/entries/pages-server-entry.js +15 -0
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +76 -18
- package/dist/index.js.map +1 -1
- package/dist/init.js.map +1 -1
- package/dist/plugins/async-hooks-stub.js.map +1 -1
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/instrumentation-client.js.map +1 -1
- package/dist/plugins/og-assets.js.map +1 -1
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/postcss.js.map +1 -1
- package/dist/plugins/rsc-client-reference-loaders.d.ts +7 -0
- package/dist/plugins/rsc-client-reference-loaders.js +48 -0
- package/dist/plugins/rsc-client-reference-loaders.js.map +1 -0
- package/dist/plugins/rsc-client-shim-excludes.js.map +1 -1
- package/dist/plugins/server-externals-manifest.js.map +1 -1
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +48 -5
- package/dist/routing/app-route-graph.js +159 -15
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/route-matching.js.map +1 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/route-validation.js.map +1 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +19 -0
- package/dist/server/app-browser-action-result.js +18 -0
- package/dist/server/app-browser-action-result.js.map +1 -0
- package/dist/server/app-browser-entry.js +91 -48
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-error.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +19 -0
- package/dist/server/app-browser-hydration.js +22 -0
- package/dist/server/app-browser-hydration.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +6 -3
- package/dist/server/app-browser-navigation-controller.js +67 -19
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +17 -17
- package/dist/server/app-browser-state.js +122 -36
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +4 -0
- package/dist/server/app-browser-stream.js +24 -2
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +6 -1
- package/dist/server/app-browser-visible-commit.js +34 -19
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-client-reference-preloader.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +6 -1
- package/dist/server/app-elements-wire.js +17 -1
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-hook-warning-suppression.js.map +1 -1
- package/dist/server/app-middleware.d.ts +1 -1
- package/dist/server/app-middleware.js +4 -9
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-mounted-slots-header.js.map +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +14 -13
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +1 -0
- package/dist/server/app-page-boundary.js +7 -5
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +10 -3
- package/dist/server/app-page-cache.js +42 -23
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +6 -1
- package/dist/server/app-page-dispatch.js +21 -7
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +3 -1
- package/dist/server/app-page-element-builder.js +6 -2
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.js +4 -0
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-method.js.map +1 -1
- package/dist/server/app-page-params.js.map +1 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +11 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.js +2 -1
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.d.ts +2 -0
- package/dist/server/app-page-response.js +15 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +6 -2
- package/dist/server/app-page-route-wiring.js +50 -49
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-segment-state.d.ts +10 -0
- package/dist/server/app-page-segment-state.js +87 -0
- package/dist/server/app-page-segment-state.js.map +1 -0
- package/dist/server/app-page-stream.d.ts +7 -2
- package/dist/server/app-page-stream.js +3 -1
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-post-middleware-context.js.map +1 -1
- package/dist/server/app-prerender-endpoints.js.map +1 -1
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-render-dependency.js.map +1 -1
- package/dist/server/app-request-context.js.map +1 -1
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.js +3 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-policy.js +1 -0
- package/dist/server/app-route-handler-policy.js.map +1 -1
- package/dist/server/app-route-handler-response.js +4 -3
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-route-handler-runtime.js.map +1 -1
- package/dist/server/app-router-entry.js +6 -2
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +5 -2
- package/dist/server/app-rsc-cache-busting.js +40 -19
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-error-handler.js.map +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +10 -1
- package/dist/server/app-rsc-handler.js +51 -17
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +21 -0
- package/dist/server/app-rsc-render-mode.js.map +1 -0
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +7 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -1
- package/dist/server/app-rsc-response-finalizer.js +6 -1
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +16 -2
- package/dist/server/app-server-action-execution.js +79 -23
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +10 -4
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.js.map +1 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-control.js +1 -0
- package/dist/server/cache-control.js.map +1 -1
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/csp.js.map +1 -1
- package/dist/server/dev-error-overlay-store.js.map +1 -1
- package/dist/server/dev-error-overlay.js +5 -0
- package/dist/server/dev-error-overlay.js.map +1 -1
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/dev-origin-check.js.map +1 -1
- package/dist/server/dev-route-files.js.map +1 -1
- package/dist/server/dev-server.js +8 -5
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +79 -0
- package/dist/server/headers.js +101 -0
- package/dist/server/headers.js.map +1 -0
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/image-optimization.d.ts +11 -1
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/implicit-tags.js +2 -1
- package/dist/server/implicit-tags.js.map +1 -1
- package/dist/server/instrumentation-runtime.js.map +1 -1
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +10 -1
- package/dist/server/isr-cache.js +12 -3
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-build-data.js.map +1 -1
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-matcher.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +4 -1
- package/dist/server/middleware-request-headers.js +15 -8
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware-response-headers.d.ts +2 -1
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-response-headers.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +1 -0
- package/dist/server/middleware-runtime.js +6 -3
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +119 -0
- package/dist/server/navigation-planner.js +171 -0
- package/dist/server/navigation-planner.js.map +1 -0
- package/dist/server/navigation-trace.d.ts +12 -2
- package/dist/server/navigation-trace.js +13 -1
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/next-error-digest.d.ts +3 -2
- package/dist/server/next-error-digest.js +4 -2
- package/dist/server/next-error-digest.js.map +1 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-media-type.js.map +1 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.js +5 -2
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.js +3 -2
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prerender-work-unit-setup.js +1 -1
- package/dist/server/prerender-work-unit-setup.js.map +1 -1
- package/dist/server/prod-server.js +35 -13
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +1 -13
- package/dist/server/request-pipeline.js +3 -25
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/rsc-stream-hints.js.map +1 -1
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.js +3 -3
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/socket-error-backstop.js.map +1 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/worker-utils.d.ts +0 -7
- package/dist/server/worker-utils.js +3 -2
- package/dist/server/worker-utils.js.map +1 -1
- package/dist/shims/amp.js.map +1 -1
- package/dist/shims/app.d.ts +37 -4
- package/dist/shims/app.js +50 -1
- package/dist/shims/app.js.map +1 -0
- package/dist/shims/cache-for-request.js.map +1 -1
- package/dist/shims/cache-runtime.js +20 -8
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +15 -3
- package/dist/shims/cache.js +99 -15
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-hook-error.js.map +1 -1
- package/dist/shims/compat-router.js.map +1 -1
- package/dist/shims/config.js.map +1 -1
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/dynamic.d.ts +18 -10
- package/dist/shims/dynamic.js +107 -51
- package/dist/shims/dynamic.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +35 -6
- package/dist/shims/error-boundary.js +118 -33
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +22 -1
- package/dist/shims/fetch-cache.js +124 -13
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.js +3 -1
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +3 -1
- package/dist/shims/head.js +28 -16
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +4 -2
- package/dist/shims/headers.js +24 -7
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-context.js.map +1 -1
- package/dist/shims/i18n-state.js.map +1 -1
- package/dist/shims/image-config.d.ts +14 -1
- package/dist/shims/image-config.js +24 -1
- package/dist/shims/image-config.js.map +1 -1
- package/dist/shims/image.js +15 -2
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/als-registry.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +1 -0
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/internal/cookie-serialize.js.map +1 -1
- package/dist/shims/internal/make-hanging-promise.d.ts +1 -1
- package/dist/shims/internal/make-hanging-promise.js +1 -1
- package/dist/shims/internal/make-hanging-promise.js.map +1 -1
- package/dist/shims/internal/parse-cookie-header.js.map +1 -1
- package/dist/shims/internal/utils.js.map +1 -1
- package/dist/shims/internal/work-unit-async-storage.js +2 -2
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
- package/dist/shims/layout-segment-context.js.map +1 -1
- package/dist/shims/legacy-image.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +34 -0
- package/dist/shims/link-prefetch.js +40 -0
- package/dist/shims/link-prefetch.js.map +1 -0
- package/dist/shims/link.d.ts +27 -4
- package/dist/shims/link.js +91 -27
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +22 -1
- package/dist/shims/navigation.js +30 -15
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/offline.js.map +1 -1
- package/dist/shims/readonly-url-search-params.js.map +1 -1
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +38 -2
- package/dist/shims/router.js +45 -17
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script-nonce-context.js.map +1 -1
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.js +10 -14
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +6 -1
- package/dist/shims/slot.js +20 -7
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/thenable-params.js.map +1 -1
- package/dist/shims/unified-request-context.js +3 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +2 -1
- package/dist/shims/url-utils.js +10 -1
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/shims/use-merged-ref.js.map +1 -1
- package/dist/shims/web-vitals.d.ts +4 -21
- package/dist/shims/web-vitals.js +19 -6
- package/dist/shims/web-vitals.js.map +1 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/encode-cache-tag.d.ts +31 -0
- package/dist/utils/encode-cache-tag.js +38 -0
- package/dist/utils/encode-cache-tag.js.map +1 -0
- package/dist/utils/error-cause.js.map +1 -1
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/mdx-scan.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +6 -0
- package/dist/utils/navigation-signal.js +14 -0
- package/dist/utils/navigation-signal.js.map +1 -0
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/public-routes.js.map +1 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/safe-json-file.js.map +1 -1
- package/dist/utils/text-stream.js.map +1 -1
- package/dist/utils/vinext-root.js.map +1 -1
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.js","names":[],"sources":["../../src/shims/dynamic.ts"],"sourcesContent":["/**\n * next/dynamic shim\n *\n * SSR-safe dynamic imports. On the server, uses React.lazy + Suspense so that\n * renderToReadableStream suspends until the dynamically-imported component is\n * available. On the client, also uses React.lazy for code splitting.\n *\n * Works in RSC, SSR, and client environments:\n * - RSC: Uses React.lazy + Suspense (available in React 19.x react-server).\n * Falls back to async component pattern if a future React version\n * strips lazy from react-server.\n * - SSR: React.lazy + Suspense (renderToReadableStream suspends)\n * - Client: React.lazy + Suspense (standard code splitting)\n *\n * Supports:\n * - dynamic(() => import('./Component'))\n * - dynamic(() => import('./Component'), { loading: () => <Spinner /> })\n * - dynamic(() => import('./Component'), { ssr: false })\n */\nimport React, { type ComponentType } from \"react\";\n\ntype DynamicOptions = {\n loading?: ComponentType<{ error?: Error | null; isLoading?: boolean; pastDelay?: boolean }>;\n ssr?: boolean;\n};\n\ntype Loader<P> = () => Promise<{ default: ComponentType<P> } | ComponentType<P>>;\n\n/**\n * Lightweight error boundary that renders the loading component with the error\n * when a dynamic() loader rejects. Without this, loader failures would propagate\n * uncaught through React's rendering — this preserves the Next.js behavior where\n * the `loading` component can display errors.\n *\n * Lazily created because React.Component is not available in the RSC environment\n * (server components use a slimmed-down React that doesn't include class components).\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nlet DynamicErrorBoundary: any;\nfunction getDynamicErrorBoundary() {\n if (DynamicErrorBoundary) return DynamicErrorBoundary;\n if (!React.Component) return null;\n DynamicErrorBoundary = class extends (\n React.Component<\n {\n fallback: ComponentType<{ error?: Error | null; isLoading?: boolean; pastDelay?: boolean }>;\n children: React.ReactNode;\n },\n { error: Error | null }\n >\n ) {\n // oxlint-disable-next-line typescript/no-explicit-any\n constructor(props: any) {\n super(props);\n this.state = { error: null };\n }\n static getDerivedStateFromError(error: unknown) {\n return { error: error instanceof Error ? error : new Error(String(error)) };\n }\n render() {\n if (this.state.error) {\n return React.createElement(this.props.fallback, {\n isLoading: false,\n pastDelay: true,\n error: this.state.error,\n });\n }\n return this.props.children;\n }\n };\n return DynamicErrorBoundary;\n}\n\n// Detect server vs client\nconst isServer = typeof window === \"undefined\";\n\n// Legacy preload queue — kept for backward compatibility with Pages Router\n// which calls flushPreloads() before rendering. The App Router uses React.lazy\n// + Suspense instead, so this queue is no longer populated.\nconst preloadQueue: Promise<void>[] = [];\n\n/**\n * Wait for all pending dynamic() preloads to resolve, then clear the queue.\n * Called by the Pages Router SSR handler before rendering.\n * No-op for the App Router path which uses React.lazy + Suspense.\n */\nexport function flushPreloads(): Promise<void[]> {\n const pending = preloadQueue.splice(0);\n return Promise.all(pending);\n}\n\nfunction dynamic<P extends object = object>(\n loader: Loader<P>,\n options?: DynamicOptions,\n): ComponentType<P> {\n const { loading: LoadingComponent, ssr = true } = options ?? {};\n\n // ssr: false — render nothing on the server, lazy-load on client\n if (!ssr) {\n if (isServer) {\n // On the server (SSR or RSC), just render the loading state or nothing\n const SSRFalse = (_props: P) =>\n LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n SSRFalse.displayName = \"DynamicSSRFalse\";\n return SSRFalse;\n }\n\n // Client: use lazy with Suspense\n const LazyComponent = React.lazy(async () => {\n const mod = await loader();\n if (\"default\" in mod) return mod as { default: ComponentType<P> };\n return { default: mod as ComponentType<P> };\n });\n\n const ClientSSRFalse = (props: P) => {\n const [mounted, setMounted] = React.useState(false);\n React.useEffect(() => setMounted(true), []);\n\n if (!mounted) {\n return LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n }\n\n const fallback = LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n return React.createElement(\n React.Suspense,\n { fallback },\n React.createElement(LazyComponent, props),\n );\n };\n\n ClientSSRFalse.displayName = \"DynamicClientSSRFalse\";\n return ClientSSRFalse;\n }\n\n // SSR-enabled path\n if (isServer) {\n // Defensive fallback: if a future React version strips React.lazy from the\n // react-server condition, fall back to an async component pattern.\n // In React 19.x, React.lazy IS available in react-server, so this branch\n // does not execute — it exists for forward compatibility only.\n if (typeof React.lazy !== \"function\") {\n const AsyncServerDynamic = async (props: P) => {\n // Note: LoadingComponent is not used here — in the RSC environment,\n // async components suspend natively and parent <Suspense> boundaries\n // provide loading states. Error handling also defers to the nearest\n // error boundary in the component tree.\n const mod = await loader();\n const Component =\n \"default\" in mod\n ? (mod as { default: ComponentType<P> }).default\n : (mod as ComponentType<P>);\n return React.createElement(Component, props);\n };\n AsyncServerDynamic.displayName = \"DynamicAsyncServer\";\n // Cast is safe: async components are natively supported by the RSC renderer,\n // but TypeScript's ComponentType<P> doesn't account for async return types.\n return AsyncServerDynamic as unknown as ComponentType<P>;\n }\n\n // SSR path: Use React.lazy so that renderToReadableStream can suspend\n // until the dynamically-imported component is available.\n const LazyServer = React.lazy(async () => {\n const mod = await loader();\n if (\"default\" in mod) return mod as { default: ComponentType<P> };\n return { default: mod as ComponentType<P> };\n });\n\n const ServerDynamic = (props: P) => {\n const fallback = LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n const lazyElement = React.createElement(LazyServer, props);\n // Wrap with error boundary so loader rejections render the loading\n // component with the error instead of propagating uncaught.\n const ErrorBoundary = LoadingComponent ? getDynamicErrorBoundary() : null;\n const content = ErrorBoundary\n ? React.createElement(ErrorBoundary, { fallback: LoadingComponent }, lazyElement)\n : lazyElement;\n return React.createElement(React.Suspense, { fallback }, content);\n };\n\n ServerDynamic.displayName = \"DynamicServer\";\n return ServerDynamic;\n }\n\n // Client path: standard React.lazy with Suspense\n const LazyComponent = React.lazy(async () => {\n const mod = await loader();\n if (\"default\" in mod) return mod as { default: ComponentType<P> };\n return { default: mod as ComponentType<P> };\n });\n\n const ClientDynamic = (props: P) => {\n const fallback = LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n return React.createElement(\n React.Suspense,\n { fallback },\n React.createElement(LazyComponent, props),\n );\n };\n\n ClientDynamic.displayName = \"DynamicClient\";\n return ClientDynamic;\n}\n\nexport default dynamic;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAI;AACJ,SAAS,0BAA0B;AACjC,KAAI,qBAAsB,QAAO;AACjC,KAAI,CAAC,MAAM,UAAW,QAAO;AAC7B,wBAAuB,cACrB,MAAM,UAON;EAEA,YAAY,OAAY;AACtB,SAAM,MAAM;AACZ,QAAK,QAAQ,EAAE,OAAO,MAAM;;EAE9B,OAAO,yBAAyB,OAAgB;AAC9C,UAAO,EAAE,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC,EAAE;;EAE7E,SAAS;AACP,OAAI,KAAK,MAAM,MACb,QAAO,MAAM,cAAc,KAAK,MAAM,UAAU;IAC9C,WAAW;IACX,WAAW;IACX,OAAO,KAAK,MAAM;IACnB,CAAC;AAEJ,UAAO,KAAK,MAAM;;;AAGtB,QAAO;;AAIT,MAAM,WAAW,OAAO,WAAW;AAKnC,MAAM,eAAgC,EAAE;;;;;;AAOxC,SAAgB,gBAAiC;CAC/C,MAAM,UAAU,aAAa,OAAO,EAAE;AACtC,QAAO,QAAQ,IAAI,QAAQ;;AAG7B,SAAS,QACP,QACA,SACkB;CAClB,MAAM,EAAE,SAAS,kBAAkB,MAAM,SAAS,WAAW,EAAE;AAG/D,KAAI,CAAC,KAAK;AACR,M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C,GACxF;GACJ,MAAM,cAAc,MAAM,cAAc,YAAY,MAAM;GAG1D,MAAM,gBAAgB,mBAAmB,yBAAyB,GAAG;GACrE,MAAM,UAAU,gBACZ,MAAM,cAAc,eAAe,EAAE,UAAU,kBAAkB,EAAE,YAAY,GAC/E;AACJ,UAAO,MAAM,cAAc,MAAM,UAAU,EAAE,UAAU,EAAE,QAAQ;;AAGnE,gBAAc,cAAc;AAC5B,SAAO;;CAIT,MAAM,gBAAgB,MAAM,KAAK,YAAY;EAC3C,MAAM,MAAM,MAAM,QAAQ;AAC1B,MAAI,aAAa,IAAK,QAAO;AAC7B,SAAO,EAAE,SAAS,KAAyB;GAC3C;CAEF,MAAM,iBAAiB,UAAa;EAClC,MAAM,WAAW,mBACb,MAAM,cAAc,kBAAkB;GAAE,WAAW;GAAM,WAAW;GAAM,OAAO;GAAM,CAAC,GACxF;AACJ,SAAO,MAAM,cACX,MAAM,UACN,EAAE,UAAU,EACZ,MAAM,cAAc,eAAe,MAAM,CAC1C;;AAGH,eAAc,cAAc;AAC5B,QAAO"}
|
|
1
|
+
{"version":3,"file":"dynamic.js","names":[],"sources":["../../src/shims/dynamic.ts"],"sourcesContent":["/**\n * next/dynamic shim\n *\n * SSR-safe dynamic imports. On the server, uses React.lazy + Suspense so that\n * renderToReadableStream suspends until the dynamically-imported component is\n * available. On the client, also uses React.lazy for code splitting.\n *\n * Works in RSC, SSR, and client environments:\n * - RSC: Uses React.lazy + Suspense (available in React 19.x react-server).\n * Falls back to async component pattern if a future React version\n * strips lazy from react-server.\n * - SSR: React.lazy + Suspense (renderToReadableStream suspends)\n * - Client: React.lazy + Suspense (standard code splitting)\n *\n * Supports:\n * - dynamic(import('./Component'))\n * - dynamic(() => import('./Component'))\n * - dynamic({ loader })\n * - dynamic(() => import('./Component'), { loading: () => <Spinner /> })\n * - dynamic(() => import('./Component'), { ssr: false })\n */\nimport React, { type ComponentType } from \"react\";\n\ntype DynamicLoadingProps = {\n error?: Error | null;\n isLoading?: boolean;\n pastDelay?: boolean;\n retry?: () => void;\n timedOut?: boolean;\n};\n\ntype ComponentModule<P> = { default: ComponentType<P> };\ntype LoaderComponent<P> = Promise<ComponentModule<P> | ComponentType<P>>;\ntype LoaderFn<P> = () => LoaderComponent<P>;\n\ntype DynamicOptions<P> = {\n loading?: ComponentType<DynamicLoadingProps>;\n loader?: Loader<P>;\n ssr?: boolean;\n};\n\ntype Loader<P> = LoaderFn<P> | LoaderComponent<P>;\ntype DynamicInput<P> = DynamicOptions<P> | Loader<P>;\n\nconst noopRetry = () => {};\n\nfunction createDynamicLoadingProps(\n overrides: Partial<DynamicLoadingProps> = {},\n): DynamicLoadingProps {\n return {\n error: null,\n isLoading: true,\n pastDelay: true,\n retry: noopRetry,\n timedOut: false,\n ...overrides,\n };\n}\n\nfunction hasDefaultExport<P>(\n mod: ComponentModule<P> | ComponentType<P>,\n): mod is ComponentModule<P> {\n return (typeof mod === \"object\" || typeof mod === \"function\") && mod !== null && \"default\" in mod;\n}\n\nfunction normalizeLoader<P extends object>(loader: Loader<P>): LoaderFn<P> {\n if (typeof loader === \"function\") {\n return loader;\n }\n return () => loader;\n}\n\nfunction normalizeDynamicOptions<P extends object>(\n dynamicInput: DynamicInput<P>,\n options?: DynamicOptions<P>,\n): DynamicOptions<P> {\n let normalizedOptions: DynamicOptions<P>;\n\n if (dynamicInput instanceof Promise || typeof dynamicInput === \"function\") {\n normalizedOptions = { loader: normalizeLoader(dynamicInput) };\n } else {\n normalizedOptions = dynamicInput;\n }\n\n return {\n ...normalizedOptions,\n ...options,\n };\n}\n\nfunction createLazyComponent<P extends object>(loader: LoaderFn<P>) {\n return React.lazy(async () => {\n const mod = await loader();\n if (hasDefaultExport(mod)) return mod;\n return { default: mod };\n });\n}\n\nfunction useRetryableLazyComponent<P extends object>(\n loader: LoaderFn<P>,\n initialLazyComponent: ReturnType<typeof createLazyComponent<P>>,\n) {\n const [LazyComponent, setLazyComponent] = React.useState(() => initialLazyComponent);\n const [retryKey, setRetryKey] = React.useState(0);\n const retry = React.useCallback(() => {\n setLazyComponent(() => createLazyComponent(loader));\n setRetryKey((key) => key + 1);\n }, [loader]);\n return { LazyComponent, retry, retryKey };\n}\n\ntype DynamicErrorBoundaryProps = {\n fallback: ComponentType<DynamicLoadingProps>;\n retry: () => void;\n resetKey: number;\n children?: React.ReactNode;\n};\n\ntype DynamicErrorBoundaryState = {\n error: Error | null;\n resetKey: number;\n};\n\n/**\n * Lightweight error boundary that renders the loading component with the error\n * when a dynamic() loader rejects. Without this, loader failures would propagate\n * uncaught through React's rendering — this preserves the Next.js behavior where\n * the `loading` component can display errors.\n *\n * Lazily created because React.Component is not available in the RSC environment\n * (server components use a slimmed-down React that doesn't include class components).\n */\nlet DynamicErrorBoundary: ComponentType<DynamicErrorBoundaryProps> | null | undefined;\nfunction getDynamicErrorBoundary() {\n if (DynamicErrorBoundary) return DynamicErrorBoundary;\n if (!React.Component) return null;\n DynamicErrorBoundary = class extends (\n React.Component<DynamicErrorBoundaryProps, DynamicErrorBoundaryState>\n ) {\n constructor(props: DynamicErrorBoundaryProps) {\n super(props);\n this.state = { error: null, resetKey: props.resetKey };\n }\n static getDerivedStateFromProps(\n props: DynamicErrorBoundaryProps,\n state: DynamicErrorBoundaryState,\n ) {\n if (props.resetKey !== state.resetKey) {\n return { error: null, resetKey: props.resetKey };\n }\n return null;\n }\n static getDerivedStateFromError(error: unknown) {\n return { error: error instanceof Error ? error : new Error(String(error)) };\n }\n render() {\n if (this.state.error) {\n return React.createElement(\n this.props.fallback,\n createDynamicLoadingProps({\n isLoading: false,\n error: this.state.error,\n retry: this.props.retry,\n }),\n );\n }\n return this.props.children;\n }\n };\n return DynamicErrorBoundary;\n}\n\n// Detect server vs client\nconst isServer = typeof window === \"undefined\";\n\n// Legacy preload queue — kept for backward compatibility with Pages Router\n// which calls flushPreloads() before rendering. The App Router uses React.lazy\n// + Suspense instead, so this queue is no longer populated.\nconst preloadQueue: Promise<void>[] = [];\n\n/**\n * Wait for all pending dynamic() preloads to resolve, then clear the queue.\n * Called by the Pages Router SSR handler before rendering.\n * No-op for the App Router path which uses React.lazy + Suspense.\n */\nexport function flushPreloads(): Promise<void[]> {\n const pending = preloadQueue.splice(0);\n return Promise.all(pending);\n}\n\nfunction dynamic<P extends object = object>(\n dynamicInput: DynamicInput<P>,\n options?: DynamicOptions<P>,\n): ComponentType<P> {\n const {\n loader: dynamicLoader,\n loading: LoadingComponent,\n ssr = true,\n } = normalizeDynamicOptions(dynamicInput, options);\n const loader = dynamicLoader ? normalizeLoader(dynamicLoader) : () => Promise.resolve(() => null);\n\n // ssr: false — render nothing on the server, lazy-load on client\n if (!ssr) {\n if (isServer) {\n // On the server (SSR or RSC), just render the loading state or nothing\n const SSRFalse = (_props: P) =>\n LoadingComponent\n ? React.createElement(LoadingComponent, createDynamicLoadingProps({ pastDelay: false }))\n : null;\n SSRFalse.displayName = \"DynamicSSRFalse\";\n return SSRFalse;\n }\n\n const InitialLazyComponent = createLazyComponent(loader);\n\n const ClientSSRFalse = (props: P) => {\n const [mounted, setMounted] = React.useState(false);\n const { LazyComponent, retry, retryKey } = useRetryableLazyComponent(\n loader,\n InitialLazyComponent,\n );\n React.useEffect(() => setMounted(true), []);\n\n if (!mounted) {\n return LoadingComponent\n ? React.createElement(LoadingComponent, createDynamicLoadingProps({ retry }))\n : null;\n }\n\n const fallback = LoadingComponent\n ? React.createElement(LoadingComponent, createDynamicLoadingProps({ retry }))\n : null;\n const lazyElement = React.createElement(LazyComponent, props);\n let content: React.ReactNode = lazyElement;\n if (LoadingComponent) {\n const ErrorBoundary = getDynamicErrorBoundary();\n if (ErrorBoundary) {\n content = React.createElement(\n ErrorBoundary,\n { fallback: LoadingComponent, retry, resetKey: retryKey },\n lazyElement,\n );\n }\n }\n return React.createElement(React.Suspense, { fallback }, content);\n };\n\n ClientSSRFalse.displayName = \"DynamicClientSSRFalse\";\n return ClientSSRFalse;\n }\n\n // SSR-enabled path\n if (isServer) {\n // Defensive fallback: if a future React version strips React.lazy from the\n // react-server condition, fall back to an async component pattern.\n // In React 19.x, React.lazy IS available in react-server, so this branch\n // does not execute — it exists for forward compatibility only.\n if (typeof React.lazy !== \"function\") {\n const AsyncServerDynamic = async (props: P) => {\n // Note: LoadingComponent is not used here — in the RSC environment,\n // async components suspend natively and parent <Suspense> boundaries\n // provide loading states. Error handling also defers to the nearest\n // error boundary in the component tree.\n const mod = await loader();\n const Component =\n \"default\" in mod\n ? (mod as { default: ComponentType<P> }).default\n : (mod as ComponentType<P>);\n return React.createElement(Component, props);\n };\n AsyncServerDynamic.displayName = \"DynamicAsyncServer\";\n // Cast is safe: async components are natively supported by the RSC renderer,\n // but TypeScript's ComponentType<P> doesn't account for async return types.\n return AsyncServerDynamic as unknown as ComponentType<P>;\n }\n\n // SSR path: Use React.lazy so that renderToReadableStream can suspend\n // until the dynamically-imported component is available.\n const LazyServer = createLazyComponent(loader);\n\n const ServerDynamic = (props: P) => {\n const fallback = LoadingComponent\n ? React.createElement(LoadingComponent, createDynamicLoadingProps())\n : null;\n const lazyElement = React.createElement(LazyServer, props);\n // Wrap with error boundary so loader rejections render the loading\n // component with the error instead of propagating uncaught.\n let content: React.ReactNode = lazyElement;\n if (LoadingComponent) {\n const ErrorBoundary = getDynamicErrorBoundary();\n if (ErrorBoundary) {\n content = React.createElement(\n ErrorBoundary,\n { fallback: LoadingComponent, retry: noopRetry, resetKey: 0 },\n lazyElement,\n );\n }\n }\n return React.createElement(React.Suspense, { fallback }, content);\n };\n\n ServerDynamic.displayName = \"DynamicServer\";\n return ServerDynamic;\n }\n\n const InitialLazyComponent = createLazyComponent(loader);\n\n const ClientDynamic = (props: P) => {\n const { LazyComponent, retry, retryKey } = useRetryableLazyComponent(\n loader,\n InitialLazyComponent,\n );\n const fallback = LoadingComponent\n ? React.createElement(LoadingComponent, createDynamicLoadingProps({ retry }))\n : null;\n const lazyElement = React.createElement(LazyComponent, props);\n let content: React.ReactNode = lazyElement;\n if (LoadingComponent) {\n const ErrorBoundary = getDynamicErrorBoundary();\n if (ErrorBoundary) {\n content = React.createElement(\n ErrorBoundary,\n { fallback: LoadingComponent, retry, resetKey: retryKey },\n lazyElement,\n );\n }\n }\n return React.createElement(React.Suspense, { fallback }, content);\n };\n\n ClientDynamic.displayName = \"DynamicClient\";\n return ClientDynamic;\n}\n\nexport default dynamic;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,kBAAkB;AAExB,SAAS,0BACP,YAA0C,EAAE,EACvB;CACrB,OAAO;EACL,OAAO;EACP,WAAW;EACX,WAAW;EACX,OAAO;EACP,UAAU;EACV,GAAG;EACJ;;AAGH,SAAS,iBACP,KAC2B;CAC3B,QAAQ,OAAO,QAAQ,YAAY,OAAO,QAAQ,eAAe,QAAQ,QAAQ,aAAa;;AAGhG,SAAS,gBAAkC,QAAgC;CACzE,IAAI,OAAO,WAAW,YACpB,OAAO;CAET,aAAa;;AAGf,SAAS,wBACP,cACA,SACmB;CACnB,IAAI;CAEJ,IAAI,wBAAwB,WAAW,OAAO,iBAAiB,YAC7D,oBAAoB,EAAE,QAAQ,gBAAgB,aAAa,EAAE;MAE7D,oBAAoB;CAGtB,OAAO;EACL,GAAG;EACH,GAAG;EACJ;;AAGH,SAAS,oBAAsC,QAAqB;CAClE,OAAO,MAAM,KAAK,YAAY;EAC5B,MAAM,MAAM,MAAM,QAAQ;EAC1B,IAAI,iBAAiB,IAAI,EAAE,OAAO;EAClC,OAAO,EAAE,SAAS,KAAK;GACvB;;AAGJ,SAAS,0BACP,QACA,sBACA;CACA,MAAM,CAAC,eAAe,oBAAoB,MAAM,eAAe,qBAAqB;CACpF,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;CAKjD,OAAO;EAAE;EAAe,OAJV,MAAM,kBAAkB;GACpC,uBAAuB,oBAAoB,OAAO,CAAC;GACnD,aAAa,QAAQ,MAAM,EAAE;KAC5B,CAAC,OAAO,CACkB;EAAE;EAAU;;;;;;;;;;;AAwB3C,IAAI;AACJ,S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c,cAAc;EAC5B,OAAO;;CAGT,MAAM,uBAAuB,oBAAoB,OAAO;CAExD,MAAM,iBAAiB,UAAa;EAClC,MAAM,EAAE,eAAe,OAAO,aAAa,0BACzC,QACA,qBACD;EACD,MAAM,WAAW,mBACb,MAAM,cAAc,kBAAkB,0BAA0B,EAAE,OAAO,CAAC,CAAC,GAC3E;EACJ,MAAM,cAAc,MAAM,cAAc,eAAe,MAAM;EAC7D,IAAI,UAA2B;EAC/B,IAAI,kBAAkB;GACpB,MAAM,gBAAgB,yBAAyB;GAC/C,IAAI,eACF,UAAU,MAAM,cACd,eACA;IAAE,UAAU;IAAkB;IAAO,UAAU;IAAU,EACzD,YACD;;EAGL,OAAO,MAAM,cAAc,MAAM,UAAU,EAAE,UAAU,EAAE,QAAQ;;CAGnE,cAAc,cAAc;CAC5B,OAAO"}
|
|
@@ -8,17 +8,37 @@ type ErrorBoundaryProps = {
|
|
|
8
8
|
reset: () => void;
|
|
9
9
|
}>;
|
|
10
10
|
children: React.ReactNode;
|
|
11
|
+
resetKey?: string | null;
|
|
11
12
|
};
|
|
12
13
|
type CapturedError = {
|
|
13
14
|
thrownValue: unknown;
|
|
14
15
|
};
|
|
16
|
+
type RedirectBoundaryState = {
|
|
17
|
+
redirect: string | null;
|
|
18
|
+
redirectType: "push" | "replace" | null;
|
|
19
|
+
};
|
|
15
20
|
type ErrorBoundaryInnerProps = {
|
|
16
21
|
pathname: string;
|
|
17
22
|
} & ErrorBoundaryProps;
|
|
18
23
|
type ErrorBoundaryState = {
|
|
19
24
|
error: CapturedError | null;
|
|
20
25
|
previousPathname: string;
|
|
26
|
+
previousResetKey: string | null;
|
|
21
27
|
};
|
|
28
|
+
declare class RedirectErrorBoundary extends React.Component<{
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
}, RedirectBoundaryState> {
|
|
31
|
+
constructor(props: {
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
});
|
|
34
|
+
static getDerivedStateFromError(error: unknown): RedirectBoundaryState;
|
|
35
|
+
render(): string | number | bigint | boolean | _$react_jsx_runtime0.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
36
|
+
}
|
|
37
|
+
declare function RedirectBoundary({
|
|
38
|
+
children
|
|
39
|
+
}: {
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
}): _$react_jsx_runtime0.JSX.Element;
|
|
22
42
|
/**
|
|
23
43
|
* Generic ErrorBoundary used to wrap route segments with error.tsx.
|
|
24
44
|
* This must be a client component since error boundaries use
|
|
@@ -33,23 +53,27 @@ declare class ErrorBoundaryInner extends React.Component<ErrorBoundaryInnerProps
|
|
|
33
53
|
}
|
|
34
54
|
declare function ErrorBoundary({
|
|
35
55
|
fallback,
|
|
36
|
-
children
|
|
56
|
+
children,
|
|
57
|
+
resetKey
|
|
37
58
|
}: ErrorBoundaryProps): _$react_jsx_runtime0.JSX.Element;
|
|
38
59
|
type NotFoundBoundaryProps = {
|
|
39
60
|
fallback: React.ReactNode;
|
|
40
61
|
children: React.ReactNode;
|
|
62
|
+
resetKey?: string | null;
|
|
41
63
|
};
|
|
42
64
|
/**
|
|
43
65
|
* Wrapper that reads the current pathname and passes it to the inner class
|
|
44
|
-
* component.
|
|
66
|
+
* component. Segment reset keys own App Router remount semantics when present.
|
|
45
67
|
*/
|
|
46
68
|
declare function NotFoundBoundary({
|
|
47
69
|
fallback,
|
|
48
|
-
children
|
|
70
|
+
children,
|
|
71
|
+
resetKey
|
|
49
72
|
}: NotFoundBoundaryProps): _$react_jsx_runtime0.JSX.Element;
|
|
50
73
|
type ForbiddenBoundaryProps = {
|
|
51
74
|
fallback: React.ReactNode;
|
|
52
75
|
children: React.ReactNode;
|
|
76
|
+
resetKey?: string | null;
|
|
53
77
|
};
|
|
54
78
|
type ForbiddenBoundaryInnerProps = {
|
|
55
79
|
pathname: string;
|
|
@@ -57,6 +81,7 @@ type ForbiddenBoundaryInnerProps = {
|
|
|
57
81
|
type ForbiddenBoundaryState = {
|
|
58
82
|
forbidden: boolean;
|
|
59
83
|
previousPathname: string;
|
|
84
|
+
previousResetKey: string | null;
|
|
60
85
|
};
|
|
61
86
|
declare class ForbiddenBoundaryInner extends React.Component<ForbiddenBoundaryInnerProps, ForbiddenBoundaryState> {
|
|
62
87
|
constructor(props: ForbiddenBoundaryInnerProps);
|
|
@@ -66,11 +91,13 @@ declare class ForbiddenBoundaryInner extends React.Component<ForbiddenBoundaryIn
|
|
|
66
91
|
}
|
|
67
92
|
declare function ForbiddenBoundary({
|
|
68
93
|
fallback,
|
|
69
|
-
children
|
|
94
|
+
children,
|
|
95
|
+
resetKey
|
|
70
96
|
}: ForbiddenBoundaryProps): _$react_jsx_runtime0.JSX.Element;
|
|
71
97
|
type UnauthorizedBoundaryProps = {
|
|
72
98
|
fallback: React.ReactNode;
|
|
73
99
|
children: React.ReactNode;
|
|
100
|
+
resetKey?: string | null;
|
|
74
101
|
};
|
|
75
102
|
type UnauthorizedBoundaryInnerProps = {
|
|
76
103
|
pathname: string;
|
|
@@ -78,6 +105,7 @@ type UnauthorizedBoundaryInnerProps = {
|
|
|
78
105
|
type UnauthorizedBoundaryState = {
|
|
79
106
|
unauthorized: boolean;
|
|
80
107
|
previousPathname: string;
|
|
108
|
+
previousResetKey: string | null;
|
|
81
109
|
};
|
|
82
110
|
declare class UnauthorizedBoundaryInner extends React.Component<UnauthorizedBoundaryInnerProps, UnauthorizedBoundaryState> {
|
|
83
111
|
constructor(props: UnauthorizedBoundaryInnerProps);
|
|
@@ -87,7 +115,8 @@ declare class UnauthorizedBoundaryInner extends React.Component<UnauthorizedBoun
|
|
|
87
115
|
}
|
|
88
116
|
declare function UnauthorizedBoundary({
|
|
89
117
|
fallback,
|
|
90
|
-
children
|
|
118
|
+
children,
|
|
119
|
+
resetKey
|
|
91
120
|
}: UnauthorizedBoundaryProps): _$react_jsx_runtime0.JSX.Element;
|
|
92
121
|
type DevRecoveryBoundaryProps = {
|
|
93
122
|
resetKey: number;
|
|
@@ -106,5 +135,5 @@ declare class DevRecoveryBoundary extends React.Component<DevRecoveryBoundaryPro
|
|
|
106
135
|
render(): React.ReactNode;
|
|
107
136
|
}
|
|
108
137
|
//#endregion
|
|
109
|
-
export { DevRecoveryBoundary, DevRecoveryBoundaryProps, ErrorBoundary, ErrorBoundaryInner, ErrorBoundaryProps, ErrorBoundaryState, ForbiddenBoundary, ForbiddenBoundaryInner, NotFoundBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
138
|
+
export { DevRecoveryBoundary, DevRecoveryBoundaryProps, ErrorBoundary, ErrorBoundaryInner, ErrorBoundaryProps, ErrorBoundaryState, ForbiddenBoundary, ForbiddenBoundaryInner, NotFoundBoundary, RedirectBoundary, RedirectErrorBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
110
139
|
//# sourceMappingURL=error-boundary.d.ts.map
|
|
@@ -1,8 +1,91 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { usePathname } from "./navigation.js";
|
|
2
|
+
import { usePathname, useRouter } from "./navigation.js";
|
|
3
|
+
import { getErrorDigest, isNavigationSignalError } from "../utils/navigation-signal.js";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/shims/error-boundary.tsx
|
|
7
|
+
function normalizeBoundaryResetKey(resetKey) {
|
|
8
|
+
return resetKey === void 0 || resetKey === null || resetKey === "" ? null : resetKey;
|
|
9
|
+
}
|
|
10
|
+
function readBoundaryResetState(props) {
|
|
11
|
+
return {
|
|
12
|
+
previousPathname: props.pathname,
|
|
13
|
+
previousResetKey: normalizeBoundaryResetKey(props.resetKey)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function shouldResetBoundary(nextResetState, previousResetState) {
|
|
17
|
+
const nextResetKey = normalizeBoundaryResetKey(nextResetState.previousResetKey);
|
|
18
|
+
const previousResetKey = normalizeBoundaryResetKey(previousResetState.previousResetKey);
|
|
19
|
+
if (nextResetKey !== null || previousResetKey !== null) return nextResetKey !== previousResetKey;
|
|
20
|
+
return nextResetState.previousPathname !== previousResetState.previousPathname;
|
|
21
|
+
}
|
|
22
|
+
function isRedirectError(error) {
|
|
23
|
+
return getErrorDigest(error)?.startsWith("NEXT_REDIRECT;") ?? false;
|
|
24
|
+
}
|
|
25
|
+
function decodeRedirectTarget(target) {
|
|
26
|
+
try {
|
|
27
|
+
return decodeURIComponent(target);
|
|
28
|
+
} catch {
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getURLFromRedirectError(error) {
|
|
33
|
+
const parts = error.digest.split(";");
|
|
34
|
+
const encodedTarget = parts.length >= 5 ? parts.slice(2, -2).join(";") : parts[2];
|
|
35
|
+
return encodedTarget ? decodeRedirectTarget(encodedTarget) : null;
|
|
36
|
+
}
|
|
37
|
+
function getRedirectTypeFromError(error) {
|
|
38
|
+
return error.digest.split(";", 2)[1] === "push" ? "push" : "replace";
|
|
39
|
+
}
|
|
40
|
+
function HandleRedirect({ redirect, redirectType }) {
|
|
41
|
+
const router = useRouter();
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
React.startTransition(() => {
|
|
44
|
+
if (redirectType === "push") router.push(redirect);
|
|
45
|
+
else router.replace(redirect);
|
|
46
|
+
});
|
|
47
|
+
}, [
|
|
48
|
+
redirect,
|
|
49
|
+
redirectType,
|
|
50
|
+
router
|
|
51
|
+
]);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
var RedirectErrorBoundary = class extends React.Component {
|
|
55
|
+
constructor(props) {
|
|
56
|
+
super(props);
|
|
57
|
+
this.state = {
|
|
58
|
+
redirect: null,
|
|
59
|
+
redirectType: null
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
static getDerivedStateFromError(error) {
|
|
63
|
+
if (isRedirectError(error)) {
|
|
64
|
+
if (error.handled) return {
|
|
65
|
+
redirect: null,
|
|
66
|
+
redirectType: null
|
|
67
|
+
};
|
|
68
|
+
const url = getURLFromRedirectError(error);
|
|
69
|
+
if (url === null) throw error;
|
|
70
|
+
return {
|
|
71
|
+
redirect: url,
|
|
72
|
+
redirectType: getRedirectTypeFromError(error)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const { redirect, redirectType } = this.state;
|
|
79
|
+
if (redirect !== null && redirectType !== null) return /* @__PURE__ */ jsx(HandleRedirect, {
|
|
80
|
+
redirect,
|
|
81
|
+
redirectType
|
|
82
|
+
});
|
|
83
|
+
return this.props.children;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
function RedirectBoundary({ children }) {
|
|
87
|
+
return /* @__PURE__ */ jsx(RedirectErrorBoundary, { children });
|
|
88
|
+
}
|
|
6
89
|
/**
|
|
7
90
|
* Generic ErrorBoundary used to wrap route segments with error.tsx.
|
|
8
91
|
* This must be a client component since error boundaries use
|
|
@@ -13,24 +96,22 @@ var ErrorBoundaryInner = class extends React.Component {
|
|
|
13
96
|
super(props);
|
|
14
97
|
this.state = {
|
|
15
98
|
error: null,
|
|
16
|
-
|
|
99
|
+
...readBoundaryResetState(props)
|
|
17
100
|
};
|
|
18
101
|
}
|
|
19
102
|
static getDerivedStateFromProps(props, state) {
|
|
20
|
-
|
|
103
|
+
const nextResetState = readBoundaryResetState(props);
|
|
104
|
+
if (state.error && shouldResetBoundary(nextResetState, state)) return {
|
|
21
105
|
error: null,
|
|
22
|
-
|
|
106
|
+
...nextResetState
|
|
23
107
|
};
|
|
24
108
|
return {
|
|
25
109
|
error: state.error,
|
|
26
|
-
|
|
110
|
+
...nextResetState
|
|
27
111
|
};
|
|
28
112
|
}
|
|
29
113
|
static getDerivedStateFromError(error) {
|
|
30
|
-
if (error
|
|
31
|
-
const digest = String(error.digest);
|
|
32
|
-
if (digest === "NEXT_NOT_FOUND" || digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;") || digest.startsWith("NEXT_REDIRECT;")) throw error;
|
|
33
|
-
}
|
|
114
|
+
if (isNavigationSignalError(error)) throw error;
|
|
34
115
|
return { error: { thrownValue: error } };
|
|
35
116
|
}
|
|
36
117
|
reset = () => {
|
|
@@ -47,17 +128,18 @@ var ErrorBoundaryInner = class extends React.Component {
|
|
|
47
128
|
return this.props.children;
|
|
48
129
|
}
|
|
49
130
|
};
|
|
50
|
-
function ErrorBoundary({ fallback, children }) {
|
|
131
|
+
function ErrorBoundary({ fallback, children, resetKey }) {
|
|
51
132
|
return /* @__PURE__ */ jsx(ErrorBoundaryInner, {
|
|
52
133
|
pathname: usePathname(),
|
|
134
|
+
resetKey,
|
|
53
135
|
fallback,
|
|
54
136
|
children
|
|
55
137
|
});
|
|
56
138
|
}
|
|
57
139
|
/**
|
|
58
140
|
* Inner class component that catches notFound() errors and renders the
|
|
59
|
-
* not-found.tsx fallback. Resets
|
|
60
|
-
*
|
|
141
|
+
* not-found.tsx fallback. Resets on the caller's segment reset key when one is
|
|
142
|
+
* provided, otherwise falls back to pathname changes for legacy callers.
|
|
61
143
|
*
|
|
62
144
|
* The ErrorBoundary above re-throws notFound errors so they propagate up to this
|
|
63
145
|
* boundary. This must be placed above the ErrorBoundary in the component tree.
|
|
@@ -67,17 +149,18 @@ var NotFoundBoundaryInner = class extends React.Component {
|
|
|
67
149
|
super(props);
|
|
68
150
|
this.state = {
|
|
69
151
|
notFound: false,
|
|
70
|
-
|
|
152
|
+
...readBoundaryResetState(props)
|
|
71
153
|
};
|
|
72
154
|
}
|
|
73
155
|
static getDerivedStateFromProps(props, state) {
|
|
74
|
-
|
|
156
|
+
const nextResetState = readBoundaryResetState(props);
|
|
157
|
+
if (state.notFound && shouldResetBoundary(nextResetState, state)) return {
|
|
75
158
|
notFound: false,
|
|
76
|
-
|
|
159
|
+
...nextResetState
|
|
77
160
|
};
|
|
78
161
|
return {
|
|
79
162
|
notFound: state.notFound,
|
|
80
|
-
|
|
163
|
+
...nextResetState
|
|
81
164
|
};
|
|
82
165
|
}
|
|
83
166
|
static getDerivedStateFromError(error) {
|
|
@@ -94,11 +177,12 @@ var NotFoundBoundaryInner = class extends React.Component {
|
|
|
94
177
|
};
|
|
95
178
|
/**
|
|
96
179
|
* Wrapper that reads the current pathname and passes it to the inner class
|
|
97
|
-
* component.
|
|
180
|
+
* component. Segment reset keys own App Router remount semantics when present.
|
|
98
181
|
*/
|
|
99
|
-
function NotFoundBoundary({ fallback, children }) {
|
|
182
|
+
function NotFoundBoundary({ fallback, children, resetKey }) {
|
|
100
183
|
return /* @__PURE__ */ jsx(NotFoundBoundaryInner, {
|
|
101
184
|
pathname: usePathname(),
|
|
185
|
+
resetKey,
|
|
102
186
|
fallback,
|
|
103
187
|
children
|
|
104
188
|
});
|
|
@@ -108,17 +192,18 @@ var ForbiddenBoundaryInner = class extends React.Component {
|
|
|
108
192
|
super(props);
|
|
109
193
|
this.state = {
|
|
110
194
|
forbidden: false,
|
|
111
|
-
|
|
195
|
+
...readBoundaryResetState(props)
|
|
112
196
|
};
|
|
113
197
|
}
|
|
114
198
|
static getDerivedStateFromProps(props, state) {
|
|
115
|
-
|
|
199
|
+
const nextResetState = readBoundaryResetState(props);
|
|
200
|
+
if (state.forbidden && shouldResetBoundary(nextResetState, state)) return {
|
|
116
201
|
forbidden: false,
|
|
117
|
-
|
|
202
|
+
...nextResetState
|
|
118
203
|
};
|
|
119
204
|
return {
|
|
120
205
|
forbidden: state.forbidden,
|
|
121
|
-
|
|
206
|
+
...nextResetState
|
|
122
207
|
};
|
|
123
208
|
}
|
|
124
209
|
static getDerivedStateFromError(error) {
|
|
@@ -132,9 +217,10 @@ var ForbiddenBoundaryInner = class extends React.Component {
|
|
|
132
217
|
return this.props.children;
|
|
133
218
|
}
|
|
134
219
|
};
|
|
135
|
-
function ForbiddenBoundary({ fallback, children }) {
|
|
220
|
+
function ForbiddenBoundary({ fallback, children, resetKey }) {
|
|
136
221
|
return /* @__PURE__ */ jsx(ForbiddenBoundaryInner, {
|
|
137
222
|
pathname: usePathname(),
|
|
223
|
+
resetKey,
|
|
138
224
|
fallback,
|
|
139
225
|
children
|
|
140
226
|
});
|
|
@@ -144,17 +230,18 @@ var UnauthorizedBoundaryInner = class extends React.Component {
|
|
|
144
230
|
super(props);
|
|
145
231
|
this.state = {
|
|
146
232
|
unauthorized: false,
|
|
147
|
-
|
|
233
|
+
...readBoundaryResetState(props)
|
|
148
234
|
};
|
|
149
235
|
}
|
|
150
236
|
static getDerivedStateFromProps(props, state) {
|
|
151
|
-
|
|
237
|
+
const nextResetState = readBoundaryResetState(props);
|
|
238
|
+
if (state.unauthorized && shouldResetBoundary(nextResetState, state)) return {
|
|
152
239
|
unauthorized: false,
|
|
153
|
-
|
|
240
|
+
...nextResetState
|
|
154
241
|
};
|
|
155
242
|
return {
|
|
156
243
|
unauthorized: state.unauthorized,
|
|
157
|
-
|
|
244
|
+
...nextResetState
|
|
158
245
|
};
|
|
159
246
|
}
|
|
160
247
|
static getDerivedStateFromError(error) {
|
|
@@ -168,9 +255,10 @@ var UnauthorizedBoundaryInner = class extends React.Component {
|
|
|
168
255
|
return this.props.children;
|
|
169
256
|
}
|
|
170
257
|
};
|
|
171
|
-
function UnauthorizedBoundary({ fallback, children }) {
|
|
258
|
+
function UnauthorizedBoundary({ fallback, children, resetKey }) {
|
|
172
259
|
return /* @__PURE__ */ jsx(UnauthorizedBoundaryInner, {
|
|
173
260
|
pathname: usePathname(),
|
|
261
|
+
resetKey,
|
|
174
262
|
fallback,
|
|
175
263
|
children
|
|
176
264
|
});
|
|
@@ -191,10 +279,7 @@ var DevRecoveryBoundary = class extends React.Component {
|
|
|
191
279
|
};
|
|
192
280
|
}
|
|
193
281
|
static getDerivedStateFromError(error) {
|
|
194
|
-
if (error
|
|
195
|
-
const digest = String(error.digest);
|
|
196
|
-
if (digest === "NEXT_NOT_FOUND" || digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;") || digest.startsWith("NEXT_REDIRECT;")) throw error;
|
|
197
|
-
}
|
|
282
|
+
if (isNavigationSignalError(error)) throw error;
|
|
198
283
|
return { error: { thrownValue: error } };
|
|
199
284
|
}
|
|
200
285
|
componentDidCatch() {
|
|
@@ -206,6 +291,6 @@ var DevRecoveryBoundary = class extends React.Component {
|
|
|
206
291
|
}
|
|
207
292
|
};
|
|
208
293
|
//#endregion
|
|
209
|
-
export { DevRecoveryBoundary, ErrorBoundary, ErrorBoundaryInner, ForbiddenBoundary, ForbiddenBoundaryInner, NotFoundBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
294
|
+
export { DevRecoveryBoundary, ErrorBoundary, ErrorBoundaryInner, ForbiddenBoundary, ForbiddenBoundaryInner, NotFoundBoundary, RedirectBoundary, RedirectErrorBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
210
295
|
|
|
211
296
|
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.js","names":[],"sources":["../../src/shims/error-boundary.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\n// Import the local shim, not the public next/navigation alias. The built\n// package may execute this file before the plugin's resolveId hook is active.\nimport { usePathname } from \"./navigation.js\";\n\nexport type ErrorBoundaryProps = {\n fallback: React.ComponentType<{ error: unknown; reset: () => void }>;\n children: React.ReactNode;\n};\n\ntype CapturedError = {\n thrownValue: unknown;\n};\n\ntype ErrorBoundaryInnerProps = {\n pathname: string;\n} & ErrorBoundaryProps;\n\nexport type ErrorBoundaryState = {\n error: CapturedError | null;\n previousPathname: string;\n};\n\n/**\n * Generic ErrorBoundary used to wrap route segments with error.tsx.\n * This must be a client component since error boundaries use\n * componentDidCatch / getDerivedStateFromError.\n */\nexport class ErrorBoundaryInner extends React.Component<\n ErrorBoundaryInnerProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryInnerProps) {\n super(props);\n this.state = { error: null, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromProps(\n props: ErrorBoundaryInnerProps,\n state: ErrorBoundaryState,\n ): ErrorBoundaryState | null {\n if (props.pathname !== state.previousPathname && state.error) {\n return { error: null, previousPathname: props.pathname };\n }\n return { error: state.error, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<ErrorBoundaryState> {\n // notFound(), forbidden(), unauthorized(), and redirect() must propagate\n // past error boundaries. Re-throw them so they bubble up to the\n // framework's HTTP access fallback / redirect handler.\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;\") ||\n digest.startsWith(\"NEXT_REDIRECT;\")\n ) {\n throw error;\n }\n }\n return { error: { thrownValue: error } };\n }\n\n reset = () => {\n this.setState({ error: null });\n };\n\n render() {\n if (this.state.error) {\n const FallbackComponent = this.props.fallback;\n return <FallbackComponent error={this.state.error.thrownValue} reset={this.reset} />;\n }\n return this.props.children;\n }\n}\n\nexport function ErrorBoundary({ fallback, children }: ErrorBoundaryProps) {\n const pathname = usePathname();\n return (\n <ErrorBoundaryInner pathname={pathname} fallback={fallback}>\n {children}\n </ErrorBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// NotFoundBoundary — catches notFound() on the client and renders not-found.tsx\n// ---------------------------------------------------------------------------\n\ntype NotFoundBoundaryProps = {\n fallback: React.ReactNode;\n children: React.ReactNode;\n};\n\ntype NotFoundBoundaryInnerProps = {\n pathname: string;\n} & NotFoundBoundaryProps;\n\ntype NotFoundBoundaryState = {\n notFound: boolean;\n previousPathname: string;\n};\n\n/**\n * Inner class component that catches notFound() errors and renders the\n * not-found.tsx fallback. Resets when the pathname changes (client navigation)\n * so a previous notFound() doesn't permanently stick.\n *\n * The ErrorBoundary above re-throws notFound errors so they propagate up to this\n * boundary. This must be placed above the ErrorBoundary in the component tree.\n */\nclass NotFoundBoundaryInner extends React.Component<\n NotFoundBoundaryInnerProps,\n NotFoundBoundaryState\n> {\n constructor(props: NotFoundBoundaryInnerProps) {\n super(props);\n this.state = { notFound: false, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromProps(\n props: NotFoundBoundaryInnerProps,\n state: NotFoundBoundaryState,\n ): NotFoundBoundaryState | null {\n // Reset the boundary when the route changes so a previous notFound()\n // doesn't permanently stick after client-side navigation.\n if (props.pathname !== state.previousPathname && state.notFound) {\n return { notFound: false, previousPathname: props.pathname };\n }\n return { notFound: state.notFound, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<NotFoundBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (digest === \"NEXT_NOT_FOUND\" || digest === \"NEXT_HTTP_ERROR_FALLBACK;404\") {\n return { notFound: true };\n }\n }\n // Not a notFound error — re-throw so it reaches an ErrorBoundary or propagates\n throw error;\n }\n\n render() {\n if (this.state.notFound) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\n/**\n * Wrapper that reads the current pathname and passes it to the inner class\n * component. This enables automatic reset on client-side navigation.\n */\nexport function NotFoundBoundary({ fallback, children }: NotFoundBoundaryProps) {\n const pathname = usePathname();\n return (\n <NotFoundBoundaryInner pathname={pathname} fallback={fallback}>\n {children}\n </NotFoundBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// ForbiddenBoundary — catches forbidden() on the client and renders forbidden.tsx\n// ---------------------------------------------------------------------------\n\ntype ForbiddenBoundaryProps = {\n fallback: React.ReactNode;\n children: React.ReactNode;\n};\n\ntype ForbiddenBoundaryInnerProps = {\n pathname: string;\n} & ForbiddenBoundaryProps;\n\ntype ForbiddenBoundaryState = {\n forbidden: boolean;\n previousPathname: string;\n};\n\nexport class ForbiddenBoundaryInner extends React.Component<\n ForbiddenBoundaryInnerProps,\n ForbiddenBoundaryState\n> {\n constructor(props: ForbiddenBoundaryInnerProps) {\n super(props);\n this.state = { forbidden: false, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromProps(\n props: ForbiddenBoundaryInnerProps,\n state: ForbiddenBoundaryState,\n ): ForbiddenBoundaryState | null {\n if (props.pathname !== state.previousPathname && state.forbidden) {\n return { forbidden: false, previousPathname: props.pathname };\n }\n return { forbidden: state.forbidden, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<ForbiddenBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (digest === \"NEXT_HTTP_ERROR_FALLBACK;403\") {\n return { forbidden: true };\n }\n }\n throw error;\n }\n\n render() {\n if (this.state.forbidden) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\nexport function ForbiddenBoundary({ fallback, children }: ForbiddenBoundaryProps) {\n const pathname = usePathname();\n return (\n <ForbiddenBoundaryInner pathname={pathname} fallback={fallback}>\n {children}\n </ForbiddenBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// UnauthorizedBoundary — catches unauthorized() on the client and renders unauthorized.tsx\n// ---------------------------------------------------------------------------\n\ntype UnauthorizedBoundaryProps = {\n fallback: React.ReactNode;\n children: React.ReactNode;\n};\n\ntype UnauthorizedBoundaryInnerProps = {\n pathname: string;\n} & UnauthorizedBoundaryProps;\n\ntype UnauthorizedBoundaryState = {\n unauthorized: boolean;\n previousPathname: string;\n};\n\nexport class UnauthorizedBoundaryInner extends React.Component<\n UnauthorizedBoundaryInnerProps,\n UnauthorizedBoundaryState\n> {\n constructor(props: UnauthorizedBoundaryInnerProps) {\n super(props);\n this.state = { unauthorized: false, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromProps(\n props: UnauthorizedBoundaryInnerProps,\n state: UnauthorizedBoundaryState,\n ): UnauthorizedBoundaryState | null {\n if (props.pathname !== state.previousPathname && state.unauthorized) {\n return { unauthorized: false, previousPathname: props.pathname };\n }\n return { unauthorized: state.unauthorized, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<UnauthorizedBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (digest === \"NEXT_HTTP_ERROR_FALLBACK;401\") {\n return { unauthorized: true };\n }\n }\n throw error;\n }\n\n render() {\n if (this.state.unauthorized) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\nexport function UnauthorizedBoundary({ fallback, children }: UnauthorizedBoundaryProps) {\n const pathname = usePathname();\n return (\n <UnauthorizedBoundaryInner pathname={pathname} fallback={fallback}>\n {children}\n </UnauthorizedBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// DevRecoveryBoundary — dev-only top-level boundary inside BrowserRoot.\n// Catches any render error that isn't already handled by a user-defined\n// error.tsx (or the access-fallback boundaries above), renders nothing, and\n// keeps BrowserRoot mounted so HMR can dispatch a new RSC payload without a\n// full page reload. Resets on resetKey change — the caller bumps that key\n// (e.g. via treeState.renderId) when a fresh tree is dispatched.\n//\n// Routing sentinels are re-thrown so notFound()/redirect()/forbidden()/\n// unauthorized() still reach their dedicated boundaries above.\n// ---------------------------------------------------------------------------\n\nexport type DevRecoveryBoundaryProps = {\n resetKey: number;\n // Called from componentDidCatch with the current resetKey so the host can\n // run any pending side effects that NavigationCommitSignal would normally\n // drive on commit — most importantly the URL update for the in-flight\n // soft-nav. Without this, a navigation that fails mid-render leaves the\n // browser on the previous URL even though the boundary recovered.\n //\n // The error itself is intentionally not passed: React's onCaughtError option\n // already routes the error to the dev overlay, so this callback is only for\n // commit-side effects keyed by resetKey.\n onCatch?: (resetKey: number) => void;\n // Children come through React.Component's PropsWithChildren default; declared\n // optional so callers can pass them positionally to createElement without\n // tripping the eslint no-children-prop rule.\n children?: React.ReactNode;\n};\n\ntype DevRecoveryBoundaryState = {\n error: CapturedError | null;\n previousResetKey: number;\n};\n\nexport class DevRecoveryBoundary extends React.Component<\n DevRecoveryBoundaryProps,\n DevRecoveryBoundaryState\n> {\n constructor(props: DevRecoveryBoundaryProps) {\n super(props);\n this.state = { error: null, previousResetKey: props.resetKey };\n }\n\n static getDerivedStateFromProps(\n props: DevRecoveryBoundaryProps,\n state: DevRecoveryBoundaryState,\n ): DevRecoveryBoundaryState | null {\n if (props.resetKey === state.previousResetKey) {\n return null;\n }\n return { error: null, previousResetKey: props.resetKey };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<DevRecoveryBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (\n digest === \"NEXT_NOT_FOUND\" ||\n digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;\") ||\n digest.startsWith(\"NEXT_REDIRECT;\")\n ) {\n throw error;\n }\n }\n return { error: { thrownValue: error } };\n }\n\n componentDidCatch(): void {\n this.props.onCatch?.(this.props.resetKey);\n }\n\n render() {\n if (this.state.error) {\n // Render nothing — the dev overlay (mounted in a separate React root)\n // shows the actual error to the developer. HMR pushing a new payload\n // bumps resetKey above, clearing this state and letting the children\n // re-render with the fixed code.\n return null;\n }\n return this.props.children;\n }\n}\n"],"mappings":";;;;;;;;;;AA8BA,IAAa,qBAAb,cAAwC,MAAM,UAG5C;CACA,YAAY,OAAgC;AAC1C,QAAM,MAAM;AACZ,OAAK,QAAQ;GAAE,OAAO;GAAM,kBAAkB,MAAM;GAAU;;CAGhE,OAAO,yBACL,OACA,OAC2B;AAC3B,MAAI,MAAM,aAAa,MAAM,oBAAoB,MAAM,MACrD,QAAO;GAAE,OAAO;GAAM,kBAAkB,MAAM;GAAU;AAE1D,SAAO;GAAE,OAAO,MAAM;GAAO,kBAAkB,MAAM;GAAU;;CAGjE,OAAO,yBAAyB,OAA6C;AAI3E,MAAI,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO;GAC3D,MAAM,SAAS,OAAO,MAAM,OAAO;AACnC,OACE,WAAW,oBACX,OAAO,WAAW,4BAA4B,IAC9C,OAAO,WAAW,iBAAiB,CAEnC,OAAM;;AAGV,SAAO,EAAE,OAAO,EAAE,aAAa,OAAO,EAAE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AM,UAG7C;CACA,YAAY,OAAiC;AAC3C,QAAM,MAAM;AACZ,OAAK,QAAQ;GAAE,OAAO;GAAM,kBAAkB,MAAM;GAAU;;CAGhE,OAAO,yBACL,OACA,OACiC;AACjC,MAAI,MAAM,aAAa,MAAM,iBAC3B,QAAO;AAET,SAAO;GAAE,OAAO;GAAM,kBAAkB,MAAM;GAAU;;CAG1D,OAAO,yBAAyB,OAAmD;AACjF,MAAI,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO;GAC3D,MAAM,SAAS,OAAO,MAAM,OAAO;AACnC,OACE,WAAW,oBACX,OAAO,WAAW,4BAA4B,IAC9C,OAAO,WAAW,iBAAiB,CAEnC,OAAM;;AAGV,SAAO,EAAE,OAAO,EAAE,aAAa,OAAO,EAAE;;CAG1C,oBAA0B;AACxB,OAAK,MAAM,UAAU,KAAK,MAAM,SAAS;;CAG3C,SAAS;AACP,MAAI,KAAK,MAAM,MAKb,QAAO;AAET,SAAO,KAAK,MAAM"}
|
|
1
|
+
{"version":3,"file":"error-boundary.js","names":[],"sources":["../../src/shims/error-boundary.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\n// Import the local shim, not the public next/navigation alias. The built\n// package may execute this file before the plugin's resolveId hook is active.\nimport { usePathname, useRouter } from \"./navigation.js\";\nimport { getErrorDigest, isNavigationSignalError } from \"../utils/navigation-signal.js\";\n\nexport type ErrorBoundaryProps = {\n fallback: React.ComponentType<{ error: unknown; reset: () => void }>;\n children: React.ReactNode;\n resetKey?: string | null;\n};\n\ntype CapturedError = {\n thrownValue: unknown;\n};\n\ntype RedirectBoundaryState = {\n redirect: string | null;\n redirectType: \"push\" | \"replace\" | null;\n};\n\ntype RedirectError = Error & {\n digest: string;\n handled?: boolean;\n};\n\ntype ErrorBoundaryInnerProps = {\n pathname: string;\n} & ErrorBoundaryProps;\n\nexport type ErrorBoundaryState = {\n error: CapturedError | null;\n previousPathname: string;\n previousResetKey: string | null;\n};\n\ntype BoundaryResetProps = {\n pathname: string;\n resetKey?: string | null;\n};\n\ntype BoundaryResetState = {\n previousPathname: string;\n previousResetKey: string | null;\n};\n\nfunction normalizeBoundaryResetKey(resetKey: string | null | undefined): string | null {\n return resetKey === undefined || resetKey === null || resetKey === \"\" ? null : resetKey;\n}\n\nfunction readBoundaryResetState(props: BoundaryResetProps): BoundaryResetState {\n return {\n previousPathname: props.pathname,\n previousResetKey: normalizeBoundaryResetKey(props.resetKey),\n };\n}\n\nfunction shouldResetBoundary(\n nextResetState: BoundaryResetState,\n previousResetState: BoundaryResetState,\n): boolean {\n const nextResetKey = normalizeBoundaryResetKey(nextResetState.previousResetKey);\n const previousResetKey = normalizeBoundaryResetKey(previousResetState.previousResetKey);\n\n if (nextResetKey !== null || previousResetKey !== null) {\n return nextResetKey !== previousResetKey;\n }\n\n return nextResetState.previousPathname !== previousResetState.previousPathname;\n}\n\nfunction isRedirectError(error: unknown): error is RedirectError {\n return getErrorDigest(error)?.startsWith(\"NEXT_REDIRECT;\") ?? false;\n}\n\nfunction decodeRedirectTarget(target: string): string {\n try {\n return decodeURIComponent(target);\n } catch {\n return target;\n }\n}\n\nfunction getURLFromRedirectError(error: RedirectError): string | null {\n const parts = error.digest.split(\";\");\n // vinext emits 3-part (redirect: `NEXT_REDIRECT;;<encoded>`) or 4-part\n // (permanentRedirect: `NEXT_REDIRECT;<type>;<encoded>;308`) digests;\n // Next.js emits 5-part digests (`NEXT_REDIRECT;<type>;<url>;<status>;<isClient>`).\n // vinext's `isRedirectError` is more permissive (just `startsWith(\"NEXT_REDIRECT;\")`)\n // so we branch on length rather than always using `slice(2, -2)`.\n const encodedTarget = parts.length >= 5 ? parts.slice(2, -2).join(\";\") : parts[2];\n return encodedTarget ? decodeRedirectTarget(encodedTarget) : null;\n}\n\nfunction getRedirectTypeFromError(error: RedirectError): \"push\" | \"replace\" {\n const type = error.digest.split(\";\", 2)[1];\n return type === \"push\" ? \"push\" : \"replace\";\n}\n\nfunction HandleRedirect({\n redirect,\n redirectType,\n}: {\n redirect: string;\n redirectType: \"push\" | \"replace\";\n}) {\n const router = useRouter();\n\n React.useEffect(() => {\n React.startTransition(() => {\n if (redirectType === \"push\") {\n router.push(redirect);\n } else {\n router.replace(redirect);\n }\n // Intentionally no reset() here. The boundary stays in its \"redirect\n // caught\" state (rendering this component, which returns null) until\n // router.push()/replace() triggers a new render at the destination\n // route. That naturally unmounts this boundary and mounts a fresh one.\n // Calling reset() would clear the boundary state, causing React to\n // re-render children — which re-mounts the page component that threw\n // redirect() in the first place. For deterministic redirects (e.g.\n // auth guards), that creates an infinite redirect loop.\n // Matches Next.js's HandleRedirect in redirect-boundary.tsx.\n });\n }, [redirect, redirectType, router]);\n\n return null;\n}\n\nexport class RedirectErrorBoundary extends React.Component<\n { children?: React.ReactNode },\n RedirectBoundaryState\n> {\n constructor(props: { children?: React.ReactNode }) {\n super(props);\n this.state = {\n redirect: null,\n redirectType: null,\n };\n }\n\n static getDerivedStateFromError(error: unknown): RedirectBoundaryState {\n if (isRedirectError(error)) {\n // Next.js parity: an outer RedirectBoundary that has already started\n // handling a redirect marks the error as `handled` so that, if React\n // re-throws the same error during a retry render, an inner boundary\n // doesn't re-dispatch the same `router.replace()`. Vinext doesn't\n // currently emit `handled` itself (we never assign it on the error\n // object), but we keep the branch so behavior matches Next.js if a\n // host or future change ever does.\n if (error.handled) {\n return {\n redirect: null,\n redirectType: null,\n };\n }\n\n const url = getURLFromRedirectError(error);\n if (url === null) {\n // Malformed digest (e.g. `NEXT_REDIRECT;push;` with an empty URL\n // segment). The server-side parser at next-error-digest.ts:51 also\n // rejects this. Re-throw so the error reaches a regular error\n // boundary instead of being silently swallowed.\n throw error;\n }\n\n return {\n redirect: url,\n redirectType: getRedirectTypeFromError(error),\n };\n }\n\n throw error;\n }\n\n render() {\n const { redirect, redirectType } = this.state;\n if (redirect !== null && redirectType !== null) {\n return <HandleRedirect redirect={redirect} redirectType={redirectType} />;\n }\n\n return this.props.children;\n }\n}\n\nexport function RedirectBoundary({ children }: { children?: React.ReactNode }) {\n return <RedirectErrorBoundary>{children}</RedirectErrorBoundary>;\n}\n\n/**\n * Generic ErrorBoundary used to wrap route segments with error.tsx.\n * This must be a client component since error boundaries use\n * componentDidCatch / getDerivedStateFromError.\n */\nexport class ErrorBoundaryInner extends React.Component<\n ErrorBoundaryInnerProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryInnerProps) {\n super(props);\n this.state = { error: null, ...readBoundaryResetState(props) };\n }\n\n static getDerivedStateFromProps(\n props: ErrorBoundaryInnerProps,\n state: ErrorBoundaryState,\n ): ErrorBoundaryState | null {\n const nextResetState = readBoundaryResetState(props);\n if (state.error && shouldResetBoundary(nextResetState, state)) {\n return { error: null, ...nextResetState };\n }\n return { error: state.error, ...nextResetState };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<ErrorBoundaryState> {\n // notFound(), forbidden(), unauthorized(), and redirect() must propagate\n // past error boundaries. Re-throw them so they bubble up to the\n // framework's HTTP access fallback / redirect handler.\n if (isNavigationSignalError(error)) {\n throw error;\n }\n return { error: { thrownValue: error } };\n }\n\n reset = () => {\n this.setState({ error: null });\n };\n\n render() {\n if (this.state.error) {\n const FallbackComponent = this.props.fallback;\n return <FallbackComponent error={this.state.error.thrownValue} reset={this.reset} />;\n }\n return this.props.children;\n }\n}\n\nexport function ErrorBoundary({ fallback, children, resetKey }: ErrorBoundaryProps) {\n const pathname = usePathname();\n return (\n <ErrorBoundaryInner pathname={pathname} resetKey={resetKey} fallback={fallback}>\n {children}\n </ErrorBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// NotFoundBoundary — catches notFound() on the client and renders not-found.tsx\n// ---------------------------------------------------------------------------\n\ntype NotFoundBoundaryProps = {\n fallback: React.ReactNode;\n children: React.ReactNode;\n resetKey?: string | null;\n};\n\ntype NotFoundBoundaryInnerProps = {\n pathname: string;\n} & NotFoundBoundaryProps;\n\ntype NotFoundBoundaryState = {\n notFound: boolean;\n previousPathname: string;\n previousResetKey: string | null;\n};\n\n/**\n * Inner class component that catches notFound() errors and renders the\n * not-found.tsx fallback. Resets on the caller's segment reset key when one is\n * provided, otherwise falls back to pathname changes for legacy callers.\n *\n * The ErrorBoundary above re-throws notFound errors so they propagate up to this\n * boundary. This must be placed above the ErrorBoundary in the component tree.\n */\nclass NotFoundBoundaryInner extends React.Component<\n NotFoundBoundaryInnerProps,\n NotFoundBoundaryState\n> {\n constructor(props: NotFoundBoundaryInnerProps) {\n super(props);\n this.state = { notFound: false, ...readBoundaryResetState(props) };\n }\n\n static getDerivedStateFromProps(\n props: NotFoundBoundaryInnerProps,\n state: NotFoundBoundaryState,\n ): NotFoundBoundaryState | null {\n const nextResetState = readBoundaryResetState(props);\n if (state.notFound && shouldResetBoundary(nextResetState, state)) {\n return { notFound: false, ...nextResetState };\n }\n return { notFound: state.notFound, ...nextResetState };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<NotFoundBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (digest === \"NEXT_NOT_FOUND\" || digest === \"NEXT_HTTP_ERROR_FALLBACK;404\") {\n return { notFound: true };\n }\n }\n // Not a notFound error — re-throw so it reaches an ErrorBoundary or propagates\n throw error;\n }\n\n render() {\n if (this.state.notFound) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\n/**\n * Wrapper that reads the current pathname and passes it to the inner class\n * component. Segment reset keys own App Router remount semantics when present.\n */\nexport function NotFoundBoundary({ fallback, children, resetKey }: NotFoundBoundaryProps) {\n const pathname = usePathname();\n return (\n <NotFoundBoundaryInner pathname={pathname} resetKey={resetKey} fallback={fallback}>\n {children}\n </NotFoundBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// ForbiddenBoundary — catches forbidden() on the client and renders forbidden.tsx\n// ---------------------------------------------------------------------------\n\ntype ForbiddenBoundaryProps = {\n fallback: React.ReactNode;\n children: React.ReactNode;\n resetKey?: string | null;\n};\n\ntype ForbiddenBoundaryInnerProps = {\n pathname: string;\n} & ForbiddenBoundaryProps;\n\ntype ForbiddenBoundaryState = {\n forbidden: boolean;\n previousPathname: string;\n previousResetKey: string | null;\n};\n\nexport class ForbiddenBoundaryInner extends React.Component<\n ForbiddenBoundaryInnerProps,\n ForbiddenBoundaryState\n> {\n constructor(props: ForbiddenBoundaryInnerProps) {\n super(props);\n this.state = { forbidden: false, ...readBoundaryResetState(props) };\n }\n\n static getDerivedStateFromProps(\n props: ForbiddenBoundaryInnerProps,\n state: ForbiddenBoundaryState,\n ): ForbiddenBoundaryState | null {\n const nextResetState = readBoundaryResetState(props);\n if (state.forbidden && shouldResetBoundary(nextResetState, state)) {\n return { forbidden: false, ...nextResetState };\n }\n return { forbidden: state.forbidden, ...nextResetState };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<ForbiddenBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (digest === \"NEXT_HTTP_ERROR_FALLBACK;403\") {\n return { forbidden: true };\n }\n }\n throw error;\n }\n\n render() {\n if (this.state.forbidden) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\nexport function ForbiddenBoundary({ fallback, children, resetKey }: ForbiddenBoundaryProps) {\n const pathname = usePathname();\n return (\n <ForbiddenBoundaryInner pathname={pathname} resetKey={resetKey} fallback={fallback}>\n {children}\n </ForbiddenBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// UnauthorizedBoundary — catches unauthorized() on the client and renders unauthorized.tsx\n// ---------------------------------------------------------------------------\n\ntype UnauthorizedBoundaryProps = {\n fallback: React.ReactNode;\n children: React.ReactNode;\n resetKey?: string | null;\n};\n\ntype UnauthorizedBoundaryInnerProps = {\n pathname: string;\n} & UnauthorizedBoundaryProps;\n\ntype UnauthorizedBoundaryState = {\n unauthorized: boolean;\n previousPathname: string;\n previousResetKey: string | null;\n};\n\nexport class UnauthorizedBoundaryInner extends React.Component<\n UnauthorizedBoundaryInnerProps,\n UnauthorizedBoundaryState\n> {\n constructor(props: UnauthorizedBoundaryInnerProps) {\n super(props);\n this.state = { unauthorized: false, ...readBoundaryResetState(props) };\n }\n\n static getDerivedStateFromProps(\n props: UnauthorizedBoundaryInnerProps,\n state: UnauthorizedBoundaryState,\n ): UnauthorizedBoundaryState | null {\n const nextResetState = readBoundaryResetState(props);\n if (state.unauthorized && shouldResetBoundary(nextResetState, state)) {\n return { unauthorized: false, ...nextResetState };\n }\n return { unauthorized: state.unauthorized, ...nextResetState };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<UnauthorizedBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String(error.digest);\n if (digest === \"NEXT_HTTP_ERROR_FALLBACK;401\") {\n return { unauthorized: true };\n }\n }\n throw error;\n }\n\n render() {\n if (this.state.unauthorized) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\nexport function UnauthorizedBoundary({ fallback, children, resetKey }: UnauthorizedBoundaryProps) {\n const pathname = usePathname();\n return (\n <UnauthorizedBoundaryInner pathname={pathname} resetKey={resetKey} fallback={fallback}>\n {children}\n </UnauthorizedBoundaryInner>\n );\n}\n\n// ---------------------------------------------------------------------------\n// DevRecoveryBoundary — dev-only top-level boundary inside BrowserRoot.\n// Catches any render error that isn't already handled by a user-defined\n// error.tsx (or the access-fallback boundaries above), renders nothing, and\n// keeps BrowserRoot mounted so HMR can dispatch a new RSC payload without a\n// full page reload. Resets on resetKey change — the caller bumps that key\n// (e.g. via treeState.renderId) when a fresh tree is dispatched.\n//\n// Routing sentinels are re-thrown so notFound()/redirect()/forbidden()/\n// unauthorized() still reach their dedicated boundaries above.\n// ---------------------------------------------------------------------------\n\nexport type DevRecoveryBoundaryProps = {\n resetKey: number;\n // Called from componentDidCatch with the current resetKey so the host can\n // run any pending side effects that NavigationCommitSignal would normally\n // drive on commit — most importantly the URL update for the in-flight\n // soft-nav. Without this, a navigation that fails mid-render leaves the\n // browser on the previous URL even though the boundary recovered.\n //\n // The error itself is intentionally not passed: React's onCaughtError option\n // already routes the error to the dev overlay, so this callback is only for\n // commit-side effects keyed by resetKey.\n onCatch?: (resetKey: number) => void;\n // Children come through React.Component's PropsWithChildren default; declared\n // optional so callers can pass them positionally to createElement without\n // tripping the eslint no-children-prop rule.\n children?: React.ReactNode;\n};\n\ntype DevRecoveryBoundaryState = {\n error: CapturedError | null;\n previousResetKey: number;\n};\n\nexport class DevRecoveryBoundary extends React.Component<\n DevRecoveryBoundaryProps,\n DevRecoveryBoundaryState\n> {\n constructor(props: DevRecoveryBoundaryProps) {\n super(props);\n this.state = { error: null, previousResetKey: props.resetKey };\n }\n\n static getDerivedStateFromProps(\n props: DevRecoveryBoundaryProps,\n state: DevRecoveryBoundaryState,\n ): DevRecoveryBoundaryState | null {\n if (props.resetKey === state.previousResetKey) {\n return null;\n }\n return { error: null, previousResetKey: props.resetKey };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<DevRecoveryBoundaryState> {\n // Re-throw routing sentinels so they still reach NotFoundBoundary /\n // RedirectBoundary / Forbidden / Unauthorized above.\n if (isNavigationSignalError(error)) {\n throw error;\n }\n return { error: { thrownValue: error } };\n }\n\n componentDidCatch(): void {\n this.props.onCatch?.(this.props.resetKey);\n }\n\n render() {\n if (this.state.error) {\n // Render nothing — the dev overlay (mounted in a separate React root)\n // shows the actual error to the developer. HMR pushing a new payload\n // bumps resetKey above, clearing this state and letting the children\n // re-render with the fixed code.\n return null;\n }\n return this.props.children;\n }\n}\n"],"mappings":";;;;;;AAgDA,SAAS,0BAA0B,UAAoD;CACrF,OAAO,aAAa,KAAA,KAAa,aAAa,QAAQ,aAAa,KAAK,OAAO;;AAGjF,SAAS,uBAAuB,OAA+C;CAC7E,OAAO;EACL,kBAAkB,MAAM;EACxB,kBAAkB,0BAA0B,MAAM,SAAS;EAC5D;;AAGH,SAAS,oBACP,gBACA,oBACS;CACT,MAAM,eAAe,0BAA0B,eAAe,iBAAiB;CAC/E,MAAM,mBAAmB,0BAA0B,mBAAmB,iBAAiB;C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,IAAI,KAAK,MAAM,OAKb,OAAO;EAET,OAAO,KAAK,MAAM"}
|
package/dist/shims/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../src/shims/error.tsx"],"sourcesContent":["/**\n * next/error shim\n *\n * Provides the default Next.js error page component.\n * Used by apps that import `import Error from 'next/error'` for\n * custom error handling in getServerSideProps or API routes.\n */\nimport React from \"react\";\n\ntype ErrorProps = {\n statusCode: number;\n title?: string;\n withDarkMode?: boolean;\n};\n\nfunction ErrorComponent({ statusCode, title }: ErrorProps): React.ReactElement {\n const defaultTitle =\n statusCode === 404 ? \"This page could not be found\" : \"Internal Server Error\";\n\n const displayTitle = title ?? defaultTitle;\n\n return React.createElement(\n \"div\",\n {\n style: {\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n height: \"100vh\",\n textAlign: \"center\" as const,\n display: \"flex\",\n flexDirection: \"column\" as const,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n },\n React.createElement(\n \"div\",\n null,\n React.createElement(\n \"h1\",\n {\n style: {\n display: \"inline-block\",\n margin: \"0 20px 0 0\",\n padding: \"0 23px 0 0\",\n fontSize: 24,\n fontWeight: 500,\n verticalAlign: \"top\",\n lineHeight: \"49px\",\n borderRight: \"1px solid rgba(0, 0, 0, .3)\",\n },\n },\n statusCode,\n ),\n React.createElement(\n \"div\",\n { style: { display: \"inline-block\" } },\n React.createElement(\n \"h2\",\n {\n style: {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: \"49px\",\n margin: 0,\n },\n },\n displayTitle + \".\",\n ),\n ),\n ),\n );\n}\n\nexport default ErrorComponent;\n"],"mappings":";;;;;;;;;AAeA,SAAS,eAAe,EAAE,YAAY,SAAyC;CAI7E,MAAM,eAAe,UAFnB,eAAe,MAAM,iCAAiC;
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../src/shims/error.tsx"],"sourcesContent":["/**\n * next/error shim\n *\n * Provides the default Next.js error page component.\n * Used by apps that import `import Error from 'next/error'` for\n * custom error handling in getServerSideProps or API routes.\n */\nimport React from \"react\";\n\ntype ErrorProps = {\n statusCode: number;\n title?: string;\n withDarkMode?: boolean;\n};\n\nfunction ErrorComponent({ statusCode, title }: ErrorProps): React.ReactElement {\n const defaultTitle =\n statusCode === 404 ? \"This page could not be found\" : \"Internal Server Error\";\n\n const displayTitle = title ?? defaultTitle;\n\n return React.createElement(\n \"div\",\n {\n style: {\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n height: \"100vh\",\n textAlign: \"center\" as const,\n display: \"flex\",\n flexDirection: \"column\" as const,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n },\n React.createElement(\n \"div\",\n null,\n React.createElement(\n \"h1\",\n {\n style: {\n display: \"inline-block\",\n margin: \"0 20px 0 0\",\n padding: \"0 23px 0 0\",\n fontSize: 24,\n fontWeight: 500,\n verticalAlign: \"top\",\n lineHeight: \"49px\",\n borderRight: \"1px solid rgba(0, 0, 0, .3)\",\n },\n },\n statusCode,\n ),\n React.createElement(\n \"div\",\n { style: { display: \"inline-block\" } },\n React.createElement(\n \"h2\",\n {\n style: {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: \"49px\",\n margin: 0,\n },\n },\n displayTitle + \".\",\n ),\n ),\n ),\n );\n}\n\nexport default ErrorComponent;\n"],"mappings":";;;;;;;;;AAeA,SAAS,eAAe,EAAE,YAAY,SAAyC;CAI7E,MAAM,eAAe,UAFnB,eAAe,MAAM,iCAAiC;CAIxD,OAAO,MAAM,cACX,OACA,EACE,OAAO;EACL,YACE;EACF,QAAQ;EACR,WAAW;EACX,SAAS;EACT,eAAe;EACf,YAAY;EACZ,gBAAgB;EACjB,EACF,EACD,MAAM,cACJ,OACA,MACA,MAAM,cACJ,MACA,EACE,OAAO;EACL,SAAS;EACT,QAAQ;EACR,SAAS;EACT,UAAU;EACV,YAAY;EACZ,eAAe;EACf,YAAY;EACZ,aAAa;EACd,EACF,EACD,WACD,EACD,MAAM,cACJ,OACA,EAAE,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACtC,MAAM,cACJ,MACA,EACE,OAAO;EACL,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,QAAQ;EACT,EACF,EACD,eAAe,IAChB,CACF,CACF,CACF"}
|
|
@@ -23,6 +23,11 @@ type NextFetchOptions = {
|
|
|
23
23
|
revalidate?: number | false;
|
|
24
24
|
tags?: string[];
|
|
25
25
|
};
|
|
26
|
+
type FetchDedupeEntry = {
|
|
27
|
+
key: string;
|
|
28
|
+
promise: Promise<Response>;
|
|
29
|
+
response: Response | null;
|
|
30
|
+
};
|
|
26
31
|
declare global {
|
|
27
32
|
interface RequestInit {
|
|
28
33
|
next?: NextFetchOptions;
|
|
@@ -34,6 +39,8 @@ type FetchCacheState = {
|
|
|
34
39
|
currentRequestTags: string[];
|
|
35
40
|
currentFetchSoftTags: string[];
|
|
36
41
|
currentFetchCacheMode: FetchCacheMode | null;
|
|
42
|
+
isFetchDedupeActive: boolean;
|
|
43
|
+
currentFetchDedupeEntries: Map<string, FetchDedupeEntry[]>;
|
|
37
44
|
};
|
|
38
45
|
type FetchCacheMode = "auto" | "default-cache" | "default-no-store" | "force-cache" | "force-no-store" | "only-cache" | "only-no-store";
|
|
39
46
|
/**
|
|
@@ -69,6 +76,20 @@ declare function withFetchCache(): () => void;
|
|
|
69
76
|
* of collected fetch tags in concurrent server environments.
|
|
70
77
|
*/
|
|
71
78
|
declare function runWithFetchCache<T>(fn: () => Promise<T>): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Activate per-render fetch memoization without resetting request fetch tags.
|
|
81
|
+
* Next.js request memoization is scoped to React render work, not the whole
|
|
82
|
+
* request pipeline, so route handlers and middleware stay observable.
|
|
83
|
+
*
|
|
84
|
+
* ALS scope lifetime: when `fn` returns synchronously (e.g. wrapping a
|
|
85
|
+
* `renderToReadableStream` call), the ALS scope established here only covers
|
|
86
|
+
* the synchronous portion. Any fetch work that happens later during async
|
|
87
|
+
* stream consumption falls back to the parent ALS store, which is fine when
|
|
88
|
+
* the parent already activated dedupe (the common dispatch case) but means
|
|
89
|
+
* standalone callers must keep the dedupe scope alive across consumption.
|
|
90
|
+
*/
|
|
91
|
+
declare function runWithFetchDedupe<T>(fn: () => T): T;
|
|
92
|
+
declare function runWithFetchDedupe<T>(fn: () => Promise<T>): Promise<T>;
|
|
72
93
|
/**
|
|
73
94
|
* Install the patched fetch without creating a standalone ALS scope.
|
|
74
95
|
*
|
|
@@ -84,5 +105,5 @@ declare function ensureFetchPatch(): void;
|
|
|
84
105
|
*/
|
|
85
106
|
declare function getOriginalFetch(): typeof globalThis.fetch;
|
|
86
107
|
//#endregion
|
|
87
|
-
export { FetchCacheMode, FetchCacheState, _resetPendingRefetches, ensureFetchPatch, getCollectedFetchTags, getOriginalFetch, runWithFetchCache, setCurrentFetchCacheMode, setCurrentFetchSoftTags, withFetchCache };
|
|
108
|
+
export { FetchCacheMode, FetchCacheState, _resetPendingRefetches, ensureFetchPatch, getCollectedFetchTags, getOriginalFetch, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, withFetchCache };
|
|
88
109
|
//# sourceMappingURL=fetch-cache.d.ts.map
|