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,136 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
* instrumentation.ts support
|
|
3
|
-
*
|
|
4
|
-
* Next.js supports an `instrumentation.ts` file at the project root that
|
|
5
|
-
* exports a `register()` function. This function is called once when the
|
|
6
|
-
* server starts, before any request handling. It's the recommended way to
|
|
7
|
-
* set up observability tools (Sentry, Datadog, OpenTelemetry, etc.).
|
|
8
|
-
*
|
|
9
|
-
* Optionally, it can also export `onRequestError()` which is called when
|
|
10
|
-
* an unhandled error occurs during request handling.
|
|
11
|
-
*
|
|
12
|
-
* References:
|
|
13
|
-
* - https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
|
|
14
|
-
*
|
|
15
|
-
* ## App Router
|
|
16
|
-
*
|
|
17
|
-
* For App Router, `register()` is baked directly into the generated RSC entry
|
|
18
|
-
* as a top-level `await` at module evaluation time (see `entries/app-rsc-entry.ts`
|
|
19
|
-
* `generateRscEntry`). This means it runs inside the Worker process (or RSC
|
|
20
|
-
* Vite environment) — the same process that handles requests — before any
|
|
21
|
-
* request is served. `runInstrumentation()` is NOT called from `configureServer`
|
|
22
|
-
* for App Router.
|
|
23
|
-
*
|
|
24
|
-
* The `onRequestError` handler is stored on `globalThis` so it is visible across
|
|
25
|
-
* the RSC and SSR Vite environments (separate module graphs, same Node.js process).
|
|
26
|
-
* With `@cloudflare/vite-plugin` it runs entirely inside the Worker, so
|
|
27
|
-
* `globalThis` is the Worker's global — also correct.
|
|
28
|
-
*
|
|
29
|
-
* ## Pages Router
|
|
30
|
-
*
|
|
31
|
-
* Pages Router has no RSC entry, so `configureServer()` is the right place to
|
|
32
|
-
* call `register()`. `runInstrumentation()` accepts a `ModuleRunner` (created
|
|
33
|
-
* via `createDirectRunner()`) rather than `server.ssrLoadModule()` so it is
|
|
34
|
-
* safe when `@cloudflare/vite-plugin` is present — that plugin replaces the
|
|
35
|
-
* SSR environment's hot channel, causing `ssrLoadModule()` to crash with
|
|
36
|
-
* `TypeError: Cannot read properties of undefined (reading 'outsideEmitter')`.
|
|
37
|
-
*/
|
|
1
|
+
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
38
2
|
import fs from "node:fs";
|
|
39
3
|
import path from "node:path";
|
|
40
|
-
|
|
4
|
+
//#region src/server/instrumentation.ts
|
|
5
|
+
/**
|
|
6
|
+
* instrumentation.ts support
|
|
7
|
+
*
|
|
8
|
+
* Next.js supports an `instrumentation.ts` file at the project root that
|
|
9
|
+
* exports a `register()` function. This function is called once when the
|
|
10
|
+
* server starts, before any request handling. It's the recommended way to
|
|
11
|
+
* set up observability tools (Sentry, Datadog, OpenTelemetry, etc.).
|
|
12
|
+
*
|
|
13
|
+
* Optionally, it can also export `onRequestError()` which is called when
|
|
14
|
+
* an unhandled error occurs during request handling.
|
|
15
|
+
*
|
|
16
|
+
* References:
|
|
17
|
+
* - https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
|
|
18
|
+
*
|
|
19
|
+
* ## App Router
|
|
20
|
+
*
|
|
21
|
+
* For App Router, `register()` is baked directly into the generated RSC entry
|
|
22
|
+
* as a top-level `await` at module evaluation time (see `entries/app-rsc-entry.ts`
|
|
23
|
+
* `generateRscEntry`). This means it runs inside the Worker process (or RSC
|
|
24
|
+
* Vite environment) — the same process that handles requests — before any
|
|
25
|
+
* request is served. `runInstrumentation()` is NOT called from `configureServer`
|
|
26
|
+
* for App Router.
|
|
27
|
+
*
|
|
28
|
+
* The `onRequestError` handler is stored on `globalThis` so it is visible across
|
|
29
|
+
* the RSC and SSR Vite environments (separate module graphs, same Node.js process).
|
|
30
|
+
* With `@cloudflare/vite-plugin` it runs entirely inside the Worker, so
|
|
31
|
+
* `globalThis` is the Worker's global — also correct.
|
|
32
|
+
*
|
|
33
|
+
* ## Pages Router
|
|
34
|
+
*
|
|
35
|
+
* Pages Router has no RSC entry, so `configureServer()` is the right place to
|
|
36
|
+
* call `register()`. `runInstrumentation()` accepts a `ModuleRunner` (created
|
|
37
|
+
* via `createDirectRunner()`) rather than `server.ssrLoadModule()` so it is
|
|
38
|
+
* safe when `@cloudflare/vite-plugin` is present — that plugin replaces the
|
|
39
|
+
* SSR environment's hot channel, causing `ssrLoadModule()` to crash with
|
|
40
|
+
* `TypeError: Cannot read properties of undefined (reading 'outsideEmitter')`.
|
|
41
|
+
*/
|
|
41
42
|
/** Possible instrumentation file names. */
|
|
42
43
|
const INSTRUMENTATION_FILES = [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
"instrumentation.ts",
|
|
45
|
+
"instrumentation.tsx",
|
|
46
|
+
"instrumentation.js",
|
|
47
|
+
"instrumentation.mjs",
|
|
48
|
+
"src/instrumentation.ts",
|
|
49
|
+
"src/instrumentation.tsx",
|
|
50
|
+
"src/instrumentation.js",
|
|
51
|
+
"src/instrumentation.mjs"
|
|
51
52
|
];
|
|
52
53
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
54
|
+
* Find the instrumentation file in the project root.
|
|
55
|
+
*/
|
|
56
|
+
function findInstrumentationFile(root) {
|
|
57
|
+
for (const file of INSTRUMENTATION_FILES) {
|
|
58
|
+
const fullPath = path.join(root, file);
|
|
59
|
+
if (fs.existsSync(fullPath)) return fullPath;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
* Get the registered onRequestError handler (if any).
|
|
65
|
+
*
|
|
66
|
+
* Reads from globalThis so it works across Vite environment boundaries.
|
|
67
|
+
*/
|
|
68
|
+
function getOnRequestErrorHandler() {
|
|
69
|
+
return globalThis.__VINEXT_onRequestErrorHandler__ ?? null;
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
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
|
-
// same handler.
|
|
101
|
-
if (typeof mod.onRequestError === "function") {
|
|
102
|
-
globalThis.__VINEXT_onRequestErrorHandler__ = mod.onRequestError;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
console.error("[vinext] Failed to load instrumentation:", err instanceof Error ? err.message : String(err));
|
|
107
|
-
}
|
|
72
|
+
* Load and execute the instrumentation file via a ModuleRunner.
|
|
73
|
+
*
|
|
74
|
+
* Called once during Pages Router server startup (`configureServer`). It:
|
|
75
|
+
* 1. Loads the instrumentation module via `runner.import()`.
|
|
76
|
+
* 2. Calls the `register()` function if exported.
|
|
77
|
+
* 3. Stores the `onRequestError()` handler on `globalThis` so it is visible
|
|
78
|
+
* to all Vite environment module graphs (SSR and the host process share
|
|
79
|
+
* the same Node.js `globalThis`).
|
|
80
|
+
*
|
|
81
|
+
* **App Router** does not use this function. For App Router, `register()` is
|
|
82
|
+
* emitted as a top-level `await` inside the generated RSC entry module so it
|
|
83
|
+
* runs in the same Worker/environment as request handling.
|
|
84
|
+
*
|
|
85
|
+
* @param runner - A ModuleRunner created via `createDirectRunner()`. Must be
|
|
86
|
+
* the same long-lived runner used for middleware and SSR so the module graph
|
|
87
|
+
* is shared. Safe with all Vite plugin combinations, including
|
|
88
|
+
* `@cloudflare/vite-plugin`, because it never touches the hot channel.
|
|
89
|
+
* @param instrumentationPath - Absolute path to the instrumentation file
|
|
90
|
+
*/
|
|
91
|
+
async function runInstrumentation(runner, instrumentationPath) {
|
|
92
|
+
try {
|
|
93
|
+
const mod = await runner.import(instrumentationPath);
|
|
94
|
+
if (typeof mod.register === "function") await mod.register();
|
|
95
|
+
if (typeof mod.onRequestError === "function") globalThis.__VINEXT_onRequestErrorHandler__ = mod.onRequestError;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error("[vinext] Failed to load instrumentation:", err instanceof Error ? err.message : String(err));
|
|
98
|
+
}
|
|
108
99
|
}
|
|
109
100
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// On Cloudflare Workers, register with ctx.waitUntil() so the isolate
|
|
130
|
-
// stays alive until the report completes (e.g. Sentry HTTP request).
|
|
131
|
-
// On Node.js (dev or vinext start), getRequestExecutionContext() returns
|
|
132
|
-
// null — fire-and-forget is fine because the process doesn't die.
|
|
133
|
-
getRequestExecutionContext()?.waitUntil(promise);
|
|
134
|
-
return promise;
|
|
101
|
+
* Report a request error via the instrumentation handler.
|
|
102
|
+
*
|
|
103
|
+
* No-op if no onRequestError handler is registered.
|
|
104
|
+
*
|
|
105
|
+
* Reads the handler from globalThis so this function works correctly regardless
|
|
106
|
+
* of which environment it is called from.
|
|
107
|
+
*/
|
|
108
|
+
function reportRequestError(error, request, context) {
|
|
109
|
+
const handler = getOnRequestErrorHandler();
|
|
110
|
+
if (!handler) return Promise.resolve();
|
|
111
|
+
const promise = (async () => {
|
|
112
|
+
try {
|
|
113
|
+
await handler(error, request, context);
|
|
114
|
+
} catch (reportErr) {
|
|
115
|
+
console.error("[vinext] onRequestError handler threw:", reportErr instanceof Error ? reportErr.message : String(reportErr));
|
|
116
|
+
}
|
|
117
|
+
})();
|
|
118
|
+
getRequestExecutionContext()?.waitUntil(promise);
|
|
119
|
+
return promise;
|
|
135
120
|
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { findInstrumentationFile, getOnRequestErrorHandler, reportRequestError, runInstrumentation };
|
|
123
|
+
|
|
136
124
|
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","
|
|
1
|
+
{"version":3,"file":"instrumentation.js","names":[],"sources":["../../src/server/instrumentation.ts"],"sourcesContent":["/**\n * instrumentation.ts support\n *\n * Next.js supports an `instrumentation.ts` file at the project root that\n * exports a `register()` function. This function is called once when the\n * server starts, before any request handling. It's the recommended way to\n * set up observability tools (Sentry, Datadog, OpenTelemetry, etc.).\n *\n * Optionally, it can also export `onRequestError()` which is called when\n * an unhandled error occurs during request handling.\n *\n * References:\n * - https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation\n *\n * ## App Router\n *\n * For App Router, `register()` is baked directly into the generated RSC entry\n * as a top-level `await` at module evaluation time (see `entries/app-rsc-entry.ts`\n * `generateRscEntry`). This means it runs inside the Worker process (or RSC\n * Vite environment) — the same process that handles requests — before any\n * request is served. `runInstrumentation()` is NOT called from `configureServer`\n * for App Router.\n *\n * The `onRequestError` handler is stored on `globalThis` so it is visible across\n * the RSC and SSR Vite environments (separate module graphs, same Node.js process).\n * With `@cloudflare/vite-plugin` it runs entirely inside the Worker, so\n * `globalThis` is the Worker's global — also correct.\n *\n * ## Pages Router\n *\n * Pages Router has no RSC entry, so `configureServer()` is the right place to\n * call `register()`. `runInstrumentation()` accepts a `ModuleRunner` (created\n * via `createDirectRunner()`) rather than `server.ssrLoadModule()` so it is\n * safe when `@cloudflare/vite-plugin` is present — that plugin replaces the\n * SSR environment's hot channel, causing `ssrLoadModule()` to crash with\n * `TypeError: Cannot read properties of undefined (reading 'outsideEmitter')`.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getRequestExecutionContext } from \"../shims/request-context.js\";\n/**\n * Minimal duck-typed interface for the module runner passed to\n * `runInstrumentation`. Only `.import()` is used — this avoids requiring\n * callers (including tests) to provide a full `ModuleRunner` instance.\n */\nexport interface ModuleImporter {\n import(id: string): Promise<unknown>;\n}\n\n/** Possible instrumentation file names. */\nconst INSTRUMENTATION_FILES = [\n \"instrumentation.ts\",\n \"instrumentation.tsx\",\n \"instrumentation.js\",\n \"instrumentation.mjs\",\n \"src/instrumentation.ts\",\n \"src/instrumentation.tsx\",\n \"src/instrumentation.js\",\n \"src/instrumentation.mjs\",\n];\n\n/**\n * Find the instrumentation file in the project root.\n */\nexport function findInstrumentationFile(root: string): string | null {\n for (const file of INSTRUMENTATION_FILES) {\n const fullPath = path.join(root, file);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * The onRequestError handler type from Next.js instrumentation.\n *\n * Called when an unhandled error occurs during request handling.\n * Provides the error, the request info, and an error context.\n */\nexport interface OnRequestErrorContext {\n /** The route path (e.g., '/blog/[slug]') */\n routerKind: \"Pages Router\" | \"App Router\";\n /** The matched route pattern */\n routePath: string;\n /** The route type */\n routeType: \"render\" | \"route\" | \"action\" | \"middleware\";\n /** HTTP status code that will be sent */\n revalidateReason?: \"on-demand\" | \"stale\" | undefined;\n}\n\nexport type OnRequestErrorHandler = (\n error: Error,\n request: { path: string; method: string; headers: Record<string, string> },\n context: OnRequestErrorContext,\n) => void | Promise<void>;\n\n/**\n * Get the registered onRequestError handler (if any).\n *\n * Reads from globalThis so it works across Vite environment boundaries.\n */\nexport function getOnRequestErrorHandler(): OnRequestErrorHandler | null {\n return globalThis.__VINEXT_onRequestErrorHandler__ ?? null;\n}\n\n/**\n * Load and execute the instrumentation file via a ModuleRunner.\n *\n * Called once during Pages Router server startup (`configureServer`). It:\n * 1. Loads the instrumentation module via `runner.import()`.\n * 2. Calls the `register()` function if exported.\n * 3. Stores the `onRequestError()` handler on `globalThis` so it is visible\n * to all Vite environment module graphs (SSR and the host process share\n * the same Node.js `globalThis`).\n *\n * **App Router** does not use this function. For App Router, `register()` is\n * emitted as a top-level `await` inside the generated RSC entry module so it\n * runs in the same Worker/environment as request handling.\n *\n * @param runner - A ModuleRunner created via `createDirectRunner()`. Must be\n * the same long-lived runner used for middleware and SSR so the module graph\n * is shared. Safe with all Vite plugin combinations, including\n * `@cloudflare/vite-plugin`, because it never touches the hot channel.\n * @param instrumentationPath - Absolute path to the instrumentation file\n */\nexport async function runInstrumentation(\n runner: ModuleImporter,\n instrumentationPath: string,\n): Promise<void> {\n try {\n const mod = (await runner.import(instrumentationPath)) as Record<string, unknown>;\n\n // Call register() if exported\n if (typeof mod.register === \"function\") {\n await mod.register();\n }\n\n // Store onRequestError handler on globalThis so environments can reach the\n // same handler.\n if (typeof mod.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = mod.onRequestError as OnRequestErrorHandler;\n }\n } catch (err) {\n console.error(\n \"[vinext] Failed to load instrumentation:\",\n err instanceof Error ? err.message : String(err),\n );\n }\n}\n\n/**\n * Report a request error via the instrumentation handler.\n *\n * No-op if no onRequestError handler is registered.\n *\n * Reads the handler from globalThis so this function works correctly regardless\n * of which environment it is called from.\n */\nexport function reportRequestError(\n error: Error,\n request: { path: string; method: string; headers: Record<string, string> },\n context: OnRequestErrorContext,\n): Promise<void> {\n const handler = getOnRequestErrorHandler();\n if (!handler) return Promise.resolve();\n\n const promise = (async () => {\n try {\n await handler(error, request, context);\n } catch (reportErr) {\n console.error(\n \"[vinext] onRequestError handler threw:\",\n reportErr instanceof Error ? reportErr.message : String(reportErr),\n );\n }\n })();\n\n // On Cloudflare Workers, register with ctx.waitUntil() so the isolate\n // stays alive until the report completes (e.g. Sentry HTTP request).\n // On Node.js (dev or vinext start), getRequestExecutionContext() returns\n // null — fire-and-forget is fine because the process doesn't die.\n getRequestExecutionContext()?.waitUntil(promise);\n\n return promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,SAAgB,wBAAwB,MAA6B;AACnE,MAAK,MAAM,QAAQ,uBAAuB;EACxC,MAAM,WAAW,KAAK,KAAK,MAAM,KAAK;AACtC,MAAI,GAAG,WAAW,SAAS,CACzB,QAAO;;AAGX,QAAO;;;;;;;AA+BT,SAAgB,2BAAyD;AACvE,QAAO,WAAW,oCAAoC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,eAAsB,mBACpB,QACA,qBACe;AACf,KAAI;EACF,MAAM,MAAO,MAAM,OAAO,OAAO,oBAAoB;AAGrD,MAAI,OAAO,IAAI,aAAa,WAC1B,OAAM,IAAI,UAAU;AAKtB,MAAI,OAAO,IAAI,mBAAmB,WAChC,YAAW,mCAAmC,IAAI;UAE7C,KAAK;AACZ,UAAQ,MACN,4CACA,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CACjD;;;;;;;;;;;AAYL,SAAgB,mBACd,OACA,SACA,SACe;CACf,MAAM,UAAU,0BAA0B;AAC1C,KAAI,CAAC,QAAS,QAAO,QAAQ,SAAS;CAEtC,MAAM,WAAW,YAAY;AAC3B,MAAI;AACF,SAAM,QAAQ,OAAO,SAAS,QAAQ;WAC/B,WAAW;AAClB,WAAQ,MACN,0CACA,qBAAqB,QAAQ,UAAU,UAAU,OAAO,UAAU,CACnE;;KAED;AAMJ,6BAA4B,EAAE,UAAU,QAAQ;AAEhD,QAAO"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* - Miss: render synchronously, cache, serve
|
|
8
|
-
*
|
|
9
|
-
* Background regeneration is deduped — only one regeneration per cache key
|
|
10
|
-
* runs at a time, preventing thundering herd on popular pages.
|
|
11
|
-
*
|
|
12
|
-
* This layer works with any CacheHandler backend (memory, Redis, KV, etc.)
|
|
13
|
-
* because it only uses the standard get/set interface.
|
|
14
|
-
*/
|
|
15
|
-
import { type CacheHandlerValue, type IncrementalCacheValue, type CachedPagesValue, type CachedAppPageValue } from "../shims/cache.js";
|
|
16
|
-
export interface ISRCacheEntry {
|
|
17
|
-
value: CacheHandlerValue;
|
|
18
|
-
isStale: boolean;
|
|
1
|
+
import { CacheHandlerValue, CachedAppPageValue, CachedPagesValue, IncrementalCacheValue } from "../shims/cache.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/isr-cache.d.ts
|
|
4
|
+
interface ISRCacheEntry {
|
|
5
|
+
value: CacheHandlerValue;
|
|
6
|
+
isStale: boolean;
|
|
19
7
|
}
|
|
20
8
|
/**
|
|
21
9
|
* Get a cache entry with staleness information.
|
|
@@ -24,11 +12,11 @@ export interface ISRCacheEntry {
|
|
|
24
12
|
* { value, isStale: true } for expired-but-usable entries,
|
|
25
13
|
* or null for cache misses.
|
|
26
14
|
*/
|
|
27
|
-
|
|
15
|
+
declare function isrGet(key: string): Promise<ISRCacheEntry | null>;
|
|
28
16
|
/**
|
|
29
17
|
* Store a value in the ISR cache with a revalidation period.
|
|
30
18
|
*/
|
|
31
|
-
|
|
19
|
+
declare function isrSet(key: string, data: IncrementalCacheValue, revalidateSeconds: number, tags?: string[]): Promise<void>;
|
|
32
20
|
/**
|
|
33
21
|
* Trigger a background regeneration for a cache key.
|
|
34
22
|
*
|
|
@@ -39,27 +27,29 @@ export declare function isrSet(key: string, data: IncrementalCacheValue, revalid
|
|
|
39
27
|
* `ctx.waitUntil()` via the ALS-backed ExecutionContext, keeping the isolate
|
|
40
28
|
* alive until the regeneration completes even after the Response is returned.
|
|
41
29
|
*/
|
|
42
|
-
|
|
30
|
+
declare function triggerBackgroundRegeneration(key: string, renderFn: () => Promise<void>): void;
|
|
43
31
|
/**
|
|
44
32
|
* Build a CachedPagesValue for the Pages Router ISR cache.
|
|
45
33
|
*/
|
|
46
|
-
|
|
34
|
+
declare function buildPagesCacheValue(html: string, pageData: object, status?: number): CachedPagesValue;
|
|
47
35
|
/**
|
|
48
36
|
* Build a CachedAppPageValue for the App Router ISR cache.
|
|
49
37
|
*/
|
|
50
|
-
|
|
38
|
+
declare function buildAppPageCacheValue(html: string, rscData?: ArrayBuffer, status?: number): CachedAppPageValue;
|
|
51
39
|
/**
|
|
52
40
|
* Compute an ISR cache key for a given router type and pathname.
|
|
53
41
|
* Long pathnames are hashed to stay within KV key-length limits (512 bytes).
|
|
54
42
|
*/
|
|
55
|
-
|
|
43
|
+
declare function isrCacheKey(router: "pages" | "app", pathname: string, buildId?: string): string;
|
|
56
44
|
/**
|
|
57
45
|
* Store the revalidate duration for a cache key.
|
|
58
46
|
* Uses insertion-order LRU eviction to prevent unbounded growth.
|
|
59
47
|
*/
|
|
60
|
-
|
|
48
|
+
declare function setRevalidateDuration(key: string, seconds: number): void;
|
|
61
49
|
/**
|
|
62
50
|
* Get the revalidate duration for a cache key.
|
|
63
51
|
*/
|
|
64
|
-
|
|
52
|
+
declare function getRevalidateDuration(key: string): number | undefined;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ISRCacheEntry, buildAppPageCacheValue, buildPagesCacheValue, getRevalidateDuration, isrCacheKey, isrGet, isrSet, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
65
55
|
//# sourceMappingURL=isr-cache.d.ts.map
|
package/dist/server/isr-cache.js
CHANGED
|
@@ -1,149 +1,127 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ISR (Incremental Static Regeneration) cache layer.
|
|
3
|
-
*
|
|
4
|
-
* Wraps the pluggable CacheHandler with stale-while-revalidate semantics:
|
|
5
|
-
* - Fresh hit: serve immediately
|
|
6
|
-
* - Stale hit: serve immediately + trigger background regeneration
|
|
7
|
-
* - Miss: render synchronously, cache, serve
|
|
8
|
-
*
|
|
9
|
-
* Background regeneration is deduped — only one regeneration per cache key
|
|
10
|
-
* runs at a time, preventing thundering herd on popular pages.
|
|
11
|
-
*
|
|
12
|
-
* This layer works with any CacheHandler backend (memory, Redis, KV, etc.)
|
|
13
|
-
* because it only uses the standard get/set interface.
|
|
14
|
-
*/
|
|
15
|
-
import { getCacheHandler, } from "../shims/cache.js";
|
|
16
|
-
import { fnv1a64 } from "../utils/hash.js";
|
|
17
1
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
2
|
+
import { fnv1a64 } from "../utils/hash.js";
|
|
3
|
+
import { getCacheHandler } from "../shims/cache.js";
|
|
4
|
+
//#region src/server/isr-cache.ts
|
|
5
|
+
/**
|
|
6
|
+
* ISR (Incremental Static Regeneration) cache layer.
|
|
7
|
+
*
|
|
8
|
+
* Wraps the pluggable CacheHandler with stale-while-revalidate semantics:
|
|
9
|
+
* - Fresh hit: serve immediately
|
|
10
|
+
* - Stale hit: serve immediately + trigger background regeneration
|
|
11
|
+
* - Miss: render synchronously, cache, serve
|
|
12
|
+
*
|
|
13
|
+
* Background regeneration is deduped — only one regeneration per cache key
|
|
14
|
+
* runs at a time, preventing thundering herd on popular pages.
|
|
15
|
+
*
|
|
16
|
+
* This layer works with any CacheHandler backend (memory, Redis, KV, etc.)
|
|
17
|
+
* because it only uses the standard get/set interface.
|
|
18
|
+
*/
|
|
18
19
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
isStale: result.cacheState === "stale",
|
|
33
|
-
};
|
|
20
|
+
* Get a cache entry with staleness information.
|
|
21
|
+
*
|
|
22
|
+
* Returns { value, isStale: false } for fresh entries,
|
|
23
|
+
* { value, isStale: true } for expired-but-usable entries,
|
|
24
|
+
* or null for cache misses.
|
|
25
|
+
*/
|
|
26
|
+
async function isrGet(key) {
|
|
27
|
+
const result = await getCacheHandler().get(key);
|
|
28
|
+
if (!result || !result.value) return null;
|
|
29
|
+
return {
|
|
30
|
+
value: result,
|
|
31
|
+
isStale: result.cacheState === "stale"
|
|
32
|
+
};
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
35
|
+
* Store a value in the ISR cache with a revalidation period.
|
|
36
|
+
*/
|
|
37
|
+
async function isrSet(key, data, revalidateSeconds, tags) {
|
|
38
|
+
await getCacheHandler().set(key, data, {
|
|
39
|
+
revalidate: revalidateSeconds,
|
|
40
|
+
tags: tags ?? []
|
|
41
|
+
});
|
|
44
42
|
}
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
// Background regeneration dedup — one in-flight regeneration per cache key.
|
|
47
|
-
// Uses Symbol.for() on globalThis so the map is shared across Vite's
|
|
48
|
-
// separate RSC and SSR module instances.
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
43
|
const _PENDING_REGEN_KEY = Symbol.for("vinext.isrCache.pendingRegenerations");
|
|
51
44
|
const _g = globalThis;
|
|
52
|
-
const pendingRegenerations =
|
|
45
|
+
const pendingRegenerations = _g[_PENDING_REGEN_KEY] ??= /* @__PURE__ */ new Map();
|
|
53
46
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
pendingRegenerations.set(key, promise);
|
|
74
|
-
// Register with the Workers ExecutionContext (retrieved from ALS) so the
|
|
75
|
-
// runtime keeps the isolate alive until the regeneration completes, even
|
|
76
|
-
// after the Response has already been sent to the client.
|
|
77
|
-
getRequestExecutionContext()?.waitUntil(promise);
|
|
47
|
+
* Trigger a background regeneration for a cache key.
|
|
48
|
+
*
|
|
49
|
+
* If a regeneration for this key is already in progress, this is a no-op.
|
|
50
|
+
* The renderFn should produce the new cache value and call isrSet internally.
|
|
51
|
+
*
|
|
52
|
+
* On Cloudflare Workers the regeneration promise is registered with
|
|
53
|
+
* `ctx.waitUntil()` via the ALS-backed ExecutionContext, keeping the isolate
|
|
54
|
+
* alive until the regeneration completes even after the Response is returned.
|
|
55
|
+
*/
|
|
56
|
+
function triggerBackgroundRegeneration(key, renderFn) {
|
|
57
|
+
if (pendingRegenerations.has(key)) return;
|
|
58
|
+
const promise = renderFn().catch((err) => {
|
|
59
|
+
console.error(`[vinext] ISR background regeneration failed for ${key}:`, err);
|
|
60
|
+
}).finally(() => {
|
|
61
|
+
pendingRegenerations.delete(key);
|
|
62
|
+
});
|
|
63
|
+
pendingRegenerations.set(key, promise);
|
|
64
|
+
getRequestExecutionContext()?.waitUntil(promise);
|
|
78
65
|
}
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// Helpers for building ISR cache values
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
66
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
67
|
+
* Build a CachedPagesValue for the Pages Router ISR cache.
|
|
68
|
+
*/
|
|
69
|
+
function buildPagesCacheValue(html, pageData, status) {
|
|
70
|
+
return {
|
|
71
|
+
kind: "PAGES",
|
|
72
|
+
html,
|
|
73
|
+
pageData,
|
|
74
|
+
headers: void 0,
|
|
75
|
+
status
|
|
76
|
+
};
|
|
93
77
|
}
|
|
94
78
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
* Build a CachedAppPageValue for the App Router ISR cache.
|
|
80
|
+
*/
|
|
81
|
+
function buildAppPageCacheValue(html, rscData, status) {
|
|
82
|
+
return {
|
|
83
|
+
kind: "APP_PAGE",
|
|
84
|
+
html,
|
|
85
|
+
rscData,
|
|
86
|
+
headers: void 0,
|
|
87
|
+
postponed: void 0,
|
|
88
|
+
status
|
|
89
|
+
};
|
|
106
90
|
}
|
|
107
91
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return `${prefix}:__hash:${fnv1a64(normalized)}`;
|
|
92
|
+
* Compute an ISR cache key for a given router type and pathname.
|
|
93
|
+
* Long pathnames are hashed to stay within KV key-length limits (512 bytes).
|
|
94
|
+
*/
|
|
95
|
+
function isrCacheKey(router, pathname, buildId) {
|
|
96
|
+
const normalized = pathname === "/" ? "/" : pathname.replace(/\/$/, "");
|
|
97
|
+
const prefix = buildId ? `${router}:${buildId}` : router;
|
|
98
|
+
const key = `${prefix}:${normalized}`;
|
|
99
|
+
if (key.length <= 200) return key;
|
|
100
|
+
return `${prefix}:__hash:${fnv1a64(normalized)}`;
|
|
118
101
|
}
|
|
119
|
-
|
|
120
|
-
// Revalidate duration tracking — remembers how long each ISR key's TTL is
|
|
121
|
-
// so we can emit correct Cache-Control headers on cache hits.
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
|
-
const MAX_REVALIDATE_ENTRIES = 10_000;
|
|
102
|
+
const MAX_REVALIDATE_ENTRIES = 1e4;
|
|
124
103
|
const _REVALIDATE_KEY = Symbol.for("vinext.isrCache.revalidateDurations");
|
|
125
|
-
const revalidateDurations =
|
|
104
|
+
const revalidateDurations = _g[_REVALIDATE_KEY] ??= /* @__PURE__ */ new Map();
|
|
126
105
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
revalidateDurations.delete(first);
|
|
139
|
-
else
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
106
|
+
* Store the revalidate duration for a cache key.
|
|
107
|
+
* Uses insertion-order LRU eviction to prevent unbounded growth.
|
|
108
|
+
*/
|
|
109
|
+
function setRevalidateDuration(key, seconds) {
|
|
110
|
+
revalidateDurations.delete(key);
|
|
111
|
+
revalidateDurations.set(key, seconds);
|
|
112
|
+
while (revalidateDurations.size > MAX_REVALIDATE_ENTRIES) {
|
|
113
|
+
const first = revalidateDurations.keys().next().value;
|
|
114
|
+
if (first !== void 0) revalidateDurations.delete(first);
|
|
115
|
+
else break;
|
|
116
|
+
}
|
|
142
117
|
}
|
|
143
118
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
119
|
+
* Get the revalidate duration for a cache key.
|
|
120
|
+
*/
|
|
121
|
+
function getRevalidateDuration(key) {
|
|
122
|
+
return revalidateDurations.get(key);
|
|
148
123
|
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { buildAppPageCacheValue, buildPagesCacheValue, getRevalidateDuration, isrCacheKey, isrGet, isrSet, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
126
|
+
|
|
149
127
|
//# sourceMappingURL=isr-cache.js.map
|