vinext 0.0.29 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/build/prerender.d.ts +188 -0
- package/dist/build/prerender.js +675 -0
- package/dist/build/prerender.js.map +1 -0
- package/dist/build/report.d.ts +45 -46
- package/dist/build/report.js +247 -276
- package/dist/build/report.js.map +1 -1
- package/dist/build/run-prerender.d.ts +62 -0
- package/dist/build/run-prerender.js +183 -0
- package/dist/build/run-prerender.js.map +1 -0
- package/dist/build/server-manifest.d.ts +19 -0
- package/dist/build/server-manifest.js +29 -0
- package/dist/build/server-manifest.js.map +1 -0
- package/dist/build/static-export.d.ts +51 -66
- package/dist/build/static-export.js +51 -545
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.d.ts +26 -24
- package/dist/check.js +591 -567
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +1 -15
- package/dist/cli.js +430 -491
- package/dist/cli.js.map +1 -1
- package/dist/client/entry.d.ts +1 -2
- package/dist/client/entry.js +49 -62
- package/dist/client/entry.js.map +1 -1
- package/dist/client/validate-module-path.d.ts +4 -1
- package/dist/client/validate-module-path.js +23 -28
- package/dist/client/validate-module-path.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +15 -20
- package/dist/client/vinext-next-data.js +0 -1
- package/dist/cloudflare/index.d.ts +3 -8
- package/dist/cloudflare/index.js +3 -8
- package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
- package/dist/cloudflare/kv-cache-handler.js +354 -366
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.d.ts +36 -34
- package/dist/cloudflare/tpr.js +460 -603
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +31 -40
- package/dist/config/config-matchers.js +727 -936
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +18 -11
- package/dist/config/dotenv.js +79 -84
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +156 -146
- package/dist/config/next-config.js +374 -464
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts +87 -96
- package/dist/deploy.js +490 -628
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +4 -1
- package/dist/entries/app-browser-entry.js +12 -8
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +33 -20
- package/dist/entries/app-rsc-entry.js +618 -343
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +9 -1
- package/dist/entries/app-ssr-entry.js +61 -28
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +6 -2
- package/dist/entries/pages-client-entry.js +30 -33
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-entry-helpers.d.ts +5 -1
- package/dist/entries/pages-entry-helpers.js +17 -14
- package/dist/entries/pages-entry-helpers.js.map +1 -1
- package/dist/entries/pages-server-entry.d.ts +6 -2
- package/dist/entries/pages-server-entry.js +229 -207
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +82 -62
- package/dist/index.js +2172 -3125
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +40 -37
- package/dist/init.js +201 -258
- package/dist/init.js.map +1 -1
- package/dist/plugins/async-hooks-stub.d.ts +7 -3
- package/dist/plugins/async-hooks-stub.js +39 -42
- package/dist/plugins/async-hooks-stub.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +7 -3
- package/dist/plugins/client-reference-dedup.js +63 -88
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/routing/app-router.d.ts +100 -96
- package/dist/routing/app-router.js +563 -659
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +18 -15
- package/dist/routing/file-matcher.js +65 -65
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +23 -24
- package/dist/routing/pages-router.js +147 -172
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/route-trie.d.ts +23 -20
- package/dist/routing/route-trie.js +131 -151
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/route-validation.d.ts +5 -2
- package/dist/routing/route-validation.js +98 -130
- package/dist/routing/route-validation.js.map +1 -1
- package/dist/routing/utils.d.ts +10 -7
- package/dist/routing/utils.js +75 -111
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.d.ts +8 -13
- package/dist/server/api-handler.js +161 -193
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-router-entry.d.ts +6 -16
- package/dist/server/app-router-entry.js +26 -54
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/dev-module-runner.d.ts +11 -64
- package/dist/server/dev-module-runner.js +89 -101
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/dev-origin-check.d.ts +12 -10
- package/dist/server/dev-origin-check.js +98 -108
- package/dist/server/dev-origin-check.js.map +1 -1
- package/dist/server/dev-server.d.ts +17 -13
- package/dist/server/dev-server.js +547 -874
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/html.d.ts +4 -1
- package/dist/server/html.js +25 -26
- package/dist/server/html.js.map +1 -1
- package/dist/server/image-optimization.d.ts +31 -28
- package/dist/server/image-optimization.js +183 -200
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/instrumentation.d.ts +25 -22
- package/dist/server/instrumentation.js +110 -122
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +16 -26
- package/dist/server/isr-cache.js +109 -126
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-routes.d.ts +85 -88
- package/dist/server/metadata-routes.js +277 -286
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-codegen.d.ts +7 -4
- package/dist/server/middleware-codegen.js +98 -65
- package/dist/server/middleware-codegen.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +8 -6
- package/dist/server/middleware-request-headers.js +47 -65
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware.d.ts +31 -47
- package/dist/server/middleware.js +276 -363
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/normalize-path.d.ts +4 -1
- package/dist/server/normalize-path.js +33 -47
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-i18n.d.ts +58 -0
- package/dist/server/pages-i18n.js +125 -0
- package/dist/server/pages-i18n.js.map +1 -0
- package/dist/server/prod-server.d.ts +19 -31
- package/dist/server/prod-server.js +714 -945
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.d.ts +18 -12
- package/dist/server/request-log.js +45 -52
- package/dist/server/request-log.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +9 -17
- package/dist/server/request-pipeline.js +133 -184
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/worker-utils.d.ts +4 -1
- package/dist/server/worker-utils.js +31 -37
- package/dist/server/worker-utils.js.map +1 -1
- package/dist/shims/amp.d.ts +5 -2
- package/dist/shims/amp.js +19 -15
- package/dist/shims/amp.js.map +1 -1
- package/dist/shims/app.d.ts +8 -10
- package/dist/shims/app.js +0 -1
- package/dist/shims/cache-runtime.d.ts +21 -43
- package/dist/shims/cache-runtime.js +271 -405
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +131 -119
- package/dist/shims/cache.js +339 -418
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-only.d.ts +1 -18
- package/dist/shims/client-only.js +0 -17
- package/dist/shims/compat-router.d.ts +4 -1
- package/dist/shims/compat-router.js +23 -19
- package/dist/shims/compat-router.js.map +1 -1
- package/dist/shims/config.d.ts +7 -5
- package/dist/shims/config.js +16 -23
- package/dist/shims/config.js.map +1 -1
- package/dist/shims/constants.d.ts +119 -118
- package/dist/shims/constants.js +159 -165
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/document.d.ts +20 -16
- package/dist/shims/document.js +41 -22
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/dynamic.d.ts +13 -22
- package/dist/shims/dynamic.js +122 -136
- package/dist/shims/dynamic.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +22 -15
- package/dist/shims/error-boundary.js +81 -79
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +11 -12
- package/dist/shims/error.js +35 -39
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +26 -10
- package/dist/shims/fetch-cache.js +443 -586
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +28 -26
- package/dist/shims/font-google-base.js +238 -325
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-google.d.ts +3 -3
- package/dist/shims/font-google.generated.d.ts +1928 -1924
- package/dist/shims/font-google.generated.js +1928 -2133
- package/dist/shims/font-google.generated.js.map +1 -1
- package/dist/shims/font-google.js +3 -3
- package/dist/shims/font-local.d.ts +28 -26
- package/dist/shims/font-local.js +204 -260
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.d.ts +13 -27
- package/dist/shims/form.js +128 -180
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head-state.d.ts +9 -10
- package/dist/shims/head-state.js +25 -39
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +16 -18
- package/dist/shims/head.js +185 -153
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +84 -71
- package/dist/shims/headers.js +447 -583
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-context.d.ts +23 -0
- package/dist/shims/i18n-context.js +44 -0
- package/dist/shims/i18n-context.js.map +1 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +45 -0
- package/dist/shims/i18n-state.js.map +1 -0
- package/dist/shims/image-config.d.ts +11 -8
- package/dist/shims/image-config.js +50 -83
- package/dist/shims/image-config.js.map +1 -1
- package/dist/shims/image.d.ts +37 -44
- package/dist/shims/image.js +284 -301
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/api-utils.d.ts +7 -4
- package/dist/shims/internal/api-utils.js +0 -6
- package/dist/shims/internal/app-router-context.d.ts +22 -17
- package/dist/shims/internal/app-router-context.js +17 -13
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/internal/cookies.d.ts +2 -9
- package/dist/shims/internal/cookies.js +2 -9
- package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
- package/dist/shims/internal/parse-cookie-header.js +29 -29
- package/dist/shims/internal/parse-cookie-header.js.map +1 -1
- package/dist/shims/internal/router-context.d.ts +6 -1
- package/dist/shims/internal/router-context.js +11 -7
- package/dist/shims/internal/router-context.js.map +1 -1
- package/dist/shims/internal/utils.d.ts +40 -36
- package/dist/shims/internal/utils.js +24 -30
- package/dist/shims/internal/utils.js.map +1 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
- package/dist/shims/internal/work-unit-async-storage.js +14 -11
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
- package/dist/shims/layout-segment-context.d.ts +11 -14
- package/dist/shims/layout-segment-context.js +24 -23
- package/dist/shims/layout-segment-context.js.map +1 -1
- package/dist/shims/legacy-image.d.ts +39 -46
- package/dist/shims/legacy-image.js +47 -42
- package/dist/shims/legacy-image.js.map +1 -1
- package/dist/shims/link.d.ts +32 -36
- package/dist/shims/link.js +262 -382
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +210 -202
- package/dist/shims/metadata.js +545 -544
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.d.ts +19 -13
- package/dist/shims/navigation-state.js +68 -58
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +59 -63
- package/dist/shims/navigation.js +508 -690
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +2 -20
- package/dist/shims/og.js +2 -19
- package/dist/shims/readonly-url-search-params.d.ts +8 -5
- package/dist/shims/readonly-url-search-params.js +26 -22
- package/dist/shims/readonly-url-search-params.js.map +1 -1
- package/dist/shims/request-context.d.ts +8 -5
- package/dist/shims/request-context.js +50 -51
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/request-state-types.d.ts +11 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/router-state.d.ts +15 -1
- package/dist/shims/router-state.js +34 -41
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +81 -81
- package/dist/shims/router.js +517 -543
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +39 -48
- package/dist/shims/script.js +107 -160
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server-only.d.ts +1 -19
- package/dist/shims/server-only.js +0 -18
- package/dist/shims/server.d.ts +175 -157
- package/dist/shims/server.js +462 -432
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +66 -0
- package/dist/shims/unified-request-context.js +98 -0
- package/dist/shims/unified-request-context.js.map +1 -0
- package/dist/shims/url-safety.d.ts +4 -1
- package/dist/shims/url-safety.js +15 -11
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +8 -5
- package/dist/shims/url-utils.js +62 -93
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/shims/web-vitals.d.ts +10 -8
- package/dist/shims/web-vitals.js +9 -15
- package/dist/shims/web-vitals.js.map +1 -1
- package/dist/utils/base-path.d.ts +5 -2
- package/dist/utils/base-path.js +21 -19
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +26 -0
- package/dist/utils/domain-locale.js +44 -0
- package/dist/utils/domain-locale.js.map +1 -0
- package/dist/utils/hash.d.ts +4 -1
- package/dist/utils/hash.js +19 -17
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/manifest-paths.d.ts +6 -3
- package/dist/utils/manifest-paths.js +15 -16
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/project.d.ts +13 -11
- package/dist/utils/project.js +169 -216
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/query.d.ts +8 -6
- package/dist/utils/query.js +57 -67
- package/dist/utils/query.js.map +1 -1
- package/package.json +11 -10
- package/dist/build/report.d.ts.map +0 -1
- package/dist/build/static-export.d.ts.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/entry.d.ts.map +0 -1
- package/dist/client/validate-module-path.d.ts.map +0 -1
- package/dist/client/vinext-next-data.d.ts.map +0 -1
- package/dist/client/vinext-next-data.js.map +0 -1
- package/dist/cloudflare/index.d.ts.map +0 -1
- package/dist/cloudflare/index.js.map +0 -1
- package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
- package/dist/cloudflare/tpr.d.ts.map +0 -1
- package/dist/config/config-matchers.d.ts.map +0 -1
- package/dist/config/dotenv.d.ts.map +0 -1
- package/dist/config/next-config.d.ts.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/entries/app-browser-entry.d.ts.map +0 -1
- package/dist/entries/app-rsc-entry.d.ts.map +0 -1
- package/dist/entries/app-ssr-entry.d.ts.map +0 -1
- package/dist/entries/pages-client-entry.d.ts.map +0 -1
- package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
- package/dist/entries/pages-server-entry.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init.d.ts.map +0 -1
- package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
- package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
- package/dist/routing/app-router.d.ts.map +0 -1
- package/dist/routing/file-matcher.d.ts.map +0 -1
- package/dist/routing/pages-router.d.ts.map +0 -1
- package/dist/routing/route-trie.d.ts.map +0 -1
- package/dist/routing/route-validation.d.ts.map +0 -1
- package/dist/routing/utils.d.ts.map +0 -1
- package/dist/server/api-handler.d.ts.map +0 -1
- package/dist/server/app-router-entry.d.ts.map +0 -1
- package/dist/server/dev-module-runner.d.ts.map +0 -1
- package/dist/server/dev-origin-check.d.ts.map +0 -1
- package/dist/server/dev-server.d.ts.map +0 -1
- package/dist/server/html.d.ts.map +0 -1
- package/dist/server/image-optimization.d.ts.map +0 -1
- package/dist/server/instrumentation.d.ts.map +0 -1
- package/dist/server/isr-cache.d.ts.map +0 -1
- package/dist/server/metadata-routes.d.ts.map +0 -1
- package/dist/server/middleware-codegen.d.ts.map +0 -1
- package/dist/server/middleware-request-headers.d.ts.map +0 -1
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/normalize-path.d.ts.map +0 -1
- package/dist/server/prod-server.d.ts.map +0 -1
- package/dist/server/request-log.d.ts.map +0 -1
- package/dist/server/request-pipeline.d.ts.map +0 -1
- package/dist/server/worker-utils.d.ts.map +0 -1
- package/dist/shims/amp.d.ts.map +0 -1
- package/dist/shims/app.d.ts.map +0 -1
- package/dist/shims/app.js.map +0 -1
- package/dist/shims/cache-runtime.d.ts.map +0 -1
- package/dist/shims/cache.d.ts.map +0 -1
- package/dist/shims/client-only.d.ts.map +0 -1
- package/dist/shims/client-only.js.map +0 -1
- package/dist/shims/compat-router.d.ts.map +0 -1
- package/dist/shims/config.d.ts.map +0 -1
- package/dist/shims/constants.d.ts.map +0 -1
- package/dist/shims/document.d.ts.map +0 -1
- package/dist/shims/dynamic.d.ts.map +0 -1
- package/dist/shims/error-boundary.d.ts.map +0 -1
- package/dist/shims/error.d.ts.map +0 -1
- package/dist/shims/fetch-cache.d.ts.map +0 -1
- package/dist/shims/font-google-base.d.ts.map +0 -1
- package/dist/shims/font-google.d.ts.map +0 -1
- package/dist/shims/font-google.generated.d.ts.map +0 -1
- package/dist/shims/font-google.js.map +0 -1
- package/dist/shims/font-local.d.ts.map +0 -1
- package/dist/shims/form.d.ts.map +0 -1
- package/dist/shims/head-state.d.ts.map +0 -1
- package/dist/shims/head.d.ts.map +0 -1
- package/dist/shims/headers.d.ts.map +0 -1
- package/dist/shims/image-config.d.ts.map +0 -1
- package/dist/shims/image.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.js.map +0 -1
- package/dist/shims/internal/app-router-context.d.ts.map +0 -1
- package/dist/shims/internal/cookies.d.ts.map +0 -1
- package/dist/shims/internal/cookies.js.map +0 -1
- package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
- package/dist/shims/internal/router-context.d.ts.map +0 -1
- package/dist/shims/internal/utils.d.ts.map +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
- package/dist/shims/layout-segment-context.d.ts.map +0 -1
- package/dist/shims/legacy-image.d.ts.map +0 -1
- package/dist/shims/link.d.ts.map +0 -1
- package/dist/shims/metadata.d.ts.map +0 -1
- package/dist/shims/navigation-state.d.ts.map +0 -1
- package/dist/shims/navigation.d.ts.map +0 -1
- package/dist/shims/og.d.ts.map +0 -1
- package/dist/shims/og.js.map +0 -1
- package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
- package/dist/shims/request-context.d.ts.map +0 -1
- package/dist/shims/router-state.d.ts.map +0 -1
- package/dist/shims/router.d.ts.map +0 -1
- package/dist/shims/script.d.ts.map +0 -1
- package/dist/shims/server-only.d.ts.map +0 -1
- package/dist/shims/server-only.js.map +0 -1
- package/dist/shims/server.d.ts.map +0 -1
- package/dist/shims/url-safety.d.ts.map +0 -1
- package/dist/shims/url-utils.d.ts.map +0 -1
- package/dist/shims/web-vitals.d.ts.map +0 -1
- package/dist/utils/base-path.d.ts.map +0 -1
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/manifest-paths.d.ts.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/query.d.ts.map +0 -1
package/dist/shims/router.js
CHANGED
|
@@ -1,598 +1,572 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* next/router shim
|
|
3
|
-
*
|
|
4
|
-
* Provides useRouter() hook and Router singleton for Pages Router.
|
|
5
|
-
* Backed by the browser History API. Supports client-side navigation
|
|
6
|
-
* by fetching new page data and re-rendering the React root.
|
|
7
|
-
*/
|
|
8
|
-
import { useState, useEffect, useCallback, useMemo, createElement } from "react";
|
|
9
1
|
import { RouterContext } from "./internal/router-context.js";
|
|
10
2
|
import { isValidModulePath } from "../client/validate-module-path.js";
|
|
11
|
-
import { toBrowserNavigationHref, toSameOriginAppPath } from "./url-utils.js";
|
|
12
3
|
import { stripBasePath } from "../utils/base-path.js";
|
|
13
|
-
import {
|
|
4
|
+
import { toBrowserNavigationHref, toSameOriginAppPath } from "./url-utils.js";
|
|
5
|
+
import { addLocalePrefix, getDomainLocaleUrl } from "../utils/domain-locale.js";
|
|
6
|
+
import { addQueryParam, appendSearchParamsToUrl, urlQueryToSearchParams } from "../utils/query.js";
|
|
7
|
+
import { createElement, useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
+
//#region src/shims/router.ts
|
|
9
|
+
/**
|
|
10
|
+
* next/router shim
|
|
11
|
+
*
|
|
12
|
+
* Provides useRouter() hook and Router singleton for Pages Router.
|
|
13
|
+
* Backed by the browser History API. Supports client-side navigation
|
|
14
|
+
* by fetching new page data and re-rendering the React root.
|
|
15
|
+
*/
|
|
14
16
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
15
17
|
const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
16
18
|
function createRouterEvents() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
19
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
20
|
+
return {
|
|
21
|
+
on(event, handler) {
|
|
22
|
+
if (!listeners.has(event)) listeners.set(event, /* @__PURE__ */ new Set());
|
|
23
|
+
listeners.get(event).add(handler);
|
|
24
|
+
},
|
|
25
|
+
off(event, handler) {
|
|
26
|
+
listeners.get(event)?.delete(handler);
|
|
27
|
+
},
|
|
28
|
+
emit(event, ...args) {
|
|
29
|
+
listeners.get(event)?.forEach((handler) => handler(...args));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
31
32
|
}
|
|
32
|
-
// Singleton events instance
|
|
33
33
|
const routerEvents = createRouterEvents();
|
|
34
34
|
function resolveUrl(url) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return result;
|
|
35
|
+
if (typeof url === "string") return url;
|
|
36
|
+
let result = url.pathname ?? "/";
|
|
37
|
+
if (url.query) {
|
|
38
|
+
const params = urlQueryToSearchParams(url.query);
|
|
39
|
+
result = appendSearchParamsToUrl(result, params);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
43
42
|
}
|
|
44
43
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
* When `as` is provided, use it as the navigation target. This is a
|
|
45
|
+
* simplification: Next.js keeps `url` and `as` as separate values (url for
|
|
46
|
+
* data fetching, as for the browser URL). We collapse them because vinext's
|
|
47
|
+
* navigateClient() fetches HTML from the target URL, so `as` must be a
|
|
48
|
+
* server-resolvable path. Purely decorative `as` values are not supported.
|
|
49
|
+
*/
|
|
51
50
|
function resolveNavigationTarget(url, as, locale) {
|
|
52
|
-
|
|
51
|
+
return applyNavigationLocale(as ?? resolveUrl(url), locale);
|
|
52
|
+
}
|
|
53
|
+
function getDomainLocales() {
|
|
54
|
+
return window.__NEXT_DATA__?.domainLocales;
|
|
55
|
+
}
|
|
56
|
+
function getCurrentHostname() {
|
|
57
|
+
return window.location?.hostname;
|
|
58
|
+
}
|
|
59
|
+
function getDomainLocalePath(url, locale) {
|
|
60
|
+
return getDomainLocaleUrl(url, locale, {
|
|
61
|
+
basePath: __basePath,
|
|
62
|
+
currentHostname: getCurrentHostname(),
|
|
63
|
+
domainItems: getDomainLocales()
|
|
64
|
+
});
|
|
53
65
|
}
|
|
54
66
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return url;
|
|
65
|
-
}
|
|
66
|
-
const defaultLocale = window.__VINEXT_DEFAULT_LOCALE__;
|
|
67
|
-
// Default locale doesn't get a prefix
|
|
68
|
-
if (locale === defaultLocale)
|
|
69
|
-
return url;
|
|
70
|
-
// Don't double-prefix
|
|
71
|
-
if (url.startsWith(`/${locale}/`) || url === `/${locale}`)
|
|
72
|
-
return url;
|
|
73
|
-
return `/${locale}${url.startsWith("/") ? url : `/${url}`}`;
|
|
67
|
+
* Apply locale prefix to a URL for client-side navigation.
|
|
68
|
+
* Same logic as Link's applyLocaleToHref but reads from window globals.
|
|
69
|
+
*/
|
|
70
|
+
function applyNavigationLocale(url, locale) {
|
|
71
|
+
if (!locale || typeof window === "undefined") return url;
|
|
72
|
+
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) return url;
|
|
73
|
+
const domainLocalePath = getDomainLocalePath(url, locale);
|
|
74
|
+
if (domainLocalePath) return domainLocalePath;
|
|
75
|
+
return addLocalePrefix(url, locale, window.__VINEXT_DEFAULT_LOCALE__ ?? "");
|
|
74
76
|
}
|
|
75
77
|
/** Check if a URL is external (any URL scheme per RFC 3986, or protocol-relative) */
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
function isExternalUrl(url) {
|
|
79
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//");
|
|
80
|
+
}
|
|
81
|
+
/** Resolve a hash URL to a basePath-stripped app URL for event payloads */
|
|
82
|
+
function resolveHashUrl(url) {
|
|
83
|
+
if (typeof window === "undefined") return url;
|
|
84
|
+
if (url.startsWith("#")) return stripBasePath(window.location.pathname, __basePath) + window.location.search + url;
|
|
85
|
+
try {
|
|
86
|
+
const parsed = new URL(url, window.location.href);
|
|
87
|
+
return stripBasePath(parsed.pathname, __basePath) + parsed.search + parsed.hash;
|
|
88
|
+
} catch {
|
|
89
|
+
return url;
|
|
90
|
+
}
|
|
78
91
|
}
|
|
79
92
|
/** Check if a href is only a hash change relative to the current URL */
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
catch {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
+
function isHashOnlyChange(href) {
|
|
94
|
+
if (href.startsWith("#")) return true;
|
|
95
|
+
if (typeof window === "undefined") return false;
|
|
96
|
+
try {
|
|
97
|
+
const current = new URL(window.location.href);
|
|
98
|
+
const next = new URL(href, window.location.href);
|
|
99
|
+
return current.pathname === next.pathname && current.search === next.search && next.hash !== "";
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
93
103
|
}
|
|
94
104
|
/** Scroll to hash target element, or top if no hash */
|
|
95
105
|
function scrollToHash(hash) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
el.scrollIntoView({ behavior: "auto" });
|
|
106
|
+
if (!hash || hash === "#") {
|
|
107
|
+
window.scrollTo(0, 0);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const el = document.getElementById(hash.slice(1));
|
|
111
|
+
if (el) el.scrollIntoView({ behavior: "auto" });
|
|
103
112
|
}
|
|
104
113
|
/** Save current scroll position into history state for back/forward restoration */
|
|
105
114
|
function saveScrollPosition() {
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
const state = window.history.state ?? {};
|
|
116
|
+
window.history.replaceState({
|
|
117
|
+
...state,
|
|
118
|
+
__vinext_scrollX: window.scrollX,
|
|
119
|
+
__vinext_scrollY: window.scrollY
|
|
120
|
+
}, "");
|
|
108
121
|
}
|
|
109
122
|
/** Restore scroll position from history state */
|
|
110
123
|
function restoreScrollPosition(state) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
if (state && typeof state === "object" && "__vinext_scrollY" in state) {
|
|
125
|
+
const { __vinext_scrollX: x, __vinext_scrollY: y } = state;
|
|
126
|
+
requestAnimationFrame(() => window.scrollTo(x, y));
|
|
127
|
+
}
|
|
115
128
|
}
|
|
116
|
-
// ---------------------------------------------------------------------------
|
|
117
|
-
// Server-side SSR state uses a registration pattern so this module can be
|
|
118
|
-
// bundled for the browser. The ALS-backed implementation lives in
|
|
119
|
-
// router-state.ts (server-only) and registers itself on import.
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
129
|
let _ssrContext = null;
|
|
122
130
|
let _getSSRContext = () => _ssrContext;
|
|
123
131
|
let _setSSRContextImpl = (ctx) => {
|
|
124
|
-
|
|
132
|
+
_ssrContext = ctx;
|
|
125
133
|
};
|
|
126
134
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
* Register ALS-backed state accessors. Called by router-state.ts on import.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
function _registerRouterStateAccessors(accessors) {
|
|
139
|
+
_getSSRContext = accessors.getSSRContext;
|
|
140
|
+
_setSSRContextImpl = accessors.setSSRContext;
|
|
133
141
|
}
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
function setSSRContext(ctx) {
|
|
143
|
+
_setSSRContextImpl(ctx);
|
|
136
144
|
}
|
|
137
145
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
* Extract param names from a Next.js route pattern.
|
|
147
|
+
* E.g., "/posts/[id]" → ["id"], "/docs/[...slug]" → ["slug"],
|
|
148
|
+
* "/shop/[[...path]]" → ["path"], "/blog/[year]/[month]" → ["year", "month"]
|
|
149
|
+
* Also handles internal format: "/posts/:id" → ["id"], "/docs/:slug+" → ["slug"]
|
|
150
|
+
*/
|
|
143
151
|
function extractRouteParamNames(pattern) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return names;
|
|
152
|
-
// Fallback: match internal :param format
|
|
153
|
-
const colonMatches = pattern.matchAll(/:([\w-]+)[+*]?/g);
|
|
154
|
-
for (const m of colonMatches) {
|
|
155
|
-
names.push(m[1]);
|
|
156
|
-
}
|
|
157
|
-
return names;
|
|
152
|
+
const names = [];
|
|
153
|
+
const bracketMatches = pattern.matchAll(/\[{1,2}(?:\.\.\.)?([\w-]+)\]{1,2}/g);
|
|
154
|
+
for (const m of bracketMatches) names.push(m[1]);
|
|
155
|
+
if (names.length > 0) return names;
|
|
156
|
+
const colonMatches = pattern.matchAll(/:([\w-]+)[+*]?/g);
|
|
157
|
+
for (const m of colonMatches) names.push(m[1]);
|
|
158
|
+
return names;
|
|
158
159
|
}
|
|
159
160
|
function getPathnameAndQuery() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const asPath = resolvedPath + window.location.search + window.location.hash;
|
|
201
|
-
return { pathname, query, asPath };
|
|
161
|
+
if (typeof window === "undefined") {
|
|
162
|
+
const _ssrCtx = _getSSRContext();
|
|
163
|
+
if (_ssrCtx) {
|
|
164
|
+
const query = {};
|
|
165
|
+
for (const [key, value] of Object.entries(_ssrCtx.query)) query[key] = Array.isArray(value) ? [...value] : value;
|
|
166
|
+
return {
|
|
167
|
+
pathname: _ssrCtx.pathname,
|
|
168
|
+
query,
|
|
169
|
+
asPath: _ssrCtx.asPath
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
pathname: "/",
|
|
174
|
+
query: {},
|
|
175
|
+
asPath: "/"
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const resolvedPath = stripBasePath(window.location.pathname, __basePath);
|
|
179
|
+
const pathname = window.__NEXT_DATA__?.page ?? resolvedPath;
|
|
180
|
+
const routeQuery = {};
|
|
181
|
+
const nextData = window.__NEXT_DATA__;
|
|
182
|
+
if (nextData && nextData.query && nextData.page) {
|
|
183
|
+
const routeParamNames = extractRouteParamNames(nextData.page);
|
|
184
|
+
for (const key of routeParamNames) {
|
|
185
|
+
const value = nextData.query[key];
|
|
186
|
+
if (typeof value === "string") routeQuery[key] = value;
|
|
187
|
+
else if (Array.isArray(value)) routeQuery[key] = [...value];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const searchQuery = {};
|
|
191
|
+
const params = new URLSearchParams(window.location.search);
|
|
192
|
+
for (const [key, value] of params) addQueryParam(searchQuery, key, value);
|
|
193
|
+
return {
|
|
194
|
+
pathname,
|
|
195
|
+
query: {
|
|
196
|
+
...searchQuery,
|
|
197
|
+
...routeQuery
|
|
198
|
+
},
|
|
199
|
+
asPath: resolvedPath + window.location.search + window.location.hash
|
|
200
|
+
};
|
|
202
201
|
}
|
|
203
202
|
/**
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
* Perform client-side navigation: fetch the target page's HTML,
|
|
204
|
+
* extract __NEXT_DATA__, and re-render the React root.
|
|
205
|
+
*/
|
|
207
206
|
let _navInProgress = false;
|
|
208
207
|
async function navigateClient(url) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
// _app not available — continue without it
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
let element;
|
|
286
|
-
if (AppComponent) {
|
|
287
|
-
element = React.createElement(AppComponent, {
|
|
288
|
-
Component: PageComponent,
|
|
289
|
-
pageProps,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
element = React.createElement(PageComponent, pageProps);
|
|
294
|
-
}
|
|
295
|
-
// Wrap with RouterContext.Provider so next/compat/router works
|
|
296
|
-
element = wrapWithRouterContext(element);
|
|
297
|
-
root.render(element);
|
|
298
|
-
}
|
|
299
|
-
catch (err) {
|
|
300
|
-
console.error("[vinext] Client navigation failed:", err);
|
|
301
|
-
routerEvents.emit("routeChangeError", err, url);
|
|
302
|
-
window.location.href = url;
|
|
303
|
-
}
|
|
304
|
-
finally {
|
|
305
|
-
_navInProgress = false;
|
|
306
|
-
}
|
|
208
|
+
if (typeof window === "undefined") return;
|
|
209
|
+
const root = window.__VINEXT_ROOT__;
|
|
210
|
+
if (!root) {
|
|
211
|
+
window.location.href = url;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (_navInProgress) return;
|
|
215
|
+
_navInProgress = true;
|
|
216
|
+
try {
|
|
217
|
+
const res = await fetch(url, { headers: { Accept: "text/html" } });
|
|
218
|
+
if (!res.ok) {
|
|
219
|
+
window.location.href = url;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const html = await res.text();
|
|
223
|
+
const match = html.match(/<script>window\.__NEXT_DATA__\s*=\s*(.*?)<\/script>/);
|
|
224
|
+
if (!match) {
|
|
225
|
+
window.location.href = url;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const nextData = JSON.parse(match[1]);
|
|
229
|
+
const { pageProps } = nextData.props;
|
|
230
|
+
window.__NEXT_DATA__ = nextData;
|
|
231
|
+
let pageModuleUrl = nextData.__vinext?.pageModuleUrl;
|
|
232
|
+
if (!pageModuleUrl) {
|
|
233
|
+
const moduleMatch = html.match(/import\("([^"]+)"\);\s*\n\s*const PageComponent/);
|
|
234
|
+
const altMatch = html.match(/await import\("([^"]+pages\/[^"]+)"\)/);
|
|
235
|
+
pageModuleUrl = moduleMatch?.[1] ?? altMatch?.[1] ?? void 0;
|
|
236
|
+
}
|
|
237
|
+
if (!pageModuleUrl) {
|
|
238
|
+
window.location.href = url;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!isValidModulePath(pageModuleUrl)) {
|
|
242
|
+
console.error("[vinext] Blocked import of invalid page module path:", pageModuleUrl);
|
|
243
|
+
window.location.href = url;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const PageComponent = (await import(
|
|
247
|
+
/* @vite-ignore */
|
|
248
|
+
pageModuleUrl
|
|
249
|
+
)).default;
|
|
250
|
+
if (!PageComponent) {
|
|
251
|
+
window.location.href = url;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const React = (await import("react")).default;
|
|
255
|
+
let AppComponent = window.__VINEXT_APP__;
|
|
256
|
+
const appModuleUrl = nextData.__vinext?.appModuleUrl;
|
|
257
|
+
if (!AppComponent && appModuleUrl) if (!isValidModulePath(appModuleUrl)) console.error("[vinext] Blocked import of invalid app module path:", appModuleUrl);
|
|
258
|
+
else try {
|
|
259
|
+
AppComponent = (await import(
|
|
260
|
+
/* @vite-ignore */
|
|
261
|
+
appModuleUrl
|
|
262
|
+
)).default;
|
|
263
|
+
window.__VINEXT_APP__ = AppComponent;
|
|
264
|
+
} catch {}
|
|
265
|
+
let element;
|
|
266
|
+
if (AppComponent) element = React.createElement(AppComponent, {
|
|
267
|
+
Component: PageComponent,
|
|
268
|
+
pageProps
|
|
269
|
+
});
|
|
270
|
+
else element = React.createElement(PageComponent, pageProps);
|
|
271
|
+
element = wrapWithRouterContext(element);
|
|
272
|
+
root.render(element);
|
|
273
|
+
} catch (err) {
|
|
274
|
+
console.error("[vinext] Client navigation failed:", err);
|
|
275
|
+
routerEvents.emit("routeChangeError", err, url, { shallow: false });
|
|
276
|
+
window.location.href = url;
|
|
277
|
+
} finally {
|
|
278
|
+
_navInProgress = false;
|
|
279
|
+
}
|
|
307
280
|
}
|
|
308
281
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
282
|
+
* Build the full router value object from the current pathname, query, asPath,
|
|
283
|
+
* and a set of navigation methods. Shared by useRouter() (which passes
|
|
284
|
+
* hook-derived callbacks) and wrapWithRouterContext() (which passes the Router
|
|
285
|
+
* singleton methods) so the shape stays in sync.
|
|
286
|
+
*/
|
|
314
287
|
function buildRouterValue(pathname, query, asPath, methods) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
288
|
+
const _ssrState = _getSSRContext();
|
|
289
|
+
const nextData = typeof window !== "undefined" ? window.__NEXT_DATA__ : void 0;
|
|
290
|
+
const locale = typeof window === "undefined" ? _ssrState?.locale : window.__VINEXT_LOCALE__;
|
|
291
|
+
const locales = typeof window === "undefined" ? _ssrState?.locales : window.__VINEXT_LOCALES__;
|
|
292
|
+
const defaultLocale = typeof window === "undefined" ? _ssrState?.defaultLocale : window.__VINEXT_DEFAULT_LOCALE__;
|
|
293
|
+
const domainLocales = typeof window === "undefined" ? _ssrState?.domainLocales : nextData?.domainLocales;
|
|
294
|
+
return {
|
|
295
|
+
pathname,
|
|
296
|
+
route: typeof window !== "undefined" ? nextData?.page ?? pathname : pathname,
|
|
297
|
+
query,
|
|
298
|
+
asPath,
|
|
299
|
+
basePath: __basePath,
|
|
300
|
+
locale,
|
|
301
|
+
locales,
|
|
302
|
+
defaultLocale,
|
|
303
|
+
domainLocales,
|
|
304
|
+
isReady: true,
|
|
305
|
+
isPreview: false,
|
|
306
|
+
isFallback: typeof window !== "undefined" && nextData?.isFallback === true,
|
|
307
|
+
...methods,
|
|
308
|
+
events: routerEvents
|
|
309
|
+
};
|
|
335
310
|
}
|
|
336
311
|
/**
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
return router;
|
|
312
|
+
* useRouter hook - Pages Router compatible.
|
|
313
|
+
*/
|
|
314
|
+
function useRouter() {
|
|
315
|
+
const [{ pathname, query, asPath }, setState] = useState(getPathnameAndQuery);
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
const onNavigate = ((_e) => {
|
|
318
|
+
setState(getPathnameAndQuery());
|
|
319
|
+
});
|
|
320
|
+
window.addEventListener("vinext:navigate", onNavigate);
|
|
321
|
+
return () => window.removeEventListener("vinext:navigate", onNavigate);
|
|
322
|
+
}, []);
|
|
323
|
+
const push = useCallback(async (url, as, options) => {
|
|
324
|
+
let resolved = resolveNavigationTarget(url, as, options?.locale);
|
|
325
|
+
if (isExternalUrl(resolved)) {
|
|
326
|
+
const localPath = toSameOriginAppPath(resolved, __basePath);
|
|
327
|
+
if (localPath == null) {
|
|
328
|
+
window.location.assign(resolved);
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
resolved = localPath;
|
|
332
|
+
}
|
|
333
|
+
const full = toBrowserNavigationHref(resolved, window.location.href, __basePath);
|
|
334
|
+
if (isHashOnlyChange(resolved)) {
|
|
335
|
+
const eventUrl = resolveHashUrl(resolved);
|
|
336
|
+
routerEvents.emit("hashChangeStart", eventUrl, { shallow: options?.shallow ?? false });
|
|
337
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
338
|
+
window.history.pushState({}, "", resolved.startsWith("#") ? resolved : full);
|
|
339
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
340
|
+
scrollToHash(hash);
|
|
341
|
+
setState(getPathnameAndQuery());
|
|
342
|
+
routerEvents.emit("hashChangeComplete", eventUrl, { shallow: options?.shallow ?? false });
|
|
343
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
saveScrollPosition();
|
|
347
|
+
routerEvents.emit("routeChangeStart", resolved, { shallow: options?.shallow ?? false });
|
|
348
|
+
routerEvents.emit("beforeHistoryChange", resolved, { shallow: options?.shallow ?? false });
|
|
349
|
+
window.history.pushState({}, "", full);
|
|
350
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
351
|
+
if (!options?.shallow) await navigateClient(full);
|
|
352
|
+
setState(getPathnameAndQuery());
|
|
353
|
+
routerEvents.emit("routeChangeComplete", resolved, { shallow: options?.shallow ?? false });
|
|
354
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
355
|
+
if (hash) scrollToHash(hash);
|
|
356
|
+
else if (options?.scroll !== false) window.scrollTo(0, 0);
|
|
357
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
358
|
+
return true;
|
|
359
|
+
}, []);
|
|
360
|
+
const replace = useCallback(async (url, as, options) => {
|
|
361
|
+
let resolved = resolveNavigationTarget(url, as, options?.locale);
|
|
362
|
+
if (isExternalUrl(resolved)) {
|
|
363
|
+
const localPath = toSameOriginAppPath(resolved, __basePath);
|
|
364
|
+
if (localPath == null) {
|
|
365
|
+
window.location.replace(resolved);
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
resolved = localPath;
|
|
369
|
+
}
|
|
370
|
+
const full = toBrowserNavigationHref(resolved, window.location.href, __basePath);
|
|
371
|
+
if (isHashOnlyChange(resolved)) {
|
|
372
|
+
const eventUrl = resolveHashUrl(resolved);
|
|
373
|
+
routerEvents.emit("hashChangeStart", eventUrl, { shallow: options?.shallow ?? false });
|
|
374
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
375
|
+
window.history.replaceState({}, "", resolved.startsWith("#") ? resolved : full);
|
|
376
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
377
|
+
scrollToHash(hash);
|
|
378
|
+
setState(getPathnameAndQuery());
|
|
379
|
+
routerEvents.emit("hashChangeComplete", eventUrl, { shallow: options?.shallow ?? false });
|
|
380
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
routerEvents.emit("routeChangeStart", resolved, { shallow: options?.shallow ?? false });
|
|
384
|
+
routerEvents.emit("beforeHistoryChange", resolved, { shallow: options?.shallow ?? false });
|
|
385
|
+
window.history.replaceState({}, "", full);
|
|
386
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
387
|
+
if (!options?.shallow) await navigateClient(full);
|
|
388
|
+
setState(getPathnameAndQuery());
|
|
389
|
+
routerEvents.emit("routeChangeComplete", resolved, { shallow: options?.shallow ?? false });
|
|
390
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
391
|
+
if (hash) scrollToHash(hash);
|
|
392
|
+
else if (options?.scroll !== false) window.scrollTo(0, 0);
|
|
393
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
394
|
+
return true;
|
|
395
|
+
}, []);
|
|
396
|
+
const back = useCallback(() => {
|
|
397
|
+
window.history.back();
|
|
398
|
+
}, []);
|
|
399
|
+
const reload = useCallback(() => {
|
|
400
|
+
window.location.reload();
|
|
401
|
+
}, []);
|
|
402
|
+
const prefetch = useCallback(async (url) => {
|
|
403
|
+
if (typeof document !== "undefined") {
|
|
404
|
+
const link = document.createElement("link");
|
|
405
|
+
link.rel = "prefetch";
|
|
406
|
+
link.href = url;
|
|
407
|
+
link.as = "document";
|
|
408
|
+
document.head.appendChild(link);
|
|
409
|
+
}
|
|
410
|
+
}, []);
|
|
411
|
+
return useMemo(() => buildRouterValue(pathname, query, asPath, {
|
|
412
|
+
push,
|
|
413
|
+
replace,
|
|
414
|
+
back,
|
|
415
|
+
reload,
|
|
416
|
+
prefetch,
|
|
417
|
+
beforePopState: (cb) => {
|
|
418
|
+
_beforePopStateCb = cb;
|
|
419
|
+
}
|
|
420
|
+
}), [
|
|
421
|
+
pathname,
|
|
422
|
+
query,
|
|
423
|
+
asPath,
|
|
424
|
+
push,
|
|
425
|
+
replace,
|
|
426
|
+
back,
|
|
427
|
+
reload,
|
|
428
|
+
prefetch
|
|
429
|
+
]);
|
|
456
430
|
}
|
|
457
|
-
// beforePopState callback: called before handling browser back/forward.
|
|
458
|
-
// If it returns false, the navigation is cancelled.
|
|
459
431
|
let _beforePopStateCb;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
432
|
+
let _lastPathnameAndSearch = typeof window !== "undefined" ? window.location.pathname + window.location.search : "";
|
|
433
|
+
if (typeof window !== "undefined") window.addEventListener("popstate", (e) => {
|
|
434
|
+
const browserUrl = window.location.pathname + window.location.search;
|
|
435
|
+
const appUrl = stripBasePath(window.location.pathname, __basePath) + window.location.search;
|
|
436
|
+
const isHashOnly = browserUrl === _lastPathnameAndSearch;
|
|
437
|
+
if (_beforePopStateCb !== void 0) {
|
|
438
|
+
if (!_beforePopStateCb({
|
|
439
|
+
url: appUrl,
|
|
440
|
+
as: appUrl,
|
|
441
|
+
options: { shallow: false }
|
|
442
|
+
})) return;
|
|
443
|
+
}
|
|
444
|
+
_lastPathnameAndSearch = browserUrl;
|
|
445
|
+
if (isHashOnly) {
|
|
446
|
+
const hashUrl = appUrl + window.location.hash;
|
|
447
|
+
routerEvents.emit("hashChangeStart", hashUrl, { shallow: false });
|
|
448
|
+
scrollToHash(window.location.hash);
|
|
449
|
+
routerEvents.emit("hashChangeComplete", hashUrl, { shallow: false });
|
|
450
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const fullAppUrl = appUrl + window.location.hash;
|
|
454
|
+
routerEvents.emit("routeChangeStart", fullAppUrl, { shallow: false });
|
|
455
|
+
routerEvents.emit("beforeHistoryChange", fullAppUrl, { shallow: false });
|
|
456
|
+
navigateClient(browserUrl).then(() => {
|
|
457
|
+
routerEvents.emit("routeChangeComplete", fullAppUrl, { shallow: false });
|
|
458
|
+
restoreScrollPosition(e.state);
|
|
459
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
460
|
+
});
|
|
461
|
+
});
|
|
485
462
|
/**
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
463
|
+
* Wrap a React element in a RouterContext.Provider so that
|
|
464
|
+
* next/compat/router's useRouter() returns the real Pages Router value.
|
|
465
|
+
*
|
|
466
|
+
* This is a plain function, NOT a React component — it builds the router
|
|
467
|
+
* value object directly from the current SSR context (server) or
|
|
468
|
+
* window.location + Router singleton (client), avoiding duplicate state
|
|
469
|
+
* that a hook-based component would create.
|
|
470
|
+
*/
|
|
471
|
+
function wrapWithRouterContext(element) {
|
|
472
|
+
const { pathname, query, asPath } = getPathnameAndQuery();
|
|
473
|
+
const routerValue = buildRouterValue(pathname, query, asPath, {
|
|
474
|
+
push: Router.push,
|
|
475
|
+
replace: Router.replace,
|
|
476
|
+
back: Router.back,
|
|
477
|
+
reload: Router.reload,
|
|
478
|
+
prefetch: Router.prefetch,
|
|
479
|
+
beforePopState: Router.beforePopState
|
|
480
|
+
});
|
|
481
|
+
return createElement(RouterContext.Provider, { value: routerValue }, element);
|
|
505
482
|
}
|
|
506
|
-
// Also export a default Router singleton for `import Router from 'next/router'`
|
|
507
483
|
const Router = {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
beforePopState: (cb) => {
|
|
593
|
-
_beforePopStateCb = cb;
|
|
594
|
-
},
|
|
595
|
-
events: routerEvents,
|
|
484
|
+
push: async (url, as, options) => {
|
|
485
|
+
let resolved = resolveNavigationTarget(url, as, options?.locale);
|
|
486
|
+
if (isExternalUrl(resolved)) {
|
|
487
|
+
const localPath = toSameOriginAppPath(resolved, __basePath);
|
|
488
|
+
if (localPath == null) {
|
|
489
|
+
window.location.assign(resolved);
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
resolved = localPath;
|
|
493
|
+
}
|
|
494
|
+
const full = toBrowserNavigationHref(resolved, window.location.href, __basePath);
|
|
495
|
+
if (isHashOnlyChange(resolved)) {
|
|
496
|
+
const eventUrl = resolveHashUrl(resolved);
|
|
497
|
+
routerEvents.emit("hashChangeStart", eventUrl, { shallow: options?.shallow ?? false });
|
|
498
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
499
|
+
window.history.pushState({}, "", resolved.startsWith("#") ? resolved : full);
|
|
500
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
501
|
+
scrollToHash(hash);
|
|
502
|
+
routerEvents.emit("hashChangeComplete", eventUrl, { shallow: options?.shallow ?? false });
|
|
503
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
saveScrollPosition();
|
|
507
|
+
routerEvents.emit("routeChangeStart", resolved, { shallow: options?.shallow ?? false });
|
|
508
|
+
routerEvents.emit("beforeHistoryChange", resolved, { shallow: options?.shallow ?? false });
|
|
509
|
+
window.history.pushState({}, "", full);
|
|
510
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
511
|
+
if (!options?.shallow) await navigateClient(full);
|
|
512
|
+
routerEvents.emit("routeChangeComplete", resolved, { shallow: options?.shallow ?? false });
|
|
513
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
514
|
+
if (hash) scrollToHash(hash);
|
|
515
|
+
else if (options?.scroll !== false) window.scrollTo(0, 0);
|
|
516
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
517
|
+
return true;
|
|
518
|
+
},
|
|
519
|
+
replace: async (url, as, options) => {
|
|
520
|
+
let resolved = resolveNavigationTarget(url, as, options?.locale);
|
|
521
|
+
if (isExternalUrl(resolved)) {
|
|
522
|
+
const localPath = toSameOriginAppPath(resolved, __basePath);
|
|
523
|
+
if (localPath == null) {
|
|
524
|
+
window.location.replace(resolved);
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
resolved = localPath;
|
|
528
|
+
}
|
|
529
|
+
const full = toBrowserNavigationHref(resolved, window.location.href, __basePath);
|
|
530
|
+
if (isHashOnlyChange(resolved)) {
|
|
531
|
+
const eventUrl = resolveHashUrl(resolved);
|
|
532
|
+
routerEvents.emit("hashChangeStart", eventUrl, { shallow: options?.shallow ?? false });
|
|
533
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
534
|
+
window.history.replaceState({}, "", resolved.startsWith("#") ? resolved : full);
|
|
535
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
536
|
+
scrollToHash(hash);
|
|
537
|
+
routerEvents.emit("hashChangeComplete", eventUrl, { shallow: options?.shallow ?? false });
|
|
538
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
routerEvents.emit("routeChangeStart", resolved, { shallow: options?.shallow ?? false });
|
|
542
|
+
routerEvents.emit("beforeHistoryChange", resolved, { shallow: options?.shallow ?? false });
|
|
543
|
+
window.history.replaceState({}, "", full);
|
|
544
|
+
_lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
545
|
+
if (!options?.shallow) await navigateClient(full);
|
|
546
|
+
routerEvents.emit("routeChangeComplete", resolved, { shallow: options?.shallow ?? false });
|
|
547
|
+
const hash = resolved.includes("#") ? resolved.slice(resolved.indexOf("#")) : "";
|
|
548
|
+
if (hash) scrollToHash(hash);
|
|
549
|
+
else if (options?.scroll !== false) window.scrollTo(0, 0);
|
|
550
|
+
window.dispatchEvent(new CustomEvent("vinext:navigate"));
|
|
551
|
+
return true;
|
|
552
|
+
},
|
|
553
|
+
back: () => window.history.back(),
|
|
554
|
+
reload: () => window.location.reload(),
|
|
555
|
+
prefetch: async (url) => {
|
|
556
|
+
if (typeof document !== "undefined") {
|
|
557
|
+
const link = document.createElement("link");
|
|
558
|
+
link.rel = "prefetch";
|
|
559
|
+
link.href = url;
|
|
560
|
+
link.as = "document";
|
|
561
|
+
document.head.appendChild(link);
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
beforePopState: (cb) => {
|
|
565
|
+
_beforePopStateCb = cb;
|
|
566
|
+
},
|
|
567
|
+
events: routerEvents
|
|
596
568
|
};
|
|
597
|
-
|
|
569
|
+
//#endregion
|
|
570
|
+
export { _registerRouterStateAccessors, applyNavigationLocale, Router as default, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, wrapWithRouterContext };
|
|
571
|
+
|
|
598
572
|
//# sourceMappingURL=router.js.map
|