@hanzogui/use-store 7.0.0 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,19 +5,14 @@ import { UNWRAP_PROXY, defaultOptions } from "./constants.native.js";
5
5
  import { UNWRAP_STORE_INFO, cache, getStoreDescriptors, getStoreUid, simpleStr } from "./helpers.native.js";
6
6
  import { DebugStores, shouldDebug, useCurrentComponent } from "./useStoreDebug.native.js";
7
7
  function _instanceof(left, right) {
8
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
9
- return !!right[Symbol.hasInstance](left);
10
- } else {
11
- return left instanceof right;
12
- }
8
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);else return left instanceof right;
13
9
  }
14
10
  var idFn = function (_) {
15
11
  return _;
16
12
  };
17
13
  function useStore(StoreKlass, props) {
18
14
  var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultOptions;
19
- var info = getOrCreateStoreInfo(StoreKlass, props, options);
20
- return useStoreFromInfo(info, options.selector, options);
15
+ return useStoreFromInfo(getOrCreateStoreInfo(StoreKlass, props, options), options.selector, options);
21
16
  }
22
17
  function useStoreDebug(StoreKlass, props) {
23
18
  return useStore(StoreKlass, props, {
@@ -32,9 +27,7 @@ function useGlobalStore(instance, debug) {
32
27
  var store = instance[UNWRAP_PROXY];
33
28
  var uid = getStoreUid(store.constructor, store.props);
34
29
  var info = cache.get(uid);
35
- if (!info) {
36
- throw new Error(`This store not created using createStore()`);
37
- }
30
+ if (!info) throw new Error(`This store not created using createStore()`);
38
31
  return useStoreFromInfo(info, void 0, {
39
32
  debug
40
33
  });
@@ -43,9 +36,7 @@ function useGlobalStoreSelector(instance, selector, debug) {
43
36
  var store = instance[UNWRAP_PROXY];
44
37
  var uid = getStoreUid(store.constructor, store.props);
45
38
  var info = cache.get(uid);
46
- if (!info) {
47
- throw new Error(`This store not created using createStore()`);
48
- }
39
+ if (!info) throw new Error(`This store not created using createStore()`);
49
40
  return useStoreFromInfo(info, selector, {
50
41
  debug
51
42
  });
@@ -98,16 +89,10 @@ function onCreateStore(cb) {
98
89
  }
99
90
  function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
100
91
  var _store_mount;
101
- if (!StoreKlass) {
102
- return null;
103
- }
92
+ if (!StoreKlass) return null;
104
93
  var uid = getStoreUid(StoreKlass, propsKeyCalculated !== null && propsKeyCalculated !== void 0 ? propsKeyCalculated : props);
105
- if (!(options === null || options === void 0 ? void 0 : options.avoidCache) && cache.has(uid)) {
106
- return cache.get(uid);
107
- }
108
- if (options === null || options === void 0 ? void 0 : options.refuseCreation) {
109
- throw new Error(`No store exists (${StoreKlass.name}) with props: ${props}`);
110
- }
94
+ if (!(options === null || options === void 0 ? void 0 : options.avoidCache) && cache.has(uid)) return cache.get(uid);
95
+ if (options === null || options === void 0 ? void 0 : options.refuseCreation) throw new Error(`No store exists (${StoreKlass.name}) with props: ${props}`);
111
96
  var storeInstance = new StoreKlass(props);
112
97
  storeInstance.props = props;
113
98
  var getters = {};
@@ -116,15 +101,7 @@ function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
116
101
  var descriptors = getStoreDescriptors(storeInstance);
117
102
  for (var key in descriptors) {
118
103
  var descriptor = descriptors[key];
119
- if (typeof descriptor.value === "function") {
120
- actions[key] = descriptor.value;
121
- } else if (typeof descriptor.get === "function") {
122
- getters[key] = descriptor.get;
123
- } else {
124
- if (key !== "props" && key[0] !== "_") {
125
- stateKeys.add(key);
126
- }
127
- }
104
+ if (typeof descriptor.value === "function") actions[key] = descriptor.value;else if (typeof descriptor.get === "function") getters[key] = descriptor.get;else if (key !== "props" && key[0] !== "_") stateKeys.add(key);
128
105
  }
129
106
  var keyComparators = storeInstance["_comparators"];
130
107
  var listeners = /* @__PURE__ */new Set();
@@ -168,13 +145,9 @@ function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
168
145
  _iteratorError = err;
169
146
  } finally {
170
147
  try {
171
- if (!_iteratorNormalCompletion && _iterator.return != null) {
172
- _iterator.return();
173
- }
148
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
174
149
  } finally {
175
- if (_didIteratorError) {
176
- throw _iteratorError;
177
- }
150
+ if (_didIteratorError) throw _iteratorError;
178
151
  }
179
152
  }
180
153
  }
@@ -182,10 +155,8 @@ function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
182
155
  var store = createProxiedStore(
183
156
  // we assign store right after and proxiedStore never accesses it until later on
184
157
  storeInfo);
185
- if (process.env.NODE_ENV === "development") {
186
- allStores[StoreKlass.name + uid] = store;
187
- }
188
- (_store_mount = store.mount) === null || _store_mount === void 0 ? void 0 : _store_mount.call(store);
158
+ if (process.env.NODE_ENV === "development") allStores[StoreKlass.name + uid] = store;
159
+ (_store_mount = store.mount) === null || _store_mount === void 0 || _store_mount.call(store);
189
160
  storeInfo.store = store;
190
161
  var result = storeInfo;
191
162
  cache.set(uid, result);
@@ -201,9 +172,7 @@ if (process.env.NODE_ENV === "development") {
201
172
  }
202
173
  var emptyObj = {};
203
174
  var selectKeys = function (obj, keys) {
204
- if (!keys.length) {
205
- return emptyObj;
206
- }
175
+ if (!keys.length) return emptyObj;
207
176
  var res = {};
208
177
  var _iteratorNormalCompletion = true,
209
178
  _didIteratorError = false,
@@ -218,13 +187,9 @@ var selectKeys = function (obj, keys) {
218
187
  _iteratorError = err;
219
188
  } finally {
220
189
  try {
221
- if (!_iteratorNormalCompletion && _iterator.return != null) {
222
- _iterator.return();
223
- }
190
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
224
191
  } finally {
225
- if (_didIteratorError) {
226
- throw _iteratorError;
227
- }
192
+ if (_didIteratorError) throw _iteratorError;
228
193
  }
229
194
  }
230
195
  return res;
@@ -237,14 +202,12 @@ function useStoreFromInfo(info, userSelector, options) {
237
202
  var store = info === null || info === void 0 ? void 0 : info.store;
238
203
  var internal = React.useRef(void 0);
239
204
  var component = useCurrentComponent();
240
- if (!internal.current) {
241
- internal.current = {
242
- component,
243
- tracked: /* @__PURE__ */new Set(),
244
- last: null,
245
- lastKeys: null
246
- };
247
- }
205
+ if (!internal.current) internal.current = {
206
+ component,
207
+ tracked: /* @__PURE__ */new Set(),
208
+ last: null,
209
+ lastKeys: null
210
+ };
248
211
  var curInternal = internal.current;
249
212
  var shouldPrintDebug = options === null || options === void 0 ? void 0 : options.debug;
250
213
  var getSnapshot = React.useCallback(function () {
@@ -254,66 +217,46 @@ function useStoreFromInfo(info, userSelector, options) {
254
217
  var keys = [...(!isTracking ? info.stateKeys : curInternal2.tracked)];
255
218
  var nextKeys = `${info.version}${keys.join("")}${userSelector || ""}`;
256
219
  var lastKeys = curInternal2.lastKeys;
257
- if (nextKeys === curInternal2.lastKeys) {
258
- return curInternal2.last;
259
- }
220
+ if (nextKeys === curInternal2.lastKeys) return curInternal2.last;
260
221
  curInternal2.lastKeys = nextKeys;
261
222
  var snap;
262
223
  info.disableTracking = true;
263
224
  var last = curInternal2.last;
264
- if (userSelector) {
265
- snap = userSelector(store);
266
- } else {
267
- snap = selectKeys(store, keys);
268
- }
225
+ if (userSelector) snap = userSelector(store);else snap = selectKeys(store, keys);
269
226
  info.disableTracking = false;
270
227
  var isUnchanged = !userSelector && !isTracking && last || typeof last !== "undefined" && isEqualSubsetShallow(last, snap, {
271
228
  keyComparators: info.keyComparators
272
229
  });
273
- if (shouldPrintDebug) {
274
- console.info("\u{1F311} getSnapshot", {
275
- storeState: selectKeys(store, Object.keys(store)),
276
- userSelector,
277
- info,
278
- isUnchanged,
279
- component,
280
- keys,
281
- last,
282
- snap,
283
- curInternal: curInternal2,
284
- nextKeys,
285
- lastKeys
286
- });
287
- }
288
- if (isUnchanged) {
289
- return last;
290
- }
230
+ if (shouldPrintDebug) console.info("🌑 getSnapshot", {
231
+ storeState: selectKeys(store, Object.keys(store)),
232
+ userSelector,
233
+ info,
234
+ isUnchanged,
235
+ component,
236
+ keys,
237
+ last,
238
+ snap,
239
+ curInternal: curInternal2,
240
+ nextKeys,
241
+ lastKeys
242
+ });
243
+ if (isUnchanged) return last;
291
244
  curInternal2.last = snap;
292
245
  return snap;
293
246
  }, [store]);
294
247
  var state = React.useSyncExternalStore((info === null || info === void 0 ? void 0 : info.subscribe) || idFn, getSnapshot, getSnapshot);
295
- if (!info || !store || !state) {
296
- return state;
297
- }
298
- if (userSelector) {
299
- return state;
300
- }
248
+ if (!info || !store || !state) return state;
249
+ if (userSelector) return state;
301
250
  return new Proxy(store, {
302
251
  get(target, key) {
303
252
  var curVal = Reflect.get(target, key);
304
- if (isInReaction) {
305
- return curVal;
306
- }
253
+ if (isInReaction) return curVal;
307
254
  var keyString = key;
308
255
  if (info.stateKeys.has(keyString) || keyString in info.getters) {
309
- if (shouldPrintDebug) {
310
- console.info("\u{1F440} tracking", keyString);
311
- }
256
+ if (shouldPrintDebug) console.info("👀 tracking", keyString);
312
257
  curInternal.tracked.add(keyString);
313
258
  }
314
- if (Reflect.has(state, key)) {
315
- return Reflect.get(state, key);
316
- }
259
+ if (Reflect.has(state, key)) return Reflect.get(state, key);
317
260
  return curVal;
318
261
  }
319
262
  });
@@ -322,51 +265,34 @@ var setters = /* @__PURE__ */new Set();
322
265
  var logStack = /* @__PURE__ */new Set();
323
266
  function createProxiedStore(storeInfo) {
324
267
  var _loop = function (key2) {
325
- if (key2 === "subscribe") {
326
- return "continue";
327
- }
268
+ if (key2 === "subscribe") return "continue";
328
269
  var actionFn = actions[key2];
329
270
  var isGetFn = key2.startsWith("get");
330
271
  wrappedActions[key2] = function useStoreAction() {
331
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
332
- args[_key] = arguments[_key];
333
- }
272
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
334
273
  var res;
335
- if (isGetFn || gettersState.isGetting) {
336
- return Reflect.apply(actionFn, proxiedStore, args);
337
- }
338
- if (process.env.NODE_ENV === "development" && shouldDebug2) {
339
- console.info("(debug) startAction", key2);
340
- }
274
+ if (isGetFn || gettersState.isGetting) return Reflect.apply(actionFn, proxiedStore, args);
275
+ if (process.env.NODE_ENV === "development" && shouldDebug2) console.info("(debug) startAction", key2);
341
276
  res = Reflect.apply(actionFn, proxiedStore, args);
342
- if (_instanceof(res, Promise)) {
343
- return res.then(finishAction);
344
- }
277
+ if (_instanceof(res, Promise)) return res.then(finishAction);
345
278
  finishAction();
346
279
  return res;
347
280
  };
348
281
  if (process.env.NODE_ENV === "development") {
349
282
  let hashCode2 = function (str) {
350
283
  var hash = 0;
351
- for (var i = 0; i < str.length; i++) {
352
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
353
- }
284
+ for (var i = 0; i < str.length; i++) hash = str.charCodeAt(i) + ((hash << 5) - hash);
354
285
  return hash;
355
286
  },
356
287
  strColor2 = function (str) {
357
288
  return `hsl(${hashCode2(str) % 360}, 90%, 40%)`;
358
289
  };
359
- var hashCode = hashCode2,
360
- strColor = strColor2;
361
290
  if (!key2.startsWith("get") && !key2.startsWith("_") && key2 !== "subscribe") {
362
291
  var ogAction = wrappedActions[key2];
363
292
  wrappedActions[key2] = new Proxy(ogAction, {
364
293
  apply(target, thisArg, args) {
365
294
  var isDebugging = shouldDebug2 || storeInfo.debug;
366
- var shouldLog = process.env.LOG_LEVEL !== "0" && (isDebugging || configureOpts.logLevel !== "error");
367
- if (!shouldLog) {
368
- return Reflect.apply(target, thisArg, args);
369
- }
295
+ if (!(process.env.LOG_LEVEL !== "0" && (isDebugging || configureOpts.logLevel !== "error"))) return Reflect.apply(target, thisArg, args);
370
296
  setters = /* @__PURE__ */new Set();
371
297
  var curSetters = setters;
372
298
  var isTopLevelLogger = logStack.size == 0;
@@ -385,19 +311,13 @@ function createProxiedStore(storeInfo) {
385
311
  var color = strColor2(name);
386
312
  var simpleArgs = args.map(simpleStr);
387
313
  logs.add([`%c \u{1F311} ${id} ${name.padStart(isTopLevelLogger ? 8 : 4)}%c.${key2}(${simpleArgs.join(", ")})${isTopLevelLogger && logStack.size > 1 ? ` (+${logStack.size - 1})` : ""}`, `color: ${color};`, "color: black;"]);
388
- if (curSetters.size) {
389
- curSetters.forEach(function (param) {
390
- var {
391
- key: key3,
392
- value
393
- } = param;
394
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
395
- logs.add([` SET ${key3} ${value}`, value]);
396
- } else {
397
- logs.add([` SET ${key3}`, value]);
398
- }
399
- });
400
- }
314
+ if (curSetters.size) curSetters.forEach(function (param) {
315
+ var {
316
+ key: key3,
317
+ value
318
+ } = param;
319
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") logs.add([` SET ${key3} ${value}`, value]);else logs.add([` SET ${key3}`, value]);
320
+ });
401
321
  if (isTopLevelLogger) {
402
322
  var error = null;
403
323
  try {
@@ -436,31 +356,21 @@ function createProxiedStore(storeInfo) {
436
356
  _iteratorError1 = err;
437
357
  } finally {
438
358
  try {
439
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
440
- _iterator1.return();
441
- }
359
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();
442
360
  } finally {
443
- if (_didIteratorError1) {
444
- throw _iteratorError1;
445
- }
361
+ if (_didIteratorError1) throw _iteratorError1;
446
362
  }
447
363
  }
448
- } else {
449
- console.info("Weird log", head, ...rest);
450
- }
364
+ } else console.info("Weird log", head, ...rest);
451
365
  }
452
366
  } catch (err) {
453
367
  _didIteratorError = true;
454
368
  _iteratorError = err;
455
369
  } finally {
456
370
  try {
457
- if (!_iteratorNormalCompletion && _iterator.return != null) {
458
- _iterator.return();
459
- }
371
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
460
372
  } finally {
461
- if (_didIteratorError) {
462
- throw _iteratorError;
463
- }
373
+ if (_didIteratorError) throw _iteratorError;
464
374
  }
465
375
  }
466
376
  } catch (err) {
@@ -471,7 +381,7 @@ function createProxiedStore(storeInfo) {
471
381
  _iteratorError2 = void 0;
472
382
  try {
473
383
  for (var _iterator2 = logStack[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
474
- var _ = _step2.value;
384
+ _step2.value;
475
385
  console.groupEnd();
476
386
  }
477
387
  } catch (err) {
@@ -479,18 +389,12 @@ function createProxiedStore(storeInfo) {
479
389
  _iteratorError2 = err;
480
390
  } finally {
481
391
  try {
482
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
483
- _iterator2.return();
484
- }
392
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) _iterator2.return();
485
393
  } finally {
486
- if (_didIteratorError2) {
487
- throw _iteratorError2;
488
- }
394
+ if (_didIteratorError2) throw _iteratorError2;
489
395
  }
490
396
  }
491
- if (error) {
492
- console.error(`error loggin`, error);
493
- }
397
+ if (error) console.error(`error loggin`, error);
494
398
  logStack.clear();
495
399
  }
496
400
  return res;
@@ -518,11 +422,9 @@ function createProxiedStore(storeInfo) {
518
422
  var wrappedActions = {};
519
423
  for (var key in actions) _loop(key);
520
424
  var finishAction = function (val) {
521
- if (process.env.NODE_ENV === "development" && shouldDebug2) {
522
- console.info("(debug) finishAction", {
523
- didSet
524
- });
525
- }
425
+ if (process.env.NODE_ENV === "development" && shouldDebug2) console.info("(debug) finishAction", {
426
+ didSet
427
+ });
526
428
  if (didSet) {
527
429
  storeInfo.triggerUpdate();
528
430
  didSet = false;
@@ -531,68 +433,42 @@ function createProxiedStore(storeInfo) {
531
433
  };
532
434
  var isTriggering = false;
533
435
  var proxiedStore = new Proxy(storeInstance, {
534
- // GET
535
436
  get(_, key2) {
536
- if (key2 in wrappedActions) {
537
- return wrappedActions[key2];
538
- }
539
- if (key2 in passThroughKeys) {
540
- return Reflect.get(storeInstance, key2);
541
- }
542
- if (key2 === UNWRAP_PROXY) {
543
- return storeInstance;
544
- }
545
- if (key2 === UNWRAP_STORE_INFO) {
546
- return storeInfo;
547
- }
548
- if (storeAccessTrackers.size) {
549
- storeAccessTrackers.forEach(function (cb) {
550
- return cb(storeInfo);
551
- });
552
- }
553
- if (typeof key2 !== "string") {
554
- return Reflect.get(storeInstance, key2);
555
- }
437
+ if (key2 in wrappedActions) return wrappedActions[key2];
438
+ if (key2 in passThroughKeys) return Reflect.get(storeInstance, key2);
439
+ if (key2 === UNWRAP_PROXY) return storeInstance;
440
+ if (key2 === UNWRAP_STORE_INFO) return storeInfo;
441
+ if (storeAccessTrackers.size) storeAccessTrackers.forEach(function (cb) {
442
+ return cb(storeInfo);
443
+ });
444
+ if (typeof key2 !== "string") return Reflect.get(storeInstance, key2);
556
445
  if (!storeInfo.disableTracking) {
557
- if (gettersState.isGetting) {
558
- gettersState.curGetKeys.add(key2);
559
- } else {}
446
+ if (gettersState.isGetting) gettersState.curGetKeys.add(key2);
560
447
  }
561
448
  if (key2 in getters) {
562
- if (getCache.has(key2)) {
563
- return getCache.get(key2);
564
- }
449
+ if (getCache.has(key2)) return getCache.get(key2);
565
450
  curGetKeys.clear();
566
451
  var isSubGetter = gettersState.isGetting;
567
452
  gettersState.isGetting = true;
568
453
  var res = getters[key2].call(proxiedStore);
569
- if (!isSubGetter) {
570
- gettersState.isGetting = false;
571
- }
454
+ if (!isSubGetter) gettersState.isGetting = false;
572
455
  var _iteratorNormalCompletion = true,
573
456
  _didIteratorError = false,
574
457
  _iteratorError = void 0;
575
458
  try {
576
459
  for (var _iterator = curGetKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
577
460
  var gk = _step.value;
578
- if (!depsToGetter.has(gk)) {
579
- depsToGetter.set(gk, /* @__PURE__ */new Set());
580
- }
581
- var cur = depsToGetter.get(gk);
582
- cur.add(key2);
461
+ if (!depsToGetter.has(gk)) depsToGetter.set(gk, /* @__PURE__ */new Set());
462
+ depsToGetter.get(gk).add(key2);
583
463
  }
584
464
  } catch (err) {
585
465
  _didIteratorError = true;
586
466
  _iteratorError = err;
587
467
  } finally {
588
468
  try {
589
- if (!_iteratorNormalCompletion && _iterator.return != null) {
590
- _iterator.return();
591
- }
469
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
592
470
  } finally {
593
- if (_didIteratorError) {
594
- throw _iteratorError;
595
- }
471
+ if (_didIteratorError) throw _iteratorError;
596
472
  }
597
473
  }
598
474
  getCache.set(key2, res);
@@ -600,7 +476,6 @@ function createProxiedStore(storeInfo) {
600
476
  }
601
477
  return Reflect.get(storeInstance, key2);
602
478
  },
603
- // SET
604
479
  set(target, key2, value, receiver) {
605
480
  var cur = Reflect.get(target, key2);
606
481
  var res = Reflect.set(target, key2, value, receiver);
@@ -612,16 +487,12 @@ function createProxiedStore(storeInfo) {
612
487
  key: key2,
613
488
  value
614
489
  });
615
- if (getShouldDebug(storeInfo)) {
616
- console.info("(debug) SET", res, key2, value);
617
- }
618
- }
619
- if (process.env.NODE_ENV === "development" && shouldDebug2) {
620
- console.info("SET...", {
621
- key: key2,
622
- value
623
- });
490
+ if (getShouldDebug(storeInfo)) console.info("(debug) SET", res, key2, value);
624
491
  }
492
+ if (process.env.NODE_ENV === "development" && shouldDebug2) console.info("SET...", {
493
+ key: key2,
494
+ value
495
+ });
625
496
  }
626
497
  if (!isTriggering) {
627
498
  isTriggering = true;
@@ -637,9 +508,7 @@ function createProxiedStore(storeInfo) {
637
508
  function clearGetterCache(setKey) {
638
509
  var parentGetters = depsToGetter.get(setKey);
639
510
  getCache.delete(setKey);
640
- if (!parentGetters) {
641
- return;
642
- }
511
+ if (!parentGetters) return;
643
512
  var _iteratorNormalCompletion = true,
644
513
  _didIteratorError = false,
645
514
  _iteratorError = void 0;
@@ -647,30 +516,24 @@ function createProxiedStore(storeInfo) {
647
516
  for (var _iterator = parentGetters[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
648
517
  var gk = _step.value;
649
518
  getCache.delete(gk);
650
- if (depsToGetter.has(gk)) {
651
- clearGetterCache(gk);
652
- }
519
+ if (depsToGetter.has(gk)) clearGetterCache(gk);
653
520
  }
654
521
  } catch (err) {
655
522
  _didIteratorError = true;
656
523
  _iteratorError = err;
657
524
  } finally {
658
525
  try {
659
- if (!_iteratorNormalCompletion && _iterator.return != null) {
660
- _iterator.return();
661
- }
526
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
662
527
  } finally {
663
- if (_didIteratorError) {
664
- throw _iteratorError;
665
- }
528
+ if (_didIteratorError) throw _iteratorError;
666
529
  }
667
530
  }
668
531
  }
669
532
  return proxiedStore;
670
533
  }
671
- var waitForEventLoop = process.env.NODE_ENV === "test" || true ? function (cb) {
534
+ var waitForEventLoop = (process.env.NODE_ENV, function (cb) {
672
535
  return cb();
673
- } : queueMicrotask;
536
+ });
674
537
  var counter = 0;
675
538
  var passThroughKeys = {
676
539
  subscribe: true,
@@ -684,8 +547,7 @@ function getShouldDebug(storeInfo) {
684
547
  var info = {
685
548
  storeInstance: storeInfo.store
686
549
  };
687
- var trackers = storeInfo.trackers;
688
- return [...trackers].some(function (tracker) {
550
+ return [...storeInfo.trackers].some(function (tracker) {
689
551
  return tracker.component && shouldDebug(tracker.component, info);
690
552
  });
691
553
  }