atom.io 0.34.1 โ 0.35.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/dist/internal/index.d.ts +32 -41
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +106 -128
- package/dist/internal/index.js.map +1 -1
- package/dist/json/index.d.ts +19 -7
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +4 -0
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts +704 -788
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +61 -33
- package/dist/main/index.js.map +1 -1
- package/dist/react-devtools/index.js +10 -10
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +3 -5
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.js +10 -10
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +8 -10
- package/dist/realtime-server/index.js.map +1 -1
- package/package.json +12 -12
- package/src/internal/atom/create-regular-atom.ts +1 -0
- package/src/internal/atom/index.ts +0 -1
- package/src/internal/families/index.ts +0 -1
- package/src/internal/index.ts +111 -89
- package/src/internal/join/join-internal.ts +3 -4
- package/src/internal/mutable/create-mutable-atom-family.ts +0 -1
- package/src/internal/mutable/create-mutable-atom.ts +1 -1
- package/src/internal/selector/register-selector.ts +2 -2
- package/src/json/entries.ts +10 -3
- package/src/json/index.ts +40 -17
- package/src/main/atom.ts +68 -115
- package/src/main/dispose-state.ts +0 -2
- package/src/main/find-state.ts +3 -9
- package/src/main/get-state.ts +0 -2
- package/src/main/index.ts +1 -176
- package/src/main/join.ts +12 -20
- package/src/main/reset-state.ts +0 -2
- package/src/main/selector.ts +5 -72
- package/src/main/set-state.ts +1 -4
- package/src/main/silo.ts +14 -5
- package/src/main/subscribe.ts +0 -7
- package/src/main/timeline.ts +24 -32
- package/src/main/tokens.ts +247 -0
- package/src/main/transaction.ts +17 -55
- package/src/main/validators.ts +1 -1
- package/src/react-devtools/store.ts +61 -45
- package/src/realtime/shared-room-store.ts +3 -5
- package/src/realtime-server/realtime-server-stores/server-user-store.ts +3 -5
- package/src/internal/atom/create-standalone-atom.ts +0 -39
- package/src/internal/families/create-atom-family.ts +0 -38
package/dist/internal/index.js
CHANGED
|
@@ -456,16 +456,16 @@ var Future = class extends Promise {
|
|
|
456
456
|
|
|
457
457
|
//#endregion
|
|
458
458
|
//#region src/internal/set-state/copy-mutable-if-needed.ts
|
|
459
|
-
function copyMutableIfNeeded(target, atom
|
|
460
|
-
const originValue = origin.valueMap.get(atom
|
|
461
|
-
const targetValue = target.valueMap.get(atom
|
|
459
|
+
function copyMutableIfNeeded(target, atom, origin) {
|
|
460
|
+
const originValue = origin.valueMap.get(atom.key);
|
|
461
|
+
const targetValue = target.valueMap.get(atom.key);
|
|
462
462
|
if (originValue !== targetValue) return targetValue;
|
|
463
|
-
if (originValue === void 0) return atom
|
|
464
|
-
origin.logger.info(`๐`, `atom`, atom
|
|
465
|
-
const jsonValue = atom
|
|
466
|
-
const copiedValue = atom
|
|
467
|
-
target.valueMap.set(atom
|
|
468
|
-
new Tracker(atom
|
|
463
|
+
if (originValue === void 0) return atom.default();
|
|
464
|
+
origin.logger.info(`๐`, `atom`, atom.key, `copying`);
|
|
465
|
+
const jsonValue = atom.toJson(originValue);
|
|
466
|
+
const copiedValue = atom.fromJson(jsonValue);
|
|
467
|
+
target.valueMap.set(atom.key, copiedValue);
|
|
468
|
+
new Tracker(atom, origin);
|
|
469
469
|
return copiedValue;
|
|
470
470
|
}
|
|
471
471
|
|
|
@@ -517,12 +517,12 @@ const markDone = (store, key) => {
|
|
|
517
517
|
|
|
518
518
|
//#endregion
|
|
519
519
|
//#region src/internal/set-state/evict-downstream.ts
|
|
520
|
-
function evictDownStream(store, atom
|
|
520
|
+
function evictDownStream(store, atom) {
|
|
521
521
|
const target = newest(store);
|
|
522
|
-
const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom
|
|
523
|
-
target.logger.info(`๐งน`, atom
|
|
522
|
+
const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom.key);
|
|
523
|
+
target.logger.info(`๐งน`, atom.type, atom.key, downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`, downstreamKeys ?? `to evict`);
|
|
524
524
|
if (downstreamKeys) {
|
|
525
|
-
if (target.operation.open) target.logger.info(`๐งน`, atom
|
|
525
|
+
if (target.operation.open) target.logger.info(`๐งน`, atom.type, atom.key, `[ ${[...target.operation.done].join(`, `)} ] already done`);
|
|
526
526
|
for (const key of downstreamKeys) {
|
|
527
527
|
if (isDone(target, key)) continue;
|
|
528
528
|
evictCachedValue(target, key);
|
|
@@ -560,10 +560,10 @@ function cacheValue(target, key, value, subject) {
|
|
|
560
560
|
const current = target.valueMap.get(key);
|
|
561
561
|
if (current === future) {
|
|
562
562
|
cacheValue(target, key, resolved, subject);
|
|
563
|
-
const atom
|
|
564
|
-
if (atom
|
|
565
|
-
openOperation(target, atom
|
|
566
|
-
evictDownStream(target, atom
|
|
563
|
+
const atom = target.atoms.get(key);
|
|
564
|
+
if (atom) {
|
|
565
|
+
openOperation(target, atom);
|
|
566
|
+
evictDownStream(target, atom);
|
|
567
567
|
closeOperation(target);
|
|
568
568
|
} else {
|
|
569
569
|
const selector = target.writableSelectors.get(key) ?? target.readonlySelectors.get(key);
|
|
@@ -634,9 +634,9 @@ const readOrComputeValue = (target, state) => {
|
|
|
634
634
|
|
|
635
635
|
//#endregion
|
|
636
636
|
//#region src/internal/subscribe/subscribe-to-root-atoms.ts
|
|
637
|
-
const subscribeToRootDependency = (target, selector, atom
|
|
638
|
-
return atom
|
|
639
|
-
target.logger.info(`๐ข`, selector.type, selector.key, `root`, atom
|
|
637
|
+
const subscribeToRootDependency = (target, selector, atom) => {
|
|
638
|
+
return atom.subject.subscribe(`${selector.type}:${selector.key}`, (atomChange) => {
|
|
639
|
+
target.logger.info(`๐ข`, selector.type, selector.key, `root`, atom.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
|
|
640
640
|
const oldValue = recallState(target, selector);
|
|
641
641
|
const newValue = readOrComputeValue(target, selector);
|
|
642
642
|
target.logger.info(`โจ`, selector.type, selector.key, `went`, oldValue, `->`, newValue);
|
|
@@ -647,55 +647,6 @@ const subscribeToRootDependency = (target, selector, atom$1) => {
|
|
|
647
647
|
});
|
|
648
648
|
};
|
|
649
649
|
|
|
650
|
-
//#endregion
|
|
651
|
-
//#region src/internal/families/create-regular-atom-family.ts
|
|
652
|
-
function createRegularAtomFamily(store, options, internalRoles) {
|
|
653
|
-
const familyToken = {
|
|
654
|
-
key: options.key,
|
|
655
|
-
type: `atom_family`
|
|
656
|
-
};
|
|
657
|
-
const existing = store.families.get(options.key);
|
|
658
|
-
if (existing) store.logger.error(`โ`, `atom_family`, options.key, `Overwriting an existing ${prettyPrintTokenType(existing)} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
659
|
-
const subject = new Subject();
|
|
660
|
-
const familyFunction = (key) => {
|
|
661
|
-
const subKey = stringifyJson(key);
|
|
662
|
-
const family = {
|
|
663
|
-
key: options.key,
|
|
664
|
-
subKey
|
|
665
|
-
};
|
|
666
|
-
const fullKey = `${options.key}(${subKey})`;
|
|
667
|
-
const target = newest(store);
|
|
668
|
-
const def = options.default;
|
|
669
|
-
const individualOptions = {
|
|
670
|
-
key: fullKey,
|
|
671
|
-
default: def instanceof Function ? () => def(key) : def
|
|
672
|
-
};
|
|
673
|
-
if (options.effects) individualOptions.effects = options.effects(key);
|
|
674
|
-
const token = createRegularAtom(target, individualOptions, family);
|
|
675
|
-
subject.next({
|
|
676
|
-
type: `state_creation`,
|
|
677
|
-
token
|
|
678
|
-
});
|
|
679
|
-
return token;
|
|
680
|
-
};
|
|
681
|
-
const atomFamily$1 = Object.assign(familyFunction, familyToken, {
|
|
682
|
-
subject,
|
|
683
|
-
install: (s) => createRegularAtomFamily(s, options),
|
|
684
|
-
internalRoles
|
|
685
|
-
});
|
|
686
|
-
store.families.set(options.key, atomFamily$1);
|
|
687
|
-
store.defaults.set(options.key, options.default);
|
|
688
|
-
return familyToken;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
//#endregion
|
|
692
|
-
//#region src/internal/families/create-atom-family.ts
|
|
693
|
-
function createAtomFamily(store, options) {
|
|
694
|
-
const isMutable = `mutable` in options;
|
|
695
|
-
if (isMutable) return createMutableAtomFamily(store, options);
|
|
696
|
-
return createRegularAtomFamily(store, options);
|
|
697
|
-
}
|
|
698
|
-
|
|
699
650
|
//#endregion
|
|
700
651
|
//#region src/internal/set-state/become.ts
|
|
701
652
|
const become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(originalThing) : nextVersionOfThing;
|
|
@@ -718,49 +669,49 @@ const emitUpdate = (store, state, update) => {
|
|
|
718
669
|
|
|
719
670
|
//#endregion
|
|
720
671
|
//#region src/internal/set-state/set-atom.ts
|
|
721
|
-
const setAtom = (target, atom
|
|
722
|
-
const oldValue = readOrComputeValue(target, atom
|
|
672
|
+
const setAtom = (target, atom, next) => {
|
|
673
|
+
const oldValue = readOrComputeValue(target, atom);
|
|
723
674
|
let newValue = oldValue;
|
|
724
|
-
if (atom
|
|
675
|
+
if (atom.type === `mutable_atom` && isChildStore(target)) {
|
|
725
676
|
const { parent } = target;
|
|
726
|
-
const copiedValue = copyMutableIfNeeded(target, atom
|
|
677
|
+
const copiedValue = copyMutableIfNeeded(target, atom, parent);
|
|
727
678
|
newValue = copiedValue;
|
|
728
679
|
}
|
|
729
680
|
newValue = become(next)(newValue);
|
|
730
|
-
target.logger.info(`๐`, `atom`, atom
|
|
731
|
-
newValue = cacheValue(target, atom
|
|
732
|
-
markDone(target, atom
|
|
733
|
-
evictDownStream(target, atom
|
|
681
|
+
target.logger.info(`๐`, `atom`, atom.key, `set to`, newValue);
|
|
682
|
+
newValue = cacheValue(target, atom.key, newValue, atom.subject);
|
|
683
|
+
markDone(target, atom.key);
|
|
684
|
+
evictDownStream(target, atom);
|
|
734
685
|
const update = {
|
|
735
686
|
oldValue,
|
|
736
687
|
newValue
|
|
737
688
|
};
|
|
738
689
|
if (!isChildStore(target)) {
|
|
739
|
-
emitUpdate(target, atom
|
|
690
|
+
emitUpdate(target, atom, update);
|
|
740
691
|
return;
|
|
741
692
|
}
|
|
742
693
|
if (target.on.transactionApplying.state === null) {
|
|
743
|
-
const { key } = atom
|
|
694
|
+
const { key } = atom;
|
|
744
695
|
if (isTransceiver(update.newValue)) return;
|
|
745
696
|
const atomUpdate = {
|
|
746
697
|
type: `atom_update`,
|
|
747
698
|
key,
|
|
748
699
|
...update
|
|
749
700
|
};
|
|
750
|
-
if (atom
|
|
701
|
+
if (atom.family) atomUpdate.family = atom.family;
|
|
751
702
|
target.transactionMeta.update.updates.push(atomUpdate);
|
|
752
703
|
target.logger.info(`๐`, `atom`, key, `stowed (`, update.oldValue, `->`, update.newValue, `)`);
|
|
753
|
-
} else if (atom
|
|
754
|
-
const mutableKey = atom
|
|
755
|
-
const mutableAtom = target.atoms.get(mutableKey);
|
|
704
|
+
} else if (atom.key.startsWith(`*`)) {
|
|
705
|
+
const mutableKey = atom.key.slice(1);
|
|
706
|
+
const mutableAtom$1 = target.atoms.get(mutableKey);
|
|
756
707
|
let transceiver = target.valueMap.get(mutableKey);
|
|
757
|
-
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
708
|
+
if (mutableAtom$1.type === `mutable_atom` && isChildStore(target)) {
|
|
758
709
|
const { parent } = target;
|
|
759
|
-
const copiedValue = copyMutableIfNeeded(target, mutableAtom, parent);
|
|
710
|
+
const copiedValue = copyMutableIfNeeded(target, mutableAtom$1, parent);
|
|
760
711
|
transceiver = copiedValue;
|
|
761
712
|
}
|
|
762
713
|
const accepted = transceiver.do(update.newValue) === null;
|
|
763
|
-
if (accepted) evictDownStream(target, mutableAtom);
|
|
714
|
+
if (accepted) evictDownStream(target, mutableAtom$1);
|
|
764
715
|
}
|
|
765
716
|
};
|
|
766
717
|
|
|
@@ -781,7 +732,7 @@ function resetAtomOrSelector(store, state) {
|
|
|
781
732
|
case `writable_held_selector`:
|
|
782
733
|
{
|
|
783
734
|
const atoms = traceRootSelectorAtoms(store, state.key);
|
|
784
|
-
for (const atom
|
|
735
|
+
for (const atom of atoms.values()) resetAtom(store, atom);
|
|
785
736
|
}
|
|
786
737
|
break;
|
|
787
738
|
}
|
|
@@ -914,8 +865,8 @@ const traceRootSelectorAtoms = (store, selectorKey, covered = /* @__PURE__ */ ne
|
|
|
914
865
|
if (covered.has(dependencyKey)) continue;
|
|
915
866
|
covered.add(dependencyKey);
|
|
916
867
|
if (isAtomKey(store, dependencyKey)) {
|
|
917
|
-
const atom
|
|
918
|
-
roots.set(atom
|
|
868
|
+
const atom = store.atoms.get(dependencyKey);
|
|
869
|
+
roots.set(atom.key, atom);
|
|
919
870
|
} else dependencies.push(...getSelectorDependencyKeys(store, dependencyKey));
|
|
920
871
|
}
|
|
921
872
|
return roots;
|
|
@@ -1871,6 +1822,47 @@ function createReadonlyPureSelectorFamily(store, options, internalRoles) {
|
|
|
1871
1822
|
return familyToken;
|
|
1872
1823
|
}
|
|
1873
1824
|
|
|
1825
|
+
//#endregion
|
|
1826
|
+
//#region src/internal/families/create-regular-atom-family.ts
|
|
1827
|
+
function createRegularAtomFamily(store, options, internalRoles) {
|
|
1828
|
+
const familyToken = {
|
|
1829
|
+
key: options.key,
|
|
1830
|
+
type: `atom_family`
|
|
1831
|
+
};
|
|
1832
|
+
const existing = store.families.get(options.key);
|
|
1833
|
+
if (existing) store.logger.error(`โ`, `atom_family`, options.key, `Overwriting an existing ${prettyPrintTokenType(existing)} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1834
|
+
const subject = new Subject();
|
|
1835
|
+
const familyFunction = (key) => {
|
|
1836
|
+
const subKey = stringifyJson(key);
|
|
1837
|
+
const family = {
|
|
1838
|
+
key: options.key,
|
|
1839
|
+
subKey
|
|
1840
|
+
};
|
|
1841
|
+
const fullKey = `${options.key}(${subKey})`;
|
|
1842
|
+
const target = newest(store);
|
|
1843
|
+
const def = options.default;
|
|
1844
|
+
const individualOptions = {
|
|
1845
|
+
key: fullKey,
|
|
1846
|
+
default: def instanceof Function ? () => def(key) : def
|
|
1847
|
+
};
|
|
1848
|
+
if (options.effects) individualOptions.effects = options.effects(key);
|
|
1849
|
+
const token = createRegularAtom(target, individualOptions, family);
|
|
1850
|
+
subject.next({
|
|
1851
|
+
type: `state_creation`,
|
|
1852
|
+
token
|
|
1853
|
+
});
|
|
1854
|
+
return token;
|
|
1855
|
+
};
|
|
1856
|
+
const atomFamily$1 = Object.assign(familyFunction, familyToken, {
|
|
1857
|
+
subject,
|
|
1858
|
+
install: (s) => createRegularAtomFamily(s, options),
|
|
1859
|
+
internalRoles
|
|
1860
|
+
});
|
|
1861
|
+
store.families.set(options.key, atomFamily$1);
|
|
1862
|
+
store.defaults.set(options.key, options.default);
|
|
1863
|
+
return familyToken;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1874
1866
|
//#endregion
|
|
1875
1867
|
//#region src/internal/families/create-readonly-held-selector-family.ts
|
|
1876
1868
|
function createReadonlyHeldSelectorFamily(store, options, internalRoles) {
|
|
@@ -2169,7 +2161,7 @@ function subscribeToState(store, token, key, handleUpdate) {
|
|
|
2169
2161
|
let updateHandler = safelyHandleUpdate;
|
|
2170
2162
|
if (isSelector) {
|
|
2171
2163
|
readOrComputeValue(store, state);
|
|
2172
|
-
for (const [atomKey, atom
|
|
2164
|
+
for (const [atomKey, atom] of traceRootSelectorAtoms(store, state.key)) rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
|
|
2173
2165
|
updateHandler = function updateRootsBeforeHandlingUpdate(update) {
|
|
2174
2166
|
const dependencies = traceRootSelectorAtoms(store, state.key);
|
|
2175
2167
|
for (const [previousRootKey, unsub] of rootSubs) {
|
|
@@ -2180,7 +2172,7 @@ function subscribeToState(store, token, key, handleUpdate) {
|
|
|
2180
2172
|
rootSubs.delete(previousRootKey);
|
|
2181
2173
|
}
|
|
2182
2174
|
}
|
|
2183
|
-
for (const [atomKey, atom
|
|
2175
|
+
for (const [atomKey, atom] of dependencies) rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
|
|
2184
2176
|
safelyHandleUpdate(update);
|
|
2185
2177
|
};
|
|
2186
2178
|
}
|
|
@@ -2356,6 +2348,7 @@ function createMutableAtom(store, options, family) {
|
|
|
2356
2348
|
}
|
|
2357
2349
|
new Tracker(token, store);
|
|
2358
2350
|
if (!family) selectJson(token, options, store);
|
|
2351
|
+
store.on.atomCreation.next(token);
|
|
2359
2352
|
return token;
|
|
2360
2353
|
}
|
|
2361
2354
|
|
|
@@ -2417,8 +2410,7 @@ function createMutableAtomFamily(store, options, internalRoles) {
|
|
|
2417
2410
|
key: fullKey,
|
|
2418
2411
|
default: () => options.default(key),
|
|
2419
2412
|
toJson: options.toJson,
|
|
2420
|
-
fromJson: options.fromJson
|
|
2421
|
-
mutable: true
|
|
2413
|
+
fromJson: options.fromJson
|
|
2422
2414
|
};
|
|
2423
2415
|
if (options.effects) individualOptions.effects = options.effects(key);
|
|
2424
2416
|
const token = createMutableAtom(target, individualOptions, family);
|
|
@@ -2597,12 +2589,12 @@ var Store = class {
|
|
|
2597
2589
|
family.install(this);
|
|
2598
2590
|
}
|
|
2599
2591
|
const mutableHelpers = /* @__PURE__ */ new Set();
|
|
2600
|
-
for (const [, atom
|
|
2601
|
-
if (mutableHelpers.has(atom
|
|
2602
|
-
atom
|
|
2603
|
-
if (atom
|
|
2604
|
-
const originalJsonToken = getJsonToken(store, atom
|
|
2605
|
-
const originalUpdateToken = getUpdateToken(atom
|
|
2592
|
+
for (const [, atom] of store.atoms) {
|
|
2593
|
+
if (mutableHelpers.has(atom.key)) continue;
|
|
2594
|
+
atom.install(this);
|
|
2595
|
+
if (atom.type === `mutable_atom`) {
|
|
2596
|
+
const originalJsonToken = getJsonToken(store, atom);
|
|
2597
|
+
const originalUpdateToken = getUpdateToken(atom);
|
|
2606
2598
|
mutableHelpers.add(originalJsonToken.key);
|
|
2607
2599
|
mutableHelpers.add(originalUpdateToken.key);
|
|
2608
2600
|
}
|
|
@@ -2716,33 +2708,20 @@ function createRegularAtom(store, options, family) {
|
|
|
2716
2708
|
for (const cleanup of cleanupFunctions) cleanup();
|
|
2717
2709
|
};
|
|
2718
2710
|
}
|
|
2711
|
+
store.on.atomCreation.next(token);
|
|
2719
2712
|
return token;
|
|
2720
2713
|
}
|
|
2721
2714
|
|
|
2722
|
-
//#endregion
|
|
2723
|
-
//#region src/internal/atom/create-standalone-atom.ts
|
|
2724
|
-
function createStandaloneAtom(store, options) {
|
|
2725
|
-
const isMutable = `mutable` in options;
|
|
2726
|
-
if (isMutable) {
|
|
2727
|
-
const state$1 = createMutableAtom(store, options, void 0);
|
|
2728
|
-
store.on.atomCreation.next(state$1);
|
|
2729
|
-
return state$1;
|
|
2730
|
-
}
|
|
2731
|
-
const state = createRegularAtom(store, options, void 0);
|
|
2732
|
-
store.on.atomCreation.next(state);
|
|
2733
|
-
return state;
|
|
2734
|
-
}
|
|
2735
|
-
|
|
2736
2715
|
//#endregion
|
|
2737
2716
|
//#region src/internal/atom/dispose-atom.ts
|
|
2738
2717
|
function disposeAtom(store, atomToken) {
|
|
2739
2718
|
const target = newest(store);
|
|
2740
2719
|
const { key, family } = atomToken;
|
|
2741
|
-
const atom
|
|
2720
|
+
const atom = withdraw(target, atomToken);
|
|
2742
2721
|
if (!family) store.logger.error(`โ`, `atom`, key, `Standalone atoms cannot be disposed.`);
|
|
2743
2722
|
else {
|
|
2744
|
-
atom
|
|
2745
|
-
const lastValue = store.valueMap.get(atom
|
|
2723
|
+
atom.cleanup?.();
|
|
2724
|
+
const lastValue = store.valueMap.get(atom.key);
|
|
2746
2725
|
const atomFamily$1 = withdraw(store, {
|
|
2747
2726
|
key: family.key,
|
|
2748
2727
|
type: `atom_family`
|
|
@@ -2769,7 +2748,7 @@ function disposeAtom(store, atomToken) {
|
|
|
2769
2748
|
if (isChild && target.transactionMeta.phase === `building`) {
|
|
2770
2749
|
const mostRecentUpdate = target.transactionMeta.update.updates.at(-1);
|
|
2771
2750
|
const wasMoleculeDisposal = mostRecentUpdate?.type === `molecule_disposal`;
|
|
2772
|
-
const updateAlreadyCaptured = wasMoleculeDisposal && mostRecentUpdate.values.some(([k]) => k === atom
|
|
2751
|
+
const updateAlreadyCaptured = wasMoleculeDisposal && mostRecentUpdate.values.some(([k]) => k === atom.family?.key);
|
|
2773
2752
|
if (!updateAlreadyCaptured) target.transactionMeta.update.updates.push(disposal);
|
|
2774
2753
|
} else store.on.atomDisposal.next(atomToken);
|
|
2775
2754
|
}
|
|
@@ -2855,7 +2834,6 @@ var Join = class {
|
|
|
2855
2834
|
const relatedKeysAtoms = createMutableAtomFamily(store, {
|
|
2856
2835
|
key: `${options.key}/relatedKeys`,
|
|
2857
2836
|
default: () => new SetRTX(),
|
|
2858
|
-
mutable: true,
|
|
2859
2837
|
fromJson: (json) => SetRTX.fromJSON(json),
|
|
2860
2838
|
toJson: (set) => set.toJSON()
|
|
2861
2839
|
}, [`join`, `relations`]);
|
|
@@ -3340,12 +3318,12 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3340
3318
|
const updateToken = getUpdateToken(maybeAtom);
|
|
3341
3319
|
maybeAtom = withdraw(store, updateToken);
|
|
3342
3320
|
}
|
|
3343
|
-
const atom
|
|
3321
|
+
const atom = maybeAtom;
|
|
3344
3322
|
store.timelineTopics.set({
|
|
3345
|
-
topicKey: atom
|
|
3323
|
+
topicKey: atom.key,
|
|
3346
3324
|
timelineKey: tl.key
|
|
3347
3325
|
}, { topicType: `atom` });
|
|
3348
|
-
tl.subscriptions.set(atom
|
|
3326
|
+
tl.subscriptions.set(atom.key, atom.subject.subscribe(`timeline`, function timelineCapturesAtomUpdate(update) {
|
|
3349
3327
|
const target = newest(store);
|
|
3350
3328
|
const currentSelectorKey = store.operation.open && store.operation.token.type === `writable_pure_selector` ? store.operation.token.key : null;
|
|
3351
3329
|
const currentSelectorTime = store.operation.open && store.operation.token.type === `writable_pure_selector` ? store.operation.time : null;
|
|
@@ -3362,7 +3340,7 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3362
3340
|
atomUpdates: []
|
|
3363
3341
|
};
|
|
3364
3342
|
latestUpdate.atomUpdates.push({
|
|
3365
|
-
key: atom
|
|
3343
|
+
key: atom.key,
|
|
3366
3344
|
type: `atom_update`,
|
|
3367
3345
|
...update
|
|
3368
3346
|
});
|
|
@@ -3373,7 +3351,7 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3373
3351
|
tl.selectorTime = currentSelectorTime;
|
|
3374
3352
|
} else if (latestUpdate?.type === `selector_update`) {
|
|
3375
3353
|
latestUpdate.atomUpdates.push({
|
|
3376
|
-
key: atom
|
|
3354
|
+
key: atom.key,
|
|
3377
3355
|
type: `atom_update`,
|
|
3378
3356
|
...update
|
|
3379
3357
|
});
|
|
@@ -3394,13 +3372,13 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3394
3372
|
const atomUpdate = {
|
|
3395
3373
|
type: `atom_update`,
|
|
3396
3374
|
timestamp,
|
|
3397
|
-
key: atom
|
|
3375
|
+
key: atom.key,
|
|
3398
3376
|
oldValue: update.oldValue,
|
|
3399
3377
|
newValue: update.newValue
|
|
3400
3378
|
};
|
|
3401
|
-
if (atom
|
|
3379
|
+
if (atom.family) atomUpdate.family = atom.family;
|
|
3402
3380
|
const willCapture = tl.shouldCapture?.(atomUpdate, tl) ?? true;
|
|
3403
|
-
store.logger.info(`โ`, `timeline`, tl.key, `got an atom_update to "${atom
|
|
3381
|
+
store.logger.info(`โ`, `timeline`, tl.key, `got an atom_update to "${atom.key}"`);
|
|
3404
3382
|
if (willCapture) {
|
|
3405
3383
|
tl.history.push(atomUpdate);
|
|
3406
3384
|
tl.at = tl.history.length;
|
|
@@ -3418,7 +3396,7 @@ function addAtomFamilyToTimeline(store, atomFamilyToken, tl) {
|
|
|
3418
3396
|
tl.subscriptions.set(family.key, family.subject.subscribe(`timeline`, function timelineCapturesStateLifecycleEvent(creationOrDisposal) {
|
|
3419
3397
|
handleStateLifecycleEvent(store, creationOrDisposal, tl);
|
|
3420
3398
|
}));
|
|
3421
|
-
for (const atom
|
|
3399
|
+
for (const atom of store.atoms.values()) if (atom.family?.key === family.key) addAtomToTimeline(store, atom, tl);
|
|
3422
3400
|
}
|
|
3423
3401
|
function joinTransaction(store, tl, txUpdateInProgress) {
|
|
3424
3402
|
const currentTxKey = txUpdateInProgress.key;
|
|
@@ -3552,5 +3530,5 @@ const timeTravel = (store, action, token) => {
|
|
|
3552
3530
|
};
|
|
3553
3531
|
|
|
3554
3532
|
//#endregion
|
|
3555
|
-
export { CircularBuffer, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Join, Junction, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, capitalize, claimWithinStore, clearStore, closeOperation, counterfeit,
|
|
3533
|
+
export { CircularBuffer, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Join, Junction, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, capitalize, claimWithinStore, clearStore, closeOperation, counterfeit, createJoin, createMutableAtom, createMutableAtomFamily, createReadonlyHeldSelector, createReadonlyPureSelector, createReadonlyPureSelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneSelector, createTimeline, createTransaction, createWritableHeldSelector, createWritablePureSelector, createWritablePureSelectorFamily, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, evictCachedValue, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, installIntoStore, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isReservedIntrospectionKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, resetAtomOrSelector, resetInStore, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceRootSelectorAtoms, updateSelectorAtoms, withdraw };
|
|
3556
3534
|
//# sourceMappingURL=index.js.map
|