@histoire/vendors 0.8.4 → 0.9.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.d.ts +3 -0
- package/dist/client/{floating-vue.js → b-floating-vue.js} +1 -1
- package/dist/client/b-iconify.d.ts +1 -0
- package/dist/client/{iconify.js → b-iconify.js} +0 -0
- package/dist/client/b-pinia.d.ts +1 -0
- package/dist/client/{pinia.js → b-pinia.js} +41 -8
- package/dist/client/b-scroll.d.ts +2 -0
- package/dist/client/{scroll.js → b-scroll.js} +1 -1
- package/dist/client/b-vue-router.d.ts +1 -0
- package/dist/client/{vue-router.js → b-vue-router.js} +279 -158
- package/dist/client/b-vue-use.d.ts +1 -0
- package/dist/client/{vue-use.js → b-vue-use.js} +1070 -603
- package/dist/client/b-vue.d.ts +1 -0
- package/dist/client/{vue.js → b-vue.js} +1 -1
- package/dist/client/node_modules/@babel/parser/package.json +45 -0
- package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +214 -0
- package/dist/client/node_modules/@floating-ui/core/index.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/core/package.json +70 -0
- package/dist/client/node_modules/@floating-ui/core/src/_babel.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/core/src/computeCoordsFromPlacement.d.ts +4 -0
- package/dist/client/node_modules/@floating-ui/core/src/computePosition.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/detectOverflow.d.ts +9 -0
- package/dist/client/node_modules/@floating-ui/core/src/enums.d.ts +4 -0
- package/dist/client/node_modules/@floating-ui/core/src/index.d.ts +11 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/arrow.d.ts +6 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/autoPlacement.d.ts +9 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/flip.d.ts +10 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/hide.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/inline.d.ts +5 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/offset.d.ts +21 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/shift.d.ts +32 -0
- package/dist/client/node_modules/@floating-ui/core/src/middleware/size.d.ts +6 -0
- package/dist/client/node_modules/@floating-ui/core/src/types.d.ts +148 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/expandPaddingObject.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignment.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignmentSides.d.ts +5 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getBasePlacement.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getCrossAxis.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getExpandedPlacements.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getLengthFromAxis.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getMainAxisFromPlacement.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositeAlignmentPlacement.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositePlacement.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/getPaddingObject.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/math.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/rectToClientRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/core/src/utils/within.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/index.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/package.json +75 -0
- package/dist/client/node_modules/@floating-ui/dom/src/index.d.ts +7 -0
- package/dist/client/node_modules/@floating-ui/dom/src/platform.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/types.d.ts +27 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/contains.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/convertOffsetParentRelativeRectToViewportRelativeRect.d.ts +6 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getBoundingClientRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingClientRect.d.ts +6 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getComputedStyle.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDimensions.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDocumentElement.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDocumentRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNodeName.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNodeScroll.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getOffsetParent.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getParentNode.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getRectRelativeToOffsetParent.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParent.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParents.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getViewportRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getWindowScrollBarX.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/is.d.ts +15 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/math.d.ts +3 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/window.d.ts +2 -0
- package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +680 -0
- package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +347 -0
- package/dist/client/node_modules/@iconify/vue/offline/package.json +14 -0
- package/dist/client/node_modules/@iconify/vue/package.json +61 -0
- package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +176 -0
- package/dist/client/node_modules/@types/web-bluetooth/package.json +40 -0
- package/dist/client/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +1198 -0
- package/dist/client/node_modules/@vue/compiler-core/package.json +43 -0
- package/dist/client/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +66 -0
- package/dist/client/node_modules/@vue/compiler-dom/package.json +43 -0
- package/dist/client/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +321 -0
- package/dist/client/node_modules/@vue/compiler-sfc/package.json +59 -0
- package/dist/client/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +6 -0
- package/dist/client/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts +108 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts +1 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts +77 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts +5 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts +179 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts +6 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts +4 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/const.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/env.d.ts +15 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/index.d.ts +18 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts +47 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts +20 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/time.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-api/package.json +37 -0
- package/dist/client/node_modules/@vue/reactivity/dist/reactivity.d.ts +347 -0
- package/dist/client/node_modules/@vue/reactivity/package.json +41 -0
- package/dist/client/node_modules/@vue/reactivity-transform/dist/reactivity-transform.d.ts +33 -0
- package/dist/client/node_modules/@vue/reactivity-transform/package.json +41 -0
- package/dist/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +2018 -0
- package/dist/client/node_modules/@vue/runtime-core/package.json +38 -0
- package/dist/client/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +1522 -0
- package/dist/client/node_modules/@vue/runtime-dom/package.json +42 -0
- package/dist/client/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +100 -0
- package/dist/client/node_modules/@vue/server-renderer/package.json +41 -0
- package/dist/client/node_modules/@vue/shared/dist/shared.d.ts +356 -0
- package/dist/client/node_modules/@vue/shared/package.json +33 -0
- package/dist/client/node_modules/@vueuse/core/index.d.ts +4305 -0
- package/dist/client/node_modules/@vueuse/core/metadata.d.ts +1 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/@vueuse/shared/index.d.ts +874 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/@vueuse/shared/package.json +50 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/lib/index.d.ts +22 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/lib/v2/index.d.ts +31 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/lib/v2.7/index.d.ts +52 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/lib/v3/index.d.ts +22 -0
- package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/package.json +47 -0
- package/dist/client/node_modules/@vueuse/core/package.json +59 -0
- package/dist/client/node_modules/@vueuse/metadata/index.d.ts +75 -0
- package/dist/client/node_modules/@vueuse/metadata/package.json +39 -0
- package/dist/client/node_modules/compute-scroll-into-view/package.json +90 -0
- package/dist/client/node_modules/compute-scroll-into-view/typings/index.d.ts +19 -0
- package/dist/client/node_modules/csstype/index.d.ts +38372 -0
- package/dist/client/node_modules/csstype/package.json +57 -0
- package/dist/client/node_modules/estree-walker/dist/esm/package.json +1 -0
- package/dist/client/node_modules/estree-walker/package.json +37 -0
- package/dist/client/node_modules/estree-walker/src/package.json +1 -0
- package/dist/client/node_modules/estree-walker/types/async.d.ts +53 -0
- package/dist/client/node_modules/estree-walker/types/index.d.ts +56 -0
- package/dist/client/node_modules/estree-walker/types/sync.d.ts +53 -0
- package/dist/client/node_modules/estree-walker/types/walker.d.ts +37 -0
- package/dist/client/node_modules/floating-vue/dist/components/Dropdown.vue.d.ts +25 -0
- package/dist/client/node_modules/floating-vue/dist/components/Menu.vue.d.ts +25 -0
- package/dist/client/node_modules/floating-vue/dist/components/Popper.d.ts +374 -0
- package/dist/client/node_modules/floating-vue/dist/components/Popper.vue.d.ts +366 -0
- package/dist/client/node_modules/floating-vue/dist/components/PopperContent.vue.d.ts +48 -0
- package/dist/client/node_modules/floating-vue/dist/components/PopperMethods.d.ts +9 -0
- package/dist/client/node_modules/floating-vue/dist/components/PopperWrapper.vue.d.ts +28 -0
- package/dist/client/node_modules/floating-vue/dist/components/ThemeClass.d.ts +6 -0
- package/dist/client/node_modules/floating-vue/dist/components/Tooltip.vue.d.ts +25 -0
- package/dist/client/node_modules/floating-vue/dist/components/TooltipDirective.vue.d.ts +28 -0
- package/dist/client/node_modules/floating-vue/dist/config.d.ts +11 -0
- package/dist/client/node_modules/floating-vue/dist/directives/v-close-popper.d.ts +13 -0
- package/dist/client/node_modules/floating-vue/dist/directives/v-tooltip.d.ts +27 -0
- package/dist/client/node_modules/floating-vue/dist/directives/v-tooltip.spec.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/index.d.ts +414 -0
- package/dist/client/node_modules/floating-vue/dist/util/assign-deep.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/util/env.d.ts +2 -0
- package/dist/client/node_modules/floating-vue/dist/util/events.d.ts +12 -0
- package/dist/client/node_modules/floating-vue/dist/util/frame.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/util/lang.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/util/popper.d.ts +3 -0
- package/dist/client/node_modules/floating-vue/package.json +71 -0
- package/dist/client/node_modules/floating-vue/src/global-shim.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/src/vue-shim.d.ts +5 -0
- package/dist/client/node_modules/magic-string/index.d.ts +221 -0
- package/dist/client/node_modules/magic-string/package.json +52 -0
- package/dist/client/node_modules/nanoid/async/index.d.ts +56 -0
- package/dist/client/node_modules/nanoid/async/package.json +12 -0
- package/dist/client/node_modules/nanoid/index.d.ts +91 -0
- package/dist/client/node_modules/nanoid/non-secure/index.d.ts +33 -0
- package/dist/client/node_modules/nanoid/non-secure/package.json +6 -0
- package/dist/client/node_modules/nanoid/package.json +60 -0
- package/dist/client/node_modules/nanoid/url-alphabet/package.json +6 -0
- package/dist/client/node_modules/picocolors/package.json +25 -0
- package/dist/client/node_modules/picocolors/picocolors.d.ts +5 -0
- package/dist/client/node_modules/pinia/dist/pinia.d.ts +963 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +22 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +31 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +52 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +22 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/package.json +47 -0
- package/dist/client/node_modules/pinia/package.json +101 -0
- package/dist/client/node_modules/postcss/lib/at-rule.d.ts +106 -0
- package/dist/client/node_modules/postcss/lib/comment.d.ts +56 -0
- package/dist/client/node_modules/postcss/lib/container.d.ts +442 -0
- package/dist/client/node_modules/postcss/lib/css-syntax-error.d.ts +239 -0
- package/dist/client/node_modules/postcss/lib/declaration.d.ts +124 -0
- package/dist/client/node_modules/postcss/lib/document.d.ts +57 -0
- package/dist/client/node_modules/postcss/lib/fromJSON.d.ts +5 -0
- package/dist/client/node_modules/postcss/lib/input.d.ts +150 -0
- package/dist/client/node_modules/postcss/lib/lazy-result.d.ts +176 -0
- package/dist/client/node_modules/postcss/lib/list.d.ts +51 -0
- package/dist/client/node_modules/postcss/lib/no-work-result.d.ts +37 -0
- package/dist/client/node_modules/postcss/lib/node.d.ts +478 -0
- package/dist/client/node_modules/postcss/lib/parse.d.ts +5 -0
- package/dist/client/node_modules/postcss/lib/postcss.d.ts +473 -0
- package/dist/client/node_modules/postcss/lib/previous-map.d.ts +72 -0
- package/dist/client/node_modules/postcss/lib/processor.d.ts +102 -0
- package/dist/client/node_modules/postcss/lib/result.d.ts +196 -0
- package/dist/client/node_modules/postcss/lib/root.d.ts +73 -0
- package/dist/client/node_modules/postcss/lib/rule.d.ts +104 -0
- package/dist/client/node_modules/postcss/lib/stringifier.d.ts +37 -0
- package/dist/client/node_modules/postcss/lib/stringify.d.ts +5 -0
- package/dist/client/node_modules/postcss/lib/warning.d.ts +138 -0
- package/dist/client/node_modules/postcss/package.json +85 -0
- package/dist/client/node_modules/scroll-into-view-if-needed/package.json +144 -0
- package/dist/client/node_modules/scroll-into-view-if-needed/typings/index.d.ts +13 -0
- package/dist/client/node_modules/scroll-into-view-if-needed/typings/types.d.ts +19 -0
- package/dist/client/node_modules/source-map/package.json +73 -0
- package/dist/client/node_modules/source-map/source-map.d.ts +98 -0
- package/dist/client/node_modules/source-map-js/package.json +71 -0
- package/dist/client/node_modules/source-map-js/source-map.d.ts +115 -0
- package/dist/client/node_modules/sourcemap-codec/dist/types/sourcemap-codec.d.ts +5 -0
- package/dist/client/node_modules/sourcemap-codec/package.json +53 -0
- package/dist/client/node_modules/vue/compiler-sfc/index.d.ts +1 -0
- package/dist/client/node_modules/vue/compiler-sfc/package.json +5 -0
- package/dist/client/node_modules/vue/dist/vue.d.ts +9 -0
- package/dist/client/node_modules/vue/macros-global.d.ts +19 -0
- package/dist/client/node_modules/vue/macros.d.ts +110 -0
- package/dist/client/node_modules/vue/package.json +75 -0
- package/dist/client/node_modules/vue/ref-macros.d.ts +2 -0
- package/dist/client/node_modules/vue/server-renderer/index.d.ts +1 -0
- package/dist/client/node_modules/vue/server-renderer/package.json +5 -0
- package/dist/client/node_modules/vue-resize/package.json +77 -0
- package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +1491 -0
- package/dist/client/node_modules/vue-router/package.json +114 -0
- package/dist/client/vue.runtime.esm-bundler.js +24 -19
- package/entries.js +7 -7
- package/floating-vue.d.ts +3 -0
- package/iconify.d.ts +3 -0
- package/package.json +13 -4
- package/pinia.d.ts +3 -0
- package/rollup.config.mjs +116 -0
- package/scroll.d.ts +3 -0
- package/src/client/b-floating-vue.ts +3 -0
- package/src/client/b-iconify.ts +1 -0
- package/src/client/b-pinia.ts +1 -0
- package/src/client/b-scroll.ts +2 -0
- package/src/client/b-vue-router.ts +1 -0
- package/src/client/b-vue-use.ts +1 -0
- package/src/client/b-vue.ts +1 -0
- package/vue-router.d.ts +3 -0
- package/vue-use.d.ts +3 -0
- package/vue.d.ts +3 -0
- package/dist/client/floating-vue.d.ts +0 -2
- package/dist/client/iconify.d.ts +0 -1
- package/dist/client/pinia.d.ts +0 -1
- package/dist/client/scroll.d.ts +0 -1
- package/dist/client/vue-router.d.ts +0 -1
- package/dist/client/vue-use.d.ts +0 -1
- package/dist/client/vue.d.ts +0 -1
- package/rollup.config.js +0 -37
- package/src/client/floating-vue.ts +0 -2
- package/src/client/iconify.ts +0 -1
- package/src/client/pinia.ts +0 -1
- package/src/client/scroll.ts +0 -1
- package/src/client/vue-router.ts +0 -1
- package/src/client/vue-use.ts +0 -1
- package/src/client/vue.ts +0 -1
|
@@ -1,71 +1,34 @@
|
|
|
1
|
-
import { I as onUnmounted, N as onDeactivated, O as onActivated, y as getCurrentInstance, z as inject, K as computed,
|
|
1
|
+
import { I as onUnmounted, N as onDeactivated, O as onActivated, y as getCurrentInstance, z as inject, K as computed, C as unref, P as watchEffect, d as defineComponent, L as reactive, x as h, Q as provide, u as ref, B as watch, R as shallowRef, a as nextTick } from './vue.runtime.esm-bundler.js';
|
|
2
2
|
import { s as setupDevtoolsPlugin } from './index2.js';
|
|
3
3
|
|
|
4
4
|
/*!
|
|
5
|
-
* vue-router v4.
|
|
5
|
+
* vue-router v4.1.3
|
|
6
6
|
* (c) 2022 Eduardo San Martin Morote
|
|
7
7
|
* @license MIT
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const hasSymbol = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
11
|
-
const PolySymbol = (name) =>
|
|
12
|
-
// vr = vue router
|
|
13
|
-
hasSymbol
|
|
14
|
-
? Symbol((process.env.NODE_ENV !== 'production') ? '[vue-router]: ' + name : name)
|
|
15
|
-
: ((process.env.NODE_ENV !== 'production') ? '[vue-router]: ' : '_vr_') + name;
|
|
16
|
-
// rvlm = Router View Location Matched
|
|
17
|
-
/**
|
|
18
|
-
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
|
19
|
-
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
|
20
|
-
* Location Matched
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
const matchedRouteKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'router view location matched' : 'rvlm');
|
|
25
|
-
/**
|
|
26
|
-
* Allows overriding the router view depth to control which component in
|
|
27
|
-
* `matched` is rendered. rvd stands for Router View Depth
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
const viewDepthKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'router view depth' : 'rvd');
|
|
32
|
-
/**
|
|
33
|
-
* Allows overriding the router instance returned by `useRouter` in tests. r
|
|
34
|
-
* stands for router
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
const routerKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'router' : 'r');
|
|
39
|
-
/**
|
|
40
|
-
* Allows overriding the current route returned by `useRoute` in tests. rl
|
|
41
|
-
* stands for route location
|
|
42
|
-
*
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
const routeLocationKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'route location' : 'rl');
|
|
46
|
-
/**
|
|
47
|
-
* Allows overriding the current route used by router-view. Internally this is
|
|
48
|
-
* used when the `route` prop is passed.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
const routerViewLocationKey = /*#__PURE__*/ PolySymbol((process.env.NODE_ENV !== 'production') ? 'router view location' : 'rvl');
|
|
53
|
-
|
|
54
10
|
const isBrowser = typeof window !== 'undefined';
|
|
55
11
|
|
|
56
12
|
function isESModule(obj) {
|
|
57
|
-
return obj.__esModule ||
|
|
13
|
+
return obj.__esModule || obj[Symbol.toStringTag] === 'Module';
|
|
58
14
|
}
|
|
59
15
|
const assign = Object.assign;
|
|
60
16
|
function applyToParams(fn, params) {
|
|
61
17
|
const newParams = {};
|
|
62
18
|
for (const key in params) {
|
|
63
19
|
const value = params[key];
|
|
64
|
-
newParams[key] =
|
|
20
|
+
newParams[key] = isArray(value)
|
|
21
|
+
? value.map(fn)
|
|
22
|
+
: fn(value);
|
|
65
23
|
}
|
|
66
24
|
return newParams;
|
|
67
25
|
}
|
|
68
|
-
const noop = () => { };
|
|
26
|
+
const noop = () => { };
|
|
27
|
+
/**
|
|
28
|
+
* Typesafe alternative to Array.isArray
|
|
29
|
+
* https://github.com/microsoft/TypeScript/pull/48228
|
|
30
|
+
*/
|
|
31
|
+
const isArray = Array.isArray;
|
|
69
32
|
|
|
70
33
|
function warn(msg) {
|
|
71
34
|
// avoid using ...args as it breaks in older Edge builds
|
|
@@ -87,8 +50,13 @@ const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, '');
|
|
|
87
50
|
function parseURL(parseQuery, location, currentLocation = '/') {
|
|
88
51
|
let path, query = {}, searchString = '', hash = '';
|
|
89
52
|
// Could use URL and URLSearchParams but IE 11 doesn't support it
|
|
90
|
-
|
|
91
|
-
const hashPos = location.indexOf('#'
|
|
53
|
+
// TODO: move to new URL()
|
|
54
|
+
const hashPos = location.indexOf('#');
|
|
55
|
+
let searchPos = location.indexOf('?');
|
|
56
|
+
// the hash appears before the search, so it's not part of the search string
|
|
57
|
+
if (hashPos < searchPos && hashPos >= 0) {
|
|
58
|
+
searchPos = -1;
|
|
59
|
+
}
|
|
92
60
|
if (searchPos > -1) {
|
|
93
61
|
path = location.slice(0, searchPos);
|
|
94
62
|
searchString = location.slice(searchPos + 1, hashPos > -1 ? hashPos : location.length);
|
|
@@ -173,9 +141,9 @@ function isSameRouteLocationParams(a, b) {
|
|
|
173
141
|
return true;
|
|
174
142
|
}
|
|
175
143
|
function isSameRouteLocationParamsValue(a, b) {
|
|
176
|
-
return
|
|
144
|
+
return isArray(a)
|
|
177
145
|
? isEquivalentArray(a, b)
|
|
178
|
-
:
|
|
146
|
+
: isArray(b)
|
|
179
147
|
? isEquivalentArray(b, a)
|
|
180
148
|
: a === b;
|
|
181
149
|
}
|
|
@@ -187,7 +155,7 @@ function isSameRouteLocationParamsValue(a, b) {
|
|
|
187
155
|
* @param b - array of values or a single value
|
|
188
156
|
*/
|
|
189
157
|
function isEquivalentArray(a, b) {
|
|
190
|
-
return
|
|
158
|
+
return isArray(b)
|
|
191
159
|
? a.length === b.length && a.every((value, i) => value === b[i])
|
|
192
160
|
: a.length === 1 && a[0] === b;
|
|
193
161
|
}
|
|
@@ -213,18 +181,24 @@ function resolveRelativePath(to, from) {
|
|
|
213
181
|
let segment;
|
|
214
182
|
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
|
|
215
183
|
segment = toSegments[toPosition];
|
|
216
|
-
//
|
|
217
|
-
if (
|
|
184
|
+
// we stay on the same position
|
|
185
|
+
if (segment === '.')
|
|
218
186
|
continue;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
187
|
+
// go up in the from array
|
|
188
|
+
if (segment === '..') {
|
|
189
|
+
// we can't go below zero but we still need to increment toPosition
|
|
190
|
+
if (position > 1)
|
|
191
|
+
position--;
|
|
192
|
+
// continue
|
|
193
|
+
}
|
|
194
|
+
// we reached a non relative path, we stop here
|
|
222
195
|
else
|
|
223
196
|
break;
|
|
224
197
|
}
|
|
225
198
|
return (fromSegments.slice(0, position).join('/') +
|
|
226
199
|
'/' +
|
|
227
200
|
toSegments
|
|
201
|
+
// ensure we use at least the last element in the toSegments
|
|
228
202
|
.slice(toPosition - (toPosition === toSegments.length ? 1 : 0))
|
|
229
203
|
.join('/'));
|
|
230
204
|
}
|
|
@@ -706,15 +680,13 @@ function createMemoryHistory(base = '') {
|
|
|
706
680
|
}
|
|
707
681
|
|
|
708
682
|
/**
|
|
709
|
-
* Creates a hash history. Useful for web applications with no host (e.g.
|
|
710
|
-
*
|
|
683
|
+
* Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
|
|
684
|
+
* handle any URL is not possible.
|
|
711
685
|
*
|
|
712
|
-
* @param base - optional base to provide. Defaults to `location.pathname +
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* `href` value **has to match this parameter** (ignoring anything after the
|
|
717
|
-
* `#`).
|
|
686
|
+
* @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
|
|
687
|
+
* in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
|
|
688
|
+
* calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
|
|
689
|
+
* after the `#`).
|
|
718
690
|
*
|
|
719
691
|
* @example
|
|
720
692
|
* ```js
|
|
@@ -779,7 +751,7 @@ const START_LOCATION_NORMALIZED = {
|
|
|
779
751
|
redirectedFrom: undefined,
|
|
780
752
|
};
|
|
781
753
|
|
|
782
|
-
const NavigationFailureSymbol =
|
|
754
|
+
const NavigationFailureSymbol = Symbol((process.env.NODE_ENV !== 'production') ? 'navigation failure' : '');
|
|
783
755
|
/**
|
|
784
756
|
* Enumeration with all possible types for navigation failures. Can be passed to
|
|
785
757
|
* {@link isNavigationFailure} to check for specific failures.
|
|
@@ -804,21 +776,21 @@ var NavigationFailureType;
|
|
|
804
776
|
})(NavigationFailureType || (NavigationFailureType = {}));
|
|
805
777
|
// DEV only debug messages
|
|
806
778
|
const ErrorTypeMessages = {
|
|
807
|
-
[1 /* MATCHER_NOT_FOUND */]({ location, currentLocation }) {
|
|
779
|
+
[1 /* ErrorTypes.MATCHER_NOT_FOUND */]({ location, currentLocation }) {
|
|
808
780
|
return `No match for\n ${JSON.stringify(location)}${currentLocation
|
|
809
781
|
? '\nwhile being at\n' + JSON.stringify(currentLocation)
|
|
810
782
|
: ''}`;
|
|
811
783
|
},
|
|
812
|
-
[2 /* NAVIGATION_GUARD_REDIRECT */]({ from, to, }) {
|
|
784
|
+
[2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */]({ from, to, }) {
|
|
813
785
|
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
|
|
814
786
|
},
|
|
815
|
-
[4 /* NAVIGATION_ABORTED */]({ from, to }) {
|
|
787
|
+
[4 /* ErrorTypes.NAVIGATION_ABORTED */]({ from, to }) {
|
|
816
788
|
return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
|
|
817
789
|
},
|
|
818
|
-
[8 /* NAVIGATION_CANCELLED */]({ from, to }) {
|
|
790
|
+
[8 /* ErrorTypes.NAVIGATION_CANCELLED */]({ from, to }) {
|
|
819
791
|
return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
|
|
820
792
|
},
|
|
821
|
-
[16 /* NAVIGATION_DUPLICATED */]({ from, to }) {
|
|
793
|
+
[16 /* ErrorTypes.NAVIGATION_DUPLICATED */]({ from, to }) {
|
|
822
794
|
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
|
|
823
795
|
},
|
|
824
796
|
};
|
|
@@ -883,23 +855,23 @@ function tokensToParser(segments, extraOptions) {
|
|
|
883
855
|
const keys = [];
|
|
884
856
|
for (const segment of segments) {
|
|
885
857
|
// the root segment needs special treatment
|
|
886
|
-
const segmentScores = segment.length ? [] : [90 /* Root */];
|
|
858
|
+
const segmentScores = segment.length ? [] : [90 /* PathScore.Root */];
|
|
887
859
|
// allow trailing slash
|
|
888
860
|
if (options.strict && !segment.length)
|
|
889
861
|
pattern += '/';
|
|
890
862
|
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
|
|
891
863
|
const token = segment[tokenIndex];
|
|
892
864
|
// resets the score if we are inside a sub segment /:a-other-:b
|
|
893
|
-
let subSegmentScore = 40 /* Segment */ +
|
|
894
|
-
(options.sensitive ? 0.25 /* BonusCaseSensitive */ : 0);
|
|
895
|
-
if (token.type === 0 /* Static */) {
|
|
865
|
+
let subSegmentScore = 40 /* PathScore.Segment */ +
|
|
866
|
+
(options.sensitive ? 0.25 /* PathScore.BonusCaseSensitive */ : 0);
|
|
867
|
+
if (token.type === 0 /* TokenType.Static */) {
|
|
896
868
|
// prepend the slash if we are starting a new segment
|
|
897
869
|
if (!tokenIndex)
|
|
898
870
|
pattern += '/';
|
|
899
871
|
pattern += token.value.replace(REGEX_CHARS_RE, '\\$&');
|
|
900
|
-
subSegmentScore += 40 /* Static */;
|
|
872
|
+
subSegmentScore += 40 /* PathScore.Static */;
|
|
901
873
|
}
|
|
902
|
-
else if (token.type === 1 /* Param */) {
|
|
874
|
+
else if (token.type === 1 /* TokenType.Param */) {
|
|
903
875
|
const { value, repeatable, optional, regexp } = token;
|
|
904
876
|
keys.push({
|
|
905
877
|
name: value,
|
|
@@ -909,7 +881,7 @@ function tokensToParser(segments, extraOptions) {
|
|
|
909
881
|
const re = regexp ? regexp : BASE_PARAM_PATTERN;
|
|
910
882
|
// the user provided a custom regexp /:id(\\d+)
|
|
911
883
|
if (re !== BASE_PARAM_PATTERN) {
|
|
912
|
-
subSegmentScore += 10 /* BonusCustomRegExp */;
|
|
884
|
+
subSegmentScore += 10 /* PathScore.BonusCustomRegExp */;
|
|
913
885
|
// make sure the regexp is valid before using it
|
|
914
886
|
try {
|
|
915
887
|
new RegExp(`(${re})`);
|
|
@@ -932,13 +904,13 @@ function tokensToParser(segments, extraOptions) {
|
|
|
932
904
|
if (optional)
|
|
933
905
|
subPattern += '?';
|
|
934
906
|
pattern += subPattern;
|
|
935
|
-
subSegmentScore += 20 /* Dynamic */;
|
|
907
|
+
subSegmentScore += 20 /* PathScore.Dynamic */;
|
|
936
908
|
if (optional)
|
|
937
|
-
subSegmentScore += -8 /* BonusOptional */;
|
|
909
|
+
subSegmentScore += -8 /* PathScore.BonusOptional */;
|
|
938
910
|
if (repeatable)
|
|
939
|
-
subSegmentScore += -20 /* BonusRepeatable */;
|
|
911
|
+
subSegmentScore += -20 /* PathScore.BonusRepeatable */;
|
|
940
912
|
if (re === '.*')
|
|
941
|
-
subSegmentScore += -50 /* BonusWildcard */;
|
|
913
|
+
subSegmentScore += -50 /* PathScore.BonusWildcard */;
|
|
942
914
|
}
|
|
943
915
|
segmentScores.push(subSegmentScore);
|
|
944
916
|
}
|
|
@@ -949,7 +921,7 @@ function tokensToParser(segments, extraOptions) {
|
|
|
949
921
|
// only apply the strict bonus to the last score
|
|
950
922
|
if (options.strict && options.end) {
|
|
951
923
|
const i = score.length - 1;
|
|
952
|
-
score[i][score[i].length - 1] += 0.7000000000000001 /* BonusStrict */;
|
|
924
|
+
score[i][score[i].length - 1] += 0.7000000000000001 /* PathScore.BonusStrict */;
|
|
953
925
|
}
|
|
954
926
|
// TODO: dev only warn double trailing slash
|
|
955
927
|
if (!options.strict)
|
|
@@ -981,20 +953,22 @@ function tokensToParser(segments, extraOptions) {
|
|
|
981
953
|
path += '/';
|
|
982
954
|
avoidDuplicatedSlash = false;
|
|
983
955
|
for (const token of segment) {
|
|
984
|
-
if (token.type === 0 /* Static */) {
|
|
956
|
+
if (token.type === 0 /* TokenType.Static */) {
|
|
985
957
|
path += token.value;
|
|
986
958
|
}
|
|
987
|
-
else if (token.type === 1 /* Param */) {
|
|
959
|
+
else if (token.type === 1 /* TokenType.Param */) {
|
|
988
960
|
const { value, repeatable, optional } = token;
|
|
989
961
|
const param = value in params ? params[value] : '';
|
|
990
|
-
if (
|
|
962
|
+
if (isArray(param) && !repeatable) {
|
|
991
963
|
throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
|
|
992
|
-
|
|
964
|
+
}
|
|
965
|
+
const text = isArray(param)
|
|
966
|
+
? param.join('/')
|
|
967
|
+
: param;
|
|
993
968
|
if (!text) {
|
|
994
969
|
if (optional) {
|
|
995
|
-
// if we have more than one optional param like /:a?-static
|
|
996
|
-
|
|
997
|
-
if (segment.length < 2 && segments.length > 1) {
|
|
970
|
+
// if we have more than one optional param like /:a?-static we don't need to care about the optional param
|
|
971
|
+
if (segment.length < 2) {
|
|
998
972
|
// remove the last slash as we could be at the end
|
|
999
973
|
if (path.endsWith('/'))
|
|
1000
974
|
path = path.slice(0, -1);
|
|
@@ -1010,7 +984,8 @@ function tokensToParser(segments, extraOptions) {
|
|
|
1010
984
|
}
|
|
1011
985
|
}
|
|
1012
986
|
}
|
|
1013
|
-
|
|
987
|
+
// avoid empty path when we have multiple optional params
|
|
988
|
+
return path || '/';
|
|
1014
989
|
}
|
|
1015
990
|
return {
|
|
1016
991
|
re,
|
|
@@ -1041,12 +1016,12 @@ function compareScoreArray(a, b) {
|
|
|
1041
1016
|
// if the last subsegment was Static, the shorter segments should be sorted first
|
|
1042
1017
|
// otherwise sort the longest segment first
|
|
1043
1018
|
if (a.length < b.length) {
|
|
1044
|
-
return a.length === 1 && a[0] === 40 /* Static */ + 40 /* Segment */
|
|
1019
|
+
return a.length === 1 && a[0] === 40 /* PathScore.Static */ + 40 /* PathScore.Segment */
|
|
1045
1020
|
? -1
|
|
1046
1021
|
: 1;
|
|
1047
1022
|
}
|
|
1048
1023
|
else if (a.length > b.length) {
|
|
1049
|
-
return b.length === 1 && b[0] === 40 /* Static */ + 40 /* Segment */
|
|
1024
|
+
return b.length === 1 && b[0] === 40 /* PathScore.Static */ + 40 /* PathScore.Segment */
|
|
1050
1025
|
? 1
|
|
1051
1026
|
: -1;
|
|
1052
1027
|
}
|
|
@@ -1070,6 +1045,12 @@ function comparePathParserScore(a, b) {
|
|
|
1070
1045
|
return comp;
|
|
1071
1046
|
i++;
|
|
1072
1047
|
}
|
|
1048
|
+
if (Math.abs(bScore.length - aScore.length) === 1) {
|
|
1049
|
+
if (isLastScoreNegative(aScore))
|
|
1050
|
+
return 1;
|
|
1051
|
+
if (isLastScoreNegative(bScore))
|
|
1052
|
+
return -1;
|
|
1053
|
+
}
|
|
1073
1054
|
// if a and b share the same score entries but b has more, sort b first
|
|
1074
1055
|
return bScore.length - aScore.length;
|
|
1075
1056
|
// this is the ternary version
|
|
@@ -1078,10 +1059,20 @@ function comparePathParserScore(a, b) {
|
|
|
1078
1059
|
// : aScore.length > bScore.length
|
|
1079
1060
|
// ? -1
|
|
1080
1061
|
// : 0
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* This allows detecting splats at the end of a path: /home/:id(.*)*
|
|
1065
|
+
*
|
|
1066
|
+
* @param score - score to check
|
|
1067
|
+
* @returns true if the last entry is negative
|
|
1068
|
+
*/
|
|
1069
|
+
function isLastScoreNegative(score) {
|
|
1070
|
+
const last = score[score.length - 1];
|
|
1071
|
+
return score.length > 0 && last[last.length - 1] < 0;
|
|
1081
1072
|
}
|
|
1082
1073
|
|
|
1083
1074
|
const ROOT_TOKEN = {
|
|
1084
|
-
type: 0 /* Static */,
|
|
1075
|
+
type: 0 /* TokenType.Static */,
|
|
1085
1076
|
value: '',
|
|
1086
1077
|
};
|
|
1087
1078
|
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
|
|
@@ -1102,7 +1093,7 @@ function tokenizePath(path) {
|
|
|
1102
1093
|
function crash(message) {
|
|
1103
1094
|
throw new Error(`ERR (${state})/"${buffer}": ${message}`);
|
|
1104
1095
|
}
|
|
1105
|
-
let state = 0 /* Static */;
|
|
1096
|
+
let state = 0 /* TokenizerState.Static */;
|
|
1106
1097
|
let previousState = state;
|
|
1107
1098
|
const tokens = [];
|
|
1108
1099
|
// the segment will always be valid because we get into the initial state
|
|
@@ -1124,19 +1115,19 @@ function tokenizePath(path) {
|
|
|
1124
1115
|
function consumeBuffer() {
|
|
1125
1116
|
if (!buffer)
|
|
1126
1117
|
return;
|
|
1127
|
-
if (state === 0 /* Static */) {
|
|
1118
|
+
if (state === 0 /* TokenizerState.Static */) {
|
|
1128
1119
|
segment.push({
|
|
1129
|
-
type: 0 /* Static */,
|
|
1120
|
+
type: 0 /* TokenType.Static */,
|
|
1130
1121
|
value: buffer,
|
|
1131
1122
|
});
|
|
1132
1123
|
}
|
|
1133
|
-
else if (state === 1 /* Param */ ||
|
|
1134
|
-
state === 2 /* ParamRegExp */ ||
|
|
1135
|
-
state === 3 /* ParamRegExpEnd */) {
|
|
1124
|
+
else if (state === 1 /* TokenizerState.Param */ ||
|
|
1125
|
+
state === 2 /* TokenizerState.ParamRegExp */ ||
|
|
1126
|
+
state === 3 /* TokenizerState.ParamRegExpEnd */) {
|
|
1136
1127
|
if (segment.length > 1 && (char === '*' || char === '+'))
|
|
1137
1128
|
crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
|
|
1138
1129
|
segment.push({
|
|
1139
|
-
type: 1 /* Param */,
|
|
1130
|
+
type: 1 /* TokenType.Param */,
|
|
1140
1131
|
value: buffer,
|
|
1141
1132
|
regexp: customRe,
|
|
1142
1133
|
repeatable: char === '*' || char === '+',
|
|
@@ -1153,13 +1144,13 @@ function tokenizePath(path) {
|
|
|
1153
1144
|
}
|
|
1154
1145
|
while (i < path.length) {
|
|
1155
1146
|
char = path[i++];
|
|
1156
|
-
if (char === '\\' && state !== 2 /* ParamRegExp */) {
|
|
1147
|
+
if (char === '\\' && state !== 2 /* TokenizerState.ParamRegExp */) {
|
|
1157
1148
|
previousState = state;
|
|
1158
|
-
state = 4 /* EscapeNext */;
|
|
1149
|
+
state = 4 /* TokenizerState.EscapeNext */;
|
|
1159
1150
|
continue;
|
|
1160
1151
|
}
|
|
1161
1152
|
switch (state) {
|
|
1162
|
-
case 0 /* Static */:
|
|
1153
|
+
case 0 /* TokenizerState.Static */:
|
|
1163
1154
|
if (char === '/') {
|
|
1164
1155
|
if (buffer) {
|
|
1165
1156
|
consumeBuffer();
|
|
@@ -1168,32 +1159,32 @@ function tokenizePath(path) {
|
|
|
1168
1159
|
}
|
|
1169
1160
|
else if (char === ':') {
|
|
1170
1161
|
consumeBuffer();
|
|
1171
|
-
state = 1 /* Param */;
|
|
1162
|
+
state = 1 /* TokenizerState.Param */;
|
|
1172
1163
|
}
|
|
1173
1164
|
else {
|
|
1174
1165
|
addCharToBuffer();
|
|
1175
1166
|
}
|
|
1176
1167
|
break;
|
|
1177
|
-
case 4 /* EscapeNext */:
|
|
1168
|
+
case 4 /* TokenizerState.EscapeNext */:
|
|
1178
1169
|
addCharToBuffer();
|
|
1179
1170
|
state = previousState;
|
|
1180
1171
|
break;
|
|
1181
|
-
case 1 /* Param */:
|
|
1172
|
+
case 1 /* TokenizerState.Param */:
|
|
1182
1173
|
if (char === '(') {
|
|
1183
|
-
state = 2 /* ParamRegExp */;
|
|
1174
|
+
state = 2 /* TokenizerState.ParamRegExp */;
|
|
1184
1175
|
}
|
|
1185
1176
|
else if (VALID_PARAM_RE.test(char)) {
|
|
1186
1177
|
addCharToBuffer();
|
|
1187
1178
|
}
|
|
1188
1179
|
else {
|
|
1189
1180
|
consumeBuffer();
|
|
1190
|
-
state = 0 /* Static */;
|
|
1181
|
+
state = 0 /* TokenizerState.Static */;
|
|
1191
1182
|
// go back one character if we were not modifying
|
|
1192
1183
|
if (char !== '*' && char !== '?' && char !== '+')
|
|
1193
1184
|
i--;
|
|
1194
1185
|
}
|
|
1195
1186
|
break;
|
|
1196
|
-
case 2 /* ParamRegExp */:
|
|
1187
|
+
case 2 /* TokenizerState.ParamRegExp */:
|
|
1197
1188
|
// TODO: is it worth handling nested regexp? like :p(?:prefix_([^/]+)_suffix)
|
|
1198
1189
|
// it already works by escaping the closing )
|
|
1199
1190
|
// https://paths.esm.dev/?p=AAMeJbiAwQEcDKbAoAAkP60PG2R6QAvgNaA6AFACM2ABuQBB#
|
|
@@ -1204,16 +1195,16 @@ function tokenizePath(path) {
|
|
|
1204
1195
|
if (customRe[customRe.length - 1] == '\\')
|
|
1205
1196
|
customRe = customRe.slice(0, -1) + char;
|
|
1206
1197
|
else
|
|
1207
|
-
state = 3 /* ParamRegExpEnd */;
|
|
1198
|
+
state = 3 /* TokenizerState.ParamRegExpEnd */;
|
|
1208
1199
|
}
|
|
1209
1200
|
else {
|
|
1210
1201
|
customRe += char;
|
|
1211
1202
|
}
|
|
1212
1203
|
break;
|
|
1213
|
-
case 3 /* ParamRegExpEnd */:
|
|
1204
|
+
case 3 /* TokenizerState.ParamRegExpEnd */:
|
|
1214
1205
|
// same as finalizing a param
|
|
1215
1206
|
consumeBuffer();
|
|
1216
|
-
state = 0 /* Static */;
|
|
1207
|
+
state = 0 /* TokenizerState.Static */;
|
|
1217
1208
|
// go back one character if we were not modifying
|
|
1218
1209
|
if (char !== '*' && char !== '?' && char !== '+')
|
|
1219
1210
|
i--;
|
|
@@ -1224,7 +1215,7 @@ function tokenizePath(path) {
|
|
|
1224
1215
|
break;
|
|
1225
1216
|
}
|
|
1226
1217
|
}
|
|
1227
|
-
if (state === 2 /* ParamRegExp */)
|
|
1218
|
+
if (state === 2 /* TokenizerState.ParamRegExp */)
|
|
1228
1219
|
crash(`Unfinished custom RegExp for param "${buffer}"`);
|
|
1229
1220
|
consumeBuffer();
|
|
1230
1221
|
finalizeSegment();
|
|
@@ -1279,6 +1270,9 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1279
1270
|
// used later on to remove by name
|
|
1280
1271
|
const isRootAdd = !originalRecord;
|
|
1281
1272
|
const mainNormalizedRecord = normalizeRouteRecord(record);
|
|
1273
|
+
if ((process.env.NODE_ENV !== 'production')) {
|
|
1274
|
+
checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
|
|
1275
|
+
}
|
|
1282
1276
|
// we might be the child of an alias
|
|
1283
1277
|
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
|
|
1284
1278
|
const options = mergeOptions(globalOptions, record);
|
|
@@ -1344,7 +1338,7 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1344
1338
|
if (isRootAdd && record.name && !isAliasRecord(matcher))
|
|
1345
1339
|
removeRoute(record.name);
|
|
1346
1340
|
}
|
|
1347
|
-
if (
|
|
1341
|
+
if (mainNormalizedRecord.children) {
|
|
1348
1342
|
const children = mainNormalizedRecord.children;
|
|
1349
1343
|
for (let i = 0; i < children.length; i++) {
|
|
1350
1344
|
addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
|
|
@@ -1412,7 +1406,7 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1412
1406
|
if ('name' in location && location.name) {
|
|
1413
1407
|
matcher = matcherMap.get(location.name);
|
|
1414
1408
|
if (!matcher)
|
|
1415
|
-
throw createRouterError(1 /* MATCHER_NOT_FOUND */, {
|
|
1409
|
+
throw createRouterError(1 /* ErrorTypes.MATCHER_NOT_FOUND */, {
|
|
1416
1410
|
location,
|
|
1417
1411
|
});
|
|
1418
1412
|
name = matcher.record.name;
|
|
@@ -1448,7 +1442,7 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1448
1442
|
? matcherMap.get(currentLocation.name)
|
|
1449
1443
|
: matchers.find(m => m.re.test(currentLocation.path));
|
|
1450
1444
|
if (!matcher)
|
|
1451
|
-
throw createRouterError(1 /* MATCHER_NOT_FOUND */, {
|
|
1445
|
+
throw createRouterError(1 /* ErrorTypes.MATCHER_NOT_FOUND */, {
|
|
1452
1446
|
location,
|
|
1453
1447
|
currentLocation,
|
|
1454
1448
|
});
|
|
@@ -1506,8 +1500,8 @@ function normalizeRouteRecord(record) {
|
|
|
1506
1500
|
updateGuards: new Set(),
|
|
1507
1501
|
enterCallbacks: {},
|
|
1508
1502
|
components: 'components' in record
|
|
1509
|
-
? record.components ||
|
|
1510
|
-
: { default: record.component },
|
|
1503
|
+
? record.components || null
|
|
1504
|
+
: record.component && { default: record.component },
|
|
1511
1505
|
};
|
|
1512
1506
|
}
|
|
1513
1507
|
/**
|
|
@@ -1578,6 +1572,20 @@ function checkSameParams(a, b) {
|
|
|
1578
1572
|
return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"`);
|
|
1579
1573
|
}
|
|
1580
1574
|
}
|
|
1575
|
+
/**
|
|
1576
|
+
* A route with a name and a child with an empty path without a name should warn when adding the route
|
|
1577
|
+
*
|
|
1578
|
+
* @param mainNormalizedRecord - RouteRecordNormalized
|
|
1579
|
+
* @param parent - RouteRecordMatcher
|
|
1580
|
+
*/
|
|
1581
|
+
function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
|
|
1582
|
+
if (parent &&
|
|
1583
|
+
parent.record.name &&
|
|
1584
|
+
!mainNormalizedRecord.name &&
|
|
1585
|
+
!mainNormalizedRecord.path) {
|
|
1586
|
+
warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1581
1589
|
function checkMissingParamsInAbsolutePath(record, parent) {
|
|
1582
1590
|
for (const key of parent.keys) {
|
|
1583
1591
|
if (!record.keys.find(isSameParam.bind(null, key)))
|
|
@@ -1751,7 +1759,7 @@ function parseQuery(search) {
|
|
|
1751
1759
|
if (key in query) {
|
|
1752
1760
|
// an extra variable for ts types
|
|
1753
1761
|
let currentValue = query[key];
|
|
1754
|
-
if (!
|
|
1762
|
+
if (!isArray(currentValue)) {
|
|
1755
1763
|
currentValue = query[key] = [currentValue];
|
|
1756
1764
|
}
|
|
1757
1765
|
currentValue.push(value);
|
|
@@ -1784,7 +1792,7 @@ function stringifyQuery(query) {
|
|
|
1784
1792
|
continue;
|
|
1785
1793
|
}
|
|
1786
1794
|
// keep null values
|
|
1787
|
-
const values =
|
|
1795
|
+
const values = isArray(value)
|
|
1788
1796
|
? value.map(v => v && encodeQueryValue(v))
|
|
1789
1797
|
: [value && encodeQueryValue(value)];
|
|
1790
1798
|
values.forEach(value => {
|
|
@@ -1813,7 +1821,7 @@ function normalizeQuery(query) {
|
|
|
1813
1821
|
for (const key in query) {
|
|
1814
1822
|
const value = query[key];
|
|
1815
1823
|
if (value !== undefined) {
|
|
1816
|
-
normalizedQuery[key] =
|
|
1824
|
+
normalizedQuery[key] = isArray(value)
|
|
1817
1825
|
? value.map(v => (v == null ? null : '' + v))
|
|
1818
1826
|
: value == null
|
|
1819
1827
|
? value
|
|
@@ -1823,6 +1831,43 @@ function normalizeQuery(query) {
|
|
|
1823
1831
|
return normalizedQuery;
|
|
1824
1832
|
}
|
|
1825
1833
|
|
|
1834
|
+
/**
|
|
1835
|
+
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
|
1836
|
+
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
|
1837
|
+
* Location Matched
|
|
1838
|
+
*
|
|
1839
|
+
* @internal
|
|
1840
|
+
*/
|
|
1841
|
+
const matchedRouteKey = Symbol((process.env.NODE_ENV !== 'production') ? 'router view location matched' : '');
|
|
1842
|
+
/**
|
|
1843
|
+
* Allows overriding the router view depth to control which component in
|
|
1844
|
+
* `matched` is rendered. rvd stands for Router View Depth
|
|
1845
|
+
*
|
|
1846
|
+
* @internal
|
|
1847
|
+
*/
|
|
1848
|
+
const viewDepthKey = Symbol((process.env.NODE_ENV !== 'production') ? 'router view depth' : '');
|
|
1849
|
+
/**
|
|
1850
|
+
* Allows overriding the router instance returned by `useRouter` in tests. r
|
|
1851
|
+
* stands for router
|
|
1852
|
+
*
|
|
1853
|
+
* @internal
|
|
1854
|
+
*/
|
|
1855
|
+
const routerKey = Symbol((process.env.NODE_ENV !== 'production') ? 'router' : '');
|
|
1856
|
+
/**
|
|
1857
|
+
* Allows overriding the current route returned by `useRoute` in tests. rl
|
|
1858
|
+
* stands for route location
|
|
1859
|
+
*
|
|
1860
|
+
* @internal
|
|
1861
|
+
*/
|
|
1862
|
+
const routeLocationKey = Symbol((process.env.NODE_ENV !== 'production') ? 'route location' : '');
|
|
1863
|
+
/**
|
|
1864
|
+
* Allows overriding the current route used by router-view. Internally this is
|
|
1865
|
+
* used when the `route` prop is passed.
|
|
1866
|
+
*
|
|
1867
|
+
* @internal
|
|
1868
|
+
*/
|
|
1869
|
+
const routerViewLocationKey = Symbol((process.env.NODE_ENV !== 'production') ? 'router view location' : '');
|
|
1870
|
+
|
|
1826
1871
|
/**
|
|
1827
1872
|
* Create a list of callbacks that can be reset. Used to create before and after navigation guards list
|
|
1828
1873
|
*/
|
|
@@ -1908,16 +1953,17 @@ function guardToPromiseFn(guard, to, from, record, name) {
|
|
|
1908
1953
|
(record.enterCallbacks[name] = record.enterCallbacks[name] || []);
|
|
1909
1954
|
return () => new Promise((resolve, reject) => {
|
|
1910
1955
|
const next = (valid) => {
|
|
1911
|
-
if (valid === false)
|
|
1912
|
-
reject(createRouterError(4 /* NAVIGATION_ABORTED */, {
|
|
1956
|
+
if (valid === false) {
|
|
1957
|
+
reject(createRouterError(4 /* ErrorTypes.NAVIGATION_ABORTED */, {
|
|
1913
1958
|
from,
|
|
1914
1959
|
to,
|
|
1915
1960
|
}));
|
|
1961
|
+
}
|
|
1916
1962
|
else if (valid instanceof Error) {
|
|
1917
1963
|
reject(valid);
|
|
1918
1964
|
}
|
|
1919
1965
|
else if (isRouteLocation(valid)) {
|
|
1920
|
-
reject(createRouterError(2 /* NAVIGATION_GUARD_REDIRECT */, {
|
|
1966
|
+
reject(createRouterError(2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */, {
|
|
1921
1967
|
from: to,
|
|
1922
1968
|
to: valid,
|
|
1923
1969
|
}));
|
|
@@ -1926,8 +1972,9 @@ function guardToPromiseFn(guard, to, from, record, name) {
|
|
|
1926
1972
|
if (enterCallbackArray &&
|
|
1927
1973
|
// since enterCallbackArray is truthy, both record and name also are
|
|
1928
1974
|
record.enterCallbacks[name] === enterCallbackArray &&
|
|
1929
|
-
typeof valid === 'function')
|
|
1975
|
+
typeof valid === 'function') {
|
|
1930
1976
|
enterCallbackArray.push(valid);
|
|
1977
|
+
}
|
|
1931
1978
|
resolve();
|
|
1932
1979
|
}
|
|
1933
1980
|
};
|
|
@@ -1947,7 +1994,6 @@ function guardToPromiseFn(guard, to, from, record, name) {
|
|
|
1947
1994
|
}
|
|
1948
1995
|
return resolvedValue;
|
|
1949
1996
|
});
|
|
1950
|
-
// TODO: test me!
|
|
1951
1997
|
}
|
|
1952
1998
|
else if (guardReturn !== undefined) {
|
|
1953
1999
|
// @ts-expect-error: _called is added at canOnlyBeCalledOnce
|
|
@@ -1975,6 +2021,10 @@ function canOnlyBeCalledOnce(next, to, from) {
|
|
|
1975
2021
|
function extractComponentsGuards(matched, guardType, to, from) {
|
|
1976
2022
|
const guards = [];
|
|
1977
2023
|
for (const record of matched) {
|
|
2024
|
+
if ((process.env.NODE_ENV !== 'production') && !record.components && !record.children.length) {
|
|
2025
|
+
warn(`Record with path "${record.path}" is either missing a "component(s)"` +
|
|
2026
|
+
` or "children" property.`);
|
|
2027
|
+
}
|
|
1978
2028
|
for (const name in record.components) {
|
|
1979
2029
|
let rawComponent = record.components[name];
|
|
1980
2030
|
if ((process.env.NODE_ENV !== 'production')) {
|
|
@@ -2031,6 +2081,7 @@ function extractComponentsGuards(matched, guardType, to, from) {
|
|
|
2031
2081
|
? resolved.default
|
|
2032
2082
|
: resolved;
|
|
2033
2083
|
// replace the function with the resolved component
|
|
2084
|
+
// cannot be null or undefined because we went into the for loop
|
|
2034
2085
|
record.components[name] = resolvedComponent;
|
|
2035
2086
|
// __vccOpts is added by vue-class-component and contain the regular options
|
|
2036
2087
|
const options = resolvedComponent.__vccOpts || resolvedComponent;
|
|
@@ -2044,6 +2095,7 @@ function extractComponentsGuards(matched, guardType, to, from) {
|
|
|
2044
2095
|
}
|
|
2045
2096
|
/**
|
|
2046
2097
|
* Allows differentiating lazy components from functional components and vue-class-component
|
|
2098
|
+
* @internal
|
|
2047
2099
|
*
|
|
2048
2100
|
* @param component
|
|
2049
2101
|
*/
|
|
@@ -2052,6 +2104,34 @@ function isRouteComponent(component) {
|
|
|
2052
2104
|
'displayName' in component ||
|
|
2053
2105
|
'props' in component ||
|
|
2054
2106
|
'__vccOpts' in component);
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Ensures a route is loaded so it can be passed as o prop to `<RouterView>`.
|
|
2110
|
+
*
|
|
2111
|
+
* @param route - resolved route to load
|
|
2112
|
+
*/
|
|
2113
|
+
function loadRouteLocation(route) {
|
|
2114
|
+
return route.matched.every(record => record.redirect)
|
|
2115
|
+
? Promise.reject(new Error('Cannot load a route that redirects.'))
|
|
2116
|
+
: Promise.all(route.matched.map(record => record.components &&
|
|
2117
|
+
Promise.all(Object.keys(record.components).reduce((promises, name) => {
|
|
2118
|
+
const rawComponent = record.components[name];
|
|
2119
|
+
if (typeof rawComponent === 'function' &&
|
|
2120
|
+
!('displayName' in rawComponent)) {
|
|
2121
|
+
promises.push(rawComponent().then(resolved => {
|
|
2122
|
+
if (!resolved)
|
|
2123
|
+
return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
|
|
2124
|
+
const resolvedComponent = isESModule(resolved)
|
|
2125
|
+
? resolved.default
|
|
2126
|
+
: resolved;
|
|
2127
|
+
// replace the function with the resolved component
|
|
2128
|
+
// cannot be null or undefined because we went into the for loop
|
|
2129
|
+
record.components[name] = resolvedComponent;
|
|
2130
|
+
return;
|
|
2131
|
+
}));
|
|
2132
|
+
}
|
|
2133
|
+
return promises;
|
|
2134
|
+
}, [])))).then(() => route);
|
|
2055
2135
|
}
|
|
2056
2136
|
|
|
2057
2137
|
// TODO: we could allow currentRoute as a prop to expose `isActive` and
|
|
@@ -2127,6 +2207,7 @@ function useLink(props) {
|
|
|
2127
2207
|
}
|
|
2128
2208
|
const RouterLinkImpl = /*#__PURE__*/ defineComponent({
|
|
2129
2209
|
name: 'RouterLink',
|
|
2210
|
+
compatConfig: { MODE: 3 },
|
|
2130
2211
|
props: {
|
|
2131
2212
|
to: {
|
|
2132
2213
|
type: [String, Object],
|
|
@@ -2210,7 +2291,7 @@ function includesParams(outer, inner) {
|
|
|
2210
2291
|
return false;
|
|
2211
2292
|
}
|
|
2212
2293
|
else {
|
|
2213
|
-
if (!
|
|
2294
|
+
if (!isArray(outerValue) ||
|
|
2214
2295
|
outerValue.length !== innerValue.length ||
|
|
2215
2296
|
innerValue.some((value, i) => value !== outerValue[i]))
|
|
2216
2297
|
return false;
|
|
@@ -2255,9 +2336,21 @@ const RouterViewImpl = /*#__PURE__*/ defineComponent({
|
|
|
2255
2336
|
(process.env.NODE_ENV !== 'production') && warnDeprecatedUsage();
|
|
2256
2337
|
const injectedRoute = inject(routerViewLocationKey);
|
|
2257
2338
|
const routeToDisplay = computed(() => props.route || injectedRoute.value);
|
|
2258
|
-
const
|
|
2259
|
-
|
|
2260
|
-
|
|
2339
|
+
const injectedDepth = inject(viewDepthKey, 0);
|
|
2340
|
+
// The depth changes based on empty components option, which allows passthrough routes e.g. routes with children
|
|
2341
|
+
// that are used to reuse the `path` property
|
|
2342
|
+
const depth = computed(() => {
|
|
2343
|
+
let initialDepth = unref(injectedDepth);
|
|
2344
|
+
const { matched } = routeToDisplay.value;
|
|
2345
|
+
let matchedRoute;
|
|
2346
|
+
while ((matchedRoute = matched[initialDepth]) &&
|
|
2347
|
+
!matchedRoute.components) {
|
|
2348
|
+
initialDepth++;
|
|
2349
|
+
}
|
|
2350
|
+
return initialDepth;
|
|
2351
|
+
});
|
|
2352
|
+
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
|
|
2353
|
+
provide(viewDepthKey, computed(() => depth.value + 1));
|
|
2261
2354
|
provide(matchedRouteKey, matchedRouteRef);
|
|
2262
2355
|
provide(routerViewLocationKey, routeToDisplay);
|
|
2263
2356
|
const viewRef = ref();
|
|
@@ -2295,16 +2388,16 @@ const RouterViewImpl = /*#__PURE__*/ defineComponent({
|
|
|
2295
2388
|
}, { flush: 'post' });
|
|
2296
2389
|
return () => {
|
|
2297
2390
|
const route = routeToDisplay.value;
|
|
2298
|
-
const matchedRoute = matchedRouteRef.value;
|
|
2299
|
-
const ViewComponent = matchedRoute && matchedRoute.components[props.name];
|
|
2300
2391
|
// we need the value at the time we render because when we unmount, we
|
|
2301
2392
|
// navigated to a different location so the value is different
|
|
2302
2393
|
const currentName = props.name;
|
|
2394
|
+
const matchedRoute = matchedRouteRef.value;
|
|
2395
|
+
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
|
|
2303
2396
|
if (!ViewComponent) {
|
|
2304
2397
|
return normalizeSlot(slots.default, { Component: ViewComponent, route });
|
|
2305
2398
|
}
|
|
2306
2399
|
// props from route configuration
|
|
2307
|
-
const routePropsOption = matchedRoute.props[
|
|
2400
|
+
const routePropsOption = matchedRoute.props[currentName];
|
|
2308
2401
|
const routeProps = routePropsOption
|
|
2309
2402
|
? routePropsOption === true
|
|
2310
2403
|
? route.params
|
|
@@ -2327,12 +2420,12 @@ const RouterViewImpl = /*#__PURE__*/ defineComponent({
|
|
|
2327
2420
|
component.ref) {
|
|
2328
2421
|
// TODO: can display if it's an alias, its props
|
|
2329
2422
|
const info = {
|
|
2330
|
-
depth,
|
|
2423
|
+
depth: depth.value,
|
|
2331
2424
|
name: matchedRoute.name,
|
|
2332
2425
|
path: matchedRoute.path,
|
|
2333
2426
|
meta: matchedRoute.meta,
|
|
2334
2427
|
};
|
|
2335
|
-
const internalInstances =
|
|
2428
|
+
const internalInstances = isArray(component.ref)
|
|
2336
2429
|
? component.ref.map(r => r.i)
|
|
2337
2430
|
: [component.ref.i];
|
|
2338
2431
|
internalInstances.forEach(instance => {
|
|
@@ -2378,6 +2471,13 @@ function warnDeprecatedUsage() {
|
|
|
2378
2471
|
}
|
|
2379
2472
|
}
|
|
2380
2473
|
|
|
2474
|
+
/**
|
|
2475
|
+
* Copies a route location and removes any problematic properties that cannot be shown in devtools (e.g. Vue instances).
|
|
2476
|
+
*
|
|
2477
|
+
* @param routeLocation - routeLocation to format
|
|
2478
|
+
* @param tooltip - optional tooltip
|
|
2479
|
+
* @returns a copy of the routeLocation
|
|
2480
|
+
*/
|
|
2381
2481
|
function formatRouteLocation(routeLocation, tooltip) {
|
|
2382
2482
|
const copy = assign({}, routeLocation, {
|
|
2383
2483
|
// remove variables that can contain vue instances
|
|
@@ -2419,6 +2519,9 @@ function addDevtools(app, router, matcher) {
|
|
|
2419
2519
|
componentStateTypes: ['Routing'],
|
|
2420
2520
|
app,
|
|
2421
2521
|
}, api => {
|
|
2522
|
+
if (typeof api.now !== 'function') {
|
|
2523
|
+
console.warn('[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.');
|
|
2524
|
+
}
|
|
2422
2525
|
// display state added by the router
|
|
2423
2526
|
api.on.inspectComponent((payload, ctx) => {
|
|
2424
2527
|
if (payload.instanceData) {
|
|
@@ -2442,7 +2545,7 @@ function addDevtools(app, router, matcher) {
|
|
|
2442
2545
|
});
|
|
2443
2546
|
}
|
|
2444
2547
|
// if multiple useLink are used
|
|
2445
|
-
if (
|
|
2548
|
+
if (isArray(componentInstance.__vrl_devtools)) {
|
|
2446
2549
|
componentInstance.__devtoolsApi = api;
|
|
2447
2550
|
componentInstance.__vrl_devtools.forEach(devtoolsData => {
|
|
2448
2551
|
let backgroundColor = ORANGE_400;
|
|
@@ -2659,6 +2762,13 @@ function formatRouteRecordMatcherForStateInspector(route) {
|
|
|
2659
2762
|
value: route.alias.map(alias => alias.record.path),
|
|
2660
2763
|
});
|
|
2661
2764
|
}
|
|
2765
|
+
if (Object.keys(route.record.meta).length) {
|
|
2766
|
+
fields.push({
|
|
2767
|
+
editable: false,
|
|
2768
|
+
key: 'meta',
|
|
2769
|
+
value: route.record.meta,
|
|
2770
|
+
});
|
|
2771
|
+
}
|
|
2662
2772
|
fields.push({
|
|
2663
2773
|
key: 'score',
|
|
2664
2774
|
editable: false,
|
|
@@ -2724,8 +2834,9 @@ function formatRouteRecordForInspector(route) {
|
|
|
2724
2834
|
}
|
|
2725
2835
|
if (record.redirect) {
|
|
2726
2836
|
tags.push({
|
|
2727
|
-
label:
|
|
2728
|
-
|
|
2837
|
+
label: typeof record.redirect === 'string'
|
|
2838
|
+
? `redirect: ${record.redirect}`
|
|
2839
|
+
: 'redirects',
|
|
2729
2840
|
textColor: 0xffffff,
|
|
2730
2841
|
backgroundColor: DARK,
|
|
2731
2842
|
});
|
|
@@ -2960,7 +3071,7 @@ function createRouter(options) {
|
|
|
2960
3071
|
}
|
|
2961
3072
|
function checkCanceledNavigation(to, from) {
|
|
2962
3073
|
if (pendingLocation !== to) {
|
|
2963
|
-
return createRouterError(8 /* NAVIGATION_CANCELLED */, {
|
|
3074
|
+
return createRouterError(8 /* ErrorTypes.NAVIGATION_CANCELLED */, {
|
|
2964
3075
|
from,
|
|
2965
3076
|
to,
|
|
2966
3077
|
});
|
|
@@ -2996,7 +3107,8 @@ function createRouter(options) {
|
|
|
2996
3107
|
return assign({
|
|
2997
3108
|
query: to.query,
|
|
2998
3109
|
hash: to.hash,
|
|
2999
|
-
params
|
|
3110
|
+
// avoid transferring params if the redirect has a path
|
|
3111
|
+
params: 'path' in newTargetLocation ? {} : to.params,
|
|
3000
3112
|
}, newTargetLocation);
|
|
3001
3113
|
}
|
|
3002
3114
|
}
|
|
@@ -3021,7 +3133,7 @@ function createRouter(options) {
|
|
|
3021
3133
|
toLocation.redirectedFrom = redirectedFrom;
|
|
3022
3134
|
let failure;
|
|
3023
3135
|
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
|
|
3024
|
-
failure = createRouterError(16 /* NAVIGATION_DUPLICATED */, { to: toLocation, from });
|
|
3136
|
+
failure = createRouterError(16 /* ErrorTypes.NAVIGATION_DUPLICATED */, { to: toLocation, from });
|
|
3025
3137
|
// trigger scroll to allow scrolling to the same anchor
|
|
3026
3138
|
handleScroll(from, from,
|
|
3027
3139
|
// this is a push, the only way for it to be triggered from a
|
|
@@ -3034,14 +3146,14 @@ function createRouter(options) {
|
|
|
3034
3146
|
return (failure ? Promise.resolve(failure) : navigate(toLocation, from))
|
|
3035
3147
|
.catch((error) => isNavigationFailure(error)
|
|
3036
3148
|
? // navigation redirects still mark the router as ready
|
|
3037
|
-
isNavigationFailure(error, 2 /* NAVIGATION_GUARD_REDIRECT */)
|
|
3149
|
+
isNavigationFailure(error, 2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */)
|
|
3038
3150
|
? error
|
|
3039
3151
|
: markAsReady(error) // also returns the error
|
|
3040
3152
|
: // reject any unknown error
|
|
3041
3153
|
triggerError(error, toLocation, from))
|
|
3042
3154
|
.then((failure) => {
|
|
3043
3155
|
if (failure) {
|
|
3044
|
-
if (isNavigationFailure(failure, 2 /* NAVIGATION_GUARD_REDIRECT */)) {
|
|
3156
|
+
if (isNavigationFailure(failure, 2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */)) {
|
|
3045
3157
|
if ((process.env.NODE_ENV !== 'production') &&
|
|
3046
3158
|
// we are redirecting to the same location we were already at
|
|
3047
3159
|
isSameRouteLocation(stringifyQuery$1, resolve(failure.to), toLocation) &&
|
|
@@ -3057,10 +3169,12 @@ function createRouter(options) {
|
|
|
3057
3169
|
}
|
|
3058
3170
|
return pushWithRedirect(
|
|
3059
3171
|
// keep options
|
|
3060
|
-
assign(
|
|
3172
|
+
assign({
|
|
3173
|
+
// preserve an existing replace but allow the redirect to override it
|
|
3174
|
+
replace,
|
|
3175
|
+
}, locationAsObject(failure.to), {
|
|
3061
3176
|
state: data,
|
|
3062
3177
|
force,
|
|
3063
|
-
replace,
|
|
3064
3178
|
}),
|
|
3065
3179
|
// preserve the original redirectedFrom if any
|
|
3066
3180
|
redirectedFrom || toLocation);
|
|
@@ -3126,7 +3240,7 @@ function createRouter(options) {
|
|
|
3126
3240
|
for (const record of to.matched) {
|
|
3127
3241
|
// do not trigger beforeEnter on reused views
|
|
3128
3242
|
if (record.beforeEnter && !from.matched.includes(record)) {
|
|
3129
|
-
if (
|
|
3243
|
+
if (isArray(record.beforeEnter)) {
|
|
3130
3244
|
for (const beforeEnter of record.beforeEnter)
|
|
3131
3245
|
guards.push(guardToPromiseFn(beforeEnter, to, from));
|
|
3132
3246
|
}
|
|
@@ -3159,7 +3273,7 @@ function createRouter(options) {
|
|
|
3159
3273
|
return runGuardQueue(guards);
|
|
3160
3274
|
})
|
|
3161
3275
|
// catch any navigation canceled
|
|
3162
|
-
.catch(err => isNavigationFailure(err, 8 /* NAVIGATION_CANCELLED */)
|
|
3276
|
+
.catch(err => isNavigationFailure(err, 8 /* ErrorTypes.NAVIGATION_CANCELLED */)
|
|
3163
3277
|
? err
|
|
3164
3278
|
: Promise.reject(err)));
|
|
3165
3279
|
}
|
|
@@ -3206,6 +3320,8 @@ function createRouter(options) {
|
|
|
3206
3320
|
if (removeHistoryListener)
|
|
3207
3321
|
return;
|
|
3208
3322
|
removeHistoryListener = routerHistory.listen((to, _from, info) => {
|
|
3323
|
+
if (!router.listening)
|
|
3324
|
+
return;
|
|
3209
3325
|
// cannot be a redirect route because it was in history
|
|
3210
3326
|
const toLocation = resolve(to);
|
|
3211
3327
|
// due to dynamic routing, and to hash history with manual navigation
|
|
@@ -3224,10 +3340,10 @@ function createRouter(options) {
|
|
|
3224
3340
|
}
|
|
3225
3341
|
navigate(toLocation, from)
|
|
3226
3342
|
.catch((error) => {
|
|
3227
|
-
if (isNavigationFailure(error, 4 /* NAVIGATION_ABORTED */ | 8 /* NAVIGATION_CANCELLED */)) {
|
|
3343
|
+
if (isNavigationFailure(error, 4 /* ErrorTypes.NAVIGATION_ABORTED */ | 8 /* ErrorTypes.NAVIGATION_CANCELLED */)) {
|
|
3228
3344
|
return error;
|
|
3229
3345
|
}
|
|
3230
|
-
if (isNavigationFailure(error, 2 /* NAVIGATION_GUARD_REDIRECT */)) {
|
|
3346
|
+
if (isNavigationFailure(error, 2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */)) {
|
|
3231
3347
|
// Here we could call if (info.delta) routerHistory.go(-info.delta,
|
|
3232
3348
|
// false) but this is bug prone as we have no way to wait the
|
|
3233
3349
|
// navigation to be finished before calling pushWithRedirect. Using
|
|
@@ -3244,8 +3360,8 @@ function createRouter(options) {
|
|
|
3244
3360
|
// manual change in hash history #916 ending up in the URL not
|
|
3245
3361
|
// changing but it was changed by the manual url change, so we
|
|
3246
3362
|
// need to manually change it ourselves
|
|
3247
|
-
if (isNavigationFailure(failure, 4 /* NAVIGATION_ABORTED */ |
|
|
3248
|
-
16 /* NAVIGATION_DUPLICATED */) &&
|
|
3363
|
+
if (isNavigationFailure(failure, 4 /* ErrorTypes.NAVIGATION_ABORTED */ |
|
|
3364
|
+
16 /* ErrorTypes.NAVIGATION_DUPLICATED */) &&
|
|
3249
3365
|
!info.delta &&
|
|
3250
3366
|
info.type === NavigationType.pop) {
|
|
3251
3367
|
routerHistory.go(-1, false);
|
|
@@ -3256,8 +3372,9 @@ function createRouter(options) {
|
|
|
3256
3372
|
return Promise.reject();
|
|
3257
3373
|
}
|
|
3258
3374
|
// do not restore history on unknown direction
|
|
3259
|
-
if (info.delta)
|
|
3375
|
+
if (info.delta) {
|
|
3260
3376
|
routerHistory.go(-info.delta, false);
|
|
3377
|
+
}
|
|
3261
3378
|
// unrecognized error, transfer to the global handler
|
|
3262
3379
|
return triggerError(error, toLocation, from);
|
|
3263
3380
|
})
|
|
@@ -3269,11 +3386,14 @@ function createRouter(options) {
|
|
|
3269
3386
|
toLocation, from, false);
|
|
3270
3387
|
// revert the navigation
|
|
3271
3388
|
if (failure) {
|
|
3272
|
-
if (info.delta
|
|
3389
|
+
if (info.delta &&
|
|
3390
|
+
// a new navigation has been triggered, so we do not want to revert, that will change the current history
|
|
3391
|
+
// entry while a different route is displayed
|
|
3392
|
+
!isNavigationFailure(failure, 8 /* ErrorTypes.NAVIGATION_CANCELLED */)) {
|
|
3273
3393
|
routerHistory.go(-info.delta, false);
|
|
3274
3394
|
}
|
|
3275
3395
|
else if (info.type === NavigationType.pop &&
|
|
3276
|
-
isNavigationFailure(failure, 4 /* NAVIGATION_ABORTED */ | 16 /* NAVIGATION_DUPLICATED */)) {
|
|
3396
|
+
isNavigationFailure(failure, 4 /* ErrorTypes.NAVIGATION_ABORTED */ | 16 /* ErrorTypes.NAVIGATION_DUPLICATED */)) {
|
|
3277
3397
|
// manual change in hash history #916
|
|
3278
3398
|
// it's like a push but lacks the information of the direction
|
|
3279
3399
|
routerHistory.go(-1, false);
|
|
@@ -3349,6 +3469,7 @@ function createRouter(options) {
|
|
|
3349
3469
|
const installedApps = new Set();
|
|
3350
3470
|
const router = {
|
|
3351
3471
|
currentRoute,
|
|
3472
|
+
listening: true,
|
|
3352
3473
|
addRoute,
|
|
3353
3474
|
removeRoute,
|
|
3354
3475
|
hasRoute,
|
|
@@ -3462,4 +3583,4 @@ function useRoute() {
|
|
|
3462
3583
|
return inject(routeLocationKey);
|
|
3463
3584
|
}
|
|
3464
3585
|
|
|
3465
|
-
export { NavigationFailureType, RouterLink, RouterView, START_LOCATION_NORMALIZED as START_LOCATION, createMemoryHistory, createRouter, createRouterMatcher, createWebHashHistory, createWebHistory, isNavigationFailure, matchedRouteKey, onBeforeRouteLeave, onBeforeRouteUpdate, parseQuery, routeLocationKey, routerKey, routerViewLocationKey, stringifyQuery, useLink, useRoute, useRouter, viewDepthKey };
|
|
3586
|
+
export { NavigationFailureType, RouterLink, RouterView, START_LOCATION_NORMALIZED as START_LOCATION, createMemoryHistory, createRouter, createRouterMatcher, createWebHashHistory, createWebHistory, isNavigationFailure, loadRouteLocation, matchedRouteKey, onBeforeRouteLeave, onBeforeRouteUpdate, parseQuery, routeLocationKey, routerKey, routerViewLocationKey, stringifyQuery, useLink, useRoute, useRouter, viewDepthKey };
|