@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
package/dist/client/node_modules/vue-router/dist/{router-CWoNjPRp.d.mts → index-D7ja2BKs.d.ts}
RENAMED
|
@@ -1,71 +1,62 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-router
|
|
3
|
-
* (c)
|
|
2
|
+
* vue-router v5.3.1
|
|
3
|
+
* (c) 2026 Eduardo San Martin Morote
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import { App, Component, ComponentPublicInstance, DefineComponent, Ref, ShallowRef } from "vue";
|
|
7
|
-
|
|
8
|
-
//#region src/query.d.ts
|
|
9
|
-
|
|
6
|
+
import { AllowedComponentProps, AnchorHTMLAttributes, App, Component as Component$1, ComponentCustomProps, ComponentPublicInstance, ComputedRef, DefineComponent, EffectScope, InjectionKey, MaybeRef, Ref, ShallowRef, UnwrapRef, VNode, VNodeProps } from "vue";
|
|
7
|
+
//#region src/experimental/data-loaders/symbols.d.ts
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
* param but without an `=`.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```
|
|
16
|
-
* ?isNull&isEmpty=&other=other
|
|
17
|
-
* gives
|
|
18
|
-
* `{ isNull: null, isEmpty: '', other: 'other' }`.
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
9
|
+
* Retrieves the internal version of loaders.
|
|
21
10
|
* @internal
|
|
22
11
|
*/
|
|
23
|
-
|
|
12
|
+
declare const LOADER_SET_KEY: unique symbol;
|
|
24
13
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
14
|
+
* Retrieves the internal version of loader entries.
|
|
27
15
|
* @internal
|
|
28
16
|
*/
|
|
29
|
-
|
|
17
|
+
declare const LOADER_ENTRIES_KEY: unique symbol;
|
|
30
18
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
19
|
+
* Added to the loaders returned by `defineLoader()` to identify them.
|
|
20
|
+
* Allows to extract exported useData() from a component.
|
|
21
|
+
* @internal
|
|
34
22
|
*/
|
|
35
|
-
|
|
23
|
+
declare const IS_USE_DATA_LOADER_KEY: unique symbol;
|
|
36
24
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* {@link RouteLocationRaw}
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
25
|
+
* Symbol used to save the pending location on the router.
|
|
26
|
+
* @internal
|
|
42
27
|
*/
|
|
43
|
-
|
|
28
|
+
declare const PENDING_LOCATION_KEY: unique symbol;
|
|
44
29
|
/**
|
|
45
|
-
*
|
|
46
|
-
* version with the leading `?` and without Should work as URLSearchParams
|
|
47
|
-
|
|
30
|
+
* Symbol used to know there is no value staged for the loader and that commit should be skipped.
|
|
48
31
|
* @internal
|
|
49
|
-
*
|
|
50
|
-
* @param search - search string to parse
|
|
51
|
-
* @returns a query object
|
|
52
32
|
*/
|
|
53
|
-
declare
|
|
33
|
+
declare const STAGED_NO_VALUE: unique symbol;
|
|
54
34
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
|
|
35
|
+
* Gives access to the current app and it's `runWithContext` method.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
declare const APP_KEY: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* Gives access to an AbortController that aborts when the navigation is canceled.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
declare const ABORT_CONTROLLER_KEY: unique symbol;
|
|
44
|
+
/**
|
|
45
|
+
* Symbol used to save the initial data on the router.
|
|
58
46
|
* @internal
|
|
59
|
-
*
|
|
60
|
-
* @param query - query object to stringify
|
|
61
|
-
* @returns string version of the query without the leading `?`
|
|
62
47
|
*/
|
|
63
|
-
declare
|
|
48
|
+
declare const IS_SSR_KEY: unique symbol;
|
|
49
|
+
/**
|
|
50
|
+
* Symbol used to get the effect scope used for data loaders.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
declare const DATA_LOADERS_EFFECT_SCOPE_KEY: unique symbol;
|
|
64
54
|
//#endregion
|
|
65
55
|
//#region src/config.d.ts
|
|
66
56
|
/**
|
|
67
57
|
* Allows customizing existing types of the router that are used globally like `$router`, `<RouterLink>`, etc. **ONLY FOR INTERNAL USAGE**.
|
|
68
58
|
*
|
|
59
|
+
* - `Router` - swaps the public {@link Router} type (e.g. to `EXPERIMENTAL_Router`)
|
|
69
60
|
* - `$router` - the router instance
|
|
70
61
|
* - `$route` - the current route location
|
|
71
62
|
* - `beforeRouteEnter` - Page component option
|
|
@@ -78,353 +69,89 @@ declare function stringifyQuery(query: LocationQueryRaw | undefined): string;
|
|
|
78
69
|
*/
|
|
79
70
|
interface TypesConfig {}
|
|
80
71
|
//#endregion
|
|
81
|
-
//#region src/
|
|
82
|
-
/**
|
|
83
|
-
* Helper type to define a Typed `RouteRecord`
|
|
84
|
-
* @see {@link RouteRecord}
|
|
85
|
-
*/
|
|
86
|
-
interface RouteRecordInfo<Name extends string | symbol = string, Path extends string = string, ParamsRaw extends RouteParamsRawGeneric = RouteParamsRawGeneric, Params extends RouteParamsGeneric = RouteParamsGeneric, ChildrenNames extends string | symbol = never> {
|
|
87
|
-
name: Name;
|
|
88
|
-
path: Path;
|
|
89
|
-
paramsRaw: ParamsRaw;
|
|
90
|
-
params: Params;
|
|
91
|
-
childrenNames: ChildrenNames;
|
|
92
|
-
}
|
|
93
|
-
type RouteRecordInfoGeneric = RouteRecordInfo<string | symbol, string, RouteParamsRawGeneric, RouteParamsGeneric, string | symbol>;
|
|
94
|
-
/**
|
|
95
|
-
* Convenience type to get the typed RouteMap or a generic one if not provided. It is extracted from the {@link TypesConfig} if it exists, it becomes {@link RouteMapGeneric} otherwise.
|
|
96
|
-
*/
|
|
97
|
-
type RouteMap = TypesConfig extends Record<'RouteNamedMap', infer RouteNamedMap> ? RouteNamedMap : RouteMapGeneric;
|
|
98
|
-
/**
|
|
99
|
-
* Generic version of the `RouteMap`.
|
|
100
|
-
*/
|
|
101
|
-
type RouteMapGeneric = Record<string | symbol, RouteRecordInfoGeneric>;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/typed-routes/params.d.ts
|
|
104
|
-
/**
|
|
105
|
-
* Utility type for raw and non raw params like :id+
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
type ParamValueOneOrMore<isRaw extends boolean> = [ParamValue<isRaw>, ...ParamValue<isRaw>[]];
|
|
72
|
+
//#region src/query.d.ts
|
|
109
73
|
/**
|
|
110
|
-
*
|
|
74
|
+
* Possible values in normalized {@link LocationQuery}. `null` renders the query
|
|
75
|
+
* param but without an `=`.
|
|
111
76
|
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```
|
|
79
|
+
* ?isNull&isEmpty=&other=other
|
|
80
|
+
* gives
|
|
81
|
+
* `{ isNull: null, isEmpty: '', other: 'other' }`.
|
|
82
|
+
* ```
|
|
116
83
|
*
|
|
84
|
+
* @internal
|
|
117
85
|
*/
|
|
118
|
-
type
|
|
86
|
+
type LocationQueryValue$1 = string | null;
|
|
119
87
|
/**
|
|
120
|
-
*
|
|
88
|
+
* Possible values when defining a query. `undefined` allows to remove a value.
|
|
121
89
|
*
|
|
122
|
-
*/
|
|
123
|
-
type ParamValue<isRaw extends boolean> = true extends isRaw ? string | number : string;
|
|
124
|
-
/**
|
|
125
|
-
* Generate a type safe params for a route location. Requires the name of the route to be passed as a generic.
|
|
126
|
-
* @see {@link RouteParamsGeneric}
|
|
127
|
-
*/
|
|
128
|
-
type RouteParams<Name extends keyof RouteMap = keyof RouteMap> = RouteMap[Name]['params'];
|
|
129
|
-
/**
|
|
130
|
-
* Generate a type safe raw params for a route location. Requires the name of the route to be passed as a generic.
|
|
131
|
-
* @see {@link RouteParamsRaw}
|
|
132
|
-
*/
|
|
133
|
-
type RouteParamsRaw<Name extends keyof RouteMap = keyof RouteMap> = RouteMap[Name]['paramsRaw'];
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/types/utils.d.ts
|
|
136
|
-
/**
|
|
137
|
-
* Creates a union type that still allows autocompletion for strings.
|
|
138
90
|
* @internal
|
|
139
91
|
*/
|
|
140
|
-
type
|
|
92
|
+
type LocationQueryValueRaw$1 = LocationQueryValue$1 | number | undefined;
|
|
141
93
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
94
|
+
* Normalized query object that appears in {@link RouteLocationNormalized}
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
144
97
|
*/
|
|
145
|
-
type
|
|
98
|
+
type LocationQuery$1 = Record<string, LocationQueryValue$1 | LocationQueryValue$1[]>;
|
|
146
99
|
/**
|
|
147
|
-
* @
|
|
100
|
+
* Loose {@link LocationQuery} object that can be passed to functions like
|
|
101
|
+
* {@link Router.push} and {@link Router.replace} or anywhere when creating a
|
|
102
|
+
* {@link RouteLocationRaw}
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
148
105
|
*/
|
|
149
|
-
type
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/typed-routes/route-records.d.ts
|
|
106
|
+
type LocationQueryRaw$1 = Record<string | number, LocationQueryValueRaw$1 | LocationQueryValueRaw$1[]>;
|
|
152
107
|
/**
|
|
108
|
+
* Transforms a queryString into a {@link LocationQuery} object. Accept both, a
|
|
109
|
+
* version with the leading `?` and without Should work as URLSearchParams
|
|
153
110
|
* @internal
|
|
154
|
-
*/
|
|
155
|
-
type RouteRecordRedirectOption = RouteLocationRaw | ((to: RouteLocation, from: RouteLocationNormalizedLoaded) => RouteLocationRaw);
|
|
156
|
-
/**
|
|
157
|
-
* Generic version of {@link RouteRecordName}.
|
|
158
|
-
*/
|
|
159
|
-
type RouteRecordNameGeneric = string | symbol | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* Possible values for a route record **after normalization**
|
|
162
111
|
*
|
|
163
|
-
*
|
|
112
|
+
* @param search - search string to parse
|
|
113
|
+
* @returns a query object
|
|
164
114
|
*/
|
|
165
|
-
|
|
115
|
+
declare function parseQuery(search: string): LocationQuery$1;
|
|
166
116
|
/**
|
|
117
|
+
* Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
|
|
118
|
+
* doesn't prepend a `?`
|
|
119
|
+
*
|
|
167
120
|
* @internal
|
|
121
|
+
*
|
|
122
|
+
* @param query - query object to stringify
|
|
123
|
+
* @returns string version of the query without the leading `?`
|
|
168
124
|
*/
|
|
169
|
-
|
|
125
|
+
declare function stringifyQuery(query: LocationQueryRaw$1 | undefined): string;
|
|
170
126
|
//#endregion
|
|
171
|
-
//#region src/
|
|
127
|
+
//#region src/matcher/types.d.ts
|
|
172
128
|
/**
|
|
173
|
-
*
|
|
129
|
+
* Normalized version of a {@link RouteRecord | route record}.
|
|
174
130
|
*/
|
|
175
|
-
interface
|
|
131
|
+
interface RouteRecordNormalized {
|
|
176
132
|
/**
|
|
177
|
-
*
|
|
178
|
-
* passed when adding records. It can also contain redirect records. This
|
|
179
|
-
* can't be used directly. **This property is non-enumerable**.
|
|
133
|
+
* {@inheritDoc _RouteRecordBase.path}
|
|
180
134
|
*/
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Helper to generate a type safe version of the {@link RouteLocation} type.
|
|
185
|
-
*/
|
|
186
|
-
interface RouteLocationTyped<RouteMap$1 extends RouteMapGeneric, Name extends keyof RouteMap$1> extends RouteLocationGeneric {
|
|
187
|
-
name: Extract<Name, string | symbol>;
|
|
188
|
-
params: RouteMap$1[Name]['params'];
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* List of all possible {@link RouteLocation} indexed by the route name.
|
|
192
|
-
* @internal
|
|
193
|
-
*/
|
|
194
|
-
type RouteLocationTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationTyped<RouteMap$1, N> };
|
|
195
|
-
/**
|
|
196
|
-
* Generic version of {@link RouteLocationNormalized} that is used when no {@link RouteMap} is provided.
|
|
197
|
-
*/
|
|
198
|
-
interface RouteLocationNormalizedGeneric extends _RouteLocationBase {
|
|
199
|
-
name: RouteRecordNameGeneric;
|
|
135
|
+
path: _RouteRecordBase['path'];
|
|
200
136
|
/**
|
|
201
|
-
*
|
|
137
|
+
* {@inheritDoc _RouteRecordBase.redirect}
|
|
202
138
|
*/
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Helper to generate a type safe version of the {@link RouteLocationNormalized} type.
|
|
207
|
-
*/
|
|
208
|
-
interface RouteLocationNormalizedTyped<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric, Name extends keyof RouteMap$1 = keyof RouteMap$1> extends RouteLocationNormalizedGeneric {
|
|
209
|
-
name: Extract<Name, string | symbol>;
|
|
210
|
-
params: RouteMap$1[Name]['params'];
|
|
139
|
+
redirect: _RouteRecordBase['redirect'] | undefined;
|
|
211
140
|
/**
|
|
212
|
-
*
|
|
141
|
+
* {@inheritDoc _RouteRecordBase.name}
|
|
213
142
|
*/
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* List of all possible {@link RouteLocationNormalized} indexed by the route name.
|
|
218
|
-
* @internal
|
|
219
|
-
*/
|
|
220
|
-
type RouteLocationNormalizedTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationNormalizedTyped<RouteMap$1, N> };
|
|
221
|
-
/**
|
|
222
|
-
* Generic version of {@link RouteLocationNormalizedLoaded} that is used when no {@link RouteMap} is provided.
|
|
223
|
-
*/
|
|
224
|
-
interface RouteLocationNormalizedLoadedGeneric extends RouteLocationNormalizedGeneric {
|
|
143
|
+
name: _RouteRecordBase['name'];
|
|
225
144
|
/**
|
|
226
|
-
*
|
|
227
|
-
* lazy-loaded components have been loaded and were replaced inside the
|
|
228
|
-
* `components` object) so it can be directly used to display routes. It
|
|
229
|
-
* cannot contain redirect records either. **This property is non-enumerable**.
|
|
145
|
+
* {@inheritDoc RouteRecordMultipleViews.components}
|
|
230
146
|
*/
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Helper to generate a type safe version of the {@link RouteLocationNormalizedLoaded} type.
|
|
235
|
-
*/
|
|
236
|
-
interface RouteLocationNormalizedLoadedTyped<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric, Name extends keyof RouteMap$1 = keyof RouteMap$1> extends RouteLocationNormalizedLoadedGeneric {
|
|
237
|
-
name: Extract<Name, string | symbol>;
|
|
238
|
-
params: RouteMap$1[Name]['params'];
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* List of all possible {@link RouteLocationNormalizedLoaded} indexed by the route name.
|
|
242
|
-
* @internal
|
|
243
|
-
*/
|
|
244
|
-
type RouteLocationNormalizedLoadedTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationNormalizedLoadedTyped<RouteMap$1, N> };
|
|
245
|
-
/**
|
|
246
|
-
* Generic version of {@link RouteLocationAsRelative}. It is used when no {@link RouteMap} is provided.
|
|
247
|
-
*/
|
|
248
|
-
interface RouteLocationAsRelativeGeneric extends RouteQueryAndHash, RouteLocationOptions {
|
|
249
|
-
name?: RouteRecordNameGeneric;
|
|
250
|
-
params?: RouteParamsRawGeneric;
|
|
147
|
+
components: RouteRecordMultipleViews['components'] | null | undefined;
|
|
251
148
|
/**
|
|
252
|
-
*
|
|
149
|
+
* Contains the original modules for lazy loaded components.
|
|
150
|
+
* @internal
|
|
253
151
|
*/
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Helper to generate a type safe version of the {@link RouteLocationAsRelative} type.
|
|
258
|
-
*/
|
|
259
|
-
interface RouteLocationAsRelativeTyped<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric, Name extends keyof RouteMap$1 = keyof RouteMap$1> extends RouteLocationAsRelativeGeneric {
|
|
260
|
-
name?: Extract<Name, string | symbol>;
|
|
261
|
-
params?: RouteMap$1[Name]['paramsRaw'];
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* List of all possible {@link RouteLocationAsRelative} indexed by the route name.
|
|
265
|
-
* @internal
|
|
266
|
-
*/
|
|
267
|
-
type RouteLocationAsRelativeTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationAsRelativeTyped<RouteMap$1, N> };
|
|
268
|
-
/**
|
|
269
|
-
* Generic version of {@link RouteLocationAsPath}. It is used when no {@link RouteMap} is provided.
|
|
270
|
-
*/
|
|
271
|
-
interface RouteLocationAsPathGeneric extends RouteQueryAndHash, RouteLocationOptions {
|
|
152
|
+
mods: Record<string, unknown>;
|
|
272
153
|
/**
|
|
273
|
-
*
|
|
274
|
-
*/
|
|
275
|
-
path: string;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Helper to generate a type safe version of the {@link RouteLocationAsPath} type.
|
|
279
|
-
*/
|
|
280
|
-
interface RouteLocationAsPathTyped<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric, Name extends keyof RouteMap$1 = keyof RouteMap$1> extends RouteLocationAsPathGeneric {
|
|
281
|
-
path: _LiteralUnion<RouteMap$1[Name]['path']>;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* List of all possible {@link RouteLocationAsPath} indexed by the route name.
|
|
285
|
-
* @internal
|
|
286
|
-
*/
|
|
287
|
-
type RouteLocationAsPathTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationAsPathTyped<RouteMap$1, N> };
|
|
288
|
-
/**
|
|
289
|
-
* Helper to generate a type safe version of the {@link RouteLocationAsString} type.
|
|
290
|
-
*/
|
|
291
|
-
type RouteLocationAsStringTyped<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric, Name extends keyof RouteMap$1 = keyof RouteMap$1> = RouteMap$1[Name]['path'];
|
|
292
|
-
/**
|
|
293
|
-
* List of all possible {@link RouteLocationAsString} indexed by the route name.
|
|
294
|
-
* @internal
|
|
295
|
-
*/
|
|
296
|
-
type RouteLocationAsStringTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationAsStringTyped<RouteMap$1, N> };
|
|
297
|
-
/**
|
|
298
|
-
* Generic version of {@link RouteLocationResolved}. It is used when no {@link RouteMap} is provided.
|
|
299
|
-
*/
|
|
300
|
-
interface RouteLocationResolvedGeneric extends RouteLocationGeneric {
|
|
301
|
-
/**
|
|
302
|
-
* Resolved `href` for the route location that will be set on the `<a href="...">`.
|
|
303
|
-
*/
|
|
304
|
-
href: string;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Helper to generate a type safe version of the {@link RouteLocationResolved} type.
|
|
308
|
-
*/
|
|
309
|
-
interface RouteLocationResolvedTyped<RouteMap$1 extends RouteMapGeneric, Name extends keyof RouteMap$1> extends RouteLocationTyped<RouteMap$1, Name> {
|
|
310
|
-
/**
|
|
311
|
-
* Resolved `href` for the route location that will be set on the `<a href="...">`.
|
|
312
|
-
*/
|
|
313
|
-
href: string;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* List of all possible {@link RouteLocationResolved} indexed by the route name.
|
|
317
|
-
* @internal
|
|
318
|
-
*/
|
|
319
|
-
type RouteLocationResolvedTypedList<RouteMap$1 extends RouteMapGeneric = RouteMapGeneric> = { [N in keyof RouteMap$1]: RouteLocationResolvedTyped<RouteMap$1, N> };
|
|
320
|
-
/**
|
|
321
|
-
* Type safe versions of types that are exposed by vue-router. We have to use a generic check to allow for names to be `undefined` when no `RouteMap` is provided.
|
|
322
|
-
*/
|
|
323
|
-
/**
|
|
324
|
-
* {@link RouteLocationRaw} resolved using the matcher
|
|
325
|
-
*/
|
|
326
|
-
type RouteLocation<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationGeneric : RouteLocationTypedList<RouteMap>[Name];
|
|
327
|
-
/**
|
|
328
|
-
* Similar to {@link RouteLocation} but its
|
|
329
|
-
* {@link RouteLocationNormalizedTyped.matched | `matched` property} cannot contain redirect records
|
|
330
|
-
*/
|
|
331
|
-
type RouteLocationNormalized<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationNormalizedGeneric : RouteLocationNormalizedTypedList<RouteMap>[Name];
|
|
332
|
-
/**
|
|
333
|
-
* Similar to {@link RouteLocationNormalized} but its `components` do not contain any function to lazy load components.
|
|
334
|
-
* In other words, it's ready to be rendered by `<RouterView>`.
|
|
335
|
-
*/
|
|
336
|
-
type RouteLocationNormalizedLoaded<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationNormalizedLoadedGeneric : RouteLocationNormalizedLoadedTypedList<RouteMap>[Name];
|
|
337
|
-
/**
|
|
338
|
-
* Route location relative to the current location. It accepts other properties than `path` like `params`, `query` and
|
|
339
|
-
* `hash` to conveniently change them.
|
|
340
|
-
*/
|
|
341
|
-
type RouteLocationAsRelative<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationAsRelativeGeneric : RouteLocationAsRelativeTypedList<RouteMap>[Name];
|
|
342
|
-
/**
|
|
343
|
-
* Route location resolved with {@link Router | `router.resolve()`}.
|
|
344
|
-
*/
|
|
345
|
-
type RouteLocationResolved<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationResolvedGeneric : RouteLocationResolvedTypedList<RouteMap>[Name];
|
|
346
|
-
/**
|
|
347
|
-
* Same as {@link RouteLocationAsPath} but as a string literal.
|
|
348
|
-
*/
|
|
349
|
-
type RouteLocationAsString<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? string : _LiteralUnion<RouteLocationAsStringTypedList<RouteMap>[Name], string>;
|
|
350
|
-
/**
|
|
351
|
-
* Route location as an object with a `path` property.
|
|
352
|
-
*/
|
|
353
|
-
type RouteLocationAsPath<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationAsPathGeneric : RouteLocationAsPathTypedList<RouteMap>[Name];
|
|
354
|
-
/**
|
|
355
|
-
* Route location that can be passed to `router.push()` and other user-facing APIs.
|
|
356
|
-
*/
|
|
357
|
-
type RouteLocationRaw<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationAsString | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric : _LiteralUnion<RouteLocationAsStringTypedList<RouteMap>[Name], string> | RouteLocationAsRelativeTypedList<RouteMap>[Name] | RouteLocationAsPathTypedList<RouteMap>[Name];
|
|
358
|
-
//#endregion
|
|
359
|
-
//#region src/typed-routes/navigation-guards.d.ts
|
|
360
|
-
/**
|
|
361
|
-
* Return types for a Navigation Guard. Based on `TypesConfig`
|
|
362
|
-
*
|
|
363
|
-
* @see {@link TypesConfig}
|
|
364
|
-
*/
|
|
365
|
-
type NavigationGuardReturn = void | Error | boolean | RouteLocationRaw;
|
|
366
|
-
/**
|
|
367
|
-
* Navigation Guard with a type parameter for `this`.
|
|
368
|
-
* @see {@link TypesConfig}
|
|
369
|
-
*/
|
|
370
|
-
interface NavigationGuardWithThis<T> {
|
|
371
|
-
(this: T, to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded, next: NavigationGuardNext): _Awaitable<NavigationGuardReturn>;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Navigation Guard.
|
|
375
|
-
*/
|
|
376
|
-
interface NavigationGuard {
|
|
377
|
-
(to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded, next: NavigationGuardNext): _Awaitable<NavigationGuardReturn>;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Navigation hook triggered after a navigation is settled.
|
|
381
|
-
*/
|
|
382
|
-
interface NavigationHookAfter {
|
|
383
|
-
(to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded, failure?: NavigationFailure | void): unknown;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* `next()` callback passed to navigation guards.
|
|
387
|
-
*/
|
|
388
|
-
interface NavigationGuardNext {
|
|
389
|
-
(): void;
|
|
390
|
-
(error: Error): void;
|
|
391
|
-
(location: RouteLocationRaw): void;
|
|
392
|
-
(valid: boolean | undefined): void;
|
|
393
|
-
(cb: NavigationGuardNextCallback): void;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Callback that can be passed to `next()` in `beforeRouteEnter()` guards.
|
|
397
|
-
*/
|
|
398
|
-
type NavigationGuardNextCallback = (vm: ComponentPublicInstance) => unknown;
|
|
399
|
-
//#endregion
|
|
400
|
-
//#region src/matcher/types.d.ts
|
|
401
|
-
/**
|
|
402
|
-
* Normalized version of a {@link RouteRecord | route record}.
|
|
403
|
-
*/
|
|
404
|
-
interface RouteRecordNormalized {
|
|
405
|
-
/**
|
|
406
|
-
* {@inheritDoc _RouteRecordBase.path}
|
|
407
|
-
*/
|
|
408
|
-
path: _RouteRecordBase['path'];
|
|
409
|
-
/**
|
|
410
|
-
* {@inheritDoc _RouteRecordBase.redirect}
|
|
411
|
-
*/
|
|
412
|
-
redirect: _RouteRecordBase['redirect'] | undefined;
|
|
413
|
-
/**
|
|
414
|
-
* {@inheritDoc _RouteRecordBase.name}
|
|
415
|
-
*/
|
|
416
|
-
name: _RouteRecordBase['name'];
|
|
417
|
-
/**
|
|
418
|
-
* {@inheritDoc RouteRecordMultipleViews.components}
|
|
419
|
-
*/
|
|
420
|
-
components: RouteRecordMultipleViews['components'] | null | undefined;
|
|
421
|
-
/**
|
|
422
|
-
* Contains the original modules for lazy loaded components.
|
|
423
|
-
* @internal
|
|
424
|
-
*/
|
|
425
|
-
mods: Record<string, unknown>;
|
|
426
|
-
/**
|
|
427
|
-
* Nested route records.
|
|
154
|
+
* Nested route records.
|
|
428
155
|
*/
|
|
429
156
|
children: RouteRecordRaw[];
|
|
430
157
|
/**
|
|
@@ -616,12 +343,12 @@ interface HistoryState {
|
|
|
616
343
|
interface HistoryStateArray extends Array<HistoryStateValue> {}
|
|
617
344
|
declare enum NavigationType {
|
|
618
345
|
pop = "pop",
|
|
619
|
-
push = "push"
|
|
346
|
+
push = "push"
|
|
620
347
|
}
|
|
621
348
|
declare enum NavigationDirection {
|
|
622
349
|
back = "back",
|
|
623
350
|
forward = "forward",
|
|
624
|
-
unknown = ""
|
|
351
|
+
unknown = ""
|
|
625
352
|
}
|
|
626
353
|
interface NavigationInformation {
|
|
627
354
|
type: NavigationType;
|
|
@@ -707,114 +434,1559 @@ interface RouterHistory {
|
|
|
707
434
|
destroy(): void;
|
|
708
435
|
}
|
|
709
436
|
//#endregion
|
|
710
|
-
//#region src/
|
|
711
|
-
type Lazy<T> = () => Promise<T>;
|
|
712
|
-
/**
|
|
713
|
-
* @internal
|
|
714
|
-
*/
|
|
715
|
-
type RouteParamValue = string;
|
|
716
|
-
/**
|
|
717
|
-
* @internal
|
|
718
|
-
*/
|
|
719
|
-
type RouteParamValueRaw = RouteParamValue | number | null | undefined;
|
|
720
|
-
type RouteParamsGeneric = Record<string, RouteParamValue | RouteParamValue[]>;
|
|
721
|
-
type RouteParamsRawGeneric = Record<string, RouteParamValueRaw | Exclude<RouteParamValueRaw, null | undefined>[]>;
|
|
722
|
-
/**
|
|
723
|
-
* @internal
|
|
724
|
-
*/
|
|
725
|
-
interface RouteQueryAndHash {
|
|
726
|
-
query?: LocationQueryRaw;
|
|
727
|
-
hash?: string;
|
|
728
|
-
}
|
|
437
|
+
//#region src/errors.d.ts
|
|
729
438
|
/**
|
|
439
|
+
* Flags so we can combine them when checking for multiple errors. This is the internal version of
|
|
440
|
+
* {@link NavigationFailureType}.
|
|
441
|
+
*
|
|
730
442
|
* @internal
|
|
731
443
|
*/
|
|
732
|
-
|
|
733
|
-
|
|
444
|
+
declare const enum ErrorTypes {
|
|
445
|
+
MATCHER_NOT_FOUND = 1,
|
|
446
|
+
NAVIGATION_GUARD_REDIRECT = 2,
|
|
447
|
+
NAVIGATION_ABORTED = 4,
|
|
448
|
+
NAVIGATION_CANCELLED = 8,
|
|
449
|
+
NAVIGATION_DUPLICATED = 16
|
|
734
450
|
}
|
|
735
451
|
/**
|
|
736
|
-
*
|
|
452
|
+
* Enumeration with all possible types for navigation failures. Can be passed to
|
|
453
|
+
* {@link isNavigationFailure} to check for specific failures.
|
|
737
454
|
*/
|
|
738
|
-
|
|
739
|
-
name: RouteRecordNameGeneric;
|
|
455
|
+
declare enum NavigationFailureType {
|
|
740
456
|
/**
|
|
741
|
-
*
|
|
457
|
+
* An aborted navigation is a navigation that failed because a navigation
|
|
458
|
+
* guard returned `false` or called `next(false)`
|
|
742
459
|
*/
|
|
743
|
-
|
|
744
|
-
params?: RouteParamsGeneric;
|
|
745
|
-
}
|
|
746
|
-
/**
|
|
747
|
-
* @internal
|
|
748
|
-
*/
|
|
749
|
-
interface MatcherLocationAsRelative {
|
|
460
|
+
aborted = 4,
|
|
750
461
|
/**
|
|
751
|
-
*
|
|
462
|
+
* A cancelled navigation is a navigation that failed because a more recent
|
|
463
|
+
* navigation finished started (not necessarily finished).
|
|
752
464
|
*/
|
|
753
|
-
|
|
754
|
-
params?: RouteParamsGeneric;
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* @internal
|
|
758
|
-
*/
|
|
759
|
-
interface LocationAsRelativeRaw {
|
|
760
|
-
name?: RouteRecordNameGeneric;
|
|
465
|
+
cancelled = 8,
|
|
761
466
|
/**
|
|
762
|
-
*
|
|
467
|
+
* A duplicated navigation is a navigation that failed because it was
|
|
468
|
+
* initiated while already being at the exact same location.
|
|
763
469
|
*/
|
|
764
|
-
|
|
765
|
-
params?: RouteParamsRawGeneric;
|
|
470
|
+
duplicated = 16
|
|
766
471
|
}
|
|
767
472
|
/**
|
|
768
|
-
*
|
|
473
|
+
* Extended Error that contains extra information regarding a failed navigation.
|
|
769
474
|
*/
|
|
770
|
-
interface
|
|
475
|
+
interface NavigationFailure extends Error {
|
|
771
476
|
/**
|
|
772
|
-
*
|
|
477
|
+
* Type of the navigation. One of {@link NavigationFailureType}
|
|
773
478
|
*/
|
|
774
|
-
|
|
479
|
+
type: ErrorTypes.NAVIGATION_CANCELLED | ErrorTypes.NAVIGATION_ABORTED | ErrorTypes.NAVIGATION_DUPLICATED;
|
|
775
480
|
/**
|
|
776
|
-
*
|
|
777
|
-
* Note this will also add a new entry to the history unless `replace: true`
|
|
778
|
-
* is passed.
|
|
481
|
+
* Route location we were navigating from
|
|
779
482
|
*/
|
|
780
|
-
|
|
483
|
+
from: RouteLocationNormalized;
|
|
781
484
|
/**
|
|
782
|
-
*
|
|
783
|
-
* values and some primitives like Symbols are forbidden. More info at
|
|
784
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/History/state
|
|
485
|
+
* Route location we were navigating to
|
|
785
486
|
*/
|
|
786
|
-
|
|
487
|
+
to: RouteLocationNormalized;
|
|
787
488
|
}
|
|
788
489
|
/**
|
|
789
|
-
*
|
|
490
|
+
* Internal error used to detect a redirection.
|
|
790
491
|
*
|
|
791
492
|
* @internal
|
|
792
493
|
*/
|
|
793
|
-
interface
|
|
494
|
+
interface NavigationRedirectError extends Omit<NavigationFailure, 'to' | 'type'> {
|
|
495
|
+
type: ErrorTypes.NAVIGATION_GUARD_REDIRECT;
|
|
496
|
+
to: RouteLocationRaw;
|
|
497
|
+
}
|
|
794
498
|
/**
|
|
795
|
-
*
|
|
499
|
+
* Check if an object is a {@link NavigationFailure}.
|
|
796
500
|
*
|
|
797
|
-
* @
|
|
501
|
+
* @param error - possible {@link NavigationFailure}
|
|
502
|
+
* @param type - optional types to check for
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```js
|
|
506
|
+
* import { isNavigationFailure, NavigationFailureType } from 'vue-router'
|
|
507
|
+
*
|
|
508
|
+
* router.afterEach((to, from, failure) => {
|
|
509
|
+
* // Any kind of navigation failure
|
|
510
|
+
* if (isNavigationFailure(failure)) {
|
|
511
|
+
* // ...
|
|
512
|
+
* }
|
|
513
|
+
* // Only duplicated navigations
|
|
514
|
+
* if (isNavigationFailure(failure, NavigationFailureType.duplicated)) {
|
|
515
|
+
* // ...
|
|
516
|
+
* }
|
|
517
|
+
* // Aborted or canceled navigations
|
|
518
|
+
* if (isNavigationFailure(failure, NavigationFailureType.aborted | NavigationFailureType.cancelled )) {
|
|
519
|
+
* // ...
|
|
520
|
+
* }
|
|
521
|
+
* })
|
|
522
|
+
* ```
|
|
798
523
|
*/
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
components: Record<string, RouteComponent> | null | undefined;
|
|
802
|
-
}
|
|
524
|
+
declare function isNavigationFailure(error: any, type?: ErrorTypes.NAVIGATION_GUARD_REDIRECT): error is NavigationRedirectError;
|
|
525
|
+
declare function isNavigationFailure(error: any, type?: ErrorTypes | NavigationFailureType): error is NavigationFailure;
|
|
803
526
|
/**
|
|
804
|
-
*
|
|
527
|
+
* Internal type to define an ErrorHandler
|
|
805
528
|
*
|
|
529
|
+
* @param error - error thrown
|
|
530
|
+
* @param to - location we were navigating to when the error happened
|
|
531
|
+
* @param from - location we were navigating from when the error happened
|
|
806
532
|
* @internal
|
|
807
533
|
*/
|
|
808
|
-
interface
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
534
|
+
interface _ErrorListener {
|
|
535
|
+
(error: any, to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded): any;
|
|
536
|
+
}
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/experimental/query.d.ts
|
|
539
|
+
/**
|
|
540
|
+
* NOTE: some types here are duplicated from ../query.ts
|
|
541
|
+
* because they will change to always have (string | null)[] values
|
|
542
|
+
*/
|
|
543
|
+
/**
|
|
544
|
+
* Possible values in normalized {@link LocationQuery}. `null` renders the query
|
|
545
|
+
* param but without an `=`.
|
|
546
|
+
*
|
|
547
|
+
* @internal
|
|
548
|
+
*/
|
|
549
|
+
type LocationQueryValue = string | null;
|
|
550
|
+
/**
|
|
551
|
+
* Possible values when defining a query. `undefined` allows to remove a value.
|
|
552
|
+
*
|
|
553
|
+
* @internal
|
|
554
|
+
*/
|
|
555
|
+
type LocationQueryValueRaw = LocationQueryValue | number | undefined;
|
|
556
|
+
/**
|
|
557
|
+
* Normalized query object that appears in {@link RouteLocationNormalized}
|
|
558
|
+
*
|
|
559
|
+
* @public
|
|
560
|
+
*/
|
|
561
|
+
type LocationQuery = Record<string, LocationQueryValue | LocationQueryValue[]>;
|
|
562
|
+
/**
|
|
563
|
+
* Loose {@link LocationQuery} object that can be passed to functions like
|
|
564
|
+
* {@link Router.push} and {@link Router.replace} or anywhere when creating a
|
|
565
|
+
* {@link RouteLocationRaw}
|
|
566
|
+
*
|
|
567
|
+
* @public
|
|
568
|
+
*/
|
|
569
|
+
type LocationQueryRaw = Record<string | number, LocationQueryValueRaw | LocationQueryValueRaw[]>;
|
|
570
|
+
/**
|
|
571
|
+
* Transforms a queryString into a {@link LocationQuery} object. Accept both, a
|
|
572
|
+
* version with the leading `?` and without. Uses `Object.create(null)` so the
|
|
573
|
+
* returned object cannot be exploited via prototype pollution.
|
|
574
|
+
*
|
|
575
|
+
* @internal
|
|
576
|
+
*
|
|
577
|
+
* @param search - search string to parse
|
|
578
|
+
* @returns a query object
|
|
579
|
+
*/
|
|
580
|
+
declare function experimental_parseQuery(search: string): LocationQuery;
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/scrollBehavior.d.ts
|
|
583
|
+
/**
|
|
584
|
+
* Scroll position similar to
|
|
585
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions | `ScrollToOptions`}.
|
|
586
|
+
* Note that not all browsers support `behavior`.
|
|
587
|
+
*/
|
|
588
|
+
type ScrollPositionCoordinates = {
|
|
589
|
+
behavior?: ScrollOptions['behavior'];
|
|
590
|
+
left?: number;
|
|
591
|
+
top?: number;
|
|
592
|
+
};
|
|
593
|
+
/**
|
|
594
|
+
* Internal normalized version of {@link ScrollPositionCoordinates} that always
|
|
595
|
+
* has `left` and `top` coordinates. Must be a type to be assignable to HistoryStateValue.
|
|
596
|
+
*
|
|
597
|
+
* @internal
|
|
598
|
+
*/
|
|
599
|
+
type _ScrollPositionNormalized = {
|
|
600
|
+
behavior?: ScrollOptions['behavior'];
|
|
601
|
+
left: number;
|
|
602
|
+
top: number;
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* Type of the `scrollBehavior` option that can be passed to `createRouter`.
|
|
606
|
+
*/
|
|
607
|
+
interface RouterScrollBehavior {
|
|
608
|
+
/**
|
|
609
|
+
* @param to - Route location where we are navigating to
|
|
610
|
+
* @param from - Route location where we are navigating from
|
|
611
|
+
* @param savedPosition - saved position if it exists, `null` otherwise
|
|
612
|
+
*/
|
|
613
|
+
(to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded, savedPosition: _ScrollPositionNormalized | null): Awaitable<ScrollPosition | false | void>;
|
|
614
|
+
}
|
|
615
|
+
interface ScrollPositionElement extends ScrollToOptions {
|
|
616
|
+
/**
|
|
617
|
+
* A valid CSS selector. Note some characters must be escaped in id selectors (https://mathiasbynens.be/notes/css-escapes).
|
|
618
|
+
* @example
|
|
619
|
+
* Here are a few examples:
|
|
620
|
+
*
|
|
621
|
+
* - `.title`
|
|
622
|
+
* - `.content:first-child`
|
|
623
|
+
* - `#marker`
|
|
624
|
+
* - `#marker\~with\~symbols`
|
|
625
|
+
* - `#marker.with.dot`: selects `class="with dot" id="marker"`, not `id="marker.with.dot"`
|
|
626
|
+
*
|
|
627
|
+
*/
|
|
628
|
+
el: string | Element;
|
|
629
|
+
}
|
|
630
|
+
type ScrollPosition = ScrollPositionCoordinates | ScrollPositionElement;
|
|
631
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/experimental/route-resolver/matchers/param-parsers/types.d.ts
|
|
634
|
+
/**
|
|
635
|
+
* Defines a parser that can read a param from the url (string-based) and
|
|
636
|
+
* transform it into a more complex type, or vice versa.
|
|
637
|
+
*
|
|
638
|
+
* @param TParam - the type of the param after parsing as exposed in
|
|
639
|
+
* `route.params`
|
|
640
|
+
*
|
|
641
|
+
* @param TUrlParam - this is the most permissive type that can be passed to
|
|
642
|
+
* get and returned by set. By default it's the type of query path params
|
|
643
|
+
* (stricter as they do not allow `null` within an array or `undefined`). By
|
|
644
|
+
* default it allows undefined because that represents a value that can be
|
|
645
|
+
* omitted and is different from null in query params
|
|
646
|
+
*
|
|
647
|
+
* @param TParamRaw - the type that can be passed as a location when
|
|
648
|
+
* navigating: `router.push({ params: {}})` it's sometimes more permissive than
|
|
649
|
+
* TParam, for example allowing nullish values
|
|
650
|
+
*
|
|
651
|
+
* @see {@link MatcherPattern}
|
|
652
|
+
*/
|
|
653
|
+
interface ParamParser<TParam = MatcherQueryParamsValue, TUrlParam = MatcherQueryParamsValue, TParamRaw = TParam> {
|
|
654
|
+
get?: (value: NoInfer<TUrlParam>) => TParam;
|
|
655
|
+
set?: (value: TParamRaw) => TUrlParam;
|
|
656
|
+
}
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/types/utils.d.ts
|
|
659
|
+
/**
|
|
660
|
+
* Creates a union type that still allows autocompletion for strings.
|
|
661
|
+
* @internal
|
|
662
|
+
*/
|
|
663
|
+
type _LiteralUnion<LiteralType, BaseType extends string = string> = LiteralType | (BaseType & Record<never, never>);
|
|
664
|
+
/**
|
|
665
|
+
* Maybe a promise maybe not
|
|
666
|
+
* @internal
|
|
667
|
+
*/
|
|
668
|
+
type _Awaitable<T> = T | PromiseLike<T>;
|
|
669
|
+
/**
|
|
670
|
+
* @internal
|
|
671
|
+
*/
|
|
672
|
+
type Simplify<T> = { [K in keyof T]: T[K]; } & {};
|
|
673
|
+
//#endregion
|
|
674
|
+
//#region src/experimental/route-resolver/matchers/matcher-pattern.d.ts
|
|
675
|
+
/**
|
|
676
|
+
* Base interface for matcher patterns that extract params from a URL.
|
|
677
|
+
*
|
|
678
|
+
* @template TIn - type of the input value to match against the pattern
|
|
679
|
+
* @template TParams - type of the output value after matching
|
|
680
|
+
* @template TParamsRaw - type of the input value to build the input from
|
|
681
|
+
*
|
|
682
|
+
* In the case of the `path`, the `TIn` is a `string`, but in the case of the
|
|
683
|
+
* query, it's the object of query params. `TParamsRaw` allows for a more permissive
|
|
684
|
+
* type when building the value, for example allowing numbers and strings like
|
|
685
|
+
* the old params.
|
|
686
|
+
*
|
|
687
|
+
* @internal this is the base interface for all matcher patterns, it shouldn't
|
|
688
|
+
* be used directly
|
|
689
|
+
*/
|
|
690
|
+
interface MatcherPattern<TIn = string, TParams extends MatcherParamsFormatted = MatcherParamsFormatted, TParamsRaw extends MatcherParamsFormatted = TParams> {
|
|
691
|
+
/**
|
|
692
|
+
* Matches a serialized params value against the pattern.
|
|
693
|
+
*
|
|
694
|
+
* @param value - params value to parse
|
|
695
|
+
* @throws {MatchMiss} if the value doesn't match
|
|
696
|
+
* @returns parsed params object
|
|
697
|
+
*/
|
|
698
|
+
match(value: TIn): TParams;
|
|
699
|
+
/**
|
|
700
|
+
* Build a serializable value from parsed params. Should apply encoding if the
|
|
701
|
+
* returned value is a string (e.g path and hash should be encoded but query
|
|
702
|
+
* shouldn't).
|
|
703
|
+
*
|
|
704
|
+
* @param value - params value to parse
|
|
705
|
+
* @returns serialized params value
|
|
706
|
+
*/
|
|
707
|
+
build(params: TParamsRaw): TIn;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Handles the `path` part of a URL. It can transform a path string into an
|
|
711
|
+
* object of params and vice versa.
|
|
712
|
+
*/
|
|
713
|
+
interface MatcherPatternPath<TParams extends MatcherParamsFormatted = MatcherParamsFormatted // | null // | undefined // | void // so it might be a bit more convenient
|
|
714
|
+
, TParamsRaw extends MatcherParamsFormatted = TParams> extends MatcherPattern<string, TParams, TParamsRaw> {}
|
|
715
|
+
/**
|
|
716
|
+
* Allows matching a static path.
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```ts
|
|
720
|
+
* const matcher = new MatcherPatternPathStatic('/team')
|
|
721
|
+
* matcher.match('/team') // {}
|
|
722
|
+
* matcher.match('/team/123') // throws MatchMiss
|
|
723
|
+
* matcher.build() // '/team'
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
declare class MatcherPatternPathStatic implements MatcherPatternPath<EmptyParams> {
|
|
727
|
+
readonly path: string;
|
|
728
|
+
/**
|
|
729
|
+
* lowercase version of the path to match against.
|
|
730
|
+
* This is used to make the matching case insensitive.
|
|
731
|
+
*/
|
|
732
|
+
private pathi;
|
|
733
|
+
constructor(path: string);
|
|
734
|
+
match(path: string): EmptyParams;
|
|
735
|
+
build(): string;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Options for param parsers in {@link MatcherPatternPathDynamic}.
|
|
739
|
+
*/
|
|
740
|
+
type MatcherPatternPathDynamic_ParamOptions<TUrlParam extends string | string[] | null = string | string[] | null, TParam = string | string[] | null, TParamRaw = TParam> = readonly [
|
|
741
|
+
/**
|
|
742
|
+
* Param parser to use for this param.
|
|
743
|
+
*/
|
|
744
|
+
parser?: ParamParser<TParam, TUrlParam, TParamRaw>,
|
|
745
|
+
/**
|
|
746
|
+
* Is tha param a repeatable param and should be converted to an array
|
|
747
|
+
*/
|
|
748
|
+
repeatable?: boolean,
|
|
749
|
+
/**
|
|
750
|
+
* Can this parameter be omitted or empty (for repeatable params, an empty array).
|
|
751
|
+
*/
|
|
752
|
+
optional?: boolean];
|
|
753
|
+
/**
|
|
754
|
+
* Helper type to extract the params from the options object.
|
|
755
|
+
*
|
|
756
|
+
* @internal
|
|
757
|
+
*/
|
|
758
|
+
type ExtractParamTypeFromOptions<TParamsOptions> = { [K in keyof TParamsOptions]: TParamsOptions[K] extends MatcherPatternPathDynamic_ParamOptions<any, infer TParam, any> ? TParam : never; };
|
|
759
|
+
/**
|
|
760
|
+
* Helper type to extract the raw params from the options object.
|
|
761
|
+
*
|
|
762
|
+
* @internal
|
|
763
|
+
*/
|
|
764
|
+
type ExtractLocationParamTypeFromOptions<TParamsOptions> = { [K in keyof TParamsOptions]: TParamsOptions[K] extends MatcherPatternPathDynamic_ParamOptions<any, any, infer TParamRaw> ? TParamRaw : never; };
|
|
765
|
+
/**
|
|
766
|
+
* Handles the `path` part of a URL with dynamic parameters.
|
|
767
|
+
*/
|
|
768
|
+
declare class MatcherPatternPathDynamic<TParamsOptions> implements MatcherPatternPath<ExtractParamTypeFromOptions<TParamsOptions>, ExtractLocationParamTypeFromOptions<TParamsOptions>> {
|
|
769
|
+
readonly re: RegExp;
|
|
770
|
+
readonly params: TParamsOptions & Record<string, MatcherPatternPathDynamic_ParamOptions<any, any>>;
|
|
771
|
+
readonly pathParts: Array<string | number | Array<string | number>>;
|
|
772
|
+
readonly trailingSlash: boolean | null;
|
|
773
|
+
/**
|
|
774
|
+
* Cached keys of the {@link params} object.
|
|
775
|
+
*/
|
|
776
|
+
private paramsKeys;
|
|
777
|
+
/**
|
|
778
|
+
* Creates a new dynamic path matcher.
|
|
779
|
+
*
|
|
780
|
+
* @param re - regex to match the path against
|
|
781
|
+
* @param params - object of param parsers as {@link MatcherPatternPathDynamic_ParamOptions}
|
|
782
|
+
* @param pathParts - array of path parts, where strings are static parts, 1 are regular params, and 0 are splat params (not encode slash)
|
|
783
|
+
* @param trailingSlash - whether the path should end with a trailing slash, null means "do not care" (for trailing splat params)
|
|
784
|
+
*/
|
|
785
|
+
constructor(re: RegExp, params: TParamsOptions & Record<string, MatcherPatternPathDynamic_ParamOptions<any, any>>, pathParts: Array<string | number | Array<string | number>>, trailingSlash?: boolean | null);
|
|
786
|
+
match(path: string): Simplify<ExtractParamTypeFromOptions<TParamsOptions>>;
|
|
787
|
+
build(params: Simplify<ExtractLocationParamTypeFromOptions<TParamsOptions>>): string;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Handles the `hash` part of a URL. It can transform a hash string into an
|
|
791
|
+
* object of params and vice versa.
|
|
792
|
+
*/
|
|
793
|
+
interface MatcherPatternHash<TParams extends MatcherParamsFormatted = MatcherParamsFormatted> extends MatcherPattern<string, TParams> {}
|
|
794
|
+
/**
|
|
795
|
+
* Generic object of params that can be passed to a matcher.
|
|
796
|
+
*/
|
|
797
|
+
type MatcherParamsFormatted = Record<string, unknown>;
|
|
798
|
+
/**
|
|
799
|
+
* Empty object in TS.
|
|
800
|
+
*/
|
|
801
|
+
type EmptyParams = Record<PropertyKey, never>;
|
|
802
|
+
/**
|
|
803
|
+
* Possible values for query params in a matcher.
|
|
804
|
+
*/
|
|
805
|
+
type MatcherQueryParamsValue = string | null | undefined | Array<string | null>;
|
|
806
|
+
type MatcherQueryParams = Record<string, MatcherQueryParamsValue>;
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/location.d.ts
|
|
809
|
+
/**
|
|
810
|
+
* Location object returned by {@link `parseURL`}.
|
|
811
|
+
* @internal
|
|
812
|
+
*/
|
|
813
|
+
interface LocationNormalized {
|
|
814
|
+
path: string;
|
|
815
|
+
fullPath: string;
|
|
816
|
+
hash: string;
|
|
817
|
+
query: LocationQuery$1;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Initial route location where the router is. Can be used in navigation guards
|
|
821
|
+
* to differentiate the initial navigation.
|
|
822
|
+
*
|
|
823
|
+
* @example
|
|
824
|
+
* ```js
|
|
825
|
+
* import { START_LOCATION } from 'vue-router'
|
|
826
|
+
*
|
|
827
|
+
* router.beforeEach((to, from) => {
|
|
828
|
+
* if (from === START_LOCATION) {
|
|
829
|
+
* // initial navigation
|
|
830
|
+
* }
|
|
831
|
+
* })
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
declare const START_LOCATION_NORMALIZED: RouteLocationNormalizedLoaded;
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/experimental/route-resolver/resolver-abstract.d.ts
|
|
837
|
+
/**
|
|
838
|
+
* Allowed types for a matcher name.
|
|
839
|
+
*/
|
|
840
|
+
type RecordName = string | symbol;
|
|
841
|
+
/**
|
|
842
|
+
* Manage and resolve routes. Also handles the encoding, decoding, parsing and
|
|
843
|
+
* serialization of params, query, and hash.
|
|
844
|
+
*
|
|
845
|
+
* - `TMatcherRecordRaw` represents the raw record type passed to {@link addMatcher}.
|
|
846
|
+
* - `TMatcherRecord` represents the normalized record type returned by {@link getRoutes}.
|
|
847
|
+
*/
|
|
848
|
+
interface EXPERIMENTAL_Resolver_Base<TRecord> {
|
|
849
|
+
/**
|
|
850
|
+
* Resolves an absolute location (like `/path/to/somewhere`).
|
|
851
|
+
*
|
|
852
|
+
* @param absoluteLocation - The absolute location to resolve.
|
|
853
|
+
* @param currentLocation - This value is ignored and should not be passed if the location is absolute.
|
|
854
|
+
*/
|
|
855
|
+
resolve(absoluteLocation: `/${string}`, currentLocation?: undefined): ResolverLocationResolved<TRecord>;
|
|
856
|
+
/**
|
|
857
|
+
* Resolves a string location relative to another location. A relative
|
|
858
|
+
* location can be `./same-folder`, `../parent-folder`, `same-folder`, or
|
|
859
|
+
* even `?page=2`.
|
|
860
|
+
*/
|
|
861
|
+
resolve(relativeLocation: string, currentLocation: ResolverLocationResolved<TRecord>): ResolverLocationResolved<TRecord>;
|
|
862
|
+
/**
|
|
863
|
+
* Resolves a location by its name. Any required params or query must be
|
|
864
|
+
* passed in the `options` argument.
|
|
865
|
+
*/
|
|
866
|
+
resolve(location: ResolverLocationAsNamed, currentLocation?: undefined): ResolverLocationResolved<TRecord>;
|
|
867
|
+
/**
|
|
868
|
+
* Resolves a location by its absolute path (starts with `/`). Any required query must be passed.
|
|
869
|
+
*
|
|
870
|
+
* @param location - The location to resolve.
|
|
871
|
+
*/
|
|
872
|
+
resolve(location: ResolverLocationAsPathAbsolute, currentLocation?: undefined): ResolverLocationResolved<TRecord>;
|
|
873
|
+
resolve(location: ResolverLocationAsPathRelative, currentLocation: ResolverLocationResolved<TRecord>): ResolverLocationResolved<TRecord>;
|
|
874
|
+
/**
|
|
875
|
+
* Resolves a location relative to another location. It reuses existing
|
|
876
|
+
* properties in the `currentLocation` like `params`, `query`, and `hash`.
|
|
877
|
+
*/
|
|
878
|
+
resolve(relativeLocation: ResolverLocationAsRelative, currentLocation: ResolverLocationResolved<TRecord>): ResolverLocationResolved<TRecord>;
|
|
879
|
+
/**
|
|
880
|
+
* Get a list of all resolver route records.
|
|
881
|
+
*/
|
|
882
|
+
getRoutes(): TRecord[];
|
|
883
|
+
/**
|
|
884
|
+
* Get a resolver record by its name.
|
|
885
|
+
* Previously named `getRecordMatcher()`
|
|
886
|
+
*/
|
|
887
|
+
getRoute(name: RecordName): TRecord | undefined;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Returned location object by {@link EXPERIMENTAL_Resolver_Base['resolve']}.
|
|
891
|
+
* It contains the resolved name, params, query, hash, and matched records.
|
|
892
|
+
*/
|
|
893
|
+
interface ResolverLocationResolved<TMatched> extends LocationNormalized {
|
|
894
|
+
/**
|
|
895
|
+
* Name of the route record. A symbol if no name is provided.
|
|
896
|
+
*/
|
|
897
|
+
name: RecordName;
|
|
898
|
+
/**
|
|
899
|
+
* Parsed params. Already decoded and formatted.
|
|
900
|
+
*/
|
|
901
|
+
params: MatcherParamsFormatted;
|
|
902
|
+
/**
|
|
903
|
+
* Chain of route records that lead to the matched one. The last record is
|
|
904
|
+
* the the one that matched the location. Each previous record is the parent
|
|
905
|
+
* of the next one.
|
|
906
|
+
*/
|
|
907
|
+
matched: TMatched[];
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Location object that can be passed to {@link
|
|
911
|
+
* EXPERIMENTAL_Resolver_Base['resolve']} and is recognized as a `name`.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* resolver.resolve({ name: 'user', params: { id: 123 } })
|
|
916
|
+
* resolver.resolve({ name: 'user-search', params: {}, query: { page: 2 } })
|
|
917
|
+
* ```
|
|
918
|
+
*/
|
|
919
|
+
interface ResolverLocationAsNamed {
|
|
920
|
+
name: RecordName;
|
|
921
|
+
params: MatcherParamsFormatted;
|
|
922
|
+
query?: LocationQueryRaw;
|
|
923
|
+
hash?: string;
|
|
924
|
+
/**
|
|
925
|
+
* @deprecated This is ignored when `name` is provided
|
|
926
|
+
*/
|
|
927
|
+
path?: undefined;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Location object that can be passed to {@link EXPERIMENTAL_Resolver_Base['resolve']}
|
|
931
|
+
* and is recognized as a relative path.
|
|
932
|
+
*
|
|
933
|
+
* @example
|
|
934
|
+
* ```ts
|
|
935
|
+
* resolver.resolve({ path: './123' }, currentLocation)
|
|
936
|
+
* resolver.resolve({ path: '..' }, currentLocation)
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
interface ResolverLocationAsPathRelative {
|
|
940
|
+
path: string;
|
|
941
|
+
query?: LocationQueryRaw;
|
|
942
|
+
hash?: string;
|
|
943
|
+
/**
|
|
944
|
+
* @deprecated This is ignored when `path` is provided
|
|
945
|
+
*/
|
|
946
|
+
name?: undefined;
|
|
947
|
+
/**
|
|
948
|
+
* @deprecated This is ignored when `path` (instead of `name`) is provided
|
|
949
|
+
*/
|
|
950
|
+
params?: undefined;
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Location object that can be passed to {@link EXPERIMENTAL_Resolver_Base['resolve']}
|
|
954
|
+
* and is recognized as an absolute path.
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```ts
|
|
958
|
+
* resolver.resolve({ path: '/team/123' })
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
interface ResolverLocationAsPathAbsolute extends ResolverLocationAsPathRelative {
|
|
962
|
+
path: `/${string}`;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Relative location object that can be passed to {@link EXPERIMENTAL_Resolver_Base['resolve']}
|
|
966
|
+
* and is recognized as a relative location, copying the `params`, `query`, and
|
|
967
|
+
* `hash` if not provided.
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* ```ts
|
|
971
|
+
* resolver.resolve({ params: { id: 123 } }, currentLocation)
|
|
972
|
+
* resolver.resolve({ hash: '#bottom' }, currentLocation)
|
|
973
|
+
* ```
|
|
974
|
+
*/
|
|
975
|
+
interface ResolverLocationAsRelative {
|
|
976
|
+
params?: MatcherParamsFormatted;
|
|
977
|
+
query?: LocationQueryRaw;
|
|
978
|
+
hash?: string;
|
|
979
|
+
/**
|
|
980
|
+
* @deprecated This location is relative to the next parameter. This `name` will be ignored.
|
|
981
|
+
*/
|
|
982
|
+
name?: undefined;
|
|
983
|
+
/**
|
|
984
|
+
* @deprecated This location is relative to the next parameter. This `path` will be ignored.
|
|
985
|
+
*/
|
|
986
|
+
path?: undefined;
|
|
987
|
+
}
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region src/experimental/route-resolver/matchers/param-parsers/define-param-parser.d.ts
|
|
990
|
+
/**
|
|
991
|
+
* Defines a param parser that works with any kind of param (path, repeatable,
|
|
992
|
+
* optional, query, hash, ...) but requires the user to handle all cases in the
|
|
993
|
+
* get and set functions (nullish, undefined, arrays, etc). This allows you to
|
|
994
|
+
* have full control over the parsing logic, but it also means that you need to
|
|
995
|
+
* handle all edge cases yourself. If possible, prefer using {@see defineParamParser}
|
|
996
|
+
* which provides a more structured way to handle these
|
|
997
|
+
* cases and automatically handles arrays and nullish values.
|
|
998
|
+
*
|
|
999
|
+
* @example
|
|
1000
|
+
*
|
|
1001
|
+
* Here is an example that allows arbitrary numbers (NaN values are filtered
|
|
1002
|
+
* out). It supports repeatable params, so it can be used both as a path param
|
|
1003
|
+
* parser and a query param parser.
|
|
1004
|
+
*
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* export const parser = defineParamParserRaw<number>({
|
|
1007
|
+
* get: value => {
|
|
1008
|
+
* if (value == null) return null
|
|
1009
|
+
* if (Array.isArray(value)) {
|
|
1010
|
+
* return value
|
|
1011
|
+
* .filter(v => v != null)
|
|
1012
|
+
* .map(Number)
|
|
1013
|
+
* .filter(v => !Number.isNaN(v))
|
|
1014
|
+
* }
|
|
1015
|
+
*
|
|
1016
|
+
* return Number.isNaN(Number(value))
|
|
1017
|
+
* ? miss(`"${value}" is not a valid number`)
|
|
1018
|
+
* : Number(value)
|
|
1019
|
+
* },
|
|
1020
|
+
*
|
|
1021
|
+
* set: value =>
|
|
1022
|
+
* Array.isArray(value)
|
|
1023
|
+
* ? value.map(String)
|
|
1024
|
+
* : value == null
|
|
1025
|
+
* ? null
|
|
1026
|
+
* : String(value),
|
|
1027
|
+
* })
|
|
1028
|
+
* ```
|
|
1029
|
+
*
|
|
1030
|
+
* @see {@link defineParamParser}
|
|
1031
|
+
*/
|
|
1032
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
1033
|
+
declare function defineParamParserRaw<TParam, TParamRaw = TParam, TUrlParam = MatcherQueryParamsValue>(parser: Required<ParamParser<TParam, TUrlParam, TParamRaw>>): Required<ParamParser<TParam, TUrlParam, TParamRaw>>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Defines a param parser that transforms strings to another type. Handles
|
|
1036
|
+
* optional and repeatable params:
|
|
1037
|
+
*
|
|
1038
|
+
* - Optional params: become `null` if the value is nullish
|
|
1039
|
+
* - Repeatable params: the value becomes an array of the parsed type, and nullish values are filtered out
|
|
1040
|
+
*
|
|
1041
|
+
* @example
|
|
1042
|
+
*
|
|
1043
|
+
* Here is an example that allows arbitrary valid numbers (NaN values are
|
|
1044
|
+
* filtered out). It can be used in both, path, and query params.
|
|
1045
|
+
*
|
|
1046
|
+
* ```ts
|
|
1047
|
+
* import { defineParamParser, miss } from 'vue-router/experimental'
|
|
1048
|
+
*
|
|
1049
|
+
* export const parser = defineParamParser<number>({
|
|
1050
|
+
* get: value => {
|
|
1051
|
+
* const num = Number(value)
|
|
1052
|
+
* if (Number.isNaN(num)) {
|
|
1053
|
+
* miss(`"${value}" is not a valid number`)
|
|
1054
|
+
* }
|
|
1055
|
+
* return num
|
|
1056
|
+
* },
|
|
1057
|
+
*
|
|
1058
|
+
* set: value => String(value),
|
|
1059
|
+
* })
|
|
1060
|
+
* ```
|
|
1061
|
+
*
|
|
1062
|
+
* @see {@link defineParamParserRaw}
|
|
1063
|
+
*/
|
|
1064
|
+
declare function defineParamParser<TParam, TParamRaw = TParam>(parser: Required<ParamParser<TParam, string, TParamRaw>>): Required<ParamParser<TParam | TParam[] | null, MatcherQueryParamsValue, TParamRaw | TParamRaw[] | null | undefined>>;
|
|
1065
|
+
//#endregion
|
|
1066
|
+
//#region src/experimental/route-resolver/matchers/param-parsers/booleans.d.ts
|
|
1067
|
+
/**
|
|
1068
|
+
* Native Param parser for booleans.
|
|
1069
|
+
*
|
|
1070
|
+
* @internal
|
|
1071
|
+
*/
|
|
1072
|
+
declare const PARAM_PARSER_BOOL: {
|
|
1073
|
+
get: (value: NoInfer<MatcherQueryParamsValue>) => boolean | boolean[] | undefined;
|
|
1074
|
+
set: (value: boolean | boolean[] | null | undefined) => string | string[] | null | undefined;
|
|
1075
|
+
};
|
|
1076
|
+
//#endregion
|
|
1077
|
+
//#region src/experimental/route-resolver/matchers/param-parsers/integers.d.ts
|
|
1078
|
+
/**
|
|
1079
|
+
* Native Param parser for integers.
|
|
1080
|
+
*
|
|
1081
|
+
* @internal
|
|
1082
|
+
*/
|
|
1083
|
+
declare const PARAM_PARSER_INT: {
|
|
1084
|
+
get: (value: NoInfer<MatcherQueryParamsValue>) => number | number[] | null;
|
|
1085
|
+
set: (value: number | number[] | null) => string | string[] | null;
|
|
1086
|
+
};
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region src/experimental/route-resolver/matchers/param-parsers/standard-schema-types.d.ts
|
|
1089
|
+
/**
|
|
1090
|
+
* Inlined subset of `@standard-schema/spec` v1.1.0 so the distributed code
|
|
1091
|
+
* has zero external type dependencies. Keep the package installed to track
|
|
1092
|
+
* upstream changes.
|
|
1093
|
+
*
|
|
1094
|
+
* @see https://github.com/standard-schema/standard-schema
|
|
1095
|
+
*/
|
|
1096
|
+
/** The Standard Schema interface. */
|
|
1097
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
1098
|
+
/** The Standard Schema properties. */
|
|
1099
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
1100
|
+
}
|
|
1101
|
+
declare namespace StandardSchemaV1 {
|
|
1102
|
+
/** The Standard Schema properties interface. */
|
|
1103
|
+
interface Props<Input = unknown, Output = Input> {
|
|
1104
|
+
/** The version number of the standard. */
|
|
1105
|
+
readonly version: 1;
|
|
1106
|
+
/** The vendor name of the schema library. */
|
|
1107
|
+
readonly vendor: string;
|
|
1108
|
+
/** Inferred types associated with the schema. */
|
|
1109
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
1110
|
+
/** Validates unknown input values. */
|
|
1111
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
1112
|
+
}
|
|
1113
|
+
/** The Standard Schema types interface. */
|
|
1114
|
+
interface Types<Input = unknown, Output = Input> {
|
|
1115
|
+
/** The input type of the schema. */
|
|
1116
|
+
readonly input: Input;
|
|
1117
|
+
/** The output type of the schema. */
|
|
1118
|
+
readonly output: Output;
|
|
1119
|
+
}
|
|
1120
|
+
/** The result interface of the validate function. */
|
|
1121
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
1122
|
+
/** The result interface if validation succeeds. */
|
|
1123
|
+
interface SuccessResult<Output> {
|
|
1124
|
+
/** The typed output value. */
|
|
1125
|
+
readonly value: Output;
|
|
1126
|
+
/** A falsy value for `issues` indicates success. */
|
|
1127
|
+
readonly issues?: undefined;
|
|
1128
|
+
}
|
|
1129
|
+
/** The result interface if validation fails. */
|
|
1130
|
+
interface FailureResult {
|
|
1131
|
+
/** The issues of failed validation. */
|
|
1132
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
1133
|
+
}
|
|
1134
|
+
/** The issue interface of the failure output. */
|
|
1135
|
+
interface Issue {
|
|
1136
|
+
/** The error message of the issue. */
|
|
1137
|
+
readonly message: string;
|
|
1138
|
+
/** The path of the issue, if any. */
|
|
1139
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
1140
|
+
}
|
|
1141
|
+
/** The path segment interface of the issue. */
|
|
1142
|
+
interface PathSegment {
|
|
1143
|
+
/** The key representing a path segment. */
|
|
1144
|
+
readonly key: PropertyKey;
|
|
1145
|
+
}
|
|
1146
|
+
/** Infers the input type of a Standard Schema. */
|
|
1147
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
1148
|
+
/** Infers the output type of a Standard Schema. */
|
|
1149
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
1150
|
+
}
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region src/experimental/route-resolver/matchers/param-parsers/standard-schema.d.ts
|
|
1153
|
+
/**
|
|
1154
|
+
* Normalizes a param parser input, converting a StandardSchema-compliant object
|
|
1155
|
+
* into a {@link ParamParser} if needed.
|
|
1156
|
+
*
|
|
1157
|
+
* @param parser - a param parser or a StandardSchema-compliant validator
|
|
1158
|
+
*
|
|
1159
|
+
* @internal
|
|
1160
|
+
*/
|
|
1161
|
+
declare function normalizeParamParser<TParam = MatcherQueryParamsValue, TUrlParam = MatcherQueryParamsValue, TParamRaw = TParam>(parser: ParamParser<TParam, TUrlParam, TParamRaw> | StandardSchemaV1<unknown, TParam>): ParamParser<TParam, TUrlParam, TParamRaw>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Extracts the param type from Param Parsers or StandardSchema validators.
|
|
1164
|
+
*
|
|
1165
|
+
* @internal
|
|
1166
|
+
*/
|
|
1167
|
+
type ExtractParamParserType<PP> = PP extends ParamParser<infer T, any, any> ? T : PP extends StandardSchemaV1<unknown, infer T> ? T : unknown;
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region src/experimental/route-resolver/matchers/matcher-pattern-query.d.ts
|
|
1170
|
+
/**
|
|
1171
|
+
* Handles the `query` part of a URL. It can transform a query object into an
|
|
1172
|
+
* object of params and vice versa.
|
|
1173
|
+
*/
|
|
1174
|
+
interface MatcherPatternQuery<TParams extends MatcherParamsFormatted = MatcherParamsFormatted> extends MatcherPattern<MatcherQueryParams, TParams> {}
|
|
1175
|
+
/**
|
|
1176
|
+
* Matcher for a specific query parameter. It will read and write the parameter
|
|
1177
|
+
*/
|
|
1178
|
+
declare class MatcherPatternQueryParam<T, ParamName extends string> implements MatcherPatternQuery<Record<ParamName, T>> {
|
|
1179
|
+
private paramName;
|
|
1180
|
+
private queryKey;
|
|
1181
|
+
private format;
|
|
1182
|
+
private parser;
|
|
1183
|
+
private defaultValue?;
|
|
1184
|
+
private required?;
|
|
1185
|
+
constructor(paramName: ParamName, queryKey: string, format: 'value' | 'array', parser?: ParamParser<T>, defaultValue?: ((() => T) | T) | undefined, required?: boolean | undefined);
|
|
1186
|
+
match(query: MatcherQueryParams): Record<ParamName, T>;
|
|
1187
|
+
build(params: Record<ParamName, T>): MatcherQueryParams;
|
|
1188
|
+
}
|
|
1189
|
+
//#endregion
|
|
1190
|
+
//#region src/experimental/route-resolver/resolver-fixed.d.ts
|
|
1191
|
+
/**
|
|
1192
|
+
* Base interface for a resolver record that can be extended.
|
|
1193
|
+
*/
|
|
1194
|
+
interface EXPERIMENTAL_ResolverRecord_Base {
|
|
1195
|
+
/**
|
|
1196
|
+
* Name of the matcher. Unique across all matchers. If missing, this record
|
|
1197
|
+
* cannot be matched. This is useful for grouping records.
|
|
1198
|
+
*/
|
|
1199
|
+
name?: RecordName;
|
|
1200
|
+
/**
|
|
1201
|
+
* {@link MatcherPattern} for the path section of the URI.
|
|
1202
|
+
*/
|
|
1203
|
+
path?: MatcherPatternPath;
|
|
1204
|
+
/**
|
|
1205
|
+
* {@link MatcherPattern} for the query section of the URI.
|
|
1206
|
+
*/
|
|
1207
|
+
query?: MatcherPatternQuery[];
|
|
1208
|
+
/**
|
|
1209
|
+
* {@link MatcherPattern} for the hash section of the URI.
|
|
1210
|
+
*/
|
|
1211
|
+
hash?: MatcherPatternHash;
|
|
1212
|
+
/**
|
|
1213
|
+
* Parent record. The parent can be a group or a matchable record.
|
|
1214
|
+
* It will be included in the `matched` array of a resolved location.
|
|
1215
|
+
*/
|
|
1216
|
+
parent?: EXPERIMENTAL_ResolverRecord_Base | null;
|
|
1217
|
+
/**
|
|
1218
|
+
* If this record is an alias of another record, this points to the original
|
|
1219
|
+
* record. Alias records are not added to the name map and resolve to the
|
|
1220
|
+
* original record's name.
|
|
1221
|
+
*/
|
|
1222
|
+
aliasOf?: EXPERIMENTAL_ResolverRecord_Base | null;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* A group can contain other useful properties like `meta` defined by the router.
|
|
1226
|
+
*/
|
|
1227
|
+
interface EXPERIMENTAL_ResolverRecord_Group extends EXPERIMENTAL_ResolverRecord_Base {
|
|
1228
|
+
/**
|
|
1229
|
+
* A group route cannot be matched directly and cannot be named.
|
|
1230
|
+
*/
|
|
1231
|
+
name?: undefined;
|
|
1232
|
+
/**
|
|
1233
|
+
* A group route can **only** match the `query`.
|
|
1234
|
+
*/
|
|
1235
|
+
path?: undefined;
|
|
1236
|
+
/**
|
|
1237
|
+
* A group route can **only** match the `query`.
|
|
1238
|
+
*/
|
|
1239
|
+
hash?: undefined;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* A matchable record is a record that can be matched by a path, query or hash
|
|
1243
|
+
* and will resolve to a location.
|
|
1244
|
+
*/
|
|
1245
|
+
interface EXPERIMENTAL_ResolverRecord_Matchable extends EXPERIMENTAL_ResolverRecord_Base {
|
|
1246
|
+
name: RecordName;
|
|
1247
|
+
path: MatcherPatternPath;
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* @alias EXPERIMENTAL_Resolver_Base
|
|
1251
|
+
*/
|
|
1252
|
+
interface EXPERIMENTAL_ResolverFixed<TRecord> extends EXPERIMENTAL_Resolver_Base<TRecord> {}
|
|
1253
|
+
/**
|
|
1254
|
+
* Creates a fixed resolver that must have all records defined at creation
|
|
1255
|
+
* time.
|
|
1256
|
+
*
|
|
1257
|
+
* @template TRecord - extended type of the records
|
|
1258
|
+
* @param {TRecord[]} records - Ordered array of records that will be used to resolve routes
|
|
1259
|
+
* @returns a resolver that can be passed to the router
|
|
1260
|
+
*/
|
|
1261
|
+
declare function createFixedResolver<TRecord extends EXPERIMENTAL_ResolverRecord_Matchable>(records: TRecord[]): EXPERIMENTAL_ResolverFixed<TRecord>;
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region src/experimental/router.d.ts
|
|
1264
|
+
/**
|
|
1265
|
+
* Options to initialize a {@link Router} instance.
|
|
1266
|
+
*/
|
|
1267
|
+
interface EXPERIMENTAL_RouterOptions_Base extends PathParserOptions {
|
|
1268
|
+
/**
|
|
1269
|
+
* History implementation used by the router. Most web applications should use
|
|
1270
|
+
* `createWebHistory` but it requires the server to be properly configured.
|
|
1271
|
+
* You can also use a _hash_ based history with `createWebHashHistory` that
|
|
1272
|
+
* does not require any configuration on the server but isn't handled at all
|
|
1273
|
+
* by search engines and does poorly on SEO.
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```js
|
|
1277
|
+
* createRouter({
|
|
1278
|
+
* history: createWebHistory(),
|
|
1279
|
+
* // other options...
|
|
1280
|
+
* })
|
|
1281
|
+
* ```
|
|
1282
|
+
*/
|
|
1283
|
+
history: RouterHistory;
|
|
1284
|
+
/**
|
|
1285
|
+
* Function to control scrolling when navigating between pages. Can return a
|
|
1286
|
+
* Promise to delay scrolling.
|
|
1287
|
+
*
|
|
1288
|
+
* @see {@link RouterScrollBehavior}.
|
|
1289
|
+
*
|
|
1290
|
+
* @example
|
|
1291
|
+
* ```js
|
|
1292
|
+
* function scrollBehavior(to, from, savedPosition) {
|
|
1293
|
+
* // `to` and `from` are both route locations
|
|
1294
|
+
* // `savedPosition` can be null if there isn't one
|
|
1295
|
+
* }
|
|
1296
|
+
* ```
|
|
1297
|
+
*/
|
|
1298
|
+
scrollBehavior?: RouterScrollBehavior;
|
|
1299
|
+
/**
|
|
1300
|
+
* Custom implementation to parse a query. See its counterpart,
|
|
1301
|
+
* {@link EXPERIMENTAL_RouterOptions_Base.stringifyQuery}.
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
* Let's say you want to use the [qs package](https://github.com/ljharb/qs)
|
|
1305
|
+
* to parse queries, you can provide both `parseQuery` and `stringifyQuery`:
|
|
1306
|
+
* ```js
|
|
1307
|
+
* import qs from 'qs'
|
|
1308
|
+
*
|
|
1309
|
+
* createRouter({
|
|
1310
|
+
* // other options...
|
|
1311
|
+
* parseQuery: qs.parse,
|
|
1312
|
+
* stringifyQuery: qs.stringify,
|
|
1313
|
+
* })
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
parseQuery?: typeof experimental_parseQuery;
|
|
1317
|
+
/**
|
|
1318
|
+
* Custom implementation to stringify a query object. Should not prepend a leading `?`.
|
|
1319
|
+
* {@link parseQuery} counterpart to handle query parsing.
|
|
1320
|
+
*/
|
|
1321
|
+
stringifyQuery?: typeof stringifyQuery;
|
|
1322
|
+
/**
|
|
1323
|
+
* Default class applied to active {@link RouterLink}. If none is provided,
|
|
1324
|
+
* `router-link-active` will be applied.
|
|
1325
|
+
*/
|
|
1326
|
+
linkActiveClass?: string;
|
|
1327
|
+
/**
|
|
1328
|
+
* Default class applied to exact active {@link RouterLink}. If none is provided,
|
|
1329
|
+
* `router-link-exact-active` will be applied.
|
|
1330
|
+
*/
|
|
1331
|
+
linkExactActiveClass?: string;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Internal type for common properties among all kind of {@link RouteRecordRaw}.
|
|
1335
|
+
*/
|
|
1336
|
+
interface EXPERIMENTAL_RouteRecord_Base extends EXPERIMENTAL_ResolverRecord_Base {
|
|
1337
|
+
/**
|
|
1338
|
+
* Where to redirect if the route is directly matched. The redirection happens
|
|
1339
|
+
* before any navigation guard and triggers a new navigation with the new
|
|
1340
|
+
* target location.
|
|
1341
|
+
*/
|
|
1342
|
+
redirect?: RouteRecordRedirectOption;
|
|
1343
|
+
/**
|
|
1344
|
+
* Before Enter guard specific to this record. Note `beforeEnter` has no
|
|
1345
|
+
* effect if the record has a `redirect` property.
|
|
1346
|
+
*/
|
|
1347
|
+
/**
|
|
1348
|
+
* Arbitrary data attached to the record.
|
|
1349
|
+
*/
|
|
1350
|
+
meta?: RouteMeta;
|
|
1351
|
+
/**
|
|
1352
|
+
* Components to display when the URL matches this route. Allow using named views.
|
|
1353
|
+
*/
|
|
1354
|
+
components?: Record<string, RawRouteComponent>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Parent of this component if any
|
|
1357
|
+
*/
|
|
1358
|
+
parent?: EXPERIMENTAL_RouteRecordNormalized | null;
|
|
1359
|
+
/**
|
|
1360
|
+
* References another record if this record is an alias of it.
|
|
1361
|
+
*/
|
|
1362
|
+
aliasOf?: EXPERIMENTAL_RouteRecordNormalized | null;
|
|
1363
|
+
}
|
|
1364
|
+
interface EXPERIMENTAL_RouteRecord_Redirect extends Omit<EXPERIMENTAL_RouteRecord_Base, 'name' | 'path'>, Omit<EXPERIMENTAL_ResolverRecord_Matchable, 'parent' | 'aliasOf'> {
|
|
1365
|
+
components?: Record<string, RawRouteComponent>;
|
|
1366
|
+
redirect: RouteRecordRedirectOption;
|
|
1367
|
+
}
|
|
1368
|
+
interface EXPERIMENTAL_RouteRecord_Group extends Omit<EXPERIMENTAL_RouteRecord_Base, 'name' | 'path' | 'query' | 'hash'>, Omit<EXPERIMENTAL_ResolverRecord_Group, 'parent' | 'aliasOf'> {
|
|
1369
|
+
components?: Record<string, RawRouteComponent>;
|
|
1370
|
+
}
|
|
1371
|
+
interface EXPERIMENTAL_RouteRecord_Components extends Omit<EXPERIMENTAL_RouteRecord_Base, 'name' | 'path'>, Omit<EXPERIMENTAL_ResolverRecord_Matchable, 'parent' | 'aliasOf'> {
|
|
1372
|
+
components: Record<string, RawRouteComponent>;
|
|
1373
|
+
redirect?: never;
|
|
1374
|
+
}
|
|
1375
|
+
type EXPERIMENTAL_RouteRecord_Matchable = EXPERIMENTAL_RouteRecord_Components | EXPERIMENTAL_RouteRecord_Redirect;
|
|
1376
|
+
type EXPERIMENTAL_RouteRecordRaw = EXPERIMENTAL_RouteRecord_Matchable | EXPERIMENTAL_RouteRecord_Group;
|
|
1377
|
+
interface EXPERIMENTAL_RouteRecordNormalized_Base {
|
|
1378
|
+
/**
|
|
1379
|
+
* Contains the original modules for lazy loaded components.
|
|
1380
|
+
*
|
|
1381
|
+
* @internal
|
|
1382
|
+
*/
|
|
1383
|
+
mods: Record<string, unknown>;
|
|
1384
|
+
props: Record<string, _RouteRecordProps>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Registered leave guards
|
|
1387
|
+
*
|
|
1388
|
+
* @internal
|
|
1389
|
+
*/
|
|
1390
|
+
leaveGuards: Set<NavigationGuard>;
|
|
1391
|
+
/**
|
|
1392
|
+
* Registered update guards
|
|
1393
|
+
*
|
|
1394
|
+
* @internal
|
|
1395
|
+
*/
|
|
1396
|
+
updateGuards: Set<NavigationGuard>;
|
|
1397
|
+
instances: Record<string, unknown>;
|
|
1398
|
+
}
|
|
1399
|
+
interface EXPERIMENTAL_RouteRecordNormalized_Group extends EXPERIMENTAL_RouteRecordNormalized_Base, EXPERIMENTAL_RouteRecord_Group {
|
|
1400
|
+
meta: RouteMeta;
|
|
1401
|
+
}
|
|
1402
|
+
interface EXPERIMENTAL_RouteRecordNormalized_Redirect extends EXPERIMENTAL_RouteRecordNormalized_Base, EXPERIMENTAL_RouteRecord_Redirect {
|
|
1403
|
+
meta: RouteMeta;
|
|
1404
|
+
}
|
|
1405
|
+
interface EXPERIMENTAL_RouteRecordNormalized_Components extends EXPERIMENTAL_RouteRecordNormalized_Base, EXPERIMENTAL_RouteRecord_Components {
|
|
1406
|
+
meta: RouteMeta;
|
|
1407
|
+
}
|
|
1408
|
+
type EXPERIMENTAL_RouteRecordNormalized_Matchable = EXPERIMENTAL_RouteRecordNormalized_Components | EXPERIMENTAL_RouteRecordNormalized_Redirect;
|
|
1409
|
+
type EXPERIMENTAL_RouteRecordNormalized = EXPERIMENTAL_RouteRecordNormalized_Matchable | EXPERIMENTAL_RouteRecordNormalized_Group;
|
|
1410
|
+
declare function normalizeRouteRecord(record: EXPERIMENTAL_RouteRecord_Group): EXPERIMENTAL_RouteRecordNormalized_Group;
|
|
1411
|
+
declare function normalizeRouteRecord(record: EXPERIMENTAL_RouteRecord_Matchable): EXPERIMENTAL_RouteRecordNormalized_Matchable;
|
|
1412
|
+
/**
|
|
1413
|
+
* Options to initialize an experimental {@link EXPERIMENTAL_Router} instance.
|
|
1414
|
+
* @experimental
|
|
1415
|
+
*/
|
|
1416
|
+
interface EXPERIMENTAL_RouterOptions extends EXPERIMENTAL_RouterOptions_Base {
|
|
1417
|
+
/**
|
|
1418
|
+
* Matcher to use to resolve routes.
|
|
1419
|
+
*
|
|
1420
|
+
* @experimental
|
|
1421
|
+
*/
|
|
1422
|
+
resolver: EXPERIMENTAL_ResolverFixed<EXPERIMENTAL_RouteRecordNormalized_Matchable>;
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Router base instance.
|
|
1426
|
+
*
|
|
1427
|
+
* @experimental This version is not stable, it's meant to replace {@link Router} in the future.
|
|
1428
|
+
*/
|
|
1429
|
+
interface EXPERIMENTAL_Router_Base<TRecord> extends DataLoaderExtensions {
|
|
1430
|
+
/**
|
|
1431
|
+
* Current {@link RouteLocationNormalized}
|
|
1432
|
+
*/
|
|
1433
|
+
readonly currentRoute: ShallowRef<RouteLocationNormalizedLoaded>;
|
|
1434
|
+
/**
|
|
1435
|
+
* Allows turning off the listening of history events. This is a low level api for micro-frontend.
|
|
1436
|
+
*/
|
|
1437
|
+
listening: boolean;
|
|
1438
|
+
/**
|
|
1439
|
+
* Checks if a route with a given name exists
|
|
1440
|
+
*
|
|
1441
|
+
* @param name - Name of the route to check
|
|
1442
|
+
*/
|
|
1443
|
+
hasRoute(name: NonNullable<RouteRecordNameGeneric>): boolean;
|
|
1444
|
+
/**
|
|
1445
|
+
* Get a full list of all the {@link RouteRecord | route records}.
|
|
1446
|
+
*/
|
|
1447
|
+
getRoutes(): TRecord[];
|
|
1448
|
+
/**
|
|
1449
|
+
* Returns the {@link RouteLocation | normalized version} of a
|
|
1450
|
+
* {@link RouteLocationRaw | route location}. Also includes an `href` property
|
|
1451
|
+
* that includes any existing `base`. By default, the `currentLocation` used is
|
|
1452
|
+
* `router.currentRoute` and should only be overridden in advanced use cases.
|
|
1453
|
+
*
|
|
1454
|
+
* @param to - Raw route location to resolve
|
|
1455
|
+
* @param currentLocation - Optional current location to resolve against
|
|
1456
|
+
*/
|
|
1457
|
+
resolve<Name extends keyof RouteMap = keyof RouteMap>(to: RouteLocationAsRelativeTyped<RouteMap, Name>, currentLocation?: RouteLocationNormalizedLoaded): RouteLocationResolved<Name>;
|
|
1458
|
+
resolve(to: RouteLocationAsString | RouteLocationAsRelative | RouteLocationAsPath, currentLocation?: RouteLocationNormalizedLoaded): RouteLocationResolved;
|
|
1459
|
+
/**
|
|
1460
|
+
* Programmatically navigate to a new URL by pushing an entry in the history
|
|
1461
|
+
* stack.
|
|
1462
|
+
*
|
|
1463
|
+
* @param to - Route location to navigate to
|
|
1464
|
+
*/
|
|
1465
|
+
push(to: RouteLocationRaw): Promise<NavigationFailure | void | undefined>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Programmatically navigate to a new URL by replacing the current entry in
|
|
1468
|
+
* the history stack.
|
|
1469
|
+
*
|
|
1470
|
+
* @param to - Route location to navigate to
|
|
1471
|
+
*/
|
|
1472
|
+
replace(to: RouteLocationRaw): Promise<NavigationFailure | void | undefined>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Go back in history if possible by calling `history.back()`. Equivalent to
|
|
1475
|
+
* `router.go(-1)`.
|
|
1476
|
+
*/
|
|
1477
|
+
back(): void;
|
|
1478
|
+
/**
|
|
1479
|
+
* Go forward in history if possible by calling `history.forward()`.
|
|
1480
|
+
* Equivalent to `router.go(1)`.
|
|
1481
|
+
*/
|
|
1482
|
+
forward(): void;
|
|
1483
|
+
/**
|
|
1484
|
+
* Allows you to move forward or backward through the history. Calls
|
|
1485
|
+
* `history.go()`.
|
|
1486
|
+
*
|
|
1487
|
+
* @param delta - The position in the history to which you want to move,
|
|
1488
|
+
* relative to the current page
|
|
1489
|
+
*/
|
|
1490
|
+
go(delta: number): void;
|
|
1491
|
+
/**
|
|
1492
|
+
* Add a navigation guard that executes before any navigation. Returns a
|
|
1493
|
+
* function that removes the registered guard.
|
|
1494
|
+
*
|
|
1495
|
+
* @param guard - navigation guard to add
|
|
1496
|
+
*/
|
|
1497
|
+
beforeEach(guard: NavigationGuardWithThis<undefined>): () => void;
|
|
1498
|
+
/**
|
|
1499
|
+
* Add a navigation guard that executes before navigation is about to be
|
|
1500
|
+
* resolved. At this state all component have been fetched and other
|
|
1501
|
+
* navigation guards have been successful. Returns a function that removes the
|
|
1502
|
+
* registered guard.
|
|
1503
|
+
*
|
|
1504
|
+
* @param guard - navigation guard to add
|
|
1505
|
+
* @returns a function that removes the registered guard
|
|
1506
|
+
*
|
|
1507
|
+
* @example
|
|
1508
|
+
* ```js
|
|
1509
|
+
* router.beforeResolve(to => {
|
|
1510
|
+
* if (to.meta.requiresAuth && !isAuthenticated) return false
|
|
1511
|
+
* })
|
|
1512
|
+
* ```
|
|
1513
|
+
*
|
|
1514
|
+
*/
|
|
1515
|
+
beforeResolve(guard: _NavigationGuardResolved): () => void;
|
|
1516
|
+
/**
|
|
1517
|
+
* Add a navigation hook that is executed after every navigation. Returns a
|
|
1518
|
+
* function that removes the registered hook.
|
|
1519
|
+
*
|
|
1520
|
+
* @param guard - navigation hook to add
|
|
1521
|
+
* @returns a function that removes the registered hook
|
|
1522
|
+
*
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```js
|
|
1525
|
+
* router.afterEach((to, from, failure) => {
|
|
1526
|
+
* if (isNavigationFailure(failure)) {
|
|
1527
|
+
* console.log('failed navigation', failure)
|
|
1528
|
+
* }
|
|
1529
|
+
* })
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1532
|
+
afterEach(guard: NavigationHookAfter): () => void;
|
|
1533
|
+
/**
|
|
1534
|
+
* Adds an error handler that is called every time a non caught error happens
|
|
1535
|
+
* during navigation. This includes errors thrown synchronously and
|
|
1536
|
+
* asynchronously, errors returned or passed to `next` in any navigation
|
|
1537
|
+
* guard, and errors occurred when trying to resolve an async component that
|
|
1538
|
+
* is required to render a route.
|
|
1539
|
+
*
|
|
1540
|
+
* @param handler - error handler to register
|
|
1541
|
+
*/
|
|
1542
|
+
onError(handler: _ErrorListener): () => void;
|
|
1543
|
+
/**
|
|
1544
|
+
* Returns a Promise that resolves when the router has completed the initial
|
|
1545
|
+
* navigation, which means it has resolved all async enter hooks and async
|
|
1546
|
+
* components that are associated with the initial route. If the initial
|
|
1547
|
+
* navigation already happened, the promise resolves immediately.
|
|
1548
|
+
*
|
|
1549
|
+
* This is useful in server-side rendering to ensure consistent output on both
|
|
1550
|
+
* the server and the client. Note that on server side, you need to manually
|
|
1551
|
+
* push the initial location while on client side, the router automatically
|
|
1552
|
+
* picks it up from the URL.
|
|
1553
|
+
*/
|
|
1554
|
+
isReady(): Promise<void>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Called automatically by `app.use(router)`. Should not be called manually by
|
|
1557
|
+
* the user. This will trigger the initial navigation when on client side.
|
|
1558
|
+
*
|
|
1559
|
+
* @internal
|
|
1560
|
+
* @param app - Application that uses the router
|
|
1561
|
+
*/
|
|
1562
|
+
install(app: App): void;
|
|
1563
|
+
}
|
|
1564
|
+
interface EXPERIMENTAL_Router extends EXPERIMENTAL_Router_Base<EXPERIMENTAL_RouteRecordNormalized_Matchable> {
|
|
1565
|
+
/**
|
|
1566
|
+
* Original options object passed to create the Router
|
|
1567
|
+
*/
|
|
1568
|
+
readonly options: EXPERIMENTAL_RouterOptions;
|
|
1569
|
+
/**
|
|
1570
|
+
* Dev only method to replace the resolver used by the router. Used during HMR
|
|
1571
|
+
*
|
|
1572
|
+
* @param newResolver - new resolver to use
|
|
1573
|
+
*
|
|
1574
|
+
* @internal
|
|
1575
|
+
*/
|
|
1576
|
+
_hmrReplaceResolver?: (newResolver: EXPERIMENTAL_ResolverFixed<EXPERIMENTAL_RouteRecordNormalized_Matchable>) => void;
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Creates an experimental Router that allows passing a resolver instead of a
|
|
1580
|
+
* routes array. This router does not have `addRoute()` and `removeRoute()`
|
|
1581
|
+
* methods and is meant to be used with file-based routing thanks to
|
|
1582
|
+
* vue-router/vite or vue-router/unplugin resolver generation in
|
|
1583
|
+
* `'vue-router/auto-resolver'`.
|
|
1584
|
+
*
|
|
1585
|
+
* @param options - Options to initialize the router
|
|
1586
|
+
*/
|
|
1587
|
+
declare function experimental_createRouter(options: EXPERIMENTAL_RouterOptions): EXPERIMENTAL_Router;
|
|
1588
|
+
//#endregion
|
|
1589
|
+
//#region src/experimental/route-resolver/matchers/errors.d.ts
|
|
1590
|
+
/**
|
|
1591
|
+
* Error throw when a matcher matches by regex but validation fails.
|
|
1592
|
+
*
|
|
1593
|
+
* @internal
|
|
1594
|
+
*/
|
|
1595
|
+
declare class MatchMiss extends Error {
|
|
1596
|
+
name: string;
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* Helper to throw a {@link MatchMiss} error.
|
|
1600
|
+
* @param args - Arguments to pass to the `MatchMiss` constructor.
|
|
1601
|
+
*
|
|
1602
|
+
* @example
|
|
1603
|
+
* ```ts
|
|
1604
|
+
* miss()
|
|
1605
|
+
* // in a number param matcher
|
|
1606
|
+
* miss('Number must be finite')
|
|
1607
|
+
* ```
|
|
1608
|
+
*/
|
|
1609
|
+
declare const miss: (...args: ConstructorParameters<typeof MatchMiss>) => never;
|
|
1610
|
+
//#endregion
|
|
1611
|
+
//#region src/experimental/runtime.d.ts
|
|
1612
|
+
/**
|
|
1613
|
+
* Helper to define page properties with file-based routing.
|
|
1614
|
+
* **Doesn't do anything**, used for types only.
|
|
1615
|
+
*
|
|
1616
|
+
* The `FilePath` type parameter is injected by the `sfc-typed-router` Volar
|
|
1617
|
+
* plugin so that `params.path` keys are restricted to the file's actual path
|
|
1618
|
+
* params. When omitted, `params.path` falls back to a loose record.
|
|
1619
|
+
*
|
|
1620
|
+
* @param route - route information to be added to this page
|
|
1621
|
+
*
|
|
1622
|
+
* @internal
|
|
1623
|
+
*/
|
|
1624
|
+
declare function definePage<FilePath extends string = string>(route: DefinePage<FilePath>): DefinePage<FilePath>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Resolves the union of valid path-param names for a given file path. Falls
|
|
1627
|
+
* back to `string` when no entry is augmented (default Volar-less usage).
|
|
1628
|
+
*
|
|
1629
|
+
* Wired via the `_RouteFileInfoMap` slot in the user's augmented
|
|
1630
|
+
* {@link TypesConfig} so the lookup survives the bundler that otherwise
|
|
1631
|
+
* inlines an empty version of the base interface.
|
|
1632
|
+
*
|
|
1633
|
+
* @internal
|
|
1634
|
+
*/
|
|
1635
|
+
type PathParamNamesForFilePath<FilePath extends string> = TypesConfig extends {
|
|
1636
|
+
_RouteFileInfoMap: { [K in FilePath]: {
|
|
1637
|
+
pathParamNames: infer N extends string;
|
|
1638
|
+
}; };
|
|
1639
|
+
} ? N : string;
|
|
1640
|
+
/**
|
|
1641
|
+
* Merges route records.
|
|
1642
|
+
*
|
|
1643
|
+
* @internal
|
|
1644
|
+
*
|
|
1645
|
+
* @param main - main route record
|
|
1646
|
+
* @param routeRecords - route records to merge
|
|
1647
|
+
* @returns merged route record
|
|
1648
|
+
*/
|
|
1649
|
+
declare function _mergeRouteRecord(main: RouteRecordRaw, ...routeRecords: Partial<RouteRecordRaw>[]): RouteRecordRaw;
|
|
1650
|
+
/**
|
|
1651
|
+
* Type to define a page. Can be augmented to add custom properties.
|
|
1652
|
+
*
|
|
1653
|
+
* @typeParam FilePath - File path of the SFC declaring this page, used to
|
|
1654
|
+
* narrow `params.path` keys to the actual path parameters of the route. When
|
|
1655
|
+
* left as the default `string`, keys are unrestricted.
|
|
1656
|
+
*/
|
|
1657
|
+
interface DefinePage<FilePath extends string = string> extends Partial<Omit<RouteRecordRaw, 'children' | 'components' | 'component' | 'name'>> {
|
|
1658
|
+
/**
|
|
1659
|
+
* Override the route name. If not provided, the name will be generated based
|
|
1660
|
+
* on the file path. Can be set to `false` to make the route _anonymous_
|
|
1661
|
+
* which removes it from types and make the route unmatchable.
|
|
1662
|
+
*/
|
|
1663
|
+
name?: string | false;
|
|
1664
|
+
/**
|
|
1665
|
+
* Custom parameters for the route. Requires `experimental.paramParsers` enabled.
|
|
1666
|
+
*
|
|
1667
|
+
* @experimental
|
|
1668
|
+
*/
|
|
1669
|
+
params?: {
|
|
1670
|
+
/**
|
|
1671
|
+
* Parameters extracted from the path. Allows to setup custom parsers without changing the filename.
|
|
1672
|
+
*/
|
|
1673
|
+
path?: { [K in PathParamNamesForFilePath<FilePath>]?: ParamParserType; };
|
|
1674
|
+
/**
|
|
1675
|
+
* Parameters extracted from the query.
|
|
1676
|
+
*/
|
|
1677
|
+
query?: Record<string, DefinePageQueryParamOptionsAny | ParamParserType>;
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Built-in param parsers. Always available; merged into {@link ParamParsers}
|
|
1682
|
+
* alongside any entries the user augments into {@link TypesConfig.ParamParsers}.
|
|
1683
|
+
*
|
|
1684
|
+
* @internal
|
|
1685
|
+
*/
|
|
1686
|
+
interface ParamParsers_Native {
|
|
1687
|
+
int: {
|
|
1688
|
+
type: number;
|
|
1689
|
+
};
|
|
1690
|
+
bool: {
|
|
1691
|
+
type: boolean;
|
|
1692
|
+
};
|
|
1693
|
+
string: {
|
|
1694
|
+
type: string;
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
type ParamParserType_Native = keyof ParamParsers_Native;
|
|
1698
|
+
/**
|
|
1699
|
+
* Full registry of param parsers: built-ins merged with whatever the user
|
|
1700
|
+
* augments into {@link TypesConfig.ParamParsers}. Each entry is shaped
|
|
1701
|
+
* `{ type: T }` so the parsed value type can be looked up by name via
|
|
1702
|
+
* {@link ParamParserTypeOf}. The vue-router codegen emits this augmentation
|
|
1703
|
+
* automatically from files in the `params/` folder.
|
|
1704
|
+
*
|
|
1705
|
+
* @internal
|
|
1706
|
+
*/
|
|
1707
|
+
type ParamParsers = ParamParsers_Native & (TypesConfig extends {
|
|
1708
|
+
_ParamParsers: infer P;
|
|
1709
|
+
} ? P : {});
|
|
1710
|
+
/**
|
|
1711
|
+
* Union of all known parser names (built-in + augmented).
|
|
1712
|
+
*/
|
|
1713
|
+
type ParamParserType = keyof ParamParsers;
|
|
1714
|
+
/**
|
|
1715
|
+
* Resolves the parsed value type for a given parser name. Distributes over a
|
|
1716
|
+
* union of names, so `ParamParserTypeOf<'int' | 'date'>` → `number | Date`.
|
|
1717
|
+
*
|
|
1718
|
+
* Falls back to `unknown` when an entry is registered without a `type` field.
|
|
1719
|
+
* The `_ParamParsers` slot is internal — vue-router's codegen populates it
|
|
1720
|
+
* from files in `params/`.
|
|
1721
|
+
*
|
|
1722
|
+
* @example
|
|
1723
|
+
* ```ts
|
|
1724
|
+
* declare module 'vue-router' {
|
|
1725
|
+
* interface TypesConfig {
|
|
1726
|
+
* _ParamParsers: {
|
|
1727
|
+
* date: { type: Date }
|
|
1728
|
+
* }
|
|
1729
|
+
* }
|
|
1730
|
+
* }
|
|
1731
|
+
* ```
|
|
1732
|
+
*/
|
|
1733
|
+
type ParamParserTypeOf<Name extends ParamParserType> = Name extends keyof ParamParsers ? ParamParsers[Name] extends {
|
|
1734
|
+
type: infer T;
|
|
1735
|
+
} ? T : unknown : unknown;
|
|
1736
|
+
/**
|
|
1737
|
+
* Distributive variant of {@link DefinePageQueryParamOptions} used in the
|
|
1738
|
+
* `params.query` record. Distributing over `ParamParserType` produces one
|
|
1739
|
+
* variant per literal parser name so the `parser` field acts as a discriminant
|
|
1740
|
+
* and `default` is narrowed to that parser's resolved value type. Without
|
|
1741
|
+
* this, the bare interface defaults `Parser` to the full `ParamParserType`
|
|
1742
|
+
* union and `default` collapses to the union of every parser's value type.
|
|
1743
|
+
*
|
|
1744
|
+
* @internal
|
|
1745
|
+
*/
|
|
1746
|
+
type DefinePageQueryParamOptionsAny<P extends ParamParserType = ParamParserType> = P extends ParamParserType ? DefinePageQueryParamOptions<P> : never;
|
|
1747
|
+
/**
|
|
1748
|
+
* Configures how to extract a route param from a specific query parameter.
|
|
1749
|
+
*
|
|
1750
|
+
* @typeParam Parser - name of the param parser used for this query parameter,
|
|
1751
|
+
* used to type the {@link DefinePageQueryParamOptions.default | `default`}
|
|
1752
|
+
* value via {@link ParamParserTypeOf}.
|
|
1753
|
+
*/
|
|
1754
|
+
interface DefinePageQueryParamOptions<Parser extends ParamParserType = ParamParserType> {
|
|
1755
|
+
/**
|
|
1756
|
+
* The type of the query parameter. Allowed values are native param parsers
|
|
1757
|
+
* and any parser in the {@link https://uvr.esm.is/TODO | params folder }. If
|
|
1758
|
+
* not provided, the value will kept as is.
|
|
1759
|
+
*/
|
|
1760
|
+
parser?: Parser;
|
|
1761
|
+
/**
|
|
1762
|
+
* Default value if the query parameter is missing or if the match fails
|
|
1763
|
+
* (e.g. a invalid number is passed to the int param parser). If not provided
|
|
1764
|
+
* and the param is not required, the route will match with undefined.
|
|
1765
|
+
*/
|
|
1766
|
+
default?: (() => ParamParserTypeOf<Parser>) | ParamParserTypeOf<Parser>;
|
|
1767
|
+
/**
|
|
1768
|
+
* How to format the query parameter value.
|
|
1769
|
+
*
|
|
1770
|
+
* - 'value' - keep the first value only and pass that to parser
|
|
1771
|
+
* - 'array' - keep all values (even one or none) as an array and pass that to parser
|
|
1772
|
+
*
|
|
1773
|
+
* @default 'value'
|
|
1774
|
+
*/
|
|
1775
|
+
format?: 'value' | 'array';
|
|
1776
|
+
/**
|
|
1777
|
+
* Whether this query parameter is required. If true and the parameter is
|
|
1778
|
+
* missing (and no default is provided), the route will not match.
|
|
1779
|
+
*
|
|
1780
|
+
* @default false
|
|
1781
|
+
*/
|
|
1782
|
+
required?: boolean;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* TODO: native parsers ideas:
|
|
1786
|
+
* - json -> just JSON.parse(value)
|
|
1787
|
+
* - boolean -> 'true' | 'false' -> boolean
|
|
1788
|
+
* - number -> Number(value) -> NaN if not a number
|
|
1789
|
+
*/
|
|
1790
|
+
//#endregion
|
|
1791
|
+
//#region src/experimental/data-loaders/types-config.d.ts
|
|
1792
|
+
/**
|
|
1793
|
+
* The default error type used for data loaders. Can be customized via {@link TypesConfig}.
|
|
1794
|
+
*
|
|
1795
|
+
* @example
|
|
1796
|
+
* ```ts
|
|
1797
|
+
* // types-extension.d.ts
|
|
1798
|
+
* import 'vue-router/experimental'
|
|
1799
|
+
* export {}
|
|
1800
|
+
* declare module 'vue-router/experimental' {
|
|
1801
|
+
* interface TypesConfig {
|
|
1802
|
+
* Error: MyCustomError
|
|
1803
|
+
* }
|
|
1804
|
+
* }
|
|
1805
|
+
* ```
|
|
1806
|
+
*
|
|
1807
|
+
* @internal
|
|
1808
|
+
*/
|
|
1809
|
+
type ErrorDefault = TypesConfig extends Record<'Error', infer E> ? E : Error;
|
|
1810
|
+
//#endregion
|
|
1811
|
+
//#region src/experimental/data-loaders/defineLoader.d.ts
|
|
1812
|
+
/**
|
|
1813
|
+
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
|
1814
|
+
*
|
|
1815
|
+
* @param name - name of the route
|
|
1816
|
+
* @param loader - function that returns a promise with the data
|
|
1817
|
+
* @param options - options to configure the data loader
|
|
1818
|
+
*/
|
|
1819
|
+
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
|
1822
|
+
*
|
|
1823
|
+
* @param name - name of the route
|
|
1824
|
+
* @param loader - function that returns a promise with the data
|
|
1825
|
+
* @param options - options to configure the data loader
|
|
1826
|
+
*/
|
|
1827
|
+
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
|
1830
|
+
*
|
|
1831
|
+
* @param loader - function that returns a promise with the data
|
|
1832
|
+
* @param options - options to configure the data loader
|
|
1833
|
+
*/
|
|
1834
|
+
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
|
1835
|
+
/**
|
|
1836
|
+
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
|
1837
|
+
*
|
|
1838
|
+
* @param loader - function that returns a promise with the data
|
|
1839
|
+
* @param options - options to configure the data loader
|
|
1840
|
+
*/
|
|
1841
|
+
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
|
1842
|
+
interface DefineDataLoaderOptions_LaxData extends DefineDataLoaderOptionsBase_LaxData {
|
|
1843
|
+
/**
|
|
1844
|
+
* Key to use for SSR state. This will be used to read the initial data from `initialData`'s object.
|
|
1845
|
+
*/
|
|
1846
|
+
key?: string;
|
|
1847
|
+
}
|
|
1848
|
+
interface DefineDataLoaderOptions_DefinedData extends DefineDataLoaderOptionsBase_DefinedData {
|
|
1849
|
+
key?: string;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* @deprecated use {@link DefineDataLoaderOptions_LaxData} instead
|
|
1853
|
+
*/
|
|
1854
|
+
type DefineDataLoaderOptions = DefineDataLoaderOptions_LaxData;
|
|
1855
|
+
interface DataLoaderContext extends DataLoaderContextBase {}
|
|
1856
|
+
/**
|
|
1857
|
+
* Symbol used to store the data in the router so it can be retrieved after the initial navigation.
|
|
1858
|
+
* @internal
|
|
1859
|
+
*/
|
|
1860
|
+
declare const SERVER_INITIAL_DATA_KEY: unique symbol;
|
|
1861
|
+
/**
|
|
1862
|
+
* Initial data generated on server and consumed on client.
|
|
1863
|
+
* @internal
|
|
1864
|
+
*/
|
|
1865
|
+
declare const INITIAL_DATA_KEY: unique symbol;
|
|
1866
|
+
interface UseDataLoaderBasic_LaxData<Data> extends UseDataLoader<Data | undefined, ErrorDefault> {}
|
|
1867
|
+
/**
|
|
1868
|
+
* @deprecated use {@link UseDataLoaderBasic_LaxData} instead
|
|
1869
|
+
*/
|
|
1870
|
+
type UseDataLoaderBasic<Data> = UseDataLoaderBasic_LaxData<Data>;
|
|
1871
|
+
interface UseDataLoaderBasic_DefinedData<Data> extends UseDataLoader<Data, ErrorDefault> {}
|
|
1872
|
+
interface DataLoaderBasicEntry<TData, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> extends DataLoaderEntryBase<TData, TError, TDataInitial> {}
|
|
1873
|
+
//#endregion
|
|
1874
|
+
//#region src/experimental/index.d.ts
|
|
1875
|
+
/**
|
|
1876
|
+
* @deprecated Use {@link reroute} instead.
|
|
1877
|
+
*/
|
|
1878
|
+
declare class NavigationResult$1 extends NavigationResult {
|
|
1879
|
+
constructor(...args: ConstructorParameters<typeof NavigationResult>);
|
|
1880
|
+
}
|
|
1881
|
+
//#endregion
|
|
1882
|
+
//#region src/types/index.d.ts
|
|
1883
|
+
type Lazy<T> = () => Promise<T>;
|
|
1884
|
+
/**
|
|
1885
|
+
* @internal
|
|
1886
|
+
*/
|
|
1887
|
+
type RouteParamValue = string;
|
|
1888
|
+
/**
|
|
1889
|
+
* @internal
|
|
1890
|
+
*/
|
|
1891
|
+
type RouteParamValueRaw = RouteParamValue | number | null | undefined;
|
|
1892
|
+
type RouteParamsGeneric = Record<string, RouteParamValue | RouteParamValue[]>;
|
|
1893
|
+
type RouteParamsRawGeneric = Record<string, RouteParamValueRaw | Exclude<RouteParamValueRaw, null | undefined>[]>;
|
|
1894
|
+
/**
|
|
1895
|
+
* @internal
|
|
1896
|
+
*/
|
|
1897
|
+
interface RouteQueryAndHash {
|
|
1898
|
+
query?: LocationQueryRaw$1;
|
|
1899
|
+
hash?: string;
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* @internal
|
|
1903
|
+
*/
|
|
1904
|
+
interface MatcherLocationAsPath {
|
|
1905
|
+
path: string;
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* @internal
|
|
1909
|
+
*/
|
|
1910
|
+
interface MatcherLocationAsName {
|
|
1911
|
+
name: RouteRecordNameGeneric;
|
|
1912
|
+
/**
|
|
1913
|
+
* Ignored path property since we are dealing with a relative location. Only `undefined` is allowed.
|
|
1914
|
+
*/
|
|
1915
|
+
path?: undefined;
|
|
1916
|
+
params?: RouteParamsGeneric;
|
|
1917
|
+
}
|
|
1918
|
+
/**
|
|
1919
|
+
* @internal
|
|
1920
|
+
*/
|
|
1921
|
+
interface MatcherLocationAsRelative {
|
|
1922
|
+
/**
|
|
1923
|
+
* Ignored path property since we are dealing with a relative location. Only `undefined` is allowed.
|
|
1924
|
+
*/
|
|
1925
|
+
path?: undefined;
|
|
1926
|
+
params?: RouteParamsGeneric;
|
|
1927
|
+
}
|
|
1928
|
+
/**
|
|
1929
|
+
* @internal
|
|
1930
|
+
*/
|
|
1931
|
+
interface LocationAsRelativeRaw {
|
|
1932
|
+
name?: RouteRecordNameGeneric;
|
|
1933
|
+
/**
|
|
1934
|
+
* Ignored path property since we are dealing with a relative location. Only `undefined` is allowed.
|
|
1935
|
+
*/
|
|
1936
|
+
path?: undefined;
|
|
1937
|
+
params?: RouteParamsRawGeneric;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Common options for all navigation methods.
|
|
1941
|
+
*/
|
|
1942
|
+
interface RouteLocationOptions {
|
|
1943
|
+
/**
|
|
1944
|
+
* Replace the entry in the history instead of pushing a new entry
|
|
1945
|
+
*/
|
|
1946
|
+
replace?: boolean;
|
|
1947
|
+
/**
|
|
1948
|
+
* Triggers the navigation even if the location is the same as the current one.
|
|
1949
|
+
* Note this will also add a new entry to the history unless `replace: true`
|
|
1950
|
+
* is passed.
|
|
1951
|
+
*/
|
|
1952
|
+
force?: boolean;
|
|
1953
|
+
/**
|
|
1954
|
+
* State to save using the History API. This cannot contain any reactive
|
|
1955
|
+
* values and some primitives like Symbols are forbidden. More info at
|
|
1956
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/History/state
|
|
1957
|
+
*/
|
|
1958
|
+
state?: HistoryState;
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* Route Location that can infer the necessary params based on the name.
|
|
1962
|
+
*
|
|
1963
|
+
* @internal
|
|
1964
|
+
*/
|
|
1965
|
+
interface RouteLocationNamedRaw extends RouteQueryAndHash, LocationAsRelativeRaw, RouteLocationOptions {}
|
|
1966
|
+
/**
|
|
1967
|
+
* Route Location that can infer the possible paths.
|
|
1968
|
+
*
|
|
1969
|
+
* @internal
|
|
1970
|
+
*/
|
|
1971
|
+
interface RouteLocationPathRaw extends RouteQueryAndHash, MatcherLocationAsPath, RouteLocationOptions {}
|
|
1972
|
+
interface RouteLocationMatched extends RouteRecordNormalized {
|
|
1973
|
+
components: Record<string, RouteComponent> | null | undefined;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Base properties for a normalized route location.
|
|
1977
|
+
*
|
|
1978
|
+
* @internal
|
|
1979
|
+
*/
|
|
1980
|
+
interface _RouteLocationBase extends Pick<MatcherLocation, 'name' | 'path' | 'params' | 'meta'> {
|
|
1981
|
+
/**
|
|
1982
|
+
* The whole location including the `search` and `hash`. This string is
|
|
1983
|
+
* percentage encoded.
|
|
1984
|
+
*/
|
|
813
1985
|
fullPath: string;
|
|
814
1986
|
/**
|
|
815
1987
|
* Object representation of the `search` property of the current location.
|
|
816
1988
|
*/
|
|
817
|
-
query: LocationQuery;
|
|
1989
|
+
query: LocationQuery$1;
|
|
818
1990
|
/**
|
|
819
1991
|
* Hash of the current location. If present, starts with a `#`.
|
|
820
1992
|
*/
|
|
@@ -828,7 +2000,7 @@ interface _RouteLocationBase extends Pick<MatcherLocation, 'name' | 'path' | 'pa
|
|
|
828
2000
|
/**
|
|
829
2001
|
* Allowed Component in {@link RouteLocationMatched}
|
|
830
2002
|
*/
|
|
831
|
-
type RouteComponent = Component | DefineComponent;
|
|
2003
|
+
type RouteComponent = Component$1 | DefineComponent;
|
|
832
2004
|
/**
|
|
833
2005
|
* Allowed Component definitions in route records provided by the user
|
|
834
2006
|
*/
|
|
@@ -894,7 +2066,34 @@ interface _RouteRecordBase extends PathParserOptions {
|
|
|
894
2066
|
* }
|
|
895
2067
|
* ```
|
|
896
2068
|
*/
|
|
897
|
-
interface RouteMeta extends Record<PropertyKey, unknown> {
|
|
2069
|
+
interface RouteMeta extends Record<PropertyKey, unknown> {
|
|
2070
|
+
/**
|
|
2071
|
+
* The data loaders for a route record. Add any data loader to this array to
|
|
2072
|
+
* have it called when the route is navigated to. Note this is only needed
|
|
2073
|
+
* when **not** using lazy components (`() => import('./pages/Home.vue')`) or
|
|
2074
|
+
* when not explicitly exporting data loaders from page components.
|
|
2075
|
+
*
|
|
2076
|
+
* This requires the use of the experimental data loaders and is ignored otherwise.
|
|
2077
|
+
*
|
|
2078
|
+
* @see {@link DataLoaderPlugin}
|
|
2079
|
+
*/
|
|
2080
|
+
loaders?: UseDataLoader[];
|
|
2081
|
+
/**
|
|
2082
|
+
* Set of loaders for the current route. This is built once during navigation
|
|
2083
|
+
* and is used to merge the loaders from the lazy import in components or the
|
|
2084
|
+
* `loaders` array in the route record.
|
|
2085
|
+
*
|
|
2086
|
+
* @internal
|
|
2087
|
+
*/
|
|
2088
|
+
[LOADER_SET_KEY]?: Set<UseDataLoader>;
|
|
2089
|
+
/**
|
|
2090
|
+
* The signal that is aborted when the navigation is canceled or an error
|
|
2091
|
+
* occurs.
|
|
2092
|
+
*
|
|
2093
|
+
* @internal
|
|
2094
|
+
*/
|
|
2095
|
+
[ABORT_CONTROLLER_KEY]?: AbortController;
|
|
2096
|
+
}
|
|
898
2097
|
/**
|
|
899
2098
|
* Route Record defining one single component with the `component` option.
|
|
900
2099
|
*/
|
|
@@ -1006,968 +2205,1089 @@ interface MatcherLocation {
|
|
|
1006
2205
|
matched: RouteRecord[];
|
|
1007
2206
|
}
|
|
1008
2207
|
//#endregion
|
|
1009
|
-
//#region src/
|
|
2208
|
+
//#region src/typed-routes/route-map.d.ts
|
|
1010
2209
|
/**
|
|
1011
|
-
*
|
|
1012
|
-
* {@link
|
|
1013
|
-
*
|
|
1014
|
-
* @internal
|
|
2210
|
+
* Helper type to define a Typed `RouteRecord`
|
|
2211
|
+
* @see {@link RouteRecord}
|
|
1015
2212
|
*/
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
2213
|
+
interface RouteRecordInfo<Name extends string | symbol = string, Path extends string = string, ParamsRaw extends RouteParamsRawGeneric = RouteParamsRawGeneric, Params extends RouteParamsGeneric = RouteParamsGeneric, ChildrenNames extends string | symbol = never> {
|
|
2214
|
+
name: Name;
|
|
2215
|
+
path: Path;
|
|
2216
|
+
paramsRaw: ParamsRaw;
|
|
2217
|
+
params: Params;
|
|
2218
|
+
childrenNames: ChildrenNames;
|
|
1022
2219
|
}
|
|
2220
|
+
type RouteRecordInfoGeneric = RouteRecordInfo<string | symbol, string, RouteParamsRawGeneric, RouteParamsGeneric, string | symbol>;
|
|
1023
2221
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
* {@link
|
|
2222
|
+
* Convenience type to get the typed RouteMap or a generic one if not provided.
|
|
2223
|
+
* It is extracted from the {@link TypesConfig} if it exists, it becomes
|
|
2224
|
+
* {@link RouteMapGeneric} otherwise.
|
|
1026
2225
|
*/
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* An aborted navigation is a navigation that failed because a navigation
|
|
1030
|
-
* guard returned `false` or called `next(false)`
|
|
1031
|
-
*/
|
|
1032
|
-
aborted = 4,
|
|
1033
|
-
/**
|
|
1034
|
-
* A cancelled navigation is a navigation that failed because a more recent
|
|
1035
|
-
* navigation finished started (not necessarily finished).
|
|
1036
|
-
*/
|
|
1037
|
-
cancelled = 8,
|
|
1038
|
-
/**
|
|
1039
|
-
* A duplicated navigation is a navigation that failed because it was
|
|
1040
|
-
* initiated while already being at the exact same location.
|
|
1041
|
-
*/
|
|
1042
|
-
duplicated = 16,
|
|
1043
|
-
}
|
|
2226
|
+
type RouteMap = TypesConfig extends Record<'RouteNamedMap', infer RouteNamedMap> ? RouteNamedMap : RouteMapGeneric;
|
|
1044
2227
|
/**
|
|
1045
|
-
*
|
|
2228
|
+
* Generic version of the `RouteMap`.
|
|
1046
2229
|
*/
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
*/
|
|
1051
|
-
type: ErrorTypes.NAVIGATION_CANCELLED | ErrorTypes.NAVIGATION_ABORTED | ErrorTypes.NAVIGATION_DUPLICATED;
|
|
1052
|
-
/**
|
|
1053
|
-
* Route location we were navigating from
|
|
1054
|
-
*/
|
|
1055
|
-
from: RouteLocationNormalized;
|
|
1056
|
-
/**
|
|
1057
|
-
* Route location we were navigating to
|
|
1058
|
-
*/
|
|
1059
|
-
to: RouteLocationNormalized;
|
|
1060
|
-
}
|
|
2230
|
+
type RouteMapGeneric = Record<string | symbol, RouteRecordInfoGeneric>;
|
|
2231
|
+
//#endregion
|
|
2232
|
+
//#region src/typed-routes/params.d.ts
|
|
1061
2233
|
/**
|
|
1062
|
-
*
|
|
2234
|
+
* Utility type for raw and non raw params like :id+
|
|
1063
2235
|
*
|
|
1064
|
-
* @internal
|
|
1065
2236
|
*/
|
|
1066
|
-
|
|
1067
|
-
type: ErrorTypes.NAVIGATION_GUARD_REDIRECT;
|
|
1068
|
-
to: RouteLocationRaw;
|
|
1069
|
-
}
|
|
2237
|
+
type ParamValueOneOrMore<isRaw extends boolean> = [ParamValue<isRaw>, ...ParamValue<isRaw>[]];
|
|
1070
2238
|
/**
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
* @param error - possible {@link NavigationFailure}
|
|
1074
|
-
* @param type - optional types to check for
|
|
2239
|
+
* Utility type for raw and non raw params like :id*
|
|
1075
2240
|
*
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
2241
|
+
*/
|
|
2242
|
+
type ParamValueZeroOrMore<isRaw extends boolean> = true extends isRaw ? ParamValue<isRaw>[] | undefined | null : ParamValue<isRaw>[] | undefined;
|
|
2243
|
+
/**
|
|
2244
|
+
* Utility type for raw and non raw params like :id?
|
|
1079
2245
|
*
|
|
1080
|
-
* router.afterEach((to, from, failure) => {
|
|
1081
|
-
* // Any kind of navigation failure
|
|
1082
|
-
* if (isNavigationFailure(failure)) {
|
|
1083
|
-
* // ...
|
|
1084
|
-
* }
|
|
1085
|
-
* // Only duplicated navigations
|
|
1086
|
-
* if (isNavigationFailure(failure, NavigationFailureType.duplicated)) {
|
|
1087
|
-
* // ...
|
|
1088
|
-
* }
|
|
1089
|
-
* // Aborted or canceled navigations
|
|
1090
|
-
* if (isNavigationFailure(failure, NavigationFailureType.aborted | NavigationFailureType.cancelled )) {
|
|
1091
|
-
* // ...
|
|
1092
|
-
* }
|
|
1093
|
-
* })
|
|
1094
|
-
* ```
|
|
1095
2246
|
*/
|
|
1096
|
-
|
|
1097
|
-
declare function isNavigationFailure(error: any, type?: ErrorTypes | NavigationFailureType): error is NavigationFailure;
|
|
2247
|
+
type ParamValueZeroOrOne<isRaw extends boolean> = true extends isRaw ? string | number | null | undefined : string;
|
|
1098
2248
|
/**
|
|
1099
|
-
*
|
|
2249
|
+
* Utility type for raw and non raw params like :id
|
|
1100
2250
|
*
|
|
1101
|
-
* @param error - error thrown
|
|
1102
|
-
* @param to - location we were navigating to when the error happened
|
|
1103
|
-
* @param from - location we were navigating from when the error happened
|
|
1104
|
-
* @internal
|
|
1105
2251
|
*/
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
2252
|
+
type ParamValue<isRaw extends boolean> = true extends isRaw ? string | number : string;
|
|
2253
|
+
/**
|
|
2254
|
+
* Generate a type safe params for a route location. Requires the name of the route to be passed as a generic.
|
|
2255
|
+
* @see {@link RouteParamsGeneric}
|
|
2256
|
+
*/
|
|
2257
|
+
type RouteParams<Name extends keyof RouteMap = keyof RouteMap> = RouteMap[Name]['params'];
|
|
2258
|
+
/**
|
|
2259
|
+
* Generate a type safe raw params for a route location. Requires the name of the route to be passed as a generic.
|
|
2260
|
+
* @see {@link RouteParamsRaw}
|
|
2261
|
+
*/
|
|
2262
|
+
type RouteParamsRaw<Name extends keyof RouteMap = keyof RouteMap> = RouteMap[Name]['paramsRaw'];
|
|
1109
2263
|
//#endregion
|
|
1110
|
-
//#region src/
|
|
2264
|
+
//#region src/typed-routes/route-records.d.ts
|
|
1111
2265
|
/**
|
|
1112
|
-
*
|
|
1113
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions | `ScrollToOptions`}.
|
|
1114
|
-
* Note that not all browsers support `behavior`.
|
|
2266
|
+
* @internal
|
|
1115
2267
|
*/
|
|
1116
|
-
type
|
|
1117
|
-
behavior?: ScrollOptions['behavior'];
|
|
1118
|
-
left?: number;
|
|
1119
|
-
top?: number;
|
|
1120
|
-
};
|
|
2268
|
+
type RouteRecordRedirectOption = RouteLocationRaw | ((to: RouteLocation, from: RouteLocationNormalizedLoaded) => RouteLocationRaw);
|
|
1121
2269
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
|
|
2270
|
+
* Generic version of {@link RouteRecordName}.
|
|
2271
|
+
*/
|
|
2272
|
+
type RouteRecordNameGeneric = string | symbol | undefined;
|
|
2273
|
+
/**
|
|
2274
|
+
* Possible values for a route record **after normalization**
|
|
1124
2275
|
*
|
|
2276
|
+
* NOTE: since `RouteRecordName` is a type, it evaluates too early and it's often the generic version {@link RouteRecordNameGeneric}. If you need a typed version of all of the names of routes, use {@link RouteMap | `keyof RouteMap`}
|
|
2277
|
+
*/
|
|
2278
|
+
type RouteRecordName = RouteMapGeneric extends RouteMap ? RouteRecordNameGeneric : keyof RouteMap;
|
|
2279
|
+
/**
|
|
1125
2280
|
* @internal
|
|
1126
2281
|
*/
|
|
1127
|
-
type
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
top: number;
|
|
1131
|
-
};
|
|
2282
|
+
type _RouteRecordProps<Name extends keyof RouteMap = keyof RouteMap> = boolean | Record<string, any> | ((to: RouteLocationNormalized<Name>) => Record<string, any>);
|
|
2283
|
+
//#endregion
|
|
2284
|
+
//#region src/typed-routes/route-location.d.ts
|
|
1132
2285
|
/**
|
|
1133
|
-
*
|
|
2286
|
+
* Generic version of {@link RouteLocation}. It is used when no {@link RouteMap} is provided.
|
|
1134
2287
|
*/
|
|
1135
|
-
interface
|
|
2288
|
+
interface RouteLocationGeneric extends _RouteLocationBase, RouteLocationOptions {
|
|
1136
2289
|
/**
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
2290
|
+
* Array of {@link RouteRecord} containing components as they were
|
|
2291
|
+
* passed when adding records. It can also contain redirect records. This
|
|
2292
|
+
* can't be used directly. **This property is non-enumerable**.
|
|
1140
2293
|
*/
|
|
1141
|
-
|
|
2294
|
+
matched: RouteRecord[];
|
|
1142
2295
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
* - `.title`
|
|
1150
|
-
* - `.content:first-child`
|
|
1151
|
-
* - `#marker`
|
|
1152
|
-
* - `#marker\~with\~symbols`
|
|
1153
|
-
* - `#marker.with.dot`: selects `class="with dot" id="marker"`, not `id="marker.with.dot"`
|
|
1154
|
-
*
|
|
1155
|
-
*/
|
|
1156
|
-
el: string | Element;
|
|
2296
|
+
/**
|
|
2297
|
+
* Helper to generate a type safe version of the {@link RouteLocation} type.
|
|
2298
|
+
*/
|
|
2299
|
+
interface RouteLocationTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; }, Name extends keyof RouteMap> extends RouteLocationGeneric {
|
|
2300
|
+
name: Extract<Name, string | symbol>;
|
|
2301
|
+
params: RouteMap[Name]['params'];
|
|
1157
2302
|
}
|
|
1158
|
-
type ScrollPosition = ScrollPositionCoordinates | ScrollPositionElement;
|
|
1159
|
-
type Awaitable<T> = T | PromiseLike<T>;
|
|
1160
|
-
//#endregion
|
|
1161
|
-
//#region src/experimental/route-resolver/matchers/param-parsers/types.d.ts
|
|
1162
2303
|
/**
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1166
|
-
* @see MatcherPattern
|
|
2304
|
+
* List of all possible {@link RouteLocation} indexed by the route name.
|
|
2305
|
+
* @internal
|
|
1167
2306
|
*/
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
2307
|
+
type RouteLocationTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationTyped<RouteMap, N>; };
|
|
2308
|
+
/**
|
|
2309
|
+
* Generic version of {@link RouteLocationNormalized} that is used when no {@link RouteMap} is provided.
|
|
2310
|
+
*/
|
|
2311
|
+
interface RouteLocationNormalizedGeneric extends _RouteLocationBase {
|
|
2312
|
+
name: RouteRecordNameGeneric;
|
|
2313
|
+
/**
|
|
2314
|
+
* Array of {@link RouteRecordNormalized}
|
|
2315
|
+
*/
|
|
2316
|
+
matched: RouteRecordNormalized[];
|
|
1171
2317
|
}
|
|
1172
|
-
//#endregion
|
|
1173
|
-
//#region src/experimental/route-resolver/matchers/matcher-pattern.d.ts
|
|
1174
2318
|
/**
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1177
|
-
* @template TIn - type of the input value to match against the pattern
|
|
1178
|
-
* @template TParams - type of the output value after matching
|
|
1179
|
-
* @template TParamsRaw - type of the input value to build the input from
|
|
1180
|
-
*
|
|
1181
|
-
* In the case of the `path`, the `TIn` is a `string`, but in the case of the
|
|
1182
|
-
* query, it's the object of query params. `TParamsRaw` allows for a more permissive
|
|
1183
|
-
* type when building the value, for example allowing numbers and strings like
|
|
1184
|
-
* the old params.
|
|
1185
|
-
*
|
|
1186
|
-
* @internal this is the base interface for all matcher patterns, it shouldn't
|
|
1187
|
-
* be used directly
|
|
2319
|
+
* Helper to generate a type safe version of the {@link RouteLocationNormalized} type.
|
|
1188
2320
|
*/
|
|
1189
|
-
interface
|
|
2321
|
+
interface RouteLocationNormalizedTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> extends RouteLocationNormalizedGeneric {
|
|
2322
|
+
name: Extract<Name, string | symbol>;
|
|
2323
|
+
params: RouteMap[Name]['params'];
|
|
1190
2324
|
/**
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
* @param value - params value to parse
|
|
1194
|
-
* @throws {MatchMiss} if the value doesn't match
|
|
1195
|
-
* @returns parsed params object
|
|
2325
|
+
* Array of {@link RouteRecordNormalized}
|
|
1196
2326
|
*/
|
|
1197
|
-
|
|
2327
|
+
matched: RouteRecordNormalized[];
|
|
2328
|
+
}
|
|
2329
|
+
/**
|
|
2330
|
+
* List of all possible {@link RouteLocationNormalized} indexed by the route name.
|
|
2331
|
+
* @internal
|
|
2332
|
+
*/
|
|
2333
|
+
type RouteLocationNormalizedTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationNormalizedTyped<RouteMap, N>; };
|
|
2334
|
+
/**
|
|
2335
|
+
* Generic version of {@link RouteLocationNormalizedLoaded} that is used when no {@link RouteMap} is provided.
|
|
2336
|
+
*/
|
|
2337
|
+
interface RouteLocationNormalizedLoadedGeneric extends RouteLocationNormalizedGeneric {
|
|
1198
2338
|
/**
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
* @param value - params value to parse
|
|
1204
|
-
* @returns serialized params value
|
|
2339
|
+
* Array of {@link RouteLocationMatched} containing only plain components (any
|
|
2340
|
+
* lazy-loaded components have been loaded and were replaced inside the
|
|
2341
|
+
* `components` object) so it can be directly used to display routes. It
|
|
2342
|
+
* cannot contain redirect records either. **This property is non-enumerable**.
|
|
1205
2343
|
*/
|
|
1206
|
-
|
|
2344
|
+
matched: RouteLocationMatched[];
|
|
1207
2345
|
}
|
|
1208
2346
|
/**
|
|
1209
|
-
*
|
|
1210
|
-
* object of params and vice versa.
|
|
2347
|
+
* Helper to generate a type safe version of the {@link RouteLocationNormalizedLoaded} type.
|
|
1211
2348
|
*/
|
|
1212
|
-
interface
|
|
1213
|
-
|
|
1214
|
-
|
|
2349
|
+
interface RouteLocationNormalizedLoadedTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> extends RouteLocationNormalizedLoadedGeneric {
|
|
2350
|
+
name: Extract<Name, string | symbol>;
|
|
2351
|
+
params: RouteMap[Name]['params'];
|
|
2352
|
+
}
|
|
1215
2353
|
/**
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
* @example
|
|
1219
|
-
* ```ts
|
|
1220
|
-
* const matcher = new MatcherPatternPathStatic('/team')
|
|
1221
|
-
* matcher.match('/team') // {}
|
|
1222
|
-
* matcher.match('/team/123') // throws MatchMiss
|
|
1223
|
-
* matcher.build() // '/team'
|
|
1224
|
-
* ```
|
|
2354
|
+
* List of all possible {@link RouteLocationNormalizedLoaded} indexed by the route name.
|
|
2355
|
+
* @internal
|
|
1225
2356
|
*/
|
|
1226
|
-
|
|
1227
|
-
|
|
2357
|
+
type RouteLocationNormalizedLoadedTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationNormalizedLoadedTyped<RouteMap, N>; };
|
|
2358
|
+
/**
|
|
2359
|
+
* Generic version of {@link RouteLocationAsRelative}. It is used when no {@link RouteMap} is provided.
|
|
2360
|
+
*/
|
|
2361
|
+
interface RouteLocationAsRelativeGeneric extends RouteQueryAndHash, RouteLocationOptions {
|
|
2362
|
+
name?: RouteRecordNameGeneric;
|
|
2363
|
+
params?: RouteParamsRawGeneric;
|
|
1228
2364
|
/**
|
|
1229
|
-
*
|
|
1230
|
-
* This is used to make the matching case insensitive.
|
|
2365
|
+
* A relative path to the current location. This property should be removed
|
|
1231
2366
|
*/
|
|
1232
|
-
|
|
1233
|
-
constructor(path: string);
|
|
1234
|
-
match(path: string): EmptyParams;
|
|
1235
|
-
build(): string;
|
|
2367
|
+
path?: undefined;
|
|
1236
2368
|
}
|
|
1237
2369
|
/**
|
|
1238
|
-
*
|
|
2370
|
+
* Helper to generate a type safe version of the {@link RouteLocationAsRelative} type.
|
|
1239
2371
|
*/
|
|
1240
|
-
|
|
2372
|
+
interface RouteLocationAsRelativeTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> extends RouteLocationAsRelativeGeneric {
|
|
2373
|
+
name?: Extract<Name, string | symbol>;
|
|
2374
|
+
params?: RouteMap[Name]['paramsRaw'];
|
|
2375
|
+
}
|
|
1241
2376
|
/**
|
|
1242
|
-
*
|
|
2377
|
+
* List of all possible {@link RouteLocationAsRelative} indexed by the route name.
|
|
2378
|
+
* @internal
|
|
1243
2379
|
*/
|
|
1244
|
-
|
|
2380
|
+
type RouteLocationAsRelativeTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationAsRelativeTyped<RouteMap, N>; };
|
|
1245
2381
|
/**
|
|
1246
|
-
*
|
|
2382
|
+
* Generic version of {@link RouteLocationAsPath}. It is used when no {@link RouteMap} is provided.
|
|
1247
2383
|
*/
|
|
1248
|
-
|
|
2384
|
+
interface RouteLocationAsPathGeneric extends RouteQueryAndHash, RouteLocationOptions {
|
|
2385
|
+
/**
|
|
2386
|
+
* Percentage encoded pathname section of the URL.
|
|
2387
|
+
*/
|
|
2388
|
+
path: string;
|
|
2389
|
+
}
|
|
1249
2390
|
/**
|
|
1250
|
-
*
|
|
2391
|
+
* Helper to generate a type safe version of the {@link RouteLocationAsPath} type.
|
|
1251
2392
|
*/
|
|
1252
|
-
|
|
2393
|
+
interface RouteLocationAsPathTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> extends RouteLocationAsPathGeneric {
|
|
2394
|
+
path: _LiteralUnion<RouteMap[Name]['path']>;
|
|
2395
|
+
}
|
|
1253
2396
|
/**
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
2397
|
+
* List of all possible {@link RouteLocationAsPath} indexed by the route name.
|
|
1256
2398
|
* @internal
|
|
1257
2399
|
*/
|
|
1258
|
-
type
|
|
2400
|
+
type RouteLocationAsPathTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationAsPathTyped<RouteMap, N>; };
|
|
1259
2401
|
/**
|
|
1260
|
-
* Helper
|
|
1261
|
-
|
|
2402
|
+
* Helper to generate a type safe version of the {@link RouteLocationAsString} type.
|
|
2403
|
+
*/
|
|
2404
|
+
type RouteLocationAsStringTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> = RouteMap[Name]['path'];
|
|
2405
|
+
/**
|
|
2406
|
+
* List of all possible {@link RouteLocationAsString} indexed by the route name.
|
|
1262
2407
|
* @internal
|
|
1263
2408
|
*/
|
|
1264
|
-
type
|
|
2409
|
+
type RouteLocationAsStringTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationAsStringTyped<RouteMap, N>; };
|
|
1265
2410
|
/**
|
|
1266
|
-
*
|
|
2411
|
+
* Generic version of {@link RouteLocationResolved}. It is used when no {@link RouteMap} is provided.
|
|
1267
2412
|
*/
|
|
1268
|
-
|
|
1269
|
-
readonly re: RegExp;
|
|
1270
|
-
readonly params: TParamsOptions & Record<string, MatcherPatternPathDynamic_ParamOptions<any, any>>;
|
|
1271
|
-
readonly pathParts: Array<string | number | Array<string | number>>;
|
|
1272
|
-
readonly trailingSlash: boolean | null;
|
|
1273
|
-
/**
|
|
1274
|
-
* Cached keys of the {@link params} object.
|
|
1275
|
-
*/
|
|
1276
|
-
private paramsKeys;
|
|
2413
|
+
interface RouteLocationResolvedGeneric extends RouteLocationGeneric {
|
|
1277
2414
|
/**
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1280
|
-
* @param re - regex to match the path against
|
|
1281
|
-
* @param params - object of param parsers as {@link MatcherPatternPathDynamic_ParamOptions}
|
|
1282
|
-
* @param pathParts - array of path parts, where strings are static parts, 1 are regular params, and 0 are splat params (not encode slash)
|
|
1283
|
-
* @param trailingSlash - whether the path should end with a trailing slash, null means "do not care" (for trailing splat params)
|
|
2415
|
+
* Resolved `href` for the route location that will be set on the `<a href="...">`.
|
|
1284
2416
|
*/
|
|
1285
|
-
|
|
1286
|
-
match(path: string): Simplify<ExtractParamTypeFromOptions<TParamsOptions>>;
|
|
1287
|
-
build(params: Simplify<ExtractLocationParamTypeFromOptions<TParamsOptions>>): string;
|
|
2417
|
+
href: string;
|
|
1288
2418
|
}
|
|
1289
2419
|
/**
|
|
1290
|
-
*
|
|
1291
|
-
* object of params and vice versa.
|
|
2420
|
+
* Helper to generate a type safe version of the {@link RouteLocationResolved} type.
|
|
1292
2421
|
*/
|
|
1293
|
-
interface
|
|
2422
|
+
interface RouteLocationResolvedTyped<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; }, Name extends keyof RouteMap> extends RouteLocationTyped<RouteMap, Name> {
|
|
2423
|
+
/**
|
|
2424
|
+
* Resolved `href` for the route location that will be set on the `<a href="...">`.
|
|
2425
|
+
*/
|
|
2426
|
+
href: string;
|
|
2427
|
+
}
|
|
1294
2428
|
/**
|
|
1295
|
-
*
|
|
2429
|
+
* List of all possible {@link RouteLocationResolved} indexed by the route name.
|
|
2430
|
+
* @internal
|
|
1296
2431
|
*/
|
|
1297
|
-
type
|
|
2432
|
+
type RouteLocationResolvedTypedList<RouteMap extends { [K in keyof RouteMap]: RouteRecordInfoGeneric; } = RouteMapGeneric> = { [N in keyof RouteMap]: RouteLocationResolvedTyped<RouteMap, N>; };
|
|
1298
2433
|
/**
|
|
1299
|
-
*
|
|
2434
|
+
* Type safe versions of types that are exposed by vue-router. We have to use a generic check to allow for names to be `undefined` when no `RouteMap` is provided.
|
|
1300
2435
|
*/
|
|
1301
|
-
type EmptyParams = Record<PropertyKey, never>;
|
|
1302
2436
|
/**
|
|
1303
|
-
*
|
|
2437
|
+
* {@link RouteLocationRaw} resolved using the matcher
|
|
1304
2438
|
*/
|
|
1305
|
-
type
|
|
1306
|
-
type MatcherQueryParams = Record<string, MatcherQueryParamsValue>;
|
|
1307
|
-
//#endregion
|
|
1308
|
-
//#region src/location.d.ts
|
|
2439
|
+
type RouteLocation<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationGeneric : RouteLocationTypedList<RouteMap>[Name];
|
|
1309
2440
|
/**
|
|
1310
|
-
*
|
|
1311
|
-
* @
|
|
2441
|
+
* Similar to {@link RouteLocation} but its
|
|
2442
|
+
* {@link RouteLocationNormalizedTyped.matched | `matched` property} cannot contain redirect records
|
|
1312
2443
|
*/
|
|
1313
|
-
|
|
1314
|
-
path: string;
|
|
1315
|
-
fullPath: string;
|
|
1316
|
-
hash: string;
|
|
1317
|
-
query: LocationQuery;
|
|
1318
|
-
}
|
|
2444
|
+
type RouteLocationNormalized<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationNormalizedGeneric : RouteLocationNormalizedTypedList<RouteMap>[Name];
|
|
1319
2445
|
/**
|
|
1320
|
-
*
|
|
1321
|
-
* to
|
|
1322
|
-
*
|
|
1323
|
-
* @example
|
|
1324
|
-
* ```js
|
|
1325
|
-
* import { START_LOCATION } from 'vue-router'
|
|
1326
|
-
*
|
|
1327
|
-
* router.beforeEach((to, from) => {
|
|
1328
|
-
* if (from === START_LOCATION) {
|
|
1329
|
-
* // initial navigation
|
|
1330
|
-
* }
|
|
1331
|
-
* })
|
|
1332
|
-
* ```
|
|
2446
|
+
* Similar to {@link RouteLocationNormalized} but its `components` do not contain any function to lazy load components.
|
|
2447
|
+
* In other words, it's ready to be rendered by `<RouterView>`.
|
|
1333
2448
|
*/
|
|
1334
|
-
|
|
1335
|
-
//#endregion
|
|
1336
|
-
//#region src/experimental/route-resolver/resolver-abstract.d.ts
|
|
2449
|
+
type RouteLocationNormalizedLoaded<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationNormalizedLoadedGeneric : RouteLocationNormalizedLoadedTypedList<RouteMap>[Name];
|
|
1337
2450
|
/**
|
|
1338
|
-
*
|
|
2451
|
+
* Route location relative to the current location. It accepts other properties than `path` like `params`, `query` and
|
|
2452
|
+
* `hash` to conveniently change them.
|
|
1339
2453
|
*/
|
|
1340
|
-
type
|
|
2454
|
+
type RouteLocationAsRelative<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationAsRelativeGeneric : RouteLocationAsRelativeTypedList<RouteMap>[Name];
|
|
1341
2455
|
/**
|
|
1342
|
-
*
|
|
1343
|
-
* serialization of params, query, and hash.
|
|
1344
|
-
*
|
|
1345
|
-
* - `TMatcherRecordRaw` represents the raw record type passed to {@link addMatcher}.
|
|
1346
|
-
* - `TMatcherRecord` represents the normalized record type returned by {@link getRoutes}.
|
|
2456
|
+
* Route location resolved with {@link Router | `router.resolve()`}.
|
|
1347
2457
|
*/
|
|
1348
|
-
|
|
1349
|
-
/**
|
|
1350
|
-
* Resolves an absolute location (like `/path/to/somewhere`).
|
|
1351
|
-
*
|
|
1352
|
-
* @param absoluteLocation - The absolute location to resolve.
|
|
1353
|
-
* @param currentLocation - This value is ignored and should not be passed if the location is absolute.
|
|
1354
|
-
*/
|
|
1355
|
-
resolve(absoluteLocation: `/${string}`, currentLocation?: undefined): ResolverLocationResolved<TRecord>;
|
|
1356
|
-
/**
|
|
1357
|
-
* Resolves a string location relative to another location. A relative
|
|
1358
|
-
* location can be `./same-folder`, `../parent-folder`, `same-folder`, or
|
|
1359
|
-
* even `?page=2`.
|
|
1360
|
-
*/
|
|
1361
|
-
resolve(relativeLocation: string, currentLocation: ResolverLocationResolved<TRecord>): ResolverLocationResolved<TRecord>;
|
|
1362
|
-
/**
|
|
1363
|
-
* Resolves a location by its name. Any required params or query must be
|
|
1364
|
-
* passed in the `options` argument.
|
|
1365
|
-
*/
|
|
1366
|
-
resolve(location: ResolverLocationAsNamed, currentLocation?: undefined): ResolverLocationResolved<TRecord>;
|
|
1367
|
-
/**
|
|
1368
|
-
* Resolves a location by its absolute path (starts with `/`). Any required query must be passed.
|
|
1369
|
-
*
|
|
1370
|
-
* @param location - The location to resolve.
|
|
1371
|
-
*/
|
|
1372
|
-
resolve(location: ResolverLocationAsPathAbsolute, currentLocation?: undefined): ResolverLocationResolved<TRecord>;
|
|
1373
|
-
resolve(location: ResolverLocationAsPathRelative, currentLocation: ResolverLocationResolved<TRecord>): ResolverLocationResolved<TRecord>;
|
|
1374
|
-
/**
|
|
1375
|
-
* Resolves a location relative to another location. It reuses existing
|
|
1376
|
-
* properties in the `currentLocation` like `params`, `query`, and `hash`.
|
|
1377
|
-
*/
|
|
1378
|
-
resolve(relativeLocation: ResolverLocationAsRelative, currentLocation: ResolverLocationResolved<TRecord>): ResolverLocationResolved<TRecord>;
|
|
1379
|
-
/**
|
|
1380
|
-
* Get a list of all resolver route records.
|
|
1381
|
-
*/
|
|
1382
|
-
getRoutes(): TRecord[];
|
|
1383
|
-
/**
|
|
1384
|
-
* Get a resolver record by its name.
|
|
1385
|
-
* Previously named `getRecordMatcher()`
|
|
1386
|
-
*/
|
|
1387
|
-
getRoute(name: RecordName): TRecord | undefined;
|
|
1388
|
-
}
|
|
2458
|
+
type RouteLocationResolved<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationResolvedGeneric : RouteLocationResolvedTypedList<RouteMap>[Name];
|
|
1389
2459
|
/**
|
|
1390
|
-
*
|
|
1391
|
-
* It contains the resolved name, params, query, hash, and matched records.
|
|
2460
|
+
* Same as {@link RouteLocationAsPath} but as a string literal.
|
|
1392
2461
|
*/
|
|
1393
|
-
|
|
1394
|
-
/**
|
|
1395
|
-
* Name of the route record. A symbol if no name is provided.
|
|
1396
|
-
*/
|
|
1397
|
-
name: RecordName;
|
|
1398
|
-
/**
|
|
1399
|
-
* Parsed params. Already decoded and formatted.
|
|
1400
|
-
*/
|
|
1401
|
-
params: MatcherParamsFormatted;
|
|
1402
|
-
/**
|
|
1403
|
-
* Chain of route records that lead to the matched one. The last record is
|
|
1404
|
-
* the the one that matched the location. Each previous record is the parent
|
|
1405
|
-
* of the next one.
|
|
1406
|
-
*/
|
|
1407
|
-
matched: TMatched[];
|
|
1408
|
-
}
|
|
2462
|
+
type RouteLocationAsString<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? string : _LiteralUnion<RouteLocationAsStringTypedList<RouteMap>[Name], string>;
|
|
1409
2463
|
/**
|
|
1410
|
-
*
|
|
1411
|
-
* EXPERIMENTAL_Resolver_Base['resolve']} and is recognized as a `name`.
|
|
1412
|
-
*
|
|
1413
|
-
* @example
|
|
1414
|
-
* ```ts
|
|
1415
|
-
* resolver.resolve({ name: 'user', params: { id: 123 } })
|
|
1416
|
-
* resolver.resolve({ name: 'user-search', params: {}, query: { page: 2 } })
|
|
1417
|
-
* ```
|
|
2464
|
+
* Route location as an object with a `path` property.
|
|
1418
2465
|
*/
|
|
1419
|
-
|
|
1420
|
-
name: RecordName;
|
|
1421
|
-
params: MatcherParamsFormatted;
|
|
1422
|
-
query?: LocationQueryRaw;
|
|
1423
|
-
hash?: string;
|
|
1424
|
-
/**
|
|
1425
|
-
* @deprecated This is ignored when `name` is provided
|
|
1426
|
-
*/
|
|
1427
|
-
path?: undefined;
|
|
1428
|
-
}
|
|
2466
|
+
type RouteLocationAsPath<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationAsPathGeneric : RouteLocationAsPathTypedList<RouteMap>[Name];
|
|
1429
2467
|
/**
|
|
1430
|
-
*
|
|
1431
|
-
* and is recognized as a relative path.
|
|
1432
|
-
*
|
|
1433
|
-
* @example
|
|
1434
|
-
* ```ts
|
|
1435
|
-
* resolver.resolve({ path: './123' }, currentLocation)
|
|
1436
|
-
* resolver.resolve({ path: '..' }, currentLocation)
|
|
1437
|
-
* ```
|
|
2468
|
+
* Route location that can be passed to `router.push()` and other user-facing APIs.
|
|
1438
2469
|
*/
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
hash?: string;
|
|
1443
|
-
/**
|
|
1444
|
-
* @deprecated This is ignored when `path` is provided
|
|
1445
|
-
*/
|
|
1446
|
-
name?: undefined;
|
|
1447
|
-
/**
|
|
1448
|
-
* @deprecated This is ignored when `path` (instead of `name`) is provided
|
|
1449
|
-
*/
|
|
1450
|
-
params?: undefined;
|
|
1451
|
-
}
|
|
2470
|
+
type RouteLocationRaw<Name extends keyof RouteMap = keyof RouteMap> = RouteMapGeneric extends RouteMap ? RouteLocationAsString | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric : _LiteralUnion<RouteLocationAsStringTypedList<RouteMap>[Name], string> | RouteLocationAsRelativeTypedList<RouteMap>[Name] | RouteLocationAsPathTypedList<RouteMap>[Name];
|
|
2471
|
+
//#endregion
|
|
2472
|
+
//#region src/typed-routes/navigation-guards.d.ts
|
|
1452
2473
|
/**
|
|
1453
|
-
*
|
|
1454
|
-
* and is recognized as an absolute path.
|
|
2474
|
+
* Return types for a Navigation Guard. Based on `TypesConfig`
|
|
1455
2475
|
*
|
|
1456
|
-
* @
|
|
1457
|
-
* ```ts
|
|
1458
|
-
* resolver.resolve({ path: '/team/123' })
|
|
1459
|
-
* ```
|
|
2476
|
+
* @see {@link TypesConfig}
|
|
1460
2477
|
*/
|
|
1461
|
-
|
|
1462
|
-
path: `/${string}`;
|
|
1463
|
-
}
|
|
2478
|
+
type NavigationGuardReturn = void | Error | boolean | RouteLocationRaw;
|
|
1464
2479
|
/**
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
* `hash` if not provided.
|
|
1468
|
-
*
|
|
1469
|
-
* @example
|
|
1470
|
-
* ```ts
|
|
1471
|
-
* resolver.resolve({ params: { id: 123 } }, currentLocation)
|
|
1472
|
-
* resolver.resolve({ hash: '#bottom' }, currentLocation)
|
|
1473
|
-
* ```
|
|
2480
|
+
* Navigation Guard with a type parameter for `this`.
|
|
2481
|
+
* @see {@link TypesConfig}
|
|
1474
2482
|
*/
|
|
1475
|
-
interface
|
|
1476
|
-
|
|
1477
|
-
query?: LocationQueryRaw;
|
|
1478
|
-
hash?: string;
|
|
1479
|
-
/**
|
|
1480
|
-
* @deprecated This location is relative to the next parameter. This `name` will be ignored.
|
|
1481
|
-
*/
|
|
1482
|
-
name?: undefined;
|
|
2483
|
+
interface NavigationGuardWithThis<T> {
|
|
2484
|
+
(this: T, to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded,
|
|
1483
2485
|
/**
|
|
1484
|
-
* @deprecated
|
|
2486
|
+
* @deprecated Return a value from the guard instead of calling `next(value)`.
|
|
2487
|
+
* The callback will be removed in a future version of Vue Router.
|
|
1485
2488
|
*/
|
|
1486
|
-
|
|
2489
|
+
next: NavigationGuardNext): _Awaitable<NavigationGuardReturn>;
|
|
1487
2490
|
}
|
|
1488
|
-
//#endregion
|
|
1489
|
-
//#region src/experimental/route-resolver/matchers/param-parsers/booleans.d.ts
|
|
1490
|
-
/**
|
|
1491
|
-
* Native Param parser for booleans.
|
|
1492
|
-
*
|
|
1493
|
-
* @internal
|
|
1494
|
-
*/
|
|
1495
|
-
declare const PARAM_PARSER_BOOL: {
|
|
1496
|
-
get: (value: NoInfer<MatcherQueryParamsValue>) => boolean | boolean[] | undefined;
|
|
1497
|
-
set: (value: boolean | boolean[] | null | undefined) => string | string[] | null | undefined;
|
|
1498
|
-
};
|
|
1499
|
-
//#endregion
|
|
1500
|
-
//#region src/experimental/route-resolver/matchers/param-parsers/integers.d.ts
|
|
1501
2491
|
/**
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
2492
|
+
* In `router.beforeResolve((to) => {})`, the `to` is typed as `RouteLocationNormalizedLoaded`, not
|
|
2493
|
+
* `RouteLocationNormalized` like in `router.beforeEach()`. In practice it doesn't change much as users do not rely on
|
|
2494
|
+
* the difference between them but if we update the type in vue-router, we will have to update this type too.
|
|
1504
2495
|
* @internal
|
|
1505
2496
|
*/
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
2497
|
+
interface _NavigationGuardResolved {
|
|
2498
|
+
(this: undefined, to: RouteLocationNormalizedLoaded, from: RouteLocationNormalizedLoaded,
|
|
2499
|
+
/**
|
|
2500
|
+
* @deprecated Return a value from the guard instead of calling `next(value)`.
|
|
2501
|
+
* The callback will be removed in a future version of Vue Router.
|
|
2502
|
+
*/
|
|
2503
|
+
next: NavigationGuardNext): _Awaitable<NavigationGuardReturn>;
|
|
2504
|
+
}
|
|
1512
2505
|
/**
|
|
1513
|
-
*
|
|
1514
|
-
*
|
|
1515
|
-
* @param parser - the parser to define. Will be returned as is.
|
|
1516
|
-
*
|
|
1517
|
-
* @see {@link defineQueryParamParser}
|
|
1518
|
-
* @see {@link defineParamParser}
|
|
2506
|
+
* Navigation Guard.
|
|
1519
2507
|
*/
|
|
1520
|
-
|
|
1521
|
-
|
|
2508
|
+
interface NavigationGuard {
|
|
2509
|
+
(to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded,
|
|
2510
|
+
/**
|
|
2511
|
+
* @deprecated Return a value from the guard instead of calling `next(value)`.
|
|
2512
|
+
* The callback will be removed in a future version of Vue Router.
|
|
2513
|
+
*/
|
|
2514
|
+
next: NavigationGuardNext): _Awaitable<NavigationGuardReturn>;
|
|
2515
|
+
}
|
|
1522
2516
|
/**
|
|
1523
|
-
*
|
|
1524
|
-
* path param parsers.
|
|
1525
|
-
*
|
|
1526
|
-
* @param parser - the parser to define. Will be returned as is.
|
|
1527
|
-
*
|
|
1528
|
-
* @see {@link definePathParamParser}
|
|
1529
|
-
* @see {@link defineParamParser}
|
|
2517
|
+
* Navigation hook triggered after a navigation is settled.
|
|
1530
2518
|
*/
|
|
1531
|
-
|
|
1532
|
-
|
|
2519
|
+
interface NavigationHookAfter {
|
|
2520
|
+
(to: RouteLocationNormalizedLoaded, from: RouteLocationNormalizedLoaded, failure?: NavigationFailure | void): unknown;
|
|
2521
|
+
}
|
|
1533
2522
|
/**
|
|
1534
|
-
*
|
|
1535
|
-
* works for path, query, and hash params.
|
|
2523
|
+
* Callback passed to navigation guards to continue or abort the navigation.
|
|
1536
2524
|
*
|
|
1537
|
-
* @
|
|
1538
|
-
*
|
|
2525
|
+
* @deprecated Prefer returning a value from the guard instead of calling
|
|
2526
|
+
* `next(value)`. The callback will be removed in a future version of Vue Router.
|
|
1539
2527
|
*/
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
2528
|
+
interface NavigationGuardNext {
|
|
2529
|
+
(): void;
|
|
2530
|
+
(error: Error): void;
|
|
2531
|
+
(location: RouteLocationRaw): void;
|
|
2532
|
+
(valid: boolean | undefined): void;
|
|
2533
|
+
(cb: NavigationGuardNextCallback): void;
|
|
2534
|
+
}
|
|
1543
2535
|
/**
|
|
1544
|
-
*
|
|
1545
|
-
* object of params and vice versa.
|
|
2536
|
+
* Callback that can be passed to `next()` in `beforeRouteEnter()` guards.
|
|
1546
2537
|
*/
|
|
1547
|
-
|
|
2538
|
+
type NavigationGuardNextCallback = (vm: ComponentPublicInstance) => unknown;
|
|
2539
|
+
//#endregion
|
|
2540
|
+
//#region src/experimental/data-loaders/meta-extensions.d.ts
|
|
1548
2541
|
/**
|
|
1549
|
-
*
|
|
2542
|
+
* Map type for the entries used by data loaders.
|
|
2543
|
+
* @internal
|
|
1550
2544
|
*/
|
|
1551
|
-
|
|
1552
|
-
private paramName;
|
|
1553
|
-
private queryKey;
|
|
1554
|
-
private format;
|
|
1555
|
-
private parser;
|
|
1556
|
-
private defaultValue?;
|
|
1557
|
-
constructor(paramName: ParamName, queryKey: string, format: 'value' | 'array', parser?: ParamParser<T>, defaultValue?: ((() => T) | T) | undefined);
|
|
1558
|
-
match(query: MatcherQueryParams): Record<ParamName, T>;
|
|
1559
|
-
build(params: Record<ParamName, T>): MatcherQueryParams;
|
|
1560
|
-
}
|
|
1561
|
-
//#endregion
|
|
1562
|
-
//#region src/experimental/route-resolver/resolver-fixed.d.ts
|
|
2545
|
+
type _DefineLoaderEntryMap<DataLoaderEntry extends DataLoaderEntryBase<unknown> = DataLoaderEntryBase<unknown>> = WeakMap<object, DataLoaderEntry>;
|
|
1563
2546
|
/**
|
|
1564
|
-
*
|
|
2547
|
+
* The extensions added to the router instance for data loaders. These are used
|
|
2548
|
+
* internally by the router and should not be accessed directly by users.
|
|
2549
|
+
*
|
|
2550
|
+
* @internal
|
|
1565
2551
|
*/
|
|
1566
|
-
interface
|
|
2552
|
+
interface DataLoaderExtensions {
|
|
1567
2553
|
/**
|
|
1568
|
-
*
|
|
1569
|
-
*
|
|
1570
|
-
*/
|
|
1571
|
-
name?: RecordName;
|
|
1572
|
-
/**
|
|
1573
|
-
* {@link MatcherPattern} for the path section of the URI.
|
|
2554
|
+
* The entries used by data loaders. Put on the router for convenience.
|
|
2555
|
+
* @internal
|
|
1574
2556
|
*/
|
|
1575
|
-
|
|
2557
|
+
[LOADER_ENTRIES_KEY]: _DefineLoaderEntryMap;
|
|
1576
2558
|
/**
|
|
1577
|
-
*
|
|
2559
|
+
* Pending navigation that is waiting for data loaders to resolve.
|
|
2560
|
+
* @internal
|
|
1578
2561
|
*/
|
|
1579
|
-
|
|
2562
|
+
[PENDING_LOCATION_KEY]: RouteLocationNormalizedLoaded | null;
|
|
1580
2563
|
/**
|
|
1581
|
-
*
|
|
2564
|
+
* The app instance that is used by the router.
|
|
2565
|
+
* @internal
|
|
1582
2566
|
*/
|
|
1583
|
-
|
|
2567
|
+
[APP_KEY]: App<unknown>;
|
|
1584
2568
|
/**
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
2569
|
+
* Whether the router is running in server-side rendering mode.
|
|
2570
|
+
* @internal
|
|
1587
2571
|
*/
|
|
1588
|
-
|
|
1589
|
-
}
|
|
1590
|
-
/**
|
|
1591
|
-
* A group can contain other useful properties like `meta` defined by the router.
|
|
1592
|
-
*/
|
|
1593
|
-
interface EXPERIMENTAL_ResolverRecord_Group extends EXPERIMENTAL_ResolverRecord_Base {
|
|
2572
|
+
[IS_SSR_KEY]: boolean;
|
|
1594
2573
|
/**
|
|
1595
|
-
*
|
|
2574
|
+
* The effect scope used to run data loaders.
|
|
2575
|
+
* @internal
|
|
1596
2576
|
*/
|
|
1597
|
-
|
|
2577
|
+
[DATA_LOADERS_EFFECT_SCOPE_KEY]: EffectScope;
|
|
1598
2578
|
/**
|
|
1599
|
-
*
|
|
2579
|
+
* Gives access to the initial state during rendering. Should be set to `false` once it's consumed.
|
|
2580
|
+
* Used by `defineLoader`
|
|
2581
|
+
*
|
|
2582
|
+
* @internal
|
|
1600
2583
|
*/
|
|
1601
|
-
|
|
2584
|
+
[SERVER_INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
|
1602
2585
|
/**
|
|
1603
|
-
*
|
|
2586
|
+
* Used by `defineLoader`
|
|
2587
|
+
*
|
|
2588
|
+
* @internal
|
|
1604
2589
|
*/
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
/**
|
|
1608
|
-
* A matchable record is a record that can be matched by a path, query or hash
|
|
1609
|
-
* and will resolve to a location.
|
|
1610
|
-
*/
|
|
1611
|
-
interface EXPERIMENTAL_ResolverRecord_Matchable extends EXPERIMENTAL_ResolverRecord_Base {
|
|
1612
|
-
name: RecordName;
|
|
1613
|
-
path: MatcherPatternPath;
|
|
2590
|
+
[INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
|
1614
2591
|
}
|
|
2592
|
+
//#endregion
|
|
2593
|
+
//#region src/history/hash.d.ts
|
|
1615
2594
|
/**
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
2595
|
+
* Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
|
|
2596
|
+
* handle any URL is not possible.
|
|
2597
|
+
*
|
|
2598
|
+
* @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
|
|
2599
|
+
* in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
|
|
2600
|
+
* calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
|
|
2601
|
+
* after the `#`).
|
|
2602
|
+
*
|
|
2603
|
+
* @example
|
|
2604
|
+
* ```js
|
|
2605
|
+
* // at https://example.com/folder
|
|
2606
|
+
* createWebHashHistory() // gives a url of `https://example.com/folder#`
|
|
2607
|
+
* createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
|
|
2608
|
+
* // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
|
|
2609
|
+
* createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
|
|
2610
|
+
* // you should avoid doing this because it changes the original url and breaks copying urls
|
|
2611
|
+
* createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
|
|
2612
|
+
*
|
|
2613
|
+
* // at file:///usr/etc/folder/index.html
|
|
2614
|
+
* // for locations with no `host`, the base is ignored
|
|
2615
|
+
* createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
|
|
2616
|
+
* ```
|
|
1618
2617
|
*/
|
|
1619
|
-
|
|
2618
|
+
declare function createWebHashHistory(base?: string): RouterHistory;
|
|
2619
|
+
//#endregion
|
|
2620
|
+
//#region src/history/html5.d.ts
|
|
1620
2621
|
/**
|
|
1621
|
-
*
|
|
2622
|
+
* Creates an HTML5 history. Most common history for single page applications.
|
|
2623
|
+
*
|
|
2624
|
+
* @param base -
|
|
1622
2625
|
*/
|
|
1623
|
-
|
|
2626
|
+
declare function createWebHistory(base?: string): RouterHistory;
|
|
2627
|
+
//#endregion
|
|
2628
|
+
//#region src/history/memory.d.ts
|
|
1624
2629
|
/**
|
|
1625
|
-
* Creates
|
|
1626
|
-
*
|
|
2630
|
+
* Creates an in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere.
|
|
2631
|
+
* It's up to the user to replace that location with the starter location by either calling `router.push` or `router.replace`.
|
|
1627
2632
|
*
|
|
1628
|
-
* @
|
|
1629
|
-
* @
|
|
1630
|
-
* @returns a resolver that can be passed to the router
|
|
2633
|
+
* @param base - Base applied to all urls, defaults to '/'
|
|
2634
|
+
* @returns a history object that can be passed to the router constructor
|
|
1631
2635
|
*/
|
|
1632
|
-
declare function
|
|
2636
|
+
declare function createMemoryHistory(base?: string): RouterHistory;
|
|
1633
2637
|
//#endregion
|
|
1634
|
-
//#region src/
|
|
2638
|
+
//#region src/router.d.ts
|
|
1635
2639
|
/**
|
|
1636
2640
|
* Options to initialize a {@link Router} instance.
|
|
1637
2641
|
*/
|
|
1638
|
-
interface
|
|
2642
|
+
interface RouterOptions extends EXPERIMENTAL_RouterOptions_Base {
|
|
1639
2643
|
/**
|
|
1640
|
-
*
|
|
1641
|
-
* `createWebHistory` but it requires the server to be properly configured.
|
|
1642
|
-
* You can also use a _hash_ based history with `createWebHashHistory` that
|
|
1643
|
-
* does not require any configuration on the server but isn't handled at all
|
|
1644
|
-
* by search engines and does poorly on SEO.
|
|
1645
|
-
*
|
|
1646
|
-
* @example
|
|
1647
|
-
* ```js
|
|
1648
|
-
* createRouter({
|
|
1649
|
-
* history: createWebHistory(),
|
|
1650
|
-
* // other options...
|
|
1651
|
-
* })
|
|
1652
|
-
* ```
|
|
2644
|
+
* Initial list of routes that should be added to the router.
|
|
1653
2645
|
*/
|
|
1654
|
-
|
|
2646
|
+
routes: Readonly<RouteRecordRaw[]>;
|
|
2647
|
+
}
|
|
2648
|
+
/**
|
|
2649
|
+
* Router instance.
|
|
2650
|
+
*/
|
|
2651
|
+
interface RouterClassic extends EXPERIMENTAL_Router_Base<RouteRecordNormalized> {
|
|
1655
2652
|
/**
|
|
1656
|
-
*
|
|
1657
|
-
* Promise to delay scrolling.
|
|
1658
|
-
*
|
|
1659
|
-
* @see {@link RouterScrollBehavior}.
|
|
1660
|
-
*
|
|
1661
|
-
* @example
|
|
1662
|
-
* ```js
|
|
1663
|
-
* function scrollBehavior(to, from, savedPosition) {
|
|
1664
|
-
* // `to` and `from` are both route locations
|
|
1665
|
-
* // `savedPosition` can be null if there isn't one
|
|
1666
|
-
* }
|
|
1667
|
-
* ```
|
|
2653
|
+
* Original options object passed to create the Router
|
|
1668
2654
|
*/
|
|
1669
|
-
|
|
2655
|
+
readonly options: RouterOptions;
|
|
1670
2656
|
/**
|
|
1671
|
-
*
|
|
1672
|
-
* {@link EXPERIMENTAL_RouterOptions_Base.stringifyQuery}.
|
|
1673
|
-
*
|
|
1674
|
-
* @example
|
|
1675
|
-
* Let's say you want to use the [qs package](https://github.com/ljharb/qs)
|
|
1676
|
-
* to parse queries, you can provide both `parseQuery` and `stringifyQuery`:
|
|
1677
|
-
* ```js
|
|
1678
|
-
* import qs from 'qs'
|
|
2657
|
+
* Add a new {@link RouteRecordRaw | route record} as the child of an existing route.
|
|
1679
2658
|
*
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
* parseQuery: qs.parse,
|
|
1683
|
-
* stringifyQuery: qs.stringify,
|
|
1684
|
-
* })
|
|
1685
|
-
* ```
|
|
2659
|
+
* @param parentName - Parent Route Record where `route` should be appended at
|
|
2660
|
+
* @param route - Route Record to add
|
|
1686
2661
|
*/
|
|
1687
|
-
|
|
2662
|
+
addRoute(parentName: NonNullable<RouteRecordNameGeneric>, route: RouteRecordRaw): () => void;
|
|
1688
2663
|
/**
|
|
1689
|
-
*
|
|
1690
|
-
*
|
|
2664
|
+
* Add a new {@link RouteRecordRaw | route record} to the router.
|
|
2665
|
+
*
|
|
2666
|
+
* @param route - Route Record to add
|
|
1691
2667
|
*/
|
|
1692
|
-
|
|
2668
|
+
addRoute(route: RouteRecordRaw): () => void;
|
|
1693
2669
|
/**
|
|
1694
|
-
*
|
|
1695
|
-
*
|
|
2670
|
+
* Remove an existing route by its name.
|
|
2671
|
+
*
|
|
2672
|
+
* @param name - Name of the route to remove
|
|
1696
2673
|
*/
|
|
1697
|
-
|
|
2674
|
+
removeRoute(name: NonNullable<RouteRecordNameGeneric>): void;
|
|
1698
2675
|
/**
|
|
1699
|
-
*
|
|
1700
|
-
* `router-link-exact-active` will be applied.
|
|
2676
|
+
* Delete all routes from the router.
|
|
1701
2677
|
*/
|
|
1702
|
-
|
|
2678
|
+
clearRoutes(): void;
|
|
1703
2679
|
}
|
|
1704
2680
|
/**
|
|
1705
|
-
*
|
|
2681
|
+
* Router instance.
|
|
2682
|
+
*
|
|
2683
|
+
* By default this resolves to the classic {@link RouterClassic}. Augment
|
|
2684
|
+
* {@link TypesConfig} with a `Router` slot to swap the public type.
|
|
2685
|
+
*
|
|
2686
|
+
* ```ts
|
|
2687
|
+
* import { router } from './router'
|
|
2688
|
+
* declare module 'vue-router' {
|
|
2689
|
+
* interface TypesConfig {
|
|
2690
|
+
* Router: typeof router
|
|
2691
|
+
* }
|
|
2692
|
+
* }
|
|
2693
|
+
* ```
|
|
1706
2694
|
*/
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
2695
|
+
type Router = TypesConfig extends Record<'Router', infer T> ? T : RouterClassic;
|
|
2696
|
+
/**
|
|
2697
|
+
* Creates a Router instance that can be used by a Vue app.
|
|
2698
|
+
*
|
|
2699
|
+
* @param options - {@link RouterOptions}
|
|
2700
|
+
*/
|
|
2701
|
+
declare function createRouter(options: RouterOptions): Router;
|
|
2702
|
+
//#endregion
|
|
2703
|
+
//#region src/injectionSymbols.d.ts
|
|
2704
|
+
/**
|
|
2705
|
+
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
|
2706
|
+
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
|
2707
|
+
* Location Matched
|
|
2708
|
+
*
|
|
2709
|
+
* @internal
|
|
2710
|
+
*/
|
|
2711
|
+
declare const matchedRouteKey: InjectionKey<ComputedRef<RouteRecordNormalized | undefined>>;
|
|
2712
|
+
/**
|
|
2713
|
+
* Allows overriding the router view depth to control which component in
|
|
2714
|
+
* `matched` is rendered. rvd stands for Router View Depth
|
|
2715
|
+
*
|
|
2716
|
+
* @internal
|
|
2717
|
+
*/
|
|
2718
|
+
declare const viewDepthKey: InjectionKey<Ref<number> | number>;
|
|
2719
|
+
/**
|
|
2720
|
+
* Allows overriding the router instance returned by `useRouter` in tests. r
|
|
2721
|
+
* stands for router
|
|
2722
|
+
*
|
|
2723
|
+
* @internal
|
|
2724
|
+
*/
|
|
2725
|
+
declare const routerKey: InjectionKey<Router>;
|
|
2726
|
+
/**
|
|
2727
|
+
* Allows overriding the current route returned by `useRoute` in tests. rl
|
|
2728
|
+
* stands for route location
|
|
2729
|
+
*
|
|
2730
|
+
* @internal
|
|
2731
|
+
*/
|
|
2732
|
+
declare const routeLocationKey: InjectionKey<RouteLocationNormalizedLoaded>;
|
|
2733
|
+
/**
|
|
2734
|
+
* Allows overriding the current route used by router-view. Internally this is
|
|
2735
|
+
* used when the `route` prop is passed.
|
|
2736
|
+
*
|
|
2737
|
+
* @internal
|
|
2738
|
+
*/
|
|
2739
|
+
declare const routerViewLocationKey: InjectionKey<Ref<RouteLocationNormalizedLoaded>>;
|
|
2740
|
+
//#endregion
|
|
2741
|
+
//#region src/navigationGuards.d.ts
|
|
2742
|
+
/**
|
|
2743
|
+
* Add a navigation guard that triggers whenever the component for the current
|
|
2744
|
+
* location is about to be left. Similar to {@link beforeRouteLeave} but can be
|
|
2745
|
+
* used in any component. The guard is removed when the component is unmounted.
|
|
2746
|
+
*
|
|
2747
|
+
* @param leaveGuard - {@link NavigationGuard}
|
|
2748
|
+
*/
|
|
2749
|
+
declare function onBeforeRouteLeave(leaveGuard: NavigationGuard): void;
|
|
2750
|
+
/**
|
|
2751
|
+
* Add a navigation guard that triggers whenever the current location is about
|
|
2752
|
+
* to be updated. Similar to {@link beforeRouteUpdate} but can be used in any
|
|
2753
|
+
* component. The guard is removed when the component is unmounted.
|
|
2754
|
+
*
|
|
2755
|
+
* @param updateGuard - {@link NavigationGuard}
|
|
2756
|
+
*/
|
|
2757
|
+
declare function onBeforeRouteUpdate(updateGuard: NavigationGuard): void;
|
|
2758
|
+
/**
|
|
2759
|
+
* Ensures a route is loaded, so it can be passed as o prop to `<RouterView>`.
|
|
2760
|
+
*
|
|
2761
|
+
* @param route - resolved route to load
|
|
2762
|
+
*/
|
|
2763
|
+
declare function loadRouteLocation(route: RouteLocation | RouteLocationNormalized): Promise<RouteLocationNormalizedLoaded>;
|
|
2764
|
+
//#endregion
|
|
2765
|
+
//#region src/RouterLink.d.ts
|
|
2766
|
+
interface RouterLinkOptions {
|
|
1718
2767
|
/**
|
|
1719
|
-
*
|
|
1720
|
-
* effect if the record has a `redirect` property.
|
|
2768
|
+
* Route Location the link should navigate to when clicked on.
|
|
1721
2769
|
*/
|
|
2770
|
+
to: RouteLocationRaw;
|
|
1722
2771
|
/**
|
|
1723
|
-
*
|
|
2772
|
+
* Calls `router.replace` instead of `router.push`.
|
|
1724
2773
|
*/
|
|
1725
|
-
|
|
2774
|
+
replace?: boolean;
|
|
2775
|
+
}
|
|
2776
|
+
interface RouterLinkProps extends RouterLinkOptions {
|
|
1726
2777
|
/**
|
|
1727
|
-
*
|
|
2778
|
+
* Whether RouterLink should not wrap its content in an `a` tag. Useful when
|
|
2779
|
+
* using `v-slot` to create a custom RouterLink
|
|
1728
2780
|
*/
|
|
1729
|
-
|
|
2781
|
+
custom?: boolean;
|
|
1730
2782
|
/**
|
|
1731
|
-
*
|
|
2783
|
+
* Class to apply when the link is active
|
|
1732
2784
|
*/
|
|
1733
|
-
|
|
1734
|
-
}
|
|
1735
|
-
interface EXPERIMENTAL_RouteRecord_Redirect extends Omit<EXPERIMENTAL_RouteRecord_Base, 'name' | 'path'>, EXPERIMENTAL_ResolverRecord_Matchable {
|
|
1736
|
-
components?: Record<string, RawRouteComponent>;
|
|
1737
|
-
redirect: RouteRecordRedirectOption;
|
|
1738
|
-
parent?: EXPERIMENTAL_RouteRecordNormalized | null;
|
|
1739
|
-
}
|
|
1740
|
-
interface EXPERIMENTAL_RouteRecord_Group extends Omit<EXPERIMENTAL_RouteRecord_Base, 'name' | 'path' | 'query' | 'hash'>, EXPERIMENTAL_ResolverRecord_Group {
|
|
1741
|
-
components?: Record<string, RawRouteComponent>;
|
|
1742
|
-
parent?: EXPERIMENTAL_RouteRecordNormalized | null;
|
|
1743
|
-
}
|
|
1744
|
-
interface EXPERIMENTAL_RouteRecord_Components extends Omit<EXPERIMENTAL_RouteRecord_Base, 'name' | 'path'>, EXPERIMENTAL_ResolverRecord_Matchable {
|
|
1745
|
-
components: Record<string, RawRouteComponent>;
|
|
1746
|
-
redirect?: never;
|
|
1747
|
-
parent?: EXPERIMENTAL_RouteRecordNormalized | null;
|
|
1748
|
-
}
|
|
1749
|
-
type EXPERIMENTAL_RouteRecord_Matchable = EXPERIMENTAL_RouteRecord_Components | EXPERIMENTAL_RouteRecord_Redirect;
|
|
1750
|
-
type EXPERIMENTAL_RouteRecordRaw = EXPERIMENTAL_RouteRecord_Matchable | EXPERIMENTAL_RouteRecord_Group;
|
|
1751
|
-
interface EXPERIMENTAL_RouteRecordNormalized_Base {
|
|
2785
|
+
activeClass?: string;
|
|
1752
2786
|
/**
|
|
1753
|
-
*
|
|
1754
|
-
*
|
|
1755
|
-
* @internal
|
|
2787
|
+
* Class to apply when the link is exact active
|
|
1756
2788
|
*/
|
|
1757
|
-
|
|
1758
|
-
props: Record<string, _RouteRecordProps>;
|
|
2789
|
+
exactActiveClass?: string;
|
|
1759
2790
|
/**
|
|
1760
|
-
*
|
|
2791
|
+
* Value passed to the attribute `aria-current` when the link is exact active.
|
|
1761
2792
|
*
|
|
1762
|
-
* @
|
|
2793
|
+
* @defaultValue `'page'`
|
|
1763
2794
|
*/
|
|
1764
|
-
|
|
2795
|
+
ariaCurrentValue?: 'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false';
|
|
1765
2796
|
/**
|
|
1766
|
-
*
|
|
2797
|
+
* Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported.
|
|
2798
|
+
*/
|
|
2799
|
+
viewTransition?: boolean;
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Options passed to {@link useLink}.
|
|
2803
|
+
*/
|
|
2804
|
+
interface UseLinkOptions<Name extends keyof RouteMap = keyof RouteMap> {
|
|
2805
|
+
to: MaybeRef<RouteLocationAsString | RouteLocationAsRelativeTyped<RouteMap, Name> | RouteLocationAsPath | RouteLocationRaw>;
|
|
2806
|
+
replace?: MaybeRef<boolean | undefined>;
|
|
2807
|
+
/**
|
|
2808
|
+
* Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported.
|
|
2809
|
+
*/
|
|
2810
|
+
viewTransition?: boolean;
|
|
2811
|
+
}
|
|
2812
|
+
/**
|
|
2813
|
+
* Return type of {@link useLink}.
|
|
2814
|
+
* @internal
|
|
2815
|
+
*/
|
|
2816
|
+
interface UseLinkReturn<Name extends keyof RouteMap = keyof RouteMap> {
|
|
2817
|
+
route: ComputedRef<RouteLocationResolved<Name>>;
|
|
2818
|
+
href: ComputedRef<string>;
|
|
2819
|
+
isActive: ComputedRef<boolean>;
|
|
2820
|
+
isExactActive: ComputedRef<boolean>;
|
|
2821
|
+
navigate(e?: MouseEvent): Promise<void | NavigationFailure>;
|
|
2822
|
+
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Returns the internal behavior of a {@link RouterLink} without the rendering part.
|
|
2825
|
+
*
|
|
2826
|
+
* @param props - a `to` location and an optional `replace` flag
|
|
2827
|
+
*/
|
|
2828
|
+
declare function useLink<Name extends keyof RouteMap = keyof RouteMap>(props: UseLinkOptions<Name>): UseLinkReturn<Name>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Component to render a link that triggers a navigation on click.
|
|
2831
|
+
*/
|
|
2832
|
+
declare const RouterLink: _RouterLinkI;
|
|
2833
|
+
/**
|
|
2834
|
+
* @internal
|
|
2835
|
+
*/
|
|
2836
|
+
type _RouterLinkPropsTypedBase = AllowedComponentProps & ComponentCustomProps & VNodeProps & RouterLinkProps;
|
|
2837
|
+
/**
|
|
2838
|
+
* @internal
|
|
2839
|
+
*/
|
|
2840
|
+
type RouterLinkPropsTyped<Custom extends boolean | undefined> = Custom extends true ? _RouterLinkPropsTypedBase & {
|
|
2841
|
+
custom: true;
|
|
2842
|
+
} : _RouterLinkPropsTypedBase & {
|
|
2843
|
+
custom?: false | undefined;
|
|
2844
|
+
} & Omit<AnchorHTMLAttributes, 'href'>;
|
|
2845
|
+
/**
|
|
2846
|
+
* Typed version of the `RouterLink` component. Its generic defaults to the typed router, so it can be inferred
|
|
2847
|
+
* automatically for JSX.
|
|
2848
|
+
*
|
|
2849
|
+
* @internal
|
|
2850
|
+
*/
|
|
2851
|
+
interface _RouterLinkI {
|
|
2852
|
+
new <Custom extends boolean | undefined = boolean | undefined>(): {
|
|
2853
|
+
$props: RouterLinkPropsTyped<Custom>;
|
|
2854
|
+
$slots: {
|
|
2855
|
+
default?: ({ route, href, isActive, isExactActive, navigate }: UnwrapRef<UseLinkReturn>) => VNode[];
|
|
2856
|
+
};
|
|
2857
|
+
};
|
|
2858
|
+
/**
|
|
2859
|
+
* Access to `useLink()` without depending on using vue-router
|
|
1767
2860
|
*
|
|
1768
2861
|
* @internal
|
|
1769
2862
|
*/
|
|
1770
|
-
|
|
1771
|
-
instances: Record<string, unknown>;
|
|
1772
|
-
}
|
|
1773
|
-
interface EXPERIMENTAL_RouteRecordNormalized_Group extends EXPERIMENTAL_RouteRecordNormalized_Base, EXPERIMENTAL_RouteRecord_Group {
|
|
1774
|
-
meta: RouteMeta;
|
|
2863
|
+
useLink: typeof useLink;
|
|
1775
2864
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
2865
|
+
//#endregion
|
|
2866
|
+
//#region src/RouterView.d.ts
|
|
2867
|
+
interface RouterViewProps {
|
|
2868
|
+
name?: string;
|
|
2869
|
+
route?: RouteLocationNormalized;
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* Component to display the current route the user is at.
|
|
2873
|
+
*/
|
|
2874
|
+
declare const RouterView: {
|
|
2875
|
+
new (): {
|
|
2876
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & RouterViewProps;
|
|
2877
|
+
$slots: {
|
|
2878
|
+
default?: ({ Component, route }: {
|
|
2879
|
+
Component: VNode;
|
|
2880
|
+
route: RouteLocationNormalizedLoaded;
|
|
2881
|
+
}) => VNode[];
|
|
2882
|
+
};
|
|
2883
|
+
};
|
|
2884
|
+
};
|
|
2885
|
+
//#endregion
|
|
2886
|
+
//#region src/useApi.d.ts
|
|
2887
|
+
/**
|
|
2888
|
+
* Returns the router instance. Equivalent to using `$router` inside
|
|
2889
|
+
* templates.
|
|
2890
|
+
*/
|
|
2891
|
+
declare function useRouter(): Router;
|
|
2892
|
+
/**
|
|
2893
|
+
* Returns the current route location. Equivalent to using `$route` inside
|
|
2894
|
+
* templates.
|
|
2895
|
+
*/
|
|
2896
|
+
declare function useRoute<Name extends keyof RouteMap = keyof RouteMap>(_name?: Name): RouteLocationNormalizedLoaded<Name | RouteMap[Name]["childrenNames"]>;
|
|
2897
|
+
//#endregion
|
|
2898
|
+
//#region src/index.d.ts
|
|
2899
|
+
declare module 'vue' {
|
|
2900
|
+
interface ComponentCustomOptions {
|
|
2901
|
+
/**
|
|
2902
|
+
* Guard called when the router is navigating to the route that is rendering
|
|
2903
|
+
* this component from a different route. Differently from `beforeRouteUpdate`
|
|
2904
|
+
* and `beforeRouteLeave`, `beforeRouteEnter` does not have access to the
|
|
2905
|
+
* component instance through `this` because it triggers before the component
|
|
2906
|
+
* is even mounted.
|
|
2907
|
+
*
|
|
2908
|
+
* @param to - RouteLocationRaw we are navigating to
|
|
2909
|
+
* @param from - RouteLocationRaw we are navigating from
|
|
2910
|
+
* @param next - function to validate, cancel or modify (by redirecting) the
|
|
2911
|
+
* navigation
|
|
2912
|
+
*/
|
|
2913
|
+
beforeRouteEnter?: TypesConfig extends Record<'beforeRouteEnter', infer T> ? T : NavigationGuardWithThis<undefined>;
|
|
2914
|
+
/**
|
|
2915
|
+
* Guard called whenever the route that renders this component has changed, but
|
|
2916
|
+
* it is reused for the new route. This allows you to guard for changes in
|
|
2917
|
+
* params, the query or the hash.
|
|
2918
|
+
*
|
|
2919
|
+
* @param to - RouteLocationRaw we are navigating to
|
|
2920
|
+
* @param from - RouteLocationRaw we are navigating from
|
|
2921
|
+
* @param next - function to validate, cancel or modify (by redirecting) the
|
|
2922
|
+
* navigation
|
|
2923
|
+
*/
|
|
2924
|
+
beforeRouteUpdate?: TypesConfig extends Record<'beforeRouteUpdate', infer T> ? T : NavigationGuard;
|
|
2925
|
+
/**
|
|
2926
|
+
* Guard called when the router is navigating away from the current route that
|
|
2927
|
+
* is rendering this component.
|
|
2928
|
+
*
|
|
2929
|
+
* @param to - RouteLocationRaw we are navigating to
|
|
2930
|
+
* @param from - RouteLocationRaw we are navigating from
|
|
2931
|
+
* @param next - function to validate, cancel or modify (by redirecting) the
|
|
2932
|
+
* navigation
|
|
2933
|
+
*/
|
|
2934
|
+
beforeRouteLeave?: TypesConfig extends Record<'beforeRouteLeave', infer T> ? T : NavigationGuard;
|
|
2935
|
+
}
|
|
2936
|
+
interface ComponentCustomProperties {
|
|
2937
|
+
/**
|
|
2938
|
+
* Normalized current location. See {@link RouteLocationNormalizedLoaded}.
|
|
2939
|
+
*/
|
|
2940
|
+
$route: TypesConfig extends Record<'$route', infer T> ? T : RouteLocationNormalizedLoaded;
|
|
2941
|
+
/**
|
|
2942
|
+
* {@link Router} instance used by the application.
|
|
2943
|
+
*/
|
|
2944
|
+
$router: TypesConfig extends Record<'$router', infer T> ? T : Router;
|
|
2945
|
+
}
|
|
2946
|
+
interface GlobalComponents {
|
|
2947
|
+
RouterView: TypesConfig extends Record<'RouterView', infer T> ? T : typeof RouterView;
|
|
2948
|
+
RouterLink: TypesConfig extends Record<'RouterLink', infer T> ? T : typeof RouterLink;
|
|
2949
|
+
}
|
|
1778
2950
|
}
|
|
1779
|
-
|
|
1780
|
-
|
|
2951
|
+
//#endregion
|
|
2952
|
+
//#region src/experimental/data-loaders/utils.d.ts
|
|
2953
|
+
/**
|
|
2954
|
+
* @internal: data loaders authoring only. Use `getCurrentContext` instead.
|
|
2955
|
+
*/
|
|
2956
|
+
declare let currentContext: readonly [entry: DataLoaderEntryBase, router: Router, route: RouteLocationNormalizedLoaded] | undefined | null;
|
|
2957
|
+
declare function getCurrentContext(): readonly [entry: DataLoaderEntryBase<unknown, unknown, unknown>, router: RouterClassic, route: RouteLocationNormalizedLoadedGeneric] | readonly [];
|
|
2958
|
+
/**
|
|
2959
|
+
* Sets the current context for data loaders. This allows for nested loaders to be aware of their parent context.
|
|
2960
|
+
* INTERNAL ONLY.
|
|
2961
|
+
*
|
|
2962
|
+
* @param context - the context to set
|
|
2963
|
+
* @internal
|
|
2964
|
+
*/
|
|
2965
|
+
declare function setCurrentContext(context?: typeof currentContext | readonly []): void;
|
|
2966
|
+
/**
|
|
2967
|
+
* Restore the current context after a promise is resolved.
|
|
2968
|
+
* @param promise - promise to wrap
|
|
2969
|
+
*/
|
|
2970
|
+
declare function withLoaderContext<P extends Promise<unknown>>(promise: P): P;
|
|
2971
|
+
/**
|
|
2972
|
+
* Object and promise of the object itself. Used when we can await some of the properties of an object to be loaded.
|
|
2973
|
+
* @internal
|
|
2974
|
+
*/
|
|
2975
|
+
type _PromiseMerged<PromiseType, RawType = PromiseType> = RawType & Promise<PromiseType>;
|
|
2976
|
+
/**
|
|
2977
|
+
* Track the reads of a route and its properties
|
|
2978
|
+
* @internal
|
|
2979
|
+
* @param route - route to track
|
|
2980
|
+
*/
|
|
2981
|
+
declare function trackRoute(route: RouteLocationNormalizedLoaded): readonly [{
|
|
2982
|
+
readonly hash: string;
|
|
2983
|
+
readonly params: RouteParamsGeneric;
|
|
2984
|
+
readonly query: LocationQuery$1;
|
|
2985
|
+
readonly matched: RouteLocationMatched[];
|
|
2986
|
+
readonly name: RouteRecordNameGeneric;
|
|
2987
|
+
readonly fullPath: string;
|
|
2988
|
+
readonly redirectedFrom: RouteLocation | undefined;
|
|
2989
|
+
readonly path: string;
|
|
2990
|
+
readonly meta: RouteMeta;
|
|
2991
|
+
}, Partial<RouteParamsGeneric>, Partial<LocationQuery$1>, {
|
|
2992
|
+
v: string | null;
|
|
2993
|
+
}];
|
|
2994
|
+
//#endregion
|
|
2995
|
+
//#region src/experimental/data-loaders/navigation-guard.d.ts
|
|
2996
|
+
/**
|
|
2997
|
+
* Options to initialize the data loader guard.
|
|
2998
|
+
*/
|
|
2999
|
+
interface SetupLoaderGuardOptions extends DataLoaderPluginOptions {
|
|
3000
|
+
/**
|
|
3001
|
+
* The Vue app instance. Used to access the `provide` and `inject` APIs.
|
|
3002
|
+
*/
|
|
3003
|
+
app: App<unknown>;
|
|
3004
|
+
/**
|
|
3005
|
+
* The effect scope to use for the data loaders.
|
|
3006
|
+
*/
|
|
3007
|
+
effect: EffectScope;
|
|
1781
3008
|
}
|
|
1782
|
-
type EXPERIMENTAL_RouteRecordNormalized_Matchable = EXPERIMENTAL_RouteRecordNormalized_Components | EXPERIMENTAL_RouteRecordNormalized_Redirect;
|
|
1783
|
-
type EXPERIMENTAL_RouteRecordNormalized = EXPERIMENTAL_RouteRecordNormalized_Matchable | EXPERIMENTAL_RouteRecordNormalized_Group;
|
|
1784
|
-
declare function normalizeRouteRecord(record: EXPERIMENTAL_RouteRecord_Group): EXPERIMENTAL_RouteRecordNormalized_Group;
|
|
1785
|
-
declare function normalizeRouteRecord(record: EXPERIMENTAL_RouteRecord_Matchable): EXPERIMENTAL_RouteRecordNormalized_Matchable;
|
|
1786
3009
|
/**
|
|
1787
|
-
*
|
|
1788
|
-
*
|
|
3010
|
+
* Possible values to change the result of a navigation within a loader
|
|
3011
|
+
* @internal
|
|
3012
|
+
*/
|
|
3013
|
+
type _DataLoaderRedirectResult = Exclude<ReturnType<NavigationGuard>, Promise<unknown> | Function | true | void | undefined>;
|
|
3014
|
+
/**
|
|
3015
|
+
* Allows data loaders to change navigation. Called by {@link reroute}.
|
|
1789
3016
|
*
|
|
1790
3017
|
* @internal
|
|
3018
|
+
*/
|
|
3019
|
+
declare class NavigationResult {
|
|
3020
|
+
readonly value: _DataLoaderRedirectResult;
|
|
3021
|
+
constructor(value: _DataLoaderRedirectResult);
|
|
3022
|
+
}
|
|
3023
|
+
/**
|
|
3024
|
+
* Changes the navigation from within a data loader. Accepts the same values as a navigation
|
|
3025
|
+
* guard return: a route location to redirect to, or `false` to cancel the navigation.
|
|
1791
3026
|
*
|
|
1792
|
-
* @
|
|
1793
|
-
*
|
|
1794
|
-
*
|
|
3027
|
+
* @example
|
|
3028
|
+
* ```ts
|
|
3029
|
+
* export const useUserData = defineBasicLoader(async (to) => {
|
|
3030
|
+
* const user = await fetchUser(to.params.id)
|
|
3031
|
+
* if (!user) {
|
|
3032
|
+
* reroute('/404')
|
|
3033
|
+
* }
|
|
3034
|
+
* return user
|
|
3035
|
+
* })
|
|
3036
|
+
* ```
|
|
1795
3037
|
*/
|
|
1796
|
-
declare function
|
|
3038
|
+
declare function reroute(to: _DataLoaderRedirectResult): never;
|
|
1797
3039
|
/**
|
|
1798
|
-
*
|
|
1799
|
-
*
|
|
3040
|
+
* Data Loader plugin to add data loading support to Vue Router.
|
|
3041
|
+
*
|
|
3042
|
+
* @example
|
|
3043
|
+
* ```ts
|
|
3044
|
+
* const router = createRouter({
|
|
3045
|
+
* routes,
|
|
3046
|
+
* history: createWebHistory(),
|
|
3047
|
+
* })
|
|
3048
|
+
*
|
|
3049
|
+
* const app = createApp({})
|
|
3050
|
+
* app.use(DataLoaderPlugin, { router })
|
|
3051
|
+
* app.use(router)
|
|
3052
|
+
* ```
|
|
1800
3053
|
*/
|
|
1801
|
-
|
|
3054
|
+
declare function DataLoaderPlugin(app: App, options: DataLoaderPluginOptions): void;
|
|
3055
|
+
/**
|
|
3056
|
+
* Options passed to the DataLoaderPlugin.
|
|
3057
|
+
*/
|
|
3058
|
+
interface DataLoaderPluginOptions {
|
|
1802
3059
|
/**
|
|
1803
|
-
*
|
|
1804
|
-
*
|
|
1805
|
-
* @experimental
|
|
3060
|
+
* The router instance. Adds the guards to it
|
|
1806
3061
|
*/
|
|
1807
|
-
|
|
3062
|
+
router: Router;
|
|
3063
|
+
isSSR?: boolean;
|
|
3064
|
+
/**
|
|
3065
|
+
* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
|
|
3066
|
+
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors.
|
|
3067
|
+
*/
|
|
3068
|
+
errors?: Array<new (...args: any) => any> | ((reason?: unknown) => boolean);
|
|
1808
3069
|
}
|
|
1809
3070
|
/**
|
|
1810
|
-
*
|
|
1811
|
-
*
|
|
1812
|
-
|
|
3071
|
+
* Return a ref that reflects the global loading state of all loaders within a navigation.
|
|
3072
|
+
* This state doesn't update if `refresh()` is manually called.
|
|
3073
|
+
*/
|
|
3074
|
+
declare function useIsDataLoading(): ShallowRef<boolean>;
|
|
3075
|
+
//#endregion
|
|
3076
|
+
//#region src/experimental/data-loaders/createDataLoader.d.ts
|
|
3077
|
+
/**
|
|
3078
|
+
* Base type for a data loader entry. Each Data Loader has its own entry in the `loaderEntries` (accessible via `[LOADER_ENTRIES_KEY]`) map.
|
|
1813
3079
|
*/
|
|
1814
|
-
interface
|
|
3080
|
+
interface DataLoaderEntryBase<TData = unknown, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> {
|
|
1815
3081
|
/**
|
|
1816
|
-
*
|
|
3082
|
+
* Data stored in the entry.
|
|
1817
3083
|
*/
|
|
1818
|
-
|
|
3084
|
+
data: ShallowRef<TData | TDataInitial>;
|
|
1819
3085
|
/**
|
|
1820
|
-
*
|
|
3086
|
+
* Error if there was an error.
|
|
1821
3087
|
*/
|
|
1822
|
-
|
|
3088
|
+
error: ShallowRef<TError | null>;
|
|
1823
3089
|
/**
|
|
1824
|
-
*
|
|
1825
|
-
*
|
|
1826
|
-
* @param name - Name of the route to check
|
|
3090
|
+
* Location the data was loaded for or `null` if the data is not loaded.
|
|
1827
3091
|
*/
|
|
1828
|
-
|
|
3092
|
+
to: RouteLocationNormalizedLoaded | null;
|
|
1829
3093
|
/**
|
|
1830
|
-
*
|
|
3094
|
+
* Whether there is an ongoing request.
|
|
1831
3095
|
*/
|
|
1832
|
-
|
|
3096
|
+
isLoading: ShallowRef<boolean>;
|
|
3097
|
+
options: DefineDataLoaderOptionsBase_LaxData;
|
|
1833
3098
|
/**
|
|
1834
|
-
*
|
|
1835
|
-
* {@link RouteLocationRaw | route location}. Also includes an `href` property
|
|
1836
|
-
* that includes any existing `base`. By default, the `currentLocation` used is
|
|
1837
|
-
* `router.currentRoute` and should only be overridden in advanced use cases.
|
|
1838
|
-
*
|
|
1839
|
-
* @param to - Raw route location to resolve
|
|
1840
|
-
* @param currentLocation - Optional current location to resolve against
|
|
3099
|
+
* Called by the navigation guard when the navigation is duplicated. Should be used to reset pendingTo and pendingLoad and any other property that should be reset.
|
|
1841
3100
|
*/
|
|
1842
|
-
|
|
1843
|
-
resolve(to: RouteLocationAsString | RouteLocationAsRelative | RouteLocationAsPath, currentLocation?: RouteLocationNormalizedLoaded): RouteLocationResolved;
|
|
3101
|
+
resetPending: () => void;
|
|
1844
3102
|
/**
|
|
1845
|
-
*
|
|
1846
|
-
* stack.
|
|
1847
|
-
*
|
|
1848
|
-
* @param to - Route location to navigate to
|
|
3103
|
+
* The latest pending load. Allows to verify if the load is still valid when it resolves.
|
|
1849
3104
|
*/
|
|
1850
|
-
|
|
3105
|
+
pendingLoad: Promise<void> | null;
|
|
1851
3106
|
/**
|
|
1852
|
-
*
|
|
1853
|
-
* the history stack.
|
|
1854
|
-
*
|
|
1855
|
-
* @param to - Route location to navigate to
|
|
3107
|
+
* The latest pending navigation's `to` route. Used to verify if the navigation is still valid when it resolves.
|
|
1856
3108
|
*/
|
|
1857
|
-
|
|
3109
|
+
pendingTo: RouteLocationNormalizedLoaded | null;
|
|
1858
3110
|
/**
|
|
1859
|
-
*
|
|
1860
|
-
* `
|
|
3111
|
+
* Data that was staged by a loader. This is used to avoid showing the old data while the new data is loading. Calling
|
|
3112
|
+
* the internal `commit()` function will replace the data with the staged data.
|
|
1861
3113
|
*/
|
|
1862
|
-
|
|
3114
|
+
staged: TData | typeof STAGED_NO_VALUE;
|
|
1863
3115
|
/**
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
3116
|
+
* Error that was staged by a loader. This is used to avoid showing the old error while the new data is loading.
|
|
3117
|
+
* Calling the internal `commit()` function will replace the error with the staged error.
|
|
1866
3118
|
*/
|
|
1867
|
-
|
|
3119
|
+
stagedError: TError | null;
|
|
1868
3120
|
/**
|
|
1869
|
-
*
|
|
1870
|
-
* `history.go()`.
|
|
1871
|
-
*
|
|
1872
|
-
* @param delta - The position in the history to which you want to move,
|
|
1873
|
-
* relative to the current page
|
|
3121
|
+
* Other data loaders that depend on this one. This is used to invalidate the data when a dependency is invalidated.
|
|
1874
3122
|
*/
|
|
1875
|
-
|
|
3123
|
+
children: Set<DataLoaderEntryBase>;
|
|
1876
3124
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
*
|
|
1880
|
-
* @param guard - navigation guard to add
|
|
3125
|
+
* Commits the pending data to the entry. This is called by the navigation guard when all non-lazy loaders have
|
|
3126
|
+
* finished loading. It should be implemented by the loader. It **must be called** from the entry itself:
|
|
3127
|
+
* `entry.commit(to)`.
|
|
1881
3128
|
*/
|
|
1882
|
-
|
|
3129
|
+
commit(to: RouteLocationNormalizedLoaded): void;
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Common properties for the options of `defineLoader()`. Types are `unknown` to allow for more specific types in the
|
|
3133
|
+
* extended types while having documentation in one single place.
|
|
3134
|
+
* @internal
|
|
3135
|
+
*/
|
|
3136
|
+
interface _DefineDataLoaderOptionsBase_Common {
|
|
1883
3137
|
/**
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1887
|
-
* registered guard.
|
|
3138
|
+
* When the data should be committed to the entry. In the case of lazy loaders, the loader will try to commit the data
|
|
3139
|
+
* after all non-lazy loaders have finished loading, but it might not be able to if the lazy loader hasn't been
|
|
3140
|
+
* resolved yet.
|
|
1888
3141
|
*
|
|
1889
|
-
* @
|
|
1890
|
-
* @
|
|
3142
|
+
* @see {@link DefineDataLoaderCommit}
|
|
3143
|
+
* @defaultValue `'after-load'`
|
|
3144
|
+
*/
|
|
3145
|
+
commit?: DefineDataLoaderCommit;
|
|
3146
|
+
/**
|
|
3147
|
+
* Whether the data should be lazy loaded without blocking the client side navigation or not. When set to true, the loader will no longer block the navigation and the returned composable can be called even
|
|
3148
|
+
* without having the data ready.
|
|
1891
3149
|
*
|
|
1892
|
-
* @
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
3150
|
+
* @defaultValue `false`
|
|
3151
|
+
*/
|
|
3152
|
+
lazy?: unknown;
|
|
3153
|
+
/**
|
|
3154
|
+
* Whether this loader should be awaited on the server side or not. Combined with the `lazy` option, this gives full
|
|
3155
|
+
* control over how to await for the data.
|
|
1898
3156
|
*
|
|
3157
|
+
* @defaultValue `true`
|
|
1899
3158
|
*/
|
|
1900
|
-
|
|
3159
|
+
server?: unknown;
|
|
1901
3160
|
/**
|
|
1902
|
-
*
|
|
1903
|
-
* function that
|
|
3161
|
+
* List of _expected_ errors that shouldn't abort the navigation (for non-lazy loaders). Provide a list of
|
|
3162
|
+
* constructors that can be checked with `instanceof` or a custom function that returns `true` for expected errors. Can also be set to `true` to accept all globally defined errors. Defaults to `false` to abort on any error.
|
|
3163
|
+
* @default `false`
|
|
3164
|
+
*/
|
|
3165
|
+
errors?: unknown;
|
|
3166
|
+
}
|
|
3167
|
+
/**
|
|
3168
|
+
* Options for a data loader that returns a data that is possibly `undefined`. Available for data loaders
|
|
3169
|
+
* implementations so they can be used in `defineLoader()` overloads.
|
|
3170
|
+
*/
|
|
3171
|
+
interface DefineDataLoaderOptionsBase_LaxData extends _DefineDataLoaderOptionsBase_Common {
|
|
3172
|
+
lazy?: boolean | ((to: RouteLocationNormalizedLoaded, from?: RouteLocationNormalizedLoaded) => boolean);
|
|
3173
|
+
server?: boolean;
|
|
3174
|
+
errors?: boolean | Array<new (...args: any[]) => any> | ((reason?: unknown) => boolean);
|
|
3175
|
+
}
|
|
3176
|
+
/**
|
|
3177
|
+
* Options for a data loader making the data defined without it being possibly `undefined`. Available for data loaders
|
|
3178
|
+
* implementations so they can be used in `defineLoader()` overloads.
|
|
3179
|
+
*/
|
|
3180
|
+
interface DefineDataLoaderOptionsBase_DefinedData extends _DefineDataLoaderOptionsBase_Common {
|
|
3181
|
+
lazy?: false;
|
|
3182
|
+
server?: true;
|
|
3183
|
+
errors?: false;
|
|
3184
|
+
}
|
|
3185
|
+
declare const toLazyValue: (lazy: undefined | DefineDataLoaderOptionsBase_LaxData["lazy"], to: RouteLocationNormalizedLoaded, from?: RouteLocationNormalizedLoaded) => boolean | undefined;
|
|
3186
|
+
/**
|
|
3187
|
+
* When the data should be committed to the entry.
|
|
3188
|
+
* - `immediate`: the data is committed as soon as it is loaded.
|
|
3189
|
+
* - `after-load`: the data is committed after all non-lazy loaders have finished loading.
|
|
3190
|
+
*/
|
|
3191
|
+
type DefineDataLoaderCommit = 'immediate' | 'after-load';
|
|
3192
|
+
interface DataLoaderContextBase {
|
|
3193
|
+
/**
|
|
3194
|
+
* Signal associated with the current navigation. It is aborted when the navigation is canceled or an error occurs.
|
|
3195
|
+
*/
|
|
3196
|
+
signal: AbortSignal | undefined;
|
|
3197
|
+
}
|
|
3198
|
+
/**
|
|
3199
|
+
* Data Loader composable returned by `defineLoader()`.
|
|
3200
|
+
* @see {@link DefineDataLoader}
|
|
3201
|
+
*/
|
|
3202
|
+
interface UseDataLoader<Data = unknown, TError = unknown> {
|
|
3203
|
+
[IS_USE_DATA_LOADER_KEY]: true;
|
|
3204
|
+
/**
|
|
3205
|
+
* Data Loader composable returned by `defineLoader()`.
|
|
1904
3206
|
*
|
|
1905
|
-
* @
|
|
1906
|
-
*
|
|
3207
|
+
* @example
|
|
3208
|
+
* Returns the Data loader data, isLoading, error etc. Meant to be used in `setup()` or `<script setup>` **without `await`**:
|
|
3209
|
+
* ```vue
|
|
3210
|
+
* <script setup>
|
|
3211
|
+
* const { data, isLoading, error } = useUserData()
|
|
3212
|
+
* </script>
|
|
3213
|
+
* ```
|
|
1907
3214
|
*
|
|
1908
3215
|
* @example
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
3216
|
+
* It also returns a promise of the data when used in nested loaders. Note this `data` is **not a ref**. This is not meant to be used in `setup()` or `<script setup>`.
|
|
3217
|
+
* ```ts
|
|
3218
|
+
* export const useUserConnections = defineLoader(async () => {
|
|
3219
|
+
* const user = await useUserData()
|
|
3220
|
+
* return fetchUserConnections(user.id)
|
|
1914
3221
|
* })
|
|
1915
3222
|
* ```
|
|
1916
3223
|
*/
|
|
1917
|
-
|
|
3224
|
+
(): _PromiseMerged<Exclude<Data, NavigationResult | undefined>, UseDataLoaderResult<Exclude<Data, NavigationResult>, TError>>;
|
|
1918
3225
|
/**
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1921
|
-
* asynchronously, errors returned or passed to `next` in any navigation
|
|
1922
|
-
* guard, and errors occurred when trying to resolve an async component that
|
|
1923
|
-
* is required to render a route.
|
|
1924
|
-
*
|
|
1925
|
-
* @param handler - error handler to register
|
|
3226
|
+
* Internals of the data loader.
|
|
3227
|
+
* @internal
|
|
1926
3228
|
*/
|
|
1927
|
-
|
|
3229
|
+
_: UseDataLoaderInternals<Exclude<Data, NavigationResult | undefined>, TError>;
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Internal properties of a data loader composable. Used by the internal implementation of `defineLoader()`. **Should
|
|
3233
|
+
* not be used in application code.**
|
|
3234
|
+
*/
|
|
3235
|
+
interface UseDataLoaderInternals<Data = unknown, TError = unknown> {
|
|
1928
3236
|
/**
|
|
1929
|
-
*
|
|
1930
|
-
* navigation, which means it has resolved all async enter hooks and async
|
|
1931
|
-
* components that are associated with the initial route. If the initial
|
|
1932
|
-
* navigation already happened, the promise resolves immediately.
|
|
3237
|
+
* Loads the data from the cache if possible, otherwise loads it from the loader and awaits it.
|
|
1933
3238
|
*
|
|
1934
|
-
*
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1937
|
-
*
|
|
3239
|
+
* @param to - route location to load the data for
|
|
3240
|
+
* @param router - router instance
|
|
3241
|
+
* @param from - route location we are coming from
|
|
3242
|
+
* @param parent - parent data loader entry
|
|
1938
3243
|
*/
|
|
1939
|
-
|
|
3244
|
+
load: (to: RouteLocationNormalizedLoaded, router: Router, from?: RouteLocationNormalizedLoaded, parent?: DataLoaderEntryBase) => Promise<void>;
|
|
1940
3245
|
/**
|
|
1941
|
-
*
|
|
1942
|
-
|
|
3246
|
+
* Resolved options for the loader.
|
|
3247
|
+
*/
|
|
3248
|
+
options: DefineDataLoaderOptionsBase_LaxData;
|
|
3249
|
+
/**
|
|
3250
|
+
* Gets the entry associated with the router instance. Assumes the data loader has been loaded and that the entry
|
|
3251
|
+
* exists.
|
|
1943
3252
|
*
|
|
1944
|
-
* @
|
|
1945
|
-
* @param app - Application that uses the router
|
|
3253
|
+
* @param router - router instance
|
|
1946
3254
|
*/
|
|
1947
|
-
|
|
3255
|
+
getEntry(router: Router): DataLoaderEntryBase<Data, TError>;
|
|
1948
3256
|
}
|
|
1949
|
-
|
|
3257
|
+
/**
|
|
3258
|
+
* Return value of a loader composable defined with `defineLoader()`.
|
|
3259
|
+
*/
|
|
3260
|
+
interface UseDataLoaderResult<TData = unknown, TError = ErrorDefault> {
|
|
1950
3261
|
/**
|
|
1951
|
-
*
|
|
3262
|
+
* Data returned by the loader. If the data loader is lazy, it will be undefined until the first load.
|
|
1952
3263
|
*/
|
|
1953
|
-
|
|
3264
|
+
data: ShallowRef<TData>;
|
|
1954
3265
|
/**
|
|
1955
|
-
*
|
|
1956
|
-
|
|
1957
|
-
|
|
3266
|
+
* Whether there is an ongoing request.
|
|
3267
|
+
*/
|
|
3268
|
+
isLoading: ShallowRef<boolean>;
|
|
3269
|
+
/**
|
|
3270
|
+
* Error if there was an error.
|
|
3271
|
+
*/
|
|
3272
|
+
error: ShallowRef<TError | null>;
|
|
3273
|
+
/**
|
|
3274
|
+
* Reload the data using the current route location. Returns a promise that resolves when the data is reloaded. This
|
|
3275
|
+
* method should not be called during a navigation as it can conflict with an ongoing load and lead to
|
|
3276
|
+
* inconsistencies.
|
|
3277
|
+
*/
|
|
3278
|
+
reload(): Promise<void>;
|
|
3279
|
+
/**
|
|
3280
|
+
* Reload the data using the route location passed as argument. Returns a promise that resolves when the data is reloaded.
|
|
1958
3281
|
*
|
|
1959
|
-
* @
|
|
3282
|
+
* @param route - route location to load the data for
|
|
1960
3283
|
*/
|
|
1961
|
-
|
|
3284
|
+
reload(route: RouteLocationNormalizedLoaded): Promise<void>;
|
|
1962
3285
|
}
|
|
1963
3286
|
/**
|
|
1964
|
-
*
|
|
1965
|
-
* routes array. This router does not have `addRoute()` and `removeRoute()`
|
|
1966
|
-
* methods and is meant to be used with unplugin-vue-router by generating the
|
|
1967
|
-
* resolver from the `pages/` folder
|
|
1968
|
-
*
|
|
1969
|
-
* @param options - Options to initialize the router
|
|
3287
|
+
* Loader function that can be passed to `defineLoader()`.
|
|
1970
3288
|
*/
|
|
1971
|
-
|
|
3289
|
+
interface DefineLoaderFn<Data, Context extends DataLoaderContextBase = DataLoaderContextBase, Route = RouteLocationNormalizedLoaded> {
|
|
3290
|
+
(route: Route, context: Context): Promise<Data>;
|
|
3291
|
+
}
|
|
1972
3292
|
//#endregion
|
|
1973
|
-
export {
|
|
3293
|
+
export { RouteLocationAsPath as $, defineParamParserRaw as $n, RouteQueryAndHash as $t, useLink as A, MatchMiss as An, LocationQueryValue$1 as Ar, ParamValue as At, RouterClassic as B, EXPERIMENTAL_RouterOptions as Bn, LocationAsRelativeRaw as Bt, RouterView as C, ParamParserTypeOf as Cn, createRouterMatcher as Cr, RouteLocationResolvedTypedList as Ct, UseLinkOptions as D, PathParamNamesForFilePath as Dn, RouteRecordNormalized as Dr, RouteRecordNameGeneric as Dt, RouterLinkProps as E, ParamParsers_Native as En, RouteRecord as Er, RouteRecordName as Et, routeLocationKey as F, EXPERIMENTAL_RouteRecordRaw as Fn, RouteParamsRaw as Ft, createWebHashHistory as G, createFixedResolver as Gn, RouteLocationNamedRaw as Gt, createRouter as H, EXPERIMENTAL_Router_Base as Hn, MatcherLocationAsPath as Ht, routerKey as I, EXPERIMENTAL_RouteRecord_Base as In, RouteMap as It, NavigationGuardNextCallback as J, ExtractParamParserType as Jn, RouteMeta as Jt, NavigationGuard as K, MatcherPatternQuery as Kn, RouteLocationOptions as Kt, routerViewLocationKey as L, EXPERIMENTAL_RouteRecord_Group as Ln, RouteMapGeneric as Lt, onBeforeRouteLeave as M, EXPERIMENTAL_RouteRecordNormalized as Mn, parseQuery as Mr, ParamValueZeroOrMore as Mt, onBeforeRouteUpdate as N, EXPERIMENTAL_RouteRecordNormalized_Group as Nn, stringifyQuery as Nr, ParamValueZeroOrOne as Nt, UseLinkReturn as O, _mergeRouteRecord as On, LocationQuery$1 as Or, RouteRecordRedirectOption as Ot, matchedRouteKey as P, EXPERIMENTAL_RouteRecordNormalized_Matchable as Pn, TypesConfig as Pr, RouteParams as Pt, RouteLocation as Q, defineParamParser as Qn, RouteParamsRawGeneric as Qt, viewDepthKey as R, EXPERIMENTAL_RouteRecord_Matchable as Rn, RouteRecordInfo as Rt, useRouter as S, ParamParserType as Sn, RouterMatcher as Sr, RouteLocationResolvedTyped as St, RouterLink as T, ParamParsers as Tn, _PathParserOptions as Tr, RouteLocationTypedList as Tt, createMemoryHistory as U, experimental_createRouter as Un, RouteComponent as Ut, RouterOptions as V, EXPERIMENTAL_RouterOptions_Base as Vn, MatcherLocation as Vt, createWebHistory as W, normalizeRouteRecord as Wn, RouteLocationMatched as Wt, NavigationGuardWithThis as X, PARAM_PARSER_INT as Xn, RouteParamValueRaw as Xt, NavigationGuardReturn as Y, normalizeParamParser as Yn, RouteParamValue as Yt, NavigationHookAfter as Z, PARAM_PARSER_BOOL as Zn, RouteParamsGeneric as Zt, getCurrentContext as _, defineBasicLoader as _n, NavigationFailureType as _r, RouteLocationNormalizedTyped as _t, DefineLoaderFn as a, RouteRecordSingleViewWithChildren as an, MatcherPatternPath as ar, RouteLocationAsRelativeTyped as at, withLoaderContext as b, DefinePageQueryParamOptions as bn, HistoryState as br, RouteLocationResolved as bt, UseDataLoaderResult as c, NavigationResult$1 as cn, MatcherPatternPathStatic as cr, RouteLocationAsStringTyped as ct, DataLoaderPluginOptions as d, DefineDataLoaderOptions as dn, _Awaitable as dr, RouteLocationNormalized as dt, RouteRecordMultipleViews as en, START_LOCATION_NORMALIZED as er, RouteLocationAsPathGeneric as et, NavigationResult as f, DefineDataLoaderOptions_DefinedData as fn, ParamParser as fr, RouteLocationNormalizedGeneric as ft, _PromiseMerged as g, UseDataLoaderBasic_LaxData as gn, NavigationFailure as gr, RouteLocationNormalizedLoadedTypedList as gt, useIsDataLoading as h, UseDataLoaderBasic_DefinedData as hn, ErrorTypes as hr, RouteLocationNormalizedLoadedTyped as ht, DefineDataLoaderOptionsBase_LaxData as i, RouteRecordSingleView as in, MatcherPatternHash as ir, RouteLocationAsRelativeGeneric as it, loadRouteLocation as j, miss as jn, LocationQueryValueRaw$1 as jr, ParamValueOneOrMore as jt, _RouterLinkI as k, definePage as kn, LocationQueryRaw$1 as kr, _RouteRecordProps as kt, toLazyValue as l, DataLoaderBasicEntry as ln, MatcherQueryParams as lr, RouteLocationAsStringTypedList as lt, reroute as m, UseDataLoaderBasic as mn, LocationQuery as mr, RouteLocationNormalizedLoadedGeneric as mt, DataLoaderEntryBase as n, RouteRecordRaw as nn, MatcherParamsFormatted as nr, RouteLocationAsPathTypedList as nt, UseDataLoader as o, _RouteLocationBase as on, MatcherPatternPathDynamic as or, RouteLocationAsRelativeTypedList as ot, SetupLoaderGuardOptions as p, DefineDataLoaderOptions_LaxData as pn, RouterScrollBehavior as pr, RouteLocationNormalizedLoaded as pt, NavigationGuardNext as q, MatcherPatternQueryParam as qn, RouteLocationPathRaw as qt, DefineDataLoaderOptionsBase_DefinedData as r, RouteRecordRedirect as rn, MatcherPattern as rr, RouteLocationAsRelative as rt, UseDataLoaderInternals as s, _RouteRecordBase as sn, MatcherPatternPathDynamic_ParamOptions as sr, RouteLocationAsString as st, DataLoaderContextBase as t, RouteRecordMultipleViewsWithChildren as tn, EmptyParams as tr, RouteLocationAsPathTyped as tt, DataLoaderPlugin as u, DataLoaderContext as un, MatcherQueryParamsValue as ur, RouteLocationGeneric as ut, setCurrentContext as v, ErrorDefault as vn, NavigationRedirectError as vr, RouteLocationNormalizedTypedList as vt, RouterViewProps as w, ParamParserType_Native as wn, PathParserOptions as wr, RouteLocationTyped as wt, useRoute as x, DefinePageQueryParamOptionsAny as xn, RouterHistory as xr, RouteLocationResolvedGeneric as xt, trackRoute as y, DefinePage as yn, isNavigationFailure as yr, RouteLocationRaw as yt, Router as z, EXPERIMENTAL_Router as zn, RouteRecordInfoGeneric as zt };
|