@poveste/vendors 0.14.0 → 0.15.0
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/dist/client/b-floating-vue.js +1 -1
- package/dist/client/b-iconify.js +1429 -1416
- package/dist/client/b-pinia.js +1359 -1936
- package/dist/client/b-vue-router.js +787 -502
- package/dist/client/b-vue-use.js +497 -367
- package/dist/client/b-vue.js +1 -1
- package/dist/client/devtools-api.js +6568 -0
- package/dist/client/index.js +178 -162
- package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +17 -72
- package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +7 -12
- package/dist/client/node_modules/@iconify/vue/offline/package.json +2 -2
- package/dist/client/node_modules/@iconify/vue/package.json +13 -16
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +88 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts +32 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts +43 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/package.json +67 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts +89 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts +33 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts +13 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/types.d.mts +44 -0
- package/dist/client/node_modules/@jridgewell/remapping/package.json +71 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts +15 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/remapping.d.mts +21 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts +46 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/source-map.d.mts +19 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/types.d.mts +16 -0
- package/dist/client/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts +4 -0
- package/dist/client/node_modules/@jridgewell/resolve-uri/package.json +69 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/package.json +67 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts +33 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts +4 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts +9 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts +4 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/sort.d.mts +4 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts +17 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts +5 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts +80 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/types.d.mts +107 -0
- package/dist/client/node_modules/@vue/devtools-api/dist/index-node.d.ts +11 -0
- package/dist/client/node_modules/@vue/devtools-api/dist/index.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-api/package.json +25 -24
- package/dist/client/node_modules/@vue/devtools-kit/dist/index.d.ts +1170 -0
- package/dist/client/node_modules/@vue/devtools-kit/global.d.ts +20 -0
- package/dist/client/node_modules/@vue/devtools-kit/package.json +44 -0
- package/dist/client/node_modules/@vue/devtools-kit/types.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-shared/dist/index.d.ts +40 -0
- package/dist/client/node_modules/@vue/devtools-shared/package.json +33 -0
- package/dist/client/node_modules/@vue-macros/common/dist/index.d.ts +124 -0
- package/dist/client/node_modules/@vue-macros/common/package.json +63 -0
- package/dist/client/node_modules/@vueuse/core/dist/index.d.ts +223 -111
- package/dist/client/node_modules/@vueuse/core/package.json +10 -3
- package/dist/client/node_modules/@vueuse/metadata/package.json +4 -1
- package/dist/client/node_modules/@vueuse/shared/dist/index.d.ts +2 -2
- package/dist/client/node_modules/@vueuse/shared/package.json +4 -1
- package/dist/client/node_modules/acorn/dist/acorn.d.mts +897 -0
- package/dist/client/node_modules/acorn/dist/acorn.d.ts +897 -0
- package/dist/client/node_modules/acorn/package.json +50 -0
- package/dist/client/node_modules/ast-kit/dist/index.d.ts +380 -0
- package/dist/client/node_modules/ast-kit/package.json +63 -0
- package/dist/client/node_modules/ast-walker-scope/dist/index.d.mts +51 -0
- package/dist/client/node_modules/ast-walker-scope/package.json +60 -0
- package/dist/client/node_modules/birpc/dist/index.d.mts +215 -0
- package/dist/client/node_modules/birpc/dist/index.d.ts +215 -0
- package/dist/client/node_modules/birpc/package.json +57 -0
- package/dist/client/node_modules/chokidar/handler.d.ts +90 -0
- package/dist/client/node_modules/chokidar/index.d.ts +217 -0
- package/dist/client/node_modules/chokidar/package.json +63 -0
- package/dist/client/node_modules/confbox/dist/_chunks/_format.d.mts +25 -0
- package/dist/client/node_modules/confbox/dist/index.d.mts +34 -0
- package/dist/client/node_modules/confbox/dist/ini.d.mts +62 -0
- package/dist/client/node_modules/confbox/dist/json5.d.mts +59 -0
- package/dist/client/node_modules/confbox/dist/jsonc.d.mts +41 -0
- package/dist/client/node_modules/confbox/dist/toml.d.mts +23 -0
- package/dist/client/node_modules/confbox/dist/yaml.d.mts +96 -0
- package/dist/client/node_modules/confbox/package.json +67 -0
- package/dist/client/node_modules/exsolve/dist/index.d.mts +66 -0
- package/dist/client/node_modules/exsolve/package.json +42 -0
- package/dist/client/node_modules/fdir/dist/index.d.mts +155 -0
- package/dist/client/node_modules/fdir/package.json +103 -0
- package/dist/client/node_modules/hookable/dist/index.d.ts +103 -0
- package/dist/client/node_modules/hookable/package.json +49 -0
- package/dist/client/node_modules/local-pkg/dist/index.d.mts +42 -0
- package/dist/client/node_modules/local-pkg/dist/index.d.ts +42 -0
- package/dist/client/node_modules/local-pkg/package.json +65 -0
- package/dist/client/node_modules/magic-string-ast/dist/index.d.ts +67 -0
- package/dist/client/node_modules/magic-string-ast/package.json +64 -0
- package/dist/client/node_modules/mlly/dist/index.d.mts +564 -0
- package/dist/client/node_modules/mlly/dist/index.d.ts +564 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/index.d.mts +32 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/index.d.ts +32 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/json5.d.mts +58 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/json5.d.ts +58 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/jsonc.d.mts +41 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/jsonc.d.ts +41 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/shared/confbox.9745c98f.d.mts +24 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/shared/confbox.9745c98f.d.ts +24 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/toml.d.mts +22 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/toml.d.ts +22 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/yaml.d.mts +95 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/yaml.d.ts +95 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/json5.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/jsonc.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/package.json +86 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/toml.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/yaml.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/pkg-types/dist/index.d.mts +411 -0
- package/dist/client/node_modules/mlly/node_modules/pkg-types/dist/index.d.ts +411 -0
- package/dist/client/node_modules/mlly/node_modules/pkg-types/package.json +47 -0
- package/dist/client/node_modules/mlly/package.json +55 -0
- package/dist/client/node_modules/muggle-string/out/base.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/basic.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/binarySearch.d.ts +1 -0
- package/dist/client/node_modules/muggle-string/out/common.d.ts +9 -0
- package/dist/client/node_modules/muggle-string/out/getLength.d.ts +2 -0
- package/dist/client/node_modules/muggle-string/out/index.d.ts +10 -0
- package/dist/client/node_modules/muggle-string/out/map.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/overwriteSource.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/replace.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/segment.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/sourceBased.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/toString.d.ts +2 -0
- package/dist/client/node_modules/muggle-string/out/track.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/types.d.ts +16 -0
- package/dist/client/node_modules/muggle-string/package.json +22 -0
- package/dist/client/node_modules/nostics/dist/diagnostic-wduO7saY.d.mts +295 -0
- package/dist/client/node_modules/nostics/dist/formatters/ansi.d.mts +15 -0
- package/dist/client/node_modules/nostics/dist/formatters/json.d.mts +7 -0
- package/dist/client/node_modules/nostics/dist/index.d.mts +51 -0
- package/dist/client/node_modules/nostics/dist/reporters/dev.d.mts +13 -0
- package/dist/client/node_modules/nostics/dist/reporters/fetch.d.mts +11 -0
- package/dist/client/node_modules/nostics/dist/reporters/node.d.mts +43 -0
- package/dist/client/node_modules/nostics/package.json +125 -0
- package/dist/client/node_modules/pathe/dist/index.d.mts +47 -0
- package/dist/client/node_modules/pathe/dist/index.d.ts +47 -0
- package/dist/client/node_modules/pathe/dist/utils.d.mts +32 -0
- package/dist/client/node_modules/pathe/dist/utils.d.ts +32 -0
- package/dist/client/node_modules/pathe/package.json +61 -0
- package/dist/client/node_modules/pathe/utils.d.ts +1 -0
- package/dist/client/node_modules/perfect-debounce/dist/index.d.mts +49 -0
- package/dist/client/node_modules/perfect-debounce/package.json +41 -0
- package/dist/client/node_modules/picomatch/package.json +83 -0
- package/dist/client/node_modules/pinia/dist/pinia.d.ts +937 -1056
- package/dist/client/node_modules/pinia/package.json +53 -67
- package/dist/client/node_modules/pkg-types/dist/index.d.mts +695 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/_chunks/_format.d.mts +22 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/_chunks/libs/js-yaml.d.mts +33 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/index.d.mts +7 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/ini.d.mts +59 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/json.d.mts +25 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/json5.d.mts +55 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/jsonc.d.mts +29 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/toml.d.mts +20 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/yaml.d.mts +101 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/package.json +68 -0
- package/dist/client/node_modules/pkg-types/package.json +47 -0
- package/dist/client/node_modules/quansync/dist/index.d.mts +22 -0
- package/dist/client/node_modules/quansync/dist/index.d.ts +22 -0
- package/dist/client/node_modules/quansync/dist/macro.d.mts +18 -0
- package/dist/client/node_modules/quansync/dist/macro.d.ts +18 -0
- package/dist/client/node_modules/quansync/dist/types.d.mts +27 -0
- package/dist/client/node_modules/quansync/dist/types.d.ts +27 -0
- package/dist/client/node_modules/quansync/package.json +95 -0
- package/dist/client/node_modules/readdirp/index.d.ts +117 -0
- package/dist/client/node_modules/readdirp/package.json +62 -0
- package/dist/client/node_modules/scule/dist/index.d.mts +57 -0
- package/dist/client/node_modules/scule/dist/index.d.ts +57 -0
- package/dist/client/node_modules/scule/package.json +43 -0
- package/dist/client/node_modules/tinyglobby/dist/index.d.mts +148 -0
- package/dist/client/node_modules/tinyglobby/package.json +70 -0
- package/dist/client/node_modules/ufo/dist/index.d.mts +714 -0
- package/dist/client/node_modules/ufo/dist/index.d.ts +714 -0
- package/dist/client/node_modules/ufo/package.json +48 -0
- package/dist/client/node_modules/unplugin/dist/index.d.mts +241 -0
- package/dist/client/node_modules/unplugin/dist/rspack/loaders/load.d.mts +4 -0
- package/dist/client/node_modules/unplugin/dist/rspack/loaders/transform.d.mts +4 -0
- package/dist/client/node_modules/unplugin/dist/webpack/loaders/load.d.mts +4 -0
- package/dist/client/node_modules/unplugin/dist/webpack/loaders/transform.d.mts +4 -0
- package/dist/client/node_modules/unplugin/package.json +146 -0
- package/dist/client/node_modules/unplugin-utils/dist/index.d.ts +31 -0
- package/dist/client/node_modules/unplugin-utils/package.json +61 -0
- package/dist/client/node_modules/vue-router/dist/experimental/index.d.ts +7 -0
- package/dist/client/node_modules/vue-router/dist/experimental/pinia-colada.d.ts +151 -0
- package/dist/client/node_modules/vue-router/dist/{router-CWoNjPRp.d.mts → index-D7ja2BKs.d.ts} +2480 -1160
- package/dist/client/node_modules/vue-router/dist/options-CwYZKRl4.d.mts +2923 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/esbuild.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/index.d.mts +62 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/options.d.mts +7 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/rolldown.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/rollup.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/types.d.mts +7 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/vite.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/webpack.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +7 -0
- package/dist/client/node_modules/vue-router/package.json +153 -95
- package/dist/client/node_modules/vue-router/vue-router-auto-resolver.d.mts +22 -17
- package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.mts +53 -0
- package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +2 -1
- package/dist/client/node_modules/webpack-virtual-modules/lib/index.d.ts +15 -0
- package/dist/client/node_modules/webpack-virtual-modules/lib/virtual-stats.d.ts +11 -0
- package/dist/client/node_modules/webpack-virtual-modules/package.json +82 -0
- package/dist/client/vue.runtime.esm-bundler.js +1 -176
- package/package.json +8 -7
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts +0 -108
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts +0 -1
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts +0 -78
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts +0 -5
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts +0 -180
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts +0 -6
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts +0 -4
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/const.d.ts +0 -2
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/env.d.ts +0 -15
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/index.d.ts +0 -18
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts +0 -47
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts +0 -20
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/time.d.ts +0 -2
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +0 -22
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
- package/dist/client/node_modules/pinia/node_modules/vue-demi/package.json +0 -47
- package/dist/client/node_modules/vue-router/dist/experimental/index.d.mts +0 -38
- package/dist/client/node_modules/vue-router/dist/vue-router.d.mts +0 -361
- package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.ts +0 -4
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { defineDiagnostics, createConsoleReporter } from './index.js';
|
|
2
|
+
import { inject, onUnmounted, onDeactivated, onActivated, getCurrentInstance, watch, computed, unref, watchEffect, defineComponent, reactive, h, provide, ref, shallowRef, nextTick, shallowReactive } from './vue.runtime.esm-bundler.js';
|
|
3
|
+
import { setupDevToolsPlugin } from './devtools-api.js';
|
|
3
4
|
|
|
4
5
|
/*!
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//#region src/utils/env.ts
|
|
11
|
-
const isBrowser = typeof document !== "undefined";
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
6
|
+
* vue-router v5.3.1
|
|
7
|
+
* (c) 2026 Eduardo San Martin Morote
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/
|
|
14
10
|
//#region src/utils/index.ts
|
|
15
11
|
/**
|
|
16
12
|
* Identity function that returns the value as is.
|
|
@@ -21,6 +17,14 @@ const isBrowser = typeof document !== "undefined";
|
|
|
21
17
|
*/
|
|
22
18
|
const identityFn = (v) => v;
|
|
23
19
|
/**
|
|
20
|
+
* Checks if a path is absolute, meaning it starts with a `/`.
|
|
21
|
+
*
|
|
22
|
+
* @param path - path to check
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
const isAbsolutePath = (path) => path.startsWith("/");
|
|
27
|
+
/**
|
|
24
28
|
* Allows differentiating lazy components from functional components and vue-class-component
|
|
25
29
|
* @internal
|
|
26
30
|
*
|
|
@@ -54,14 +58,398 @@ function mergeOptions(defaults, partialOptions) {
|
|
|
54
58
|
for (const key in defaults) options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
|
|
55
59
|
return options;
|
|
56
60
|
}
|
|
57
|
-
|
|
58
61
|
//#endregion
|
|
59
|
-
//#region src/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
//#region src/errors.ts
|
|
63
|
+
const NavigationFailureSymbol = Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
|
|
64
|
+
/**
|
|
65
|
+
* Enumeration with all possible types for navigation failures. Can be passed to
|
|
66
|
+
* {@link isNavigationFailure} to check for specific failures.
|
|
67
|
+
*/
|
|
68
|
+
let NavigationFailureType = /* @__PURE__ */ function(NavigationFailureType) {
|
|
69
|
+
/**
|
|
70
|
+
* An aborted navigation is a navigation that failed because a navigation
|
|
71
|
+
* guard returned `false` or called `next(false)`
|
|
72
|
+
*/
|
|
73
|
+
NavigationFailureType[NavigationFailureType["aborted"] = 4] = "aborted";
|
|
74
|
+
/**
|
|
75
|
+
* A cancelled navigation is a navigation that failed because a more recent
|
|
76
|
+
* navigation finished started (not necessarily finished).
|
|
77
|
+
*/
|
|
78
|
+
NavigationFailureType[NavigationFailureType["cancelled"] = 8] = "cancelled";
|
|
79
|
+
/**
|
|
80
|
+
* A duplicated navigation is a navigation that failed because it was
|
|
81
|
+
* initiated while already being at the exact same location.
|
|
82
|
+
*/
|
|
83
|
+
NavigationFailureType[NavigationFailureType["duplicated"] = 16] = "duplicated";
|
|
84
|
+
return NavigationFailureType;
|
|
85
|
+
}({});
|
|
86
|
+
const ErrorTypeMessages = {
|
|
87
|
+
[1]({ location, currentLocation }) {
|
|
88
|
+
return `No match for\n ${JSON.stringify(location)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
|
|
89
|
+
},
|
|
90
|
+
[2]({ from, to }) {
|
|
91
|
+
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
|
|
92
|
+
},
|
|
93
|
+
[4]({ from, to }) {
|
|
94
|
+
return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
|
|
95
|
+
},
|
|
96
|
+
[8]({ from, to }) {
|
|
97
|
+
return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
|
|
98
|
+
},
|
|
99
|
+
[16]({ from, to: _to }) {
|
|
100
|
+
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Creates a typed NavigationFailure object.
|
|
105
|
+
* @internal
|
|
106
|
+
* @param type - NavigationFailureType
|
|
107
|
+
* @param params - { from, to }
|
|
108
|
+
*/
|
|
109
|
+
function createRouterError(type, params) {
|
|
110
|
+
if (process.env.NODE_ENV !== "production" || false) return assign(new Error(ErrorTypeMessages[type](params)), {
|
|
111
|
+
type,
|
|
112
|
+
[NavigationFailureSymbol]: true
|
|
113
|
+
}, params);
|
|
114
|
+
else return assign(/* @__PURE__ */ new Error(), {
|
|
115
|
+
type,
|
|
116
|
+
[NavigationFailureSymbol]: true
|
|
117
|
+
}, params);
|
|
118
|
+
}
|
|
119
|
+
function isNavigationFailure(error, type) {
|
|
120
|
+
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
|
|
121
|
+
}
|
|
122
|
+
const propertiesToLog = [
|
|
123
|
+
"params",
|
|
124
|
+
"query",
|
|
125
|
+
"hash"
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* Stringifies a raw location for display in dev warnings.
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
function stringifyRoute(to) {
|
|
133
|
+
if (!to || typeof to === "string") return to;
|
|
134
|
+
if (to.path != null) return to.path;
|
|
135
|
+
const location = {};
|
|
136
|
+
for (const key of propertiesToLog) if (key in to) location[key] = to[key];
|
|
137
|
+
return JSON.stringify(location, null, 2);
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/diagnostics.ts
|
|
141
|
+
/**
|
|
142
|
+
* Runtime diagnostics catalog for Vue Router.
|
|
143
|
+
*
|
|
144
|
+
* Every entry has a stable `VUE_ROUTER_R####` code, a `why` that states the problem
|
|
145
|
+
* (the diagnosis only, never the remedy) and a `fix` that states the remedy
|
|
146
|
+
* (only, never the diagnosis). They are complementary: the reporter prints
|
|
147
|
+
* both, so neither repeats the other. The diagnosis substrings asserted by the
|
|
148
|
+
* warning tests stay in `why`. All call sites stay behind the existing `__DEV__` (or
|
|
149
|
+
* `process.env.NODE_ENV !== 'production'`) guards and remain bare expression
|
|
150
|
+
* statements so they tree-shake out of production builds.
|
|
151
|
+
*
|
|
152
|
+
* Codes are permanent: never rename or reuse one.
|
|
153
|
+
* - `VUE_ROUTER_R0###` core runtime warnings
|
|
154
|
+
* - `VUE_ROUTER_R1###` experimental data-loaders
|
|
155
|
+
*/
|
|
156
|
+
const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
157
|
+
reporters: [/*#__PURE__*/ createConsoleReporter()],
|
|
158
|
+
codes: {
|
|
159
|
+
VUE_ROUTER_R0001: {
|
|
160
|
+
why: (p) => `Parent route "${p.name}" not found when adding child route`,
|
|
161
|
+
fix: "Add the parent route before its children, or check the parent name for typos.",
|
|
162
|
+
docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Adding-nested-routes"
|
|
163
|
+
},
|
|
164
|
+
VUE_ROUTER_R0002: {
|
|
165
|
+
why: (p) => `Cannot remove non-existent route "${p.name}"`,
|
|
166
|
+
fix: "Check the route name; it may already have been removed or was never added.",
|
|
167
|
+
docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Removing-routes"
|
|
168
|
+
},
|
|
169
|
+
VUE_ROUTER_R0003: {
|
|
170
|
+
why: (p) => `Location "${stringifyRoute(p.location)}" resolved to "${p.href}". A resolved location cannot start with multiple slashes.`,
|
|
171
|
+
fix: "Remove the leading slashes from the location or fix the route configuration."
|
|
172
|
+
},
|
|
173
|
+
VUE_ROUTER_R0004: {
|
|
174
|
+
why: (p) => `No match found for location with path "${stringifyRoute(p.path)}"`,
|
|
175
|
+
fix: "Add a route matching this path or check for typos in the location.",
|
|
176
|
+
docs: "https://router.vuejs.org/guide/essentials/dynamic-matching.html#Catch-all-404-Not-found-Route"
|
|
177
|
+
},
|
|
178
|
+
VUE_ROUTER_R0005: {
|
|
179
|
+
why: (p) => `router.resolve() was passed an invalid location. This will fail in production.\nLocation: ${stringifyRoute(p.rawLocation)}`,
|
|
180
|
+
fix: "Pass a valid route location: a string path or an object with `path` or `name`."
|
|
181
|
+
},
|
|
182
|
+
VUE_ROUTER_R0006: {
|
|
183
|
+
why: (p) => `Path "${p.path}" was passed with params but they will be ignored because a "path" was passed.`,
|
|
184
|
+
fix: "Use a named route `{ name, params }` instead of `{ path, params }`.",
|
|
185
|
+
docs: "https://router.vuejs.org/guide/essentials/navigation.html#Navigate-to-a-different-location"
|
|
186
|
+
},
|
|
187
|
+
VUE_ROUTER_R0007: {
|
|
188
|
+
why: (p) => `A \`hash\` should always start with the character "#" but received "${p.hash}".`,
|
|
189
|
+
fix: (p) => `Prepend "#" to the hash in your route location: use "#${p.hash}".`
|
|
190
|
+
},
|
|
191
|
+
VUE_ROUTER_R0008: {
|
|
192
|
+
why: (p) => `Invalid redirect found:\n${p.target}\n when navigating to "${p.to}".\nThis will break in production.`,
|
|
193
|
+
fix: "A redirect must resolve to a location with a `name` or `path`; return one of those (or a string path) from `redirect`.",
|
|
194
|
+
docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Redirect"
|
|
195
|
+
},
|
|
196
|
+
VUE_ROUTER_R0009: {
|
|
197
|
+
why: (p) => `Detected a possibly infinite redirection in a navigation guard when going from "${p.from}" to "${p.to}". Aborting to avoid a Stack Overflow. This might break in production if not fixed.`,
|
|
198
|
+
fix: "A guard is returning a new location on every call; make that return conditional so it only redirects when actually needed.",
|
|
199
|
+
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Global-Before-Guards"
|
|
200
|
+
},
|
|
201
|
+
VUE_ROUTER_R0010: {
|
|
202
|
+
why: "Uncaught error during route navigation",
|
|
203
|
+
fix: "Register an error handler with `router.onError()` to handle navigation errors."
|
|
204
|
+
},
|
|
205
|
+
VUE_ROUTER_R0011: {
|
|
206
|
+
why: "Unexpected error when starting the router:",
|
|
207
|
+
fix: "Inspect the actual cause; a navigation guard or async component likely threw during the initial navigation."
|
|
208
|
+
},
|
|
209
|
+
VUE_ROUTER_R0020: {
|
|
210
|
+
why: (p) => `No active route record was found when calling \`${p.fn}()\`. Maybe you called it inside of App.vue?`,
|
|
211
|
+
fix: "Call it from a component rendered inside <router-view> (a page component or one of its children), not from App.vue.",
|
|
212
|
+
docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
|
|
213
|
+
},
|
|
214
|
+
VUE_ROUTER_R0021: {
|
|
215
|
+
why: "No active route record was found when reactivating component with navigation guard. This is likely a bug in vue-router.",
|
|
216
|
+
fix: "Report with a minimal reproduction at https://github.com/vuejs/router/issues/new/choose."
|
|
217
|
+
},
|
|
218
|
+
VUE_ROUTER_R0022: {
|
|
219
|
+
why: (p) => `${p.fn}() was called outside of component setup but it must be called at the top of a setup function`,
|
|
220
|
+
fix: "Call it synchronously at the top of `setup()`, before any `await`.",
|
|
221
|
+
docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
|
|
222
|
+
},
|
|
223
|
+
VUE_ROUTER_R0023: {
|
|
224
|
+
why: (p) => `The "next" callback was never called inside of ${p.name ? `"${p.name}"` : ""}:\n${p.guard}`,
|
|
225
|
+
fix: "Make sure `next()` runs on every branch, including early returns and async paths, or drop the `next` parameter and return the value instead.",
|
|
226
|
+
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
|
227
|
+
},
|
|
228
|
+
VUE_ROUTER_R0024: {
|
|
229
|
+
why: (p) => `The "next" callback was called more than once in one navigation guard when going from "${p.from}" to "${p.to}". This will fail in production.`,
|
|
230
|
+
fix: "Call `next()` exactly once per guard: remove the extra call, or migrate to returning the value you passed to `next()`.",
|
|
231
|
+
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
|
232
|
+
},
|
|
233
|
+
VUE_ROUTER_R0025: {
|
|
234
|
+
why: "The `next()` callback in navigation guards is deprecated.",
|
|
235
|
+
fix: "Return the value instead: `next()` becomes `return`, `next(false)` becomes `return false`, `next(\"/path\")` becomes `return \"/path\"`.",
|
|
236
|
+
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
|
237
|
+
},
|
|
238
|
+
VUE_ROUTER_R0026: {
|
|
239
|
+
why: (p) => `Record with path "${p.path}" is either missing a "component(s)" or "children" property.`,
|
|
240
|
+
fix: "Add a `component`, `components`, or `children` to the route record.",
|
|
241
|
+
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
|
|
242
|
+
},
|
|
243
|
+
VUE_ROUTER_R0027: {
|
|
244
|
+
why: (p) => `Component "${p.name}" in record with path "${p.path}" is not a valid component. Received "${p.received}".`,
|
|
245
|
+
fix: "Pass a component or a function returning a Promise that resolves to one."
|
|
246
|
+
},
|
|
247
|
+
VUE_ROUTER_R0028: {
|
|
248
|
+
why: (p) => `Component "${p.name}" in record with path "${p.path}" is a Promise instead of a function that returns a Promise. This will break in production if not fixed.`,
|
|
249
|
+
fix: `Defer the import in an arrow function so it loads lazily: write "() => import('./MyPage.vue')", not "import('./MyPage.vue')".`,
|
|
250
|
+
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
|
|
251
|
+
},
|
|
252
|
+
VUE_ROUTER_R0029: {
|
|
253
|
+
why: (p) => `Component "${p.name}" in record with path "${p.path}" is defined using "defineAsyncComponent()".`,
|
|
254
|
+
fix: `Drop the wrapper and pass "() => import('./MyPage.vue')" directly; the router handles lazy components itself.`,
|
|
255
|
+
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html#Relationship-to-async-components"
|
|
256
|
+
},
|
|
257
|
+
VUE_ROUTER_R0030: {
|
|
258
|
+
why: (p) => `Component "${p.name}" in record with path "${p.path}" is a function that does not return a Promise. This will break in production if not fixed.`,
|
|
259
|
+
fix: "Return a dynamic import (`() => import(\"./MyPage.vue\")`) from the function, or add a `displayName` if it is a functional component.",
|
|
260
|
+
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
|
|
261
|
+
},
|
|
262
|
+
VUE_ROUTER_R0040: {
|
|
263
|
+
why: (p) => `Because "${p.el}" starts with "#", scrollBehavior resolves it as an element id via document.getElementById("${p.el.slice(1)}"), not as a CSS selector. No element has that id, but "${p.el}" does match an element with document.querySelector().`,
|
|
264
|
+
fix: (p) => `Resolve the element yourself and return the node: el: document.querySelector('${p.el}').`,
|
|
265
|
+
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
|
266
|
+
},
|
|
267
|
+
VUE_ROUTER_R0041: {
|
|
268
|
+
why: (p) => `The selector "${p.el}" is invalid. See https://mathiasbynens.be/notes/css-escapes or CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape) for the escaping rules.`,
|
|
269
|
+
fix: "Build an id selector as `#${CSS.escape(id)}` so special characters in the id are escaped.",
|
|
270
|
+
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
|
271
|
+
},
|
|
272
|
+
VUE_ROUTER_R0042: {
|
|
273
|
+
why: (p) => `Couldn't find element using selector "${p.el}" returned by scrollBehavior.`,
|
|
274
|
+
fix: "Return a selector that matches an existing element, or guard against missing elements.",
|
|
275
|
+
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
|
276
|
+
},
|
|
277
|
+
VUE_ROUTER_R0050: {
|
|
278
|
+
why: (p) => {
|
|
279
|
+
let to;
|
|
280
|
+
try {
|
|
281
|
+
to = p.to === void 0 ? "undefined" : JSON.stringify(p.to);
|
|
282
|
+
} catch {
|
|
283
|
+
to = String(p.to);
|
|
284
|
+
}
|
|
285
|
+
return `Invalid value for prop "to" in useLink()\n- to: ${to}`;
|
|
286
|
+
},
|
|
287
|
+
fix: "Pass a valid route location (a string path or an object) to the \"to\" prop."
|
|
288
|
+
},
|
|
289
|
+
VUE_ROUTER_R0060: {
|
|
290
|
+
why: (p) => `<router-view> can no longer be used directly inside <${p.comp}>.`,
|
|
291
|
+
fix: (p) => `Wrap the slot's resolved component with <${p.comp}> instead of nesting <router-view> in it:\n\n<router-view v-slot="{ Component }">\n <${p.comp}>\n <component :is="Component" />\n </${p.comp}>\n</router-view>`,
|
|
292
|
+
docs: "https://router.vuejs.org/guide/advanced/router-view-slot.html#KeepAlive-Transition"
|
|
293
|
+
},
|
|
294
|
+
VUE_ROUTER_R0070: {
|
|
295
|
+
why: (p) => `Cannot resolve a relative location without an absolute path. Trying to resolve "${p.to}" from "${p.from}".`,
|
|
296
|
+
fix: (p) => `Resolve from an absolute \`from\` path that starts with "/", e.g. "/${p.from}".`
|
|
297
|
+
},
|
|
298
|
+
VUE_ROUTER_R0080: {
|
|
299
|
+
why: (p) => `Error decoding "${p.text}". Using original value`,
|
|
300
|
+
fix: "Ensure the value is correctly percent-encoded."
|
|
301
|
+
},
|
|
302
|
+
VUE_ROUTER_R0090: {
|
|
303
|
+
why: (p) => `Found duplicated params with name "${p.name}" for path "${p.path}". Only the last one will be available on "$route.params".`,
|
|
304
|
+
fix: "Give each param a unique name within the path.",
|
|
305
|
+
docs: "https://router.vuejs.org/guide/essentials/route-matching-syntax.html"
|
|
306
|
+
},
|
|
307
|
+
VUE_ROUTER_R0100: {
|
|
308
|
+
why: (p) => `Discarded invalid param(s) "${p.params}" when navigating.` + p.inherited + ` See https://github.com/vuejs/router/commit/e887570 for more details.`,
|
|
309
|
+
fix: "Only pass params that exist on the target route."
|
|
310
|
+
},
|
|
311
|
+
VUE_ROUTER_R0101: {
|
|
312
|
+
why: (p) => `The Matcher cannot resolve relative paths but received "${p.path}". Unless you directly called \`matcher.resolve("${p.path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`,
|
|
313
|
+
fix: "Pass an absolute path (starting with \"/\") to the matcher."
|
|
314
|
+
},
|
|
315
|
+
VUE_ROUTER_R0102: {
|
|
316
|
+
why: (p) => `Alias "${p.alias}" and the original record: "${p.original}" must have the exact same param named "${p.name}"`,
|
|
317
|
+
fix: "Use the same param names in the alias as in the original route.",
|
|
318
|
+
docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Alias"
|
|
319
|
+
},
|
|
320
|
+
VUE_ROUTER_R0103: {
|
|
321
|
+
why: (p) => `The route named "${p.name}" has a child without a name, an empty path, and no children. Using that name won't render the empty path child, so this is probably a mistake.`,
|
|
322
|
+
fix: "Move the `name` onto the empty-path child; or, if intentional, give the child its own name to silence this.",
|
|
323
|
+
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html#Nested-Named-Routes"
|
|
324
|
+
},
|
|
325
|
+
VUE_ROUTER_R0104: {
|
|
326
|
+
why: (p) => `Absolute path "${p.path}" must have the exact same param named "${p.name}" as its parent "${p.parent}".`,
|
|
327
|
+
fix: "Include the parent route params in the absolute child path.",
|
|
328
|
+
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
|
|
329
|
+
},
|
|
330
|
+
VUE_ROUTER_R0105: {
|
|
331
|
+
why: (p) => `Finding ancestor route "${p.ancestor}" failed for "${p.record}"`,
|
|
332
|
+
fix: "Report a reproduction at https://github.com/vuejs/router/issues/new/choose."
|
|
333
|
+
},
|
|
334
|
+
VUE_ROUTER_R0110: {
|
|
335
|
+
why: `A hash base must end with a "#"`,
|
|
336
|
+
fix: (p) => `Append "#" to the "base" argument passed to "createWebHashHistory()": "${p.base}" should be "${p.suggestion}".`
|
|
337
|
+
},
|
|
338
|
+
VUE_ROUTER_R0120: {
|
|
339
|
+
why: "Error with push/replace State",
|
|
340
|
+
fix: "The browser rejected the history API call; check for cross-origin or rate-limit issues."
|
|
341
|
+
},
|
|
342
|
+
VUE_ROUTER_R0121: {
|
|
343
|
+
why: "history.state seems to have been manually replaced without preserving the necessary values.\nYou can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state",
|
|
344
|
+
fix: "Merge the router's state into your own when calling it manually: `history.replaceState({ ...history.state, ...yourState }, '', url)`.",
|
|
345
|
+
docs: "https://router.vuejs.org/guide/migration.html#Usage-of-history-state"
|
|
346
|
+
},
|
|
347
|
+
VUE_ROUTER_R1001: {
|
|
348
|
+
why: (p) => `Data loader "${String(p.key)}" has a different parent than the current context. This shouldn't be happening.`,
|
|
349
|
+
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
|
350
|
+
},
|
|
351
|
+
VUE_ROUTER_R1002: {
|
|
352
|
+
why: "Returning a NavigationResult is deprecated.",
|
|
353
|
+
fix: "Replace `return new NavigationResult(to)` with `reroute(to)`, which throws internally to reroute.",
|
|
354
|
+
docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
|
|
355
|
+
},
|
|
356
|
+
VUE_ROUTER_R1003: {
|
|
357
|
+
why: (p) => `Loader "${p.key}"'s "commit()" was called but there is no staged data.`,
|
|
358
|
+
fix: "Ensure the loader resolved before calling `commit()`.",
|
|
359
|
+
docs: "https://router.vuejs.org/data-loaders/defining-loaders.html#Delaying-data-updates-with-commit"
|
|
360
|
+
},
|
|
361
|
+
VUE_ROUTER_R1004: {
|
|
362
|
+
why: (p) => "A loader returned a NavigationResult but is not registered on the route." + p.key,
|
|
363
|
+
fix: "Export the loader from the page component so it gets registered, e.g. `export const useUserData = defineLoader(...)`.",
|
|
364
|
+
docs: "https://router.vuejs.org/data-loaders/organization.html"
|
|
365
|
+
},
|
|
366
|
+
VUE_ROUTER_R1005: {
|
|
367
|
+
why: (p) => `Data loader "${p.key}" has itself as parent. This shouldn't be happening.`,
|
|
368
|
+
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
|
369
|
+
},
|
|
370
|
+
VUE_ROUTER_R1006: {
|
|
371
|
+
why: (p) => `A query was defined with the same key as the loader "[${p.key}]".\nSee https://pinia-colada.esm.dev/#TODO`,
|
|
372
|
+
fix: "If the key is meant to match, use the data loader directly; otherwise rename the `useQuery()` key so it no longer collides.",
|
|
373
|
+
docs: "https://router.vuejs.org/data-loaders/colada.html"
|
|
374
|
+
},
|
|
375
|
+
VUE_ROUTER_R1007: {
|
|
376
|
+
why: "Data Loader was setup twice.",
|
|
377
|
+
fix: "Register `DataLoaderPlugin` a single time via `app.use()`.",
|
|
378
|
+
docs: "https://router.vuejs.org/data-loaders.html#Installation"
|
|
379
|
+
},
|
|
380
|
+
VUE_ROUTER_R1008: {
|
|
381
|
+
why: "Data Loader is experimental and subject to breaking changes in the future.",
|
|
382
|
+
docs: "https://router.vuejs.org/data-loaders.html"
|
|
383
|
+
},
|
|
384
|
+
VUE_ROUTER_R1009: {
|
|
385
|
+
why: "Returning a NavigationResult from a loader is deprecated.",
|
|
386
|
+
fix: "Call `reroute(to)` inside the loader instead of returning `new NavigationResult(to)`; it throws internally to reroute.",
|
|
387
|
+
docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/injectionSymbols.ts
|
|
393
|
+
/**
|
|
394
|
+
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
|
395
|
+
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
|
396
|
+
* Location Matched
|
|
397
|
+
*
|
|
398
|
+
* @internal
|
|
399
|
+
*/
|
|
400
|
+
const matchedRouteKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
|
|
401
|
+
/**
|
|
402
|
+
* Allows overriding the router view depth to control which component in
|
|
403
|
+
* `matched` is rendered. rvd stands for Router View Depth
|
|
404
|
+
*
|
|
405
|
+
* @internal
|
|
406
|
+
*/
|
|
407
|
+
const viewDepthKey = Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
|
|
408
|
+
/**
|
|
409
|
+
* Allows overriding the router instance returned by `useRouter` in tests. r
|
|
410
|
+
* stands for router
|
|
411
|
+
*
|
|
412
|
+
* @internal
|
|
413
|
+
*/
|
|
414
|
+
const routerKey = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
|
|
415
|
+
/**
|
|
416
|
+
* Allows overriding the current route returned by `useRoute` in tests. rl
|
|
417
|
+
* stands for route location
|
|
418
|
+
*
|
|
419
|
+
* @internal
|
|
420
|
+
*/
|
|
421
|
+
const routeLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
|
422
|
+
/**
|
|
423
|
+
* Allows overriding the current route used by router-view. Internally this is
|
|
424
|
+
* used when the `route` prop is passed.
|
|
425
|
+
*
|
|
426
|
+
* @internal
|
|
427
|
+
*/
|
|
428
|
+
const routerViewLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/useApi.ts
|
|
431
|
+
/**
|
|
432
|
+
* Returns the router instance. Equivalent to using `$router` inside
|
|
433
|
+
* templates.
|
|
434
|
+
*/
|
|
435
|
+
function useRouter() {
|
|
436
|
+
return inject(routerKey);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Returns the current route location. Equivalent to using `$route` inside
|
|
440
|
+
* templates.
|
|
441
|
+
*/
|
|
442
|
+
function useRoute(_name) {
|
|
443
|
+
return inject(routeLocationKey);
|
|
63
444
|
}
|
|
64
445
|
|
|
446
|
+
/*!
|
|
447
|
+
* vue-router v5.3.1
|
|
448
|
+
* (c) 2026 Eduardo San Martin Morote
|
|
449
|
+
* @license MIT
|
|
450
|
+
*/
|
|
451
|
+
//#region src/utils/env.ts
|
|
452
|
+
const isBrowser = typeof document !== "undefined";
|
|
65
453
|
//#endregion
|
|
66
454
|
//#region src/encoding.ts
|
|
67
455
|
/**
|
|
@@ -172,12 +560,11 @@ function decode(text) {
|
|
|
172
560
|
if (text == null) return null;
|
|
173
561
|
try {
|
|
174
562
|
return decodeURIComponent("" + text);
|
|
175
|
-
} catch
|
|
176
|
-
process.env.NODE_ENV !== "production" &&
|
|
563
|
+
} catch {
|
|
564
|
+
process.env.NODE_ENV !== "production" && diagnostics.VUE_ROUTER_R0080({ text: "" + text });
|
|
177
565
|
}
|
|
178
566
|
return "" + text;
|
|
179
567
|
}
|
|
180
|
-
|
|
181
568
|
//#endregion
|
|
182
569
|
//#region src/location.ts
|
|
183
570
|
const TRAILING_SLASH_RE = /\/$/;
|
|
@@ -191,7 +578,7 @@ const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
|
|
|
191
578
|
* paths. Must start with `/`. Defaults to `/`
|
|
192
579
|
* @returns a normalized history location
|
|
193
580
|
*/
|
|
194
|
-
function parseURL(parseQuery
|
|
581
|
+
function parseURL(parseQuery, location, currentLocation = "/") {
|
|
195
582
|
let path, query = {}, searchString = "", hash = "";
|
|
196
583
|
const hashPos = location.indexOf("#");
|
|
197
584
|
let searchPos = location.indexOf("?");
|
|
@@ -199,7 +586,7 @@ function parseURL(parseQuery$1, location, currentLocation = "/") {
|
|
|
199
586
|
if (searchPos >= 0) {
|
|
200
587
|
path = location.slice(0, searchPos);
|
|
201
588
|
searchString = location.slice(searchPos, hashPos > 0 ? hashPos : location.length);
|
|
202
|
-
query = parseQuery
|
|
589
|
+
query = parseQuery(searchString.slice(1));
|
|
203
590
|
}
|
|
204
591
|
if (hashPos >= 0) {
|
|
205
592
|
path = path || location.slice(0, hashPos);
|
|
@@ -213,8 +600,8 @@ function parseURL(parseQuery$1, location, currentLocation = "/") {
|
|
|
213
600
|
hash: decode(hash)
|
|
214
601
|
};
|
|
215
602
|
}
|
|
216
|
-
function NEW_stringifyURL(stringifyQuery
|
|
217
|
-
const searchText = stringifyQuery
|
|
603
|
+
function NEW_stringifyURL(stringifyQuery, path, query, hash = "") {
|
|
604
|
+
const searchText = stringifyQuery(query);
|
|
218
605
|
return path + (searchText && "?") + searchText + encodeHash(hash);
|
|
219
606
|
}
|
|
220
607
|
/**
|
|
@@ -223,8 +610,8 @@ function NEW_stringifyURL(stringifyQuery$1, path, query, hash = "") {
|
|
|
223
610
|
* @param stringifyQuery
|
|
224
611
|
* @param location
|
|
225
612
|
*/
|
|
226
|
-
function stringifyURL(stringifyQuery
|
|
227
|
-
const query = location.query ? stringifyQuery
|
|
613
|
+
function stringifyURL(stringifyQuery, location) {
|
|
614
|
+
const query = location.query ? stringifyQuery(location.query) : "";
|
|
228
615
|
return location.path + (query && "?") + query + (location.hash || "");
|
|
229
616
|
}
|
|
230
617
|
/**
|
|
@@ -246,10 +633,10 @@ function stripBase(pathname, base) {
|
|
|
246
633
|
* @param a - first {@link RouteLocation}
|
|
247
634
|
* @param b - second {@link RouteLocation}
|
|
248
635
|
*/
|
|
249
|
-
function isSameRouteLocation(stringifyQuery
|
|
636
|
+
function isSameRouteLocation(stringifyQuery, a, b) {
|
|
250
637
|
const aLastIndex = a.matched.length - 1;
|
|
251
638
|
const bLastIndex = b.matched.length - 1;
|
|
252
|
-
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery
|
|
639
|
+
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery(a.query) === stringifyQuery(b.query) && a.hash === b.hash;
|
|
253
640
|
}
|
|
254
641
|
/**
|
|
255
642
|
* Check if two `RouteRecords` are equal. Takes into account aliases: they are
|
|
@@ -267,7 +654,7 @@ function isSameRouteLocationParams(a, b) {
|
|
|
267
654
|
return true;
|
|
268
655
|
}
|
|
269
656
|
function isSameRouteLocationParamsValue(a, b) {
|
|
270
|
-
return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : a
|
|
657
|
+
return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : (a && a.valueOf()) === (b && b.valueOf());
|
|
271
658
|
}
|
|
272
659
|
/**
|
|
273
660
|
* Check if two arrays are the same or if an array with one single entry is the
|
|
@@ -286,9 +673,12 @@ function isEquivalentArray(a, b) {
|
|
|
286
673
|
* @param from - currentLocation.path, should start with `/`
|
|
287
674
|
*/
|
|
288
675
|
function resolveRelativePath(to, from) {
|
|
289
|
-
if (to
|
|
290
|
-
if (process.env.NODE_ENV !== "production" && !from
|
|
291
|
-
|
|
676
|
+
if (isAbsolutePath(to)) return to;
|
|
677
|
+
if (process.env.NODE_ENV !== "production" && !isAbsolutePath(from)) {
|
|
678
|
+
diagnostics.VUE_ROUTER_R0070({
|
|
679
|
+
to,
|
|
680
|
+
from
|
|
681
|
+
});
|
|
292
682
|
return to;
|
|
293
683
|
}
|
|
294
684
|
if (!to) return from;
|
|
@@ -334,24 +724,8 @@ const START_LOCATION_NORMALIZED = {
|
|
|
334
724
|
meta: {},
|
|
335
725
|
redirectedFrom: void 0
|
|
336
726
|
};
|
|
337
|
-
|
|
338
727
|
//#endregion
|
|
339
728
|
//#region src/history/common.ts
|
|
340
|
-
let NavigationType = /* @__PURE__ */ function(NavigationType$1) {
|
|
341
|
-
NavigationType$1["pop"] = "pop";
|
|
342
|
-
NavigationType$1["push"] = "push";
|
|
343
|
-
return NavigationType$1;
|
|
344
|
-
}({});
|
|
345
|
-
let NavigationDirection = /* @__PURE__ */ function(NavigationDirection$1) {
|
|
346
|
-
NavigationDirection$1["back"] = "back";
|
|
347
|
-
NavigationDirection$1["forward"] = "forward";
|
|
348
|
-
NavigationDirection$1["unknown"] = "";
|
|
349
|
-
return NavigationDirection$1;
|
|
350
|
-
}({});
|
|
351
|
-
/**
|
|
352
|
-
* Starting location for Histories
|
|
353
|
-
*/
|
|
354
|
-
const START = "";
|
|
355
729
|
/**
|
|
356
730
|
* Normalizes a base by removing any trailing slash and reading the base tag if
|
|
357
731
|
* present.
|
|
@@ -359,11 +733,13 @@ const START = "";
|
|
|
359
733
|
* @param base - base to normalize
|
|
360
734
|
*/
|
|
361
735
|
function normalizeBase(base) {
|
|
362
|
-
if (!base)
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
736
|
+
if (!base) {
|
|
737
|
+
if (isBrowser) {
|
|
738
|
+
const baseEl = document.querySelector("base");
|
|
739
|
+
base = baseEl && baseEl.getAttribute("href") || "/";
|
|
740
|
+
base = base.replace(/^\w+:\/\/[^/]+/, "");
|
|
741
|
+
} else base = "/";
|
|
742
|
+
}
|
|
367
743
|
if (base[0] !== "/" && base[0] !== "#") base = "/" + base;
|
|
368
744
|
return removeTrailingSlash(base);
|
|
369
745
|
}
|
|
@@ -371,7 +747,6 @@ const BEFORE_HASH_RE = /^[^#]+#/;
|
|
|
371
747
|
function createHref(base, location) {
|
|
372
748
|
return base.replace(BEFORE_HASH_RE, "#") + location;
|
|
373
749
|
}
|
|
374
|
-
|
|
375
750
|
//#endregion
|
|
376
751
|
//#region src/scrollBehavior.ts
|
|
377
752
|
function getElementPosition(el, offset) {
|
|
@@ -383,10 +758,10 @@ function getElementPosition(el, offset) {
|
|
|
383
758
|
top: elRect.top - docRect.top - (offset.top || 0)
|
|
384
759
|
};
|
|
385
760
|
}
|
|
386
|
-
const computeScrollPosition = () =>
|
|
761
|
+
const computeScrollPosition = () => history.scrollRestoration === "manual" ? {
|
|
387
762
|
left: window.scrollX,
|
|
388
763
|
top: window.scrollY
|
|
389
|
-
}
|
|
764
|
+
} : null;
|
|
390
765
|
function scrollToPosition(position) {
|
|
391
766
|
let scrollToOptions;
|
|
392
767
|
if ("el" in position) {
|
|
@@ -417,17 +792,17 @@ function scrollToPosition(position) {
|
|
|
417
792
|
if (!isIdSelector || !document.getElementById(position.el.slice(1))) try {
|
|
418
793
|
const foundEl = document.querySelector(position.el);
|
|
419
794
|
if (isIdSelector && foundEl) {
|
|
420
|
-
|
|
795
|
+
diagnostics.VUE_ROUTER_R0040({ el: position.el });
|
|
421
796
|
return;
|
|
422
797
|
}
|
|
423
|
-
} catch
|
|
424
|
-
|
|
798
|
+
} catch {
|
|
799
|
+
diagnostics.VUE_ROUTER_R0041({ el: position.el });
|
|
425
800
|
return;
|
|
426
801
|
}
|
|
427
802
|
}
|
|
428
803
|
const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
|
|
429
804
|
if (!el) {
|
|
430
|
-
process.env.NODE_ENV !== "production" &&
|
|
805
|
+
process.env.NODE_ENV !== "production" && diagnostics.VUE_ROUTER_R0042({ el: position.el });
|
|
431
806
|
return;
|
|
432
807
|
}
|
|
433
808
|
scrollToOptions = getElementPosition(el, position);
|
|
@@ -439,8 +814,8 @@ function getScrollKey(path, delta) {
|
|
|
439
814
|
return (history.state ? history.state.position - delta : -1) + path;
|
|
440
815
|
}
|
|
441
816
|
const scrollPositions = /* @__PURE__ */ new Map();
|
|
442
|
-
function saveScrollPosition(key
|
|
443
|
-
scrollPositions.set(key,
|
|
817
|
+
function saveScrollPosition(key) {
|
|
818
|
+
scrollPositions.set(key, computeScrollPosition());
|
|
444
819
|
}
|
|
445
820
|
function getSavedScrollPosition(key) {
|
|
446
821
|
const scroll = scrollPositions.get(key);
|
|
@@ -451,7 +826,6 @@ function getSavedScrollPosition(key) {
|
|
|
451
826
|
* ScrollBehavior instance used by the router to compute and restore the scroll
|
|
452
827
|
* position when navigating.
|
|
453
828
|
*/
|
|
454
|
-
|
|
455
829
|
//#endregion
|
|
456
830
|
//#region src/types/typeGuards.ts
|
|
457
831
|
function isRouteLocation(route) {
|
|
@@ -460,95 +834,6 @@ function isRouteLocation(route) {
|
|
|
460
834
|
function isRouteName(name) {
|
|
461
835
|
return typeof name === "string" || typeof name === "symbol";
|
|
462
836
|
}
|
|
463
|
-
|
|
464
|
-
//#endregion
|
|
465
|
-
//#region src/errors.ts
|
|
466
|
-
/**
|
|
467
|
-
* Flags so we can combine them when checking for multiple errors. This is the internal version of
|
|
468
|
-
* {@link NavigationFailureType}.
|
|
469
|
-
*
|
|
470
|
-
* @internal
|
|
471
|
-
*/
|
|
472
|
-
let ErrorTypes = /* @__PURE__ */ function(ErrorTypes$1) {
|
|
473
|
-
ErrorTypes$1[ErrorTypes$1["MATCHER_NOT_FOUND"] = 1] = "MATCHER_NOT_FOUND";
|
|
474
|
-
ErrorTypes$1[ErrorTypes$1["NAVIGATION_GUARD_REDIRECT"] = 2] = "NAVIGATION_GUARD_REDIRECT";
|
|
475
|
-
ErrorTypes$1[ErrorTypes$1["NAVIGATION_ABORTED"] = 4] = "NAVIGATION_ABORTED";
|
|
476
|
-
ErrorTypes$1[ErrorTypes$1["NAVIGATION_CANCELLED"] = 8] = "NAVIGATION_CANCELLED";
|
|
477
|
-
ErrorTypes$1[ErrorTypes$1["NAVIGATION_DUPLICATED"] = 16] = "NAVIGATION_DUPLICATED";
|
|
478
|
-
return ErrorTypes$1;
|
|
479
|
-
}({});
|
|
480
|
-
const NavigationFailureSymbol = Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
|
|
481
|
-
/**
|
|
482
|
-
* Enumeration with all possible types for navigation failures. Can be passed to
|
|
483
|
-
* {@link isNavigationFailure} to check for specific failures.
|
|
484
|
-
*/
|
|
485
|
-
let NavigationFailureType = /* @__PURE__ */ function(NavigationFailureType$1) {
|
|
486
|
-
/**
|
|
487
|
-
* An aborted navigation is a navigation that failed because a navigation
|
|
488
|
-
* guard returned `false` or called `next(false)`
|
|
489
|
-
*/
|
|
490
|
-
NavigationFailureType$1[NavigationFailureType$1["aborted"] = 4] = "aborted";
|
|
491
|
-
/**
|
|
492
|
-
* A cancelled navigation is a navigation that failed because a more recent
|
|
493
|
-
* navigation finished started (not necessarily finished).
|
|
494
|
-
*/
|
|
495
|
-
NavigationFailureType$1[NavigationFailureType$1["cancelled"] = 8] = "cancelled";
|
|
496
|
-
/**
|
|
497
|
-
* A duplicated navigation is a navigation that failed because it was
|
|
498
|
-
* initiated while already being at the exact same location.
|
|
499
|
-
*/
|
|
500
|
-
NavigationFailureType$1[NavigationFailureType$1["duplicated"] = 16] = "duplicated";
|
|
501
|
-
return NavigationFailureType$1;
|
|
502
|
-
}({});
|
|
503
|
-
const ErrorTypeMessages = {
|
|
504
|
-
[ErrorTypes.MATCHER_NOT_FOUND]({ location, currentLocation }) {
|
|
505
|
-
return `No match for\n ${JSON.stringify(location)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
|
|
506
|
-
},
|
|
507
|
-
[ErrorTypes.NAVIGATION_GUARD_REDIRECT]({ from, to }) {
|
|
508
|
-
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
|
|
509
|
-
},
|
|
510
|
-
[ErrorTypes.NAVIGATION_ABORTED]({ from, to }) {
|
|
511
|
-
return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
|
|
512
|
-
},
|
|
513
|
-
[ErrorTypes.NAVIGATION_CANCELLED]({ from, to }) {
|
|
514
|
-
return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
|
|
515
|
-
},
|
|
516
|
-
[ErrorTypes.NAVIGATION_DUPLICATED]({ from, to }) {
|
|
517
|
-
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
/**
|
|
521
|
-
* Creates a typed NavigationFailure object.
|
|
522
|
-
* @internal
|
|
523
|
-
* @param type - NavigationFailureType
|
|
524
|
-
* @param params - { from, to }
|
|
525
|
-
*/
|
|
526
|
-
function createRouterError(type, params) {
|
|
527
|
-
if (process.env.NODE_ENV !== "production" || false) return assign(new Error(ErrorTypeMessages[type](params)), {
|
|
528
|
-
type,
|
|
529
|
-
[NavigationFailureSymbol]: true
|
|
530
|
-
}, params);
|
|
531
|
-
else return assign(/* @__PURE__ */ new Error(), {
|
|
532
|
-
type,
|
|
533
|
-
[NavigationFailureSymbol]: true
|
|
534
|
-
}, params);
|
|
535
|
-
}
|
|
536
|
-
function isNavigationFailure(error, type) {
|
|
537
|
-
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
|
|
538
|
-
}
|
|
539
|
-
const propertiesToLog = [
|
|
540
|
-
"params",
|
|
541
|
-
"query",
|
|
542
|
-
"hash"
|
|
543
|
-
];
|
|
544
|
-
function stringifyRoute(to) {
|
|
545
|
-
if (typeof to === "string") return to;
|
|
546
|
-
if (to.path != null) return to.path;
|
|
547
|
-
const location = {};
|
|
548
|
-
for (const key of propertiesToLog) if (key in to) location[key] = to[key];
|
|
549
|
-
return JSON.stringify(location, null, 2);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
837
|
//#endregion
|
|
553
838
|
//#region src/query.ts
|
|
554
839
|
/**
|
|
@@ -595,10 +880,10 @@ function stringifyQuery(query) {
|
|
|
595
880
|
if (value !== void 0) search += (search.length ? "&" : "") + key;
|
|
596
881
|
continue;
|
|
597
882
|
}
|
|
598
|
-
(isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)]).forEach((value
|
|
599
|
-
if (value
|
|
883
|
+
(isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)]).forEach((value) => {
|
|
884
|
+
if (value !== void 0) {
|
|
600
885
|
search += (search.length ? "&" : "") + key;
|
|
601
|
-
if (value
|
|
886
|
+
if (value != null) search += "=" + value;
|
|
602
887
|
}
|
|
603
888
|
});
|
|
604
889
|
}
|
|
@@ -620,46 +905,6 @@ function normalizeQuery(query) {
|
|
|
620
905
|
}
|
|
621
906
|
return normalizedQuery;
|
|
622
907
|
}
|
|
623
|
-
|
|
624
|
-
//#endregion
|
|
625
|
-
//#region src/injectionSymbols.ts
|
|
626
|
-
/**
|
|
627
|
-
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
|
628
|
-
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
|
629
|
-
* Location Matched
|
|
630
|
-
*
|
|
631
|
-
* @internal
|
|
632
|
-
*/
|
|
633
|
-
const matchedRouteKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
|
|
634
|
-
/**
|
|
635
|
-
* Allows overriding the router view depth to control which component in
|
|
636
|
-
* `matched` is rendered. rvd stands for Router View Depth
|
|
637
|
-
*
|
|
638
|
-
* @internal
|
|
639
|
-
*/
|
|
640
|
-
const viewDepthKey = Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
|
|
641
|
-
/**
|
|
642
|
-
* Allows overriding the router instance returned by `useRouter` in tests. r
|
|
643
|
-
* stands for router
|
|
644
|
-
*
|
|
645
|
-
* @internal
|
|
646
|
-
*/
|
|
647
|
-
const routerKey = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
|
|
648
|
-
/**
|
|
649
|
-
* Allows overriding the current route returned by `useRoute` in tests. rl
|
|
650
|
-
* stands for route location
|
|
651
|
-
*
|
|
652
|
-
* @internal
|
|
653
|
-
*/
|
|
654
|
-
const routeLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
|
655
|
-
/**
|
|
656
|
-
* Allows overriding the current route used by router-view. Internally this is
|
|
657
|
-
* used when the `route` prop is passed.
|
|
658
|
-
*
|
|
659
|
-
* @internal
|
|
660
|
-
*/
|
|
661
|
-
const routerViewLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
|
|
662
|
-
|
|
663
908
|
//#endregion
|
|
664
909
|
//#region src/utils/callbacks.ts
|
|
665
910
|
/**
|
|
@@ -683,19 +928,30 @@ function useCallbacks() {
|
|
|
683
928
|
reset
|
|
684
929
|
};
|
|
685
930
|
}
|
|
686
|
-
|
|
687
931
|
//#endregion
|
|
688
932
|
//#region src/navigationGuards.ts
|
|
689
|
-
function registerGuard(
|
|
933
|
+
function registerGuard(activeRecordRef, name, guard) {
|
|
934
|
+
const record = activeRecordRef.value;
|
|
935
|
+
if (!record) {
|
|
936
|
+
if (process.env.NODE_ENV !== "production") {
|
|
937
|
+
const fnName = name === "updateGuards" ? "onBeforeRouteUpdate" : "onBeforeRouteLeave";
|
|
938
|
+
diagnostics.VUE_ROUTER_R0020({ fn: fnName });
|
|
939
|
+
}
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
let currentRecord = record;
|
|
690
943
|
const removeFromList = () => {
|
|
691
|
-
|
|
944
|
+
currentRecord[name].delete(guard);
|
|
692
945
|
};
|
|
693
946
|
onUnmounted(removeFromList);
|
|
694
947
|
onDeactivated(removeFromList);
|
|
695
948
|
onActivated(() => {
|
|
696
|
-
|
|
949
|
+
const newRecord = activeRecordRef.value;
|
|
950
|
+
if (process.env.NODE_ENV !== "production" && !newRecord) diagnostics.VUE_ROUTER_R0021();
|
|
951
|
+
if (newRecord) currentRecord = newRecord;
|
|
952
|
+
currentRecord[name].add(guard);
|
|
697
953
|
});
|
|
698
|
-
|
|
954
|
+
currentRecord[name].add(guard);
|
|
699
955
|
}
|
|
700
956
|
/**
|
|
701
957
|
* Add a navigation guard that triggers whenever the component for the current
|
|
@@ -706,15 +962,10 @@ function registerGuard(record, name, guard) {
|
|
|
706
962
|
*/
|
|
707
963
|
function onBeforeRouteLeave(leaveGuard) {
|
|
708
964
|
if (process.env.NODE_ENV !== "production" && !getCurrentInstance()) {
|
|
709
|
-
|
|
965
|
+
diagnostics.VUE_ROUTER_R0022({ fn: "onBeforeRouteLeave" });
|
|
710
966
|
return;
|
|
711
967
|
}
|
|
712
|
-
|
|
713
|
-
if (!activeRecord) {
|
|
714
|
-
process.env.NODE_ENV !== "production" && warn$1("No active route record was found when calling `onBeforeRouteLeave()`. Make sure you call this function inside a component child of <router-view>. Maybe you called it inside of App.vue?");
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
registerGuard(activeRecord, "leaveGuards", leaveGuard);
|
|
968
|
+
registerGuard(inject(matchedRouteKey, {}), "leaveGuards", leaveGuard);
|
|
718
969
|
}
|
|
719
970
|
/**
|
|
720
971
|
* Add a navigation guard that triggers whenever the current location is about
|
|
@@ -725,26 +976,21 @@ function onBeforeRouteLeave(leaveGuard) {
|
|
|
725
976
|
*/
|
|
726
977
|
function onBeforeRouteUpdate(updateGuard) {
|
|
727
978
|
if (process.env.NODE_ENV !== "production" && !getCurrentInstance()) {
|
|
728
|
-
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
const activeRecord = inject(matchedRouteKey, {}).value;
|
|
732
|
-
if (!activeRecord) {
|
|
733
|
-
process.env.NODE_ENV !== "production" && warn$1("No active route record was found when calling `onBeforeRouteUpdate()`. Make sure you call this function inside a component child of <router-view>. Maybe you called it inside of App.vue?");
|
|
979
|
+
diagnostics.VUE_ROUTER_R0022({ fn: "onBeforeRouteUpdate" });
|
|
734
980
|
return;
|
|
735
981
|
}
|
|
736
|
-
registerGuard(
|
|
982
|
+
registerGuard(inject(matchedRouteKey, {}), "updateGuards", updateGuard);
|
|
737
983
|
}
|
|
738
984
|
function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
|
|
739
985
|
const enterCallbackArray = record && (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
|
|
740
986
|
return () => new Promise((resolve, reject) => {
|
|
741
987
|
const next = (valid) => {
|
|
742
|
-
if (valid === false) reject(createRouterError(
|
|
988
|
+
if (valid === false) reject(createRouterError(4, {
|
|
743
989
|
from,
|
|
744
990
|
to
|
|
745
991
|
}));
|
|
746
992
|
else if (valid instanceof Error) reject(valid);
|
|
747
|
-
else if (isRouteLocation(valid)) reject(createRouterError(
|
|
993
|
+
else if (isRouteLocation(valid)) reject(createRouterError(2, {
|
|
748
994
|
from: to,
|
|
749
995
|
to: valid
|
|
750
996
|
}));
|
|
@@ -753,21 +999,24 @@ function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) =
|
|
|
753
999
|
resolve();
|
|
754
1000
|
}
|
|
755
1001
|
};
|
|
756
|
-
const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, process.env.NODE_ENV !== "production" ? canOnlyBeCalledOnce(next, to, from) : next));
|
|
1002
|
+
const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, process.env.NODE_ENV !== "production" ? withDeprecationWarning(canOnlyBeCalledOnce(next, to, from)) : next));
|
|
757
1003
|
let guardCall = Promise.resolve(guardReturn);
|
|
758
1004
|
if (guard.length < 3) guardCall = guardCall.then(next);
|
|
759
1005
|
if (process.env.NODE_ENV !== "production" && guard.length > 2) {
|
|
760
|
-
const
|
|
1006
|
+
const guardInfo = {
|
|
1007
|
+
name: guard.name,
|
|
1008
|
+
guard: guard.toString()
|
|
1009
|
+
};
|
|
761
1010
|
if (typeof guardReturn === "object" && "then" in guardReturn) guardCall = guardCall.then((resolvedValue) => {
|
|
762
1011
|
if (!next._called) {
|
|
763
|
-
|
|
1012
|
+
diagnostics.VUE_ROUTER_R0023(guardInfo);
|
|
764
1013
|
return Promise.reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
|
|
765
1014
|
}
|
|
766
1015
|
return resolvedValue;
|
|
767
1016
|
});
|
|
768
1017
|
else if (guardReturn !== void 0) {
|
|
769
1018
|
if (!next._called) {
|
|
770
|
-
|
|
1019
|
+
diagnostics.VUE_ROUTER_R0023(guardInfo);
|
|
771
1020
|
reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
|
|
772
1021
|
return;
|
|
773
1022
|
}
|
|
@@ -776,10 +1025,30 @@ function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) =
|
|
|
776
1025
|
guardCall.catch((err) => reject(err));
|
|
777
1026
|
});
|
|
778
1027
|
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Wraps the next callback to warn when it is used. Dev-only: when __DEV__ is
|
|
1030
|
+
* false (production builds), this branch is dead code and is stripped from the
|
|
1031
|
+
* bundle.
|
|
1032
|
+
*
|
|
1033
|
+
* @internal
|
|
1034
|
+
*/
|
|
1035
|
+
function withDeprecationWarning(next) {
|
|
1036
|
+
let warned = false;
|
|
1037
|
+
return function() {
|
|
1038
|
+
if (!warned) {
|
|
1039
|
+
warned = true;
|
|
1040
|
+
diagnostics.VUE_ROUTER_R0025();
|
|
1041
|
+
}
|
|
1042
|
+
return next.apply(this, arguments);
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
779
1045
|
function canOnlyBeCalledOnce(next, to, from) {
|
|
780
1046
|
let called = 0;
|
|
781
1047
|
return function() {
|
|
782
|
-
if (called++ === 1)
|
|
1048
|
+
if (called++ === 1) diagnostics.VUE_ROUTER_R0024({
|
|
1049
|
+
from: from.fullPath,
|
|
1050
|
+
to: to.fullPath
|
|
1051
|
+
});
|
|
783
1052
|
next._called = true;
|
|
784
1053
|
if (called === 1) next.apply(null, arguments);
|
|
785
1054
|
};
|
|
@@ -787,20 +1056,30 @@ function canOnlyBeCalledOnce(next, to, from) {
|
|
|
787
1056
|
function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
|
|
788
1057
|
const guards = [];
|
|
789
1058
|
for (const record of matched) {
|
|
790
|
-
if (process.env.NODE_ENV !== "production" && !record.components && record.children && !record.children.length)
|
|
1059
|
+
if (process.env.NODE_ENV !== "production" && !record.components && record.children && !record.children.length) diagnostics.VUE_ROUTER_R0026({ path: record.path });
|
|
791
1060
|
for (const name in record.components) {
|
|
792
1061
|
let rawComponent = record.components[name];
|
|
793
1062
|
if (process.env.NODE_ENV !== "production") {
|
|
794
1063
|
if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
|
|
795
|
-
|
|
1064
|
+
diagnostics.VUE_ROUTER_R0027({
|
|
1065
|
+
name,
|
|
1066
|
+
path: record.path,
|
|
1067
|
+
received: String(rawComponent)
|
|
1068
|
+
});
|
|
796
1069
|
throw new Error("Invalid route component");
|
|
797
1070
|
} else if ("then" in rawComponent) {
|
|
798
|
-
|
|
1071
|
+
diagnostics.VUE_ROUTER_R0028({
|
|
1072
|
+
name,
|
|
1073
|
+
path: record.path
|
|
1074
|
+
});
|
|
799
1075
|
const promise = rawComponent;
|
|
800
1076
|
rawComponent = () => promise;
|
|
801
1077
|
} else if (rawComponent.__asyncLoader && !rawComponent.__warnedDefineAsync) {
|
|
802
1078
|
rawComponent.__warnedDefineAsync = true;
|
|
803
|
-
|
|
1079
|
+
diagnostics.VUE_ROUTER_R0029({
|
|
1080
|
+
name,
|
|
1081
|
+
path: record.path
|
|
1082
|
+
});
|
|
804
1083
|
}
|
|
805
1084
|
}
|
|
806
1085
|
if (guardType !== "beforeRouteEnter" && !record.instances[name]) continue;
|
|
@@ -810,7 +1089,10 @@ function extractComponentsGuards(matched, guardType, to, from, runWithContext =
|
|
|
810
1089
|
} else {
|
|
811
1090
|
let componentPromise = rawComponent();
|
|
812
1091
|
if (process.env.NODE_ENV !== "production" && !("catch" in componentPromise)) {
|
|
813
|
-
|
|
1092
|
+
diagnostics.VUE_ROUTER_R0030({
|
|
1093
|
+
name,
|
|
1094
|
+
path: record.path
|
|
1095
|
+
});
|
|
814
1096
|
componentPromise = Promise.resolve(componentPromise);
|
|
815
1097
|
}
|
|
816
1098
|
guards.push(() => componentPromise.then((resolved) => {
|
|
@@ -857,8 +1139,10 @@ function extractChangingRecords(to, from) {
|
|
|
857
1139
|
const len = Math.max(from.matched.length, to.matched.length);
|
|
858
1140
|
for (let i = 0; i < len; i++) {
|
|
859
1141
|
const recordFrom = from.matched[i];
|
|
860
|
-
if (recordFrom)
|
|
861
|
-
|
|
1142
|
+
if (recordFrom) {
|
|
1143
|
+
if (to.matched.find((record) => isSameRouteRecord(record, recordFrom))) updatingRecords.push(recordFrom);
|
|
1144
|
+
else leavingRecords.push(recordFrom);
|
|
1145
|
+
}
|
|
862
1146
|
const recordTo = to.matched[i];
|
|
863
1147
|
if (recordTo) {
|
|
864
1148
|
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) enteringRecords.push(recordTo);
|
|
@@ -870,7 +1154,6 @@ function extractChangingRecords(to, from) {
|
|
|
870
1154
|
enteringRecords
|
|
871
1155
|
];
|
|
872
1156
|
}
|
|
873
|
-
|
|
874
1157
|
//#endregion
|
|
875
1158
|
//#region src/devtools.ts
|
|
876
1159
|
/**
|
|
@@ -902,7 +1185,7 @@ function addDevtools(app, router, matcher) {
|
|
|
902
1185
|
if (router.__hasDevtools) return;
|
|
903
1186
|
router.__hasDevtools = true;
|
|
904
1187
|
const id = routerId++;
|
|
905
|
-
|
|
1188
|
+
setupDevToolsPlugin({
|
|
906
1189
|
id: "org.vuejs.router" + (id ? "." + id : ""),
|
|
907
1190
|
label: "Vue Router",
|
|
908
1191
|
packageName: "vue-router",
|
|
@@ -911,8 +1194,7 @@ function addDevtools(app, router, matcher) {
|
|
|
911
1194
|
componentStateTypes: ["Routing"],
|
|
912
1195
|
app
|
|
913
1196
|
}, (api) => {
|
|
914
|
-
|
|
915
|
-
api.on.inspectComponent((payload, ctx) => {
|
|
1197
|
+
api.on.inspectComponent((payload) => {
|
|
916
1198
|
if (payload.instanceData) payload.instanceData.state.push({
|
|
917
1199
|
type: "Routing",
|
|
918
1200
|
key: "$route",
|
|
@@ -1056,7 +1338,7 @@ function addDevtools(app, router, matcher) {
|
|
|
1056
1338
|
*/
|
|
1057
1339
|
api.on.getInspectorState((payload) => {
|
|
1058
1340
|
if (payload.app === app && payload.inspectorId === routerInspectorId) {
|
|
1059
|
-
const route = matcher.getRoutes().find((route
|
|
1341
|
+
const route = matcher.getRoutes().find((route) => route.record.__vd_id === payload.nodeId);
|
|
1060
1342
|
if (route) payload.state = { options: formatRouteRecordMatcherForStateInspector(route) };
|
|
1061
1343
|
}
|
|
1062
1344
|
});
|
|
@@ -1206,7 +1488,7 @@ function isRouteMatching(route, filter) {
|
|
|
1206
1488
|
}
|
|
1207
1489
|
const path = route.record.path.toLowerCase();
|
|
1208
1490
|
const decodedPath = decode(path);
|
|
1209
|
-
if (!filter
|
|
1491
|
+
if (!isAbsolutePath(filter) && (decodedPath.includes(filter) || path.includes(filter))) return true;
|
|
1210
1492
|
if (decodedPath.startsWith(filter) || path.startsWith(filter)) return true;
|
|
1211
1493
|
if (route.record.name && String(route.record.name).includes(filter)) return true;
|
|
1212
1494
|
return route.children.some((child) => isRouteMatching(child, filter));
|
|
@@ -1218,11 +1500,10 @@ function omit(obj, keys) {
|
|
|
1218
1500
|
}
|
|
1219
1501
|
|
|
1220
1502
|
/*!
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1503
|
+
* vue-router v5.3.1
|
|
1504
|
+
* (c) 2026 Eduardo San Martin Morote
|
|
1505
|
+
* @license MIT
|
|
1506
|
+
*/
|
|
1226
1507
|
//#region src/history/html5.ts
|
|
1227
1508
|
let createBaseLocation = () => location.protocol + "//" + location.host;
|
|
1228
1509
|
/**
|
|
@@ -1230,8 +1511,8 @@ let createBaseLocation = () => location.protocol + "//" + location.host;
|
|
|
1230
1511
|
* @param base - The base path
|
|
1231
1512
|
* @param location - The window.location object
|
|
1232
1513
|
*/
|
|
1233
|
-
function createCurrentLocation(base, location
|
|
1234
|
-
const { pathname, search, hash } = location
|
|
1514
|
+
function createCurrentLocation(base, location) {
|
|
1515
|
+
const { pathname, search, hash } = location;
|
|
1235
1516
|
const hashPos = base.indexOf("#");
|
|
1236
1517
|
if (hashPos > -1) {
|
|
1237
1518
|
let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
|
|
@@ -1262,8 +1543,8 @@ function useHistoryListeners(base, historyState, currentLocation, replace) {
|
|
|
1262
1543
|
listeners.forEach((listener) => {
|
|
1263
1544
|
listener(currentLocation.value, from, {
|
|
1264
1545
|
delta,
|
|
1265
|
-
type:
|
|
1266
|
-
direction: delta ? delta > 0 ?
|
|
1546
|
+
type: "pop",
|
|
1547
|
+
direction: delta ? delta > 0 ? "forward" : "back" : ""
|
|
1267
1548
|
});
|
|
1268
1549
|
});
|
|
1269
1550
|
};
|
|
@@ -1280,22 +1561,18 @@ function useHistoryListeners(base, historyState, currentLocation, replace) {
|
|
|
1280
1561
|
return teardown;
|
|
1281
1562
|
}
|
|
1282
1563
|
function beforeUnloadListener() {
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
history$1.replaceState(assign({}, history$1.state, { scroll: computeScrollPosition() }), "");
|
|
1287
|
-
}
|
|
1564
|
+
const { history } = window;
|
|
1565
|
+
if (!history.state) return;
|
|
1566
|
+
history.replaceState(assign({}, history.state, { scroll: computeScrollPosition() }), "");
|
|
1288
1567
|
}
|
|
1289
1568
|
function destroy() {
|
|
1290
1569
|
for (const teardown of teardowns) teardown();
|
|
1291
1570
|
teardowns = [];
|
|
1292
1571
|
window.removeEventListener("popstate", popStateHandler);
|
|
1293
1572
|
window.removeEventListener("pagehide", beforeUnloadListener);
|
|
1294
|
-
document.removeEventListener("visibilitychange", beforeUnloadListener);
|
|
1295
1573
|
}
|
|
1296
1574
|
window.addEventListener("popstate", popStateHandler);
|
|
1297
1575
|
window.addEventListener("pagehide", beforeUnloadListener);
|
|
1298
|
-
document.addEventListener("visibilitychange", beforeUnloadListener);
|
|
1299
1576
|
return {
|
|
1300
1577
|
pauseListeners,
|
|
1301
1578
|
listen,
|
|
@@ -1305,29 +1582,29 @@ function useHistoryListeners(base, historyState, currentLocation, replace) {
|
|
|
1305
1582
|
/**
|
|
1306
1583
|
* Creates a state object
|
|
1307
1584
|
*/
|
|
1308
|
-
function buildState(back, current, forward, replaced = false
|
|
1585
|
+
function buildState(back, current, forward, replaced = false) {
|
|
1309
1586
|
return {
|
|
1310
1587
|
back,
|
|
1311
1588
|
current,
|
|
1312
1589
|
forward,
|
|
1313
1590
|
replaced,
|
|
1314
1591
|
position: window.history.length,
|
|
1315
|
-
scroll:
|
|
1592
|
+
scroll: null
|
|
1316
1593
|
};
|
|
1317
1594
|
}
|
|
1318
1595
|
function useHistoryStateNavigation(base) {
|
|
1319
|
-
const { history
|
|
1320
|
-
const currentLocation = { value: createCurrentLocation(base, location
|
|
1321
|
-
const historyState = { value: history
|
|
1596
|
+
const { history, location } = window;
|
|
1597
|
+
const currentLocation = { value: createCurrentLocation(base, location) };
|
|
1598
|
+
const historyState = { value: history.state };
|
|
1322
1599
|
if (!historyState.value) changeLocation(currentLocation.value, {
|
|
1323
1600
|
back: null,
|
|
1324
1601
|
current: currentLocation.value,
|
|
1325
1602
|
forward: null,
|
|
1326
|
-
position: history
|
|
1603
|
+
position: history.length - 1,
|
|
1327
1604
|
replaced: true,
|
|
1328
1605
|
scroll: null
|
|
1329
1606
|
}, true);
|
|
1330
|
-
function changeLocation(to, state, replace
|
|
1607
|
+
function changeLocation(to, state, replace) {
|
|
1331
1608
|
/**
|
|
1332
1609
|
* if a base tag is provided, and we are on a normal domain, we have to
|
|
1333
1610
|
* respect the provided `base` attribute because pushState() will use it and
|
|
@@ -1338,26 +1615,26 @@ function useHistoryStateNavigation(base) {
|
|
|
1338
1615
|
* base tag we can just use everything after the `#`.
|
|
1339
1616
|
*/
|
|
1340
1617
|
const hashIndex = base.indexOf("#");
|
|
1341
|
-
const url = hashIndex > -1 ? (location
|
|
1618
|
+
const url = hashIndex > -1 ? (location.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
|
|
1342
1619
|
try {
|
|
1343
|
-
history
|
|
1620
|
+
history[replace ? "replaceState" : "pushState"](state, "", url);
|
|
1344
1621
|
historyState.value = state;
|
|
1345
1622
|
} catch (err) {
|
|
1346
|
-
if (process.env.NODE_ENV !== "production")
|
|
1623
|
+
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0120({ cause: err });
|
|
1347
1624
|
else console.error(err);
|
|
1348
|
-
location
|
|
1625
|
+
location[replace ? "replace" : "assign"](url);
|
|
1349
1626
|
}
|
|
1350
1627
|
}
|
|
1351
1628
|
function replace(to, data) {
|
|
1352
|
-
changeLocation(to, assign({}, history
|
|
1629
|
+
changeLocation(to, assign({}, history.state, buildState(historyState.value.back, to, historyState.value.forward, true), data, { position: historyState.value.position }), true);
|
|
1353
1630
|
currentLocation.value = to;
|
|
1354
1631
|
}
|
|
1355
1632
|
function push(to, data) {
|
|
1356
|
-
const currentState = assign({}, historyState.value, history
|
|
1633
|
+
const currentState = assign({}, historyState.value, history.state, {
|
|
1357
1634
|
forward: to,
|
|
1358
1635
|
scroll: computeScrollPosition()
|
|
1359
1636
|
});
|
|
1360
|
-
if (process.env.NODE_ENV !== "production" && !history
|
|
1637
|
+
if (process.env.NODE_ENV !== "production" && !history.state) diagnostics.VUE_ROUTER_R0121();
|
|
1361
1638
|
changeLocation(currentState.current, currentState, true);
|
|
1362
1639
|
changeLocation(to, assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data), false);
|
|
1363
1640
|
currentLocation.value = to;
|
|
@@ -1398,7 +1675,41 @@ function createWebHistory(base) {
|
|
|
1398
1675
|
});
|
|
1399
1676
|
return routerHistory;
|
|
1400
1677
|
}
|
|
1401
|
-
|
|
1678
|
+
//#endregion
|
|
1679
|
+
//#region src/history/hash.ts
|
|
1680
|
+
/**
|
|
1681
|
+
* Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
|
|
1682
|
+
* handle any URL is not possible.
|
|
1683
|
+
*
|
|
1684
|
+
* @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
|
|
1685
|
+
* in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
|
|
1686
|
+
* calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
|
|
1687
|
+
* after the `#`).
|
|
1688
|
+
*
|
|
1689
|
+
* @example
|
|
1690
|
+
* ```js
|
|
1691
|
+
* // at https://example.com/folder
|
|
1692
|
+
* createWebHashHistory() // gives a url of `https://example.com/folder#`
|
|
1693
|
+
* createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
|
|
1694
|
+
* // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
|
|
1695
|
+
* createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
|
|
1696
|
+
* // you should avoid doing this because it changes the original url and breaks copying urls
|
|
1697
|
+
* createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
|
|
1698
|
+
*
|
|
1699
|
+
* // at file:///usr/etc/folder/index.html
|
|
1700
|
+
* // for locations with no `host`, the base is ignored
|
|
1701
|
+
* createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
|
|
1702
|
+
* ```
|
|
1703
|
+
*/
|
|
1704
|
+
function createWebHashHistory(base) {
|
|
1705
|
+
base = location.host ? base || location.pathname + location.search : "";
|
|
1706
|
+
if (!base.includes("#")) base += "#";
|
|
1707
|
+
if (process.env.NODE_ENV !== "production" && !base.endsWith("#/") && !base.endsWith("#")) diagnostics.VUE_ROUTER_R0110({
|
|
1708
|
+
base,
|
|
1709
|
+
suggestion: base.replace(/#.*$/, "#")
|
|
1710
|
+
});
|
|
1711
|
+
return createWebHistory(base);
|
|
1712
|
+
}
|
|
1402
1713
|
//#endregion
|
|
1403
1714
|
//#region src/history/memory.ts
|
|
1404
1715
|
/**
|
|
@@ -1410,24 +1721,24 @@ function createWebHistory(base) {
|
|
|
1410
1721
|
*/
|
|
1411
1722
|
function createMemoryHistory(base = "") {
|
|
1412
1723
|
let listeners = [];
|
|
1413
|
-
let queue = [[
|
|
1724
|
+
let queue = [["", {}]];
|
|
1414
1725
|
let position = 0;
|
|
1415
1726
|
base = normalizeBase(base);
|
|
1416
|
-
function setLocation(location
|
|
1727
|
+
function setLocation(location, state = {}) {
|
|
1417
1728
|
position++;
|
|
1418
1729
|
if (position !== queue.length) queue.splice(position);
|
|
1419
|
-
queue.push([location
|
|
1730
|
+
queue.push([location, state]);
|
|
1420
1731
|
}
|
|
1421
1732
|
function triggerListeners(to, from, { direction, delta }) {
|
|
1422
1733
|
const info = {
|
|
1423
1734
|
direction,
|
|
1424
1735
|
delta,
|
|
1425
|
-
type:
|
|
1736
|
+
type: "pop"
|
|
1426
1737
|
};
|
|
1427
1738
|
for (const callback of listeners) callback(to, from, info);
|
|
1428
1739
|
}
|
|
1429
1740
|
const routerHistory = {
|
|
1430
|
-
location:
|
|
1741
|
+
location: "",
|
|
1431
1742
|
state: {},
|
|
1432
1743
|
base,
|
|
1433
1744
|
createHref: createHref.bind(null, base),
|
|
@@ -1447,12 +1758,12 @@ function createMemoryHistory(base = "") {
|
|
|
1447
1758
|
},
|
|
1448
1759
|
destroy() {
|
|
1449
1760
|
listeners = [];
|
|
1450
|
-
queue = [[
|
|
1761
|
+
queue = [["", {}]];
|
|
1451
1762
|
position = 0;
|
|
1452
1763
|
},
|
|
1453
1764
|
go(delta, shouldTrigger = true) {
|
|
1454
1765
|
const from = this.location;
|
|
1455
|
-
const direction = delta < 0 ?
|
|
1766
|
+
const direction = delta < 0 ? "back" : "forward";
|
|
1456
1767
|
position = Math.max(0, Math.min(position + delta, queue.length - 1));
|
|
1457
1768
|
if (shouldTrigger) triggerListeners(this.location, from, {
|
|
1458
1769
|
direction,
|
|
@@ -1470,69 +1781,21 @@ function createMemoryHistory(base = "") {
|
|
|
1470
1781
|
});
|
|
1471
1782
|
return routerHistory;
|
|
1472
1783
|
}
|
|
1473
|
-
|
|
1474
|
-
//#endregion
|
|
1475
|
-
//#region src/history/hash.ts
|
|
1476
|
-
/**
|
|
1477
|
-
* Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
|
|
1478
|
-
* handle any URL is not possible.
|
|
1479
|
-
*
|
|
1480
|
-
* @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
|
|
1481
|
-
* in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
|
|
1482
|
-
* calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
|
|
1483
|
-
* after the `#`).
|
|
1484
|
-
*
|
|
1485
|
-
* @example
|
|
1486
|
-
* ```js
|
|
1487
|
-
* // at https://example.com/folder
|
|
1488
|
-
* createWebHashHistory() // gives a url of `https://example.com/folder#`
|
|
1489
|
-
* createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
|
|
1490
|
-
* // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
|
|
1491
|
-
* createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
|
|
1492
|
-
* // you should avoid doing this because it changes the original url and breaks copying urls
|
|
1493
|
-
* createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
|
|
1494
|
-
*
|
|
1495
|
-
* // at file:///usr/etc/folder/index.html
|
|
1496
|
-
* // for locations with no `host`, the base is ignored
|
|
1497
|
-
* createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
|
|
1498
|
-
* ```
|
|
1499
|
-
*/
|
|
1500
|
-
function createWebHashHistory(base) {
|
|
1501
|
-
base = location.host ? base || location.pathname + location.search : "";
|
|
1502
|
-
if (!base.includes("#")) base += "#";
|
|
1503
|
-
if (process.env.NODE_ENV !== "production" && !base.endsWith("#/") && !base.endsWith("#")) warn$1(`A hash base must end with a "#":\n"${base}" should be "${base.replace(/#.*$/, "#")}".`);
|
|
1504
|
-
return createWebHistory(base);
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
1784
|
//#endregion
|
|
1508
1785
|
//#region src/matcher/pathTokenizer.ts
|
|
1509
|
-
let TokenType = /* @__PURE__ */ function(TokenType$1) {
|
|
1510
|
-
TokenType$1[TokenType$1["Static"] = 0] = "Static";
|
|
1511
|
-
TokenType$1[TokenType$1["Param"] = 1] = "Param";
|
|
1512
|
-
TokenType$1[TokenType$1["Group"] = 2] = "Group";
|
|
1513
|
-
return TokenType$1;
|
|
1514
|
-
}({});
|
|
1515
|
-
var TokenizerState = /* @__PURE__ */ function(TokenizerState$1) {
|
|
1516
|
-
TokenizerState$1[TokenizerState$1["Static"] = 0] = "Static";
|
|
1517
|
-
TokenizerState$1[TokenizerState$1["Param"] = 1] = "Param";
|
|
1518
|
-
TokenizerState$1[TokenizerState$1["ParamRegExp"] = 2] = "ParamRegExp";
|
|
1519
|
-
TokenizerState$1[TokenizerState$1["ParamRegExpEnd"] = 3] = "ParamRegExpEnd";
|
|
1520
|
-
TokenizerState$1[TokenizerState$1["EscapeNext"] = 4] = "EscapeNext";
|
|
1521
|
-
return TokenizerState$1;
|
|
1522
|
-
}(TokenizerState || {});
|
|
1523
1786
|
const ROOT_TOKEN = {
|
|
1524
|
-
type:
|
|
1787
|
+
type: 0,
|
|
1525
1788
|
value: ""
|
|
1526
1789
|
};
|
|
1527
1790
|
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
|
|
1528
1791
|
function tokenizePath(path) {
|
|
1529
1792
|
if (!path) return [[]];
|
|
1530
1793
|
if (path === "/") return [[ROOT_TOKEN]];
|
|
1531
|
-
if (!path
|
|
1794
|
+
if (!isAbsolutePath(path)) throw new Error(process.env.NODE_ENV !== "production" ? `Route paths should start with a "/": "${path}" should be "/${path}".` : `Invalid path "${path}"`);
|
|
1532
1795
|
function crash(message) {
|
|
1533
1796
|
throw new Error(`ERR (${state})/"${buffer}": ${message}`);
|
|
1534
1797
|
}
|
|
1535
|
-
let state =
|
|
1798
|
+
let state = 0;
|
|
1536
1799
|
let previousState = state;
|
|
1537
1800
|
const tokens = [];
|
|
1538
1801
|
let segment;
|
|
@@ -1546,14 +1809,14 @@ function tokenizePath(path) {
|
|
|
1546
1809
|
let customRe = "";
|
|
1547
1810
|
function consumeBuffer() {
|
|
1548
1811
|
if (!buffer) return;
|
|
1549
|
-
if (state ===
|
|
1550
|
-
type:
|
|
1812
|
+
if (state === 0) segment.push({
|
|
1813
|
+
type: 0,
|
|
1551
1814
|
value: buffer
|
|
1552
1815
|
});
|
|
1553
|
-
else if (state ===
|
|
1816
|
+
else if (state === 1 || state === 2 || state === 3) {
|
|
1554
1817
|
if (segment.length > 1 && (char === "*" || char === "+")) crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
|
|
1555
1818
|
segment.push({
|
|
1556
|
-
type:
|
|
1819
|
+
type: 1,
|
|
1557
1820
|
value: buffer,
|
|
1558
1821
|
regexp: customRe,
|
|
1559
1822
|
repeatable: char === "*" || char === "+",
|
|
@@ -1567,56 +1830,52 @@ function tokenizePath(path) {
|
|
|
1567
1830
|
}
|
|
1568
1831
|
while (i < path.length) {
|
|
1569
1832
|
char = path[i++];
|
|
1570
|
-
if (char === "\\" && state !== TokenizerState.ParamRegExp) {
|
|
1571
|
-
previousState = state;
|
|
1572
|
-
state = TokenizerState.EscapeNext;
|
|
1573
|
-
continue;
|
|
1574
|
-
}
|
|
1575
1833
|
switch (state) {
|
|
1576
|
-
case
|
|
1577
|
-
if (char === "
|
|
1834
|
+
case 0:
|
|
1835
|
+
if (char === "\\") {
|
|
1836
|
+
previousState = state;
|
|
1837
|
+
state = 4;
|
|
1838
|
+
} else if (char === "/") {
|
|
1578
1839
|
if (buffer) consumeBuffer();
|
|
1579
1840
|
finalizeSegment();
|
|
1580
1841
|
} else if (char === ":") {
|
|
1581
1842
|
consumeBuffer();
|
|
1582
|
-
state =
|
|
1843
|
+
state = 1;
|
|
1583
1844
|
} else addCharToBuffer();
|
|
1584
1845
|
break;
|
|
1585
|
-
case
|
|
1846
|
+
case 4:
|
|
1586
1847
|
addCharToBuffer();
|
|
1587
1848
|
state = previousState;
|
|
1588
1849
|
break;
|
|
1589
|
-
case
|
|
1590
|
-
if (char === "(") state =
|
|
1850
|
+
case 1:
|
|
1851
|
+
if (char === "(") state = 2;
|
|
1591
1852
|
else if (VALID_PARAM_RE.test(char)) addCharToBuffer();
|
|
1592
1853
|
else {
|
|
1593
1854
|
consumeBuffer();
|
|
1594
|
-
state =
|
|
1855
|
+
state = 0;
|
|
1595
1856
|
if (char !== "*" && char !== "?" && char !== "+") i--;
|
|
1596
1857
|
}
|
|
1597
1858
|
break;
|
|
1598
|
-
case
|
|
1599
|
-
if (char === ")")
|
|
1600
|
-
|
|
1601
|
-
|
|
1859
|
+
case 2:
|
|
1860
|
+
if (char === ")") {
|
|
1861
|
+
if (customRe[customRe.length - 1] == "\\") customRe = customRe.slice(0, -1) + char;
|
|
1862
|
+
else state = 3;
|
|
1863
|
+
} else customRe += char;
|
|
1602
1864
|
break;
|
|
1603
|
-
case
|
|
1865
|
+
case 3:
|
|
1604
1866
|
consumeBuffer();
|
|
1605
|
-
state =
|
|
1867
|
+
state = 0;
|
|
1606
1868
|
if (char !== "*" && char !== "?" && char !== "+") i--;
|
|
1607
1869
|
customRe = "";
|
|
1608
1870
|
break;
|
|
1609
|
-
default:
|
|
1610
|
-
crash("Unknown state");
|
|
1611
|
-
break;
|
|
1871
|
+
default: crash("Unknown state");
|
|
1612
1872
|
}
|
|
1613
1873
|
}
|
|
1614
|
-
if (state ===
|
|
1874
|
+
if (state === 2) crash(`Unfinished custom RegExp for param "${buffer}"`);
|
|
1615
1875
|
consumeBuffer();
|
|
1616
1876
|
finalizeSegment();
|
|
1617
1877
|
return tokens;
|
|
1618
1878
|
}
|
|
1619
|
-
|
|
1620
1879
|
//#endregion
|
|
1621
1880
|
//#region src/matcher/pathParserRanker.ts
|
|
1622
1881
|
const BASE_PARAM_PATTERN = "[^/]+?";
|
|
@@ -1626,21 +1885,6 @@ const BASE_PATH_PARSER_OPTIONS = {
|
|
|
1626
1885
|
start: true,
|
|
1627
1886
|
end: true
|
|
1628
1887
|
};
|
|
1629
|
-
var PathScore = /* @__PURE__ */ function(PathScore$1) {
|
|
1630
|
-
PathScore$1[PathScore$1["_multiplier"] = 10] = "_multiplier";
|
|
1631
|
-
PathScore$1[PathScore$1["Root"] = 90] = "Root";
|
|
1632
|
-
PathScore$1[PathScore$1["Segment"] = 40] = "Segment";
|
|
1633
|
-
PathScore$1[PathScore$1["SubSegment"] = 30] = "SubSegment";
|
|
1634
|
-
PathScore$1[PathScore$1["Static"] = 40] = "Static";
|
|
1635
|
-
PathScore$1[PathScore$1["Dynamic"] = 20] = "Dynamic";
|
|
1636
|
-
PathScore$1[PathScore$1["BonusCustomRegExp"] = 10] = "BonusCustomRegExp";
|
|
1637
|
-
PathScore$1[PathScore$1["BonusWildcard"] = -50] = "BonusWildcard";
|
|
1638
|
-
PathScore$1[PathScore$1["BonusRepeatable"] = -20] = "BonusRepeatable";
|
|
1639
|
-
PathScore$1[PathScore$1["BonusOptional"] = -8] = "BonusOptional";
|
|
1640
|
-
PathScore$1[PathScore$1["BonusStrict"] = .7000000000000001] = "BonusStrict";
|
|
1641
|
-
PathScore$1[PathScore$1["BonusCaseSensitive"] = .25] = "BonusCaseSensitive";
|
|
1642
|
-
return PathScore$1;
|
|
1643
|
-
}(PathScore || {});
|
|
1644
1888
|
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
|
|
1645
1889
|
/**
|
|
1646
1890
|
* Creates a path parser from an array of Segments (a segment is an array of Tokens)
|
|
@@ -1655,39 +1899,39 @@ function tokensToParser(segments, extraOptions) {
|
|
|
1655
1899
|
let pattern = options.start ? "^" : "";
|
|
1656
1900
|
const keys = [];
|
|
1657
1901
|
for (const segment of segments) {
|
|
1658
|
-
const segmentScores = segment.length ? [] : [
|
|
1902
|
+
const segmentScores = segment.length ? [] : [90];
|
|
1659
1903
|
if (options.strict && !segment.length) pattern += "/";
|
|
1660
1904
|
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
|
|
1661
1905
|
const token = segment[tokenIndex];
|
|
1662
|
-
let subSegmentScore =
|
|
1663
|
-
if (token.type ===
|
|
1906
|
+
let subSegmentScore = 40 + (options.sensitive ? .25 : 0);
|
|
1907
|
+
if (token.type === 0) {
|
|
1664
1908
|
if (!tokenIndex) pattern += "/";
|
|
1665
1909
|
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
|
|
1666
|
-
subSegmentScore +=
|
|
1667
|
-
} else if (token.type ===
|
|
1910
|
+
subSegmentScore += 40;
|
|
1911
|
+
} else if (token.type === 1) {
|
|
1668
1912
|
const { value, repeatable, optional, regexp } = token;
|
|
1669
1913
|
keys.push({
|
|
1670
1914
|
name: value,
|
|
1671
1915
|
repeatable,
|
|
1672
1916
|
optional
|
|
1673
1917
|
});
|
|
1674
|
-
const re
|
|
1675
|
-
if (re
|
|
1676
|
-
subSegmentScore +=
|
|
1918
|
+
const re = regexp ? regexp : BASE_PARAM_PATTERN;
|
|
1919
|
+
if (re !== BASE_PARAM_PATTERN) {
|
|
1920
|
+
subSegmentScore += 10;
|
|
1677
1921
|
try {
|
|
1678
|
-
|
|
1922
|
+
new RegExp(`(${re})`);
|
|
1679
1923
|
} catch (err) {
|
|
1680
|
-
throw new Error(`Invalid custom RegExp for param "${value}" (${re
|
|
1924
|
+
throw new Error(`Invalid custom RegExp for param "${value}" (${re}): ` + err.message);
|
|
1681
1925
|
}
|
|
1682
1926
|
}
|
|
1683
|
-
let subPattern = repeatable ? `((?:${re
|
|
1927
|
+
let subPattern = repeatable ? `((?:${re})(?:/(?:${re}))*)` : `(${re})`;
|
|
1684
1928
|
if (!tokenIndex) subPattern = optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
|
|
1685
1929
|
if (optional) subPattern += "?";
|
|
1686
1930
|
pattern += subPattern;
|
|
1687
|
-
subSegmentScore +=
|
|
1688
|
-
if (optional) subSegmentScore +=
|
|
1689
|
-
if (repeatable) subSegmentScore +=
|
|
1690
|
-
if (re
|
|
1931
|
+
subSegmentScore += 20;
|
|
1932
|
+
if (optional) subSegmentScore += -8;
|
|
1933
|
+
if (repeatable) subSegmentScore += -20;
|
|
1934
|
+
if (re === ".*") subSegmentScore += -50;
|
|
1691
1935
|
}
|
|
1692
1936
|
segmentScores.push(subSegmentScore);
|
|
1693
1937
|
}
|
|
@@ -1695,7 +1939,7 @@ function tokensToParser(segments, extraOptions) {
|
|
|
1695
1939
|
}
|
|
1696
1940
|
if (options.strict && options.end) {
|
|
1697
1941
|
const i = score.length - 1;
|
|
1698
|
-
score[i][score[i].length - 1] +=
|
|
1942
|
+
score[i][score[i].length - 1] += .7000000000000001;
|
|
1699
1943
|
}
|
|
1700
1944
|
if (!options.strict) pattern += "/?";
|
|
1701
1945
|
if (options.end) pattern += "$";
|
|
@@ -1718,16 +1962,20 @@ function tokensToParser(segments, extraOptions) {
|
|
|
1718
1962
|
for (const segment of segments) {
|
|
1719
1963
|
if (!avoidDuplicatedSlash || !path.endsWith("/")) path += "/";
|
|
1720
1964
|
avoidDuplicatedSlash = false;
|
|
1721
|
-
for (const token of segment) if (token.type ===
|
|
1722
|
-
else if (token.type ===
|
|
1965
|
+
for (const token of segment) if (token.type === 0) path += token.value;
|
|
1966
|
+
else if (token.type === 1) {
|
|
1723
1967
|
const { value, repeatable, optional } = token;
|
|
1724
1968
|
const param = value in params ? params[value] : "";
|
|
1725
1969
|
if (isArray(param) && !repeatable) throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
|
|
1726
1970
|
const text = isArray(param) ? param.join("/") : param;
|
|
1727
|
-
if (!text)
|
|
1728
|
-
if (
|
|
1729
|
-
|
|
1730
|
-
|
|
1971
|
+
if (!text) {
|
|
1972
|
+
if (optional) {
|
|
1973
|
+
if (segment.length < 2) {
|
|
1974
|
+
if (path.endsWith("/")) path = path.slice(0, -1);
|
|
1975
|
+
else avoidDuplicatedSlash = true;
|
|
1976
|
+
}
|
|
1977
|
+
} else throw new Error(`Missing required param "${value}"`);
|
|
1978
|
+
}
|
|
1731
1979
|
path += text;
|
|
1732
1980
|
}
|
|
1733
1981
|
}
|
|
@@ -1757,8 +2005,8 @@ function compareScoreArray(a, b) {
|
|
|
1757
2005
|
if (diff) return diff;
|
|
1758
2006
|
i++;
|
|
1759
2007
|
}
|
|
1760
|
-
if (a.length < b.length) return a.length === 1 && a[0] ===
|
|
1761
|
-
else if (a.length > b.length) return b.length === 1 && b[0] ===
|
|
2008
|
+
if (a.length < b.length) return a.length === 1 && a[0] === 80 ? -1 : 1;
|
|
2009
|
+
else if (a.length > b.length) return b.length === 1 && b[0] === 80 ? 1 : -1;
|
|
1762
2010
|
return 0;
|
|
1763
2011
|
}
|
|
1764
2012
|
/**
|
|
@@ -1798,7 +2046,6 @@ const PATH_PARSER_OPTIONS_DEFAULTS = {
|
|
|
1798
2046
|
end: true,
|
|
1799
2047
|
sensitive: false
|
|
1800
2048
|
};
|
|
1801
|
-
|
|
1802
2049
|
//#endregion
|
|
1803
2050
|
//#region src/matcher/pathMatcher.ts
|
|
1804
2051
|
function createRouteRecordMatcher(record, parent, options) {
|
|
@@ -1806,7 +2053,10 @@ function createRouteRecordMatcher(record, parent, options) {
|
|
|
1806
2053
|
if (process.env.NODE_ENV !== "production") {
|
|
1807
2054
|
const existingKeys = /* @__PURE__ */ new Set();
|
|
1808
2055
|
for (const key of parser.keys) {
|
|
1809
|
-
if (existingKeys.has(key.name))
|
|
2056
|
+
if (existingKeys.has(key.name)) diagnostics.VUE_ROUTER_R0090({
|
|
2057
|
+
name: key.name,
|
|
2058
|
+
path: record.path
|
|
2059
|
+
});
|
|
1810
2060
|
existingKeys.add(key.name);
|
|
1811
2061
|
}
|
|
1812
2062
|
}
|
|
@@ -1821,7 +2071,6 @@ function createRouteRecordMatcher(record, parent, options) {
|
|
|
1821
2071
|
}
|
|
1822
2072
|
return matcher;
|
|
1823
2073
|
}
|
|
1824
|
-
|
|
1825
2074
|
//#endregion
|
|
1826
2075
|
//#region src/matcher/index.ts
|
|
1827
2076
|
/**
|
|
@@ -1857,14 +2106,14 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1857
2106
|
let originalMatcher;
|
|
1858
2107
|
for (const normalizedRecord of normalizedRecords) {
|
|
1859
2108
|
const { path } = normalizedRecord;
|
|
1860
|
-
if (parent && path
|
|
2109
|
+
if (parent && !isAbsolutePath(path)) {
|
|
1861
2110
|
const parentPath = parent.record.path;
|
|
1862
2111
|
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
|
|
1863
2112
|
normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
|
|
1864
2113
|
}
|
|
1865
2114
|
if (process.env.NODE_ENV !== "production" && normalizedRecord.path === "*") throw new Error("Catch all routes (\"*\") must now be defined using a param with a custom regexp.\nSee more at https://router.vuejs.org/guide/migration/#Removed-star-or-catch-all-routes.");
|
|
1866
2115
|
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
|
|
1867
|
-
if (process.env.NODE_ENV !== "production" && parent && path
|
|
2116
|
+
if (process.env.NODE_ENV !== "production" && parent && isAbsolutePath(path)) checkMissingParamsInAbsolutePath(matcher, parent);
|
|
1868
2117
|
if (originalRecord) {
|
|
1869
2118
|
originalRecord.alias.push(matcher);
|
|
1870
2119
|
if (process.env.NODE_ENV !== "production") checkSameParams(originalRecord, matcher);
|
|
@@ -1914,37 +2163,46 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1914
2163
|
matchers.splice(index, 0, matcher);
|
|
1915
2164
|
if (matcher.record.name && !isAliasRecord(matcher)) matcherMap.set(matcher.record.name, matcher);
|
|
1916
2165
|
}
|
|
1917
|
-
function resolve(location
|
|
2166
|
+
function resolve(location, currentLocation) {
|
|
1918
2167
|
let matcher;
|
|
1919
2168
|
let params = {};
|
|
1920
2169
|
let path;
|
|
1921
2170
|
let name;
|
|
1922
|
-
if ("name" in location
|
|
1923
|
-
matcher = matcherMap.get(location
|
|
1924
|
-
if (!matcher) throw createRouterError(
|
|
2171
|
+
if ("name" in location && location.name) {
|
|
2172
|
+
matcher = matcherMap.get(location.name);
|
|
2173
|
+
if (!matcher) throw createRouterError(1, { location });
|
|
1925
2174
|
if (process.env.NODE_ENV !== "production") {
|
|
1926
|
-
const invalidParams = Object.keys(location
|
|
1927
|
-
if (invalidParams.length)
|
|
2175
|
+
const invalidParams = Object.keys(location.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
|
|
2176
|
+
if (invalidParams.length) {
|
|
2177
|
+
const isInherited = !matcher.keys.length && invalidParams.some((name) => name in currentLocation.params);
|
|
2178
|
+
diagnostics.VUE_ROUTER_R0100({
|
|
2179
|
+
params: invalidParams.join("\", \""),
|
|
2180
|
+
inherited: isInherited ? ` If you are using a catch-all route with a named redirect, pass an empty \`params\` object: \`redirect: { name: '...', params: {} }\`.` : ""
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
1928
2183
|
}
|
|
1929
2184
|
name = matcher.record.name;
|
|
1930
|
-
params = assign(pickParams(currentLocation.params, matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)), location
|
|
2185
|
+
params = assign(pickParams(currentLocation.params, matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)), location.params && pickParams(location.params, matcher.keys.map((k) => k.name)));
|
|
1931
2186
|
path = matcher.stringify(params);
|
|
1932
|
-
} else if (location
|
|
1933
|
-
path = location
|
|
1934
|
-
if (process.env.NODE_ENV !== "production" && !path
|
|
2187
|
+
} else if (location.path != null) {
|
|
2188
|
+
path = location.path;
|
|
2189
|
+
if (process.env.NODE_ENV !== "production" && !isAbsolutePath(path)) diagnostics.VUE_ROUTER_R0101({ path });
|
|
1935
2190
|
matcher = matchers.find((m) => m.re.test(path));
|
|
1936
2191
|
if (matcher) {
|
|
1937
2192
|
params = matcher.parse(path);
|
|
1938
2193
|
name = matcher.record.name;
|
|
2194
|
+
matcher.keys.forEach((key) => {
|
|
2195
|
+
if (key.optional && !params[key.name]) delete params[key.name];
|
|
2196
|
+
});
|
|
1939
2197
|
}
|
|
1940
2198
|
} else {
|
|
1941
2199
|
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
|
|
1942
|
-
if (!matcher) throw createRouterError(
|
|
1943
|
-
location
|
|
2200
|
+
if (!matcher) throw createRouterError(1, {
|
|
2201
|
+
location,
|
|
1944
2202
|
currentLocation
|
|
1945
2203
|
});
|
|
1946
2204
|
name = matcher.record.name;
|
|
1947
|
-
params = assign({}, currentLocation.params, location
|
|
2205
|
+
params = assign({}, currentLocation.params, location.params);
|
|
1948
2206
|
path = matcher.stringify(params);
|
|
1949
2207
|
}
|
|
1950
2208
|
const matched = [];
|
|
@@ -2052,8 +2310,22 @@ function isSameParam(a, b) {
|
|
|
2052
2310
|
* @param b - alias record
|
|
2053
2311
|
*/
|
|
2054
2312
|
function checkSameParams(a, b) {
|
|
2055
|
-
for (const key of a.keys) if (!key.optional && !b.keys.find(isSameParam.bind(null, key)))
|
|
2056
|
-
|
|
2313
|
+
for (const key of a.keys) if (!key.optional && !b.keys.find(isSameParam.bind(null, key))) {
|
|
2314
|
+
diagnostics.VUE_ROUTER_R0102({
|
|
2315
|
+
alias: b.record.path,
|
|
2316
|
+
original: a.record.path,
|
|
2317
|
+
name: key.name
|
|
2318
|
+
});
|
|
2319
|
+
return;
|
|
2320
|
+
}
|
|
2321
|
+
for (const key of b.keys) if (!key.optional && !a.keys.find(isSameParam.bind(null, key))) {
|
|
2322
|
+
diagnostics.VUE_ROUTER_R0102({
|
|
2323
|
+
alias: b.record.path,
|
|
2324
|
+
original: a.record.path,
|
|
2325
|
+
name: key.name
|
|
2326
|
+
});
|
|
2327
|
+
return;
|
|
2328
|
+
}
|
|
2057
2329
|
}
|
|
2058
2330
|
/**
|
|
2059
2331
|
* A route with a name and a child with an empty path without a name should warn when adding the route
|
|
@@ -2062,13 +2334,20 @@ function checkSameParams(a, b) {
|
|
|
2062
2334
|
* @param parent - RouteRecordMatcher
|
|
2063
2335
|
*/
|
|
2064
2336
|
function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
|
|
2065
|
-
if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path)
|
|
2337
|
+
if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path && mainNormalizedRecord.children.length === 0) diagnostics.VUE_ROUTER_R0103({ name: String(parent.record.name) });
|
|
2066
2338
|
}
|
|
2067
2339
|
function checkSameNameAsAncestor(record, parent) {
|
|
2068
2340
|
for (let ancestor = parent; ancestor; ancestor = ancestor.parent) if (ancestor.record.name === record.name) throw new Error(`A route named "${String(record.name)}" has been added as a ${parent === ancestor ? "child" : "descendant"} of a route with the same name. Route names must be unique and a nested route cannot use the same name as an ancestor.`);
|
|
2069
2341
|
}
|
|
2070
2342
|
function checkMissingParamsInAbsolutePath(record, parent) {
|
|
2071
|
-
for (const key of parent.keys) if (!record.keys.find(isSameParam.bind(null, key)))
|
|
2343
|
+
for (const key of parent.keys) if (!record.keys.find(isSameParam.bind(null, key))) {
|
|
2344
|
+
diagnostics.VUE_ROUTER_R0104({
|
|
2345
|
+
path: record.record.path,
|
|
2346
|
+
name: key.name,
|
|
2347
|
+
parent: parent.record.path
|
|
2348
|
+
});
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2072
2351
|
}
|
|
2073
2352
|
/**
|
|
2074
2353
|
* Performs a binary search to find the correct insertion index for a new matcher.
|
|
@@ -2090,7 +2369,10 @@ function findInsertionIndex(matcher, matchers) {
|
|
|
2090
2369
|
const insertionAncestor = getInsertionAncestor(matcher);
|
|
2091
2370
|
if (insertionAncestor) {
|
|
2092
2371
|
upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
|
|
2093
|
-
if (process.env.NODE_ENV !== "production" && upper < 0)
|
|
2372
|
+
if (process.env.NODE_ENV !== "production" && upper < 0) diagnostics.VUE_ROUTER_R0105({
|
|
2373
|
+
ancestor: insertionAncestor.record.path,
|
|
2374
|
+
record: matcher.record.path
|
|
2375
|
+
});
|
|
2094
2376
|
}
|
|
2095
2377
|
return upper;
|
|
2096
2378
|
}
|
|
@@ -2108,7 +2390,6 @@ function getInsertionAncestor(matcher) {
|
|
|
2108
2390
|
function isMatchable({ record }) {
|
|
2109
2391
|
return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
|
|
2110
2392
|
}
|
|
2111
|
-
|
|
2112
2393
|
//#endregion
|
|
2113
2394
|
//#region src/RouterLink.ts
|
|
2114
2395
|
/**
|
|
@@ -2124,8 +2405,7 @@ function useLink(props) {
|
|
|
2124
2405
|
const route = computed(() => {
|
|
2125
2406
|
const to = unref(props.to);
|
|
2126
2407
|
if (process.env.NODE_ENV !== "production" && (!hasPrevious || to !== previousTo)) {
|
|
2127
|
-
if (!isRouteLocation(to))
|
|
2128
|
-
else warn$1(`Invalid value for prop "to" in useLink()\n- to:`, to, `\n- props:`, props);
|
|
2408
|
+
if (!isRouteLocation(to)) diagnostics.VUE_ROUTER_R0050({ to });
|
|
2129
2409
|
previousTo = to;
|
|
2130
2410
|
hasPrevious = true;
|
|
2131
2411
|
}
|
|
@@ -2185,7 +2465,10 @@ function useLink(props) {
|
|
|
2185
2465
|
function preferSingleVNode(vnodes) {
|
|
2186
2466
|
return vnodes.length === 1 ? vnodes[0] : vnodes;
|
|
2187
2467
|
}
|
|
2188
|
-
|
|
2468
|
+
/**
|
|
2469
|
+
* Component to render a link that triggers a navigation on click.
|
|
2470
|
+
*/
|
|
2471
|
+
const RouterLink = /* @__PURE__ */ defineComponent({
|
|
2189
2472
|
name: "RouterLink",
|
|
2190
2473
|
compatConfig: { MODE: 3 },
|
|
2191
2474
|
props: {
|
|
@@ -2222,10 +2505,6 @@ const RouterLinkImpl = /* @__PURE__ */ defineComponent({
|
|
|
2222
2505
|
};
|
|
2223
2506
|
}
|
|
2224
2507
|
});
|
|
2225
|
-
/**
|
|
2226
|
-
* Component to render a link that triggers a navigation on click.
|
|
2227
|
-
*/
|
|
2228
|
-
const RouterLink = RouterLinkImpl;
|
|
2229
2508
|
function guardEvent(e) {
|
|
2230
2509
|
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return;
|
|
2231
2510
|
if (e.defaultPrevented) return;
|
|
@@ -2241,9 +2520,9 @@ function includesParams(outer, inner) {
|
|
|
2241
2520
|
for (const key in inner) {
|
|
2242
2521
|
const innerValue = inner[key];
|
|
2243
2522
|
const outerValue = outer[key];
|
|
2244
|
-
if (
|
|
2245
|
-
if (innerValue !== outerValue) return false;
|
|
2246
|
-
} else if (
|
|
2523
|
+
if (isArray(innerValue)) {
|
|
2524
|
+
if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value.valueOf() !== outerValue[i].valueOf())) return false;
|
|
2525
|
+
} else if (innerValue !== outerValue) return false;
|
|
2247
2526
|
}
|
|
2248
2527
|
return true;
|
|
2249
2528
|
}
|
|
@@ -2261,10 +2540,9 @@ function getOriginalPath(record) {
|
|
|
2261
2540
|
* @param defaultClass
|
|
2262
2541
|
*/
|
|
2263
2542
|
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
|
|
2264
|
-
|
|
2265
2543
|
//#endregion
|
|
2266
2544
|
//#region src/RouterView.ts
|
|
2267
|
-
const RouterViewImpl =
|
|
2545
|
+
const RouterViewImpl = /*#__PURE__*/ defineComponent({
|
|
2268
2546
|
name: "RouterView",
|
|
2269
2547
|
inheritAttrs: false,
|
|
2270
2548
|
props: {
|
|
@@ -2296,7 +2574,7 @@ const RouterViewImpl = /* @__PURE__ */ defineComponent({
|
|
|
2296
2574
|
viewRef.value,
|
|
2297
2575
|
matchedRouteRef.value,
|
|
2298
2576
|
props.name
|
|
2299
|
-
], ([instance, to, name], [oldInstance, from,
|
|
2577
|
+
], ([instance, to, name], [oldInstance, from, _oldName]) => {
|
|
2300
2578
|
if (to) {
|
|
2301
2579
|
to.instances[name] = instance;
|
|
2302
2580
|
if (from && from !== to && instance && instance === oldInstance) {
|
|
@@ -2332,7 +2610,7 @@ const RouterViewImpl = /* @__PURE__ */ defineComponent({
|
|
|
2332
2610
|
meta: matchedRoute.meta
|
|
2333
2611
|
};
|
|
2334
2612
|
(isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i]).forEach((instance) => {
|
|
2335
|
-
instance.__vrv_devtools = info;
|
|
2613
|
+
if (instance) instance.__vrv_devtools = info;
|
|
2336
2614
|
});
|
|
2337
2615
|
}
|
|
2338
2616
|
return normalizeSlot(slots.default, {
|
|
@@ -2357,14 +2635,9 @@ function warnDeprecatedUsage() {
|
|
|
2357
2635
|
const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
|
|
2358
2636
|
if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
|
|
2359
2637
|
const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
|
|
2360
|
-
|
|
2361
|
-
Use slot props instead:
|
|
2362
|
-
|
|
2363
|
-
<router-view v-slot="{ Component }">
|
|
2364
|
-
<${comp}>\n <component :is="Component" />\n </${comp}>\n</router-view>`);
|
|
2638
|
+
diagnostics.VUE_ROUTER_R0060({ comp });
|
|
2365
2639
|
}
|
|
2366
2640
|
}
|
|
2367
|
-
|
|
2368
2641
|
//#endregion
|
|
2369
2642
|
//#region src/router.ts
|
|
2370
2643
|
/**
|
|
@@ -2382,6 +2655,7 @@ function createRouter(options) {
|
|
|
2382
2655
|
const beforeResolveGuards = useCallbacks();
|
|
2383
2656
|
const afterGuards = useCallbacks();
|
|
2384
2657
|
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
|
|
2658
|
+
const routesVersion = shallowRef(0);
|
|
2385
2659
|
let pendingLocation = START_LOCATION_NORMALIZED;
|
|
2386
2660
|
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) history.scrollRestoration = "manual";
|
|
2387
2661
|
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
|
|
@@ -2392,15 +2666,26 @@ function createRouter(options) {
|
|
|
2392
2666
|
let record;
|
|
2393
2667
|
if (isRouteName(parentOrRoute)) {
|
|
2394
2668
|
parent = matcher.getRecordMatcher(parentOrRoute);
|
|
2395
|
-
if (process.env.NODE_ENV !== "production" && !parent)
|
|
2669
|
+
if (process.env.NODE_ENV !== "production" && !parent) diagnostics.VUE_ROUTER_R0001({ name: String(parentOrRoute) });
|
|
2396
2670
|
record = route;
|
|
2397
2671
|
} else record = parentOrRoute;
|
|
2398
|
-
|
|
2672
|
+
const removeRoute = matcher.addRoute(record, parent);
|
|
2673
|
+
routesVersion.value++;
|
|
2674
|
+
return () => {
|
|
2675
|
+
removeRoute();
|
|
2676
|
+
routesVersion.value++;
|
|
2677
|
+
};
|
|
2399
2678
|
}
|
|
2400
2679
|
function removeRoute(name) {
|
|
2401
2680
|
const recordMatcher = matcher.getRecordMatcher(name);
|
|
2402
|
-
if (recordMatcher)
|
|
2403
|
-
|
|
2681
|
+
if (recordMatcher) {
|
|
2682
|
+
matcher.removeRoute(recordMatcher);
|
|
2683
|
+
routesVersion.value++;
|
|
2684
|
+
} else if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0002({ name: String(name) });
|
|
2685
|
+
}
|
|
2686
|
+
function clearRoutes() {
|
|
2687
|
+
matcher.clearRoutes();
|
|
2688
|
+
routesVersion.value++;
|
|
2404
2689
|
}
|
|
2405
2690
|
function getRoutes() {
|
|
2406
2691
|
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
|
|
@@ -2409,29 +2694,33 @@ function createRouter(options) {
|
|
|
2409
2694
|
return !!matcher.getRecordMatcher(name);
|
|
2410
2695
|
}
|
|
2411
2696
|
function resolve(rawLocation, currentLocation) {
|
|
2412
|
-
|
|
2697
|
+
routesVersion.value;
|
|
2413
2698
|
if (typeof rawLocation === "string") {
|
|
2699
|
+
currentLocation = currentLocation || (rawLocation.startsWith("/") ? START_LOCATION_NORMALIZED : currentRoute.value);
|
|
2414
2700
|
const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
|
|
2415
|
-
const matchedRoute
|
|
2416
|
-
const href
|
|
2701
|
+
const matchedRoute = matcher.resolve({ path: locationNormalized.path }, currentLocation);
|
|
2702
|
+
const href = routerHistory.createHref(locationNormalized.fullPath);
|
|
2417
2703
|
if (process.env.NODE_ENV !== "production") {
|
|
2418
|
-
if (href
|
|
2419
|
-
|
|
2704
|
+
if (href.startsWith("//")) diagnostics.VUE_ROUTER_R0003({
|
|
2705
|
+
location: rawLocation,
|
|
2706
|
+
href
|
|
2707
|
+
});
|
|
2708
|
+
else if (!matchedRoute.matched.length) diagnostics.VUE_ROUTER_R0004({ path: rawLocation });
|
|
2420
2709
|
}
|
|
2421
|
-
return assign(locationNormalized, matchedRoute
|
|
2422
|
-
params: decodeParams(matchedRoute
|
|
2423
|
-
hash: decode(locationNormalized.hash),
|
|
2710
|
+
return assign(locationNormalized, matchedRoute, {
|
|
2711
|
+
params: decodeParams(matchedRoute.params),
|
|
2424
2712
|
redirectedFrom: void 0,
|
|
2425
|
-
href
|
|
2713
|
+
href
|
|
2426
2714
|
});
|
|
2427
2715
|
}
|
|
2428
2716
|
if (process.env.NODE_ENV !== "production" && !isRouteLocation(rawLocation)) {
|
|
2429
|
-
|
|
2717
|
+
diagnostics.VUE_ROUTER_R0005({ rawLocation });
|
|
2430
2718
|
return resolve({});
|
|
2431
2719
|
}
|
|
2720
|
+
currentLocation = assign({}, currentLocation || (rawLocation.path != null && rawLocation.path.startsWith("/") && !("name" in rawLocation && rawLocation.name) ? START_LOCATION_NORMALIZED : currentRoute.value));
|
|
2432
2721
|
let matcherLocation;
|
|
2433
2722
|
if (rawLocation.path != null) {
|
|
2434
|
-
if (process.env.NODE_ENV !== "production" && "params" in rawLocation && !("name" in rawLocation) && Object.keys(rawLocation.params).length)
|
|
2723
|
+
if (process.env.NODE_ENV !== "production" && "params" in rawLocation && !("name" in rawLocation) && Object.keys(rawLocation.params).length) diagnostics.VUE_ROUTER_R0006({ path: rawLocation.path });
|
|
2435
2724
|
matcherLocation = assign({}, rawLocation, { path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path });
|
|
2436
2725
|
} else {
|
|
2437
2726
|
const targetParams = assign({}, rawLocation.params);
|
|
@@ -2441,7 +2730,7 @@ function createRouter(options) {
|
|
|
2441
2730
|
}
|
|
2442
2731
|
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
|
|
2443
2732
|
const hash = rawLocation.hash || "";
|
|
2444
|
-
if (process.env.NODE_ENV !== "production" && hash && !hash.startsWith("#"))
|
|
2733
|
+
if (process.env.NODE_ENV !== "production" && hash && !hash.startsWith("#")) diagnostics.VUE_ROUTER_R0007({ hash });
|
|
2445
2734
|
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
|
|
2446
2735
|
const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
|
|
2447
2736
|
hash: encodeHash(hash),
|
|
@@ -2449,8 +2738,11 @@ function createRouter(options) {
|
|
|
2449
2738
|
}));
|
|
2450
2739
|
const href = routerHistory.createHref(fullPath);
|
|
2451
2740
|
if (process.env.NODE_ENV !== "production") {
|
|
2452
|
-
if (href.startsWith("//"))
|
|
2453
|
-
|
|
2741
|
+
if (href.startsWith("//")) diagnostics.VUE_ROUTER_R0003({
|
|
2742
|
+
location: rawLocation,
|
|
2743
|
+
href
|
|
2744
|
+
});
|
|
2745
|
+
else if (!matchedRoute.matched.length) diagnostics.VUE_ROUTER_R0004({ path: rawLocation.path != null ? rawLocation.path : rawLocation });
|
|
2454
2746
|
}
|
|
2455
2747
|
return assign({
|
|
2456
2748
|
fullPath,
|
|
@@ -2465,7 +2757,7 @@ function createRouter(options) {
|
|
|
2465
2757
|
return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
|
|
2466
2758
|
}
|
|
2467
2759
|
function checkCanceledNavigation(to, from) {
|
|
2468
|
-
if (pendingLocation !== to) return createRouterError(
|
|
2760
|
+
if (pendingLocation !== to) return createRouterError(8, {
|
|
2469
2761
|
from,
|
|
2470
2762
|
to
|
|
2471
2763
|
});
|
|
@@ -2486,7 +2778,10 @@ function createRouter(options) {
|
|
|
2486
2778
|
newTargetLocation.params = {};
|
|
2487
2779
|
}
|
|
2488
2780
|
if (process.env.NODE_ENV !== "production" && newTargetLocation.path == null && !("name" in newTargetLocation)) {
|
|
2489
|
-
|
|
2781
|
+
diagnostics.VUE_ROUTER_R0008({
|
|
2782
|
+
target: JSON.stringify(newTargetLocation, null, 2),
|
|
2783
|
+
to: to.fullPath
|
|
2784
|
+
});
|
|
2490
2785
|
throw new Error("Invalid redirect");
|
|
2491
2786
|
}
|
|
2492
2787
|
return assign({
|
|
@@ -2501,38 +2796,41 @@ function createRouter(options) {
|
|
|
2501
2796
|
const from = currentRoute.value;
|
|
2502
2797
|
const data = to.state;
|
|
2503
2798
|
const force = to.force;
|
|
2504
|
-
const replace
|
|
2799
|
+
const replace = to.replace === true;
|
|
2505
2800
|
const shouldRedirect = handleRedirectRecord(targetLocation, from);
|
|
2506
2801
|
if (shouldRedirect) return pushWithRedirect(assign(locationAsObject(shouldRedirect), {
|
|
2507
2802
|
state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
|
|
2508
2803
|
force,
|
|
2509
|
-
replace
|
|
2804
|
+
replace
|
|
2510
2805
|
}), redirectedFrom || targetLocation);
|
|
2511
2806
|
const toLocation = targetLocation;
|
|
2512
2807
|
toLocation.redirectedFrom = redirectedFrom;
|
|
2513
2808
|
let failure;
|
|
2514
2809
|
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
|
|
2515
|
-
failure = createRouterError(
|
|
2810
|
+
failure = createRouterError(16, {
|
|
2516
2811
|
to: toLocation,
|
|
2517
2812
|
from
|
|
2518
2813
|
});
|
|
2519
2814
|
handleScroll(from, from, true, false);
|
|
2520
2815
|
}
|
|
2521
|
-
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? isNavigationFailure(error,
|
|
2522
|
-
if (failure
|
|
2523
|
-
if (isNavigationFailure(failure
|
|
2524
|
-
if (process.env.NODE_ENV !== "production" && isSameRouteLocation(stringifyQuery$1, resolve(failure
|
|
2525
|
-
|
|
2816
|
+
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? isNavigationFailure(error, 2) ? error : markAsReady(error) : triggerError(error, toLocation, from)).then((failure) => {
|
|
2817
|
+
if (failure) {
|
|
2818
|
+
if (isNavigationFailure(failure, 2)) {
|
|
2819
|
+
if (process.env.NODE_ENV !== "production" && isSameRouteLocation(stringifyQuery$1, resolve(failure.to), toLocation) && redirectedFrom && (redirectedFrom._count = redirectedFrom._count ? redirectedFrom._count + 1 : 1) > 30) {
|
|
2820
|
+
diagnostics.VUE_ROUTER_R0009({
|
|
2821
|
+
from: from.fullPath,
|
|
2822
|
+
to: toLocation.fullPath
|
|
2823
|
+
});
|
|
2526
2824
|
return Promise.reject(/* @__PURE__ */ new Error("Infinite redirect in navigation guard"));
|
|
2527
2825
|
}
|
|
2528
|
-
return pushWithRedirect(assign({ replace
|
|
2529
|
-
state: typeof failure
|
|
2826
|
+
return pushWithRedirect(assign({ replace }, locationAsObject(failure.to), {
|
|
2827
|
+
state: typeof failure.to === "object" ? assign({}, data, failure.to.state) : data,
|
|
2530
2828
|
force
|
|
2531
2829
|
}), redirectedFrom || toLocation);
|
|
2532
2830
|
}
|
|
2533
|
-
} else failure
|
|
2534
|
-
triggerAfterEach(toLocation, from, failure
|
|
2535
|
-
return failure
|
|
2831
|
+
} else failure = finalizeNavigation(toLocation, from, true, replace, data);
|
|
2832
|
+
triggerAfterEach(toLocation, from, failure);
|
|
2833
|
+
return failure;
|
|
2536
2834
|
});
|
|
2537
2835
|
}
|
|
2538
2836
|
/**
|
|
@@ -2571,8 +2869,10 @@ function createRouter(options) {
|
|
|
2571
2869
|
return runGuardQueue(guards);
|
|
2572
2870
|
}).then(() => {
|
|
2573
2871
|
guards = [];
|
|
2574
|
-
for (const record of enteringRecords) if (record.beforeEnter)
|
|
2575
|
-
|
|
2872
|
+
for (const record of enteringRecords) if (record.beforeEnter) {
|
|
2873
|
+
if (isArray(record.beforeEnter)) for (const beforeEnter of record.beforeEnter) guards.push(guardToPromiseFn(beforeEnter, to, from));
|
|
2874
|
+
else guards.push(guardToPromiseFn(record.beforeEnter, to, from));
|
|
2875
|
+
}
|
|
2576
2876
|
guards.push(canceledNavigationCheck);
|
|
2577
2877
|
return runGuardQueue(guards);
|
|
2578
2878
|
}).then(() => {
|
|
@@ -2585,7 +2885,7 @@ function createRouter(options) {
|
|
|
2585
2885
|
for (const guard of beforeResolveGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
|
|
2586
2886
|
guards.push(canceledNavigationCheck);
|
|
2587
2887
|
return runGuardQueue(guards);
|
|
2588
|
-
}).catch((err) => isNavigationFailure(err,
|
|
2888
|
+
}).catch((err) => isNavigationFailure(err, 8) ? err : Promise.reject(err));
|
|
2589
2889
|
}
|
|
2590
2890
|
function triggerAfterEach(to, from, failure) {
|
|
2591
2891
|
afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
|
|
@@ -2595,13 +2895,15 @@ function createRouter(options) {
|
|
|
2595
2895
|
* - Changes the url if necessary
|
|
2596
2896
|
* - Calls the scrollBehavior
|
|
2597
2897
|
*/
|
|
2598
|
-
function finalizeNavigation(toLocation, from, isPush, replace
|
|
2898
|
+
function finalizeNavigation(toLocation, from, isPush, replace, data) {
|
|
2599
2899
|
const error = checkCanceledNavigation(toLocation, from);
|
|
2600
2900
|
if (error) return error;
|
|
2601
2901
|
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
|
|
2602
2902
|
const state = !isBrowser ? {} : history.state;
|
|
2603
|
-
if (isPush)
|
|
2604
|
-
|
|
2903
|
+
if (isPush) {
|
|
2904
|
+
if (replace || isFirstNavigation) routerHistory.replace(toLocation.fullPath, assign({ scroll: isFirstNavigation && state && state.scroll }, data));
|
|
2905
|
+
else routerHistory.push(toLocation.fullPath, data);
|
|
2906
|
+
}
|
|
2605
2907
|
currentRoute.value = toLocation;
|
|
2606
2908
|
handleScroll(toLocation, from, isPush, isFirstNavigation);
|
|
2607
2909
|
markAsReady();
|
|
@@ -2622,12 +2924,12 @@ function createRouter(options) {
|
|
|
2622
2924
|
}
|
|
2623
2925
|
pendingLocation = toLocation;
|
|
2624
2926
|
const from = currentRoute.value;
|
|
2625
|
-
if (isBrowser) saveScrollPosition(getScrollKey(from.fullPath, info.delta)
|
|
2927
|
+
if (isBrowser && info.delta) saveScrollPosition(getScrollKey(from.fullPath, info.delta));
|
|
2626
2928
|
navigate(toLocation, from).catch((error) => {
|
|
2627
|
-
if (isNavigationFailure(error,
|
|
2628
|
-
if (isNavigationFailure(error,
|
|
2929
|
+
if (isNavigationFailure(error, 12)) return error;
|
|
2930
|
+
if (isNavigationFailure(error, 2)) {
|
|
2629
2931
|
pushWithRedirect(assign(locationAsObject(error.to), { force: true }), toLocation).then((failure) => {
|
|
2630
|
-
if (isNavigationFailure(failure,
|
|
2932
|
+
if (isNavigationFailure(failure, 20) && !info.delta && info.type === "pop") routerHistory.go(-1, false);
|
|
2631
2933
|
}).catch(noop);
|
|
2632
2934
|
return Promise.reject();
|
|
2633
2935
|
}
|
|
@@ -2636,8 +2938,8 @@ function createRouter(options) {
|
|
|
2636
2938
|
}).then((failure) => {
|
|
2637
2939
|
failure = failure || finalizeNavigation(toLocation, from, false);
|
|
2638
2940
|
if (failure) {
|
|
2639
|
-
if (info.delta && !isNavigationFailure(failure,
|
|
2640
|
-
else if (info.type ===
|
|
2941
|
+
if (info.delta && !isNavigationFailure(failure, 8)) routerHistory.go(-info.delta, false);
|
|
2942
|
+
else if (info.type === "pop" && isNavigationFailure(failure, 20)) routerHistory.go(-1, false);
|
|
2641
2943
|
}
|
|
2642
2944
|
triggerAfterEach(toLocation, from, failure);
|
|
2643
2945
|
}).catch(noop);
|
|
@@ -2659,22 +2961,22 @@ function createRouter(options) {
|
|
|
2659
2961
|
const list = errorListeners.list();
|
|
2660
2962
|
if (list.length) list.forEach((handler) => handler(error, to, from));
|
|
2661
2963
|
else {
|
|
2662
|
-
if (process.env.NODE_ENV !== "production")
|
|
2964
|
+
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0010();
|
|
2663
2965
|
console.error(error);
|
|
2664
2966
|
}
|
|
2665
2967
|
return Promise.reject(error);
|
|
2666
2968
|
}
|
|
2667
2969
|
function isReady() {
|
|
2668
2970
|
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED) return Promise.resolve();
|
|
2669
|
-
return new Promise((resolve
|
|
2670
|
-
readyHandlers.add([resolve
|
|
2971
|
+
return new Promise((resolve, reject) => {
|
|
2972
|
+
readyHandlers.add([resolve, reject]);
|
|
2671
2973
|
});
|
|
2672
2974
|
}
|
|
2673
2975
|
function markAsReady(err) {
|
|
2674
2976
|
if (!ready) {
|
|
2675
2977
|
ready = !err;
|
|
2676
2978
|
setupListeners();
|
|
2677
|
-
readyHandlers.list().forEach(([resolve
|
|
2979
|
+
readyHandlers.list().forEach(([resolve, reject]) => err ? reject(err) : resolve());
|
|
2678
2980
|
readyHandlers.reset();
|
|
2679
2981
|
}
|
|
2680
2982
|
return err;
|
|
@@ -2683,7 +2985,7 @@ function createRouter(options) {
|
|
|
2683
2985
|
const { scrollBehavior } = options;
|
|
2684
2986
|
if (!isBrowser || !scrollBehavior) return Promise.resolve();
|
|
2685
2987
|
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
|
|
2686
|
-
return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to, from));
|
|
2988
|
+
return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => to === currentRoute.value && position && scrollToPosition(position)).catch((err) => to === currentRoute.value && triggerError(err, to, from));
|
|
2687
2989
|
}
|
|
2688
2990
|
const go = (delta) => routerHistory.go(delta);
|
|
2689
2991
|
let started;
|
|
@@ -2693,7 +2995,7 @@ function createRouter(options) {
|
|
|
2693
2995
|
listening: true,
|
|
2694
2996
|
addRoute,
|
|
2695
2997
|
removeRoute,
|
|
2696
|
-
clearRoutes
|
|
2998
|
+
clearRoutes,
|
|
2697
2999
|
hasRoute,
|
|
2698
3000
|
getRoutes,
|
|
2699
3001
|
resolve,
|
|
@@ -2719,7 +3021,7 @@ function createRouter(options) {
|
|
|
2719
3021
|
if (isBrowser && !started && currentRoute.value === START_LOCATION_NORMALIZED) {
|
|
2720
3022
|
started = true;
|
|
2721
3023
|
push(routerHistory.location).catch((err) => {
|
|
2722
|
-
if (process.env.NODE_ENV !== "production")
|
|
3024
|
+
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0011({ cause: err });
|
|
2723
3025
|
});
|
|
2724
3026
|
}
|
|
2725
3027
|
const reactiveRoute = {};
|
|
@@ -2744,7 +3046,7 @@ function createRouter(options) {
|
|
|
2744
3046
|
}
|
|
2745
3047
|
unmountApp();
|
|
2746
3048
|
};
|
|
2747
|
-
if ((process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) && isBrowser) addDevtools(app, router, matcher);
|
|
3049
|
+
if ((process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) && isBrowser && true) addDevtools(app, router, matcher);
|
|
2748
3050
|
}
|
|
2749
3051
|
};
|
|
2750
3052
|
function runGuardQueue(guards) {
|
|
@@ -2753,21 +3055,4 @@ function createRouter(options) {
|
|
|
2753
3055
|
return router;
|
|
2754
3056
|
}
|
|
2755
3057
|
|
|
2756
|
-
//#endregion
|
|
2757
|
-
//#region src/useApi.ts
|
|
2758
|
-
/**
|
|
2759
|
-
* Returns the router instance. Equivalent to using `$router` inside
|
|
2760
|
-
* templates.
|
|
2761
|
-
*/
|
|
2762
|
-
function useRouter() {
|
|
2763
|
-
return inject(routerKey);
|
|
2764
|
-
}
|
|
2765
|
-
/**
|
|
2766
|
-
* Returns the current route location. Equivalent to using `$route` inside
|
|
2767
|
-
* templates.
|
|
2768
|
-
*/
|
|
2769
|
-
function useRoute(_name) {
|
|
2770
|
-
return inject(routeLocationKey);
|
|
2771
|
-
}
|
|
2772
|
-
|
|
2773
3058
|
export { NavigationFailureType, RouterLink, RouterView, START_LOCATION_NORMALIZED as START_LOCATION, createMemoryHistory, createRouter, createRouterMatcher, createWebHashHistory, createWebHistory, isNavigationFailure, loadRouteLocation, matchedRouteKey, onBeforeRouteLeave, onBeforeRouteUpdate, parseQuery, routeLocationKey, routerKey, routerViewLocationKey, stringifyQuery, useLink, useRoute, useRouter, viewDepthKey };
|