atom.io 0.23.5 → 0.24.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/data/dist/index.cjs +51 -27
- package/data/dist/index.d.ts +5 -4
- package/data/dist/index.js +625 -9
- package/data/src/join.ts +74 -46
- package/dist/chunk-BF4MVQF6.js +44 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.ts +63 -18
- package/dist/index.js +27 -3
- package/immortal/dist/index.cjs +4 -262
- package/immortal/dist/index.d.ts +4 -94
- package/immortal/dist/index.js +3 -215
- package/immortal/src/index.ts +0 -2
- package/immortal/src/seek-state.ts +10 -11
- package/internal/dist/index.cjs +279 -111
- package/internal/dist/index.d.ts +63 -93
- package/internal/dist/index.js +273 -88
- package/internal/src/families/dispose-from-store.ts +11 -7
- package/internal/src/families/find-in-store.ts +2 -2
- package/internal/src/families/init-family-member.ts +37 -25
- package/internal/src/families/seek-in-store.ts +11 -15
- package/internal/src/get-environment-data.ts +0 -4
- package/internal/src/index.ts +1 -0
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +8 -8
- package/internal/src/molecule/create-molecule-family.ts +30 -0
- package/internal/src/molecule/dispose-molecule.ts +76 -0
- package/internal/src/molecule/grow-molecule-in-store.ts +89 -0
- package/internal/src/molecule/index.ts +5 -0
- package/internal/src/molecule/make-molecule-in-store.ts +122 -0
- package/internal/src/molecule/molecule-internal.ts +48 -0
- package/internal/src/not-found-error.ts +4 -3
- package/internal/src/set-state/emit-update.ts +1 -2
- package/internal/src/store/deposit.ts +16 -30
- package/internal/src/store/store.ts +7 -12
- package/internal/src/store/withdraw.ts +30 -19
- package/internal/src/timeline/create-timeline.ts +7 -6
- package/internal/src/transaction/build-transaction.ts +2 -1
- package/introspection/dist/index.cjs +29 -33
- package/introspection/dist/index.js +1 -1
- package/introspection/src/auditor.ts +6 -6
- package/json/dist/index.cjs +4 -4
- package/json/dist/index.js +7 -8
- package/json/src/select-json-family.ts +6 -5
- package/package.json +2 -2
- package/react-devtools/dist/index.js +2 -3
- package/realtime-client/dist/index.js +362 -15
- package/realtime-react/dist/index.cjs +1 -326
- package/realtime-react/dist/index.d.ts +1 -14
- package/realtime-react/dist/index.js +1 -1
- package/realtime-react/src/use-sync-continuity.ts +2 -2
- package/realtime-server/dist/index.cjs +3 -151
- package/realtime-server/dist/index.d.ts +1 -3
- package/realtime-server/dist/index.js +2 -18
- package/realtime-server/src/index.ts +0 -2
- package/realtime-server/src/realtime-continuity-synchronizer.ts +1 -1
- package/realtime-testing/dist/index.cjs +4 -82
- package/realtime-testing/dist/index.js +2 -4
- package/realtime-testing/src/setup-realtime-test.tsx +2 -3
- package/src/dispose-state.ts +2 -2
- package/src/index.ts +1 -0
- package/src/logger.ts +2 -0
- package/src/molecule.ts +133 -0
- package/src/timeline.ts +3 -3
- package/src/transaction.ts +15 -13
- package/dist/chunk-6MLFYN32.js +0 -18
- package/dist/chunk-7DT3PVS3.js +0 -598
- package/dist/chunk-GVHKIJ3G.js +0 -329
- package/dist/chunk-O47EQUM6.js +0 -29
- package/dist/chunk-OAYGID5B.js +0 -27
- package/dist/chunk-PNIHPILQ.js +0 -8
- package/immortal/src/make-molecule.ts +0 -234
- package/immortal/src/molecule.ts +0 -167
- package/realtime-server/src/realtime-state-synchronizer.ts +0 -23
package/internal/dist/index.cjs
CHANGED
|
@@ -2,28 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var json = require('atom.io/json');
|
|
4
4
|
var atom_io = require('atom.io');
|
|
5
|
-
var
|
|
6
|
-
var Internal = require('atom.io/internal');
|
|
7
|
-
|
|
8
|
-
function _interopNamespace(e) {
|
|
9
|
-
if (e && e.__esModule) return e;
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var Internal__namespace = /*#__PURE__*/_interopNamespace(Internal);
|
|
5
|
+
var data = require('atom.io/data');
|
|
27
6
|
|
|
28
7
|
var __defProp = Object.defineProperty;
|
|
29
8
|
var __defProps = Object.defineProperties;
|
|
@@ -102,26 +81,14 @@ function newest(scion) {
|
|
|
102
81
|
|
|
103
82
|
// internal/src/store/deposit.ts
|
|
104
83
|
function deposit(state) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
case `readonly_selector`:
|
|
112
|
-
case `transaction`: {
|
|
113
|
-
const token = {
|
|
114
|
-
key: state.key,
|
|
115
|
-
type: state.type
|
|
116
|
-
};
|
|
117
|
-
if (`family` in state) {
|
|
118
|
-
token.family = state.family;
|
|
119
|
-
}
|
|
120
|
-
return token;
|
|
121
|
-
}
|
|
122
|
-
case `molecule`:
|
|
123
|
-
return state.token;
|
|
84
|
+
const token = {
|
|
85
|
+
key: state.key,
|
|
86
|
+
type: state.type
|
|
87
|
+
};
|
|
88
|
+
if (`family` in state) {
|
|
89
|
+
token.family = state.family;
|
|
124
90
|
}
|
|
91
|
+
return token;
|
|
125
92
|
}
|
|
126
93
|
|
|
127
94
|
// ../rel8/junction/src/junction.ts
|
|
@@ -734,21 +701,27 @@ function createSelectorFamily(options, store) {
|
|
|
734
701
|
}
|
|
735
702
|
return createReadonlySelectorFamily(options, store);
|
|
736
703
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
break;
|
|
704
|
+
|
|
705
|
+
// internal/src/transaction/abort-transaction.ts
|
|
706
|
+
var abortTransaction = (store) => {
|
|
707
|
+
const target = newest(store);
|
|
708
|
+
if (!isChildStore(target)) {
|
|
709
|
+
store.logger.warn(
|
|
710
|
+
`\u{1F41E}`,
|
|
711
|
+
`transaction`,
|
|
712
|
+
`???`,
|
|
713
|
+
`abortTransaction called outside of a transaction. This is probably a bug in AtomIO.`
|
|
714
|
+
);
|
|
715
|
+
return;
|
|
750
716
|
}
|
|
751
|
-
|
|
717
|
+
store.logger.info(
|
|
718
|
+
`\u{1FA82}`,
|
|
719
|
+
`transaction`,
|
|
720
|
+
target.transactionMeta.update.key,
|
|
721
|
+
`Aborting transaction`
|
|
722
|
+
);
|
|
723
|
+
target.parent.child = null;
|
|
724
|
+
};
|
|
752
725
|
|
|
753
726
|
// internal/src/not-found-error.ts
|
|
754
727
|
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
@@ -776,27 +749,6 @@ var NotFoundError = class extends Error {
|
|
|
776
749
|
}
|
|
777
750
|
};
|
|
778
751
|
|
|
779
|
-
// internal/src/transaction/abort-transaction.ts
|
|
780
|
-
var abortTransaction = (store) => {
|
|
781
|
-
const target = newest(store);
|
|
782
|
-
if (!isChildStore(target)) {
|
|
783
|
-
store.logger.warn(
|
|
784
|
-
`\u{1F41E}`,
|
|
785
|
-
`transaction`,
|
|
786
|
-
`???`,
|
|
787
|
-
`abortTransaction called outside of a transaction. This is probably a bug in AtomIO.`
|
|
788
|
-
);
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
store.logger.info(
|
|
792
|
-
`\u{1FA82}`,
|
|
793
|
-
`transaction`,
|
|
794
|
-
target.transactionMeta.update.key,
|
|
795
|
-
`Aborting transaction`
|
|
796
|
-
);
|
|
797
|
-
target.parent.child = null;
|
|
798
|
-
};
|
|
799
|
-
|
|
800
752
|
// internal/src/transaction/act-upon-store.ts
|
|
801
753
|
function actUponStore(token, id, store) {
|
|
802
754
|
return (...parameters) => {
|
|
@@ -1068,8 +1020,154 @@ function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
|
1068
1020
|
setIntoStore(token, value, store);
|
|
1069
1021
|
}
|
|
1070
1022
|
|
|
1071
|
-
//
|
|
1072
|
-
|
|
1023
|
+
// internal/src/molecule/create-molecule-family.ts
|
|
1024
|
+
function createMoleculeFamily(options, store) {
|
|
1025
|
+
var _a;
|
|
1026
|
+
const subject = new Subject();
|
|
1027
|
+
const token = {
|
|
1028
|
+
type: `molecule_family`,
|
|
1029
|
+
key: options.key,
|
|
1030
|
+
dependsOn: (_a = options.dependsOn) != null ? _a : `all`
|
|
1031
|
+
};
|
|
1032
|
+
const family = __spreadProps(__spreadValues({}, token), {
|
|
1033
|
+
subject,
|
|
1034
|
+
new: options.new
|
|
1035
|
+
});
|
|
1036
|
+
store.moleculeFamilies.set(options.key, family);
|
|
1037
|
+
return token;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// internal/src/molecule/grow-molecule-in-store.ts
|
|
1041
|
+
function growMoleculeInStore(molecule, family, store) {
|
|
1042
|
+
const stateToken = initFamilyMemberInStore(family, molecule.key, store);
|
|
1043
|
+
molecule.tokens.set(stateToken.key, stateToken);
|
|
1044
|
+
const isTransaction = isChildStore(store) && store.transactionMeta.phase === `building`;
|
|
1045
|
+
if (isTransaction) {
|
|
1046
|
+
store.transactionMeta.update.updates.push({
|
|
1047
|
+
type: `state_creation`,
|
|
1048
|
+
token: stateToken
|
|
1049
|
+
});
|
|
1050
|
+
} else {
|
|
1051
|
+
molecule.subject.next({ type: `state_creation`, token: stateToken });
|
|
1052
|
+
}
|
|
1053
|
+
return stateToken;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
// internal/src/get-environment-data.ts
|
|
1057
|
+
function getEnvironmentData(store) {
|
|
1058
|
+
return {
|
|
1059
|
+
store
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// internal/src/get-state/get-from-store.ts
|
|
1064
|
+
function getFromStore(token, store) {
|
|
1065
|
+
const state = withdraw(token, store);
|
|
1066
|
+
return readOrComputeValue(state, store);
|
|
1067
|
+
}
|
|
1068
|
+
var Molecule = class {
|
|
1069
|
+
constructor(ctx, key, family) {
|
|
1070
|
+
this.key = key;
|
|
1071
|
+
this.type = `molecule`;
|
|
1072
|
+
this.subject = new Subject();
|
|
1073
|
+
this.tokens = /* @__PURE__ */ new Map();
|
|
1074
|
+
this.above = /* @__PURE__ */ new Map();
|
|
1075
|
+
this.below = /* @__PURE__ */ new Map();
|
|
1076
|
+
this.joins = /* @__PURE__ */ new Map();
|
|
1077
|
+
this.stringKey = json.stringifyJson(key);
|
|
1078
|
+
if (family) {
|
|
1079
|
+
this.family = family;
|
|
1080
|
+
}
|
|
1081
|
+
if (ctx) {
|
|
1082
|
+
if (Array.isArray(ctx)) {
|
|
1083
|
+
for (const molecule of ctx) {
|
|
1084
|
+
this.above.set(molecule.stringKey, molecule);
|
|
1085
|
+
}
|
|
1086
|
+
} else {
|
|
1087
|
+
this.above.set(ctx.stringKey, ctx);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
// internal/src/molecule/make-molecule-in-store.ts
|
|
1094
|
+
function makeMoleculeInStore(store, context, familyToken, key, ...params) {
|
|
1095
|
+
const target = newest(store);
|
|
1096
|
+
const token = {
|
|
1097
|
+
type: `molecule`,
|
|
1098
|
+
key,
|
|
1099
|
+
family: familyToken
|
|
1100
|
+
};
|
|
1101
|
+
const contextArray = Array.isArray(context) ? context : [context];
|
|
1102
|
+
const owners = contextArray.map((ctx) => {
|
|
1103
|
+
if (ctx instanceof Molecule) {
|
|
1104
|
+
return ctx;
|
|
1105
|
+
}
|
|
1106
|
+
const stringKey = json.stringifyJson(ctx.key);
|
|
1107
|
+
const molecule2 = store.molecules.get(stringKey);
|
|
1108
|
+
if (!molecule2) {
|
|
1109
|
+
throw new Error(
|
|
1110
|
+
`Molecule ${stringKey} not found in store "${store.config.name}"`
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
return molecule2;
|
|
1114
|
+
});
|
|
1115
|
+
const family = withdraw(familyToken, store);
|
|
1116
|
+
const molecule = new Molecule(owners, key, family);
|
|
1117
|
+
target.molecules.set(json.stringifyJson(key), molecule);
|
|
1118
|
+
for (const owner of owners) {
|
|
1119
|
+
owner.below.set(molecule.stringKey, molecule);
|
|
1120
|
+
}
|
|
1121
|
+
const transactors = {
|
|
1122
|
+
get: (t) => getFromStore(t, newest(store)),
|
|
1123
|
+
set: (t, newValue) => {
|
|
1124
|
+
setIntoStore(t, newValue, newest(store));
|
|
1125
|
+
},
|
|
1126
|
+
seek: (t, k) => seekInStore(t, k, newest(store)),
|
|
1127
|
+
json: (t) => getJsonToken(t, newest(store)),
|
|
1128
|
+
run: (t, i = arbitrary()) => actUponStore(t, i, newest(store)),
|
|
1129
|
+
make: (ctx, f, k, ...args) => makeMoleculeInStore(newest(store), ctx, f, k, ...args),
|
|
1130
|
+
dispose: (t) => {
|
|
1131
|
+
disposeFromStore(t, newest(store));
|
|
1132
|
+
},
|
|
1133
|
+
env: () => getEnvironmentData(newest(store)),
|
|
1134
|
+
bond: (f) => growMoleculeInStore(
|
|
1135
|
+
molecule,
|
|
1136
|
+
withdraw(f, store),
|
|
1137
|
+
newest(store)
|
|
1138
|
+
),
|
|
1139
|
+
join: (joinToken) => {
|
|
1140
|
+
const join = data.getJoin(joinToken, store);
|
|
1141
|
+
join.molecules.set(json.stringifyJson(key), molecule);
|
|
1142
|
+
molecule.joins.set(joinToken.key, join);
|
|
1143
|
+
},
|
|
1144
|
+
spawn: (f, k, ...p) => makeMoleculeInStore(
|
|
1145
|
+
newest(store),
|
|
1146
|
+
[molecule],
|
|
1147
|
+
withdraw(f, store),
|
|
1148
|
+
k,
|
|
1149
|
+
...p
|
|
1150
|
+
)
|
|
1151
|
+
};
|
|
1152
|
+
const Constructor = family.new;
|
|
1153
|
+
molecule.instance = new Constructor(transactors, token.key, ...params);
|
|
1154
|
+
const update = {
|
|
1155
|
+
type: `molecule_creation`,
|
|
1156
|
+
token,
|
|
1157
|
+
family,
|
|
1158
|
+
context: contextArray,
|
|
1159
|
+
params
|
|
1160
|
+
};
|
|
1161
|
+
const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
|
|
1162
|
+
if (isTransaction) {
|
|
1163
|
+
target.transactionMeta.update.updates.push(update);
|
|
1164
|
+
} else {
|
|
1165
|
+
family.subject.next(update);
|
|
1166
|
+
}
|
|
1167
|
+
return token;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// internal/src/ingest-updates/ingest-creation-disposal.ts
|
|
1073
1171
|
function ingestCreationEvent(update, applying, store) {
|
|
1074
1172
|
switch (applying) {
|
|
1075
1173
|
case `newValue`: {
|
|
@@ -1101,20 +1199,20 @@ function createInStore(token, store) {
|
|
|
1101
1199
|
if (family) {
|
|
1102
1200
|
const molecule = store.molecules.get(token.family.subKey);
|
|
1103
1201
|
if (molecule) {
|
|
1104
|
-
molecule
|
|
1202
|
+
growMoleculeInStore(molecule, family, store);
|
|
1105
1203
|
return;
|
|
1106
1204
|
}
|
|
1107
1205
|
if (store.config.lifespan === `immortal`) {
|
|
1108
1206
|
throw new Error(`No molecule found for key "${token.family.subKey}"`);
|
|
1109
1207
|
}
|
|
1110
|
-
|
|
1208
|
+
initFamilyMemberInStore(family, json.parseJson(token.family.subKey), store);
|
|
1111
1209
|
}
|
|
1112
1210
|
}
|
|
1113
1211
|
}
|
|
1114
1212
|
function ingestMoleculeCreationEvent(update, applying, store) {
|
|
1115
1213
|
switch (applying) {
|
|
1116
1214
|
case `newValue`:
|
|
1117
|
-
|
|
1215
|
+
makeMoleculeInStore(
|
|
1118
1216
|
store,
|
|
1119
1217
|
update.context[0],
|
|
1120
1218
|
update.family,
|
|
@@ -1123,17 +1221,17 @@ function ingestMoleculeCreationEvent(update, applying, store) {
|
|
|
1123
1221
|
);
|
|
1124
1222
|
break;
|
|
1125
1223
|
case `oldValue`:
|
|
1126
|
-
|
|
1224
|
+
disposeFromStore(update.token, store);
|
|
1127
1225
|
break;
|
|
1128
1226
|
}
|
|
1129
1227
|
}
|
|
1130
1228
|
function ingestMoleculeDisposalEvent(update, applying, store) {
|
|
1131
1229
|
switch (applying) {
|
|
1132
1230
|
case `newValue`:
|
|
1133
|
-
|
|
1231
|
+
disposeFromStore(update.token, store);
|
|
1134
1232
|
break;
|
|
1135
1233
|
case `oldValue`:
|
|
1136
|
-
|
|
1234
|
+
makeMoleculeInStore(
|
|
1137
1235
|
store,
|
|
1138
1236
|
update.context[0],
|
|
1139
1237
|
update.family,
|
|
@@ -1268,21 +1366,6 @@ function assignTransactionToContinuity(continuityKey, transactionKey, store) {
|
|
|
1268
1366
|
}
|
|
1269
1367
|
}
|
|
1270
1368
|
|
|
1271
|
-
// internal/src/get-environment-data.ts
|
|
1272
|
-
function getEnvironmentData(store) {
|
|
1273
|
-
return {
|
|
1274
|
-
window: typeof window === `undefined` ? void 0 : window,
|
|
1275
|
-
global: typeof global === `undefined` ? void 0 : global,
|
|
1276
|
-
store
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
// internal/src/get-state/get-from-store.ts
|
|
1281
|
-
function getFromStore(token, store) {
|
|
1282
|
-
const state = withdraw(token, store);
|
|
1283
|
-
return readOrComputeValue(state, store);
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
1369
|
// internal/src/lazy-map.ts
|
|
1287
1370
|
var LazyMap = class extends Map {
|
|
1288
1371
|
constructor(source) {
|
|
@@ -1367,7 +1450,7 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
1367
1450
|
find: (token, k) => findInStore(token, k, child),
|
|
1368
1451
|
seek: (token, k) => seekInStore(token, k, child),
|
|
1369
1452
|
json: (token) => getJsonToken(token, child),
|
|
1370
|
-
make: (context, family, k, ...args) =>
|
|
1453
|
+
make: (context, family, k, ...args) => makeMoleculeInStore(child, context, family, k, ...args),
|
|
1371
1454
|
dispose: (token) => {
|
|
1372
1455
|
disposeFromStore(token, child);
|
|
1373
1456
|
},
|
|
@@ -1438,8 +1521,88 @@ function getEpochNumberOfAction(transactionKey, store) {
|
|
|
1438
1521
|
// internal/src/transaction/index.ts
|
|
1439
1522
|
var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
1440
1523
|
|
|
1524
|
+
// internal/src/molecule/dispose-molecule.ts
|
|
1525
|
+
function disposeMolecule(token, store) {
|
|
1526
|
+
var _a;
|
|
1527
|
+
let molecule;
|
|
1528
|
+
try {
|
|
1529
|
+
molecule = withdraw(token, store);
|
|
1530
|
+
} catch (thrown) {
|
|
1531
|
+
if (thrown instanceof Error) {
|
|
1532
|
+
store.logger.error(
|
|
1533
|
+
`\u{1F41E}`,
|
|
1534
|
+
`molecule`,
|
|
1535
|
+
JSON.stringify(token.key),
|
|
1536
|
+
`Failed to dispose molecule, because it was not found in the store.`,
|
|
1537
|
+
thrown.message
|
|
1538
|
+
);
|
|
1539
|
+
}
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
const { family } = token;
|
|
1543
|
+
if (family) {
|
|
1544
|
+
const Formula = withdraw(family, store);
|
|
1545
|
+
const disposalEvent = {
|
|
1546
|
+
type: `molecule_disposal`,
|
|
1547
|
+
token,
|
|
1548
|
+
family,
|
|
1549
|
+
context: [...molecule.above.values()].map((m) => deposit(m)),
|
|
1550
|
+
familyKeys: [...molecule.tokens.values()].map((t) => {
|
|
1551
|
+
var _a2;
|
|
1552
|
+
return (_a2 = t.family) == null ? void 0 : _a2.key;
|
|
1553
|
+
}).filter((k) => typeof k === `string`)
|
|
1554
|
+
};
|
|
1555
|
+
if (token.family) {
|
|
1556
|
+
disposalEvent.family = token.family;
|
|
1557
|
+
}
|
|
1558
|
+
const isTransaction = isChildStore(store) && store.transactionMeta.phase === `building`;
|
|
1559
|
+
if (isTransaction) {
|
|
1560
|
+
store.transactionMeta.update.updates.push(disposalEvent);
|
|
1561
|
+
} else {
|
|
1562
|
+
Formula.subject.next(disposalEvent);
|
|
1563
|
+
}
|
|
1564
|
+
store.molecules.delete(molecule.stringKey);
|
|
1565
|
+
}
|
|
1566
|
+
for (const state of molecule.tokens.values()) {
|
|
1567
|
+
disposeFromStore(state, store);
|
|
1568
|
+
}
|
|
1569
|
+
for (const child of molecule.below.values()) {
|
|
1570
|
+
if (((_a = child.family) == null ? void 0 : _a.dependsOn) === `all`) {
|
|
1571
|
+
disposeMolecule(child, store);
|
|
1572
|
+
} else {
|
|
1573
|
+
child.above.delete(molecule.stringKey);
|
|
1574
|
+
if (child.above.size === 0) {
|
|
1575
|
+
disposeMolecule(child, store);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
for (const join of molecule.joins.values()) {
|
|
1580
|
+
join.molecules.delete(molecule.stringKey);
|
|
1581
|
+
}
|
|
1582
|
+
for (const parent of molecule.above.values()) {
|
|
1583
|
+
parent.below.delete(molecule.stringKey);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// internal/src/families/dispose-from-store.ts
|
|
1588
|
+
function disposeFromStore(token, store = IMPLICIT.STORE) {
|
|
1589
|
+
switch (token.type) {
|
|
1590
|
+
case `atom`:
|
|
1591
|
+
case `mutable_atom`:
|
|
1592
|
+
disposeAtom(token, store);
|
|
1593
|
+
break;
|
|
1594
|
+
case `selector`:
|
|
1595
|
+
case `readonly_selector`:
|
|
1596
|
+
disposeSelector(token, store);
|
|
1597
|
+
break;
|
|
1598
|
+
case `molecule`:
|
|
1599
|
+
disposeMolecule(token, store);
|
|
1600
|
+
break;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1441
1604
|
// internal/src/families/init-family-member.ts
|
|
1442
|
-
function
|
|
1605
|
+
function initFamilyMemberInStore(token, key, store) {
|
|
1443
1606
|
const familyKey = token.key;
|
|
1444
1607
|
const family = store.families.get(familyKey);
|
|
1445
1608
|
if (family === void 0) {
|
|
@@ -1507,7 +1670,7 @@ function findInStore(token, key, store) {
|
|
|
1507
1670
|
if (state) {
|
|
1508
1671
|
return state;
|
|
1509
1672
|
}
|
|
1510
|
-
state =
|
|
1673
|
+
state = initFamilyMemberInStore(token, key, store);
|
|
1511
1674
|
return state;
|
|
1512
1675
|
}
|
|
1513
1676
|
|
|
@@ -1724,7 +1887,7 @@ function createStandaloneSelector(options, store) {
|
|
|
1724
1887
|
}
|
|
1725
1888
|
|
|
1726
1889
|
// internal/src/selector/dispose-selector.ts
|
|
1727
|
-
function
|
|
1890
|
+
function disposeSelector(selectorToken, store) {
|
|
1728
1891
|
var _a;
|
|
1729
1892
|
const target = newest(store);
|
|
1730
1893
|
const { key } = selectorToken;
|
|
@@ -1782,7 +1945,7 @@ function disposeSelector2(selectorToken, store) {
|
|
|
1782
1945
|
);
|
|
1783
1946
|
for (const downstreamToken of downstreamTokens) {
|
|
1784
1947
|
if (downstreamToken) {
|
|
1785
|
-
|
|
1948
|
+
disposeSelector(downstreamToken, store);
|
|
1786
1949
|
}
|
|
1787
1950
|
}
|
|
1788
1951
|
target.selectorGraph.delete(key);
|
|
@@ -2420,7 +2583,7 @@ function createStandaloneAtom(options, store) {
|
|
|
2420
2583
|
}
|
|
2421
2584
|
|
|
2422
2585
|
// internal/src/atom/dispose-atom.ts
|
|
2423
|
-
function
|
|
2586
|
+
function disposeAtom(atomToken, store) {
|
|
2424
2587
|
var _a, _b;
|
|
2425
2588
|
const target = newest(store);
|
|
2426
2589
|
const { key } = atomToken;
|
|
@@ -2450,7 +2613,7 @@ function disposeAtom2(atomToken, store) {
|
|
|
2450
2613
|
for (const selectorKey of selectorKeys) {
|
|
2451
2614
|
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
2452
2615
|
if (token) {
|
|
2453
|
-
|
|
2616
|
+
disposeSelector(token, store);
|
|
2454
2617
|
}
|
|
2455
2618
|
}
|
|
2456
2619
|
}
|
|
@@ -2459,7 +2622,7 @@ function disposeAtom2(atomToken, store) {
|
|
|
2459
2622
|
target.timelineAtoms.delete(key);
|
|
2460
2623
|
if (atomToken.type === `mutable_atom`) {
|
|
2461
2624
|
const updateToken = getUpdateToken(atomToken);
|
|
2462
|
-
|
|
2625
|
+
disposeAtom(updateToken, store);
|
|
2463
2626
|
store.trackers.delete(key);
|
|
2464
2627
|
}
|
|
2465
2628
|
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
@@ -2794,7 +2957,7 @@ function createTimeline(options, store, data) {
|
|
|
2794
2957
|
tl.history.push(event);
|
|
2795
2958
|
tl.at = tl.history.length;
|
|
2796
2959
|
tl.subject.next(event);
|
|
2797
|
-
for (const token2 of molecule.tokens) {
|
|
2960
|
+
for (const token2 of molecule.tokens.values()) {
|
|
2798
2961
|
switch (token2.type) {
|
|
2799
2962
|
case `atom`:
|
|
2800
2963
|
case `mutable_atom`:
|
|
@@ -2948,6 +3111,7 @@ exports.FamilyTracker = FamilyTracker;
|
|
|
2948
3111
|
exports.Future = Future;
|
|
2949
3112
|
exports.IMPLICIT = IMPLICIT;
|
|
2950
3113
|
exports.LazyMap = LazyMap;
|
|
3114
|
+
exports.Molecule = Molecule;
|
|
2951
3115
|
exports.NotFoundError = NotFoundError;
|
|
2952
3116
|
exports.StatefulSubject = StatefulSubject;
|
|
2953
3117
|
exports.Store = Store;
|
|
@@ -2966,6 +3130,7 @@ exports.cacheValue = cacheValue;
|
|
|
2966
3130
|
exports.clearStore = clearStore;
|
|
2967
3131
|
exports.closeOperation = closeOperation;
|
|
2968
3132
|
exports.createAtomFamily = createAtomFamily;
|
|
3133
|
+
exports.createMoleculeFamily = createMoleculeFamily;
|
|
2969
3134
|
exports.createMutableAtom = createMutableAtom;
|
|
2970
3135
|
exports.createMutableAtomFamily = createMutableAtomFamily;
|
|
2971
3136
|
exports.createReadonlySelector = createReadonlySelector;
|
|
@@ -2979,9 +3144,10 @@ exports.createTimeline = createTimeline;
|
|
|
2979
3144
|
exports.createTransaction = createTransaction;
|
|
2980
3145
|
exports.createWritableSelector = createWritableSelector;
|
|
2981
3146
|
exports.deposit = deposit;
|
|
2982
|
-
exports.disposeAtom =
|
|
3147
|
+
exports.disposeAtom = disposeAtom;
|
|
2983
3148
|
exports.disposeFromStore = disposeFromStore;
|
|
2984
|
-
exports.
|
|
3149
|
+
exports.disposeMolecule = disposeMolecule;
|
|
3150
|
+
exports.disposeSelector = disposeSelector;
|
|
2985
3151
|
exports.evictCachedValue = evictCachedValue;
|
|
2986
3152
|
exports.findInStore = findInStore;
|
|
2987
3153
|
exports.getContinuityKey = getContinuityKey;
|
|
@@ -2993,6 +3159,7 @@ exports.getJsonFamily = getJsonFamily;
|
|
|
2993
3159
|
exports.getJsonToken = getJsonToken;
|
|
2994
3160
|
exports.getSelectorDependencyKeys = getSelectorDependencyKeys;
|
|
2995
3161
|
exports.getUpdateToken = getUpdateToken;
|
|
3162
|
+
exports.growMoleculeInStore = growMoleculeInStore;
|
|
2996
3163
|
exports.ingestAtomUpdate = ingestAtomUpdate;
|
|
2997
3164
|
exports.ingestCreationEvent = ingestCreationEvent;
|
|
2998
3165
|
exports.ingestDisposalEvent = ingestDisposalEvent;
|
|
@@ -3000,7 +3167,7 @@ exports.ingestMoleculeCreationEvent = ingestMoleculeCreationEvent;
|
|
|
3000
3167
|
exports.ingestMoleculeDisposalEvent = ingestMoleculeDisposalEvent;
|
|
3001
3168
|
exports.ingestSelectorUpdate = ingestSelectorUpdate;
|
|
3002
3169
|
exports.ingestTransactionUpdate = ingestTransactionUpdate;
|
|
3003
|
-
exports.
|
|
3170
|
+
exports.initFamilyMemberInStore = initFamilyMemberInStore;
|
|
3004
3171
|
exports.isAtomDefault = isAtomDefault;
|
|
3005
3172
|
exports.isAtomKey = isAtomKey;
|
|
3006
3173
|
exports.isChildStore = isChildStore;
|
|
@@ -3011,6 +3178,7 @@ exports.isRootStore = isRootStore;
|
|
|
3011
3178
|
exports.isSelectorKey = isSelectorKey;
|
|
3012
3179
|
exports.isStateKey = isStateKey;
|
|
3013
3180
|
exports.isTransceiver = isTransceiver;
|
|
3181
|
+
exports.makeMoleculeInStore = makeMoleculeInStore;
|
|
3014
3182
|
exports.markAtomAsDefault = markAtomAsDefault;
|
|
3015
3183
|
exports.markAtomAsNotDefault = markAtomAsNotDefault;
|
|
3016
3184
|
exports.markDone = markDone;
|