atom.io 0.42.1 → 0.43.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/data/index.js +4 -6
- package/dist/data/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +53 -97
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.js +2 -4
- package/dist/introspection/index.js.map +1 -1
- package/dist/react/index.d.ts +3 -4
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +17 -20
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.js +6 -10
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.js +2 -4
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.js +4 -9
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +4 -4
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +16 -16
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.js +8 -15
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.d.ts +3 -3
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/realtime-testing/index.js +4 -2
- package/dist/realtime-testing/index.js.map +1 -1
- package/dist/transceivers/o-list/index.d.ts +6 -1
- package/dist/transceivers/o-list/index.d.ts.map +1 -1
- package/dist/transceivers/o-list/index.js +109 -42
- package/dist/transceivers/o-list/index.js.map +1 -1
- package/dist/transceivers/u-list/index.js +1 -2
- package/dist/transceivers/u-list/index.js.map +1 -1
- package/package.json +21 -20
- package/src/internal/atom/create-regular-atom.ts +1 -1
- package/src/internal/families/create-readonly-held-selector-family.ts +1 -1
- package/src/internal/families/create-readonly-pure-selector-family.ts +1 -1
- package/src/internal/families/create-regular-atom-family.ts +1 -1
- package/src/internal/families/create-writable-held-selector-family.ts +1 -1
- package/src/internal/families/create-writable-pure-selector-family.ts +1 -1
- package/src/internal/mutable/create-mutable-atom-family.ts +1 -1
- package/src/internal/mutable/create-mutable-atom.ts +1 -1
- package/src/internal/store/store.ts +3 -0
- package/src/react/store-context.tsx +2 -2
- package/src/react/use-i.ts +3 -3
- package/src/react/use-json.ts +2 -2
- package/src/react/use-loadable.ts +4 -4
- package/src/react/use-o.ts +4 -4
- package/src/react/use-tl.ts +6 -6
- package/src/realtime-testing/setup-realtime-test.tsx +5 -1
- package/src/transceivers/o-list/index.ts +1 -0
- package/src/transceivers/o-list/o-list-disposed-key-cleanup-effect.ts +153 -0
package/dist/internal/index.js
CHANGED
|
@@ -276,8 +276,7 @@ var RelationsOverlay = class extends Map {
|
|
|
276
276
|
get(key) {
|
|
277
277
|
if (super.has(key)) return super.get(key);
|
|
278
278
|
if (!this.deleted.has(key) && this.source.has(key)) {
|
|
279
|
-
const
|
|
280
|
-
const valueOverlay = new SetOverlay(value);
|
|
279
|
+
const valueOverlay = new SetOverlay(this.source.get(key));
|
|
281
280
|
super.set(key, valueOverlay);
|
|
282
281
|
return valueOverlay;
|
|
283
282
|
}
|
|
@@ -709,10 +708,8 @@ function deallocateFromStore(target, claim) {
|
|
|
709
708
|
const provenance = [];
|
|
710
709
|
const values = [];
|
|
711
710
|
const relatedMolecules = target.moleculeGraph.getRelationEntries({ downstreamMoleculeKey: stringKey });
|
|
712
|
-
if (relatedMolecules) for (const [relatedStringKey, { source }] of relatedMolecules) if (source === stringKey)
|
|
713
|
-
|
|
714
|
-
deallocateFromStore(target, relatedKey);
|
|
715
|
-
} else provenance.push(source);
|
|
711
|
+
if (relatedMolecules) for (const [relatedStringKey, { source }] of relatedMolecules) if (source === stringKey) deallocateFromStore(target, parseJson(relatedStringKey));
|
|
712
|
+
else provenance.push(source);
|
|
716
713
|
const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey);
|
|
717
714
|
if (familyKeys) for (const familyKey of familyKeys) {
|
|
718
715
|
const family = target.families.get(familyKey);
|
|
@@ -827,16 +824,13 @@ function ingestMoleculeDisposalEvent(store, event, applying) {
|
|
|
827
824
|
deallocateFromStore(store, event.key);
|
|
828
825
|
break;
|
|
829
826
|
case `oldValue`:
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
const memberKey = `${familyKey}(${stringifyJson(event.key)})`;
|
|
838
|
-
store.valueMap.set(memberKey, value);
|
|
839
|
-
}
|
|
827
|
+
allocateIntoStore(store, event.provenance.map(parseJson), event.key);
|
|
828
|
+
for (const [familyKey, value] of event.values) {
|
|
829
|
+
const family = store.families.get(familyKey);
|
|
830
|
+
if (family) {
|
|
831
|
+
getFromStore(store, family, event.key);
|
|
832
|
+
const memberKey = `${familyKey}(${stringifyJson(event.key)})`;
|
|
833
|
+
store.valueMap.set(memberKey, value);
|
|
840
834
|
}
|
|
841
835
|
}
|
|
842
836
|
break;
|
|
@@ -1046,8 +1040,7 @@ function createTransaction(store, options) {
|
|
|
1046
1040
|
key,
|
|
1047
1041
|
type: `transaction`,
|
|
1048
1042
|
run: (params, id) => {
|
|
1049
|
-
const
|
|
1050
|
-
const target = buildTransaction(store, token$1, params, id);
|
|
1043
|
+
const target = buildTransaction(store, deposit(newTransaction), params, id);
|
|
1051
1044
|
try {
|
|
1052
1045
|
const { toolkit } = target.transactionMeta;
|
|
1053
1046
|
const output = options.do(toolkit, ...params);
|
|
@@ -1141,7 +1134,8 @@ var Store = class {
|
|
|
1141
1134
|
operation = { open: false };
|
|
1142
1135
|
config = {
|
|
1143
1136
|
name: `IMPLICIT_STORE`,
|
|
1144
|
-
lifespan: `ephemeral
|
|
1137
|
+
lifespan: `ephemeral`,
|
|
1138
|
+
isProduction: globalThis.process?.env?.[`NODE_ENV`] === `production`
|
|
1145
1139
|
};
|
|
1146
1140
|
loggers = [new AtomIOLogger(`warn`, (_, __, key) => !isReservedIntrospectionKey(key))];
|
|
1147
1141
|
logger = {
|
|
@@ -1194,7 +1188,8 @@ var Store = class {
|
|
|
1194
1188
|
const IMPLICIT = { get STORE() {
|
|
1195
1189
|
globalThis.ATOM_IO_IMPLICIT_STORE ??= new Store({
|
|
1196
1190
|
name: `IMPLICIT_STORE`,
|
|
1197
|
-
lifespan: `ephemeral
|
|
1191
|
+
lifespan: `ephemeral`,
|
|
1192
|
+
isProduction: process?.env?.[`NODE_ENV`] === `production`
|
|
1198
1193
|
});
|
|
1199
1194
|
return globalThis.ATOM_IO_IMPLICIT_STORE;
|
|
1200
1195
|
} };
|
|
@@ -1392,12 +1387,10 @@ function mintInStore(mustCreate, store, family, key) {
|
|
|
1392
1387
|
if (!molecule && store.config.lifespan === `immortal`) {
|
|
1393
1388
|
const { type: familyType, key: familyKey } = family;
|
|
1394
1389
|
store.logger.warn(`💣`, `key`, stringKey, `was used to mint a counterfeit token for`, familyType, `"${familyKey}"`);
|
|
1395
|
-
const fullKey = `${familyKey}(${stringKey})`;
|
|
1396
|
-
const type = FAMILY_MEMBER_TOKEN_TYPES[familyType];
|
|
1397
1390
|
return {
|
|
1398
1391
|
counterfeit: true,
|
|
1399
|
-
key:
|
|
1400
|
-
type,
|
|
1392
|
+
key: `${familyKey}(${stringKey})`,
|
|
1393
|
+
type: FAMILY_MEMBER_TOKEN_TYPES[familyType],
|
|
1401
1394
|
family: {
|
|
1402
1395
|
key: familyKey,
|
|
1403
1396
|
subKey: stringKey
|
|
@@ -1411,11 +1404,9 @@ function mintInStore(mustCreate, store, family, key) {
|
|
|
1411
1404
|
if (molecule) store.moleculeData.set(stringKey, family.key);
|
|
1412
1405
|
} else {
|
|
1413
1406
|
const { type: familyType, key: familyKey } = family;
|
|
1414
|
-
const fullKey = `${familyKey}(${stringKey})`;
|
|
1415
|
-
const type = FAMILY_MEMBER_TOKEN_TYPES[familyType];
|
|
1416
1407
|
return {
|
|
1417
|
-
key:
|
|
1418
|
-
type,
|
|
1408
|
+
key: `${familyKey}(${stringKey})`,
|
|
1409
|
+
type: FAMILY_MEMBER_TOKEN_TYPES[familyType],
|
|
1419
1410
|
family: {
|
|
1420
1411
|
key: familyKey,
|
|
1421
1412
|
subKey: stringKey
|
|
@@ -1512,8 +1503,7 @@ function reduceReference(store, ...params) {
|
|
|
1512
1503
|
function getFromStore(store, ...params) {
|
|
1513
1504
|
const { token, family, subKey } = reduceReference(store, ...params);
|
|
1514
1505
|
if (`counterfeit` in token && family && subKey) return getFallback(store, token, family, subKey);
|
|
1515
|
-
|
|
1516
|
-
return readOrComputeValue(store, state);
|
|
1506
|
+
return readOrComputeValue(store, withdraw(store, token));
|
|
1517
1507
|
}
|
|
1518
1508
|
|
|
1519
1509
|
//#endregion
|
|
@@ -1560,7 +1550,7 @@ function createReadonlyPureSelectorFamily(store, options, internalRoles) {
|
|
|
1560
1550
|
type
|
|
1561
1551
|
};
|
|
1562
1552
|
const existing = store.families.get(familyKey);
|
|
1563
|
-
if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1553
|
+
if (existing && store.config.isProduction === true) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1564
1554
|
const subject = new Subject();
|
|
1565
1555
|
const create = (key) => {
|
|
1566
1556
|
const subKey = stringifyJson(key);
|
|
@@ -1603,7 +1593,7 @@ function createRegularAtomFamily(store, options, internalRoles) {
|
|
|
1603
1593
|
type: `atom_family`
|
|
1604
1594
|
};
|
|
1605
1595
|
const existing = store.families.get(options.key);
|
|
1606
|
-
if (existing) store.logger.error(`❗`, `atom_family`, options.key, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1596
|
+
if (existing && store.config.isProduction === true) store.logger.error(`❗`, `atom_family`, options.key, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1607
1597
|
const subject = new Subject();
|
|
1608
1598
|
const create = (key) => {
|
|
1609
1599
|
const subKey = stringifyJson(key);
|
|
@@ -1645,7 +1635,7 @@ function createReadonlyHeldSelectorFamily(store, options, internalRoles) {
|
|
|
1645
1635
|
type
|
|
1646
1636
|
};
|
|
1647
1637
|
const existing = store.families.get(familyKey);
|
|
1648
|
-
if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1638
|
+
if (existing && store.config.isProduction === true) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1649
1639
|
const subject = new Subject();
|
|
1650
1640
|
const create = (key) => {
|
|
1651
1641
|
const subKey = stringifyJson(key);
|
|
@@ -1654,8 +1644,7 @@ function createReadonlyHeldSelectorFamily(store, options, internalRoles) {
|
|
|
1654
1644
|
subKey
|
|
1655
1645
|
};
|
|
1656
1646
|
const fullKey = `${familyKey}(${subKey})`;
|
|
1657
|
-
|
|
1658
|
-
return createReadonlyHeldSelector(target, {
|
|
1647
|
+
return createReadonlyHeldSelector(newest(store), {
|
|
1659
1648
|
key: fullKey,
|
|
1660
1649
|
const: options.const(key),
|
|
1661
1650
|
get: options.get(key)
|
|
@@ -1683,7 +1672,7 @@ function createWritableHeldSelectorFamily(store, options, internalRoles) {
|
|
|
1683
1672
|
type
|
|
1684
1673
|
};
|
|
1685
1674
|
const existing = store.families.get(familyKey);
|
|
1686
|
-
if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1675
|
+
if (existing && store.config.isProduction === true) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1687
1676
|
const subject = new Subject();
|
|
1688
1677
|
const create = (key) => {
|
|
1689
1678
|
const subKey = stringifyJson(key);
|
|
@@ -1692,8 +1681,7 @@ function createWritableHeldSelectorFamily(store, options, internalRoles) {
|
|
|
1692
1681
|
subKey
|
|
1693
1682
|
};
|
|
1694
1683
|
const fullKey = `${familyKey}(${subKey})`;
|
|
1695
|
-
|
|
1696
|
-
return createWritableHeldSelector(target, {
|
|
1684
|
+
return createWritableHeldSelector(newest(store), {
|
|
1697
1685
|
key: fullKey,
|
|
1698
1686
|
const: options.const(key),
|
|
1699
1687
|
get: options.get(key),
|
|
@@ -1722,7 +1710,7 @@ function createWritablePureSelectorFamily(store, options, internalRoles) {
|
|
|
1722
1710
|
type
|
|
1723
1711
|
};
|
|
1724
1712
|
const existing = store.families.get(familyKey);
|
|
1725
|
-
if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1713
|
+
if (existing && store.config.isProduction === true) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
1726
1714
|
const subject = new Subject();
|
|
1727
1715
|
const create = (key) => {
|
|
1728
1716
|
const subKey = stringifyJson(key);
|
|
@@ -1946,10 +1934,7 @@ function resetAtomOrSelector(target, state) {
|
|
|
1946
1934
|
case `writable_held_selector`:
|
|
1947
1935
|
{
|
|
1948
1936
|
const atoms = traceRootSelectorAtoms(target, state.key);
|
|
1949
|
-
for (const atom of atoms.values())
|
|
1950
|
-
const rootProtoUpdate = resetAtom(target, atom);
|
|
1951
|
-
dispatchOrDeferStateUpdate(target, state, rootProtoUpdate, false);
|
|
1952
|
-
}
|
|
1937
|
+
for (const atom of atoms.values()) dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
|
|
1953
1938
|
const value = state.getFrom(target);
|
|
1954
1939
|
protoUpdate = {
|
|
1955
1940
|
oldValue: value,
|
|
@@ -1961,14 +1946,10 @@ function resetAtomOrSelector(target, state) {
|
|
|
1961
1946
|
{
|
|
1962
1947
|
const oldValue = safeCompute(target, state);
|
|
1963
1948
|
const atoms = traceRootSelectorAtoms(target, state.key);
|
|
1964
|
-
for (const atom of atoms.values())
|
|
1965
|
-
const rootProtoUpdate = resetAtom(target, atom);
|
|
1966
|
-
dispatchOrDeferStateUpdate(target, state, rootProtoUpdate, false);
|
|
1967
|
-
}
|
|
1968
|
-
const newValue = safeCompute(target, state);
|
|
1949
|
+
for (const atom of atoms.values()) dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
|
|
1969
1950
|
protoUpdate = {
|
|
1970
1951
|
oldValue,
|
|
1971
|
-
newValue
|
|
1952
|
+
newValue: safeCompute(target, state)
|
|
1972
1953
|
};
|
|
1973
1954
|
}
|
|
1974
1955
|
break;
|
|
@@ -1986,8 +1967,7 @@ function setIntoStore(store, ...params) {
|
|
|
1986
1967
|
//#region src/internal/set-state/reset-in-store.ts
|
|
1987
1968
|
const RESET_STATE = Symbol(`RESET`);
|
|
1988
1969
|
function resetInStore(store, ...params) {
|
|
1989
|
-
|
|
1990
|
-
setIntoStore(store, ...subParams);
|
|
1970
|
+
setIntoStore(store, ...[...params, RESET_STATE]);
|
|
1991
1971
|
}
|
|
1992
1972
|
|
|
1993
1973
|
//#endregion
|
|
@@ -2154,10 +2134,7 @@ function registerSelector(store, selectorType, selectorKey, covered) {
|
|
|
2154
2134
|
const { token, family, subKey } = reduceReference(store, ...params);
|
|
2155
2135
|
let dependencyValue;
|
|
2156
2136
|
if (`counterfeit` in token && family && subKey) dependencyValue = getFallback(store, token, family, subKey);
|
|
2157
|
-
else
|
|
2158
|
-
const dependency = withdraw(store, token);
|
|
2159
|
-
dependencyValue = readOrComputeValue(store, dependency);
|
|
2160
|
-
}
|
|
2137
|
+
else dependencyValue = readOrComputeValue(store, withdraw(store, token));
|
|
2161
2138
|
store.logger.info(`🔌`, selectorType, selectorKey, `registers dependency ( "${token.key}" =`, dependencyValue, `)`);
|
|
2162
2139
|
target.selectorGraph.set({
|
|
2163
2140
|
upstreamSelectorKey: token.key,
|
|
@@ -2167,8 +2144,7 @@ function registerSelector(store, selectorType, selectorKey, covered) {
|
|
|
2167
2144
|
return dependencyValue;
|
|
2168
2145
|
},
|
|
2169
2146
|
set: ((...params) => {
|
|
2170
|
-
|
|
2171
|
-
operateOnStore(JOIN_OP, target, ...params);
|
|
2147
|
+
operateOnStore(JOIN_OP, newest(store), ...params);
|
|
2172
2148
|
}),
|
|
2173
2149
|
find: ((...args) => findInStore(store, ...args)),
|
|
2174
2150
|
json: (token) => getJsonToken(store, token)
|
|
@@ -2231,12 +2207,11 @@ function createReadonlyPureSelector(store, options, family) {
|
|
|
2231
2207
|
const upstreamStates = innerTarget.selectorGraph.getRelationEntries({ downstreamSelectorKey: key });
|
|
2232
2208
|
for (const [downstreamSelectorKey, { source }] of upstreamStates) if (source !== key) innerTarget.selectorGraph.delete(downstreamSelectorKey, key);
|
|
2233
2209
|
innerTarget.selectorAtoms.delete(key);
|
|
2234
|
-
const
|
|
2210
|
+
const cached = writeToCache(innerTarget, readonlySelector, options.get({
|
|
2235
2211
|
get,
|
|
2236
2212
|
find,
|
|
2237
2213
|
json
|
|
2238
|
-
});
|
|
2239
|
-
const cached = writeToCache(innerTarget, readonlySelector, value);
|
|
2214
|
+
}));
|
|
2240
2215
|
store.logger.info(`✨`, type, key, `=`, cached);
|
|
2241
2216
|
covered.clear();
|
|
2242
2217
|
return cached;
|
|
@@ -2325,8 +2300,7 @@ function createWritablePureSelector(store, options, family) {
|
|
|
2325
2300
|
const upstreamStates = innerTarget.selectorGraph.getRelationEntries({ downstreamSelectorKey: key });
|
|
2326
2301
|
for (const [downstreamSelectorKey, { source }] of upstreamStates) if (source !== key) innerTarget.selectorGraph.delete(downstreamSelectorKey, key);
|
|
2327
2302
|
innerTarget.selectorAtoms.delete(key);
|
|
2328
|
-
const
|
|
2329
|
-
const cached = writeToCache(innerTarget, mySelector, value);
|
|
2303
|
+
const cached = writeToCache(innerTarget, mySelector, options.get(getterToolkit));
|
|
2330
2304
|
store.logger.info(`✨`, type, key, `=`, cached);
|
|
2331
2305
|
covered.clear();
|
|
2332
2306
|
return cached;
|
|
@@ -2588,9 +2562,7 @@ var Tracker = class {
|
|
|
2588
2562
|
unsubscribeFromState;
|
|
2589
2563
|
captureSignalsFromCore(mutableState, latestSignalState, target) {
|
|
2590
2564
|
const stateKey = mutableState.key;
|
|
2591
|
-
const
|
|
2592
|
-
const storeStatus = isChildStore(target) ? target.transactionMeta.update.token.key : `main`;
|
|
2593
|
-
const subscriptionKey = `tracker-from-core:${storeName}:${storeStatus}:${stateKey}`;
|
|
2565
|
+
const subscriptionKey = `tracker-from-core:${target.config.name}:${isChildStore(target) ? target.transactionMeta.update.token.key : `main`}:${stateKey}`;
|
|
2594
2566
|
const trackerCapturesOutboundSignal = (update) => {
|
|
2595
2567
|
operateOnStore(JOIN_OP, target, latestSignalState, update);
|
|
2596
2568
|
};
|
|
@@ -2604,9 +2576,7 @@ var Tracker = class {
|
|
|
2604
2576
|
}
|
|
2605
2577
|
supplySignalsToCore(mutableState, latestSignalState, target) {
|
|
2606
2578
|
const stateKey = mutableState.key;
|
|
2607
|
-
const
|
|
2608
|
-
const storeStatus = isChildStore(target) ? target.transactionMeta.update.token.key : `main`;
|
|
2609
|
-
const subscriptionKey = `tracker-to-core:${storeName}:${storeStatus}:${stateKey}`;
|
|
2579
|
+
const subscriptionKey = `tracker-to-core:${target.config.name}:${isChildStore(target) ? target.transactionMeta.update.token.key : `main`}:${stateKey}`;
|
|
2610
2580
|
subscribeToState(target, latestSignalState, subscriptionKey, Object.assign(function trackerCapturesInboundSignal({ newValue, oldValue }) {
|
|
2611
2581
|
const timelineId = target.timelineTopics.getRelatedKey(latestSignalState.key);
|
|
2612
2582
|
if (timelineId && target.timelines.get(timelineId)?.timeTraveling) {
|
|
@@ -2653,7 +2623,7 @@ function createMutableAtom(store, options, family) {
|
|
|
2653
2623
|
const { key } = options;
|
|
2654
2624
|
const existing = target.atoms.get(key);
|
|
2655
2625
|
const type = `mutable_atom`;
|
|
2656
|
-
if (existing &&
|
|
2626
|
+
if (existing?.type === type && store.config.isProduction === true) {
|
|
2657
2627
|
store.logger.error(`❌`, type, key, `Tried to create atom, but it already exists in the store.`);
|
|
2658
2628
|
return deposit(existing);
|
|
2659
2629
|
}
|
|
@@ -2711,11 +2681,10 @@ var FamilyTracker = class {
|
|
|
2711
2681
|
latestSignalAtoms;
|
|
2712
2682
|
mutableAtoms;
|
|
2713
2683
|
constructor(mutableAtoms, store) {
|
|
2714
|
-
|
|
2684
|
+
this.latestSignalAtoms = withdraw(store, createRegularAtomFamily(store, {
|
|
2715
2685
|
key: `*${mutableAtoms.key}`,
|
|
2716
2686
|
default: null
|
|
2717
|
-
}, [`mutable`, `updates`]);
|
|
2718
|
-
this.latestSignalAtoms = withdraw(store, latestSignalAtoms);
|
|
2687
|
+
}, [`mutable`, `updates`]));
|
|
2719
2688
|
this.mutableAtoms = mutableAtoms;
|
|
2720
2689
|
const trackerFamilyWatchesForCreationAndDisposalEvents = (event) => {
|
|
2721
2690
|
const { type, token } = event;
|
|
@@ -2747,7 +2716,7 @@ function createMutableAtomFamily(store, options, internalRoles) {
|
|
|
2747
2716
|
type: `mutable_atom_family`
|
|
2748
2717
|
};
|
|
2749
2718
|
const existing = store.families.get(options.key);
|
|
2750
|
-
if (existing) store.logger.error(`❗`, `mutable_atom_family`, options.key, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
2719
|
+
if (existing && store.config.isProduction === true) store.logger.error(`❗`, `mutable_atom_family`, options.key, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
|
|
2751
2720
|
const subject = new Subject();
|
|
2752
2721
|
const create = (key) => {
|
|
2753
2722
|
const subKey = stringifyJson(key);
|
|
@@ -2795,16 +2764,10 @@ const getJsonFamily = (mutableAtomFamily, store) => {
|
|
|
2795
2764
|
//#endregion
|
|
2796
2765
|
//#region src/internal/mutable/get-json-token.ts
|
|
2797
2766
|
const getJsonToken = (store, mutableAtomToken) => {
|
|
2798
|
-
if (mutableAtomToken.family) {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
type: `writable_pure_selector_family`
|
|
2803
|
-
};
|
|
2804
|
-
const family = withdraw(target, jsonFamilyToken);
|
|
2805
|
-
const subKey = parseJson(mutableAtomToken.family.subKey);
|
|
2806
|
-
return findInStore(store, family, subKey);
|
|
2807
|
-
}
|
|
2767
|
+
if (mutableAtomToken.family) return findInStore(store, withdraw(newest(store), {
|
|
2768
|
+
key: `${mutableAtomToken.family.key}:JSON`,
|
|
2769
|
+
type: `writable_pure_selector_family`
|
|
2770
|
+
}), parseJson(mutableAtomToken.family.subKey));
|
|
2808
2771
|
return {
|
|
2809
2772
|
type: `writable_pure_selector`,
|
|
2810
2773
|
key: `${mutableAtomToken.key}:JSON`
|
|
@@ -2954,7 +2917,7 @@ function createRegularAtom(store, options, family, internalRoles) {
|
|
|
2954
2917
|
store.logger.info(`🔨`, type, key, `is being created`);
|
|
2955
2918
|
const target = newest(store);
|
|
2956
2919
|
const existing = target.atoms.get(key);
|
|
2957
|
-
if (existing &&
|
|
2920
|
+
if (existing?.type === type && store.config.isProduction === true) {
|
|
2958
2921
|
store.logger.error(`❌`, `atom`, key, `Tried to create atom, but it already exists in the store.`);
|
|
2959
2922
|
return deposit(existing);
|
|
2960
2923
|
}
|
|
@@ -3016,8 +2979,7 @@ function disposeAtom(store, atomToken) {
|
|
|
3016
2979
|
else {
|
|
3017
2980
|
atom.cleanup?.();
|
|
3018
2981
|
const lastValue = store.valueMap.get(atom.key);
|
|
3019
|
-
const
|
|
3020
|
-
const subject = withdraw(store, familyToken).subject;
|
|
2982
|
+
const subject = withdraw(store, getFamilyOfToken(store, atomToken)).subject;
|
|
3021
2983
|
const disposalEvent = {
|
|
3022
2984
|
type: `state_disposal`,
|
|
3023
2985
|
subType: `atom`,
|
|
@@ -3034,8 +2996,7 @@ function disposeAtom(store, atomToken) {
|
|
|
3034
2996
|
target.moleculeData.delete(family.key, family.subKey);
|
|
3035
2997
|
store.timelineTopics.delete(key);
|
|
3036
2998
|
if (atomToken.type === `mutable_atom`) {
|
|
3037
|
-
|
|
3038
|
-
disposeAtom(store, updateToken);
|
|
2999
|
+
disposeAtom(store, getUpdateToken(atomToken));
|
|
3039
3000
|
store.trackers.delete(key);
|
|
3040
3001
|
}
|
|
3041
3002
|
store.logger.info(`🔥`, `atom`, key, `deleted`);
|
|
@@ -3217,8 +3178,7 @@ var Join = class {
|
|
|
3217
3178
|
return createReadonlyPureSelectorFamily(store, {
|
|
3218
3179
|
key: `${options.key}/multipleRelatedKeys`,
|
|
3219
3180
|
get: (key) => ({ get }) => {
|
|
3220
|
-
|
|
3221
|
-
return get(jsonFamily, key);
|
|
3181
|
+
return get(getJsonFamily(relatedKeysAtoms, store), key);
|
|
3222
3182
|
}
|
|
3223
3183
|
}, [`join`, `keys`]);
|
|
3224
3184
|
};
|
|
@@ -3426,10 +3386,7 @@ function createTimeline(store, options, data) {
|
|
|
3426
3386
|
function addAtomToTimeline(store, atomToken, tl) {
|
|
3427
3387
|
reduceReference(store, atomToken);
|
|
3428
3388
|
let maybeAtom = withdraw(store, atomToken);
|
|
3429
|
-
if (maybeAtom.type === `mutable_atom`)
|
|
3430
|
-
const updateToken = getUpdateToken(maybeAtom);
|
|
3431
|
-
maybeAtom = withdraw(store, updateToken);
|
|
3432
|
-
}
|
|
3389
|
+
if (maybeAtom.type === `mutable_atom`) maybeAtom = withdraw(store, getUpdateToken(maybeAtom));
|
|
3433
3390
|
const atom = maybeAtom;
|
|
3434
3391
|
store.timelineTopics.set({
|
|
3435
3392
|
topicKey: atom.key,
|
|
@@ -3484,12 +3441,11 @@ function joinTransaction(store, tl, txUpdateInProgress) {
|
|
|
3484
3441
|
if (tl.timeTraveling === null && currentTxInstanceId) {
|
|
3485
3442
|
const timelineTopics = store.timelineTopics.getRelatedKeys(tl.key);
|
|
3486
3443
|
const subEventsFiltered = filterTransactionSubEvents(transactionUpdate.subEvents, timelineTopics);
|
|
3487
|
-
|
|
3444
|
+
addToHistory(tl, {
|
|
3488
3445
|
checkpoint: true,
|
|
3489
3446
|
...transactionUpdate,
|
|
3490
3447
|
subEvents: subEventsFiltered
|
|
3491
|
-
};
|
|
3492
|
-
addToHistory(tl, timelineTransactionUpdate);
|
|
3448
|
+
});
|
|
3493
3449
|
}
|
|
3494
3450
|
});
|
|
3495
3451
|
}
|