atom.io 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +62 -40
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.ts +8 -2
- package/data/dist/index.js +64 -42
- package/data/dist/index.js.map +1 -1
- package/data/src/dict.ts +8 -4
- package/data/src/join.ts +74 -33
- package/data/src/struct-family.ts +18 -17
- package/dist/chunk-OEVFAUPE.js +289 -0
- package/dist/chunk-OEVFAUPE.js.map +1 -0
- package/dist/index.cjs +4 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +62 -51
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +163 -64
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +94 -70
- package/internal/dist/index.js +155 -59
- package/internal/dist/index.js.map +1 -1
- package/internal/src/arbitrary.ts +3 -0
- package/internal/src/caching.ts +8 -6
- package/internal/src/families/find-in-store.ts +16 -0
- package/internal/src/get-environment-data.ts +4 -7
- package/internal/src/index.ts +6 -5
- package/internal/src/ingest-updates/ingest-transaction-update.ts +0 -1
- package/internal/src/selector/create-standalone-selector.ts +0 -2
- package/internal/src/set-state/set-atom.ts +14 -18
- package/internal/src/store/store.ts +14 -2
- package/internal/src/store/withdraw.ts +72 -2
- package/internal/src/subscribe/subscribe-to-timeline.ts +2 -2
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +12 -1
- package/internal/src/transaction/act-upon-store.ts +19 -0
- package/internal/src/transaction/apply-transaction.ts +7 -1
- package/internal/src/transaction/assign-transaction-to-continuity.ts +18 -0
- package/internal/src/transaction/build-transaction.ts +7 -6
- package/internal/src/transaction/create-transaction.ts +1 -1
- package/internal/src/transaction/get-epoch-number.ts +40 -0
- package/internal/src/transaction/index.ts +10 -1
- package/internal/src/transaction/set-epoch-number.ts +31 -0
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.ts +3 -3
- package/introspection/dist/index.js.map +1 -1
- package/introspection/src/attach-introspection-states.ts +6 -2
- package/introspection/src/attach-timeline-family.ts +5 -2
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.d.ts +3 -1
- package/json/src/index.ts +6 -2
- package/package.json +24 -13
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js.map +1 -1
- package/react/src/use-json.ts +1 -1
- package/react-devtools/dist/index.cjs +131 -134
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.ts +3 -3
- package/react-devtools/dist/index.js +103 -106
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -5
- package/react-devtools/src/TimelineIndex.tsx +3 -3
- package/react-devtools/src/TransactionIndex.tsx +9 -8
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +4 -4
- package/realtime/dist/index.cjs +72 -0
- package/realtime/dist/index.cjs.map +1 -0
- package/realtime/dist/index.d.ts +39 -0
- package/realtime/dist/index.js +68 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/package.json +16 -0
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +152 -0
- package/realtime-client/dist/index.cjs +389 -48
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +16 -9
- package/realtime-client/dist/index.js +100 -37
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +8 -5
- package/realtime-client/src/{pull-family-member.ts → pull-atom-family-member.ts} +2 -2
- package/realtime-client/src/{pull-state.ts → pull-atom.ts} +2 -2
- package/realtime-client/src/{pull-mutable-family-member.ts → pull-mutable-atom-family-member.ts} +1 -1
- package/realtime-client/src/{pull-mutable.ts → pull-mutable-atom.ts} +1 -1
- package/realtime-client/src/pull-selector-family-member.ts +42 -0
- package/realtime-client/src/pull-selector.ts +38 -0
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +2 -2
- package/realtime-client/src/realtime-client-stores/client-sync-store.ts +7 -7
- package/realtime-client/src/sync-continuity.ts +321 -0
- package/realtime-client/src/sync-server-action.ts +18 -20
- package/realtime-react/dist/index.cjs +330 -15
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +26 -6
- package/realtime-react/dist/index.js +43 -12
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +6 -3
- package/realtime-react/src/use-pull-atom-family-member.ts +21 -0
- package/realtime-react/src/{use-pull-family-member.ts → use-pull-atom.ts} +6 -5
- package/realtime-react/src/{use-pull-mutable.ts → use-pull-mutable-atom.ts} +4 -3
- package/realtime-react/src/use-pull-mutable-family-member.ts +9 -4
- package/realtime-react/src/use-pull-selector-family-member.ts +21 -0
- package/realtime-react/src/{use-pull.ts → use-pull-selector.ts} +7 -5
- package/realtime-react/src/use-push.ts +3 -2
- package/realtime-react/src/use-server-action.ts +3 -2
- package/realtime-react/src/use-sync-continuity.ts +12 -0
- package/realtime-react/src/use-sync-server-action.ts +3 -2
- package/realtime-server/dist/index.cjs +568 -242
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +124 -49
- package/realtime-server/dist/index.js +555 -238
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +18 -2
- package/realtime-server/src/ipc-socket.ts +230 -0
- package/realtime-server/src/realtime-action-receiver.ts +8 -5
- package/realtime-server/src/realtime-action-synchronizer.ts +40 -28
- package/realtime-server/src/realtime-continuity-synchronizer.ts +247 -0
- package/realtime-server/src/realtime-family-provider.ts +30 -71
- package/realtime-server/src/realtime-mutable-family-provider.ts +24 -86
- package/realtime-server/src/realtime-server-stores/index.ts +3 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +90 -0
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +97 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +2 -72
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +14 -29
- package/realtime-server/src/realtime-state-receiver.ts +0 -1
- package/realtime-testing/dist/index.cjs +28 -28
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.js +28 -27
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +38 -28
- package/src/atom.ts +49 -31
- package/src/logger.ts +10 -5
- package/src/selector.ts +44 -25
- package/src/subscribe.ts +2 -1
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +13 -17
- package/src/validators.ts +15 -9
- package/dist/chunk-H4Q5FTPZ.js +0 -11
- package/dist/chunk-H4Q5FTPZ.js.map +0 -1
- package/internal/src/set-state/copy-mutable-in-transaction.ts +0 -19
package/internal/dist/index.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var json = require('atom.io/json');
|
|
4
4
|
var atom_io = require('atom.io');
|
|
5
|
-
var internal = require('atom.io/internal');
|
|
6
5
|
|
|
7
6
|
var __defProp = Object.defineProperty;
|
|
8
7
|
var __defProps = Object.defineProperties;
|
|
@@ -333,6 +332,14 @@ var StatefulSubject = class extends Subject {
|
|
|
333
332
|
}
|
|
334
333
|
};
|
|
335
334
|
|
|
335
|
+
// internal/src/transaction/is-root-store.ts
|
|
336
|
+
function isRootStore(store) {
|
|
337
|
+
return `epoch` in store.transactionMeta;
|
|
338
|
+
}
|
|
339
|
+
function isChildStore(store) {
|
|
340
|
+
return `phase` in store.transactionMeta;
|
|
341
|
+
}
|
|
342
|
+
|
|
336
343
|
// internal/src/store/store.ts
|
|
337
344
|
var Store = class {
|
|
338
345
|
constructor(name, store = null) {
|
|
@@ -376,7 +383,11 @@ var Store = class {
|
|
|
376
383
|
};
|
|
377
384
|
this.operation = { open: false };
|
|
378
385
|
this.transactionMeta = {
|
|
379
|
-
epoch:
|
|
386
|
+
epoch: /* @__PURE__ */ new Map(),
|
|
387
|
+
actionContinuities: new Junction({
|
|
388
|
+
between: [`continuity`, `action`],
|
|
389
|
+
cardinality: `1:n`
|
|
390
|
+
})
|
|
380
391
|
};
|
|
381
392
|
this.config = {
|
|
382
393
|
name: `IMPLICIT_STORE`
|
|
@@ -401,7 +412,14 @@ var Store = class {
|
|
|
401
412
|
if (store !== null) {
|
|
402
413
|
this.valueMap = new Map(store == null ? void 0 : store.valueMap);
|
|
403
414
|
this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
|
|
404
|
-
|
|
415
|
+
if (isRootStore(store)) {
|
|
416
|
+
this.transactionMeta = {
|
|
417
|
+
epoch: new Map(store == null ? void 0 : store.transactionMeta.epoch),
|
|
418
|
+
actionContinuities: new Junction(
|
|
419
|
+
store == null ? void 0 : store.transactionMeta.actionContinuities.toJSON()
|
|
420
|
+
)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
405
423
|
this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
|
|
406
424
|
name
|
|
407
425
|
});
|
|
@@ -468,6 +486,12 @@ function withdraw(token, store) {
|
|
|
468
486
|
case `readonly_selector`:
|
|
469
487
|
withdrawn = target.readonlySelectors.get(token.key);
|
|
470
488
|
break;
|
|
489
|
+
case `atom_family`:
|
|
490
|
+
case `mutable_atom_family`:
|
|
491
|
+
case `selector_family`:
|
|
492
|
+
case `readonly_selector_family`:
|
|
493
|
+
withdrawn = target.families.get(token.key);
|
|
494
|
+
break;
|
|
471
495
|
case `timeline`:
|
|
472
496
|
withdrawn = target.timelines.get(token.key);
|
|
473
497
|
break;
|
|
@@ -522,34 +546,6 @@ var Future = class extends Promise {
|
|
|
522
546
|
}
|
|
523
547
|
};
|
|
524
548
|
|
|
525
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
526
|
-
function copyMutableIfNeeded(atom, origin, target) {
|
|
527
|
-
const originValue = origin.valueMap.get(atom.key);
|
|
528
|
-
const targetValue = target.valueMap.get(atom.key);
|
|
529
|
-
if (originValue === targetValue) {
|
|
530
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
531
|
-
const jsonValue = atom.toJson(originValue);
|
|
532
|
-
const copiedValue = atom.fromJson(jsonValue);
|
|
533
|
-
target.valueMap.set(atom.key, copiedValue);
|
|
534
|
-
new Tracker(atom, origin);
|
|
535
|
-
return copiedValue;
|
|
536
|
-
}
|
|
537
|
-
return targetValue;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// internal/src/set-state/copy-mutable-in-transaction.ts
|
|
541
|
-
function copyMutableIfWithinTransaction(oldValue, atom, store) {
|
|
542
|
-
const target = newest(store);
|
|
543
|
-
const parent = target.parent;
|
|
544
|
-
if (parent !== null) {
|
|
545
|
-
if (atom.type === `mutable_atom`) {
|
|
546
|
-
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
547
|
-
return copiedValue;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return oldValue;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
549
|
// internal/src/caching.ts
|
|
554
550
|
function cacheValue(key, value, subject, target) {
|
|
555
551
|
const currentValue = target.valueMap.get(key);
|
|
@@ -576,10 +572,7 @@ function cacheValue(key, value, subject, target) {
|
|
|
576
572
|
return value;
|
|
577
573
|
}
|
|
578
574
|
var readCachedValue = (token, target) => {
|
|
579
|
-
|
|
580
|
-
if (token.type === `atom`) {
|
|
581
|
-
value = copyMutableIfWithinTransaction(value, token, target);
|
|
582
|
-
}
|
|
575
|
+
const value = target.valueMap.get(token.key);
|
|
583
576
|
return value;
|
|
584
577
|
};
|
|
585
578
|
var evictCachedValue = (key, target) => {
|
|
@@ -764,14 +757,6 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
|
|
|
764
757
|
originalThing instanceof Function ? originalThing() : originalThing
|
|
765
758
|
) : nextVersionOfThing;
|
|
766
759
|
|
|
767
|
-
// internal/src/transaction/is-root-store.ts
|
|
768
|
-
function isRootStore(store) {
|
|
769
|
-
return `epoch` in store.transactionMeta;
|
|
770
|
-
}
|
|
771
|
-
function isChildStore(store) {
|
|
772
|
-
return `phase` in store.transactionMeta;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
760
|
// internal/src/operation.ts
|
|
776
761
|
var openOperation = (token, store) => {
|
|
777
762
|
if (store.operation.open) {
|
|
@@ -834,6 +819,21 @@ var markDone = (key, store) => {
|
|
|
834
819
|
store.operation.done.add(key);
|
|
835
820
|
};
|
|
836
821
|
|
|
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
837
|
// internal/src/set-state/emit-update.ts
|
|
838
838
|
var emitUpdate = (state, update, store) => {
|
|
839
839
|
store.logger.info(
|
|
@@ -925,7 +925,12 @@ var stowUpdate = (state, update, store) => {
|
|
|
925
925
|
// internal/src/set-state/set-atom.ts
|
|
926
926
|
var setAtom = (atom, next, target) => {
|
|
927
927
|
const oldValue = readOrComputeValue(atom, target);
|
|
928
|
-
let newValue =
|
|
928
|
+
let newValue = oldValue;
|
|
929
|
+
if (atom.type === `mutable_atom` && isChildStore(target)) {
|
|
930
|
+
const { parent } = target;
|
|
931
|
+
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
932
|
+
newValue = copiedValue;
|
|
933
|
+
}
|
|
929
934
|
newValue = become(next)(newValue);
|
|
930
935
|
target.logger.info(`\u{1F4DD}`, `atom`, atom.key, `set to`, newValue);
|
|
931
936
|
newValue = cacheValue(atom.key, newValue, atom.subject, target);
|
|
@@ -942,19 +947,14 @@ var setAtom = (atom, next, target) => {
|
|
|
942
947
|
stowUpdate(atom, update, target);
|
|
943
948
|
} else if (atom.key.startsWith(`*`)) {
|
|
944
949
|
const mutableKey = atom.key.slice(1);
|
|
945
|
-
|
|
946
|
-
let
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
`\u274C`,
|
|
952
|
-
`mutable_atom`,
|
|
953
|
-
mutableKey,
|
|
954
|
-
`could not be updated.`,
|
|
955
|
-
typeof output === `number` ? `Expected update number ${mutable.cacheUpdateNumber + 1}, but got ${output}` : output
|
|
956
|
-
);
|
|
950
|
+
target.atoms.get(mutableKey);
|
|
951
|
+
let transceiver = target.valueMap.get(mutableKey);
|
|
952
|
+
if (atom.type === `mutable_atom` && isChildStore(target)) {
|
|
953
|
+
const { parent } = target;
|
|
954
|
+
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
955
|
+
transceiver = copiedValue;
|
|
957
956
|
}
|
|
957
|
+
transceiver.do(update.newValue);
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
960
|
};
|
|
@@ -1322,8 +1322,10 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1322
1322
|
};
|
|
1323
1323
|
return unsubscribe;
|
|
1324
1324
|
}
|
|
1325
|
+
|
|
1326
|
+
// internal/src/subscribe/subscribe-to-timeline.ts
|
|
1325
1327
|
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1326
|
-
const tl =
|
|
1328
|
+
const tl = withdraw(token, store);
|
|
1327
1329
|
if (tl === void 0) {
|
|
1328
1330
|
throw new Error(
|
|
1329
1331
|
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
@@ -1341,8 +1343,10 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
|
1341
1343
|
unsubscribe();
|
|
1342
1344
|
};
|
|
1343
1345
|
};
|
|
1346
|
+
|
|
1347
|
+
// internal/src/subscribe/subscribe-to-transaction.ts
|
|
1344
1348
|
var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
1345
|
-
const tx =
|
|
1349
|
+
const tx = withdraw(token, store);
|
|
1346
1350
|
if (tx === void 0) {
|
|
1347
1351
|
throw new Error(
|
|
1348
1352
|
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
@@ -1828,10 +1832,16 @@ function deleteAtom(atomToken, store) {
|
|
|
1828
1832
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1829
1833
|
}
|
|
1830
1834
|
|
|
1835
|
+
// internal/src/arbitrary.ts
|
|
1836
|
+
function arbitrary(random = Math.random) {
|
|
1837
|
+
return random().toString(36).slice(2);
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1831
1840
|
// internal/src/get-environment-data.ts
|
|
1832
1841
|
function getEnvironmentData(store) {
|
|
1833
1842
|
return {
|
|
1834
|
-
|
|
1843
|
+
window: typeof window === `undefined` ? void 0 : window,
|
|
1844
|
+
global: typeof global === `undefined` ? void 0 : global,
|
|
1835
1845
|
store
|
|
1836
1846
|
};
|
|
1837
1847
|
}
|
|
@@ -2129,7 +2139,17 @@ function createTimeline(options, store, data) {
|
|
|
2129
2139
|
for (const tokenOrFamily of options.atoms) {
|
|
2130
2140
|
let atomKey = tokenOrFamily.key;
|
|
2131
2141
|
if (tokenOrFamily.type === `atom_family` || tokenOrFamily.type === `mutable_atom_family`) {
|
|
2132
|
-
const
|
|
2142
|
+
const familyToken = tokenOrFamily;
|
|
2143
|
+
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
|
+
}
|
|
2133
2153
|
const familyKey = family.key;
|
|
2134
2154
|
target.timelineAtoms.set({ atomKey: familyKey, timelineKey });
|
|
2135
2155
|
family.subject.subscribe(`timeline:${options.key}`, (token2) => {
|
|
@@ -2282,6 +2302,36 @@ var abortTransaction = (store) => {
|
|
|
2282
2302
|
target.parent.child = null;
|
|
2283
2303
|
};
|
|
2284
2304
|
|
|
2305
|
+
// internal/src/transaction/act-upon-store.ts
|
|
2306
|
+
function actUponStore(token, id, store) {
|
|
2307
|
+
return (...parameters) => {
|
|
2308
|
+
const tx = withdraw(token, store);
|
|
2309
|
+
if (tx) {
|
|
2310
|
+
return tx.run(parameters, id);
|
|
2311
|
+
}
|
|
2312
|
+
throw new NotFoundError(token, store);
|
|
2313
|
+
};
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
// internal/src/transaction/set-epoch-number.ts
|
|
2317
|
+
function setEpochNumberOfContinuity(continuityKey, newEpoch, store) {
|
|
2318
|
+
const isRoot = isRootStore(store);
|
|
2319
|
+
if (isRoot && continuityKey) {
|
|
2320
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
function setEpochNumberOfAction(transactionKey, newEpoch, store) {
|
|
2324
|
+
const isRoot = isRootStore(store);
|
|
2325
|
+
if (!isRoot) {
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2328
|
+
const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
2329
|
+
if (continuityKey !== void 0) {
|
|
2330
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2331
|
+
console.log(`epoch is now`, newEpoch);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2285
2335
|
// internal/src/transaction/apply-transaction.ts
|
|
2286
2336
|
var applyTransaction = (output, store) => {
|
|
2287
2337
|
var _a;
|
|
@@ -2330,7 +2380,12 @@ var applyTransaction = (output, store) => {
|
|
|
2330
2380
|
}
|
|
2331
2381
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2332
2382
|
if (isRootStore(parent)) {
|
|
2333
|
-
|
|
2383
|
+
console.log(child.transactionMeta.update);
|
|
2384
|
+
setEpochNumberOfAction(
|
|
2385
|
+
child.transactionMeta.update.key,
|
|
2386
|
+
child.transactionMeta.update.epoch,
|
|
2387
|
+
parent
|
|
2388
|
+
);
|
|
2334
2389
|
const myTransaction = withdraw(
|
|
2335
2390
|
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
2336
2391
|
store
|
|
@@ -2347,6 +2402,21 @@ var applyTransaction = (output, store) => {
|
|
|
2347
2402
|
}
|
|
2348
2403
|
parent.on.transactionApplying.next(null);
|
|
2349
2404
|
};
|
|
2405
|
+
|
|
2406
|
+
// internal/src/transaction/assign-transaction-to-continuity.ts
|
|
2407
|
+
function assignTransactionToContinuity(continuityKey, transactionKey, store) {
|
|
2408
|
+
const isRoot = isRootStore(store);
|
|
2409
|
+
if (!isRoot) {
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
const { epoch, actionContinuities } = store.transactionMeta;
|
|
2413
|
+
actionContinuities.set(continuityKey, transactionKey);
|
|
2414
|
+
if (!epoch.has(continuityKey)) {
|
|
2415
|
+
epoch.set(continuityKey, -1);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
// internal/src/transaction/build-transaction.ts
|
|
2350
2420
|
var buildTransaction = (key, params, store, id) => {
|
|
2351
2421
|
const parent = newest(store);
|
|
2352
2422
|
const childBase = {
|
|
@@ -2372,12 +2442,13 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2372
2442
|
selectors: new LazyMap(parent.selectors),
|
|
2373
2443
|
valueMap: new LazyMap(parent.valueMap)
|
|
2374
2444
|
};
|
|
2445
|
+
const epoch = getEpochNumberOfAction(key, store);
|
|
2375
2446
|
const transactionMeta = {
|
|
2376
2447
|
phase: `building`,
|
|
2377
2448
|
update: {
|
|
2378
2449
|
key,
|
|
2379
|
-
id
|
|
2380
|
-
epoch:
|
|
2450
|
+
id,
|
|
2451
|
+
epoch: epoch === void 0 ? NaN : epoch + 1,
|
|
2381
2452
|
updates: [],
|
|
2382
2453
|
params,
|
|
2383
2454
|
output: void 0
|
|
@@ -2385,7 +2456,7 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2385
2456
|
transactors: {
|
|
2386
2457
|
get: (token) => getFromStore(token, child),
|
|
2387
2458
|
set: (token, value) => setIntoStore(token, value, child),
|
|
2388
|
-
run: (token, id2) =>
|
|
2459
|
+
run: (token, id2 = arbitrary()) => actUponStore(token, id2, child),
|
|
2389
2460
|
find: (token, key2) => findInStore(token, key2, child),
|
|
2390
2461
|
env: () => getEnvironmentData(child)
|
|
2391
2462
|
}
|
|
@@ -2433,6 +2504,24 @@ function createTransaction(options, store) {
|
|
|
2433
2504
|
return token;
|
|
2434
2505
|
}
|
|
2435
2506
|
|
|
2507
|
+
// internal/src/transaction/get-epoch-number.ts
|
|
2508
|
+
function getContinuityKey(transactionKey, store) {
|
|
2509
|
+
const isRoot = isRootStore(store);
|
|
2510
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
2511
|
+
return continuity;
|
|
2512
|
+
}
|
|
2513
|
+
function getEpochNumberOfContinuity(continuityKey, store) {
|
|
2514
|
+
const isRoot = isRootStore(store);
|
|
2515
|
+
const epoch = isRoot && continuityKey ? store.transactionMeta.epoch.get(continuityKey) : void 0;
|
|
2516
|
+
return epoch;
|
|
2517
|
+
}
|
|
2518
|
+
function getEpochNumberOfAction(transactionKey, store) {
|
|
2519
|
+
const isRoot = isRootStore(store);
|
|
2520
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
2521
|
+
const epoch = isRoot && continuity !== void 0 ? store.transactionMeta.epoch.get(continuity) : void 0;
|
|
2522
|
+
return epoch;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2436
2525
|
// internal/src/transaction/index.ts
|
|
2437
2526
|
var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
2438
2527
|
|
|
@@ -2447,8 +2536,11 @@ exports.Subject = Subject;
|
|
|
2447
2536
|
exports.TRANSACTION_PHASES = TRANSACTION_PHASES;
|
|
2448
2537
|
exports.Tracker = Tracker;
|
|
2449
2538
|
exports.abortTransaction = abortTransaction;
|
|
2539
|
+
exports.actUponStore = actUponStore;
|
|
2450
2540
|
exports.addAtomToTimeline = addAtomToTimeline;
|
|
2451
2541
|
exports.applyTransaction = applyTransaction;
|
|
2542
|
+
exports.arbitrary = arbitrary;
|
|
2543
|
+
exports.assignTransactionToContinuity = assignTransactionToContinuity;
|
|
2452
2544
|
exports.become = become;
|
|
2453
2545
|
exports.buildTransaction = buildTransaction;
|
|
2454
2546
|
exports.cacheValue = cacheValue;
|
|
@@ -2472,7 +2564,10 @@ exports.deleteSelector = deleteSelector;
|
|
|
2472
2564
|
exports.deposit = deposit;
|
|
2473
2565
|
exports.evictCachedValue = evictCachedValue;
|
|
2474
2566
|
exports.findInStore = findInStore;
|
|
2567
|
+
exports.getContinuityKey = getContinuityKey;
|
|
2475
2568
|
exports.getEnvironmentData = getEnvironmentData;
|
|
2569
|
+
exports.getEpochNumberOfAction = getEpochNumberOfAction;
|
|
2570
|
+
exports.getEpochNumberOfContinuity = getEpochNumberOfContinuity;
|
|
2476
2571
|
exports.getFromStore = getFromStore;
|
|
2477
2572
|
exports.getJsonFamily = getJsonFamily;
|
|
2478
2573
|
exports.getJsonToken = getJsonToken;
|
|
@@ -2483,9 +2578,11 @@ exports.ingestSelectorUpdate = ingestSelectorUpdate;
|
|
|
2483
2578
|
exports.ingestTransactionUpdate = ingestTransactionUpdate;
|
|
2484
2579
|
exports.isAtomDefault = isAtomDefault;
|
|
2485
2580
|
exports.isAtomKey = isAtomKey;
|
|
2581
|
+
exports.isChildStore = isChildStore;
|
|
2486
2582
|
exports.isDone = isDone;
|
|
2487
2583
|
exports.isMutable = isMutable;
|
|
2488
2584
|
exports.isReadonlySelectorKey = isReadonlySelectorKey;
|
|
2585
|
+
exports.isRootStore = isRootStore;
|
|
2489
2586
|
exports.isSelectorKey = isSelectorKey;
|
|
2490
2587
|
exports.isStateKey = isStateKey;
|
|
2491
2588
|
exports.isTransceiver = isTransceiver;
|
|
@@ -2498,6 +2595,8 @@ exports.readCachedValue = readCachedValue;
|
|
|
2498
2595
|
exports.readOrComputeValue = readOrComputeValue;
|
|
2499
2596
|
exports.registerSelector = registerSelector;
|
|
2500
2597
|
exports.setAtomOrSelector = setAtomOrSelector;
|
|
2598
|
+
exports.setEpochNumberOfAction = setEpochNumberOfAction;
|
|
2599
|
+
exports.setEpochNumberOfContinuity = setEpochNumberOfContinuity;
|
|
2501
2600
|
exports.setIntoStore = setIntoStore;
|
|
2502
2601
|
exports.subscribeToRootAtoms = subscribeToRootAtoms;
|
|
2503
2602
|
exports.subscribeToState = subscribeToState;
|