atom.io 0.15.4 → 0.15.6
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 +20 -16
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.js +21 -17
- package/data/dist/index.js.map +1 -1
- package/data/src/join.ts +6 -2
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +69 -18
- package/dist/index.js +157 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +88 -146
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +29 -17
- package/internal/dist/index.js +79 -92
- package/internal/dist/index.js.map +1 -1
- package/internal/src/get-environment-data.ts +18 -0
- package/internal/src/index.ts +2 -0
- package/internal/src/ingest-updates/index.ts +3 -0
- package/internal/src/ingest-updates/ingest-atom-update.ts +14 -0
- package/internal/src/ingest-updates/ingest-selector-update.ts +17 -0
- package/internal/src/ingest-updates/ingest-transaction-update.ts +22 -0
- package/internal/src/mutable/tracker.ts +1 -1
- package/internal/src/not-found-error.ts +3 -8
- package/internal/src/operation.ts +3 -3
- package/internal/src/selector/create-read-write-selector.ts +5 -3
- package/internal/src/selector/create-readonly-selector.ts +2 -2
- package/internal/src/selector/register-selector.ts +6 -4
- package/internal/src/selector/update-selector-atoms.ts +2 -2
- package/internal/src/set-state/set-atom.ts +8 -3
- package/internal/src/store/deposit.ts +5 -5
- package/internal/src/store/withdraw-new-family-member.ts +8 -11
- package/internal/src/store/withdraw.ts +4 -3
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/timeline/time-travel.ts +18 -44
- package/internal/src/transaction/apply-transaction.ts +3 -49
- package/internal/src/transaction/build-transaction.ts +8 -1
- package/internal/src/transaction/create-transaction.ts +3 -3
- package/internal/src/transaction/index.ts +2 -2
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.ts +4 -4
- package/introspection/dist/index.js.map +1 -1
- package/introspection/src/attach-atom-index.ts +2 -2
- package/introspection/src/attach-selector-index.ts +2 -2
- package/introspection/src/index.ts +1 -1
- package/package.json +8 -8
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +3 -3
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +4 -4
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.ts +3 -3
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +3 -3
- package/react-devtools/src/StateIndex.tsx +3 -3
- package/realtime-client/dist/index.cjs +67 -65
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +6 -5
- package/realtime-client/dist/index.js +62 -61
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/pull-family-member.ts +1 -1
- package/realtime-client/src/pull.ts +1 -1
- package/realtime-client/src/push.ts +2 -3
- package/realtime-client/src/realtime-state.ts +8 -0
- package/realtime-client/src/server-action.ts +65 -65
- package/realtime-react/dist/index.cjs +88 -52
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +11 -6
- package/realtime-react/dist/index.js +87 -51
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/on-mount.ts +23 -0
- package/realtime-react/src/realtime-context.tsx +12 -2
- package/realtime-react/src/use-pull-family-member.ts +5 -8
- package/realtime-react/src/use-pull-mutable-family-member.ts +4 -7
- package/realtime-react/src/use-pull-mutable.ts +4 -7
- package/realtime-react/src/use-pull.ts +5 -8
- package/realtime-react/src/use-push.ts +5 -9
- package/realtime-react/src/use-realtime-service.ts +30 -0
- package/realtime-react/src/use-server-action.ts +8 -8
- package/realtime-server/dist/index.cjs +109 -40
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +7 -6
- package/realtime-server/dist/index.js +90 -39
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/hook-composition/expose-family.ts +2 -2
- package/realtime-server/src/hook-composition/expose-mutable-family.ts +1 -1
- package/realtime-server/src/hook-composition/expose-single.ts +1 -1
- package/realtime-server/src/hook-composition/index.ts +2 -1
- package/realtime-server/src/hook-composition/receive-state.ts +2 -2
- package/realtime-server/src/hook-composition/receive-transaction.ts +13 -32
- package/realtime-server/src/hook-composition/sync-transaction.ts +92 -0
- package/realtime-testing/dist/index.cjs +3 -3
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.js +2 -2
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +4 -3
- package/src/atom.ts +30 -7
- package/src/dispose.ts +2 -2
- package/src/find-state.ts +64 -0
- package/src/get-state.ts +2 -2
- package/src/index.ts +15 -2
- package/src/logger.ts +1 -0
- package/src/selector.ts +16 -0
- package/src/set-state.ts +2 -2
- package/src/silo.ts +2 -2
- package/src/timeline.ts +2 -2
- package/src/transaction.ts +31 -12
- package/dist/chunk-RLZQ6IIY.js +0 -147
- package/dist/chunk-RLZQ6IIY.js.map +0 -1
package/internal/dist/index.cjs
CHANGED
|
@@ -2,27 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var json = require('atom.io/json');
|
|
4
4
|
var atom_io = require('atom.io');
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var Internal2__namespace = /*#__PURE__*/_interopNamespace(Internal2);
|
|
5
|
+
var internal = require('atom.io/internal');
|
|
26
6
|
|
|
27
7
|
var __defProp = Object.defineProperty;
|
|
28
8
|
var __defProps = Object.defineProperties;
|
|
@@ -392,10 +372,13 @@ var setAtom = (atom, next, target) => {
|
|
|
392
372
|
const update = { oldValue, newValue };
|
|
393
373
|
if (target.transactionMeta === null) {
|
|
394
374
|
emitUpdate(atom, update, target);
|
|
395
|
-
} else if (target.
|
|
396
|
-
emitUpdate(atom, update, target.parent);
|
|
397
|
-
} else {
|
|
375
|
+
} else if (target.on.transactionApplying && target.parent) {
|
|
398
376
|
stowUpdate(atom, update, target);
|
|
377
|
+
if (atom.key.startsWith(`*`)) {
|
|
378
|
+
const mutableKey = atom.key.slice(1);
|
|
379
|
+
const mutable = target.valueMap.get(mutableKey);
|
|
380
|
+
mutable.do(update.newValue);
|
|
381
|
+
}
|
|
399
382
|
}
|
|
400
383
|
};
|
|
401
384
|
|
|
@@ -953,24 +936,27 @@ var registerSelector = (selectorKey, store) => ({
|
|
|
953
936
|
updateSelectorAtoms(selectorKey, dependency, store);
|
|
954
937
|
return dependencyValue;
|
|
955
938
|
},
|
|
956
|
-
set: (
|
|
957
|
-
const state = withdraw(
|
|
939
|
+
set: (WritableToken, newValue) => {
|
|
940
|
+
const state = withdraw(WritableToken, store);
|
|
958
941
|
if (state === void 0) {
|
|
959
942
|
throw new Error(
|
|
960
|
-
`State "${
|
|
943
|
+
`State "${WritableToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
961
944
|
);
|
|
962
945
|
}
|
|
963
946
|
setAtomOrSelector(state, newValue, store);
|
|
964
|
-
}
|
|
947
|
+
},
|
|
948
|
+
find: (token, key) => atom_io.findInStore(token, key, store)
|
|
965
949
|
});
|
|
966
950
|
|
|
967
951
|
// internal/src/selector/create-read-write-selector.ts
|
|
968
952
|
var createReadWriteSelector = (options, family, store) => {
|
|
969
953
|
const target = newest(store);
|
|
970
954
|
const subject = new Subject();
|
|
971
|
-
const
|
|
955
|
+
const transactors = registerSelector(options.key, store);
|
|
956
|
+
const { find, get } = transactors;
|
|
957
|
+
const readonlyTransactors = { find, get };
|
|
972
958
|
const getSelf = () => {
|
|
973
|
-
const value = options.get(
|
|
959
|
+
const value = options.get(readonlyTransactors);
|
|
974
960
|
cacheValue(options.key, value, subject, newest(store));
|
|
975
961
|
return value;
|
|
976
962
|
};
|
|
@@ -992,7 +978,7 @@ var createReadWriteSelector = (options, family, store) => {
|
|
|
992
978
|
if (target.transactionMeta === null) {
|
|
993
979
|
subject.next({ newValue, oldValue });
|
|
994
980
|
}
|
|
995
|
-
options.set(
|
|
981
|
+
options.set(transactors, newValue);
|
|
996
982
|
};
|
|
997
983
|
const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
998
984
|
subject,
|
|
@@ -1019,9 +1005,9 @@ var createReadWriteSelector = (options, family, store) => {
|
|
|
1019
1005
|
var createReadonlySelector = (options, family, store) => {
|
|
1020
1006
|
const target = newest(store);
|
|
1021
1007
|
const subject = new Subject();
|
|
1022
|
-
const { get } = registerSelector(options.key, store);
|
|
1008
|
+
const { get, find } = registerSelector(options.key, store);
|
|
1023
1009
|
const getSelf = () => {
|
|
1024
|
-
const value = options.get({ get });
|
|
1010
|
+
const value = options.get({ get, find });
|
|
1025
1011
|
cacheValue(options.key, value, subject, store);
|
|
1026
1012
|
return value;
|
|
1027
1013
|
};
|
|
@@ -1185,7 +1171,7 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1185
1171
|
return unsubscribe;
|
|
1186
1172
|
}
|
|
1187
1173
|
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1188
|
-
const tl =
|
|
1174
|
+
const tl = internal.withdraw(token, store);
|
|
1189
1175
|
if (tl === void 0) {
|
|
1190
1176
|
throw new Error(
|
|
1191
1177
|
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
@@ -1204,7 +1190,7 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
|
1204
1190
|
};
|
|
1205
1191
|
};
|
|
1206
1192
|
var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
1207
|
-
const tx =
|
|
1193
|
+
const tx = internal.withdraw(token, store);
|
|
1208
1194
|
if (tx === void 0) {
|
|
1209
1195
|
throw new Error(
|
|
1210
1196
|
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
@@ -1704,7 +1690,7 @@ function createAtom(options, family, store) {
|
|
|
1704
1690
|
}
|
|
1705
1691
|
|
|
1706
1692
|
// internal/src/atom/delete-atom.ts
|
|
1707
|
-
function
|
|
1693
|
+
function deleteAtom(atomToken, store) {
|
|
1708
1694
|
var _a, _b;
|
|
1709
1695
|
const target = newest(store);
|
|
1710
1696
|
const { key } = atomToken;
|
|
@@ -1735,6 +1721,39 @@ function deleteAtom2(atomToken, store) {
|
|
|
1735
1721
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1736
1722
|
}
|
|
1737
1723
|
|
|
1724
|
+
// internal/src/get-environment-data.ts
|
|
1725
|
+
function getEnvironmentData(store) {
|
|
1726
|
+
return {
|
|
1727
|
+
runtime: typeof window === `undefined` ? typeof global === `object` ? `node` : `unknown` : `browser`,
|
|
1728
|
+
store
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
1732
|
+
const { key, newValue, oldValue } = atomUpdate;
|
|
1733
|
+
const value = applying === `newValue` ? newValue : oldValue;
|
|
1734
|
+
atom_io.setState({ key, type: `atom` }, value, store);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
// internal/src/ingest-updates/ingest-selector-update.ts
|
|
1738
|
+
function ingestSelectorUpdate(applying, selectorUpdate, store) {
|
|
1739
|
+
const updates = applying === `newValue` ? selectorUpdate.atomUpdates : [...selectorUpdate.atomUpdates].reverse();
|
|
1740
|
+
for (const atomUpdate of updates) {
|
|
1741
|
+
ingestAtomUpdate(applying, atomUpdate, store);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
// internal/src/ingest-updates/ingest-transaction-update.ts
|
|
1746
|
+
function ingestTransactionUpdate(applying, transactionUpdate, store) {
|
|
1747
|
+
const updates = applying === `newValue` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
|
|
1748
|
+
for (const updateFromTransaction of updates) {
|
|
1749
|
+
if (`newValue` in updateFromTransaction) {
|
|
1750
|
+
ingestAtomUpdate(applying, updateFromTransaction, store);
|
|
1751
|
+
} else {
|
|
1752
|
+
ingestTransactionUpdate(applying, updateFromTransaction, store);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1738
1757
|
// internal/src/lazy-map.ts
|
|
1739
1758
|
var LazyMap = class extends Map {
|
|
1740
1759
|
constructor(source) {
|
|
@@ -2088,10 +2107,11 @@ function createTimeline(options, store, data) {
|
|
|
2088
2107
|
store.on.timelineCreation.next(token);
|
|
2089
2108
|
return token;
|
|
2090
2109
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2110
|
+
|
|
2111
|
+
// internal/src/timeline/time-travel.ts
|
|
2112
|
+
var timeTravel = (action, token, store) => {
|
|
2093
2113
|
store.logger.info(
|
|
2094
|
-
|
|
2114
|
+
action === `redo` ? `\u23E9` : `\u23EA`,
|
|
2095
2115
|
`timeline`,
|
|
2096
2116
|
token.key,
|
|
2097
2117
|
action
|
|
@@ -2106,53 +2126,36 @@ var timeTravel = (direction, token, store) => {
|
|
|
2106
2126
|
);
|
|
2107
2127
|
return;
|
|
2108
2128
|
}
|
|
2109
|
-
if (
|
|
2129
|
+
if (action === `redo` && timelineData.at === timelineData.history.length || action === `undo` && timelineData.at === 0) {
|
|
2110
2130
|
store.logger.warn(
|
|
2111
2131
|
`\u{1F481}`,
|
|
2112
2132
|
`timeline`,
|
|
2113
2133
|
token.key,
|
|
2114
|
-
`Failed to ${action} at the ${
|
|
2134
|
+
`Failed to ${action} at the ${action === `redo` ? `end` : `beginning`} of timeline "${token.key}". There is nothing to ${action}.`
|
|
2115
2135
|
);
|
|
2116
2136
|
return;
|
|
2117
2137
|
}
|
|
2118
|
-
timelineData.timeTraveling =
|
|
2119
|
-
if (
|
|
2138
|
+
timelineData.timeTraveling = action === `redo` ? `into_future` : `into_past`;
|
|
2139
|
+
if (action === `undo`) {
|
|
2120
2140
|
--timelineData.at;
|
|
2121
2141
|
}
|
|
2122
2142
|
const update = timelineData.history[timelineData.at];
|
|
2123
|
-
const
|
|
2124
|
-
const { key, newValue, oldValue } = atomUpdate;
|
|
2125
|
-
const value = direction === `forward` ? newValue : oldValue;
|
|
2126
|
-
atom_io.setState({ key, type: `atom` }, value, store);
|
|
2127
|
-
};
|
|
2128
|
-
const updateValuesFromTransactionUpdate = (transactionUpdate) => {
|
|
2129
|
-
const updates = direction === `forward` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
|
|
2130
|
-
for (const updateFromTransaction of updates) {
|
|
2131
|
-
if (`newValue` in updateFromTransaction) {
|
|
2132
|
-
updateValues(updateFromTransaction);
|
|
2133
|
-
} else {
|
|
2134
|
-
updateValuesFromTransactionUpdate(updateFromTransaction);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
};
|
|
2143
|
+
const applying = action === `redo` ? `newValue` : `oldValue`;
|
|
2138
2144
|
switch (update.type) {
|
|
2139
2145
|
case `atom_update`: {
|
|
2140
|
-
|
|
2146
|
+
ingestAtomUpdate(applying, update, store);
|
|
2141
2147
|
break;
|
|
2142
2148
|
}
|
|
2143
2149
|
case `selector_update`: {
|
|
2144
|
-
|
|
2145
|
-
for (const atomUpdate of updates) {
|
|
2146
|
-
updateValues(atomUpdate);
|
|
2147
|
-
}
|
|
2150
|
+
ingestSelectorUpdate(applying, update, store);
|
|
2148
2151
|
break;
|
|
2149
2152
|
}
|
|
2150
2153
|
case `transaction_update`: {
|
|
2151
|
-
|
|
2154
|
+
ingestTransactionUpdate(applying, update, store);
|
|
2152
2155
|
break;
|
|
2153
2156
|
}
|
|
2154
2157
|
}
|
|
2155
|
-
if (
|
|
2158
|
+
if (action === `redo`) {
|
|
2156
2159
|
++timelineData.at;
|
|
2157
2160
|
}
|
|
2158
2161
|
timelineData.subject.next(action);
|
|
@@ -2185,44 +2188,8 @@ var abortTransaction = (store) => {
|
|
|
2185
2188
|
);
|
|
2186
2189
|
target.parent.child = null;
|
|
2187
2190
|
};
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
const { key, newValue } = update;
|
|
2191
|
-
const token = { key, type: `atom` };
|
|
2192
|
-
if (!parent.valueMap.has(token.key)) {
|
|
2193
|
-
if (token.family) {
|
|
2194
|
-
const family = parent.families.get(token.family.key);
|
|
2195
|
-
if (family) {
|
|
2196
|
-
family(token.family.subKey);
|
|
2197
|
-
}
|
|
2198
|
-
} else {
|
|
2199
|
-
const newAtom = child.atoms.get(token.key);
|
|
2200
|
-
if (!newAtom) {
|
|
2201
|
-
throw new Error(
|
|
2202
|
-
`Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${(_a = child.transactionMeta) == null ? void 0 : _a.update.key}" to store "${parent.config.name}"`
|
|
2203
|
-
);
|
|
2204
|
-
}
|
|
2205
|
-
parent.atoms.set(newAtom.key, newAtom);
|
|
2206
|
-
parent.valueMap.set(newAtom.key, newAtom.default);
|
|
2207
|
-
parent.logger.info(
|
|
2208
|
-
`\u{1F528}`,
|
|
2209
|
-
`transaction`,
|
|
2210
|
-
(_c = (_b = child.transactionMeta) == null ? void 0 : _b.update.key) != null ? _c : `???`,
|
|
2211
|
-
`Adding atom "${newAtom.key}"`
|
|
2212
|
-
);
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
atom_io.setState(token, newValue, parent);
|
|
2216
|
-
}
|
|
2217
|
-
function ingestTransactionUpdate(transactionUpdate, parent, child) {
|
|
2218
|
-
for (const update of transactionUpdate.updates) {
|
|
2219
|
-
if (`newValue` in update) {
|
|
2220
|
-
ingestAtomUpdate(update, parent, child);
|
|
2221
|
-
} else {
|
|
2222
|
-
ingestTransactionUpdate(update, parent, child);
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2191
|
+
|
|
2192
|
+
// internal/src/transaction/apply-transaction.ts
|
|
2226
2193
|
var applyTransaction = (output, store) => {
|
|
2227
2194
|
var _a;
|
|
2228
2195
|
const child = newest(store);
|
|
@@ -2268,7 +2235,7 @@ var applyTransaction = (output, store) => {
|
|
|
2268
2235
|
);
|
|
2269
2236
|
}
|
|
2270
2237
|
}
|
|
2271
|
-
ingestTransactionUpdate(child.transactionMeta.update, parent
|
|
2238
|
+
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2272
2239
|
if (parent.transactionMeta === null) {
|
|
2273
2240
|
const myTransaction = withdraw(
|
|
2274
2241
|
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
@@ -2286,39 +2253,7 @@ var applyTransaction = (output, store) => {
|
|
|
2286
2253
|
}
|
|
2287
2254
|
parent.on.transactionApplying.next(null);
|
|
2288
2255
|
};
|
|
2289
|
-
|
|
2290
|
-
var _a;
|
|
2291
|
-
const state = (_a = Internal2__namespace.withdraw(token, store)) != null ? _a : Internal2__namespace.withdrawNewFamilyMember(token, store);
|
|
2292
|
-
if (state === void 0) {
|
|
2293
|
-
throw new Internal2__namespace.NotFoundError(token, store);
|
|
2294
|
-
}
|
|
2295
|
-
return Internal2__namespace.readOrComputeValue(state, store);
|
|
2296
|
-
}
|
|
2297
|
-
function setState5(token, value, store = Internal2__namespace.IMPLICIT.STORE) {
|
|
2298
|
-
var _a;
|
|
2299
|
-
const rejection = Internal2__namespace.openOperation(token, store);
|
|
2300
|
-
if (rejection) {
|
|
2301
|
-
return;
|
|
2302
|
-
}
|
|
2303
|
-
const state = (_a = Internal2__namespace.withdraw(token, store)) != null ? _a : Internal2__namespace.withdrawNewFamilyMember(token, store);
|
|
2304
|
-
if (state === void 0) {
|
|
2305
|
-
throw new Internal2__namespace.NotFoundError(token, store);
|
|
2306
|
-
}
|
|
2307
|
-
Internal2__namespace.setAtomOrSelector(state, value, store);
|
|
2308
|
-
Internal2__namespace.closeOperation(store);
|
|
2309
|
-
}
|
|
2310
|
-
var runTransaction = (token, store = Internal2.IMPLICIT.STORE) => (...parameters) => {
|
|
2311
|
-
const tx = Internal2.withdraw(token, store);
|
|
2312
|
-
if (tx) {
|
|
2313
|
-
return tx.run(...parameters);
|
|
2314
|
-
}
|
|
2315
|
-
throw new Error(
|
|
2316
|
-
`Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
2317
|
-
);
|
|
2318
|
-
};
|
|
2319
|
-
|
|
2320
|
-
// internal/src/transaction/build-transaction.ts
|
|
2321
|
-
var buildTransaction = (key, params, store) => {
|
|
2256
|
+
var buildTransaction = (key, params, store, id) => {
|
|
2322
2257
|
const parent = newest(store);
|
|
2323
2258
|
const child = {
|
|
2324
2259
|
parent,
|
|
@@ -2349,14 +2284,17 @@ var buildTransaction = (key, params, store) => {
|
|
|
2349
2284
|
time: Date.now(),
|
|
2350
2285
|
update: {
|
|
2351
2286
|
key,
|
|
2287
|
+
id: id != null ? id : Math.random().toString(36).slice(2),
|
|
2352
2288
|
updates: [],
|
|
2353
2289
|
params,
|
|
2354
2290
|
output: void 0
|
|
2355
2291
|
},
|
|
2356
2292
|
transactors: {
|
|
2357
|
-
get: (token) =>
|
|
2358
|
-
set: (token, value) =>
|
|
2359
|
-
run: (token) => runTransaction(token, child)
|
|
2293
|
+
get: (token) => atom_io.getState(token, child),
|
|
2294
|
+
set: (token, value) => atom_io.setState(token, value, child),
|
|
2295
|
+
run: (token) => atom_io.runTransaction(token, child),
|
|
2296
|
+
find: (token, key2) => atom_io.findInStore(token, key2, child),
|
|
2297
|
+
env: () => getEnvironmentData(child)
|
|
2360
2298
|
}
|
|
2361
2299
|
};
|
|
2362
2300
|
parent.child = child;
|
|
@@ -2370,12 +2308,12 @@ var buildTransaction = (key, params, store) => {
|
|
|
2370
2308
|
};
|
|
2371
2309
|
|
|
2372
2310
|
// internal/src/transaction/create-transaction.ts
|
|
2373
|
-
function
|
|
2311
|
+
function createTransaction(options, store) {
|
|
2374
2312
|
const newTransaction = {
|
|
2375
2313
|
key: options.key,
|
|
2376
2314
|
type: `transaction`,
|
|
2377
|
-
run: (
|
|
2378
|
-
buildTransaction(options.key, params, store);
|
|
2315
|
+
run: (params, id) => {
|
|
2316
|
+
buildTransaction(options.key, params, store, id);
|
|
2379
2317
|
try {
|
|
2380
2318
|
const target2 = newest(store);
|
|
2381
2319
|
const { transactors } = target2.transactionMeta;
|
|
@@ -2388,7 +2326,7 @@ function createTransaction2(options, store) {
|
|
|
2388
2326
|
throw thrown;
|
|
2389
2327
|
}
|
|
2390
2328
|
},
|
|
2391
|
-
install: (store2) =>
|
|
2329
|
+
install: (store2) => createTransaction(options, store2),
|
|
2392
2330
|
subject: new Subject()
|
|
2393
2331
|
};
|
|
2394
2332
|
const target = newest(store);
|
|
@@ -2429,17 +2367,21 @@ exports.createRegularAtomFamily = createRegularAtomFamily;
|
|
|
2429
2367
|
exports.createSelector = createSelector;
|
|
2430
2368
|
exports.createSelectorFamily = createSelectorFamily;
|
|
2431
2369
|
exports.createTimeline = createTimeline;
|
|
2432
|
-
exports.createTransaction =
|
|
2433
|
-
exports.deleteAtom =
|
|
2370
|
+
exports.createTransaction = createTransaction;
|
|
2371
|
+
exports.deleteAtom = deleteAtom;
|
|
2434
2372
|
exports.deleteSelector = deleteSelector;
|
|
2435
2373
|
exports.deposit = deposit;
|
|
2436
2374
|
exports.eldest = eldest;
|
|
2437
2375
|
exports.evictCachedValue = evictCachedValue;
|
|
2376
|
+
exports.getEnvironmentData = getEnvironmentData;
|
|
2438
2377
|
exports.getJsonFamily = getJsonFamily;
|
|
2439
2378
|
exports.getJsonToken = getJsonToken;
|
|
2440
2379
|
exports.getSelectorDependencyKeys = getSelectorDependencyKeys;
|
|
2441
2380
|
exports.getUpdateFamily = getUpdateFamily;
|
|
2442
2381
|
exports.getUpdateToken = getUpdateToken;
|
|
2382
|
+
exports.ingestAtomUpdate = ingestAtomUpdate;
|
|
2383
|
+
exports.ingestSelectorUpdate = ingestSelectorUpdate;
|
|
2384
|
+
exports.ingestTransactionUpdate = ingestTransactionUpdate;
|
|
2443
2385
|
exports.isAtomDefault = isAtomDefault;
|
|
2444
2386
|
exports.isAtomKey = isAtomKey;
|
|
2445
2387
|
exports.isDone = isDone;
|