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
package/internal/dist/index.cjs
CHANGED
|
@@ -212,16 +212,16 @@ var Junction = class {
|
|
|
212
212
|
if (a === void 0 && typeof b === `string`) {
|
|
213
213
|
const bRelations = this.getRelatedKeys(b);
|
|
214
214
|
if (bRelations) {
|
|
215
|
-
for (const
|
|
216
|
-
this.delete(
|
|
215
|
+
for (const bRelation of bRelations) {
|
|
216
|
+
this.delete(bRelation, b);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
if (typeof a === `string` && b === void 0) {
|
|
221
221
|
const aRelations = this.getRelatedKeys(a);
|
|
222
222
|
if (aRelations) {
|
|
223
|
-
for (const
|
|
224
|
-
this.delete(a,
|
|
223
|
+
for (const aRelation of aRelations) {
|
|
224
|
+
this.delete(a, aRelation);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -274,18 +274,18 @@ var Junction = class {
|
|
|
274
274
|
if (a !== void 0 && b === void 0) {
|
|
275
275
|
const aRelations = this.getRelatedKeys(a);
|
|
276
276
|
if (aRelations) {
|
|
277
|
-
return [...aRelations].map((
|
|
277
|
+
return [...aRelations].map((aRelation) => {
|
|
278
278
|
var _a;
|
|
279
|
-
return [
|
|
279
|
+
return [aRelation, (_a = this.getContent(a, aRelation)) != null ? _a : null];
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
if (a === void 0 && b !== void 0) {
|
|
284
284
|
const bRelations = this.getRelatedKeys(b);
|
|
285
285
|
if (bRelations) {
|
|
286
|
-
return [...bRelations].map((
|
|
286
|
+
return [...bRelations].map((bRelation) => {
|
|
287
287
|
var _a;
|
|
288
|
-
return [
|
|
288
|
+
return [bRelation, (_a = this.getContent(bRelation, b)) != null ? _a : null];
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
}
|
|
@@ -308,7 +308,9 @@ var Subject = class {
|
|
|
308
308
|
}
|
|
309
309
|
subscribe(key, subscriber) {
|
|
310
310
|
this.subscribers.set(key, subscriber);
|
|
311
|
-
const unsubscribe = () =>
|
|
311
|
+
const unsubscribe = () => {
|
|
312
|
+
this.unsubscribe(key);
|
|
313
|
+
};
|
|
312
314
|
return unsubscribe;
|
|
313
315
|
}
|
|
314
316
|
unsubscribe(key) {
|
|
@@ -541,8 +543,12 @@ function withdrawOrCreate(token, store) {
|
|
|
541
543
|
var Future = class extends Promise {
|
|
542
544
|
constructor(executor) {
|
|
543
545
|
super((resolve, reject) => {
|
|
544
|
-
const pass = (value) =>
|
|
545
|
-
|
|
546
|
+
const pass = (value) => {
|
|
547
|
+
this.isCanceled ? reject(`canceled`) : resolve(value);
|
|
548
|
+
};
|
|
549
|
+
const fail = (reason) => {
|
|
550
|
+
this.isCanceled ? reject(`canceled`) : reject(reason);
|
|
551
|
+
};
|
|
546
552
|
if (typeof executor === `function`) {
|
|
547
553
|
executor(pass, fail);
|
|
548
554
|
} else {
|
|
@@ -564,7 +570,7 @@ function copyMutableIfNeeded(atom, origin, target) {
|
|
|
564
570
|
if (originValue === void 0) {
|
|
565
571
|
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
566
572
|
}
|
|
567
|
-
origin.logger.info(`\u{1F4C3}`, `atom`,
|
|
573
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
|
|
568
574
|
const jsonValue = atom.toJson(originValue);
|
|
569
575
|
const copiedValue = atom.fromJson(jsonValue);
|
|
570
576
|
target.valueMap.set(atom.key, copiedValue);
|
|
@@ -669,7 +675,7 @@ function createRegularAtomFamily(options, store) {
|
|
|
669
675
|
key: options.key,
|
|
670
676
|
type: `atom_family`,
|
|
671
677
|
subject,
|
|
672
|
-
install: (
|
|
678
|
+
install: (s) => createRegularAtomFamily(options, s)
|
|
673
679
|
}
|
|
674
680
|
);
|
|
675
681
|
const target = newest(store);
|
|
@@ -710,7 +716,7 @@ function createReadonlySelectorFamily(options, store) {
|
|
|
710
716
|
key: options.key,
|
|
711
717
|
type: `readonly_selector_family`,
|
|
712
718
|
subject,
|
|
713
|
-
install: (
|
|
719
|
+
install: (s) => createReadonlySelectorFamily(options, s)
|
|
714
720
|
}
|
|
715
721
|
);
|
|
716
722
|
store.families.set(options.key, readonlySelectorFamily);
|
|
@@ -743,7 +749,7 @@ function createWritableSelectorFamily(options, store) {
|
|
|
743
749
|
key: options.key,
|
|
744
750
|
type: `selector_family`,
|
|
745
751
|
subject,
|
|
746
|
-
install: (
|
|
752
|
+
install: (s) => createWritableSelectorFamily(options, s)
|
|
747
753
|
}
|
|
748
754
|
);
|
|
749
755
|
store.families.set(options.key, selectorFamily);
|
|
@@ -1252,7 +1258,7 @@ function deleteSelector(selectorToken, store) {
|
|
|
1252
1258
|
}
|
|
1253
1259
|
}
|
|
1254
1260
|
target.selectorGraph.delete(key);
|
|
1255
|
-
store.logger.info(`\u{1F525}`, selectorToken.type,
|
|
1261
|
+
store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
|
|
1256
1262
|
}
|
|
1257
1263
|
|
|
1258
1264
|
// internal/src/subscribe/recall-state.ts
|
|
@@ -1431,18 +1437,18 @@ var Tracker = class {
|
|
|
1431
1437
|
this.unsubscribeFromInnerValue();
|
|
1432
1438
|
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1433
1439
|
subscriptionKey,
|
|
1434
|
-
(
|
|
1440
|
+
(transceiverUpdate) => {
|
|
1435
1441
|
if (target.operation.open) {
|
|
1436
1442
|
const unsubscribe = target.on.operationClose.subscribe(
|
|
1437
1443
|
subscriptionKey,
|
|
1438
1444
|
() => {
|
|
1439
1445
|
unsubscribe();
|
|
1440
|
-
setIntoStore(latestUpdateState,
|
|
1446
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1441
1447
|
}
|
|
1442
1448
|
);
|
|
1443
1449
|
} else {
|
|
1444
1450
|
setIntoStore(mutableState, (current) => current, target);
|
|
1445
|
-
setIntoStore(latestUpdateState,
|
|
1451
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1446
1452
|
}
|
|
1447
1453
|
}
|
|
1448
1454
|
);
|
|
@@ -1551,14 +1557,14 @@ function createMutableAtom(options, family, store) {
|
|
|
1551
1557
|
const subject = new Subject();
|
|
1552
1558
|
const newAtom = __spreadProps(__spreadValues({}, options), {
|
|
1553
1559
|
type: `mutable_atom`,
|
|
1554
|
-
install: (
|
|
1555
|
-
|
|
1560
|
+
install: (s) => {
|
|
1561
|
+
s.logger.info(
|
|
1556
1562
|
`\u{1F6E0}\uFE0F`,
|
|
1557
1563
|
`atom`,
|
|
1558
1564
|
options.key,
|
|
1559
|
-
`installing in store "${
|
|
1565
|
+
`installing in store "${s.config.name}"`
|
|
1560
1566
|
);
|
|
1561
|
-
return createMutableAtom(options, family,
|
|
1567
|
+
return createMutableAtom(options, family, s);
|
|
1562
1568
|
},
|
|
1563
1569
|
subject
|
|
1564
1570
|
});
|
|
@@ -1575,7 +1581,9 @@ function createMutableAtom(options, family, store) {
|
|
|
1575
1581
|
const cleanupFunctions = [];
|
|
1576
1582
|
for (const effect of options.effects) {
|
|
1577
1583
|
const cleanup = effect({
|
|
1578
|
-
setSelf: (next) =>
|
|
1584
|
+
setSelf: (next) => {
|
|
1585
|
+
setIntoStore(token, next, store);
|
|
1586
|
+
},
|
|
1579
1587
|
onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
|
|
1580
1588
|
});
|
|
1581
1589
|
if (cleanup) {
|
|
@@ -1660,7 +1668,7 @@ function createMutableAtomFamily(options, store) {
|
|
|
1660
1668
|
key: options.key,
|
|
1661
1669
|
type: `mutable_atom_family`,
|
|
1662
1670
|
subject,
|
|
1663
|
-
install: (
|
|
1671
|
+
install: (s) => createMutableAtomFamily(options, s),
|
|
1664
1672
|
toJson: options.toJson,
|
|
1665
1673
|
fromJson: options.fromJson
|
|
1666
1674
|
}
|
|
@@ -1756,14 +1764,14 @@ function createRegularAtom(options, family, store) {
|
|
|
1756
1764
|
const subject = new Subject();
|
|
1757
1765
|
const newAtom = __spreadProps(__spreadValues({}, options), {
|
|
1758
1766
|
type: `atom`,
|
|
1759
|
-
install: (
|
|
1760
|
-
|
|
1767
|
+
install: (s) => {
|
|
1768
|
+
s.logger.info(
|
|
1761
1769
|
`\u{1F6E0}\uFE0F`,
|
|
1762
1770
|
`atom`,
|
|
1763
1771
|
options.key,
|
|
1764
|
-
`installing in store "${
|
|
1772
|
+
`installing in store "${s.config.name}"`
|
|
1765
1773
|
);
|
|
1766
|
-
return createRegularAtom(options, family,
|
|
1774
|
+
return createRegularAtom(options, family, s);
|
|
1767
1775
|
},
|
|
1768
1776
|
subject
|
|
1769
1777
|
});
|
|
@@ -1783,7 +1791,9 @@ function createRegularAtom(options, family, store) {
|
|
|
1783
1791
|
const cleanupFunctions = [];
|
|
1784
1792
|
for (const effect of options.effects) {
|
|
1785
1793
|
const cleanup = effect({
|
|
1786
|
-
setSelf: (next) =>
|
|
1794
|
+
setSelf: (next) => {
|
|
1795
|
+
setIntoStore(token, next, store);
|
|
1796
|
+
},
|
|
1787
1797
|
onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
|
|
1788
1798
|
});
|
|
1789
1799
|
if (cleanup) {
|
|
@@ -1820,7 +1830,7 @@ function deleteAtom(atomToken, store) {
|
|
|
1820
1830
|
store.logger.error(
|
|
1821
1831
|
`\u274C`,
|
|
1822
1832
|
`atom`,
|
|
1823
|
-
|
|
1833
|
+
key,
|
|
1824
1834
|
`Tried to delete atom, but it does not exist in the store.`
|
|
1825
1835
|
);
|
|
1826
1836
|
}
|
|
@@ -1843,7 +1853,7 @@ function deleteAtom(atomToken, store) {
|
|
|
1843
1853
|
const updateToken = getUpdateToken(atomToken);
|
|
1844
1854
|
deleteAtom(updateToken, store);
|
|
1845
1855
|
}
|
|
1846
|
-
store.logger.info(`\u{1F525}`, `atom`,
|
|
1856
|
+
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1847
1857
|
}
|
|
1848
1858
|
|
|
1849
1859
|
// internal/src/arbitrary.ts
|
|
@@ -1987,7 +1997,7 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
1987
1997
|
tl.transactionKey = currentTransactionKey;
|
|
1988
1998
|
const unsubscribe = currentTransaction.subject.subscribe(
|
|
1989
1999
|
`timeline:${tl.key}`,
|
|
1990
|
-
(
|
|
2000
|
+
(transactionUpdate) => {
|
|
1991
2001
|
var _a2, _b2;
|
|
1992
2002
|
unsubscribe();
|
|
1993
2003
|
if (tl.timeTraveling === null && currentTransactionInstanceId) {
|
|
@@ -1995,11 +2005,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
1995
2005
|
tl.history.splice(tl.at);
|
|
1996
2006
|
}
|
|
1997
2007
|
const filterUpdates = (updates2) => updates2.filter((updateFromTx) => {
|
|
1998
|
-
const
|
|
2008
|
+
const newestStore = newest(store);
|
|
1999
2009
|
if (`updates` in updateFromTx) {
|
|
2000
2010
|
return true;
|
|
2001
2011
|
}
|
|
2002
|
-
const atomOrFamilyKeys =
|
|
2012
|
+
const atomOrFamilyKeys = newestStore.timelineAtoms.getRelatedKeys(tl.key);
|
|
2003
2013
|
return atomOrFamilyKeys ? [...atomOrFamilyKeys].some(
|
|
2004
2014
|
(key) => {
|
|
2005
2015
|
var _a3;
|
|
@@ -2014,11 +2024,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
2014
2024
|
}
|
|
2015
2025
|
return updateFromTx;
|
|
2016
2026
|
});
|
|
2017
|
-
const updates = filterUpdates(
|
|
2027
|
+
const updates = filterUpdates(transactionUpdate.updates);
|
|
2018
2028
|
const timelineTransactionUpdate = __spreadProps(__spreadValues({
|
|
2019
2029
|
type: `transaction_update`,
|
|
2020
2030
|
timestamp: Date.now()
|
|
2021
|
-
},
|
|
2031
|
+
}, transactionUpdate), {
|
|
2022
2032
|
updates
|
|
2023
2033
|
});
|
|
2024
2034
|
const willCapture = (_b2 = (_a2 = tl.shouldCapture) == null ? void 0 : _a2.call(tl, timelineTransactionUpdate, tl)) != null ? _b2 : true;
|
|
@@ -2033,7 +2043,7 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
2033
2043
|
`\u231B`,
|
|
2034
2044
|
`timeline`,
|
|
2035
2045
|
tl.key,
|
|
2036
|
-
`got a transaction_update "${
|
|
2046
|
+
`got a transaction_update "${transactionUpdate.key}"`
|
|
2037
2047
|
);
|
|
2038
2048
|
}
|
|
2039
2049
|
);
|
|
@@ -2133,7 +2143,7 @@ function createTimeline(options, store, data) {
|
|
|
2133
2143
|
transactionKey: null
|
|
2134
2144
|
}, data), {
|
|
2135
2145
|
history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
|
|
2136
|
-
install: (
|
|
2146
|
+
install: (s) => createTimeline(options, s, tl),
|
|
2137
2147
|
subject: new Subject()
|
|
2138
2148
|
});
|
|
2139
2149
|
if (options.shouldCapture) {
|
|
@@ -2431,9 +2441,11 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2431
2441
|
},
|
|
2432
2442
|
transactors: {
|
|
2433
2443
|
get: (token) => getFromStore(token, child),
|
|
2434
|
-
set: (token, value) =>
|
|
2435
|
-
|
|
2436
|
-
|
|
2444
|
+
set: (token, value) => {
|
|
2445
|
+
setIntoStore(token, value, child);
|
|
2446
|
+
},
|
|
2447
|
+
run: (token, identifier = arbitrary()) => actUponStore(token, identifier, child),
|
|
2448
|
+
find: (token, k) => findInStore(token, k, child),
|
|
2437
2449
|
env: () => getEnvironmentData(child)
|
|
2438
2450
|
}
|
|
2439
2451
|
};
|
|
@@ -2470,7 +2482,7 @@ function createTransaction(options, store) {
|
|
|
2470
2482
|
throw thrown;
|
|
2471
2483
|
}
|
|
2472
2484
|
},
|
|
2473
|
-
install: (
|
|
2485
|
+
install: (s) => createTransaction(options, s),
|
|
2474
2486
|
subject: new Subject()
|
|
2475
2487
|
};
|
|
2476
2488
|
const target = newest(store);
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Func, TransactionToken, TransactionUpdate, TransactionOptions, TransactorsWithRunAndEnv, RegularAtomToken, MutableAtomToken, WritableSelectorToken, ReadonlySelectorToken, WritableToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, TimelineUpdate, TimelineOptions, TimelineToken, AtomToken, WritableSelectorFamily, MutableAtomFamily, RegularAtomFamily, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomFamily, SelectorFamily, SelectorToken, RegularAtomFamilyToken, MutableAtomFamilyToken, AtomFamilyToken, ReadonlySelectorFamilyToken, WritableSelectorFamilyToken, SelectorFamilyToken, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, WritableFamilyToken, ReadableFamilyToken, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, Transactors, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
2
2
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
3
3
|
|
|
4
4
|
type primitive = boolean | number | string | null;
|
|
@@ -77,9 +77,9 @@ declare class Junction<const ASide extends string, const BSide extends string, c
|
|
|
77
77
|
|
|
78
78
|
declare const abortTransaction: (store: Store) => void;
|
|
79
79
|
|
|
80
|
-
declare function actUponStore
|
|
80
|
+
declare function actUponStore<F extends Func>(token: TransactionToken<F>, id: string, store: Store): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
81
81
|
|
|
82
|
-
declare const applyTransaction:
|
|
82
|
+
declare const applyTransaction: <F extends Func>(output: ReturnType<F>, store: Store) => void;
|
|
83
83
|
|
|
84
84
|
declare function assignTransactionToContinuity(continuityKey: string, transactionKey: string, store: Store): void;
|
|
85
85
|
|
|
@@ -89,7 +89,7 @@ interface RootStore extends Store {
|
|
|
89
89
|
child: ChildStore | null;
|
|
90
90
|
}
|
|
91
91
|
interface ChildStore extends Store {
|
|
92
|
-
transactionMeta: TransactionProgress<
|
|
92
|
+
transactionMeta: TransactionProgress<Func>;
|
|
93
93
|
parent: ChildStore | RootStore;
|
|
94
94
|
child: ChildStore | null;
|
|
95
95
|
}
|
|
@@ -111,14 +111,14 @@ declare class StatefulSubject<T> extends Subject<T> {
|
|
|
111
111
|
next(value: T): void;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
type Transaction
|
|
114
|
+
type Transaction<F extends Func> = {
|
|
115
115
|
key: string;
|
|
116
116
|
type: `transaction`;
|
|
117
117
|
install: (store: Store) => void;
|
|
118
|
-
subject: Subject<TransactionUpdate
|
|
119
|
-
run: (parameters: Parameters
|
|
118
|
+
subject: Subject<TransactionUpdate<F>>;
|
|
119
|
+
run: (parameters: Parameters<F>, id?: string) => ReturnType<F>;
|
|
120
120
|
};
|
|
121
|
-
declare function createTransaction
|
|
121
|
+
declare function createTransaction<F extends Func>(options: TransactionOptions<F>, store: Store): TransactionToken<F>;
|
|
122
122
|
|
|
123
123
|
declare function getContinuityKey(transactionKey: string, store: Store): string | undefined;
|
|
124
124
|
declare function getEpochNumberOfContinuity(continuityKey: string, store: Store): number | undefined;
|
|
@@ -129,9 +129,9 @@ declare function setEpochNumberOfAction(transactionKey: string, newEpoch: number
|
|
|
129
129
|
|
|
130
130
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
131
131
|
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
132
|
-
type TransactionProgress
|
|
132
|
+
type TransactionProgress<F extends Func> = {
|
|
133
133
|
phase: `applying` | `building`;
|
|
134
|
-
update: TransactionUpdate
|
|
134
|
+
update: TransactionUpdate<F>;
|
|
135
135
|
transactors: TransactorsWithRunAndEnv;
|
|
136
136
|
};
|
|
137
137
|
type TransactionEpoch = {
|
|
@@ -144,7 +144,7 @@ declare function deposit<T extends Transceiver<any>>(state: MutableAtom<T, any>)
|
|
|
144
144
|
declare function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>;
|
|
145
145
|
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
146
146
|
declare function deposit<T>(state: WritableState<T>): WritableToken<T>;
|
|
147
|
-
declare function deposit<T>(state: Transaction<T
|
|
147
|
+
declare function deposit<T extends Func>(state: Transaction<T>): TransactionToken<T>;
|
|
148
148
|
declare function deposit<T>(state: ReadableState<T>): ReadableToken<T>;
|
|
149
149
|
|
|
150
150
|
interface Lineage {
|
|
@@ -179,7 +179,7 @@ type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
|
|
|
179
179
|
timestamp: number;
|
|
180
180
|
atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[];
|
|
181
181
|
};
|
|
182
|
-
type TimelineTransactionUpdate = TransactionUpdate<
|
|
182
|
+
type TimelineTransactionUpdate = TransactionUpdate<Func> & {
|
|
183
183
|
key: string;
|
|
184
184
|
type: `transaction_update`;
|
|
185
185
|
timestamp: number;
|
|
@@ -212,7 +212,7 @@ declare class Store implements Lineage {
|
|
|
212
212
|
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
213
213
|
families: Map<string, WritableSelectorFamily<any, any> | MutableAtomFamily<any, any, any> | RegularAtomFamily<any, any> | ReadonlySelectorFamily<any, any>>;
|
|
214
214
|
timelines: Map<string, Timeline<any>>;
|
|
215
|
-
transactions: Map<string, Transaction<
|
|
215
|
+
transactions: Map<string, Transaction<Func>>;
|
|
216
216
|
atomsThatAreDefault: Set<string>;
|
|
217
217
|
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
218
218
|
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
@@ -222,13 +222,13 @@ declare class Store implements Lineage {
|
|
|
222
222
|
on: {
|
|
223
223
|
atomCreation: Subject<AtomToken<unknown>>;
|
|
224
224
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
225
|
-
transactionCreation: Subject<TransactionToken<
|
|
225
|
+
transactionCreation: Subject<TransactionToken<Func>>;
|
|
226
226
|
timelineCreation: Subject<TimelineToken<unknown>>;
|
|
227
|
-
transactionApplying: StatefulSubject<TransactionProgress<
|
|
227
|
+
transactionApplying: StatefulSubject<TransactionProgress<Func> | null>;
|
|
228
228
|
operationClose: Subject<OperationProgress>;
|
|
229
229
|
};
|
|
230
230
|
operation: OperationProgress;
|
|
231
|
-
transactionMeta: TransactionEpoch | TransactionProgress<
|
|
231
|
+
transactionMeta: TransactionEpoch | TransactionProgress<Func>;
|
|
232
232
|
config: {
|
|
233
233
|
name: string;
|
|
234
234
|
};
|
|
@@ -242,7 +242,7 @@ declare const IMPLICIT: {
|
|
|
242
242
|
};
|
|
243
243
|
declare const clearStore: (store: Store) => void;
|
|
244
244
|
|
|
245
|
-
type Withdrawable = Atom<any> | AtomFamily<any, any> | MutableAtom<any, any> | MutableAtomFamily<any, any, any> | ReadableState<any> |
|
|
245
|
+
type Withdrawable = Atom<any> | AtomFamily<any, any> | MutableAtom<any, any> | MutableAtomFamily<any, any, any> | ReadableState<any> | ReadonlySelector<any> | ReadonlySelectorFamily<any, any> | RegularAtom<any> | RegularAtomFamily<any, any> | Selector<any> | SelectorFamily<any, any> | Timeline<any> | Transaction<any> | WritableSelector<any> | WritableSelectorFamily<any, any> | WritableState<any>;
|
|
246
246
|
declare function withdraw<T>(token: RegularAtomToken<T>, store: Store): RegularAtom<T>;
|
|
247
247
|
declare function withdraw<T extends Transceiver<any>>(token: MutableAtomToken<T, any>, store: Store): MutableAtom<T, any>;
|
|
248
248
|
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T>;
|
|
@@ -257,7 +257,7 @@ declare function withdraw<T, K extends Json.Serializable>(token: AtomFamilyToken
|
|
|
257
257
|
declare function withdraw<T, K extends Json.Serializable>(token: ReadonlySelectorFamilyToken<T, K>, store: Store): ReadonlySelectorFamily<T, any>;
|
|
258
258
|
declare function withdraw<T, K extends Json.Serializable>(token: WritableSelectorFamilyToken<T, K>, store: Store): WritableSelectorFamily<T, any>;
|
|
259
259
|
declare function withdraw<T, K extends Json.Serializable>(token: SelectorFamilyToken<T, K>, store: Store): SelectorFamily<T, any>;
|
|
260
|
-
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends
|
|
260
|
+
declare function withdraw<T extends Func>(token: TransactionToken<T>, store: Store): Transaction<T extends Func ? T : never>;
|
|
261
261
|
declare function withdraw<T>(token: TimelineToken<T>, store: Store): Timeline<T extends TimelineManageable ? T : never>;
|
|
262
262
|
|
|
263
263
|
declare function withdrawOrCreate<T>(token: RegularAtomToken<T>, store: Store): Atom<T>;
|
|
@@ -275,7 +275,7 @@ interface Transceiver<Signal extends Json.Serializable> {
|
|
|
275
275
|
}
|
|
276
276
|
declare function isTransceiver(value: unknown): value is Transceiver<Json.Serializable>;
|
|
277
277
|
type TransceiverMode = `playback` | `record` | `transaction`;
|
|
278
|
-
type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer
|
|
278
|
+
type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer S> ? S : never;
|
|
279
279
|
|
|
280
280
|
declare function createMutableAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, family: FamilyMetadata | undefined, store: Store): MutableAtomToken<T, J>;
|
|
281
281
|
|
|
@@ -449,7 +449,7 @@ declare function subscribeToState<T>(token: ReadableToken<T>, handleUpdate: Upda
|
|
|
449
449
|
|
|
450
450
|
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void, key: string, store: Store) => (() => void);
|
|
451
451
|
|
|
452
|
-
declare const subscribeToTransaction:
|
|
452
|
+
declare const subscribeToTransaction: <F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key: string, store: Store) => (() => void);
|
|
453
453
|
|
|
454
454
|
type AtomIOState = {
|
|
455
455
|
key: string;
|