atom.io 0.18.0 → 0.18.2
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/chunk-3J2EGSBE.js +31 -0
- package/dist/chunk-3J2EGSBE.js.map +1 -0
- package/dist/chunk-A4ZCNKWQ.js +18 -0
- package/dist/chunk-A4ZCNKWQ.js.map +1 -0
- package/dist/{chunk-OEVFAUPE.js → chunk-IZHOMSXA.js} +53 -11
- package/dist/chunk-IZHOMSXA.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +110 -134
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +24 -24
- package/internal/dist/index.js +110 -134
- package/internal/dist/index.js.map +1 -1
- package/internal/src/atom/delete-atom.ts +7 -6
- package/internal/src/caching.ts +6 -6
- package/internal/src/families/create-regular-atom-family.ts +4 -4
- package/internal/src/get-state/get-from-store.ts +2 -5
- package/internal/src/ingest-updates/ingest-atom-update.ts +6 -2
- package/internal/src/mutable/create-mutable-atom-family.ts +4 -4
- package/internal/src/selector/register-selector.ts +3 -14
- package/internal/src/set-state/copy-mutable-if-needed.ts +5 -0
- package/internal/src/set-state/emit-update.ts +25 -11
- package/internal/src/set-state/set-atom.ts +4 -3
- package/internal/src/set-state/set-into-store.ts +2 -5
- package/internal/src/store/withdraw-new-family-member.ts +38 -28
- package/internal/src/store/withdraw.ts +20 -23
- package/internal/src/subscribe/subscribe-to-state.ts +2 -3
- package/internal/src/subscribe/subscribe-to-timeline.ts +0 -5
- package/internal/src/subscribe/subscribe-to-transaction.ts +0 -5
- package/internal/src/timeline/add-atom-to-timeline.ts +6 -15
- package/internal/src/timeline/create-timeline.ts +0 -27
- package/internal/src/transaction/apply-transaction.ts +0 -1
- package/internal/src/transaction/set-epoch-number.ts +0 -1
- package/json/src/index.ts +3 -3
- package/package.json +242 -241
- package/react/dist/index.cjs +2 -3
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.js +2 -3
- package/react/dist/index.js.map +1 -1
- package/react/src/use-tl.ts +2 -2
- package/react-devtools/dist/index.cjs +1 -1
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.js +1 -15
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -2
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +3 -3
- package/realtime/dist/index.cjs +50 -2
- package/realtime/dist/index.cjs.map +1 -1
- package/realtime/dist/index.d.ts +110 -3
- package/realtime/dist/index.js +47 -4
- package/realtime/dist/index.js.map +1 -1
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +14 -4
- package/realtime/src/shared-room-store.ts +48 -0
- package/realtime-client/dist/index.cjs +113 -200
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +2 -5
- package/realtime-client/dist/index.js +22 -190
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +0 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +5 -5
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +10 -0
- package/realtime-client/src/sync-continuity.ts +56 -9
- package/realtime-react/dist/index.cjs +51 -26
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +2 -6
- package/realtime-react/dist/index.js +2 -17
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +0 -2
- package/realtime-server/dist/index.cjs +399 -327
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +55 -60
- package/realtime-server/dist/index.js +394 -319
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +2 -4
- package/realtime-server/src/ipc-sockets/child-socket.ts +135 -0
- package/realtime-server/src/ipc-sockets/custom-socket.ts +90 -0
- package/realtime-server/src/ipc-sockets/index.ts +3 -0
- package/realtime-server/src/ipc-sockets/parent-socket.ts +186 -0
- package/realtime-server/src/realtime-continuity-synchronizer.ts +225 -96
- package/realtime-server/src/realtime-server-stores/index.ts +2 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +50 -31
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +64 -0
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +42 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +49 -26
- package/realtime-testing/dist/index.cjs +51 -11
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.ts +1 -0
- package/realtime-testing/dist/index.js +11 -11
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +11 -11
- package/src/logger.ts +5 -1
- package/dist/chunk-OEVFAUPE.js.map +0 -1
- package/realtime-client/src/sync-server-action.ts +0 -168
- package/realtime-client/src/sync-state.ts +0 -19
- package/realtime-react/src/use-sync-server-action.ts +0 -17
- package/realtime-react/src/use-sync.ts +0 -17
- package/realtime-server/src/ipc-socket.ts +0 -230
- package/realtime-server/src/realtime-action-synchronizer.ts +0 -164
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +0 -97
package/internal/dist/index.cjs
CHANGED
|
@@ -504,27 +504,37 @@ function withdraw(token, store) {
|
|
|
504
504
|
}
|
|
505
505
|
target = target.child;
|
|
506
506
|
}
|
|
507
|
+
throw new NotFoundError(token, store);
|
|
507
508
|
}
|
|
508
509
|
|
|
509
510
|
// internal/src/store/withdraw-new-family-member.ts
|
|
510
|
-
function
|
|
511
|
-
|
|
512
|
-
store
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
511
|
+
function withdrawOrCreate(token, store) {
|
|
512
|
+
try {
|
|
513
|
+
const state = withdraw(token, store);
|
|
514
|
+
return state;
|
|
515
|
+
} catch (notFoundError) {
|
|
516
|
+
if (token.family) {
|
|
517
|
+
store.logger.info(
|
|
518
|
+
`\u{1F46A}`,
|
|
519
|
+
token.type,
|
|
520
|
+
token.key,
|
|
521
|
+
`creating new family member in store "${store.config.name}"`
|
|
522
|
+
);
|
|
523
|
+
const target = newest(store);
|
|
524
|
+
const family = target.families.get(token.family.key);
|
|
525
|
+
if (family) {
|
|
526
|
+
const jsonSubKey = JSON.parse(token.family.subKey);
|
|
527
|
+
family(jsonSubKey);
|
|
528
|
+
const state = withdraw(token, store);
|
|
529
|
+
return state;
|
|
530
|
+
}
|
|
531
|
+
throw new NotFoundError(
|
|
532
|
+
{ key: token.family.key, type: `${token.type}_family` },
|
|
533
|
+
store
|
|
534
|
+
);
|
|
525
535
|
}
|
|
536
|
+
throw notFoundError;
|
|
526
537
|
}
|
|
527
|
-
return void 0;
|
|
528
538
|
}
|
|
529
539
|
|
|
530
540
|
// internal/src/future.ts
|
|
@@ -546,6 +556,24 @@ var Future = class extends Promise {
|
|
|
546
556
|
}
|
|
547
557
|
};
|
|
548
558
|
|
|
559
|
+
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
560
|
+
function copyMutableIfNeeded(atom, origin, target) {
|
|
561
|
+
const originValue = origin.valueMap.get(atom.key);
|
|
562
|
+
const targetValue = target.valueMap.get(atom.key);
|
|
563
|
+
if (originValue === targetValue) {
|
|
564
|
+
if (originValue === void 0) {
|
|
565
|
+
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
566
|
+
}
|
|
567
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
568
|
+
const jsonValue = atom.toJson(originValue);
|
|
569
|
+
const copiedValue = atom.fromJson(jsonValue);
|
|
570
|
+
target.valueMap.set(atom.key, copiedValue);
|
|
571
|
+
new Tracker(atom, origin);
|
|
572
|
+
return copiedValue;
|
|
573
|
+
}
|
|
574
|
+
return targetValue;
|
|
575
|
+
}
|
|
576
|
+
|
|
549
577
|
// internal/src/caching.ts
|
|
550
578
|
function cacheValue(key, value, subject, target) {
|
|
551
579
|
const currentValue = target.valueMap.get(key);
|
|
@@ -572,7 +600,12 @@ function cacheValue(key, value, subject, target) {
|
|
|
572
600
|
return value;
|
|
573
601
|
}
|
|
574
602
|
var readCachedValue = (token, target) => {
|
|
575
|
-
|
|
603
|
+
let value = target.valueMap.get(token.key);
|
|
604
|
+
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
605
|
+
const { parent } = target;
|
|
606
|
+
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
607
|
+
value = copiedValue;
|
|
608
|
+
}
|
|
576
609
|
return value;
|
|
577
610
|
};
|
|
578
611
|
var evictCachedValue = (key, target) => {
|
|
@@ -614,10 +647,11 @@ function createRegularAtomFamily(options, store) {
|
|
|
614
647
|
const subKey = json.stringifyJson(key);
|
|
615
648
|
const family = { key: options.key, subKey };
|
|
616
649
|
const fullKey = `${options.key}(${subKey})`;
|
|
617
|
-
const
|
|
650
|
+
const target2 = newest(store);
|
|
651
|
+
const atomAlreadyCreated = target2.atoms.has(fullKey);
|
|
618
652
|
let token;
|
|
619
|
-
if (
|
|
620
|
-
token =
|
|
653
|
+
if (atomAlreadyCreated) {
|
|
654
|
+
token = { type: `atom`, key: fullKey, family };
|
|
621
655
|
} else {
|
|
622
656
|
const individualOptions = {
|
|
623
657
|
key: fullKey,
|
|
@@ -819,34 +853,33 @@ var markDone = (key, store) => {
|
|
|
819
853
|
store.operation.done.add(key);
|
|
820
854
|
};
|
|
821
855
|
|
|
822
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
823
|
-
function copyMutableIfNeeded(atom, origin, target) {
|
|
824
|
-
const originValue = origin.valueMap.get(atom.key);
|
|
825
|
-
const targetValue = target.valueMap.get(atom.key);
|
|
826
|
-
if (originValue === targetValue) {
|
|
827
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
828
|
-
const jsonValue = atom.toJson(originValue);
|
|
829
|
-
const copiedValue = atom.fromJson(jsonValue);
|
|
830
|
-
target.valueMap.set(atom.key, copiedValue);
|
|
831
|
-
new Tracker(atom, origin);
|
|
832
|
-
return copiedValue;
|
|
833
|
-
}
|
|
834
|
-
return targetValue;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
856
|
// internal/src/set-state/emit-update.ts
|
|
838
857
|
var emitUpdate = (state, update, store) => {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
858
|
+
switch (state.type) {
|
|
859
|
+
case `mutable_atom`:
|
|
860
|
+
store.logger.info(
|
|
861
|
+
`\u{1F4E2}`,
|
|
862
|
+
state.type,
|
|
863
|
+
state.key,
|
|
864
|
+
`is now (`,
|
|
865
|
+
update.newValue,
|
|
866
|
+
`) subscribers:`,
|
|
867
|
+
state.subject.subscribers
|
|
868
|
+
);
|
|
869
|
+
break;
|
|
870
|
+
default:
|
|
871
|
+
store.logger.info(
|
|
872
|
+
`\u{1F4E2}`,
|
|
873
|
+
state.type,
|
|
874
|
+
state.key,
|
|
875
|
+
`went (`,
|
|
876
|
+
update.oldValue,
|
|
877
|
+
`->`,
|
|
878
|
+
update.newValue,
|
|
879
|
+
`) subscribers:`,
|
|
880
|
+
state.subject.subscribers
|
|
881
|
+
);
|
|
882
|
+
}
|
|
850
883
|
state.subject.next(update);
|
|
851
884
|
};
|
|
852
885
|
|
|
@@ -947,14 +980,16 @@ var setAtom = (atom, next, target) => {
|
|
|
947
980
|
stowUpdate(atom, update, target);
|
|
948
981
|
} else if (atom.key.startsWith(`*`)) {
|
|
949
982
|
const mutableKey = atom.key.slice(1);
|
|
950
|
-
target.atoms.get(mutableKey);
|
|
983
|
+
const mutableAtom = target.atoms.get(mutableKey);
|
|
951
984
|
let transceiver = target.valueMap.get(mutableKey);
|
|
952
|
-
if (
|
|
985
|
+
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
953
986
|
const { parent } = target;
|
|
954
|
-
const copiedValue = copyMutableIfNeeded(
|
|
987
|
+
const copiedValue = copyMutableIfNeeded(mutableAtom, parent, target);
|
|
955
988
|
transceiver = copiedValue;
|
|
956
989
|
}
|
|
957
|
-
transceiver.do(update.newValue);
|
|
990
|
+
const accepted = transceiver.do(update.newValue) === null;
|
|
991
|
+
if (accepted)
|
|
992
|
+
evictDownStream(mutableAtom, target);
|
|
958
993
|
}
|
|
959
994
|
}
|
|
960
995
|
};
|
|
@@ -974,15 +1009,11 @@ var setAtomOrSelector = (state, value, store) => {
|
|
|
974
1009
|
|
|
975
1010
|
// internal/src/set-state/set-into-store.ts
|
|
976
1011
|
function setIntoStore(token, value, store) {
|
|
977
|
-
var _a;
|
|
978
1012
|
const rejection = openOperation(token, store);
|
|
979
1013
|
if (rejection) {
|
|
980
1014
|
return;
|
|
981
1015
|
}
|
|
982
|
-
const state = (
|
|
983
|
-
if (state === void 0) {
|
|
984
|
-
throw new NotFoundError(token, store);
|
|
985
|
-
}
|
|
1016
|
+
const state = withdrawOrCreate(token, store);
|
|
986
1017
|
setAtomOrSelector(state, value, store);
|
|
987
1018
|
closeOperation(store);
|
|
988
1019
|
}
|
|
@@ -1067,14 +1098,8 @@ var updateSelectorAtoms = (selectorKey, dependency, store) => {
|
|
|
1067
1098
|
// internal/src/selector/register-selector.ts
|
|
1068
1099
|
var registerSelector = (selectorKey, store) => ({
|
|
1069
1100
|
get: (dependency) => {
|
|
1070
|
-
var _a;
|
|
1071
1101
|
const target = newest(store);
|
|
1072
|
-
const dependencyState = (
|
|
1073
|
-
if (dependencyState === void 0) {
|
|
1074
|
-
throw new Error(
|
|
1075
|
-
`State "${dependency.key}" not found in store "${store.config.name}".`
|
|
1076
|
-
);
|
|
1077
|
-
}
|
|
1102
|
+
const dependencyState = withdrawOrCreate(dependency, store);
|
|
1078
1103
|
const dependencyValue = readOrComputeValue(dependencyState, store);
|
|
1079
1104
|
store.logger.info(
|
|
1080
1105
|
`\u{1F50C}`,
|
|
@@ -1097,12 +1122,7 @@ var registerSelector = (selectorKey, store) => ({
|
|
|
1097
1122
|
return dependencyValue;
|
|
1098
1123
|
},
|
|
1099
1124
|
set: (WritableToken, newValue) => {
|
|
1100
|
-
const state =
|
|
1101
|
-
if (state === void 0) {
|
|
1102
|
-
throw new Error(
|
|
1103
|
-
`State "${WritableToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
1104
|
-
);
|
|
1105
|
-
}
|
|
1125
|
+
const state = withdrawOrCreate(WritableToken, store);
|
|
1106
1126
|
setAtomOrSelector(state, newValue, store);
|
|
1107
1127
|
},
|
|
1108
1128
|
find: (token, key) => findInStore(token, key, store)
|
|
@@ -1290,8 +1310,7 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
1290
1310
|
|
|
1291
1311
|
// internal/src/subscribe/subscribe-to-state.ts
|
|
1292
1312
|
function subscribeToState(token, handleUpdate, key, store) {
|
|
1293
|
-
|
|
1294
|
-
const state = (_a = withdraw(token, store)) != null ? _a : withdrawNewFamilyMember(token, store);
|
|
1313
|
+
const state = withdrawOrCreate(token, store);
|
|
1295
1314
|
if (state === void 0) {
|
|
1296
1315
|
throw new Error(
|
|
1297
1316
|
`State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
@@ -1326,11 +1345,6 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1326
1345
|
// internal/src/subscribe/subscribe-to-timeline.ts
|
|
1327
1346
|
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1328
1347
|
const tl = withdraw(token, store);
|
|
1329
|
-
if (tl === void 0) {
|
|
1330
|
-
throw new Error(
|
|
1331
|
-
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
1348
|
store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
|
|
1335
1349
|
const unsubscribe = tl.subject.subscribe(key, handleUpdate);
|
|
1336
1350
|
return () => {
|
|
@@ -1347,11 +1361,6 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
|
1347
1361
|
// internal/src/subscribe/subscribe-to-transaction.ts
|
|
1348
1362
|
var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
1349
1363
|
const tx = withdraw(token, store);
|
|
1350
|
-
if (tx === void 0) {
|
|
1351
|
-
throw new Error(
|
|
1352
|
-
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
1353
|
-
);
|
|
1354
|
-
}
|
|
1355
1364
|
store.logger.info(
|
|
1356
1365
|
`\u{1F440}`,
|
|
1357
1366
|
`transaction`,
|
|
@@ -1626,10 +1635,11 @@ function createMutableAtomFamily(options, store) {
|
|
|
1626
1635
|
const subKey = json.stringifyJson(key);
|
|
1627
1636
|
const family = { key: options.key, subKey };
|
|
1628
1637
|
const fullKey = `${options.key}(${subKey})`;
|
|
1629
|
-
const
|
|
1638
|
+
const target2 = newest(store);
|
|
1639
|
+
const atomAlreadyCreated = target2.atoms.has(fullKey);
|
|
1630
1640
|
let token;
|
|
1631
|
-
if (
|
|
1632
|
-
token =
|
|
1641
|
+
if (atomAlreadyCreated) {
|
|
1642
|
+
token = { type: `mutable_atom`, key: fullKey, family };
|
|
1633
1643
|
} else {
|
|
1634
1644
|
const individualOptions = {
|
|
1635
1645
|
key: fullKey,
|
|
@@ -1829,6 +1839,10 @@ function deleteAtom(atomToken, store) {
|
|
|
1829
1839
|
target.selectorAtoms.delete(key);
|
|
1830
1840
|
target.atomsThatAreDefault.delete(key);
|
|
1831
1841
|
target.timelineAtoms.delete(key);
|
|
1842
|
+
if (atomToken.type === `mutable_atom`) {
|
|
1843
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1844
|
+
deleteAtom(updateToken, store);
|
|
1845
|
+
}
|
|
1832
1846
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1833
1847
|
}
|
|
1834
1848
|
|
|
@@ -1848,11 +1862,7 @@ function getEnvironmentData(store) {
|
|
|
1848
1862
|
|
|
1849
1863
|
// internal/src/get-state/get-from-store.ts
|
|
1850
1864
|
function getFromStore(token, store) {
|
|
1851
|
-
|
|
1852
|
-
const state = (_a = withdraw(token, store)) != null ? _a : withdrawNewFamilyMember(token, store);
|
|
1853
|
-
if (state === void 0) {
|
|
1854
|
-
throw new NotFoundError(token, store);
|
|
1855
|
-
}
|
|
1865
|
+
const state = withdrawOrCreate(token, store);
|
|
1856
1866
|
return readOrComputeValue(state, store);
|
|
1857
1867
|
}
|
|
1858
1868
|
|
|
@@ -1860,7 +1870,11 @@ function getFromStore(token, store) {
|
|
|
1860
1870
|
function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
1861
1871
|
const { key, newValue, oldValue } = atomUpdate;
|
|
1862
1872
|
const value = applying === `newValue` ? newValue : oldValue;
|
|
1863
|
-
|
|
1873
|
+
const token = { key, type: `atom` };
|
|
1874
|
+
if (atomUpdate.family) {
|
|
1875
|
+
Object.assign(token, { family: atomUpdate.family });
|
|
1876
|
+
}
|
|
1877
|
+
setIntoStore(token, value, store);
|
|
1864
1878
|
}
|
|
1865
1879
|
|
|
1866
1880
|
// internal/src/ingest-updates/ingest-selector-update.ts
|
|
@@ -1920,16 +1934,11 @@ var LazyMap = class extends Map {
|
|
|
1920
1934
|
// internal/src/timeline/add-atom-to-timeline.ts
|
|
1921
1935
|
var addAtomToTimeline = (atomToken, tl, store) => {
|
|
1922
1936
|
let maybeAtom = withdraw(atomToken, store);
|
|
1923
|
-
if (
|
|
1937
|
+
if (maybeAtom.type === `mutable_atom`) {
|
|
1924
1938
|
const updateToken = getUpdateToken(maybeAtom);
|
|
1925
1939
|
maybeAtom = withdraw(updateToken, store);
|
|
1926
1940
|
}
|
|
1927
1941
|
const atom = maybeAtom;
|
|
1928
|
-
if (atom === void 0) {
|
|
1929
|
-
throw new Error(
|
|
1930
|
-
`Cannot subscribe to atom "${atomToken.key}" because it has not been initialized in store "${store.config.name}"`
|
|
1931
|
-
);
|
|
1932
|
-
}
|
|
1933
1942
|
store.timelineAtoms.set({ atomKey: atom.key, timelineKey: tl.key });
|
|
1934
1943
|
atom.subject.subscribe(`timeline`, (update) => {
|
|
1935
1944
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -1961,15 +1970,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
1961
1970
|
}
|
|
1962
1971
|
}
|
|
1963
1972
|
if (currentTransactionKey) {
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
throw new Error(
|
|
1970
|
-
`Transaction "${currentTransactionKey}" not found in store "${store.config.name}". This is surprising, because we are in the application phase of "${currentTransactionKey}".`
|
|
1971
|
-
);
|
|
1972
|
-
}
|
|
1973
|
+
const txToken = {
|
|
1974
|
+
key: currentTransactionKey,
|
|
1975
|
+
type: `transaction`
|
|
1976
|
+
};
|
|
1977
|
+
const currentTransaction = withdraw(txToken, store);
|
|
1973
1978
|
if (tl.transactionKey !== currentTransactionKey) {
|
|
1974
1979
|
if (tl.transactionKey) {
|
|
1975
1980
|
store.logger.error(
|
|
@@ -2141,15 +2146,6 @@ function createTimeline(options, store, data) {
|
|
|
2141
2146
|
if (tokenOrFamily.type === `atom_family` || tokenOrFamily.type === `mutable_atom_family`) {
|
|
2142
2147
|
const familyToken = tokenOrFamily;
|
|
2143
2148
|
const family = withdraw(familyToken, store);
|
|
2144
|
-
if (family === void 0) {
|
|
2145
|
-
store.logger.error(
|
|
2146
|
-
`\u274C`,
|
|
2147
|
-
`timeline`,
|
|
2148
|
-
options.key,
|
|
2149
|
-
`Failed to add family "${familyToken.key}" because it does not exist in the store`
|
|
2150
|
-
);
|
|
2151
|
-
continue;
|
|
2152
|
-
}
|
|
2153
2149
|
const familyKey = family.key;
|
|
2154
2150
|
target.timelineAtoms.set({ atomKey: familyKey, timelineKey });
|
|
2155
2151
|
family.subject.subscribe(`timeline:${options.key}`, (token2) => {
|
|
@@ -2162,26 +2158,8 @@ function createTimeline(options, store, data) {
|
|
|
2162
2158
|
}
|
|
2163
2159
|
} else {
|
|
2164
2160
|
let atom = withdraw(tokenOrFamily, store);
|
|
2165
|
-
if (atom === void 0) {
|
|
2166
|
-
store.logger.error(
|
|
2167
|
-
`\u274C`,
|
|
2168
|
-
`timeline`,
|
|
2169
|
-
options.key,
|
|
2170
|
-
`Failed to add atom "${atomKey}" because it does not exist in the store`
|
|
2171
|
-
);
|
|
2172
|
-
continue;
|
|
2173
|
-
}
|
|
2174
2161
|
if (isMutable(atom)) {
|
|
2175
2162
|
const updateAtom = withdraw(getUpdateToken(atom), store);
|
|
2176
|
-
if (updateAtom === void 0) {
|
|
2177
|
-
store.logger.error(
|
|
2178
|
-
`\u274C`,
|
|
2179
|
-
`timeline`,
|
|
2180
|
-
options.key,
|
|
2181
|
-
`Failed to add update atom "${atomKey}" because it does not exist in the store`
|
|
2182
|
-
);
|
|
2183
|
-
continue;
|
|
2184
|
-
}
|
|
2185
2163
|
atom = updateAtom;
|
|
2186
2164
|
atomKey = atom.key;
|
|
2187
2165
|
}
|
|
@@ -2328,7 +2306,6 @@ function setEpochNumberOfAction(transactionKey, newEpoch, store) {
|
|
|
2328
2306
|
const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
2329
2307
|
if (continuityKey !== void 0) {
|
|
2330
2308
|
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2331
|
-
console.log(`epoch is now`, newEpoch);
|
|
2332
2309
|
}
|
|
2333
2310
|
}
|
|
2334
2311
|
|
|
@@ -2380,7 +2357,6 @@ var applyTransaction = (output, store) => {
|
|
|
2380
2357
|
}
|
|
2381
2358
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2382
2359
|
if (isRootStore(parent)) {
|
|
2383
|
-
console.log(child.transactionMeta.update);
|
|
2384
2360
|
setEpochNumberOfAction(
|
|
2385
2361
|
child.transactionMeta.update.key,
|
|
2386
2362
|
child.transactionMeta.update.epoch,
|
|
@@ -2607,6 +2583,6 @@ exports.traceAllSelectorAtoms = traceAllSelectorAtoms;
|
|
|
2607
2583
|
exports.traceSelectorAtoms = traceSelectorAtoms;
|
|
2608
2584
|
exports.updateSelectorAtoms = updateSelectorAtoms;
|
|
2609
2585
|
exports.withdraw = withdraw;
|
|
2610
|
-
exports.
|
|
2586
|
+
exports.withdrawOrCreate = withdrawOrCreate;
|
|
2611
2587
|
//# sourceMappingURL=out.js.map
|
|
2612
2588
|
//# sourceMappingURL=index.cjs.map
|