jwt-ui 1.0.4 → 1.0.5

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/lib/jwt-ui.umd.js CHANGED
@@ -41559,7 +41559,7 @@ const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(JwtIconvue_type
41559
41559
 
41560
41560
  /***/ }),
41561
41561
 
41562
- /***/ 7598:
41562
+ /***/ 6082:
41563
41563
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
41564
41564
 
41565
41565
  "use strict";
@@ -41573,10 +41573,10 @@ __webpack_require__.d(__webpack_exports__, {
41573
41573
 
41574
41574
  // EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
41575
41575
  var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(7203);
41576
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtIconSelect/index.vue?vue&type=template&id=5e3b233f&scoped=true
41576
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtIconSelect/index.vue?vue&type=template&id=45bb6640&scoped=true
41577
41577
 
41578
41578
 
41579
- const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.pushScopeId)("data-v-5e3b233f"), n = n(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.popScopeId)(), n);
41579
+ const _withScopeId = n => ((0,external_commonjs_vue_commonjs2_vue_root_Vue_.pushScopeId)("data-v-45bb6640"), n = n(), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.popScopeId)(), n);
41580
41580
 
41581
41581
  const _hoisted_1 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,external_commonjs_vue_commonjs2_vue_root_Vue_.createElementVNode)("span", {
41582
41582
  style: {
@@ -41695,7 +41695,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
41695
41695
  _: 1
41696
41696
  });
41697
41697
  }
41698
- ;// CONCATENATED MODULE: ./src/packages/JwtIconSelect/index.vue?vue&type=template&id=5e3b233f&scoped=true
41698
+ ;// CONCATENATED MODULE: ./src/packages/JwtIconSelect/index.vue?vue&type=template&id=45bb6640&scoped=true
41699
41699
 
41700
41700
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.includes.js
41701
41701
  var es_array_includes = __webpack_require__(6699);
@@ -41782,10 +41782,10 @@ const pageSize = 16;
41782
41782
  }));
41783
41783
  ;// CONCATENATED MODULE: ./src/packages/JwtIconSelect/index.vue?vue&type=script&lang=js
41784
41784
 
41785
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtIconSelect/index.vue?vue&type=style&index=0&id=5e3b233f&lang=scss&scoped=true
41785
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtIconSelect/index.vue?vue&type=style&index=0&id=45bb6640&lang=scss&scoped=true
41786
41786
  // extracted by mini-css-extract-plugin
41787
41787
 
41788
- ;// CONCATENATED MODULE: ./src/packages/JwtIconSelect/index.vue?vue&type=style&index=0&id=5e3b233f&lang=scss&scoped=true
41788
+ ;// CONCATENATED MODULE: ./src/packages/JwtIconSelect/index.vue?vue&type=style&index=0&id=45bb6640&lang=scss&scoped=true
41789
41789
 
41790
41790
  // EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
41791
41791
  var exportHelper = __webpack_require__(3744);
@@ -41797,7 +41797,7 @@ var exportHelper = __webpack_require__(3744);
41797
41797
  ;
41798
41798
 
41799
41799
 
41800
- const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(JwtIconSelectvue_type_script_lang_js, [['render',render],['__scopeId',"data-v-5e3b233f"]])
41800
+ const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(JwtIconSelectvue_type_script_lang_js, [['render',render],['__scopeId',"data-v-45bb6640"]])
41801
41801
 
41802
41802
  /* harmony default export */ var JwtIconSelect = (__exports__);
41803
41803
 
@@ -42420,7 +42420,7 @@ const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(JwtSelectServer
42420
42420
 
42421
42421
  /***/ }),
42422
42422
 
42423
- /***/ 5639:
42423
+ /***/ 7801:
42424
42424
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
42425
42425
 
42426
42426
  "use strict";
@@ -42434,10 +42434,10 @@ __webpack_require__.d(__webpack_exports__, {
42434
42434
 
42435
42435
  // EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
42436
42436
  var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(7203);
42437
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtTable/index.vue?vue&type=template&id=755af22e&scoped=true
42437
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtTable/index.vue?vue&type=template&id=9e6b1136&scoped=true
42438
42438
 
42439
42439
 
42440
- const _withScopeId = n => (_pushScopeId("data-v-755af22e"), n = n(), _popScopeId(), n);
42440
+ const _withScopeId = n => (_pushScopeId("data-v-9e6b1136"), n = n(), _popScopeId(), n);
42441
42441
 
42442
42442
  const _hoisted_1 = {
42443
42443
  class: "app-table-wrapper"
@@ -42673,7 +42673,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
42673
42673
  }, undefined, true)])])
42674
42674
  } : undefined]), 1040, ["modelValue", "title"])], 64);
42675
42675
  }
42676
- ;// CONCATENATED MODULE: ./src/packages/JwtTable/index.vue?vue&type=template&id=755af22e&scoped=true
42676
+ ;// CONCATENATED MODULE: ./src/packages/JwtTable/index.vue?vue&type=template&id=9e6b1136&scoped=true
42677
42677
 
42678
42678
  // EXTERNAL MODULE: ./node_modules/@vueuse/shared/index.mjs
42679
42679
  var shared = __webpack_require__(7475);
@@ -48235,3393 +48235,6 @@ const ElMessageBox = _MessageBox;
48235
48235
  var message = __webpack_require__(9489);
48236
48236
  // EXTERNAL MODULE: ./node_modules/lodash/lodash.js
48237
48237
  var lodash = __webpack_require__(6486);
48238
- ;// CONCATENATED MODULE: ./node_modules/vue-router/dist/vue-router.mjs
48239
- /*!
48240
- * vue-router v4.1.2
48241
- * (c) 2022 Eduardo San Martin Morote
48242
- * @license MIT
48243
- */
48244
-
48245
-
48246
-
48247
- const isBrowser = typeof window !== 'undefined';
48248
-
48249
- function isESModule(obj) {
48250
- return obj.__esModule || obj[Symbol.toStringTag] === 'Module';
48251
- }
48252
- const vue_router_assign = Object.assign;
48253
- function applyToParams(fn, params) {
48254
- const newParams = {};
48255
- for (const key in params) {
48256
- const value = params[key];
48257
- newParams[key] = vue_router_isArray(value)
48258
- ? value.map(fn)
48259
- : fn(value);
48260
- }
48261
- return newParams;
48262
- }
48263
- const noop = () => { };
48264
- /**
48265
- * Typesafe alternative to Array.isArray
48266
- * https://github.com/microsoft/TypeScript/pull/48228
48267
- */
48268
- const vue_router_isArray = Array.isArray;
48269
-
48270
- function warn(msg) {
48271
- // avoid using ...args as it breaks in older Edge builds
48272
- const args = Array.from(arguments).slice(1);
48273
- console.warn.apply(console, ['[Vue Router warn]: ' + msg].concat(args));
48274
- }
48275
-
48276
- const TRAILING_SLASH_RE = /\/$/;
48277
- const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, '');
48278
- /**
48279
- * Transforms an URI into a normalized history location
48280
- *
48281
- * @param parseQuery
48282
- * @param location - URI to normalize
48283
- * @param currentLocation - current absolute location. Allows resolving relative
48284
- * paths. Must start with `/`. Defaults to `/`
48285
- * @returns a normalized history location
48286
- */
48287
- function parseURL(parseQuery, location, currentLocation = '/') {
48288
- let path, query = {}, searchString = '', hash = '';
48289
- // Could use URL and URLSearchParams but IE 11 doesn't support it
48290
- // TODO: move to new URL()
48291
- const hashPos = location.indexOf('#');
48292
- let searchPos = location.indexOf('?');
48293
- // the hash appears before the search, so it's not part of the search string
48294
- if (hashPos < searchPos && hashPos >= 0) {
48295
- searchPos = -1;
48296
- }
48297
- if (searchPos > -1) {
48298
- path = location.slice(0, searchPos);
48299
- searchString = location.slice(searchPos + 1, hashPos > -1 ? hashPos : location.length);
48300
- query = parseQuery(searchString);
48301
- }
48302
- if (hashPos > -1) {
48303
- path = path || location.slice(0, hashPos);
48304
- // keep the # character
48305
- hash = location.slice(hashPos, location.length);
48306
- }
48307
- // no search and no query
48308
- path = resolveRelativePath(path != null ? path : location, currentLocation);
48309
- // empty path means a relative query or hash `?foo=f`, `#thing`
48310
- return {
48311
- fullPath: path + (searchString && '?') + searchString + hash,
48312
- path,
48313
- query,
48314
- hash,
48315
- };
48316
- }
48317
- /**
48318
- * Stringifies a URL object
48319
- *
48320
- * @param stringifyQuery
48321
- * @param location
48322
- */
48323
- function stringifyURL(stringifyQuery, location) {
48324
- const query = location.query ? stringifyQuery(location.query) : '';
48325
- return location.path + (query && '?') + query + (location.hash || '');
48326
- }
48327
- /**
48328
- * Strips off the base from the beginning of a location.pathname in a non
48329
- * case-sensitive way.
48330
- *
48331
- * @param pathname - location.pathname
48332
- * @param base - base to strip off
48333
- */
48334
- function stripBase(pathname, base) {
48335
- // no base or base is not found at the beginning
48336
- if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase()))
48337
- return pathname;
48338
- return pathname.slice(base.length) || '/';
48339
- }
48340
- /**
48341
- * Checks if two RouteLocation are equal. This means that both locations are
48342
- * pointing towards the same {@link RouteRecord} and that all `params`, `query`
48343
- * parameters and `hash` are the same
48344
- *
48345
- * @param a - first {@link RouteLocation}
48346
- * @param b - second {@link RouteLocation}
48347
- */
48348
- function isSameRouteLocation(stringifyQuery, a, b) {
48349
- const aLastIndex = a.matched.length - 1;
48350
- const bLastIndex = b.matched.length - 1;
48351
- return (aLastIndex > -1 &&
48352
- aLastIndex === bLastIndex &&
48353
- isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) &&
48354
- isSameRouteLocationParams(a.params, b.params) &&
48355
- stringifyQuery(a.query) === stringifyQuery(b.query) &&
48356
- a.hash === b.hash);
48357
- }
48358
- /**
48359
- * Check if two `RouteRecords` are equal. Takes into account aliases: they are
48360
- * considered equal to the `RouteRecord` they are aliasing.
48361
- *
48362
- * @param a - first {@link RouteRecord}
48363
- * @param b - second {@link RouteRecord}
48364
- */
48365
- function isSameRouteRecord(a, b) {
48366
- // since the original record has an undefined value for aliasOf
48367
- // but all aliases point to the original record, this will always compare
48368
- // the original record
48369
- return (a.aliasOf || a) === (b.aliasOf || b);
48370
- }
48371
- function isSameRouteLocationParams(a, b) {
48372
- if (Object.keys(a).length !== Object.keys(b).length)
48373
- return false;
48374
- for (const key in a) {
48375
- if (!isSameRouteLocationParamsValue(a[key], b[key]))
48376
- return false;
48377
- }
48378
- return true;
48379
- }
48380
- function isSameRouteLocationParamsValue(a, b) {
48381
- return vue_router_isArray(a)
48382
- ? isEquivalentArray(a, b)
48383
- : vue_router_isArray(b)
48384
- ? isEquivalentArray(b, a)
48385
- : a === b;
48386
- }
48387
- /**
48388
- * Check if two arrays are the same or if an array with one single entry is the
48389
- * same as another primitive value. Used to check query and parameters
48390
- *
48391
- * @param a - array of values
48392
- * @param b - array of values or a single value
48393
- */
48394
- function isEquivalentArray(a, b) {
48395
- return vue_router_isArray(b)
48396
- ? a.length === b.length && a.every((value, i) => value === b[i])
48397
- : a.length === 1 && a[0] === b;
48398
- }
48399
- /**
48400
- * Resolves a relative path that starts with `.`.
48401
- *
48402
- * @param to - path location we are resolving
48403
- * @param from - currentLocation.path, should start with `/`
48404
- */
48405
- function resolveRelativePath(to, from) {
48406
- if (to.startsWith('/'))
48407
- return to;
48408
- if (false) {}
48409
- if (!to)
48410
- return from;
48411
- const fromSegments = from.split('/');
48412
- const toSegments = to.split('/');
48413
- let position = fromSegments.length - 1;
48414
- let toPosition;
48415
- let segment;
48416
- for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
48417
- segment = toSegments[toPosition];
48418
- // we stay on the same position
48419
- if (segment === '.')
48420
- continue;
48421
- // go up in the from array
48422
- if (segment === '..') {
48423
- // we can't go below zero but we still need to increment toPosition
48424
- if (position > 1)
48425
- position--;
48426
- // continue
48427
- }
48428
- // we reached a non relative path, we stop here
48429
- else
48430
- break;
48431
- }
48432
- return (fromSegments.slice(0, position).join('/') +
48433
- '/' +
48434
- toSegments
48435
- // ensure we use at least the last element in the toSegments
48436
- .slice(toPosition - (toPosition === toSegments.length ? 1 : 0))
48437
- .join('/'));
48438
- }
48439
-
48440
- var NavigationType;
48441
- (function (NavigationType) {
48442
- NavigationType["pop"] = "pop";
48443
- NavigationType["push"] = "push";
48444
- })(NavigationType || (NavigationType = {}));
48445
- var NavigationDirection;
48446
- (function (NavigationDirection) {
48447
- NavigationDirection["back"] = "back";
48448
- NavigationDirection["forward"] = "forward";
48449
- NavigationDirection["unknown"] = "";
48450
- })(NavigationDirection || (NavigationDirection = {}));
48451
- /**
48452
- * Starting location for Histories
48453
- */
48454
- const START = '';
48455
- // Generic utils
48456
- /**
48457
- * Normalizes a base by removing any trailing slash and reading the base tag if
48458
- * present.
48459
- *
48460
- * @param base - base to normalize
48461
- */
48462
- function normalizeBase(base) {
48463
- if (!base) {
48464
- if (isBrowser) {
48465
- // respect <base> tag
48466
- const baseEl = document.querySelector('base');
48467
- base = (baseEl && baseEl.getAttribute('href')) || '/';
48468
- // strip full URL origin
48469
- base = base.replace(/^\w+:\/\/[^\/]+/, '');
48470
- }
48471
- else {
48472
- base = '/';
48473
- }
48474
- }
48475
- // ensure leading slash when it was removed by the regex above avoid leading
48476
- // slash with hash because the file could be read from the disk like file://
48477
- // and the leading slash would cause problems
48478
- if (base[0] !== '/' && base[0] !== '#')
48479
- base = '/' + base;
48480
- // remove the trailing slash so all other method can just do `base + fullPath`
48481
- // to build an href
48482
- return removeTrailingSlash(base);
48483
- }
48484
- // remove any character before the hash
48485
- const BEFORE_HASH_RE = /^[^#]+#/;
48486
- function createHref(base, location) {
48487
- return base.replace(BEFORE_HASH_RE, '#') + location;
48488
- }
48489
-
48490
- function getElementPosition(el, offset) {
48491
- const docRect = document.documentElement.getBoundingClientRect();
48492
- const elRect = el.getBoundingClientRect();
48493
- return {
48494
- behavior: offset.behavior,
48495
- left: elRect.left - docRect.left - (offset.left || 0),
48496
- top: elRect.top - docRect.top - (offset.top || 0),
48497
- };
48498
- }
48499
- const computeScrollPosition = () => ({
48500
- left: window.pageXOffset,
48501
- top: window.pageYOffset,
48502
- });
48503
- function scrollToPosition(position) {
48504
- let scrollToOptions;
48505
- if ('el' in position) {
48506
- const positionEl = position.el;
48507
- const isIdSelector = typeof positionEl === 'string' && positionEl.startsWith('#');
48508
- /**
48509
- * `id`s can accept pretty much any characters, including CSS combinators
48510
- * like `>` or `~`. It's still possible to retrieve elements using
48511
- * `document.getElementById('~')` but it needs to be escaped when using
48512
- * `document.querySelector('#\\~')` for it to be valid. The only
48513
- * requirements for `id`s are them to be unique on the page and to not be
48514
- * empty (`id=""`). Because of that, when passing an id selector, it should
48515
- * be properly escaped for it to work with `querySelector`. We could check
48516
- * for the id selector to be simple (no CSS combinators `+ >~`) but that
48517
- * would make things inconsistent since they are valid characters for an
48518
- * `id` but would need to be escaped when using `querySelector`, breaking
48519
- * their usage and ending up in no selector returned. Selectors need to be
48520
- * escaped:
48521
- *
48522
- * - `#1-thing` becomes `#\31 -thing`
48523
- * - `#with~symbols` becomes `#with\\~symbols`
48524
- *
48525
- * - More information about the topic can be found at
48526
- * https://mathiasbynens.be/notes/html5-id-class.
48527
- * - Practical example: https://mathiasbynens.be/demo/html5-id
48528
- */
48529
- if (false) {}
48530
- const el = typeof positionEl === 'string'
48531
- ? isIdSelector
48532
- ? document.getElementById(positionEl.slice(1))
48533
- : document.querySelector(positionEl)
48534
- : positionEl;
48535
- if (!el) {
48536
- ( false) &&
48537
- 0;
48538
- return;
48539
- }
48540
- scrollToOptions = getElementPosition(el, position);
48541
- }
48542
- else {
48543
- scrollToOptions = position;
48544
- }
48545
- if ('scrollBehavior' in document.documentElement.style)
48546
- window.scrollTo(scrollToOptions);
48547
- else {
48548
- window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset, scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset);
48549
- }
48550
- }
48551
- function getScrollKey(path, delta) {
48552
- const position = history.state ? history.state.position - delta : -1;
48553
- return position + path;
48554
- }
48555
- const scrollPositions = new Map();
48556
- function saveScrollPosition(key, scrollPosition) {
48557
- scrollPositions.set(key, scrollPosition);
48558
- }
48559
- function getSavedScrollPosition(key) {
48560
- const scroll = scrollPositions.get(key);
48561
- // consume it so it's not used again
48562
- scrollPositions.delete(key);
48563
- return scroll;
48564
- }
48565
- // TODO: RFC about how to save scroll position
48566
- /**
48567
- * ScrollBehavior instance used by the router to compute and restore the scroll
48568
- * position when navigating.
48569
- */
48570
- // export interface ScrollHandler<ScrollPositionEntry extends HistoryStateValue, ScrollPosition extends ScrollPositionEntry> {
48571
- // // returns a scroll position that can be saved in history
48572
- // compute(): ScrollPositionEntry
48573
- // // can take an extended ScrollPositionEntry
48574
- // scroll(position: ScrollPosition): void
48575
- // }
48576
- // export const scrollHandler: ScrollHandler<ScrollPosition> = {
48577
- // compute: computeScroll,
48578
- // scroll: scrollToPosition,
48579
- // }
48580
-
48581
- let createBaseLocation = () => location.protocol + '//' + location.host;
48582
- /**
48583
- * Creates a normalized history location from a window.location object
48584
- * @param location -
48585
- */
48586
- function createCurrentLocation(base, location) {
48587
- const { pathname, search, hash } = location;
48588
- // allows hash bases like #, /#, #/, #!, #!/, /#!/, or even /folder#end
48589
- const hashPos = base.indexOf('#');
48590
- if (hashPos > -1) {
48591
- let slicePos = hash.includes(base.slice(hashPos))
48592
- ? base.slice(hashPos).length
48593
- : 1;
48594
- let pathFromHash = hash.slice(slicePos);
48595
- // prepend the starting slash to hash so the url starts with /#
48596
- if (pathFromHash[0] !== '/')
48597
- pathFromHash = '/' + pathFromHash;
48598
- return stripBase(pathFromHash, '');
48599
- }
48600
- const path = stripBase(pathname, base);
48601
- return path + search + hash;
48602
- }
48603
- function useHistoryListeners(base, historyState, currentLocation, replace) {
48604
- let listeners = [];
48605
- let teardowns = [];
48606
- // TODO: should it be a stack? a Dict. Check if the popstate listener
48607
- // can trigger twice
48608
- let pauseState = null;
48609
- const popStateHandler = ({ state, }) => {
48610
- const to = createCurrentLocation(base, location);
48611
- const from = currentLocation.value;
48612
- const fromState = historyState.value;
48613
- let delta = 0;
48614
- if (state) {
48615
- currentLocation.value = to;
48616
- historyState.value = state;
48617
- // ignore the popstate and reset the pauseState
48618
- if (pauseState && pauseState === from) {
48619
- pauseState = null;
48620
- return;
48621
- }
48622
- delta = fromState ? state.position - fromState.position : 0;
48623
- }
48624
- else {
48625
- replace(to);
48626
- }
48627
- // console.log({ deltaFromCurrent })
48628
- // Here we could also revert the navigation by calling history.go(-delta)
48629
- // this listener will have to be adapted to not trigger again and to wait for the url
48630
- // to be updated before triggering the listeners. Some kind of validation function would also
48631
- // need to be passed to the listeners so the navigation can be accepted
48632
- // call all listeners
48633
- listeners.forEach(listener => {
48634
- listener(currentLocation.value, from, {
48635
- delta,
48636
- type: NavigationType.pop,
48637
- direction: delta
48638
- ? delta > 0
48639
- ? NavigationDirection.forward
48640
- : NavigationDirection.back
48641
- : NavigationDirection.unknown,
48642
- });
48643
- });
48644
- };
48645
- function pauseListeners() {
48646
- pauseState = currentLocation.value;
48647
- }
48648
- function listen(callback) {
48649
- // setup the listener and prepare teardown callbacks
48650
- listeners.push(callback);
48651
- const teardown = () => {
48652
- const index = listeners.indexOf(callback);
48653
- if (index > -1)
48654
- listeners.splice(index, 1);
48655
- };
48656
- teardowns.push(teardown);
48657
- return teardown;
48658
- }
48659
- function beforeUnloadListener() {
48660
- const { history } = window;
48661
- if (!history.state)
48662
- return;
48663
- history.replaceState(vue_router_assign({}, history.state, { scroll: computeScrollPosition() }), '');
48664
- }
48665
- function destroy() {
48666
- for (const teardown of teardowns)
48667
- teardown();
48668
- teardowns = [];
48669
- window.removeEventListener('popstate', popStateHandler);
48670
- window.removeEventListener('beforeunload', beforeUnloadListener);
48671
- }
48672
- // setup the listeners and prepare teardown callbacks
48673
- window.addEventListener('popstate', popStateHandler);
48674
- window.addEventListener('beforeunload', beforeUnloadListener);
48675
- return {
48676
- pauseListeners,
48677
- listen,
48678
- destroy,
48679
- };
48680
- }
48681
- /**
48682
- * Creates a state object
48683
- */
48684
- function buildState(back, current, forward, replaced = false, computeScroll = false) {
48685
- return {
48686
- back,
48687
- current,
48688
- forward,
48689
- replaced,
48690
- position: window.history.length,
48691
- scroll: computeScroll ? computeScrollPosition() : null,
48692
- };
48693
- }
48694
- function useHistoryStateNavigation(base) {
48695
- const { history, location } = window;
48696
- // private variables
48697
- const currentLocation = {
48698
- value: createCurrentLocation(base, location),
48699
- };
48700
- const historyState = { value: history.state };
48701
- // build current history entry as this is a fresh navigation
48702
- if (!historyState.value) {
48703
- changeLocation(currentLocation.value, {
48704
- back: null,
48705
- current: currentLocation.value,
48706
- forward: null,
48707
- // the length is off by one, we need to decrease it
48708
- position: history.length - 1,
48709
- replaced: true,
48710
- // don't add a scroll as the user may have an anchor and we want
48711
- // scrollBehavior to be triggered without a saved position
48712
- scroll: null,
48713
- }, true);
48714
- }
48715
- function changeLocation(to, state, replace) {
48716
- /**
48717
- * if a base tag is provided and we are on a normal domain, we have to
48718
- * respect the provided `base` attribute because pushState() will use it and
48719
- * potentially erase anything before the `#` like at
48720
- * https://github.com/vuejs/router/issues/685 where a base of
48721
- * `/folder/#` but a base of `/` would erase the `/folder/` section. If
48722
- * there is no host, the `<base>` tag makes no sense and if there isn't a
48723
- * base tag we can just use everything after the `#`.
48724
- */
48725
- const hashIndex = base.indexOf('#');
48726
- const url = hashIndex > -1
48727
- ? (location.host && document.querySelector('base')
48728
- ? base
48729
- : base.slice(hashIndex)) + to
48730
- : createBaseLocation() + base + to;
48731
- try {
48732
- // BROWSER QUIRK
48733
- // NOTE: Safari throws a SecurityError when calling this function 100 times in 30 seconds
48734
- history[replace ? 'replaceState' : 'pushState'](state, '', url);
48735
- historyState.value = state;
48736
- }
48737
- catch (err) {
48738
- if ((false)) {}
48739
- else {
48740
- console.error(err);
48741
- }
48742
- // Force the navigation, this also resets the call count
48743
- location[replace ? 'replace' : 'assign'](url);
48744
- }
48745
- }
48746
- function replace(to, data) {
48747
- const state = vue_router_assign({}, history.state, buildState(historyState.value.back,
48748
- // keep back and forward entries but override current position
48749
- to, historyState.value.forward, true), data, { position: historyState.value.position });
48750
- changeLocation(to, state, true);
48751
- currentLocation.value = to;
48752
- }
48753
- function push(to, data) {
48754
- // Add to current entry the information of where we are going
48755
- // as well as saving the current position
48756
- const currentState = vue_router_assign({},
48757
- // use current history state to gracefully handle a wrong call to
48758
- // history.replaceState
48759
- // https://github.com/vuejs/router/issues/366
48760
- historyState.value, history.state, {
48761
- forward: to,
48762
- scroll: computeScrollPosition(),
48763
- });
48764
- if (false) {}
48765
- changeLocation(currentState.current, currentState, true);
48766
- const state = vue_router_assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data);
48767
- changeLocation(to, state, false);
48768
- currentLocation.value = to;
48769
- }
48770
- return {
48771
- location: currentLocation,
48772
- state: historyState,
48773
- push,
48774
- replace,
48775
- };
48776
- }
48777
- /**
48778
- * Creates an HTML5 history. Most common history for single page applications.
48779
- *
48780
- * @param base -
48781
- */
48782
- function createWebHistory(base) {
48783
- base = normalizeBase(base);
48784
- const historyNavigation = useHistoryStateNavigation(base);
48785
- const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
48786
- function go(delta, triggerListeners = true) {
48787
- if (!triggerListeners)
48788
- historyListeners.pauseListeners();
48789
- history.go(delta);
48790
- }
48791
- const routerHistory = vue_router_assign({
48792
- // it's overridden right after
48793
- location: '',
48794
- base,
48795
- go,
48796
- createHref: createHref.bind(null, base),
48797
- }, historyNavigation, historyListeners);
48798
- Object.defineProperty(routerHistory, 'location', {
48799
- enumerable: true,
48800
- get: () => historyNavigation.location.value,
48801
- });
48802
- Object.defineProperty(routerHistory, 'state', {
48803
- enumerable: true,
48804
- get: () => historyNavigation.state.value,
48805
- });
48806
- return routerHistory;
48807
- }
48808
-
48809
- /**
48810
- * Creates a in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere.
48811
- * It's up to the user to replace that location with the starter location by either calling `router.push` or `router.replace`.
48812
- *
48813
- * @param base - Base applied to all urls, defaults to '/'
48814
- * @returns a history object that can be passed to the router constructor
48815
- */
48816
- function createMemoryHistory(base = '') {
48817
- let listeners = [];
48818
- let queue = [START];
48819
- let position = 0;
48820
- base = normalizeBase(base);
48821
- function setLocation(location) {
48822
- position++;
48823
- if (position === queue.length) {
48824
- // we are at the end, we can simply append a new entry
48825
- queue.push(location);
48826
- }
48827
- else {
48828
- // we are in the middle, we remove everything from here in the queue
48829
- queue.splice(position);
48830
- queue.push(location);
48831
- }
48832
- }
48833
- function triggerListeners(to, from, { direction, delta }) {
48834
- const info = {
48835
- direction,
48836
- delta,
48837
- type: NavigationType.pop,
48838
- };
48839
- for (const callback of listeners) {
48840
- callback(to, from, info);
48841
- }
48842
- }
48843
- const routerHistory = {
48844
- // rewritten by Object.defineProperty
48845
- location: START,
48846
- // TODO: should be kept in queue
48847
- state: {},
48848
- base,
48849
- createHref: createHref.bind(null, base),
48850
- replace(to) {
48851
- // remove current entry and decrement position
48852
- queue.splice(position--, 1);
48853
- setLocation(to);
48854
- },
48855
- push(to, data) {
48856
- setLocation(to);
48857
- },
48858
- listen(callback) {
48859
- listeners.push(callback);
48860
- return () => {
48861
- const index = listeners.indexOf(callback);
48862
- if (index > -1)
48863
- listeners.splice(index, 1);
48864
- };
48865
- },
48866
- destroy() {
48867
- listeners = [];
48868
- queue = [START];
48869
- position = 0;
48870
- },
48871
- go(delta, shouldTrigger = true) {
48872
- const from = this.location;
48873
- const direction =
48874
- // we are considering delta === 0 going forward, but in abstract mode
48875
- // using 0 for the delta doesn't make sense like it does in html5 where
48876
- // it reloads the page
48877
- delta < 0 ? NavigationDirection.back : NavigationDirection.forward;
48878
- position = Math.max(0, Math.min(position + delta, queue.length - 1));
48879
- if (shouldTrigger) {
48880
- triggerListeners(this.location, from, {
48881
- direction,
48882
- delta,
48883
- });
48884
- }
48885
- },
48886
- };
48887
- Object.defineProperty(routerHistory, 'location', {
48888
- enumerable: true,
48889
- get: () => queue[position],
48890
- });
48891
- return routerHistory;
48892
- }
48893
-
48894
- /**
48895
- * Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
48896
- * handle any URL is not possible.
48897
- *
48898
- * @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
48899
- * in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
48900
- * calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
48901
- * after the `#`).
48902
- *
48903
- * @example
48904
- * ```js
48905
- * // at https://example.com/folder
48906
- * createWebHashHistory() // gives a url of `https://example.com/folder#`
48907
- * createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
48908
- * // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
48909
- * createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
48910
- * // you should avoid doing this because it changes the original url and breaks copying urls
48911
- * createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
48912
- *
48913
- * // at file:///usr/etc/folder/index.html
48914
- * // for locations with no `host`, the base is ignored
48915
- * createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
48916
- * ```
48917
- */
48918
- function createWebHashHistory(base) {
48919
- // Make sure this implementation is fine in terms of encoding, specially for IE11
48920
- // for `file://`, directly use the pathname and ignore the base
48921
- // location.pathname contains an initial `/` even at the root: `https://example.com`
48922
- base = location.host ? base || location.pathname + location.search : '';
48923
- // allow the user to provide a `#` in the middle: `/base/#/app`
48924
- if (!base.includes('#'))
48925
- base += '#';
48926
- if (false) {}
48927
- return createWebHistory(base);
48928
- }
48929
-
48930
- function isRouteLocation(route) {
48931
- return typeof route === 'string' || (route && typeof route === 'object');
48932
- }
48933
- function isRouteName(name) {
48934
- return typeof name === 'string' || typeof name === 'symbol';
48935
- }
48936
-
48937
- /**
48938
- * Initial route location where the router is. Can be used in navigation guards
48939
- * to differentiate the initial navigation.
48940
- *
48941
- * @example
48942
- * ```js
48943
- * import { START_LOCATION } from 'vue-router'
48944
- *
48945
- * router.beforeEach((to, from) => {
48946
- * if (from === START_LOCATION) {
48947
- * // initial navigation
48948
- * }
48949
- * })
48950
- * ```
48951
- */
48952
- const START_LOCATION_NORMALIZED = {
48953
- path: '/',
48954
- name: undefined,
48955
- params: {},
48956
- query: {},
48957
- hash: '',
48958
- fullPath: '/',
48959
- matched: [],
48960
- meta: {},
48961
- redirectedFrom: undefined,
48962
- };
48963
-
48964
- const NavigationFailureSymbol = Symbol(( false) ? 0 : '');
48965
- /**
48966
- * Enumeration with all possible types for navigation failures. Can be passed to
48967
- * {@link isNavigationFailure} to check for specific failures.
48968
- */
48969
- var NavigationFailureType;
48970
- (function (NavigationFailureType) {
48971
- /**
48972
- * An aborted navigation is a navigation that failed because a navigation
48973
- * guard returned `false` or called `next(false)`
48974
- */
48975
- NavigationFailureType[NavigationFailureType["aborted"] = 4] = "aborted";
48976
- /**
48977
- * A cancelled navigation is a navigation that failed because a more recent
48978
- * navigation finished started (not necessarily finished).
48979
- */
48980
- NavigationFailureType[NavigationFailureType["cancelled"] = 8] = "cancelled";
48981
- /**
48982
- * A duplicated navigation is a navigation that failed because it was
48983
- * initiated while already being at the exact same location.
48984
- */
48985
- NavigationFailureType[NavigationFailureType["duplicated"] = 16] = "duplicated";
48986
- })(NavigationFailureType || (NavigationFailureType = {}));
48987
- // DEV only debug messages
48988
- const ErrorTypeMessages = {
48989
- [1 /* ErrorTypes.MATCHER_NOT_FOUND */]({ location, currentLocation }) {
48990
- return `No match for\n ${JSON.stringify(location)}${currentLocation
48991
- ? '\nwhile being at\n' + JSON.stringify(currentLocation)
48992
- : ''}`;
48993
- },
48994
- [2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */]({ from, to, }) {
48995
- return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
48996
- },
48997
- [4 /* ErrorTypes.NAVIGATION_ABORTED */]({ from, to }) {
48998
- return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
48999
- },
49000
- [8 /* ErrorTypes.NAVIGATION_CANCELLED */]({ from, to }) {
49001
- return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
49002
- },
49003
- [16 /* ErrorTypes.NAVIGATION_DUPLICATED */]({ from, to }) {
49004
- return `Avoided redundant navigation to current location: "${from.fullPath}".`;
49005
- },
49006
- };
49007
- function createRouterError(type, params) {
49008
- // keep full error messages in cjs versions
49009
- if (false) {}
49010
- else {
49011
- return vue_router_assign(new Error(), {
49012
- type,
49013
- [NavigationFailureSymbol]: true,
49014
- }, params);
49015
- }
49016
- }
49017
- function isNavigationFailure(error, type) {
49018
- return (error instanceof Error &&
49019
- NavigationFailureSymbol in error &&
49020
- (type == null || !!(error.type & type)));
49021
- }
49022
- const propertiesToLog = ['params', 'query', 'hash'];
49023
- function stringifyRoute(to) {
49024
- if (typeof to === 'string')
49025
- return to;
49026
- if ('path' in to)
49027
- return to.path;
49028
- const location = {};
49029
- for (const key of propertiesToLog) {
49030
- if (key in to)
49031
- location[key] = to[key];
49032
- }
49033
- return JSON.stringify(location, null, 2);
49034
- }
49035
-
49036
- // default pattern for a param: non greedy everything but /
49037
- const BASE_PARAM_PATTERN = '[^/]+?';
49038
- const BASE_PATH_PARSER_OPTIONS = {
49039
- sensitive: false,
49040
- strict: false,
49041
- start: true,
49042
- end: true,
49043
- };
49044
- // Special Regex characters that must be escaped in static tokens
49045
- const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
49046
- /**
49047
- * Creates a path parser from an array of Segments (a segment is an array of Tokens)
49048
- *
49049
- * @param segments - array of segments returned by tokenizePath
49050
- * @param extraOptions - optional options for the regexp
49051
- * @returns a PathParser
49052
- */
49053
- function tokensToParser(segments, extraOptions) {
49054
- const options = vue_router_assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
49055
- // the amount of scores is the same as the length of segments except for the root segment "/"
49056
- const score = [];
49057
- // the regexp as a string
49058
- let pattern = options.start ? '^' : '';
49059
- // extracted keys
49060
- const keys = [];
49061
- for (const segment of segments) {
49062
- // the root segment needs special treatment
49063
- const segmentScores = segment.length ? [] : [90 /* PathScore.Root */];
49064
- // allow trailing slash
49065
- if (options.strict && !segment.length)
49066
- pattern += '/';
49067
- for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
49068
- const token = segment[tokenIndex];
49069
- // resets the score if we are inside a sub segment /:a-other-:b
49070
- let subSegmentScore = 40 /* PathScore.Segment */ +
49071
- (options.sensitive ? 0.25 /* PathScore.BonusCaseSensitive */ : 0);
49072
- if (token.type === 0 /* TokenType.Static */) {
49073
- // prepend the slash if we are starting a new segment
49074
- if (!tokenIndex)
49075
- pattern += '/';
49076
- pattern += token.value.replace(REGEX_CHARS_RE, '\\$&');
49077
- subSegmentScore += 40 /* PathScore.Static */;
49078
- }
49079
- else if (token.type === 1 /* TokenType.Param */) {
49080
- const { value, repeatable, optional, regexp } = token;
49081
- keys.push({
49082
- name: value,
49083
- repeatable,
49084
- optional,
49085
- });
49086
- const re = regexp ? regexp : BASE_PARAM_PATTERN;
49087
- // the user provided a custom regexp /:id(\\d+)
49088
- if (re !== BASE_PARAM_PATTERN) {
49089
- subSegmentScore += 10 /* PathScore.BonusCustomRegExp */;
49090
- // make sure the regexp is valid before using it
49091
- try {
49092
- new RegExp(`(${re})`);
49093
- }
49094
- catch (err) {
49095
- throw new Error(`Invalid custom RegExp for param "${value}" (${re}): ` +
49096
- err.message);
49097
- }
49098
- }
49099
- // when we repeat we must take care of the repeating leading slash
49100
- let subPattern = repeatable ? `((?:${re})(?:/(?:${re}))*)` : `(${re})`;
49101
- // prepend the slash if we are starting a new segment
49102
- if (!tokenIndex)
49103
- subPattern =
49104
- // avoid an optional / if there are more segments e.g. /:p?-static
49105
- // or /:p?-:p2
49106
- optional && segment.length < 2
49107
- ? `(?:/${subPattern})`
49108
- : '/' + subPattern;
49109
- if (optional)
49110
- subPattern += '?';
49111
- pattern += subPattern;
49112
- subSegmentScore += 20 /* PathScore.Dynamic */;
49113
- if (optional)
49114
- subSegmentScore += -8 /* PathScore.BonusOptional */;
49115
- if (repeatable)
49116
- subSegmentScore += -20 /* PathScore.BonusRepeatable */;
49117
- if (re === '.*')
49118
- subSegmentScore += -50 /* PathScore.BonusWildcard */;
49119
- }
49120
- segmentScores.push(subSegmentScore);
49121
- }
49122
- // an empty array like /home/ -> [[{home}], []]
49123
- // if (!segment.length) pattern += '/'
49124
- score.push(segmentScores);
49125
- }
49126
- // only apply the strict bonus to the last score
49127
- if (options.strict && options.end) {
49128
- const i = score.length - 1;
49129
- score[i][score[i].length - 1] += 0.7000000000000001 /* PathScore.BonusStrict */;
49130
- }
49131
- // TODO: dev only warn double trailing slash
49132
- if (!options.strict)
49133
- pattern += '/?';
49134
- if (options.end)
49135
- pattern += '$';
49136
- // allow paths like /dynamic to only match dynamic or dynamic/... but not dynamic_something_else
49137
- else if (options.strict)
49138
- pattern += '(?:/|$)';
49139
- const re = new RegExp(pattern, options.sensitive ? '' : 'i');
49140
- function parse(path) {
49141
- const match = path.match(re);
49142
- const params = {};
49143
- if (!match)
49144
- return null;
49145
- for (let i = 1; i < match.length; i++) {
49146
- const value = match[i] || '';
49147
- const key = keys[i - 1];
49148
- params[key.name] = value && key.repeatable ? value.split('/') : value;
49149
- }
49150
- return params;
49151
- }
49152
- function stringify(params) {
49153
- let path = '';
49154
- // for optional parameters to allow to be empty
49155
- let avoidDuplicatedSlash = false;
49156
- for (const segment of segments) {
49157
- if (!avoidDuplicatedSlash || !path.endsWith('/'))
49158
- path += '/';
49159
- avoidDuplicatedSlash = false;
49160
- for (const token of segment) {
49161
- if (token.type === 0 /* TokenType.Static */) {
49162
- path += token.value;
49163
- }
49164
- else if (token.type === 1 /* TokenType.Param */) {
49165
- const { value, repeatable, optional } = token;
49166
- const param = value in params ? params[value] : '';
49167
- if (vue_router_isArray(param) && !repeatable) {
49168
- throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
49169
- }
49170
- const text = vue_router_isArray(param)
49171
- ? param.join('/')
49172
- : param;
49173
- if (!text) {
49174
- if (optional) {
49175
- // if we have more than one optional param like /:a?-static and there are more segments, we don't need to
49176
- // care about the optional param
49177
- if (segment.length < 2 && segments.length > 1) {
49178
- // remove the last slash as we could be at the end
49179
- if (path.endsWith('/'))
49180
- path = path.slice(0, -1);
49181
- // do not append a slash on the next iteration
49182
- else
49183
- avoidDuplicatedSlash = true;
49184
- }
49185
- }
49186
- else
49187
- throw new Error(`Missing required param "${value}"`);
49188
- }
49189
- path += text;
49190
- }
49191
- }
49192
- }
49193
- return path;
49194
- }
49195
- return {
49196
- re,
49197
- score,
49198
- keys,
49199
- parse,
49200
- stringify,
49201
- };
49202
- }
49203
- /**
49204
- * Compares an array of numbers as used in PathParser.score and returns a
49205
- * number. This function can be used to `sort` an array
49206
- *
49207
- * @param a - first array of numbers
49208
- * @param b - second array of numbers
49209
- * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
49210
- * should be sorted first
49211
- */
49212
- function compareScoreArray(a, b) {
49213
- let i = 0;
49214
- while (i < a.length && i < b.length) {
49215
- const diff = b[i] - a[i];
49216
- // only keep going if diff === 0
49217
- if (diff)
49218
- return diff;
49219
- i++;
49220
- }
49221
- // if the last subsegment was Static, the shorter segments should be sorted first
49222
- // otherwise sort the longest segment first
49223
- if (a.length < b.length) {
49224
- return a.length === 1 && a[0] === 40 /* PathScore.Static */ + 40 /* PathScore.Segment */
49225
- ? -1
49226
- : 1;
49227
- }
49228
- else if (a.length > b.length) {
49229
- return b.length === 1 && b[0] === 40 /* PathScore.Static */ + 40 /* PathScore.Segment */
49230
- ? 1
49231
- : -1;
49232
- }
49233
- return 0;
49234
- }
49235
- /**
49236
- * Compare function that can be used with `sort` to sort an array of PathParser
49237
- *
49238
- * @param a - first PathParser
49239
- * @param b - second PathParser
49240
- * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
49241
- */
49242
- function comparePathParserScore(a, b) {
49243
- let i = 0;
49244
- const aScore = a.score;
49245
- const bScore = b.score;
49246
- while (i < aScore.length && i < bScore.length) {
49247
- const comp = compareScoreArray(aScore[i], bScore[i]);
49248
- // do not return if both are equal
49249
- if (comp)
49250
- return comp;
49251
- i++;
49252
- }
49253
- if (Math.abs(bScore.length - aScore.length) === 1) {
49254
- if (isLastScoreNegative(aScore))
49255
- return 1;
49256
- if (isLastScoreNegative(bScore))
49257
- return -1;
49258
- }
49259
- // if a and b share the same score entries but b has more, sort b first
49260
- return bScore.length - aScore.length;
49261
- // this is the ternary version
49262
- // return aScore.length < bScore.length
49263
- // ? 1
49264
- // : aScore.length > bScore.length
49265
- // ? -1
49266
- // : 0
49267
- }
49268
- /**
49269
- * This allows detecting splats at the end of a path: /home/:id(.*)*
49270
- *
49271
- * @param score - score to check
49272
- * @returns true if the last entry is negative
49273
- */
49274
- function isLastScoreNegative(score) {
49275
- const last = score[score.length - 1];
49276
- return score.length > 0 && last[last.length - 1] < 0;
49277
- }
49278
-
49279
- const ROOT_TOKEN = {
49280
- type: 0 /* TokenType.Static */,
49281
- value: '',
49282
- };
49283
- const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
49284
- // After some profiling, the cache seems to be unnecessary because tokenizePath
49285
- // (the slowest part of adding a route) is very fast
49286
- // const tokenCache = new Map<string, Token[][]>()
49287
- function tokenizePath(path) {
49288
- if (!path)
49289
- return [[]];
49290
- if (path === '/')
49291
- return [[ROOT_TOKEN]];
49292
- if (!path.startsWith('/')) {
49293
- throw new Error(( false)
49294
- ? 0
49295
- : `Invalid path "${path}"`);
49296
- }
49297
- // if (tokenCache.has(path)) return tokenCache.get(path)!
49298
- function crash(message) {
49299
- throw new Error(`ERR (${state})/"${buffer}": ${message}`);
49300
- }
49301
- let state = 0 /* TokenizerState.Static */;
49302
- let previousState = state;
49303
- const tokens = [];
49304
- // the segment will always be valid because we get into the initial state
49305
- // with the leading /
49306
- let segment;
49307
- function finalizeSegment() {
49308
- if (segment)
49309
- tokens.push(segment);
49310
- segment = [];
49311
- }
49312
- // index on the path
49313
- let i = 0;
49314
- // char at index
49315
- let char;
49316
- // buffer of the value read
49317
- let buffer = '';
49318
- // custom regexp for a param
49319
- let customRe = '';
49320
- function consumeBuffer() {
49321
- if (!buffer)
49322
- return;
49323
- if (state === 0 /* TokenizerState.Static */) {
49324
- segment.push({
49325
- type: 0 /* TokenType.Static */,
49326
- value: buffer,
49327
- });
49328
- }
49329
- else if (state === 1 /* TokenizerState.Param */ ||
49330
- state === 2 /* TokenizerState.ParamRegExp */ ||
49331
- state === 3 /* TokenizerState.ParamRegExpEnd */) {
49332
- if (segment.length > 1 && (char === '*' || char === '+'))
49333
- crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
49334
- segment.push({
49335
- type: 1 /* TokenType.Param */,
49336
- value: buffer,
49337
- regexp: customRe,
49338
- repeatable: char === '*' || char === '+',
49339
- optional: char === '*' || char === '?',
49340
- });
49341
- }
49342
- else {
49343
- crash('Invalid state to consume buffer');
49344
- }
49345
- buffer = '';
49346
- }
49347
- function addCharToBuffer() {
49348
- buffer += char;
49349
- }
49350
- while (i < path.length) {
49351
- char = path[i++];
49352
- if (char === '\\' && state !== 2 /* TokenizerState.ParamRegExp */) {
49353
- previousState = state;
49354
- state = 4 /* TokenizerState.EscapeNext */;
49355
- continue;
49356
- }
49357
- switch (state) {
49358
- case 0 /* TokenizerState.Static */:
49359
- if (char === '/') {
49360
- if (buffer) {
49361
- consumeBuffer();
49362
- }
49363
- finalizeSegment();
49364
- }
49365
- else if (char === ':') {
49366
- consumeBuffer();
49367
- state = 1 /* TokenizerState.Param */;
49368
- }
49369
- else {
49370
- addCharToBuffer();
49371
- }
49372
- break;
49373
- case 4 /* TokenizerState.EscapeNext */:
49374
- addCharToBuffer();
49375
- state = previousState;
49376
- break;
49377
- case 1 /* TokenizerState.Param */:
49378
- if (char === '(') {
49379
- state = 2 /* TokenizerState.ParamRegExp */;
49380
- }
49381
- else if (VALID_PARAM_RE.test(char)) {
49382
- addCharToBuffer();
49383
- }
49384
- else {
49385
- consumeBuffer();
49386
- state = 0 /* TokenizerState.Static */;
49387
- // go back one character if we were not modifying
49388
- if (char !== '*' && char !== '?' && char !== '+')
49389
- i--;
49390
- }
49391
- break;
49392
- case 2 /* TokenizerState.ParamRegExp */:
49393
- // TODO: is it worth handling nested regexp? like :p(?:prefix_([^/]+)_suffix)
49394
- // it already works by escaping the closing )
49395
- // https://paths.esm.dev/?p=AAMeJbiAwQEcDKbAoAAkP60PG2R6QAvgNaA6AFACM2ABuQBB#
49396
- // is this really something people need since you can also write
49397
- // /prefix_:p()_suffix
49398
- if (char === ')') {
49399
- // handle the escaped )
49400
- if (customRe[customRe.length - 1] == '\\')
49401
- customRe = customRe.slice(0, -1) + char;
49402
- else
49403
- state = 3 /* TokenizerState.ParamRegExpEnd */;
49404
- }
49405
- else {
49406
- customRe += char;
49407
- }
49408
- break;
49409
- case 3 /* TokenizerState.ParamRegExpEnd */:
49410
- // same as finalizing a param
49411
- consumeBuffer();
49412
- state = 0 /* TokenizerState.Static */;
49413
- // go back one character if we were not modifying
49414
- if (char !== '*' && char !== '?' && char !== '+')
49415
- i--;
49416
- customRe = '';
49417
- break;
49418
- default:
49419
- crash('Unknown state');
49420
- break;
49421
- }
49422
- }
49423
- if (state === 2 /* TokenizerState.ParamRegExp */)
49424
- crash(`Unfinished custom RegExp for param "${buffer}"`);
49425
- consumeBuffer();
49426
- finalizeSegment();
49427
- // tokenCache.set(path, tokens)
49428
- return tokens;
49429
- }
49430
-
49431
- function createRouteRecordMatcher(record, parent, options) {
49432
- const parser = tokensToParser(tokenizePath(record.path), options);
49433
- // warn against params with the same name
49434
- if ((false)) {}
49435
- const matcher = vue_router_assign(parser, {
49436
- record,
49437
- parent,
49438
- // these needs to be populated by the parent
49439
- children: [],
49440
- alias: [],
49441
- });
49442
- if (parent) {
49443
- // both are aliases or both are not aliases
49444
- // we don't want to mix them because the order is used when
49445
- // passing originalRecord in Matcher.addRoute
49446
- if (!matcher.record.aliasOf === !parent.record.aliasOf)
49447
- parent.children.push(matcher);
49448
- }
49449
- return matcher;
49450
- }
49451
-
49452
- /**
49453
- * Creates a Router Matcher.
49454
- *
49455
- * @internal
49456
- * @param routes - array of initial routes
49457
- * @param globalOptions - global route options
49458
- */
49459
- function createRouterMatcher(routes, globalOptions) {
49460
- // normalized ordered array of matchers
49461
- const matchers = [];
49462
- const matcherMap = new Map();
49463
- globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
49464
- function getRecordMatcher(name) {
49465
- return matcherMap.get(name);
49466
- }
49467
- function addRoute(record, parent, originalRecord) {
49468
- // used later on to remove by name
49469
- const isRootAdd = !originalRecord;
49470
- const mainNormalizedRecord = normalizeRouteRecord(record);
49471
- if ((false)) {}
49472
- // we might be the child of an alias
49473
- mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
49474
- const options = mergeOptions(globalOptions, record);
49475
- // generate an array of records to correctly handle aliases
49476
- const normalizedRecords = [
49477
- mainNormalizedRecord,
49478
- ];
49479
- if ('alias' in record) {
49480
- const aliases = typeof record.alias === 'string' ? [record.alias] : record.alias;
49481
- for (const alias of aliases) {
49482
- normalizedRecords.push(vue_router_assign({}, mainNormalizedRecord, {
49483
- // this allows us to hold a copy of the `components` option
49484
- // so that async components cache is hold on the original record
49485
- components: originalRecord
49486
- ? originalRecord.record.components
49487
- : mainNormalizedRecord.components,
49488
- path: alias,
49489
- // we might be the child of an alias
49490
- aliasOf: originalRecord
49491
- ? originalRecord.record
49492
- : mainNormalizedRecord,
49493
- // the aliases are always of the same kind as the original since they
49494
- // are defined on the same record
49495
- }));
49496
- }
49497
- }
49498
- let matcher;
49499
- let originalMatcher;
49500
- for (const normalizedRecord of normalizedRecords) {
49501
- const { path } = normalizedRecord;
49502
- // Build up the path for nested routes if the child isn't an absolute
49503
- // route. Only add the / delimiter if the child path isn't empty and if the
49504
- // parent path doesn't have a trailing slash
49505
- if (parent && path[0] !== '/') {
49506
- const parentPath = parent.record.path;
49507
- const connectingSlash = parentPath[parentPath.length - 1] === '/' ? '' : '/';
49508
- normalizedRecord.path =
49509
- parent.record.path + (path && connectingSlash + path);
49510
- }
49511
- if (false) {}
49512
- // create the object before hand so it can be passed to children
49513
- matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
49514
- if (false)
49515
- {}
49516
- // if we are an alias we must tell the original record that we exist
49517
- // so we can be removed
49518
- if (originalRecord) {
49519
- originalRecord.alias.push(matcher);
49520
- if ((false)) {}
49521
- }
49522
- else {
49523
- // otherwise, the first record is the original and others are aliases
49524
- originalMatcher = originalMatcher || matcher;
49525
- if (originalMatcher !== matcher)
49526
- originalMatcher.alias.push(matcher);
49527
- // remove the route if named and only for the top record (avoid in nested calls)
49528
- // this works because the original record is the first one
49529
- if (isRootAdd && record.name && !isAliasRecord(matcher))
49530
- removeRoute(record.name);
49531
- }
49532
- if (mainNormalizedRecord.children) {
49533
- const children = mainNormalizedRecord.children;
49534
- for (let i = 0; i < children.length; i++) {
49535
- addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
49536
- }
49537
- }
49538
- // if there was no original record, then the first one was not an alias and all
49539
- // other alias (if any) need to reference this record when adding children
49540
- originalRecord = originalRecord || matcher;
49541
- // TODO: add normalized records for more flexibility
49542
- // if (parent && isAliasRecord(originalRecord)) {
49543
- // parent.children.push(originalRecord)
49544
- // }
49545
- insertMatcher(matcher);
49546
- }
49547
- return originalMatcher
49548
- ? () => {
49549
- // since other matchers are aliases, they should be removed by the original matcher
49550
- removeRoute(originalMatcher);
49551
- }
49552
- : noop;
49553
- }
49554
- function removeRoute(matcherRef) {
49555
- if (isRouteName(matcherRef)) {
49556
- const matcher = matcherMap.get(matcherRef);
49557
- if (matcher) {
49558
- matcherMap.delete(matcherRef);
49559
- matchers.splice(matchers.indexOf(matcher), 1);
49560
- matcher.children.forEach(removeRoute);
49561
- matcher.alias.forEach(removeRoute);
49562
- }
49563
- }
49564
- else {
49565
- const index = matchers.indexOf(matcherRef);
49566
- if (index > -1) {
49567
- matchers.splice(index, 1);
49568
- if (matcherRef.record.name)
49569
- matcherMap.delete(matcherRef.record.name);
49570
- matcherRef.children.forEach(removeRoute);
49571
- matcherRef.alias.forEach(removeRoute);
49572
- }
49573
- }
49574
- }
49575
- function getRoutes() {
49576
- return matchers;
49577
- }
49578
- function insertMatcher(matcher) {
49579
- let i = 0;
49580
- while (i < matchers.length &&
49581
- comparePathParserScore(matcher, matchers[i]) >= 0 &&
49582
- // Adding children with empty path should still appear before the parent
49583
- // https://github.com/vuejs/router/issues/1124
49584
- (matcher.record.path !== matchers[i].record.path ||
49585
- !isRecordChildOf(matcher, matchers[i])))
49586
- i++;
49587
- matchers.splice(i, 0, matcher);
49588
- // only add the original record to the name map
49589
- if (matcher.record.name && !isAliasRecord(matcher))
49590
- matcherMap.set(matcher.record.name, matcher);
49591
- }
49592
- function resolve(location, currentLocation) {
49593
- let matcher;
49594
- let params = {};
49595
- let path;
49596
- let name;
49597
- if ('name' in location && location.name) {
49598
- matcher = matcherMap.get(location.name);
49599
- if (!matcher)
49600
- throw createRouterError(1 /* ErrorTypes.MATCHER_NOT_FOUND */, {
49601
- location,
49602
- });
49603
- name = matcher.record.name;
49604
- params = vue_router_assign(
49605
- // paramsFromLocation is a new object
49606
- paramsFromLocation(currentLocation.params,
49607
- // only keep params that exist in the resolved location
49608
- // TODO: only keep optional params coming from a parent record
49609
- matcher.keys.filter(k => !k.optional).map(k => k.name)), location.params);
49610
- // throws if cannot be stringified
49611
- path = matcher.stringify(params);
49612
- }
49613
- else if ('path' in location) {
49614
- // no need to resolve the path with the matcher as it was provided
49615
- // this also allows the user to control the encoding
49616
- path = location.path;
49617
- if (false) {}
49618
- matcher = matchers.find(m => m.re.test(path));
49619
- // matcher should have a value after the loop
49620
- if (matcher) {
49621
- // TODO: dev warning of unused params if provided
49622
- // we know the matcher works because we tested the regexp
49623
- params = matcher.parse(path);
49624
- name = matcher.record.name;
49625
- }
49626
- // location is a relative path
49627
- }
49628
- else {
49629
- // match by name or path of current route
49630
- matcher = currentLocation.name
49631
- ? matcherMap.get(currentLocation.name)
49632
- : matchers.find(m => m.re.test(currentLocation.path));
49633
- if (!matcher)
49634
- throw createRouterError(1 /* ErrorTypes.MATCHER_NOT_FOUND */, {
49635
- location,
49636
- currentLocation,
49637
- });
49638
- name = matcher.record.name;
49639
- // since we are navigating to the same location, we don't need to pick the
49640
- // params like when `name` is provided
49641
- params = vue_router_assign({}, currentLocation.params, location.params);
49642
- path = matcher.stringify(params);
49643
- }
49644
- const matched = [];
49645
- let parentMatcher = matcher;
49646
- while (parentMatcher) {
49647
- // reversed order so parents are at the beginning
49648
- matched.unshift(parentMatcher.record);
49649
- parentMatcher = parentMatcher.parent;
49650
- }
49651
- return {
49652
- name,
49653
- path,
49654
- params,
49655
- matched,
49656
- meta: mergeMetaFields(matched),
49657
- };
49658
- }
49659
- // add initial routes
49660
- routes.forEach(route => addRoute(route));
49661
- return { addRoute, resolve, removeRoute, getRoutes, getRecordMatcher };
49662
- }
49663
- function paramsFromLocation(params, keys) {
49664
- const newParams = {};
49665
- for (const key of keys) {
49666
- if (key in params)
49667
- newParams[key] = params[key];
49668
- }
49669
- return newParams;
49670
- }
49671
- /**
49672
- * Normalizes a RouteRecordRaw. Creates a copy
49673
- *
49674
- * @param record
49675
- * @returns the normalized version
49676
- */
49677
- function normalizeRouteRecord(record) {
49678
- return {
49679
- path: record.path,
49680
- redirect: record.redirect,
49681
- name: record.name,
49682
- meta: record.meta || {},
49683
- aliasOf: undefined,
49684
- beforeEnter: record.beforeEnter,
49685
- props: normalizeRecordProps(record),
49686
- children: record.children || [],
49687
- instances: {},
49688
- leaveGuards: new Set(),
49689
- updateGuards: new Set(),
49690
- enterCallbacks: {},
49691
- components: 'components' in record
49692
- ? record.components || null
49693
- : record.component && { default: record.component },
49694
- };
49695
- }
49696
- /**
49697
- * Normalize the optional `props` in a record to always be an object similar to
49698
- * components. Also accept a boolean for components.
49699
- * @param record
49700
- */
49701
- function normalizeRecordProps(record) {
49702
- const propsObject = {};
49703
- // props does not exist on redirect records but we can set false directly
49704
- const props = record.props || false;
49705
- if ('component' in record) {
49706
- propsObject.default = props;
49707
- }
49708
- else {
49709
- // NOTE: we could also allow a function to be applied to every component.
49710
- // Would need user feedback for use cases
49711
- for (const name in record.components)
49712
- propsObject[name] = typeof props === 'boolean' ? props : props[name];
49713
- }
49714
- return propsObject;
49715
- }
49716
- /**
49717
- * Checks if a record or any of its parent is an alias
49718
- * @param record
49719
- */
49720
- function isAliasRecord(record) {
49721
- while (record) {
49722
- if (record.record.aliasOf)
49723
- return true;
49724
- record = record.parent;
49725
- }
49726
- return false;
49727
- }
49728
- /**
49729
- * Merge meta fields of an array of records
49730
- *
49731
- * @param matched - array of matched records
49732
- */
49733
- function mergeMetaFields(matched) {
49734
- return matched.reduce((meta, record) => vue_router_assign(meta, record.meta), {});
49735
- }
49736
- function mergeOptions(defaults, partialOptions) {
49737
- const options = {};
49738
- for (const key in defaults) {
49739
- options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
49740
- }
49741
- return options;
49742
- }
49743
- function isSameParam(a, b) {
49744
- return (a.name === b.name &&
49745
- a.optional === b.optional &&
49746
- a.repeatable === b.repeatable);
49747
- }
49748
- /**
49749
- * Check if a path and its alias have the same required params
49750
- *
49751
- * @param a - original record
49752
- * @param b - alias record
49753
- */
49754
- function checkSameParams(a, b) {
49755
- for (const key of a.keys) {
49756
- if (!key.optional && !b.keys.find(isSameParam.bind(null, key)))
49757
- return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"`);
49758
- }
49759
- for (const key of b.keys) {
49760
- if (!key.optional && !a.keys.find(isSameParam.bind(null, key)))
49761
- return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"`);
49762
- }
49763
- }
49764
- /**
49765
- * A route with a name and a child with an empty path without a name should warn when adding the route
49766
- *
49767
- * @param mainNormalizedRecord - RouteRecordNormalized
49768
- * @param parent - RouteRecordMatcher
49769
- */
49770
- function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
49771
- if (parent &&
49772
- parent.record.name &&
49773
- !mainNormalizedRecord.name &&
49774
- !mainNormalizedRecord.path) {
49775
- warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
49776
- }
49777
- }
49778
- function checkMissingParamsInAbsolutePath(record, parent) {
49779
- for (const key of parent.keys) {
49780
- if (!record.keys.find(isSameParam.bind(null, key)))
49781
- return warn(`Absolute path "${record.record.path}" should have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
49782
- }
49783
- }
49784
- function isRecordChildOf(record, parent) {
49785
- return parent.children.some(child => child === record || isRecordChildOf(record, child));
49786
- }
49787
-
49788
- /**
49789
- * Encoding Rules ␣ = Space Path: ␣ " < > # ? { } Query: ␣ " < > # & = Hash: ␣ "
49790
- * < > `
49791
- *
49792
- * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
49793
- * defines some extra characters to be encoded. Most browsers do not encode them
49794
- * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
49795
- * also encode `!'()*`. Leaving unencoded only ASCII alphanumeric(`a-zA-Z0-9`)
49796
- * plus `-._~`. This extra safety should be applied to query by patching the
49797
- * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
49798
- * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
49799
- * into a `/` if directly typed in. The _backtick_ (`````) should also be
49800
- * encoded everywhere because some browsers like FF encode it when directly
49801
- * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
49802
- */
49803
- // const EXTRA_RESERVED_RE = /[!'()*]/g
49804
- // const encodeReservedReplacer = (c: string) => '%' + c.charCodeAt(0).toString(16)
49805
- const HASH_RE = /#/g; // %23
49806
- const AMPERSAND_RE = /&/g; // %26
49807
- const SLASH_RE = /\//g; // %2F
49808
- const EQUAL_RE = /=/g; // %3D
49809
- const IM_RE = /\?/g; // %3F
49810
- const PLUS_RE = /\+/g; // %2B
49811
- /**
49812
- * NOTE: It's not clear to me if we should encode the + symbol in queries, it
49813
- * seems to be less flexible than not doing so and I can't find out the legacy
49814
- * systems requiring this for regular requests like text/html. In the standard,
49815
- * the encoding of the plus character is only mentioned for
49816
- * application/x-www-form-urlencoded
49817
- * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
49818
- * leave the plus character as is in queries. To be more flexible, we allow the
49819
- * plus character on the query but it can also be manually encoded by the user.
49820
- *
49821
- * Resources:
49822
- * - https://url.spec.whatwg.org/#urlencoded-parsing
49823
- * - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
49824
- */
49825
- const ENC_BRACKET_OPEN_RE = /%5B/g; // [
49826
- const ENC_BRACKET_CLOSE_RE = /%5D/g; // ]
49827
- const ENC_CARET_RE = /%5E/g; // ^
49828
- const ENC_BACKTICK_RE = /%60/g; // `
49829
- const ENC_CURLY_OPEN_RE = /%7B/g; // {
49830
- const ENC_PIPE_RE = /%7C/g; // |
49831
- const ENC_CURLY_CLOSE_RE = /%7D/g; // }
49832
- const ENC_SPACE_RE = /%20/g; // }
49833
- /**
49834
- * Encode characters that need to be encoded on the path, search and hash
49835
- * sections of the URL.
49836
- *
49837
- * @internal
49838
- * @param text - string to encode
49839
- * @returns encoded string
49840
- */
49841
- function commonEncode(text) {
49842
- return encodeURI('' + text)
49843
- .replace(ENC_PIPE_RE, '|')
49844
- .replace(ENC_BRACKET_OPEN_RE, '[')
49845
- .replace(ENC_BRACKET_CLOSE_RE, ']');
49846
- }
49847
- /**
49848
- * Encode characters that need to be encoded on the hash section of the URL.
49849
- *
49850
- * @param text - string to encode
49851
- * @returns encoded string
49852
- */
49853
- function encodeHash(text) {
49854
- return commonEncode(text)
49855
- .replace(ENC_CURLY_OPEN_RE, '{')
49856
- .replace(ENC_CURLY_CLOSE_RE, '}')
49857
- .replace(ENC_CARET_RE, '^');
49858
- }
49859
- /**
49860
- * Encode characters that need to be encoded query values on the query
49861
- * section of the URL.
49862
- *
49863
- * @param text - string to encode
49864
- * @returns encoded string
49865
- */
49866
- function encodeQueryValue(text) {
49867
- return (commonEncode(text)
49868
- // Encode the space as +, encode the + to differentiate it from the space
49869
- .replace(PLUS_RE, '%2B')
49870
- .replace(ENC_SPACE_RE, '+')
49871
- .replace(HASH_RE, '%23')
49872
- .replace(AMPERSAND_RE, '%26')
49873
- .replace(ENC_BACKTICK_RE, '`')
49874
- .replace(ENC_CURLY_OPEN_RE, '{')
49875
- .replace(ENC_CURLY_CLOSE_RE, '}')
49876
- .replace(ENC_CARET_RE, '^'));
49877
- }
49878
- /**
49879
- * Like `encodeQueryValue` but also encodes the `=` character.
49880
- *
49881
- * @param text - string to encode
49882
- */
49883
- function encodeQueryKey(text) {
49884
- return encodeQueryValue(text).replace(EQUAL_RE, '%3D');
49885
- }
49886
- /**
49887
- * Encode characters that need to be encoded on the path section of the URL.
49888
- *
49889
- * @param text - string to encode
49890
- * @returns encoded string
49891
- */
49892
- function encodePath(text) {
49893
- return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F');
49894
- }
49895
- /**
49896
- * Encode characters that need to be encoded on the path section of the URL as a
49897
- * param. This function encodes everything {@link encodePath} does plus the
49898
- * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
49899
- * string instead.
49900
- *
49901
- * @param text - string to encode
49902
- * @returns encoded string
49903
- */
49904
- function encodeParam(text) {
49905
- return text == null ? '' : encodePath(text).replace(SLASH_RE, '%2F');
49906
- }
49907
- /**
49908
- * Decode text using `decodeURIComponent`. Returns the original text if it
49909
- * fails.
49910
- *
49911
- * @param text - string to decode
49912
- * @returns decoded string
49913
- */
49914
- function decode(text) {
49915
- try {
49916
- return decodeURIComponent('' + text);
49917
- }
49918
- catch (err) {
49919
- ( false) && 0;
49920
- }
49921
- return '' + text;
49922
- }
49923
-
49924
- /**
49925
- * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
49926
- * version with the leading `?` and without Should work as URLSearchParams
49927
-
49928
- * @internal
49929
- *
49930
- * @param search - search string to parse
49931
- * @returns a query object
49932
- */
49933
- function parseQuery(search) {
49934
- const query = {};
49935
- // avoid creating an object with an empty key and empty value
49936
- // because of split('&')
49937
- if (search === '' || search === '?')
49938
- return query;
49939
- const hasLeadingIM = search[0] === '?';
49940
- const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&');
49941
- for (let i = 0; i < searchParams.length; ++i) {
49942
- // pre decode the + into space
49943
- const searchParam = searchParams[i].replace(PLUS_RE, ' ');
49944
- // allow the = character
49945
- const eqPos = searchParam.indexOf('=');
49946
- const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
49947
- const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
49948
- if (key in query) {
49949
- // an extra variable for ts types
49950
- let currentValue = query[key];
49951
- if (!vue_router_isArray(currentValue)) {
49952
- currentValue = query[key] = [currentValue];
49953
- }
49954
- currentValue.push(value);
49955
- }
49956
- else {
49957
- query[key] = value;
49958
- }
49959
- }
49960
- return query;
49961
- }
49962
- /**
49963
- * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
49964
- * doesn't prepend a `?`
49965
- *
49966
- * @internal
49967
- *
49968
- * @param query - query object to stringify
49969
- * @returns string version of the query without the leading `?`
49970
- */
49971
- function stringifyQuery(query) {
49972
- let search = '';
49973
- for (let key in query) {
49974
- const value = query[key];
49975
- key = encodeQueryKey(key);
49976
- if (value == null) {
49977
- // only null adds the value
49978
- if (value !== undefined) {
49979
- search += (search.length ? '&' : '') + key;
49980
- }
49981
- continue;
49982
- }
49983
- // keep null values
49984
- const values = vue_router_isArray(value)
49985
- ? value.map(v => v && encodeQueryValue(v))
49986
- : [value && encodeQueryValue(value)];
49987
- values.forEach(value => {
49988
- // skip undefined values in arrays as if they were not present
49989
- // smaller code than using filter
49990
- if (value !== undefined) {
49991
- // only append & with non-empty search
49992
- search += (search.length ? '&' : '') + key;
49993
- if (value != null)
49994
- search += '=' + value;
49995
- }
49996
- });
49997
- }
49998
- return search;
49999
- }
50000
- /**
50001
- * Transforms a {@link LocationQueryRaw} into a {@link LocationQuery} by casting
50002
- * numbers into strings, removing keys with an undefined value and replacing
50003
- * undefined with null in arrays
50004
- *
50005
- * @param query - query object to normalize
50006
- * @returns a normalized query object
50007
- */
50008
- function normalizeQuery(query) {
50009
- const normalizedQuery = {};
50010
- for (const key in query) {
50011
- const value = query[key];
50012
- if (value !== undefined) {
50013
- normalizedQuery[key] = vue_router_isArray(value)
50014
- ? value.map(v => (v == null ? null : '' + v))
50015
- : value == null
50016
- ? value
50017
- : '' + value;
50018
- }
50019
- }
50020
- return normalizedQuery;
50021
- }
50022
-
50023
- /**
50024
- * RouteRecord being rendered by the closest ancestor Router View. Used for
50025
- * `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
50026
- * Location Matched
50027
- *
50028
- * @internal
50029
- */
50030
- const matchedRouteKey = Symbol(( false) ? 0 : '');
50031
- /**
50032
- * Allows overriding the router view depth to control which component in
50033
- * `matched` is rendered. rvd stands for Router View Depth
50034
- *
50035
- * @internal
50036
- */
50037
- const viewDepthKey = Symbol(( false) ? 0 : '');
50038
- /**
50039
- * Allows overriding the router instance returned by `useRouter` in tests. r
50040
- * stands for router
50041
- *
50042
- * @internal
50043
- */
50044
- const routerKey = Symbol(( false) ? 0 : '');
50045
- /**
50046
- * Allows overriding the current route returned by `useRoute` in tests. rl
50047
- * stands for route location
50048
- *
50049
- * @internal
50050
- */
50051
- const routeLocationKey = Symbol(( false) ? 0 : '');
50052
- /**
50053
- * Allows overriding the current route used by router-view. Internally this is
50054
- * used when the `route` prop is passed.
50055
- *
50056
- * @internal
50057
- */
50058
- const routerViewLocationKey = Symbol(( false) ? 0 : '');
50059
-
50060
- /**
50061
- * Create a list of callbacks that can be reset. Used to create before and after navigation guards list
50062
- */
50063
- function useCallbacks() {
50064
- let handlers = [];
50065
- function add(handler) {
50066
- handlers.push(handler);
50067
- return () => {
50068
- const i = handlers.indexOf(handler);
50069
- if (i > -1)
50070
- handlers.splice(i, 1);
50071
- };
50072
- }
50073
- function reset() {
50074
- handlers = [];
50075
- }
50076
- return {
50077
- add,
50078
- list: () => handlers,
50079
- reset,
50080
- };
50081
- }
50082
-
50083
- function registerGuard(record, name, guard) {
50084
- const removeFromList = () => {
50085
- record[name].delete(guard);
50086
- };
50087
- onUnmounted(removeFromList);
50088
- onDeactivated(removeFromList);
50089
- onActivated(() => {
50090
- record[name].add(guard);
50091
- });
50092
- record[name].add(guard);
50093
- }
50094
- /**
50095
- * Add a navigation guard that triggers whenever the component for the current
50096
- * location is about to be left. Similar to {@link beforeRouteLeave} but can be
50097
- * used in any component. The guard is removed when the component is unmounted.
50098
- *
50099
- * @param leaveGuard - {@link NavigationGuard}
50100
- */
50101
- function onBeforeRouteLeave(leaveGuard) {
50102
- if (false) {}
50103
- const activeRecord = inject(matchedRouteKey,
50104
- // to avoid warning
50105
- {}).value;
50106
- if (!activeRecord) {
50107
- ( false) &&
50108
- 0;
50109
- return;
50110
- }
50111
- registerGuard(activeRecord, 'leaveGuards', leaveGuard);
50112
- }
50113
- /**
50114
- * Add a navigation guard that triggers whenever the current location is about
50115
- * to be updated. Similar to {@link beforeRouteUpdate} but can be used in any
50116
- * component. The guard is removed when the component is unmounted.
50117
- *
50118
- * @param updateGuard - {@link NavigationGuard}
50119
- */
50120
- function onBeforeRouteUpdate(updateGuard) {
50121
- if (false) {}
50122
- const activeRecord = inject(matchedRouteKey,
50123
- // to avoid warning
50124
- {}).value;
50125
- if (!activeRecord) {
50126
- ( false) &&
50127
- 0;
50128
- return;
50129
- }
50130
- registerGuard(activeRecord, 'updateGuards', updateGuard);
50131
- }
50132
- function guardToPromiseFn(guard, to, from, record, name) {
50133
- // keep a reference to the enterCallbackArray to prevent pushing callbacks if a new navigation took place
50134
- const enterCallbackArray = record &&
50135
- // name is defined if record is because of the function overload
50136
- (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
50137
- return () => new Promise((resolve, reject) => {
50138
- const next = (valid) => {
50139
- if (valid === false)
50140
- reject(createRouterError(4 /* ErrorTypes.NAVIGATION_ABORTED */, {
50141
- from,
50142
- to,
50143
- }));
50144
- else if (valid instanceof Error) {
50145
- reject(valid);
50146
- }
50147
- else if (isRouteLocation(valid)) {
50148
- reject(createRouterError(2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */, {
50149
- from: to,
50150
- to: valid,
50151
- }));
50152
- }
50153
- else {
50154
- if (enterCallbackArray &&
50155
- // since enterCallbackArray is truthy, both record and name also are
50156
- record.enterCallbacks[name] === enterCallbackArray &&
50157
- typeof valid === 'function')
50158
- enterCallbackArray.push(valid);
50159
- resolve();
50160
- }
50161
- };
50162
- // wrapping with Promise.resolve allows it to work with both async and sync guards
50163
- const guardReturn = guard.call(record && record.instances[name], to, from, ( false) ? 0 : next);
50164
- let guardCall = Promise.resolve(guardReturn);
50165
- if (guard.length < 3)
50166
- guardCall = guardCall.then(next);
50167
- if (false) {}
50168
- guardCall.catch(err => reject(err));
50169
- });
50170
- }
50171
- function canOnlyBeCalledOnce(next, to, from) {
50172
- let called = 0;
50173
- return function () {
50174
- if (called++ === 1)
50175
- warn(`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`);
50176
- // @ts-expect-error: we put it in the original one because it's easier to check
50177
- next._called = true;
50178
- if (called === 1)
50179
- next.apply(null, arguments);
50180
- };
50181
- }
50182
- function extractComponentsGuards(matched, guardType, to, from) {
50183
- const guards = [];
50184
- for (const record of matched) {
50185
- if (false) {}
50186
- for (const name in record.components) {
50187
- let rawComponent = record.components[name];
50188
- if ((false)) {}
50189
- // skip update and leave guards if the route component is not mounted
50190
- if (guardType !== 'beforeRouteEnter' && !record.instances[name])
50191
- continue;
50192
- if (isRouteComponent(rawComponent)) {
50193
- // __vccOpts is added by vue-class-component and contain the regular options
50194
- const options = rawComponent.__vccOpts || rawComponent;
50195
- const guard = options[guardType];
50196
- guard && guards.push(guardToPromiseFn(guard, to, from, record, name));
50197
- }
50198
- else {
50199
- // start requesting the chunk already
50200
- let componentPromise = rawComponent();
50201
- if (false) {}
50202
- guards.push(() => componentPromise.then(resolved => {
50203
- if (!resolved)
50204
- return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}"`));
50205
- const resolvedComponent = isESModule(resolved)
50206
- ? resolved.default
50207
- : resolved;
50208
- // replace the function with the resolved component
50209
- // cannot be null or undefined because we went into the for loop
50210
- record.components[name] = resolvedComponent;
50211
- // __vccOpts is added by vue-class-component and contain the regular options
50212
- const options = resolvedComponent.__vccOpts || resolvedComponent;
50213
- const guard = options[guardType];
50214
- return guard && guardToPromiseFn(guard, to, from, record, name)();
50215
- }));
50216
- }
50217
- }
50218
- }
50219
- return guards;
50220
- }
50221
- /**
50222
- * Allows differentiating lazy components from functional components and vue-class-component
50223
- * @internal
50224
- *
50225
- * @param component
50226
- */
50227
- function isRouteComponent(component) {
50228
- return (typeof component === 'object' ||
50229
- 'displayName' in component ||
50230
- 'props' in component ||
50231
- '__vccOpts' in component);
50232
- }
50233
- /**
50234
- * Ensures a route is loaded so it can be passed as o prop to `<RouterView>`.
50235
- *
50236
- * @param route - resolved route to load
50237
- */
50238
- function loadRouteLocation(route) {
50239
- return route.matched.every(record => record.redirect)
50240
- ? Promise.reject(new Error('Cannot load a route that redirects.'))
50241
- : Promise.all(route.matched.map(record => record.components &&
50242
- Promise.all(Object.keys(record.components).reduce((promises, name) => {
50243
- const rawComponent = record.components[name];
50244
- if (typeof rawComponent === 'function' &&
50245
- !('displayName' in rawComponent)) {
50246
- promises.push(rawComponent().then(resolved => {
50247
- if (!resolved)
50248
- return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
50249
- const resolvedComponent = isESModule(resolved)
50250
- ? resolved.default
50251
- : resolved;
50252
- // replace the function with the resolved component
50253
- // cannot be null or undefined because we went into the for loop
50254
- record.components[name] = resolvedComponent;
50255
- return;
50256
- }));
50257
- }
50258
- return promises;
50259
- }, [])))).then(() => route);
50260
- }
50261
-
50262
- // TODO: we could allow currentRoute as a prop to expose `isActive` and
50263
- // `isExactActive` behavior should go through an RFC
50264
- function useLink(props) {
50265
- const router = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(routerKey);
50266
- const currentRoute = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(routeLocationKey);
50267
- const route = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => router.resolve((0,external_commonjs_vue_commonjs2_vue_root_Vue_.unref)(props.to)));
50268
- const activeRecordIndex = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
50269
- const { matched } = route.value;
50270
- const { length } = matched;
50271
- const routeMatched = matched[length - 1];
50272
- const currentMatched = currentRoute.matched;
50273
- if (!routeMatched || !currentMatched.length)
50274
- return -1;
50275
- const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
50276
- if (index > -1)
50277
- return index;
50278
- // possible parent record
50279
- const parentRecordPath = getOriginalPath(matched[length - 2]);
50280
- return (
50281
- // we are dealing with nested routes
50282
- length > 1 &&
50283
- // if the parent and matched route have the same path, this link is
50284
- // referring to the empty child. Or we currently are on a different
50285
- // child of the same parent
50286
- getOriginalPath(routeMatched) === parentRecordPath &&
50287
- // avoid comparing the child with its parent
50288
- currentMatched[currentMatched.length - 1].path !== parentRecordPath
50289
- ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2]))
50290
- : index);
50291
- });
50292
- const isActive = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => activeRecordIndex.value > -1 &&
50293
- includesParams(currentRoute.params, route.value.params));
50294
- const isExactActive = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => activeRecordIndex.value > -1 &&
50295
- activeRecordIndex.value === currentRoute.matched.length - 1 &&
50296
- isSameRouteLocationParams(currentRoute.params, route.value.params));
50297
- function navigate(e = {}) {
50298
- if (guardEvent(e)) {
50299
- return router[(0,external_commonjs_vue_commonjs2_vue_root_Vue_.unref)(props.replace) ? 'replace' : 'push']((0,external_commonjs_vue_commonjs2_vue_root_Vue_.unref)(props.to)
50300
- // avoid uncaught errors are they are logged anyway
50301
- ).catch(noop);
50302
- }
50303
- return Promise.resolve();
50304
- }
50305
- // devtools only
50306
- if (false) {}
50307
- return {
50308
- route,
50309
- href: (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => route.value.href),
50310
- isActive,
50311
- isExactActive,
50312
- navigate,
50313
- };
50314
- }
50315
- const RouterLinkImpl = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.defineComponent)({
50316
- name: 'RouterLink',
50317
- compatConfig: { MODE: 3 },
50318
- props: {
50319
- to: {
50320
- type: [String, Object],
50321
- required: true,
50322
- },
50323
- replace: Boolean,
50324
- activeClass: String,
50325
- // inactiveClass: String,
50326
- exactActiveClass: String,
50327
- custom: Boolean,
50328
- ariaCurrentValue: {
50329
- type: String,
50330
- default: 'page',
50331
- },
50332
- },
50333
- useLink,
50334
- setup(props, { slots }) {
50335
- const link = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.reactive)(useLink(props));
50336
- const { options } = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(routerKey);
50337
- const elClass = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => ({
50338
- [getLinkClass(props.activeClass, options.linkActiveClass, 'router-link-active')]: link.isActive,
50339
- // [getLinkClass(
50340
- // props.inactiveClass,
50341
- // options.linkInactiveClass,
50342
- // 'router-link-inactive'
50343
- // )]: !link.isExactActive,
50344
- [getLinkClass(props.exactActiveClass, options.linkExactActiveClass, 'router-link-exact-active')]: link.isExactActive,
50345
- }));
50346
- return () => {
50347
- const children = slots.default && slots.default(link);
50348
- return props.custom
50349
- ? children
50350
- : (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('a', {
50351
- 'aria-current': link.isExactActive
50352
- ? props.ariaCurrentValue
50353
- : null,
50354
- href: link.href,
50355
- // this would override user added attrs but Vue will still add
50356
- // the listener so we end up triggering both
50357
- onClick: link.navigate,
50358
- class: elClass.value,
50359
- }, children);
50360
- };
50361
- },
50362
- });
50363
- // export the public type for h/tsx inference
50364
- // also to avoid inline import() in generated d.ts files
50365
- /**
50366
- * Component to render a link that triggers a navigation on click.
50367
- */
50368
- const RouterLink = (/* unused pure expression or super */ null && (RouterLinkImpl));
50369
- function guardEvent(e) {
50370
- // don't redirect with control keys
50371
- if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
50372
- return;
50373
- // don't redirect when preventDefault called
50374
- if (e.defaultPrevented)
50375
- return;
50376
- // don't redirect on right click
50377
- if (e.button !== undefined && e.button !== 0)
50378
- return;
50379
- // don't redirect if `target="_blank"`
50380
- // @ts-expect-error getAttribute does exist
50381
- if (e.currentTarget && e.currentTarget.getAttribute) {
50382
- // @ts-expect-error getAttribute exists
50383
- const target = e.currentTarget.getAttribute('target');
50384
- if (/\b_blank\b/i.test(target))
50385
- return;
50386
- }
50387
- // this may be a Weex event which doesn't have this method
50388
- if (e.preventDefault)
50389
- e.preventDefault();
50390
- return true;
50391
- }
50392
- function includesParams(outer, inner) {
50393
- for (const key in inner) {
50394
- const innerValue = inner[key];
50395
- const outerValue = outer[key];
50396
- if (typeof innerValue === 'string') {
50397
- if (innerValue !== outerValue)
50398
- return false;
50399
- }
50400
- else {
50401
- if (!vue_router_isArray(outerValue) ||
50402
- outerValue.length !== innerValue.length ||
50403
- innerValue.some((value, i) => value !== outerValue[i]))
50404
- return false;
50405
- }
50406
- }
50407
- return true;
50408
- }
50409
- /**
50410
- * Get the original path value of a record by following its aliasOf
50411
- * @param record
50412
- */
50413
- function getOriginalPath(record) {
50414
- return record ? (record.aliasOf ? record.aliasOf.path : record.path) : '';
50415
- }
50416
- /**
50417
- * Utility class to get the active class based on defaults.
50418
- * @param propClass
50419
- * @param globalClass
50420
- * @param defaultClass
50421
- */
50422
- const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null
50423
- ? propClass
50424
- : globalClass != null
50425
- ? globalClass
50426
- : defaultClass;
50427
-
50428
- const RouterViewImpl = /*#__PURE__*/ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.defineComponent)({
50429
- name: 'RouterView',
50430
- // #674 we manually inherit them
50431
- inheritAttrs: false,
50432
- props: {
50433
- name: {
50434
- type: String,
50435
- default: 'default',
50436
- },
50437
- route: Object,
50438
- },
50439
- // Better compat for @vue/compat users
50440
- // https://github.com/vuejs/router/issues/1315
50441
- compatConfig: { MODE: 3 },
50442
- setup(props, { attrs, slots }) {
50443
- ( false) && 0;
50444
- const injectedRoute = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(routerViewLocationKey);
50445
- const routeToDisplay = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => props.route || injectedRoute.value);
50446
- const injectedDepth = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(viewDepthKey, 0);
50447
- // The depth changes based on empty components option, which allows passthrough routes e.g. routes with children
50448
- // that are used to reuse the `path` property
50449
- const depth = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
50450
- let initialDepth = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.unref)(injectedDepth);
50451
- const { matched } = routeToDisplay.value;
50452
- let matchedRoute;
50453
- while ((matchedRoute = matched[initialDepth]) &&
50454
- !matchedRoute.components) {
50455
- initialDepth++;
50456
- }
50457
- return initialDepth;
50458
- });
50459
- const matchedRouteRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => routeToDisplay.value.matched[depth.value]);
50460
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.provide)(viewDepthKey, (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => depth.value + 1));
50461
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.provide)(matchedRouteKey, matchedRouteRef);
50462
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.provide)(routerViewLocationKey, routeToDisplay);
50463
- const viewRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)();
50464
- // watch at the same time the component instance, the route record we are
50465
- // rendering, and the name
50466
- (0,external_commonjs_vue_commonjs2_vue_root_Vue_.watch)(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => {
50467
- // copy reused instances
50468
- if (to) {
50469
- // this will update the instance for new instances as well as reused
50470
- // instances when navigating to a new route
50471
- to.instances[name] = instance;
50472
- // the component instance is reused for a different route or name so
50473
- // we copy any saved update or leave guards. With async setup, the
50474
- // mounting component will mount before the matchedRoute changes,
50475
- // making instance === oldInstance, so we check if guards have been
50476
- // added before. This works because we remove guards when
50477
- // unmounting/deactivating components
50478
- if (from && from !== to && instance && instance === oldInstance) {
50479
- if (!to.leaveGuards.size) {
50480
- to.leaveGuards = from.leaveGuards;
50481
- }
50482
- if (!to.updateGuards.size) {
50483
- to.updateGuards = from.updateGuards;
50484
- }
50485
- }
50486
- }
50487
- // trigger beforeRouteEnter next callbacks
50488
- if (instance &&
50489
- to &&
50490
- // if there is no instance but to and from are the same this might be
50491
- // the first visit
50492
- (!from || !isSameRouteRecord(to, from) || !oldInstance)) {
50493
- (to.enterCallbacks[name] || []).forEach(callback => callback(instance));
50494
- }
50495
- }, { flush: 'post' });
50496
- return () => {
50497
- const route = routeToDisplay.value;
50498
- const matchedRoute = matchedRouteRef.value;
50499
- const ViewComponent = matchedRoute && matchedRoute.components[props.name];
50500
- // we need the value at the time we render because when we unmount, we
50501
- // navigated to a different location so the value is different
50502
- const currentName = props.name;
50503
- if (!ViewComponent) {
50504
- return normalizeSlot(slots.default, { Component: ViewComponent, route });
50505
- }
50506
- // props from route configuration
50507
- const routePropsOption = matchedRoute.props[props.name];
50508
- const routeProps = routePropsOption
50509
- ? routePropsOption === true
50510
- ? route.params
50511
- : typeof routePropsOption === 'function'
50512
- ? routePropsOption(route)
50513
- : routePropsOption
50514
- : null;
50515
- const onVnodeUnmounted = vnode => {
50516
- // remove the instance reference to prevent leak
50517
- if (vnode.component.isUnmounted) {
50518
- matchedRoute.instances[currentName] = null;
50519
- }
50520
- };
50521
- const component = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)(ViewComponent, vue_router_assign({}, routeProps, attrs, {
50522
- onVnodeUnmounted,
50523
- ref: viewRef,
50524
- }));
50525
- if (false) {}
50526
- return (
50527
- // pass the vnode to the slot as a prop.
50528
- // h and <component :is="..."> both accept vnodes
50529
- normalizeSlot(slots.default, { Component: component, route }) ||
50530
- component);
50531
- };
50532
- },
50533
- });
50534
- function normalizeSlot(slot, data) {
50535
- if (!slot)
50536
- return null;
50537
- const slotContent = slot(data);
50538
- return slotContent.length === 1 ? slotContent[0] : slotContent;
50539
- }
50540
- // export the public type for h/tsx inference
50541
- // also to avoid inline import() in generated d.ts files
50542
- /**
50543
- * Component to display the current route the user is at.
50544
- */
50545
- const RouterView = (/* unused pure expression or super */ null && (RouterViewImpl));
50546
- // warn against deprecated usage with <transition> & <keep-alive>
50547
- // due to functional component being no longer eager in Vue 3
50548
- function warnDeprecatedUsage() {
50549
- const instance = getCurrentInstance();
50550
- const parentName = instance.parent && instance.parent.type.name;
50551
- if (parentName &&
50552
- (parentName === 'KeepAlive' || parentName.includes('Transition'))) {
50553
- const comp = parentName === 'KeepAlive' ? 'keep-alive' : 'transition';
50554
- warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.\n` +
50555
- `Use slot props instead:\n\n` +
50556
- `<router-view v-slot="{ Component }">\n` +
50557
- ` <${comp}>\n` +
50558
- ` <component :is="Component" />\n` +
50559
- ` </${comp}>\n` +
50560
- `</router-view>`);
50561
- }
50562
- }
50563
-
50564
- /**
50565
- * Copies a route location and removes any problematic properties that cannot be shown in devtools (e.g. Vue instances).
50566
- *
50567
- * @param routeLocation - routeLocation to format
50568
- * @param tooltip - optional tooltip
50569
- * @returns a copy of the routeLocation
50570
- */
50571
- function formatRouteLocation(routeLocation, tooltip) {
50572
- const copy = vue_router_assign({}, routeLocation, {
50573
- // remove variables that can contain vue instances
50574
- matched: routeLocation.matched.map(matched => omit(matched, ['instances', 'children', 'aliasOf'])),
50575
- });
50576
- return {
50577
- _custom: {
50578
- type: null,
50579
- readOnly: true,
50580
- display: routeLocation.fullPath,
50581
- tooltip,
50582
- value: copy,
50583
- },
50584
- };
50585
- }
50586
- function formatDisplay(display) {
50587
- return {
50588
- _custom: {
50589
- display,
50590
- },
50591
- };
50592
- }
50593
- // to support multiple router instances
50594
- let routerId = 0;
50595
- function addDevtools(app, router, matcher) {
50596
- // Take over router.beforeEach and afterEach
50597
- // make sure we are not registering the devtool twice
50598
- if (router.__hasDevtools)
50599
- return;
50600
- router.__hasDevtools = true;
50601
- // increment to support multiple router instances
50602
- const id = routerId++;
50603
- setupDevtoolsPlugin({
50604
- id: 'org.vuejs.router' + (id ? '.' + id : ''),
50605
- label: 'Vue Router',
50606
- packageName: 'vue-router',
50607
- homepage: 'https://router.vuejs.org',
50608
- logo: 'https://router.vuejs.org/logo.png',
50609
- componentStateTypes: ['Routing'],
50610
- app,
50611
- }, api => {
50612
- if (typeof api.now !== 'function') {
50613
- console.warn('[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.');
50614
- }
50615
- // display state added by the router
50616
- api.on.inspectComponent((payload, ctx) => {
50617
- if (payload.instanceData) {
50618
- payload.instanceData.state.push({
50619
- type: 'Routing',
50620
- key: '$route',
50621
- editable: false,
50622
- value: formatRouteLocation(router.currentRoute.value, 'Current Route'),
50623
- });
50624
- }
50625
- });
50626
- // mark router-link as active and display tags on router views
50627
- api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
50628
- if (componentInstance.__vrv_devtools) {
50629
- const info = componentInstance.__vrv_devtools;
50630
- node.tags.push({
50631
- label: (info.name ? `${info.name.toString()}: ` : '') + info.path,
50632
- textColor: 0,
50633
- tooltip: 'This component is rendered by &lt;router-view&gt;',
50634
- backgroundColor: PINK_500,
50635
- });
50636
- }
50637
- // if multiple useLink are used
50638
- if (vue_router_isArray(componentInstance.__vrl_devtools)) {
50639
- componentInstance.__devtoolsApi = api;
50640
- componentInstance.__vrl_devtools.forEach(devtoolsData => {
50641
- let backgroundColor = ORANGE_400;
50642
- let tooltip = '';
50643
- if (devtoolsData.isExactActive) {
50644
- backgroundColor = LIME_500;
50645
- tooltip = 'This is exactly active';
50646
- }
50647
- else if (devtoolsData.isActive) {
50648
- backgroundColor = BLUE_600;
50649
- tooltip = 'This link is active';
50650
- }
50651
- node.tags.push({
50652
- label: devtoolsData.route.path,
50653
- textColor: 0,
50654
- tooltip,
50655
- backgroundColor,
50656
- });
50657
- });
50658
- }
50659
- });
50660
- watch(router.currentRoute, () => {
50661
- // refresh active state
50662
- refreshRoutesView();
50663
- api.notifyComponentUpdate();
50664
- api.sendInspectorTree(routerInspectorId);
50665
- api.sendInspectorState(routerInspectorId);
50666
- });
50667
- const navigationsLayerId = 'router:navigations:' + id;
50668
- api.addTimelineLayer({
50669
- id: navigationsLayerId,
50670
- label: `Router${id ? ' ' + id : ''} Navigations`,
50671
- color: 0x40a8c4,
50672
- });
50673
- // const errorsLayerId = 'router:errors'
50674
- // api.addTimelineLayer({
50675
- // id: errorsLayerId,
50676
- // label: 'Router Errors',
50677
- // color: 0xea5455,
50678
- // })
50679
- router.onError((error, to) => {
50680
- api.addTimelineEvent({
50681
- layerId: navigationsLayerId,
50682
- event: {
50683
- title: 'Error during Navigation',
50684
- subtitle: to.fullPath,
50685
- logType: 'error',
50686
- time: api.now(),
50687
- data: { error },
50688
- groupId: to.meta.__navigationId,
50689
- },
50690
- });
50691
- });
50692
- // attached to `meta` and used to group events
50693
- let navigationId = 0;
50694
- router.beforeEach((to, from) => {
50695
- const data = {
50696
- guard: formatDisplay('beforeEach'),
50697
- from: formatRouteLocation(from, 'Current Location during this navigation'),
50698
- to: formatRouteLocation(to, 'Target location'),
50699
- };
50700
- // Used to group navigations together, hide from devtools
50701
- Object.defineProperty(to.meta, '__navigationId', {
50702
- value: navigationId++,
50703
- });
50704
- api.addTimelineEvent({
50705
- layerId: navigationsLayerId,
50706
- event: {
50707
- time: api.now(),
50708
- title: 'Start of navigation',
50709
- subtitle: to.fullPath,
50710
- data,
50711
- groupId: to.meta.__navigationId,
50712
- },
50713
- });
50714
- });
50715
- router.afterEach((to, from, failure) => {
50716
- const data = {
50717
- guard: formatDisplay('afterEach'),
50718
- };
50719
- if (failure) {
50720
- data.failure = {
50721
- _custom: {
50722
- type: Error,
50723
- readOnly: true,
50724
- display: failure ? failure.message : '',
50725
- tooltip: 'Navigation Failure',
50726
- value: failure,
50727
- },
50728
- };
50729
- data.status = formatDisplay('❌');
50730
- }
50731
- else {
50732
- data.status = formatDisplay('✅');
50733
- }
50734
- // we set here to have the right order
50735
- data.from = formatRouteLocation(from, 'Current Location during this navigation');
50736
- data.to = formatRouteLocation(to, 'Target location');
50737
- api.addTimelineEvent({
50738
- layerId: navigationsLayerId,
50739
- event: {
50740
- title: 'End of navigation',
50741
- subtitle: to.fullPath,
50742
- time: api.now(),
50743
- data,
50744
- logType: failure ? 'warning' : 'default',
50745
- groupId: to.meta.__navigationId,
50746
- },
50747
- });
50748
- });
50749
- /**
50750
- * Inspector of Existing routes
50751
- */
50752
- const routerInspectorId = 'router-inspector:' + id;
50753
- api.addInspector({
50754
- id: routerInspectorId,
50755
- label: 'Routes' + (id ? ' ' + id : ''),
50756
- icon: 'book',
50757
- treeFilterPlaceholder: 'Search routes',
50758
- });
50759
- function refreshRoutesView() {
50760
- // the routes view isn't active
50761
- if (!activeRoutesPayload)
50762
- return;
50763
- const payload = activeRoutesPayload;
50764
- // children routes will appear as nested
50765
- let routes = matcher.getRoutes().filter(route => !route.parent);
50766
- // reset match state to false
50767
- routes.forEach(resetMatchStateOnRouteRecord);
50768
- // apply a match state if there is a payload
50769
- if (payload.filter) {
50770
- routes = routes.filter(route =>
50771
- // save matches state based on the payload
50772
- isRouteMatching(route, payload.filter.toLowerCase()));
50773
- }
50774
- // mark active routes
50775
- routes.forEach(route => markRouteRecordActive(route, router.currentRoute.value));
50776
- payload.rootNodes = routes.map(formatRouteRecordForInspector);
50777
- }
50778
- let activeRoutesPayload;
50779
- api.on.getInspectorTree(payload => {
50780
- activeRoutesPayload = payload;
50781
- if (payload.app === app && payload.inspectorId === routerInspectorId) {
50782
- refreshRoutesView();
50783
- }
50784
- });
50785
- /**
50786
- * Display information about the currently selected route record
50787
- */
50788
- api.on.getInspectorState(payload => {
50789
- if (payload.app === app && payload.inspectorId === routerInspectorId) {
50790
- const routes = matcher.getRoutes();
50791
- const route = routes.find(route => route.record.__vd_id === payload.nodeId);
50792
- if (route) {
50793
- payload.state = {
50794
- options: formatRouteRecordMatcherForStateInspector(route),
50795
- };
50796
- }
50797
- }
50798
- });
50799
- api.sendInspectorTree(routerInspectorId);
50800
- api.sendInspectorState(routerInspectorId);
50801
- });
50802
- }
50803
- function modifierForKey(key) {
50804
- if (key.optional) {
50805
- return key.repeatable ? '*' : '?';
50806
- }
50807
- else {
50808
- return key.repeatable ? '+' : '';
50809
- }
50810
- }
50811
- function formatRouteRecordMatcherForStateInspector(route) {
50812
- const { record } = route;
50813
- const fields = [
50814
- { editable: false, key: 'path', value: record.path },
50815
- ];
50816
- if (record.name != null) {
50817
- fields.push({
50818
- editable: false,
50819
- key: 'name',
50820
- value: record.name,
50821
- });
50822
- }
50823
- fields.push({ editable: false, key: 'regexp', value: route.re });
50824
- if (route.keys.length) {
50825
- fields.push({
50826
- editable: false,
50827
- key: 'keys',
50828
- value: {
50829
- _custom: {
50830
- type: null,
50831
- readOnly: true,
50832
- display: route.keys
50833
- .map(key => `${key.name}${modifierForKey(key)}`)
50834
- .join(' '),
50835
- tooltip: 'Param keys',
50836
- value: route.keys,
50837
- },
50838
- },
50839
- });
50840
- }
50841
- if (record.redirect != null) {
50842
- fields.push({
50843
- editable: false,
50844
- key: 'redirect',
50845
- value: record.redirect,
50846
- });
50847
- }
50848
- if (route.alias.length) {
50849
- fields.push({
50850
- editable: false,
50851
- key: 'aliases',
50852
- value: route.alias.map(alias => alias.record.path),
50853
- });
50854
- }
50855
- if (Object.keys(route.record.meta).length) {
50856
- fields.push({
50857
- editable: false,
50858
- key: 'meta',
50859
- value: route.record.meta,
50860
- });
50861
- }
50862
- fields.push({
50863
- key: 'score',
50864
- editable: false,
50865
- value: {
50866
- _custom: {
50867
- type: null,
50868
- readOnly: true,
50869
- display: route.score.map(score => score.join(', ')).join(' | '),
50870
- tooltip: 'Score used to sort routes',
50871
- value: route.score,
50872
- },
50873
- },
50874
- });
50875
- return fields;
50876
- }
50877
- /**
50878
- * Extracted from tailwind palette
50879
- */
50880
- const PINK_500 = 0xec4899;
50881
- const BLUE_600 = 0x2563eb;
50882
- const LIME_500 = 0x84cc16;
50883
- const CYAN_400 = 0x22d3ee;
50884
- const ORANGE_400 = 0xfb923c;
50885
- // const GRAY_100 = 0xf4f4f5
50886
- const DARK = 0x666666;
50887
- function formatRouteRecordForInspector(route) {
50888
- const tags = [];
50889
- const { record } = route;
50890
- if (record.name != null) {
50891
- tags.push({
50892
- label: String(record.name),
50893
- textColor: 0,
50894
- backgroundColor: CYAN_400,
50895
- });
50896
- }
50897
- if (record.aliasOf) {
50898
- tags.push({
50899
- label: 'alias',
50900
- textColor: 0,
50901
- backgroundColor: ORANGE_400,
50902
- });
50903
- }
50904
- if (route.__vd_match) {
50905
- tags.push({
50906
- label: 'matches',
50907
- textColor: 0,
50908
- backgroundColor: PINK_500,
50909
- });
50910
- }
50911
- if (route.__vd_exactActive) {
50912
- tags.push({
50913
- label: 'exact',
50914
- textColor: 0,
50915
- backgroundColor: LIME_500,
50916
- });
50917
- }
50918
- if (route.__vd_active) {
50919
- tags.push({
50920
- label: 'active',
50921
- textColor: 0,
50922
- backgroundColor: BLUE_600,
50923
- });
50924
- }
50925
- if (record.redirect) {
50926
- tags.push({
50927
- label: typeof record.redirect === 'string'
50928
- ? `redirect: ${record.redirect}`
50929
- : 'redirects',
50930
- textColor: 0xffffff,
50931
- backgroundColor: DARK,
50932
- });
50933
- }
50934
- // add an id to be able to select it. Using the `path` is not possible because
50935
- // empty path children would collide with their parents
50936
- let id = record.__vd_id;
50937
- if (id == null) {
50938
- id = String(routeRecordId++);
50939
- record.__vd_id = id;
50940
- }
50941
- return {
50942
- id,
50943
- label: record.path,
50944
- tags,
50945
- children: route.children.map(formatRouteRecordForInspector),
50946
- };
50947
- }
50948
- // incremental id for route records and inspector state
50949
- let routeRecordId = 0;
50950
- const EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
50951
- function markRouteRecordActive(route, currentRoute) {
50952
- // no route will be active if matched is empty
50953
- // reset the matching state
50954
- const isExactActive = currentRoute.matched.length &&
50955
- isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
50956
- route.__vd_exactActive = route.__vd_active = isExactActive;
50957
- if (!isExactActive) {
50958
- route.__vd_active = currentRoute.matched.some(match => isSameRouteRecord(match, route.record));
50959
- }
50960
- route.children.forEach(childRoute => markRouteRecordActive(childRoute, currentRoute));
50961
- }
50962
- function resetMatchStateOnRouteRecord(route) {
50963
- route.__vd_match = false;
50964
- route.children.forEach(resetMatchStateOnRouteRecord);
50965
- }
50966
- function isRouteMatching(route, filter) {
50967
- const found = String(route.re).match(EXTRACT_REGEXP_RE);
50968
- route.__vd_match = false;
50969
- if (!found || found.length < 3) {
50970
- return false;
50971
- }
50972
- // use a regexp without $ at the end to match nested routes better
50973
- const nonEndingRE = new RegExp(found[1].replace(/\$$/, ''), found[2]);
50974
- if (nonEndingRE.test(filter)) {
50975
- // mark children as matches
50976
- route.children.forEach(child => isRouteMatching(child, filter));
50977
- // exception case: `/`
50978
- if (route.record.path !== '/' || filter === '/') {
50979
- route.__vd_match = route.re.test(filter);
50980
- return true;
50981
- }
50982
- // hide the / route
50983
- return false;
50984
- }
50985
- const path = route.record.path.toLowerCase();
50986
- const decodedPath = decode(path);
50987
- // also allow partial matching on the path
50988
- if (!filter.startsWith('/') &&
50989
- (decodedPath.includes(filter) || path.includes(filter)))
50990
- return true;
50991
- if (decodedPath.startsWith(filter) || path.startsWith(filter))
50992
- return true;
50993
- if (route.record.name && String(route.record.name).includes(filter))
50994
- return true;
50995
- return route.children.some(child => isRouteMatching(child, filter));
50996
- }
50997
- function omit(obj, keys) {
50998
- const ret = {};
50999
- for (const key in obj) {
51000
- if (!keys.includes(key)) {
51001
- // @ts-expect-error
51002
- ret[key] = obj[key];
51003
- }
51004
- }
51005
- return ret;
51006
- }
51007
-
51008
- /**
51009
- * Creates a Router instance that can be used by a Vue app.
51010
- *
51011
- * @param options - {@link RouterOptions}
51012
- */
51013
- function createRouter(options) {
51014
- const matcher = createRouterMatcher(options.routes, options);
51015
- const parseQuery$1 = options.parseQuery || parseQuery;
51016
- const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
51017
- const routerHistory = options.history;
51018
- if (false)
51019
- {}
51020
- const beforeGuards = useCallbacks();
51021
- const beforeResolveGuards = useCallbacks();
51022
- const afterGuards = useCallbacks();
51023
- const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
51024
- let pendingLocation = START_LOCATION_NORMALIZED;
51025
- // leave the scrollRestoration if no scrollBehavior is provided
51026
- if (isBrowser && options.scrollBehavior && 'scrollRestoration' in history) {
51027
- history.scrollRestoration = 'manual';
51028
- }
51029
- const normalizeParams = applyToParams.bind(null, paramValue => '' + paramValue);
51030
- const encodeParams = applyToParams.bind(null, encodeParam);
51031
- const decodeParams =
51032
- // @ts-expect-error: intentionally avoid the type check
51033
- applyToParams.bind(null, decode);
51034
- function addRoute(parentOrRoute, route) {
51035
- let parent;
51036
- let record;
51037
- if (isRouteName(parentOrRoute)) {
51038
- parent = matcher.getRecordMatcher(parentOrRoute);
51039
- record = route;
51040
- }
51041
- else {
51042
- record = parentOrRoute;
51043
- }
51044
- return matcher.addRoute(record, parent);
51045
- }
51046
- function removeRoute(name) {
51047
- const recordMatcher = matcher.getRecordMatcher(name);
51048
- if (recordMatcher) {
51049
- matcher.removeRoute(recordMatcher);
51050
- }
51051
- else if ((false)) {}
51052
- }
51053
- function getRoutes() {
51054
- return matcher.getRoutes().map(routeMatcher => routeMatcher.record);
51055
- }
51056
- function hasRoute(name) {
51057
- return !!matcher.getRecordMatcher(name);
51058
- }
51059
- function resolve(rawLocation, currentLocation) {
51060
- // const objectLocation = routerLocationAsObject(rawLocation)
51061
- // we create a copy to modify it later
51062
- currentLocation = vue_router_assign({}, currentLocation || currentRoute.value);
51063
- if (typeof rawLocation === 'string') {
51064
- const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
51065
- const matchedRoute = matcher.resolve({ path: locationNormalized.path }, currentLocation);
51066
- const href = routerHistory.createHref(locationNormalized.fullPath);
51067
- if ((false)) {}
51068
- // locationNormalized is always a new object
51069
- return vue_router_assign(locationNormalized, matchedRoute, {
51070
- params: decodeParams(matchedRoute.params),
51071
- hash: decode(locationNormalized.hash),
51072
- redirectedFrom: undefined,
51073
- href,
51074
- });
51075
- }
51076
- let matcherLocation;
51077
- // path could be relative in object as well
51078
- if ('path' in rawLocation) {
51079
- if (false) {}
51080
- matcherLocation = vue_router_assign({}, rawLocation, {
51081
- path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path,
51082
- });
51083
- }
51084
- else {
51085
- // remove any nullish param
51086
- const targetParams = vue_router_assign({}, rawLocation.params);
51087
- for (const key in targetParams) {
51088
- if (targetParams[key] == null) {
51089
- delete targetParams[key];
51090
- }
51091
- }
51092
- // pass encoded values to the matcher so it can produce encoded path and fullPath
51093
- matcherLocation = vue_router_assign({}, rawLocation, {
51094
- params: encodeParams(rawLocation.params),
51095
- });
51096
- // current location params are decoded, we need to encode them in case the
51097
- // matcher merges the params
51098
- currentLocation.params = encodeParams(currentLocation.params);
51099
- }
51100
- const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
51101
- const hash = rawLocation.hash || '';
51102
- if (false) {}
51103
- // decoding them) the matcher might have merged current location params so
51104
- // we need to run the decoding again
51105
- matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
51106
- const fullPath = stringifyURL(stringifyQuery$1, vue_router_assign({}, rawLocation, {
51107
- hash: encodeHash(hash),
51108
- path: matchedRoute.path,
51109
- }));
51110
- const href = routerHistory.createHref(fullPath);
51111
- if ((false)) {}
51112
- return vue_router_assign({
51113
- fullPath,
51114
- // keep the hash encoded so fullPath is effectively path + encodedQuery +
51115
- // hash
51116
- hash,
51117
- query:
51118
- // if the user is using a custom query lib like qs, we might have
51119
- // nested objects, so we keep the query as is, meaning it can contain
51120
- // numbers at `$route.query`, but at the point, the user will have to
51121
- // use their own type anyway.
51122
- // https://github.com/vuejs/router/issues/328#issuecomment-649481567
51123
- stringifyQuery$1 === stringifyQuery
51124
- ? normalizeQuery(rawLocation.query)
51125
- : (rawLocation.query || {}),
51126
- }, matchedRoute, {
51127
- redirectedFrom: undefined,
51128
- href,
51129
- });
51130
- }
51131
- function locationAsObject(to) {
51132
- return typeof to === 'string'
51133
- ? parseURL(parseQuery$1, to, currentRoute.value.path)
51134
- : vue_router_assign({}, to);
51135
- }
51136
- function checkCanceledNavigation(to, from) {
51137
- if (pendingLocation !== to) {
51138
- return createRouterError(8 /* ErrorTypes.NAVIGATION_CANCELLED */, {
51139
- from,
51140
- to,
51141
- });
51142
- }
51143
- }
51144
- function push(to) {
51145
- return pushWithRedirect(to);
51146
- }
51147
- function replace(to) {
51148
- return push(vue_router_assign(locationAsObject(to), { replace: true }));
51149
- }
51150
- function handleRedirectRecord(to) {
51151
- const lastMatched = to.matched[to.matched.length - 1];
51152
- if (lastMatched && lastMatched.redirect) {
51153
- const { redirect } = lastMatched;
51154
- let newTargetLocation = typeof redirect === 'function' ? redirect(to) : redirect;
51155
- if (typeof newTargetLocation === 'string') {
51156
- newTargetLocation =
51157
- newTargetLocation.includes('?') || newTargetLocation.includes('#')
51158
- ? (newTargetLocation = locationAsObject(newTargetLocation))
51159
- : // force empty params
51160
- { path: newTargetLocation };
51161
- // @ts-expect-error: force empty params when a string is passed to let
51162
- // the router parse them again
51163
- newTargetLocation.params = {};
51164
- }
51165
- if (false) {}
51166
- return vue_router_assign({
51167
- query: to.query,
51168
- hash: to.hash,
51169
- // avoid transferring params if the redirect has a path
51170
- params: 'path' in newTargetLocation ? {} : to.params,
51171
- }, newTargetLocation);
51172
- }
51173
- }
51174
- function pushWithRedirect(to, redirectedFrom) {
51175
- const targetLocation = (pendingLocation = resolve(to));
51176
- const from = currentRoute.value;
51177
- const data = to.state;
51178
- const force = to.force;
51179
- // to could be a string where `replace` is a function
51180
- const replace = to.replace === true;
51181
- const shouldRedirect = handleRedirectRecord(targetLocation);
51182
- if (shouldRedirect)
51183
- return pushWithRedirect(vue_router_assign(locationAsObject(shouldRedirect), {
51184
- state: data,
51185
- force,
51186
- replace,
51187
- }),
51188
- // keep original redirectedFrom if it exists
51189
- redirectedFrom || targetLocation);
51190
- // if it was a redirect we already called `pushWithRedirect` above
51191
- const toLocation = targetLocation;
51192
- toLocation.redirectedFrom = redirectedFrom;
51193
- let failure;
51194
- if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
51195
- failure = createRouterError(16 /* ErrorTypes.NAVIGATION_DUPLICATED */, { to: toLocation, from });
51196
- // trigger scroll to allow scrolling to the same anchor
51197
- handleScroll(from, from,
51198
- // this is a push, the only way for it to be triggered from a
51199
- // history.listen is with a redirect, which makes it become a push
51200
- true,
51201
- // This cannot be the first navigation because the initial location
51202
- // cannot be manually navigated to
51203
- false);
51204
- }
51205
- return (failure ? Promise.resolve(failure) : navigate(toLocation, from))
51206
- .catch((error) => isNavigationFailure(error)
51207
- ? // navigation redirects still mark the router as ready
51208
- isNavigationFailure(error, 2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */)
51209
- ? error
51210
- : markAsReady(error) // also returns the error
51211
- : // reject any unknown error
51212
- triggerError(error, toLocation, from))
51213
- .then((failure) => {
51214
- if (failure) {
51215
- if (isNavigationFailure(failure, 2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */)) {
51216
- if (false) {}
51217
- return pushWithRedirect(
51218
- // keep options
51219
- vue_router_assign(locationAsObject(failure.to), {
51220
- state: data,
51221
- force,
51222
- replace,
51223
- }),
51224
- // preserve the original redirectedFrom if any
51225
- redirectedFrom || toLocation);
51226
- }
51227
- }
51228
- else {
51229
- // if we fail we don't finalize the navigation
51230
- failure = finalizeNavigation(toLocation, from, true, replace, data);
51231
- }
51232
- triggerAfterEach(toLocation, from, failure);
51233
- return failure;
51234
- });
51235
- }
51236
- /**
51237
- * Helper to reject and skip all navigation guards if a new navigation happened
51238
- * @param to
51239
- * @param from
51240
- */
51241
- function checkCanceledNavigationAndReject(to, from) {
51242
- const error = checkCanceledNavigation(to, from);
51243
- return error ? Promise.reject(error) : Promise.resolve();
51244
- }
51245
- // TODO: refactor the whole before guards by internally using router.beforeEach
51246
- function navigate(to, from) {
51247
- let guards;
51248
- const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
51249
- // all components here have been resolved once because we are leaving
51250
- guards = extractComponentsGuards(leavingRecords.reverse(), 'beforeRouteLeave', to, from);
51251
- // leavingRecords is already reversed
51252
- for (const record of leavingRecords) {
51253
- record.leaveGuards.forEach(guard => {
51254
- guards.push(guardToPromiseFn(guard, to, from));
51255
- });
51256
- }
51257
- const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
51258
- guards.push(canceledNavigationCheck);
51259
- // run the queue of per route beforeRouteLeave guards
51260
- return (runGuardQueue(guards)
51261
- .then(() => {
51262
- // check global guards beforeEach
51263
- guards = [];
51264
- for (const guard of beforeGuards.list()) {
51265
- guards.push(guardToPromiseFn(guard, to, from));
51266
- }
51267
- guards.push(canceledNavigationCheck);
51268
- return runGuardQueue(guards);
51269
- })
51270
- .then(() => {
51271
- // check in components beforeRouteUpdate
51272
- guards = extractComponentsGuards(updatingRecords, 'beforeRouteUpdate', to, from);
51273
- for (const record of updatingRecords) {
51274
- record.updateGuards.forEach(guard => {
51275
- guards.push(guardToPromiseFn(guard, to, from));
51276
- });
51277
- }
51278
- guards.push(canceledNavigationCheck);
51279
- // run the queue of per route beforeEnter guards
51280
- return runGuardQueue(guards);
51281
- })
51282
- .then(() => {
51283
- // check the route beforeEnter
51284
- guards = [];
51285
- for (const record of to.matched) {
51286
- // do not trigger beforeEnter on reused views
51287
- if (record.beforeEnter && !from.matched.includes(record)) {
51288
- if (vue_router_isArray(record.beforeEnter)) {
51289
- for (const beforeEnter of record.beforeEnter)
51290
- guards.push(guardToPromiseFn(beforeEnter, to, from));
51291
- }
51292
- else {
51293
- guards.push(guardToPromiseFn(record.beforeEnter, to, from));
51294
- }
51295
- }
51296
- }
51297
- guards.push(canceledNavigationCheck);
51298
- // run the queue of per route beforeEnter guards
51299
- return runGuardQueue(guards);
51300
- })
51301
- .then(() => {
51302
- // NOTE: at this point to.matched is normalized and does not contain any () => Promise<Component>
51303
- // clear existing enterCallbacks, these are added by extractComponentsGuards
51304
- to.matched.forEach(record => (record.enterCallbacks = {}));
51305
- // check in-component beforeRouteEnter
51306
- guards = extractComponentsGuards(enteringRecords, 'beforeRouteEnter', to, from);
51307
- guards.push(canceledNavigationCheck);
51308
- // run the queue of per route beforeEnter guards
51309
- return runGuardQueue(guards);
51310
- })
51311
- .then(() => {
51312
- // check global guards beforeResolve
51313
- guards = [];
51314
- for (const guard of beforeResolveGuards.list()) {
51315
- guards.push(guardToPromiseFn(guard, to, from));
51316
- }
51317
- guards.push(canceledNavigationCheck);
51318
- return runGuardQueue(guards);
51319
- })
51320
- // catch any navigation canceled
51321
- .catch(err => isNavigationFailure(err, 8 /* ErrorTypes.NAVIGATION_CANCELLED */)
51322
- ? err
51323
- : Promise.reject(err)));
51324
- }
51325
- function triggerAfterEach(to, from, failure) {
51326
- // navigation is confirmed, call afterGuards
51327
- // TODO: wrap with error handlers
51328
- for (const guard of afterGuards.list())
51329
- guard(to, from, failure);
51330
- }
51331
- /**
51332
- * - Cleans up any navigation guards
51333
- * - Changes the url if necessary
51334
- * - Calls the scrollBehavior
51335
- */
51336
- function finalizeNavigation(toLocation, from, isPush, replace, data) {
51337
- // a more recent navigation took place
51338
- const error = checkCanceledNavigation(toLocation, from);
51339
- if (error)
51340
- return error;
51341
- // only consider as push if it's not the first navigation
51342
- const isFirstNavigation = from === START_LOCATION_NORMALIZED;
51343
- const state = !isBrowser ? {} : history.state;
51344
- // change URL only if the user did a push/replace and if it's not the initial navigation because
51345
- // it's just reflecting the url
51346
- if (isPush) {
51347
- // on the initial navigation, we want to reuse the scroll position from
51348
- // history state if it exists
51349
- if (replace || isFirstNavigation)
51350
- routerHistory.replace(toLocation.fullPath, vue_router_assign({
51351
- scroll: isFirstNavigation && state && state.scroll,
51352
- }, data));
51353
- else
51354
- routerHistory.push(toLocation.fullPath, data);
51355
- }
51356
- // accept current navigation
51357
- currentRoute.value = toLocation;
51358
- handleScroll(toLocation, from, isPush, isFirstNavigation);
51359
- markAsReady();
51360
- }
51361
- let removeHistoryListener;
51362
- // attach listener to history to trigger navigations
51363
- function setupListeners() {
51364
- // avoid setting up listeners twice due to an invalid first navigation
51365
- if (removeHistoryListener)
51366
- return;
51367
- removeHistoryListener = routerHistory.listen((to, _from, info) => {
51368
- if (!router.listening)
51369
- return;
51370
- // cannot be a redirect route because it was in history
51371
- const toLocation = resolve(to);
51372
- // due to dynamic routing, and to hash history with manual navigation
51373
- // (manually changing the url or calling history.hash = '#/somewhere'),
51374
- // there could be a redirect record in history
51375
- const shouldRedirect = handleRedirectRecord(toLocation);
51376
- if (shouldRedirect) {
51377
- pushWithRedirect(vue_router_assign(shouldRedirect, { replace: true }), toLocation).catch(noop);
51378
- return;
51379
- }
51380
- pendingLocation = toLocation;
51381
- const from = currentRoute.value;
51382
- // TODO: should be moved to web history?
51383
- if (isBrowser) {
51384
- saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
51385
- }
51386
- navigate(toLocation, from)
51387
- .catch((error) => {
51388
- if (isNavigationFailure(error, 4 /* ErrorTypes.NAVIGATION_ABORTED */ | 8 /* ErrorTypes.NAVIGATION_CANCELLED */)) {
51389
- return error;
51390
- }
51391
- if (isNavigationFailure(error, 2 /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */)) {
51392
- // Here we could call if (info.delta) routerHistory.go(-info.delta,
51393
- // false) but this is bug prone as we have no way to wait the
51394
- // navigation to be finished before calling pushWithRedirect. Using
51395
- // a setTimeout of 16ms seems to work but there is not guarantee for
51396
- // it to work on every browser. So Instead we do not restore the
51397
- // history entry and trigger a new navigation as requested by the
51398
- // navigation guard.
51399
- // the error is already handled by router.push we just want to avoid
51400
- // logging the error
51401
- pushWithRedirect(error.to, toLocation
51402
- // avoid an uncaught rejection, let push call triggerError
51403
- )
51404
- .then(failure => {
51405
- // manual change in hash history #916 ending up in the URL not
51406
- // changing but it was changed by the manual url change, so we
51407
- // need to manually change it ourselves
51408
- if (isNavigationFailure(failure, 4 /* ErrorTypes.NAVIGATION_ABORTED */ |
51409
- 16 /* ErrorTypes.NAVIGATION_DUPLICATED */) &&
51410
- !info.delta &&
51411
- info.type === NavigationType.pop) {
51412
- routerHistory.go(-1, false);
51413
- }
51414
- })
51415
- .catch(noop);
51416
- // avoid the then branch
51417
- return Promise.reject();
51418
- }
51419
- // do not restore history on unknown direction
51420
- if (info.delta)
51421
- routerHistory.go(-info.delta, false);
51422
- // unrecognized error, transfer to the global handler
51423
- return triggerError(error, toLocation, from);
51424
- })
51425
- .then((failure) => {
51426
- failure =
51427
- failure ||
51428
- finalizeNavigation(
51429
- // after navigation, all matched components are resolved
51430
- toLocation, from, false);
51431
- // revert the navigation
51432
- if (failure) {
51433
- if (info.delta) {
51434
- routerHistory.go(-info.delta, false);
51435
- }
51436
- else if (info.type === NavigationType.pop &&
51437
- isNavigationFailure(failure, 4 /* ErrorTypes.NAVIGATION_ABORTED */ | 16 /* ErrorTypes.NAVIGATION_DUPLICATED */)) {
51438
- // manual change in hash history #916
51439
- // it's like a push but lacks the information of the direction
51440
- routerHistory.go(-1, false);
51441
- }
51442
- }
51443
- triggerAfterEach(toLocation, from, failure);
51444
- })
51445
- .catch(noop);
51446
- });
51447
- }
51448
- // Initialization and Errors
51449
- let readyHandlers = useCallbacks();
51450
- let errorHandlers = useCallbacks();
51451
- let ready;
51452
- /**
51453
- * Trigger errorHandlers added via onError and throws the error as well
51454
- *
51455
- * @param error - error to throw
51456
- * @param to - location we were navigating to when the error happened
51457
- * @param from - location we were navigating from when the error happened
51458
- * @returns the error as a rejected promise
51459
- */
51460
- function triggerError(error, to, from) {
51461
- markAsReady(error);
51462
- const list = errorHandlers.list();
51463
- if (list.length) {
51464
- list.forEach(handler => handler(error, to, from));
51465
- }
51466
- else {
51467
- if ((false)) {}
51468
- console.error(error);
51469
- }
51470
- return Promise.reject(error);
51471
- }
51472
- function isReady() {
51473
- if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
51474
- return Promise.resolve();
51475
- return new Promise((resolve, reject) => {
51476
- readyHandlers.add([resolve, reject]);
51477
- });
51478
- }
51479
- function markAsReady(err) {
51480
- if (!ready) {
51481
- // still not ready if an error happened
51482
- ready = !err;
51483
- setupListeners();
51484
- readyHandlers
51485
- .list()
51486
- .forEach(([resolve, reject]) => (err ? reject(err) : resolve()));
51487
- readyHandlers.reset();
51488
- }
51489
- return err;
51490
- }
51491
- // Scroll behavior
51492
- function handleScroll(to, from, isPush, isFirstNavigation) {
51493
- const { scrollBehavior } = options;
51494
- if (!isBrowser || !scrollBehavior)
51495
- return Promise.resolve();
51496
- const scrollPosition = (!isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0))) ||
51497
- ((isFirstNavigation || !isPush) &&
51498
- history.state &&
51499
- history.state.scroll) ||
51500
- null;
51501
- return nextTick()
51502
- .then(() => scrollBehavior(to, from, scrollPosition))
51503
- .then(position => position && scrollToPosition(position))
51504
- .catch(err => triggerError(err, to, from));
51505
- }
51506
- const go = (delta) => routerHistory.go(delta);
51507
- let started;
51508
- const installedApps = new Set();
51509
- const router = {
51510
- currentRoute,
51511
- listening: true,
51512
- addRoute,
51513
- removeRoute,
51514
- hasRoute,
51515
- getRoutes,
51516
- resolve,
51517
- options,
51518
- push,
51519
- replace,
51520
- go,
51521
- back: () => go(-1),
51522
- forward: () => go(1),
51523
- beforeEach: beforeGuards.add,
51524
- beforeResolve: beforeResolveGuards.add,
51525
- afterEach: afterGuards.add,
51526
- onError: errorHandlers.add,
51527
- isReady,
51528
- install(app) {
51529
- const router = this;
51530
- app.component('RouterLink', RouterLink);
51531
- app.component('RouterView', RouterView);
51532
- app.config.globalProperties.$router = router;
51533
- Object.defineProperty(app.config.globalProperties, '$route', {
51534
- enumerable: true,
51535
- get: () => unref(currentRoute),
51536
- });
51537
- // this initial navigation is only necessary on client, on server it doesn't
51538
- // make sense because it will create an extra unnecessary navigation and could
51539
- // lead to problems
51540
- if (isBrowser &&
51541
- // used for the initial navigation client side to avoid pushing
51542
- // multiple times when the router is used in multiple apps
51543
- !started &&
51544
- currentRoute.value === START_LOCATION_NORMALIZED) {
51545
- // see above
51546
- started = true;
51547
- push(routerHistory.location).catch(err => {
51548
- if ((false))
51549
- {}
51550
- });
51551
- }
51552
- const reactiveRoute = {};
51553
- for (const key in START_LOCATION_NORMALIZED) {
51554
- // @ts-expect-error: the key matches
51555
- reactiveRoute[key] = computed(() => currentRoute.value[key]);
51556
- }
51557
- app.provide(routerKey, router);
51558
- app.provide(routeLocationKey, reactive(reactiveRoute));
51559
- app.provide(routerViewLocationKey, currentRoute);
51560
- const unmountApp = app.unmount;
51561
- installedApps.add(app);
51562
- app.unmount = function () {
51563
- installedApps.delete(app);
51564
- // the router is not attached to an app anymore
51565
- if (installedApps.size < 1) {
51566
- // invalidate the current navigation
51567
- pendingLocation = START_LOCATION_NORMALIZED;
51568
- removeHistoryListener && removeHistoryListener();
51569
- removeHistoryListener = null;
51570
- currentRoute.value = START_LOCATION_NORMALIZED;
51571
- started = false;
51572
- ready = false;
51573
- }
51574
- unmountApp();
51575
- };
51576
- if (false) {}
51577
- },
51578
- };
51579
- return router;
51580
- }
51581
- function runGuardQueue(guards) {
51582
- return guards.reduce((promise, guard) => promise.then(() => guard()), Promise.resolve());
51583
- }
51584
- function extractChangingRecords(to, from) {
51585
- const leavingRecords = [];
51586
- const updatingRecords = [];
51587
- const enteringRecords = [];
51588
- const len = Math.max(from.matched.length, to.matched.length);
51589
- for (let i = 0; i < len; i++) {
51590
- const recordFrom = from.matched[i];
51591
- if (recordFrom) {
51592
- if (to.matched.find(record => isSameRouteRecord(record, recordFrom)))
51593
- updatingRecords.push(recordFrom);
51594
- else
51595
- leavingRecords.push(recordFrom);
51596
- }
51597
- const recordTo = to.matched[i];
51598
- if (recordTo) {
51599
- // the type doesn't matter because we are comparing per reference
51600
- if (!from.matched.find(record => isSameRouteRecord(record, recordTo))) {
51601
- enteringRecords.push(recordTo);
51602
- }
51603
- }
51604
- }
51605
- return [leavingRecords, updatingRecords, enteringRecords];
51606
- }
51607
-
51608
- /**
51609
- * Returns the router instance. Equivalent to using `$router` inside
51610
- * templates.
51611
- */
51612
- function useRouter() {
51613
- return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(routerKey);
51614
- }
51615
- /**
51616
- * Returns the current route location. Equivalent to using `$route` inside
51617
- * templates.
51618
- */
51619
- function useRoute() {
51620
- return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)(routeLocationKey);
51621
- }
51622
-
51623
-
51624
-
51625
48238
  // EXTERNAL MODULE: ./src/utils/commons.js
51626
48239
  var commons = __webpack_require__(9657);
51627
48240
  // EXTERNAL MODULE: ./node_modules/dayjs/dayjs.min.js
@@ -51632,7 +48245,6 @@ var dayjs_min_default = /*#__PURE__*/__webpack_require__.n(dayjs_min);
51632
48245
 
51633
48246
 
51634
48247
 
51635
-
51636
48248
  // 默认分页数据
51637
48249
 
51638
48250
  const paginationDefault = {
@@ -51675,7 +48287,17 @@ const paginationDefault = {
51675
48287
  userMenusAuth: {
51676
48288
  type: Object,
51677
48289
  default: () => {}
51678
- } // 用户权限
48290
+ },
48291
+ // 用户权限
48292
+ route: {
48293
+ type: Object,
48294
+ default: () => {}
48295
+ },
48296
+ // 路由
48297
+ router: {
48298
+ type: Object,
48299
+ default: () => {}
48300
+ } // 路由
51679
48301
 
51680
48302
  },
51681
48303
  emits: ['selection-change', 'list-change', 'header-action', 'table-action', 'add-handle', 'edit-handle', 'add-success', 'edit-success', 'delete-success', 'table-current-change', 'tablelist-change', 'get-detail-success'],
@@ -51689,7 +48311,10 @@ const paginationDefault = {
51689
48311
  ajaxLoading: false,
51690
48312
  // 请求的loading
51691
48313
  submitLoading: false
51692
- }); // 配置信息 默认初始值
48314
+ });
48315
+ const {
48316
+ proxy
48317
+ } = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.getCurrentInstance)(); // 配置信息 默认初始值
51693
48318
 
51694
48319
  let appConfig = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.reactive)((0,lodash.merge)({
51695
48320
  headerActions: {
@@ -51756,11 +48381,6 @@ const paginationDefault = {
51756
48381
  model: {},
51757
48382
  boxName: 'editBox'
51758
48383
  });
51759
- const route = useRoute();
51760
- const router = useRouter();
51761
- const {
51762
- proxy
51763
- } = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.getCurrentInstance)();
51764
48384
  const selectionRow = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)([]); // 选择的row
51765
48385
 
51766
48386
  const tableSearchModel = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)({}); // 搜索数据
@@ -51770,7 +48390,7 @@ const paginationDefault = {
51770
48390
  const currentPagePath = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
51771
48391
  const {
51772
48392
  path: currentPath
51773
- } = route;
48393
+ } = props.route;
51774
48394
  return currentPath || '';
51775
48395
  }); // 用户权限
51776
48396
 
@@ -51819,7 +48439,7 @@ const paginationDefault = {
51819
48439
  const initSearch = () => {
51820
48440
  const {
51821
48441
  query
51822
- } = route;
48442
+ } = props.route;
51823
48443
 
51824
48444
  if (query.fromJump) {
51825
48445
  for (let [k, v] of Object.entries(query)) {
@@ -51829,7 +48449,7 @@ const paginationDefault = {
51829
48449
  }
51830
48450
 
51831
48451
  const result = { ...tableSearchModel.value,
51832
- ...route.query
48452
+ ...props.route.query
51833
48453
  };
51834
48454
  delete result.fromJump;
51835
48455
  tableSearchModel.value = result;
@@ -51996,7 +48616,8 @@ const paginationDefault = {
51996
48616
  emit(`add-handle`, selectionRow.value);
51997
48617
  } else if (rowAction && rowAction.type === 'editRoute') {
51998
48618
  console.log('跳转到新建页面');
51999
- rowAction.jumpUrl && router.push({
48619
+ rowAction.jumpUrl && // eslint-disable-next-line vue/no-mutating-props
48620
+ props?.router?.push({
52000
48621
  path: rowAction.jumpUrl,
52001
48622
  query: rowAction.jumpParams
52002
48623
  });
@@ -52060,7 +48681,8 @@ const paginationDefault = {
52060
48681
  emit(`edit-handle`, row);
52061
48682
  } else if (rowAction && rowAction.type === 'editRoute') {
52062
48683
  console.log('跳转到新建页面');
52063
- rowAction.jumpUrl && router.push({
48684
+ rowAction.jumpUrl && // eslint-disable-next-line vue/no-mutating-props
48685
+ props?.router?.push({
52064
48686
  path: rowAction.jumpUrl,
52065
48687
  query: row
52066
48688
  });
@@ -52094,8 +48716,9 @@ const paginationDefault = {
52094
48716
 
52095
48717
  default:
52096
48718
  if (rowAction && rowAction.type === 'editRoute') {
52097
- console.log('跳转到新建页面');
52098
- router.push({
48719
+ console.log('跳转到新建页面'); // eslint-disable-next-line vue/no-mutating-props
48720
+
48721
+ props.router.push({
52099
48722
  path: rowAction.jumpUrl,
52100
48723
  query: row
52101
48724
  });
@@ -52353,10 +48976,10 @@ const paginationDefault = {
52353
48976
  }));
52354
48977
  ;// CONCATENATED MODULE: ./src/packages/JwtTable/index.vue?vue&type=script&lang=js
52355
48978
 
52356
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtTable/index.vue?vue&type=style&index=0&id=755af22e&lang=scss&scoped=true
48979
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/packages/JwtTable/index.vue?vue&type=style&index=0&id=9e6b1136&lang=scss&scoped=true
52357
48980
  // extracted by mini-css-extract-plugin
52358
48981
 
52359
- ;// CONCATENATED MODULE: ./src/packages/JwtTable/index.vue?vue&type=style&index=0&id=755af22e&lang=scss&scoped=true
48982
+ ;// CONCATENATED MODULE: ./src/packages/JwtTable/index.vue?vue&type=style&index=0&id=9e6b1136&lang=scss&scoped=true
52360
48983
 
52361
48984
  // EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
52362
48985
  var exportHelper = __webpack_require__(3744);
@@ -52368,7 +48991,7 @@ var exportHelper = __webpack_require__(3744);
52368
48991
  ;
52369
48992
 
52370
48993
 
52371
- const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(JwtTablevue_type_script_lang_js, [['render',render],['__scopeId',"data-v-755af22e"]])
48994
+ const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(JwtTablevue_type_script_lang_js, [['render',render],['__scopeId',"data-v-9e6b1136"]])
52372
48995
 
52373
48996
  /* harmony default export */ var JwtTable = (__exports__);
52374
48997
 
@@ -53552,12 +50175,12 @@ var map = {
53552
50175
  "./JwtForm/index.vue": 6227,
53553
50176
  "./JwtHeaderButton/index.vue": 7539,
53554
50177
  "./JwtIcon/index.vue": 3514,
53555
- "./JwtIconSelect/index.vue": 7598,
50178
+ "./JwtIconSelect/index.vue": 6082,
53556
50179
  "./JwtImage/index.vue": 6409,
53557
50180
  "./JwtInput/index.vue": 376,
53558
50181
  "./JwtRateIcon/index.vue": 897,
53559
50182
  "./JwtSelectServer/index.vue": 9813,
53560
- "./JwtTable/index.vue": 5639,
50183
+ "./JwtTable/index.vue": 7801,
53561
50184
  "./JwtTableButton/index.vue": 3682,
53562
50185
  "./JwtTableOnly/index.vue": 5082,
53563
50186
  "./JwtTags/index.vue": 4308,