@histoire/vendors 0.17.16 → 1.0.0-alpha.1

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.
Files changed (231) hide show
  1. package/dist/client/b-floating-vue.d.ts +3 -3
  2. package/dist/client/b-floating-vue.js +2176 -2149
  3. package/dist/client/b-iconify.d.ts +1 -1
  4. package/dist/client/b-iconify.js +751 -825
  5. package/dist/client/b-pinia.d.ts +1 -1
  6. package/dist/client/b-pinia.js +130 -68
  7. package/dist/client/b-scroll.d.ts +2 -2
  8. package/dist/client/b-scroll.js +5 -52
  9. package/dist/client/b-vue-router.d.ts +1 -1
  10. package/dist/client/b-vue-router.js +385 -237
  11. package/dist/client/b-vue-use.d.ts +1 -1
  12. package/dist/client/b-vue-use.js +3898 -2871
  13. package/dist/client/b-vue.d.ts +1 -1
  14. package/dist/client/b-vue.js +1 -1
  15. package/dist/client/index.js +162 -20
  16. package/dist/client/node_modules/@babel/helper-string-parser/package.json +31 -0
  17. package/dist/client/node_modules/@babel/helper-validator-identifier/package.json +31 -0
  18. package/dist/client/node_modules/@babel/parser/package.json +10 -6
  19. package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +47 -31
  20. package/dist/client/node_modules/@babel/types/lib/index-legacy.d.ts +2776 -0
  21. package/dist/client/node_modules/@babel/types/lib/index.d.ts +3275 -0
  22. package/dist/client/node_modules/@babel/types/package.json +39 -0
  23. package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +525 -0
  24. package/dist/client/node_modules/@floating-ui/core/package.json +32 -39
  25. package/dist/client/node_modules/@floating-ui/dom/package.json +23 -24
  26. package/dist/client/node_modules/@floating-ui/dom/src/autoUpdate.d.ts +31 -0
  27. package/dist/client/node_modules/@floating-ui/dom/src/index.d.ts +11 -7
  28. package/dist/client/node_modules/@floating-ui/dom/src/platform.d.ts +1 -1
  29. package/dist/client/node_modules/@floating-ui/dom/src/types.d.ts +121 -20
  30. package/dist/client/node_modules/@floating-ui/dom/src/utils/getBoundingClientRect.d.ts +1 -1
  31. package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingRect.d.ts +12 -0
  32. package/dist/client/node_modules/@floating-ui/dom/src/utils/getCssDimensions.d.ts +4 -0
  33. package/dist/client/node_modules/@floating-ui/dom/src/utils/getDimensions.d.ts +1 -1
  34. package/dist/client/node_modules/@floating-ui/dom/src/utils/getNearestOverflowAncestor.d.ts +1 -0
  35. package/dist/client/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts +3 -0
  36. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScale.d.ts +7 -0
  37. package/dist/client/node_modules/@floating-ui/dom/src/utils/getViewportRect.d.ts +2 -2
  38. package/dist/client/node_modules/@floating-ui/dom/src/utils/getWindowScrollBarX.d.ts +1 -1
  39. package/dist/client/node_modules/@floating-ui/dom/src/utils/is.d.ts +3 -1
  40. package/dist/client/node_modules/@floating-ui/dom/src/utils/unwrapElement.d.ts +2 -0
  41. package/dist/client/node_modules/@floating-ui/dom/src/utils/userAgent.d.ts +1 -0
  42. package/dist/client/node_modules/@floating-ui/dom/src/utils/window.d.ts +1 -2
  43. package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +103 -0
  44. package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +47 -0
  45. package/dist/client/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +47 -0
  46. package/dist/client/node_modules/@floating-ui/utils/dom/package.json +6 -0
  47. package/dist/client/node_modules/@floating-ui/utils/package.json +70 -0
  48. package/dist/client/node_modules/@iconify/types/package.json +23 -0
  49. package/dist/client/node_modules/@iconify/types/provider.d.ts +44 -0
  50. package/dist/client/node_modules/@iconify/types/types.d.ts +272 -0
  51. package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +72 -330
  52. package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +28 -268
  53. package/dist/client/node_modules/@iconify/vue/package.json +64 -60
  54. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/scopes.d.ts +49 -0
  55. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts +2 -0
  56. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/strings.d.ts +15 -0
  57. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/vlq.d.ts +6 -0
  58. package/dist/client/node_modules/@jridgewell/sourcemap-codec/package.json +3 -2
  59. package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +33 -14
  60. package/dist/client/node_modules/@types/web-bluetooth/package.json +12 -12
  61. package/dist/client/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +218 -125
  62. package/dist/client/node_modules/@vue/compiler-core/package.json +20 -5
  63. package/dist/client/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +6 -3
  64. package/dist/client/node_modules/@vue/compiler-dom/package.json +17 -3
  65. package/dist/client/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +35 -25
  66. package/dist/client/node_modules/@vue/compiler-sfc/package.json +27 -18
  67. package/dist/client/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +2 -2
  68. package/dist/client/node_modules/@vue/compiler-ssr/package.json +3 -3
  69. package/dist/client/node_modules/@vue/devtools-api/package.json +1 -1
  70. package/dist/client/node_modules/@vue/reactivity/dist/reactivity.d.ts +268 -166
  71. package/dist/client/node_modules/@vue/reactivity/package.json +16 -2
  72. package/dist/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +728 -529
  73. package/dist/client/node_modules/@vue/runtime-core/package.json +17 -3
  74. package/dist/client/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +195 -86
  75. package/dist/client/node_modules/@vue/runtime-dom/package.json +22 -4
  76. package/dist/client/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +4 -8
  77. package/dist/client/node_modules/@vue/server-renderer/package.json +18 -4
  78. package/dist/client/node_modules/@vue/shared/dist/shared.d.ts +45 -30
  79. package/dist/client/node_modules/@vue/shared/package.json +15 -1
  80. package/dist/client/node_modules/@vueuse/core/index.d.ts +2040 -633
  81. package/dist/client/node_modules/@vueuse/core/package.json +10 -12
  82. package/dist/client/node_modules/@vueuse/metadata/index.d.ts +7 -5
  83. package/dist/client/node_modules/@vueuse/metadata/package.json +4 -4
  84. package/dist/client/node_modules/@vueuse/shared/index.d.ts +410 -273
  85. package/dist/client/node_modules/@vueuse/shared/package.json +5 -6
  86. package/dist/client/node_modules/compute-scroll-into-view/dist/index.d.ts +75 -0
  87. package/dist/client/node_modules/compute-scroll-into-view/package.json +35 -45
  88. package/dist/client/node_modules/entities/lib/decode.d.ts +211 -0
  89. package/dist/client/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
  90. package/dist/client/node_modules/entities/lib/encode.d.ts +22 -0
  91. package/dist/client/node_modules/entities/lib/escape.d.ts +43 -0
  92. package/dist/client/node_modules/entities/lib/esm/decode.d.ts +211 -0
  93. package/dist/client/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
  94. package/dist/client/node_modules/entities/lib/esm/encode.d.ts +22 -0
  95. package/dist/client/node_modules/entities/lib/esm/escape.d.ts +43 -0
  96. package/dist/client/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
  97. package/dist/client/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
  98. package/dist/client/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
  99. package/dist/client/node_modules/entities/lib/esm/index.d.ts +96 -0
  100. package/dist/client/node_modules/entities/lib/esm/package.json +1 -0
  101. package/dist/client/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
  102. package/dist/client/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
  103. package/dist/client/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
  104. package/dist/client/node_modules/entities/lib/index.d.ts +96 -0
  105. package/dist/client/node_modules/entities/package.json +90 -0
  106. package/dist/client/node_modules/floating-vue/dist/components/Dropdown.d.ts +398 -0
  107. package/dist/client/node_modules/floating-vue/dist/components/Menu.d.ts +398 -0
  108. package/dist/client/node_modules/floating-vue/dist/components/Popper.d.ts +225 -105
  109. package/dist/client/node_modules/floating-vue/dist/components/Popper.vue.d.ts +471 -364
  110. package/dist/client/node_modules/floating-vue/dist/components/PopperContent.vue.d.ts +14 -25
  111. package/dist/client/node_modules/floating-vue/dist/components/PopperWrapper.vue.d.ts +392 -6
  112. package/dist/client/node_modules/floating-vue/dist/components/Tooltip.d.ts +398 -0
  113. package/dist/client/node_modules/floating-vue/dist/components/TooltipDirective.vue.d.ts +49 -10
  114. package/dist/client/node_modules/floating-vue/dist/config.d.ts +1 -1
  115. package/dist/client/node_modules/floating-vue/dist/index.d.ts +2071 -247
  116. package/dist/client/node_modules/floating-vue/dist/util/events.d.ts +2 -0
  117. package/dist/client/node_modules/floating-vue/dist/util/popper.d.ts +1 -1
  118. package/dist/client/node_modules/floating-vue/package.json +42 -33
  119. package/dist/client/node_modules/magic-string/dist/magic-string.cjs.d.ts +250 -229
  120. package/dist/client/node_modules/magic-string/package.json +24 -26
  121. package/dist/client/node_modules/nanoid/package.json +1 -1
  122. package/dist/client/node_modules/picocolors/package.json +2 -2
  123. package/dist/client/node_modules/picocolors/types.d.ts +51 -0
  124. package/dist/client/node_modules/pinia/dist/pinia.d.ts +116 -37
  125. package/dist/client/node_modules/pinia/package.json +7 -11
  126. package/dist/client/node_modules/postcss/lib/at-rule.d.ts +25 -22
  127. package/dist/client/node_modules/postcss/lib/comment.d.ts +10 -9
  128. package/dist/client/node_modules/postcss/lib/container.d.ts +47 -54
  129. package/dist/client/node_modules/postcss/lib/css-syntax-error.d.ts +1 -1
  130. package/dist/client/node_modules/postcss/lib/declaration.d.ts +20 -17
  131. package/dist/client/node_modules/postcss/lib/document.d.ts +4 -4
  132. package/dist/client/node_modules/postcss/lib/input.d.ts +14 -0
  133. package/dist/client/node_modules/postcss/lib/list.d.ts +5 -2
  134. package/dist/client/node_modules/postcss/lib/node.d.ts +19 -14
  135. package/dist/client/node_modules/postcss/lib/postcss.d.ts +25 -8
  136. package/dist/client/node_modules/postcss/lib/processor.d.ts +1 -1
  137. package/dist/client/node_modules/postcss/lib/result.d.ts +0 -1
  138. package/dist/client/node_modules/postcss/lib/root.d.ts +4 -4
  139. package/dist/client/node_modules/postcss/lib/rule.d.ts +27 -18
  140. package/dist/client/node_modules/postcss/package.json +4 -4
  141. package/dist/client/node_modules/scroll-into-view-if-needed/dist/index.d.ts +79 -0
  142. package/dist/client/node_modules/scroll-into-view-if-needed/package.json +28 -67
  143. package/dist/client/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  144. package/dist/client/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  145. package/dist/client/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  146. package/dist/client/node_modules/source-map-js/package.json +1 -1
  147. package/dist/client/node_modules/source-map-js/source-map.d.ts +88 -99
  148. package/dist/client/node_modules/vue/dist/vue.d.ts +0 -4
  149. package/dist/client/node_modules/vue/jsx-runtime/index.d.ts +2 -1
  150. package/dist/client/node_modules/vue/jsx.d.ts +2 -1
  151. package/dist/client/node_modules/vue/package.json +13 -14
  152. package/dist/client/node_modules/{pinia/node_modules/vue-demi → vue-demi}/package.json +1 -1
  153. package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +410 -81
  154. package/dist/client/node_modules/vue-router/package.json +66 -37
  155. package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.ts +4 -0
  156. package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +4 -0
  157. package/dist/client/vue.runtime.esm-bundler.js +6458 -4714
  158. package/floating-vue.d.ts +1 -0
  159. package/iconify.d.ts +1 -0
  160. package/package.json +20 -20
  161. package/pinia.d.ts +1 -0
  162. package/rollup.config.mjs +11 -9
  163. package/scroll.d.ts +1 -0
  164. package/src/client/b-floating-vue.ts +2 -0
  165. package/src/client/b-scroll.ts +2 -0
  166. package/tsconfig.json +17 -17
  167. package/vue-router.d.ts +1 -0
  168. package/vue-use.d.ts +1 -0
  169. package/vue.d.ts +1 -0
  170. package/dist/client/index2.js +0 -168
  171. package/dist/client/node_modules/@floating-ui/core/index.d.ts +0 -1
  172. package/dist/client/node_modules/@floating-ui/core/src/_babel.d.ts +0 -1
  173. package/dist/client/node_modules/@floating-ui/core/src/computeCoordsFromPlacement.d.ts +0 -4
  174. package/dist/client/node_modules/@floating-ui/core/src/computePosition.d.ts +0 -2
  175. package/dist/client/node_modules/@floating-ui/core/src/detectOverflow.d.ts +0 -9
  176. package/dist/client/node_modules/@floating-ui/core/src/enums.d.ts +0 -4
  177. package/dist/client/node_modules/@floating-ui/core/src/index.d.ts +0 -11
  178. package/dist/client/node_modules/@floating-ui/core/src/middleware/arrow.d.ts +0 -6
  179. package/dist/client/node_modules/@floating-ui/core/src/middleware/autoPlacement.d.ts +0 -9
  180. package/dist/client/node_modules/@floating-ui/core/src/middleware/flip.d.ts +0 -10
  181. package/dist/client/node_modules/@floating-ui/core/src/middleware/hide.d.ts +0 -2
  182. package/dist/client/node_modules/@floating-ui/core/src/middleware/inline.d.ts +0 -5
  183. package/dist/client/node_modules/@floating-ui/core/src/middleware/offset.d.ts +0 -21
  184. package/dist/client/node_modules/@floating-ui/core/src/middleware/shift.d.ts +0 -32
  185. package/dist/client/node_modules/@floating-ui/core/src/middleware/size.d.ts +0 -6
  186. package/dist/client/node_modules/@floating-ui/core/src/types.d.ts +0 -148
  187. package/dist/client/node_modules/@floating-ui/core/src/utils/expandPaddingObject.d.ts +0 -2
  188. package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignment.d.ts +0 -2
  189. package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignmentSides.d.ts +0 -5
  190. package/dist/client/node_modules/@floating-ui/core/src/utils/getBasePlacement.d.ts +0 -2
  191. package/dist/client/node_modules/@floating-ui/core/src/utils/getCrossAxis.d.ts +0 -2
  192. package/dist/client/node_modules/@floating-ui/core/src/utils/getExpandedPlacements.d.ts +0 -2
  193. package/dist/client/node_modules/@floating-ui/core/src/utils/getLengthFromAxis.d.ts +0 -2
  194. package/dist/client/node_modules/@floating-ui/core/src/utils/getMainAxisFromPlacement.d.ts +0 -2
  195. package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositeAlignmentPlacement.d.ts +0 -2
  196. package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositePlacement.d.ts +0 -1
  197. package/dist/client/node_modules/@floating-ui/core/src/utils/getPaddingObject.d.ts +0 -2
  198. package/dist/client/node_modules/@floating-ui/core/src/utils/math.d.ts +0 -2
  199. package/dist/client/node_modules/@floating-ui/core/src/utils/rectToClientRect.d.ts +0 -2
  200. package/dist/client/node_modules/@floating-ui/core/src/utils/within.d.ts +0 -1
  201. package/dist/client/node_modules/@floating-ui/dom/src/utils/contains.d.ts +0 -1
  202. package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingClientRect.d.ts +0 -6
  203. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParent.d.ts +0 -1
  204. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParents.d.ts +0 -1
  205. package/dist/client/node_modules/@vue/reactivity-transform/dist/reactivity-transform.d.ts +0 -43
  206. package/dist/client/node_modules/@vue/reactivity-transform/package.json +0 -41
  207. package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/package.json +0 -47
  208. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/index.d.ts +0 -22
  209. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
  210. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
  211. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
  212. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/package.json +0 -47
  213. package/dist/client/node_modules/compute-scroll-into-view/typings/index.d.ts +0 -19
  214. package/dist/client/node_modules/floating-vue/dist/components/Dropdown.vue.d.ts +0 -25
  215. package/dist/client/node_modules/floating-vue/dist/components/Menu.vue.d.ts +0 -25
  216. package/dist/client/node_modules/floating-vue/dist/components/Tooltip.vue.d.ts +0 -25
  217. package/dist/client/node_modules/floating-vue/src/global-shim.d.ts +0 -1
  218. package/dist/client/node_modules/floating-vue/src/vue-shim.d.ts +0 -5
  219. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +0 -22
  220. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
  221. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
  222. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
  223. package/dist/client/node_modules/scroll-into-view-if-needed/typings/index.d.ts +0 -13
  224. package/dist/client/node_modules/scroll-into-view-if-needed/typings/types.d.ts +0 -19
  225. package/dist/client/node_modules/vue/macros-global.d.ts +0 -19
  226. package/dist/client/node_modules/vue/macros.d.ts +0 -112
  227. package/dist/client/node_modules/vue/ref-macros.d.ts +0 -2
  228. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/index.d.ts +0 -0
  229. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v2/index.d.ts +0 -0
  230. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v2.7/index.d.ts +0 -0
  231. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v3/index.d.ts +0 -0
@@ -1,16 +1,32 @@
1
- import { P as onUnmounted, Q as onDeactivated, R as onActivated, O as getCurrentInstance, z as inject, B as unref, L as computed, S as watchEffect, M as reactive, v as h, d as defineComponent, T as provide, u as ref, C as watch, U as shallowRef, b as nextTick, V as shallowReactive } from './vue.runtime.esm-bundler.js';
2
- import { s as setupDevtoolsPlugin } from './index2.js';
1
+ import { P as onUnmounted, Q as onDeactivated, R as onActivated, O as getCurrentInstance, z as inject, L as computed, C as unref, S as watchEffect, d as defineComponent, M as reactive, x as h, T as provide, u as ref, B as watch, U as shallowRef, b as nextTick, V as shallowReactive } from './vue.runtime.esm-bundler.js';
2
+ import { s as setupDevtoolsPlugin } from './index.js';
3
3
 
4
4
  /*!
5
- * vue-router v4.2.5
6
- * (c) 2023 Eduardo San Martin Morote
5
+ * vue-router v4.5.0
6
+ * (c) 2024 Eduardo San Martin Morote
7
7
  * @license MIT
8
8
  */
9
9
 
10
- const isBrowser = typeof window !== 'undefined';
10
+ const isBrowser = typeof document !== 'undefined';
11
11
 
12
+ /**
13
+ * Allows differentiating lazy components from functional components and vue-class-component
14
+ * @internal
15
+ *
16
+ * @param component
17
+ */
18
+ function isRouteComponent(component) {
19
+ return (typeof component === 'object' ||
20
+ 'displayName' in component ||
21
+ 'props' in component ||
22
+ '__vccOpts' in component);
23
+ }
12
24
  function isESModule(obj) {
13
- return obj.__esModule || obj[Symbol.toStringTag] === 'Module';
25
+ return (obj.__esModule ||
26
+ obj[Symbol.toStringTag] === 'Module' ||
27
+ // support CF with dynamic imports that do not
28
+ // add the Module string tag
29
+ (obj.default && isRouteComponent(obj.default)));
14
30
  }
15
31
  const assign = Object.assign;
16
32
  function applyToParams(fn, params) {
@@ -36,6 +52,144 @@ function warn(msg) {
36
52
  console.warn.apply(console, ['[Vue Router warn]: ' + msg].concat(args));
37
53
  }
38
54
 
55
+ /**
56
+ * Encoding Rules (␣ = Space)
57
+ * - Path: ␣ " < > # ? { }
58
+ * - Query: ␣ " < > # & =
59
+ * - Hash: ␣ " < > `
60
+ *
61
+ * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
62
+ * defines some extra characters to be encoded. Most browsers do not encode them
63
+ * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
64
+ * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
65
+ * plus `-._~`. This extra safety should be applied to query by patching the
66
+ * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
67
+ * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
68
+ * into a `/` if directly typed in. The _backtick_ (`````) should also be
69
+ * encoded everywhere because some browsers like FF encode it when directly
70
+ * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
71
+ */
72
+ // const EXTRA_RESERVED_RE = /[!'()*]/g
73
+ // const encodeReservedReplacer = (c: string) => '%' + c.charCodeAt(0).toString(16)
74
+ const HASH_RE = /#/g; // %23
75
+ const AMPERSAND_RE = /&/g; // %26
76
+ const SLASH_RE = /\//g; // %2F
77
+ const EQUAL_RE = /=/g; // %3D
78
+ const IM_RE = /\?/g; // %3F
79
+ const PLUS_RE = /\+/g; // %2B
80
+ /**
81
+ * NOTE: It's not clear to me if we should encode the + symbol in queries, it
82
+ * seems to be less flexible than not doing so and I can't find out the legacy
83
+ * systems requiring this for regular requests like text/html. In the standard,
84
+ * the encoding of the plus character is only mentioned for
85
+ * application/x-www-form-urlencoded
86
+ * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
87
+ * leave the plus character as is in queries. To be more flexible, we allow the
88
+ * plus character on the query, but it can also be manually encoded by the user.
89
+ *
90
+ * Resources:
91
+ * - https://url.spec.whatwg.org/#urlencoded-parsing
92
+ * - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
93
+ */
94
+ const ENC_BRACKET_OPEN_RE = /%5B/g; // [
95
+ const ENC_BRACKET_CLOSE_RE = /%5D/g; // ]
96
+ const ENC_CARET_RE = /%5E/g; // ^
97
+ const ENC_BACKTICK_RE = /%60/g; // `
98
+ const ENC_CURLY_OPEN_RE = /%7B/g; // {
99
+ const ENC_PIPE_RE = /%7C/g; // |
100
+ const ENC_CURLY_CLOSE_RE = /%7D/g; // }
101
+ const ENC_SPACE_RE = /%20/g; // }
102
+ /**
103
+ * Encode characters that need to be encoded on the path, search and hash
104
+ * sections of the URL.
105
+ *
106
+ * @internal
107
+ * @param text - string to encode
108
+ * @returns encoded string
109
+ */
110
+ function commonEncode(text) {
111
+ return encodeURI('' + text)
112
+ .replace(ENC_PIPE_RE, '|')
113
+ .replace(ENC_BRACKET_OPEN_RE, '[')
114
+ .replace(ENC_BRACKET_CLOSE_RE, ']');
115
+ }
116
+ /**
117
+ * Encode characters that need to be encoded on the hash section of the URL.
118
+ *
119
+ * @param text - string to encode
120
+ * @returns encoded string
121
+ */
122
+ function encodeHash(text) {
123
+ return commonEncode(text)
124
+ .replace(ENC_CURLY_OPEN_RE, '{')
125
+ .replace(ENC_CURLY_CLOSE_RE, '}')
126
+ .replace(ENC_CARET_RE, '^');
127
+ }
128
+ /**
129
+ * Encode characters that need to be encoded query values on the query
130
+ * section of the URL.
131
+ *
132
+ * @param text - string to encode
133
+ * @returns encoded string
134
+ */
135
+ function encodeQueryValue(text) {
136
+ return (commonEncode(text)
137
+ // Encode the space as +, encode the + to differentiate it from the space
138
+ .replace(PLUS_RE, '%2B')
139
+ .replace(ENC_SPACE_RE, '+')
140
+ .replace(HASH_RE, '%23')
141
+ .replace(AMPERSAND_RE, '%26')
142
+ .replace(ENC_BACKTICK_RE, '`')
143
+ .replace(ENC_CURLY_OPEN_RE, '{')
144
+ .replace(ENC_CURLY_CLOSE_RE, '}')
145
+ .replace(ENC_CARET_RE, '^'));
146
+ }
147
+ /**
148
+ * Like `encodeQueryValue` but also encodes the `=` character.
149
+ *
150
+ * @param text - string to encode
151
+ */
152
+ function encodeQueryKey(text) {
153
+ return encodeQueryValue(text).replace(EQUAL_RE, '%3D');
154
+ }
155
+ /**
156
+ * Encode characters that need to be encoded on the path section of the URL.
157
+ *
158
+ * @param text - string to encode
159
+ * @returns encoded string
160
+ */
161
+ function encodePath(text) {
162
+ return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F');
163
+ }
164
+ /**
165
+ * Encode characters that need to be encoded on the path section of the URL as a
166
+ * param. This function encodes everything {@link encodePath} does plus the
167
+ * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
168
+ * string instead.
169
+ *
170
+ * @param text - string to encode
171
+ * @returns encoded string
172
+ */
173
+ function encodeParam(text) {
174
+ return text == null ? '' : encodePath(text).replace(SLASH_RE, '%2F');
175
+ }
176
+ /**
177
+ * Decode text using `decodeURIComponent`. Returns the original text if it
178
+ * fails.
179
+ *
180
+ * @param text - string to decode
181
+ * @returns decoded string
182
+ */
183
+ function decode(text) {
184
+ try {
185
+ return decodeURIComponent('' + text);
186
+ }
187
+ catch (err) {
188
+ (process.env.NODE_ENV !== 'production') && warn(`Error decoding "${text}". Using original value`);
189
+ }
190
+ return '' + text;
191
+ }
192
+
39
193
  const TRAILING_SLASH_RE = /\/$/;
40
194
  const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, '');
41
195
  /**
@@ -74,7 +228,7 @@ function parseURL(parseQuery, location, currentLocation = '/') {
74
228
  fullPath: path + (searchString && '?') + searchString + hash,
75
229
  path,
76
230
  query,
77
- hash,
231
+ hash: decode(hash),
78
232
  };
79
233
  }
80
234
  /**
@@ -203,11 +357,35 @@ function resolveRelativePath(to, from) {
203
357
  }
204
358
  return (fromSegments.slice(0, position).join('/') +
205
359
  '/' +
206
- toSegments
207
- // ensure we use at least the last element in the toSegments
208
- .slice(toPosition - (toPosition === toSegments.length ? 1 : 0))
209
- .join('/'));
360
+ toSegments.slice(toPosition).join('/'));
210
361
  }
362
+ /**
363
+ * Initial route location where the router is. Can be used in navigation guards
364
+ * to differentiate the initial navigation.
365
+ *
366
+ * @example
367
+ * ```js
368
+ * import { START_LOCATION } from 'vue-router'
369
+ *
370
+ * router.beforeEach((to, from) => {
371
+ * if (from === START_LOCATION) {
372
+ * // initial navigation
373
+ * }
374
+ * })
375
+ * ```
376
+ */
377
+ const START_LOCATION_NORMALIZED = {
378
+ path: '/',
379
+ // TODO: could we use a symbol in the future?
380
+ name: undefined,
381
+ params: {},
382
+ query: {},
383
+ hash: '',
384
+ fullPath: '/',
385
+ matched: [],
386
+ meta: {},
387
+ redirectedFrom: undefined,
388
+ };
211
389
 
212
390
  var NavigationType;
213
391
  (function (NavigationType) {
@@ -269,8 +447,8 @@ function getElementPosition(el, offset) {
269
447
  };
270
448
  }
271
449
  const computeScrollPosition = () => ({
272
- left: window.pageXOffset,
273
- top: window.pageYOffset,
450
+ left: window.scrollX,
451
+ top: window.scrollY,
274
452
  });
275
453
  function scrollToPosition(position) {
276
454
  let scrollToOptions;
@@ -333,7 +511,7 @@ function scrollToPosition(position) {
333
511
  if ('scrollBehavior' in document.documentElement.style)
334
512
  window.scrollTo(scrollToOptions);
335
513
  else {
336
- window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset, scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset);
514
+ window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
337
515
  }
338
516
  }
339
517
  function getScrollKey(path, delta) {
@@ -558,7 +736,7 @@ function useHistoryStateNavigation(base) {
558
736
  if ((process.env.NODE_ENV !== 'production') && !history.state) {
559
737
  warn(`history.state seems to have been manually replaced without preserving the necessary values. Make sure to preserve existing history state if you are manually calling history.replaceState:\n\n` +
560
738
  `history.replaceState(history.state, '', url)\n\n` +
561
- `You can find more information at https://next.router.vuejs.org/guide/migration/#usage-of-history-state.`);
739
+ `You can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state`);
562
740
  }
563
741
  changeLocation(currentState.current, currentState, true);
564
742
  const state = assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data);
@@ -730,33 +908,6 @@ function isRouteName(name) {
730
908
  return typeof name === 'string' || typeof name === 'symbol';
731
909
  }
732
910
 
733
- /**
734
- * Initial route location where the router is. Can be used in navigation guards
735
- * to differentiate the initial navigation.
736
- *
737
- * @example
738
- * ```js
739
- * import { START_LOCATION } from 'vue-router'
740
- *
741
- * router.beforeEach((to, from) => {
742
- * if (from === START_LOCATION) {
743
- * // initial navigation
744
- * }
745
- * })
746
- * ```
747
- */
748
- const START_LOCATION_NORMALIZED = {
749
- path: '/',
750
- name: undefined,
751
- params: {},
752
- query: {},
753
- hash: '',
754
- fullPath: '/',
755
- matched: [],
756
- meta: {},
757
- redirectedFrom: undefined,
758
- };
759
-
760
911
  const NavigationFailureSymbol = Symbol((process.env.NODE_ENV !== 'production') ? 'navigation failure' : '');
761
912
  /**
762
913
  * Enumeration with all possible types for navigation failures. Can be passed to
@@ -800,6 +951,12 @@ const ErrorTypeMessages = {
800
951
  return `Avoided redundant navigation to current location: "${from.fullPath}".`;
801
952
  },
802
953
  };
954
+ /**
955
+ * Creates a typed NavigationFailure object.
956
+ * @internal
957
+ * @param type - NavigationFailureType
958
+ * @param params - { from, to }
959
+ */
803
960
  function createRouterError(type, params) {
804
961
  // keep full error messages in cjs versions
805
962
  if ((process.env.NODE_ENV !== 'production') || !true) {
@@ -824,7 +981,7 @@ const propertiesToLog = ['params', 'query', 'hash'];
824
981
  function stringifyRoute(to) {
825
982
  if (typeof to === 'string')
826
983
  return to;
827
- if ('path' in to)
984
+ if (to.path != null)
828
985
  return to.path;
829
986
  const location = {};
830
987
  for (const key of propertiesToLog) {
@@ -935,7 +1092,7 @@ function tokensToParser(segments, extraOptions) {
935
1092
  if (options.end)
936
1093
  pattern += '$';
937
1094
  // allow paths like /dynamic to only match dynamic or dynamic/... but not dynamic_something_else
938
- else if (options.strict)
1095
+ else if (options.strict && !pattern.endsWith('/'))
939
1096
  pattern += '(?:/|$)';
940
1097
  const re = new RegExp(pattern, options.sensitive ? '' : 'i');
941
1098
  function parse(path) {
@@ -1283,13 +1440,14 @@ function createRouterMatcher(routes, globalOptions) {
1283
1440
  mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
1284
1441
  const options = mergeOptions(globalOptions, record);
1285
1442
  // generate an array of records to correctly handle aliases
1286
- const normalizedRecords = [
1287
- mainNormalizedRecord,
1288
- ];
1443
+ const normalizedRecords = [mainNormalizedRecord];
1289
1444
  if ('alias' in record) {
1290
1445
  const aliases = typeof record.alias === 'string' ? [record.alias] : record.alias;
1291
1446
  for (const alias of aliases) {
1292
- normalizedRecords.push(assign({}, mainNormalizedRecord, {
1447
+ normalizedRecords.push(
1448
+ // we need to normalize again to ensure the `mods` property
1449
+ // being non enumerable
1450
+ normalizeRouteRecord(assign({}, mainNormalizedRecord, {
1293
1451
  // this allows us to hold a copy of the `components` option
1294
1452
  // so that async components cache is hold on the original record
1295
1453
  components: originalRecord
@@ -1302,7 +1460,7 @@ function createRouterMatcher(routes, globalOptions) {
1302
1460
  : mainNormalizedRecord,
1303
1461
  // the aliases are always of the same kind as the original since they
1304
1462
  // are defined on the same record
1305
- }));
1463
+ })));
1306
1464
  }
1307
1465
  }
1308
1466
  let matcher;
@@ -1320,7 +1478,7 @@ function createRouterMatcher(routes, globalOptions) {
1320
1478
  }
1321
1479
  if ((process.env.NODE_ENV !== 'production') && normalizedRecord.path === '*') {
1322
1480
  throw new Error('Catch all routes ("*") must now be defined using a param with a custom regexp.\n' +
1323
- 'See more at https://next.router.vuejs.org/guide/migration/#removed-star-or-catch-all-routes.');
1481
+ 'See more at https://router.vuejs.org/guide/migration/#Removed-star-or-catch-all-routes.');
1324
1482
  }
1325
1483
  // create the object beforehand, so it can be passed to children
1326
1484
  matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
@@ -1341,8 +1499,17 @@ function createRouterMatcher(routes, globalOptions) {
1341
1499
  originalMatcher.alias.push(matcher);
1342
1500
  // remove the route if named and only for the top record (avoid in nested calls)
1343
1501
  // this works because the original record is the first one
1344
- if (isRootAdd && record.name && !isAliasRecord(matcher))
1502
+ if (isRootAdd && record.name && !isAliasRecord(matcher)) {
1503
+ if ((process.env.NODE_ENV !== 'production')) {
1504
+ checkSameNameAsAncestor(record, parent);
1505
+ }
1345
1506
  removeRoute(record.name);
1507
+ }
1508
+ }
1509
+ // Avoid adding a record that doesn't display anything. This allows passing through records without a component to
1510
+ // not be reached and pass through the catch all route
1511
+ if (isMatchable(matcher)) {
1512
+ insertMatcher(matcher);
1346
1513
  }
1347
1514
  if (mainNormalizedRecord.children) {
1348
1515
  const children = mainNormalizedRecord.children;
@@ -1357,14 +1524,6 @@ function createRouterMatcher(routes, globalOptions) {
1357
1524
  // if (parent && isAliasRecord(originalRecord)) {
1358
1525
  // parent.children.push(originalRecord)
1359
1526
  // }
1360
- // Avoid adding a record that doesn't display anything. This allows passing through records without a component to
1361
- // not be reached and pass through the catch all route
1362
- if ((matcher.record.components &&
1363
- Object.keys(matcher.record.components).length) ||
1364
- matcher.record.name ||
1365
- matcher.record.redirect) {
1366
- insertMatcher(matcher);
1367
- }
1368
1527
  }
1369
1528
  return originalMatcher
1370
1529
  ? () => {
@@ -1398,15 +1557,8 @@ function createRouterMatcher(routes, globalOptions) {
1398
1557
  return matchers;
1399
1558
  }
1400
1559
  function insertMatcher(matcher) {
1401
- let i = 0;
1402
- while (i < matchers.length &&
1403
- comparePathParserScore(matcher, matchers[i]) >= 0 &&
1404
- // Adding children with empty path should still appear before the parent
1405
- // https://github.com/vuejs/router/issues/1124
1406
- (matcher.record.path !== matchers[i].record.path ||
1407
- !isRecordChildOf(matcher, matchers[i])))
1408
- i++;
1409
- matchers.splice(i, 0, matcher);
1560
+ const index = findInsertionIndex(matcher, matchers);
1561
+ matchers.splice(index, 0, matcher);
1410
1562
  // only add the original record to the name map
1411
1563
  if (matcher.record.name && !isAliasRecord(matcher))
1412
1564
  matcherMap.set(matcher.record.name, matcher);
@@ -1434,8 +1586,11 @@ function createRouterMatcher(routes, globalOptions) {
1434
1586
  // paramsFromLocation is a new object
1435
1587
  paramsFromLocation(currentLocation.params,
1436
1588
  // only keep params that exist in the resolved location
1437
- // TODO: only keep optional params coming from a parent record
1438
- matcher.keys.filter(k => !k.optional).map(k => k.name)),
1589
+ // only keep optional params coming from a parent record
1590
+ matcher.keys
1591
+ .filter(k => !k.optional)
1592
+ .concat(matcher.parent ? matcher.parent.keys.filter(k => k.optional) : [])
1593
+ .map(k => k.name)),
1439
1594
  // discard any existing params in the current location that do not exist here
1440
1595
  // #1497 this ensures better active/exact matching
1441
1596
  location.params &&
@@ -1443,7 +1598,7 @@ function createRouterMatcher(routes, globalOptions) {
1443
1598
  // throws if cannot be stringified
1444
1599
  path = matcher.stringify(params);
1445
1600
  }
1446
- else if ('path' in location) {
1601
+ else if (location.path != null) {
1447
1602
  // no need to resolve the path with the matcher as it was provided
1448
1603
  // this also allows the user to control the encoding
1449
1604
  path = location.path;
@@ -1492,7 +1647,18 @@ function createRouterMatcher(routes, globalOptions) {
1492
1647
  }
1493
1648
  // add initial routes
1494
1649
  routes.forEach(route => addRoute(route));
1495
- return { addRoute, resolve, removeRoute, getRoutes, getRecordMatcher };
1650
+ function clearRoutes() {
1651
+ matchers.length = 0;
1652
+ matcherMap.clear();
1653
+ }
1654
+ return {
1655
+ addRoute,
1656
+ resolve,
1657
+ removeRoute,
1658
+ clearRoutes,
1659
+ getRoutes,
1660
+ getRecordMatcher,
1661
+ };
1496
1662
  }
1497
1663
  function paramsFromLocation(params, keys) {
1498
1664
  const newParams = {};
@@ -1509,12 +1675,12 @@ function paramsFromLocation(params, keys) {
1509
1675
  * @returns the normalized version
1510
1676
  */
1511
1677
  function normalizeRouteRecord(record) {
1512
- return {
1678
+ const normalized = {
1513
1679
  path: record.path,
1514
1680
  redirect: record.redirect,
1515
1681
  name: record.name,
1516
1682
  meta: record.meta || {},
1517
- aliasOf: undefined,
1683
+ aliasOf: record.aliasOf,
1518
1684
  beforeEnter: record.beforeEnter,
1519
1685
  props: normalizeRecordProps(record),
1520
1686
  children: record.children || [],
@@ -1522,10 +1688,19 @@ function normalizeRouteRecord(record) {
1522
1688
  leaveGuards: new Set(),
1523
1689
  updateGuards: new Set(),
1524
1690
  enterCallbacks: {},
1691
+ // must be declared afterwards
1692
+ // mods: {},
1525
1693
  components: 'components' in record
1526
1694
  ? record.components || null
1527
1695
  : record.component && { default: record.component },
1528
1696
  };
1697
+ // mods contain modules and shouldn't be copied,
1698
+ // logged or anything. It's just used for internal
1699
+ // advanced use cases like data loaders
1700
+ Object.defineProperty(normalized, 'mods', {
1701
+ value: {},
1702
+ });
1703
+ return normalized;
1529
1704
  }
1530
1705
  /**
1531
1706
  * Normalize the optional `props` in a record to always be an object similar to
@@ -1609,150 +1784,74 @@ function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
1609
1784
  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.`);
1610
1785
  }
1611
1786
  }
1787
+ function checkSameNameAsAncestor(record, parent) {
1788
+ for (let ancestor = parent; ancestor; ancestor = ancestor.parent) {
1789
+ if (ancestor.record.name === record.name) {
1790
+ throw new Error(`A route named "${String(record.name)}" has been added as a ${parent === ancestor ? 'child' : 'descendant'} of a route with the same name. Route names must be unique and a nested route cannot use the same name as an ancestor.`);
1791
+ }
1792
+ }
1793
+ }
1612
1794
  function checkMissingParamsInAbsolutePath(record, parent) {
1613
1795
  for (const key of parent.keys) {
1614
1796
  if (!record.keys.find(isSameParam.bind(null, key)))
1615
1797
  return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
1616
1798
  }
1617
1799
  }
1618
- function isRecordChildOf(record, parent) {
1619
- return parent.children.some(child => child === record || isRecordChildOf(record, child));
1620
- }
1621
-
1622
- /**
1623
- * Encoding Rules ␣ = Space Path: ␣ " < > # ? { } Query: ␣ " < > # & = Hash: ␣ "
1624
- * < > `
1625
- *
1626
- * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
1627
- * defines some extra characters to be encoded. Most browsers do not encode them
1628
- * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
1629
- * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
1630
- * plus `-._~`. This extra safety should be applied to query by patching the
1631
- * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
1632
- * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
1633
- * into a `/` if directly typed in. The _backtick_ (`````) should also be
1634
- * encoded everywhere because some browsers like FF encode it when directly
1635
- * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
1636
- */
1637
- // const EXTRA_RESERVED_RE = /[!'()*]/g
1638
- // const encodeReservedReplacer = (c: string) => '%' + c.charCodeAt(0).toString(16)
1639
- const HASH_RE = /#/g; // %23
1640
- const AMPERSAND_RE = /&/g; // %26
1641
- const SLASH_RE = /\//g; // %2F
1642
- const EQUAL_RE = /=/g; // %3D
1643
- const IM_RE = /\?/g; // %3F
1644
- const PLUS_RE = /\+/g; // %2B
1645
- /**
1646
- * NOTE: It's not clear to me if we should encode the + symbol in queries, it
1647
- * seems to be less flexible than not doing so and I can't find out the legacy
1648
- * systems requiring this for regular requests like text/html. In the standard,
1649
- * the encoding of the plus character is only mentioned for
1650
- * application/x-www-form-urlencoded
1651
- * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
1652
- * leave the plus character as is in queries. To be more flexible, we allow the
1653
- * plus character on the query, but it can also be manually encoded by the user.
1654
- *
1655
- * Resources:
1656
- * - https://url.spec.whatwg.org/#urlencoded-parsing
1657
- * - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
1658
- */
1659
- const ENC_BRACKET_OPEN_RE = /%5B/g; // [
1660
- const ENC_BRACKET_CLOSE_RE = /%5D/g; // ]
1661
- const ENC_CARET_RE = /%5E/g; // ^
1662
- const ENC_BACKTICK_RE = /%60/g; // `
1663
- const ENC_CURLY_OPEN_RE = /%7B/g; // {
1664
- const ENC_PIPE_RE = /%7C/g; // |
1665
- const ENC_CURLY_CLOSE_RE = /%7D/g; // }
1666
- const ENC_SPACE_RE = /%20/g; // }
1667
- /**
1668
- * Encode characters that need to be encoded on the path, search and hash
1669
- * sections of the URL.
1670
- *
1671
- * @internal
1672
- * @param text - string to encode
1673
- * @returns encoded string
1674
- */
1675
- function commonEncode(text) {
1676
- return encodeURI('' + text)
1677
- .replace(ENC_PIPE_RE, '|')
1678
- .replace(ENC_BRACKET_OPEN_RE, '[')
1679
- .replace(ENC_BRACKET_CLOSE_RE, ']');
1680
- }
1681
- /**
1682
- * Encode characters that need to be encoded on the hash section of the URL.
1683
- *
1684
- * @param text - string to encode
1685
- * @returns encoded string
1686
- */
1687
- function encodeHash(text) {
1688
- return commonEncode(text)
1689
- .replace(ENC_CURLY_OPEN_RE, '{')
1690
- .replace(ENC_CURLY_CLOSE_RE, '}')
1691
- .replace(ENC_CARET_RE, '^');
1692
- }
1693
- /**
1694
- * Encode characters that need to be encoded query values on the query
1695
- * section of the URL.
1696
- *
1697
- * @param text - string to encode
1698
- * @returns encoded string
1699
- */
1700
- function encodeQueryValue(text) {
1701
- return (commonEncode(text)
1702
- // Encode the space as +, encode the + to differentiate it from the space
1703
- .replace(PLUS_RE, '%2B')
1704
- .replace(ENC_SPACE_RE, '+')
1705
- .replace(HASH_RE, '%23')
1706
- .replace(AMPERSAND_RE, '%26')
1707
- .replace(ENC_BACKTICK_RE, '`')
1708
- .replace(ENC_CURLY_OPEN_RE, '{')
1709
- .replace(ENC_CURLY_CLOSE_RE, '}')
1710
- .replace(ENC_CARET_RE, '^'));
1711
- }
1712
1800
  /**
1713
- * Like `encodeQueryValue` but also encodes the `=` character.
1801
+ * Performs a binary search to find the correct insertion index for a new matcher.
1714
1802
  *
1715
- * @param text - string to encode
1716
- */
1717
- function encodeQueryKey(text) {
1718
- return encodeQueryValue(text).replace(EQUAL_RE, '%3D');
1719
- }
1720
- /**
1721
- * Encode characters that need to be encoded on the path section of the URL.
1803
+ * Matchers are primarily sorted by their score. If scores are tied then we also consider parent/child relationships,
1804
+ * with descendants coming before ancestors. If there's still a tie, new routes are inserted after existing routes.
1722
1805
  *
1723
- * @param text - string to encode
1724
- * @returns encoded string
1806
+ * @param matcher - new matcher to be inserted
1807
+ * @param matchers - existing matchers
1725
1808
  */
1726
- function encodePath(text) {
1727
- return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F');
1809
+ function findInsertionIndex(matcher, matchers) {
1810
+ // First phase: binary search based on score
1811
+ let lower = 0;
1812
+ let upper = matchers.length;
1813
+ while (lower !== upper) {
1814
+ const mid = (lower + upper) >> 1;
1815
+ const sortOrder = comparePathParserScore(matcher, matchers[mid]);
1816
+ if (sortOrder < 0) {
1817
+ upper = mid;
1818
+ }
1819
+ else {
1820
+ lower = mid + 1;
1821
+ }
1822
+ }
1823
+ // Second phase: check for an ancestor with the same score
1824
+ const insertionAncestor = getInsertionAncestor(matcher);
1825
+ if (insertionAncestor) {
1826
+ upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
1827
+ if ((process.env.NODE_ENV !== 'production') && upper < 0) {
1828
+ // This should never happen
1829
+ warn(`Finding ancestor route "${insertionAncestor.record.path}" failed for "${matcher.record.path}"`);
1830
+ }
1831
+ }
1832
+ return upper;
1728
1833
  }
1729
- /**
1730
- * Encode characters that need to be encoded on the path section of the URL as a
1731
- * param. This function encodes everything {@link encodePath} does plus the
1732
- * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
1733
- * string instead.
1734
- *
1735
- * @param text - string to encode
1736
- * @returns encoded string
1737
- */
1738
- function encodeParam(text) {
1739
- return text == null ? '' : encodePath(text).replace(SLASH_RE, '%2F');
1834
+ function getInsertionAncestor(matcher) {
1835
+ let ancestor = matcher;
1836
+ while ((ancestor = ancestor.parent)) {
1837
+ if (isMatchable(ancestor) &&
1838
+ comparePathParserScore(matcher, ancestor) === 0) {
1839
+ return ancestor;
1840
+ }
1841
+ }
1842
+ return;
1740
1843
  }
1741
1844
  /**
1742
- * Decode text using `decodeURIComponent`. Returns the original text if it
1743
- * fails.
1744
- *
1745
- * @param text - string to decode
1746
- * @returns decoded string
1845
+ * Checks if a matcher can be reachable. This means if it's possible to reach it as a route. For example, routes without
1846
+ * a component, or name, or redirect, are just used to group other routes.
1847
+ * @param matcher
1848
+ * @param matcher.record record of the matcher
1849
+ * @returns
1747
1850
  */
1748
- function decode(text) {
1749
- try {
1750
- return decodeURIComponent('' + text);
1751
- }
1752
- catch (err) {
1753
- (process.env.NODE_ENV !== 'production') && warn(`Error decoding "${text}". Using original value`);
1754
- }
1755
- return '' + text;
1851
+ function isMatchable({ record }) {
1852
+ return !!(record.name ||
1853
+ (record.components && Object.keys(record.components).length) ||
1854
+ record.redirect);
1756
1855
  }
1757
1856
 
1758
1857
  /**
@@ -1969,7 +2068,7 @@ function onBeforeRouteUpdate(updateGuard) {
1969
2068
  }
1970
2069
  registerGuard(activeRecord, 'updateGuards', updateGuard);
1971
2070
  }
1972
- function guardToPromiseFn(guard, to, from, record, name) {
2071
+ function guardToPromiseFn(guard, to, from, record, name, runWithContext = fn => fn()) {
1973
2072
  // keep a reference to the enterCallbackArray to prevent pushing callbacks if a new navigation took place
1974
2073
  const enterCallbackArray = record &&
1975
2074
  // name is defined if record is because of the function overload
@@ -2002,7 +2101,7 @@ function guardToPromiseFn(guard, to, from, record, name) {
2002
2101
  }
2003
2102
  };
2004
2103
  // wrapping with Promise.resolve allows it to work with both async and sync guards
2005
- const guardReturn = guard.call(record && record.instances[name], to, from, (process.env.NODE_ENV !== 'production') ? canOnlyBeCalledOnce(next, to, from) : next);
2104
+ const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, (process.env.NODE_ENV !== 'production') ? canOnlyBeCalledOnce(next, to, from) : next));
2006
2105
  let guardCall = Promise.resolve(guardReturn);
2007
2106
  if (guard.length < 3)
2008
2107
  guardCall = guardCall.then(next);
@@ -2041,7 +2140,7 @@ function canOnlyBeCalledOnce(next, to, from) {
2041
2140
  next.apply(null, arguments);
2042
2141
  };
2043
2142
  }
2044
- function extractComponentsGuards(matched, guardType, to, from) {
2143
+ function extractComponentsGuards(matched, guardType, to, from, runWithContext = fn => fn()) {
2045
2144
  const guards = [];
2046
2145
  for (const record of matched) {
2047
2146
  if ((process.env.NODE_ENV !== 'production') && !record.components && !record.children.length) {
@@ -2088,7 +2187,8 @@ function extractComponentsGuards(matched, guardType, to, from) {
2088
2187
  // __vccOpts is added by vue-class-component and contain the regular options
2089
2188
  const options = rawComponent.__vccOpts || rawComponent;
2090
2189
  const guard = options[guardType];
2091
- guard && guards.push(guardToPromiseFn(guard, to, from, record, name));
2190
+ guard &&
2191
+ guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
2092
2192
  }
2093
2193
  else {
2094
2194
  // start requesting the chunk already
@@ -2099,35 +2199,26 @@ function extractComponentsGuards(matched, guardType, to, from) {
2099
2199
  }
2100
2200
  guards.push(() => componentPromise.then(resolved => {
2101
2201
  if (!resolved)
2102
- return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}"`));
2202
+ throw new Error(`Couldn't resolve component "${name}" at "${record.path}"`);
2103
2203
  const resolvedComponent = isESModule(resolved)
2104
2204
  ? resolved.default
2105
2205
  : resolved;
2206
+ // keep the resolved module for plugins like data loaders
2207
+ record.mods[name] = resolved;
2106
2208
  // replace the function with the resolved component
2107
2209
  // cannot be null or undefined because we went into the for loop
2108
2210
  record.components[name] = resolvedComponent;
2109
2211
  // __vccOpts is added by vue-class-component and contain the regular options
2110
2212
  const options = resolvedComponent.__vccOpts || resolvedComponent;
2111
2213
  const guard = options[guardType];
2112
- return guard && guardToPromiseFn(guard, to, from, record, name)();
2214
+ return (guard &&
2215
+ guardToPromiseFn(guard, to, from, record, name, runWithContext)());
2113
2216
  }));
2114
2217
  }
2115
2218
  }
2116
2219
  }
2117
2220
  return guards;
2118
2221
  }
2119
- /**
2120
- * Allows differentiating lazy components from functional components and vue-class-component
2121
- * @internal
2122
- *
2123
- * @param component
2124
- */
2125
- function isRouteComponent(component) {
2126
- return (typeof component === 'object' ||
2127
- 'displayName' in component ||
2128
- 'props' in component ||
2129
- '__vccOpts' in component);
2130
- }
2131
2222
  /**
2132
2223
  * Ensures a route is loaded, so it can be passed as o prop to `<RouterView>`.
2133
2224
  *
@@ -2147,6 +2238,8 @@ function loadRouteLocation(route) {
2147
2238
  const resolvedComponent = isESModule(resolved)
2148
2239
  ? resolved.default
2149
2240
  : resolved;
2241
+ // keep the resolved module for plugins like data loaders
2242
+ record.mods[name] = resolved;
2150
2243
  // replace the function with the resolved component
2151
2244
  // cannot be null or undefined because we went into the for loop
2152
2245
  record.components[name] = resolvedComponent;
@@ -2159,10 +2252,32 @@ function loadRouteLocation(route) {
2159
2252
 
2160
2253
  // TODO: we could allow currentRoute as a prop to expose `isActive` and
2161
2254
  // `isExactActive` behavior should go through an RFC
2255
+ /**
2256
+ * Returns the internal behavior of a {@link RouterLink} without the rendering part.
2257
+ *
2258
+ * @param props - a `to` location and an optional `replace` flag
2259
+ */
2162
2260
  function useLink(props) {
2163
2261
  const router = inject(routerKey);
2164
2262
  const currentRoute = inject(routeLocationKey);
2165
- const route = computed(() => router.resolve(unref(props.to)));
2263
+ let hasPrevious = false;
2264
+ let previousTo = null;
2265
+ const route = computed(() => {
2266
+ const to = unref(props.to);
2267
+ if ((process.env.NODE_ENV !== 'production') && (!hasPrevious || to !== previousTo)) {
2268
+ if (!isRouteLocation(to)) {
2269
+ if (hasPrevious) {
2270
+ warn(`Invalid value for prop "to" in useLink()\n- to:`, to, `\n- previous to:`, previousTo, `\n- props:`, props);
2271
+ }
2272
+ else {
2273
+ warn(`Invalid value for prop "to" in useLink()\n- to:`, to, `\n- props:`, props);
2274
+ }
2275
+ }
2276
+ previousTo = to;
2277
+ hasPrevious = true;
2278
+ }
2279
+ return router.resolve(to);
2280
+ });
2166
2281
  const activeRecordIndex = computed(() => {
2167
2282
  const { matched } = route.value;
2168
2283
  const { length } = matched;
@@ -2194,9 +2309,15 @@ function useLink(props) {
2194
2309
  isSameRouteLocationParams(currentRoute.params, route.value.params));
2195
2310
  function navigate(e = {}) {
2196
2311
  if (guardEvent(e)) {
2197
- return router[unref(props.replace) ? 'replace' : 'push'](unref(props.to)
2312
+ const p = router[unref(props.replace) ? 'replace' : 'push'](unref(props.to)
2198
2313
  // avoid uncaught errors are they are logged anyway
2199
2314
  ).catch(noop);
2315
+ if (props.viewTransition &&
2316
+ typeof document !== 'undefined' &&
2317
+ 'startViewTransition' in document) {
2318
+ document.startViewTransition(() => p);
2319
+ }
2320
+ return p;
2200
2321
  }
2201
2322
  return Promise.resolve();
2202
2323
  }
@@ -2208,6 +2329,7 @@ function useLink(props) {
2208
2329
  route: route.value,
2209
2330
  isActive: isActive.value,
2210
2331
  isExactActive: isExactActive.value,
2332
+ error: null,
2211
2333
  };
2212
2334
  // @ts-expect-error: this is internal
2213
2335
  instance.__vrl_devtools = instance.__vrl_devtools || [];
@@ -2217,6 +2339,9 @@ function useLink(props) {
2217
2339
  linkContextDevtools.route = route.value;
2218
2340
  linkContextDevtools.isActive = isActive.value;
2219
2341
  linkContextDevtools.isExactActive = isExactActive.value;
2342
+ linkContextDevtools.error = isRouteLocation(unref(props.to))
2343
+ ? null
2344
+ : 'Invalid "to" value';
2220
2345
  }, { flush: 'post' });
2221
2346
  }
2222
2347
  }
@@ -2231,6 +2356,9 @@ function useLink(props) {
2231
2356
  navigate,
2232
2357
  };
2233
2358
  }
2359
+ function preferSingleVNode(vnodes) {
2360
+ return vnodes.length === 1 ? vnodes[0] : vnodes;
2361
+ }
2234
2362
  const RouterLinkImpl = /*#__PURE__*/ defineComponent({
2235
2363
  name: 'RouterLink',
2236
2364
  compatConfig: { MODE: 3 },
@@ -2263,7 +2391,7 @@ const RouterLinkImpl = /*#__PURE__*/ defineComponent({
2263
2391
  [getLinkClass(props.exactActiveClass, options.linkExactActiveClass, 'router-link-exact-active')]: link.isExactActive,
2264
2392
  }));
2265
2393
  return () => {
2266
- const children = slots.default && slots.default(link);
2394
+ const children = slots.default && preferSingleVNode(slots.default(link));
2267
2395
  return props.custom
2268
2396
  ? children
2269
2397
  : h('a', {
@@ -2577,9 +2705,16 @@ function addDevtools(app, router, matcher) {
2577
2705
  if (isArray(componentInstance.__vrl_devtools)) {
2578
2706
  componentInstance.__devtoolsApi = api;
2579
2707
  componentInstance.__vrl_devtools.forEach(devtoolsData => {
2708
+ let label = devtoolsData.route.path;
2580
2709
  let backgroundColor = ORANGE_400;
2581
2710
  let tooltip = '';
2582
- if (devtoolsData.isExactActive) {
2711
+ let textColor = 0;
2712
+ if (devtoolsData.error) {
2713
+ label = devtoolsData.error;
2714
+ backgroundColor = RED_100;
2715
+ textColor = RED_700;
2716
+ }
2717
+ else if (devtoolsData.isExactActive) {
2583
2718
  backgroundColor = LIME_500;
2584
2719
  tooltip = 'This is exactly active';
2585
2720
  }
@@ -2588,8 +2723,8 @@ function addDevtools(app, router, matcher) {
2588
2723
  tooltip = 'This link is active';
2589
2724
  }
2590
2725
  node.tags.push({
2591
- label: devtoolsData.route.path,
2592
- textColor: 0,
2726
+ label,
2727
+ textColor,
2593
2728
  tooltip,
2594
2729
  backgroundColor,
2595
2730
  });
@@ -2826,6 +2961,8 @@ const CYAN_400 = 0x22d3ee;
2826
2961
  const ORANGE_400 = 0xfb923c;
2827
2962
  // const GRAY_100 = 0xf4f4f5
2828
2963
  const DARK = 0x666666;
2964
+ const RED_100 = 0xfee2e2;
2965
+ const RED_700 = 0xb91c1c;
2829
2966
  function formatRouteRecordForInspector(route) {
2830
2967
  const tags = [];
2831
2968
  const { record } = route;
@@ -2959,7 +3096,7 @@ function createRouter(options) {
2959
3096
  const routerHistory = options.history;
2960
3097
  if ((process.env.NODE_ENV !== 'production') && !routerHistory)
2961
3098
  throw new Error('Provide the "history" option when calling "createRouter()":' +
2962
- ' https://next.router.vuejs.org/api/#history.');
3099
+ ' https://router.vuejs.org/api/interfaces/RouterOptions.html#history');
2963
3100
  const beforeGuards = useCallbacks();
2964
3101
  const beforeResolveGuards = useCallbacks();
2965
3102
  const afterGuards = useCallbacks();
@@ -2979,6 +3116,9 @@ function createRouter(options) {
2979
3116
  let record;
2980
3117
  if (isRouteName(parentOrRoute)) {
2981
3118
  parent = matcher.getRecordMatcher(parentOrRoute);
3119
+ if ((process.env.NODE_ENV !== 'production') && !parent) {
3120
+ warn(`Parent route "${String(parentOrRoute)}" not found when adding child route`, route);
3121
+ }
2982
3122
  record = route;
2983
3123
  }
2984
3124
  else {
@@ -3002,6 +3142,7 @@ function createRouter(options) {
3002
3142
  return !!matcher.getRecordMatcher(name);
3003
3143
  }
3004
3144
  function resolve(rawLocation, currentLocation) {
3145
+ // const resolve: Router['resolve'] = (rawLocation: RouteLocationRaw, currentLocation) => {
3005
3146
  // const objectLocation = routerLocationAsObject(rawLocation)
3006
3147
  // we create a copy to modify it later
3007
3148
  currentLocation = assign({}, currentLocation || currentRoute.value);
@@ -3024,9 +3165,13 @@ function createRouter(options) {
3024
3165
  href,
3025
3166
  });
3026
3167
  }
3168
+ if ((process.env.NODE_ENV !== 'production') && !isRouteLocation(rawLocation)) {
3169
+ warn(`router.resolve() was passed an invalid location. This will fail in production.\n- Location:`, rawLocation);
3170
+ return resolve({});
3171
+ }
3027
3172
  let matcherLocation;
3028
3173
  // path could be relative in object as well
3029
- if ('path' in rawLocation) {
3174
+ if (rawLocation.path != null) {
3030
3175
  if ((process.env.NODE_ENV !== 'production') &&
3031
3176
  'params' in rawLocation &&
3032
3177
  !('name' in rawLocation) &&
@@ -3072,7 +3217,7 @@ function createRouter(options) {
3072
3217
  warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
3073
3218
  }
3074
3219
  else if (!matchedRoute.matched.length) {
3075
- warn(`No match found for location with path "${'path' in rawLocation ? rawLocation.path : rawLocation}"`);
3220
+ warn(`No match found for location with path "${rawLocation.path != null ? rawLocation.path : rawLocation}"`);
3076
3221
  }
3077
3222
  }
3078
3223
  return assign({
@@ -3129,7 +3274,7 @@ function createRouter(options) {
3129
3274
  newTargetLocation.params = {};
3130
3275
  }
3131
3276
  if ((process.env.NODE_ENV !== 'production') &&
3132
- !('path' in newTargetLocation) &&
3277
+ newTargetLocation.path == null &&
3133
3278
  !('name' in newTargetLocation)) {
3134
3279
  warn(`Invalid redirect found:\n${JSON.stringify(newTargetLocation, null, 2)}\n when navigating to "${to.fullPath}". A redirect must contain a name or path. This will break in production.`);
3135
3280
  throw new Error('Invalid redirect');
@@ -3138,7 +3283,7 @@ function createRouter(options) {
3138
3283
  query: to.query,
3139
3284
  hash: to.hash,
3140
3285
  // avoid transferring params if the redirect has a path
3141
- params: 'path' in newTargetLocation ? {} : to.params,
3286
+ params: newTargetLocation.path != null ? {} : to.params,
3142
3287
  }, newTargetLocation);
3143
3288
  }
3144
3289
  }
@@ -3299,7 +3444,7 @@ function createRouter(options) {
3299
3444
  // clear existing enterCallbacks, these are added by extractComponentsGuards
3300
3445
  to.matched.forEach(record => (record.enterCallbacks = {}));
3301
3446
  // check in-component beforeRouteEnter
3302
- guards = extractComponentsGuards(enteringRecords, 'beforeRouteEnter', to, from);
3447
+ guards = extractComponentsGuards(enteringRecords, 'beforeRouteEnter', to, from, runWithContext);
3303
3448
  guards.push(canceledNavigationCheck);
3304
3449
  // run the queue of per route beforeEnter guards
3305
3450
  return runGuardQueue(guards);
@@ -3371,7 +3516,7 @@ function createRouter(options) {
3371
3516
  // there could be a redirect record in history
3372
3517
  const shouldRedirect = handleRedirectRecord(toLocation);
3373
3518
  if (shouldRedirect) {
3374
- pushWithRedirect(assign(shouldRedirect, { replace: true }), toLocation).catch(noop);
3519
+ pushWithRedirect(assign(shouldRedirect, { replace: true, force: true }), toLocation).catch(noop);
3375
3520
  return;
3376
3521
  }
3377
3522
  pendingLocation = toLocation;
@@ -3395,7 +3540,9 @@ function createRouter(options) {
3395
3540
  // navigation guard.
3396
3541
  // the error is already handled by router.push we just want to avoid
3397
3542
  // logging the error
3398
- pushWithRedirect(error.to, toLocation
3543
+ pushWithRedirect(assign(locationAsObject(error.to), {
3544
+ force: true,
3545
+ }), toLocation
3399
3546
  // avoid an uncaught rejection, let push call triggerError
3400
3547
  )
3401
3548
  .then(failure => {
@@ -3516,6 +3663,7 @@ function createRouter(options) {
3516
3663
  listening: true,
3517
3664
  addRoute,
3518
3665
  removeRoute,
3666
+ clearRoutes: matcher.clearRoutes,
3519
3667
  hasRoute,
3520
3668
  getRoutes,
3521
3669
  resolve,
@@ -3627,7 +3775,7 @@ function useRouter() {
3627
3775
  * Returns the current route location. Equivalent to using `$route` inside
3628
3776
  * templates.
3629
3777
  */
3630
- function useRoute() {
3778
+ function useRoute(_name) {
3631
3779
  return inject(routeLocationKey);
3632
3780
  }
3633
3781