atom.io 0.19.1 → 0.19.3
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/data/dist/index.cjs +99 -79
- package/data/dist/index.js +3 -3
- package/data/package.json +1 -1
- package/data/src/join.ts +67 -50
- package/dist/{chunk-YDOGCZ53.js → chunk-ATKDGVTV.js} +29 -29
- package/dist/{chunk-7VCCW45K.js → chunk-CC7IF7QF.js} +4 -3
- package/dist/{chunk-U2IICNHQ.js → chunk-F2X4B4VY.js} +5 -1
- package/dist/{chunk-WX2NCOZR.js → chunk-FTONNX2R.js} +8 -8
- package/dist/{chunk-7ZR244C2.js → chunk-MSCJWACE.js} +92 -72
- package/dist/index.cjs +14 -7
- package/dist/index.d.ts +23 -35
- package/dist/index.js +15 -8
- package/eslint-plugin/dist/index.cjs +180 -0
- package/eslint-plugin/dist/index.js +171 -0
- package/eslint-plugin/package.json +16 -0
- package/eslint-plugin/src/index.ts +11 -0
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +190 -0
- package/internal/dist/index.cjs +55 -43
- package/internal/dist/index.d.ts +20 -20
- package/internal/dist/index.js +49 -37
- package/internal/package.json +1 -1
- package/internal/src/atom/create-regular-atom.ts +7 -5
- package/internal/src/atom/delete-atom.ts +2 -2
- package/internal/src/families/create-readonly-selector-family.ts +2 -2
- package/internal/src/families/create-regular-atom-family.ts +1 -1
- package/internal/src/families/create-writable-selector-family.ts +1 -1
- package/internal/src/future.ts +4 -2
- package/internal/src/lineage.ts +1 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +7 -5
- package/internal/src/mutable/tracker.ts +3 -3
- package/internal/src/mutable/transceiver.ts +2 -2
- package/internal/src/selector/delete-selector.ts +1 -1
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/store/deposit.ts +5 -5
- package/internal/src/store/store.ts +5 -5
- package/internal/src/store/withdraw.ts +4 -5
- package/internal/src/subject.ts +3 -1
- package/internal/src/subscribe/subscribe-to-transaction.ts +4 -4
- package/internal/src/timeline/add-atom-to-timeline.ts +13 -8
- package/internal/src/timeline/create-timeline.ts +3 -4
- package/internal/src/transaction/act-upon-store.ts +5 -5
- package/internal/src/transaction/apply-transaction.ts +4 -4
- package/internal/src/transaction/build-transaction.ts +9 -6
- package/internal/src/transaction/create-transaction.ts +10 -10
- package/internal/src/transaction/index.ts +3 -3
- package/internal/src/transaction/is-root-store.ts +2 -2
- package/introspection/dist/index.d.ts +3 -3
- package/introspection/dist/index.js +1 -1
- package/introspection/package.json +1 -1
- package/introspection/src/attach-introspection-states.ts +3 -3
- package/introspection/src/attach-transaction-index.ts +4 -4
- package/introspection/src/attach-transaction-logs.ts +8 -4
- package/json/dist/index.cjs +6 -2
- package/json/dist/index.js +7 -3
- package/json/package.json +1 -1
- package/json/src/select-json-family.ts +3 -2
- package/json/src/select-json.ts +3 -1
- package/package.json +258 -241
- package/react/dist/index.cjs +9 -3
- package/react/dist/index.js +10 -4
- package/react/package.json +1 -1
- package/react/src/use-i.ts +3 -1
- package/react/src/use-tl.ts +6 -2
- package/react-devtools/dist/index.cjs +205 -155
- package/react-devtools/dist/index.d.ts +3 -5
- package/react-devtools/dist/index.js +182 -133
- package/react-devtools/package.json +1 -1
- package/react-devtools/src/AtomIODevtools.tsx +3 -1
- package/react-devtools/src/Button.tsx +3 -1
- package/react-devtools/src/StateIndex.tsx +6 -2
- package/react-devtools/src/TimelineIndex.tsx +6 -2
- package/react-devtools/src/TransactionIndex.tsx +3 -3
- package/react-devtools/src/Updates.tsx +24 -13
- package/realtime/dist/index.cjs +1 -0
- package/realtime/dist/index.d.ts +2 -2
- package/realtime/dist/index.js +2 -1
- package/realtime/package.json +1 -1
- package/realtime/src/realtime-continuity.ts +4 -3
- package/realtime-client/dist/index.cjs +29 -29
- package/realtime-client/dist/index.d.ts +2 -2
- package/realtime-client/dist/index.js +2 -2
- package/realtime-client/package.json +1 -1
- package/realtime-client/src/server-action.ts +2 -2
- package/realtime-client/src/sync-continuity.ts +23 -23
- package/realtime-react/dist/index.cjs +29 -29
- package/realtime-react/dist/index.d.ts +2 -2
- package/realtime-react/dist/index.js +2 -2
- package/realtime-react/package.json +1 -1
- package/realtime-react/src/use-server-action.ts +3 -3
- package/realtime-server/dist/index.cjs +54 -44
- package/realtime-server/dist/index.d.ts +5 -5
- package/realtime-server/dist/index.js +35 -25
- package/realtime-server/package.json +1 -1
- package/realtime-server/src/ipc-sockets/child-socket.ts +6 -6
- package/realtime-server/src/ipc-sockets/custom-socket.ts +4 -8
- package/realtime-server/src/ipc-sockets/parent-socket.ts +13 -7
- package/realtime-server/src/realtime-action-receiver.ts +7 -5
- package/realtime-server/src/realtime-continuity-synchronizer.ts +3 -3
- package/realtime-server/src/realtime-state-receiver.ts +3 -1
- package/realtime-testing/dist/index.cjs +15 -13
- package/realtime-testing/dist/index.js +10 -8
- package/realtime-testing/package.json +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +6 -4
- package/src/atom.ts +4 -8
- package/src/dispose.ts +1 -0
- package/src/index.ts +2 -9
- package/src/selector.ts +4 -8
- package/src/silo.ts +9 -3
- package/src/subscribe.ts +6 -6
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +24 -24
- package/transceivers/set-rtx/dist/index.cjs +11 -12
- package/transceivers/set-rtx/dist/index.js +12 -13
- package/transceivers/set-rtx/package.json +1 -1
- package/transceivers/set-rtx/src/set-rtx.ts +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Junction } from './chunk-
|
|
1
|
+
import { Junction } from './chunk-FTONNX2R.js';
|
|
2
2
|
import { dispose } from 'atom.io';
|
|
3
3
|
import { getFromStore, setIntoStore, findInStore, createMutableAtomFamily, createRegularAtomFamily, IMPLICIT, newest, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
4
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
@@ -31,11 +31,13 @@ var Join = class _Join {
|
|
|
31
31
|
this.alternates.set(store.config.name, this);
|
|
32
32
|
this.transactors = {
|
|
33
33
|
get: (token) => getFromStore(token, store),
|
|
34
|
-
set: (token, value) =>
|
|
34
|
+
set: (token, value) => {
|
|
35
|
+
setIntoStore(token, value, store);
|
|
36
|
+
},
|
|
35
37
|
find: (token, key) => findInStore(token, key, store)
|
|
36
38
|
};
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
+
const aSide = options.between[0];
|
|
40
|
+
const bSide = options.between[1];
|
|
39
41
|
const relatedKeysAtoms = createMutableAtomFamily(
|
|
40
42
|
{
|
|
41
43
|
key: `${options.key}/relatedKeys`,
|
|
@@ -48,23 +50,23 @@ var Join = class _Join {
|
|
|
48
50
|
);
|
|
49
51
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
50
52
|
const getRelatedKeys = ({ find, get }, key) => get(find(relatedKeysAtoms, key));
|
|
51
|
-
const addRelation = (transactors,
|
|
53
|
+
const addRelation = (transactors, a, b) => {
|
|
52
54
|
const { set, find } = transactors;
|
|
53
|
-
const aKeysState = find(relatedKeysAtoms,
|
|
54
|
-
const bKeysState = find(relatedKeysAtoms,
|
|
55
|
-
set(aKeysState, (aKeys) => aKeys.add(
|
|
56
|
-
set(bKeysState, (bKeys) => bKeys.add(
|
|
55
|
+
const aKeysState = find(relatedKeysAtoms, a);
|
|
56
|
+
const bKeysState = find(relatedKeysAtoms, b);
|
|
57
|
+
set(aKeysState, (aKeys) => aKeys.add(b));
|
|
58
|
+
set(bKeysState, (bKeys) => bKeys.add(a));
|
|
57
59
|
};
|
|
58
|
-
const deleteRelation = (transactors,
|
|
60
|
+
const deleteRelation = (transactors, a, b) => {
|
|
59
61
|
const { find, set } = transactors;
|
|
60
|
-
const aKeysState = find(relatedKeysAtoms,
|
|
61
|
-
const bKeysState = find(relatedKeysAtoms,
|
|
62
|
-
set(aKeysState, (aKeys) => (aKeys.delete(
|
|
63
|
-
set(bKeysState, (bKeys) => (bKeys.delete(
|
|
62
|
+
const aKeysState = find(relatedKeysAtoms, a);
|
|
63
|
+
const bKeysState = find(relatedKeysAtoms, b);
|
|
64
|
+
set(aKeysState, (aKeys) => (aKeys.delete(b), aKeys));
|
|
65
|
+
set(bKeysState, (bKeys) => (bKeys.delete(a), bKeys));
|
|
64
66
|
};
|
|
65
|
-
const replaceRelationsSafely = (transactors,
|
|
67
|
+
const replaceRelationsSafely = (transactors, a, newRelationsOfA) => {
|
|
66
68
|
const { find, get, set } = transactors;
|
|
67
|
-
const relationsOfAState = find(relatedKeysAtoms,
|
|
69
|
+
const relationsOfAState = find(relatedKeysAtoms, a);
|
|
68
70
|
const currentRelationsOfA = get(relationsOfAState);
|
|
69
71
|
for (const currentRelationB of currentRelationsOfA) {
|
|
70
72
|
const remainsRelated = newRelationsOfA.includes(currentRelationB);
|
|
@@ -73,7 +75,7 @@ var Join = class _Join {
|
|
|
73
75
|
}
|
|
74
76
|
const relationsOfBState = find(relatedKeysAtoms, currentRelationB);
|
|
75
77
|
set(relationsOfBState, (relationsOfB) => {
|
|
76
|
-
relationsOfB.delete(
|
|
78
|
+
relationsOfB.delete(a);
|
|
77
79
|
return relationsOfB;
|
|
78
80
|
});
|
|
79
81
|
}
|
|
@@ -82,10 +84,10 @@ var Join = class _Join {
|
|
|
82
84
|
nextRelationsOfA.clear();
|
|
83
85
|
for (const newRelationB of newRelationsOfA) {
|
|
84
86
|
const relationsOfB = getRelatedKeys(transactors, newRelationB);
|
|
85
|
-
const newRelationBIsAlreadyRelated = relationsOfB.has(
|
|
87
|
+
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
86
88
|
if (this.relations.cardinality === `1:n`) {
|
|
87
89
|
for (const previousOwner of relationsOfB) {
|
|
88
|
-
if (previousOwner ===
|
|
90
|
+
if (previousOwner === a) {
|
|
89
91
|
continue;
|
|
90
92
|
}
|
|
91
93
|
const previousOwnerRelations = getRelatedKeys(
|
|
@@ -99,7 +101,7 @@ var Join = class _Join {
|
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
if (!newRelationBIsAlreadyRelated) {
|
|
102
|
-
relationsOfB.add(
|
|
104
|
+
relationsOfB.add(a);
|
|
103
105
|
}
|
|
104
106
|
nextRelationsOfA.add(newRelationB);
|
|
105
107
|
}
|
|
@@ -108,9 +110,9 @@ var Join = class _Join {
|
|
|
108
110
|
return relationsOfA;
|
|
109
111
|
});
|
|
110
112
|
};
|
|
111
|
-
const replaceRelationsUnsafely = (transactors,
|
|
113
|
+
const replaceRelationsUnsafely = (transactors, a, newRelationsOfA) => {
|
|
112
114
|
const { find, set } = transactors;
|
|
113
|
-
const relationsOfAState = find(relatedKeysAtoms,
|
|
115
|
+
const relationsOfAState = find(relatedKeysAtoms, a);
|
|
114
116
|
set(relationsOfAState, (relationsOfA) => {
|
|
115
117
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
116
118
|
for (const newRelationB of newRelationsOfA) {
|
|
@@ -123,23 +125,31 @@ var Join = class _Join {
|
|
|
123
125
|
for (const newRelationB of newRelationsOfA) {
|
|
124
126
|
const newRelationsBState = find(relatedKeysAtoms, newRelationB);
|
|
125
127
|
set(newRelationsBState, (newRelationsB) => {
|
|
126
|
-
newRelationsB.add(
|
|
128
|
+
newRelationsB.add(a);
|
|
127
129
|
return newRelationsB;
|
|
128
130
|
});
|
|
129
131
|
}
|
|
130
132
|
return true;
|
|
131
133
|
};
|
|
132
|
-
const has = (transactors,
|
|
133
|
-
const aKeys = getRelatedKeys(transactors,
|
|
134
|
-
return
|
|
134
|
+
const has = (transactors, a, b) => {
|
|
135
|
+
const aKeys = getRelatedKeys(transactors, a);
|
|
136
|
+
return b ? aKeys.has(b) : aKeys.size > 0;
|
|
135
137
|
};
|
|
136
138
|
const baseExternalStoreConfiguration = {
|
|
137
139
|
getRelatedKeys: (key) => getRelatedKeys(this.transactors, key),
|
|
138
|
-
addRelation: (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
addRelation: (a, b) => {
|
|
141
|
+
addRelation(this.transactors, a, b);
|
|
142
|
+
},
|
|
143
|
+
deleteRelation: (a, b) => {
|
|
144
|
+
deleteRelation(this.transactors, a, b);
|
|
145
|
+
},
|
|
146
|
+
replaceRelationsSafely: (a, bs) => {
|
|
147
|
+
replaceRelationsSafely(this.transactors, a, bs);
|
|
148
|
+
},
|
|
149
|
+
replaceRelationsUnsafely: (a, bs) => {
|
|
150
|
+
replaceRelationsUnsafely(this.transactors, a, bs);
|
|
151
|
+
},
|
|
152
|
+
has: (a, b) => has(this.transactors, a, b)
|
|
143
153
|
};
|
|
144
154
|
let externalStore;
|
|
145
155
|
let contentAtoms;
|
|
@@ -152,8 +162,12 @@ var Join = class _Join {
|
|
|
152
162
|
store
|
|
153
163
|
);
|
|
154
164
|
const getContent = ({ find, get }, key) => get(find(contentAtoms, key));
|
|
155
|
-
const setContent = ({ find, set }, key, content) =>
|
|
156
|
-
|
|
165
|
+
const setContent = ({ find, set }, key, content) => {
|
|
166
|
+
set(find(contentAtoms, key), content);
|
|
167
|
+
};
|
|
168
|
+
const deleteContent = ({ find }, key) => {
|
|
169
|
+
dispose(find(contentAtoms, key));
|
|
170
|
+
};
|
|
157
171
|
const externalStoreWithContentConfiguration = {
|
|
158
172
|
getContent: (contentKey) => {
|
|
159
173
|
const content = getContent(this.transactors, contentKey);
|
|
@@ -241,8 +255,8 @@ var Join = class _Join {
|
|
|
241
255
|
switch (options.cardinality) {
|
|
242
256
|
case `1:1`: {
|
|
243
257
|
const findSingleRelatedKeyState = createSingleKeyStateFamily();
|
|
244
|
-
const stateKeyA = `${
|
|
245
|
-
const stateKeyB = `${
|
|
258
|
+
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
259
|
+
const stateKeyB = `${bSide}KeyOf${capitalize(aSide)}`;
|
|
246
260
|
const baseStates = {
|
|
247
261
|
[stateKeyA]: findSingleRelatedKeyState,
|
|
248
262
|
[stateKeyB]: findSingleRelatedKeyState
|
|
@@ -250,8 +264,8 @@ var Join = class _Join {
|
|
|
250
264
|
let states;
|
|
251
265
|
if (defaultContent) {
|
|
252
266
|
const findSingleRelatedEntryState = createSingleEntryStateFamily();
|
|
253
|
-
const entriesStateKeyA = `${
|
|
254
|
-
const entriesStateKeyB = `${
|
|
267
|
+
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
268
|
+
const entriesStateKeyB = `${bSide}EntryOf${capitalize(aSide)}`;
|
|
255
269
|
const contentStates = {
|
|
256
270
|
[entriesStateKeyA]: findSingleRelatedEntryState,
|
|
257
271
|
[entriesStateKeyB]: findSingleRelatedEntryState
|
|
@@ -267,8 +281,8 @@ var Join = class _Join {
|
|
|
267
281
|
case `1:n`: {
|
|
268
282
|
const findSingleRelatedKeyState = createSingleKeyStateFamily();
|
|
269
283
|
const findMultipleRelatedKeysState = getMultipleKeyStateFamily();
|
|
270
|
-
const stateKeyA = `${
|
|
271
|
-
const stateKeyB = `${
|
|
284
|
+
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
285
|
+
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
272
286
|
const baseStates = {
|
|
273
287
|
[stateKeyA]: findSingleRelatedKeyState,
|
|
274
288
|
[stateKeyB]: findMultipleRelatedKeysState
|
|
@@ -277,8 +291,10 @@ var Join = class _Join {
|
|
|
277
291
|
if (defaultContent) {
|
|
278
292
|
const findSingleRelatedEntryState = createSingleEntryStateFamily();
|
|
279
293
|
const findMultipleRelatedEntriesState = getMultipleEntryStateFamily();
|
|
280
|
-
const entriesStateKeyA = `${
|
|
281
|
-
const entriesStateKeyB = `${
|
|
294
|
+
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
295
|
+
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(
|
|
296
|
+
aSide
|
|
297
|
+
)}`;
|
|
282
298
|
const contentStates = {
|
|
283
299
|
[entriesStateKeyA]: findSingleRelatedEntryState,
|
|
284
300
|
[entriesStateKeyB]: findMultipleRelatedEntriesState
|
|
@@ -293,8 +309,8 @@ var Join = class _Join {
|
|
|
293
309
|
}
|
|
294
310
|
default: {
|
|
295
311
|
const findMultipleRelatedKeysState = getMultipleKeyStateFamily();
|
|
296
|
-
const stateKeyA = `${
|
|
297
|
-
const stateKeyB = `${
|
|
312
|
+
const stateKeyA = `${aSide}KeysOf${capitalize(bSide)}`;
|
|
313
|
+
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
298
314
|
const baseStates = {
|
|
299
315
|
[stateKeyA]: findMultipleRelatedKeysState,
|
|
300
316
|
[stateKeyB]: findMultipleRelatedKeysState
|
|
@@ -302,8 +318,12 @@ var Join = class _Join {
|
|
|
302
318
|
let states;
|
|
303
319
|
if (defaultContent) {
|
|
304
320
|
const findMultipleRelatedEntriesState = getMultipleEntryStateFamily();
|
|
305
|
-
const entriesStateKeyA = `${
|
|
306
|
-
|
|
321
|
+
const entriesStateKeyA = `${aSide}EntriesOf${capitalize(
|
|
322
|
+
bSide
|
|
323
|
+
)}`;
|
|
324
|
+
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(
|
|
325
|
+
aSide
|
|
326
|
+
)}`;
|
|
307
327
|
const contentStates = {
|
|
308
328
|
[entriesStateKeyA]: findMultipleRelatedEntriesState,
|
|
309
329
|
[entriesStateKeyB]: findMultipleRelatedEntriesState
|
|
@@ -341,21 +361,21 @@ function getJoinMap(store) {
|
|
|
341
361
|
function getJoin(token, store) {
|
|
342
362
|
var _a;
|
|
343
363
|
const joinMap = getJoinMap(store);
|
|
344
|
-
let
|
|
345
|
-
if (
|
|
364
|
+
let myJoin = joinMap.get(token.key);
|
|
365
|
+
if (myJoin === void 0) {
|
|
346
366
|
const rootJoinMap = getJoinMap(IMPLICIT.STORE);
|
|
347
|
-
|
|
348
|
-
if (
|
|
367
|
+
myJoin = (_a = rootJoinMap.get(token.key)) == null ? void 0 : _a.in(store);
|
|
368
|
+
if (myJoin === void 0) {
|
|
349
369
|
throw new Error(
|
|
350
370
|
`Join "${token.key}" not found in store "${store.config.name}"`
|
|
351
371
|
);
|
|
352
372
|
}
|
|
353
|
-
joinMap.set(token.key,
|
|
373
|
+
joinMap.set(token.key, myJoin);
|
|
354
374
|
}
|
|
355
|
-
return
|
|
375
|
+
return myJoin;
|
|
356
376
|
}
|
|
357
377
|
function findRelationsInStore(token, key, store) {
|
|
358
|
-
const
|
|
378
|
+
const myJoin = getJoin(token, store);
|
|
359
379
|
let relations;
|
|
360
380
|
switch (token.cardinality) {
|
|
361
381
|
case `1:1`: {
|
|
@@ -363,27 +383,27 @@ function findRelationsInStore(token, key, store) {
|
|
|
363
383
|
const keyBA = `${token.b}KeyOf${capitalize(token.a)}`;
|
|
364
384
|
relations = {
|
|
365
385
|
get [keyAB]() {
|
|
366
|
-
const familyAB =
|
|
386
|
+
const familyAB = myJoin.states[keyAB];
|
|
367
387
|
const state = findInStore(familyAB, key, store);
|
|
368
388
|
return state;
|
|
369
389
|
},
|
|
370
390
|
get [keyBA]() {
|
|
371
|
-
const familyBA =
|
|
391
|
+
const familyBA = myJoin.states[keyBA];
|
|
372
392
|
const state = findInStore(familyBA, key, store);
|
|
373
393
|
return state;
|
|
374
394
|
}
|
|
375
395
|
};
|
|
376
396
|
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
377
|
-
if (entryAB in
|
|
397
|
+
if (entryAB in myJoin.states) {
|
|
378
398
|
const entryBA = `${token.b}EntryOf${capitalize(token.a)}`;
|
|
379
399
|
Object.assign(relations, {
|
|
380
400
|
get [entryAB]() {
|
|
381
|
-
const familyAB =
|
|
401
|
+
const familyAB = myJoin.states[entryAB];
|
|
382
402
|
const state = findInStore(familyAB, key, store);
|
|
383
403
|
return state;
|
|
384
404
|
},
|
|
385
405
|
get [entryBA]() {
|
|
386
|
-
const familyBA =
|
|
406
|
+
const familyBA = myJoin.states[entryBA];
|
|
387
407
|
const state = findInStore(familyBA, key, store);
|
|
388
408
|
return state;
|
|
389
409
|
}
|
|
@@ -396,27 +416,27 @@ function findRelationsInStore(token, key, store) {
|
|
|
396
416
|
const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
|
|
397
417
|
relations = {
|
|
398
418
|
get [keyAB]() {
|
|
399
|
-
const familyAB =
|
|
419
|
+
const familyAB = myJoin.states[keyAB];
|
|
400
420
|
const state = findInStore(familyAB, key, store);
|
|
401
421
|
return state;
|
|
402
422
|
},
|
|
403
423
|
get [keysBA]() {
|
|
404
|
-
const familyBA =
|
|
424
|
+
const familyBA = myJoin.states[keysBA];
|
|
405
425
|
const state = findInStore(familyBA, key, store);
|
|
406
426
|
return state;
|
|
407
427
|
}
|
|
408
428
|
};
|
|
409
429
|
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
410
|
-
if (entryAB in
|
|
430
|
+
if (entryAB in myJoin.states) {
|
|
411
431
|
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
412
432
|
Object.assign(relations, {
|
|
413
433
|
get [entryAB]() {
|
|
414
|
-
const familyAB =
|
|
434
|
+
const familyAB = myJoin.states[entryAB];
|
|
415
435
|
const state = findInStore(familyAB, key, store);
|
|
416
436
|
return state;
|
|
417
437
|
},
|
|
418
438
|
get [entriesBA]() {
|
|
419
|
-
const familyBA =
|
|
439
|
+
const familyBA = myJoin.states[entriesBA];
|
|
420
440
|
const state = findInStore(familyBA, key, store);
|
|
421
441
|
return state;
|
|
422
442
|
}
|
|
@@ -429,27 +449,27 @@ function findRelationsInStore(token, key, store) {
|
|
|
429
449
|
const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
|
|
430
450
|
relations = {
|
|
431
451
|
get [keysAB]() {
|
|
432
|
-
const familyAB =
|
|
452
|
+
const familyAB = myJoin.states[keysAB];
|
|
433
453
|
const state = findInStore(familyAB, key, store);
|
|
434
454
|
return state;
|
|
435
455
|
},
|
|
436
456
|
get [keysBA]() {
|
|
437
|
-
const familyBA =
|
|
457
|
+
const familyBA = myJoin.states[keysBA];
|
|
438
458
|
const state = findInStore(familyBA, key, store);
|
|
439
459
|
return state;
|
|
440
460
|
}
|
|
441
461
|
};
|
|
442
462
|
const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`;
|
|
443
|
-
if (entriesAB in
|
|
463
|
+
if (entriesAB in myJoin.states) {
|
|
444
464
|
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
445
465
|
Object.assign(relations, {
|
|
446
466
|
get [entriesAB]() {
|
|
447
|
-
const familyAB =
|
|
467
|
+
const familyAB = myJoin.states[entriesAB];
|
|
448
468
|
const state = findInStore(familyAB, key, store);
|
|
449
469
|
return state;
|
|
450
470
|
},
|
|
451
471
|
get [entriesBA]() {
|
|
452
|
-
const familyBA =
|
|
472
|
+
const familyBA = myJoin.states[entriesBA];
|
|
453
473
|
const state = findInStore(familyBA, key, store);
|
|
454
474
|
return state;
|
|
455
475
|
}
|
|
@@ -463,23 +483,23 @@ function findRelations(token, key) {
|
|
|
463
483
|
return findRelationsInStore(token, key, IMPLICIT.STORE);
|
|
464
484
|
}
|
|
465
485
|
function editRelationsInStore(token, change, store) {
|
|
466
|
-
const
|
|
486
|
+
const myJoin = getJoin(token, store);
|
|
467
487
|
const target = newest(store);
|
|
468
488
|
if (isChildStore(target)) {
|
|
469
489
|
const { transactors } = target.transactionMeta;
|
|
470
|
-
|
|
490
|
+
myJoin.transact(transactors, ({ relations }) => {
|
|
471
491
|
change(relations);
|
|
472
492
|
});
|
|
473
493
|
} else {
|
|
474
|
-
change(
|
|
494
|
+
change(myJoin.relations);
|
|
475
495
|
}
|
|
476
496
|
}
|
|
477
497
|
function editRelations(token, change) {
|
|
478
498
|
editRelationsInStore(token, change, IMPLICIT.STORE);
|
|
479
499
|
}
|
|
480
500
|
function getInternalRelationsFromStore(token, store) {
|
|
481
|
-
const
|
|
482
|
-
const family =
|
|
501
|
+
const myJoin = getJoin(token, store);
|
|
502
|
+
const family = myJoin.core.findRelatedKeysState;
|
|
483
503
|
return family;
|
|
484
504
|
}
|
|
485
505
|
function getInternalRelations(token) {
|
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ function atomFamily(options) {
|
|
|
32
32
|
function dispose(token, store = Internal__namespace.IMPLICIT.STORE) {
|
|
33
33
|
switch (token.type) {
|
|
34
34
|
case `atom`:
|
|
35
|
+
case `mutable_atom`:
|
|
35
36
|
Internal__namespace.deleteAtom(token, store);
|
|
36
37
|
break;
|
|
37
38
|
case `selector`:
|
|
@@ -113,10 +114,16 @@ var Silo = class {
|
|
|
113
114
|
this.timeline = (options) => Internal.createTimeline(options, s);
|
|
114
115
|
this.findState = (token, key) => Internal.findInStore(token, key, s);
|
|
115
116
|
this.getState = (token) => Internal.getFromStore(token, s);
|
|
116
|
-
this.setState = (token, newValue) =>
|
|
117
|
+
this.setState = (token, newValue) => {
|
|
118
|
+
Internal.setIntoStore(token, newValue, s);
|
|
119
|
+
};
|
|
117
120
|
this.subscribe = (token, handler, key) => subscribe(token, handler, key, s);
|
|
118
|
-
this.undo = (token) =>
|
|
119
|
-
|
|
121
|
+
this.undo = (token) => {
|
|
122
|
+
Internal.timeTravel(`undo`, token, s);
|
|
123
|
+
};
|
|
124
|
+
this.redo = (token) => {
|
|
125
|
+
Internal.timeTravel(`redo`, token, s);
|
|
126
|
+
};
|
|
120
127
|
}
|
|
121
128
|
};
|
|
122
129
|
function subscribe(token, handleUpdate, key = Internal.arbitrary(), store = Internal.IMPLICIT.STORE) {
|
|
@@ -135,11 +142,11 @@ function subscribe(token, handleUpdate, key = Internal.arbitrary(), store = Inte
|
|
|
135
142
|
var timeline = (options) => {
|
|
136
143
|
return Internal.createTimeline(options, Internal.IMPLICIT.STORE);
|
|
137
144
|
};
|
|
138
|
-
var redo = (
|
|
139
|
-
Internal.timeTravel(`redo`,
|
|
145
|
+
var redo = (tl) => {
|
|
146
|
+
Internal.timeTravel(`redo`, tl, Internal.IMPLICIT.STORE);
|
|
140
147
|
};
|
|
141
|
-
var undo = (
|
|
142
|
-
Internal.timeTravel(`undo`,
|
|
148
|
+
var undo = (tl) => {
|
|
149
|
+
Internal.timeTravel(`undo`, tl, Internal.IMPLICIT.STORE);
|
|
143
150
|
};
|
|
144
151
|
function transaction(options) {
|
|
145
152
|
return Internal.createTransaction(options, Internal.IMPLICIT.STORE);
|
package/dist/index.d.ts
CHANGED
|
@@ -33,10 +33,7 @@ type RegularAtomFamilyToken<T, K extends Json.Serializable> = {
|
|
|
33
33
|
__T?: T;
|
|
34
34
|
__K?: K;
|
|
35
35
|
};
|
|
36
|
-
type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> &
|
|
37
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
38
|
-
(key: K): RegularAtomToken<T>;
|
|
39
|
-
};
|
|
36
|
+
type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => RegularAtomToken<T>);
|
|
40
37
|
type RegularAtomFamily<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & {
|
|
41
38
|
(key: K): RegularAtomToken<T>;
|
|
42
39
|
subject: Subject<RegularAtomToken<T>>;
|
|
@@ -55,10 +52,7 @@ type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializa
|
|
|
55
52
|
__J?: J;
|
|
56
53
|
__K?: K;
|
|
57
54
|
};
|
|
58
|
-
type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = MutableAtomFamilyToken<T, J, K> &
|
|
59
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
60
|
-
(key: K): MutableAtomToken<T, J>;
|
|
61
|
-
};
|
|
55
|
+
type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = MutableAtomFamilyToken<T, J, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => MutableAtomToken<T, J>);
|
|
62
56
|
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
63
57
|
(key: K): MutableAtomToken<T, J>;
|
|
64
58
|
subject: Subject<MutableAtomToken<T, J>>;
|
|
@@ -69,19 +63,19 @@ type AtomFamilyToken<T, K extends Json.Serializable = Json.Serializable> = Mutab
|
|
|
69
63
|
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyTokenWithCall<T, J, K>;
|
|
70
64
|
declare function atomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyTokenWithCall<T, K>;
|
|
71
65
|
|
|
72
|
-
type TransactionToken<F> = {
|
|
66
|
+
type TransactionToken<F extends Func> = {
|
|
73
67
|
key: string;
|
|
74
68
|
type: `transaction`;
|
|
75
69
|
__F?: F;
|
|
76
70
|
};
|
|
77
|
-
type TransactionUpdateContent = KeyedStateUpdate<unknown> | TransactionUpdate
|
|
78
|
-
type TransactionUpdate
|
|
71
|
+
type TransactionUpdateContent = KeyedStateUpdate<unknown> | TransactionUpdate<Func>;
|
|
72
|
+
type TransactionUpdate<F extends Func> = {
|
|
79
73
|
key: string;
|
|
80
74
|
id: string;
|
|
81
75
|
epoch: number;
|
|
82
76
|
updates: TransactionUpdateContent[];
|
|
83
|
-
params: Parameters
|
|
84
|
-
output: ReturnType
|
|
77
|
+
params: Parameters<F>;
|
|
78
|
+
output: ReturnType<F>;
|
|
85
79
|
};
|
|
86
80
|
type Transactors = Readonly<{
|
|
87
81
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S;
|
|
@@ -96,16 +90,16 @@ type TransactorsWithRunAndEnv = Readonly<{
|
|
|
96
90
|
env: () => EnvironmentData;
|
|
97
91
|
}>;
|
|
98
92
|
type ReadonlyTransactors = Pick<Transactors, `find` | `get`>;
|
|
99
|
-
type Read
|
|
100
|
-
type Write
|
|
101
|
-
type Transact
|
|
102
|
-
type TransactionOptions
|
|
93
|
+
type Read<F extends Func> = (transactors: ReadonlyTransactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
94
|
+
type Write<F extends Func> = (transactors: Transactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
95
|
+
type Transact<F extends Func> = (transactors: TransactorsWithRunAndEnv, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
96
|
+
type TransactionOptions<F extends Func> = {
|
|
103
97
|
key: string;
|
|
104
|
-
do: Transact
|
|
98
|
+
do: Transact<F>;
|
|
105
99
|
};
|
|
106
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer
|
|
107
|
-
declare function transaction
|
|
108
|
-
declare function runTransaction
|
|
100
|
+
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer F> ? F : never;
|
|
101
|
+
declare function transaction<F extends Func>(options: TransactionOptions<F>): TransactionToken<F>;
|
|
102
|
+
declare function runTransaction<F extends Func>(token: TransactionToken<F>, id?: string): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
109
103
|
|
|
110
104
|
type WritableSelectorOptions<T> = {
|
|
111
105
|
key: string;
|
|
@@ -133,10 +127,7 @@ type WritableSelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
|
133
127
|
__T?: T;
|
|
134
128
|
__K?: K;
|
|
135
129
|
};
|
|
136
|
-
type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> &
|
|
137
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
138
|
-
(key: K): WritableSelectorToken<T>;
|
|
139
|
-
};
|
|
130
|
+
type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => WritableSelectorToken<T>);
|
|
140
131
|
type WritableSelectorFamily<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & {
|
|
141
132
|
(key: K): WritableSelectorToken<T>;
|
|
142
133
|
subject: Subject<WritableSelectorToken<T>>;
|
|
@@ -148,10 +139,7 @@ type ReadonlySelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
|
148
139
|
__T?: T;
|
|
149
140
|
__K?: K;
|
|
150
141
|
};
|
|
151
|
-
type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = ReadonlySelectorFamilyToken<T, K> &
|
|
152
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
153
|
-
(key: K): ReadonlySelectorToken<T>;
|
|
154
|
-
};
|
|
142
|
+
type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = ReadonlySelectorFamilyToken<T, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => ReadonlySelectorToken<T>);
|
|
155
143
|
type ReadonlySelectorFamily<T, K extends Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
156
144
|
key: string;
|
|
157
145
|
type: `readonly_selector_family`;
|
|
@@ -272,9 +260,9 @@ type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
|
272
260
|
family?: FamilyMetadata;
|
|
273
261
|
};
|
|
274
262
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
275
|
-
type TransactionUpdateHandler
|
|
263
|
+
type TransactionUpdateHandler<F extends Func> = (data: TransactionUpdate<F>) => void;
|
|
276
264
|
declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
|
|
277
|
-
declare function subscribe
|
|
265
|
+
declare function subscribe<F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string, store?: Store): () => void;
|
|
278
266
|
declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
|
|
279
267
|
|
|
280
268
|
type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
|
|
@@ -290,8 +278,8 @@ type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
|
290
278
|
};
|
|
291
279
|
type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineSelectorUpdate<ManagedAtom> | TimelineTransactionUpdate;
|
|
292
280
|
declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
|
|
293
|
-
declare const redo: (
|
|
294
|
-
declare const undo: (
|
|
281
|
+
declare const redo: (tl: TimelineToken<any>) => void;
|
|
282
|
+
declare const undo: (tl: TimelineToken<any>) => void;
|
|
295
283
|
|
|
296
284
|
type TokenType<Comparison extends ReadableFamilyToken$1<any, any> | ReadableToken$1<any>> = Comparison extends ReadableToken$1<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken$1<infer RepresentedValue, any> ? RepresentedValue : never;
|
|
297
285
|
declare function isToken<KnownToken extends RegularAtomToken$1<any>>(knownToken: KnownToken, unknownToken: ReadableToken$1<any>): unknownToken is RegularAtomToken$1<TokenType<KnownToken>>;
|
|
@@ -307,7 +295,7 @@ declare function belongsTo<Family extends ReadonlySelectorFamilyToken$1<any, any
|
|
|
307
295
|
declare function belongsTo<Family extends WritableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is WritableToken$1<TokenType<Family>>;
|
|
308
296
|
declare function belongsTo<Family extends ReadableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is ReadableToken$1<TokenType<Family>>;
|
|
309
297
|
|
|
310
|
-
type
|
|
298
|
+
type Func = (...parameters: any[]) => any;
|
|
311
299
|
type RegularAtomToken<T> = {
|
|
312
300
|
key: string;
|
|
313
301
|
type: `atom`;
|
|
@@ -346,4 +334,4 @@ type FamilyMetadata = {
|
|
|
346
334
|
subKey: string;
|
|
347
335
|
};
|
|
348
336
|
|
|
349
|
-
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, dispose, findState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo
|
|
337
|
+
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, dispose, findState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-F2X4B4VY.js';
|
|
2
2
|
import * as Internal from 'atom.io/internal';
|
|
3
3
|
import { createStandaloneAtom, IMPLICIT, createAtomFamily, findInStore, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, getFromStore, setIntoStore, timeTravel, subscribeToTimeline, subscribeToTransaction, subscribeToState, arbitrary, actUponStore } from 'atom.io/internal';
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@ function atomFamily(options) {
|
|
|
11
11
|
function dispose(token, store = Internal.IMPLICIT.STORE) {
|
|
12
12
|
switch (token.type) {
|
|
13
13
|
case `atom`:
|
|
14
|
+
case `mutable_atom`:
|
|
14
15
|
Internal.deleteAtom(token, store);
|
|
15
16
|
break;
|
|
16
17
|
case `selector`:
|
|
@@ -92,10 +93,16 @@ var Silo = class {
|
|
|
92
93
|
this.timeline = (options) => createTimeline(options, s);
|
|
93
94
|
this.findState = (token, key) => findInStore(token, key, s);
|
|
94
95
|
this.getState = (token) => getFromStore(token, s);
|
|
95
|
-
this.setState = (token, newValue) =>
|
|
96
|
+
this.setState = (token, newValue) => {
|
|
97
|
+
setIntoStore(token, newValue, s);
|
|
98
|
+
};
|
|
96
99
|
this.subscribe = (token, handler, key) => subscribe(token, handler, key, s);
|
|
97
|
-
this.undo = (token) =>
|
|
98
|
-
|
|
100
|
+
this.undo = (token) => {
|
|
101
|
+
timeTravel(`undo`, token, s);
|
|
102
|
+
};
|
|
103
|
+
this.redo = (token) => {
|
|
104
|
+
timeTravel(`redo`, token, s);
|
|
105
|
+
};
|
|
99
106
|
}
|
|
100
107
|
};
|
|
101
108
|
function subscribe(token, handleUpdate, key = arbitrary(), store = IMPLICIT.STORE) {
|
|
@@ -114,11 +121,11 @@ function subscribe(token, handleUpdate, key = arbitrary(), store = IMPLICIT.STOR
|
|
|
114
121
|
var timeline = (options) => {
|
|
115
122
|
return createTimeline(options, IMPLICIT.STORE);
|
|
116
123
|
};
|
|
117
|
-
var redo = (
|
|
118
|
-
timeTravel(`redo`,
|
|
124
|
+
var redo = (tl) => {
|
|
125
|
+
timeTravel(`redo`, tl, IMPLICIT.STORE);
|
|
119
126
|
};
|
|
120
|
-
var undo = (
|
|
121
|
-
timeTravel(`undo`,
|
|
127
|
+
var undo = (tl) => {
|
|
128
|
+
timeTravel(`undo`, tl, IMPLICIT.STORE);
|
|
122
129
|
};
|
|
123
130
|
function transaction(options) {
|
|
124
131
|
return createTransaction(options, IMPLICIT.STORE);
|