atom.io 0.6.6 → 0.6.8
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/index.d.mts +34 -25
- package/dist/index.d.ts +34 -25
- package/dist/index.js +94 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -105
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.d.mts +272 -0
- package/introspection/dist/index.d.ts +272 -0
- package/introspection/dist/index.js +41 -3
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +41 -3
- package/introspection/dist/index.mjs.map +1 -1
- package/json/dist/index.d.mts +5 -7
- package/json/dist/index.d.ts +5 -7
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs.map +1 -1
- package/package.json +22 -14
- package/react-devtools/dist/index.css +9 -1
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +22 -25
- package/react-devtools/dist/index.d.ts +22 -25
- package/react-devtools/dist/index.js +845 -326
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +830 -306
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +6 -8
- package/realtime/dist/index.d.ts +6 -8
- package/realtime/dist/index.js +0 -1
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +0 -1
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +11 -13
- package/realtime-react/dist/index.d.ts +11 -13
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs.map +1 -1
- package/src/atom.ts +4 -4
- package/src/index.ts +1 -1
- package/src/internal/atom-internal.ts +5 -6
- package/src/internal/families-internal.ts +23 -20
- package/src/internal/get.ts +7 -9
- package/src/internal/index.ts +1 -1
- package/src/internal/operation.ts +14 -21
- package/src/internal/selector/create-read-write-selector.ts +11 -5
- package/src/internal/selector/create-readonly-selector.ts +4 -8
- package/src/internal/selector-internal.ts +1 -3
- package/src/internal/set.ts +1 -4
- package/src/internal/store.ts +19 -22
- package/src/internal/subscribe-internal.ts +7 -1
- package/src/internal/time-travel-internal.ts +4 -4
- package/src/internal/timeline/add-atom-to-timeline.ts +2 -2
- package/src/internal/timeline-internal.ts +3 -5
- package/src/internal/transaction/apply-transaction.ts +9 -6
- package/src/internal/transaction/build-transaction.ts +6 -6
- package/src/internal/transaction-internal.ts +1 -7
- package/src/introspection/attach-timeline-family.ts +14 -4
- package/src/introspection/attach-transaction-logs.ts +1 -1
- package/src/json/select-json.ts +1 -1
- package/src/react-devtools/AtomIODevtools.tsx +1 -2
- package/src/react-devtools/StateEditor.tsx +5 -1
- package/src/react-devtools/StateIndex.tsx +4 -1
- package/src/react-devtools/devtools.scss +0 -1
- package/src/react-explorer/AtomIOExplorer.tsx +3 -3
- package/src/realtime/hook-composition/expose-family.ts +2 -2
- package/src/realtime/hook-composition/expose-single.ts +1 -1
- package/src/realtime/hook-composition/receive-state.ts +1 -1
- package/src/realtime-react/realtime-hooks.ts +4 -4
- package/src/realtime-react/use-pull-family-member.ts +2 -2
- package/src/realtime-react/use-pull-family.ts +2 -2
- package/src/realtime-react/use-pull.ts +3 -1
- package/src/realtime-react/use-push.ts +3 -1
- package/src/selector.ts +14 -12
- package/src/subscribe.ts +1 -1
- package/src/tracker/index.ts +3 -0
- package/src/tracker/tracker.ts +61 -0
- package/src/web-effects/storage.ts +1 -1
- package/src/internal/subject.ts +0 -24
package/dist/index.mjs
CHANGED
|
@@ -97,21 +97,17 @@ __export(internal_exports, {
|
|
|
97
97
|
withdraw: () => withdraw
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
// src/internal/atom-internal.ts
|
|
101
|
-
import HAMT5 from "hamt_plus";
|
|
102
|
-
|
|
103
100
|
// src/internal/get.ts
|
|
104
|
-
import HAMT from "hamt_plus";
|
|
105
101
|
var computeSelectorState = (selector2) => selector2.get();
|
|
106
102
|
function lookup(key, store) {
|
|
107
103
|
const core = target(store);
|
|
108
|
-
const type =
|
|
104
|
+
const type = core.atoms.has(key) ? `atom` : core.selectors.has(key) ? `selector` : `readonly_selector`;
|
|
109
105
|
return { key, type };
|
|
110
106
|
}
|
|
111
107
|
function withdraw(token, store) {
|
|
112
108
|
var _a, _b, _c, _d, _e;
|
|
113
109
|
const core = target(store);
|
|
114
|
-
return (_e = (_d = (_c = (_b = (_a =
|
|
110
|
+
return (_e = (_d = (_c = (_b = (_a = core.atoms.get(token.key)) != null ? _a : core.selectors.get(token.key)) != null ? _b : core.readonlySelectors.get(token.key)) != null ? _c : core.transactions.get(token.key)) != null ? _d : core.timelines.get(token.key)) != null ? _e : null;
|
|
115
111
|
}
|
|
116
112
|
function deposit(state) {
|
|
117
113
|
return __spreadValues({
|
|
@@ -154,12 +150,6 @@ var isSelectorDefault = (key, store = IMPLICIT.STORE) => {
|
|
|
154
150
|
return roots.every((root) => isAtomDefault(root.key, store));
|
|
155
151
|
};
|
|
156
152
|
|
|
157
|
-
// src/internal/operation.ts
|
|
158
|
-
import HAMT3 from "hamt_plus";
|
|
159
|
-
|
|
160
|
-
// src/internal/store.ts
|
|
161
|
-
import HAMT2 from "hamt_plus";
|
|
162
|
-
|
|
163
153
|
// ../anvl/src/function/index.ts
|
|
164
154
|
var doNothing = () => void 0;
|
|
165
155
|
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
|
|
@@ -612,17 +602,17 @@ var Join = class _Join {
|
|
|
612
602
|
// src/internal/store.ts
|
|
613
603
|
var createStore = (name, store = null) => {
|
|
614
604
|
var _a;
|
|
615
|
-
const
|
|
605
|
+
const created = __spreadProps(__spreadValues({}, store != null ? store : (() => ({
|
|
616
606
|
atomsThatAreDefault: /* @__PURE__ */ new Set(),
|
|
617
607
|
selectorAtoms: new Join({ relationType: `n:n` }).from(`selectorKey`).to(`atomKey`),
|
|
618
|
-
selectorGraph: new Join({ relationType: `n:n` })
|
|
619
|
-
valueMap: HAMT2.make()
|
|
608
|
+
selectorGraph: new Join({ relationType: `n:n` })
|
|
620
609
|
}))()), {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
610
|
+
valueMap: new Map(store == null ? void 0 : store.valueMap),
|
|
611
|
+
atoms: /* @__PURE__ */ new Map(),
|
|
612
|
+
readonlySelectors: /* @__PURE__ */ new Map(),
|
|
613
|
+
selectors: /* @__PURE__ */ new Map(),
|
|
614
|
+
transactions: /* @__PURE__ */ new Map(),
|
|
615
|
+
timelines: /* @__PURE__ */ new Map(),
|
|
626
616
|
timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
|
|
627
617
|
subject: {
|
|
628
618
|
atomCreation: new Subject(),
|
|
@@ -648,21 +638,21 @@ var createStore = (name, store = null) => {
|
|
|
648
638
|
});
|
|
649
639
|
store == null ? void 0 : store.atoms.forEach((atom2) => {
|
|
650
640
|
const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
|
|
651
|
-
|
|
641
|
+
created.atoms.set(atom2.key, copiedAtom);
|
|
652
642
|
});
|
|
653
643
|
store == null ? void 0 : store.readonlySelectors.forEach((selector2) => {
|
|
654
|
-
selector2.install(
|
|
644
|
+
selector2.install(created);
|
|
655
645
|
});
|
|
656
646
|
store == null ? void 0 : store.selectors.forEach((selector2) => {
|
|
657
|
-
selector2.install(
|
|
647
|
+
selector2.install(created);
|
|
658
648
|
});
|
|
659
649
|
store == null ? void 0 : store.transactions.forEach((tx) => {
|
|
660
|
-
tx.install(
|
|
650
|
+
tx.install(created);
|
|
661
651
|
});
|
|
662
652
|
store == null ? void 0 : store.timelines.forEach((timeline2) => {
|
|
663
|
-
timeline2.install(
|
|
653
|
+
timeline2.install(created);
|
|
664
654
|
});
|
|
665
|
-
return
|
|
655
|
+
return created;
|
|
666
656
|
};
|
|
667
657
|
var IMPLICIT = {
|
|
668
658
|
STORE_INTERNAL: void 0,
|
|
@@ -690,7 +680,7 @@ var openOperation = (token, store) => {
|
|
|
690
680
|
core.operation = {
|
|
691
681
|
open: true,
|
|
692
682
|
done: /* @__PURE__ */ new Set(),
|
|
693
|
-
prev: store.valueMap,
|
|
683
|
+
prev: new Map(store.valueMap),
|
|
694
684
|
time: Date.now(),
|
|
695
685
|
token
|
|
696
686
|
};
|
|
@@ -734,43 +724,38 @@ var recallState = (state, store = IMPLICIT.STORE) => {
|
|
|
734
724
|
(_a = store.config.logger) == null ? void 0 : _a.warn(
|
|
735
725
|
`recall called outside of an operation. This is probably a bug.`
|
|
736
726
|
);
|
|
737
|
-
return
|
|
727
|
+
return core.valueMap.get(state.key);
|
|
738
728
|
}
|
|
739
|
-
return
|
|
729
|
+
return core.operation.prev.get(state.key);
|
|
740
730
|
};
|
|
741
731
|
var cacheValue = (key, value, store = IMPLICIT.STORE) => {
|
|
742
732
|
const core = target(store);
|
|
743
|
-
core.valueMap
|
|
733
|
+
core.valueMap.set(key, value);
|
|
744
734
|
};
|
|
745
735
|
var evictCachedValue = (key, store = IMPLICIT.STORE) => {
|
|
746
736
|
const core = target(store);
|
|
747
|
-
core.valueMap
|
|
737
|
+
core.valueMap.delete(key);
|
|
748
738
|
};
|
|
749
|
-
var readCachedValue = (key, store = IMPLICIT.STORE) =>
|
|
750
|
-
var isValueCached = (key, store = IMPLICIT.STORE) =>
|
|
739
|
+
var readCachedValue = (key, store = IMPLICIT.STORE) => target(store).valueMap.get(key);
|
|
740
|
+
var isValueCached = (key, store = IMPLICIT.STORE) => target(store).valueMap.has(key);
|
|
751
741
|
var storeAtom = (atom2, store = IMPLICIT.STORE) => {
|
|
752
742
|
const core = target(store);
|
|
753
|
-
core.atoms
|
|
743
|
+
core.atoms.set(atom2.key, atom2);
|
|
754
744
|
};
|
|
755
745
|
var storeSelector = (selector2, store = IMPLICIT.STORE) => {
|
|
756
746
|
const core = target(store);
|
|
757
|
-
core.selectors
|
|
747
|
+
core.selectors.set(selector2.key, selector2);
|
|
758
748
|
};
|
|
759
749
|
var storeReadonlySelector = (selector2, store = IMPLICIT.STORE) => {
|
|
760
750
|
const core = target(store);
|
|
761
|
-
core.readonlySelectors
|
|
762
|
-
selector2.key,
|
|
763
|
-
selector2,
|
|
764
|
-
core.readonlySelectors
|
|
765
|
-
);
|
|
751
|
+
core.readonlySelectors.set(selector2.key, selector2);
|
|
766
752
|
};
|
|
767
753
|
var hasKeyBeenUsed = (key, store = IMPLICIT.STORE) => {
|
|
768
754
|
const core = target(store);
|
|
769
|
-
return
|
|
755
|
+
return core.atoms.has(key) || core.selectors.has(key) || core.readonlySelectors.has(key);
|
|
770
756
|
};
|
|
771
757
|
|
|
772
758
|
// src/internal/transaction-internal.ts
|
|
773
|
-
import HAMT4 from "hamt_plus";
|
|
774
759
|
function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
775
760
|
const newTransaction = {
|
|
776
761
|
key: options.key,
|
|
@@ -798,11 +783,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
798
783
|
subject: new Subject()
|
|
799
784
|
};
|
|
800
785
|
const core = target(store);
|
|
801
|
-
core.transactions
|
|
802
|
-
newTransaction.key,
|
|
803
|
-
newTransaction,
|
|
804
|
-
core.transactions
|
|
805
|
-
);
|
|
786
|
+
core.transactions.set(newTransaction.key, newTransaction);
|
|
806
787
|
const token = deposit(newTransaction);
|
|
807
788
|
store.subject.transactionCreation.next(token);
|
|
808
789
|
return token;
|
|
@@ -813,12 +794,13 @@ var target = (store = IMPLICIT.STORE) => store.transactionStatus.phase === `buil
|
|
|
813
794
|
function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
814
795
|
var _a, _b, _c;
|
|
815
796
|
const core = target(store);
|
|
816
|
-
|
|
797
|
+
const existing = core.atoms.get(options.key);
|
|
798
|
+
if (existing) {
|
|
817
799
|
(_b = (_a = store.config.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(
|
|
818
800
|
_a,
|
|
819
801
|
`Key "${options.key}" already exists in the store.`
|
|
820
802
|
);
|
|
821
|
-
return deposit(
|
|
803
|
+
return deposit(existing);
|
|
822
804
|
}
|
|
823
805
|
const subject = new Subject();
|
|
824
806
|
const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
@@ -826,7 +808,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
826
808
|
type: `atom`
|
|
827
809
|
}), family && { family });
|
|
828
810
|
const initialValue = options.default instanceof Function ? options.default() : options.default;
|
|
829
|
-
core.atoms
|
|
811
|
+
core.atoms.set(newAtom.key, newAtom);
|
|
830
812
|
markAtomAsDefault(options.key, store);
|
|
831
813
|
cacheValue(options.key, initialValue, store);
|
|
832
814
|
const token = deposit(newAtom);
|
|
@@ -841,7 +823,6 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
841
823
|
}
|
|
842
824
|
|
|
843
825
|
// ../anvl/src/json/index.ts
|
|
844
|
-
import { pipe as pipe6 } from "fp-ts/function";
|
|
845
826
|
var stringifyJson = (json) => JSON.stringify(json);
|
|
846
827
|
|
|
847
828
|
// src/internal/families-internal.ts
|
|
@@ -849,20 +830,23 @@ function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
849
830
|
const subject = new Subject();
|
|
850
831
|
return Object.assign(
|
|
851
832
|
(key) => {
|
|
852
|
-
var _a;
|
|
853
833
|
const subKey = stringifyJson(key);
|
|
854
834
|
const family = { key: options.key, subKey };
|
|
855
835
|
const fullKey = `${options.key}(${subKey})`;
|
|
856
836
|
const existing = withdraw({ key: fullKey, type: `atom` }, store);
|
|
857
|
-
|
|
858
|
-
|
|
837
|
+
let token;
|
|
838
|
+
if (existing) {
|
|
839
|
+
token = deposit(existing);
|
|
840
|
+
} else {
|
|
841
|
+
const individualOptions = {
|
|
859
842
|
key: fullKey,
|
|
860
|
-
default: options.default instanceof Function ? options.default(key) : options.default
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
843
|
+
default: options.default instanceof Function ? options.default(key) : options.default
|
|
844
|
+
};
|
|
845
|
+
if (options.effects) {
|
|
846
|
+
individualOptions.effects = options.effects(key);
|
|
847
|
+
}
|
|
848
|
+
token = atom__INTERNAL(individualOptions, family, store);
|
|
849
|
+
}
|
|
866
850
|
subject.next(token);
|
|
867
851
|
return token;
|
|
868
852
|
},
|
|
@@ -936,11 +920,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
936
920
|
);
|
|
937
921
|
}
|
|
938
922
|
|
|
939
|
-
// src/internal/selector-internal.ts
|
|
940
|
-
import HAMT9 from "hamt_plus";
|
|
941
|
-
|
|
942
923
|
// src/internal/selector/create-read-write-selector.ts
|
|
943
|
-
import HAMT6 from "hamt_plus";
|
|
944
924
|
var createReadWriteSelector = (options, family, store, core) => {
|
|
945
925
|
var _a;
|
|
946
926
|
const subject = new Subject();
|
|
@@ -952,8 +932,14 @@ var createReadWriteSelector = (options, family, store, core) => {
|
|
|
952
932
|
};
|
|
953
933
|
const setSelf = (next) => {
|
|
954
934
|
var _a2;
|
|
955
|
-
(_a2 = store.config.logger) == null ? void 0 : _a2.info(` <- "${options.key}" became`, next);
|
|
956
935
|
const oldValue = getSelf();
|
|
936
|
+
(_a2 = store.config.logger) == null ? void 0 : _a2.info(
|
|
937
|
+
` <- "${options.key}" went (`,
|
|
938
|
+
oldValue,
|
|
939
|
+
`->`,
|
|
940
|
+
next,
|
|
941
|
+
`)`
|
|
942
|
+
);
|
|
957
943
|
const newValue = become(next)(oldValue);
|
|
958
944
|
cacheValue(options.key, newValue, store);
|
|
959
945
|
markDone(options.key, store);
|
|
@@ -969,21 +955,20 @@ var createReadWriteSelector = (options, family, store, core) => {
|
|
|
969
955
|
set: setSelf,
|
|
970
956
|
type: `selector`
|
|
971
957
|
}), family && { family });
|
|
972
|
-
core.selectors
|
|
958
|
+
core.selectors.set(options.key, mySelector);
|
|
973
959
|
const initialValue = getSelf();
|
|
974
960
|
(_a = store.config.logger) == null ? void 0 : _a.info(` \u2728 "${options.key}" =`, initialValue);
|
|
975
961
|
const token = {
|
|
976
962
|
key: options.key,
|
|
977
|
-
type: `selector
|
|
978
|
-
family
|
|
963
|
+
type: `selector`
|
|
979
964
|
};
|
|
965
|
+
if (family) {
|
|
966
|
+
token.family = family;
|
|
967
|
+
}
|
|
980
968
|
store.subject.selectorCreation.next(token);
|
|
981
969
|
return token;
|
|
982
970
|
};
|
|
983
971
|
|
|
984
|
-
// src/internal/selector/create-readonly-selector.ts
|
|
985
|
-
import HAMT8 from "hamt_plus";
|
|
986
|
-
|
|
987
972
|
// src/internal/selector/lookup-selector-sources.ts
|
|
988
973
|
var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
|
|
989
974
|
|
|
@@ -1043,7 +1028,6 @@ var updateSelectorAtoms = (selectorKey, dependency, store) => {
|
|
|
1043
1028
|
};
|
|
1044
1029
|
|
|
1045
1030
|
// src/internal/set.ts
|
|
1046
|
-
import HAMT7 from "hamt_plus";
|
|
1047
1031
|
var evictDownStream = (state, store = IMPLICIT.STORE) => {
|
|
1048
1032
|
var _a, _b;
|
|
1049
1033
|
const core = target(store);
|
|
@@ -1062,7 +1046,7 @@ var evictDownStream = (state, store = IMPLICIT.STORE) => {
|
|
|
1062
1046
|
(_a2 = store.config.logger) == null ? void 0 : _a2.info(` || ${stateKey} already done`);
|
|
1063
1047
|
return;
|
|
1064
1048
|
}
|
|
1065
|
-
const state2 = (_b2 =
|
|
1049
|
+
const state2 = (_b2 = core.selectors.get(stateKey)) != null ? _b2 : core.readonlySelectors.get(stateKey);
|
|
1066
1050
|
if (!state2) {
|
|
1067
1051
|
(_c = store.config.logger) == null ? void 0 : _c.info(
|
|
1068
1052
|
` || ${stateKey} is an atom, and can't be downstream`
|
|
@@ -1172,18 +1156,16 @@ var createReadonlySelector = (options, family, store, core) => {
|
|
|
1172
1156
|
get: getSelf,
|
|
1173
1157
|
type: `readonly_selector`
|
|
1174
1158
|
}), family && { family });
|
|
1175
|
-
core.readonlySelectors
|
|
1176
|
-
options.key,
|
|
1177
|
-
readonlySelector,
|
|
1178
|
-
core.readonlySelectors
|
|
1179
|
-
);
|
|
1159
|
+
core.readonlySelectors.set(options.key, readonlySelector);
|
|
1180
1160
|
const initialValue = getSelf();
|
|
1181
1161
|
(_a = store.config.logger) == null ? void 0 : _a.info(` \u2728 "${options.key}" =`, initialValue);
|
|
1182
1162
|
const token = {
|
|
1183
1163
|
key: options.key,
|
|
1184
|
-
type: `readonly_selector
|
|
1185
|
-
family
|
|
1164
|
+
type: `readonly_selector`
|
|
1186
1165
|
};
|
|
1166
|
+
if (family) {
|
|
1167
|
+
token.family = family;
|
|
1168
|
+
}
|
|
1187
1169
|
store.subject.selectorCreation.next(token);
|
|
1188
1170
|
return token;
|
|
1189
1171
|
};
|
|
@@ -1192,7 +1174,7 @@ var createReadonlySelector = (options, family, store, core) => {
|
|
|
1192
1174
|
function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
1193
1175
|
var _a;
|
|
1194
1176
|
const core = target(store);
|
|
1195
|
-
if (
|
|
1177
|
+
if (core.selectors.has(options.key)) {
|
|
1196
1178
|
(_a = store.config.logger) == null ? void 0 : _a.error(
|
|
1197
1179
|
`Key "${options.key}" already exists in the store.`
|
|
1198
1180
|
);
|
|
@@ -1203,7 +1185,7 @@ function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
|
|
|
1203
1185
|
return createReadWriteSelector(options, family, store, core);
|
|
1204
1186
|
}
|
|
1205
1187
|
|
|
1206
|
-
//
|
|
1188
|
+
// ../anvl/reactivity/subject.ts
|
|
1207
1189
|
var Subject = class {
|
|
1208
1190
|
constructor() {
|
|
1209
1191
|
this.subscribers = [];
|
|
@@ -1276,7 +1258,13 @@ var subscribeToRootAtoms = (state, store) => {
|
|
|
1276
1258
|
);
|
|
1277
1259
|
const oldValue = recallState(state, store);
|
|
1278
1260
|
const newValue = getState__INTERNAL(state, store);
|
|
1279
|
-
(_b = store.config.logger) == null ? void 0 : _b.info(
|
|
1261
|
+
(_b = store.config.logger) == null ? void 0 : _b.info(
|
|
1262
|
+
` <- "${state.key}" went (`,
|
|
1263
|
+
oldValue,
|
|
1264
|
+
`->`,
|
|
1265
|
+
newValue,
|
|
1266
|
+
`)`
|
|
1267
|
+
);
|
|
1280
1268
|
state.subject.next({ newValue, oldValue });
|
|
1281
1269
|
});
|
|
1282
1270
|
});
|
|
@@ -1300,7 +1288,7 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1300
1288
|
);
|
|
1301
1289
|
return;
|
|
1302
1290
|
}
|
|
1303
|
-
timelineData.timeTraveling =
|
|
1291
|
+
timelineData.timeTraveling = `into_future`;
|
|
1304
1292
|
const update = timelineData.history[timelineData.at];
|
|
1305
1293
|
switch (update.type) {
|
|
1306
1294
|
case `atom_update`: {
|
|
@@ -1319,7 +1307,7 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1319
1307
|
}
|
|
1320
1308
|
++timelineData.at;
|
|
1321
1309
|
timelineData.subject.next(`redo`);
|
|
1322
|
-
timelineData.timeTraveling =
|
|
1310
|
+
timelineData.timeTraveling = null;
|
|
1323
1311
|
(_d = store.config.logger) == null ? void 0 : _d.info(
|
|
1324
1312
|
`\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
|
|
1325
1313
|
);
|
|
@@ -1340,7 +1328,7 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1340
1328
|
);
|
|
1341
1329
|
return;
|
|
1342
1330
|
}
|
|
1343
|
-
timelineData.timeTraveling =
|
|
1331
|
+
timelineData.timeTraveling = `into_past`;
|
|
1344
1332
|
--timelineData.at;
|
|
1345
1333
|
const update = timelineData.history[timelineData.at];
|
|
1346
1334
|
switch (update.type) {
|
|
@@ -1359,15 +1347,12 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1359
1347
|
}
|
|
1360
1348
|
}
|
|
1361
1349
|
timelineData.subject.next(`undo`);
|
|
1362
|
-
timelineData.timeTraveling =
|
|
1350
|
+
timelineData.timeTraveling = null;
|
|
1363
1351
|
(_d = store.config.logger) == null ? void 0 : _d.info(
|
|
1364
1352
|
`\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
|
|
1365
1353
|
);
|
|
1366
1354
|
};
|
|
1367
1355
|
|
|
1368
|
-
// src/internal/timeline-internal.ts
|
|
1369
|
-
import HAMT10 from "hamt_plus";
|
|
1370
|
-
|
|
1371
1356
|
// src/internal/timeline/add-atom-to-timeline.ts
|
|
1372
1357
|
var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
1373
1358
|
const atom2 = withdraw(atomToken, store);
|
|
@@ -1389,7 +1374,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1389
1374
|
update.newValue,
|
|
1390
1375
|
currentTransactionKey ? `) in transaction "${currentTransactionKey}"` : currentSelectorKey ? `) in selector "${currentSelectorKey}"` : `)`
|
|
1391
1376
|
);
|
|
1392
|
-
if (tl.timeTraveling ===
|
|
1377
|
+
if (tl.timeTraveling === null) {
|
|
1393
1378
|
if (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {
|
|
1394
1379
|
const mostRecentUpdate = tl.history.at(-1);
|
|
1395
1380
|
if (mostRecentUpdate === void 0) {
|
|
@@ -1418,7 +1403,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1418
1403
|
const subscription = currentTransaction.subject.subscribe((update2) => {
|
|
1419
1404
|
var _a2;
|
|
1420
1405
|
subscription.unsubscribe();
|
|
1421
|
-
if (tl.timeTraveling ===
|
|
1406
|
+
if (tl.timeTraveling === null && currentTransactionTime) {
|
|
1422
1407
|
if (tl.at !== tl.history.length) {
|
|
1423
1408
|
tl.history.splice(tl.at);
|
|
1424
1409
|
}
|
|
@@ -1507,7 +1492,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
|
|
|
1507
1492
|
const tl = __spreadProps(__spreadValues({
|
|
1508
1493
|
key: options.key,
|
|
1509
1494
|
at: 0,
|
|
1510
|
-
timeTraveling:
|
|
1495
|
+
timeTraveling: null,
|
|
1511
1496
|
selectorTime: null,
|
|
1512
1497
|
transactionKey: null
|
|
1513
1498
|
}, data), {
|
|
@@ -1549,7 +1534,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
|
|
|
1549
1534
|
timelineKey: options.key
|
|
1550
1535
|
});
|
|
1551
1536
|
}
|
|
1552
|
-
store.timelines
|
|
1537
|
+
store.timelines.set(options.key, tl);
|
|
1553
1538
|
const token = {
|
|
1554
1539
|
key: options.key,
|
|
1555
1540
|
type: `timeline`
|
|
@@ -1572,7 +1557,6 @@ var abortTransaction = (store) => {
|
|
|
1572
1557
|
};
|
|
1573
1558
|
|
|
1574
1559
|
// src/internal/transaction/apply-transaction.ts
|
|
1575
|
-
import HAMT11 from "hamt_plus";
|
|
1576
1560
|
var applyTransaction = (output, store) => {
|
|
1577
1561
|
var _a, _b, _c, _d;
|
|
1578
1562
|
if (store.transactionStatus.phase !== `building`) {
|
|
@@ -1589,10 +1573,15 @@ var applyTransaction = (output, store) => {
|
|
|
1589
1573
|
const { atomUpdates } = store.transactionStatus;
|
|
1590
1574
|
for (const { key, newValue } of atomUpdates) {
|
|
1591
1575
|
const token = { key, type: `atom` };
|
|
1592
|
-
if (!
|
|
1593
|
-
const newAtom =
|
|
1594
|
-
|
|
1595
|
-
|
|
1576
|
+
if (!store.valueMap.has(token.key)) {
|
|
1577
|
+
const newAtom = store.transactionStatus.core.atoms.get(token.key);
|
|
1578
|
+
if (!newAtom) {
|
|
1579
|
+
throw new Error(
|
|
1580
|
+
`Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${store.transactionStatus.key}" to store "${store.config.name}"`
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
store.atoms.set(newAtom.key, newAtom);
|
|
1584
|
+
store.valueMap.set(newAtom.key, newAtom.default);
|
|
1596
1585
|
(_c = store.config.logger) == null ? void 0 : _c.info(`\u{1F527}`, `add atom "${newAtom.key}"`);
|
|
1597
1586
|
}
|
|
1598
1587
|
setState(token, newValue, store);
|
|
@@ -1624,17 +1613,17 @@ var buildTransaction = (key, params, store) => {
|
|
|
1624
1613
|
phase: `building`,
|
|
1625
1614
|
time: Date.now(),
|
|
1626
1615
|
core: {
|
|
1627
|
-
atoms: store.atoms,
|
|
1616
|
+
atoms: new Map(store.atoms),
|
|
1628
1617
|
atomsThatAreDefault: store.atomsThatAreDefault,
|
|
1629
1618
|
operation: { open: false },
|
|
1630
|
-
readonlySelectors: store.readonlySelectors,
|
|
1631
|
-
timelines: store.timelines,
|
|
1619
|
+
readonlySelectors: new Map(store.readonlySelectors),
|
|
1620
|
+
timelines: new Map(store.timelines),
|
|
1632
1621
|
timelineAtoms: store.timelineAtoms,
|
|
1633
|
-
transactions: store.transactions,
|
|
1622
|
+
transactions: new Map(store.transactions),
|
|
1634
1623
|
selectorAtoms: store.selectorAtoms,
|
|
1635
1624
|
selectorGraph: store.selectorGraph,
|
|
1636
|
-
selectors: store.selectors,
|
|
1637
|
-
valueMap: store.valueMap
|
|
1625
|
+
selectors: new Map(store.selectors),
|
|
1626
|
+
valueMap: new Map(store.valueMap)
|
|
1638
1627
|
},
|
|
1639
1628
|
atomUpdates: [],
|
|
1640
1629
|
params,
|