vinext 0.0.30 → 0.0.32
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 +15 -7
- 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 +581 -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 +681 -571
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +1 -15
- package/dist/cli.js +432 -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 +376 -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 +444 -212
- 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 +86 -114
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +92 -60
- package/dist/index.js +2151 -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 +160 -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 +19 -15
- package/dist/server/dev-server.js +543 -871
- 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 +34 -59
- package/dist/server/instrumentation.js +112 -125
- 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 +32 -47
- package/dist/server/middleware.js +261 -409
- 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 +715 -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 +6 -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 +439 -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 +17 -20
- package/dist/shims/head.js +194 -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 +7 -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 +213 -164
- package/dist/shims/server.js +545 -478
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +20 -20
- package/dist/shims/unified-request-context.js +81 -99
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/url-safety.d.ts +4 -1
- package/dist/shims/url-safety.js +15 -11
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +8 -5
- package/dist/shims/url-utils.js +62 -93
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/shims/web-vitals.d.ts +10 -8
- package/dist/shims/web-vitals.js +9 -15
- package/dist/shims/web-vitals.js.map +1 -1
- package/dist/utils/base-path.d.ts +5 -2
- package/dist/utils/base-path.js +21 -19
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +17 -9
- package/dist/utils/domain-locale.js +36 -56
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/hash.d.ts +4 -1
- package/dist/utils/hash.js +19 -17
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/manifest-paths.d.ts +6 -3
- package/dist/utils/manifest-paths.js +15 -16
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/project.d.ts +13 -11
- package/dist/utils/project.js +169 -216
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/query.d.ts +8 -6
- package/dist/utils/query.js +57 -67
- package/dist/utils/query.js.map +1 -1
- package/package.json +10 -9
- package/dist/build/report.d.ts.map +0 -1
- package/dist/build/static-export.d.ts.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/entry.d.ts.map +0 -1
- package/dist/client/validate-module-path.d.ts.map +0 -1
- package/dist/client/vinext-next-data.d.ts.map +0 -1
- package/dist/client/vinext-next-data.js.map +0 -1
- package/dist/cloudflare/index.d.ts.map +0 -1
- package/dist/cloudflare/index.js.map +0 -1
- package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
- package/dist/cloudflare/tpr.d.ts.map +0 -1
- package/dist/config/config-matchers.d.ts.map +0 -1
- package/dist/config/dotenv.d.ts.map +0 -1
- package/dist/config/next-config.d.ts.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/entries/app-browser-entry.d.ts.map +0 -1
- package/dist/entries/app-rsc-entry.d.ts.map +0 -1
- package/dist/entries/app-ssr-entry.d.ts.map +0 -1
- package/dist/entries/pages-client-entry.d.ts.map +0 -1
- package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
- package/dist/entries/pages-server-entry.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init.d.ts.map +0 -1
- package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
- package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
- package/dist/routing/app-router.d.ts.map +0 -1
- package/dist/routing/file-matcher.d.ts.map +0 -1
- package/dist/routing/pages-router.d.ts.map +0 -1
- package/dist/routing/route-trie.d.ts.map +0 -1
- package/dist/routing/route-validation.d.ts.map +0 -1
- package/dist/routing/utils.d.ts.map +0 -1
- package/dist/server/api-handler.d.ts.map +0 -1
- package/dist/server/app-router-entry.d.ts.map +0 -1
- package/dist/server/dev-module-runner.d.ts.map +0 -1
- package/dist/server/dev-origin-check.d.ts.map +0 -1
- package/dist/server/dev-server.d.ts.map +0 -1
- package/dist/server/html.d.ts.map +0 -1
- package/dist/server/image-optimization.d.ts.map +0 -1
- package/dist/server/instrumentation.d.ts.map +0 -1
- package/dist/server/isr-cache.d.ts.map +0 -1
- package/dist/server/metadata-routes.d.ts.map +0 -1
- package/dist/server/middleware-codegen.d.ts.map +0 -1
- package/dist/server/middleware-request-headers.d.ts.map +0 -1
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/normalize-path.d.ts.map +0 -1
- package/dist/server/pages-i18n.d.ts.map +0 -1
- package/dist/server/prod-server.d.ts.map +0 -1
- package/dist/server/request-log.d.ts.map +0 -1
- package/dist/server/request-pipeline.d.ts.map +0 -1
- package/dist/server/worker-utils.d.ts.map +0 -1
- package/dist/shims/amp.d.ts.map +0 -1
- package/dist/shims/app.d.ts.map +0 -1
- package/dist/shims/app.js.map +0 -1
- package/dist/shims/cache-runtime.d.ts.map +0 -1
- package/dist/shims/cache.d.ts.map +0 -1
- package/dist/shims/client-only.d.ts.map +0 -1
- package/dist/shims/client-only.js.map +0 -1
- package/dist/shims/compat-router.d.ts.map +0 -1
- package/dist/shims/config.d.ts.map +0 -1
- package/dist/shims/constants.d.ts.map +0 -1
- package/dist/shims/document.d.ts.map +0 -1
- package/dist/shims/dynamic.d.ts.map +0 -1
- package/dist/shims/error-boundary.d.ts.map +0 -1
- package/dist/shims/error.d.ts.map +0 -1
- package/dist/shims/fetch-cache.d.ts.map +0 -1
- package/dist/shims/font-google-base.d.ts.map +0 -1
- package/dist/shims/font-google.d.ts.map +0 -1
- package/dist/shims/font-google.generated.d.ts.map +0 -1
- package/dist/shims/font-google.js.map +0 -1
- package/dist/shims/font-local.d.ts.map +0 -1
- package/dist/shims/form.d.ts.map +0 -1
- package/dist/shims/head-state.d.ts.map +0 -1
- package/dist/shims/head.d.ts.map +0 -1
- package/dist/shims/headers.d.ts.map +0 -1
- package/dist/shims/i18n-context.d.ts.map +0 -1
- package/dist/shims/i18n-state.d.ts.map +0 -1
- package/dist/shims/image-config.d.ts.map +0 -1
- package/dist/shims/image.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.js.map +0 -1
- package/dist/shims/internal/app-router-context.d.ts.map +0 -1
- package/dist/shims/internal/cookies.d.ts.map +0 -1
- package/dist/shims/internal/cookies.js.map +0 -1
- package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
- package/dist/shims/internal/router-context.d.ts.map +0 -1
- package/dist/shims/internal/utils.d.ts.map +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
- package/dist/shims/layout-segment-context.d.ts.map +0 -1
- package/dist/shims/legacy-image.d.ts.map +0 -1
- package/dist/shims/link.d.ts.map +0 -1
- package/dist/shims/metadata.d.ts.map +0 -1
- package/dist/shims/navigation-state.d.ts.map +0 -1
- package/dist/shims/navigation.d.ts.map +0 -1
- package/dist/shims/og.d.ts.map +0 -1
- package/dist/shims/og.js.map +0 -1
- package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
- package/dist/shims/request-context.d.ts.map +0 -1
- package/dist/shims/request-state-types.d.ts.map +0 -1
- package/dist/shims/request-state-types.js.map +0 -1
- package/dist/shims/router-state.d.ts.map +0 -1
- package/dist/shims/router.d.ts.map +0 -1
- package/dist/shims/script.d.ts.map +0 -1
- package/dist/shims/server-only.d.ts.map +0 -1
- package/dist/shims/server-only.js.map +0 -1
- package/dist/shims/server.d.ts.map +0 -1
- package/dist/shims/unified-request-context.d.ts.map +0 -1
- package/dist/shims/url-safety.d.ts.map +0 -1
- package/dist/shims/url-utils.d.ts.map +0 -1
- package/dist/shims/web-vitals.d.ts.map +0 -1
- package/dist/utils/base-path.d.ts.map +0 -1
- package/dist/utils/domain-locale.d.ts.map +0 -1
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/manifest-paths.d.ts.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/query.d.ts.map +0 -1
package/dist/build/report.js
CHANGED
|
@@ -1,303 +1,608 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build report — prints a Next.js-style route table after `vinext build`.
|
|
3
|
-
*
|
|
4
|
-
* Classifies every discovered route as:
|
|
5
|
-
* ○ Static — confirmed static: force-static or revalidate=Infinity
|
|
6
|
-
* ◐ ISR — statically rendered, revalidated on a timer (revalidate=N)
|
|
7
|
-
* ƒ Dynamic — confirmed dynamic: force-dynamic, revalidate=0, or getServerSideProps
|
|
8
|
-
* ? Unknown — no explicit config; likely dynamic but not confirmed
|
|
9
|
-
* λ API — API route handler
|
|
10
|
-
*
|
|
11
|
-
* Classification uses regex-based static source analysis (no module
|
|
12
|
-
* execution). Vite's parseAst() is NOT used because it doesn't handle
|
|
13
|
-
* TypeScript syntax.
|
|
14
|
-
*
|
|
15
|
-
* Limitation: without running the build, we cannot detect dynamic API usage
|
|
16
|
-
* (headers(), cookies(), connection(), etc.) that implicitly forces a route
|
|
17
|
-
* dynamic. Routes without explicit `export const dynamic` or
|
|
18
|
-
* `export const revalidate` are classified as "unknown" rather than "static"
|
|
19
|
-
* to avoid false confidence.
|
|
20
|
-
*/
|
|
21
1
|
import fs from "node:fs";
|
|
22
2
|
import path from "node:path";
|
|
23
|
-
|
|
3
|
+
//#region src/build/report.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build report — prints a Next.js-style route table after `vinext build`.
|
|
6
|
+
*
|
|
7
|
+
* Classifies every discovered route as:
|
|
8
|
+
* ○ Static — confirmed static: force-static or revalidate=Infinity
|
|
9
|
+
* ◐ ISR — statically rendered, revalidated on a timer (revalidate=N)
|
|
10
|
+
* ƒ Dynamic — confirmed dynamic: force-dynamic, revalidate=0, or getServerSideProps
|
|
11
|
+
* ? Unknown — no explicit config; likely dynamic but not confirmed
|
|
12
|
+
* λ API — API route handler
|
|
13
|
+
*
|
|
14
|
+
* Classification uses regex-based static source analysis (no module
|
|
15
|
+
* execution). Vite's parseAst() is NOT used because it doesn't handle
|
|
16
|
+
* TypeScript syntax.
|
|
17
|
+
*
|
|
18
|
+
* Limitation: without running the build, we cannot detect dynamic API usage
|
|
19
|
+
* (headers(), cookies(), connection(), etc.) that implicitly forces a route
|
|
20
|
+
* dynamic. Routes without explicit `export const dynamic` or
|
|
21
|
+
* `export const revalidate` are classified as "unknown" rather than "static"
|
|
22
|
+
* to avoid false confidence.
|
|
23
|
+
*/
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Variable declaration (const / let / var)
|
|
37
|
-
const varRe = new RegExp(`(?:^|\\n)\\s*export\\s+(?:const|let|var)\\s+${name}\\s*[=:]`);
|
|
38
|
-
if (varRe.test(code))
|
|
39
|
-
return true;
|
|
40
|
-
// Re-export specifier: export { foo } or export { foo as bar }
|
|
41
|
-
const reRe = new RegExp(`export\\s*\\{[^}]*\\b${name}\\b[^}]*\\}`);
|
|
42
|
-
if (reRe.test(code))
|
|
43
|
-
return true;
|
|
44
|
-
return false;
|
|
25
|
+
* Returns true if the source code contains a named export with the given name.
|
|
26
|
+
* Handles all three common export forms:
|
|
27
|
+
* export function foo() {}
|
|
28
|
+
* export const foo = ...
|
|
29
|
+
* export { foo }
|
|
30
|
+
*/
|
|
31
|
+
function hasNamedExport(code, name) {
|
|
32
|
+
if (new RegExp(`(?:^|\\n)\\s*export\\s+(?:async\\s+)?function\\s+${name}\\b`).test(code)) return true;
|
|
33
|
+
if (new RegExp(`(?:^|\\n)\\s*export\\s+(?:const|let|var)\\s+${name}\\s*[=:]`).test(code)) return true;
|
|
34
|
+
if (new RegExp(`export\\s*\\{[^}]*\\b${name}\\b[^}]*\\}`).test(code)) return true;
|
|
35
|
+
return false;
|
|
45
36
|
}
|
|
46
37
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return m ? m[1] : null;
|
|
38
|
+
* Extracts the string value of `export const <name> = "value"`.
|
|
39
|
+
* Handles optional TypeScript type annotations:
|
|
40
|
+
* export const dynamic: string = "force-dynamic"
|
|
41
|
+
* Returns null if the export is absent or not a string literal.
|
|
42
|
+
*/
|
|
43
|
+
function extractExportConstString(code, name) {
|
|
44
|
+
const m = new RegExp(`^\\s*export\\s+const\\s+${name}\\s*(?::[^=]+)?\\s*=\\s*['"]([^'"]+)['"]`, "m").exec(code);
|
|
45
|
+
return m ? m[1] : null;
|
|
56
46
|
}
|
|
57
47
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return null;
|
|
68
|
-
return m[1] === "Infinity" ? Infinity : parseFloat(m[1]);
|
|
48
|
+
* Extracts the numeric value of `export const <name> = <number>`.
|
|
49
|
+
* Supports integers, decimals, negative values, and `Infinity`.
|
|
50
|
+
* Handles optional TypeScript type annotations.
|
|
51
|
+
* Returns null if the export is absent or not a number.
|
|
52
|
+
*/
|
|
53
|
+
function extractExportConstNumber(code, name) {
|
|
54
|
+
const m = new RegExp(`^\\s*export\\s+const\\s+${name}\\s*(?::[^=]+)?\\s*=\\s*(-?\\d+(?:\\.\\d+)?|Infinity)`, "m").exec(code);
|
|
55
|
+
if (!m) return null;
|
|
56
|
+
return m[1] === "Infinity" ? Infinity : parseFloat(m[1]);
|
|
69
57
|
}
|
|
70
58
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
59
|
+
* Extracts the `revalidate` value from inside a `getStaticProps` return object.
|
|
60
|
+
* Looks for: revalidate: <number> or revalidate: false or revalidate: Infinity
|
|
61
|
+
*
|
|
62
|
+
* Returns:
|
|
63
|
+
* number — a positive revalidation interval (enables ISR)
|
|
64
|
+
* 0 — treat as SSR (revalidate every request)
|
|
65
|
+
* false — fully static (no revalidation)
|
|
66
|
+
* Infinity — fully static (treated same as false by Next.js)
|
|
67
|
+
* null — no `revalidate` key found (fully static)
|
|
68
|
+
*/
|
|
69
|
+
function extractGetStaticPropsRevalidate(code) {
|
|
70
|
+
const returnObjects = extractGetStaticPropsReturnObjects(code);
|
|
71
|
+
if (returnObjects) {
|
|
72
|
+
for (const searchSpace of returnObjects) {
|
|
73
|
+
const revalidate = extractTopLevelRevalidateValue(searchSpace);
|
|
74
|
+
if (revalidate !== null) return revalidate;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const m = /\brevalidate\s*:\s*(-?\d+(?:\.\d+)?|Infinity|false)\b/.exec(code);
|
|
79
|
+
if (!m) return null;
|
|
80
|
+
if (m[1] === "false") return false;
|
|
81
|
+
if (m[1] === "Infinity") return Infinity;
|
|
82
|
+
return parseFloat(m[1]);
|
|
83
|
+
}
|
|
84
|
+
function extractTopLevelRevalidateValue(code) {
|
|
85
|
+
let braceDepth = 0;
|
|
86
|
+
let parenDepth = 0;
|
|
87
|
+
let bracketDepth = 0;
|
|
88
|
+
let quote = null;
|
|
89
|
+
let inLineComment = false;
|
|
90
|
+
let inBlockComment = false;
|
|
91
|
+
for (let i = 0; i < code.length; i++) {
|
|
92
|
+
const char = code[i];
|
|
93
|
+
const next = code[i + 1];
|
|
94
|
+
if (inLineComment) {
|
|
95
|
+
if (char === "\n") inLineComment = false;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (inBlockComment) {
|
|
99
|
+
if (char === "*" && next === "/") {
|
|
100
|
+
inBlockComment = false;
|
|
101
|
+
i++;
|
|
102
|
+
}
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (quote) {
|
|
106
|
+
if (char === "\\") {
|
|
107
|
+
i++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (char === quote) quote = null;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (char === "/" && next === "/") {
|
|
114
|
+
inLineComment = true;
|
|
115
|
+
i++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (char === "/" && next === "*") {
|
|
119
|
+
inBlockComment = true;
|
|
120
|
+
i++;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
124
|
+
quote = char;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (char === "{") {
|
|
128
|
+
braceDepth++;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (char === "}") {
|
|
132
|
+
braceDepth--;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (char === "(") {
|
|
136
|
+
parenDepth++;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (char === ")") {
|
|
140
|
+
parenDepth--;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (char === "[") {
|
|
144
|
+
bracketDepth++;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (char === "]") {
|
|
148
|
+
bracketDepth--;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (braceDepth === 1 && parenDepth === 0 && bracketDepth === 0 && matchesKeywordAt(code, i, "revalidate")) {
|
|
152
|
+
const colonIndex = findNextNonWhitespaceIndex(code, i + 10);
|
|
153
|
+
if (colonIndex === -1 || code[colonIndex] !== ":") continue;
|
|
154
|
+
const valueStart = findNextNonWhitespaceIndex(code, colonIndex + 1);
|
|
155
|
+
if (valueStart === -1) return null;
|
|
156
|
+
const valueMatch = /^(-?\d+(?:\.\d+)?|Infinity|false)\b/.exec(code.slice(valueStart));
|
|
157
|
+
if (!valueMatch) return null;
|
|
158
|
+
if (valueMatch[1] === "false") return false;
|
|
159
|
+
if (valueMatch[1] === "Infinity") return Infinity;
|
|
160
|
+
return parseFloat(valueMatch[1]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
function extractGetStaticPropsReturnObjects(code) {
|
|
166
|
+
const declarationMatch = /(?:^|\n)\s*(?:export\s+)?(?:async\s+)?function\s+getStaticProps\b|(?:^|\n)\s*(?:export\s+)?(?:const|let|var)\s+getStaticProps\b/.exec(code);
|
|
167
|
+
if (!declarationMatch) {
|
|
168
|
+
if (/(?:^|\n)\s*export\s*\{[^}]*\bgetStaticProps\b[^}]*\}\s*from\b/.test(code)) return [];
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
const declaration = extractGetStaticPropsDeclaration(code, declarationMatch);
|
|
172
|
+
if (declaration === null) return [];
|
|
173
|
+
const returnObjects = declaration.trimStart().startsWith("{") ? collectReturnObjectsFromFunctionBody(declaration) : [];
|
|
174
|
+
if (returnObjects.length > 0) return returnObjects;
|
|
175
|
+
const arrowMatch = declaration.search(/=>\s*\(\s*\{/);
|
|
176
|
+
if (arrowMatch === -1) return [];
|
|
177
|
+
const braceStart = declaration.indexOf("{", arrowMatch);
|
|
178
|
+
if (braceStart === -1) return [];
|
|
179
|
+
const braceEnd = findMatchingBrace(declaration, braceStart);
|
|
180
|
+
if (braceEnd === -1) return [];
|
|
181
|
+
return [declaration.slice(braceStart, braceEnd + 1)];
|
|
182
|
+
}
|
|
183
|
+
function extractGetStaticPropsDeclaration(code, declarationMatch) {
|
|
184
|
+
const declarationStart = declarationMatch.index;
|
|
185
|
+
const declarationText = declarationMatch[0];
|
|
186
|
+
const declarationTail = code.slice(declarationStart);
|
|
187
|
+
if (declarationText.includes("function getStaticProps")) return extractFunctionBody(code, declarationStart + declarationText.length);
|
|
188
|
+
const functionExpressionMatch = /(?:async\s+)?function\b/.exec(declarationTail);
|
|
189
|
+
if (functionExpressionMatch) return extractFunctionBody(declarationTail, functionExpressionMatch.index);
|
|
190
|
+
const blockBodyMatch = /=>\s*\{/.exec(declarationTail);
|
|
191
|
+
if (blockBodyMatch) {
|
|
192
|
+
const braceStart = declarationTail.indexOf("{", blockBodyMatch.index);
|
|
193
|
+
if (braceStart === -1) return null;
|
|
194
|
+
const braceEnd = findMatchingBrace(declarationTail, braceStart);
|
|
195
|
+
if (braceEnd === -1) return null;
|
|
196
|
+
return declarationTail.slice(braceStart, braceEnd + 1);
|
|
197
|
+
}
|
|
198
|
+
const implicitArrowMatch = declarationTail.search(/=>\s*\(\s*\{/);
|
|
199
|
+
if (implicitArrowMatch === -1) return null;
|
|
200
|
+
const implicitBraceStart = declarationTail.indexOf("{", implicitArrowMatch);
|
|
201
|
+
if (implicitBraceStart === -1) return null;
|
|
202
|
+
const implicitBraceEnd = findMatchingBrace(declarationTail, implicitBraceStart);
|
|
203
|
+
if (implicitBraceEnd === -1) return null;
|
|
204
|
+
return declarationTail.slice(0, implicitBraceEnd + 1);
|
|
205
|
+
}
|
|
206
|
+
function extractFunctionBody(code, functionStart) {
|
|
207
|
+
const bodyEnd = findFunctionBodyEnd(code, functionStart);
|
|
208
|
+
if (bodyEnd === -1) return null;
|
|
209
|
+
const paramsStart = code.indexOf("(", functionStart);
|
|
210
|
+
if (paramsStart === -1) return null;
|
|
211
|
+
const paramsEnd = findMatchingParen(code, paramsStart);
|
|
212
|
+
if (paramsEnd === -1) return null;
|
|
213
|
+
const bodyStart = code.indexOf("{", paramsEnd + 1);
|
|
214
|
+
if (bodyStart === -1) return null;
|
|
215
|
+
return code.slice(bodyStart, bodyEnd + 1);
|
|
216
|
+
}
|
|
217
|
+
function collectReturnObjectsFromFunctionBody(code) {
|
|
218
|
+
const returnObjects = [];
|
|
219
|
+
let quote = null;
|
|
220
|
+
let inLineComment = false;
|
|
221
|
+
let inBlockComment = false;
|
|
222
|
+
for (let i = 0; i < code.length; i++) {
|
|
223
|
+
const char = code[i];
|
|
224
|
+
const next = code[i + 1];
|
|
225
|
+
if (inLineComment) {
|
|
226
|
+
if (char === "\n") inLineComment = false;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (inBlockComment) {
|
|
230
|
+
if (char === "*" && next === "/") {
|
|
231
|
+
inBlockComment = false;
|
|
232
|
+
i++;
|
|
233
|
+
}
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (quote) {
|
|
237
|
+
if (char === "\\") {
|
|
238
|
+
i++;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (char === quote) quote = null;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (char === "/" && next === "/") {
|
|
245
|
+
inLineComment = true;
|
|
246
|
+
i++;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (char === "/" && next === "*") {
|
|
250
|
+
inBlockComment = true;
|
|
251
|
+
i++;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
255
|
+
quote = char;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (matchesKeywordAt(code, i, "function")) {
|
|
259
|
+
const nestedBodyEnd = findFunctionBodyEnd(code, i);
|
|
260
|
+
if (nestedBodyEnd !== -1) i = nestedBodyEnd;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (matchesKeywordAt(code, i, "class")) {
|
|
264
|
+
const classBodyEnd = findClassBodyEnd(code, i);
|
|
265
|
+
if (classBodyEnd !== -1) i = classBodyEnd;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (char === "=" && next === ">") {
|
|
269
|
+
const nestedBodyEnd = findArrowFunctionBodyEnd(code, i);
|
|
270
|
+
if (nestedBodyEnd !== -1) i = nestedBodyEnd;
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (char >= "A" && char <= "Z" || char >= "a" && char <= "z" || char === "_" || char === "$" || char === "*") {
|
|
274
|
+
const methodBodyEnd = findObjectMethodBodyEnd(code, i);
|
|
275
|
+
if (methodBodyEnd !== -1) {
|
|
276
|
+
i = methodBodyEnd;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (matchesKeywordAt(code, i, "return")) {
|
|
281
|
+
const braceStart = findNextNonWhitespaceIndex(code, i + 6);
|
|
282
|
+
if (braceStart === -1 || code[braceStart] !== "{") continue;
|
|
283
|
+
const braceEnd = findMatchingBrace(code, braceStart);
|
|
284
|
+
if (braceEnd === -1) continue;
|
|
285
|
+
returnObjects.push(code.slice(braceStart, braceEnd + 1));
|
|
286
|
+
i = braceEnd;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return returnObjects;
|
|
290
|
+
}
|
|
291
|
+
function findFunctionBodyEnd(code, functionStart) {
|
|
292
|
+
const paramsStart = code.indexOf("(", functionStart);
|
|
293
|
+
if (paramsStart === -1) return -1;
|
|
294
|
+
const paramsEnd = findMatchingParen(code, paramsStart);
|
|
295
|
+
if (paramsEnd === -1) return -1;
|
|
296
|
+
const bodyStart = code.indexOf("{", paramsEnd + 1);
|
|
297
|
+
if (bodyStart === -1) return -1;
|
|
298
|
+
return findMatchingBrace(code, bodyStart);
|
|
299
|
+
}
|
|
300
|
+
function findClassBodyEnd(code, classStart) {
|
|
301
|
+
const bodyStart = code.indexOf("{", classStart + 5);
|
|
302
|
+
if (bodyStart === -1) return -1;
|
|
303
|
+
return findMatchingBrace(code, bodyStart);
|
|
304
|
+
}
|
|
305
|
+
function findArrowFunctionBodyEnd(code, arrowIndex) {
|
|
306
|
+
const bodyStart = findNextNonWhitespaceIndex(code, arrowIndex + 2);
|
|
307
|
+
if (bodyStart === -1 || code[bodyStart] !== "{") return -1;
|
|
308
|
+
return findMatchingBrace(code, bodyStart);
|
|
309
|
+
}
|
|
310
|
+
function findObjectMethodBodyEnd(code, start) {
|
|
311
|
+
let i = start;
|
|
312
|
+
if (matchesKeywordAt(code, i, "async")) {
|
|
313
|
+
const afterAsync = findNextNonWhitespaceIndex(code, i + 5);
|
|
314
|
+
if (afterAsync === -1) return -1;
|
|
315
|
+
if (code[afterAsync] !== "(") i = afterAsync;
|
|
316
|
+
}
|
|
317
|
+
if (code[i] === "*") {
|
|
318
|
+
i = findNextNonWhitespaceIndex(code, i + 1);
|
|
319
|
+
if (i === -1) return -1;
|
|
320
|
+
}
|
|
321
|
+
if (!/[A-Za-z_$]/.test(code[i] ?? "")) return -1;
|
|
322
|
+
const nameStart = i;
|
|
323
|
+
while (/[A-Za-z0-9_$]/.test(code[i] ?? "")) i++;
|
|
324
|
+
const name = code.slice(nameStart, i);
|
|
325
|
+
if (name === "if" || name === "for" || name === "while" || name === "switch" || name === "catch" || name === "function" || name === "return" || name === "const" || name === "let" || name === "var" || name === "new") return -1;
|
|
326
|
+
if (name === "get" || name === "set") {
|
|
327
|
+
const afterAccessor = findNextNonWhitespaceIndex(code, i);
|
|
328
|
+
if (afterAccessor === -1) return -1;
|
|
329
|
+
if (code[afterAccessor] !== "(") {
|
|
330
|
+
i = afterAccessor;
|
|
331
|
+
if (!/[A-Za-z_$]/.test(code[i] ?? "")) return -1;
|
|
332
|
+
while (/[A-Za-z0-9_$]/.test(code[i] ?? "")) i++;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const paramsStart = findNextNonWhitespaceIndex(code, i);
|
|
336
|
+
if (paramsStart === -1 || code[paramsStart] !== "(") return -1;
|
|
337
|
+
const paramsEnd = findMatchingParen(code, paramsStart);
|
|
338
|
+
if (paramsEnd === -1) return -1;
|
|
339
|
+
const bodyStart = findNextNonWhitespaceIndex(code, paramsEnd + 1);
|
|
340
|
+
if (bodyStart === -1 || code[bodyStart] !== "{") return -1;
|
|
341
|
+
return findMatchingBrace(code, bodyStart);
|
|
342
|
+
}
|
|
343
|
+
function findNextNonWhitespaceIndex(code, start) {
|
|
344
|
+
for (let i = start; i < code.length; i++) if (!/\s/.test(code[i])) return i;
|
|
345
|
+
return -1;
|
|
346
|
+
}
|
|
347
|
+
function matchesKeywordAt(code, index, keyword) {
|
|
348
|
+
const before = index === 0 ? "" : code[index - 1];
|
|
349
|
+
const after = code[index + keyword.length] ?? "";
|
|
350
|
+
return code.startsWith(keyword, index) && (before === "" || !/[A-Za-z0-9_$]/.test(before)) && (after === "" || !/[A-Za-z0-9_$]/.test(after));
|
|
351
|
+
}
|
|
352
|
+
function findMatchingBrace(code, start) {
|
|
353
|
+
return findMatchingToken(code, start, "{", "}");
|
|
354
|
+
}
|
|
355
|
+
function findMatchingParen(code, start) {
|
|
356
|
+
return findMatchingToken(code, start, "(", ")");
|
|
357
|
+
}
|
|
358
|
+
function findMatchingToken(code, start, openToken, closeToken) {
|
|
359
|
+
let depth = 0;
|
|
360
|
+
let quote = null;
|
|
361
|
+
let inLineComment = false;
|
|
362
|
+
let inBlockComment = false;
|
|
363
|
+
for (let i = start; i < code.length; i++) {
|
|
364
|
+
const char = code[i];
|
|
365
|
+
const next = code[i + 1];
|
|
366
|
+
if (inLineComment) {
|
|
367
|
+
if (char === "\n") inLineComment = false;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (inBlockComment) {
|
|
371
|
+
if (char === "*" && next === "/") {
|
|
372
|
+
inBlockComment = false;
|
|
373
|
+
i++;
|
|
374
|
+
}
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (quote) {
|
|
378
|
+
if (char === "\\") {
|
|
379
|
+
i++;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (char === quote) quote = null;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (char === "/" && next === "/") {
|
|
386
|
+
inLineComment = true;
|
|
387
|
+
i++;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (char === "/" && next === "*") {
|
|
391
|
+
inBlockComment = true;
|
|
392
|
+
i++;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
396
|
+
quote = char;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (char === openToken) {
|
|
400
|
+
depth++;
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
if (char === closeToken) {
|
|
404
|
+
depth--;
|
|
405
|
+
if (depth === 0) return i;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return -1;
|
|
96
409
|
}
|
|
97
|
-
// ─── Route classification ─────────────────────────────────────────────────────
|
|
98
410
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return { type: "static" };
|
|
124
|
-
}
|
|
125
|
-
if (revalidate === 0) {
|
|
126
|
-
return { type: "ssr" };
|
|
127
|
-
}
|
|
128
|
-
// Positive number → ISR
|
|
129
|
-
return { type: "isr", revalidate };
|
|
130
|
-
}
|
|
131
|
-
return { type: "static" };
|
|
411
|
+
* Classifies a Pages Router page file by reading its source and examining
|
|
412
|
+
* which data-fetching exports it contains.
|
|
413
|
+
*
|
|
414
|
+
* API routes (files under pages/api/) are always `api`.
|
|
415
|
+
*/
|
|
416
|
+
function classifyPagesRoute(filePath) {
|
|
417
|
+
if (filePath.replace(/\\/g, "/").includes("/pages/api/")) return { type: "api" };
|
|
418
|
+
let code;
|
|
419
|
+
try {
|
|
420
|
+
code = fs.readFileSync(filePath, "utf8");
|
|
421
|
+
} catch {
|
|
422
|
+
return { type: "unknown" };
|
|
423
|
+
}
|
|
424
|
+
if (hasNamedExport(code, "getServerSideProps")) return { type: "ssr" };
|
|
425
|
+
if (hasNamedExport(code, "getStaticProps")) {
|
|
426
|
+
const revalidate = extractGetStaticPropsRevalidate(code);
|
|
427
|
+
if (revalidate === null || revalidate === false || revalidate === Infinity) return { type: "static" };
|
|
428
|
+
if (revalidate === 0) return { type: "ssr" };
|
|
429
|
+
return {
|
|
430
|
+
type: "isr",
|
|
431
|
+
revalidate
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
return { type: "static" };
|
|
132
435
|
}
|
|
133
436
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
// Check `export const revalidate`
|
|
166
|
-
const revalidateValue = extractExportConstNumber(code, "revalidate");
|
|
167
|
-
if (revalidateValue !== null) {
|
|
168
|
-
if (revalidateValue === Infinity)
|
|
169
|
-
return { type: "static" };
|
|
170
|
-
if (revalidateValue === 0)
|
|
171
|
-
return { type: "ssr" };
|
|
172
|
-
if (revalidateValue > 0)
|
|
173
|
-
return { type: "isr", revalidate: revalidateValue };
|
|
174
|
-
}
|
|
175
|
-
// Fall back to isDynamic flag (dynamic URL segments without explicit config)
|
|
176
|
-
if (isDynamic)
|
|
177
|
-
return { type: "ssr" };
|
|
178
|
-
// No explicit config and no dynamic URL segments — we can't confirm static
|
|
179
|
-
// without running the build (dynamic API calls like headers() are invisible
|
|
180
|
-
// to static analysis). Report as unknown rather than falsely claiming static.
|
|
181
|
-
return { type: "unknown" };
|
|
437
|
+
* Classifies an App Router route.
|
|
438
|
+
*
|
|
439
|
+
* @param pagePath Absolute path to the page.tsx (null for API-only routes)
|
|
440
|
+
* @param routePath Absolute path to the route.ts handler (null for page routes)
|
|
441
|
+
* @param isDynamic Whether the URL pattern contains dynamic segments
|
|
442
|
+
*/
|
|
443
|
+
function classifyAppRoute(pagePath, routePath, isDynamic) {
|
|
444
|
+
if (routePath !== null && pagePath === null) return { type: "api" };
|
|
445
|
+
const filePath = pagePath ?? routePath;
|
|
446
|
+
if (!filePath) return { type: "unknown" };
|
|
447
|
+
let code;
|
|
448
|
+
try {
|
|
449
|
+
code = fs.readFileSync(filePath, "utf8");
|
|
450
|
+
} catch {
|
|
451
|
+
return { type: "unknown" };
|
|
452
|
+
}
|
|
453
|
+
const dynamicValue = extractExportConstString(code, "dynamic");
|
|
454
|
+
if (dynamicValue === "force-dynamic") return { type: "ssr" };
|
|
455
|
+
if (dynamicValue === "force-static" || dynamicValue === "error") return { type: "static" };
|
|
456
|
+
const revalidateValue = extractExportConstNumber(code, "revalidate");
|
|
457
|
+
if (revalidateValue !== null) {
|
|
458
|
+
if (revalidateValue === Infinity) return { type: "static" };
|
|
459
|
+
if (revalidateValue === 0) return { type: "ssr" };
|
|
460
|
+
if (revalidateValue > 0) return {
|
|
461
|
+
type: "isr",
|
|
462
|
+
revalidate: revalidateValue
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
if (isDynamic) return { type: "ssr" };
|
|
466
|
+
return { type: "unknown" };
|
|
182
467
|
}
|
|
183
|
-
// ─── Row building ─────────────────────────────────────────────────────────────
|
|
184
468
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
469
|
+
* Builds a sorted list of RouteRow objects from the discovered routes.
|
|
470
|
+
* Routes are sorted alphabetically by path, matching filesystem order.
|
|
471
|
+
*
|
|
472
|
+
* When `prerenderResult` is provided, routes that were classified as `unknown`
|
|
473
|
+
* by static analysis but were successfully rendered speculatively are upgraded
|
|
474
|
+
* to `static` (confirmed by execution). The `prerendered` flag is set on those
|
|
475
|
+
* rows so the formatter can add a legend note.
|
|
476
|
+
*/
|
|
477
|
+
function buildReportRows(options) {
|
|
478
|
+
const rows = [];
|
|
479
|
+
const renderedRoutes = /* @__PURE__ */ new Set();
|
|
480
|
+
if (options.prerenderResult) {
|
|
481
|
+
for (const r of options.prerenderResult.routes) if (r.status === "rendered") renderedRoutes.add(r.route);
|
|
482
|
+
}
|
|
483
|
+
for (const route of options.pageRoutes ?? []) {
|
|
484
|
+
const { type, revalidate } = classifyPagesRoute(route.filePath);
|
|
485
|
+
rows.push({
|
|
486
|
+
pattern: route.pattern,
|
|
487
|
+
type,
|
|
488
|
+
revalidate
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
for (const route of options.apiRoutes ?? []) rows.push({
|
|
492
|
+
pattern: route.pattern,
|
|
493
|
+
type: "api"
|
|
494
|
+
});
|
|
495
|
+
for (const route of options.appRoutes ?? []) {
|
|
496
|
+
const { type, revalidate } = classifyAppRoute(route.pagePath, route.routePath, route.isDynamic);
|
|
497
|
+
if (type === "unknown" && renderedRoutes.has(route.pattern)) rows.push({
|
|
498
|
+
pattern: route.pattern,
|
|
499
|
+
type: "static",
|
|
500
|
+
prerendered: true
|
|
501
|
+
});
|
|
502
|
+
else rows.push({
|
|
503
|
+
pattern: route.pattern,
|
|
504
|
+
type,
|
|
505
|
+
revalidate
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
rows.sort((a, b) => a.pattern.localeCompare(b.pattern));
|
|
509
|
+
return rows;
|
|
204
510
|
}
|
|
205
|
-
// ─── Formatting ───────────────────────────────────────────────────────────────
|
|
206
511
|
const SYMBOLS = {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
512
|
+
static: "○",
|
|
513
|
+
isr: "◐",
|
|
514
|
+
ssr: "ƒ",
|
|
515
|
+
unknown: "?",
|
|
516
|
+
api: "λ"
|
|
212
517
|
};
|
|
213
518
|
const LABELS = {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
519
|
+
static: "Static",
|
|
520
|
+
isr: "ISR",
|
|
521
|
+
ssr: "Dynamic",
|
|
522
|
+
unknown: "Unknown",
|
|
523
|
+
api: "API"
|
|
219
524
|
};
|
|
220
525
|
/**
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
526
|
+
* Formats a list of RouteRows into a Next.js-style build report string.
|
|
527
|
+
*
|
|
528
|
+
* Example output:
|
|
529
|
+
* Route (pages)
|
|
530
|
+
* ┌ ○ /
|
|
531
|
+
* ├ ◐ /blog/:slug (60s)
|
|
532
|
+
* ├ ƒ /dashboard
|
|
533
|
+
* └ λ /api/posts
|
|
534
|
+
*
|
|
535
|
+
* ○ Static ◐ ISR ƒ Dynamic λ API
|
|
536
|
+
*/
|
|
537
|
+
function formatBuildReport(rows, routerLabel = "app") {
|
|
538
|
+
if (rows.length === 0) return "";
|
|
539
|
+
const lines = [];
|
|
540
|
+
lines.push(` Route (${routerLabel})`);
|
|
541
|
+
const maxPatternLen = Math.max(...rows.map((r) => r.pattern.length));
|
|
542
|
+
rows.forEach((row, i) => {
|
|
543
|
+
const isLast = i === rows.length - 1;
|
|
544
|
+
const corner = rows.length === 1 ? "─" : i === 0 ? "┌" : isLast ? "└" : "├";
|
|
545
|
+
const sym = SYMBOLS[row.type];
|
|
546
|
+
const suffix = row.type === "isr" && row.revalidate !== void 0 ? ` (${row.revalidate}s)` : "";
|
|
547
|
+
const padding = " ".repeat(maxPatternLen - row.pattern.length);
|
|
548
|
+
lines.push(` ${corner} ${sym} ${row.pattern}${padding}${suffix}`);
|
|
549
|
+
});
|
|
550
|
+
lines.push("");
|
|
551
|
+
const usedTypes = [...new Set(rows.map((r) => r.type))].sort((a, b) => LABELS[a].localeCompare(LABELS[b]));
|
|
552
|
+
lines.push(" " + usedTypes.map((t) => `${SYMBOLS[t]} ${LABELS[t]}`).join(" "));
|
|
553
|
+
if (usedTypes.includes("unknown")) {
|
|
554
|
+
lines.push("");
|
|
555
|
+
lines.push(" ? Some routes could not be classified. vinext currently uses static analysis");
|
|
556
|
+
lines.push(" and cannot detect dynamic API usage (headers(), cookies(), etc.) at build time.");
|
|
557
|
+
lines.push(" Automatic classification will be improved in a future release.");
|
|
558
|
+
}
|
|
559
|
+
if (rows.some((r) => r.prerendered)) {
|
|
560
|
+
lines.push("");
|
|
561
|
+
lines.push(" ○ Routes marked static were confirmed by speculative prerender (attempted render");
|
|
562
|
+
lines.push(" succeeded without dynamic API usage).");
|
|
563
|
+
}
|
|
564
|
+
return lines.join("\n");
|
|
259
565
|
}
|
|
260
|
-
// ─── Directory detection ──────────────────────────────────────────────────────
|
|
261
566
|
function findDir(root, ...candidates) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
567
|
+
for (const candidate of candidates) {
|
|
568
|
+
const full = path.join(root, candidate);
|
|
569
|
+
try {
|
|
570
|
+
if (fs.statSync(full).isDirectory()) return full;
|
|
571
|
+
} catch {}
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
268
574
|
}
|
|
269
|
-
// ─── Main entry point ─────────────────────────────────────────────────────────
|
|
270
575
|
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
console.log("\n" + formatBuildReport(rows, "pages"));
|
|
300
|
-
}
|
|
301
|
-
}
|
|
576
|
+
* Scans the project at `root`, classifies all routes, and prints the
|
|
577
|
+
* Next.js-style build report to stdout.
|
|
578
|
+
*
|
|
579
|
+
* Called at the end of `vinext build` in cli.ts.
|
|
580
|
+
*/
|
|
581
|
+
async function printBuildReport(options) {
|
|
582
|
+
const { root } = options;
|
|
583
|
+
const appDir = findDir(root, "app", "src/app");
|
|
584
|
+
const pagesDir = findDir(root, "pages", "src/pages");
|
|
585
|
+
if (!appDir && !pagesDir) return;
|
|
586
|
+
if (appDir) {
|
|
587
|
+
const { appRouter } = await import("../routing/app-router.js");
|
|
588
|
+
const rows = buildReportRows({
|
|
589
|
+
appRoutes: await appRouter(appDir, options.pageExtensions),
|
|
590
|
+
prerenderResult: options.prerenderResult
|
|
591
|
+
});
|
|
592
|
+
if (rows.length > 0) console.log("\n" + formatBuildReport(rows, "app"));
|
|
593
|
+
}
|
|
594
|
+
if (pagesDir) {
|
|
595
|
+
const { pagesRouter, apiRouter } = await import("../routing/pages-router.js");
|
|
596
|
+
const [pageRoutes, apiRoutes] = await Promise.all([pagesRouter(pagesDir, options.pageExtensions), apiRouter(pagesDir, options.pageExtensions)]);
|
|
597
|
+
const rows = buildReportRows({
|
|
598
|
+
pageRoutes,
|
|
599
|
+
apiRoutes,
|
|
600
|
+
prerenderResult: options.prerenderResult
|
|
601
|
+
});
|
|
602
|
+
if (rows.length > 0) console.log("\n" + formatBuildReport(rows, "pages"));
|
|
603
|
+
}
|
|
302
604
|
}
|
|
605
|
+
//#endregion
|
|
606
|
+
export { buildReportRows, classifyAppRoute, classifyPagesRoute, extractExportConstNumber, extractExportConstString, extractGetStaticPropsRevalidate, findDir, formatBuildReport, hasNamedExport, printBuildReport };
|
|
607
|
+
|
|
303
608
|
//# sourceMappingURL=report.js.map
|