atom.io 0.15.4 → 0.15.5
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 +82 -143
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +29 -17
- package/internal/dist/index.js +73 -89
- 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/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;
|
|
@@ -953,24 +933,27 @@ var registerSelector = (selectorKey, store) => ({
|
|
|
953
933
|
updateSelectorAtoms(selectorKey, dependency, store);
|
|
954
934
|
return dependencyValue;
|
|
955
935
|
},
|
|
956
|
-
set: (
|
|
957
|
-
const state = withdraw(
|
|
936
|
+
set: (WritableToken, newValue) => {
|
|
937
|
+
const state = withdraw(WritableToken, store);
|
|
958
938
|
if (state === void 0) {
|
|
959
939
|
throw new Error(
|
|
960
|
-
`State "${
|
|
940
|
+
`State "${WritableToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
961
941
|
);
|
|
962
942
|
}
|
|
963
943
|
setAtomOrSelector(state, newValue, store);
|
|
964
|
-
}
|
|
944
|
+
},
|
|
945
|
+
find: (token, key) => atom_io.findInStore(token, key, store)
|
|
965
946
|
});
|
|
966
947
|
|
|
967
948
|
// internal/src/selector/create-read-write-selector.ts
|
|
968
949
|
var createReadWriteSelector = (options, family, store) => {
|
|
969
950
|
const target = newest(store);
|
|
970
951
|
const subject = new Subject();
|
|
971
|
-
const
|
|
952
|
+
const transactors = registerSelector(options.key, store);
|
|
953
|
+
const { find, get } = transactors;
|
|
954
|
+
const readonlyTransactors = { find, get };
|
|
972
955
|
const getSelf = () => {
|
|
973
|
-
const value = options.get(
|
|
956
|
+
const value = options.get(readonlyTransactors);
|
|
974
957
|
cacheValue(options.key, value, subject, newest(store));
|
|
975
958
|
return value;
|
|
976
959
|
};
|
|
@@ -992,7 +975,7 @@ var createReadWriteSelector = (options, family, store) => {
|
|
|
992
975
|
if (target.transactionMeta === null) {
|
|
993
976
|
subject.next({ newValue, oldValue });
|
|
994
977
|
}
|
|
995
|
-
options.set(
|
|
978
|
+
options.set(transactors, newValue);
|
|
996
979
|
};
|
|
997
980
|
const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
998
981
|
subject,
|
|
@@ -1019,9 +1002,9 @@ var createReadWriteSelector = (options, family, store) => {
|
|
|
1019
1002
|
var createReadonlySelector = (options, family, store) => {
|
|
1020
1003
|
const target = newest(store);
|
|
1021
1004
|
const subject = new Subject();
|
|
1022
|
-
const { get } = registerSelector(options.key, store);
|
|
1005
|
+
const { get, find } = registerSelector(options.key, store);
|
|
1023
1006
|
const getSelf = () => {
|
|
1024
|
-
const value = options.get({ get });
|
|
1007
|
+
const value = options.get({ get, find });
|
|
1025
1008
|
cacheValue(options.key, value, subject, store);
|
|
1026
1009
|
return value;
|
|
1027
1010
|
};
|
|
@@ -1185,7 +1168,7 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1185
1168
|
return unsubscribe;
|
|
1186
1169
|
}
|
|
1187
1170
|
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1188
|
-
const tl =
|
|
1171
|
+
const tl = internal.withdraw(token, store);
|
|
1189
1172
|
if (tl === void 0) {
|
|
1190
1173
|
throw new Error(
|
|
1191
1174
|
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
@@ -1204,7 +1187,7 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
|
1204
1187
|
};
|
|
1205
1188
|
};
|
|
1206
1189
|
var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
1207
|
-
const tx =
|
|
1190
|
+
const tx = internal.withdraw(token, store);
|
|
1208
1191
|
if (tx === void 0) {
|
|
1209
1192
|
throw new Error(
|
|
1210
1193
|
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
@@ -1704,7 +1687,7 @@ function createAtom(options, family, store) {
|
|
|
1704
1687
|
}
|
|
1705
1688
|
|
|
1706
1689
|
// internal/src/atom/delete-atom.ts
|
|
1707
|
-
function
|
|
1690
|
+
function deleteAtom(atomToken, store) {
|
|
1708
1691
|
var _a, _b;
|
|
1709
1692
|
const target = newest(store);
|
|
1710
1693
|
const { key } = atomToken;
|
|
@@ -1735,6 +1718,39 @@ function deleteAtom2(atomToken, store) {
|
|
|
1735
1718
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1736
1719
|
}
|
|
1737
1720
|
|
|
1721
|
+
// internal/src/get-environment-data.ts
|
|
1722
|
+
function getEnvironmentData(store) {
|
|
1723
|
+
return {
|
|
1724
|
+
runtime: typeof window === `undefined` ? typeof global === `object` ? `node` : `unknown` : `browser`,
|
|
1725
|
+
store
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
1729
|
+
const { key, newValue, oldValue } = atomUpdate;
|
|
1730
|
+
const value = applying === `newValue` ? newValue : oldValue;
|
|
1731
|
+
atom_io.setState({ key, type: `atom` }, value, store);
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
// internal/src/ingest-updates/ingest-selector-update.ts
|
|
1735
|
+
function ingestSelectorUpdate(applying, selectorUpdate, store) {
|
|
1736
|
+
const updates = applying === `newValue` ? selectorUpdate.atomUpdates : [...selectorUpdate.atomUpdates].reverse();
|
|
1737
|
+
for (const atomUpdate of updates) {
|
|
1738
|
+
ingestAtomUpdate(applying, atomUpdate, store);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
// internal/src/ingest-updates/ingest-transaction-update.ts
|
|
1743
|
+
function ingestTransactionUpdate(applying, transactionUpdate, store) {
|
|
1744
|
+
const updates = applying === `newValue` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
|
|
1745
|
+
for (const updateFromTransaction of updates) {
|
|
1746
|
+
if (`newValue` in updateFromTransaction) {
|
|
1747
|
+
ingestAtomUpdate(applying, updateFromTransaction, store);
|
|
1748
|
+
} else {
|
|
1749
|
+
ingestTransactionUpdate(applying, updateFromTransaction, store);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1738
1754
|
// internal/src/lazy-map.ts
|
|
1739
1755
|
var LazyMap = class extends Map {
|
|
1740
1756
|
constructor(source) {
|
|
@@ -2088,10 +2104,11 @@ function createTimeline(options, store, data) {
|
|
|
2088
2104
|
store.on.timelineCreation.next(token);
|
|
2089
2105
|
return token;
|
|
2090
2106
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2107
|
+
|
|
2108
|
+
// internal/src/timeline/time-travel.ts
|
|
2109
|
+
var timeTravel = (action, token, store) => {
|
|
2093
2110
|
store.logger.info(
|
|
2094
|
-
|
|
2111
|
+
action === `redo` ? `\u23E9` : `\u23EA`,
|
|
2095
2112
|
`timeline`,
|
|
2096
2113
|
token.key,
|
|
2097
2114
|
action
|
|
@@ -2106,53 +2123,36 @@ var timeTravel = (direction, token, store) => {
|
|
|
2106
2123
|
);
|
|
2107
2124
|
return;
|
|
2108
2125
|
}
|
|
2109
|
-
if (
|
|
2126
|
+
if (action === `redo` && timelineData.at === timelineData.history.length || action === `undo` && timelineData.at === 0) {
|
|
2110
2127
|
store.logger.warn(
|
|
2111
2128
|
`\u{1F481}`,
|
|
2112
2129
|
`timeline`,
|
|
2113
2130
|
token.key,
|
|
2114
|
-
`Failed to ${action} at the ${
|
|
2131
|
+
`Failed to ${action} at the ${action === `redo` ? `end` : `beginning`} of timeline "${token.key}". There is nothing to ${action}.`
|
|
2115
2132
|
);
|
|
2116
2133
|
return;
|
|
2117
2134
|
}
|
|
2118
|
-
timelineData.timeTraveling =
|
|
2119
|
-
if (
|
|
2135
|
+
timelineData.timeTraveling = action === `redo` ? `into_future` : `into_past`;
|
|
2136
|
+
if (action === `undo`) {
|
|
2120
2137
|
--timelineData.at;
|
|
2121
2138
|
}
|
|
2122
2139
|
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
|
-
};
|
|
2140
|
+
const applying = action === `redo` ? `newValue` : `oldValue`;
|
|
2138
2141
|
switch (update.type) {
|
|
2139
2142
|
case `atom_update`: {
|
|
2140
|
-
|
|
2143
|
+
ingestAtomUpdate(applying, update, store);
|
|
2141
2144
|
break;
|
|
2142
2145
|
}
|
|
2143
2146
|
case `selector_update`: {
|
|
2144
|
-
|
|
2145
|
-
for (const atomUpdate of updates) {
|
|
2146
|
-
updateValues(atomUpdate);
|
|
2147
|
-
}
|
|
2147
|
+
ingestSelectorUpdate(applying, update, store);
|
|
2148
2148
|
break;
|
|
2149
2149
|
}
|
|
2150
2150
|
case `transaction_update`: {
|
|
2151
|
-
|
|
2151
|
+
ingestTransactionUpdate(applying, update, store);
|
|
2152
2152
|
break;
|
|
2153
2153
|
}
|
|
2154
2154
|
}
|
|
2155
|
-
if (
|
|
2155
|
+
if (action === `redo`) {
|
|
2156
2156
|
++timelineData.at;
|
|
2157
2157
|
}
|
|
2158
2158
|
timelineData.subject.next(action);
|
|
@@ -2185,44 +2185,8 @@ var abortTransaction = (store) => {
|
|
|
2185
2185
|
);
|
|
2186
2186
|
target.parent.child = null;
|
|
2187
2187
|
};
|
|
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
|
-
}
|
|
2188
|
+
|
|
2189
|
+
// internal/src/transaction/apply-transaction.ts
|
|
2226
2190
|
var applyTransaction = (output, store) => {
|
|
2227
2191
|
var _a;
|
|
2228
2192
|
const child = newest(store);
|
|
@@ -2268,7 +2232,7 @@ var applyTransaction = (output, store) => {
|
|
|
2268
2232
|
);
|
|
2269
2233
|
}
|
|
2270
2234
|
}
|
|
2271
|
-
ingestTransactionUpdate(child.transactionMeta.update, parent
|
|
2235
|
+
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2272
2236
|
if (parent.transactionMeta === null) {
|
|
2273
2237
|
const myTransaction = withdraw(
|
|
2274
2238
|
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
@@ -2286,39 +2250,7 @@ var applyTransaction = (output, store) => {
|
|
|
2286
2250
|
}
|
|
2287
2251
|
parent.on.transactionApplying.next(null);
|
|
2288
2252
|
};
|
|
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) => {
|
|
2253
|
+
var buildTransaction = (key, params, store, id) => {
|
|
2322
2254
|
const parent = newest(store);
|
|
2323
2255
|
const child = {
|
|
2324
2256
|
parent,
|
|
@@ -2349,14 +2281,17 @@ var buildTransaction = (key, params, store) => {
|
|
|
2349
2281
|
time: Date.now(),
|
|
2350
2282
|
update: {
|
|
2351
2283
|
key,
|
|
2284
|
+
id: id != null ? id : Math.random().toString(36).slice(2),
|
|
2352
2285
|
updates: [],
|
|
2353
2286
|
params,
|
|
2354
2287
|
output: void 0
|
|
2355
2288
|
},
|
|
2356
2289
|
transactors: {
|
|
2357
|
-
get: (token) =>
|
|
2358
|
-
set: (token, value) =>
|
|
2359
|
-
run: (token) => runTransaction(token, child)
|
|
2290
|
+
get: (token) => atom_io.getState(token, child),
|
|
2291
|
+
set: (token, value) => atom_io.setState(token, value, child),
|
|
2292
|
+
run: (token) => atom_io.runTransaction(token, child),
|
|
2293
|
+
find: (token, key2) => atom_io.findInStore(token, key2, child),
|
|
2294
|
+
env: () => getEnvironmentData(child)
|
|
2360
2295
|
}
|
|
2361
2296
|
};
|
|
2362
2297
|
parent.child = child;
|
|
@@ -2370,12 +2305,12 @@ var buildTransaction = (key, params, store) => {
|
|
|
2370
2305
|
};
|
|
2371
2306
|
|
|
2372
2307
|
// internal/src/transaction/create-transaction.ts
|
|
2373
|
-
function
|
|
2308
|
+
function createTransaction(options, store) {
|
|
2374
2309
|
const newTransaction = {
|
|
2375
2310
|
key: options.key,
|
|
2376
2311
|
type: `transaction`,
|
|
2377
|
-
run: (
|
|
2378
|
-
buildTransaction(options.key, params, store);
|
|
2312
|
+
run: (params, id) => {
|
|
2313
|
+
buildTransaction(options.key, params, store, id);
|
|
2379
2314
|
try {
|
|
2380
2315
|
const target2 = newest(store);
|
|
2381
2316
|
const { transactors } = target2.transactionMeta;
|
|
@@ -2388,7 +2323,7 @@ function createTransaction2(options, store) {
|
|
|
2388
2323
|
throw thrown;
|
|
2389
2324
|
}
|
|
2390
2325
|
},
|
|
2391
|
-
install: (store2) =>
|
|
2326
|
+
install: (store2) => createTransaction(options, store2),
|
|
2392
2327
|
subject: new Subject()
|
|
2393
2328
|
};
|
|
2394
2329
|
const target = newest(store);
|
|
@@ -2429,17 +2364,21 @@ exports.createRegularAtomFamily = createRegularAtomFamily;
|
|
|
2429
2364
|
exports.createSelector = createSelector;
|
|
2430
2365
|
exports.createSelectorFamily = createSelectorFamily;
|
|
2431
2366
|
exports.createTimeline = createTimeline;
|
|
2432
|
-
exports.createTransaction =
|
|
2433
|
-
exports.deleteAtom =
|
|
2367
|
+
exports.createTransaction = createTransaction;
|
|
2368
|
+
exports.deleteAtom = deleteAtom;
|
|
2434
2369
|
exports.deleteSelector = deleteSelector;
|
|
2435
2370
|
exports.deposit = deposit;
|
|
2436
2371
|
exports.eldest = eldest;
|
|
2437
2372
|
exports.evictCachedValue = evictCachedValue;
|
|
2373
|
+
exports.getEnvironmentData = getEnvironmentData;
|
|
2438
2374
|
exports.getJsonFamily = getJsonFamily;
|
|
2439
2375
|
exports.getJsonToken = getJsonToken;
|
|
2440
2376
|
exports.getSelectorDependencyKeys = getSelectorDependencyKeys;
|
|
2441
2377
|
exports.getUpdateFamily = getUpdateFamily;
|
|
2442
2378
|
exports.getUpdateToken = getUpdateToken;
|
|
2379
|
+
exports.ingestAtomUpdate = ingestAtomUpdate;
|
|
2380
|
+
exports.ingestSelectorUpdate = ingestSelectorUpdate;
|
|
2381
|
+
exports.ingestTransactionUpdate = ingestTransactionUpdate;
|
|
2443
2382
|
exports.isAtomDefault = isAtomDefault;
|
|
2444
2383
|
exports.isAtomKey = isAtomKey;
|
|
2445
2384
|
exports.isDone = isDone;
|