@slimlib/store 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.mjs +215 -135
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Branch coverage](https://raw.githubusercontent.com/kshutkin/slimlib/coverage/store/badge.svg)](https://github.com/kshutkin/slimlib/tree/coverage/store/coverage)
2
+
1
3
  # Store
2
4
 
3
5
  Reactive state management for SPAs with automatic dependency tracking.
package/index.mjs CHANGED
@@ -16,23 +16,24 @@ const [unwrap, propertyDepsSymbol, trackSymbol, childrenSymbol, parentSymbol,
16
16
 
17
17
  ] = Array.from([, , , , ,], Symbol);
18
18
 
19
+ /* v8 ignore next -- @preserve */
19
20
  const noopGetter = () => undefined;
20
21
 
21
22
  class DepsSet extends Set {
22
- a = 0;
23
- b;
23
+ c = 0;
24
+ d;
24
25
  constructor(getter) {
25
26
  super();
26
- this.b = getter;
27
+ this.d = getter;
27
28
  }
28
29
  }
29
30
 
30
31
  const createSourceEntry = (dependents, node, version, getter, storedValue) => ({
31
- c: dependents,
32
- d: node,
33
- a: version,
34
- b: getter,
35
- e: storedValue,
32
+ f: dependents,
33
+ g: node,
34
+ c: version,
35
+ d: getter,
36
+ h: storedValue,
36
37
  });
37
38
  let flushScheduled = false;
38
39
 
@@ -49,7 +50,7 @@ const setTracked = (value) => {
49
50
  };
50
51
 
51
52
  const batchedAdd = (node) => {
52
- const nodeId = node.f;
53
+ const nodeId = node.k;
53
54
 
54
55
  if (nodeId < lastAddedId) {
55
56
  needsSort = true;
@@ -70,7 +71,8 @@ const unwrapValue = (value) => (value !== null &&
70
71
 
71
72
  const makeLive = (node) => {
72
73
 
73
- if ((node.g & (1 | 2 | 4 )) === 0 && node.f !== globalVersion) {
74
+
75
+ if ((node.l & (1 | 2 | 4 )) === 0 && node.k !== globalVersion) {
74
76
  const prevTracked = tracked;
75
77
  tracked = false;
76
78
  try {
@@ -78,60 +80,61 @@ const makeLive = (node) => {
78
80
  }
79
81
  catch {
80
82
 
81
- if (node.f !== globalVersion)
82
- node.g |= 1 ;
83
+
84
+ if (node.k !== globalVersion)
85
+ node.l |= 1 ;
83
86
  }
84
87
  finally {
85
88
  tracked = prevTracked;
86
89
  }
87
90
  }
88
- node.g |= 64 ;
89
- const nodeSources = node.h;
91
+ node.l |= 64 ;
92
+ const nodeSources = node.m;
90
93
  for (let i = 0, len = nodeSources.length; i < len; ++i) {
91
- const { c: c, d: sourceNode } = nodeSources[i];
92
- c.add(node);
93
- if (sourceNode !== undefined && (sourceNode.g & (8 | 64 )) === 0) {
94
+ const { f: f, g: sourceNode } = nodeSources[i];
95
+ f.add(node);
96
+ if (sourceNode !== undefined && (sourceNode.l & (8 | 64 )) === 0) {
94
97
  makeLive(sourceNode);
95
98
  }
96
99
  }
97
100
  };
98
101
 
99
102
  const makeNonLive = (node) => {
100
- node.g &= -65 ;
101
- const nodeSources = node.h;
103
+ node.l &= -65 ;
104
+ const nodeSources = node.m;
102
105
  for (let i = 0, len = nodeSources.length; i < len; ++i) {
103
- const { c: c, d: sourceNode } = nodeSources[i];
104
- c.delete(node);
106
+ const { f: f, g: sourceNode } = nodeSources[i];
107
+ f.delete(node);
105
108
 
106
109
  if (sourceNode !== undefined &&
107
- (sourceNode.g & (8 | 64 )) === 64 &&
108
- sourceNode.i.size === 0) {
110
+ (sourceNode.l & (8 | 64 )) === 64 &&
111
+ sourceNode.n.size === 0) {
109
112
  makeNonLive(sourceNode);
110
113
  }
111
114
  }
112
115
  };
113
116
 
114
117
  const clearSources = (node, fromIndex = 0) => {
115
- const nodeSources = node.h;
118
+ const nodeSources = node.m;
116
119
 
117
- if ((node.g & (8 | 64 )) === 0) {
120
+ if ((node.l & (8 | 64 )) === 0) {
118
121
  nodeSources.length = fromIndex;
119
122
  return;
120
123
  }
121
124
  for (let i = fromIndex, len = nodeSources.length; i < len; ++i) {
122
- const { c: c, d: sourceNode } = nodeSources[i];
125
+ const { f: f, g: sourceNode } = nodeSources[i];
123
126
 
124
127
  let retained = false;
125
128
  for (let j = 0; j < fromIndex && !retained; ++j) {
126
- retained = nodeSources[j].c === c;
129
+ retained = nodeSources[j].f === f;
127
130
  }
128
131
  if (!retained) {
129
132
 
130
- c.delete(node);
133
+ f.delete(node);
131
134
 
132
135
  if (sourceNode !== undefined &&
133
- (sourceNode.g & (8 | 64 )) === 64 &&
134
- sourceNode.i.size === 0) {
136
+ (sourceNode.l & (8 | 64 )) === 64 &&
137
+ sourceNode.n.size === 0) {
135
138
  makeNonLive(sourceNode);
136
139
  }
137
140
  }
@@ -142,18 +145,20 @@ const clearSources = (node, fromIndex = 0) => {
142
145
  const flushEffects = () => {
143
146
  flushScheduled = false;
144
147
 
148
+
145
149
  const nodes = batched.slice();
146
150
  batched.length = 0;
147
151
  if (needsSort) {
148
- nodes.sort((a, b) => a.f - b.f);
152
+ nodes.sort((a, b) => a.k - b.k);
149
153
  }
150
154
  lastAddedId = 0;
151
155
  needsSort = false;
152
156
 
157
+
153
158
  for (let i = 0, len = nodes.length; i < len; ++i) {
154
159
  const node = nodes[i];
155
160
  try {
156
- node.j();
161
+ node.o();
157
162
  }
158
163
  catch (e) {
159
164
  console.error(e);
@@ -170,11 +175,11 @@ const scheduleFlush = () => {
170
175
 
171
176
  const trackStateDependency = (deps, cachedValue) => {
172
177
 
173
- const sourcesArray = currentComputing.h;
174
- const skipIndex = currentComputing.k;
178
+ const sourcesArray = currentComputing.m;
179
+ const skipIndex = currentComputing.q;
175
180
  const existing = sourcesArray[skipIndex];
176
181
  const noSource = existing === undefined;
177
- if (noSource || existing.c !== deps) {
182
+ if (noSource || existing.f !== deps) {
178
183
  const previous = skipIndex === 0 ? undefined : sourcesArray[skipIndex - 1];
179
184
 
180
185
  if (!noSource) {
@@ -182,44 +187,49 @@ const trackStateDependency = (deps, cachedValue) => {
182
187
  }
183
188
 
184
189
  if (previous !== undefined &&
185
- previous.c === deps &&
186
- previous.a === deps.a &&
187
- Object.is(previous.e, cachedValue)) {
190
+ previous.f === deps &&
191
+ previous.c === deps.c &&
192
+ Object.is(previous.h, cachedValue)) {
188
193
  return;
189
194
  }
190
195
 
191
- sourcesArray.push(createSourceEntry(deps, undefined, deps.a, deps.b, cachedValue));
192
196
 
193
- if ((currentComputing.g & (8 | 64 )) !== 0) {
197
+
198
+
199
+ sourcesArray.push(createSourceEntry(deps, undefined, deps.c, deps.d, cachedValue));
200
+
201
+ if ((currentComputing.l & (8 | 64 )) !== 0) {
194
202
  deps.add(currentComputing);
195
203
  }
196
204
  }
197
205
  else {
198
206
 
199
207
  const entry = sourcesArray[skipIndex];
200
- entry.a = deps.a;
201
- entry.e = cachedValue;
208
+ entry.c = deps.c;
209
+ entry.h = cachedValue;
202
210
  }
203
- ++currentComputing.k;
211
+ ++currentComputing.q;
204
212
  };
205
213
 
206
214
  const markNeedsCheck = (node) => {
207
- const flags = node.g;
215
+ const flags = node.l;
216
+
208
217
 
209
218
  if ((flags & (4 | 1 | 2 )) !== 0) {
210
219
 
220
+
211
221
  if ((flags & (4 | 8 | 1 )) === (4 | 8 )) {
212
- node.g = flags | 1 ;
222
+ node.l = flags | 1 ;
213
223
  batchedAdd(node);
214
224
  }
215
225
  return;
216
226
  }
217
227
 
218
- node.g = flags | 2 ;
228
+ node.l = flags | 2 ;
219
229
  if ((flags & 8 ) !== 0) {
220
230
  batchedAdd(node);
221
231
  }
222
- for (const dep of node.i) {
232
+ for (const dep of node.n) {
223
233
  markNeedsCheck(dep);
224
234
  }
225
235
  };
@@ -227,7 +237,7 @@ const markNeedsCheck = (node) => {
227
237
  const markDependents = (deps, schedule = true) => {
228
238
  ++globalVersion;
229
239
 
230
- ++deps.a;
240
+ ++deps.c;
231
241
  for (const dep of deps) {
232
242
  markNeedsCheck(dep);
233
243
  }
@@ -238,8 +248,10 @@ const markDependents = (deps, schedule = true) => {
238
248
 
239
249
  const runWithTracking = (node, getter) => {
240
250
 
241
- node.g = (node.g & -132) | 4 ;
242
- node.k = 0;
251
+
252
+
253
+ node.l = (node.l & -132) | 4 ;
254
+ node.q = 0;
243
255
  const prev = currentComputing;
244
256
  const prevTracked = tracked;
245
257
  currentComputing = node;
@@ -251,18 +263,18 @@ const runWithTracking = (node, getter) => {
251
263
  currentComputing = prev;
252
264
  tracked = prevTracked;
253
265
 
254
- const flags = (node.g &= -5 );
255
- const nodeSources = node.h;
256
- const skipped = node.k;
266
+ const flags = (node.l &= -5 );
267
+ const nodeSources = node.m;
268
+ const skipped = node.q;
257
269
  const nodeSourcesLength = nodeSources.length;
258
270
 
259
271
  if ((flags & 128 ) !== 0) {
260
272
  const updateLen = Math.min(skipped, nodeSourcesLength);
261
273
  for (let i = 0; i < updateLen; ++i) {
262
274
  const entry = nodeSources[i];
263
- const entryNode = entry.d;
275
+ const entryNode = entry.g;
264
276
  if (entryNode !== undefined) {
265
- entry.a = entryNode.a;
277
+ entry.c = entryNode.c;
266
278
  }
267
279
  }
268
280
  }
@@ -291,9 +303,9 @@ const checkSources = (sourcesArray) => {
291
303
  const len = sourcesArray.length;
292
304
  for (let i = 0; i < len; ++i) {
293
305
  const sourceEntry = sourcesArray[i];
294
- const sourceNode = sourceEntry.d;
306
+ const sourceNode = sourceEntry.g;
295
307
  if (sourceNode === undefined) {
296
- if (sourceEntry.a !== sourceEntry.c.a) {
308
+ if (sourceEntry.c !== sourceEntry.f.c) {
297
309
  tracked = prevTracked;
298
310
  return true;
299
311
  }
@@ -309,7 +321,8 @@ const checkSources = (sourcesArray) => {
309
321
  return true;
310
322
  }
311
323
 
312
- if (sourceEntry.a !== sourceNode.a) {
324
+
325
+ if (sourceEntry.c !== sourceNode.c) {
313
326
  tracked = prevTracked;
314
327
  return true;
315
328
  }
@@ -344,7 +357,7 @@ const safeForEach = (fns) => {
344
357
  };
345
358
 
346
359
  const warnIfWriteInComputed = (context) => {
347
- if (DEV && (debugConfigFlags & WARN_ON_WRITE_IN_COMPUTED) !== 0 && currentComputing && (currentComputing.g & 8 ) === 0) {
360
+ if (DEV && (debugConfigFlags & WARN_ON_WRITE_IN_COMPUTED) !== 0 && currentComputing && (currentComputing.l & 8 ) === 0) {
348
361
  console.warn(`[@slimlib/store] Writing to ${context} inside a computed is not recommended. The computed will not automatically re-run when this value changes, which may lead to stale values.`);
349
362
  }
350
363
  };
@@ -361,6 +374,7 @@ const registerEffect = DEV
361
374
  ? () => {
362
375
  const token = {};
363
376
 
377
+
364
378
  const relevantStack = String(new Error().stack).split('\n').slice(3).join('\n');
365
379
  effectRegistry.register(token, relevantStack, token);
366
380
  return token;
@@ -384,50 +398,55 @@ const cycleMessage = 'Detected cycle in computations.';
384
398
 
385
399
  function computedRead(self) {
386
400
 
401
+
387
402
  if (tracked && currentComputing !== undefined) {
388
403
 
389
- const consumerSources = currentComputing.h;
390
- const skipIndex = currentComputing.k;
391
- const deps = self.i;
404
+ const consumerSources = currentComputing.m;
405
+ const skipIndex = currentComputing.q;
406
+ const deps = self.n;
392
407
  const existing = consumerSources[skipIndex];
393
408
  const noSource = existing === undefined;
394
- if (noSource || existing.c !== deps) {
409
+ if (noSource || existing.f !== deps) {
395
410
  if (!noSource) {
396
411
  clearSources(currentComputing, skipIndex);
397
412
  }
398
413
 
414
+
399
415
  consumerSources.push(createSourceEntry(deps, self, 0, undefined, undefined));
400
416
 
401
- if ((currentComputing.g & (8 | 64 )) !== 0) {
417
+ if ((currentComputing.l & (8 | 64 )) !== 0) {
402
418
  deps.add(currentComputing);
403
419
 
404
- if ((self.g & 64 ) === 0) {
420
+ if ((self.l & 64 ) === 0) {
405
421
  makeLive(self);
406
422
  }
407
423
  }
408
424
  }
409
425
 
410
- currentComputing.g |= 128 ;
411
- currentComputing.k = skipIndex + 1;
426
+ currentComputing.l |= 128 ;
427
+ currentComputing.q = skipIndex + 1;
412
428
  }
413
- let flags = self.g;
414
- const sourcesArray = self.h;
429
+ let flags = self.l;
430
+ const sourcesArray = self.m;
431
+
415
432
 
416
433
  if ((flags & 4 ) !== 0) {
417
434
  throw new Error(cycleMessage);
418
435
  }
419
436
 
437
+
420
438
  const hasCached = (flags & (16 | 32 )) !== 0;
421
439
 
422
440
  checkCache: if ((flags & (1 | 2 )) === 0 && hasCached) {
423
441
 
424
- if (self.f === globalVersion) {
442
+ if (self.k === globalVersion) {
425
443
  if ((flags & 32 ) !== 0) {
426
- throw self.l;
444
+ throw self.r;
427
445
  }
428
- return self.l;
446
+ return self.r;
429
447
  }
430
448
 
449
+
431
450
  if ((flags & 64 ) === 0) {
432
451
  let sourceChanged = false;
433
452
 
@@ -437,19 +456,19 @@ function computedRead(self) {
437
456
  try {
438
457
  for (let i = 0, len = sourcesArray.length; i < len; ++i) {
439
458
  const source = sourcesArray[i];
440
- const sourceNode = source.d;
459
+ const sourceNode = source.g;
441
460
  if (sourceNode === undefined) {
442
461
 
443
- const currentDepsVersion = source.c.a;
444
- if (source.a !== currentDepsVersion) {
462
+ const currentDepsVersion = source.f.c;
463
+ if (source.c !== currentDepsVersion) {
445
464
 
446
- const storedValue = source.e;
465
+ const storedValue = source.h;
447
466
  const storedType = typeof storedValue;
448
467
  if (storedValue === null || (storedType !== 'object' && storedType !== 'function')) {
449
- const currentValue = source.b();
468
+ const currentValue = source.d();
450
469
  if (Object.is(currentValue, storedValue)) {
451
470
 
452
- source.a = currentDepsVersion;
471
+ source.c = currentDepsVersion;
453
472
  continue;
454
473
  }
455
474
  }
@@ -468,7 +487,7 @@ function computedRead(self) {
468
487
  sourceChanged = true;
469
488
  break;
470
489
  }
471
- if (source.a !== sourceNode.a) {
490
+ if (source.c !== sourceNode.c) {
472
491
  sourceChanged = true;
473
492
  break;
474
493
  }
@@ -480,18 +499,21 @@ function computedRead(self) {
480
499
  }
481
500
  if (sourceChanged) {
482
501
 
483
- self.g = flags |= 1 ;
502
+ self.l = flags |= 1 ;
484
503
  break checkCache;
485
504
  }
486
505
 
487
- self.f = globalVersion;
506
+ self.k = globalVersion;
488
507
  if ((flags & 32 ) !== 0) {
489
- throw self.l;
508
+ throw self.r;
490
509
  }
491
- return self.l;
510
+ return self.r;
492
511
  }
493
512
  }
494
513
 
514
+
515
+
516
+
495
517
  if ((flags & (1 | 2 | 128 )) === (2 | 128 ) && hasCached) {
496
518
  if (checkSources(sourcesArray)) {
497
519
 
@@ -499,69 +521,74 @@ function computedRead(self) {
499
521
  }
500
522
  else {
501
523
 
502
- self.g = flags & -3 ;
524
+ self.l = flags & -3 ;
503
525
 
504
- self.f = globalVersion;
526
+ self.k = globalVersion;
505
527
  if ((flags & 32 ) !== 0) {
506
- throw self.l;
528
+ throw self.r;
507
529
  }
508
- return self.l;
530
+ return self.r;
509
531
  }
510
532
  }
511
533
 
534
+
512
535
  if ((flags & (1 | 2 )) !== 0) {
513
536
  const wasDirty = (flags & 1 ) !== 0;
514
537
  runWithTracking(self, () => {
515
538
  try {
516
- const newValue = self.j();
539
+ const newValue = self.o();
517
540
 
518
- const changed = (flags & 16 ) === 0 || !self.m(self.l, newValue);
541
+ const changed = (flags & 16 ) === 0 || !self.s(self.r, newValue);
519
542
  if (changed) {
520
- self.l = newValue;
543
+ self.r = newValue;
544
+
545
+ ++self.c;
546
+ self.l = (self.l | 16 ) & ~32 ;
521
547
 
522
- ++self.a;
523
- self.g = (self.g | 16 ) & ~32 ;
524
548
 
525
- for (const dep of self.i) {
526
- const depFlags = dep.g;
549
+ for (const dep of self.n) {
550
+ const depFlags = dep.l;
527
551
  if ((depFlags & (4 | 1 | 2 )) === 2 ) {
528
- dep.g = depFlags | 1 ;
552
+ dep.l = depFlags | 1 ;
529
553
  }
530
554
  }
531
555
  }
532
556
  else if (wasDirty) {
533
- self.g |= 16 ;
557
+ self.l |= 16 ;
534
558
  }
535
559
 
536
- self.f = globalVersion;
560
+ self.k = globalVersion;
537
561
  }
538
562
  catch (e) {
539
563
 
540
- ++self.a;
541
- self.l = e;
542
- self.g = (self.g & ~16 ) | 32 ;
543
- self.f = globalVersion;
564
+
565
+
566
+
567
+ ++self.c;
568
+ self.r = e;
569
+ self.l = (self.l & ~16 ) | 32 ;
570
+ self.k = globalVersion;
544
571
  }
545
572
  });
546
573
  }
547
574
 
548
- if ((self.g & 32 ) !== 0) {
549
- throw self.l;
575
+ if ((self.l & 32 ) !== 0) {
576
+ throw self.r;
550
577
  }
551
- return self.l;
578
+ return self.r;
552
579
  }
553
580
 
554
581
  const computed = (getter, equals = Object.is) => {
555
582
  const node = {
556
- h: [],
557
- i: new DepsSet(noopGetter),
558
- g: 1 ,
583
+ m: [],
584
+ n: new DepsSet(noopGetter),
585
+ l: 1 ,
586
+ q: 0,
587
+ c: 0,
588
+ r: undefined,
559
589
  k: 0,
560
- a: 0,
561
- l: undefined,
562
- f: 0,
563
- j: getter,
564
- m: equals,
590
+ o: getter,
591
+ s: equals,
565
592
  };
566
593
  return () => computedRead(node);
567
594
  };
@@ -580,38 +607,51 @@ const effect = (callback, eager = 0 ) => {
580
607
 
581
608
  warnIfNoActiveScope(activeScope);
582
609
 
610
+
583
611
  let node;
584
612
  const effectScope = activeScope;
585
613
 
614
+
615
+
586
616
  const runner = () => {
587
617
 
588
618
  if (disposed) {
589
619
  return;
590
620
  }
591
621
 
592
- const flags = node.g;
622
+ const flags = node.l;
593
623
  if ((flags & 4 ) !== 0) {
594
624
  throw new Error(cycleMessage);
595
625
  }
596
626
 
627
+
628
+
629
+
630
+
631
+
597
632
  if ((flags & (1 | 2 | 128 )) === (2 | 128 )) {
598
633
 
599
- if (!checkSources(node.h)) {
600
- node.g = flags & -3 ;
634
+
635
+
636
+ if (!checkSources(node.m)) {
637
+ node.l = flags & -3 ;
601
638
  return;
602
639
  }
603
640
  }
604
641
  const previousScope = activeScope;
605
642
  setActiveScope(effectScope);
606
643
 
644
+
645
+
607
646
  try {
608
647
  runWithTracking(node, () => {
609
648
 
610
- if (typeof node.l === 'function') {
611
- node.l();
649
+ if (typeof node.r === 'function') {
650
+ node.r();
612
651
  }
613
652
 
614
- node.l = callback();
653
+
654
+ node.r = callback();
615
655
  });
616
656
  }
617
657
  finally {
@@ -619,18 +659,25 @@ const effect = (callback, eager = 0 ) => {
619
659
  }
620
660
  };
621
661
 
662
+
663
+
664
+
665
+
666
+
667
+
668
+
622
669
  node = {
623
- h: [],
624
- i: new DepsSet(noopGetter),
625
- g: 1 | 8 ,
626
- k: 0,
627
- a: 0,
628
- l: undefined,
629
- f: ++effectCreationCounter,
630
- j: runner,
631
- m: Object.is,
670
+ m: [],
671
+ n: new DepsSet(noopGetter),
672
+ l: 1 | 8 ,
673
+ q: 0,
674
+ c: 0,
675
+ r: undefined,
676
+ k: ++effectCreationCounter,
677
+ o: runner,
678
+ s: Object.is,
632
679
  };
633
- const effectId = node.f;
680
+ const effectId = node.k;
634
681
  const dispose = () => {
635
682
 
636
683
  if (!disposed) {
@@ -639,16 +686,19 @@ const effect = (callback, eager = 0 ) => {
639
686
 
640
687
  unregisterEffect(gcToken);
641
688
 
642
- if (typeof node.l === 'function') {
643
- node.l();
689
+ if (typeof node.r === 'function') {
690
+ node.r();
644
691
  }
645
692
  clearSources(node);
646
693
  }
647
694
  };
695
+ const effects = effectScope?.[trackSymbol];
696
+ const effectIndex = effects ? effects.push(dispose) - 1 : -1;
697
+
698
+
699
+
700
+
648
701
 
649
- if (effectScope) {
650
- effectScope[trackSymbol](dispose);
651
- }
652
702
 
653
703
  if (eager === 0 ) {
654
704
  batchedAddNew(node, effectId);
@@ -656,7 +706,22 @@ const effect = (callback, eager = 0 ) => {
656
706
  }
657
707
  else {
658
708
 
659
- runner();
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+ try {
717
+ runner();
718
+ }
719
+ catch (error) {
720
+ if (!disposed && effects)
721
+ effects[effectIndex] = undefined;
722
+ dispose();
723
+ throw error;
724
+ }
660
725
  }
661
726
  return dispose;
662
727
  };
@@ -668,6 +733,7 @@ const scope = (callback, parent = activeScope) => {
668
733
  let disposed = false;
669
734
  let myIndex = -1;
670
735
 
736
+
671
737
  const onDispose = cleanup => {
672
738
  if (disposed) {
673
739
  return;
@@ -711,7 +777,7 @@ const scope = (callback, parent = activeScope) => {
711
777
  return ctx;
712
778
  });
713
779
 
714
- ctx[trackSymbol] = (dispose) => effects.push(dispose);
780
+ ctx[trackSymbol] = effects;
715
781
  ctx[childrenSymbol] = children;
716
782
  ctx[parentSymbol] = parent;
717
783
 
@@ -730,8 +796,11 @@ function signal(initialValue) {
730
796
  let value = initialValue;
731
797
  let deps;
732
798
 
799
+
733
800
  const read = () => {
734
801
 
802
+
803
+
735
804
  if (tracked && currentComputing !== undefined) {
736
805
 
737
806
  trackStateDependency((deps ??= new DepsSet(read)), value);
@@ -740,8 +809,11 @@ function signal(initialValue) {
740
809
 
741
810
  };
742
811
 
812
+
743
813
  read.set = (newValue) => {
744
814
 
815
+
816
+
745
817
  warnIfWriteInComputed('signal');
746
818
  if (!Object.is(value, newValue)) {
747
819
  value = newValue;
@@ -756,8 +828,11 @@ function signal(initialValue) {
756
828
 
757
829
  function state(object = {}) {
758
830
 
831
+
832
+
759
833
  const proxiesCache = new WeakMap();
760
834
 
835
+
761
836
  const notifyPropertyDependents = (target, property) => {
762
837
  const propsMap = target[propertyDepsSymbol];
763
838
  if (!propsMap)
@@ -819,6 +894,8 @@ function state(object = {}) {
819
894
  return propValue;
820
895
  }
821
896
 
897
+
898
+
822
899
  if (propertyType === 'function') {
823
900
 
824
901
  if (methodCache === undefined) {
@@ -835,6 +912,8 @@ function state(object = {}) {
835
912
  }
836
913
  const result = method.apply(target, args);
837
914
 
915
+
916
+
838
917
  if (currentComputing === undefined) {
839
918
  const propsMap = target[propertyDepsSymbol];
840
919
  if (propsMap === undefined)
@@ -844,6 +923,7 @@ function state(object = {}) {
844
923
  markDependents(deps, false);
845
924
  }
846
925
 
926
+
847
927
  scheduleFlush();
848
928
  }
849
929
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "name": "@slimlib/store",
5
5
  "description": "Simple Proxy-based store for SPA",
6
6
  "license": "MIT",