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
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Generates the virtual RSC entry module for the App Router.
|
|
5
|
-
* The RSC entry does route matching and renders the component tree,
|
|
6
|
-
* then delegates to the SSR entry for HTML generation.
|
|
7
|
-
*
|
|
8
|
-
* Previously housed in server/app-dev-server.ts.
|
|
9
|
-
*/
|
|
1
|
+
import { isProxyFile } from "../server/middleware.js";
|
|
2
|
+
import { generateMiddlewareMatcherCode, generateNormalizePathCode, generateRouteMatchNormalizationCode, generateSafeRegExpCode } from "../server/middleware-codegen.js";
|
|
3
|
+
import { generateDevOriginCheckCode } from "../server/dev-origin-check.js";
|
|
10
4
|
import fs from "node:fs";
|
|
11
5
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
//#region src/entries/app-rsc-entry.ts
|
|
7
|
+
/**
|
|
8
|
+
* App Router RSC entry generator.
|
|
9
|
+
*
|
|
10
|
+
* Generates the virtual RSC entry module for the App Router.
|
|
11
|
+
* The RSC entry does route matching and renders the component tree,
|
|
12
|
+
* then delegates to the SSR entry for HTML generation.
|
|
13
|
+
*
|
|
14
|
+
* Previously housed in server/app-dev-server.ts.
|
|
15
|
+
*/
|
|
18
16
|
const configMatchersPath = fileURLToPath(new URL("../config/config-matchers.js", import.meta.url)).replace(/\\/g, "/");
|
|
19
17
|
const requestPipelinePath = fileURLToPath(new URL("../server/request-pipeline.js", import.meta.url)).replace(/\\/g, "/");
|
|
20
18
|
const requestContextShimPath = fileURLToPath(new URL("../shims/request-context.js", import.meta.url)).replace(/\\/g, "/");
|
|
21
19
|
const routeTriePath = fileURLToPath(new URL("../routing/route-trie.js", import.meta.url)).replace(/\\/g, "/");
|
|
22
|
-
|
|
23
|
-
const ROUTE_HANDLER_HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
|
|
24
|
-
// Runtime helpers injected into the generated RSC entry so OPTIONS/Allow handling
|
|
25
|
-
// logic stays alongside the route handler pipeline.
|
|
26
|
-
const routeHandlerHelperCode = String.raw `
|
|
20
|
+
const routeHandlerHelperCode = String.raw`
|
|
27
21
|
// Duplicated from the build-time constant above via JSON.stringify.
|
|
28
|
-
const ROUTE_HANDLER_HTTP_METHODS = ${JSON.stringify(
|
|
22
|
+
const ROUTE_HANDLER_HTTP_METHODS = ${JSON.stringify([
|
|
23
|
+
"GET",
|
|
24
|
+
"HEAD",
|
|
25
|
+
"POST",
|
|
26
|
+
"PUT",
|
|
27
|
+
"DELETE",
|
|
28
|
+
"PATCH",
|
|
29
|
+
"OPTIONS"
|
|
30
|
+
])};
|
|
29
31
|
|
|
30
32
|
function collectRouteHandlerMethods(handler) {
|
|
31
33
|
const methods = ROUTE_HANDLER_HTTP_METHODS.filter((method) => typeof handler[method] === "function");
|
|
@@ -42,96 +44,74 @@ function buildRouteHandlerAllowHeader(exportedMethods) {
|
|
|
42
44
|
}
|
|
43
45
|
`;
|
|
44
46
|
/**
|
|
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
|
-
|
|
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
|
-
if (slot.defaultPath)
|
|
107
|
-
getImportVar(slot.defaultPath);
|
|
108
|
-
if (slot.layoutPath)
|
|
109
|
-
getImportVar(slot.layoutPath);
|
|
110
|
-
if (slot.loadingPath)
|
|
111
|
-
getImportVar(slot.loadingPath);
|
|
112
|
-
if (slot.errorPath)
|
|
113
|
-
getImportVar(slot.errorPath);
|
|
114
|
-
// Register intercepting route page modules
|
|
115
|
-
for (const ir of slot.interceptingRoutes) {
|
|
116
|
-
getImportVar(ir.pagePath);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// Build route table as serialized JS
|
|
121
|
-
const routeEntries = routes.map((route) => {
|
|
122
|
-
const layoutVars = route.layouts.map((l) => getImportVar(l));
|
|
123
|
-
const templateVars = route.templates.map((t) => getImportVar(t));
|
|
124
|
-
const notFoundVars = (route.notFoundPaths || []).map((nf) => (nf ? getImportVar(nf) : "null"));
|
|
125
|
-
const slotEntries = route.parallelSlots.map((slot) => {
|
|
126
|
-
const interceptEntries = slot.interceptingRoutes.map((ir) => {
|
|
127
|
-
return ` {
|
|
47
|
+
* Generate the virtual RSC entry module.
|
|
48
|
+
*
|
|
49
|
+
* This runs in the `rsc` Vite environment (react-server condition).
|
|
50
|
+
* It matches the incoming request URL to an app route, builds the
|
|
51
|
+
* nested layout + page tree, and renders it to an RSC stream.
|
|
52
|
+
*/
|
|
53
|
+
function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, globalErrorPath, basePath, trailingSlash, config, instrumentationPath) {
|
|
54
|
+
const bp = basePath ?? "";
|
|
55
|
+
const ts = trailingSlash ?? false;
|
|
56
|
+
const redirects = config?.redirects ?? [];
|
|
57
|
+
const rewrites = config?.rewrites ?? {
|
|
58
|
+
beforeFiles: [],
|
|
59
|
+
afterFiles: [],
|
|
60
|
+
fallback: []
|
|
61
|
+
};
|
|
62
|
+
const headers = config?.headers ?? [];
|
|
63
|
+
const allowedOrigins = config?.allowedOrigins ?? [];
|
|
64
|
+
const bodySizeLimit = config?.bodySizeLimit ?? 1 * 1024 * 1024;
|
|
65
|
+
const i18nConfig = config?.i18n ?? null;
|
|
66
|
+
const hasPagesDir = config?.hasPagesDir ?? false;
|
|
67
|
+
const imports = [];
|
|
68
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
69
|
+
let importIdx = 0;
|
|
70
|
+
function getImportVar(filePath) {
|
|
71
|
+
if (importMap.has(filePath)) return importMap.get(filePath);
|
|
72
|
+
const varName = `mod_${importIdx++}`;
|
|
73
|
+
const absPath = filePath.replace(/\\/g, "/");
|
|
74
|
+
imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);
|
|
75
|
+
importMap.set(filePath, varName);
|
|
76
|
+
return varName;
|
|
77
|
+
}
|
|
78
|
+
for (const route of routes) {
|
|
79
|
+
if (route.pagePath) getImportVar(route.pagePath);
|
|
80
|
+
if (route.routePath) getImportVar(route.routePath);
|
|
81
|
+
for (const layout of route.layouts) getImportVar(layout);
|
|
82
|
+
for (const tmpl of route.templates) getImportVar(tmpl);
|
|
83
|
+
if (route.loadingPath) getImportVar(route.loadingPath);
|
|
84
|
+
if (route.errorPath) getImportVar(route.errorPath);
|
|
85
|
+
if (route.layoutErrorPaths) {
|
|
86
|
+
for (const ep of route.layoutErrorPaths) if (ep) getImportVar(ep);
|
|
87
|
+
}
|
|
88
|
+
if (route.notFoundPath) getImportVar(route.notFoundPath);
|
|
89
|
+
for (const nfp of route.notFoundPaths || []) if (nfp) getImportVar(nfp);
|
|
90
|
+
if (route.forbiddenPath) getImportVar(route.forbiddenPath);
|
|
91
|
+
if (route.unauthorizedPath) getImportVar(route.unauthorizedPath);
|
|
92
|
+
for (const slot of route.parallelSlots) {
|
|
93
|
+
if (slot.pagePath) getImportVar(slot.pagePath);
|
|
94
|
+
if (slot.defaultPath) getImportVar(slot.defaultPath);
|
|
95
|
+
if (slot.layoutPath) getImportVar(slot.layoutPath);
|
|
96
|
+
if (slot.loadingPath) getImportVar(slot.loadingPath);
|
|
97
|
+
if (slot.errorPath) getImportVar(slot.errorPath);
|
|
98
|
+
for (const ir of slot.interceptingRoutes) getImportVar(ir.pagePath);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const routeEntries = routes.map((route) => {
|
|
102
|
+
const layoutVars = route.layouts.map((l) => getImportVar(l));
|
|
103
|
+
const templateVars = route.templates.map((t) => getImportVar(t));
|
|
104
|
+
const notFoundVars = (route.notFoundPaths || []).map((nf) => nf ? getImportVar(nf) : "null");
|
|
105
|
+
const slotEntries = route.parallelSlots.map((slot) => {
|
|
106
|
+
const interceptEntries = slot.interceptingRoutes.map((ir) => {
|
|
107
|
+
return ` {
|
|
128
108
|
convention: ${JSON.stringify(ir.convention)},
|
|
129
109
|
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
130
110
|
page: ${getImportVar(ir.pagePath)},
|
|
131
111
|
params: ${JSON.stringify(ir.params)},
|
|
132
112
|
}`;
|
|
133
|
-
|
|
134
|
-
|
|
113
|
+
});
|
|
114
|
+
return ` ${JSON.stringify(slot.name)}: {
|
|
135
115
|
page: ${slot.pagePath ? getImportVar(slot.pagePath) : "null"},
|
|
136
116
|
default: ${slot.defaultPath ? getImportVar(slot.defaultPath) : "null"},
|
|
137
117
|
layout: ${slot.layoutPath ? getImportVar(slot.layoutPath) : "null"},
|
|
@@ -142,9 +122,9 @@ export function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes,
|
|
|
142
122
|
${interceptEntries.join(",\n")}
|
|
143
123
|
],
|
|
144
124
|
}`;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
125
|
+
});
|
|
126
|
+
const layoutErrorVars = (route.layoutErrorPaths || []).map((ep) => ep ? getImportVar(ep) : "null");
|
|
127
|
+
return ` {
|
|
148
128
|
pattern: ${JSON.stringify(route.pattern)},
|
|
149
129
|
patternParts: ${JSON.stringify(route.patternParts)},
|
|
150
130
|
isDynamic: ${route.isDynamic},
|
|
@@ -166,86 +146,80 @@ ${slotEntries.join(",\n")}
|
|
|
166
146
|
forbidden: ${route.forbiddenPath ? getImportVar(route.forbiddenPath) : "null"},
|
|
167
147
|
unauthorized: ${route.unauthorizedPath ? getImportVar(route.unauthorizedPath) : "null"},
|
|
168
148
|
}`;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// Build metadata route table
|
|
188
|
-
// For static metadata files, read the file content at code-generation time
|
|
189
|
-
// and embed it as base64. This ensures static metadata files work on runtimes
|
|
190
|
-
// without filesystem access (e.g., Cloudflare Workers).
|
|
191
|
-
//
|
|
192
|
-
// For metadata routes in dynamic segments (e.g., /blog/[slug]/opengraph-image),
|
|
193
|
-
// generate patternParts so the runtime can use matchPattern() instead of strict
|
|
194
|
-
// equality — the same matching used for intercept routes.
|
|
195
|
-
const metaRouteEntries = effectiveMetaRoutes.map((mr) => {
|
|
196
|
-
// Convert dynamic segments in servedUrl to matchPattern format.
|
|
197
|
-
// Keep in sync with routing/app-router.ts patternParts generation.
|
|
198
|
-
// [param] → :param
|
|
199
|
-
// [...param] → :param+
|
|
200
|
-
// [[...param]] → :param*
|
|
201
|
-
const patternParts = mr.isDynamic && mr.servedUrl.includes("[")
|
|
202
|
-
? JSON.stringify(mr.servedUrl
|
|
203
|
-
.split("/")
|
|
204
|
-
.filter(Boolean)
|
|
205
|
-
.map((seg) => {
|
|
206
|
-
if (seg.startsWith("[[...") && seg.endsWith("]]"))
|
|
207
|
-
return ":" + seg.slice(5, -2) + "*";
|
|
208
|
-
if (seg.startsWith("[...") && seg.endsWith("]"))
|
|
209
|
-
return ":" + seg.slice(4, -1) + "+";
|
|
210
|
-
if (seg.startsWith("[") && seg.endsWith("]"))
|
|
211
|
-
return ":" + seg.slice(1, -1);
|
|
212
|
-
return seg;
|
|
213
|
-
}))
|
|
214
|
-
: null;
|
|
215
|
-
if (mr.isDynamic) {
|
|
216
|
-
return ` {
|
|
149
|
+
});
|
|
150
|
+
const rootRoute = routes.find((r) => r.pattern === "/");
|
|
151
|
+
const rootNotFoundVar = rootRoute?.notFoundPath ? getImportVar(rootRoute.notFoundPath) : null;
|
|
152
|
+
const rootForbiddenVar = rootRoute?.forbiddenPath ? getImportVar(rootRoute.forbiddenPath) : null;
|
|
153
|
+
const rootUnauthorizedVar = rootRoute?.unauthorizedPath ? getImportVar(rootRoute.unauthorizedPath) : null;
|
|
154
|
+
const rootLayoutVars = rootRoute ? rootRoute.layouts.map((l) => getImportVar(l)) : [];
|
|
155
|
+
const globalErrorVar = globalErrorPath ? getImportVar(globalErrorPath) : null;
|
|
156
|
+
const effectiveMetaRoutes = metadataRoutes ?? [];
|
|
157
|
+
const dynamicMetaRoutes = effectiveMetaRoutes.filter((r) => r.isDynamic);
|
|
158
|
+
for (const mr of dynamicMetaRoutes) getImportVar(mr.filePath);
|
|
159
|
+
const metaRouteEntries = effectiveMetaRoutes.map((mr) => {
|
|
160
|
+
const patternParts = mr.isDynamic && mr.servedUrl.includes("[") ? JSON.stringify(mr.servedUrl.split("/").filter(Boolean).map((seg) => {
|
|
161
|
+
if (seg.startsWith("[[...") && seg.endsWith("]]")) return ":" + seg.slice(5, -2) + "*";
|
|
162
|
+
if (seg.startsWith("[...") && seg.endsWith("]")) return ":" + seg.slice(4, -1) + "+";
|
|
163
|
+
if (seg.startsWith("[") && seg.endsWith("]")) return ":" + seg.slice(1, -1);
|
|
164
|
+
return seg;
|
|
165
|
+
})) : null;
|
|
166
|
+
if (mr.isDynamic) return ` {
|
|
217
167
|
type: ${JSON.stringify(mr.type)},
|
|
218
168
|
isDynamic: true,
|
|
219
169
|
servedUrl: ${JSON.stringify(mr.servedUrl)},
|
|
220
170
|
contentType: ${JSON.stringify(mr.contentType)},
|
|
221
171
|
module: ${getImportVar(mr.filePath)},${patternParts ? `\n patternParts: ${patternParts},` : ""}
|
|
222
172
|
}`;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
fileDataBase64 = buf.toString("base64");
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
// File unreadable — will serve empty response at runtime
|
|
232
|
-
}
|
|
233
|
-
return ` {
|
|
173
|
+
let fileDataBase64 = "";
|
|
174
|
+
try {
|
|
175
|
+
fileDataBase64 = fs.readFileSync(mr.filePath).toString("base64");
|
|
176
|
+
} catch {}
|
|
177
|
+
return ` {
|
|
234
178
|
type: ${JSON.stringify(mr.type)},
|
|
235
179
|
isDynamic: false,
|
|
236
180
|
servedUrl: ${JSON.stringify(mr.servedUrl)},
|
|
237
181
|
contentType: ${JSON.stringify(mr.contentType)},
|
|
238
182
|
fileDataBase64: ${JSON.stringify(fileDataBase64)},
|
|
239
183
|
}`;
|
|
240
|
-
|
|
241
|
-
|
|
184
|
+
});
|
|
185
|
+
return `
|
|
242
186
|
import {
|
|
243
|
-
renderToReadableStream,
|
|
187
|
+
renderToReadableStream as _renderToReadableStream,
|
|
244
188
|
decodeReply,
|
|
245
189
|
loadServerAction,
|
|
246
190
|
createTemporaryReferenceSet,
|
|
247
191
|
} from "@vitejs/plugin-rsc/rsc";
|
|
248
192
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
193
|
+
|
|
194
|
+
// React Flight emits HL hints with "stylesheet" for CSS, but the HTML spec
|
|
195
|
+
// requires "style" for <link rel="preload">. Fix at the source so every
|
|
196
|
+
// consumer (SSR embed, client-side navigation, server actions) gets clean data.
|
|
197
|
+
//
|
|
198
|
+
// Flight lines are newline-delimited, so we buffer partial lines across chunks
|
|
199
|
+
// to guarantee the regex never sees a split hint.
|
|
200
|
+
function renderToReadableStream(model, options) {
|
|
201
|
+
const _hlFixRe = /(\\d+:HL\\[.*?),"stylesheet"(\\]|,)/g;
|
|
202
|
+
const stream = _renderToReadableStream(model, options);
|
|
203
|
+
const decoder = new TextDecoder();
|
|
204
|
+
const encoder = new TextEncoder();
|
|
205
|
+
let carry = "";
|
|
206
|
+
return stream.pipeThrough(new TransformStream({
|
|
207
|
+
transform(chunk, controller) {
|
|
208
|
+
const text = carry + decoder.decode(chunk, { stream: true });
|
|
209
|
+
const lastNl = text.lastIndexOf("\\n");
|
|
210
|
+
if (lastNl === -1) {
|
|
211
|
+
carry = text;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
carry = text.slice(lastNl + 1);
|
|
215
|
+
controller.enqueue(encoder.encode(text.slice(0, lastNl + 1).replace(_hlFixRe, '$1,"style"$2')));
|
|
216
|
+
},
|
|
217
|
+
flush(controller) {
|
|
218
|
+
const text = carry + decoder.decode();
|
|
219
|
+
if (text) controller.enqueue(encoder.encode(text.replace(_hlFixRe, '$1,"style"$2')));
|
|
220
|
+
}
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
249
223
|
import { createElement, Suspense, Fragment } from "react";
|
|
250
224
|
import { setNavigationContext as _setNavigationContextOrig, getNavigationContext as _getNavigationContext } from "next/navigation";
|
|
251
225
|
import { setHeadersContext, headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, markDynamicUsage, applyMiddlewareRequestHeaders, getHeadersContext, setHeadersAccessPhase } from "next/headers";
|
|
@@ -270,6 +244,7 @@ import { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontSty
|
|
|
270
244
|
import { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from "next/font/local";
|
|
271
245
|
function _getSSRFontStyles() { return [..._getSSRFontStylesGoogle(), ..._getSSRFontStylesLocal()]; }
|
|
272
246
|
function _getSSRFontPreloads() { return [..._getSSRFontPreloadsGoogle(), ..._getSSRFontPreloadsLocal()]; }
|
|
247
|
+
${hasPagesDir ? `// Note: pageRoutes loaded lazily via SSR env in /__vinext/prerender/pages-static-paths handler` : ""}
|
|
273
248
|
${routeHandlerHelperCode}
|
|
274
249
|
|
|
275
250
|
// ALS used to suppress the expected "Invalid hook call" dev warning when
|
|
@@ -316,6 +291,18 @@ async function __isrSet(key, data, revalidateSeconds, tags) {
|
|
|
316
291
|
}
|
|
317
292
|
function __pageCacheTags(pathname, extraTags) {
|
|
318
293
|
const tags = [pathname, "_N_T_" + pathname];
|
|
294
|
+
// Layout hierarchy tags — matches Next.js getDerivedTags.
|
|
295
|
+
tags.push("_N_T_/layout");
|
|
296
|
+
const segments = pathname.split("/");
|
|
297
|
+
let built = "";
|
|
298
|
+
for (let i = 1; i < segments.length; i++) {
|
|
299
|
+
if (segments[i]) {
|
|
300
|
+
built += "/" + segments[i];
|
|
301
|
+
tags.push("_N_T_" + built + "/layout");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Leaf page tag — revalidatePath(path, "page") targets this.
|
|
305
|
+
tags.push("_N_T_" + built + "/page");
|
|
319
306
|
if (Array.isArray(extraTags)) {
|
|
320
307
|
for (const tag of extraTags) {
|
|
321
308
|
if (!tags.includes(tag)) tags.push(tag);
|
|
@@ -380,6 +367,7 @@ function __isrCacheKey(pathname, suffix) {
|
|
|
380
367
|
}
|
|
381
368
|
function __isrHtmlKey(pathname) { return __isrCacheKey(pathname, "html"); }
|
|
382
369
|
function __isrRscKey(pathname) { return __isrCacheKey(pathname, "rsc"); }
|
|
370
|
+
function __isrRouteKey(pathname) { return __isrCacheKey(pathname, "route"); }
|
|
383
371
|
// Verbose cache logging — opt in with NEXT_PRIVATE_DEBUG_CACHE=1.
|
|
384
372
|
// Matches the env var Next.js uses for its own cache debug output so operators
|
|
385
373
|
// have a single knob for all cache tracing.
|
|
@@ -562,8 +550,7 @@ function createRscOnErrorHandler(request, pathname, routePath) {
|
|
|
562
550
|
|
|
563
551
|
${imports.join("\n")}
|
|
564
552
|
|
|
565
|
-
${instrumentationPath
|
|
566
|
-
? `// Run instrumentation register() exactly once, lazily on the first request.
|
|
553
|
+
${instrumentationPath ? `// Run instrumentation register() exactly once, lazily on the first request.
|
|
567
554
|
// Previously this was a top-level await, which blocked the entire module graph
|
|
568
555
|
// from finishing initialization until register() resolved — adding that latency
|
|
569
556
|
// to every cold start. Moving it here preserves the "runs before any request is
|
|
@@ -574,6 +561,7 @@ ${instrumentationPath
|
|
|
574
561
|
let __instrumentationInitialized = false;
|
|
575
562
|
let __instrumentationInitPromise = null;
|
|
576
563
|
async function __ensureInstrumentation() {
|
|
564
|
+
if (process.env.VINEXT_PRERENDER === "1") return;
|
|
577
565
|
if (__instrumentationInitialized) return;
|
|
578
566
|
if (__instrumentationInitPromise) return __instrumentationInitPromise;
|
|
579
567
|
__instrumentationInitPromise = (async () => {
|
|
@@ -592,8 +580,7 @@ async function __ensureInstrumentation() {
|
|
|
592
580
|
__instrumentationInitialized = true;
|
|
593
581
|
})();
|
|
594
582
|
return __instrumentationInitPromise;
|
|
595
|
-
}`
|
|
596
|
-
: ""}
|
|
583
|
+
}` : ""}
|
|
597
584
|
|
|
598
585
|
const routes = [
|
|
599
586
|
${routeEntries.join(",\n")}
|
|
@@ -690,8 +677,7 @@ async function renderHTTPAccessFallbackPage(route, statusCode, isRscRequest, req
|
|
|
690
677
|
element = createElement(LayoutSegmentProvider, { childSegments: _cs }, element);
|
|
691
678
|
}
|
|
692
679
|
}
|
|
693
|
-
${globalErrorVar
|
|
694
|
-
? `
|
|
680
|
+
${globalErrorVar ? `
|
|
695
681
|
const _GlobalErrorComponent = ${globalErrorVar}.default;
|
|
696
682
|
if (_GlobalErrorComponent) {
|
|
697
683
|
element = createElement(ErrorBoundary, {
|
|
@@ -699,8 +685,7 @@ async function renderHTTPAccessFallbackPage(route, statusCode, isRscRequest, req
|
|
|
699
685
|
children: element,
|
|
700
686
|
});
|
|
701
687
|
}
|
|
702
|
-
`
|
|
703
|
-
: ""}
|
|
688
|
+
` : ""}
|
|
704
689
|
const _pathname = new URL(request.url).pathname;
|
|
705
690
|
const onRenderError = createRscOnErrorHandler(
|
|
706
691
|
request,
|
|
@@ -780,14 +765,12 @@ async function renderErrorBoundaryPage(route, error, isRscRequest, request, matc
|
|
|
780
765
|
}
|
|
781
766
|
}
|
|
782
767
|
}
|
|
783
|
-
${globalErrorVar
|
|
784
|
-
? `
|
|
768
|
+
${globalErrorVar ? `
|
|
785
769
|
if (!ErrorComponent) {
|
|
786
770
|
ErrorComponent = ${globalErrorVar}?.default ?? null;
|
|
787
771
|
_isGlobalError = !!ErrorComponent;
|
|
788
772
|
}
|
|
789
|
-
`
|
|
790
|
-
: ""}
|
|
773
|
+
` : ""}
|
|
791
774
|
if (!ErrorComponent) return null;
|
|
792
775
|
|
|
793
776
|
const rawError = error instanceof Error ? error : new Error(String(error));
|
|
@@ -825,8 +808,7 @@ async function renderErrorBoundaryPage(route, error, isRscRequest, request, matc
|
|
|
825
808
|
element = createElement(LayoutSegmentProvider, { childSegments: _ecs }, element);
|
|
826
809
|
}
|
|
827
810
|
}
|
|
828
|
-
${globalErrorVar
|
|
829
|
-
? `
|
|
811
|
+
${globalErrorVar ? `
|
|
830
812
|
const _ErrGlobalComponent = ${globalErrorVar}.default;
|
|
831
813
|
if (_ErrGlobalComponent) {
|
|
832
814
|
element = createElement(ErrorBoundary, {
|
|
@@ -834,8 +816,7 @@ async function renderErrorBoundaryPage(route, error, isRscRequest, request, matc
|
|
|
834
816
|
children: element,
|
|
835
817
|
});
|
|
836
818
|
}
|
|
837
|
-
`
|
|
838
|
-
: ""}
|
|
819
|
+
` : ""}
|
|
839
820
|
} else {
|
|
840
821
|
// For HTML (full page load) responses, wrap with layouts only.
|
|
841
822
|
const _errParamsHtml = matchedParams ?? route?.params ?? {};
|
|
@@ -1245,8 +1226,7 @@ async function buildPageElement(route, params, opts, searchParams) {
|
|
|
1245
1226
|
// For HTML requests (initial page load), the ErrorBoundary catches during SSR
|
|
1246
1227
|
// but produces double <html>/<body> (root layout + global-error). The request
|
|
1247
1228
|
// handler detects this via the rscOnError flag and re-renders without layouts.
|
|
1248
|
-
${globalErrorVar
|
|
1249
|
-
? `
|
|
1229
|
+
${globalErrorVar ? `
|
|
1250
1230
|
const GlobalErrorComponent = ${globalErrorVar}.default;
|
|
1251
1231
|
if (GlobalErrorComponent) {
|
|
1252
1232
|
element = createElement(ErrorBoundary, {
|
|
@@ -1254,8 +1234,7 @@ async function buildPageElement(route, params, opts, searchParams) {
|
|
|
1254
1234
|
children: element,
|
|
1255
1235
|
});
|
|
1256
1236
|
}
|
|
1257
|
-
`
|
|
1258
|
-
: ""}
|
|
1237
|
+
` : ""}
|
|
1259
1238
|
|
|
1260
1239
|
return element;
|
|
1261
1240
|
}
|
|
@@ -1374,13 +1353,23 @@ async function __readFormDataWithLimit(request, maxBytes) {
|
|
|
1374
1353
|
return new Response(combined, { headers: { "Content-Type": contentType } }).formData();
|
|
1375
1354
|
}
|
|
1376
1355
|
|
|
1356
|
+
// Map from route pattern to generateStaticParams function.
|
|
1357
|
+
// Used by the prerender phase to enumerate dynamic route URLs without
|
|
1358
|
+
// loading route modules via the dev server.
|
|
1359
|
+
export const generateStaticParamsMap = {
|
|
1360
|
+
// TODO: layout-level generateStaticParams — this map only includes routes that
|
|
1361
|
+
// have a pagePath (leaf pages). Layout segments can also export generateStaticParams
|
|
1362
|
+
// to provide parent params for nested dynamic routes, but they don't have a pagePath
|
|
1363
|
+
// so they are excluded here. Supporting layout-level generateStaticParams requires
|
|
1364
|
+
// scanning layout.tsx files separately and including them in this map.
|
|
1365
|
+
${routes.filter((r) => r.isDynamic && r.pagePath).map((r) => ` ${JSON.stringify(r.pattern)}: ${getImportVar(r.pagePath)}?.generateStaticParams ?? null,`).join("\n")}
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1377
1368
|
export default async function handler(request, ctx) {
|
|
1378
|
-
${instrumentationPath
|
|
1379
|
-
? `// Ensure instrumentation.register() has run before handling the first request.
|
|
1369
|
+
${instrumentationPath ? `// Ensure instrumentation.register() has run before handling the first request.
|
|
1380
1370
|
// This is a no-op after the first call (guarded by __instrumentationInitialized).
|
|
1381
1371
|
await __ensureInstrumentation();
|
|
1382
|
-
`
|
|
1383
|
-
: ""}
|
|
1372
|
+
` : ""}
|
|
1384
1373
|
// Wrap the entire request in a single unified ALS scope for per-request
|
|
1385
1374
|
// isolation. All state modules (headers, navigation, cache, fetch-cache,
|
|
1386
1375
|
// execution-context) read from this store via isInsideUnifiedScope().
|
|
@@ -1457,12 +1446,79 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1457
1446
|
}
|
|
1458
1447
|
let pathname = __normalizePath(decodedUrlPathname);
|
|
1459
1448
|
|
|
1460
|
-
${bp
|
|
1461
|
-
? `
|
|
1449
|
+
${bp ? `
|
|
1462
1450
|
// Strip basePath prefix
|
|
1463
1451
|
pathname = stripBasePath(pathname, __basePath);
|
|
1464
|
-
`
|
|
1465
|
-
|
|
1452
|
+
` : ""}
|
|
1453
|
+
|
|
1454
|
+
// ── Prerender: static-params endpoint ────────────────────────────────
|
|
1455
|
+
// Internal endpoint used by prerenderApp() during build to fetch
|
|
1456
|
+
// generateStaticParams results via wrangler unstable_startWorker.
|
|
1457
|
+
// Gated on VINEXT_PRERENDER=1 to prevent exposure in normal deployments.
|
|
1458
|
+
// For Node builds, process.env.VINEXT_PRERENDER is set directly by the
|
|
1459
|
+
// prerender orchestrator. For CF Workers builds, wrangler unstable_startWorker
|
|
1460
|
+
// injects VINEXT_PRERENDER as a binding which Miniflare exposes via process.env
|
|
1461
|
+
// in bundled workers. The /__vinext/ prefix ensures no user route ever conflicts.
|
|
1462
|
+
if (pathname === "/__vinext/prerender/static-params") {
|
|
1463
|
+
if (process.env.VINEXT_PRERENDER !== "1") {
|
|
1464
|
+
return new Response("Not Found", { status: 404 });
|
|
1465
|
+
}
|
|
1466
|
+
const pattern = url.searchParams.get("pattern");
|
|
1467
|
+
if (!pattern) return new Response("missing pattern", { status: 400 });
|
|
1468
|
+
const fn = generateStaticParamsMap[pattern];
|
|
1469
|
+
if (typeof fn !== "function") return new Response("null", { status: 200, headers: { "content-type": "application/json" } });
|
|
1470
|
+
try {
|
|
1471
|
+
const parentParams = url.searchParams.get("parentParams");
|
|
1472
|
+
const raw = parentParams ? JSON.parse(parentParams) : {};
|
|
1473
|
+
// Ensure params is a plain object — reject primitives, arrays, and null
|
|
1474
|
+
// so user-authored generateStaticParams always receives { params: {} }
|
|
1475
|
+
// rather than { params: 5 } or similar if input is malformed.
|
|
1476
|
+
const params = (typeof raw === "object" && raw !== null && !Array.isArray(raw)) ? raw : {};
|
|
1477
|
+
const result = await fn({ params });
|
|
1478
|
+
return new Response(JSON.stringify(result), { status: 200, headers: { "content-type": "application/json" } });
|
|
1479
|
+
} catch (e) {
|
|
1480
|
+
return new Response(JSON.stringify({ error: String(e) }), { status: 500, headers: { "content-type": "application/json" } });
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
${hasPagesDir ? `
|
|
1485
|
+
// ── Prerender: pages-static-paths endpoint ───────────────────────────
|
|
1486
|
+
// Internal endpoint used by prerenderPages() during a CF Workers hybrid
|
|
1487
|
+
// build to call getStaticPaths() for dynamic Pages Router routes via
|
|
1488
|
+
// wrangler unstable_startWorker. Returns JSON-serialised getStaticPaths result.
|
|
1489
|
+
// Gated on VINEXT_PRERENDER=1 to prevent exposure in normal deployments.
|
|
1490
|
+
// See static-params endpoint above for process.env vs CF vars notes.
|
|
1491
|
+
//
|
|
1492
|
+
// pageRoutes lives in the SSR environment (virtual:vinext-server-entry).
|
|
1493
|
+
// We load it lazily via import.meta.viteRsc.loadModule — the same pattern
|
|
1494
|
+
// used by handleSsr() elsewhere in this template. At build time, Vite's RSC
|
|
1495
|
+
// plugin transforms this call into a bundled cross-environment import, so it
|
|
1496
|
+
// works correctly in the CF Workers production bundle running in Miniflare.
|
|
1497
|
+
if (pathname === "/__vinext/prerender/pages-static-paths") {
|
|
1498
|
+
if (process.env.VINEXT_PRERENDER !== "1") {
|
|
1499
|
+
return new Response("Not Found", { status: 404 });
|
|
1500
|
+
}
|
|
1501
|
+
const __gspPattern = url.searchParams.get("pattern");
|
|
1502
|
+
if (!__gspPattern) return new Response("missing pattern", { status: 400 });
|
|
1503
|
+
try {
|
|
1504
|
+
const __gspSsrEntry = await import.meta.viteRsc.loadModule("ssr", "index");
|
|
1505
|
+
const __pagesRoutes = __gspSsrEntry.pageRoutes;
|
|
1506
|
+
const __gspRoute = Array.isArray(__pagesRoutes)
|
|
1507
|
+
? __pagesRoutes.find((r) => r.pattern === __gspPattern)
|
|
1508
|
+
: undefined;
|
|
1509
|
+
if (!__gspRoute || typeof __gspRoute.module?.getStaticPaths !== "function") {
|
|
1510
|
+
return new Response("null", { status: 200, headers: { "content-type": "application/json" } });
|
|
1511
|
+
}
|
|
1512
|
+
const __localesParam = url.searchParams.get("locales");
|
|
1513
|
+
const __locales = __localesParam ? JSON.parse(__localesParam) : [];
|
|
1514
|
+
const __defaultLocale = url.searchParams.get("defaultLocale") ?? "";
|
|
1515
|
+
const __gspResult = await __gspRoute.module.getStaticPaths({ locales: __locales, defaultLocale: __defaultLocale });
|
|
1516
|
+
return new Response(JSON.stringify(__gspResult), { status: 200, headers: { "content-type": "application/json" } });
|
|
1517
|
+
} catch (e) {
|
|
1518
|
+
return new Response(JSON.stringify({ error: String(e) }), { status: 500, headers: { "content-type": "application/json" } });
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
` : ""}
|
|
1466
1522
|
|
|
1467
1523
|
// Trailing slash normalization (redirect to canonical form)
|
|
1468
1524
|
const __tsRedirect = normalizeTrailingSlash(pathname, __basePath, __trailingSlash, url.search);
|
|
@@ -1497,8 +1553,48 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1497
1553
|
// _mwCtx (per-request container) so handler() can merge them into
|
|
1498
1554
|
// every response path without module-level state that races on Workers.
|
|
1499
1555
|
|
|
1500
|
-
${middlewarePath
|
|
1501
|
-
|
|
1556
|
+
${middlewarePath ? `
|
|
1557
|
+
// In hybrid app+pages dev mode the connect handler already ran middleware
|
|
1558
|
+
// and forwarded the results via x-vinext-mw-ctx. Reconstruct _mwCtx from
|
|
1559
|
+
// the forwarded data instead of re-running the middleware function.
|
|
1560
|
+
// Guarded by NODE_ENV because this header only exists in dev (the connect
|
|
1561
|
+
// handler sets it). In production there is no connect handler, so an
|
|
1562
|
+
// attacker-supplied header must not be trusted.
|
|
1563
|
+
let __mwCtxApplied = false;
|
|
1564
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1565
|
+
const __mwCtxHeader = request.headers.get("x-vinext-mw-ctx");
|
|
1566
|
+
if (__mwCtxHeader) {
|
|
1567
|
+
try {
|
|
1568
|
+
const __mwCtxData = JSON.parse(__mwCtxHeader);
|
|
1569
|
+
if (__mwCtxData.h && __mwCtxData.h.length > 0) {
|
|
1570
|
+
// Note: h may include x-middleware-request-* internal headers so
|
|
1571
|
+
// applyMiddlewareRequestHeaders() can unpack them below.
|
|
1572
|
+
// processMiddlewareHeaders() strips them before any response.
|
|
1573
|
+
_mwCtx.headers = new Headers();
|
|
1574
|
+
for (const [key, value] of __mwCtxData.h) {
|
|
1575
|
+
_mwCtx.headers.append(key, value);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
if (__mwCtxData.s != null) {
|
|
1579
|
+
_mwCtx.status = __mwCtxData.s;
|
|
1580
|
+
}
|
|
1581
|
+
// Apply forwarded middleware rewrite so routing uses the rewritten path.
|
|
1582
|
+
// The RSC plugin constructs its Request from the original HTTP request,
|
|
1583
|
+
// not from req.url, so the connect handler's req.url rewrite is invisible.
|
|
1584
|
+
if (__mwCtxData.r) {
|
|
1585
|
+
const __rewriteParsed = new URL(__mwCtxData.r, request.url);
|
|
1586
|
+
cleanPathname = __rewriteParsed.pathname;
|
|
1587
|
+
url.search = __rewriteParsed.search;
|
|
1588
|
+
}
|
|
1589
|
+
// Flag set after full context application — if any step fails (e.g. malformed
|
|
1590
|
+
// rewrite URL), we fall back to re-running middleware as a safety net.
|
|
1591
|
+
__mwCtxApplied = true;
|
|
1592
|
+
} catch (e) {
|
|
1593
|
+
console.error("[vinext] Failed to parse forwarded middleware context:", e);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
if (!__mwCtxApplied) {
|
|
1502
1598
|
// Run proxy/middleware if present and path matches.
|
|
1503
1599
|
// Validate exports match the file type (proxy.ts vs middleware.ts), matching Next.js behavior.
|
|
1504
1600
|
// https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/proxy-missing-export/proxy-missing-export.test.ts
|
|
@@ -1576,6 +1672,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1576
1672
|
return new Response("Internal Server Error", { status: 500 });
|
|
1577
1673
|
}
|
|
1578
1674
|
}
|
|
1675
|
+
} // end of if (!__mwCtxApplied)
|
|
1579
1676
|
|
|
1580
1677
|
// Unpack x-middleware-request-* headers into the request context so that
|
|
1581
1678
|
// headers() returns the middleware-modified headers instead of the original
|
|
@@ -1586,8 +1683,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1586
1683
|
applyMiddlewareRequestHeaders(_mwCtx.headers);
|
|
1587
1684
|
processMiddlewareHeaders(_mwCtx.headers);
|
|
1588
1685
|
}
|
|
1589
|
-
`
|
|
1590
|
-
: ""}
|
|
1686
|
+
` : ""}
|
|
1591
1687
|
|
|
1592
1688
|
// Build post-middleware request context for afterFiles/fallback rewrites.
|
|
1593
1689
|
// These run after middleware in the App Router execution order and should
|
|
@@ -1897,6 +1993,28 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1897
1993
|
}
|
|
1898
1994
|
|
|
1899
1995
|
if (!match) {
|
|
1996
|
+
${hasPagesDir ? `
|
|
1997
|
+
// ── Pages Router fallback ────────────────────────────────────────────
|
|
1998
|
+
// When a request doesn't match any App Router route, delegate to the
|
|
1999
|
+
// Pages Router handler (available in the SSR environment). This covers
|
|
2000
|
+
// both production request serving and prerender fetches from wrangler.
|
|
2001
|
+
// RSC requests (.rsc suffix or Accept: text/x-component) cannot be
|
|
2002
|
+
// handled by the Pages Router, so skip the delegation for those.
|
|
2003
|
+
if (!isRscRequest) {
|
|
2004
|
+
const __pagesEntry = await import.meta.viteRsc.loadModule("ssr", "index");
|
|
2005
|
+
if (typeof __pagesEntry.renderPage === "function") {
|
|
2006
|
+
const __pagesRes = await __pagesEntry.renderPage(request, decodeURIComponent(url.pathname) + (url.search || ""), {});
|
|
2007
|
+
// Only return the Pages Router response if it matched a route
|
|
2008
|
+
// (non-404). A 404 means the path isn't a Pages route either,
|
|
2009
|
+
// so fall through to the App Router not-found page below.
|
|
2010
|
+
if (__pagesRes.status !== 404) {
|
|
2011
|
+
setHeadersContext(null);
|
|
2012
|
+
setNavigationContext(null);
|
|
2013
|
+
return __pagesRes;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
` : ""}
|
|
1900
2018
|
// Render custom not-found page if available, otherwise plain 404
|
|
1901
2019
|
const notFoundResponse = await renderNotFoundPage(null, isRscRequest, request);
|
|
1902
2020
|
if (notFoundResponse) return notFoundResponse;
|
|
@@ -1918,7 +2036,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1918
2036
|
if (route.routeHandler) {
|
|
1919
2037
|
const handler = route.routeHandler;
|
|
1920
2038
|
const method = request.method.toUpperCase();
|
|
1921
|
-
const revalidateSeconds = typeof handler.revalidate === "number" && handler.revalidate > 0 ? handler.revalidate : null;
|
|
2039
|
+
const revalidateSeconds = typeof handler.revalidate === "number" && handler.revalidate > 0 && handler.revalidate !== Infinity ? handler.revalidate : null;
|
|
1922
2040
|
if (typeof handler["default"] === "function" && process.env.NODE_ENV === "development") {
|
|
1923
2041
|
console.error(
|
|
1924
2042
|
"[vinext] Detected default export in route handler " + route.pattern + ". Export a named export for each HTTP method instead.",
|
|
@@ -1970,11 +2088,91 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1970
2088
|
isAutoHead = true;
|
|
1971
2089
|
}
|
|
1972
2090
|
|
|
2091
|
+
// ISR cache read for route handlers (production only).
|
|
2092
|
+
// Only GET/HEAD (auto-HEAD) with finite revalidate > 0 are ISR-eligible.
|
|
2093
|
+
// This runs before handler execution so a cache HIT skips the handler entirely.
|
|
2094
|
+
if (
|
|
2095
|
+
process.env.NODE_ENV === "production" &&
|
|
2096
|
+
revalidateSeconds !== null &&
|
|
2097
|
+
handler.dynamic !== "force-dynamic" &&
|
|
2098
|
+
(method === "GET" || isAutoHead) &&
|
|
2099
|
+
typeof handlerFn === "function"
|
|
2100
|
+
) {
|
|
2101
|
+
const __routeKey = __isrRouteKey(cleanPathname);
|
|
2102
|
+
try {
|
|
2103
|
+
const __cached = await __isrGet(__routeKey);
|
|
2104
|
+
if (__cached && !__cached.isStale && __cached.value.value && __cached.value.value.kind === "APP_ROUTE") {
|
|
2105
|
+
// HIT — return cached response immediately
|
|
2106
|
+
const __cv = __cached.value.value;
|
|
2107
|
+
__isrDebug?.("HIT (route)", cleanPathname);
|
|
2108
|
+
setHeadersContext(null);
|
|
2109
|
+
setNavigationContext(null);
|
|
2110
|
+
const __hitHeaders = Object.assign({}, __cv.headers || {});
|
|
2111
|
+
__hitHeaders["X-Vinext-Cache"] = "HIT";
|
|
2112
|
+
__hitHeaders["Cache-Control"] = "s-maxage=" + revalidateSeconds + ", stale-while-revalidate";
|
|
2113
|
+
if (isAutoHead) {
|
|
2114
|
+
return attachRouteHandlerMiddlewareContext(new Response(null, { status: __cv.status, headers: __hitHeaders }));
|
|
2115
|
+
}
|
|
2116
|
+
return attachRouteHandlerMiddlewareContext(new Response(__cv.body, { status: __cv.status, headers: __hitHeaders }));
|
|
2117
|
+
}
|
|
2118
|
+
if (__cached && __cached.isStale && __cached.value.value && __cached.value.value.kind === "APP_ROUTE") {
|
|
2119
|
+
// STALE — serve stale response, trigger background regeneration
|
|
2120
|
+
const __sv = __cached.value.value;
|
|
2121
|
+
const __revalSecs = revalidateSeconds;
|
|
2122
|
+
const __revalHandlerFn = handlerFn;
|
|
2123
|
+
const __revalParams = params;
|
|
2124
|
+
const __revalUrl = request.url;
|
|
2125
|
+
const __revalSearchParams = new URLSearchParams(url.searchParams);
|
|
2126
|
+
__triggerBackgroundRegeneration(__routeKey, async function() {
|
|
2127
|
+
const __revalHeadCtx = { headers: new Headers(), cookies: new Map() };
|
|
2128
|
+
const __revalUCtx = _createUnifiedCtx({
|
|
2129
|
+
headersContext: __revalHeadCtx,
|
|
2130
|
+
executionContext: _getRequestExecutionContext(),
|
|
2131
|
+
});
|
|
2132
|
+
await _runWithUnifiedCtx(__revalUCtx, async () => {
|
|
2133
|
+
_ensureFetchPatch();
|
|
2134
|
+
setNavigationContext({ pathname: cleanPathname, searchParams: __revalSearchParams, params: __revalParams });
|
|
2135
|
+
const __syntheticReq = new Request(__revalUrl, { method: "GET" });
|
|
2136
|
+
const __revalResponse = await __revalHandlerFn(__syntheticReq, { params: __revalParams });
|
|
2137
|
+
const __regenDynamic = consumeDynamicUsage();
|
|
2138
|
+
setNavigationContext(null);
|
|
2139
|
+
if (__regenDynamic) {
|
|
2140
|
+
__isrDebug?.("route regen skipped (dynamic usage)", cleanPathname);
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
const __freshBody = await __revalResponse.arrayBuffer();
|
|
2144
|
+
const __freshHeaders = {};
|
|
2145
|
+
__revalResponse.headers.forEach(function(v, k) {
|
|
2146
|
+
if (k !== "x-vinext-cache" && k !== "cache-control") __freshHeaders[k] = v;
|
|
2147
|
+
});
|
|
2148
|
+
const __routeTags = __pageCacheTags(cleanPathname, getCollectedFetchTags());
|
|
2149
|
+
await __isrSet(__routeKey, { kind: "APP_ROUTE", body: __freshBody, status: __revalResponse.status, headers: __freshHeaders }, __revalSecs, __routeTags);
|
|
2150
|
+
__isrDebug?.("route regen complete", __routeKey);
|
|
2151
|
+
});
|
|
2152
|
+
});
|
|
2153
|
+
__isrDebug?.("STALE (route)", cleanPathname);
|
|
2154
|
+
setHeadersContext(null);
|
|
2155
|
+
setNavigationContext(null);
|
|
2156
|
+
const __staleHeaders = Object.assign({}, __sv.headers || {});
|
|
2157
|
+
__staleHeaders["X-Vinext-Cache"] = "STALE";
|
|
2158
|
+
__staleHeaders["Cache-Control"] = "s-maxage=0, stale-while-revalidate";
|
|
2159
|
+
if (isAutoHead) {
|
|
2160
|
+
return attachRouteHandlerMiddlewareContext(new Response(null, { status: __sv.status, headers: __staleHeaders }));
|
|
2161
|
+
}
|
|
2162
|
+
return attachRouteHandlerMiddlewareContext(new Response(__sv.body, { status: __sv.status, headers: __staleHeaders }));
|
|
2163
|
+
}
|
|
2164
|
+
} catch (__routeCacheErr) {
|
|
2165
|
+
// Cache read failure — fall through to normal handler execution
|
|
2166
|
+
console.error("[vinext] ISR route cache read error:", __routeCacheErr);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
|
|
1973
2170
|
if (typeof handlerFn === "function") {
|
|
1974
2171
|
const previousHeadersPhase = setHeadersAccessPhase("route-handler");
|
|
1975
2172
|
try {
|
|
1976
2173
|
const response = await handlerFn(request, { params });
|
|
1977
2174
|
const dynamicUsedInHandler = consumeDynamicUsage();
|
|
2175
|
+
const handlerSetCacheControl = response.headers.has("cache-control");
|
|
1978
2176
|
|
|
1979
2177
|
// Apply Cache-Control from route segment config (export const revalidate = N).
|
|
1980
2178
|
// Runtime request APIs like headers() / cookies() make GET handlers dynamic,
|
|
@@ -1983,11 +2181,43 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
1983
2181
|
revalidateSeconds !== null &&
|
|
1984
2182
|
!dynamicUsedInHandler &&
|
|
1985
2183
|
(method === "GET" || isAutoHead) &&
|
|
1986
|
-
!
|
|
2184
|
+
!handlerSetCacheControl
|
|
1987
2185
|
) {
|
|
1988
2186
|
response.headers.set("cache-control", "s-maxage=" + revalidateSeconds + ", stale-while-revalidate");
|
|
1989
2187
|
}
|
|
1990
2188
|
|
|
2189
|
+
// ISR cache write for route handlers (production, MISS).
|
|
2190
|
+
// Store the raw handler response before cookie/middleware transforms
|
|
2191
|
+
// (those are request-specific and shouldn't be cached).
|
|
2192
|
+
if (
|
|
2193
|
+
process.env.NODE_ENV === "production" &&
|
|
2194
|
+
revalidateSeconds !== null &&
|
|
2195
|
+
handler.dynamic !== "force-dynamic" &&
|
|
2196
|
+
!dynamicUsedInHandler &&
|
|
2197
|
+
(method === "GET" || isAutoHead) &&
|
|
2198
|
+
!handlerSetCacheControl
|
|
2199
|
+
) {
|
|
2200
|
+
response.headers.set("X-Vinext-Cache", "MISS");
|
|
2201
|
+
const __routeClone = response.clone();
|
|
2202
|
+
const __routeKey = __isrRouteKey(cleanPathname);
|
|
2203
|
+
const __revalSecs = revalidateSeconds;
|
|
2204
|
+
const __routeTags = __pageCacheTags(cleanPathname, getCollectedFetchTags());
|
|
2205
|
+
const __routeWritePromise = (async () => {
|
|
2206
|
+
try {
|
|
2207
|
+
const __buf = await __routeClone.arrayBuffer();
|
|
2208
|
+
const __hdrs = {};
|
|
2209
|
+
__routeClone.headers.forEach(function(v, k) {
|
|
2210
|
+
if (k !== "x-vinext-cache" && k !== "cache-control") __hdrs[k] = v;
|
|
2211
|
+
});
|
|
2212
|
+
await __isrSet(__routeKey, { kind: "APP_ROUTE", body: __buf, status: __routeClone.status, headers: __hdrs }, __revalSecs, __routeTags);
|
|
2213
|
+
__isrDebug?.("route cache written", __routeKey);
|
|
2214
|
+
} catch (__cacheErr) {
|
|
2215
|
+
console.error("[vinext] ISR route cache write error:", __cacheErr);
|
|
2216
|
+
}
|
|
2217
|
+
})();
|
|
2218
|
+
_getRequestExecutionContext()?.waitUntil(__routeWritePromise);
|
|
2219
|
+
}
|
|
2220
|
+
|
|
1991
2221
|
// Collect any Set-Cookie headers from cookies().set()/delete() calls
|
|
1992
2222
|
const pendingCookies = getAndClearPendingCookies();
|
|
1993
2223
|
const draftCookie = getDraftModeCookieHeader();
|
|
@@ -2190,8 +2420,8 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
2190
2420
|
});
|
|
2191
2421
|
const __revalResult = await _runWithUnifiedCtx(__revalUCtx, async () => {
|
|
2192
2422
|
_ensureFetchPatch();
|
|
2193
|
-
setNavigationContext({ pathname: cleanPathname, searchParams:
|
|
2194
|
-
const __revalElement = await buildPageElement(route, params, undefined,
|
|
2423
|
+
setNavigationContext({ pathname: cleanPathname, searchParams: new URLSearchParams(), params });
|
|
2424
|
+
const __revalElement = await buildPageElement(route, params, undefined, new URLSearchParams());
|
|
2195
2425
|
const __revalOnError = createRscOnErrorHandler(request, cleanPathname, route.pattern);
|
|
2196
2426
|
const __revalRscStream = renderToReadableStream(__revalElement, { onError: __revalOnError });
|
|
2197
2427
|
// Tee RSC stream: one for SSR, one to capture rscData
|
|
@@ -2703,8 +2933,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
2703
2933
|
// the HTML output has double <html>/<body> (root layout + global-error.tsx).
|
|
2704
2934
|
// Discard it and re-render using renderErrorBoundaryPage which skips layouts
|
|
2705
2935
|
// when the error falls through to global-error.tsx.
|
|
2706
|
-
${globalErrorVar
|
|
2707
|
-
? `
|
|
2936
|
+
${globalErrorVar ? `
|
|
2708
2937
|
if (_rscErrorForRerender && !isRscRequest) {
|
|
2709
2938
|
const _hasLocalBoundary = !!(route?.error?.default) || !!(route?.errors && route.errors.some(function(e) { return e?.default; }));
|
|
2710
2939
|
if (!_hasLocalBoundary) {
|
|
@@ -2712,8 +2941,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
|
|
|
2712
2941
|
if (cleanResp) return cleanResp;
|
|
2713
2942
|
}
|
|
2714
2943
|
}
|
|
2715
|
-
`
|
|
2716
|
-
: ""}
|
|
2944
|
+
` : ""}
|
|
2717
2945
|
|
|
2718
2946
|
// Check for draftMode Set-Cookie header (from draftMode().enable()/disable())
|
|
2719
2947
|
const draftCookie = getDraftModeCookieHeader();
|
|
@@ -2914,4 +3142,7 @@ if (import.meta.hot) {
|
|
|
2914
3142
|
}
|
|
2915
3143
|
`;
|
|
2916
3144
|
}
|
|
3145
|
+
//#endregion
|
|
3146
|
+
export { generateRscEntry };
|
|
3147
|
+
|
|
2917
3148
|
//# sourceMappingURL=app-rsc-entry.js.map
|