vinext 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/build/prerender.d.ts +188 -0
- package/dist/build/prerender.js +675 -0
- package/dist/build/prerender.js.map +1 -0
- package/dist/build/report.d.ts +45 -46
- package/dist/build/report.js +247 -276
- package/dist/build/report.js.map +1 -1
- package/dist/build/run-prerender.d.ts +62 -0
- package/dist/build/run-prerender.js +183 -0
- package/dist/build/run-prerender.js.map +1 -0
- package/dist/build/server-manifest.d.ts +19 -0
- package/dist/build/server-manifest.js +29 -0
- package/dist/build/server-manifest.js.map +1 -0
- package/dist/build/static-export.d.ts +51 -66
- package/dist/build/static-export.js +51 -545
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.d.ts +26 -24
- package/dist/check.js +591 -571
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +1 -15
- package/dist/cli.js +430 -491
- package/dist/cli.js.map +1 -1
- package/dist/client/entry.d.ts +1 -2
- package/dist/client/entry.js +49 -62
- package/dist/client/entry.js.map +1 -1
- package/dist/client/validate-module-path.d.ts +4 -1
- package/dist/client/validate-module-path.js +23 -28
- package/dist/client/validate-module-path.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +15 -20
- package/dist/client/vinext-next-data.js +0 -1
- package/dist/cloudflare/index.d.ts +3 -8
- package/dist/cloudflare/index.js +3 -8
- package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
- package/dist/cloudflare/kv-cache-handler.js +354 -380
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.d.ts +36 -34
- package/dist/cloudflare/tpr.js +460 -603
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +31 -40
- package/dist/config/config-matchers.js +727 -936
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +18 -11
- package/dist/config/dotenv.js +79 -84
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +156 -146
- package/dist/config/next-config.js +374 -464
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts +87 -96
- package/dist/deploy.js +490 -628
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +4 -1
- package/dist/entries/app-browser-entry.js +12 -8
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +33 -20
- package/dist/entries/app-rsc-entry.js +442 -211
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +9 -1
- package/dist/entries/app-ssr-entry.js +61 -28
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +6 -2
- package/dist/entries/pages-client-entry.js +30 -33
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-entry-helpers.d.ts +5 -1
- package/dist/entries/pages-entry-helpers.js +17 -14
- package/dist/entries/pages-entry-helpers.js.map +1 -1
- package/dist/entries/pages-server-entry.d.ts +6 -2
- package/dist/entries/pages-server-entry.js +84 -113
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +82 -62
- package/dist/index.js +2172 -3133
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +40 -37
- package/dist/init.js +201 -258
- package/dist/init.js.map +1 -1
- package/dist/plugins/async-hooks-stub.d.ts +7 -3
- package/dist/plugins/async-hooks-stub.js +39 -42
- package/dist/plugins/async-hooks-stub.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +7 -3
- package/dist/plugins/client-reference-dedup.js +63 -88
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/routing/app-router.d.ts +100 -96
- package/dist/routing/app-router.js +560 -670
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +18 -15
- package/dist/routing/file-matcher.js +65 -65
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +23 -24
- package/dist/routing/pages-router.js +147 -172
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/route-trie.d.ts +23 -20
- package/dist/routing/route-trie.js +131 -151
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/route-validation.d.ts +5 -2
- package/dist/routing/route-validation.js +98 -130
- package/dist/routing/route-validation.js.map +1 -1
- package/dist/routing/utils.d.ts +10 -7
- package/dist/routing/utils.js +75 -111
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.d.ts +8 -13
- package/dist/server/api-handler.js +161 -193
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-router-entry.d.ts +6 -16
- package/dist/server/app-router-entry.js +26 -54
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/dev-module-runner.d.ts +11 -64
- package/dist/server/dev-module-runner.js +89 -101
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/dev-origin-check.d.ts +12 -10
- package/dist/server/dev-origin-check.js +98 -108
- package/dist/server/dev-origin-check.js.map +1 -1
- package/dist/server/dev-server.d.ts +17 -14
- package/dist/server/dev-server.js +542 -869
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/html.d.ts +4 -1
- package/dist/server/html.js +25 -26
- package/dist/server/html.js.map +1 -1
- package/dist/server/image-optimization.d.ts +31 -28
- package/dist/server/image-optimization.js +181 -210
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/instrumentation.d.ts +25 -22
- package/dist/server/instrumentation.js +110 -122
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +16 -26
- package/dist/server/isr-cache.js +106 -128
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-routes.d.ts +85 -88
- package/dist/server/metadata-routes.js +270 -317
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-codegen.d.ts +7 -4
- package/dist/server/middleware-codegen.js +61 -61
- package/dist/server/middleware-codegen.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +8 -6
- package/dist/server/middleware-request-headers.js +47 -65
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware.d.ts +31 -47
- package/dist/server/middleware.js +273 -404
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/normalize-path.d.ts +4 -1
- package/dist/server/normalize-path.js +33 -47
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-i18n.d.ts +38 -30
- package/dist/server/pages-i18n.js +112 -139
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/prod-server.d.ts +19 -31
- package/dist/server/prod-server.js +714 -945
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.d.ts +18 -12
- package/dist/server/request-log.js +45 -52
- package/dist/server/request-log.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +9 -17
- package/dist/server/request-pipeline.js +133 -184
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/worker-utils.d.ts +4 -1
- package/dist/server/worker-utils.js +31 -37
- package/dist/server/worker-utils.js.map +1 -1
- package/dist/shims/amp.d.ts +5 -2
- package/dist/shims/amp.js +19 -15
- package/dist/shims/amp.js.map +1 -1
- package/dist/shims/app.d.ts +8 -10
- package/dist/shims/app.js +0 -1
- package/dist/shims/cache-runtime.d.ts +20 -45
- package/dist/shims/cache-runtime.js +271 -422
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +130 -121
- package/dist/shims/cache.js +339 -427
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-only.d.ts +1 -18
- package/dist/shims/client-only.js +0 -17
- package/dist/shims/compat-router.d.ts +4 -1
- package/dist/shims/compat-router.js +23 -19
- package/dist/shims/compat-router.js.map +1 -1
- package/dist/shims/config.d.ts +7 -5
- package/dist/shims/config.js +16 -23
- package/dist/shims/config.js.map +1 -1
- package/dist/shims/constants.d.ts +119 -118
- package/dist/shims/constants.js +159 -164
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/document.d.ts +20 -16
- package/dist/shims/document.js +41 -22
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/dynamic.d.ts +13 -22
- package/dist/shims/dynamic.js +122 -136
- package/dist/shims/dynamic.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +22 -15
- package/dist/shims/error-boundary.js +81 -79
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +11 -12
- package/dist/shims/error.js +35 -39
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +16 -14
- package/dist/shims/fetch-cache.js +437 -645
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +28 -26
- package/dist/shims/font-google-base.js +238 -325
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-google.d.ts +3 -3
- package/dist/shims/font-google.generated.d.ts +1928 -1924
- package/dist/shims/font-google.generated.js +1928 -2133
- package/dist/shims/font-google.generated.js.map +1 -1
- package/dist/shims/font-google.js +3 -3
- package/dist/shims/font-local.d.ts +28 -26
- package/dist/shims/font-local.js +204 -260
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.d.ts +13 -27
- package/dist/shims/form.js +128 -180
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head-state.d.ts +8 -13
- package/dist/shims/head-state.js +25 -42
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +16 -20
- package/dist/shims/head.js +172 -250
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +84 -78
- package/dist/shims/headers.js +447 -575
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-context.d.ts +16 -20
- package/dist/shims/i18n-context.js +35 -48
- package/dist/shims/i18n-context.js.map +1 -1
- package/dist/shims/i18n-state.d.ts +8 -14
- package/dist/shims/i18n-state.js +34 -42
- package/dist/shims/i18n-state.js.map +1 -1
- package/dist/shims/image-config.d.ts +11 -8
- package/dist/shims/image-config.js +50 -83
- package/dist/shims/image-config.js.map +1 -1
- package/dist/shims/image.d.ts +37 -46
- package/dist/shims/image.js +283 -308
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/api-utils.d.ts +7 -4
- package/dist/shims/internal/api-utils.js +0 -6
- package/dist/shims/internal/app-router-context.d.ts +22 -17
- package/dist/shims/internal/app-router-context.js +17 -13
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/internal/cookies.d.ts +2 -9
- package/dist/shims/internal/cookies.js +2 -9
- package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
- package/dist/shims/internal/parse-cookie-header.js +29 -29
- package/dist/shims/internal/parse-cookie-header.js.map +1 -1
- package/dist/shims/internal/router-context.d.ts +6 -1
- package/dist/shims/internal/router-context.js +11 -7
- package/dist/shims/internal/router-context.js.map +1 -1
- package/dist/shims/internal/utils.d.ts +40 -37
- package/dist/shims/internal/utils.js +24 -30
- package/dist/shims/internal/utils.js.map +1 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
- package/dist/shims/internal/work-unit-async-storage.js +14 -11
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
- package/dist/shims/layout-segment-context.d.ts +11 -14
- package/dist/shims/layout-segment-context.js +24 -23
- package/dist/shims/layout-segment-context.js.map +1 -1
- package/dist/shims/legacy-image.d.ts +39 -46
- package/dist/shims/legacy-image.js +47 -42
- package/dist/shims/legacy-image.js.map +1 -1
- package/dist/shims/link.d.ts +32 -36
- package/dist/shims/link.js +255 -391
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +210 -202
- package/dist/shims/metadata.js +545 -546
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.d.ts +10 -18
- package/dist/shims/navigation-state.js +66 -74
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +59 -63
- package/dist/shims/navigation.js +505 -704
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +2 -20
- package/dist/shims/og.js +2 -19
- package/dist/shims/readonly-url-search-params.d.ts +8 -5
- package/dist/shims/readonly-url-search-params.js +26 -22
- package/dist/shims/readonly-url-search-params.js.map +1 -1
- package/dist/shims/request-context.d.ts +8 -5
- package/dist/shims/request-context.js +50 -60
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/request-state-types.d.ts +11 -11
- package/dist/shims/request-state-types.js +0 -1
- package/dist/shims/router-state.d.ts +13 -10
- package/dist/shims/router-state.js +34 -43
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +81 -85
- package/dist/shims/router.js +506 -628
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +39 -48
- package/dist/shims/script.js +107 -160
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server-only.d.ts +1 -19
- package/dist/shims/server-only.js +0 -18
- package/dist/shims/server.d.ts +175 -164
- package/dist/shims/server.js +462 -478
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +20 -20
- package/dist/shims/unified-request-context.js +81 -99
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/url-safety.d.ts +4 -1
- package/dist/shims/url-safety.js +15 -11
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +8 -5
- package/dist/shims/url-utils.js +62 -93
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/shims/web-vitals.d.ts +10 -8
- package/dist/shims/web-vitals.js +9 -15
- package/dist/shims/web-vitals.js.map +1 -1
- package/dist/utils/base-path.d.ts +5 -2
- package/dist/utils/base-path.js +21 -19
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +17 -9
- package/dist/utils/domain-locale.js +36 -56
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/hash.d.ts +4 -1
- package/dist/utils/hash.js +19 -17
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/manifest-paths.d.ts +6 -3
- package/dist/utils/manifest-paths.js +15 -16
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/project.d.ts +13 -11
- package/dist/utils/project.js +169 -216
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/query.d.ts +8 -6
- package/dist/utils/query.js +57 -67
- package/dist/utils/query.js.map +1 -1
- package/package.json +10 -9
- package/dist/build/report.d.ts.map +0 -1
- package/dist/build/static-export.d.ts.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/entry.d.ts.map +0 -1
- package/dist/client/validate-module-path.d.ts.map +0 -1
- package/dist/client/vinext-next-data.d.ts.map +0 -1
- package/dist/client/vinext-next-data.js.map +0 -1
- package/dist/cloudflare/index.d.ts.map +0 -1
- package/dist/cloudflare/index.js.map +0 -1
- package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
- package/dist/cloudflare/tpr.d.ts.map +0 -1
- package/dist/config/config-matchers.d.ts.map +0 -1
- package/dist/config/dotenv.d.ts.map +0 -1
- package/dist/config/next-config.d.ts.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/entries/app-browser-entry.d.ts.map +0 -1
- package/dist/entries/app-rsc-entry.d.ts.map +0 -1
- package/dist/entries/app-ssr-entry.d.ts.map +0 -1
- package/dist/entries/pages-client-entry.d.ts.map +0 -1
- package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
- package/dist/entries/pages-server-entry.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init.d.ts.map +0 -1
- package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
- package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
- package/dist/routing/app-router.d.ts.map +0 -1
- package/dist/routing/file-matcher.d.ts.map +0 -1
- package/dist/routing/pages-router.d.ts.map +0 -1
- package/dist/routing/route-trie.d.ts.map +0 -1
- package/dist/routing/route-validation.d.ts.map +0 -1
- package/dist/routing/utils.d.ts.map +0 -1
- package/dist/server/api-handler.d.ts.map +0 -1
- package/dist/server/app-router-entry.d.ts.map +0 -1
- package/dist/server/dev-module-runner.d.ts.map +0 -1
- package/dist/server/dev-origin-check.d.ts.map +0 -1
- package/dist/server/dev-server.d.ts.map +0 -1
- package/dist/server/html.d.ts.map +0 -1
- package/dist/server/image-optimization.d.ts.map +0 -1
- package/dist/server/instrumentation.d.ts.map +0 -1
- package/dist/server/isr-cache.d.ts.map +0 -1
- package/dist/server/metadata-routes.d.ts.map +0 -1
- package/dist/server/middleware-codegen.d.ts.map +0 -1
- package/dist/server/middleware-request-headers.d.ts.map +0 -1
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/normalize-path.d.ts.map +0 -1
- package/dist/server/pages-i18n.d.ts.map +0 -1
- package/dist/server/prod-server.d.ts.map +0 -1
- package/dist/server/request-log.d.ts.map +0 -1
- package/dist/server/request-pipeline.d.ts.map +0 -1
- package/dist/server/worker-utils.d.ts.map +0 -1
- package/dist/shims/amp.d.ts.map +0 -1
- package/dist/shims/app.d.ts.map +0 -1
- package/dist/shims/app.js.map +0 -1
- package/dist/shims/cache-runtime.d.ts.map +0 -1
- package/dist/shims/cache.d.ts.map +0 -1
- package/dist/shims/client-only.d.ts.map +0 -1
- package/dist/shims/client-only.js.map +0 -1
- package/dist/shims/compat-router.d.ts.map +0 -1
- package/dist/shims/config.d.ts.map +0 -1
- package/dist/shims/constants.d.ts.map +0 -1
- package/dist/shims/document.d.ts.map +0 -1
- package/dist/shims/dynamic.d.ts.map +0 -1
- package/dist/shims/error-boundary.d.ts.map +0 -1
- package/dist/shims/error.d.ts.map +0 -1
- package/dist/shims/fetch-cache.d.ts.map +0 -1
- package/dist/shims/font-google-base.d.ts.map +0 -1
- package/dist/shims/font-google.d.ts.map +0 -1
- package/dist/shims/font-google.generated.d.ts.map +0 -1
- package/dist/shims/font-google.js.map +0 -1
- package/dist/shims/font-local.d.ts.map +0 -1
- package/dist/shims/form.d.ts.map +0 -1
- package/dist/shims/head-state.d.ts.map +0 -1
- package/dist/shims/head.d.ts.map +0 -1
- package/dist/shims/headers.d.ts.map +0 -1
- package/dist/shims/i18n-context.d.ts.map +0 -1
- package/dist/shims/i18n-state.d.ts.map +0 -1
- package/dist/shims/image-config.d.ts.map +0 -1
- package/dist/shims/image.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.js.map +0 -1
- package/dist/shims/internal/app-router-context.d.ts.map +0 -1
- package/dist/shims/internal/cookies.d.ts.map +0 -1
- package/dist/shims/internal/cookies.js.map +0 -1
- package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
- package/dist/shims/internal/router-context.d.ts.map +0 -1
- package/dist/shims/internal/utils.d.ts.map +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
- package/dist/shims/layout-segment-context.d.ts.map +0 -1
- package/dist/shims/legacy-image.d.ts.map +0 -1
- package/dist/shims/link.d.ts.map +0 -1
- package/dist/shims/metadata.d.ts.map +0 -1
- package/dist/shims/navigation-state.d.ts.map +0 -1
- package/dist/shims/navigation.d.ts.map +0 -1
- package/dist/shims/og.d.ts.map +0 -1
- package/dist/shims/og.js.map +0 -1
- package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
- package/dist/shims/request-context.d.ts.map +0 -1
- package/dist/shims/request-state-types.d.ts.map +0 -1
- package/dist/shims/request-state-types.js.map +0 -1
- package/dist/shims/router-state.d.ts.map +0 -1
- package/dist/shims/router.d.ts.map +0 -1
- package/dist/shims/script.d.ts.map +0 -1
- package/dist/shims/server-only.d.ts.map +0 -1
- package/dist/shims/server-only.js.map +0 -1
- package/dist/shims/server.d.ts.map +0 -1
- package/dist/shims/unified-request-context.d.ts.map +0 -1
- package/dist/shims/url-safety.d.ts.map +0 -1
- package/dist/shims/url-utils.d.ts.map +0 -1
- package/dist/shims/web-vitals.d.ts.map +0 -1
- package/dist/utils/base-path.d.ts.map +0 -1
- package/dist/utils/domain-locale.d.ts.map +0 -1
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/manifest-paths.d.ts.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/query.d.ts.map +0 -1
package/dist/shims/dynamic.js
CHANGED
|
@@ -1,149 +1,135 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import React, { Suspense, lazy, useEffect, useState } from "react";
|
|
3
|
+
//#region src/shims/dynamic.ts
|
|
2
4
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import React, { lazy, Suspense, useState, useEffect } from "react";
|
|
5
|
+
* next/dynamic shim
|
|
6
|
+
*
|
|
7
|
+
* SSR-safe dynamic imports. On the server, uses React.lazy + Suspense so that
|
|
8
|
+
* renderToReadableStream suspends until the dynamically-imported component is
|
|
9
|
+
* available. On the client, also uses React.lazy for code splitting.
|
|
10
|
+
*
|
|
11
|
+
* Supports:
|
|
12
|
+
* - dynamic(() => import('./Component'))
|
|
13
|
+
* - dynamic(() => import('./Component'), { loading: () => <Spinner /> })
|
|
14
|
+
* - dynamic(() => import('./Component'), { ssr: false })
|
|
15
|
+
*/
|
|
15
16
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
* Lightweight error boundary that renders the loading component with the error
|
|
18
|
+
* when a dynamic() loader rejects. Without this, loader failures would propagate
|
|
19
|
+
* uncaught through React's rendering — this preserves the Next.js behavior where
|
|
20
|
+
* the `loading` component can display errors.
|
|
21
|
+
*
|
|
22
|
+
* Lazily created because React.Component is not available in the RSC environment
|
|
23
|
+
* (server components use a slimmed-down React that doesn't include class components).
|
|
24
|
+
*/
|
|
24
25
|
let DynamicErrorBoundary;
|
|
25
26
|
function getDynamicErrorBoundary() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return this.props.children;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return DynamicErrorBoundary;
|
|
27
|
+
if (DynamicErrorBoundary) return DynamicErrorBoundary;
|
|
28
|
+
if (!React.Component) return null;
|
|
29
|
+
DynamicErrorBoundary = class extends React.Component {
|
|
30
|
+
constructor(props) {
|
|
31
|
+
super(props);
|
|
32
|
+
this.state = { error: null };
|
|
33
|
+
}
|
|
34
|
+
static getDerivedStateFromError(error) {
|
|
35
|
+
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
if (this.state.error) return React.createElement(this.props.fallback, {
|
|
39
|
+
isLoading: false,
|
|
40
|
+
pastDelay: true,
|
|
41
|
+
error: this.state.error
|
|
42
|
+
});
|
|
43
|
+
return this.props.children;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return DynamicErrorBoundary;
|
|
50
47
|
}
|
|
51
|
-
// Detect server vs client
|
|
52
48
|
const isServer = typeof window === "undefined";
|
|
53
|
-
// Legacy preload queue — kept for backward compatibility with Pages Router
|
|
54
|
-
// which calls flushPreloads() before rendering. The App Router uses React.lazy
|
|
55
|
-
// + Suspense instead, so this queue is no longer populated.
|
|
56
49
|
const preloadQueue = [];
|
|
57
50
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
* Wait for all pending dynamic() preloads to resolve, then clear the queue.
|
|
52
|
+
* Called by the Pages Router SSR handler before rendering.
|
|
53
|
+
* No-op for the App Router path which uses React.lazy + Suspense.
|
|
54
|
+
*/
|
|
55
|
+
function flushPreloads() {
|
|
56
|
+
const pending = preloadQueue.splice(0);
|
|
57
|
+
return Promise.all(pending);
|
|
65
58
|
}
|
|
66
59
|
function dynamic(loader, options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
const ClientDynamic = (props) => {
|
|
140
|
-
const fallback = LoadingComponent
|
|
141
|
-
? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })
|
|
142
|
-
: null;
|
|
143
|
-
return React.createElement(Suspense, { fallback }, React.createElement(LazyComponent, props));
|
|
144
|
-
};
|
|
145
|
-
ClientDynamic.displayName = "DynamicClient";
|
|
146
|
-
return ClientDynamic;
|
|
60
|
+
const { loading: LoadingComponent, ssr = true } = options ?? {};
|
|
61
|
+
if (!ssr) {
|
|
62
|
+
if (isServer) {
|
|
63
|
+
const SSRFalse = (_props) => {
|
|
64
|
+
return LoadingComponent ? React.createElement(LoadingComponent, {
|
|
65
|
+
isLoading: true,
|
|
66
|
+
pastDelay: true,
|
|
67
|
+
error: null
|
|
68
|
+
}) : null;
|
|
69
|
+
};
|
|
70
|
+
SSRFalse.displayName = "DynamicSSRFalse";
|
|
71
|
+
return SSRFalse;
|
|
72
|
+
}
|
|
73
|
+
const LazyComponent = lazy(async () => {
|
|
74
|
+
const mod = await loader();
|
|
75
|
+
if ("default" in mod) return mod;
|
|
76
|
+
return { default: mod };
|
|
77
|
+
});
|
|
78
|
+
const ClientSSRFalse = (props) => {
|
|
79
|
+
const [mounted, setMounted] = useState(false);
|
|
80
|
+
useEffect(() => setMounted(true), []);
|
|
81
|
+
if (!mounted) return LoadingComponent ? React.createElement(LoadingComponent, {
|
|
82
|
+
isLoading: true,
|
|
83
|
+
pastDelay: true,
|
|
84
|
+
error: null
|
|
85
|
+
}) : null;
|
|
86
|
+
const fallback = LoadingComponent ? React.createElement(LoadingComponent, {
|
|
87
|
+
isLoading: true,
|
|
88
|
+
pastDelay: true,
|
|
89
|
+
error: null
|
|
90
|
+
}) : null;
|
|
91
|
+
return React.createElement(Suspense, { fallback }, React.createElement(LazyComponent, props));
|
|
92
|
+
};
|
|
93
|
+
ClientSSRFalse.displayName = "DynamicClientSSRFalse";
|
|
94
|
+
return ClientSSRFalse;
|
|
95
|
+
}
|
|
96
|
+
if (isServer) {
|
|
97
|
+
const LazyServer = lazy(async () => {
|
|
98
|
+
const mod = await loader();
|
|
99
|
+
if ("default" in mod) return mod;
|
|
100
|
+
return { default: mod };
|
|
101
|
+
});
|
|
102
|
+
const ServerDynamic = (props) => {
|
|
103
|
+
const fallback = LoadingComponent ? React.createElement(LoadingComponent, {
|
|
104
|
+
isLoading: true,
|
|
105
|
+
pastDelay: true,
|
|
106
|
+
error: null
|
|
107
|
+
}) : null;
|
|
108
|
+
const lazyElement = React.createElement(LazyServer, props);
|
|
109
|
+
const ErrorBoundary = LoadingComponent ? getDynamicErrorBoundary() : null;
|
|
110
|
+
const content = ErrorBoundary ? React.createElement(ErrorBoundary, { fallback: LoadingComponent }, lazyElement) : lazyElement;
|
|
111
|
+
return React.createElement(Suspense, { fallback }, content);
|
|
112
|
+
};
|
|
113
|
+
ServerDynamic.displayName = "DynamicServer";
|
|
114
|
+
return ServerDynamic;
|
|
115
|
+
}
|
|
116
|
+
const LazyComponent = lazy(async () => {
|
|
117
|
+
const mod = await loader();
|
|
118
|
+
if ("default" in mod) return mod;
|
|
119
|
+
return { default: mod };
|
|
120
|
+
});
|
|
121
|
+
const ClientDynamic = (props) => {
|
|
122
|
+
const fallback = LoadingComponent ? React.createElement(LoadingComponent, {
|
|
123
|
+
isLoading: true,
|
|
124
|
+
pastDelay: true,
|
|
125
|
+
error: null
|
|
126
|
+
}) : null;
|
|
127
|
+
return React.createElement(Suspense, { fallback }, React.createElement(LazyComponent, props));
|
|
128
|
+
};
|
|
129
|
+
ClientDynamic.displayName = "DynamicClient";
|
|
130
|
+
return ClientDynamic;
|
|
147
131
|
}
|
|
148
|
-
|
|
132
|
+
//#endregion
|
|
133
|
+
export { dynamic as default, flushPreloads };
|
|
134
|
+
|
|
149
135
|
//# sourceMappingURL=dynamic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.js","sourceRoot":"","sources":["../../src/shims/dynamic.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAsB,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvF;;;;;;;;GAQG;AACH,IAAI,oBAAyB,CAAC;AAC9B,SAAS,uBAAuB;IAC9B,IAAI,oBAAoB;QAAE,OAAO,oBAAoB,CAAC;IACtD,IAAI,CAAC,KAAK,CAAC,SA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,aAAa;gBAC3B,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,WAAW,CAAC;gBACjF,CAAC,CAAC,WAAW,CAAC;YAChB,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC,CAAC;QAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;QAC5C,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,iDAAiD;IACjD,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;QACpC,MAAM,GAAG,GAAG,MAAM,MAAM,EAAE,CAAC;QAC3B,IAAI,SAAS,IAAI,GAAG;YAAE,OAAO,GAAoC,CAAC;QAClE,OAAO,EAAE,OAAO,EAAE,GAAuB,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,CAAC,KAAQ,EAAE,EAAE;QACjC,MAAM,QAAQ,GAAG,gBAAgB;YAC/B,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YAC1F,CAAC,CAAC,IAAI,CAAC;QACT,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;IAChG,CAAC,CAAC;IAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;IAC5C,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,eAAe,OAAO,CAAC","sourcesContent":["\"use client\";\n/**\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 * Supports:\n * - dynamic(() => import('./Component'))\n * - dynamic(() => import('./Component'), { loading: () => <Spinner /> })\n * - dynamic(() => import('./Component'), { ssr: false })\n */\nimport React, { lazy, Suspense, type ComponentType, useState, useEffect } from \"react\";\n\ninterface 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 */\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 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, just render the loading state or nothing\n const SSRFalse = (_props: P) => {\n return LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n };\n SSRFalse.displayName = \"DynamicSSRFalse\";\n return SSRFalse;\n }\n\n // Client: use lazy with Suspense\n const LazyComponent = 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] = useState(false);\n 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(Suspense, { fallback }, React.createElement(LazyComponent, props));\n };\n\n ClientSSRFalse.displayName = \"DynamicClientSSRFalse\";\n return ClientSSRFalse;\n }\n\n // SSR-enabled path\n if (isServer) {\n // Use React.lazy so that renderToReadableStream can suspend until the\n // dynamically-imported component is available. The previous eager-load\n // pattern relied on flushPreloads() being called before rendering, which\n // works for the Pages Router but not the App Router where client modules\n // are loaded lazily during RSC stream deserialization (issue #75).\n const LazyServer = 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(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 = 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(Suspense, { fallback }, React.createElement(LazyComponent, props));\n };\n\n ClientDynamic.displayName = \"DynamicClient\";\n return ClientDynamic;\n}\n\nexport default dynamic;\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic.js","names":[],"sources":["../../src/shims/dynamic.ts"],"sourcesContent":["\"use client\";\n/**\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 * Supports:\n * - dynamic(() => import('./Component'))\n * - dynamic(() => import('./Component'), { loading: () => <Spinner /> })\n * - dynamic(() => import('./Component'), { ssr: false })\n */\nimport React, { lazy, Suspense, type ComponentType, useState, useEffect } from \"react\";\n\ninterface 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 */\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 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, just render the loading state or nothing\n const SSRFalse = (_props: P) => {\n return LoadingComponent\n ? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })\n : null;\n };\n SSRFalse.displayName = \"DynamicSSRFalse\";\n return SSRFalse;\n }\n\n // Client: use lazy with Suspense\n const LazyComponent = 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] = useState(false);\n 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(Suspense, { fallback }, React.createElement(LazyComponent, props));\n };\n\n ClientSSRFalse.displayName = \"DynamicClientSSRFalse\";\n return ClientSSRFalse;\n }\n\n // SSR-enabled path\n if (isServer) {\n // Use React.lazy so that renderToReadableStream can suspend until the\n // dynamically-imported component is available. The previous eager-load\n // pattern relied on flushPreloads() being called before rendering, which\n // works for the Pages Router but not the App Router where client modules\n // are loaded lazily during RSC stream deserialization (issue #75).\n const LazyServer = 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(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 = 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(Suspense, { fallback }, React.createElement(LazyComponent, props));\n };\n\n ClientDynamic.displayName = \"DynamicClient\";\n return ClientDynamic;\n}\n\nexport default dynamic;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IA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* as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/shims/error-boundary.d.ts
|
|
2
5
|
interface ErrorBoundaryProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
fallback: React.ComponentType<{
|
|
7
|
+
error: Error;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
}>;
|
|
10
|
+
children: React.ReactNode;
|
|
8
11
|
}
|
|
9
12
|
interface ErrorBoundaryState {
|
|
10
|
-
|
|
13
|
+
error: Error | null;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Generic ErrorBoundary used to wrap route segments with error.tsx.
|
|
14
17
|
* This must be a client component since error boundaries use
|
|
15
18
|
* componentDidCatch / getDerivedStateFromError.
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
21
|
+
constructor(props: ErrorBoundaryProps);
|
|
22
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
23
|
+
reset: () => void;
|
|
24
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime0.JSX.Element | null | undefined;
|
|
22
25
|
}
|
|
23
26
|
interface NotFoundBoundaryProps {
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
fallback: React.ReactNode;
|
|
28
|
+
children: React.ReactNode;
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
31
|
* Wrapper that reads the current pathname and passes it to the inner class
|
|
29
32
|
* component. This enables automatic reset on client-side navigation.
|
|
30
33
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
declare function NotFoundBoundary({
|
|
35
|
+
fallback,
|
|
36
|
+
children
|
|
37
|
+
}: NotFoundBoundaryProps): react_jsx_runtime0.JSX.Element;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { ErrorBoundary, NotFoundBoundary };
|
|
33
40
|
//# sourceMappingURL=error-boundary.d.ts.map
|
|
@@ -1,87 +1,89 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import React from "react";
|
|
4
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { usePathname } from "next/navigation";
|
|
5
|
+
//#region src/shims/error-boundary.tsx
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return this.props.children;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
7
|
+
* Generic ErrorBoundary used to wrap route segments with error.tsx.
|
|
8
|
+
* This must be a client component since error boundaries use
|
|
9
|
+
* componentDidCatch / getDerivedStateFromError.
|
|
10
|
+
*/
|
|
11
|
+
var ErrorBoundary = class extends React.Component {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.state = { error: null };
|
|
15
|
+
}
|
|
16
|
+
static getDerivedStateFromError(error) {
|
|
17
|
+
if (error && typeof error === "object" && "digest" in error) {
|
|
18
|
+
const digest = String(error.digest);
|
|
19
|
+
if (digest === "NEXT_NOT_FOUND" || digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;") || digest.startsWith("NEXT_REDIRECT;")) throw error;
|
|
20
|
+
}
|
|
21
|
+
return { error };
|
|
22
|
+
}
|
|
23
|
+
reset = () => {
|
|
24
|
+
this.setState({ error: null });
|
|
25
|
+
};
|
|
26
|
+
render() {
|
|
27
|
+
if (this.state.error) {
|
|
28
|
+
const FallbackComponent = this.props.fallback;
|
|
29
|
+
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
30
|
+
error: this.state.error,
|
|
31
|
+
reset: this.reset
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return this.props.children;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
41
37
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
38
|
+
* Inner class component that catches notFound() errors and renders the
|
|
39
|
+
* not-found.tsx fallback. Resets when the pathname changes (client navigation)
|
|
40
|
+
* so a previous notFound() doesn't permanently stick.
|
|
41
|
+
*
|
|
42
|
+
* The ErrorBoundary above re-throws notFound errors so they propagate up to this
|
|
43
|
+
* boundary. This must be placed above the ErrorBoundary in the component tree.
|
|
44
|
+
*/
|
|
45
|
+
var NotFoundBoundaryInner = class extends React.Component {
|
|
46
|
+
constructor(props) {
|
|
47
|
+
super(props);
|
|
48
|
+
this.state = {
|
|
49
|
+
notFound: false,
|
|
50
|
+
previousPathname: props.pathname
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static getDerivedStateFromProps(props, state) {
|
|
54
|
+
if (props.pathname !== state.previousPathname && state.notFound) return {
|
|
55
|
+
notFound: false,
|
|
56
|
+
previousPathname: props.pathname
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
notFound: state.notFound,
|
|
60
|
+
previousPathname: props.pathname
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
static getDerivedStateFromError(error) {
|
|
64
|
+
if (error && typeof error === "object" && "digest" in error) {
|
|
65
|
+
const digest = String(error.digest);
|
|
66
|
+
if (digest === "NEXT_NOT_FOUND" || digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;404")) return { notFound: true };
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
render() {
|
|
71
|
+
if (this.state.notFound) return this.props.fallback;
|
|
72
|
+
return this.props.children;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
79
75
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
* Wrapper that reads the current pathname and passes it to the inner class
|
|
77
|
+
* component. This enables automatic reset on client-side navigation.
|
|
78
|
+
*/
|
|
79
|
+
function NotFoundBoundary({ fallback, children }) {
|
|
80
|
+
return /* @__PURE__ */ jsx(NotFoundBoundaryInner, {
|
|
81
|
+
pathname: usePathname(),
|
|
82
|
+
fallback,
|
|
83
|
+
children
|
|
84
|
+
});
|
|
86
85
|
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { ErrorBoundary, NotFoundBoundary };
|
|
88
|
+
|
|
87
89
|
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.js","
|
|
1
|
+
{"version":3,"file":"error-boundary.js","names":[],"sources":["../../src/shims/error-boundary.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\n// eslint-disable-next-line @typescript-eslint/no-require-imports -- next/navigation is shimmed\nimport { usePathname } from \"next/navigation\";\n\ninterface ErrorBoundaryProps {\n fallback: React.ComponentType<{ error: Error; reset: () => void }>;\n children: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error: Error | null;\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 ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error): 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 as any).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 };\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} reset={this.reset} />;\n }\n return this.props.children;\n }\n}\n\n// ---------------------------------------------------------------------------\n// NotFoundBoundary — catches notFound() on the client and renders not-found.tsx\n// ---------------------------------------------------------------------------\n\ninterface NotFoundBoundaryProps {\n fallback: React.ReactNode;\n children: React.ReactNode;\n}\n\ninterface NotFoundBoundaryInnerProps extends NotFoundBoundaryProps {\n pathname: string;\n}\n\ninterface 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: Error): Partial<NotFoundBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (digest === \"NEXT_NOT_FOUND\" || digest.startsWith(\"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"],"mappings":";;;;;;;;;;AAoBA,IAAa,gBAAb,cAAmC,MAAM,UAAkD;CACzF,YAAY,OAA2B;AACrC,QAAM,MAAM;AACZ,OAAK,QAAQ,EAAE,OAAO,MAAM;;CAG9B,OAAO,yBAAyB,OAAkC;AAIhE,MAAI,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO;GAC3D,MAAM,SAAS,OAAQ,MAAc,OAAO;AAC5C,OACE,WAAW,oBACX,OAAO,WAAW,4BAA4B,IAC9C,OAAO,WAAW,iBAAiB,CAEnC,OAAM;;AAGV,SAAO,EAAE,OAAO;;CAGlB,cAAc;AACZ,OAAK,SAAS,EAAE,OAAO,MAAM,CAAC;;CAGhC,SAAS;AACP,MAAI,KAAK,MAAM,OAAO;GACpB,MAAM,oBAAoB,KAAK,MAAM;AACrC,UAAO,oBAAC,mBAAD;IAAmB,OAAO,KAAK,MAAM;IAAO,OAAO,KAAK;IAAS,CAAA;;AAE1E,SAAO,KAAK,MAAM;;;;;;;;;;;AA8BtB,IAAM,wBAAN,cAAoC,MAAM,UAGxC;CACA,YAAY,OAAmC;AAC7C,QAAM,MAAM;AACZ,OAAK,QAAQ;GAAE,UAAU;GAAO,kBAAkB,MAAM;GAAU;;CAGpE,OAAO,yBACL,OACA,OAC8B;AAG9B,MAAI,MAAM,aAAa,MAAM,oBAAoB,MAAM,SACrD,QAAO;GAAE,UAAU;GAAO,kBAAkB,MAAM;GAAU;AAE9D,SAAO;GAAE,UAAU,MAAM;GAAU,kBAAkB,MAAM;GAAU;;CAGvE,OAAO,yBAAyB,OAA8C;AAC5E,MAAI,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO;GAC3D,MAAM,SAAS,OAAQ,MAAc,OAAO;AAC5C,OAAI,WAAW,oBAAoB,OAAO,WAAW,+BAA+B,CAClF,QAAO,EAAE,UAAU,MAAM;;AAI7B,QAAM;;CAGR,SAAS;AACP,MAAI,KAAK,MAAM,SACb,QAAO,KAAK,MAAM;AAEpB,SAAO,KAAK,MAAM;;;;;;;AAQtB,SAAgB,iBAAiB,EAAE,UAAU,YAAmC;AAE9E,QACE,oBAAC,uBAAD;EAAuB,UAFR,aAAa;EAEyB;EAClD;EACqB,CAAA"}
|
package/dist/shims/error.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* next/error shim
|
|
3
|
-
*
|
|
4
|
-
* Provides the default Next.js error page component.
|
|
5
|
-
* Used by apps that import `import Error from 'next/error'` for
|
|
6
|
-
* custom error handling in getServerSideProps or API routes.
|
|
7
|
-
*/
|
|
8
1
|
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/shims/error.d.ts
|
|
9
4
|
interface ErrorProps {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
statusCode: number;
|
|
6
|
+
title?: string;
|
|
7
|
+
withDarkMode?: boolean;
|
|
13
8
|
}
|
|
14
|
-
declare function ErrorComponent({
|
|
15
|
-
|
|
9
|
+
declare function ErrorComponent({
|
|
10
|
+
statusCode,
|
|
11
|
+
title
|
|
12
|
+
}: ErrorProps): React.ReactElement;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ErrorComponent as default };
|
|
16
15
|
//# sourceMappingURL=error.d.ts.map
|