vinext 0.0.29 → 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 -567
- 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 -366
- 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 +618 -343
- 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 +229 -207
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +82 -62
- package/dist/index.js +2172 -3125
- 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 +563 -659
- 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 -13
- package/dist/server/dev-server.js +547 -874
- 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 +183 -200
- 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 +109 -126
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-routes.d.ts +85 -88
- package/dist/server/metadata-routes.js +277 -286
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-codegen.d.ts +7 -4
- package/dist/server/middleware-codegen.js +98 -65
- 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 +276 -363
- 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 +58 -0
- package/dist/server/pages-i18n.js +125 -0
- package/dist/server/pages-i18n.js.map +1 -0
- 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 +21 -43
- package/dist/shims/cache-runtime.js +271 -405
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +131 -119
- package/dist/shims/cache.js +339 -418
- 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 -165
- 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 +26 -10
- package/dist/shims/fetch-cache.js +443 -586
- 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 +9 -10
- package/dist/shims/head-state.js +25 -39
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +16 -18
- package/dist/shims/head.js +185 -153
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +84 -71
- package/dist/shims/headers.js +447 -583
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-context.d.ts +23 -0
- package/dist/shims/i18n-context.js +44 -0
- package/dist/shims/i18n-context.js.map +1 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +45 -0
- package/dist/shims/i18n-state.js.map +1 -0
- 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 -44
- package/dist/shims/image.js +284 -301
- 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 -36
- 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 +262 -382
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +210 -202
- package/dist/shims/metadata.js +545 -544
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.d.ts +19 -13
- package/dist/shims/navigation-state.js +68 -58
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +59 -63
- package/dist/shims/navigation.js +508 -690
- 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 -51
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/request-state-types.d.ts +11 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/router-state.d.ts +15 -1
- package/dist/shims/router-state.js +34 -41
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +81 -81
- package/dist/shims/router.js +517 -543
- 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 -157
- package/dist/shims/server.js +462 -432
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +66 -0
- package/dist/shims/unified-request-context.js +98 -0
- package/dist/shims/unified-request-context.js.map +1 -0
- 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 +26 -0
- package/dist/utils/domain-locale.js +44 -0
- package/dist/utils/domain-locale.js.map +1 -0
- 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 +11 -10
- 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/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/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/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/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/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,99 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
* Pages Router server entry generator.
|
|
3
|
-
*
|
|
4
|
-
* Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).
|
|
5
|
-
* This is the entry point for `vite build --ssr`. It handles SSR, API routes,
|
|
6
|
-
* middleware, ISR, and i18n for the Pages Router.
|
|
7
|
-
*
|
|
8
|
-
* Extracted from index.ts.
|
|
9
|
-
*/
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { pagesRouter, apiRouter } from "../routing/pages-router.js";
|
|
1
|
+
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
13
2
|
import { isProxyFile } from "../server/middleware.js";
|
|
14
|
-
import {
|
|
3
|
+
import { generateMiddlewareMatcherCode, generateNormalizePathCode, generateRouteMatchNormalizationCode, generateSafeRegExpCode } from "../server/middleware-codegen.js";
|
|
15
4
|
import { findFileWithExts } from "./pages-entry-helpers.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
//#region src/entries/pages-server-entry.ts
|
|
8
|
+
/**
|
|
9
|
+
* Pages Router server entry generator.
|
|
10
|
+
*
|
|
11
|
+
* Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).
|
|
12
|
+
* This is the entry point for `vite build --ssr`. It handles SSR, API routes,
|
|
13
|
+
* middleware, ISR, and i18n for the Pages Router.
|
|
14
|
+
*
|
|
15
|
+
* Extracted from index.ts.
|
|
16
|
+
*/
|
|
16
17
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
17
18
|
const _requestContextShimPath = fileURLToPath(new URL("../shims/request-context.js", import.meta.url)).replace(/\\/g, "/");
|
|
18
19
|
const _routeTriePath = fileURLToPath(new URL("../routing/route-trie.js", import.meta.url)).replace(/\\/g, "/");
|
|
20
|
+
const _pagesI18nPath = fileURLToPath(new URL("../server/pages-i18n.js", import.meta.url)).replace(/\\/g, "/");
|
|
19
21
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
headers: nextConfig?.headers ?? [],
|
|
74
|
-
i18n: nextConfig?.i18n ?? null,
|
|
75
|
-
images: {
|
|
76
|
-
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
77
|
-
imageSizes: nextConfig?.images?.imageSizes,
|
|
78
|
-
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
79
|
-
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
80
|
-
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
// Generate instrumentation code if instrumentation.ts exists.
|
|
84
|
-
// For production (Cloudflare Workers), instrumentation.ts is bundled into the
|
|
85
|
-
// Worker and register() is called as a top-level await at module evaluation time —
|
|
86
|
-
// before any request is handled. This mirrors App Router behavior (generateRscEntry)
|
|
87
|
-
// and matches Next.js semantics: register() runs once on startup in the process
|
|
88
|
-
// that handles requests.
|
|
89
|
-
//
|
|
90
|
-
// The onRequestError handler is stored on globalThis so it is visible across
|
|
91
|
-
// all code within the Worker (same global scope).
|
|
92
|
-
const instrumentationImportCode = instrumentationPath
|
|
93
|
-
? `import * as _instrumentation from ${JSON.stringify(instrumentationPath.replace(/\\/g, "/"))};`
|
|
94
|
-
: "";
|
|
95
|
-
const instrumentationInitCode = instrumentationPath
|
|
96
|
-
? `// Run instrumentation register() once at module evaluation time — before any
|
|
22
|
+
* Generate the virtual SSR server entry module.
|
|
23
|
+
* This is the entry point for `vite build --ssr`.
|
|
24
|
+
*/
|
|
25
|
+
async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath) {
|
|
26
|
+
const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
27
|
+
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
28
|
+
const pageImports = pageRoutes.map((r, i) => {
|
|
29
|
+
const absPath = r.filePath.replace(/\\/g, "/");
|
|
30
|
+
return `import * as page_${i} from ${JSON.stringify(absPath)};`;
|
|
31
|
+
});
|
|
32
|
+
const apiImports = apiRoutes.map((r, i) => {
|
|
33
|
+
const absPath = r.filePath.replace(/\\/g, "/");
|
|
34
|
+
return `import * as api_${i} from ${JSON.stringify(absPath)};`;
|
|
35
|
+
});
|
|
36
|
+
const pageRouteEntries = pageRoutes.map((r, i) => {
|
|
37
|
+
const absPath = r.filePath.replace(/\\/g, "/");
|
|
38
|
+
return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;
|
|
39
|
+
});
|
|
40
|
+
const apiRouteEntries = apiRoutes.map((r, i) => {
|
|
41
|
+
return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`;
|
|
42
|
+
});
|
|
43
|
+
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
44
|
+
const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
|
|
45
|
+
const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(appFilePath.replace(/\\/g, "/"))};` : `const AppComponent = null;`;
|
|
46
|
+
const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath.replace(/\\/g, "/"))};` : `const DocumentComponent = null;`;
|
|
47
|
+
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
48
|
+
locales: nextConfig.i18n.locales,
|
|
49
|
+
defaultLocale: nextConfig.i18n.defaultLocale,
|
|
50
|
+
localeDetection: nextConfig.i18n.localeDetection,
|
|
51
|
+
domains: nextConfig.i18n.domains
|
|
52
|
+
}) : "null";
|
|
53
|
+
const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);
|
|
54
|
+
const vinextConfigJson = JSON.stringify({
|
|
55
|
+
basePath: nextConfig?.basePath ?? "",
|
|
56
|
+
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
57
|
+
redirects: nextConfig?.redirects ?? [],
|
|
58
|
+
rewrites: nextConfig?.rewrites ?? {
|
|
59
|
+
beforeFiles: [],
|
|
60
|
+
afterFiles: [],
|
|
61
|
+
fallback: []
|
|
62
|
+
},
|
|
63
|
+
headers: nextConfig?.headers ?? [],
|
|
64
|
+
i18n: nextConfig?.i18n ?? null,
|
|
65
|
+
images: {
|
|
66
|
+
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
67
|
+
imageSizes: nextConfig?.images?.imageSizes,
|
|
68
|
+
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
69
|
+
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
70
|
+
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath.replace(/\\/g, "/"))};` : "";
|
|
74
|
+
const instrumentationInitCode = instrumentationPath ? `// Run instrumentation register() once at module evaluation time — before any
|
|
97
75
|
// requests are handled. Matches Next.js semantics: register() is called once
|
|
98
76
|
// on startup in the process that handles requests.
|
|
99
77
|
if (typeof _instrumentation.register === "function") {
|
|
@@ -103,17 +81,10 @@ if (typeof _instrumentation.register === "function") {
|
|
|
103
81
|
// code within the Worker (same global scope).
|
|
104
82
|
if (typeof _instrumentation.onRequestError === "function") {
|
|
105
83
|
globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;
|
|
106
|
-
}`
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
? `import * as middlewareModule from ${JSON.stringify(middlewarePath.replace(/\\/g, "/"))};
|
|
111
|
-
import { NextRequest, NextFetchEvent } from "next/server";`
|
|
112
|
-
: "";
|
|
113
|
-
// The matcher config is read from the middleware module at import time.
|
|
114
|
-
// We inline the matching + execution logic so the prod server can call it.
|
|
115
|
-
const middlewareExportCode = middlewarePath
|
|
116
|
-
? `
|
|
84
|
+
}` : "";
|
|
85
|
+
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(middlewarePath.replace(/\\/g, "/"))};
|
|
86
|
+
import { NextRequest, NextFetchEvent } from "next/server";` : "";
|
|
87
|
+
const middlewareExportCode = middlewarePath ? `
|
|
117
88
|
// --- Middleware support (generated from middleware-codegen.ts) ---
|
|
118
89
|
${generateNormalizePathCode("es5")}
|
|
119
90
|
${generateRouteMatchNormalizationCode("es5")}
|
|
@@ -211,32 +182,33 @@ async function _runMiddleware(request) {
|
|
|
211
182
|
|
|
212
183
|
return { continue: false, response: response };
|
|
213
184
|
}
|
|
214
|
-
`
|
|
215
|
-
: `
|
|
185
|
+
` : `
|
|
216
186
|
export async function runMiddleware() { return { continue: true }; }
|
|
217
187
|
`;
|
|
218
|
-
|
|
219
|
-
// (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.
|
|
220
|
-
return `
|
|
188
|
+
return `
|
|
221
189
|
import React from "react";
|
|
222
190
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
223
191
|
import { resetSSRHead, getSSRHeadHTML } from "next/head";
|
|
224
192
|
import { flushPreloads } from "next/dynamic";
|
|
225
193
|
import { setSSRContext, wrapWithRouterContext } from "next/router";
|
|
226
|
-
import { getCacheHandler } from "next/cache";
|
|
227
|
-
import { runWithFetchCache } from "vinext/fetch-cache";
|
|
228
|
-
import { _runWithCacheState } from "next/cache";
|
|
194
|
+
import { getCacheHandler, _runWithCacheState } from "next/cache";
|
|
229
195
|
import { runWithPrivateCache } from "vinext/cache-runtime";
|
|
230
|
-
import {
|
|
196
|
+
import { ensureFetchPatch, runWithFetchCache } from "vinext/fetch-cache";
|
|
197
|
+
import { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from "vinext/unified-request-context";
|
|
198
|
+
import "vinext/router-state";
|
|
199
|
+
import { runWithServerInsertedHTMLState } from "vinext/navigation-state";
|
|
231
200
|
import { runWithHeadState } from "vinext/head-state";
|
|
201
|
+
import "vinext/i18n-state";
|
|
202
|
+
import { setI18nContext } from "vinext/i18n-context";
|
|
232
203
|
import { safeJsonStringify } from "vinext/html";
|
|
233
204
|
import { decode as decodeQueryString } from "node:querystring";
|
|
234
205
|
import { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from "next/font/google";
|
|
235
206
|
import { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from "next/font/local";
|
|
236
|
-
import { parseCookies } from ${JSON.stringify(path.resolve(__dirname, "../config/config-matchers.js").replace(/\\/g, "/"))};
|
|
207
|
+
import { parseCookies, sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(path.resolve(__dirname, "../config/config-matchers.js").replace(/\\/g, "/"))};
|
|
237
208
|
import { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};
|
|
238
209
|
import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};
|
|
239
210
|
import { reportRequestError as _reportRequestError } from "vinext/instrumentation";
|
|
211
|
+
import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
|
|
240
212
|
${instrumentationImportCode}
|
|
241
213
|
${middlewareImportCode}
|
|
242
214
|
|
|
@@ -322,13 +294,28 @@ async function renderToStringAsync(element) {
|
|
|
322
294
|
return new Response(stream).text();
|
|
323
295
|
}
|
|
324
296
|
|
|
297
|
+
async function renderIsrPassToStringAsync(element) {
|
|
298
|
+
// The cache-fill render is a second render pass for the same request.
|
|
299
|
+
// Reset render-scoped state so it cannot leak from the streamed response
|
|
300
|
+
// render or affect async work that is still draining from that stream.
|
|
301
|
+
// Keep request identity state (pathname/query/locale/executionContext)
|
|
302
|
+
// intact: this second pass still belongs to the same request.
|
|
303
|
+
return await runWithServerInsertedHTMLState(() =>
|
|
304
|
+
runWithHeadState(() =>
|
|
305
|
+
_runWithCacheState(() =>
|
|
306
|
+
runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),
|
|
307
|
+
),
|
|
308
|
+
),
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
325
312
|
${pageImports.join("\n")}
|
|
326
313
|
${apiImports.join("\n")}
|
|
327
314
|
|
|
328
315
|
${appImportCode}
|
|
329
316
|
${docImportCode}
|
|
330
317
|
|
|
331
|
-
const pageRoutes = [
|
|
318
|
+
export const pageRoutes = [
|
|
332
319
|
${pageRouteEntries.join(",\n")}
|
|
333
320
|
];
|
|
334
321
|
const _pageRouteTrie = _buildRouteTrie(pageRoutes);
|
|
@@ -390,7 +377,7 @@ function collectAssetTags(manifest, moduleIds) {
|
|
|
390
377
|
const entry = globalThis.__VINEXT_CLIENT_ENTRY__;
|
|
391
378
|
seen.add(entry);
|
|
392
379
|
tags.push('<link rel="modulepreload" href="/' + entry + '" />');
|
|
393
|
-
tags.push('<script type="module" src="/' + entry + '" crossorigin
|
|
380
|
+
tags.push('<script type="module" src="/' + entry + '" crossorigin><\/script>');
|
|
394
381
|
}
|
|
395
382
|
if (m) {
|
|
396
383
|
// Always inject shared chunks (framework, vinext runtime, entry) and
|
|
@@ -471,7 +458,7 @@ function collectAssetTags(manifest, moduleIds) {
|
|
|
471
458
|
// (React.lazy, next/dynamic) and should only be fetched on demand.
|
|
472
459
|
if (lazySet && lazySet.has(tf)) continue;
|
|
473
460
|
tags.push('<link rel="modulepreload" href="/' + tf + '" />');
|
|
474
|
-
tags.push('<script type="module" src="/' + tf + '" crossorigin
|
|
461
|
+
tags.push('<script type="module" src="/' + tf + '" crossorigin><\/script>');
|
|
475
462
|
}
|
|
476
463
|
}
|
|
477
464
|
}
|
|
@@ -651,23 +638,25 @@ export async function renderPage(request, url, manifest, ctx) {
|
|
|
651
638
|
}
|
|
652
639
|
|
|
653
640
|
async function _renderPage(request, url, manifest) {
|
|
654
|
-
const localeInfo =
|
|
641
|
+
const localeInfo = i18nConfig
|
|
642
|
+
? resolvePagesI18nRequest(
|
|
643
|
+
url,
|
|
644
|
+
i18nConfig,
|
|
645
|
+
request.headers,
|
|
646
|
+
new URL(request.url).hostname,
|
|
647
|
+
vinextConfig.basePath,
|
|
648
|
+
vinextConfig.trailingSlash,
|
|
649
|
+
)
|
|
650
|
+
: { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };
|
|
655
651
|
const locale = localeInfo.locale;
|
|
656
652
|
const routeUrl = localeInfo.url;
|
|
657
|
-
const
|
|
653
|
+
const currentDefaultLocale = i18nConfig
|
|
654
|
+
? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)
|
|
655
|
+
: undefined;
|
|
656
|
+
const domainLocales = i18nConfig ? i18nConfig.domains : undefined;
|
|
658
657
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
const cookieLocale = parseCookieLocaleFromHeader(cookieHeader);
|
|
662
|
-
if (cookieLocale && cookieLocale !== i18nConfig.defaultLocale) {
|
|
663
|
-
return new Response(null, { status: 307, headers: { Location: "/" + cookieLocale + routeUrl } });
|
|
664
|
-
}
|
|
665
|
-
if (!cookieLocale && i18nConfig.localeDetection !== false) {
|
|
666
|
-
const detected = detectLocaleFromHeaders(request.headers);
|
|
667
|
-
if (detected && detected !== i18nConfig.defaultLocale) {
|
|
668
|
-
return new Response(null, { status: 307, headers: { Location: "/" + detected + routeUrl } });
|
|
669
|
-
}
|
|
670
|
-
}
|
|
658
|
+
if (localeInfo.redirectUrl) {
|
|
659
|
+
return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });
|
|
671
660
|
}
|
|
672
661
|
|
|
673
662
|
const match = matchRoute(routeUrl, pageRoutes);
|
|
@@ -677,12 +666,12 @@ async function _renderPage(request, url, manifest) {
|
|
|
677
666
|
}
|
|
678
667
|
|
|
679
668
|
const { route, params } = match;
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
669
|
+
const __uCtx = _createUnifiedCtx({
|
|
670
|
+
executionContext: _getRequestExecutionContext(),
|
|
671
|
+
});
|
|
672
|
+
return _runWithUnifiedCtx(__uCtx, async () => {
|
|
673
|
+
ensureFetchPatch();
|
|
674
|
+
try {
|
|
686
675
|
if (typeof setSSRContext === "function") {
|
|
687
676
|
setSSRContext({
|
|
688
677
|
pathname: patternToNextFormat(route.pattern),
|
|
@@ -690,14 +679,19 @@ async function _renderPage(request, url, manifest) {
|
|
|
690
679
|
asPath: routeUrl,
|
|
691
680
|
locale: locale,
|
|
692
681
|
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
693
|
-
defaultLocale:
|
|
682
|
+
defaultLocale: currentDefaultLocale,
|
|
683
|
+
domainLocales: domainLocales,
|
|
694
684
|
});
|
|
695
685
|
}
|
|
696
686
|
|
|
697
687
|
if (i18nConfig) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
688
|
+
setI18nContext({
|
|
689
|
+
locale: locale,
|
|
690
|
+
locales: i18nConfig.locales,
|
|
691
|
+
defaultLocale: currentDefaultLocale,
|
|
692
|
+
domainLocales: domainLocales,
|
|
693
|
+
hostname: new URL(request.url).hostname,
|
|
694
|
+
});
|
|
701
695
|
}
|
|
702
696
|
|
|
703
697
|
const pageModule = route.module;
|
|
@@ -710,7 +704,7 @@ async function _renderPage(request, url, manifest) {
|
|
|
710
704
|
if (typeof pageModule.getStaticPaths === "function" && route.isDynamic) {
|
|
711
705
|
const pathsResult = await pageModule.getStaticPaths({
|
|
712
706
|
locales: i18nConfig ? i18nConfig.locales : [],
|
|
713
|
-
defaultLocale:
|
|
707
|
+
defaultLocale: currentDefaultLocale || "",
|
|
714
708
|
});
|
|
715
709
|
const fallback = pathsResult && pathsResult.fallback !== undefined ? pathsResult.fallback : false;
|
|
716
710
|
|
|
@@ -743,7 +737,7 @@ async function _renderPage(request, url, manifest) {
|
|
|
743
737
|
resolvedUrl: routeUrl,
|
|
744
738
|
locale: locale,
|
|
745
739
|
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
746
|
-
defaultLocale:
|
|
740
|
+
defaultLocale: currentDefaultLocale,
|
|
747
741
|
};
|
|
748
742
|
const result = await pageModule.getServerSideProps(ctx);
|
|
749
743
|
// If gSSP called res.end() directly (short-circuit), return that response.
|
|
@@ -792,61 +786,89 @@ async function _renderPage(request, url, manifest) {
|
|
|
792
786
|
|
|
793
787
|
if (cached && cached.isStale && cached.value.value && cached.value.value.kind === "PAGES") {
|
|
794
788
|
triggerBackgroundRegeneration(cacheKey, async function() {
|
|
795
|
-
var
|
|
796
|
-
|
|
797
|
-
locale: locale,
|
|
798
|
-
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
799
|
-
defaultLocale: i18nConfig ? i18nConfig.defaultLocale : undefined,
|
|
789
|
+
var revalCtx = _createUnifiedCtx({
|
|
790
|
+
executionContext: _getRequestExecutionContext(),
|
|
800
791
|
});
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
792
|
+
return _runWithUnifiedCtx(revalCtx, async () => {
|
|
793
|
+
ensureFetchPatch();
|
|
794
|
+
var freshResult = await pageModule.getStaticProps({
|
|
795
|
+
params: params,
|
|
796
|
+
locale: locale,
|
|
797
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
798
|
+
defaultLocale: currentDefaultLocale,
|
|
799
|
+
});
|
|
800
|
+
if (freshResult && freshResult.props && typeof freshResult.revalidate === "number" && freshResult.revalidate > 0) {
|
|
801
|
+
var _fp = freshResult.props;
|
|
802
|
+
if (typeof setSSRContext === "function") {
|
|
803
|
+
setSSRContext({
|
|
804
|
+
pathname: patternToNextFormat(route.pattern),
|
|
805
|
+
query: { ...params, ...parseQuery(routeUrl) },
|
|
806
|
+
asPath: routeUrl,
|
|
807
|
+
locale: locale,
|
|
808
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
809
|
+
defaultLocale: currentDefaultLocale,
|
|
810
|
+
domainLocales: domainLocales,
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
if (i18nConfig) {
|
|
814
|
+
setI18nContext({
|
|
815
|
+
locale: locale,
|
|
816
|
+
locales: i18nConfig.locales,
|
|
817
|
+
defaultLocale: currentDefaultLocale,
|
|
818
|
+
domainLocales: domainLocales,
|
|
819
|
+
hostname: new URL(request.url).hostname,
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
// Re-render the page with fresh props inside fresh render sub-scopes
|
|
823
|
+
// so head/cache state cannot leak across passes.
|
|
824
|
+
var _el = AppComponent
|
|
825
|
+
? React.createElement(AppComponent, { Component: PageComponent, pageProps: _fp })
|
|
826
|
+
: React.createElement(PageComponent, _fp);
|
|
827
|
+
_el = wrapWithRouterContext(_el);
|
|
828
|
+
var _freshBody = await renderIsrPassToStringAsync(_el);
|
|
829
|
+
// Rebuild __NEXT_DATA__ with fresh props
|
|
830
|
+
var _regenPayload = {
|
|
831
|
+
props: { pageProps: _fp }, page: patternToNextFormat(route.pattern),
|
|
832
|
+
query: params, buildId: buildId, isFallback: false,
|
|
833
|
+
};
|
|
834
|
+
if (i18nConfig) {
|
|
835
|
+
_regenPayload.locale = locale;
|
|
836
|
+
_regenPayload.locales = i18nConfig.locales;
|
|
837
|
+
_regenPayload.defaultLocale = currentDefaultLocale;
|
|
838
|
+
_regenPayload.domainLocales = domainLocales;
|
|
839
|
+
}
|
|
840
|
+
var _lGlobals = i18nConfig
|
|
841
|
+
? ";window.__VINEXT_LOCALE__=" + safeJsonStringify(locale) +
|
|
842
|
+
";window.__VINEXT_LOCALES__=" + safeJsonStringify(i18nConfig.locales) +
|
|
843
|
+
";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(currentDefaultLocale)
|
|
844
|
+
: "";
|
|
845
|
+
var _freshNDS = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(_regenPayload) + _lGlobals + "<\/script>";
|
|
846
|
+
// Reconstruct ISR HTML preserving the document shell from the
|
|
847
|
+
// cached entry (head, fonts, assets, custom _document markup).
|
|
848
|
+
var _cachedStr = cached.value.value.html;
|
|
849
|
+
var _btag = '<div id="__next">';
|
|
850
|
+
var _bstart = _cachedStr.indexOf(_btag);
|
|
851
|
+
var _bodyStart = _bstart >= 0 ? _bstart + _btag.length : -1;
|
|
852
|
+
// Locate __NEXT_DATA__ script to split body from suffix
|
|
853
|
+
var _ndMarker = '<script>window.__NEXT_DATA__';
|
|
854
|
+
var _ndStart = _cachedStr.indexOf(_ndMarker);
|
|
855
|
+
var _freshHtml;
|
|
856
|
+
if (_bodyStart >= 0 && _ndStart >= 0) {
|
|
857
|
+
// Region between body start and __NEXT_DATA__ contains:
|
|
858
|
+
// BODY_HTML + </div> + optional gap (custom _document content)
|
|
859
|
+
var _region = _cachedStr.slice(_bodyStart, _ndStart);
|
|
860
|
+
var _lastClose = _region.lastIndexOf('</div>');
|
|
861
|
+
var _gap = _lastClose >= 0 ? _region.slice(_lastClose + 6) : '';
|
|
862
|
+
// Tail: everything after the old __NEXT_DATA__ <\/script>
|
|
863
|
+
var _ndEnd = _cachedStr.indexOf('<\/script>', _ndStart) + 9;
|
|
864
|
+
var _tail = _cachedStr.slice(_ndEnd);
|
|
865
|
+
_freshHtml = _cachedStr.slice(0, _bodyStart) + _freshBody + '</div>' + _gap + _freshNDS + _tail;
|
|
866
|
+
} else {
|
|
867
|
+
_freshHtml = '<!DOCTYPE html>\\n<html>\\n<head>\\n</head>\\n<body>\\n <div id="__next">' + _freshBody + '</div>\\n ' + _freshNDS + '\\n</body>\\n</html>';
|
|
868
|
+
}
|
|
869
|
+
await isrSet(cacheKey, { kind: "PAGES", html: _freshHtml, pageData: _fp, headers: undefined, status: undefined }, freshResult.revalidate);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
850
872
|
});
|
|
851
873
|
var _staleHeaders = {
|
|
852
874
|
"Content-Type": "text/html", "X-Vinext-Cache": "STALE",
|
|
@@ -860,7 +882,7 @@ async function _renderPage(request, url, manifest) {
|
|
|
860
882
|
params,
|
|
861
883
|
locale: locale,
|
|
862
884
|
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
863
|
-
defaultLocale:
|
|
885
|
+
defaultLocale: currentDefaultLocale,
|
|
864
886
|
};
|
|
865
887
|
const result = await pageModule.getStaticProps(ctx);
|
|
866
888
|
if (result && result.props) pageProps = result.props;
|
|
@@ -913,14 +935,15 @@ async function _renderPage(request, url, manifest) {
|
|
|
913
935
|
if (i18nConfig) {
|
|
914
936
|
nextDataPayload.locale = locale;
|
|
915
937
|
nextDataPayload.locales = i18nConfig.locales;
|
|
916
|
-
nextDataPayload.defaultLocale =
|
|
938
|
+
nextDataPayload.defaultLocale = currentDefaultLocale;
|
|
939
|
+
nextDataPayload.domainLocales = domainLocales;
|
|
917
940
|
}
|
|
918
941
|
const localeGlobals = i18nConfig
|
|
919
942
|
? ";window.__VINEXT_LOCALE__=" + safeJsonStringify(locale) +
|
|
920
943
|
";window.__VINEXT_LOCALES__=" + safeJsonStringify(i18nConfig.locales) +
|
|
921
|
-
";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(
|
|
944
|
+
";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(currentDefaultLocale)
|
|
922
945
|
: "";
|
|
923
|
-
const nextDataScript = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(nextDataPayload) + localeGlobals + "
|
|
946
|
+
const nextDataScript = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(nextDataPayload) + localeGlobals + "<\/script>";
|
|
924
947
|
|
|
925
948
|
// Build the document shell with a placeholder for the streamed body
|
|
926
949
|
var BODY_MARKER = "<!--VINEXT_STREAM_BODY-->";
|
|
@@ -981,7 +1004,7 @@ async function _renderPage(request, url, manifest) {
|
|
|
981
1004
|
isrElement = React.createElement(PageComponent, pageProps);
|
|
982
1005
|
}
|
|
983
1006
|
isrElement = wrapWithRouterContext(isrElement);
|
|
984
|
-
var isrHtml = await
|
|
1007
|
+
var isrHtml = await renderIsrPassToStringAsync(isrElement);
|
|
985
1008
|
var fullHtml = shellPrefix + isrHtml + shellSuffix;
|
|
986
1009
|
var isrPathname = url.split("?")[0];
|
|
987
1010
|
var _cacheKey = isrCacheKey("pages", isrPathname);
|
|
@@ -1015,20 +1038,16 @@ async function _renderPage(request, url, manifest) {
|
|
|
1015
1038
|
responseHeaders.set("Link", _fontLinkHeader);
|
|
1016
1039
|
}
|
|
1017
1040
|
return new Response(compositeStream, { status: finalStatus, headers: responseHeaders });
|
|
1018
|
-
|
|
1041
|
+
} catch (e) {
|
|
1019
1042
|
console.error("[vinext] SSR error:", e);
|
|
1020
1043
|
_reportRequestError(
|
|
1021
1044
|
e instanceof Error ? e : new Error(String(e)),
|
|
1022
1045
|
{ path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },
|
|
1023
1046
|
{ routerKind: "Pages Router", routePath: route.pattern, routeType: "render" },
|
|
1024
|
-
);
|
|
1047
|
+
).catch(() => { /* ignore reporting errors */ });
|
|
1025
1048
|
return new Response("Internal Server Error", { status: 500 });
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
) // end runWithPrivateCache
|
|
1029
|
-
) // end _runWithCacheState
|
|
1030
|
-
) // end runWithHeadState
|
|
1031
|
-
); // end runWithRouterState
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1032
1051
|
}
|
|
1033
1052
|
|
|
1034
1053
|
export async function handleApiRoute(request, url) {
|
|
@@ -1108,4 +1127,7 @@ export async function handleApiRoute(request, url) {
|
|
|
1108
1127
|
${middlewareExportCode}
|
|
1109
1128
|
`;
|
|
1110
1129
|
}
|
|
1130
|
+
//#endregion
|
|
1131
|
+
export { generateServerEntry };
|
|
1132
|
+
|
|
1111
1133
|
//# sourceMappingURL=pages-server-entry.js.map
|