atom.io 0.40.0 → 0.40.1
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 +67 -62
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +81 -93
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts +2 -2
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js.map +1 -1
- package/dist/main/index.d.ts +14 -11
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +16 -13
- package/dist/main/index.js.map +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.js +1 -1
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +3 -3
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +3 -4
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +2 -2
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/internal/atom/create-regular-atom.ts +3 -2
- package/src/internal/atom/dispose-atom.ts +6 -6
- package/src/internal/families/create-readonly-held-selector-family.ts +3 -4
- package/src/internal/families/create-readonly-pure-selector-family.ts +4 -9
- package/src/internal/families/create-regular-atom-family.ts +3 -4
- package/src/internal/families/create-selector-family.ts +6 -6
- package/src/internal/families/create-writable-held-selector-family.ts +2 -2
- package/src/internal/families/create-writable-pure-selector-family.ts +3 -7
- package/src/internal/families/dispose-from-store.ts +9 -2
- package/src/internal/get-state/get-from-store.ts +10 -3
- package/src/internal/index.ts +8 -8
- package/src/internal/install-into-store.ts +2 -1
- package/src/internal/join/create-join.ts +2 -2
- package/src/internal/join/find-relations-in-store.ts +2 -2
- package/src/internal/join/get-internal-relations-from-store.ts +2 -2
- package/src/internal/join/get-join.ts +5 -2
- package/src/internal/join/join-internal.ts +15 -20
- package/src/internal/lineage.ts +12 -1
- package/src/internal/molecule.ts +64 -36
- package/src/internal/mutable/create-mutable-atom-family.ts +4 -4
- package/src/internal/mutable/create-mutable-atom.ts +2 -2
- package/src/internal/mutable/tracker-family.ts +3 -3
- package/src/internal/selector/create-readonly-held-selector.ts +2 -2
- package/src/internal/selector/create-readonly-pure-selector.ts +2 -2
- package/src/internal/selector/create-writable-held-selector.ts +2 -2
- package/src/internal/selector/create-writable-pure-selector.ts +2 -2
- package/src/internal/set-state/become.ts +1 -3
- package/src/internal/set-state/dispatch-state-update.ts +1 -1
- package/src/internal/set-state/reset-in-store.ts +11 -13
- package/src/internal/set-state/set-into-store.ts +27 -3
- package/src/internal/store/store.ts +14 -12
- package/src/internal/timeline/create-timeline.ts +6 -5
- package/src/internal/timeline/time-travel.ts +4 -3
- package/src/internal/transaction/abort-transaction.ts +3 -15
- package/src/internal/transaction/act-upon-store.ts +1 -5
- package/src/internal/transaction/apply-transaction.ts +3 -15
- package/src/internal/transaction/assign-transaction-to-continuity.ts +2 -7
- package/src/internal/transaction/build-transaction.ts +2 -3
- package/src/internal/transaction/create-transaction.ts +5 -6
- package/src/internal/transaction/get-epoch-number.ts +1 -7
- package/src/internal/transaction/set-epoch-number.ts +4 -12
- package/src/introspection/attach-introspection-states.ts +4 -2
- package/src/introspection/attach-timeline-family.ts +2 -2
- package/src/introspection/attach-transaction-logs.ts +2 -2
- package/src/introspection/attach-type-selectors.ts +2 -2
- package/src/main/dispose-state.ts +1 -5
- package/src/main/events.ts +1 -3
- package/src/main/get-state.ts +3 -6
- package/src/main/realm.ts +36 -12
- package/src/main/reset-state.ts +1 -5
- package/src/main/set-state.ts +4 -11
- package/src/main/silo.ts +4 -3
- package/src/react/store-context.tsx +3 -3
- package/src/react-devtools/Button.tsx +3 -2
- package/src/react-devtools/TimelineIndex.tsx +0 -2
- package/src/react-devtools/store.ts +2 -2
- package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +4 -8
- package/src/realtime-client/sync-continuity.ts +2 -2
- package/src/realtime-server/index.ts +2 -2
package/dist/internal/index.js
CHANGED
|
@@ -13,6 +13,10 @@ function newest(scion) {
|
|
|
13
13
|
while (scion.child !== null) scion = scion.child;
|
|
14
14
|
return scion;
|
|
15
15
|
}
|
|
16
|
+
function eldest(scion) {
|
|
17
|
+
while (scion.parent !== null) scion = scion.parent;
|
|
18
|
+
return scion;
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
//#endregion
|
|
18
22
|
//#region src/internal/store/circular-buffer.ts
|
|
@@ -872,31 +876,17 @@ function mintInStore(store, family, key, mustCreate) {
|
|
|
872
876
|
|
|
873
877
|
//#endregion
|
|
874
878
|
//#region src/internal/transaction/abort-transaction.ts
|
|
875
|
-
const abortTransaction = (
|
|
876
|
-
|
|
877
|
-
if (!isChildStore(target)) {
|
|
878
|
-
store.logger.warn(`🐞`, `transaction`, `???`, `abortTransaction called outside of a transaction. This is probably a bug in AtomIO.`);
|
|
879
|
-
return;
|
|
880
|
-
}
|
|
881
|
-
store.logger.info(`🪂`, `transaction`, target.transactionMeta.update.token.key, `Aborting transaction`);
|
|
879
|
+
const abortTransaction = (target) => {
|
|
880
|
+
target.logger.info(`🪂`, `transaction`, target.transactionMeta.update.token.key, `Aborting transaction`);
|
|
882
881
|
target.parent.child = null;
|
|
883
882
|
};
|
|
884
883
|
|
|
885
|
-
//#endregion
|
|
886
|
-
//#region src/internal/not-found-error.ts
|
|
887
|
-
var NotFoundError = class extends Error {
|
|
888
|
-
constructor(token, store) {
|
|
889
|
-
super(`${PRETTY_TOKEN_TYPES[token.type]} ${stringifyJson(token.key)} not found in store "${store.config.name}".`);
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
|
|
893
884
|
//#endregion
|
|
894
885
|
//#region src/internal/transaction/act-upon-store.ts
|
|
895
886
|
function actUponStore(store, token, id) {
|
|
896
887
|
return (...parameters) => {
|
|
897
888
|
const tx = withdraw(store, token);
|
|
898
|
-
|
|
899
|
-
throw new NotFoundError(token, store);
|
|
889
|
+
return tx.run(parameters, id);
|
|
900
890
|
};
|
|
901
891
|
}
|
|
902
892
|
|
|
@@ -971,17 +961,8 @@ function setIntoStore(store, ...params) {
|
|
|
971
961
|
//#region src/internal/set-state/reset-in-store.ts
|
|
972
962
|
const RESET_STATE = Symbol(`RESET`);
|
|
973
963
|
function resetInStore(store, ...params) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
let key;
|
|
977
|
-
if (params.length === 1) {
|
|
978
|
-
token = params[0];
|
|
979
|
-
setIntoStore(store, token, RESET_STATE);
|
|
980
|
-
} else {
|
|
981
|
-
family = params[0];
|
|
982
|
-
key = params[1];
|
|
983
|
-
setIntoStore(store, family, key, RESET_STATE);
|
|
984
|
-
}
|
|
964
|
+
const subParams = [...params, RESET_STATE];
|
|
965
|
+
setIntoStore(store, ...subParams);
|
|
985
966
|
}
|
|
986
967
|
|
|
987
968
|
//#endregion
|
|
@@ -1099,25 +1080,42 @@ function fuseWithinStore(store, type, sideA, sideB) {
|
|
|
1099
1080
|
allocateIntoStore(store, above, compoundKey, `all`);
|
|
1100
1081
|
return compoundKey;
|
|
1101
1082
|
}
|
|
1102
|
-
function
|
|
1083
|
+
function createDeallocateTX(store) {
|
|
1084
|
+
return createTransaction(store, {
|
|
1085
|
+
key: `[Internal] deallocate`,
|
|
1086
|
+
do: (_, claim) => {
|
|
1087
|
+
deallocateFromStore(newest(store), claim);
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
function deallocateFromStore(target, claim) {
|
|
1103
1092
|
const stringKey = stringifyJson(claim);
|
|
1104
|
-
const molecule =
|
|
1093
|
+
const molecule = target.molecules.get(stringKey);
|
|
1105
1094
|
if (!molecule) {
|
|
1106
|
-
const disposal =
|
|
1107
|
-
|
|
1095
|
+
const disposal = target.disposalTraces.buffer.find((item) => item?.key === stringKey);
|
|
1096
|
+
target.logger.error(`❌`, `key`, claim, `deallocation failed:`, `Could not find allocation for ${stringKey} in store "${target.config.name}".`, disposal ? `\n This state was most recently deallocated\n${disposal.trace}` : `No previous disposal trace for ${stringKey} was found.`);
|
|
1108
1097
|
return;
|
|
1109
1098
|
}
|
|
1110
|
-
const joinKeys =
|
|
1099
|
+
const joinKeys = target.moleculeJoins.getRelatedKeys(stringKey);
|
|
1111
1100
|
if (joinKeys) for (const joinKey of joinKeys) {
|
|
1112
|
-
const join$1 =
|
|
1113
|
-
if (join$1)
|
|
1114
|
-
join$1.relations.delete(molecule.key);
|
|
1115
|
-
join$1.molecules.delete(molecule.stringKey);
|
|
1116
|
-
}
|
|
1101
|
+
const join$1 = target.joins.get(joinKey);
|
|
1102
|
+
if (join$1) join$1.relations.delete(claim);
|
|
1117
1103
|
}
|
|
1118
|
-
|
|
1104
|
+
target.moleculeJoins.delete(stringKey);
|
|
1119
1105
|
const provenance = [];
|
|
1120
1106
|
const values = [];
|
|
1107
|
+
const relatedMolecules = target.moleculeGraph.getRelationEntries({ downstreamMoleculeKey: stringKey });
|
|
1108
|
+
if (relatedMolecules) for (const [relatedStringKey, { source }] of relatedMolecules) if (source === stringKey) {
|
|
1109
|
+
const relatedKey = parseJson(relatedStringKey);
|
|
1110
|
+
deallocateFromStore(target, relatedKey);
|
|
1111
|
+
} else provenance.push(source);
|
|
1112
|
+
const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey);
|
|
1113
|
+
if (familyKeys) for (const familyKey of familyKeys) {
|
|
1114
|
+
const family = target.families.get(familyKey);
|
|
1115
|
+
const value = getFromStore(target, family, claim);
|
|
1116
|
+
values.push([family.key, value]);
|
|
1117
|
+
disposeFromStore(target, family, claim);
|
|
1118
|
+
}
|
|
1121
1119
|
const disposalEvent = {
|
|
1122
1120
|
type: `molecule_disposal`,
|
|
1123
1121
|
key: molecule.key,
|
|
@@ -1125,34 +1123,28 @@ function deallocateFromStore(store, claim) {
|
|
|
1125
1123
|
provenance,
|
|
1126
1124
|
timestamp: Date.now()
|
|
1127
1125
|
};
|
|
1128
|
-
const target = newest(store);
|
|
1129
1126
|
target.molecules.delete(stringKey);
|
|
1130
1127
|
const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
|
|
1131
1128
|
if (isTransaction) target.transactionMeta.update.subEvents.push(disposalEvent);
|
|
1132
|
-
const relatedMolecules = store.moleculeGraph.getRelationEntries({ downstreamMoleculeKey: molecule.stringKey });
|
|
1133
|
-
if (relatedMolecules) for (const [relatedStringKey, { source }] of relatedMolecules) if (source === molecule.stringKey) {
|
|
1134
|
-
const relatedKey = parseJson(relatedStringKey);
|
|
1135
|
-
deallocateFromStore(store, relatedKey);
|
|
1136
|
-
} else provenance.push(source);
|
|
1137
|
-
const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey);
|
|
1138
|
-
if (familyKeys) for (const familyKey of familyKeys) {
|
|
1139
|
-
const family = target.families.get(familyKey);
|
|
1140
|
-
const token = findInStore(store, family, molecule.key);
|
|
1141
|
-
const value = getFromStore(store, token);
|
|
1142
|
-
values.push([family.key, value]);
|
|
1143
|
-
disposeFromStore(store, token);
|
|
1144
|
-
}
|
|
1145
1129
|
target.moleculeGraph.delete(molecule.stringKey);
|
|
1146
1130
|
target.moleculeJoins.delete(molecule.stringKey);
|
|
1147
1131
|
target.moleculeData.delete(molecule.stringKey);
|
|
1148
1132
|
if (!isTransaction) target.on.moleculeDisposal.next(disposalEvent);
|
|
1149
1133
|
target.molecules.delete(molecule.stringKey);
|
|
1150
1134
|
const trace = getTrace(/* @__PURE__ */ new Error());
|
|
1151
|
-
|
|
1135
|
+
target.disposalTraces.add({
|
|
1152
1136
|
key: stringKey,
|
|
1153
1137
|
trace
|
|
1154
1138
|
});
|
|
1155
1139
|
}
|
|
1140
|
+
function createClaimTX(store) {
|
|
1141
|
+
return createTransaction(store, {
|
|
1142
|
+
key: `[Internal] claim`,
|
|
1143
|
+
do: (_, newProvenance, claim, exclusive) => {
|
|
1144
|
+
claimWithinStore(store, newProvenance, claim, exclusive);
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1156
1148
|
function claimWithinStore(store, newProvenance, claim, exclusive) {
|
|
1157
1149
|
const stringKey = stringifyJson(claim);
|
|
1158
1150
|
const target = newest(store);
|
|
@@ -1314,8 +1306,6 @@ function getEpochNumberOfContinuity(store, continuityKey) {
|
|
|
1314
1306
|
return epoch;
|
|
1315
1307
|
}
|
|
1316
1308
|
function getEpochNumberOfAction(store, transactionKey) {
|
|
1317
|
-
const isRoot = isRootStore(store);
|
|
1318
|
-
if (!isRoot) return void 0;
|
|
1319
1309
|
const continuityKey = getContinuityKey(store, transactionKey);
|
|
1320
1310
|
if (continuityKey === void 0) return void 0;
|
|
1321
1311
|
return getEpochNumberOfContinuity(store, continuityKey);
|
|
@@ -1324,12 +1314,9 @@ function getEpochNumberOfAction(store, transactionKey) {
|
|
|
1324
1314
|
//#endregion
|
|
1325
1315
|
//#region src/internal/transaction/set-epoch-number.ts
|
|
1326
1316
|
function setEpochNumberOfContinuity(store, continuityKey, newEpoch) {
|
|
1327
|
-
|
|
1328
|
-
if (isRoot && continuityKey) store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
1317
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
1329
1318
|
}
|
|
1330
1319
|
function setEpochNumberOfAction(store, transactionKey, newEpoch) {
|
|
1331
|
-
const isRoot = isRootStore(store);
|
|
1332
|
-
if (!isRoot) return;
|
|
1333
1320
|
const continuityKey = getContinuityKey(store, transactionKey);
|
|
1334
1321
|
if (continuityKey !== void 0) store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
1335
1322
|
}
|
|
@@ -1339,10 +1326,6 @@ function setEpochNumberOfAction(store, transactionKey, newEpoch) {
|
|
|
1339
1326
|
function applyTransaction(store, output) {
|
|
1340
1327
|
const child = newest(store);
|
|
1341
1328
|
const { parent } = child;
|
|
1342
|
-
if (parent === null || !isChildStore(child) || child.transactionMeta?.phase !== `building`) {
|
|
1343
|
-
store.logger.warn(`🐞`, `transaction`, `???`, `applyTransaction called outside of a transaction. This is probably a bug in AtomIO.`);
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
1329
|
child.transactionMeta.phase = `applying`;
|
|
1347
1330
|
child.transactionMeta.update.output = output;
|
|
1348
1331
|
parent.child = null;
|
|
@@ -1365,8 +1348,6 @@ function applyTransaction(store, output) {
|
|
|
1365
1348
|
//#endregion
|
|
1366
1349
|
//#region src/internal/transaction/assign-transaction-to-continuity.ts
|
|
1367
1350
|
function assignTransactionToContinuity(store, continuityKey, transactionKey) {
|
|
1368
|
-
const isRoot = isRootStore(store);
|
|
1369
|
-
if (!isRoot) return;
|
|
1370
1351
|
const { epoch, actionContinuities } = store.transactionMeta;
|
|
1371
1352
|
actionContinuities.set(continuityKey, transactionKey);
|
|
1372
1353
|
if (!epoch.has(continuityKey)) epoch.set(continuityKey, -1);
|
|
@@ -1457,15 +1438,14 @@ function createTransaction(store, options) {
|
|
|
1457
1438
|
type: `transaction`,
|
|
1458
1439
|
run: (params, id) => {
|
|
1459
1440
|
const token$1 = deposit(newTransaction);
|
|
1460
|
-
const
|
|
1441
|
+
const target$1 = buildTransaction(store, token$1, params, id);
|
|
1461
1442
|
try {
|
|
1462
|
-
const target$1
|
|
1463
|
-
const { toolkit } = childStore.transactionMeta;
|
|
1443
|
+
const { toolkit } = target$1.transactionMeta;
|
|
1464
1444
|
const output = options.do(toolkit, ...params);
|
|
1465
1445
|
applyTransaction(target$1, output);
|
|
1466
1446
|
return output;
|
|
1467
1447
|
} catch (thrown) {
|
|
1468
|
-
abortTransaction(target);
|
|
1448
|
+
abortTransaction(target$1);
|
|
1469
1449
|
store.logger.warn(`💥`, `transaction`, key, `caught:`, thrown);
|
|
1470
1450
|
throw thrown;
|
|
1471
1451
|
}
|
|
@@ -1495,7 +1475,7 @@ function dispatchOrDeferStateUpdate(target, state, { oldValue, newValue }, state
|
|
|
1495
1475
|
if (stateIsNewlyCreated && family) {
|
|
1496
1476
|
state.subject.next({ newValue });
|
|
1497
1477
|
const stateCreationEvent = {
|
|
1498
|
-
|
|
1478
|
+
checkpoint: true,
|
|
1499
1479
|
type: `state_creation`,
|
|
1500
1480
|
subType: `writable`,
|
|
1501
1481
|
token,
|
|
@@ -2985,14 +2965,14 @@ function disposeAtom(store, atomToken) {
|
|
|
2985
2965
|
const familyToken = getFamilyOfToken(store, atomToken);
|
|
2986
2966
|
const atomFamily$1 = withdraw(store, familyToken);
|
|
2987
2967
|
const subject = atomFamily$1.subject;
|
|
2988
|
-
const
|
|
2968
|
+
const disposalEvent = {
|
|
2989
2969
|
type: `state_disposal`,
|
|
2990
2970
|
subType: `atom`,
|
|
2991
2971
|
token: atomToken,
|
|
2992
2972
|
value: lastValue,
|
|
2993
2973
|
timestamp: Date.now()
|
|
2994
2974
|
};
|
|
2995
|
-
subject.next(
|
|
2975
|
+
subject.next(disposalEvent);
|
|
2996
2976
|
const isChild = isChildStore(target);
|
|
2997
2977
|
target.atoms.delete(key);
|
|
2998
2978
|
target.valueMap.delete(key);
|
|
@@ -3010,7 +2990,8 @@ function disposeAtom(store, atomToken) {
|
|
|
3010
2990
|
const mostRecentUpdate = target.transactionMeta.update.subEvents.at(-1);
|
|
3011
2991
|
const wasMoleculeDisposal = mostRecentUpdate?.type === `molecule_disposal`;
|
|
3012
2992
|
const updateAlreadyCaptured = wasMoleculeDisposal && mostRecentUpdate.values.some(([k]) => k === atom.family?.key);
|
|
3013
|
-
|
|
2993
|
+
const isTracker = hasRole(atom, `tracker:signal`);
|
|
2994
|
+
if (!updateAlreadyCaptured && !isTracker) target.transactionMeta.update.subEvents.push(disposalEvent);
|
|
3014
2995
|
} else store.on.atomDisposal.next(atomToken);
|
|
3015
2996
|
}
|
|
3016
2997
|
}
|
|
@@ -3062,7 +3043,6 @@ var Join = class {
|
|
|
3062
3043
|
toolkit;
|
|
3063
3044
|
options;
|
|
3064
3045
|
defaultContent;
|
|
3065
|
-
molecules = /* @__PURE__ */ new Map();
|
|
3066
3046
|
relations;
|
|
3067
3047
|
states;
|
|
3068
3048
|
core;
|
|
@@ -3112,6 +3092,9 @@ var Join = class {
|
|
|
3112
3092
|
bKeys.delete(a);
|
|
3113
3093
|
return bKeys;
|
|
3114
3094
|
});
|
|
3095
|
+
const [x, y] = [a, b].sort();
|
|
3096
|
+
const compositeKey = `${x}:${y}`;
|
|
3097
|
+
this.store.moleculeJoins.delete(compositeKey);
|
|
3115
3098
|
};
|
|
3116
3099
|
const replaceRelationsSafely = (toolkit, a, newRelationsOfA) => {
|
|
3117
3100
|
const { find, get, set } = toolkit;
|
|
@@ -3141,9 +3124,9 @@ var Join = class {
|
|
|
3141
3124
|
}
|
|
3142
3125
|
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) relationsOfB.clear();
|
|
3143
3126
|
for (const previousOwner of previousOwnersToDispose) {
|
|
3144
|
-
const
|
|
3145
|
-
const compositeKey =
|
|
3146
|
-
|
|
3127
|
+
const [x, y] = [newRelationB, previousOwner].sort();
|
|
3128
|
+
const compositeKey = `${x}:${y}`;
|
|
3129
|
+
store.moleculeJoins.delete(compositeKey);
|
|
3147
3130
|
}
|
|
3148
3131
|
}
|
|
3149
3132
|
if (!newRelationBIsAlreadyRelated) relationsOfB.add(a);
|
|
@@ -3176,8 +3159,8 @@ var Join = class {
|
|
|
3176
3159
|
const baseExternalStoreConfiguration = {
|
|
3177
3160
|
getRelatedKeys: (key) => getRelatedKeys(this.toolkit, key),
|
|
3178
3161
|
addRelation: (a, b) => {
|
|
3179
|
-
this.store.moleculeJoins.set(a
|
|
3180
|
-
this.store.moleculeJoins.set(b
|
|
3162
|
+
this.store.moleculeJoins.set(`"${a}"`, options.key);
|
|
3163
|
+
this.store.moleculeJoins.set(`"${b}"`, options.key);
|
|
3181
3164
|
addRelation(this.toolkit, a, b);
|
|
3182
3165
|
},
|
|
3183
3166
|
deleteRelation: (a, b) => {
|
|
@@ -3210,9 +3193,7 @@ var Join = class {
|
|
|
3210
3193
|
setContent: (contentKey, content) => {
|
|
3211
3194
|
setContent(this.toolkit, contentKey, content);
|
|
3212
3195
|
},
|
|
3213
|
-
deleteContent: (
|
|
3214
|
-
this.realm.deallocate(contentKey);
|
|
3215
|
-
}
|
|
3196
|
+
deleteContent: (_) => {}
|
|
3216
3197
|
};
|
|
3217
3198
|
externalStore = Object.assign(baseExternalStoreConfiguration, externalStoreWithContentConfiguration);
|
|
3218
3199
|
} else externalStore = baseExternalStoreConfiguration;
|
|
@@ -3222,8 +3203,8 @@ var Join = class {
|
|
|
3222
3203
|
isBType: options.isBType,
|
|
3223
3204
|
makeContentKey: (...args) => {
|
|
3224
3205
|
const [a, b] = args;
|
|
3225
|
-
const
|
|
3226
|
-
const compositeKey = `${
|
|
3206
|
+
const [x, y] = args.sort();
|
|
3207
|
+
const compositeKey = `${x}:${y}`;
|
|
3227
3208
|
const aMolecule = store.molecules.get(stringifyJson(a));
|
|
3228
3209
|
const bMolecule = store.molecules.get(stringifyJson(b));
|
|
3229
3210
|
if (!aMolecule) this.realm.allocate(options.key, a);
|
|
@@ -3381,7 +3362,8 @@ function getJoin(token, store) {
|
|
|
3381
3362
|
const rootJoinMap = IMPLICIT.STORE.joins;
|
|
3382
3363
|
const rootJoin = rootJoinMap.get(token.key);
|
|
3383
3364
|
if (rootJoin === void 0) throw new Error(`Join "${token.key}" not found in store "${store.config.name}"`);
|
|
3384
|
-
|
|
3365
|
+
const root = eldest(store);
|
|
3366
|
+
myJoin = new Join(rootJoin.options, rootJoin.defaultContent, root);
|
|
3385
3367
|
store.joins.set(token.key, myJoin);
|
|
3386
3368
|
}
|
|
3387
3369
|
return myJoin;
|
|
@@ -3516,6 +3498,14 @@ function getInternalRelationsFromStore(token, store) {
|
|
|
3516
3498
|
return family;
|
|
3517
3499
|
}
|
|
3518
3500
|
|
|
3501
|
+
//#endregion
|
|
3502
|
+
//#region src/internal/not-found-error.ts
|
|
3503
|
+
var NotFoundError = class extends Error {
|
|
3504
|
+
constructor(token, store) {
|
|
3505
|
+
super(`${PRETTY_TOKEN_TYPES[token.type]} ${stringifyJson(token.key)} not found in store "${store.config.name}".`);
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3508
|
+
|
|
3519
3509
|
//#endregion
|
|
3520
3510
|
//#region src/internal/reserved-keys.ts
|
|
3521
3511
|
function isReservedIntrospectionKey(value) {
|
|
@@ -3608,7 +3598,7 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3608
3598
|
const timestamp = Date.now();
|
|
3609
3599
|
tl.selectorTime = null;
|
|
3610
3600
|
const atomUpdate = {
|
|
3611
|
-
|
|
3601
|
+
checkpoint: true,
|
|
3612
3602
|
type: `atom_update`,
|
|
3613
3603
|
token: deposit(atom),
|
|
3614
3604
|
update,
|
|
@@ -3647,7 +3637,7 @@ function joinTransaction(store, tl, txUpdateInProgress) {
|
|
|
3647
3637
|
const timelineTopics = store.timelineTopics.getRelatedKeys(tl.key);
|
|
3648
3638
|
const subEventsFiltered = filterTransactionSubEvents(transactionUpdate.subEvents, timelineTopics);
|
|
3649
3639
|
const timelineTransactionUpdate = {
|
|
3650
|
-
|
|
3640
|
+
checkpoint: true,
|
|
3651
3641
|
...transactionUpdate,
|
|
3652
3642
|
subEvents: subEventsFiltered
|
|
3653
3643
|
};
|
|
@@ -3660,7 +3650,7 @@ function buildSelectorUpdate(store, tl, atomToken, eventOrUpdate, currentSelecto
|
|
|
3660
3650
|
let latestUpdate = tl.history.at(-1);
|
|
3661
3651
|
if (currentSelectorTime !== tl.selectorTime) {
|
|
3662
3652
|
const selectorUpdate = latestUpdate = {
|
|
3663
|
-
|
|
3653
|
+
checkpoint: true,
|
|
3664
3654
|
type: `selector_update`,
|
|
3665
3655
|
timestamp: currentSelectorTime,
|
|
3666
3656
|
token: currentSelectorToken,
|
|
@@ -3768,7 +3758,7 @@ const timeTravel = (store, action, token) => {
|
|
|
3768
3758
|
switch (action) {
|
|
3769
3759
|
case `undo`:
|
|
3770
3760
|
--nextIndex;
|
|
3771
|
-
while (nextIndex !== 0 && timelineData.history[nextIndex].
|
|
3761
|
+
while (nextIndex !== 0 && timelineData.history[nextIndex].checkpoint !== true) --nextIndex;
|
|
3772
3762
|
events = timelineData.history.slice(nextIndex, timelineData.at).reverse();
|
|
3773
3763
|
break;
|
|
3774
3764
|
case `redo`:
|
|
@@ -3793,8 +3783,6 @@ const timeTravel = (store, action, token) => {
|
|
|
3793
3783
|
case `state_disposal`:
|
|
3794
3784
|
ingestDisposalEvent(store, event, applying);
|
|
3795
3785
|
break;
|
|
3796
|
-
case `molecule_creation`:
|
|
3797
|
-
case `molecule_disposal`:
|
|
3798
3786
|
}
|
|
3799
3787
|
timelineData.subject.next(action);
|
|
3800
3788
|
timelineData.timeTraveling = null;
|
|
@@ -3802,5 +3790,5 @@ const timeTravel = (store, action, token) => {
|
|
|
3802
3790
|
};
|
|
3803
3791
|
|
|
3804
3792
|
//#endregion
|
|
3805
|
-
export { COUNTERFEIT, CircularBuffer, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, INTERNAL_ROLES, Join, Junction, MapOverlay, NotFoundError, RESET_STATE, RelationsOverlay, SetOverlay, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, capitalize, claimWithinStore, clearStore, closeOperation, createJoin, createMutableAtom, createMutableAtomFamily, createReadonlyHeldSelector, createReadonlyPureSelector, createReadonlyPureSelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneSelector, createTimeline, createTransaction, createWritableHeldSelector, createWritablePureSelector, createWritablePureSelectorFamily, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, evictCachedValue, evictDownstreamFromAtom, evictDownstreamFromSelector, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, hasRole, ingestAtomUpdateEvent, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdateEvent, ingestTransactionOutcomeEvent, installIntoStore, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isReservedIntrospectionKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markDone, mint, newest, openOperation, readFromCache, readOrComputeValue, recallState, registerSelector, resetAtomOrSelector, resetInStore, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceRootSelectorAtoms, updateSelectorAtoms, withdraw, writeToCache };
|
|
3793
|
+
export { COUNTERFEIT, CircularBuffer, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, INTERNAL_ROLES, Join, Junction, MapOverlay, NotFoundError, RESET_STATE, RelationsOverlay, SetOverlay, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, capitalize, claimWithinStore, clearStore, closeOperation, createClaimTX, createDeallocateTX, createJoin, createMutableAtom, createMutableAtomFamily, createReadonlyHeldSelector, createReadonlyPureSelector, createReadonlyPureSelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneSelector, createTimeline, createTransaction, createWritableHeldSelector, createWritablePureSelector, createWritablePureSelectorFamily, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, eldest, evictCachedValue, evictDownstreamFromAtom, evictDownstreamFromSelector, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, hasRole, ingestAtomUpdateEvent, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdateEvent, ingestTransactionOutcomeEvent, installIntoStore, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isReservedIntrospectionKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markDone, mint, newest, openOperation, readFromCache, readOrComputeValue, recallState, registerSelector, resetAtomOrSelector, resetInStore, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceRootSelectorAtoms, updateSelectorAtoms, withdraw, writeToCache };
|
|
3806
3794
|
//# sourceMappingURL=index.js.map
|