@poveste/vendors 0.15.0 → 0.16.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/README.md +15 -1
- package/iconify.d.ts +5 -0
- package/iconify.js +5 -0
- package/package.json +39 -34
- package/pinia.d.ts +5 -0
- package/pinia.js +5 -0
- package/vue-router.d.ts +5 -0
- package/vue-router.js +5 -0
- package/vue-use.d.ts +5 -0
- package/vue-use.js +5 -0
- package/vue.d.ts +5 -0
- package/vue.js +9 -0
- package/dist/client/b-floating-vue.d.ts +0 -3
- package/dist/client/b-floating-vue.js +0 -3377
- package/dist/client/b-iconify.d.ts +0 -1
- package/dist/client/b-iconify.js +0 -1896
- package/dist/client/b-pinia.d.ts +0 -1
- package/dist/client/b-pinia.js +0 -1492
- package/dist/client/b-scroll.d.ts +0 -2
- package/dist/client/b-scroll.js +0 -7
- package/dist/client/b-vue-router.d.ts +0 -1
- package/dist/client/b-vue-router.js +0 -3058
- package/dist/client/b-vue-use.d.ts +0 -1
- package/dist/client/b-vue-use.js +0 -10774
- package/dist/client/b-vue.d.ts +0 -1
- package/dist/client/b-vue.js +0 -1
- package/dist/client/devtools-api.js +0 -6568
- package/dist/client/index.js +0 -185
- package/dist/client/node_modules/@babel/helper-string-parser/package.json +0 -31
- package/dist/client/node_modules/@babel/helper-validator-identifier/package.json +0 -31
- package/dist/client/node_modules/@babel/parser/package.json +0 -50
- package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +0 -262
- package/dist/client/node_modules/@babel/types/lib/index-legacy.d.ts +0 -2796
- package/dist/client/node_modules/@babel/types/lib/index.d.ts +0 -3616
- package/dist/client/node_modules/@babel/types/package.json +0 -39
- package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts +0 -535
- package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +0 -535
- package/dist/client/node_modules/@floating-ui/core/package.json +0 -63
- package/dist/client/node_modules/@floating-ui/dom/index.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/package.json +0 -74
- package/dist/client/node_modules/@floating-ui/dom/src/autoUpdate.d.ts +0 -31
- package/dist/client/node_modules/@floating-ui/dom/src/index.d.ts +0 -11
- package/dist/client/node_modules/@floating-ui/dom/src/platform.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/types.d.ts +0 -128
- package/dist/client/node_modules/@floating-ui/dom/src/utils/convertOffsetParentRelativeRectToViewportRelativeRect.d.ts +0 -6
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getBoundingClientRect.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingRect.d.ts +0 -12
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getComputedStyle.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getCssDimensions.d.ts +0 -4
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDimensions.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDocumentElement.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDocumentRect.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNearestOverflowAncestor.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNodeName.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNodeScroll.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getOffsetParent.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts +0 -3
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getParentNode.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getRectRelativeToOffsetParent.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getScale.d.ts +0 -7
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getViewportRect.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getWindowScrollBarX.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/is.d.ts +0 -17
- package/dist/client/node_modules/@floating-ui/dom/src/utils/math.d.ts +0 -3
- package/dist/client/node_modules/@floating-ui/dom/src/utils/unwrapElement.d.ts +0 -2
- package/dist/client/node_modules/@floating-ui/dom/src/utils/userAgent.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/dom/src/utils/window.d.ts +0 -1
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.mts +0 -105
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +0 -105
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.mts +0 -47
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +0 -47
- package/dist/client/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +0 -47
- package/dist/client/node_modules/@floating-ui/utils/dom/package.json +0 -6
- package/dist/client/node_modules/@floating-ui/utils/package.json +0 -70
- package/dist/client/node_modules/@iconify/types/package.json +0 -23
- package/dist/client/node_modules/@iconify/types/provider.d.ts +0 -44
- package/dist/client/node_modules/@iconify/types/types.d.ts +0 -272
- package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +0 -420
- package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +0 -109
- package/dist/client/node_modules/@iconify/vue/offline/package.json +0 -14
- package/dist/client/node_modules/@iconify/vue/package.json +0 -62
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +0 -88
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts +0 -32
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +0 -12
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts +0 -43
- package/dist/client/node_modules/@jridgewell/gen-mapping/package.json +0 -67
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts +0 -89
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts +0 -33
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts +0 -13
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/types.d.mts +0 -44
- package/dist/client/node_modules/@jridgewell/remapping/package.json +0 -71
- package/dist/client/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts +0 -15
- package/dist/client/node_modules/@jridgewell/remapping/types/remapping.d.mts +0 -21
- package/dist/client/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts +0 -46
- package/dist/client/node_modules/@jridgewell/remapping/types/source-map.d.mts +0 -19
- package/dist/client/node_modules/@jridgewell/remapping/types/types.d.mts +0 -16
- package/dist/client/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts +0 -4
- package/dist/client/node_modules/@jridgewell/resolve-uri/package.json +0 -69
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/package.json +0 -64
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts +0 -5
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts +0 -50
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts +0 -11
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts +0 -16
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts +0 -9
- package/dist/client/node_modules/@jridgewell/trace-mapping/package.json +0 -67
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts +0 -33
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts +0 -4
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts +0 -9
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts +0 -4
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/sort.d.mts +0 -4
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts +0 -17
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts +0 -5
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts +0 -80
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/types.d.mts +0 -107
- package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +0 -265
- package/dist/client/node_modules/@types/web-bluetooth/package.json +0 -46
- package/dist/client/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +0 -1120
- package/dist/client/node_modules/@vue/compiler-core/package.json +0 -58
- package/dist/client/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +0 -45
- package/dist/client/node_modules/@vue/compiler-dom/package.json +0 -57
- package/dist/client/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +0 -487
- package/dist/client/node_modules/@vue/compiler-sfc/package.json +0 -67
- package/dist/client/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +0 -4
- package/dist/client/node_modules/@vue/compiler-ssr/package.json +0 -34
- package/dist/client/node_modules/@vue/devtools-api/dist/index-node.d.ts +0 -11
- package/dist/client/node_modules/@vue/devtools-api/dist/index.d.ts +0 -2
- package/dist/client/node_modules/@vue/devtools-api/package.json +0 -38
- package/dist/client/node_modules/@vue/devtools-kit/dist/index.d.ts +0 -1170
- package/dist/client/node_modules/@vue/devtools-kit/global.d.ts +0 -20
- package/dist/client/node_modules/@vue/devtools-kit/package.json +0 -44
- package/dist/client/node_modules/@vue/devtools-kit/types.d.ts +0 -2
- package/dist/client/node_modules/@vue/devtools-shared/dist/index.d.ts +0 -40
- package/dist/client/node_modules/@vue/devtools-shared/package.json +0 -33
- package/dist/client/node_modules/@vue/reactivity/dist/reactivity.d.ts +0 -757
- package/dist/client/node_modules/@vue/reactivity/package.json +0 -55
- package/dist/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +0 -1868
- package/dist/client/node_modules/@vue/runtime-core/package.json +0 -52
- package/dist/client/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +0 -1452
- package/dist/client/node_modules/@vue/runtime-dom/package.json +0 -60
- package/dist/client/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +0 -65
- package/dist/client/node_modules/@vue/server-renderer/package.json +0 -53
- package/dist/client/node_modules/@vue/shared/dist/shared.d.ts +0 -334
- package/dist/client/node_modules/@vue/shared/package.json +0 -47
- package/dist/client/node_modules/@vue-macros/common/dist/index.d.ts +0 -124
- package/dist/client/node_modules/@vue-macros/common/package.json +0 -63
- package/dist/client/node_modules/@vueuse/core/dist/index.d.ts +0 -5860
- package/dist/client/node_modules/@vueuse/core/dist/metadata.d.mts +0 -1
- package/dist/client/node_modules/@vueuse/core/package.json +0 -56
- package/dist/client/node_modules/@vueuse/metadata/dist/index.d.ts +0 -81
- package/dist/client/node_modules/@vueuse/metadata/package.json +0 -41
- package/dist/client/node_modules/@vueuse/shared/dist/index.d.ts +0 -1511
- package/dist/client/node_modules/@vueuse/shared/package.json +0 -45
- package/dist/client/node_modules/acorn/dist/acorn.d.mts +0 -897
- package/dist/client/node_modules/acorn/dist/acorn.d.ts +0 -897
- package/dist/client/node_modules/acorn/package.json +0 -50
- package/dist/client/node_modules/ast-kit/dist/index.d.ts +0 -380
- package/dist/client/node_modules/ast-kit/package.json +0 -63
- package/dist/client/node_modules/ast-walker-scope/dist/index.d.mts +0 -51
- package/dist/client/node_modules/ast-walker-scope/package.json +0 -60
- package/dist/client/node_modules/birpc/dist/index.d.mts +0 -215
- package/dist/client/node_modules/birpc/dist/index.d.ts +0 -215
- package/dist/client/node_modules/birpc/package.json +0 -57
- package/dist/client/node_modules/chokidar/handler.d.ts +0 -90
- package/dist/client/node_modules/chokidar/index.d.ts +0 -217
- package/dist/client/node_modules/chokidar/package.json +0 -63
- package/dist/client/node_modules/compute-scroll-into-view/dist/index.d.ts +0 -75
- package/dist/client/node_modules/compute-scroll-into-view/package.json +0 -82
- package/dist/client/node_modules/confbox/dist/_chunks/_format.d.mts +0 -25
- package/dist/client/node_modules/confbox/dist/index.d.mts +0 -34
- package/dist/client/node_modules/confbox/dist/ini.d.mts +0 -62
- package/dist/client/node_modules/confbox/dist/json5.d.mts +0 -59
- package/dist/client/node_modules/confbox/dist/jsonc.d.mts +0 -41
- package/dist/client/node_modules/confbox/dist/toml.d.mts +0 -23
- package/dist/client/node_modules/confbox/dist/yaml.d.mts +0 -96
- package/dist/client/node_modules/confbox/package.json +0 -67
- package/dist/client/node_modules/csstype/index.d.ts +0 -22569
- package/dist/client/node_modules/csstype/package.json +0 -70
- package/dist/client/node_modules/entities/decode.d.ts +0 -3
- package/dist/client/node_modules/entities/dist/commonjs/decode-codepoint.d.ts +0 -19
- package/dist/client/node_modules/entities/dist/commonjs/decode.d.ts +0 -205
- package/dist/client/node_modules/entities/dist/commonjs/encode.d.ts +0 -22
- package/dist/client/node_modules/entities/dist/commonjs/escape.d.ts +0 -46
- package/dist/client/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts +0 -2
- package/dist/client/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts +0 -2
- package/dist/client/node_modules/entities/dist/commonjs/generated/encode-html.d.ts +0 -3
- package/dist/client/node_modules/entities/dist/commonjs/index.d.ts +0 -96
- package/dist/client/node_modules/entities/dist/commonjs/internal/bin-trie-flags.d.ts +0 -17
- package/dist/client/node_modules/entities/dist/commonjs/internal/decode-shared.d.ts +0 -2
- package/dist/client/node_modules/entities/dist/commonjs/internal/encode-shared.d.ts +0 -32
- package/dist/client/node_modules/entities/dist/commonjs/package.json +0 -3
- package/dist/client/node_modules/entities/dist/esm/decode-codepoint.d.ts +0 -19
- package/dist/client/node_modules/entities/dist/esm/decode.d.ts +0 -205
- package/dist/client/node_modules/entities/dist/esm/encode.d.ts +0 -22
- package/dist/client/node_modules/entities/dist/esm/escape.d.ts +0 -46
- package/dist/client/node_modules/entities/dist/esm/generated/decode-data-html.d.ts +0 -2
- package/dist/client/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts +0 -2
- package/dist/client/node_modules/entities/dist/esm/generated/encode-html.d.ts +0 -3
- package/dist/client/node_modules/entities/dist/esm/index.d.ts +0 -96
- package/dist/client/node_modules/entities/dist/esm/internal/bin-trie-flags.d.ts +0 -17
- package/dist/client/node_modules/entities/dist/esm/internal/decode-shared.d.ts +0 -2
- package/dist/client/node_modules/entities/dist/esm/internal/encode-shared.d.ts +0 -32
- package/dist/client/node_modules/entities/dist/esm/package.json +0 -3
- package/dist/client/node_modules/entities/escape.d.ts +0 -3
- package/dist/client/node_modules/entities/package.json +0 -120
- package/dist/client/node_modules/estree-walker/dist/esm/package.json +0 -1
- package/dist/client/node_modules/estree-walker/package.json +0 -37
- package/dist/client/node_modules/estree-walker/src/package.json +0 -1
- package/dist/client/node_modules/estree-walker/types/async.d.ts +0 -53
- package/dist/client/node_modules/estree-walker/types/index.d.ts +0 -56
- package/dist/client/node_modules/estree-walker/types/sync.d.ts +0 -53
- package/dist/client/node_modules/estree-walker/types/walker.d.ts +0 -37
- package/dist/client/node_modules/exsolve/dist/index.d.mts +0 -66
- package/dist/client/node_modules/exsolve/package.json +0 -42
- package/dist/client/node_modules/fdir/dist/index.d.mts +0 -155
- package/dist/client/node_modules/fdir/package.json +0 -103
- package/dist/client/node_modules/floating-vue/dist/components/Dropdown.d.ts +0 -398
- package/dist/client/node_modules/floating-vue/dist/components/Menu.d.ts +0 -398
- package/dist/client/node_modules/floating-vue/dist/components/Popper.d.ts +0 -495
- package/dist/client/node_modules/floating-vue/dist/components/Popper.vue.d.ts +0 -474
- package/dist/client/node_modules/floating-vue/dist/components/PopperContent.vue.d.ts +0 -37
- package/dist/client/node_modules/floating-vue/dist/components/PopperMethods.d.ts +0 -9
- package/dist/client/node_modules/floating-vue/dist/components/PopperWrapper.vue.d.ts +0 -414
- package/dist/client/node_modules/floating-vue/dist/components/ThemeClass.d.ts +0 -6
- package/dist/client/node_modules/floating-vue/dist/components/Tooltip.d.ts +0 -398
- package/dist/client/node_modules/floating-vue/dist/components/TooltipDirective.vue.d.ts +0 -67
- package/dist/client/node_modules/floating-vue/dist/config.d.ts +0 -11
- package/dist/client/node_modules/floating-vue/dist/directives/v-close-popper.d.ts +0 -13
- package/dist/client/node_modules/floating-vue/dist/directives/v-tooltip.d.ts +0 -27
- package/dist/client/node_modules/floating-vue/dist/directives/v-tooltip.spec.d.ts +0 -1
- package/dist/client/node_modules/floating-vue/dist/index.d.ts +0 -2239
- package/dist/client/node_modules/floating-vue/dist/util/assign-deep.d.ts +0 -1
- package/dist/client/node_modules/floating-vue/dist/util/env.d.ts +0 -2
- package/dist/client/node_modules/floating-vue/dist/util/events.d.ts +0 -14
- package/dist/client/node_modules/floating-vue/dist/util/frame.d.ts +0 -1
- package/dist/client/node_modules/floating-vue/dist/util/lang.d.ts +0 -1
- package/dist/client/node_modules/floating-vue/dist/util/popper.d.ts +0 -3
- package/dist/client/node_modules/floating-vue/package.json +0 -80
- package/dist/client/node_modules/hookable/dist/index.d.ts +0 -103
- package/dist/client/node_modules/hookable/package.json +0 -49
- package/dist/client/node_modules/local-pkg/dist/index.d.mts +0 -42
- package/dist/client/node_modules/local-pkg/dist/index.d.ts +0 -42
- package/dist/client/node_modules/local-pkg/package.json +0 -65
- package/dist/client/node_modules/magic-string/dist/magic-string.cjs.d.ts +0 -289
- package/dist/client/node_modules/magic-string/dist/magic-string.es.d.mts +0 -289
- package/dist/client/node_modules/magic-string/package.json +0 -67
- package/dist/client/node_modules/magic-string-ast/dist/index.d.ts +0 -67
- package/dist/client/node_modules/magic-string-ast/package.json +0 -64
- package/dist/client/node_modules/mlly/dist/index.d.mts +0 -564
- package/dist/client/node_modules/mlly/dist/index.d.ts +0 -564
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/index.d.mts +0 -32
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/index.d.ts +0 -32
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/json5.d.mts +0 -58
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/json5.d.ts +0 -58
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/jsonc.d.mts +0 -41
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/jsonc.d.ts +0 -41
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/shared/confbox.9745c98f.d.mts +0 -24
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/shared/confbox.9745c98f.d.ts +0 -24
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/toml.d.mts +0 -22
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/toml.d.ts +0 -22
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/yaml.d.mts +0 -95
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/yaml.d.ts +0 -95
- package/dist/client/node_modules/mlly/node_modules/confbox/json5.d.ts +0 -2
- package/dist/client/node_modules/mlly/node_modules/confbox/jsonc.d.ts +0 -2
- package/dist/client/node_modules/mlly/node_modules/confbox/package.json +0 -86
- package/dist/client/node_modules/mlly/node_modules/confbox/toml.d.ts +0 -2
- package/dist/client/node_modules/mlly/node_modules/confbox/yaml.d.ts +0 -2
- package/dist/client/node_modules/mlly/node_modules/pkg-types/dist/index.d.mts +0 -411
- package/dist/client/node_modules/mlly/node_modules/pkg-types/dist/index.d.ts +0 -411
- package/dist/client/node_modules/mlly/node_modules/pkg-types/package.json +0 -47
- package/dist/client/node_modules/mlly/package.json +0 -55
- package/dist/client/node_modules/muggle-string/out/base.d.ts +0 -6
- package/dist/client/node_modules/muggle-string/out/basic.d.ts +0 -6
- package/dist/client/node_modules/muggle-string/out/binarySearch.d.ts +0 -1
- package/dist/client/node_modules/muggle-string/out/common.d.ts +0 -9
- package/dist/client/node_modules/muggle-string/out/getLength.d.ts +0 -2
- package/dist/client/node_modules/muggle-string/out/index.d.ts +0 -10
- package/dist/client/node_modules/muggle-string/out/map.d.ts +0 -3
- package/dist/client/node_modules/muggle-string/out/overwriteSource.d.ts +0 -3
- package/dist/client/node_modules/muggle-string/out/replace.d.ts +0 -3
- package/dist/client/node_modules/muggle-string/out/segment.d.ts +0 -6
- package/dist/client/node_modules/muggle-string/out/sourceBased.d.ts +0 -3
- package/dist/client/node_modules/muggle-string/out/toString.d.ts +0 -2
- package/dist/client/node_modules/muggle-string/out/track.d.ts +0 -6
- package/dist/client/node_modules/muggle-string/out/types.d.ts +0 -16
- package/dist/client/node_modules/muggle-string/package.json +0 -22
- package/dist/client/node_modules/nanoid/async/index.d.ts +0 -56
- package/dist/client/node_modules/nanoid/async/package.json +0 -12
- package/dist/client/node_modules/nanoid/index.d.ts +0 -91
- package/dist/client/node_modules/nanoid/non-secure/index.d.ts +0 -33
- package/dist/client/node_modules/nanoid/non-secure/package.json +0 -6
- package/dist/client/node_modules/nanoid/package.json +0 -89
- package/dist/client/node_modules/nanoid/url-alphabet/package.json +0 -6
- package/dist/client/node_modules/nostics/dist/diagnostic-wduO7saY.d.mts +0 -295
- package/dist/client/node_modules/nostics/dist/formatters/ansi.d.mts +0 -15
- package/dist/client/node_modules/nostics/dist/formatters/json.d.mts +0 -7
- package/dist/client/node_modules/nostics/dist/index.d.mts +0 -51
- package/dist/client/node_modules/nostics/dist/reporters/dev.d.mts +0 -13
- package/dist/client/node_modules/nostics/dist/reporters/fetch.d.mts +0 -11
- package/dist/client/node_modules/nostics/dist/reporters/node.d.mts +0 -43
- package/dist/client/node_modules/nostics/package.json +0 -125
- package/dist/client/node_modules/pathe/dist/index.d.mts +0 -47
- package/dist/client/node_modules/pathe/dist/index.d.ts +0 -47
- package/dist/client/node_modules/pathe/dist/utils.d.mts +0 -32
- package/dist/client/node_modules/pathe/dist/utils.d.ts +0 -32
- package/dist/client/node_modules/pathe/package.json +0 -61
- package/dist/client/node_modules/pathe/utils.d.ts +0 -1
- package/dist/client/node_modules/perfect-debounce/dist/index.d.mts +0 -49
- package/dist/client/node_modules/perfect-debounce/package.json +0 -41
- package/dist/client/node_modules/picocolors/package.json +0 -25
- package/dist/client/node_modules/picocolors/picocolors.d.ts +0 -5
- package/dist/client/node_modules/picocolors/types.d.ts +0 -51
- package/dist/client/node_modules/picomatch/package.json +0 -83
- package/dist/client/node_modules/pinia/dist/pinia.d.ts +0 -955
- package/dist/client/node_modules/pinia/package.json +0 -82
- package/dist/client/node_modules/pkg-types/dist/index.d.mts +0 -695
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/_chunks/_format.d.mts +0 -22
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/_chunks/libs/js-yaml.d.mts +0 -33
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/index.d.mts +0 -7
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/ini.d.mts +0 -59
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/json.d.mts +0 -25
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/json5.d.mts +0 -55
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/jsonc.d.mts +0 -29
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/toml.d.mts +0 -20
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/yaml.d.mts +0 -101
- package/dist/client/node_modules/pkg-types/node_modules/confbox/package.json +0 -68
- package/dist/client/node_modules/pkg-types/package.json +0 -47
- package/dist/client/node_modules/postcss/lib/at-rule.d.ts +0 -139
- package/dist/client/node_modules/postcss/lib/comment.d.ts +0 -67
- package/dist/client/node_modules/postcss/lib/container.d.ts +0 -474
- package/dist/client/node_modules/postcss/lib/css-syntax-error.d.ts +0 -247
- package/dist/client/node_modules/postcss/lib/declaration.d.ts +0 -150
- package/dist/client/node_modules/postcss/lib/document.d.ts +0 -68
- package/dist/client/node_modules/postcss/lib/fromJSON.d.ts +0 -9
- package/dist/client/node_modules/postcss/lib/input.d.ts +0 -226
- package/dist/client/node_modules/postcss/lib/lazy-result.d.ts +0 -189
- package/dist/client/node_modules/postcss/lib/list.d.ts +0 -60
- package/dist/client/node_modules/postcss/lib/no-work-result.d.ts +0 -45
- package/dist/client/node_modules/postcss/lib/node.d.ts +0 -555
- package/dist/client/node_modules/postcss/lib/parse.d.ts +0 -9
- package/dist/client/node_modules/postcss/lib/postcss.d.mts +0 -66
- package/dist/client/node_modules/postcss/lib/postcss.d.ts +0 -464
- package/dist/client/node_modules/postcss/lib/previous-map.d.ts +0 -80
- package/dist/client/node_modules/postcss/lib/processor.d.ts +0 -114
- package/dist/client/node_modules/postcss/lib/result.d.ts +0 -204
- package/dist/client/node_modules/postcss/lib/root.d.ts +0 -86
- package/dist/client/node_modules/postcss/lib/rule.d.ts +0 -126
- package/dist/client/node_modules/postcss/lib/stringifier.d.ts +0 -45
- package/dist/client/node_modules/postcss/lib/stringify.d.ts +0 -9
- package/dist/client/node_modules/postcss/lib/warning.d.ts +0 -146
- package/dist/client/node_modules/postcss/package.json +0 -88
- package/dist/client/node_modules/quansync/dist/index.d.mts +0 -22
- package/dist/client/node_modules/quansync/dist/index.d.ts +0 -22
- package/dist/client/node_modules/quansync/dist/macro.d.mts +0 -18
- package/dist/client/node_modules/quansync/dist/macro.d.ts +0 -18
- package/dist/client/node_modules/quansync/dist/types.d.mts +0 -27
- package/dist/client/node_modules/quansync/dist/types.d.ts +0 -27
- package/dist/client/node_modules/quansync/package.json +0 -95
- package/dist/client/node_modules/readdirp/index.d.ts +0 -117
- package/dist/client/node_modules/readdirp/package.json +0 -62
- package/dist/client/node_modules/scroll-into-view-if-needed/dist/index.d.ts +0 -79
- package/dist/client/node_modules/scroll-into-view-if-needed/package.json +0 -80
- package/dist/client/node_modules/scule/dist/index.d.mts +0 -57
- package/dist/client/node_modules/scule/dist/index.d.ts +0 -57
- package/dist/client/node_modules/scule/package.json +0 -43
- package/dist/client/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
- package/dist/client/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
- package/dist/client/node_modules/source-map-js/lib/source-node.d.ts +0 -1
- package/dist/client/node_modules/source-map-js/package.json +0 -71
- package/dist/client/node_modules/source-map-js/source-map.d.ts +0 -104
- package/dist/client/node_modules/tinyglobby/dist/index.d.mts +0 -148
- package/dist/client/node_modules/tinyglobby/package.json +0 -70
- package/dist/client/node_modules/ufo/dist/index.d.mts +0 -714
- package/dist/client/node_modules/ufo/dist/index.d.ts +0 -714
- package/dist/client/node_modules/ufo/package.json +0 -48
- package/dist/client/node_modules/unplugin/dist/index.d.mts +0 -241
- package/dist/client/node_modules/unplugin/dist/rspack/loaders/load.d.mts +0 -4
- package/dist/client/node_modules/unplugin/dist/rspack/loaders/transform.d.mts +0 -4
- package/dist/client/node_modules/unplugin/dist/webpack/loaders/load.d.mts +0 -4
- package/dist/client/node_modules/unplugin/dist/webpack/loaders/transform.d.mts +0 -4
- package/dist/client/node_modules/unplugin/package.json +0 -146
- package/dist/client/node_modules/unplugin-utils/dist/index.d.ts +0 -31
- package/dist/client/node_modules/unplugin-utils/package.json +0 -61
- package/dist/client/node_modules/vue/compiler-sfc/index.d.mts +0 -1
- package/dist/client/node_modules/vue/compiler-sfc/index.d.ts +0 -1
- package/dist/client/node_modules/vue/compiler-sfc/package.json +0 -4
- package/dist/client/node_modules/vue/dist/vue.d.mts +0 -7
- package/dist/client/node_modules/vue/dist/vue.d.ts +0 -7
- package/dist/client/node_modules/vue/jsx-runtime/index.d.ts +0 -25
- package/dist/client/node_modules/vue/jsx-runtime/package.json +0 -5
- package/dist/client/node_modules/vue/jsx.d.ts +0 -22
- package/dist/client/node_modules/vue/package.json +0 -112
- package/dist/client/node_modules/vue/server-renderer/index.d.mts +0 -1
- package/dist/client/node_modules/vue/server-renderer/index.d.ts +0 -1
- package/dist/client/node_modules/vue/server-renderer/package.json +0 -4
- package/dist/client/node_modules/vue-resize/package.json +0 -77
- package/dist/client/node_modules/vue-router/dist/experimental/index.d.ts +0 -7
- package/dist/client/node_modules/vue-router/dist/experimental/pinia-colada.d.ts +0 -151
- package/dist/client/node_modules/vue-router/dist/index-D7ja2BKs.d.ts +0 -3293
- package/dist/client/node_modules/vue-router/dist/options-CwYZKRl4.d.mts +0 -2923
- package/dist/client/node_modules/vue-router/dist/unplugin/esbuild.d.mts +0 -10
- package/dist/client/node_modules/vue-router/dist/unplugin/index.d.mts +0 -62
- package/dist/client/node_modules/vue-router/dist/unplugin/options.d.mts +0 -7
- package/dist/client/node_modules/vue-router/dist/unplugin/rolldown.d.mts +0 -10
- package/dist/client/node_modules/vue-router/dist/unplugin/rollup.d.mts +0 -10
- package/dist/client/node_modules/vue-router/dist/unplugin/types.d.mts +0 -7
- package/dist/client/node_modules/vue-router/dist/unplugin/vite.d.mts +0 -10
- package/dist/client/node_modules/vue-router/dist/unplugin/webpack.d.mts +0 -10
- package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +0 -7
- package/dist/client/node_modules/vue-router/package.json +0 -211
- package/dist/client/node_modules/vue-router/vue-router-auto-resolver.d.mts +0 -27
- package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.mts +0 -53
- package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +0 -2
- package/dist/client/node_modules/webpack-virtual-modules/lib/index.d.ts +0 -15
- package/dist/client/node_modules/webpack-virtual-modules/lib/virtual-stats.d.ts +0 -11
- package/dist/client/node_modules/webpack-virtual-modules/package.json +0 -82
- package/dist/client/vue.runtime.esm-bundler.js +0 -13389
- package/src/client/b-floating-vue.ts +0 -5
- package/src/client/b-iconify.ts +0 -1
- package/src/client/b-pinia.ts +0 -1
- package/src/client/b-scroll.ts +0 -4
- package/src/client/b-vue-router.ts +0 -1
- package/src/client/b-vue-use.ts +0 -1
- package/src/client/b-vue.ts +0 -1
|
@@ -1,3058 +0,0 @@
|
|
|
1
|
-
import { defineDiagnostics, createConsoleReporter } from './index.js';
|
|
2
|
-
import { inject, onUnmounted, onDeactivated, onActivated, getCurrentInstance, watch, computed, unref, watchEffect, defineComponent, reactive, h, provide, ref, shallowRef, nextTick, shallowReactive } from './vue.runtime.esm-bundler.js';
|
|
3
|
-
import { setupDevToolsPlugin } from './devtools-api.js';
|
|
4
|
-
|
|
5
|
-
/*!
|
|
6
|
-
* vue-router v5.3.1
|
|
7
|
-
* (c) 2026 Eduardo San Martin Morote
|
|
8
|
-
* @license MIT
|
|
9
|
-
*/
|
|
10
|
-
//#region src/utils/index.ts
|
|
11
|
-
/**
|
|
12
|
-
* Identity function that returns the value as is.
|
|
13
|
-
*
|
|
14
|
-
* @param v - the value to return
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
const identityFn = (v) => v;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if a path is absolute, meaning it starts with a `/`.
|
|
21
|
-
*
|
|
22
|
-
* @param path - path to check
|
|
23
|
-
*
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
const isAbsolutePath = (path) => path.startsWith("/");
|
|
27
|
-
/**
|
|
28
|
-
* Allows differentiating lazy components from functional components and vue-class-component
|
|
29
|
-
* @internal
|
|
30
|
-
*
|
|
31
|
-
* @param component
|
|
32
|
-
*/
|
|
33
|
-
function isRouteComponent(component) {
|
|
34
|
-
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
|
|
35
|
-
}
|
|
36
|
-
function isESModule(obj) {
|
|
37
|
-
return obj.__esModule || obj[Symbol.toStringTag] === "Module" || obj.default && isRouteComponent(obj.default);
|
|
38
|
-
}
|
|
39
|
-
const assign = Object.assign;
|
|
40
|
-
function applyToParams(fn, params) {
|
|
41
|
-
const newParams = {};
|
|
42
|
-
for (const key in params) {
|
|
43
|
-
const value = params[key];
|
|
44
|
-
newParams[key] = isArray(value) ? value.map(fn) : fn(value);
|
|
45
|
-
}
|
|
46
|
-
return newParams;
|
|
47
|
-
}
|
|
48
|
-
const noop = () => {};
|
|
49
|
-
/**
|
|
50
|
-
* Typesafe alternative to Array.isArray
|
|
51
|
-
* https://github.com/microsoft/TypeScript/pull/48228
|
|
52
|
-
*
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
const isArray = Array.isArray;
|
|
56
|
-
function mergeOptions(defaults, partialOptions) {
|
|
57
|
-
const options = {};
|
|
58
|
-
for (const key in defaults) options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
|
|
59
|
-
return options;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/errors.ts
|
|
63
|
-
const NavigationFailureSymbol = Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
|
|
64
|
-
/**
|
|
65
|
-
* Enumeration with all possible types for navigation failures. Can be passed to
|
|
66
|
-
* {@link isNavigationFailure} to check for specific failures.
|
|
67
|
-
*/
|
|
68
|
-
let NavigationFailureType = /* @__PURE__ */ function(NavigationFailureType) {
|
|
69
|
-
/**
|
|
70
|
-
* An aborted navigation is a navigation that failed because a navigation
|
|
71
|
-
* guard returned `false` or called `next(false)`
|
|
72
|
-
*/
|
|
73
|
-
NavigationFailureType[NavigationFailureType["aborted"] = 4] = "aborted";
|
|
74
|
-
/**
|
|
75
|
-
* A cancelled navigation is a navigation that failed because a more recent
|
|
76
|
-
* navigation finished started (not necessarily finished).
|
|
77
|
-
*/
|
|
78
|
-
NavigationFailureType[NavigationFailureType["cancelled"] = 8] = "cancelled";
|
|
79
|
-
/**
|
|
80
|
-
* A duplicated navigation is a navigation that failed because it was
|
|
81
|
-
* initiated while already being at the exact same location.
|
|
82
|
-
*/
|
|
83
|
-
NavigationFailureType[NavigationFailureType["duplicated"] = 16] = "duplicated";
|
|
84
|
-
return NavigationFailureType;
|
|
85
|
-
}({});
|
|
86
|
-
const ErrorTypeMessages = {
|
|
87
|
-
[1]({ location, currentLocation }) {
|
|
88
|
-
return `No match for\n ${JSON.stringify(location)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
|
|
89
|
-
},
|
|
90
|
-
[2]({ from, to }) {
|
|
91
|
-
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
|
|
92
|
-
},
|
|
93
|
-
[4]({ from, to }) {
|
|
94
|
-
return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
|
|
95
|
-
},
|
|
96
|
-
[8]({ from, to }) {
|
|
97
|
-
return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
|
|
98
|
-
},
|
|
99
|
-
[16]({ from, to: _to }) {
|
|
100
|
-
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Creates a typed NavigationFailure object.
|
|
105
|
-
* @internal
|
|
106
|
-
* @param type - NavigationFailureType
|
|
107
|
-
* @param params - { from, to }
|
|
108
|
-
*/
|
|
109
|
-
function createRouterError(type, params) {
|
|
110
|
-
if (process.env.NODE_ENV !== "production" || false) return assign(new Error(ErrorTypeMessages[type](params)), {
|
|
111
|
-
type,
|
|
112
|
-
[NavigationFailureSymbol]: true
|
|
113
|
-
}, params);
|
|
114
|
-
else return assign(/* @__PURE__ */ new Error(), {
|
|
115
|
-
type,
|
|
116
|
-
[NavigationFailureSymbol]: true
|
|
117
|
-
}, params);
|
|
118
|
-
}
|
|
119
|
-
function isNavigationFailure(error, type) {
|
|
120
|
-
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
|
|
121
|
-
}
|
|
122
|
-
const propertiesToLog = [
|
|
123
|
-
"params",
|
|
124
|
-
"query",
|
|
125
|
-
"hash"
|
|
126
|
-
];
|
|
127
|
-
/**
|
|
128
|
-
* Stringifies a raw location for display in dev warnings.
|
|
129
|
-
*
|
|
130
|
-
* @internal
|
|
131
|
-
*/
|
|
132
|
-
function stringifyRoute(to) {
|
|
133
|
-
if (!to || typeof to === "string") return to;
|
|
134
|
-
if (to.path != null) return to.path;
|
|
135
|
-
const location = {};
|
|
136
|
-
for (const key of propertiesToLog) if (key in to) location[key] = to[key];
|
|
137
|
-
return JSON.stringify(location, null, 2);
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/diagnostics.ts
|
|
141
|
-
/**
|
|
142
|
-
* Runtime diagnostics catalog for Vue Router.
|
|
143
|
-
*
|
|
144
|
-
* Every entry has a stable `VUE_ROUTER_R####` code, a `why` that states the problem
|
|
145
|
-
* (the diagnosis only, never the remedy) and a `fix` that states the remedy
|
|
146
|
-
* (only, never the diagnosis). They are complementary: the reporter prints
|
|
147
|
-
* both, so neither repeats the other. The diagnosis substrings asserted by the
|
|
148
|
-
* warning tests stay in `why`. All call sites stay behind the existing `__DEV__` (or
|
|
149
|
-
* `process.env.NODE_ENV !== 'production'`) guards and remain bare expression
|
|
150
|
-
* statements so they tree-shake out of production builds.
|
|
151
|
-
*
|
|
152
|
-
* Codes are permanent: never rename or reuse one.
|
|
153
|
-
* - `VUE_ROUTER_R0###` core runtime warnings
|
|
154
|
-
* - `VUE_ROUTER_R1###` experimental data-loaders
|
|
155
|
-
*/
|
|
156
|
-
const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
157
|
-
reporters: [/*#__PURE__*/ createConsoleReporter()],
|
|
158
|
-
codes: {
|
|
159
|
-
VUE_ROUTER_R0001: {
|
|
160
|
-
why: (p) => `Parent route "${p.name}" not found when adding child route`,
|
|
161
|
-
fix: "Add the parent route before its children, or check the parent name for typos.",
|
|
162
|
-
docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Adding-nested-routes"
|
|
163
|
-
},
|
|
164
|
-
VUE_ROUTER_R0002: {
|
|
165
|
-
why: (p) => `Cannot remove non-existent route "${p.name}"`,
|
|
166
|
-
fix: "Check the route name; it may already have been removed or was never added.",
|
|
167
|
-
docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Removing-routes"
|
|
168
|
-
},
|
|
169
|
-
VUE_ROUTER_R0003: {
|
|
170
|
-
why: (p) => `Location "${stringifyRoute(p.location)}" resolved to "${p.href}". A resolved location cannot start with multiple slashes.`,
|
|
171
|
-
fix: "Remove the leading slashes from the location or fix the route configuration."
|
|
172
|
-
},
|
|
173
|
-
VUE_ROUTER_R0004: {
|
|
174
|
-
why: (p) => `No match found for location with path "${stringifyRoute(p.path)}"`,
|
|
175
|
-
fix: "Add a route matching this path or check for typos in the location.",
|
|
176
|
-
docs: "https://router.vuejs.org/guide/essentials/dynamic-matching.html#Catch-all-404-Not-found-Route"
|
|
177
|
-
},
|
|
178
|
-
VUE_ROUTER_R0005: {
|
|
179
|
-
why: (p) => `router.resolve() was passed an invalid location. This will fail in production.\nLocation: ${stringifyRoute(p.rawLocation)}`,
|
|
180
|
-
fix: "Pass a valid route location: a string path or an object with `path` or `name`."
|
|
181
|
-
},
|
|
182
|
-
VUE_ROUTER_R0006: {
|
|
183
|
-
why: (p) => `Path "${p.path}" was passed with params but they will be ignored because a "path" was passed.`,
|
|
184
|
-
fix: "Use a named route `{ name, params }` instead of `{ path, params }`.",
|
|
185
|
-
docs: "https://router.vuejs.org/guide/essentials/navigation.html#Navigate-to-a-different-location"
|
|
186
|
-
},
|
|
187
|
-
VUE_ROUTER_R0007: {
|
|
188
|
-
why: (p) => `A \`hash\` should always start with the character "#" but received "${p.hash}".`,
|
|
189
|
-
fix: (p) => `Prepend "#" to the hash in your route location: use "#${p.hash}".`
|
|
190
|
-
},
|
|
191
|
-
VUE_ROUTER_R0008: {
|
|
192
|
-
why: (p) => `Invalid redirect found:\n${p.target}\n when navigating to "${p.to}".\nThis will break in production.`,
|
|
193
|
-
fix: "A redirect must resolve to a location with a `name` or `path`; return one of those (or a string path) from `redirect`.",
|
|
194
|
-
docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Redirect"
|
|
195
|
-
},
|
|
196
|
-
VUE_ROUTER_R0009: {
|
|
197
|
-
why: (p) => `Detected a possibly infinite redirection in a navigation guard when going from "${p.from}" to "${p.to}". Aborting to avoid a Stack Overflow. This might break in production if not fixed.`,
|
|
198
|
-
fix: "A guard is returning a new location on every call; make that return conditional so it only redirects when actually needed.",
|
|
199
|
-
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Global-Before-Guards"
|
|
200
|
-
},
|
|
201
|
-
VUE_ROUTER_R0010: {
|
|
202
|
-
why: "Uncaught error during route navigation",
|
|
203
|
-
fix: "Register an error handler with `router.onError()` to handle navigation errors."
|
|
204
|
-
},
|
|
205
|
-
VUE_ROUTER_R0011: {
|
|
206
|
-
why: "Unexpected error when starting the router:",
|
|
207
|
-
fix: "Inspect the actual cause; a navigation guard or async component likely threw during the initial navigation."
|
|
208
|
-
},
|
|
209
|
-
VUE_ROUTER_R0020: {
|
|
210
|
-
why: (p) => `No active route record was found when calling \`${p.fn}()\`. Maybe you called it inside of App.vue?`,
|
|
211
|
-
fix: "Call it from a component rendered inside <router-view> (a page component or one of its children), not from App.vue.",
|
|
212
|
-
docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
|
|
213
|
-
},
|
|
214
|
-
VUE_ROUTER_R0021: {
|
|
215
|
-
why: "No active route record was found when reactivating component with navigation guard. This is likely a bug in vue-router.",
|
|
216
|
-
fix: "Report with a minimal reproduction at https://github.com/vuejs/router/issues/new/choose."
|
|
217
|
-
},
|
|
218
|
-
VUE_ROUTER_R0022: {
|
|
219
|
-
why: (p) => `${p.fn}() was called outside of component setup but it must be called at the top of a setup function`,
|
|
220
|
-
fix: "Call it synchronously at the top of `setup()`, before any `await`.",
|
|
221
|
-
docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
|
|
222
|
-
},
|
|
223
|
-
VUE_ROUTER_R0023: {
|
|
224
|
-
why: (p) => `The "next" callback was never called inside of ${p.name ? `"${p.name}"` : ""}:\n${p.guard}`,
|
|
225
|
-
fix: "Make sure `next()` runs on every branch, including early returns and async paths, or drop the `next` parameter and return the value instead.",
|
|
226
|
-
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
|
227
|
-
},
|
|
228
|
-
VUE_ROUTER_R0024: {
|
|
229
|
-
why: (p) => `The "next" callback was called more than once in one navigation guard when going from "${p.from}" to "${p.to}". This will fail in production.`,
|
|
230
|
-
fix: "Call `next()` exactly once per guard: remove the extra call, or migrate to returning the value you passed to `next()`.",
|
|
231
|
-
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
|
232
|
-
},
|
|
233
|
-
VUE_ROUTER_R0025: {
|
|
234
|
-
why: "The `next()` callback in navigation guards is deprecated.",
|
|
235
|
-
fix: "Return the value instead: `next()` becomes `return`, `next(false)` becomes `return false`, `next(\"/path\")` becomes `return \"/path\"`.",
|
|
236
|
-
docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
|
|
237
|
-
},
|
|
238
|
-
VUE_ROUTER_R0026: {
|
|
239
|
-
why: (p) => `Record with path "${p.path}" is either missing a "component(s)" or "children" property.`,
|
|
240
|
-
fix: "Add a `component`, `components`, or `children` to the route record.",
|
|
241
|
-
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
|
|
242
|
-
},
|
|
243
|
-
VUE_ROUTER_R0027: {
|
|
244
|
-
why: (p) => `Component "${p.name}" in record with path "${p.path}" is not a valid component. Received "${p.received}".`,
|
|
245
|
-
fix: "Pass a component or a function returning a Promise that resolves to one."
|
|
246
|
-
},
|
|
247
|
-
VUE_ROUTER_R0028: {
|
|
248
|
-
why: (p) => `Component "${p.name}" in record with path "${p.path}" is a Promise instead of a function that returns a Promise. This will break in production if not fixed.`,
|
|
249
|
-
fix: `Defer the import in an arrow function so it loads lazily: write "() => import('./MyPage.vue')", not "import('./MyPage.vue')".`,
|
|
250
|
-
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
|
|
251
|
-
},
|
|
252
|
-
VUE_ROUTER_R0029: {
|
|
253
|
-
why: (p) => `Component "${p.name}" in record with path "${p.path}" is defined using "defineAsyncComponent()".`,
|
|
254
|
-
fix: `Drop the wrapper and pass "() => import('./MyPage.vue')" directly; the router handles lazy components itself.`,
|
|
255
|
-
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html#Relationship-to-async-components"
|
|
256
|
-
},
|
|
257
|
-
VUE_ROUTER_R0030: {
|
|
258
|
-
why: (p) => `Component "${p.name}" in record with path "${p.path}" is a function that does not return a Promise. This will break in production if not fixed.`,
|
|
259
|
-
fix: "Return a dynamic import (`() => import(\"./MyPage.vue\")`) from the function, or add a `displayName` if it is a functional component.",
|
|
260
|
-
docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
|
|
261
|
-
},
|
|
262
|
-
VUE_ROUTER_R0040: {
|
|
263
|
-
why: (p) => `Because "${p.el}" starts with "#", scrollBehavior resolves it as an element id via document.getElementById("${p.el.slice(1)}"), not as a CSS selector. No element has that id, but "${p.el}" does match an element with document.querySelector().`,
|
|
264
|
-
fix: (p) => `Resolve the element yourself and return the node: el: document.querySelector('${p.el}').`,
|
|
265
|
-
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
|
266
|
-
},
|
|
267
|
-
VUE_ROUTER_R0041: {
|
|
268
|
-
why: (p) => `The selector "${p.el}" is invalid. See https://mathiasbynens.be/notes/css-escapes or CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape) for the escaping rules.`,
|
|
269
|
-
fix: "Build an id selector as `#${CSS.escape(id)}` so special characters in the id are escaped.",
|
|
270
|
-
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
|
271
|
-
},
|
|
272
|
-
VUE_ROUTER_R0042: {
|
|
273
|
-
why: (p) => `Couldn't find element using selector "${p.el}" returned by scrollBehavior.`,
|
|
274
|
-
fix: "Return a selector that matches an existing element, or guard against missing elements.",
|
|
275
|
-
docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
|
|
276
|
-
},
|
|
277
|
-
VUE_ROUTER_R0050: {
|
|
278
|
-
why: (p) => {
|
|
279
|
-
let to;
|
|
280
|
-
try {
|
|
281
|
-
to = p.to === void 0 ? "undefined" : JSON.stringify(p.to);
|
|
282
|
-
} catch {
|
|
283
|
-
to = String(p.to);
|
|
284
|
-
}
|
|
285
|
-
return `Invalid value for prop "to" in useLink()\n- to: ${to}`;
|
|
286
|
-
},
|
|
287
|
-
fix: "Pass a valid route location (a string path or an object) to the \"to\" prop."
|
|
288
|
-
},
|
|
289
|
-
VUE_ROUTER_R0060: {
|
|
290
|
-
why: (p) => `<router-view> can no longer be used directly inside <${p.comp}>.`,
|
|
291
|
-
fix: (p) => `Wrap the slot's resolved component with <${p.comp}> instead of nesting <router-view> in it:\n\n<router-view v-slot="{ Component }">\n <${p.comp}>\n <component :is="Component" />\n </${p.comp}>\n</router-view>`,
|
|
292
|
-
docs: "https://router.vuejs.org/guide/advanced/router-view-slot.html#KeepAlive-Transition"
|
|
293
|
-
},
|
|
294
|
-
VUE_ROUTER_R0070: {
|
|
295
|
-
why: (p) => `Cannot resolve a relative location without an absolute path. Trying to resolve "${p.to}" from "${p.from}".`,
|
|
296
|
-
fix: (p) => `Resolve from an absolute \`from\` path that starts with "/", e.g. "/${p.from}".`
|
|
297
|
-
},
|
|
298
|
-
VUE_ROUTER_R0080: {
|
|
299
|
-
why: (p) => `Error decoding "${p.text}". Using original value`,
|
|
300
|
-
fix: "Ensure the value is correctly percent-encoded."
|
|
301
|
-
},
|
|
302
|
-
VUE_ROUTER_R0090: {
|
|
303
|
-
why: (p) => `Found duplicated params with name "${p.name}" for path "${p.path}". Only the last one will be available on "$route.params".`,
|
|
304
|
-
fix: "Give each param a unique name within the path.",
|
|
305
|
-
docs: "https://router.vuejs.org/guide/essentials/route-matching-syntax.html"
|
|
306
|
-
},
|
|
307
|
-
VUE_ROUTER_R0100: {
|
|
308
|
-
why: (p) => `Discarded invalid param(s) "${p.params}" when navigating.` + p.inherited + ` See https://github.com/vuejs/router/commit/e887570 for more details.`,
|
|
309
|
-
fix: "Only pass params that exist on the target route."
|
|
310
|
-
},
|
|
311
|
-
VUE_ROUTER_R0101: {
|
|
312
|
-
why: (p) => `The Matcher cannot resolve relative paths but received "${p.path}". Unless you directly called \`matcher.resolve("${p.path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`,
|
|
313
|
-
fix: "Pass an absolute path (starting with \"/\") to the matcher."
|
|
314
|
-
},
|
|
315
|
-
VUE_ROUTER_R0102: {
|
|
316
|
-
why: (p) => `Alias "${p.alias}" and the original record: "${p.original}" must have the exact same param named "${p.name}"`,
|
|
317
|
-
fix: "Use the same param names in the alias as in the original route.",
|
|
318
|
-
docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Alias"
|
|
319
|
-
},
|
|
320
|
-
VUE_ROUTER_R0103: {
|
|
321
|
-
why: (p) => `The route named "${p.name}" has a child without a name, an empty path, and no children. Using that name won't render the empty path child, so this is probably a mistake.`,
|
|
322
|
-
fix: "Move the `name` onto the empty-path child; or, if intentional, give the child its own name to silence this.",
|
|
323
|
-
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html#Nested-Named-Routes"
|
|
324
|
-
},
|
|
325
|
-
VUE_ROUTER_R0104: {
|
|
326
|
-
why: (p) => `Absolute path "${p.path}" must have the exact same param named "${p.name}" as its parent "${p.parent}".`,
|
|
327
|
-
fix: "Include the parent route params in the absolute child path.",
|
|
328
|
-
docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
|
|
329
|
-
},
|
|
330
|
-
VUE_ROUTER_R0105: {
|
|
331
|
-
why: (p) => `Finding ancestor route "${p.ancestor}" failed for "${p.record}"`,
|
|
332
|
-
fix: "Report a reproduction at https://github.com/vuejs/router/issues/new/choose."
|
|
333
|
-
},
|
|
334
|
-
VUE_ROUTER_R0110: {
|
|
335
|
-
why: `A hash base must end with a "#"`,
|
|
336
|
-
fix: (p) => `Append "#" to the "base" argument passed to "createWebHashHistory()": "${p.base}" should be "${p.suggestion}".`
|
|
337
|
-
},
|
|
338
|
-
VUE_ROUTER_R0120: {
|
|
339
|
-
why: "Error with push/replace State",
|
|
340
|
-
fix: "The browser rejected the history API call; check for cross-origin or rate-limit issues."
|
|
341
|
-
},
|
|
342
|
-
VUE_ROUTER_R0121: {
|
|
343
|
-
why: "history.state seems to have been manually replaced without preserving the necessary values.\nYou can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state",
|
|
344
|
-
fix: "Merge the router's state into your own when calling it manually: `history.replaceState({ ...history.state, ...yourState }, '', url)`.",
|
|
345
|
-
docs: "https://router.vuejs.org/guide/migration.html#Usage-of-history-state"
|
|
346
|
-
},
|
|
347
|
-
VUE_ROUTER_R1001: {
|
|
348
|
-
why: (p) => `Data loader "${String(p.key)}" has a different parent than the current context. This shouldn't be happening.`,
|
|
349
|
-
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
|
350
|
-
},
|
|
351
|
-
VUE_ROUTER_R1002: {
|
|
352
|
-
why: "Returning a NavigationResult is deprecated.",
|
|
353
|
-
fix: "Replace `return new NavigationResult(to)` with `reroute(to)`, which throws internally to reroute.",
|
|
354
|
-
docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
|
|
355
|
-
},
|
|
356
|
-
VUE_ROUTER_R1003: {
|
|
357
|
-
why: (p) => `Loader "${p.key}"'s "commit()" was called but there is no staged data.`,
|
|
358
|
-
fix: "Ensure the loader resolved before calling `commit()`.",
|
|
359
|
-
docs: "https://router.vuejs.org/data-loaders/defining-loaders.html#Delaying-data-updates-with-commit"
|
|
360
|
-
},
|
|
361
|
-
VUE_ROUTER_R1004: {
|
|
362
|
-
why: (p) => "A loader returned a NavigationResult but is not registered on the route." + p.key,
|
|
363
|
-
fix: "Export the loader from the page component so it gets registered, e.g. `export const useUserData = defineLoader(...)`.",
|
|
364
|
-
docs: "https://router.vuejs.org/data-loaders/organization.html"
|
|
365
|
-
},
|
|
366
|
-
VUE_ROUTER_R1005: {
|
|
367
|
-
why: (p) => `Data loader "${p.key}" has itself as parent. This shouldn't be happening.`,
|
|
368
|
-
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
|
369
|
-
},
|
|
370
|
-
VUE_ROUTER_R1006: {
|
|
371
|
-
why: (p) => `A query was defined with the same key as the loader "[${p.key}]".\nSee https://pinia-colada.esm.dev/#TODO`,
|
|
372
|
-
fix: "If the key is meant to match, use the data loader directly; otherwise rename the `useQuery()` key so it no longer collides.",
|
|
373
|
-
docs: "https://router.vuejs.org/data-loaders/colada.html"
|
|
374
|
-
},
|
|
375
|
-
VUE_ROUTER_R1007: {
|
|
376
|
-
why: "Data Loader was setup twice.",
|
|
377
|
-
fix: "Register `DataLoaderPlugin` a single time via `app.use()`.",
|
|
378
|
-
docs: "https://router.vuejs.org/data-loaders.html#Installation"
|
|
379
|
-
},
|
|
380
|
-
VUE_ROUTER_R1008: {
|
|
381
|
-
why: "Data Loader is experimental and subject to breaking changes in the future.",
|
|
382
|
-
docs: "https://router.vuejs.org/data-loaders.html"
|
|
383
|
-
},
|
|
384
|
-
VUE_ROUTER_R1009: {
|
|
385
|
-
why: "Returning a NavigationResult from a loader is deprecated.",
|
|
386
|
-
fix: "Call `reroute(to)` inside the loader instead of returning `new NavigationResult(to)`; it throws internally to reroute.",
|
|
387
|
-
docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region src/injectionSymbols.ts
|
|
393
|
-
/**
|
|
394
|
-
* RouteRecord being rendered by the closest ancestor Router View. Used for
|
|
395
|
-
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
|
|
396
|
-
* Location Matched
|
|
397
|
-
*
|
|
398
|
-
* @internal
|
|
399
|
-
*/
|
|
400
|
-
const matchedRouteKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
|
|
401
|
-
/**
|
|
402
|
-
* Allows overriding the router view depth to control which component in
|
|
403
|
-
* `matched` is rendered. rvd stands for Router View Depth
|
|
404
|
-
*
|
|
405
|
-
* @internal
|
|
406
|
-
*/
|
|
407
|
-
const viewDepthKey = Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
|
|
408
|
-
/**
|
|
409
|
-
* Allows overriding the router instance returned by `useRouter` in tests. r
|
|
410
|
-
* stands for router
|
|
411
|
-
*
|
|
412
|
-
* @internal
|
|
413
|
-
*/
|
|
414
|
-
const routerKey = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
|
|
415
|
-
/**
|
|
416
|
-
* Allows overriding the current route returned by `useRoute` in tests. rl
|
|
417
|
-
* stands for route location
|
|
418
|
-
*
|
|
419
|
-
* @internal
|
|
420
|
-
*/
|
|
421
|
-
const routeLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
|
422
|
-
/**
|
|
423
|
-
* Allows overriding the current route used by router-view. Internally this is
|
|
424
|
-
* used when the `route` prop is passed.
|
|
425
|
-
*
|
|
426
|
-
* @internal
|
|
427
|
-
*/
|
|
428
|
-
const routerViewLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
|
|
429
|
-
//#endregion
|
|
430
|
-
//#region src/useApi.ts
|
|
431
|
-
/**
|
|
432
|
-
* Returns the router instance. Equivalent to using `$router` inside
|
|
433
|
-
* templates.
|
|
434
|
-
*/
|
|
435
|
-
function useRouter() {
|
|
436
|
-
return inject(routerKey);
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Returns the current route location. Equivalent to using `$route` inside
|
|
440
|
-
* templates.
|
|
441
|
-
*/
|
|
442
|
-
function useRoute(_name) {
|
|
443
|
-
return inject(routeLocationKey);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/*!
|
|
447
|
-
* vue-router v5.3.1
|
|
448
|
-
* (c) 2026 Eduardo San Martin Morote
|
|
449
|
-
* @license MIT
|
|
450
|
-
*/
|
|
451
|
-
//#region src/utils/env.ts
|
|
452
|
-
const isBrowser = typeof document !== "undefined";
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/encoding.ts
|
|
455
|
-
/**
|
|
456
|
-
* Encoding Rules (␣ = Space)
|
|
457
|
-
* - Path: ␣ " < > # ? { }
|
|
458
|
-
* - Query: ␣ " < > # & =
|
|
459
|
-
* - Hash: ␣ " < > `
|
|
460
|
-
*
|
|
461
|
-
* On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
|
|
462
|
-
* defines some extra characters to be encoded. Most browsers do not encode them
|
|
463
|
-
* in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
|
|
464
|
-
* also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
|
|
465
|
-
* plus `-._~`. This extra safety should be applied to query by patching the
|
|
466
|
-
* string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
|
|
467
|
-
* should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
|
|
468
|
-
* into a `/` if directly typed in. The _backtick_ (`````) should also be
|
|
469
|
-
* encoded everywhere because some browsers like FF encode it when directly
|
|
470
|
-
* written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
|
|
471
|
-
*/
|
|
472
|
-
const HASH_RE = /#/g;
|
|
473
|
-
const AMPERSAND_RE = /&/g;
|
|
474
|
-
const SLASH_RE = /\//g;
|
|
475
|
-
const EQUAL_RE = /=/g;
|
|
476
|
-
const IM_RE = /\?/g;
|
|
477
|
-
const PLUS_RE = /\+/g;
|
|
478
|
-
/**
|
|
479
|
-
* NOTE: It's not clear to me if we should encode the + symbol in queries, it
|
|
480
|
-
* seems to be less flexible than not doing so and I can't find out the legacy
|
|
481
|
-
* systems requiring this for regular requests like text/html. In the standard,
|
|
482
|
-
* the encoding of the plus character is only mentioned for
|
|
483
|
-
* application/x-www-form-urlencoded
|
|
484
|
-
* (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
|
|
485
|
-
* leave the plus character as is in queries. To be more flexible, we allow the
|
|
486
|
-
* plus character on the query, but it can also be manually encoded by the user.
|
|
487
|
-
*
|
|
488
|
-
* Resources:
|
|
489
|
-
* - https://url.spec.whatwg.org/#urlencoded-parsing
|
|
490
|
-
* - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
|
|
491
|
-
*/
|
|
492
|
-
const ENC_BRACKET_OPEN_RE = /%5B/g;
|
|
493
|
-
const ENC_BRACKET_CLOSE_RE = /%5D/g;
|
|
494
|
-
const ENC_CARET_RE = /%5E/g;
|
|
495
|
-
const ENC_BACKTICK_RE = /%60/g;
|
|
496
|
-
const ENC_CURLY_OPEN_RE = /%7B/g;
|
|
497
|
-
const ENC_PIPE_RE = /%7C/g;
|
|
498
|
-
const ENC_CURLY_CLOSE_RE = /%7D/g;
|
|
499
|
-
const ENC_SPACE_RE = /%20/g;
|
|
500
|
-
/**
|
|
501
|
-
* Encode characters that need to be encoded on the path, search and hash
|
|
502
|
-
* sections of the URL.
|
|
503
|
-
*
|
|
504
|
-
* @internal
|
|
505
|
-
* @param text - string to encode
|
|
506
|
-
* @returns encoded string
|
|
507
|
-
*/
|
|
508
|
-
function commonEncode(text) {
|
|
509
|
-
return text == null ? "" : encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Encode characters that need to be encoded on the hash section of the URL.
|
|
513
|
-
*
|
|
514
|
-
* @param text - string to encode
|
|
515
|
-
* @returns encoded string
|
|
516
|
-
*/
|
|
517
|
-
function encodeHash(text) {
|
|
518
|
-
return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Encode characters that need to be encoded query values on the query
|
|
522
|
-
* section of the URL.
|
|
523
|
-
*
|
|
524
|
-
* @param text - string to encode
|
|
525
|
-
* @returns encoded string
|
|
526
|
-
*/
|
|
527
|
-
function encodeQueryValue(text) {
|
|
528
|
-
return commonEncode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Like `encodeQueryValue` but also encodes the `=` character.
|
|
532
|
-
*
|
|
533
|
-
* @param text - string to encode
|
|
534
|
-
*/
|
|
535
|
-
function encodeQueryKey(text) {
|
|
536
|
-
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Encode characters that need to be encoded on the path section of the URL.
|
|
540
|
-
*
|
|
541
|
-
* @param text - string to encode
|
|
542
|
-
* @returns encoded string
|
|
543
|
-
*/
|
|
544
|
-
function encodePath(text) {
|
|
545
|
-
return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Encode characters that need to be encoded on the path section of the URL as a
|
|
549
|
-
* param. This function encodes everything {@link encodePath} does plus the
|
|
550
|
-
* slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
|
|
551
|
-
* string instead.
|
|
552
|
-
*
|
|
553
|
-
* @param text - string to encode
|
|
554
|
-
* @returns encoded string
|
|
555
|
-
*/
|
|
556
|
-
function encodeParam(text) {
|
|
557
|
-
return encodePath(text).replace(SLASH_RE, "%2F");
|
|
558
|
-
}
|
|
559
|
-
function decode(text) {
|
|
560
|
-
if (text == null) return null;
|
|
561
|
-
try {
|
|
562
|
-
return decodeURIComponent("" + text);
|
|
563
|
-
} catch {
|
|
564
|
-
process.env.NODE_ENV !== "production" && diagnostics.VUE_ROUTER_R0080({ text: "" + text });
|
|
565
|
-
}
|
|
566
|
-
return "" + text;
|
|
567
|
-
}
|
|
568
|
-
//#endregion
|
|
569
|
-
//#region src/location.ts
|
|
570
|
-
const TRAILING_SLASH_RE = /\/$/;
|
|
571
|
-
const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
|
|
572
|
-
/**
|
|
573
|
-
* Transforms a URI into a normalized history location
|
|
574
|
-
*
|
|
575
|
-
* @param parseQuery
|
|
576
|
-
* @param location - URI to normalize
|
|
577
|
-
* @param currentLocation - current absolute location. Allows resolving relative
|
|
578
|
-
* paths. Must start with `/`. Defaults to `/`
|
|
579
|
-
* @returns a normalized history location
|
|
580
|
-
*/
|
|
581
|
-
function parseURL(parseQuery, location, currentLocation = "/") {
|
|
582
|
-
let path, query = {}, searchString = "", hash = "";
|
|
583
|
-
const hashPos = location.indexOf("#");
|
|
584
|
-
let searchPos = location.indexOf("?");
|
|
585
|
-
searchPos = hashPos >= 0 && searchPos > hashPos ? -1 : searchPos;
|
|
586
|
-
if (searchPos >= 0) {
|
|
587
|
-
path = location.slice(0, searchPos);
|
|
588
|
-
searchString = location.slice(searchPos, hashPos > 0 ? hashPos : location.length);
|
|
589
|
-
query = parseQuery(searchString.slice(1));
|
|
590
|
-
}
|
|
591
|
-
if (hashPos >= 0) {
|
|
592
|
-
path = path || location.slice(0, hashPos);
|
|
593
|
-
hash = location.slice(hashPos, location.length);
|
|
594
|
-
}
|
|
595
|
-
path = resolveRelativePath(path != null ? path : location, currentLocation);
|
|
596
|
-
return {
|
|
597
|
-
fullPath: path + searchString + hash,
|
|
598
|
-
path,
|
|
599
|
-
query,
|
|
600
|
-
hash: decode(hash)
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
function NEW_stringifyURL(stringifyQuery, path, query, hash = "") {
|
|
604
|
-
const searchText = stringifyQuery(query);
|
|
605
|
-
return path + (searchText && "?") + searchText + encodeHash(hash);
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Stringifies a URL object
|
|
609
|
-
*
|
|
610
|
-
* @param stringifyQuery
|
|
611
|
-
* @param location
|
|
612
|
-
*/
|
|
613
|
-
function stringifyURL(stringifyQuery, location) {
|
|
614
|
-
const query = location.query ? stringifyQuery(location.query) : "";
|
|
615
|
-
return location.path + (query && "?") + query + (location.hash || "");
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Strips off the base from the beginning of a location.pathname in a non-case-sensitive way.
|
|
619
|
-
*
|
|
620
|
-
* @param pathname - location.pathname
|
|
621
|
-
* @param base - base to strip off
|
|
622
|
-
*/
|
|
623
|
-
function stripBase(pathname, base) {
|
|
624
|
-
if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase())) return pathname;
|
|
625
|
-
return pathname.slice(base.length) || "/";
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Checks if two RouteLocation are equal. This means that both locations are
|
|
629
|
-
* pointing towards the same {@link RouteRecord} and that all `params`, `query`
|
|
630
|
-
* parameters and `hash` are the same
|
|
631
|
-
*
|
|
632
|
-
* @param stringifyQuery - A function that takes a query object of type LocationQueryRaw and returns a string representation of it.
|
|
633
|
-
* @param a - first {@link RouteLocation}
|
|
634
|
-
* @param b - second {@link RouteLocation}
|
|
635
|
-
*/
|
|
636
|
-
function isSameRouteLocation(stringifyQuery, a, b) {
|
|
637
|
-
const aLastIndex = a.matched.length - 1;
|
|
638
|
-
const bLastIndex = b.matched.length - 1;
|
|
639
|
-
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery(a.query) === stringifyQuery(b.query) && a.hash === b.hash;
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Check if two `RouteRecords` are equal. Takes into account aliases: they are
|
|
643
|
-
* considered equal to the `RouteRecord` they are aliasing.
|
|
644
|
-
*
|
|
645
|
-
* @param a - first {@link RouteRecord}
|
|
646
|
-
* @param b - second {@link RouteRecord}
|
|
647
|
-
*/
|
|
648
|
-
function isSameRouteRecord(a, b) {
|
|
649
|
-
return (a.aliasOf || a) === (b.aliasOf || b);
|
|
650
|
-
}
|
|
651
|
-
function isSameRouteLocationParams(a, b) {
|
|
652
|
-
if (Object.keys(a).length !== Object.keys(b).length) return false;
|
|
653
|
-
for (var key in a) if (!isSameRouteLocationParamsValue(a[key], b[key])) return false;
|
|
654
|
-
return true;
|
|
655
|
-
}
|
|
656
|
-
function isSameRouteLocationParamsValue(a, b) {
|
|
657
|
-
return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : (a && a.valueOf()) === (b && b.valueOf());
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Check if two arrays are the same or if an array with one single entry is the
|
|
661
|
-
* same as another primitive value. Used to check query and parameters
|
|
662
|
-
*
|
|
663
|
-
* @param a - array of values
|
|
664
|
-
* @param b - array of values or a single value
|
|
665
|
-
*/
|
|
666
|
-
function isEquivalentArray(a, b) {
|
|
667
|
-
return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Resolves a relative path that starts with `.`.
|
|
671
|
-
*
|
|
672
|
-
* @param to - path location we are resolving
|
|
673
|
-
* @param from - currentLocation.path, should start with `/`
|
|
674
|
-
*/
|
|
675
|
-
function resolveRelativePath(to, from) {
|
|
676
|
-
if (isAbsolutePath(to)) return to;
|
|
677
|
-
if (process.env.NODE_ENV !== "production" && !isAbsolutePath(from)) {
|
|
678
|
-
diagnostics.VUE_ROUTER_R0070({
|
|
679
|
-
to,
|
|
680
|
-
from
|
|
681
|
-
});
|
|
682
|
-
return to;
|
|
683
|
-
}
|
|
684
|
-
if (!to) return from;
|
|
685
|
-
const fromSegments = from.split("/");
|
|
686
|
-
const toSegments = to.split("/");
|
|
687
|
-
const lastToSegment = toSegments[toSegments.length - 1];
|
|
688
|
-
if (lastToSegment === ".." || lastToSegment === ".") toSegments.push("");
|
|
689
|
-
let position = fromSegments.length - 1;
|
|
690
|
-
let toPosition;
|
|
691
|
-
let segment;
|
|
692
|
-
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
|
|
693
|
-
segment = toSegments[toPosition];
|
|
694
|
-
if (segment === ".") continue;
|
|
695
|
-
if (segment === "..") {
|
|
696
|
-
if (position > 1) position--;
|
|
697
|
-
} else break;
|
|
698
|
-
}
|
|
699
|
-
return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition).join("/");
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Initial route location where the router is. Can be used in navigation guards
|
|
703
|
-
* to differentiate the initial navigation.
|
|
704
|
-
*
|
|
705
|
-
* @example
|
|
706
|
-
* ```js
|
|
707
|
-
* import { START_LOCATION } from 'vue-router'
|
|
708
|
-
*
|
|
709
|
-
* router.beforeEach((to, from) => {
|
|
710
|
-
* if (from === START_LOCATION) {
|
|
711
|
-
* // initial navigation
|
|
712
|
-
* }
|
|
713
|
-
* })
|
|
714
|
-
* ```
|
|
715
|
-
*/
|
|
716
|
-
const START_LOCATION_NORMALIZED = {
|
|
717
|
-
path: "/",
|
|
718
|
-
name: void 0,
|
|
719
|
-
params: {},
|
|
720
|
-
query: {},
|
|
721
|
-
hash: "",
|
|
722
|
-
fullPath: "/",
|
|
723
|
-
matched: [],
|
|
724
|
-
meta: {},
|
|
725
|
-
redirectedFrom: void 0
|
|
726
|
-
};
|
|
727
|
-
//#endregion
|
|
728
|
-
//#region src/history/common.ts
|
|
729
|
-
/**
|
|
730
|
-
* Normalizes a base by removing any trailing slash and reading the base tag if
|
|
731
|
-
* present.
|
|
732
|
-
*
|
|
733
|
-
* @param base - base to normalize
|
|
734
|
-
*/
|
|
735
|
-
function normalizeBase(base) {
|
|
736
|
-
if (!base) {
|
|
737
|
-
if (isBrowser) {
|
|
738
|
-
const baseEl = document.querySelector("base");
|
|
739
|
-
base = baseEl && baseEl.getAttribute("href") || "/";
|
|
740
|
-
base = base.replace(/^\w+:\/\/[^/]+/, "");
|
|
741
|
-
} else base = "/";
|
|
742
|
-
}
|
|
743
|
-
if (base[0] !== "/" && base[0] !== "#") base = "/" + base;
|
|
744
|
-
return removeTrailingSlash(base);
|
|
745
|
-
}
|
|
746
|
-
const BEFORE_HASH_RE = /^[^#]+#/;
|
|
747
|
-
function createHref(base, location) {
|
|
748
|
-
return base.replace(BEFORE_HASH_RE, "#") + location;
|
|
749
|
-
}
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region src/scrollBehavior.ts
|
|
752
|
-
function getElementPosition(el, offset) {
|
|
753
|
-
const docRect = document.documentElement.getBoundingClientRect();
|
|
754
|
-
const elRect = el.getBoundingClientRect();
|
|
755
|
-
return {
|
|
756
|
-
behavior: offset.behavior,
|
|
757
|
-
left: elRect.left - docRect.left - (offset.left || 0),
|
|
758
|
-
top: elRect.top - docRect.top - (offset.top || 0)
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
const computeScrollPosition = () => history.scrollRestoration === "manual" ? {
|
|
762
|
-
left: window.scrollX,
|
|
763
|
-
top: window.scrollY
|
|
764
|
-
} : null;
|
|
765
|
-
function scrollToPosition(position) {
|
|
766
|
-
let scrollToOptions;
|
|
767
|
-
if ("el" in position) {
|
|
768
|
-
const positionEl = position.el;
|
|
769
|
-
const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
|
|
770
|
-
/**
|
|
771
|
-
* `id`s can accept pretty much any characters, including CSS combinators
|
|
772
|
-
* like `>` or `~`. It's still possible to retrieve elements using
|
|
773
|
-
* `document.getElementById('~')` but it needs to be escaped when using
|
|
774
|
-
* `document.querySelector('#\\~')` for it to be valid. The only
|
|
775
|
-
* requirements for `id`s are them to be unique on the page and to not be
|
|
776
|
-
* empty (`id=""`). Because of that, when passing an id selector, it should
|
|
777
|
-
* be properly escaped for it to work with `querySelector`. We could check
|
|
778
|
-
* for the id selector to be simple (no CSS combinators `+ >~`) but that
|
|
779
|
-
* would make things inconsistent since they are valid characters for an
|
|
780
|
-
* `id` but would need to be escaped when using `querySelector`, breaking
|
|
781
|
-
* their usage and ending up in no selector returned. Selectors need to be
|
|
782
|
-
* escaped:
|
|
783
|
-
*
|
|
784
|
-
* - `#1-thing` becomes `#\31 -thing`
|
|
785
|
-
* - `#with~symbols` becomes `#with\\~symbols`
|
|
786
|
-
*
|
|
787
|
-
* - More information about the topic can be found at
|
|
788
|
-
* https://mathiasbynens.be/notes/html5-id-class.
|
|
789
|
-
* - Practical example: https://mathiasbynens.be/demo/html5-id
|
|
790
|
-
*/
|
|
791
|
-
if (process.env.NODE_ENV !== "production" && typeof position.el === "string") {
|
|
792
|
-
if (!isIdSelector || !document.getElementById(position.el.slice(1))) try {
|
|
793
|
-
const foundEl = document.querySelector(position.el);
|
|
794
|
-
if (isIdSelector && foundEl) {
|
|
795
|
-
diagnostics.VUE_ROUTER_R0040({ el: position.el });
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
} catch {
|
|
799
|
-
diagnostics.VUE_ROUTER_R0041({ el: position.el });
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
|
|
804
|
-
if (!el) {
|
|
805
|
-
process.env.NODE_ENV !== "production" && diagnostics.VUE_ROUTER_R0042({ el: position.el });
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
scrollToOptions = getElementPosition(el, position);
|
|
809
|
-
} else scrollToOptions = position;
|
|
810
|
-
if ("scrollBehavior" in document.documentElement.style) window.scrollTo(scrollToOptions);
|
|
811
|
-
else window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
|
|
812
|
-
}
|
|
813
|
-
function getScrollKey(path, delta) {
|
|
814
|
-
return (history.state ? history.state.position - delta : -1) + path;
|
|
815
|
-
}
|
|
816
|
-
const scrollPositions = /* @__PURE__ */ new Map();
|
|
817
|
-
function saveScrollPosition(key) {
|
|
818
|
-
scrollPositions.set(key, computeScrollPosition());
|
|
819
|
-
}
|
|
820
|
-
function getSavedScrollPosition(key) {
|
|
821
|
-
const scroll = scrollPositions.get(key);
|
|
822
|
-
scrollPositions.delete(key);
|
|
823
|
-
return scroll;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* ScrollBehavior instance used by the router to compute and restore the scroll
|
|
827
|
-
* position when navigating.
|
|
828
|
-
*/
|
|
829
|
-
//#endregion
|
|
830
|
-
//#region src/types/typeGuards.ts
|
|
831
|
-
function isRouteLocation(route) {
|
|
832
|
-
return typeof route === "string" || route && typeof route === "object";
|
|
833
|
-
}
|
|
834
|
-
function isRouteName(name) {
|
|
835
|
-
return typeof name === "string" || typeof name === "symbol";
|
|
836
|
-
}
|
|
837
|
-
//#endregion
|
|
838
|
-
//#region src/query.ts
|
|
839
|
-
/**
|
|
840
|
-
* Transforms a queryString into a {@link LocationQuery} object. Accept both, a
|
|
841
|
-
* version with the leading `?` and without Should work as URLSearchParams
|
|
842
|
-
|
|
843
|
-
* @internal
|
|
844
|
-
*
|
|
845
|
-
* @param search - search string to parse
|
|
846
|
-
* @returns a query object
|
|
847
|
-
*/
|
|
848
|
-
function parseQuery(search) {
|
|
849
|
-
const query = {};
|
|
850
|
-
if (search === "" || search === "?") return query;
|
|
851
|
-
const searchParams = (search[0] === "?" ? search.slice(1) : search).split("&");
|
|
852
|
-
for (let i = 0; i < searchParams.length; ++i) {
|
|
853
|
-
const searchParam = searchParams[i].replace(PLUS_RE, " ");
|
|
854
|
-
const eqPos = searchParam.indexOf("=");
|
|
855
|
-
const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
|
|
856
|
-
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
|
|
857
|
-
if (key in query) {
|
|
858
|
-
let currentValue = query[key];
|
|
859
|
-
if (!isArray(currentValue)) currentValue = query[key] = [currentValue];
|
|
860
|
-
currentValue.push(value);
|
|
861
|
-
} else query[key] = value;
|
|
862
|
-
}
|
|
863
|
-
return query;
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
|
|
867
|
-
* doesn't prepend a `?`
|
|
868
|
-
*
|
|
869
|
-
* @internal
|
|
870
|
-
*
|
|
871
|
-
* @param query - query object to stringify
|
|
872
|
-
* @returns string version of the query without the leading `?`
|
|
873
|
-
*/
|
|
874
|
-
function stringifyQuery(query) {
|
|
875
|
-
let search = "";
|
|
876
|
-
for (let key in query) {
|
|
877
|
-
const value = query[key];
|
|
878
|
-
key = encodeQueryKey(key);
|
|
879
|
-
if (value == null) {
|
|
880
|
-
if (value !== void 0) search += (search.length ? "&" : "") + key;
|
|
881
|
-
continue;
|
|
882
|
-
}
|
|
883
|
-
(isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)]).forEach((value) => {
|
|
884
|
-
if (value !== void 0) {
|
|
885
|
-
search += (search.length ? "&" : "") + key;
|
|
886
|
-
if (value != null) search += "=" + value;
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
return search;
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Transforms a {@link LocationQueryRaw} into a {@link LocationQuery} by casting
|
|
894
|
-
* numbers into strings, removing keys with an undefined value and replacing
|
|
895
|
-
* undefined with null in arrays
|
|
896
|
-
*
|
|
897
|
-
* @param query - query object to normalize
|
|
898
|
-
* @returns a normalized query object
|
|
899
|
-
*/
|
|
900
|
-
function normalizeQuery(query) {
|
|
901
|
-
const normalizedQuery = {};
|
|
902
|
-
for (const key in query) {
|
|
903
|
-
const value = query[key];
|
|
904
|
-
if (value !== void 0) normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
|
|
905
|
-
}
|
|
906
|
-
return normalizedQuery;
|
|
907
|
-
}
|
|
908
|
-
//#endregion
|
|
909
|
-
//#region src/utils/callbacks.ts
|
|
910
|
-
/**
|
|
911
|
-
* Create a list of callbacks that can be reset. Used to create before and after navigation guards list
|
|
912
|
-
*/
|
|
913
|
-
function useCallbacks() {
|
|
914
|
-
let handlers = [];
|
|
915
|
-
function add(handler) {
|
|
916
|
-
handlers.push(handler);
|
|
917
|
-
return () => {
|
|
918
|
-
const i = handlers.indexOf(handler);
|
|
919
|
-
if (i > -1) handlers.splice(i, 1);
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
function reset() {
|
|
923
|
-
handlers = [];
|
|
924
|
-
}
|
|
925
|
-
return {
|
|
926
|
-
add,
|
|
927
|
-
list: () => handlers.slice(),
|
|
928
|
-
reset
|
|
929
|
-
};
|
|
930
|
-
}
|
|
931
|
-
//#endregion
|
|
932
|
-
//#region src/navigationGuards.ts
|
|
933
|
-
function registerGuard(activeRecordRef, name, guard) {
|
|
934
|
-
const record = activeRecordRef.value;
|
|
935
|
-
if (!record) {
|
|
936
|
-
if (process.env.NODE_ENV !== "production") {
|
|
937
|
-
const fnName = name === "updateGuards" ? "onBeforeRouteUpdate" : "onBeforeRouteLeave";
|
|
938
|
-
diagnostics.VUE_ROUTER_R0020({ fn: fnName });
|
|
939
|
-
}
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
let currentRecord = record;
|
|
943
|
-
const removeFromList = () => {
|
|
944
|
-
currentRecord[name].delete(guard);
|
|
945
|
-
};
|
|
946
|
-
onUnmounted(removeFromList);
|
|
947
|
-
onDeactivated(removeFromList);
|
|
948
|
-
onActivated(() => {
|
|
949
|
-
const newRecord = activeRecordRef.value;
|
|
950
|
-
if (process.env.NODE_ENV !== "production" && !newRecord) diagnostics.VUE_ROUTER_R0021();
|
|
951
|
-
if (newRecord) currentRecord = newRecord;
|
|
952
|
-
currentRecord[name].add(guard);
|
|
953
|
-
});
|
|
954
|
-
currentRecord[name].add(guard);
|
|
955
|
-
}
|
|
956
|
-
/**
|
|
957
|
-
* Add a navigation guard that triggers whenever the component for the current
|
|
958
|
-
* location is about to be left. Similar to {@link beforeRouteLeave} but can be
|
|
959
|
-
* used in any component. The guard is removed when the component is unmounted.
|
|
960
|
-
*
|
|
961
|
-
* @param leaveGuard - {@link NavigationGuard}
|
|
962
|
-
*/
|
|
963
|
-
function onBeforeRouteLeave(leaveGuard) {
|
|
964
|
-
if (process.env.NODE_ENV !== "production" && !getCurrentInstance()) {
|
|
965
|
-
diagnostics.VUE_ROUTER_R0022({ fn: "onBeforeRouteLeave" });
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
registerGuard(inject(matchedRouteKey, {}), "leaveGuards", leaveGuard);
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Add a navigation guard that triggers whenever the current location is about
|
|
972
|
-
* to be updated. Similar to {@link beforeRouteUpdate} but can be used in any
|
|
973
|
-
* component. The guard is removed when the component is unmounted.
|
|
974
|
-
*
|
|
975
|
-
* @param updateGuard - {@link NavigationGuard}
|
|
976
|
-
*/
|
|
977
|
-
function onBeforeRouteUpdate(updateGuard) {
|
|
978
|
-
if (process.env.NODE_ENV !== "production" && !getCurrentInstance()) {
|
|
979
|
-
diagnostics.VUE_ROUTER_R0022({ fn: "onBeforeRouteUpdate" });
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
registerGuard(inject(matchedRouteKey, {}), "updateGuards", updateGuard);
|
|
983
|
-
}
|
|
984
|
-
function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
|
|
985
|
-
const enterCallbackArray = record && (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
|
|
986
|
-
return () => new Promise((resolve, reject) => {
|
|
987
|
-
const next = (valid) => {
|
|
988
|
-
if (valid === false) reject(createRouterError(4, {
|
|
989
|
-
from,
|
|
990
|
-
to
|
|
991
|
-
}));
|
|
992
|
-
else if (valid instanceof Error) reject(valid);
|
|
993
|
-
else if (isRouteLocation(valid)) reject(createRouterError(2, {
|
|
994
|
-
from: to,
|
|
995
|
-
to: valid
|
|
996
|
-
}));
|
|
997
|
-
else {
|
|
998
|
-
if (enterCallbackArray && record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") enterCallbackArray.push(valid);
|
|
999
|
-
resolve();
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, process.env.NODE_ENV !== "production" ? withDeprecationWarning(canOnlyBeCalledOnce(next, to, from)) : next));
|
|
1003
|
-
let guardCall = Promise.resolve(guardReturn);
|
|
1004
|
-
if (guard.length < 3) guardCall = guardCall.then(next);
|
|
1005
|
-
if (process.env.NODE_ENV !== "production" && guard.length > 2) {
|
|
1006
|
-
const guardInfo = {
|
|
1007
|
-
name: guard.name,
|
|
1008
|
-
guard: guard.toString()
|
|
1009
|
-
};
|
|
1010
|
-
if (typeof guardReturn === "object" && "then" in guardReturn) guardCall = guardCall.then((resolvedValue) => {
|
|
1011
|
-
if (!next._called) {
|
|
1012
|
-
diagnostics.VUE_ROUTER_R0023(guardInfo);
|
|
1013
|
-
return Promise.reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
|
|
1014
|
-
}
|
|
1015
|
-
return resolvedValue;
|
|
1016
|
-
});
|
|
1017
|
-
else if (guardReturn !== void 0) {
|
|
1018
|
-
if (!next._called) {
|
|
1019
|
-
diagnostics.VUE_ROUTER_R0023(guardInfo);
|
|
1020
|
-
reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
guardCall.catch((err) => reject(err));
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Wraps the next callback to warn when it is used. Dev-only: when __DEV__ is
|
|
1030
|
-
* false (production builds), this branch is dead code and is stripped from the
|
|
1031
|
-
* bundle.
|
|
1032
|
-
*
|
|
1033
|
-
* @internal
|
|
1034
|
-
*/
|
|
1035
|
-
function withDeprecationWarning(next) {
|
|
1036
|
-
let warned = false;
|
|
1037
|
-
return function() {
|
|
1038
|
-
if (!warned) {
|
|
1039
|
-
warned = true;
|
|
1040
|
-
diagnostics.VUE_ROUTER_R0025();
|
|
1041
|
-
}
|
|
1042
|
-
return next.apply(this, arguments);
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
function canOnlyBeCalledOnce(next, to, from) {
|
|
1046
|
-
let called = 0;
|
|
1047
|
-
return function() {
|
|
1048
|
-
if (called++ === 1) diagnostics.VUE_ROUTER_R0024({
|
|
1049
|
-
from: from.fullPath,
|
|
1050
|
-
to: to.fullPath
|
|
1051
|
-
});
|
|
1052
|
-
next._called = true;
|
|
1053
|
-
if (called === 1) next.apply(null, arguments);
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
|
|
1057
|
-
const guards = [];
|
|
1058
|
-
for (const record of matched) {
|
|
1059
|
-
if (process.env.NODE_ENV !== "production" && !record.components && record.children && !record.children.length) diagnostics.VUE_ROUTER_R0026({ path: record.path });
|
|
1060
|
-
for (const name in record.components) {
|
|
1061
|
-
let rawComponent = record.components[name];
|
|
1062
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1063
|
-
if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
|
|
1064
|
-
diagnostics.VUE_ROUTER_R0027({
|
|
1065
|
-
name,
|
|
1066
|
-
path: record.path,
|
|
1067
|
-
received: String(rawComponent)
|
|
1068
|
-
});
|
|
1069
|
-
throw new Error("Invalid route component");
|
|
1070
|
-
} else if ("then" in rawComponent) {
|
|
1071
|
-
diagnostics.VUE_ROUTER_R0028({
|
|
1072
|
-
name,
|
|
1073
|
-
path: record.path
|
|
1074
|
-
});
|
|
1075
|
-
const promise = rawComponent;
|
|
1076
|
-
rawComponent = () => promise;
|
|
1077
|
-
} else if (rawComponent.__asyncLoader && !rawComponent.__warnedDefineAsync) {
|
|
1078
|
-
rawComponent.__warnedDefineAsync = true;
|
|
1079
|
-
diagnostics.VUE_ROUTER_R0029({
|
|
1080
|
-
name,
|
|
1081
|
-
path: record.path
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
if (guardType !== "beforeRouteEnter" && !record.instances[name]) continue;
|
|
1086
|
-
if (isRouteComponent(rawComponent)) {
|
|
1087
|
-
const guard = (rawComponent.__vccOpts || rawComponent)[guardType];
|
|
1088
|
-
guard && guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
|
|
1089
|
-
} else {
|
|
1090
|
-
let componentPromise = rawComponent();
|
|
1091
|
-
if (process.env.NODE_ENV !== "production" && !("catch" in componentPromise)) {
|
|
1092
|
-
diagnostics.VUE_ROUTER_R0030({
|
|
1093
|
-
name,
|
|
1094
|
-
path: record.path
|
|
1095
|
-
});
|
|
1096
|
-
componentPromise = Promise.resolve(componentPromise);
|
|
1097
|
-
}
|
|
1098
|
-
guards.push(() => componentPromise.then((resolved) => {
|
|
1099
|
-
if (!resolved) throw new Error(`Couldn't resolve component "${name}" at "${record.path}"`);
|
|
1100
|
-
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
|
|
1101
|
-
record.mods[name] = resolved;
|
|
1102
|
-
record.components[name] = resolvedComponent;
|
|
1103
|
-
const guard = (resolvedComponent.__vccOpts || resolvedComponent)[guardType];
|
|
1104
|
-
return guard && guardToPromiseFn(guard, to, from, record, name, runWithContext)();
|
|
1105
|
-
}));
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
return guards;
|
|
1110
|
-
}
|
|
1111
|
-
/**
|
|
1112
|
-
* Ensures a route is loaded, so it can be passed as o prop to `<RouterView>`.
|
|
1113
|
-
*
|
|
1114
|
-
* @param route - resolved route to load
|
|
1115
|
-
*/
|
|
1116
|
-
function loadRouteLocation(route) {
|
|
1117
|
-
return route.matched.every((record) => record.redirect) ? Promise.reject(/* @__PURE__ */ new Error("Cannot load a route that redirects.")) : Promise.all(route.matched.map((record) => record.components && Promise.all(Object.keys(record.components).reduce((promises, name) => {
|
|
1118
|
-
const rawComponent = record.components[name];
|
|
1119
|
-
if (typeof rawComponent === "function" && !("displayName" in rawComponent)) promises.push(rawComponent().then((resolved) => {
|
|
1120
|
-
if (!resolved) return Promise.reject(/* @__PURE__ */ new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
|
|
1121
|
-
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
|
|
1122
|
-
record.mods[name] = resolved;
|
|
1123
|
-
record.components[name] = resolvedComponent;
|
|
1124
|
-
}));
|
|
1125
|
-
return promises;
|
|
1126
|
-
}, [])))).then(() => route);
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* Split the leaving, updating, and entering records.
|
|
1130
|
-
* @internal
|
|
1131
|
-
*
|
|
1132
|
-
* @param to - Location we are navigating to
|
|
1133
|
-
* @param from - Location we are navigating from
|
|
1134
|
-
*/
|
|
1135
|
-
function extractChangingRecords(to, from) {
|
|
1136
|
-
const leavingRecords = [];
|
|
1137
|
-
const updatingRecords = [];
|
|
1138
|
-
const enteringRecords = [];
|
|
1139
|
-
const len = Math.max(from.matched.length, to.matched.length);
|
|
1140
|
-
for (let i = 0; i < len; i++) {
|
|
1141
|
-
const recordFrom = from.matched[i];
|
|
1142
|
-
if (recordFrom) {
|
|
1143
|
-
if (to.matched.find((record) => isSameRouteRecord(record, recordFrom))) updatingRecords.push(recordFrom);
|
|
1144
|
-
else leavingRecords.push(recordFrom);
|
|
1145
|
-
}
|
|
1146
|
-
const recordTo = to.matched[i];
|
|
1147
|
-
if (recordTo) {
|
|
1148
|
-
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) enteringRecords.push(recordTo);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
return [
|
|
1152
|
-
leavingRecords,
|
|
1153
|
-
updatingRecords,
|
|
1154
|
-
enteringRecords
|
|
1155
|
-
];
|
|
1156
|
-
}
|
|
1157
|
-
//#endregion
|
|
1158
|
-
//#region src/devtools.ts
|
|
1159
|
-
/**
|
|
1160
|
-
* Copies a route location and removes any problematic properties that cannot be shown in devtools (e.g. Vue instances).
|
|
1161
|
-
*
|
|
1162
|
-
* @param routeLocation - routeLocation to format
|
|
1163
|
-
* @param tooltip - optional tooltip
|
|
1164
|
-
* @returns a copy of the routeLocation
|
|
1165
|
-
*/
|
|
1166
|
-
function formatRouteLocation(routeLocation, tooltip) {
|
|
1167
|
-
const copy = assign({}, routeLocation, { matched: routeLocation.matched.map((matched) => omit(matched, [
|
|
1168
|
-
"instances",
|
|
1169
|
-
"children",
|
|
1170
|
-
"aliasOf"
|
|
1171
|
-
])) });
|
|
1172
|
-
return { _custom: {
|
|
1173
|
-
type: null,
|
|
1174
|
-
readOnly: true,
|
|
1175
|
-
display: routeLocation.fullPath,
|
|
1176
|
-
tooltip,
|
|
1177
|
-
value: copy
|
|
1178
|
-
} };
|
|
1179
|
-
}
|
|
1180
|
-
function formatDisplay(display) {
|
|
1181
|
-
return { _custom: { display } };
|
|
1182
|
-
}
|
|
1183
|
-
let routerId = 0;
|
|
1184
|
-
function addDevtools(app, router, matcher) {
|
|
1185
|
-
if (router.__hasDevtools) return;
|
|
1186
|
-
router.__hasDevtools = true;
|
|
1187
|
-
const id = routerId++;
|
|
1188
|
-
setupDevToolsPlugin({
|
|
1189
|
-
id: "org.vuejs.router" + (id ? "." + id : ""),
|
|
1190
|
-
label: "Vue Router",
|
|
1191
|
-
packageName: "vue-router",
|
|
1192
|
-
homepage: "https://router.vuejs.org",
|
|
1193
|
-
logo: "https://router.vuejs.org/logo.png",
|
|
1194
|
-
componentStateTypes: ["Routing"],
|
|
1195
|
-
app
|
|
1196
|
-
}, (api) => {
|
|
1197
|
-
api.on.inspectComponent((payload) => {
|
|
1198
|
-
if (payload.instanceData) payload.instanceData.state.push({
|
|
1199
|
-
type: "Routing",
|
|
1200
|
-
key: "$route",
|
|
1201
|
-
editable: false,
|
|
1202
|
-
value: formatRouteLocation(router.currentRoute.value, "Current Route")
|
|
1203
|
-
});
|
|
1204
|
-
});
|
|
1205
|
-
api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
|
|
1206
|
-
if (componentInstance.__vrv_devtools) {
|
|
1207
|
-
const info = componentInstance.__vrv_devtools;
|
|
1208
|
-
node.tags.push({
|
|
1209
|
-
label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
|
|
1210
|
-
textColor: 0,
|
|
1211
|
-
tooltip: "This component is rendered by <router-view>",
|
|
1212
|
-
backgroundColor: PINK_500
|
|
1213
|
-
});
|
|
1214
|
-
}
|
|
1215
|
-
if (isArray(componentInstance.__vrl_devtools)) {
|
|
1216
|
-
componentInstance.__devtoolsApi = api;
|
|
1217
|
-
componentInstance.__vrl_devtools.forEach((devtoolsData) => {
|
|
1218
|
-
let label = devtoolsData.route.path;
|
|
1219
|
-
let backgroundColor = ORANGE_400;
|
|
1220
|
-
let tooltip = "";
|
|
1221
|
-
let textColor = 0;
|
|
1222
|
-
if (devtoolsData.error) {
|
|
1223
|
-
label = devtoolsData.error;
|
|
1224
|
-
backgroundColor = RED_100;
|
|
1225
|
-
textColor = RED_700;
|
|
1226
|
-
} else if (devtoolsData.isExactActive) {
|
|
1227
|
-
backgroundColor = LIME_500;
|
|
1228
|
-
tooltip = "This is exactly active";
|
|
1229
|
-
} else if (devtoolsData.isActive) {
|
|
1230
|
-
backgroundColor = BLUE_600;
|
|
1231
|
-
tooltip = "This link is active";
|
|
1232
|
-
}
|
|
1233
|
-
node.tags.push({
|
|
1234
|
-
label,
|
|
1235
|
-
textColor,
|
|
1236
|
-
tooltip,
|
|
1237
|
-
backgroundColor
|
|
1238
|
-
});
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
});
|
|
1242
|
-
watch(router.currentRoute, () => {
|
|
1243
|
-
refreshRoutesView();
|
|
1244
|
-
api.notifyComponentUpdate();
|
|
1245
|
-
api.sendInspectorTree(routerInspectorId);
|
|
1246
|
-
api.sendInspectorState(routerInspectorId);
|
|
1247
|
-
});
|
|
1248
|
-
const navigationsLayerId = "router:navigations:" + id;
|
|
1249
|
-
api.addTimelineLayer({
|
|
1250
|
-
id: navigationsLayerId,
|
|
1251
|
-
label: `Router${id ? " " + id : ""} Navigations`,
|
|
1252
|
-
color: 4237508
|
|
1253
|
-
});
|
|
1254
|
-
router.onError((error, to) => {
|
|
1255
|
-
api.addTimelineEvent({
|
|
1256
|
-
layerId: navigationsLayerId,
|
|
1257
|
-
event: {
|
|
1258
|
-
title: "Error during Navigation",
|
|
1259
|
-
subtitle: to.fullPath,
|
|
1260
|
-
logType: "error",
|
|
1261
|
-
time: api.now(),
|
|
1262
|
-
data: { error },
|
|
1263
|
-
groupId: to.meta.__navigationId
|
|
1264
|
-
}
|
|
1265
|
-
});
|
|
1266
|
-
});
|
|
1267
|
-
let navigationId = 0;
|
|
1268
|
-
router.beforeEach((to, from) => {
|
|
1269
|
-
const data = {
|
|
1270
|
-
guard: formatDisplay("beforeEach"),
|
|
1271
|
-
from: formatRouteLocation(from, "Current Location during this navigation"),
|
|
1272
|
-
to: formatRouteLocation(to, "Target location")
|
|
1273
|
-
};
|
|
1274
|
-
Object.defineProperty(to.meta, "__navigationId", { value: navigationId++ });
|
|
1275
|
-
api.addTimelineEvent({
|
|
1276
|
-
layerId: navigationsLayerId,
|
|
1277
|
-
event: {
|
|
1278
|
-
time: api.now(),
|
|
1279
|
-
title: "Start of navigation",
|
|
1280
|
-
subtitle: to.fullPath,
|
|
1281
|
-
data,
|
|
1282
|
-
groupId: to.meta.__navigationId
|
|
1283
|
-
}
|
|
1284
|
-
});
|
|
1285
|
-
});
|
|
1286
|
-
router.afterEach((to, from, failure) => {
|
|
1287
|
-
const data = { guard: formatDisplay("afterEach") };
|
|
1288
|
-
if (failure) {
|
|
1289
|
-
data.failure = { _custom: {
|
|
1290
|
-
type: Error,
|
|
1291
|
-
readOnly: true,
|
|
1292
|
-
display: failure ? failure.message : "",
|
|
1293
|
-
tooltip: "Navigation Failure",
|
|
1294
|
-
value: failure
|
|
1295
|
-
} };
|
|
1296
|
-
data.status = formatDisplay("❌");
|
|
1297
|
-
} else data.status = formatDisplay("✅");
|
|
1298
|
-
data.from = formatRouteLocation(from, "Current Location during this navigation");
|
|
1299
|
-
data.to = formatRouteLocation(to, "Target location");
|
|
1300
|
-
api.addTimelineEvent({
|
|
1301
|
-
layerId: navigationsLayerId,
|
|
1302
|
-
event: {
|
|
1303
|
-
title: "End of navigation",
|
|
1304
|
-
subtitle: to.fullPath,
|
|
1305
|
-
time: api.now(),
|
|
1306
|
-
data,
|
|
1307
|
-
logType: failure ? "warning" : "default",
|
|
1308
|
-
groupId: to.meta.__navigationId
|
|
1309
|
-
}
|
|
1310
|
-
});
|
|
1311
|
-
});
|
|
1312
|
-
/**
|
|
1313
|
-
* Inspector of Existing routes
|
|
1314
|
-
*/
|
|
1315
|
-
const routerInspectorId = "router-inspector:" + id;
|
|
1316
|
-
api.addInspector({
|
|
1317
|
-
id: routerInspectorId,
|
|
1318
|
-
label: "Routes" + (id ? " " + id : ""),
|
|
1319
|
-
icon: "book",
|
|
1320
|
-
treeFilterPlaceholder: "Search routes"
|
|
1321
|
-
});
|
|
1322
|
-
function refreshRoutesView() {
|
|
1323
|
-
if (!activeRoutesPayload) return;
|
|
1324
|
-
const payload = activeRoutesPayload;
|
|
1325
|
-
let routes = matcher.getRoutes().filter((route) => !route.parent || !route.parent.record.components);
|
|
1326
|
-
routes.forEach(resetMatchStateOnRouteRecord);
|
|
1327
|
-
if (payload.filter) routes = routes.filter((route) => isRouteMatching(route, payload.filter.toLowerCase()));
|
|
1328
|
-
routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
|
|
1329
|
-
payload.rootNodes = routes.map(formatRouteRecordForInspector);
|
|
1330
|
-
}
|
|
1331
|
-
let activeRoutesPayload;
|
|
1332
|
-
api.on.getInspectorTree((payload) => {
|
|
1333
|
-
activeRoutesPayload = payload;
|
|
1334
|
-
if (payload.app === app && payload.inspectorId === routerInspectorId) refreshRoutesView();
|
|
1335
|
-
});
|
|
1336
|
-
/**
|
|
1337
|
-
* Display information about the currently selected route record
|
|
1338
|
-
*/
|
|
1339
|
-
api.on.getInspectorState((payload) => {
|
|
1340
|
-
if (payload.app === app && payload.inspectorId === routerInspectorId) {
|
|
1341
|
-
const route = matcher.getRoutes().find((route) => route.record.__vd_id === payload.nodeId);
|
|
1342
|
-
if (route) payload.state = { options: formatRouteRecordMatcherForStateInspector(route) };
|
|
1343
|
-
}
|
|
1344
|
-
});
|
|
1345
|
-
api.sendInspectorTree(routerInspectorId);
|
|
1346
|
-
api.sendInspectorState(routerInspectorId);
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1349
|
-
function modifierForKey(key) {
|
|
1350
|
-
if (key.optional) return key.repeatable ? "*" : "?";
|
|
1351
|
-
else return key.repeatable ? "+" : "";
|
|
1352
|
-
}
|
|
1353
|
-
function formatRouteRecordMatcherForStateInspector(route) {
|
|
1354
|
-
const { record } = route;
|
|
1355
|
-
const fields = [{
|
|
1356
|
-
editable: false,
|
|
1357
|
-
key: "path",
|
|
1358
|
-
value: record.path
|
|
1359
|
-
}];
|
|
1360
|
-
if (record.name != null) fields.push({
|
|
1361
|
-
editable: false,
|
|
1362
|
-
key: "name",
|
|
1363
|
-
value: record.name
|
|
1364
|
-
});
|
|
1365
|
-
fields.push({
|
|
1366
|
-
editable: false,
|
|
1367
|
-
key: "regexp",
|
|
1368
|
-
value: route.re
|
|
1369
|
-
});
|
|
1370
|
-
if (route.keys.length) fields.push({
|
|
1371
|
-
editable: false,
|
|
1372
|
-
key: "keys",
|
|
1373
|
-
value: { _custom: {
|
|
1374
|
-
type: null,
|
|
1375
|
-
readOnly: true,
|
|
1376
|
-
display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
|
|
1377
|
-
tooltip: "Param keys",
|
|
1378
|
-
value: route.keys
|
|
1379
|
-
} }
|
|
1380
|
-
});
|
|
1381
|
-
if (record.redirect != null) fields.push({
|
|
1382
|
-
editable: false,
|
|
1383
|
-
key: "redirect",
|
|
1384
|
-
value: record.redirect
|
|
1385
|
-
});
|
|
1386
|
-
if (route.alias.length) fields.push({
|
|
1387
|
-
editable: false,
|
|
1388
|
-
key: "aliases",
|
|
1389
|
-
value: route.alias.map((alias) => alias.record.path)
|
|
1390
|
-
});
|
|
1391
|
-
if (Object.keys(route.record.meta).length) fields.push({
|
|
1392
|
-
editable: false,
|
|
1393
|
-
key: "meta",
|
|
1394
|
-
value: route.record.meta
|
|
1395
|
-
});
|
|
1396
|
-
fields.push({
|
|
1397
|
-
key: "score",
|
|
1398
|
-
editable: false,
|
|
1399
|
-
value: { _custom: {
|
|
1400
|
-
type: null,
|
|
1401
|
-
readOnly: true,
|
|
1402
|
-
display: route.score.map((score) => score.join(", ")).join(" | "),
|
|
1403
|
-
tooltip: "Score used to sort routes",
|
|
1404
|
-
value: route.score
|
|
1405
|
-
} }
|
|
1406
|
-
});
|
|
1407
|
-
return fields;
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Extracted from tailwind palette
|
|
1411
|
-
*/
|
|
1412
|
-
const PINK_500 = 15485081;
|
|
1413
|
-
const BLUE_600 = 2450411;
|
|
1414
|
-
const LIME_500 = 8702998;
|
|
1415
|
-
const CYAN_400 = 2282478;
|
|
1416
|
-
const ORANGE_400 = 16486972;
|
|
1417
|
-
const DARK = 6710886;
|
|
1418
|
-
const RED_100 = 16704226;
|
|
1419
|
-
const RED_700 = 12131356;
|
|
1420
|
-
function formatRouteRecordForInspector(route) {
|
|
1421
|
-
const tags = [];
|
|
1422
|
-
const { record } = route;
|
|
1423
|
-
if (record.name != null) tags.push({
|
|
1424
|
-
label: String(record.name),
|
|
1425
|
-
textColor: 0,
|
|
1426
|
-
backgroundColor: CYAN_400
|
|
1427
|
-
});
|
|
1428
|
-
if (record.aliasOf) tags.push({
|
|
1429
|
-
label: "alias",
|
|
1430
|
-
textColor: 0,
|
|
1431
|
-
backgroundColor: ORANGE_400
|
|
1432
|
-
});
|
|
1433
|
-
if (route.__vd_match) tags.push({
|
|
1434
|
-
label: "matches",
|
|
1435
|
-
textColor: 0,
|
|
1436
|
-
backgroundColor: PINK_500
|
|
1437
|
-
});
|
|
1438
|
-
if (route.__vd_exactActive) tags.push({
|
|
1439
|
-
label: "exact",
|
|
1440
|
-
textColor: 0,
|
|
1441
|
-
backgroundColor: LIME_500
|
|
1442
|
-
});
|
|
1443
|
-
if (route.__vd_active) tags.push({
|
|
1444
|
-
label: "active",
|
|
1445
|
-
textColor: 0,
|
|
1446
|
-
backgroundColor: BLUE_600
|
|
1447
|
-
});
|
|
1448
|
-
if (record.redirect) tags.push({
|
|
1449
|
-
label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
|
|
1450
|
-
textColor: 16777215,
|
|
1451
|
-
backgroundColor: DARK
|
|
1452
|
-
});
|
|
1453
|
-
let id = record.__vd_id;
|
|
1454
|
-
if (id == null) {
|
|
1455
|
-
id = String(routeRecordId++);
|
|
1456
|
-
record.__vd_id = id;
|
|
1457
|
-
}
|
|
1458
|
-
return {
|
|
1459
|
-
id,
|
|
1460
|
-
label: record.path,
|
|
1461
|
-
tags,
|
|
1462
|
-
children: route.children.map(formatRouteRecordForInspector)
|
|
1463
|
-
};
|
|
1464
|
-
}
|
|
1465
|
-
let routeRecordId = 0;
|
|
1466
|
-
const EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
|
|
1467
|
-
function markRouteRecordActive(route, currentRoute) {
|
|
1468
|
-
const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
|
|
1469
|
-
route.__vd_exactActive = route.__vd_active = isExactActive;
|
|
1470
|
-
if (!isExactActive) route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
|
|
1471
|
-
route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
|
|
1472
|
-
}
|
|
1473
|
-
function resetMatchStateOnRouteRecord(route) {
|
|
1474
|
-
route.__vd_match = false;
|
|
1475
|
-
route.children.forEach(resetMatchStateOnRouteRecord);
|
|
1476
|
-
}
|
|
1477
|
-
function isRouteMatching(route, filter) {
|
|
1478
|
-
const found = String(route.re).match(EXTRACT_REGEXP_RE);
|
|
1479
|
-
route.__vd_match = false;
|
|
1480
|
-
if (!found || found.length < 3) return false;
|
|
1481
|
-
if (new RegExp(found[1].replace(/\$$/, ""), found[2]).test(filter)) {
|
|
1482
|
-
route.children.forEach((child) => isRouteMatching(child, filter));
|
|
1483
|
-
if (route.record.path !== "/" || filter === "/") {
|
|
1484
|
-
route.__vd_match = route.re.test(filter);
|
|
1485
|
-
return true;
|
|
1486
|
-
}
|
|
1487
|
-
return false;
|
|
1488
|
-
}
|
|
1489
|
-
const path = route.record.path.toLowerCase();
|
|
1490
|
-
const decodedPath = decode(path);
|
|
1491
|
-
if (!isAbsolutePath(filter) && (decodedPath.includes(filter) || path.includes(filter))) return true;
|
|
1492
|
-
if (decodedPath.startsWith(filter) || path.startsWith(filter)) return true;
|
|
1493
|
-
if (route.record.name && String(route.record.name).includes(filter)) return true;
|
|
1494
|
-
return route.children.some((child) => isRouteMatching(child, filter));
|
|
1495
|
-
}
|
|
1496
|
-
function omit(obj, keys) {
|
|
1497
|
-
const ret = {};
|
|
1498
|
-
for (const key in obj) if (!keys.includes(key)) ret[key] = obj[key];
|
|
1499
|
-
return ret;
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
/*!
|
|
1503
|
-
* vue-router v5.3.1
|
|
1504
|
-
* (c) 2026 Eduardo San Martin Morote
|
|
1505
|
-
* @license MIT
|
|
1506
|
-
*/
|
|
1507
|
-
//#region src/history/html5.ts
|
|
1508
|
-
let createBaseLocation = () => location.protocol + "//" + location.host;
|
|
1509
|
-
/**
|
|
1510
|
-
* Creates a normalized history location from a window.location object
|
|
1511
|
-
* @param base - The base path
|
|
1512
|
-
* @param location - The window.location object
|
|
1513
|
-
*/
|
|
1514
|
-
function createCurrentLocation(base, location) {
|
|
1515
|
-
const { pathname, search, hash } = location;
|
|
1516
|
-
const hashPos = base.indexOf("#");
|
|
1517
|
-
if (hashPos > -1) {
|
|
1518
|
-
let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
|
|
1519
|
-
let pathFromHash = hash.slice(slicePos);
|
|
1520
|
-
if (pathFromHash[0] !== "/") pathFromHash = "/" + pathFromHash;
|
|
1521
|
-
return stripBase(pathFromHash, "");
|
|
1522
|
-
}
|
|
1523
|
-
return stripBase(pathname, base) + search + hash;
|
|
1524
|
-
}
|
|
1525
|
-
function useHistoryListeners(base, historyState, currentLocation, replace) {
|
|
1526
|
-
let listeners = [];
|
|
1527
|
-
let teardowns = [];
|
|
1528
|
-
let pauseState = null;
|
|
1529
|
-
const popStateHandler = ({ state }) => {
|
|
1530
|
-
const to = createCurrentLocation(base, location);
|
|
1531
|
-
const from = currentLocation.value;
|
|
1532
|
-
const fromState = historyState.value;
|
|
1533
|
-
let delta = 0;
|
|
1534
|
-
if (state) {
|
|
1535
|
-
currentLocation.value = to;
|
|
1536
|
-
historyState.value = state;
|
|
1537
|
-
if (pauseState && pauseState === from) {
|
|
1538
|
-
pauseState = null;
|
|
1539
|
-
return;
|
|
1540
|
-
}
|
|
1541
|
-
delta = fromState ? state.position - fromState.position : 0;
|
|
1542
|
-
} else replace(to);
|
|
1543
|
-
listeners.forEach((listener) => {
|
|
1544
|
-
listener(currentLocation.value, from, {
|
|
1545
|
-
delta,
|
|
1546
|
-
type: "pop",
|
|
1547
|
-
direction: delta ? delta > 0 ? "forward" : "back" : ""
|
|
1548
|
-
});
|
|
1549
|
-
});
|
|
1550
|
-
};
|
|
1551
|
-
function pauseListeners() {
|
|
1552
|
-
pauseState = currentLocation.value;
|
|
1553
|
-
}
|
|
1554
|
-
function listen(callback) {
|
|
1555
|
-
listeners.push(callback);
|
|
1556
|
-
const teardown = () => {
|
|
1557
|
-
const index = listeners.indexOf(callback);
|
|
1558
|
-
if (index > -1) listeners.splice(index, 1);
|
|
1559
|
-
};
|
|
1560
|
-
teardowns.push(teardown);
|
|
1561
|
-
return teardown;
|
|
1562
|
-
}
|
|
1563
|
-
function beforeUnloadListener() {
|
|
1564
|
-
const { history } = window;
|
|
1565
|
-
if (!history.state) return;
|
|
1566
|
-
history.replaceState(assign({}, history.state, { scroll: computeScrollPosition() }), "");
|
|
1567
|
-
}
|
|
1568
|
-
function destroy() {
|
|
1569
|
-
for (const teardown of teardowns) teardown();
|
|
1570
|
-
teardowns = [];
|
|
1571
|
-
window.removeEventListener("popstate", popStateHandler);
|
|
1572
|
-
window.removeEventListener("pagehide", beforeUnloadListener);
|
|
1573
|
-
}
|
|
1574
|
-
window.addEventListener("popstate", popStateHandler);
|
|
1575
|
-
window.addEventListener("pagehide", beforeUnloadListener);
|
|
1576
|
-
return {
|
|
1577
|
-
pauseListeners,
|
|
1578
|
-
listen,
|
|
1579
|
-
destroy
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Creates a state object
|
|
1584
|
-
*/
|
|
1585
|
-
function buildState(back, current, forward, replaced = false) {
|
|
1586
|
-
return {
|
|
1587
|
-
back,
|
|
1588
|
-
current,
|
|
1589
|
-
forward,
|
|
1590
|
-
replaced,
|
|
1591
|
-
position: window.history.length,
|
|
1592
|
-
scroll: null
|
|
1593
|
-
};
|
|
1594
|
-
}
|
|
1595
|
-
function useHistoryStateNavigation(base) {
|
|
1596
|
-
const { history, location } = window;
|
|
1597
|
-
const currentLocation = { value: createCurrentLocation(base, location) };
|
|
1598
|
-
const historyState = { value: history.state };
|
|
1599
|
-
if (!historyState.value) changeLocation(currentLocation.value, {
|
|
1600
|
-
back: null,
|
|
1601
|
-
current: currentLocation.value,
|
|
1602
|
-
forward: null,
|
|
1603
|
-
position: history.length - 1,
|
|
1604
|
-
replaced: true,
|
|
1605
|
-
scroll: null
|
|
1606
|
-
}, true);
|
|
1607
|
-
function changeLocation(to, state, replace) {
|
|
1608
|
-
/**
|
|
1609
|
-
* if a base tag is provided, and we are on a normal domain, we have to
|
|
1610
|
-
* respect the provided `base` attribute because pushState() will use it and
|
|
1611
|
-
* potentially erase anything before the `#` like at
|
|
1612
|
-
* https://github.com/vuejs/router/issues/685 where a base of
|
|
1613
|
-
* `/folder/#` but a base of `/` would erase the `/folder/` section. If
|
|
1614
|
-
* there is no host, the `<base>` tag makes no sense and if there isn't a
|
|
1615
|
-
* base tag we can just use everything after the `#`.
|
|
1616
|
-
*/
|
|
1617
|
-
const hashIndex = base.indexOf("#");
|
|
1618
|
-
const url = hashIndex > -1 ? (location.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
|
|
1619
|
-
try {
|
|
1620
|
-
history[replace ? "replaceState" : "pushState"](state, "", url);
|
|
1621
|
-
historyState.value = state;
|
|
1622
|
-
} catch (err) {
|
|
1623
|
-
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0120({ cause: err });
|
|
1624
|
-
else console.error(err);
|
|
1625
|
-
location[replace ? "replace" : "assign"](url);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
function replace(to, data) {
|
|
1629
|
-
changeLocation(to, assign({}, history.state, buildState(historyState.value.back, to, historyState.value.forward, true), data, { position: historyState.value.position }), true);
|
|
1630
|
-
currentLocation.value = to;
|
|
1631
|
-
}
|
|
1632
|
-
function push(to, data) {
|
|
1633
|
-
const currentState = assign({}, historyState.value, history.state, {
|
|
1634
|
-
forward: to,
|
|
1635
|
-
scroll: computeScrollPosition()
|
|
1636
|
-
});
|
|
1637
|
-
if (process.env.NODE_ENV !== "production" && !history.state) diagnostics.VUE_ROUTER_R0121();
|
|
1638
|
-
changeLocation(currentState.current, currentState, true);
|
|
1639
|
-
changeLocation(to, assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data), false);
|
|
1640
|
-
currentLocation.value = to;
|
|
1641
|
-
}
|
|
1642
|
-
return {
|
|
1643
|
-
location: currentLocation,
|
|
1644
|
-
state: historyState,
|
|
1645
|
-
push,
|
|
1646
|
-
replace
|
|
1647
|
-
};
|
|
1648
|
-
}
|
|
1649
|
-
/**
|
|
1650
|
-
* Creates an HTML5 history. Most common history for single page applications.
|
|
1651
|
-
*
|
|
1652
|
-
* @param base -
|
|
1653
|
-
*/
|
|
1654
|
-
function createWebHistory(base) {
|
|
1655
|
-
base = normalizeBase(base);
|
|
1656
|
-
const historyNavigation = useHistoryStateNavigation(base);
|
|
1657
|
-
const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
|
|
1658
|
-
function go(delta, triggerListeners = true) {
|
|
1659
|
-
if (!triggerListeners) historyListeners.pauseListeners();
|
|
1660
|
-
history.go(delta);
|
|
1661
|
-
}
|
|
1662
|
-
const routerHistory = assign({
|
|
1663
|
-
location: "",
|
|
1664
|
-
base,
|
|
1665
|
-
go,
|
|
1666
|
-
createHref: createHref.bind(null, base)
|
|
1667
|
-
}, historyNavigation, historyListeners);
|
|
1668
|
-
Object.defineProperty(routerHistory, "location", {
|
|
1669
|
-
enumerable: true,
|
|
1670
|
-
get: () => historyNavigation.location.value
|
|
1671
|
-
});
|
|
1672
|
-
Object.defineProperty(routerHistory, "state", {
|
|
1673
|
-
enumerable: true,
|
|
1674
|
-
get: () => historyNavigation.state.value
|
|
1675
|
-
});
|
|
1676
|
-
return routerHistory;
|
|
1677
|
-
}
|
|
1678
|
-
//#endregion
|
|
1679
|
-
//#region src/history/hash.ts
|
|
1680
|
-
/**
|
|
1681
|
-
* Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
|
|
1682
|
-
* handle any URL is not possible.
|
|
1683
|
-
*
|
|
1684
|
-
* @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
|
|
1685
|
-
* in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
|
|
1686
|
-
* calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
|
|
1687
|
-
* after the `#`).
|
|
1688
|
-
*
|
|
1689
|
-
* @example
|
|
1690
|
-
* ```js
|
|
1691
|
-
* // at https://example.com/folder
|
|
1692
|
-
* createWebHashHistory() // gives a url of `https://example.com/folder#`
|
|
1693
|
-
* createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
|
|
1694
|
-
* // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
|
|
1695
|
-
* createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
|
|
1696
|
-
* // you should avoid doing this because it changes the original url and breaks copying urls
|
|
1697
|
-
* createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
|
|
1698
|
-
*
|
|
1699
|
-
* // at file:///usr/etc/folder/index.html
|
|
1700
|
-
* // for locations with no `host`, the base is ignored
|
|
1701
|
-
* createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
|
|
1702
|
-
* ```
|
|
1703
|
-
*/
|
|
1704
|
-
function createWebHashHistory(base) {
|
|
1705
|
-
base = location.host ? base || location.pathname + location.search : "";
|
|
1706
|
-
if (!base.includes("#")) base += "#";
|
|
1707
|
-
if (process.env.NODE_ENV !== "production" && !base.endsWith("#/") && !base.endsWith("#")) diagnostics.VUE_ROUTER_R0110({
|
|
1708
|
-
base,
|
|
1709
|
-
suggestion: base.replace(/#.*$/, "#")
|
|
1710
|
-
});
|
|
1711
|
-
return createWebHistory(base);
|
|
1712
|
-
}
|
|
1713
|
-
//#endregion
|
|
1714
|
-
//#region src/history/memory.ts
|
|
1715
|
-
/**
|
|
1716
|
-
* Creates an in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere.
|
|
1717
|
-
* It's up to the user to replace that location with the starter location by either calling `router.push` or `router.replace`.
|
|
1718
|
-
*
|
|
1719
|
-
* @param base - Base applied to all urls, defaults to '/'
|
|
1720
|
-
* @returns a history object that can be passed to the router constructor
|
|
1721
|
-
*/
|
|
1722
|
-
function createMemoryHistory(base = "") {
|
|
1723
|
-
let listeners = [];
|
|
1724
|
-
let queue = [["", {}]];
|
|
1725
|
-
let position = 0;
|
|
1726
|
-
base = normalizeBase(base);
|
|
1727
|
-
function setLocation(location, state = {}) {
|
|
1728
|
-
position++;
|
|
1729
|
-
if (position !== queue.length) queue.splice(position);
|
|
1730
|
-
queue.push([location, state]);
|
|
1731
|
-
}
|
|
1732
|
-
function triggerListeners(to, from, { direction, delta }) {
|
|
1733
|
-
const info = {
|
|
1734
|
-
direction,
|
|
1735
|
-
delta,
|
|
1736
|
-
type: "pop"
|
|
1737
|
-
};
|
|
1738
|
-
for (const callback of listeners) callback(to, from, info);
|
|
1739
|
-
}
|
|
1740
|
-
const routerHistory = {
|
|
1741
|
-
location: "",
|
|
1742
|
-
state: {},
|
|
1743
|
-
base,
|
|
1744
|
-
createHref: createHref.bind(null, base),
|
|
1745
|
-
replace(to, state) {
|
|
1746
|
-
queue.splice(position--, 1);
|
|
1747
|
-
setLocation(to, state);
|
|
1748
|
-
},
|
|
1749
|
-
push(to, state) {
|
|
1750
|
-
setLocation(to, state);
|
|
1751
|
-
},
|
|
1752
|
-
listen(callback) {
|
|
1753
|
-
listeners.push(callback);
|
|
1754
|
-
return () => {
|
|
1755
|
-
const index = listeners.indexOf(callback);
|
|
1756
|
-
if (index > -1) listeners.splice(index, 1);
|
|
1757
|
-
};
|
|
1758
|
-
},
|
|
1759
|
-
destroy() {
|
|
1760
|
-
listeners = [];
|
|
1761
|
-
queue = [["", {}]];
|
|
1762
|
-
position = 0;
|
|
1763
|
-
},
|
|
1764
|
-
go(delta, shouldTrigger = true) {
|
|
1765
|
-
const from = this.location;
|
|
1766
|
-
const direction = delta < 0 ? "back" : "forward";
|
|
1767
|
-
position = Math.max(0, Math.min(position + delta, queue.length - 1));
|
|
1768
|
-
if (shouldTrigger) triggerListeners(this.location, from, {
|
|
1769
|
-
direction,
|
|
1770
|
-
delta
|
|
1771
|
-
});
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
|
-
Object.defineProperty(routerHistory, "location", {
|
|
1775
|
-
enumerable: true,
|
|
1776
|
-
get: () => queue[position][0]
|
|
1777
|
-
});
|
|
1778
|
-
Object.defineProperty(routerHistory, "state", {
|
|
1779
|
-
enumerable: true,
|
|
1780
|
-
get: () => queue[position][1]
|
|
1781
|
-
});
|
|
1782
|
-
return routerHistory;
|
|
1783
|
-
}
|
|
1784
|
-
//#endregion
|
|
1785
|
-
//#region src/matcher/pathTokenizer.ts
|
|
1786
|
-
const ROOT_TOKEN = {
|
|
1787
|
-
type: 0,
|
|
1788
|
-
value: ""
|
|
1789
|
-
};
|
|
1790
|
-
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
|
|
1791
|
-
function tokenizePath(path) {
|
|
1792
|
-
if (!path) return [[]];
|
|
1793
|
-
if (path === "/") return [[ROOT_TOKEN]];
|
|
1794
|
-
if (!isAbsolutePath(path)) throw new Error(process.env.NODE_ENV !== "production" ? `Route paths should start with a "/": "${path}" should be "/${path}".` : `Invalid path "${path}"`);
|
|
1795
|
-
function crash(message) {
|
|
1796
|
-
throw new Error(`ERR (${state})/"${buffer}": ${message}`);
|
|
1797
|
-
}
|
|
1798
|
-
let state = 0;
|
|
1799
|
-
let previousState = state;
|
|
1800
|
-
const tokens = [];
|
|
1801
|
-
let segment;
|
|
1802
|
-
function finalizeSegment() {
|
|
1803
|
-
if (segment) tokens.push(segment);
|
|
1804
|
-
segment = [];
|
|
1805
|
-
}
|
|
1806
|
-
let i = 0;
|
|
1807
|
-
let char;
|
|
1808
|
-
let buffer = "";
|
|
1809
|
-
let customRe = "";
|
|
1810
|
-
function consumeBuffer() {
|
|
1811
|
-
if (!buffer) return;
|
|
1812
|
-
if (state === 0) segment.push({
|
|
1813
|
-
type: 0,
|
|
1814
|
-
value: buffer
|
|
1815
|
-
});
|
|
1816
|
-
else if (state === 1 || state === 2 || state === 3) {
|
|
1817
|
-
if (segment.length > 1 && (char === "*" || char === "+")) crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
|
|
1818
|
-
segment.push({
|
|
1819
|
-
type: 1,
|
|
1820
|
-
value: buffer,
|
|
1821
|
-
regexp: customRe,
|
|
1822
|
-
repeatable: char === "*" || char === "+",
|
|
1823
|
-
optional: char === "*" || char === "?"
|
|
1824
|
-
});
|
|
1825
|
-
} else crash("Invalid state to consume buffer");
|
|
1826
|
-
buffer = "";
|
|
1827
|
-
}
|
|
1828
|
-
function addCharToBuffer() {
|
|
1829
|
-
buffer += char;
|
|
1830
|
-
}
|
|
1831
|
-
while (i < path.length) {
|
|
1832
|
-
char = path[i++];
|
|
1833
|
-
switch (state) {
|
|
1834
|
-
case 0:
|
|
1835
|
-
if (char === "\\") {
|
|
1836
|
-
previousState = state;
|
|
1837
|
-
state = 4;
|
|
1838
|
-
} else if (char === "/") {
|
|
1839
|
-
if (buffer) consumeBuffer();
|
|
1840
|
-
finalizeSegment();
|
|
1841
|
-
} else if (char === ":") {
|
|
1842
|
-
consumeBuffer();
|
|
1843
|
-
state = 1;
|
|
1844
|
-
} else addCharToBuffer();
|
|
1845
|
-
break;
|
|
1846
|
-
case 4:
|
|
1847
|
-
addCharToBuffer();
|
|
1848
|
-
state = previousState;
|
|
1849
|
-
break;
|
|
1850
|
-
case 1:
|
|
1851
|
-
if (char === "(") state = 2;
|
|
1852
|
-
else if (VALID_PARAM_RE.test(char)) addCharToBuffer();
|
|
1853
|
-
else {
|
|
1854
|
-
consumeBuffer();
|
|
1855
|
-
state = 0;
|
|
1856
|
-
if (char !== "*" && char !== "?" && char !== "+") i--;
|
|
1857
|
-
}
|
|
1858
|
-
break;
|
|
1859
|
-
case 2:
|
|
1860
|
-
if (char === ")") {
|
|
1861
|
-
if (customRe[customRe.length - 1] == "\\") customRe = customRe.slice(0, -1) + char;
|
|
1862
|
-
else state = 3;
|
|
1863
|
-
} else customRe += char;
|
|
1864
|
-
break;
|
|
1865
|
-
case 3:
|
|
1866
|
-
consumeBuffer();
|
|
1867
|
-
state = 0;
|
|
1868
|
-
if (char !== "*" && char !== "?" && char !== "+") i--;
|
|
1869
|
-
customRe = "";
|
|
1870
|
-
break;
|
|
1871
|
-
default: crash("Unknown state");
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
if (state === 2) crash(`Unfinished custom RegExp for param "${buffer}"`);
|
|
1875
|
-
consumeBuffer();
|
|
1876
|
-
finalizeSegment();
|
|
1877
|
-
return tokens;
|
|
1878
|
-
}
|
|
1879
|
-
//#endregion
|
|
1880
|
-
//#region src/matcher/pathParserRanker.ts
|
|
1881
|
-
const BASE_PARAM_PATTERN = "[^/]+?";
|
|
1882
|
-
const BASE_PATH_PARSER_OPTIONS = {
|
|
1883
|
-
sensitive: false,
|
|
1884
|
-
strict: false,
|
|
1885
|
-
start: true,
|
|
1886
|
-
end: true
|
|
1887
|
-
};
|
|
1888
|
-
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
|
|
1889
|
-
/**
|
|
1890
|
-
* Creates a path parser from an array of Segments (a segment is an array of Tokens)
|
|
1891
|
-
*
|
|
1892
|
-
* @param segments - array of segments returned by tokenizePath
|
|
1893
|
-
* @param extraOptions - optional options for the regexp
|
|
1894
|
-
* @returns a PathParser
|
|
1895
|
-
*/
|
|
1896
|
-
function tokensToParser(segments, extraOptions) {
|
|
1897
|
-
const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
|
|
1898
|
-
const score = [];
|
|
1899
|
-
let pattern = options.start ? "^" : "";
|
|
1900
|
-
const keys = [];
|
|
1901
|
-
for (const segment of segments) {
|
|
1902
|
-
const segmentScores = segment.length ? [] : [90];
|
|
1903
|
-
if (options.strict && !segment.length) pattern += "/";
|
|
1904
|
-
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
|
|
1905
|
-
const token = segment[tokenIndex];
|
|
1906
|
-
let subSegmentScore = 40 + (options.sensitive ? .25 : 0);
|
|
1907
|
-
if (token.type === 0) {
|
|
1908
|
-
if (!tokenIndex) pattern += "/";
|
|
1909
|
-
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
|
|
1910
|
-
subSegmentScore += 40;
|
|
1911
|
-
} else if (token.type === 1) {
|
|
1912
|
-
const { value, repeatable, optional, regexp } = token;
|
|
1913
|
-
keys.push({
|
|
1914
|
-
name: value,
|
|
1915
|
-
repeatable,
|
|
1916
|
-
optional
|
|
1917
|
-
});
|
|
1918
|
-
const re = regexp ? regexp : BASE_PARAM_PATTERN;
|
|
1919
|
-
if (re !== BASE_PARAM_PATTERN) {
|
|
1920
|
-
subSegmentScore += 10;
|
|
1921
|
-
try {
|
|
1922
|
-
new RegExp(`(${re})`);
|
|
1923
|
-
} catch (err) {
|
|
1924
|
-
throw new Error(`Invalid custom RegExp for param "${value}" (${re}): ` + err.message);
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
let subPattern = repeatable ? `((?:${re})(?:/(?:${re}))*)` : `(${re})`;
|
|
1928
|
-
if (!tokenIndex) subPattern = optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
|
|
1929
|
-
if (optional) subPattern += "?";
|
|
1930
|
-
pattern += subPattern;
|
|
1931
|
-
subSegmentScore += 20;
|
|
1932
|
-
if (optional) subSegmentScore += -8;
|
|
1933
|
-
if (repeatable) subSegmentScore += -20;
|
|
1934
|
-
if (re === ".*") subSegmentScore += -50;
|
|
1935
|
-
}
|
|
1936
|
-
segmentScores.push(subSegmentScore);
|
|
1937
|
-
}
|
|
1938
|
-
score.push(segmentScores);
|
|
1939
|
-
}
|
|
1940
|
-
if (options.strict && options.end) {
|
|
1941
|
-
const i = score.length - 1;
|
|
1942
|
-
score[i][score[i].length - 1] += .7000000000000001;
|
|
1943
|
-
}
|
|
1944
|
-
if (!options.strict) pattern += "/?";
|
|
1945
|
-
if (options.end) pattern += "$";
|
|
1946
|
-
else if (options.strict && !pattern.endsWith("/")) pattern += "(?:/|$)";
|
|
1947
|
-
const re = new RegExp(pattern, options.sensitive ? "" : "i");
|
|
1948
|
-
function parse(path) {
|
|
1949
|
-
const match = path.match(re);
|
|
1950
|
-
const params = {};
|
|
1951
|
-
if (!match) return null;
|
|
1952
|
-
for (let i = 1; i < match.length; i++) {
|
|
1953
|
-
const value = match[i] || "";
|
|
1954
|
-
const key = keys[i - 1];
|
|
1955
|
-
params[key.name] = value && key.repeatable ? value.split("/") : value;
|
|
1956
|
-
}
|
|
1957
|
-
return params;
|
|
1958
|
-
}
|
|
1959
|
-
function stringify(params) {
|
|
1960
|
-
let path = "";
|
|
1961
|
-
let avoidDuplicatedSlash = false;
|
|
1962
|
-
for (const segment of segments) {
|
|
1963
|
-
if (!avoidDuplicatedSlash || !path.endsWith("/")) path += "/";
|
|
1964
|
-
avoidDuplicatedSlash = false;
|
|
1965
|
-
for (const token of segment) if (token.type === 0) path += token.value;
|
|
1966
|
-
else if (token.type === 1) {
|
|
1967
|
-
const { value, repeatable, optional } = token;
|
|
1968
|
-
const param = value in params ? params[value] : "";
|
|
1969
|
-
if (isArray(param) && !repeatable) throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
|
|
1970
|
-
const text = isArray(param) ? param.join("/") : param;
|
|
1971
|
-
if (!text) {
|
|
1972
|
-
if (optional) {
|
|
1973
|
-
if (segment.length < 2) {
|
|
1974
|
-
if (path.endsWith("/")) path = path.slice(0, -1);
|
|
1975
|
-
else avoidDuplicatedSlash = true;
|
|
1976
|
-
}
|
|
1977
|
-
} else throw new Error(`Missing required param "${value}"`);
|
|
1978
|
-
}
|
|
1979
|
-
path += text;
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
return path || "/";
|
|
1983
|
-
}
|
|
1984
|
-
return {
|
|
1985
|
-
re,
|
|
1986
|
-
score,
|
|
1987
|
-
keys,
|
|
1988
|
-
parse,
|
|
1989
|
-
stringify
|
|
1990
|
-
};
|
|
1991
|
-
}
|
|
1992
|
-
/**
|
|
1993
|
-
* Compares an array of numbers as used in PathParser.score and returns a
|
|
1994
|
-
* number. This function can be used to `sort` an array
|
|
1995
|
-
*
|
|
1996
|
-
* @param a - first array of numbers
|
|
1997
|
-
* @param b - second array of numbers
|
|
1998
|
-
* @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
|
|
1999
|
-
* should be sorted first
|
|
2000
|
-
*/
|
|
2001
|
-
function compareScoreArray(a, b) {
|
|
2002
|
-
let i = 0;
|
|
2003
|
-
while (i < a.length && i < b.length) {
|
|
2004
|
-
const diff = b[i] - a[i];
|
|
2005
|
-
if (diff) return diff;
|
|
2006
|
-
i++;
|
|
2007
|
-
}
|
|
2008
|
-
if (a.length < b.length) return a.length === 1 && a[0] === 80 ? -1 : 1;
|
|
2009
|
-
else if (a.length > b.length) return b.length === 1 && b[0] === 80 ? 1 : -1;
|
|
2010
|
-
return 0;
|
|
2011
|
-
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Compare function that can be used with `sort` to sort an array of PathParser
|
|
2014
|
-
*
|
|
2015
|
-
* @param a - first PathParser
|
|
2016
|
-
* @param b - second PathParser
|
|
2017
|
-
* @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
|
|
2018
|
-
*/
|
|
2019
|
-
function comparePathParserScore(a, b) {
|
|
2020
|
-
let i = 0;
|
|
2021
|
-
const aScore = a.score;
|
|
2022
|
-
const bScore = b.score;
|
|
2023
|
-
while (i < aScore.length && i < bScore.length) {
|
|
2024
|
-
const comp = compareScoreArray(aScore[i], bScore[i]);
|
|
2025
|
-
if (comp) return comp;
|
|
2026
|
-
i++;
|
|
2027
|
-
}
|
|
2028
|
-
if (Math.abs(bScore.length - aScore.length) === 1) {
|
|
2029
|
-
if (isLastScoreNegative(aScore)) return 1;
|
|
2030
|
-
if (isLastScoreNegative(bScore)) return -1;
|
|
2031
|
-
}
|
|
2032
|
-
return bScore.length - aScore.length;
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* This allows detecting splats at the end of a path: /home/:id(.*)*
|
|
2036
|
-
*
|
|
2037
|
-
* @param score - score to check
|
|
2038
|
-
* @returns true if the last entry is negative
|
|
2039
|
-
*/
|
|
2040
|
-
function isLastScoreNegative(score) {
|
|
2041
|
-
const last = score[score.length - 1];
|
|
2042
|
-
return score.length > 0 && last[last.length - 1] < 0;
|
|
2043
|
-
}
|
|
2044
|
-
const PATH_PARSER_OPTIONS_DEFAULTS = {
|
|
2045
|
-
strict: false,
|
|
2046
|
-
end: true,
|
|
2047
|
-
sensitive: false
|
|
2048
|
-
};
|
|
2049
|
-
//#endregion
|
|
2050
|
-
//#region src/matcher/pathMatcher.ts
|
|
2051
|
-
function createRouteRecordMatcher(record, parent, options) {
|
|
2052
|
-
const parser = tokensToParser(tokenizePath(record.path), options);
|
|
2053
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2054
|
-
const existingKeys = /* @__PURE__ */ new Set();
|
|
2055
|
-
for (const key of parser.keys) {
|
|
2056
|
-
if (existingKeys.has(key.name)) diagnostics.VUE_ROUTER_R0090({
|
|
2057
|
-
name: key.name,
|
|
2058
|
-
path: record.path
|
|
2059
|
-
});
|
|
2060
|
-
existingKeys.add(key.name);
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
const matcher = assign(parser, {
|
|
2064
|
-
record,
|
|
2065
|
-
parent,
|
|
2066
|
-
children: [],
|
|
2067
|
-
alias: []
|
|
2068
|
-
});
|
|
2069
|
-
if (parent) {
|
|
2070
|
-
if (!matcher.record.aliasOf === !parent.record.aliasOf) parent.children.push(matcher);
|
|
2071
|
-
}
|
|
2072
|
-
return matcher;
|
|
2073
|
-
}
|
|
2074
|
-
//#endregion
|
|
2075
|
-
//#region src/matcher/index.ts
|
|
2076
|
-
/**
|
|
2077
|
-
* Creates a Router Matcher.
|
|
2078
|
-
*
|
|
2079
|
-
* @internal
|
|
2080
|
-
* @param routes - array of initial routes
|
|
2081
|
-
* @param globalOptions - global route options
|
|
2082
|
-
*/
|
|
2083
|
-
function createRouterMatcher(routes, globalOptions) {
|
|
2084
|
-
const matchers = [];
|
|
2085
|
-
const matcherMap = /* @__PURE__ */ new Map();
|
|
2086
|
-
globalOptions = mergeOptions(PATH_PARSER_OPTIONS_DEFAULTS, globalOptions);
|
|
2087
|
-
function getRecordMatcher(name) {
|
|
2088
|
-
return matcherMap.get(name);
|
|
2089
|
-
}
|
|
2090
|
-
function addRoute(record, parent, originalRecord) {
|
|
2091
|
-
const isRootAdd = !originalRecord;
|
|
2092
|
-
const mainNormalizedRecord = normalizeRouteRecord(record);
|
|
2093
|
-
if (process.env.NODE_ENV !== "production") checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
|
|
2094
|
-
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
|
|
2095
|
-
const options = mergeOptions(globalOptions, record);
|
|
2096
|
-
const normalizedRecords = [mainNormalizedRecord];
|
|
2097
|
-
if ("alias" in record) {
|
|
2098
|
-
const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
|
|
2099
|
-
for (const alias of aliases) normalizedRecords.push(normalizeRouteRecord(assign({}, mainNormalizedRecord, {
|
|
2100
|
-
components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
|
|
2101
|
-
path: alias,
|
|
2102
|
-
aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
|
|
2103
|
-
})));
|
|
2104
|
-
}
|
|
2105
|
-
let matcher;
|
|
2106
|
-
let originalMatcher;
|
|
2107
|
-
for (const normalizedRecord of normalizedRecords) {
|
|
2108
|
-
const { path } = normalizedRecord;
|
|
2109
|
-
if (parent && !isAbsolutePath(path)) {
|
|
2110
|
-
const parentPath = parent.record.path;
|
|
2111
|
-
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
|
|
2112
|
-
normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
|
|
2113
|
-
}
|
|
2114
|
-
if (process.env.NODE_ENV !== "production" && normalizedRecord.path === "*") throw new Error("Catch all routes (\"*\") must now be defined using a param with a custom regexp.\nSee more at https://router.vuejs.org/guide/migration/#Removed-star-or-catch-all-routes.");
|
|
2115
|
-
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
|
|
2116
|
-
if (process.env.NODE_ENV !== "production" && parent && isAbsolutePath(path)) checkMissingParamsInAbsolutePath(matcher, parent);
|
|
2117
|
-
if (originalRecord) {
|
|
2118
|
-
originalRecord.alias.push(matcher);
|
|
2119
|
-
if (process.env.NODE_ENV !== "production") checkSameParams(originalRecord, matcher);
|
|
2120
|
-
} else {
|
|
2121
|
-
originalMatcher = originalMatcher || matcher;
|
|
2122
|
-
if (originalMatcher !== matcher) originalMatcher.alias.push(matcher);
|
|
2123
|
-
if (isRootAdd && record.name && !isAliasRecord(matcher)) {
|
|
2124
|
-
if (process.env.NODE_ENV !== "production") checkSameNameAsAncestor(record, parent);
|
|
2125
|
-
removeRoute(record.name);
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
if (isMatchable(matcher)) insertMatcher(matcher);
|
|
2129
|
-
if (mainNormalizedRecord.children) {
|
|
2130
|
-
const children = mainNormalizedRecord.children;
|
|
2131
|
-
for (let i = 0; i < children.length; i++) addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
|
|
2132
|
-
}
|
|
2133
|
-
originalRecord = originalRecord || matcher;
|
|
2134
|
-
}
|
|
2135
|
-
return originalMatcher ? () => {
|
|
2136
|
-
removeRoute(originalMatcher);
|
|
2137
|
-
} : noop;
|
|
2138
|
-
}
|
|
2139
|
-
function removeRoute(matcherRef) {
|
|
2140
|
-
if (isRouteName(matcherRef)) {
|
|
2141
|
-
const matcher = matcherMap.get(matcherRef);
|
|
2142
|
-
if (matcher) {
|
|
2143
|
-
matcherMap.delete(matcherRef);
|
|
2144
|
-
matchers.splice(matchers.indexOf(matcher), 1);
|
|
2145
|
-
matcher.children.forEach(removeRoute);
|
|
2146
|
-
matcher.alias.forEach(removeRoute);
|
|
2147
|
-
}
|
|
2148
|
-
} else {
|
|
2149
|
-
const index = matchers.indexOf(matcherRef);
|
|
2150
|
-
if (index > -1) {
|
|
2151
|
-
matchers.splice(index, 1);
|
|
2152
|
-
if (matcherRef.record.name) matcherMap.delete(matcherRef.record.name);
|
|
2153
|
-
matcherRef.children.forEach(removeRoute);
|
|
2154
|
-
matcherRef.alias.forEach(removeRoute);
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
function getRoutes() {
|
|
2159
|
-
return matchers;
|
|
2160
|
-
}
|
|
2161
|
-
function insertMatcher(matcher) {
|
|
2162
|
-
const index = findInsertionIndex(matcher, matchers);
|
|
2163
|
-
matchers.splice(index, 0, matcher);
|
|
2164
|
-
if (matcher.record.name && !isAliasRecord(matcher)) matcherMap.set(matcher.record.name, matcher);
|
|
2165
|
-
}
|
|
2166
|
-
function resolve(location, currentLocation) {
|
|
2167
|
-
let matcher;
|
|
2168
|
-
let params = {};
|
|
2169
|
-
let path;
|
|
2170
|
-
let name;
|
|
2171
|
-
if ("name" in location && location.name) {
|
|
2172
|
-
matcher = matcherMap.get(location.name);
|
|
2173
|
-
if (!matcher) throw createRouterError(1, { location });
|
|
2174
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2175
|
-
const invalidParams = Object.keys(location.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
|
|
2176
|
-
if (invalidParams.length) {
|
|
2177
|
-
const isInherited = !matcher.keys.length && invalidParams.some((name) => name in currentLocation.params);
|
|
2178
|
-
diagnostics.VUE_ROUTER_R0100({
|
|
2179
|
-
params: invalidParams.join("\", \""),
|
|
2180
|
-
inherited: isInherited ? ` If you are using a catch-all route with a named redirect, pass an empty \`params\` object: \`redirect: { name: '...', params: {} }\`.` : ""
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
name = matcher.record.name;
|
|
2185
|
-
params = assign(pickParams(currentLocation.params, matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)), location.params && pickParams(location.params, matcher.keys.map((k) => k.name)));
|
|
2186
|
-
path = matcher.stringify(params);
|
|
2187
|
-
} else if (location.path != null) {
|
|
2188
|
-
path = location.path;
|
|
2189
|
-
if (process.env.NODE_ENV !== "production" && !isAbsolutePath(path)) diagnostics.VUE_ROUTER_R0101({ path });
|
|
2190
|
-
matcher = matchers.find((m) => m.re.test(path));
|
|
2191
|
-
if (matcher) {
|
|
2192
|
-
params = matcher.parse(path);
|
|
2193
|
-
name = matcher.record.name;
|
|
2194
|
-
matcher.keys.forEach((key) => {
|
|
2195
|
-
if (key.optional && !params[key.name]) delete params[key.name];
|
|
2196
|
-
});
|
|
2197
|
-
}
|
|
2198
|
-
} else {
|
|
2199
|
-
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
|
|
2200
|
-
if (!matcher) throw createRouterError(1, {
|
|
2201
|
-
location,
|
|
2202
|
-
currentLocation
|
|
2203
|
-
});
|
|
2204
|
-
name = matcher.record.name;
|
|
2205
|
-
params = assign({}, currentLocation.params, location.params);
|
|
2206
|
-
path = matcher.stringify(params);
|
|
2207
|
-
}
|
|
2208
|
-
const matched = [];
|
|
2209
|
-
let parentMatcher = matcher;
|
|
2210
|
-
while (parentMatcher) {
|
|
2211
|
-
matched.unshift(parentMatcher.record);
|
|
2212
|
-
parentMatcher = parentMatcher.parent;
|
|
2213
|
-
}
|
|
2214
|
-
return {
|
|
2215
|
-
name,
|
|
2216
|
-
path,
|
|
2217
|
-
params,
|
|
2218
|
-
matched,
|
|
2219
|
-
meta: mergeMetaFields(matched)
|
|
2220
|
-
};
|
|
2221
|
-
}
|
|
2222
|
-
routes.forEach((route) => addRoute(route));
|
|
2223
|
-
function clearRoutes() {
|
|
2224
|
-
matchers.length = 0;
|
|
2225
|
-
matcherMap.clear();
|
|
2226
|
-
}
|
|
2227
|
-
return {
|
|
2228
|
-
addRoute,
|
|
2229
|
-
resolve,
|
|
2230
|
-
removeRoute,
|
|
2231
|
-
clearRoutes,
|
|
2232
|
-
getRoutes,
|
|
2233
|
-
getRecordMatcher
|
|
2234
|
-
};
|
|
2235
|
-
}
|
|
2236
|
-
/**
|
|
2237
|
-
* Picks an object param to contain only specified keys.
|
|
2238
|
-
*
|
|
2239
|
-
* @param params - params object to pick from
|
|
2240
|
-
* @param keys - keys to pick
|
|
2241
|
-
*/
|
|
2242
|
-
function pickParams(params, keys) {
|
|
2243
|
-
const newParams = {};
|
|
2244
|
-
for (const key of keys) if (key in params) newParams[key] = params[key];
|
|
2245
|
-
return newParams;
|
|
2246
|
-
}
|
|
2247
|
-
/**
|
|
2248
|
-
* Normalizes a RouteRecordRaw. Creates a copy
|
|
2249
|
-
*
|
|
2250
|
-
* @param record
|
|
2251
|
-
* @returns the normalized version
|
|
2252
|
-
*/
|
|
2253
|
-
function normalizeRouteRecord(record) {
|
|
2254
|
-
const normalized = {
|
|
2255
|
-
path: record.path,
|
|
2256
|
-
redirect: record.redirect,
|
|
2257
|
-
name: record.name,
|
|
2258
|
-
meta: record.meta || {},
|
|
2259
|
-
aliasOf: record.aliasOf,
|
|
2260
|
-
beforeEnter: record.beforeEnter,
|
|
2261
|
-
props: normalizeRecordProps(record),
|
|
2262
|
-
children: record.children || [],
|
|
2263
|
-
instances: {},
|
|
2264
|
-
leaveGuards: /* @__PURE__ */ new Set(),
|
|
2265
|
-
updateGuards: /* @__PURE__ */ new Set(),
|
|
2266
|
-
enterCallbacks: {},
|
|
2267
|
-
components: "components" in record ? record.components || null : record.component && { default: record.component }
|
|
2268
|
-
};
|
|
2269
|
-
Object.defineProperty(normalized, "mods", { value: {} });
|
|
2270
|
-
return normalized;
|
|
2271
|
-
}
|
|
2272
|
-
/**
|
|
2273
|
-
* Normalize the optional `props` in a record to always be an object similar to
|
|
2274
|
-
* components. Also accept a boolean for components.
|
|
2275
|
-
* @param record
|
|
2276
|
-
*/
|
|
2277
|
-
function normalizeRecordProps(record) {
|
|
2278
|
-
const propsObject = {};
|
|
2279
|
-
const props = record.props || false;
|
|
2280
|
-
if ("component" in record) propsObject.default = props;
|
|
2281
|
-
else for (const name in record.components) propsObject[name] = typeof props === "object" ? props[name] : props;
|
|
2282
|
-
return propsObject;
|
|
2283
|
-
}
|
|
2284
|
-
/**
|
|
2285
|
-
* Checks if a record or any of its parent is an alias
|
|
2286
|
-
* @param record
|
|
2287
|
-
*/
|
|
2288
|
-
function isAliasRecord(record) {
|
|
2289
|
-
while (record) {
|
|
2290
|
-
if (record.record.aliasOf) return true;
|
|
2291
|
-
record = record.parent;
|
|
2292
|
-
}
|
|
2293
|
-
return false;
|
|
2294
|
-
}
|
|
2295
|
-
/**
|
|
2296
|
-
* Merge meta fields of an array of records
|
|
2297
|
-
*
|
|
2298
|
-
* @param matched - array of matched records
|
|
2299
|
-
*/
|
|
2300
|
-
function mergeMetaFields(matched) {
|
|
2301
|
-
return matched.reduce((meta, record) => assign(meta, record.meta), {});
|
|
2302
|
-
}
|
|
2303
|
-
function isSameParam(a, b) {
|
|
2304
|
-
return a.name === b.name && a.optional === b.optional && a.repeatable === b.repeatable;
|
|
2305
|
-
}
|
|
2306
|
-
/**
|
|
2307
|
-
* Check if a path and its alias have the same required params
|
|
2308
|
-
*
|
|
2309
|
-
* @param a - original record
|
|
2310
|
-
* @param b - alias record
|
|
2311
|
-
*/
|
|
2312
|
-
function checkSameParams(a, b) {
|
|
2313
|
-
for (const key of a.keys) if (!key.optional && !b.keys.find(isSameParam.bind(null, key))) {
|
|
2314
|
-
diagnostics.VUE_ROUTER_R0102({
|
|
2315
|
-
alias: b.record.path,
|
|
2316
|
-
original: a.record.path,
|
|
2317
|
-
name: key.name
|
|
2318
|
-
});
|
|
2319
|
-
return;
|
|
2320
|
-
}
|
|
2321
|
-
for (const key of b.keys) if (!key.optional && !a.keys.find(isSameParam.bind(null, key))) {
|
|
2322
|
-
diagnostics.VUE_ROUTER_R0102({
|
|
2323
|
-
alias: b.record.path,
|
|
2324
|
-
original: a.record.path,
|
|
2325
|
-
name: key.name
|
|
2326
|
-
});
|
|
2327
|
-
return;
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
/**
|
|
2331
|
-
* A route with a name and a child with an empty path without a name should warn when adding the route
|
|
2332
|
-
*
|
|
2333
|
-
* @param mainNormalizedRecord - RouteRecordNormalized
|
|
2334
|
-
* @param parent - RouteRecordMatcher
|
|
2335
|
-
*/
|
|
2336
|
-
function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
|
|
2337
|
-
if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path && mainNormalizedRecord.children.length === 0) diagnostics.VUE_ROUTER_R0103({ name: String(parent.record.name) });
|
|
2338
|
-
}
|
|
2339
|
-
function checkSameNameAsAncestor(record, parent) {
|
|
2340
|
-
for (let ancestor = parent; ancestor; ancestor = ancestor.parent) if (ancestor.record.name === record.name) throw new Error(`A route named "${String(record.name)}" has been added as a ${parent === ancestor ? "child" : "descendant"} of a route with the same name. Route names must be unique and a nested route cannot use the same name as an ancestor.`);
|
|
2341
|
-
}
|
|
2342
|
-
function checkMissingParamsInAbsolutePath(record, parent) {
|
|
2343
|
-
for (const key of parent.keys) if (!record.keys.find(isSameParam.bind(null, key))) {
|
|
2344
|
-
diagnostics.VUE_ROUTER_R0104({
|
|
2345
|
-
path: record.record.path,
|
|
2346
|
-
name: key.name,
|
|
2347
|
-
parent: parent.record.path
|
|
2348
|
-
});
|
|
2349
|
-
return;
|
|
2350
|
-
}
|
|
2351
|
-
}
|
|
2352
|
-
/**
|
|
2353
|
-
* Performs a binary search to find the correct insertion index for a new matcher.
|
|
2354
|
-
*
|
|
2355
|
-
* Matchers are primarily sorted by their score. If scores are tied then we also consider parent/child relationships,
|
|
2356
|
-
* with descendants coming before ancestors. If there's still a tie, new routes are inserted after existing routes.
|
|
2357
|
-
*
|
|
2358
|
-
* @param matcher - new matcher to be inserted
|
|
2359
|
-
* @param matchers - existing matchers
|
|
2360
|
-
*/
|
|
2361
|
-
function findInsertionIndex(matcher, matchers) {
|
|
2362
|
-
let lower = 0;
|
|
2363
|
-
let upper = matchers.length;
|
|
2364
|
-
while (lower !== upper) {
|
|
2365
|
-
const mid = lower + upper >> 1;
|
|
2366
|
-
if (comparePathParserScore(matcher, matchers[mid]) < 0) upper = mid;
|
|
2367
|
-
else lower = mid + 1;
|
|
2368
|
-
}
|
|
2369
|
-
const insertionAncestor = getInsertionAncestor(matcher);
|
|
2370
|
-
if (insertionAncestor) {
|
|
2371
|
-
upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
|
|
2372
|
-
if (process.env.NODE_ENV !== "production" && upper < 0) diagnostics.VUE_ROUTER_R0105({
|
|
2373
|
-
ancestor: insertionAncestor.record.path,
|
|
2374
|
-
record: matcher.record.path
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
return upper;
|
|
2378
|
-
}
|
|
2379
|
-
function getInsertionAncestor(matcher) {
|
|
2380
|
-
let ancestor = matcher;
|
|
2381
|
-
while (ancestor = ancestor.parent) if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) return ancestor;
|
|
2382
|
-
}
|
|
2383
|
-
/**
|
|
2384
|
-
* Checks if a matcher can be reachable. This means if it's possible to reach it as a route. For example, routes without
|
|
2385
|
-
* a component, or name, or redirect, are just used to group other routes.
|
|
2386
|
-
* @param matcher
|
|
2387
|
-
* @param matcher.record record of the matcher
|
|
2388
|
-
* @returns
|
|
2389
|
-
*/
|
|
2390
|
-
function isMatchable({ record }) {
|
|
2391
|
-
return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
|
|
2392
|
-
}
|
|
2393
|
-
//#endregion
|
|
2394
|
-
//#region src/RouterLink.ts
|
|
2395
|
-
/**
|
|
2396
|
-
* Returns the internal behavior of a {@link RouterLink} without the rendering part.
|
|
2397
|
-
*
|
|
2398
|
-
* @param props - a `to` location and an optional `replace` flag
|
|
2399
|
-
*/
|
|
2400
|
-
function useLink(props) {
|
|
2401
|
-
const router = inject(routerKey);
|
|
2402
|
-
const currentRoute = inject(routeLocationKey);
|
|
2403
|
-
let hasPrevious = false;
|
|
2404
|
-
let previousTo = null;
|
|
2405
|
-
const route = computed(() => {
|
|
2406
|
-
const to = unref(props.to);
|
|
2407
|
-
if (process.env.NODE_ENV !== "production" && (!hasPrevious || to !== previousTo)) {
|
|
2408
|
-
if (!isRouteLocation(to)) diagnostics.VUE_ROUTER_R0050({ to });
|
|
2409
|
-
previousTo = to;
|
|
2410
|
-
hasPrevious = true;
|
|
2411
|
-
}
|
|
2412
|
-
return router.resolve(to);
|
|
2413
|
-
});
|
|
2414
|
-
const activeRecordIndex = computed(() => {
|
|
2415
|
-
const { matched } = route.value;
|
|
2416
|
-
const { length } = matched;
|
|
2417
|
-
const routeMatched = matched[length - 1];
|
|
2418
|
-
const currentMatched = currentRoute.matched;
|
|
2419
|
-
if (!routeMatched || !currentMatched.length) return -1;
|
|
2420
|
-
const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
|
|
2421
|
-
if (index > -1) return index;
|
|
2422
|
-
const parentRecordPath = getOriginalPath(matched[length - 2]);
|
|
2423
|
-
return length > 1 && getOriginalPath(routeMatched) === parentRecordPath && currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index;
|
|
2424
|
-
});
|
|
2425
|
-
const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
|
|
2426
|
-
const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
|
|
2427
|
-
function navigate(e = {}) {
|
|
2428
|
-
if (guardEvent(e)) {
|
|
2429
|
-
const p = router[unref(props.replace) ? "replace" : "push"](unref(props.to)).catch(noop);
|
|
2430
|
-
if (props.viewTransition && typeof document !== "undefined" && "startViewTransition" in document) document.startViewTransition(() => p);
|
|
2431
|
-
return p;
|
|
2432
|
-
}
|
|
2433
|
-
return Promise.resolve();
|
|
2434
|
-
}
|
|
2435
|
-
if ((process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) && isBrowser) {
|
|
2436
|
-
const instance = getCurrentInstance();
|
|
2437
|
-
if (instance) {
|
|
2438
|
-
const linkContextDevtools = {
|
|
2439
|
-
route: route.value,
|
|
2440
|
-
isActive: isActive.value,
|
|
2441
|
-
isExactActive: isExactActive.value,
|
|
2442
|
-
error: null
|
|
2443
|
-
};
|
|
2444
|
-
instance.__vrl_devtools = instance.__vrl_devtools || [];
|
|
2445
|
-
instance.__vrl_devtools.push(linkContextDevtools);
|
|
2446
|
-
watchEffect(() => {
|
|
2447
|
-
linkContextDevtools.route = route.value;
|
|
2448
|
-
linkContextDevtools.isActive = isActive.value;
|
|
2449
|
-
linkContextDevtools.isExactActive = isExactActive.value;
|
|
2450
|
-
linkContextDevtools.error = isRouteLocation(unref(props.to)) ? null : "Invalid \"to\" value";
|
|
2451
|
-
}, { flush: "post" });
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* NOTE: update {@link _RouterLinkI}'s `$slots` type when updating this
|
|
2456
|
-
*/
|
|
2457
|
-
return {
|
|
2458
|
-
route,
|
|
2459
|
-
href: computed(() => route.value.href),
|
|
2460
|
-
isActive,
|
|
2461
|
-
isExactActive,
|
|
2462
|
-
navigate
|
|
2463
|
-
};
|
|
2464
|
-
}
|
|
2465
|
-
function preferSingleVNode(vnodes) {
|
|
2466
|
-
return vnodes.length === 1 ? vnodes[0] : vnodes;
|
|
2467
|
-
}
|
|
2468
|
-
/**
|
|
2469
|
-
* Component to render a link that triggers a navigation on click.
|
|
2470
|
-
*/
|
|
2471
|
-
const RouterLink = /* @__PURE__ */ defineComponent({
|
|
2472
|
-
name: "RouterLink",
|
|
2473
|
-
compatConfig: { MODE: 3 },
|
|
2474
|
-
props: {
|
|
2475
|
-
to: {
|
|
2476
|
-
type: [String, Object],
|
|
2477
|
-
required: true
|
|
2478
|
-
},
|
|
2479
|
-
replace: Boolean,
|
|
2480
|
-
activeClass: String,
|
|
2481
|
-
exactActiveClass: String,
|
|
2482
|
-
custom: Boolean,
|
|
2483
|
-
ariaCurrentValue: {
|
|
2484
|
-
type: String,
|
|
2485
|
-
default: "page"
|
|
2486
|
-
},
|
|
2487
|
-
viewTransition: Boolean
|
|
2488
|
-
},
|
|
2489
|
-
useLink,
|
|
2490
|
-
setup(props, { slots }) {
|
|
2491
|
-
const link = reactive(useLink(props));
|
|
2492
|
-
const { options } = inject(routerKey);
|
|
2493
|
-
const elClass = computed(() => ({
|
|
2494
|
-
[getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
|
|
2495
|
-
[getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
|
|
2496
|
-
}));
|
|
2497
|
-
return () => {
|
|
2498
|
-
const children = slots.default && preferSingleVNode(slots.default(link));
|
|
2499
|
-
return props.custom ? children : h("a", {
|
|
2500
|
-
"aria-current": link.isExactActive ? props.ariaCurrentValue : null,
|
|
2501
|
-
href: link.href,
|
|
2502
|
-
onClick: link.navigate,
|
|
2503
|
-
class: elClass.value
|
|
2504
|
-
}, children);
|
|
2505
|
-
};
|
|
2506
|
-
}
|
|
2507
|
-
});
|
|
2508
|
-
function guardEvent(e) {
|
|
2509
|
-
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return;
|
|
2510
|
-
if (e.defaultPrevented) return;
|
|
2511
|
-
if (e.button !== void 0 && e.button !== 0) return;
|
|
2512
|
-
if (e.currentTarget && e.currentTarget.getAttribute) {
|
|
2513
|
-
const target = e.currentTarget.getAttribute("target");
|
|
2514
|
-
if (/\b_blank\b/i.test(target)) return;
|
|
2515
|
-
}
|
|
2516
|
-
if (e.preventDefault) e.preventDefault();
|
|
2517
|
-
return true;
|
|
2518
|
-
}
|
|
2519
|
-
function includesParams(outer, inner) {
|
|
2520
|
-
for (const key in inner) {
|
|
2521
|
-
const innerValue = inner[key];
|
|
2522
|
-
const outerValue = outer[key];
|
|
2523
|
-
if (isArray(innerValue)) {
|
|
2524
|
-
if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value.valueOf() !== outerValue[i].valueOf())) return false;
|
|
2525
|
-
} else if (innerValue !== outerValue) return false;
|
|
2526
|
-
}
|
|
2527
|
-
return true;
|
|
2528
|
-
}
|
|
2529
|
-
/**
|
|
2530
|
-
* Get the original path value of a record by following its aliasOf
|
|
2531
|
-
* @param record
|
|
2532
|
-
*/
|
|
2533
|
-
function getOriginalPath(record) {
|
|
2534
|
-
return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
|
|
2535
|
-
}
|
|
2536
|
-
/**
|
|
2537
|
-
* Utility class to get the active class based on defaults.
|
|
2538
|
-
* @param propClass
|
|
2539
|
-
* @param globalClass
|
|
2540
|
-
* @param defaultClass
|
|
2541
|
-
*/
|
|
2542
|
-
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
|
|
2543
|
-
//#endregion
|
|
2544
|
-
//#region src/RouterView.ts
|
|
2545
|
-
const RouterViewImpl = /*#__PURE__*/ defineComponent({
|
|
2546
|
-
name: "RouterView",
|
|
2547
|
-
inheritAttrs: false,
|
|
2548
|
-
props: {
|
|
2549
|
-
name: {
|
|
2550
|
-
type: String,
|
|
2551
|
-
default: "default"
|
|
2552
|
-
},
|
|
2553
|
-
route: Object
|
|
2554
|
-
},
|
|
2555
|
-
compatConfig: { MODE: 3 },
|
|
2556
|
-
setup(props, { attrs, slots }) {
|
|
2557
|
-
process.env.NODE_ENV !== "production" && warnDeprecatedUsage();
|
|
2558
|
-
const injectedRoute = inject(routerViewLocationKey);
|
|
2559
|
-
const routeToDisplay = computed(() => props.route || injectedRoute.value);
|
|
2560
|
-
const injectedDepth = inject(viewDepthKey, 0);
|
|
2561
|
-
const depth = computed(() => {
|
|
2562
|
-
let initialDepth = unref(injectedDepth);
|
|
2563
|
-
const { matched } = routeToDisplay.value;
|
|
2564
|
-
let matchedRoute;
|
|
2565
|
-
while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) initialDepth++;
|
|
2566
|
-
return initialDepth;
|
|
2567
|
-
});
|
|
2568
|
-
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
|
|
2569
|
-
provide(viewDepthKey, computed(() => depth.value + 1));
|
|
2570
|
-
provide(matchedRouteKey, matchedRouteRef);
|
|
2571
|
-
provide(routerViewLocationKey, routeToDisplay);
|
|
2572
|
-
const viewRef = ref();
|
|
2573
|
-
watch(() => [
|
|
2574
|
-
viewRef.value,
|
|
2575
|
-
matchedRouteRef.value,
|
|
2576
|
-
props.name
|
|
2577
|
-
], ([instance, to, name], [oldInstance, from, _oldName]) => {
|
|
2578
|
-
if (to) {
|
|
2579
|
-
to.instances[name] = instance;
|
|
2580
|
-
if (from && from !== to && instance && instance === oldInstance) {
|
|
2581
|
-
if (!to.leaveGuards.size) to.leaveGuards = from.leaveGuards;
|
|
2582
|
-
if (!to.updateGuards.size) to.updateGuards = from.updateGuards;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
if (instance && to && (!from || !isSameRouteRecord(to, from) || !oldInstance)) (to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
|
|
2586
|
-
}, { flush: "post" });
|
|
2587
|
-
return () => {
|
|
2588
|
-
const route = routeToDisplay.value;
|
|
2589
|
-
const currentName = props.name;
|
|
2590
|
-
const matchedRoute = matchedRouteRef.value;
|
|
2591
|
-
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
|
|
2592
|
-
if (!ViewComponent) return normalizeSlot(slots.default, {
|
|
2593
|
-
Component: ViewComponent,
|
|
2594
|
-
route
|
|
2595
|
-
});
|
|
2596
|
-
const routePropsOption = matchedRoute.props[currentName];
|
|
2597
|
-
const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
|
|
2598
|
-
const onVnodeUnmounted = (vnode) => {
|
|
2599
|
-
if (vnode.component.isUnmounted) matchedRoute.instances[currentName] = null;
|
|
2600
|
-
};
|
|
2601
|
-
const component = h(ViewComponent, assign({}, routeProps, attrs, {
|
|
2602
|
-
onVnodeUnmounted,
|
|
2603
|
-
ref: viewRef
|
|
2604
|
-
}));
|
|
2605
|
-
if ((process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) && isBrowser && component.ref) {
|
|
2606
|
-
const info = {
|
|
2607
|
-
depth: depth.value,
|
|
2608
|
-
name: matchedRoute.name,
|
|
2609
|
-
path: matchedRoute.path,
|
|
2610
|
-
meta: matchedRoute.meta
|
|
2611
|
-
};
|
|
2612
|
-
(isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i]).forEach((instance) => {
|
|
2613
|
-
if (instance) instance.__vrv_devtools = info;
|
|
2614
|
-
});
|
|
2615
|
-
}
|
|
2616
|
-
return normalizeSlot(slots.default, {
|
|
2617
|
-
Component: component,
|
|
2618
|
-
route
|
|
2619
|
-
}) || component;
|
|
2620
|
-
};
|
|
2621
|
-
}
|
|
2622
|
-
});
|
|
2623
|
-
function normalizeSlot(slot, data) {
|
|
2624
|
-
if (!slot) return null;
|
|
2625
|
-
const slotContent = slot(data);
|
|
2626
|
-
return slotContent.length === 1 ? slotContent[0] : slotContent;
|
|
2627
|
-
}
|
|
2628
|
-
/**
|
|
2629
|
-
* Component to display the current route the user is at.
|
|
2630
|
-
*/
|
|
2631
|
-
const RouterView = RouterViewImpl;
|
|
2632
|
-
function warnDeprecatedUsage() {
|
|
2633
|
-
const instance = getCurrentInstance();
|
|
2634
|
-
const parentName = instance.parent && instance.parent.type.name;
|
|
2635
|
-
const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
|
|
2636
|
-
if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
|
|
2637
|
-
const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
|
|
2638
|
-
diagnostics.VUE_ROUTER_R0060({ comp });
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
//#endregion
|
|
2642
|
-
//#region src/router.ts
|
|
2643
|
-
/**
|
|
2644
|
-
* Creates a Router instance that can be used by a Vue app.
|
|
2645
|
-
*
|
|
2646
|
-
* @param options - {@link RouterOptions}
|
|
2647
|
-
*/
|
|
2648
|
-
function createRouter(options) {
|
|
2649
|
-
const matcher = createRouterMatcher(options.routes, options);
|
|
2650
|
-
const parseQuery$1 = options.parseQuery || parseQuery;
|
|
2651
|
-
const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
|
|
2652
|
-
const routerHistory = options.history;
|
|
2653
|
-
if (process.env.NODE_ENV !== "production" && !routerHistory) throw new Error("Provide the \"history\" option when calling \"createRouter()\": https://router.vuejs.org/api/interfaces/RouterOptions.html#history");
|
|
2654
|
-
const beforeGuards = useCallbacks();
|
|
2655
|
-
const beforeResolveGuards = useCallbacks();
|
|
2656
|
-
const afterGuards = useCallbacks();
|
|
2657
|
-
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
|
|
2658
|
-
const routesVersion = shallowRef(0);
|
|
2659
|
-
let pendingLocation = START_LOCATION_NORMALIZED;
|
|
2660
|
-
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) history.scrollRestoration = "manual";
|
|
2661
|
-
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
|
|
2662
|
-
const encodeParams = applyToParams.bind(null, encodeParam);
|
|
2663
|
-
const decodeParams = applyToParams.bind(null, decode);
|
|
2664
|
-
function addRoute(parentOrRoute, route) {
|
|
2665
|
-
let parent;
|
|
2666
|
-
let record;
|
|
2667
|
-
if (isRouteName(parentOrRoute)) {
|
|
2668
|
-
parent = matcher.getRecordMatcher(parentOrRoute);
|
|
2669
|
-
if (process.env.NODE_ENV !== "production" && !parent) diagnostics.VUE_ROUTER_R0001({ name: String(parentOrRoute) });
|
|
2670
|
-
record = route;
|
|
2671
|
-
} else record = parentOrRoute;
|
|
2672
|
-
const removeRoute = matcher.addRoute(record, parent);
|
|
2673
|
-
routesVersion.value++;
|
|
2674
|
-
return () => {
|
|
2675
|
-
removeRoute();
|
|
2676
|
-
routesVersion.value++;
|
|
2677
|
-
};
|
|
2678
|
-
}
|
|
2679
|
-
function removeRoute(name) {
|
|
2680
|
-
const recordMatcher = matcher.getRecordMatcher(name);
|
|
2681
|
-
if (recordMatcher) {
|
|
2682
|
-
matcher.removeRoute(recordMatcher);
|
|
2683
|
-
routesVersion.value++;
|
|
2684
|
-
} else if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0002({ name: String(name) });
|
|
2685
|
-
}
|
|
2686
|
-
function clearRoutes() {
|
|
2687
|
-
matcher.clearRoutes();
|
|
2688
|
-
routesVersion.value++;
|
|
2689
|
-
}
|
|
2690
|
-
function getRoutes() {
|
|
2691
|
-
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
|
|
2692
|
-
}
|
|
2693
|
-
function hasRoute(name) {
|
|
2694
|
-
return !!matcher.getRecordMatcher(name);
|
|
2695
|
-
}
|
|
2696
|
-
function resolve(rawLocation, currentLocation) {
|
|
2697
|
-
routesVersion.value;
|
|
2698
|
-
if (typeof rawLocation === "string") {
|
|
2699
|
-
currentLocation = currentLocation || (rawLocation.startsWith("/") ? START_LOCATION_NORMALIZED : currentRoute.value);
|
|
2700
|
-
const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
|
|
2701
|
-
const matchedRoute = matcher.resolve({ path: locationNormalized.path }, currentLocation);
|
|
2702
|
-
const href = routerHistory.createHref(locationNormalized.fullPath);
|
|
2703
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2704
|
-
if (href.startsWith("//")) diagnostics.VUE_ROUTER_R0003({
|
|
2705
|
-
location: rawLocation,
|
|
2706
|
-
href
|
|
2707
|
-
});
|
|
2708
|
-
else if (!matchedRoute.matched.length) diagnostics.VUE_ROUTER_R0004({ path: rawLocation });
|
|
2709
|
-
}
|
|
2710
|
-
return assign(locationNormalized, matchedRoute, {
|
|
2711
|
-
params: decodeParams(matchedRoute.params),
|
|
2712
|
-
redirectedFrom: void 0,
|
|
2713
|
-
href
|
|
2714
|
-
});
|
|
2715
|
-
}
|
|
2716
|
-
if (process.env.NODE_ENV !== "production" && !isRouteLocation(rawLocation)) {
|
|
2717
|
-
diagnostics.VUE_ROUTER_R0005({ rawLocation });
|
|
2718
|
-
return resolve({});
|
|
2719
|
-
}
|
|
2720
|
-
currentLocation = assign({}, currentLocation || (rawLocation.path != null && rawLocation.path.startsWith("/") && !("name" in rawLocation && rawLocation.name) ? START_LOCATION_NORMALIZED : currentRoute.value));
|
|
2721
|
-
let matcherLocation;
|
|
2722
|
-
if (rawLocation.path != null) {
|
|
2723
|
-
if (process.env.NODE_ENV !== "production" && "params" in rawLocation && !("name" in rawLocation) && Object.keys(rawLocation.params).length) diagnostics.VUE_ROUTER_R0006({ path: rawLocation.path });
|
|
2724
|
-
matcherLocation = assign({}, rawLocation, { path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path });
|
|
2725
|
-
} else {
|
|
2726
|
-
const targetParams = assign({}, rawLocation.params);
|
|
2727
|
-
for (const key in targetParams) if (targetParams[key] == null) delete targetParams[key];
|
|
2728
|
-
matcherLocation = assign({}, rawLocation, { params: encodeParams(targetParams) });
|
|
2729
|
-
currentLocation.params = encodeParams(currentLocation.params);
|
|
2730
|
-
}
|
|
2731
|
-
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
|
|
2732
|
-
const hash = rawLocation.hash || "";
|
|
2733
|
-
if (process.env.NODE_ENV !== "production" && hash && !hash.startsWith("#")) diagnostics.VUE_ROUTER_R0007({ hash });
|
|
2734
|
-
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
|
|
2735
|
-
const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
|
|
2736
|
-
hash: encodeHash(hash),
|
|
2737
|
-
path: matchedRoute.path
|
|
2738
|
-
}));
|
|
2739
|
-
const href = routerHistory.createHref(fullPath);
|
|
2740
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2741
|
-
if (href.startsWith("//")) diagnostics.VUE_ROUTER_R0003({
|
|
2742
|
-
location: rawLocation,
|
|
2743
|
-
href
|
|
2744
|
-
});
|
|
2745
|
-
else if (!matchedRoute.matched.length) diagnostics.VUE_ROUTER_R0004({ path: rawLocation.path != null ? rawLocation.path : rawLocation });
|
|
2746
|
-
}
|
|
2747
|
-
return assign({
|
|
2748
|
-
fullPath,
|
|
2749
|
-
hash,
|
|
2750
|
-
query: stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
|
|
2751
|
-
}, matchedRoute, {
|
|
2752
|
-
redirectedFrom: void 0,
|
|
2753
|
-
href
|
|
2754
|
-
});
|
|
2755
|
-
}
|
|
2756
|
-
function locationAsObject(to) {
|
|
2757
|
-
return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
|
|
2758
|
-
}
|
|
2759
|
-
function checkCanceledNavigation(to, from) {
|
|
2760
|
-
if (pendingLocation !== to) return createRouterError(8, {
|
|
2761
|
-
from,
|
|
2762
|
-
to
|
|
2763
|
-
});
|
|
2764
|
-
}
|
|
2765
|
-
function push(to) {
|
|
2766
|
-
return pushWithRedirect(to);
|
|
2767
|
-
}
|
|
2768
|
-
function replace(to) {
|
|
2769
|
-
return push(assign(locationAsObject(to), { replace: true }));
|
|
2770
|
-
}
|
|
2771
|
-
function handleRedirectRecord(to, from) {
|
|
2772
|
-
const lastMatched = to.matched[to.matched.length - 1];
|
|
2773
|
-
if (lastMatched && lastMatched.redirect) {
|
|
2774
|
-
const { redirect } = lastMatched;
|
|
2775
|
-
let newTargetLocation = typeof redirect === "function" ? redirect(to, from) : redirect;
|
|
2776
|
-
if (typeof newTargetLocation === "string") {
|
|
2777
|
-
newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : { path: newTargetLocation };
|
|
2778
|
-
newTargetLocation.params = {};
|
|
2779
|
-
}
|
|
2780
|
-
if (process.env.NODE_ENV !== "production" && newTargetLocation.path == null && !("name" in newTargetLocation)) {
|
|
2781
|
-
diagnostics.VUE_ROUTER_R0008({
|
|
2782
|
-
target: JSON.stringify(newTargetLocation, null, 2),
|
|
2783
|
-
to: to.fullPath
|
|
2784
|
-
});
|
|
2785
|
-
throw new Error("Invalid redirect");
|
|
2786
|
-
}
|
|
2787
|
-
return assign({
|
|
2788
|
-
query: to.query,
|
|
2789
|
-
hash: to.hash,
|
|
2790
|
-
params: newTargetLocation.path != null ? {} : to.params
|
|
2791
|
-
}, newTargetLocation);
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
function pushWithRedirect(to, redirectedFrom) {
|
|
2795
|
-
const targetLocation = pendingLocation = resolve(to);
|
|
2796
|
-
const from = currentRoute.value;
|
|
2797
|
-
const data = to.state;
|
|
2798
|
-
const force = to.force;
|
|
2799
|
-
const replace = to.replace === true;
|
|
2800
|
-
const shouldRedirect = handleRedirectRecord(targetLocation, from);
|
|
2801
|
-
if (shouldRedirect) return pushWithRedirect(assign(locationAsObject(shouldRedirect), {
|
|
2802
|
-
state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
|
|
2803
|
-
force,
|
|
2804
|
-
replace
|
|
2805
|
-
}), redirectedFrom || targetLocation);
|
|
2806
|
-
const toLocation = targetLocation;
|
|
2807
|
-
toLocation.redirectedFrom = redirectedFrom;
|
|
2808
|
-
let failure;
|
|
2809
|
-
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
|
|
2810
|
-
failure = createRouterError(16, {
|
|
2811
|
-
to: toLocation,
|
|
2812
|
-
from
|
|
2813
|
-
});
|
|
2814
|
-
handleScroll(from, from, true, false);
|
|
2815
|
-
}
|
|
2816
|
-
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? isNavigationFailure(error, 2) ? error : markAsReady(error) : triggerError(error, toLocation, from)).then((failure) => {
|
|
2817
|
-
if (failure) {
|
|
2818
|
-
if (isNavigationFailure(failure, 2)) {
|
|
2819
|
-
if (process.env.NODE_ENV !== "production" && isSameRouteLocation(stringifyQuery$1, resolve(failure.to), toLocation) && redirectedFrom && (redirectedFrom._count = redirectedFrom._count ? redirectedFrom._count + 1 : 1) > 30) {
|
|
2820
|
-
diagnostics.VUE_ROUTER_R0009({
|
|
2821
|
-
from: from.fullPath,
|
|
2822
|
-
to: toLocation.fullPath
|
|
2823
|
-
});
|
|
2824
|
-
return Promise.reject(/* @__PURE__ */ new Error("Infinite redirect in navigation guard"));
|
|
2825
|
-
}
|
|
2826
|
-
return pushWithRedirect(assign({ replace }, locationAsObject(failure.to), {
|
|
2827
|
-
state: typeof failure.to === "object" ? assign({}, data, failure.to.state) : data,
|
|
2828
|
-
force
|
|
2829
|
-
}), redirectedFrom || toLocation);
|
|
2830
|
-
}
|
|
2831
|
-
} else failure = finalizeNavigation(toLocation, from, true, replace, data);
|
|
2832
|
-
triggerAfterEach(toLocation, from, failure);
|
|
2833
|
-
return failure;
|
|
2834
|
-
});
|
|
2835
|
-
}
|
|
2836
|
-
/**
|
|
2837
|
-
* Helper to reject and skip all navigation guards if a new navigation happened
|
|
2838
|
-
* @param to
|
|
2839
|
-
* @param from
|
|
2840
|
-
*/
|
|
2841
|
-
function checkCanceledNavigationAndReject(to, from) {
|
|
2842
|
-
const error = checkCanceledNavigation(to, from);
|
|
2843
|
-
return error ? Promise.reject(error) : Promise.resolve();
|
|
2844
|
-
}
|
|
2845
|
-
function runWithContext(fn) {
|
|
2846
|
-
const app = installedApps.values().next().value;
|
|
2847
|
-
return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
|
|
2848
|
-
}
|
|
2849
|
-
function navigate(to, from) {
|
|
2850
|
-
let guards;
|
|
2851
|
-
const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
|
|
2852
|
-
guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
|
|
2853
|
-
for (const record of leavingRecords) record.leaveGuards.forEach((guard) => {
|
|
2854
|
-
guards.push(guardToPromiseFn(guard, to, from));
|
|
2855
|
-
});
|
|
2856
|
-
const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
|
|
2857
|
-
guards.push(canceledNavigationCheck);
|
|
2858
|
-
return runGuardQueue(guards).then(() => {
|
|
2859
|
-
guards = [];
|
|
2860
|
-
for (const guard of beforeGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
|
|
2861
|
-
guards.push(canceledNavigationCheck);
|
|
2862
|
-
return runGuardQueue(guards);
|
|
2863
|
-
}).then(() => {
|
|
2864
|
-
guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
|
|
2865
|
-
for (const record of updatingRecords) record.updateGuards.forEach((guard) => {
|
|
2866
|
-
guards.push(guardToPromiseFn(guard, to, from));
|
|
2867
|
-
});
|
|
2868
|
-
guards.push(canceledNavigationCheck);
|
|
2869
|
-
return runGuardQueue(guards);
|
|
2870
|
-
}).then(() => {
|
|
2871
|
-
guards = [];
|
|
2872
|
-
for (const record of enteringRecords) if (record.beforeEnter) {
|
|
2873
|
-
if (isArray(record.beforeEnter)) for (const beforeEnter of record.beforeEnter) guards.push(guardToPromiseFn(beforeEnter, to, from));
|
|
2874
|
-
else guards.push(guardToPromiseFn(record.beforeEnter, to, from));
|
|
2875
|
-
}
|
|
2876
|
-
guards.push(canceledNavigationCheck);
|
|
2877
|
-
return runGuardQueue(guards);
|
|
2878
|
-
}).then(() => {
|
|
2879
|
-
to.matched.forEach((record) => record.enterCallbacks = {});
|
|
2880
|
-
guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from, runWithContext);
|
|
2881
|
-
guards.push(canceledNavigationCheck);
|
|
2882
|
-
return runGuardQueue(guards);
|
|
2883
|
-
}).then(() => {
|
|
2884
|
-
guards = [];
|
|
2885
|
-
for (const guard of beforeResolveGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
|
|
2886
|
-
guards.push(canceledNavigationCheck);
|
|
2887
|
-
return runGuardQueue(guards);
|
|
2888
|
-
}).catch((err) => isNavigationFailure(err, 8) ? err : Promise.reject(err));
|
|
2889
|
-
}
|
|
2890
|
-
function triggerAfterEach(to, from, failure) {
|
|
2891
|
-
afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
|
|
2892
|
-
}
|
|
2893
|
-
/**
|
|
2894
|
-
* - Cleans up any navigation guards
|
|
2895
|
-
* - Changes the url if necessary
|
|
2896
|
-
* - Calls the scrollBehavior
|
|
2897
|
-
*/
|
|
2898
|
-
function finalizeNavigation(toLocation, from, isPush, replace, data) {
|
|
2899
|
-
const error = checkCanceledNavigation(toLocation, from);
|
|
2900
|
-
if (error) return error;
|
|
2901
|
-
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
|
|
2902
|
-
const state = !isBrowser ? {} : history.state;
|
|
2903
|
-
if (isPush) {
|
|
2904
|
-
if (replace || isFirstNavigation) routerHistory.replace(toLocation.fullPath, assign({ scroll: isFirstNavigation && state && state.scroll }, data));
|
|
2905
|
-
else routerHistory.push(toLocation.fullPath, data);
|
|
2906
|
-
}
|
|
2907
|
-
currentRoute.value = toLocation;
|
|
2908
|
-
handleScroll(toLocation, from, isPush, isFirstNavigation);
|
|
2909
|
-
markAsReady();
|
|
2910
|
-
}
|
|
2911
|
-
let removeHistoryListener;
|
|
2912
|
-
function setupListeners() {
|
|
2913
|
-
if (removeHistoryListener) return;
|
|
2914
|
-
removeHistoryListener = routerHistory.listen((to, _from, info) => {
|
|
2915
|
-
if (!router.listening) return;
|
|
2916
|
-
const toLocation = resolve(to);
|
|
2917
|
-
const shouldRedirect = handleRedirectRecord(toLocation, router.currentRoute.value);
|
|
2918
|
-
if (shouldRedirect) {
|
|
2919
|
-
pushWithRedirect(assign(shouldRedirect, {
|
|
2920
|
-
replace: true,
|
|
2921
|
-
force: true
|
|
2922
|
-
}), toLocation).catch(noop);
|
|
2923
|
-
return;
|
|
2924
|
-
}
|
|
2925
|
-
pendingLocation = toLocation;
|
|
2926
|
-
const from = currentRoute.value;
|
|
2927
|
-
if (isBrowser && info.delta) saveScrollPosition(getScrollKey(from.fullPath, info.delta));
|
|
2928
|
-
navigate(toLocation, from).catch((error) => {
|
|
2929
|
-
if (isNavigationFailure(error, 12)) return error;
|
|
2930
|
-
if (isNavigationFailure(error, 2)) {
|
|
2931
|
-
pushWithRedirect(assign(locationAsObject(error.to), { force: true }), toLocation).then((failure) => {
|
|
2932
|
-
if (isNavigationFailure(failure, 20) && !info.delta && info.type === "pop") routerHistory.go(-1, false);
|
|
2933
|
-
}).catch(noop);
|
|
2934
|
-
return Promise.reject();
|
|
2935
|
-
}
|
|
2936
|
-
if (info.delta) routerHistory.go(-info.delta, false);
|
|
2937
|
-
return triggerError(error, toLocation, from);
|
|
2938
|
-
}).then((failure) => {
|
|
2939
|
-
failure = failure || finalizeNavigation(toLocation, from, false);
|
|
2940
|
-
if (failure) {
|
|
2941
|
-
if (info.delta && !isNavigationFailure(failure, 8)) routerHistory.go(-info.delta, false);
|
|
2942
|
-
else if (info.type === "pop" && isNavigationFailure(failure, 20)) routerHistory.go(-1, false);
|
|
2943
|
-
}
|
|
2944
|
-
triggerAfterEach(toLocation, from, failure);
|
|
2945
|
-
}).catch(noop);
|
|
2946
|
-
});
|
|
2947
|
-
}
|
|
2948
|
-
let readyHandlers = useCallbacks();
|
|
2949
|
-
let errorListeners = useCallbacks();
|
|
2950
|
-
let ready;
|
|
2951
|
-
/**
|
|
2952
|
-
* Trigger errorListeners added via onError and throws the error as well
|
|
2953
|
-
*
|
|
2954
|
-
* @param error - error to throw
|
|
2955
|
-
* @param to - location we were navigating to when the error happened
|
|
2956
|
-
* @param from - location we were navigating from when the error happened
|
|
2957
|
-
* @returns the error as a rejected promise
|
|
2958
|
-
*/
|
|
2959
|
-
function triggerError(error, to, from) {
|
|
2960
|
-
markAsReady(error);
|
|
2961
|
-
const list = errorListeners.list();
|
|
2962
|
-
if (list.length) list.forEach((handler) => handler(error, to, from));
|
|
2963
|
-
else {
|
|
2964
|
-
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0010();
|
|
2965
|
-
console.error(error);
|
|
2966
|
-
}
|
|
2967
|
-
return Promise.reject(error);
|
|
2968
|
-
}
|
|
2969
|
-
function isReady() {
|
|
2970
|
-
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED) return Promise.resolve();
|
|
2971
|
-
return new Promise((resolve, reject) => {
|
|
2972
|
-
readyHandlers.add([resolve, reject]);
|
|
2973
|
-
});
|
|
2974
|
-
}
|
|
2975
|
-
function markAsReady(err) {
|
|
2976
|
-
if (!ready) {
|
|
2977
|
-
ready = !err;
|
|
2978
|
-
setupListeners();
|
|
2979
|
-
readyHandlers.list().forEach(([resolve, reject]) => err ? reject(err) : resolve());
|
|
2980
|
-
readyHandlers.reset();
|
|
2981
|
-
}
|
|
2982
|
-
return err;
|
|
2983
|
-
}
|
|
2984
|
-
function handleScroll(to, from, isPush, isFirstNavigation) {
|
|
2985
|
-
const { scrollBehavior } = options;
|
|
2986
|
-
if (!isBrowser || !scrollBehavior) return Promise.resolve();
|
|
2987
|
-
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
|
|
2988
|
-
return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => to === currentRoute.value && position && scrollToPosition(position)).catch((err) => to === currentRoute.value && triggerError(err, to, from));
|
|
2989
|
-
}
|
|
2990
|
-
const go = (delta) => routerHistory.go(delta);
|
|
2991
|
-
let started;
|
|
2992
|
-
const installedApps = /* @__PURE__ */ new Set();
|
|
2993
|
-
const router = {
|
|
2994
|
-
currentRoute,
|
|
2995
|
-
listening: true,
|
|
2996
|
-
addRoute,
|
|
2997
|
-
removeRoute,
|
|
2998
|
-
clearRoutes,
|
|
2999
|
-
hasRoute,
|
|
3000
|
-
getRoutes,
|
|
3001
|
-
resolve,
|
|
3002
|
-
options,
|
|
3003
|
-
push,
|
|
3004
|
-
replace,
|
|
3005
|
-
go,
|
|
3006
|
-
back: () => go(-1),
|
|
3007
|
-
forward: () => go(1),
|
|
3008
|
-
beforeEach: beforeGuards.add,
|
|
3009
|
-
beforeResolve: beforeResolveGuards.add,
|
|
3010
|
-
afterEach: afterGuards.add,
|
|
3011
|
-
onError: errorListeners.add,
|
|
3012
|
-
isReady,
|
|
3013
|
-
install(app) {
|
|
3014
|
-
app.component("RouterLink", RouterLink);
|
|
3015
|
-
app.component("RouterView", RouterView);
|
|
3016
|
-
app.config.globalProperties.$router = router;
|
|
3017
|
-
Object.defineProperty(app.config.globalProperties, "$route", {
|
|
3018
|
-
enumerable: true,
|
|
3019
|
-
get: () => unref(currentRoute)
|
|
3020
|
-
});
|
|
3021
|
-
if (isBrowser && !started && currentRoute.value === START_LOCATION_NORMALIZED) {
|
|
3022
|
-
started = true;
|
|
3023
|
-
push(routerHistory.location).catch((err) => {
|
|
3024
|
-
if (process.env.NODE_ENV !== "production") diagnostics.VUE_ROUTER_R0011({ cause: err });
|
|
3025
|
-
});
|
|
3026
|
-
}
|
|
3027
|
-
const reactiveRoute = {};
|
|
3028
|
-
for (const key in START_LOCATION_NORMALIZED) Object.defineProperty(reactiveRoute, key, {
|
|
3029
|
-
get: () => currentRoute.value[key],
|
|
3030
|
-
enumerable: true
|
|
3031
|
-
});
|
|
3032
|
-
app.provide(routerKey, router);
|
|
3033
|
-
app.provide(routeLocationKey, shallowReactive(reactiveRoute));
|
|
3034
|
-
app.provide(routerViewLocationKey, currentRoute);
|
|
3035
|
-
const unmountApp = app.unmount;
|
|
3036
|
-
installedApps.add(app);
|
|
3037
|
-
app.unmount = function() {
|
|
3038
|
-
installedApps.delete(app);
|
|
3039
|
-
if (installedApps.size < 1) {
|
|
3040
|
-
pendingLocation = START_LOCATION_NORMALIZED;
|
|
3041
|
-
removeHistoryListener && removeHistoryListener();
|
|
3042
|
-
removeHistoryListener = null;
|
|
3043
|
-
currentRoute.value = START_LOCATION_NORMALIZED;
|
|
3044
|
-
started = false;
|
|
3045
|
-
ready = false;
|
|
3046
|
-
}
|
|
3047
|
-
unmountApp();
|
|
3048
|
-
};
|
|
3049
|
-
if ((process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) && isBrowser && true) addDevtools(app, router, matcher);
|
|
3050
|
-
}
|
|
3051
|
-
};
|
|
3052
|
-
function runGuardQueue(guards) {
|
|
3053
|
-
return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
|
|
3054
|
-
}
|
|
3055
|
-
return router;
|
|
3056
|
-
}
|
|
3057
|
-
|
|
3058
|
-
export { NavigationFailureType, RouterLink, RouterView, START_LOCATION_NORMALIZED as START_LOCATION, createMemoryHistory, createRouter, createRouterMatcher, createWebHashHistory, createWebHistory, isNavigationFailure, loadRouteLocation, matchedRouteKey, onBeforeRouteLeave, onBeforeRouteUpdate, parseQuery, routeLocationKey, routerKey, routerViewLocationKey, stringifyQuery, useLink, useRoute, useRouter, viewDepthKey };
|