@ant-design/pro-components 2.3.45 → 2.3.47

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.
@@ -13397,6 +13397,90 @@ var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.2
13397
13397
 
13398
13398
  /***/ }),
13399
13399
 
13400
+ /***/ 2618:
13401
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
13402
+
13403
+ "use strict";
13404
+ /**
13405
+ * @license React
13406
+ * use-sync-external-store-shim.production.min.js
13407
+ *
13408
+ * Copyright (c) Facebook, Inc. and its affiliates.
13409
+ *
13410
+ * This source code is licensed under the MIT license found in the
13411
+ * LICENSE file in the root directory of this source tree.
13412
+ */
13413
+
13414
+
13415
+ var e = __webpack_require__(1024);
13416
+ function h(a, b) {
13417
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
13418
+ }
13419
+ var k = "function" === typeof Object.is ? Object.is : h,
13420
+ l = e.useState,
13421
+ m = e.useEffect,
13422
+ n = e.useLayoutEffect,
13423
+ p = e.useDebugValue;
13424
+ function q(a, b) {
13425
+ var d = b(),
13426
+ f = l({
13427
+ inst: {
13428
+ value: d,
13429
+ getSnapshot: b
13430
+ }
13431
+ }),
13432
+ c = f[0].inst,
13433
+ g = f[1];
13434
+ n(function () {
13435
+ c.value = d;
13436
+ c.getSnapshot = b;
13437
+ r(c) && g({
13438
+ inst: c
13439
+ });
13440
+ }, [a, d, b]);
13441
+ m(function () {
13442
+ r(c) && g({
13443
+ inst: c
13444
+ });
13445
+ return a(function () {
13446
+ r(c) && g({
13447
+ inst: c
13448
+ });
13449
+ });
13450
+ }, [a]);
13451
+ p(d);
13452
+ return d;
13453
+ }
13454
+ function r(a) {
13455
+ var b = a.getSnapshot;
13456
+ a = a.value;
13457
+ try {
13458
+ var d = b();
13459
+ return !k(a, d);
13460
+ } catch (f) {
13461
+ return !0;
13462
+ }
13463
+ }
13464
+ function t(a, b) {
13465
+ return b();
13466
+ }
13467
+ var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
13468
+ exports.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
13469
+
13470
+ /***/ }),
13471
+
13472
+ /***/ 3740:
13473
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
13474
+
13475
+ "use strict";
13476
+
13477
+
13478
+ if (true) {
13479
+ module.exports = __webpack_require__(2618);
13480
+ } else {}
13481
+
13482
+ /***/ }),
13483
+
13400
13484
  /***/ 1242:
13401
13485
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
13402
13486
 
@@ -15092,7 +15176,7 @@ function combine(array, callback) {
15092
15176
  * @param {function} callback
15093
15177
  * @return {string}
15094
15178
  */
15095
- function serialize(children, callback) {
15179
+ function Serializer_serialize(children, callback) {
15096
15180
  var output = '';
15097
15181
  var length = sizeof(children);
15098
15182
  for (var i = 0; i < length; i++) {
@@ -15116,11 +15200,11 @@ function stringify(element, index, children, callback) {
15116
15200
  case COMMENT:
15117
15201
  return '';
15118
15202
  case KEYFRAMES:
15119
- return element.return = element.value + '{' + serialize(element.children, callback) + '}';
15203
+ return element.return = element.value + '{' + Serializer_serialize(element.children, callback) + '}';
15120
15204
  case RULESET:
15121
15205
  element.value = element.props.join(',');
15122
15206
  }
15123
- return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : '';
15207
+ return strlen(children = Serializer_serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : '';
15124
15208
  }
15125
15209
  ;// CONCATENATED MODULE: ./node_modules/stylis/src/Tokenizer.js
15126
15210
 
@@ -15954,7 +16038,7 @@ var SKIP_CHECK = '_skip_check_';
15954
16038
  // ============================================================================
15955
16039
  // Preprocessor style content to browser support one
15956
16040
  function normalizeStyle(styleStr) {
15957
- var serialized = serialize(compile(styleStr), stringify);
16041
+ var serialized = Serializer_serialize(compile(styleStr), stringify);
15958
16042
  return serialized.replace(/\{%%%\:[^;];}/g, ';');
15959
16043
  }
15960
16044
  function isCompoundCSSProperty(value) {
@@ -17390,87 +17474,55 @@ var localeValues = {
17390
17474
  }
17391
17475
  };
17392
17476
  /* harmony default export */ var es_locale_zh_CN = (localeValues);
17393
- ;// CONCATENATED MODULE: ./node_modules/swr/dist/index.mjs
17394
-
17395
-
17396
- /*! *****************************************************************************
17397
- Copyright (c) Microsoft Corporation.
17398
-
17399
- Permission to use, copy, modify, and/or distribute this software for any
17400
- purpose with or without fee is hereby granted.
17401
-
17402
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17403
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17404
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17405
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17406
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17407
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17408
- PERFORMANCE OF THIS SOFTWARE.
17409
- ***************************************************************************** */
17410
-
17411
- function __awaiter(thisArg, _arguments, P, generator) {
17412
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17413
- return new (P || (P = Promise))(function (resolve, reject) {
17414
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17415
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17416
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17417
- step((generator = generator.apply(thisArg, _arguments || [])).next());
17418
- });
17419
- }
17420
-
17421
- function __generator(thisArg, body) {
17422
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17423
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
17424
- function verb(n) { return function (v) { return step([n, v]); }; }
17425
- function step(op) {
17426
- if (f) throw new TypeError("Generator is already executing.");
17427
- while (_) try {
17428
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
17429
- if (y = 0, t) op = [op[0] & 2, t.value];
17430
- switch (op[0]) {
17431
- case 0: case 1: t = op; break;
17432
- case 4: _.label++; return { value: op[1], done: false };
17433
- case 5: _.label++; y = op[1]; op = [0]; continue;
17434
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
17435
- default:
17436
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
17437
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
17438
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
17439
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
17440
- if (t[2]) _.ops.pop();
17441
- _.trys.pop(); continue;
17442
- }
17443
- op = body.call(thisArg, _);
17444
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
17445
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
17446
- }
17447
- }
17448
-
17449
- var noop = function () { };
17450
- // Using noop() as the undefined value as undefined can possibly be replaced
17451
- // by something else. Prettier ignore and extra parentheses are necessary here
17477
+ // EXTERNAL MODULE: ./node_modules/use-sync-external-store/shim/index.js
17478
+ var shim = __webpack_require__(3740);
17479
+ ;// CONCATENATED MODULE: ./node_modules/swr/_internal/dist/index.mjs
17480
+
17481
+
17482
+ // Global state used to deduplicate requests and store listeners
17483
+ const SWRGlobalState = new WeakMap();
17484
+
17485
+ const EMPTY_CACHE = {};
17486
+ const noop = ()=>{};
17487
+ // Using noop() as the undefined value as undefined can be replaced
17488
+ // by something else. Prettier ignore and extra parentheses are necessary here
17452
17489
  // to ensure that tsc doesn't remove the __NOINLINE__ comment.
17453
17490
  // prettier-ignore
17454
- var UNDEFINED = ( /*#__NOINLINE__*/noop());
17455
- var OBJECT = Object;
17456
- var isUndefined = function (v) { return v === UNDEFINED; };
17457
- var isFunction = function (v) { return typeof v == 'function'; };
17458
- var mergeObjects = function (a, b) { return OBJECT.assign({}, a, b); };
17459
- var STR_UNDEFINED = 'undefined';
17460
- // NOTE: Use function to guarantee it's re-evaluated between jsdom and node runtime for tests.
17461
- var hasWindow = function () { return typeof window != STR_UNDEFINED; };
17462
- var hasDocument = function () { return typeof document != STR_UNDEFINED; };
17463
- var hasRequestAnimationFrame = function () {
17464
- return hasWindow() && typeof window['requestAnimationFrame'] != STR_UNDEFINED;
17491
+ const UNDEFINED = /*#__NOINLINE__*/ noop();
17492
+ const OBJECT = Object;
17493
+ const isUndefined = (v)=>v === UNDEFINED;
17494
+ const isFunction = (v)=>typeof v == 'function';
17495
+ const mergeObjects = (a, b)=>({
17496
+ ...a,
17497
+ ...b
17498
+ });
17499
+ const STR_UNDEFINED = 'undefined';
17500
+ // NOTE: Use the function to guarantee it's re-evaluated between jsdom and node runtime for tests.
17501
+ const isWindowDefined = typeof window != STR_UNDEFINED;
17502
+ const isDocumentDefined = typeof document != STR_UNDEFINED;
17503
+ const hasRequestAnimationFrame = ()=>isWindowDefined && typeof window['requestAnimationFrame'] != STR_UNDEFINED;
17504
+ const createCacheHelper = (cache, key)=>{
17505
+ const state = SWRGlobalState.get(cache);
17506
+ return [
17507
+ // Getter
17508
+ ()=>cache.get(key) || EMPTY_CACHE,
17509
+ // Setter
17510
+ (info)=>{
17511
+ const prev = cache.get(key);
17512
+ state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE);
17513
+ },
17514
+ // Subscriber
17515
+ state[6]
17516
+ ];
17465
17517
  };
17466
17518
 
17467
17519
  // use WeakMap to store the object->key mapping
17468
17520
  // so the objects can be garbage collected.
17469
17521
  // WeakMap uses a hashtable under the hood, so the lookup
17470
17522
  // complexity is almost O(1).
17471
- var table = new WeakMap();
17523
+ const table = new WeakMap();
17472
17524
  // counter of the key
17473
- var counter = 0;
17525
+ let counter = 0;
17474
17526
  // A stable hash implementation that supports:
17475
17527
  // - Fast and ensures unique hash properties
17476
17528
  // - Handles unserializable values
@@ -17478,19 +17530,18 @@ var counter = 0;
17478
17530
  // - Generates short results
17479
17531
  //
17480
17532
  // This is not a serialization function, and the result is not guaranteed to be
17481
- // parsible.
17482
- var stableHash = function (arg) {
17483
- var type = typeof arg;
17484
- var constructor = arg && arg.constructor;
17485
- var isDate = constructor == Date;
17486
- var result;
17487
- var index;
17533
+ // parsable.
17534
+ const stableHash = (arg)=>{
17535
+ const type = typeof arg;
17536
+ const constructor = arg && arg.constructor;
17537
+ const isDate = constructor == Date;
17538
+ let result;
17539
+ let index;
17488
17540
  if (OBJECT(arg) === arg && !isDate && constructor != RegExp) {
17489
17541
  // Object/function, not null/date/regexp. Use WeakMap to store the id first.
17490
17542
  // If it's already hashed, directly return the result.
17491
17543
  result = table.get(arg);
17492
- if (result)
17493
- return result;
17544
+ if (result) return result;
17494
17545
  // Store the hash first for circular reference detection before entering the
17495
17546
  // recursive `stableHash` calls.
17496
17547
  // For other objects like set and map, we use this id directly as the hash.
@@ -17499,7 +17550,7 @@ var stableHash = function (arg) {
17499
17550
  if (constructor == Array) {
17500
17551
  // Array.
17501
17552
  result = '@';
17502
- for (index = 0; index < arg.length; index++) {
17553
+ for(index = 0; index < arg.length; index++){
17503
17554
  result += stableHash(arg[index]) + ',';
17504
17555
  }
17505
17556
  table.set(arg, result);
@@ -17507,342 +17558,384 @@ var stableHash = function (arg) {
17507
17558
  if (constructor == OBJECT) {
17508
17559
  // Object, sort keys.
17509
17560
  result = '#';
17510
- var keys = OBJECT.keys(arg).sort();
17511
- while (!isUndefined((index = keys.pop()))) {
17561
+ const keys = OBJECT.keys(arg).sort();
17562
+ while(!isUndefined(index = keys.pop())){
17512
17563
  if (!isUndefined(arg[index])) {
17513
17564
  result += index + ':' + stableHash(arg[index]) + ',';
17514
17565
  }
17515
17566
  }
17516
17567
  table.set(arg, result);
17517
17568
  }
17518
- }
17519
- else {
17520
- result = isDate
17521
- ? arg.toJSON()
17522
- : type == 'symbol'
17523
- ? arg.toString()
17524
- : type == 'string'
17525
- ? JSON.stringify(arg)
17526
- : '' + arg;
17569
+ } else {
17570
+ result = isDate ? arg.toJSON() : type == 'symbol' ? arg.toString() : type == 'string' ? JSON.stringify(arg) : '' + arg;
17527
17571
  }
17528
17572
  return result;
17529
17573
  };
17530
17574
 
17531
17575
  /**
17532
- * Due to bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,
17576
+ * Due to the bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,
17533
17577
  * it's not reliable to detect if the browser is currently online or offline
17534
17578
  * based on `navigator.onLine`.
17535
- * As a work around, we always assume it's online on first load, and change
17579
+ * As a workaround, we always assume it's online on the first load, and change
17536
17580
  * the status upon `online` or `offline` events.
17537
- */
17538
- var online = true;
17539
- var isOnline = function () { return online; };
17540
- var hasWin = hasWindow();
17541
- var hasDoc = hasDocument();
17581
+ */ let online = true;
17582
+ const isOnline = ()=>online;
17542
17583
  // For node and React Native, `add/removeEventListener` doesn't exist on window.
17543
- var onWindowEvent = hasWin && window.addEventListener
17544
- ? window.addEventListener.bind(window)
17545
- : noop;
17546
- var onDocumentEvent = hasDoc ? document.addEventListener.bind(document) : noop;
17547
- var offWindowEvent = hasWin && window.removeEventListener
17548
- ? window.removeEventListener.bind(window)
17549
- : noop;
17550
- var offDocumentEvent = hasDoc
17551
- ? document.removeEventListener.bind(document)
17552
- : noop;
17553
- var isVisible = function () {
17554
- var visibilityState = hasDoc && document.visibilityState;
17584
+ const [onWindowEvent, offWindowEvent] = isWindowDefined && window.addEventListener ? [
17585
+ window.addEventListener.bind(window),
17586
+ window.removeEventListener.bind(window)
17587
+ ] : [
17588
+ noop,
17589
+ noop
17590
+ ];
17591
+ const isVisible = ()=>{
17592
+ const visibilityState = isDocumentDefined && document.visibilityState;
17555
17593
  return isUndefined(visibilityState) || visibilityState !== 'hidden';
17556
17594
  };
17557
- var initFocus = function (callback) {
17595
+ const initFocus = (callback)=>{
17558
17596
  // focus revalidate
17559
- onDocumentEvent('visibilitychange', callback);
17597
+ if (isDocumentDefined) {
17598
+ document.addEventListener('visibilitychange', callback);
17599
+ }
17560
17600
  onWindowEvent('focus', callback);
17561
- return function () {
17562
- offDocumentEvent('visibilitychange', callback);
17601
+ return ()=>{
17602
+ if (isDocumentDefined) {
17603
+ document.removeEventListener('visibilitychange', callback);
17604
+ }
17563
17605
  offWindowEvent('focus', callback);
17564
17606
  };
17565
17607
  };
17566
- var initReconnect = function (callback) {
17608
+ const initReconnect = (callback)=>{
17567
17609
  // revalidate on reconnected
17568
- var onOnline = function () {
17610
+ const onOnline = ()=>{
17569
17611
  online = true;
17570
17612
  callback();
17571
17613
  };
17572
17614
  // nothing to revalidate, just update the status
17573
- var onOffline = function () {
17615
+ const onOffline = ()=>{
17574
17616
  online = false;
17575
17617
  };
17576
17618
  onWindowEvent('online', onOnline);
17577
17619
  onWindowEvent('offline', onOffline);
17578
- return function () {
17620
+ return ()=>{
17579
17621
  offWindowEvent('online', onOnline);
17580
17622
  offWindowEvent('offline', onOffline);
17581
17623
  };
17582
17624
  };
17583
- var preset = {
17584
- isOnline: isOnline,
17585
- isVisible: isVisible
17625
+ const preset = {
17626
+ isOnline,
17627
+ isVisible
17586
17628
  };
17587
- var defaultConfigOptions = {
17588
- initFocus: initFocus,
17589
- initReconnect: initReconnect
17629
+ const defaultConfigOptions = {
17630
+ initFocus,
17631
+ initReconnect
17590
17632
  };
17591
17633
 
17592
- var IS_SERVER = !hasWindow() || 'Deno' in window;
17634
+ const IS_REACT_LEGACY = !external_React_.useId;
17635
+ const IS_SERVER = !isWindowDefined || 'Deno' in window;
17593
17636
  // Polyfill requestAnimationFrame
17594
- var rAF = function (f) {
17595
- return hasRequestAnimationFrame() ? window['requestAnimationFrame'](f) : setTimeout(f, 1);
17596
- };
17637
+ const rAF = (f)=>hasRequestAnimationFrame() ? window['requestAnimationFrame'](f) : setTimeout(f, 1);
17597
17638
  // React currently throws a warning when using useLayoutEffect on the server.
17598
17639
  // To get around it, we can conditionally useEffect on the server (no-op) and
17599
17640
  // useLayoutEffect in the browser.
17600
- var useIsomorphicLayoutEffect = IS_SERVER ? external_React_.useEffect : external_React_.useLayoutEffect;
17641
+ const useIsomorphicLayoutEffect = IS_SERVER ? external_React_.useEffect : external_React_.useLayoutEffect;
17601
17642
  // This assignment is to extend the Navigator type to use effectiveType.
17602
- var navigatorConnection = typeof navigator !== 'undefined' &&
17603
- navigator.connection;
17643
+ const navigatorConnection = typeof navigator !== 'undefined' && navigator.connection;
17604
17644
  // Adjust the config based on slow connection status (<= 70Kbps).
17605
- var slowConnection = !IS_SERVER &&
17606
- navigatorConnection &&
17607
- (['slow-2g', '2g'].includes(navigatorConnection.effectiveType) ||
17608
- navigatorConnection.saveData);
17645
+ const slowConnection = !IS_SERVER && navigatorConnection && ([
17646
+ 'slow-2g',
17647
+ '2g'
17648
+ ].includes(navigatorConnection.effectiveType) || navigatorConnection.saveData);
17609
17649
 
17610
- var dist_serialize = function (key) {
17650
+ const dist_serialize = (key)=>{
17611
17651
  if (isFunction(key)) {
17612
17652
  try {
17613
17653
  key = key();
17614
- }
17615
- catch (err) {
17654
+ } catch (err) {
17616
17655
  // dependencies not ready
17617
17656
  key = '';
17618
17657
  }
17619
17658
  }
17620
- var args = [].concat(key);
17659
+ // Use the original key as the argument of fetcher. This can be a string or an
17660
+ // array of values.
17661
+ const args = key;
17621
17662
  // If key is not falsy, or not an empty array, hash it.
17622
- key =
17623
- typeof key == 'string'
17624
- ? key
17625
- : (Array.isArray(key) ? key.length : key)
17626
- ? stableHash(key)
17627
- : '';
17628
- var infoKey = key ? '$swr$' + key : '';
17629
- return [key, args, infoKey];
17663
+ key = typeof key == 'string' ? key : (Array.isArray(key) ? key.length : key) ? stableHash(key) : '';
17664
+ return [
17665
+ key,
17666
+ args
17667
+ ];
17630
17668
  };
17631
17669
 
17632
- // Global state used to deduplicate requests and store listeners
17633
- var SWRGlobalState = new WeakMap();
17634
-
17635
- var FOCUS_EVENT = 0;
17636
- var RECONNECT_EVENT = 1;
17637
- var MUTATE_EVENT = 2;
17638
-
17639
- var broadcastState = function (cache, key, data, error, isValidating, revalidate, broadcast) {
17640
- if (broadcast === void 0) { broadcast = true; }
17641
- var _a = SWRGlobalState.get(cache), EVENT_REVALIDATORS = _a[0], STATE_UPDATERS = _a[1], FETCH = _a[3];
17642
- var revalidators = EVENT_REVALIDATORS[key];
17643
- var updaters = STATE_UPDATERS[key];
17644
- // Cache was populated, update states of all hooks.
17645
- if (broadcast && updaters) {
17646
- for (var i = 0; i < updaters.length; ++i) {
17647
- updaters[i](data, error, isValidating);
17670
+ // Global timestamp.
17671
+ let __timestamp = 0;
17672
+ const getTimestamp = ()=>++__timestamp;
17673
+
17674
+ const FOCUS_EVENT = 0;
17675
+ const RECONNECT_EVENT = 1;
17676
+ const MUTATE_EVENT = 2;
17677
+
17678
+ var constants = {
17679
+ __proto__: null,
17680
+ FOCUS_EVENT: FOCUS_EVENT,
17681
+ RECONNECT_EVENT: RECONNECT_EVENT,
17682
+ MUTATE_EVENT: MUTATE_EVENT
17683
+ };
17684
+
17685
+ async function internalMutate(...args) {
17686
+ const [cache, _key, _data, _opts] = args;
17687
+ // When passing as a boolean, it's explicitly used to disable/enable
17688
+ // revalidation.
17689
+ const options = mergeObjects({
17690
+ populateCache: true,
17691
+ throwOnError: true
17692
+ }, typeof _opts === 'boolean' ? {
17693
+ revalidate: _opts
17694
+ } : _opts || {});
17695
+ let populateCache = options.populateCache;
17696
+ const rollbackOnErrorOption = options.rollbackOnError;
17697
+ let optimisticData = options.optimisticData;
17698
+ const revalidate = options.revalidate !== false;
17699
+ const rollbackOnError = (error)=>{
17700
+ return typeof rollbackOnErrorOption === 'function' ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false;
17701
+ };
17702
+ const throwOnError = options.throwOnError;
17703
+ // If the second argument is a key filter, return the mutation results for all
17704
+ // filtered keys.
17705
+ if (isFunction(_key)) {
17706
+ const keyFilter = _key;
17707
+ const matchedKeys = [];
17708
+ const it = cache.keys();
17709
+ for(let keyIt = it.next(); !keyIt.done; keyIt = it.next()){
17710
+ const key = keyIt.value;
17711
+ if (// Skip the special useSWRInfinite keys.
17712
+ !key.startsWith('$inf$') && keyFilter(cache.get(key)._k)) {
17713
+ matchedKeys.push(key);
17714
+ }
17648
17715
  }
17649
- }
17650
- // If we also need to revalidate, only do it for the first hook.
17651
- if (revalidate) {
17652
- // Invalidate the key by deleting the concurrent request markers so new
17653
- // requests will not be deduped.
17654
- delete FETCH[key];
17655
- if (revalidators && revalidators[0]) {
17656
- return revalidators[0](MUTATE_EVENT).then(function () {
17657
- return cache.get(key);
17716
+ return Promise.all(matchedKeys.map(mutateByKey));
17717
+ }
17718
+ return mutateByKey(_key);
17719
+ async function mutateByKey(_k) {
17720
+ // Serialize key
17721
+ const [key] = dist_serialize(_k);
17722
+ if (!key) return;
17723
+ const [get, set] = createCacheHelper(cache, key);
17724
+ const [EVENT_REVALIDATORS, MUTATION, FETCH] = SWRGlobalState.get(cache);
17725
+ const revalidators = EVENT_REVALIDATORS[key];
17726
+ const startRevalidate = ()=>{
17727
+ if (revalidate) {
17728
+ // Invalidate the key by deleting the concurrent request markers so new
17729
+ // requests will not be deduped.
17730
+ delete FETCH[key];
17731
+ if (revalidators && revalidators[0]) {
17732
+ return revalidators[0](MUTATE_EVENT).then(()=>get().data);
17733
+ }
17734
+ }
17735
+ return get().data;
17736
+ };
17737
+ // If there is no new data provided, revalidate the key with current state.
17738
+ if (args.length < 3) {
17739
+ // Revalidate and broadcast state.
17740
+ return startRevalidate();
17741
+ }
17742
+ let data = _data;
17743
+ let error;
17744
+ // Update global timestamps.
17745
+ const beforeMutationTs = getTimestamp();
17746
+ MUTATION[key] = [
17747
+ beforeMutationTs,
17748
+ 0
17749
+ ];
17750
+ const hasOptimisticData = !isUndefined(optimisticData);
17751
+ const state = get();
17752
+ // `displayedData` is the current value on screen. It could be the optimistic value
17753
+ // that is going to be overridden by a `committedData`, or get reverted back.
17754
+ // `committedData` is the validated value that comes from a fetch or mutation.
17755
+ const displayedData = state.data;
17756
+ const currentData = state._c;
17757
+ const committedData = isUndefined(currentData) ? displayedData : currentData;
17758
+ // Do optimistic data update.
17759
+ if (hasOptimisticData) {
17760
+ optimisticData = isFunction(optimisticData) ? optimisticData(committedData) : optimisticData;
17761
+ // When we set optimistic data, backup the current committedData data in `_c`.
17762
+ set({
17763
+ data: optimisticData,
17764
+ _c: committedData
17658
17765
  });
17659
17766
  }
17660
- }
17661
- return cache.get(key);
17662
- };
17663
-
17664
- // Global timestamp.
17665
- var __timestamp = 0;
17666
- var getTimestamp = function () { return ++__timestamp; };
17667
-
17668
- var internalMutate = function () {
17669
- var args = [];
17670
- for (var _i = 0; _i < arguments.length; _i++) {
17671
- args[_i] = arguments[_i];
17672
- }
17673
- return __awaiter(void 0, void 0, void 0, function () {
17674
- var cache, _key, _data, _opts, options, populateCache, revalidate, rollbackOnError, customOptimisticData, _a, key, keyInfo, _b, MUTATION, data, error, beforeMutationTs, hasCustomOptimisticData, rollbackData, optimisticData, res;
17675
- return __generator(this, function (_c) {
17676
- switch (_c.label) {
17677
- case 0:
17678
- cache = args[0], _key = args[1], _data = args[2], _opts = args[3];
17679
- options = typeof _opts === 'boolean' ? { revalidate: _opts } : _opts || {};
17680
- populateCache = isUndefined(options.populateCache)
17681
- ? true
17682
- : options.populateCache;
17683
- revalidate = options.revalidate !== false;
17684
- rollbackOnError = options.rollbackOnError !== false;
17685
- customOptimisticData = options.optimisticData;
17686
- _a = dist_serialize(_key), key = _a[0], keyInfo = _a[2];
17687
- if (!key)
17688
- return [2 /*return*/];
17689
- _b = SWRGlobalState.get(cache), MUTATION = _b[2];
17690
- // If there is no new data provided, revalidate the key with current state.
17691
- if (args.length < 3) {
17692
- // Revalidate and broadcast state.
17693
- return [2 /*return*/, broadcastState(cache, key, cache.get(key), UNDEFINED, UNDEFINED, revalidate, true)];
17694
- }
17695
- data = _data;
17696
- beforeMutationTs = getTimestamp();
17697
- MUTATION[key] = [beforeMutationTs, 0];
17698
- hasCustomOptimisticData = !isUndefined(customOptimisticData);
17699
- rollbackData = cache.get(key);
17700
- // Do optimistic data update.
17701
- if (hasCustomOptimisticData) {
17702
- optimisticData = isFunction(customOptimisticData)
17703
- ? customOptimisticData(rollbackData)
17704
- : customOptimisticData;
17705
- cache.set(key, optimisticData);
17706
- broadcastState(cache, key, optimisticData);
17707
- }
17708
- if (isFunction(data)) {
17709
- // `data` is a function, call it passing current cache value.
17710
- try {
17711
- data = data(cache.get(key));
17712
- }
17713
- catch (err) {
17714
- // If it throws an error synchronously, we shouldn't update the cache.
17715
- error = err;
17716
- }
17717
- }
17718
- if (!(data && isFunction(data.then))) return [3 /*break*/, 2];
17719
- return [4 /*yield*/, data.catch(function (err) {
17720
- error = err;
17721
- })
17722
- // Check if other mutations have occurred since we've started this mutation.
17723
- // If there's a race we don't update cache or broadcast the change,
17724
- // just return the data.
17725
- ];
17726
- case 1:
17727
- // This means that the mutation is async, we need to check timestamps to
17728
- // avoid race conditions.
17729
- data = _c.sent();
17730
- // Check if other mutations have occurred since we've started this mutation.
17731
- // If there's a race we don't update cache or broadcast the change,
17732
- // just return the data.
17733
- if (beforeMutationTs !== MUTATION[key][0]) {
17734
- if (error)
17735
- throw error;
17736
- return [2 /*return*/, data];
17737
- }
17738
- else if (error && hasCustomOptimisticData && rollbackOnError) {
17739
- // Rollback. Always populate the cache in this case but without
17740
- // transforming the data.
17741
- populateCache = true;
17742
- data = rollbackData;
17743
- cache.set(key, rollbackData);
17744
- }
17745
- _c.label = 2;
17746
- case 2:
17747
- // If we should write back the cache after request.
17748
- if (populateCache) {
17749
- if (!error) {
17750
- // Transform the result into data.
17751
- if (isFunction(populateCache)) {
17752
- data = populateCache(data, rollbackData);
17753
- }
17754
- // Only update cached data if there's no error. Data can be `undefined` here.
17755
- cache.set(key, data);
17756
- }
17757
- // Always update or reset the error.
17758
- cache.set(keyInfo, mergeObjects(cache.get(keyInfo), { error: error }));
17759
- }
17760
- // Reset the timestamp to mark the mutation has ended.
17761
- MUTATION[key][1] = getTimestamp();
17762
- return [4 /*yield*/, broadcastState(cache, key, data, error, UNDEFINED, revalidate, !!populateCache)
17763
- // Throw error or return data
17764
- ];
17765
- case 3:
17766
- res = _c.sent();
17767
- // Throw error or return data
17768
- if (error)
17769
- throw error;
17770
- return [2 /*return*/, populateCache ? res : data];
17767
+ if (isFunction(data)) {
17768
+ // `data` is a function, call it passing current cache value.
17769
+ try {
17770
+ data = data(committedData);
17771
+ } catch (err) {
17772
+ // If it throws an error synchronously, we shouldn't update the cache.
17773
+ error = err;
17774
+ }
17775
+ }
17776
+ // `data` is a promise/thenable, resolve the final data first.
17777
+ if (data && isFunction(data.then)) {
17778
+ // This means that the mutation is async, we need to check timestamps to
17779
+ // avoid race conditions.
17780
+ data = await data.catch((err)=>{
17781
+ error = err;
17782
+ });
17783
+ // Check if other mutations have occurred since we've started this mutation.
17784
+ // If there's a race we don't update cache or broadcast the change,
17785
+ // just return the data.
17786
+ if (beforeMutationTs !== MUTATION[key][0]) {
17787
+ if (error) throw error;
17788
+ return data;
17789
+ } else if (error && hasOptimisticData && rollbackOnError(error)) {
17790
+ // Rollback. Always populate the cache in this case but without
17791
+ // transforming the data.
17792
+ populateCache = true;
17793
+ data = committedData;
17794
+ // Reset data to be the latest committed data, and clear the `_c` value.
17795
+ set({
17796
+ data,
17797
+ _c: UNDEFINED
17798
+ });
17799
+ }
17800
+ }
17801
+ // If we should write back the cache after request.
17802
+ if (populateCache) {
17803
+ if (!error) {
17804
+ // Transform the result into data.
17805
+ if (isFunction(populateCache)) {
17806
+ data = populateCache(data, committedData);
17807
+ }
17808
+ // Only update cached data if there's no error. Data can be `undefined` here.
17809
+ set({
17810
+ data,
17811
+ _c: UNDEFINED
17812
+ });
17771
17813
  }
17814
+ }
17815
+ // Reset the timestamp to mark the mutation has ended.
17816
+ MUTATION[key][1] = getTimestamp();
17817
+ // Update existing SWR Hooks' internal states:
17818
+ const res = await startRevalidate();
17819
+ // The mutation and revalidation are ended, we can clear it since the data is
17820
+ // not an optimistic value anymore.
17821
+ set({
17822
+ _c: UNDEFINED
17772
17823
  });
17773
- });
17774
- };
17824
+ // Throw error or return data
17825
+ if (error) {
17826
+ if (throwOnError) throw error;
17827
+ return;
17828
+ }
17829
+ return populateCache ? res : data;
17830
+ }
17831
+ }
17775
17832
 
17776
- var revalidateAllKeys = function (revalidators, type) {
17777
- for (var key in revalidators) {
17778
- if (revalidators[key][0])
17779
- revalidators[key][0](type);
17833
+ const revalidateAllKeys = (revalidators, type)=>{
17834
+ for(const key in revalidators){
17835
+ if (revalidators[key][0]) revalidators[key][0](type);
17780
17836
  }
17781
17837
  };
17782
- var initCache = function (provider, options) {
17838
+ const initCache = (provider, options)=>{
17783
17839
  // The global state for a specific provider will be used to deduplicate
17784
- // requests and store listeners. As well as a mutate function that bound to
17840
+ // requests and store listeners. As well as a mutate function that is bound to
17785
17841
  // the cache.
17786
- // Provider's global state might be already initialized. Let's try to get the
17842
+ // The provider's global state might be already initialized. Let's try to get the
17787
17843
  // global state associated with the provider first.
17788
17844
  if (!SWRGlobalState.has(provider)) {
17789
- var opts = mergeObjects(defaultConfigOptions, options);
17845
+ const opts = mergeObjects(defaultConfigOptions, options);
17790
17846
  // If there's no global state bound to the provider, create a new one with the
17791
17847
  // new mutate function.
17792
- var EVENT_REVALIDATORS = {};
17793
- var mutate = internalMutate.bind(UNDEFINED, provider);
17794
- var unmount = noop;
17795
- // Update the state if it's new, or the provider has been extended.
17796
- SWRGlobalState.set(provider, [EVENT_REVALIDATORS, {}, {}, {}, mutate]);
17848
+ const EVENT_REVALIDATORS = {};
17849
+ const mutate = internalMutate.bind(UNDEFINED, provider);
17850
+ let unmount = noop;
17851
+ const subscriptions = {};
17852
+ const subscribe = (key, callback)=>{
17853
+ const subs = subscriptions[key] || [];
17854
+ subscriptions[key] = subs;
17855
+ subs.push(callback);
17856
+ return ()=>subs.splice(subs.indexOf(callback), 1);
17857
+ };
17858
+ const setter = (key, value, prev)=>{
17859
+ provider.set(key, value);
17860
+ const subs = subscriptions[key];
17861
+ if (subs) {
17862
+ for(let i = subs.length; i--;){
17863
+ subs[i](prev, value);
17864
+ }
17865
+ }
17866
+ };
17867
+ const initProvider = ()=>{
17868
+ if (!SWRGlobalState.has(provider)) {
17869
+ // Update the state if it's new, or if the provider has been extended.
17870
+ SWRGlobalState.set(provider, [
17871
+ EVENT_REVALIDATORS,
17872
+ {},
17873
+ {},
17874
+ {},
17875
+ mutate,
17876
+ setter,
17877
+ subscribe
17878
+ ]);
17879
+ if (!IS_SERVER) {
17880
+ // When listening to the native events for auto revalidations,
17881
+ // we intentionally put a delay (setTimeout) here to make sure they are
17882
+ // fired after immediate JavaScript executions, which can be
17883
+ // React's state updates.
17884
+ // This avoids some unnecessary revalidations such as
17885
+ // https://github.com/vercel/swr/issues/1680.
17886
+ const releaseFocus = opts.initFocus(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, FOCUS_EVENT)));
17887
+ const releaseReconnect = opts.initReconnect(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, RECONNECT_EVENT)));
17888
+ unmount = ()=>{
17889
+ releaseFocus && releaseFocus();
17890
+ releaseReconnect && releaseReconnect();
17891
+ // When un-mounting, we need to remove the cache provider from the state
17892
+ // storage too because it's a side-effect. Otherwise, when re-mounting we
17893
+ // will not re-register those event listeners.
17894
+ SWRGlobalState.delete(provider);
17895
+ };
17896
+ }
17897
+ }
17898
+ };
17899
+ initProvider();
17797
17900
  // This is a new provider, we need to initialize it and setup DOM events
17798
17901
  // listeners for `focus` and `reconnect` actions.
17799
- if (!IS_SERVER) {
17800
- // When listening to the native events for auto revalidations,
17801
- // we intentionally put a delay (setTimeout) here to make sure they are
17802
- // fired after immediate JavaScript executions, which can possibly be
17803
- // React's state updates.
17804
- // This avoids some unnecessary revalidations such as
17805
- // https://github.com/vercel/swr/issues/1680.
17806
- var releaseFocus_1 = opts.initFocus(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, FOCUS_EVENT)));
17807
- var releaseReconnect_1 = opts.initReconnect(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, RECONNECT_EVENT)));
17808
- unmount = function () {
17809
- releaseFocus_1 && releaseFocus_1();
17810
- releaseReconnect_1 && releaseReconnect_1();
17811
- // When un-mounting, we need to remove the cache provider from the state
17812
- // storage too because it's a side-effect. Otherwise when re-mounting we
17813
- // will not re-register those event listeners.
17814
- SWRGlobalState.delete(provider);
17815
- };
17816
- }
17817
17902
  // We might want to inject an extra layer on top of `provider` in the future,
17818
17903
  // such as key serialization, auto GC, etc.
17819
17904
  // For now, it's just a `Map` interface without any modifications.
17820
- return [provider, mutate, unmount];
17905
+ return [
17906
+ provider,
17907
+ mutate,
17908
+ initProvider,
17909
+ unmount
17910
+ ];
17821
17911
  }
17822
- return [provider, SWRGlobalState.get(provider)[4]];
17912
+ return [
17913
+ provider,
17914
+ SWRGlobalState.get(provider)[4]
17915
+ ];
17823
17916
  };
17824
17917
 
17825
17918
  // error retry
17826
- var onErrorRetry = function (_, __, config, revalidate, opts) {
17827
- var maxRetryCount = config.errorRetryCount;
17828
- var currentRetryCount = opts.retryCount;
17919
+ const onErrorRetry = (_, __, config, revalidate, opts)=>{
17920
+ const maxRetryCount = config.errorRetryCount;
17921
+ const currentRetryCount = opts.retryCount;
17829
17922
  // Exponential backoff
17830
- var timeout = ~~((Math.random() + 0.5) *
17831
- (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval;
17923
+ const timeout = ~~((Math.random() + 0.5) * (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval;
17832
17924
  if (!isUndefined(maxRetryCount) && currentRetryCount > maxRetryCount) {
17833
17925
  return;
17834
17926
  }
17835
17927
  setTimeout(revalidate, timeout, opts);
17836
17928
  };
17929
+ const compare = (currentData, newData)=>stableHash(currentData) == stableHash(newData);
17837
17930
  // Default cache provider
17838
- var _a = initCache(new Map()), cache = _a[0], mutate = _a[1];
17931
+ const [cache, mutate] = initCache(new Map());
17839
17932
  // Default config
17840
- var defaultConfig = mergeObjects({
17933
+ const defaultConfig = mergeObjects({
17841
17934
  // events
17842
17935
  onLoadingSlow: noop,
17843
17936
  onSuccess: noop,
17844
17937
  onError: noop,
17845
- onErrorRetry: onErrorRetry,
17938
+ onErrorRetry,
17846
17939
  onDiscarded: noop,
17847
17940
  // switches
17848
17941
  revalidateOnFocus: true,
@@ -17855,24 +17948,21 @@ var defaultConfig = mergeObjects({
17855
17948
  dedupingInterval: 2 * 1000,
17856
17949
  loadingTimeout: slowConnection ? 5000 : 3000,
17857
17950
  // providers
17858
- compare: function (currentData, newData) {
17859
- return stableHash(currentData) == stableHash(newData);
17860
- },
17861
- isPaused: function () { return false; },
17862
- cache: cache,
17863
- mutate: mutate,
17951
+ compare,
17952
+ isPaused: ()=>false,
17953
+ cache,
17954
+ mutate,
17864
17955
  fallback: {}
17865
- },
17866
- // use web preset by default
17956
+ }, // use web preset by default
17867
17957
  preset);
17868
17958
 
17869
- var mergeConfigs = function (a, b) {
17959
+ const mergeConfigs = (a, b)=>{
17870
17960
  // Need to create a new object to avoid mutating the original here.
17871
- var v = mergeObjects(a, b);
17961
+ const v = mergeObjects(a, b);
17872
17962
  // If two configs are provided, merge their `use` and `fallback` options.
17873
17963
  if (b) {
17874
- var u1 = a.use, f1 = a.fallback;
17875
- var u2 = b.use, f2 = b.fallback;
17964
+ const { use: u1 , fallback: f1 } = a;
17965
+ const { use: u2 , fallback: f2 } = b;
17876
17966
  if (u1 && u2) {
17877
17967
  v.use = u1.concat(u2);
17878
17968
  }
@@ -17883,68 +17973,152 @@ var mergeConfigs = function (a, b) {
17883
17973
  return v;
17884
17974
  };
17885
17975
 
17886
- var SWRConfigContext = (0,external_React_.createContext)({});
17887
- var SWRConfig$1 = function (props) {
17888
- var value = props.value;
17976
+ const SWRConfigContext = (0,external_React_.createContext)({});
17977
+ const SWRConfig = (props)=>{
17978
+ const { value } = props;
17979
+ const parentConfig = (0,external_React_.useContext)(SWRConfigContext);
17980
+ const isFunctionalConfig = isFunction(value);
17981
+ const config = (0,external_React_.useMemo)(()=>isFunctionalConfig ? value(parentConfig) : value, [
17982
+ isFunctionalConfig,
17983
+ parentConfig,
17984
+ value
17985
+ ]);
17889
17986
  // Extend parent context values and middleware.
17890
- var extendedConfig = mergeConfigs((0,external_React_.useContext)(SWRConfigContext), value);
17987
+ const extendedConfig = (0,external_React_.useMemo)(()=>isFunctionalConfig ? config : mergeConfigs(parentConfig, config), [
17988
+ isFunctionalConfig,
17989
+ parentConfig,
17990
+ config
17991
+ ]);
17891
17992
  // Should not use the inherited provider.
17892
- var provider = value && value.provider;
17993
+ const provider = config && config.provider;
17893
17994
  // Use a lazy initialized state to create the cache on first access.
17894
- var cacheContext = (0,external_React_.useState)(function () {
17895
- return provider
17896
- ? initCache(provider(extendedConfig.cache || cache), value)
17897
- : UNDEFINED;
17898
- })[0];
17995
+ const [cacheContext] = (0,external_React_.useState)(()=>provider ? initCache(provider(extendedConfig.cache || cache), config) : UNDEFINED);
17899
17996
  // Override the cache if a new provider is given.
17900
17997
  if (cacheContext) {
17901
17998
  extendedConfig.cache = cacheContext[0];
17902
17999
  extendedConfig.mutate = cacheContext[1];
17903
18000
  }
17904
18001
  // Unsubscribe events.
17905
- useIsomorphicLayoutEffect(function () { return (cacheContext ? cacheContext[2] : UNDEFINED); }, []);
18002
+ useIsomorphicLayoutEffect(()=>{
18003
+ if (cacheContext) {
18004
+ cacheContext[2] && cacheContext[2]();
18005
+ return cacheContext[3];
18006
+ }
18007
+ }, []);
17906
18008
  return (0,external_React_.createElement)(SWRConfigContext.Provider, mergeObjects(props, {
17907
18009
  value: extendedConfig
17908
18010
  }));
17909
18011
  };
17910
18012
 
18013
+ // @ts-expect-error
18014
+ const enableDevtools = isWindowDefined && window.__SWR_DEVTOOLS_USE__;
18015
+ const use = enableDevtools ? window.__SWR_DEVTOOLS_USE__ : [];
18016
+ const setupDevTools = ()=>{
18017
+ if (enableDevtools) {
18018
+ // @ts-expect-error
18019
+ window.__SWR_DEVTOOLS_REACT__ = external_React_;
18020
+ }
18021
+ };
18022
+
18023
+ const normalize = (args)=>{
18024
+ return isFunction(args[1]) ? [
18025
+ args[0],
18026
+ args[1],
18027
+ args[2] || {}
18028
+ ] : [
18029
+ args[0],
18030
+ null,
18031
+ (args[1] === null ? args[2] : args[1]) || {}
18032
+ ];
18033
+ };
18034
+
18035
+ const useSWRConfig = ()=>{
18036
+ return mergeObjects(defaultConfig, (0,external_React_.useContext)(SWRConfigContext));
18037
+ };
18038
+
18039
+ const preload = (key_, fetcher)=>{
18040
+ const key = dist_serialize(key_)[0];
18041
+ const [, , , PRELOAD] = SWRGlobalState.get(cache);
18042
+ // Prevent preload to be called multiple times before used.
18043
+ if (PRELOAD[key]) return PRELOAD[key];
18044
+ const req = fetcher(key_);
18045
+ PRELOAD[key] = req;
18046
+ return req;
18047
+ };
18048
+ const middleware = (useSWRNext)=>(key_, fetcher_, config)=>{
18049
+ // fetcher might be a sync function, so this should not be an async function
18050
+ const fetcher = fetcher_ && ((...args)=>{
18051
+ const key = dist_serialize(key_)[0];
18052
+ const [, , , PRELOAD] = SWRGlobalState.get(cache);
18053
+ const req = PRELOAD[key];
18054
+ if (req) {
18055
+ delete PRELOAD[key];
18056
+ return req;
18057
+ }
18058
+ return fetcher_(...args);
18059
+ });
18060
+ return useSWRNext(key_, fetcher, config);
18061
+ };
18062
+
18063
+ const BUILT_IN_MIDDLEWARE = use.concat(middleware);
18064
+
18065
+ // It's tricky to pass generic types as parameters, so we just directly override
18066
+ // the types here.
18067
+ const withArgs = (hook)=>{
18068
+ return function useSWRArgs(...args) {
18069
+ // Get the default and inherited configuration.
18070
+ const fallbackConfig = useSWRConfig();
18071
+ // Normalize arguments.
18072
+ const [key, fn, _config] = normalize(args);
18073
+ // Merge configurations.
18074
+ const config = mergeConfigs(fallbackConfig, _config);
18075
+ // Apply middleware
18076
+ let next = hook;
18077
+ const { use } = config;
18078
+ const middleware = (use || []).concat(BUILT_IN_MIDDLEWARE);
18079
+ for(let i = middleware.length; i--;){
18080
+ next = middleware[i](next);
18081
+ }
18082
+ return next(key, fn || config.fetcher || null, config);
18083
+ };
18084
+ };
18085
+
17911
18086
  /**
17912
18087
  * An implementation of state with dependency-tracking.
17913
- */
17914
- var useStateWithDeps = function (state, unmountedRef) {
17915
- var rerender = (0,external_React_.useState)({})[1];
17916
- var stateRef = (0,external_React_.useRef)(state);
17917
- // If a state property (data, error or isValidating) is accessed by the render
18088
+ */ const useStateWithDeps = (state)=>{
18089
+ const rerender = useState({})[1];
18090
+ const unmountedRef = useRef(false);
18091
+ const stateRef = useRef(state);
18092
+ // If a state property (data, error, or isValidating) is accessed by the render
17918
18093
  // function, we mark the property as a dependency so if it is updated again
17919
18094
  // in the future, we trigger a rerender.
17920
18095
  // This is also known as dependency-tracking.
17921
- var stateDependenciesRef = (0,external_React_.useRef)({
18096
+ const stateDependenciesRef = useRef({
17922
18097
  data: false,
17923
18098
  error: false,
17924
18099
  isValidating: false
17925
18100
  });
17926
18101
  /**
17927
- * @param payload To change stateRef, pass the values explicitly to setState:
17928
- * @example
17929
- * ```js
17930
- * setState({
17931
- * isValidating: false
17932
- * data: newData // set data to newData
17933
- * error: undefined // set error to undefined
17934
- * })
17935
- *
17936
- * setState({
17937
- * isValidating: false
17938
- * data: undefined // set data to undefined
17939
- * error: err // set error to err
17940
- * })
17941
- * ```
17942
- */
17943
- var setState = (0,external_React_.useCallback)(function (payload) {
17944
- var shouldRerender = false;
17945
- var currentState = stateRef.current;
17946
- for (var _ in payload) {
17947
- var k = _;
18102
+ * @param payload To change stateRef, pass the values explicitly to setState:
18103
+ * @example
18104
+ * ```js
18105
+ * setState({
18106
+ * isValidating: false
18107
+ * data: newData // set data to newData
18108
+ * error: undefined // set error to undefined
18109
+ * })
18110
+ *
18111
+ * setState({
18112
+ * isValidating: false
18113
+ * data: undefined // set data to undefined
18114
+ * error: err // set error to err
18115
+ * })
18116
+ * ```
18117
+ */ const setState = useCallback((payload)=>{
18118
+ let shouldRerender = false;
18119
+ const currentState = stateRef.current;
18120
+ for(const _ in payload){
18121
+ const k = _;
17948
18122
  // If the property has changed, update the state and mark rerender as
17949
18123
  // needed.
17950
18124
  if (currentState[k] !== payload[k]) {
@@ -17957,62 +18131,35 @@ var useStateWithDeps = function (state, unmountedRef) {
17957
18131
  }
17958
18132
  }
17959
18133
  if (shouldRerender && !unmountedRef.current) {
17960
- rerender({});
18134
+ if (IS_REACT_LEGACY) {
18135
+ rerender({});
18136
+ } else {
18137
+ React.startTransition(()=>rerender({}));
18138
+ }
17961
18139
  }
17962
- },
17963
- // config.suspense isn't allowed to change during the lifecycle
18140
+ }, // config.suspense isn't allowed to change during the lifecycle
17964
18141
  // eslint-disable-next-line react-hooks/exhaustive-deps
17965
18142
  []);
17966
- // Always update the state reference.
17967
- useIsomorphicLayoutEffect(function () {
17968
- stateRef.current = state;
18143
+ useIsomorphicLayoutEffect(()=>{
18144
+ unmountedRef.current = false;
18145
+ return ()=>{
18146
+ unmountedRef.current = true;
18147
+ };
17969
18148
  });
17970
- return [stateRef, stateDependenciesRef.current, setState];
17971
- };
17972
-
17973
- var normalize = function (args) {
17974
- return isFunction(args[1])
17975
- ? [args[0], args[1], args[2] || {}]
17976
- : [args[0], null, (args[1] === null ? args[2] : args[1]) || {}];
17977
- };
17978
-
17979
- var useSWRConfig = function () {
17980
- return mergeObjects(defaultConfig, (0,external_React_.useContext)(SWRConfigContext));
17981
- };
17982
-
17983
- // It's tricky to pass generic types as parameters, so we just directly override
17984
- // the types here.
17985
- var withArgs = function (hook) {
17986
- return function useSWRArgs() {
17987
- var args = [];
17988
- for (var _i = 0; _i < arguments.length; _i++) {
17989
- args[_i] = arguments[_i];
17990
- }
17991
- // Get the default and inherited configuration.
17992
- var fallbackConfig = useSWRConfig();
17993
- // Normalize arguments.
17994
- var _a = normalize(args), key = _a[0], fn = _a[1], _config = _a[2];
17995
- // Merge configurations.
17996
- var config = mergeConfigs(fallbackConfig, _config);
17997
- // Apply middleware
17998
- var next = hook;
17999
- var use = config.use;
18000
- if (use) {
18001
- for (var i = use.length; i-- > 0;) {
18002
- next = use[i](next);
18003
- }
18004
- }
18005
- return next(key, fn || config.fetcher, config);
18006
- };
18149
+ return [
18150
+ stateRef,
18151
+ stateDependenciesRef.current,
18152
+ setState
18153
+ ];
18007
18154
  };
18008
18155
 
18009
18156
  // Add a callback function to a list of keyed callback functions and return
18010
18157
  // the unsubscribe function.
18011
- var subscribeCallback = function (key, callbacks, callback) {
18012
- var keyedRevalidators = callbacks[key] || (callbacks[key] = []);
18158
+ const subscribeCallback = (key, callbacks, callback)=>{
18159
+ const keyedRevalidators = callbacks[key] || (callbacks[key] = []);
18013
18160
  keyedRevalidators.push(callback);
18014
- return function () {
18015
- var index = keyedRevalidators.indexOf(callback);
18161
+ return ()=>{
18162
+ const index = keyedRevalidators.indexOf(callback);
18016
18163
  if (index >= 0) {
18017
18164
  // O(1): faster than splice
18018
18165
  keyedRevalidators[index] = keyedRevalidators[keyedRevalidators.length - 1];
@@ -18021,247 +18168,308 @@ var subscribeCallback = function (key, callbacks, callback) {
18021
18168
  };
18022
18169
  };
18023
18170
 
18024
- var WITH_DEDUPE = { dedupe: true };
18025
- var useSWRHandler = function (_key, fetcher, config) {
18026
- var cache = config.cache, compare = config.compare, fallbackData = config.fallbackData, suspense = config.suspense, revalidateOnMount = config.revalidateOnMount, refreshInterval = config.refreshInterval, refreshWhenHidden = config.refreshWhenHidden, refreshWhenOffline = config.refreshWhenOffline;
18027
- var _a = SWRGlobalState.get(cache), EVENT_REVALIDATORS = _a[0], STATE_UPDATERS = _a[1], MUTATION = _a[2], FETCH = _a[3];
18171
+ // Create a custom hook with a middleware
18172
+ const withMiddleware = (useSWR, middleware)=>{
18173
+ return (...args)=>{
18174
+ const [key, fn, config] = normalize(args);
18175
+ const uses = (config.use || []).concat(middleware);
18176
+ return useSWR(key, fn, {
18177
+ ...config,
18178
+ use: uses
18179
+ });
18180
+ };
18181
+ };
18182
+
18183
+ setupDevTools();
18184
+
18185
+
18186
+
18187
+ ;// CONCATENATED MODULE: ./node_modules/swr/core/dist/index.mjs
18188
+
18189
+
18190
+
18191
+
18192
+
18193
+ const WITH_DEDUPE = {
18194
+ dedupe: true
18195
+ };
18196
+ const useSWRHandler = (_key, fetcher, config)=>{
18197
+ const { cache , compare , suspense , fallbackData , revalidateOnMount , refreshInterval , refreshWhenHidden , refreshWhenOffline , keepPreviousData } = config;
18198
+ const [EVENT_REVALIDATORS, MUTATION, FETCH] = SWRGlobalState.get(cache);
18028
18199
  // `key` is the identifier of the SWR `data` state, `keyInfo` holds extra
18029
18200
  // states such as `error` and `isValidating` inside,
18030
18201
  // all of them are derived from `_key`.
18031
- // `fnArgs` is an array of arguments parsed from the key, which will be passed
18202
+ // `fnArg` is the argument/arguments parsed from the key, which will be passed
18032
18203
  // to the fetcher.
18033
- var _b = dist_serialize(_key), key = _b[0], fnArgs = _b[1], keyInfo = _b[2];
18204
+ const [key, fnArg] = dist_serialize(_key);
18034
18205
  // If it's the initial render of this hook.
18035
- var initialMountedRef = (0,external_React_.useRef)(false);
18206
+ const initialMountedRef = (0,external_React_.useRef)(false);
18036
18207
  // If the hook is unmounted already. This will be used to prevent some effects
18037
18208
  // to be called after unmounting.
18038
- var unmountedRef = (0,external_React_.useRef)(false);
18209
+ const unmountedRef = (0,external_React_.useRef)(false);
18039
18210
  // Refs to keep the key and config.
18040
- var keyRef = (0,external_React_.useRef)(key);
18041
- var fetcherRef = (0,external_React_.useRef)(fetcher);
18042
- var configRef = (0,external_React_.useRef)(config);
18043
- var getConfig = function () { return configRef.current; };
18044
- var isActive = function () { return getConfig().isVisible() && getConfig().isOnline(); };
18045
- var patchFetchInfo = function (info) {
18046
- return cache.set(keyInfo, mergeObjects(cache.get(keyInfo), info));
18211
+ const keyRef = (0,external_React_.useRef)(key);
18212
+ const fetcherRef = (0,external_React_.useRef)(fetcher);
18213
+ const configRef = (0,external_React_.useRef)(config);
18214
+ const getConfig = ()=>configRef.current;
18215
+ const isActive = ()=>getConfig().isVisible() && getConfig().isOnline();
18216
+ const [getCache, setCache, subscribeCache] = createCacheHelper(cache, key);
18217
+ const stateDependencies = (0,external_React_.useRef)({}).current;
18218
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18219
+ const fallback = isUndefined(fallbackData) ? config.fallback[key] : fallbackData;
18220
+ const isEqual = (prev, current)=>{
18221
+ let equal = true;
18222
+ for(const _ in stateDependencies){
18223
+ const t = _;
18224
+ if (!compare(current[t], prev[t])) {
18225
+ if (t === 'data' && isUndefined(prev[t])) {
18226
+ if (!compare(current[t], returnedData)) {
18227
+ equal = false;
18228
+ }
18229
+ } else {
18230
+ equal = false;
18231
+ }
18232
+ }
18233
+ }
18234
+ return equal;
18047
18235
  };
18236
+ const getSnapshot = (0,external_React_.useMemo)(()=>{
18237
+ const shouldStartRequest = (()=>{
18238
+ if (!key) return false;
18239
+ if (!fetcher) return false;
18240
+ // If `revalidateOnMount` is set, we take the value directly.
18241
+ if (!isUndefined(revalidateOnMount)) return revalidateOnMount;
18242
+ // If it's paused, we skip revalidation.
18243
+ if (getConfig().isPaused()) return false;
18244
+ if (suspense) return false;
18245
+ return true;
18246
+ })();
18247
+ const getSelectedCache = ()=>{
18248
+ const state = getCache();
18249
+ // We only select the needed fields from the state.
18250
+ const snapshot = mergeObjects(state);
18251
+ delete snapshot._k;
18252
+ if (!shouldStartRequest) {
18253
+ return snapshot;
18254
+ }
18255
+ return {
18256
+ isValidating: true,
18257
+ isLoading: true,
18258
+ ...snapshot
18259
+ };
18260
+ };
18261
+ let memorizedSnapshot = getSelectedCache();
18262
+ return ()=>{
18263
+ const snapshot = getSelectedCache();
18264
+ return isEqual(snapshot, memorizedSnapshot) ? memorizedSnapshot : memorizedSnapshot = snapshot;
18265
+ };
18266
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18267
+ }, [
18268
+ cache,
18269
+ key
18270
+ ]);
18048
18271
  // Get the current state that SWR should return.
18049
- var cached = cache.get(key);
18050
- var fallback = isUndefined(fallbackData)
18051
- ? config.fallback[key]
18052
- : fallbackData;
18053
- var data = isUndefined(cached) ? fallback : cached;
18054
- var info = cache.get(keyInfo) || {};
18055
- var error = info.error;
18056
- var isInitialMount = !initialMountedRef.current;
18272
+ const cached = (0,shim.useSyncExternalStore)((0,external_React_.useCallback)((callback)=>subscribeCache(key, (prev, current)=>{
18273
+ if (!isEqual(prev, current)) callback();
18274
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
18275
+ [
18276
+ cache,
18277
+ key
18278
+ ]), getSnapshot, getSnapshot);
18279
+ const isInitialMount = !initialMountedRef.current;
18280
+ const cachedData = cached.data;
18281
+ const data = isUndefined(cachedData) ? fallback : cachedData;
18282
+ const error = cached.error;
18283
+ // Use a ref to store previously returned data. Use the initial data as its initial value.
18284
+ const laggyDataRef = (0,external_React_.useRef)(data);
18285
+ const returnedData = keepPreviousData ? isUndefined(cachedData) ? laggyDataRef.current : cachedData : data;
18057
18286
  // - Suspense mode and there's stale data for the initial render.
18058
18287
  // - Not suspense mode and there is no fallback data and `revalidateIfStale` is enabled.
18059
18288
  // - `revalidateIfStale` is enabled but `data` is not defined.
18060
- var shouldRevalidate = function () {
18289
+ const shouldDoInitialRevalidation = (()=>{
18061
18290
  // If `revalidateOnMount` is set, we take the value directly.
18062
- if (isInitialMount && !isUndefined(revalidateOnMount))
18063
- return revalidateOnMount;
18291
+ if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount;
18064
18292
  // If it's paused, we skip revalidation.
18065
- if (getConfig().isPaused())
18066
- return false;
18293
+ if (getConfig().isPaused()) return false;
18067
18294
  // Under suspense mode, it will always fetch on render if there is no
18068
- // stale data so no need to revalidate immediately on mount again.
18295
+ // stale data so no need to revalidate immediately mount it again.
18069
18296
  // If data exists, only revalidate if `revalidateIfStale` is true.
18070
- if (suspense)
18071
- return isUndefined(data) ? false : config.revalidateIfStale;
18072
- // If there is no stale data, we need to revalidate on mount;
18297
+ if (suspense) return isUndefined(data) ? false : config.revalidateIfStale;
18298
+ // If there is no stale data, we need to revalidate when mount;
18073
18299
  // If `revalidateIfStale` is set to true, we will always revalidate.
18074
18300
  return isUndefined(data) || config.revalidateIfStale;
18075
- };
18076
- // Resolve the current validating state.
18077
- var resolveValidating = function () {
18078
- if (!key || !fetcher)
18079
- return false;
18080
- if (info.isValidating)
18081
- return true;
18082
- // If it's not mounted yet and it should revalidate on mount, revalidate.
18083
- return isInitialMount && shouldRevalidate();
18084
- };
18085
- var isValidating = resolveValidating();
18086
- var _c = useStateWithDeps({
18087
- data: data,
18088
- error: error,
18089
- isValidating: isValidating
18090
- }, unmountedRef), stateRef = _c[0], stateDependencies = _c[1], setState = _c[2];
18301
+ })();
18302
+ // Resolve the default validating state:
18303
+ // If it's able to validate, and it should revalidate when mount, this will be true.
18304
+ const defaultValidatingState = !!(key && fetcher && isInitialMount && shouldDoInitialRevalidation);
18305
+ const isValidating = isUndefined(cached.isValidating) ? defaultValidatingState : cached.isValidating;
18306
+ const isLoading = isUndefined(cached.isLoading) ? defaultValidatingState : cached.isLoading;
18091
18307
  // The revalidation function is a carefully crafted wrapper of the original
18092
18308
  // `fetcher`, to correctly handle the many edge cases.
18093
- var revalidate = (0,external_React_.useCallback)(function (revalidateOpts) { return __awaiter(void 0, void 0, void 0, function () {
18094
- var currentFetcher, newData, startAt, loading, opts, shouldStartNewRequest, isCurrentKeyMounted, cleanupState, newState, finishRequestAndUpdateState, mutationInfo, err_1;
18095
- var _a;
18096
- return __generator(this, function (_b) {
18097
- switch (_b.label) {
18098
- case 0:
18099
- currentFetcher = fetcherRef.current;
18100
- if (!key ||
18101
- !currentFetcher ||
18102
- unmountedRef.current ||
18103
- getConfig().isPaused()) {
18104
- return [2 /*return*/, false];
18105
- }
18106
- loading = true;
18107
- opts = revalidateOpts || {};
18108
- shouldStartNewRequest = !FETCH[key] || !opts.dedupe;
18109
- isCurrentKeyMounted = function () {
18110
- return !unmountedRef.current &&
18111
- key === keyRef.current &&
18112
- initialMountedRef.current;
18113
- };
18114
- cleanupState = function () {
18115
- // Check if it's still the same request before deleting.
18116
- var requestInfo = FETCH[key];
18117
- if (requestInfo && requestInfo[1] === startAt) {
18118
- delete FETCH[key];
18119
- }
18120
- };
18121
- newState = { isValidating: false };
18122
- finishRequestAndUpdateState = function () {
18123
- patchFetchInfo({ isValidating: false });
18124
- // We can only set state if it's safe (still mounted with the same key).
18125
- if (isCurrentKeyMounted()) {
18126
- setState(newState);
18127
- }
18128
- };
18129
- // Start fetching. Change the `isValidating` state, update the cache.
18130
- patchFetchInfo({
18131
- isValidating: true
18132
- });
18133
- setState({ isValidating: true });
18134
- _b.label = 1;
18135
- case 1:
18136
- _b.trys.push([1, 3, , 4]);
18137
- if (shouldStartNewRequest) {
18138
- // Tell all other hooks to change the `isValidating` state.
18139
- broadcastState(cache, key, stateRef.current.data, stateRef.current.error, true);
18140
- // If no cache being rendered currently (it shows a blank page),
18141
- // we trigger the loading slow event.
18142
- if (config.loadingTimeout && !cache.get(key)) {
18143
- setTimeout(function () {
18144
- if (loading && isCurrentKeyMounted()) {
18145
- getConfig().onLoadingSlow(key, config);
18146
- }
18147
- }, config.loadingTimeout);
18148
- }
18149
- // Start the request and save the timestamp.
18150
- FETCH[key] = [currentFetcher.apply(void 0, fnArgs), getTimestamp()];
18151
- }
18152
- _a = FETCH[key], newData = _a[0], startAt = _a[1];
18153
- return [4 /*yield*/, newData];
18154
- case 2:
18155
- newData = _b.sent();
18156
- if (shouldStartNewRequest) {
18157
- // If the request isn't interrupted, clean it up after the
18158
- // deduplication interval.
18159
- setTimeout(cleanupState, config.dedupingInterval);
18160
- }
18161
- // If there're other ongoing request(s), started after the current one,
18162
- // we need to ignore the current one to avoid possible race conditions:
18163
- // req1------------------>res1 (current one)
18164
- // req2---------------->res2
18165
- // the request that fired later will always be kept.
18166
- // The timestamp maybe be `undefined` or a number
18167
- if (!FETCH[key] || FETCH[key][1] !== startAt) {
18168
- if (shouldStartNewRequest) {
18169
- if (isCurrentKeyMounted()) {
18170
- getConfig().onDiscarded(key);
18171
- }
18172
- }
18173
- return [2 /*return*/, false];
18174
- }
18175
- // Clear error.
18176
- patchFetchInfo({
18177
- error: UNDEFINED
18178
- });
18179
- newState.error = UNDEFINED;
18180
- mutationInfo = MUTATION[key];
18181
- if (!isUndefined(mutationInfo) &&
18182
- // case 1
18183
- (startAt <= mutationInfo[0] ||
18184
- // case 2
18185
- startAt <= mutationInfo[1] ||
18186
- // case 3
18187
- mutationInfo[1] === 0)) {
18188
- finishRequestAndUpdateState();
18189
- if (shouldStartNewRequest) {
18190
- if (isCurrentKeyMounted()) {
18191
- getConfig().onDiscarded(key);
18192
- }
18309
+ const revalidate = (0,external_React_.useCallback)(async (revalidateOpts)=>{
18310
+ const currentFetcher = fetcherRef.current;
18311
+ if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) {
18312
+ return false;
18313
+ }
18314
+ let newData;
18315
+ let startAt;
18316
+ let loading = true;
18317
+ const opts = revalidateOpts || {};
18318
+ // If there is no ongoing concurrent request, or `dedupe` is not set, a
18319
+ // new request should be initiated.
18320
+ const shouldStartNewRequest = !FETCH[key] || !opts.dedupe;
18321
+ /*
18322
+ For React 17
18323
+ Do unmount check for calls:
18324
+ If key has changed during the revalidation, or the component has been
18325
+ unmounted, old dispatch and old event callbacks should not take any
18326
+ effect
18327
+
18328
+ For React 18
18329
+ only check if key has changed
18330
+ https://github.com/reactwg/react-18/discussions/82
18331
+ */ const callbackSafeguard = ()=>{
18332
+ if (IS_REACT_LEGACY) {
18333
+ return !unmountedRef.current && key === keyRef.current && initialMountedRef.current;
18334
+ }
18335
+ return key === keyRef.current;
18336
+ };
18337
+ // The final state object when the request finishes.
18338
+ const finalState = {
18339
+ isValidating: false,
18340
+ isLoading: false
18341
+ };
18342
+ const finishRequestAndUpdateState = ()=>{
18343
+ setCache(finalState);
18344
+ };
18345
+ const cleanupState = ()=>{
18346
+ // Check if it's still the same request before deleting it.
18347
+ const requestInfo = FETCH[key];
18348
+ if (requestInfo && requestInfo[1] === startAt) {
18349
+ delete FETCH[key];
18350
+ }
18351
+ };
18352
+ // Start fetching. Change the `isValidating` state, update the cache.
18353
+ const initialState = {
18354
+ isValidating: true
18355
+ };
18356
+ // It is in the `isLoading` state, if and only if there is no cached data.
18357
+ // This bypasses fallback data and laggy data.
18358
+ if (isUndefined(getCache().data)) {
18359
+ initialState.isLoading = true;
18360
+ }
18361
+ try {
18362
+ if (shouldStartNewRequest) {
18363
+ setCache(initialState);
18364
+ // If no cache is being rendered currently (it shows a blank page),
18365
+ // we trigger the loading slow event.
18366
+ if (config.loadingTimeout && isUndefined(getCache().data)) {
18367
+ setTimeout(()=>{
18368
+ if (loading && callbackSafeguard()) {
18369
+ getConfig().onLoadingSlow(key, config);
18193
18370
  }
18194
- return [2 /*return*/, false];
18195
- }
18196
- // Deep compare with latest state to avoid extra re-renders.
18197
- // For local state, compare and assign.
18198
- if (!compare(stateRef.current.data, newData)) {
18199
- newState.data = newData;
18200
- }
18201
- else {
18202
- // data and newData are deeply equal
18203
- // it should be safe to broadcast the stale data
18204
- newState.data = stateRef.current.data;
18205
- // At the end of this function, `brocastState` invokes the `onStateUpdate` function,
18206
- // which takes care of avoiding the re-render
18207
- }
18208
- // For global state, it's possible that the key has changed.
18209
- // https://github.com/vercel/swr/pull/1058
18210
- if (!compare(cache.get(key), newData)) {
18211
- cache.set(key, newData);
18371
+ }, config.loadingTimeout);
18372
+ }
18373
+ // Start the request and save the timestamp.
18374
+ // Key must be truthy if entering here.
18375
+ FETCH[key] = [
18376
+ currentFetcher(fnArg),
18377
+ getTimestamp()
18378
+ ];
18379
+ }
18380
+ [newData, startAt] = FETCH[key];
18381
+ newData = await newData;
18382
+ if (shouldStartNewRequest) {
18383
+ // If the request isn't interrupted, clean it up after the
18384
+ // deduplication interval.
18385
+ setTimeout(cleanupState, config.dedupingInterval);
18386
+ }
18387
+ // If there're other ongoing request(s), started after the current one,
18388
+ // we need to ignore the current one to avoid possible race conditions:
18389
+ // req1------------------>res1 (current one)
18390
+ // req2---------------->res2
18391
+ // the request that fired later will always be kept.
18392
+ // The timestamp maybe be `undefined` or a number
18393
+ if (!FETCH[key] || FETCH[key][1] !== startAt) {
18394
+ if (shouldStartNewRequest) {
18395
+ if (callbackSafeguard()) {
18396
+ getConfig().onDiscarded(key);
18212
18397
  }
18213
- // Trigger the successful callback if it's the original request.
18214
- if (shouldStartNewRequest) {
18215
- if (isCurrentKeyMounted()) {
18216
- getConfig().onSuccess(newData, key, config);
18217
- }
18398
+ }
18399
+ return false;
18400
+ }
18401
+ // Clear error.
18402
+ finalState.error = UNDEFINED;
18403
+ // If there're other mutations(s), that overlapped with the current revalidation:
18404
+ // case 1:
18405
+ // req------------------>res
18406
+ // mutate------>end
18407
+ // case 2:
18408
+ // req------------>res
18409
+ // mutate------>end
18410
+ // case 3:
18411
+ // req------------------>res
18412
+ // mutate-------...---------->
18413
+ // we have to ignore the revalidation result (res) because it's no longer fresh.
18414
+ // meanwhile, a new revalidation should be triggered when the mutation ends.
18415
+ const mutationInfo = MUTATION[key];
18416
+ if (!isUndefined(mutationInfo) && // case 1
18417
+ (startAt <= mutationInfo[0] || // case 2
18418
+ startAt <= mutationInfo[1] || // case 3
18419
+ mutationInfo[1] === 0)) {
18420
+ finishRequestAndUpdateState();
18421
+ if (shouldStartNewRequest) {
18422
+ if (callbackSafeguard()) {
18423
+ getConfig().onDiscarded(key);
18218
18424
  }
18219
- return [3 /*break*/, 4];
18220
- case 3:
18221
- err_1 = _b.sent();
18222
- cleanupState();
18223
- // Not paused, we continue handling the error. Otherwise discard it.
18224
- if (!getConfig().isPaused()) {
18225
- // Get a new error, don't use deep comparison for errors.
18226
- patchFetchInfo({ error: err_1 });
18227
- newState.error = err_1;
18228
- // Error event and retry logic. Only for the actual request, not
18229
- // deduped ones.
18230
- if (shouldStartNewRequest && isCurrentKeyMounted()) {
18231
- getConfig().onError(err_1, key, config);
18232
- if ((typeof config.shouldRetryOnError === 'boolean' &&
18233
- config.shouldRetryOnError) ||
18234
- (isFunction(config.shouldRetryOnError) &&
18235
- config.shouldRetryOnError(err_1))) {
18236
- // When retrying, dedupe is always enabled
18237
- if (isActive()) {
18238
- // If it's active, stop. It will auto revalidate when refocusing
18239
- // or reconnecting.
18240
- getConfig().onErrorRetry(err_1, key, config, revalidate, {
18241
- retryCount: (opts.retryCount || 0) + 1,
18242
- dedupe: true
18243
- });
18244
- }
18245
- }
18425
+ }
18426
+ return false;
18427
+ }
18428
+ // Deep compare with the latest state to avoid extra re-renders.
18429
+ // For local state, compare and assign.
18430
+ const cacheData = getCache().data;
18431
+ // Since the compare fn could be custom fn
18432
+ // cacheData might be different from newData even when compare fn returns True
18433
+ finalState.data = compare(cacheData, newData) ? cacheData : newData;
18434
+ // Trigger the successful callback if it's the original request.
18435
+ if (shouldStartNewRequest) {
18436
+ if (callbackSafeguard()) {
18437
+ getConfig().onSuccess(newData, key, config);
18438
+ }
18439
+ }
18440
+ } catch (err) {
18441
+ cleanupState();
18442
+ const currentConfig = getConfig();
18443
+ const { shouldRetryOnError } = currentConfig;
18444
+ // Not paused, we continue handling the error. Otherwise, discard it.
18445
+ if (!currentConfig.isPaused()) {
18446
+ // Get a new error, don't use deep comparison for errors.
18447
+ finalState.error = err;
18448
+ // Error event and retry logic. Only for the actual request, not
18449
+ // deduped ones.
18450
+ if (shouldStartNewRequest && callbackSafeguard()) {
18451
+ currentConfig.onError(err, key, currentConfig);
18452
+ if (shouldRetryOnError === true || isFunction(shouldRetryOnError) && shouldRetryOnError(err)) {
18453
+ if (isActive()) {
18454
+ // If it's inactive, stop. It will auto-revalidate when
18455
+ // refocusing or reconnecting.
18456
+ // When retrying, deduplication is always enabled.
18457
+ currentConfig.onErrorRetry(err, key, currentConfig, revalidate, {
18458
+ retryCount: (opts.retryCount || 0) + 1,
18459
+ dedupe: true
18460
+ });
18246
18461
  }
18247
18462
  }
18248
- return [3 /*break*/, 4];
18249
- case 4:
18250
- // Mark loading as stopped.
18251
- loading = false;
18252
- // Update the current hook's state.
18253
- finishRequestAndUpdateState();
18254
- // Here is the source of the request, need to tell all other hooks to
18255
- // update their states.
18256
- if (isCurrentKeyMounted() && shouldStartNewRequest) {
18257
- broadcastState(cache, key, newState.data, newState.error, false);
18258
- }
18259
- return [2 /*return*/, true];
18463
+ }
18260
18464
  }
18261
- });
18262
- }); },
18263
- // `setState` is immutable, and `eventsCallback`, `fnArgs`, `keyInfo`,
18264
- // and `keyValidating` are depending on `key`, so we can exclude them from
18465
+ }
18466
+ // Mark loading as stopped.
18467
+ loading = false;
18468
+ // Update the current hook's state.
18469
+ finishRequestAndUpdateState();
18470
+ return true;
18471
+ }, // `setState` is immutable, and `eventsCallback`, `fnArg`, and
18472
+ // `keyValidating` are depending on `key`, so we can exclude them from
18265
18473
  // the deps array.
18266
18474
  //
18267
18475
  // FIXME:
@@ -18271,110 +18479,87 @@ var useSWRHandler = function (_key, fetcher, config) {
18271
18479
  // So we omit the values from the deps array
18272
18480
  // even though it might cause unexpected behaviors.
18273
18481
  // eslint-disable-next-line react-hooks/exhaustive-deps
18274
- [key]);
18275
- // Similar to the global mutate, but bound to the current cache and key.
18482
+ [
18483
+ key,
18484
+ cache
18485
+ ]);
18486
+ // Similar to the global mutate but bound to the current cache and key.
18276
18487
  // `cache` isn't allowed to change during the lifecycle.
18277
18488
  // eslint-disable-next-line react-hooks/exhaustive-deps
18278
- var boundMutate = (0,external_React_.useCallback)(
18279
- // By using `bind` we don't need to modify the size of the rest arguments.
18280
- // Due to https://github.com/microsoft/TypeScript/issues/37181, we have to
18281
- // cast it to any for now.
18282
- internalMutate.bind(UNDEFINED, cache, function () { return keyRef.current; }),
18283
- // eslint-disable-next-line react-hooks/exhaustive-deps
18489
+ const boundMutate = (0,external_React_.useCallback)(// Use callback to make sure `keyRef.current` returns latest result every time
18490
+ (...args)=>{
18491
+ return internalMutate(cache, keyRef.current, ...args);
18492
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
18284
18493
  []);
18285
- // Always update fetcher and config refs.
18286
- useIsomorphicLayoutEffect(function () {
18494
+ // The logic for updating refs.
18495
+ useIsomorphicLayoutEffect(()=>{
18287
18496
  fetcherRef.current = fetcher;
18288
18497
  configRef.current = config;
18498
+ // Handle laggy data updates. If there's cached data of the current key,
18499
+ // it'll be the correct reference.
18500
+ if (!isUndefined(cachedData)) {
18501
+ laggyDataRef.current = cachedData;
18502
+ }
18289
18503
  });
18290
18504
  // After mounted or key changed.
18291
- useIsomorphicLayoutEffect(function () {
18292
- if (!key)
18293
- return;
18294
- var keyChanged = key !== keyRef.current;
18295
- var softRevalidate = revalidate.bind(UNDEFINED, WITH_DEDUPE);
18296
- // Expose state updater to global event listeners. So we can update hook's
18297
- // internal state from the outside.
18298
- var onStateUpdate = function (updatedData, updatedError, updatedIsValidating) {
18299
- setState(mergeObjects({
18300
- error: updatedError,
18301
- isValidating: updatedIsValidating
18302
- },
18303
- // Since `setState` only shallowly compares states, we do a deep
18304
- // comparison here.
18305
- compare(stateRef.current.data, updatedData)
18306
- ? UNDEFINED
18307
- : {
18308
- data: updatedData
18309
- }));
18310
- };
18505
+ useIsomorphicLayoutEffect(()=>{
18506
+ if (!key) return;
18507
+ const softRevalidate = revalidate.bind(UNDEFINED, WITH_DEDUPE);
18311
18508
  // Expose revalidators to global event listeners. So we can trigger
18312
18509
  // revalidation from the outside.
18313
- var nextFocusRevalidatedAt = 0;
18314
- var onRevalidate = function (type) {
18315
- if (type == FOCUS_EVENT) {
18316
- var now = Date.now();
18317
- if (getConfig().revalidateOnFocus &&
18318
- now > nextFocusRevalidatedAt &&
18319
- isActive()) {
18510
+ let nextFocusRevalidatedAt = 0;
18511
+ const onRevalidate = (type)=>{
18512
+ if (type == constants.FOCUS_EVENT) {
18513
+ const now = Date.now();
18514
+ if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) {
18320
18515
  nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval;
18321
18516
  softRevalidate();
18322
18517
  }
18323
- }
18324
- else if (type == RECONNECT_EVENT) {
18518
+ } else if (type == constants.RECONNECT_EVENT) {
18325
18519
  if (getConfig().revalidateOnReconnect && isActive()) {
18326
18520
  softRevalidate();
18327
18521
  }
18328
- }
18329
- else if (type == MUTATE_EVENT) {
18522
+ } else if (type == constants.MUTATE_EVENT) {
18330
18523
  return revalidate();
18331
18524
  }
18332
18525
  return;
18333
18526
  };
18334
- var unsubUpdate = subscribeCallback(key, STATE_UPDATERS, onStateUpdate);
18335
- var unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate);
18527
+ const unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate);
18336
18528
  // Mark the component as mounted and update corresponding refs.
18337
18529
  unmountedRef.current = false;
18338
18530
  keyRef.current = key;
18339
18531
  initialMountedRef.current = true;
18340
- // When `key` updates, reset the state to the initial value
18341
- // and trigger a rerender if necessary.
18342
- if (keyChanged) {
18343
- setState({
18344
- data: data,
18345
- error: error,
18346
- isValidating: isValidating
18347
- });
18348
- }
18532
+ // Keep the original key in the cache.
18533
+ setCache({
18534
+ _k: fnArg
18535
+ });
18349
18536
  // Trigger a revalidation.
18350
- if (shouldRevalidate()) {
18537
+ if (shouldDoInitialRevalidation) {
18351
18538
  if (isUndefined(data) || IS_SERVER) {
18352
18539
  // Revalidate immediately.
18353
18540
  softRevalidate();
18354
- }
18355
- else {
18541
+ } else {
18356
18542
  // Delay the revalidate if we have data to return so we won't block
18357
18543
  // rendering.
18358
18544
  rAF(softRevalidate);
18359
18545
  }
18360
18546
  }
18361
- return function () {
18547
+ return ()=>{
18362
18548
  // Mark it as unmounted.
18363
18549
  unmountedRef.current = true;
18364
- unsubUpdate();
18365
18550
  unsubEvents();
18366
18551
  };
18367
- }, [key, revalidate]);
18552
+ }, [
18553
+ key
18554
+ ]);
18368
18555
  // Polling
18369
- useIsomorphicLayoutEffect(function () {
18370
- var timer;
18556
+ useIsomorphicLayoutEffect(()=>{
18557
+ let timer;
18371
18558
  function next() {
18372
18559
  // Use the passed interval
18373
18560
  // ...or invoke the function with the updated data to get the interval
18374
- var interval = isFunction(refreshInterval)
18375
- ? refreshInterval(data)
18376
- : refreshInterval;
18377
- // We only start next interval if `refreshInterval` is not 0, and:
18561
+ const interval = isFunction(refreshInterval) ? refreshInterval(data) : refreshInterval;
18562
+ // We only start the next interval if `refreshInterval` is not 0, and:
18378
18563
  // - `force` is true, which is the start of polling
18379
18564
  // - or `timer` is not 0, which means the effect wasn't canceled
18380
18565
  if (interval && timer !== -1) {
@@ -18383,32 +18568,40 @@ var useSWRHandler = function (_key, fetcher, config) {
18383
18568
  }
18384
18569
  function execute() {
18385
18570
  // Check if it's OK to execute:
18386
- // Only revalidate when the page is visible, online and not errored.
18387
- if (!stateRef.current.error &&
18388
- (refreshWhenHidden || getConfig().isVisible()) &&
18389
- (refreshWhenOffline || getConfig().isOnline())) {
18571
+ // Only revalidate when the page is visible, online, and not errored.
18572
+ if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) {
18390
18573
  revalidate(WITH_DEDUPE).then(next);
18391
- }
18392
- else {
18393
- // Schedule next interval to check again.
18574
+ } else {
18575
+ // Schedule the next interval to check again.
18394
18576
  next();
18395
18577
  }
18396
18578
  }
18397
18579
  next();
18398
- return function () {
18580
+ return ()=>{
18399
18581
  if (timer) {
18400
18582
  clearTimeout(timer);
18401
18583
  timer = -1;
18402
18584
  }
18403
18585
  };
18404
- }, [refreshInterval, refreshWhenHidden, refreshWhenOffline, revalidate]);
18586
+ }, [
18587
+ refreshInterval,
18588
+ refreshWhenHidden,
18589
+ refreshWhenOffline,
18590
+ key
18591
+ ]);
18405
18592
  // Display debug info in React DevTools.
18406
- (0,external_React_.useDebugValue)(data);
18593
+ (0,external_React_.useDebugValue)(returnedData);
18407
18594
  // In Suspense mode, we can't return the empty `data` state.
18408
- // If there is `error`, the `error` needs to be thrown to the error boundary.
18595
+ // If there is an `error`, the `error` needs to be thrown to the error boundary.
18409
18596
  // If there is no `error`, the `revalidation` promise needs to be thrown to
18410
18597
  // the suspense boundary.
18411
18598
  if (suspense && isUndefined(data) && key) {
18599
+ // SWR should throw when trying to use Suspense on the server with React 18,
18600
+ // without providing any initial data. See:
18601
+ // https://github.com/vercel/swr/issues/1832
18602
+ if (!IS_REACT_LEGACY && IS_SERVER) {
18603
+ throw new Error('Fallback data is required when using suspense in SSR.');
18604
+ }
18412
18605
  // Always update fetcher and config refs even with the Suspense mode.
18413
18606
  fetcherRef.current = fetcher;
18414
18607
  configRef.current = config;
@@ -18417,25 +18610,43 @@ var useSWRHandler = function (_key, fetcher, config) {
18417
18610
  }
18418
18611
  return {
18419
18612
  mutate: boundMutate,
18420
- get data() {
18613
+ get data () {
18421
18614
  stateDependencies.data = true;
18422
- return data;
18615
+ return returnedData;
18423
18616
  },
18424
- get error() {
18617
+ get error () {
18425
18618
  stateDependencies.error = true;
18426
18619
  return error;
18427
18620
  },
18428
- get isValidating() {
18621
+ get isValidating () {
18429
18622
  stateDependencies.isValidating = true;
18430
18623
  return isValidating;
18624
+ },
18625
+ get isLoading () {
18626
+ stateDependencies.isLoading = true;
18627
+ return isLoading;
18431
18628
  }
18432
18629
  };
18433
18630
  };
18434
- var SWRConfig = OBJECT.defineProperty(SWRConfig$1, 'default', {
18631
+ const dist_SWRConfig = OBJECT.defineProperty(SWRConfig, 'defaultValue', {
18435
18632
  value: defaultConfig
18436
18633
  });
18437
- var unstable_serialize = function (key) { return dist_serialize(key)[0]; };
18438
- var useSWR = withArgs(useSWRHandler);
18634
+ const unstable_serialize = (key)=>serialize(key)[0];
18635
+ /**
18636
+ * A hook to fetch data.
18637
+ *
18638
+ * @link https://swr.vercel.app
18639
+ * @example
18640
+ * ```jsx
18641
+ * import useSWR from 'swr'
18642
+ * function Profile() {
18643
+ * const { data, error } = useSWR('/api/user', fetcher)
18644
+ * if (error) return <div>failed to load</div>
18645
+ * if (!data) return <div>loading...</div>
18646
+ * return <div>hello {data.name}!</div>
18647
+ * }
18648
+ * ```
18649
+ */ var useSWR = withArgs(useSWRHandler);
18439
18650
 
18440
18651
  // useSWR
18441
18652
 
@@ -20034,6 +20245,8 @@ var useSWR = withArgs(useSWRHandler);
20034
20245
  ;// CONCATENATED MODULE: ./packages/provider/es/locale/zh_TW.js
20035
20246
  /* harmony default export */ var zh_TW = ({
20036
20247
  moneySymbol: 'NT$',
20248
+ deleteThisLine: '刪除此行',
20249
+ copyThisLine: '複製此行',
20037
20250
  form: {
20038
20251
  lightFilter: {
20039
20252
  more: '更多篩選',
@@ -20083,19 +20296,20 @@ var useSWR = withArgs(useSWRHandler);
20083
20296
  densitySmall: '緊湊'
20084
20297
  },
20085
20298
  stepsForm: {
20086
- next: '下一個',
20087
- prev: '以前的',
20299
+ next: '下一步',
20300
+ prev: '上一步',
20088
20301
  submit: '完成'
20089
20302
  },
20090
20303
  loginForm: {
20091
20304
  submitText: '登入'
20092
20305
  },
20093
20306
  editableTable: {
20307
+ onlyOneLineEditor: '只能同時編輯一行',
20094
20308
  action: {
20095
20309
  save: '保存',
20096
20310
  cancel: '取消',
20097
20311
  delete: '刪除',
20098
- add: '添加一行數據'
20312
+ add: '新增一行資料'
20099
20313
  }
20100
20314
  },
20101
20315
  switch: {
@@ -20863,7 +21077,7 @@ var ConfigProVidContainer = function ConfigProVidContainer(props) {
20863
21077
  // eslint-disable-next-line react-hooks/exhaustive-deps
20864
21078
  }, [autoClearCache, children, getPrefixCls, hashId, locale, proProvideValue, token]);
20865
21079
  if (!autoClearCache) return configProviderDom;
20866
- return (0,jsx_runtime.jsx)(SWRConfig, {
21080
+ return (0,jsx_runtime.jsx)(dist_SWRConfig, {
20867
21081
  value: {
20868
21082
  provider: function provider() {
20869
21083
  return new Map();
@@ -32009,7 +32223,10 @@ var useFieldFetchData = function useFieldFetchData(props) {
32009
32223
  return null;
32010
32224
  }
32011
32225
  return swrKey;
32012
- }, function (_, params, kw) {
32226
+ }, function (_ref6) {
32227
+ var _ref7 = slicedToArray_slicedToArray(_ref6, 3),
32228
+ params = _ref7[1],
32229
+ kw = _ref7[2];
32013
32230
  return props.request(objectSpread2_objectSpread2(objectSpread2_objectSpread2({}, params), {}, {
32014
32231
  keyWords: kw
32015
32232
  }), props);
@@ -32107,13 +32324,13 @@ var FieldSelect = function FieldSelect(props, ref) {
32107
32324
  });
32108
32325
  var optionsValueEnum = (0,external_React_.useMemo)(function () {
32109
32326
  if (mode !== 'read') return;
32110
- var _ref6 = fieldNames || {},
32111
- _ref6$label = _ref6.label,
32112
- labelPropsName = _ref6$label === void 0 ? 'label' : _ref6$label,
32113
- _ref6$value = _ref6.value,
32114
- valuePropsName = _ref6$value === void 0 ? 'value' : _ref6$value,
32115
- _ref6$options = _ref6.options,
32116
- optionsPropsName = _ref6$options === void 0 ? 'options' : _ref6$options;
32327
+ var _ref8 = fieldNames || {},
32328
+ _ref8$label = _ref8.label,
32329
+ labelPropsName = _ref8$label === void 0 ? 'label' : _ref8$label,
32330
+ _ref8$value = _ref8.value,
32331
+ valuePropsName = _ref8$value === void 0 ? 'value' : _ref8$value,
32332
+ _ref8$options = _ref8.options,
32333
+ optionsPropsName = _ref8$options === void 0 ? 'options' : _ref8$options;
32117
32334
  var valuesMap = new Map();
32118
32335
  var traverseOptions = function traverseOptions(_options) {
32119
32336
  if (!(_options === null || _options === void 0 ? void 0 : _options.length)) {
@@ -48780,7 +48997,7 @@ var TopNavHeader = function TopNavHeader(props) {
48780
48997
 
48781
48998
 
48782
48999
  var genGlobalHeaderStyle = function genGlobalHeaderStyle(token) {
48783
- var _token$layout, _token$layout$header, _token$layout2, _token$layout2$header, _token$componentCls;
49000
+ var _token$layout, _token$layout$header, _token$layout2, _token$layout2$header, _token$layout3, _token$layout3$header, _token$componentCls;
48784
49001
  return defineProperty_defineProperty({}, token.componentCls, (_token$componentCls = {
48785
49002
  position: 'relative',
48786
49003
  background: 'transparent',
@@ -48819,7 +49036,7 @@ var genGlobalHeaderStyle = function genGlobalHeaderStyle(token) {
48819
49036
  marginInline: 0,
48820
49037
  marginInlineStart: 8,
48821
49038
  fontWeight: '600',
48822
- color: token.colorTextHeading,
49039
+ color: ((_token$layout3 = token.layout) === null || _token$layout3 === void 0 ? void 0 : (_token$layout3$header = _token$layout3.header) === null || _token$layout3$header === void 0 ? void 0 : _token$layout3$header.colorHeaderTitle) || token.colorTextHeading,
48823
49040
  fontSize: '18px',
48824
49041
  lineHeight: '32px'
48825
49042
  },
@@ -53087,7 +53304,6 @@ var ProLayout_excluded = ["id", "defaultMessage"],
53087
53304
 
53088
53305
 
53089
53306
 
53090
-
53091
53307
 
53092
53308
 
53093
53309
  var layoutIndex = 0;
@@ -53256,33 +53472,31 @@ var BaseProLayout = function BaseProLayout(props) {
53256
53472
  var locales = gLocaleObject();
53257
53473
  return locales[id] ? locales[id] : defaultMessage;
53258
53474
  }, [propsFormatMessage]);
53259
- var _useSWR = useSWR(function () {
53260
- if (!(menu === null || menu === void 0 ? void 0 : menu.params)) return [defaultId, {}];
53261
- return [defaultId, menu === null || menu === void 0 ? void 0 : menu.params];
53262
- }, /*#__PURE__*/function () {
53263
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_, params) {
53475
+ var _useSWR = useSWR([defaultId, menu === null || menu === void 0 ? void 0 : menu.params], /*#__PURE__*/function () {
53476
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref5) {
53264
53477
  var _menu$request;
53265
- var msg;
53478
+ var _ref7, params, menuDataItems;
53266
53479
  return _regeneratorRuntime().wrap(function _callee$(_context) {
53267
53480
  while (1) {
53268
53481
  switch (_context.prev = _context.next) {
53269
53482
  case 0:
53483
+ _ref7 = slicedToArray_slicedToArray(_ref5, 2), params = _ref7[1];
53270
53484
  setMenuLoading(true);
53271
- _context.next = 3;
53272
- return menu === null || menu === void 0 ? void 0 : (_menu$request = menu.request) === null || _menu$request === void 0 ? void 0 : _menu$request.call(menu, params, (route === null || route === void 0 ? void 0 : route.children) || (route === null || route === void 0 ? void 0 : route.routes) || []);
53273
- case 3:
53274
- msg = _context.sent;
53485
+ _context.next = 4;
53486
+ return menu === null || menu === void 0 ? void 0 : (_menu$request = menu.request) === null || _menu$request === void 0 ? void 0 : _menu$request.call(menu, params || {}, (route === null || route === void 0 ? void 0 : route.children) || (route === null || route === void 0 ? void 0 : route.routes) || []);
53487
+ case 4:
53488
+ menuDataItems = _context.sent;
53275
53489
  setMenuLoading(false);
53276
- return _context.abrupt("return", msg);
53277
- case 6:
53490
+ return _context.abrupt("return", menuDataItems);
53491
+ case 7:
53278
53492
  case "end":
53279
53493
  return _context.stop();
53280
53494
  }
53281
53495
  }
53282
53496
  }, _callee);
53283
53497
  }));
53284
- return function (_x, _x2) {
53285
- return _ref5.apply(this, arguments);
53498
+ return function (_x) {
53499
+ return _ref6.apply(this, arguments);
53286
53500
  };
53287
53501
  }(), {
53288
53502
  revalidateOnFocus: false,
@@ -53302,12 +53516,12 @@ var BaseProLayout = function BaseProLayout(props) {
53302
53516
  var menuInfoData = (0,external_React_.useMemo)(function () {
53303
53517
  return getMenuData(data || (route === null || route === void 0 ? void 0 : route.children) || (route === null || route === void 0 ? void 0 : route.routes) || [], menu, formatMessage, menuDataRender);
53304
53518
  }, [formatMessage, menu, menuDataRender, data, route === null || route === void 0 ? void 0 : route.children, route === null || route === void 0 ? void 0 : route.routes]);
53305
- var _ref6 = menuInfoData || {},
53306
- _ref6$breadcrumb = _ref6.breadcrumb,
53307
- breadcrumb = _ref6$breadcrumb === void 0 ? {} : _ref6$breadcrumb,
53308
- breadcrumbMap = _ref6.breadcrumbMap,
53309
- _ref6$menuData = _ref6.menuData,
53310
- menuData = _ref6$menuData === void 0 ? [] : _ref6$menuData;
53519
+ var _ref8 = menuInfoData || {},
53520
+ _ref8$breadcrumb = _ref8.breadcrumb,
53521
+ breadcrumb = _ref8$breadcrumb === void 0 ? {} : _ref8$breadcrumb,
53522
+ breadcrumbMap = _ref8.breadcrumbMap,
53523
+ _ref8$menuData = _ref8.menuData,
53524
+ menuData = _ref8$menuData === void 0 ? [] : _ref8$menuData;
53311
53525
  if (actionRef && (menu === null || menu === void 0 ? void 0 : menu.request)) {
53312
53526
  actionRef.current = {
53313
53527
  reload: function reload() {
@@ -64674,7 +64888,7 @@ var genFocusStyle = function genFocusStyle(token) {
64674
64888
  };
64675
64889
  };
64676
64890
  ;// CONCATENATED MODULE: ./node_modules/antd/es/version/version.js
64677
- /* harmony default export */ var version = ('5.0.4');
64891
+ /* harmony default export */ var version = ('5.0.5');
64678
64892
  ;// CONCATENATED MODULE: ./node_modules/antd/es/version/index.js
64679
64893
  /* eslint import/no-unresolved: 0 */
64680
64894
  // @ts-ignore
@@ -65660,7 +65874,6 @@ var Checkbox_rest = undefined && undefined.__rest || function (s, e) {
65660
65874
 
65661
65875
 
65662
65876
 
65663
-
65664
65877
  var InternalCheckbox = function InternalCheckbox(_a, ref) {
65665
65878
  var _classNames;
65666
65879
  var _b;
@@ -65680,9 +65893,9 @@ var InternalCheckbox = function InternalCheckbox(_a, ref) {
65680
65893
  getPrefixCls = _React$useContext.getPrefixCls,
65681
65894
  direction = _React$useContext.direction;
65682
65895
  var checkboxGroup = external_React_.useContext(GroupContext);
65683
- var _useContext = (0,external_React_.useContext)(FormItemInputContext),
65684
- isFormItemInput = _useContext.isFormItemInput;
65685
- var contextDisabled = (0,external_React_.useContext)(config_provider_DisabledContext);
65896
+ var _React$useContext2 = external_React_.useContext(FormItemInputContext),
65897
+ isFormItemInput = _React$useContext2.isFormItemInput;
65898
+ var contextDisabled = external_React_.useContext(config_provider_DisabledContext);
65686
65899
  var mergedDisabled = (_b = (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.disabled) || disabled) !== null && _b !== void 0 ? _b : contextDisabled;
65687
65900
  var prevValue = external_React_.useRef(restProps.value);
65688
65901
  external_React_.useEffect(function () {
@@ -76501,15 +76714,18 @@ var genGroupStyle = function genGroupStyle(token) {
76501
76714
 
76502
76715
 
76503
76716
  // handle border collapse
76504
- function compactItemBorder(token, borderedItemCls, popoverFocusedCls) {
76505
- var childCombinator = borderedItemCls ? '> *' : '';
76717
+ function compactItemBorder(token, options) {
76718
+ var childCombinator = options.borderElCls ? '> *' : '';
76719
+ var hoverEffects = ['hover', options.focus ? 'focus' : null, 'active'].filter(Boolean).map(function (n) {
76720
+ return "&:" + n + " " + childCombinator;
76721
+ }).join(',');
76506
76722
  return {
76507
76723
  '&-item:not(&-last-item)': {
76508
76724
  marginInlineEnd: -token.lineWidth
76509
76725
  },
76510
- '&-item': extends_extends(extends_extends(defineProperty_defineProperty({}, "&:hover " + childCombinator + ", &:focus " + childCombinator + ", &:active " + childCombinator, {
76726
+ '&-item': extends_extends(extends_extends(defineProperty_defineProperty({}, hoverEffects, {
76511
76727
  zIndex: 2
76512
- }), popoverFocusedCls ? defineProperty_defineProperty({}, "&" + popoverFocusedCls, {
76728
+ }), options.focusElCls ? defineProperty_defineProperty({}, "&" + options.focusElCls, {
76513
76729
  zIndex: 2
76514
76730
  }) : {}), defineProperty_defineProperty({}, "&[disabled] " + childCombinator, {
76515
76731
  zIndex: 0
@@ -76517,9 +76733,9 @@ function compactItemBorder(token, borderedItemCls, popoverFocusedCls) {
76517
76733
  };
76518
76734
  }
76519
76735
  // handle border-radius
76520
- function compactItemBorderRadius(prefixCls, borderedElementCls) {
76736
+ function compactItemBorderRadius(prefixCls, options) {
76521
76737
  var _ref2;
76522
- var childCombinator = borderedElementCls ? "> " + borderedElementCls : '';
76738
+ var childCombinator = options.borderElCls ? "> " + options.borderElCls : '';
76523
76739
  return _ref2 = {}, defineProperty_defineProperty(_ref2, "&-item:not(&-first-item):not(&-last-item) " + childCombinator, {
76524
76740
  borderRadius: 0
76525
76741
  }), defineProperty_defineProperty(_ref2, '&-item:not(&-last-item)&-first-item', defineProperty_defineProperty({}, "& " + childCombinator + ", &" + prefixCls + "-sm " + childCombinator + ", &" + prefixCls + "-lg " + childCombinator, {
@@ -76530,15 +76746,12 @@ function compactItemBorderRadius(prefixCls, borderedElementCls) {
76530
76746
  borderEndStartRadius: 0
76531
76747
  })), _ref2;
76532
76748
  }
76533
- function genCompactItemStyle(token, prefixCls, /** Some component borders are implemented on child elements like `Select` */
76534
- borderedElementCls,
76535
- /**
76536
- * Some components have special `focus` className especially with popovers like `Select` and
76537
- * `DatePicker`
76538
- */
76539
- popoverFocusedCls) {
76749
+ function genCompactItemStyle(token, prefixCls) {
76750
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
76751
+ focus: true
76752
+ };
76540
76753
  return {
76541
- '&-compact': extends_extends(extends_extends({}, compactItemBorder(token, borderedElementCls, popoverFocusedCls)), compactItemBorderRadius(prefixCls, borderedElementCls))
76754
+ '&-compact': extends_extends(extends_extends({}, compactItemBorder(token, options)), compactItemBorderRadius(prefixCls, options))
76542
76755
  };
76543
76756
  }
76544
76757
  ;// CONCATENATED MODULE: ./node_modules/antd/es/style/compact-item-vertical.js
@@ -76614,7 +76827,9 @@ var genSharedButtonStyle = function genSharedButtonStyle(token) {
76614
76827
  }
76615
76828
  }, defineProperty_defineProperty(_extends2, "> " + iconCls + " + span, > span + " + iconCls, {
76616
76829
  marginInlineStart: token.marginXS
76617
- }), defineProperty_defineProperty(_extends2, '&:not(:disabled)', extends_extends({}, genFocusStyle(token))), _extends2), genCompactItemStyle(token, componentCls)), genCompactItemVerticalStyle(token, componentCls)), (_extends3 = {
76830
+ }), defineProperty_defineProperty(_extends2, '&:not(:disabled)', extends_extends({}, genFocusStyle(token))), _extends2), genCompactItemStyle(token, componentCls, {
76831
+ focus: false
76832
+ })), genCompactItemVerticalStyle(token, componentCls)), (_extends3 = {
76618
76833
  // make `btn-icon-only` not too narrow
76619
76834
  '&-icon-only&-compact-item': {
76620
76835
  flex: 'none'
@@ -76622,28 +76837,28 @@ var genSharedButtonStyle = function genSharedButtonStyle(token) {
76622
76837
  }, defineProperty_defineProperty(_extends3, "&-compact-item" + componentCls + "-primary", {
76623
76838
  '&:not([disabled]) + &:not([disabled])': {
76624
76839
  position: 'relative',
76625
- '&:after': {
76840
+ '&:before': {
76626
76841
  position: 'absolute',
76627
76842
  top: -token.lineWidth,
76628
76843
  insetInlineStart: -token.lineWidth,
76629
76844
  display: 'inline-block',
76630
76845
  width: token.lineWidth,
76631
76846
  height: "calc(100% + " + token.lineWidth * 2 + "px)",
76632
- backgroundColor: token.colorPrimaryBorder,
76847
+ backgroundColor: token.colorPrimaryHover,
76633
76848
  content: '""'
76634
76849
  }
76635
76850
  }
76636
76851
  }), defineProperty_defineProperty(_extends3, '&-compact-vertical-item', defineProperty_defineProperty({}, "&" + componentCls + "-primary", {
76637
76852
  '&:not([disabled]) + &:not([disabled])': {
76638
76853
  position: 'relative',
76639
- '&:after': {
76854
+ '&:before': {
76640
76855
  position: 'absolute',
76641
76856
  top: -token.lineWidth,
76642
76857
  insetInlineStart: -token.lineWidth,
76643
76858
  display: 'inline-block',
76644
76859
  width: "calc(100% + " + token.lineWidth * 2 + "px)",
76645
76860
  height: token.lineWidth,
76646
- backgroundColor: token.colorPrimaryBorder,
76861
+ backgroundColor: token.colorPrimaryHover,
76647
76862
  content: '""'
76648
76863
  }
76649
76864
  }
@@ -78528,7 +78743,6 @@ var radio_rest = undefined && undefined.__rest || function (s, e) {
78528
78743
 
78529
78744
 
78530
78745
 
78531
-
78532
78746
  var InternalRadio = function InternalRadio(props, ref) {
78533
78747
  var _classNames;
78534
78748
  var groupContext = external_React_.useContext(radio_context);
@@ -78538,8 +78752,8 @@ var InternalRadio = function InternalRadio(props, ref) {
78538
78752
  direction = _React$useContext.direction;
78539
78753
  var innerRef = external_React_.useRef();
78540
78754
  var mergedRef = composeRef(ref, innerRef);
78541
- var _useContext = (0,external_React_.useContext)(FormItemInputContext),
78542
- isFormItemInput = _useContext.isFormItemInput;
78755
+ var _React$useContext2 = external_React_.useContext(FormItemInputContext),
78756
+ isFormItemInput = _React$useContext2.isFormItemInput;
78543
78757
  false ? 0 : void 0;
78544
78758
  var onChange = function onChange(e) {
78545
78759
  var _a, _b;
@@ -80139,17 +80353,17 @@ function BaseProList(props) {
80139
80353
 
80140
80354
  ;// CONCATENATED MODULE: ./packages/components/src/version.ts
80141
80355
  var version_version = {
80142
- "@ant-design/pro-card": "2.1.4",
80143
- "@ant-design/pro-components": "2.3.44",
80144
- "@ant-design/pro-descriptions": "2.0.37",
80145
- "@ant-design/pro-field": "2.1.28",
80146
- "@ant-design/pro-form": "2.4.5",
80147
- "@ant-design/pro-layout": "7.3.7",
80148
- "@ant-design/pro-list": "2.0.38",
80149
- "@ant-design/pro-provider": "2.1.4",
80356
+ "@ant-design/pro-card": "2.1.5",
80357
+ "@ant-design/pro-components": "2.3.46",
80358
+ "@ant-design/pro-descriptions": "2.0.38",
80359
+ "@ant-design/pro-field": "2.1.29",
80360
+ "@ant-design/pro-form": "2.4.6",
80361
+ "@ant-design/pro-layout": "7.3.9",
80362
+ "@ant-design/pro-list": "2.0.39",
80363
+ "@ant-design/pro-provider": "2.1.5",
80150
80364
  "@ant-design/pro-skeleton": "2.0.7",
80151
- "@ant-design/pro-table": "3.2.5",
80152
- "@ant-design/pro-utils": "2.4.4"
80365
+ "@ant-design/pro-table": "3.2.6",
80366
+ "@ant-design/pro-utils": "2.4.5"
80153
80367
  };
80154
80368
  ;// CONCATENATED MODULE: ./packages/components/src/index.tsx
80155
80369