@rlabs-inc/signals 1.2.1 → 1.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.
- package/dist/collections/map.d.ts.map +1 -1
- package/dist/collections/set.d.ts.map +1 -1
- package/dist/deep/proxy.d.ts.map +1 -1
- package/dist/index.js +74 -5
- package/dist/index.mjs +74 -5
- package/dist/primitives/bind.d.ts.map +1 -1
- package/dist/primitives/derived.d.ts.map +1 -1
- package/dist/primitives/signal.d.ts +5 -0
- package/dist/primitives/signal.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/collections/map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/collections/map.ts"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;;gBAUlC,OAAO,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI;IAmCtD,IAAI,IAAI,IAAI,MAAM,CAGjB;IAMD,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAwBpB,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IA0B1B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAsC3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAwBvB,KAAK,IAAI,IAAI;IAmBb,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAKtB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAKxB,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAK9B,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAKxF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAGzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/collections/set.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/collections/set.ts"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,CAAC;;gBAU5B,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAmCvC,IAAI,IAAI,IAAI,MAAM,CAGjB;IAMD,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IA0BrB,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAmBlB,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAuBxB,KAAK,IAAI,IAAI;IAmBb,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAKtB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAKxB,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAK9B,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAKxF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC;CAGpC"}
|
package/dist/deep/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/deep/proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/deep/proxy.ts"],"names":[],"mappings":"AA8EA;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CA8PnD;AAMD;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAKpC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
package/dist/index.js
CHANGED
|
@@ -565,6 +565,7 @@ function updateReaction(reaction) {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
// src/primitives/signal.ts
|
|
568
|
+
var SOURCE_SYMBOL = Symbol("signal.source");
|
|
568
569
|
function source(initialValue, options) {
|
|
569
570
|
return {
|
|
570
571
|
f: 0,
|
|
@@ -578,9 +579,13 @@ function source(initialValue, options) {
|
|
|
578
579
|
function mutableSource(initialValue) {
|
|
579
580
|
return source(initialValue, { equals: safeEquals });
|
|
580
581
|
}
|
|
582
|
+
var signalCleanup = new FinalizationRegistry((src) => {
|
|
583
|
+
src.reactions = null;
|
|
584
|
+
});
|
|
581
585
|
function signal(initialValue, options) {
|
|
582
586
|
const src = source(initialValue, options);
|
|
583
|
-
|
|
587
|
+
const sig = {
|
|
588
|
+
[SOURCE_SYMBOL]: src,
|
|
584
589
|
get value() {
|
|
585
590
|
return get(src);
|
|
586
591
|
},
|
|
@@ -588,6 +593,11 @@ function signal(initialValue, options) {
|
|
|
588
593
|
set(src, newValue);
|
|
589
594
|
}
|
|
590
595
|
};
|
|
596
|
+
signalCleanup.register(sig, src);
|
|
597
|
+
return sig;
|
|
598
|
+
}
|
|
599
|
+
function getSource(sig) {
|
|
600
|
+
return sig[SOURCE_SYMBOL];
|
|
591
601
|
}
|
|
592
602
|
var proxyFn = null;
|
|
593
603
|
function setProxyFn(fn) {
|
|
@@ -604,6 +614,13 @@ function stateRaw(initialValue) {
|
|
|
604
614
|
}
|
|
605
615
|
|
|
606
616
|
// src/deep/proxy.ts
|
|
617
|
+
var proxyCleanup = new FinalizationRegistry((data) => {
|
|
618
|
+
data.version.reactions = null;
|
|
619
|
+
for (const src of data.sources.values()) {
|
|
620
|
+
src.reactions = null;
|
|
621
|
+
}
|
|
622
|
+
data.sources.clear();
|
|
623
|
+
});
|
|
607
624
|
function shouldProxy(value) {
|
|
608
625
|
if (value === null || typeof value !== "object") {
|
|
609
626
|
return false;
|
|
@@ -641,7 +658,7 @@ function proxy(value) {
|
|
|
641
658
|
setActiveReaction(prevReaction);
|
|
642
659
|
}
|
|
643
660
|
};
|
|
644
|
-
const
|
|
661
|
+
const getSource2 = (prop, initialValue) => {
|
|
645
662
|
let s = sources.get(prop);
|
|
646
663
|
if (s === undefined) {
|
|
647
664
|
s = withParent(() => {
|
|
@@ -664,7 +681,7 @@ function proxy(value) {
|
|
|
664
681
|
return currentValue.bind(proxyObj);
|
|
665
682
|
}
|
|
666
683
|
if (exists || isWritable(target, prop)) {
|
|
667
|
-
const s =
|
|
684
|
+
const s = getSource2(prop, currentValue);
|
|
668
685
|
const val = get(s);
|
|
669
686
|
if (val === UNINITIALIZED) {
|
|
670
687
|
return;
|
|
@@ -764,6 +781,7 @@ function proxy(value) {
|
|
|
764
781
|
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
765
782
|
}
|
|
766
783
|
});
|
|
784
|
+
proxyCleanup.register(proxyObj, { sources, version });
|
|
767
785
|
return proxyObj;
|
|
768
786
|
}
|
|
769
787
|
function toRaw(value) {
|
|
@@ -776,6 +794,18 @@ function isReactive(value) {
|
|
|
776
794
|
return isProxy(value);
|
|
777
795
|
}
|
|
778
796
|
// src/primitives/derived.ts
|
|
797
|
+
var derivedCleanup = new FinalizationRegistry((d) => {
|
|
798
|
+
removeReactions(d, 0);
|
|
799
|
+
d.deps = null;
|
|
800
|
+
d.reactions = null;
|
|
801
|
+
const effects = d.effects;
|
|
802
|
+
if (effects !== null) {
|
|
803
|
+
d.effects = null;
|
|
804
|
+
for (let i = 0;i < effects.length; i++) {
|
|
805
|
+
destroyEffectImpl(effects[i]);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
});
|
|
779
809
|
function createDerived(fn, options) {
|
|
780
810
|
let flags = DERIVED | DIRTY;
|
|
781
811
|
const parentDerived = activeReaction !== null && (activeReaction.f & DERIVED) !== 0 ? activeReaction : null;
|
|
@@ -826,11 +856,13 @@ function destroyDerivedEffects(derived) {
|
|
|
826
856
|
}
|
|
827
857
|
function derived(fn, options) {
|
|
828
858
|
const d = createDerived(fn, options);
|
|
829
|
-
|
|
859
|
+
const wrapper = {
|
|
830
860
|
get value() {
|
|
831
861
|
return get(d);
|
|
832
862
|
}
|
|
833
863
|
};
|
|
864
|
+
derivedCleanup.register(wrapper, d);
|
|
865
|
+
return wrapper;
|
|
834
866
|
}
|
|
835
867
|
derived.by = derived;
|
|
836
868
|
function disconnectDerived(derived2) {
|
|
@@ -963,6 +995,9 @@ effect.tracking = function effectTracking() {
|
|
|
963
995
|
return activeEffect !== null;
|
|
964
996
|
};
|
|
965
997
|
// src/primitives/bind.ts
|
|
998
|
+
var bindingCleanup = new FinalizationRegistry((internalSource) => {
|
|
999
|
+
internalSource.reactions = null;
|
|
1000
|
+
});
|
|
966
1001
|
var BINDING_SYMBOL = Symbol("binding");
|
|
967
1002
|
function isBinding(value) {
|
|
968
1003
|
return value !== null && typeof value === "object" && BINDING_SYMBOL in value;
|
|
@@ -983,10 +1018,13 @@ function bind(source2) {
|
|
|
983
1018
|
};
|
|
984
1019
|
}
|
|
985
1020
|
let actualSource;
|
|
1021
|
+
let internalSource = null;
|
|
986
1022
|
if (isBinding(source2) || isSignal(source2)) {
|
|
987
1023
|
actualSource = source2;
|
|
988
1024
|
} else {
|
|
989
|
-
|
|
1025
|
+
const sig = signal(source2);
|
|
1026
|
+
actualSource = sig;
|
|
1027
|
+
internalSource = getSource(sig) ?? null;
|
|
990
1028
|
}
|
|
991
1029
|
const binding = {
|
|
992
1030
|
[BINDING_SYMBOL]: true,
|
|
@@ -997,6 +1035,9 @@ function bind(source2) {
|
|
|
997
1035
|
actualSource.value = v;
|
|
998
1036
|
}
|
|
999
1037
|
};
|
|
1038
|
+
if (internalSource !== null) {
|
|
1039
|
+
bindingCleanup.register(binding, internalSource);
|
|
1040
|
+
}
|
|
1000
1041
|
return binding;
|
|
1001
1042
|
}
|
|
1002
1043
|
function bindReadonly(source2) {
|
|
@@ -1044,6 +1085,15 @@ function untrack(fn) {
|
|
|
1044
1085
|
}
|
|
1045
1086
|
var peek = untrack;
|
|
1046
1087
|
// src/collections/map.ts
|
|
1088
|
+
var mapCleanup = new FinalizationRegistry((data) => {
|
|
1089
|
+
data.version.reactions = null;
|
|
1090
|
+
data.size.reactions = null;
|
|
1091
|
+
for (const sig of data.keySignals.values()) {
|
|
1092
|
+
sig.reactions = null;
|
|
1093
|
+
}
|
|
1094
|
+
data.keySignals.clear();
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1047
1097
|
class ReactiveMap extends Map {
|
|
1048
1098
|
#keySignals = new Map;
|
|
1049
1099
|
#version = source(0);
|
|
@@ -1051,6 +1101,11 @@ class ReactiveMap extends Map {
|
|
|
1051
1101
|
constructor(entries) {
|
|
1052
1102
|
super(entries);
|
|
1053
1103
|
this.#size = source(super.size);
|
|
1104
|
+
mapCleanup.register(this, {
|
|
1105
|
+
keySignals: this.#keySignals,
|
|
1106
|
+
version: this.#version,
|
|
1107
|
+
size: this.#size
|
|
1108
|
+
});
|
|
1054
1109
|
}
|
|
1055
1110
|
#getKeySignal(key) {
|
|
1056
1111
|
let sig = this.#keySignals.get(key);
|
|
@@ -1161,6 +1216,15 @@ class ReactiveMap extends Map {
|
|
|
1161
1216
|
}
|
|
1162
1217
|
}
|
|
1163
1218
|
// src/collections/set.ts
|
|
1219
|
+
var setCleanup = new FinalizationRegistry((data) => {
|
|
1220
|
+
data.version.reactions = null;
|
|
1221
|
+
data.size.reactions = null;
|
|
1222
|
+
for (const sig of data.itemSignals.values()) {
|
|
1223
|
+
sig.reactions = null;
|
|
1224
|
+
}
|
|
1225
|
+
data.itemSignals.clear();
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1164
1228
|
class ReactiveSet extends Set {
|
|
1165
1229
|
#itemSignals = new Map;
|
|
1166
1230
|
#version = source(0);
|
|
@@ -1168,6 +1232,11 @@ class ReactiveSet extends Set {
|
|
|
1168
1232
|
constructor(values) {
|
|
1169
1233
|
super(values);
|
|
1170
1234
|
this.#size = source(super.size);
|
|
1235
|
+
setCleanup.register(this, {
|
|
1236
|
+
itemSignals: this.#itemSignals,
|
|
1237
|
+
version: this.#version,
|
|
1238
|
+
size: this.#size
|
|
1239
|
+
});
|
|
1171
1240
|
}
|
|
1172
1241
|
#getItemSignal(item) {
|
|
1173
1242
|
let sig = this.#itemSignals.get(item);
|
package/dist/index.mjs
CHANGED
|
@@ -452,6 +452,7 @@ function updateReaction(reaction) {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
// src/primitives/signal.ts
|
|
455
|
+
var SOURCE_SYMBOL = Symbol("signal.source");
|
|
455
456
|
function source(initialValue, options) {
|
|
456
457
|
return {
|
|
457
458
|
f: 0,
|
|
@@ -465,9 +466,13 @@ function source(initialValue, options) {
|
|
|
465
466
|
function mutableSource(initialValue) {
|
|
466
467
|
return source(initialValue, { equals: safeEquals });
|
|
467
468
|
}
|
|
469
|
+
var signalCleanup = new FinalizationRegistry((src) => {
|
|
470
|
+
src.reactions = null;
|
|
471
|
+
});
|
|
468
472
|
function signal(initialValue, options) {
|
|
469
473
|
const src = source(initialValue, options);
|
|
470
|
-
|
|
474
|
+
const sig = {
|
|
475
|
+
[SOURCE_SYMBOL]: src,
|
|
471
476
|
get value() {
|
|
472
477
|
return get(src);
|
|
473
478
|
},
|
|
@@ -475,6 +480,11 @@ function signal(initialValue, options) {
|
|
|
475
480
|
set(src, newValue);
|
|
476
481
|
}
|
|
477
482
|
};
|
|
483
|
+
signalCleanup.register(sig, src);
|
|
484
|
+
return sig;
|
|
485
|
+
}
|
|
486
|
+
function getSource(sig) {
|
|
487
|
+
return sig[SOURCE_SYMBOL];
|
|
478
488
|
}
|
|
479
489
|
var proxyFn = null;
|
|
480
490
|
function setProxyFn(fn) {
|
|
@@ -491,6 +501,13 @@ function stateRaw(initialValue) {
|
|
|
491
501
|
}
|
|
492
502
|
|
|
493
503
|
// src/deep/proxy.ts
|
|
504
|
+
var proxyCleanup = new FinalizationRegistry((data) => {
|
|
505
|
+
data.version.reactions = null;
|
|
506
|
+
for (const src of data.sources.values()) {
|
|
507
|
+
src.reactions = null;
|
|
508
|
+
}
|
|
509
|
+
data.sources.clear();
|
|
510
|
+
});
|
|
494
511
|
function shouldProxy(value) {
|
|
495
512
|
if (value === null || typeof value !== "object") {
|
|
496
513
|
return false;
|
|
@@ -528,7 +545,7 @@ function proxy(value) {
|
|
|
528
545
|
setActiveReaction(prevReaction);
|
|
529
546
|
}
|
|
530
547
|
};
|
|
531
|
-
const
|
|
548
|
+
const getSource2 = (prop, initialValue) => {
|
|
532
549
|
let s = sources.get(prop);
|
|
533
550
|
if (s === undefined) {
|
|
534
551
|
s = withParent(() => {
|
|
@@ -551,7 +568,7 @@ function proxy(value) {
|
|
|
551
568
|
return currentValue.bind(proxyObj);
|
|
552
569
|
}
|
|
553
570
|
if (exists || isWritable(target, prop)) {
|
|
554
|
-
const s =
|
|
571
|
+
const s = getSource2(prop, currentValue);
|
|
555
572
|
const val = get(s);
|
|
556
573
|
if (val === UNINITIALIZED) {
|
|
557
574
|
return;
|
|
@@ -651,6 +668,7 @@ function proxy(value) {
|
|
|
651
668
|
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
652
669
|
}
|
|
653
670
|
});
|
|
671
|
+
proxyCleanup.register(proxyObj, { sources, version });
|
|
654
672
|
return proxyObj;
|
|
655
673
|
}
|
|
656
674
|
function toRaw(value) {
|
|
@@ -663,6 +681,18 @@ function isReactive(value) {
|
|
|
663
681
|
return isProxy(value);
|
|
664
682
|
}
|
|
665
683
|
// src/primitives/derived.ts
|
|
684
|
+
var derivedCleanup = new FinalizationRegistry((d) => {
|
|
685
|
+
removeReactions(d, 0);
|
|
686
|
+
d.deps = null;
|
|
687
|
+
d.reactions = null;
|
|
688
|
+
const effects = d.effects;
|
|
689
|
+
if (effects !== null) {
|
|
690
|
+
d.effects = null;
|
|
691
|
+
for (let i = 0;i < effects.length; i++) {
|
|
692
|
+
destroyEffectImpl(effects[i]);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
});
|
|
666
696
|
function createDerived(fn, options) {
|
|
667
697
|
let flags = DERIVED | DIRTY;
|
|
668
698
|
const parentDerived = activeReaction !== null && (activeReaction.f & DERIVED) !== 0 ? activeReaction : null;
|
|
@@ -713,11 +743,13 @@ function destroyDerivedEffects(derived) {
|
|
|
713
743
|
}
|
|
714
744
|
function derived(fn, options) {
|
|
715
745
|
const d = createDerived(fn, options);
|
|
716
|
-
|
|
746
|
+
const wrapper = {
|
|
717
747
|
get value() {
|
|
718
748
|
return get(d);
|
|
719
749
|
}
|
|
720
750
|
};
|
|
751
|
+
derivedCleanup.register(wrapper, d);
|
|
752
|
+
return wrapper;
|
|
721
753
|
}
|
|
722
754
|
derived.by = derived;
|
|
723
755
|
function disconnectDerived(derived2) {
|
|
@@ -850,6 +882,9 @@ effect.tracking = function effectTracking() {
|
|
|
850
882
|
return activeEffect !== null;
|
|
851
883
|
};
|
|
852
884
|
// src/primitives/bind.ts
|
|
885
|
+
var bindingCleanup = new FinalizationRegistry((internalSource) => {
|
|
886
|
+
internalSource.reactions = null;
|
|
887
|
+
});
|
|
853
888
|
var BINDING_SYMBOL = Symbol("binding");
|
|
854
889
|
function isBinding(value) {
|
|
855
890
|
return value !== null && typeof value === "object" && BINDING_SYMBOL in value;
|
|
@@ -870,10 +905,13 @@ function bind(source2) {
|
|
|
870
905
|
};
|
|
871
906
|
}
|
|
872
907
|
let actualSource;
|
|
908
|
+
let internalSource = null;
|
|
873
909
|
if (isBinding(source2) || isSignal(source2)) {
|
|
874
910
|
actualSource = source2;
|
|
875
911
|
} else {
|
|
876
|
-
|
|
912
|
+
const sig = signal(source2);
|
|
913
|
+
actualSource = sig;
|
|
914
|
+
internalSource = getSource(sig) ?? null;
|
|
877
915
|
}
|
|
878
916
|
const binding = {
|
|
879
917
|
[BINDING_SYMBOL]: true,
|
|
@@ -884,6 +922,9 @@ function bind(source2) {
|
|
|
884
922
|
actualSource.value = v;
|
|
885
923
|
}
|
|
886
924
|
};
|
|
925
|
+
if (internalSource !== null) {
|
|
926
|
+
bindingCleanup.register(binding, internalSource);
|
|
927
|
+
}
|
|
887
928
|
return binding;
|
|
888
929
|
}
|
|
889
930
|
function bindReadonly(source2) {
|
|
@@ -931,6 +972,15 @@ function untrack(fn) {
|
|
|
931
972
|
}
|
|
932
973
|
var peek = untrack;
|
|
933
974
|
// src/collections/map.ts
|
|
975
|
+
var mapCleanup = new FinalizationRegistry((data) => {
|
|
976
|
+
data.version.reactions = null;
|
|
977
|
+
data.size.reactions = null;
|
|
978
|
+
for (const sig of data.keySignals.values()) {
|
|
979
|
+
sig.reactions = null;
|
|
980
|
+
}
|
|
981
|
+
data.keySignals.clear();
|
|
982
|
+
});
|
|
983
|
+
|
|
934
984
|
class ReactiveMap extends Map {
|
|
935
985
|
#keySignals = new Map;
|
|
936
986
|
#version = source(0);
|
|
@@ -938,6 +988,11 @@ class ReactiveMap extends Map {
|
|
|
938
988
|
constructor(entries) {
|
|
939
989
|
super(entries);
|
|
940
990
|
this.#size = source(super.size);
|
|
991
|
+
mapCleanup.register(this, {
|
|
992
|
+
keySignals: this.#keySignals,
|
|
993
|
+
version: this.#version,
|
|
994
|
+
size: this.#size
|
|
995
|
+
});
|
|
941
996
|
}
|
|
942
997
|
#getKeySignal(key) {
|
|
943
998
|
let sig = this.#keySignals.get(key);
|
|
@@ -1048,6 +1103,15 @@ class ReactiveMap extends Map {
|
|
|
1048
1103
|
}
|
|
1049
1104
|
}
|
|
1050
1105
|
// src/collections/set.ts
|
|
1106
|
+
var setCleanup = new FinalizationRegistry((data) => {
|
|
1107
|
+
data.version.reactions = null;
|
|
1108
|
+
data.size.reactions = null;
|
|
1109
|
+
for (const sig of data.itemSignals.values()) {
|
|
1110
|
+
sig.reactions = null;
|
|
1111
|
+
}
|
|
1112
|
+
data.itemSignals.clear();
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1051
1115
|
class ReactiveSet extends Set {
|
|
1052
1116
|
#itemSignals = new Map;
|
|
1053
1117
|
#version = source(0);
|
|
@@ -1055,6 +1119,11 @@ class ReactiveSet extends Set {
|
|
|
1055
1119
|
constructor(values) {
|
|
1056
1120
|
super(values);
|
|
1057
1121
|
this.#size = source(super.size);
|
|
1122
|
+
setCleanup.register(this, {
|
|
1123
|
+
itemSignals: this.#itemSignals,
|
|
1124
|
+
version: this.#version,
|
|
1125
|
+
size: this.#size
|
|
1126
|
+
});
|
|
1058
1127
|
}
|
|
1059
1128
|
#getItemSignal(item) {
|
|
1060
1129
|
let sig = this.#itemSignals.get(item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/primitives/bind.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/primitives/bind.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAU,MAAM,kBAAkB,CAAA;AAqB9E;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,IAAI,KAAK,IAAI,CAAC,CAAA;IACd,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAClB;AAQD;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAEnE;AA0DD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAC9D,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;AACtE,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AACvD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;AACvE,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;AAC5D,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AA2D9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAQ1F;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAKvE;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvD,OAAO,EAAE,CAAC,GACT;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAU1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived.d.ts","sourceRoot":"","sources":["../../src/primitives/derived.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"derived.d.ts","sourceRoot":"","sources":["../../src/primitives/derived.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AA+C9E,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CACnB;AAMD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA4BrF;AAMD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAQxD;AAMD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAc1D;AAYD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAEzE;AAmBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAarF;yBAbe,OAAO;;;AAyBvB;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAKxD"}
|
|
@@ -27,6 +27,11 @@ export interface SignalOptions<T> {
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare function signal<T>(initialValue: T, options?: SignalOptions<T>): WritableSignal<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the internal Source from a signal wrapper.
|
|
32
|
+
* Used internally for cleanup registration.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSource<T>(sig: WritableSignal<T>): Source<T> | undefined;
|
|
30
35
|
export declare function setProxyFn(fn: <T extends object>(value: T) => T): void;
|
|
31
36
|
/**
|
|
32
37
|
* Create a deeply reactive state object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/primitives/signal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/primitives/signal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAetE,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAShF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAE3D;AAMD,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CACnB;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAiBxF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAE1E;AASD,wBAAgB,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAEtE;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAK1D;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAE9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rlabs-inc/signals",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Production-grade fine-grained reactivity for TypeScript. A complete standalone mirror of Svelte 5's reactivity system - signals, effects, derived values, deep reactivity, reactive collections, and reactive bindings.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|