atom.io 0.23.5 → 0.24.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/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 +6 -6
- 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.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Junction } from '../../dist/chunk-FTONNX2R.js';
|
|
2
|
-
import { parseJson } from '../../dist/chunk-OAYGID5B.js';
|
|
3
2
|
import { __spreadValues, __spreadProps } from '../../dist/chunk-F2X4B4VY.js';
|
|
4
|
-
import { stringifyJson,
|
|
3
|
+
import { stringifyJson, parseJson, selectJson, selectJsonFamily } from 'atom.io/json';
|
|
5
4
|
import { AtomIOLogger } from 'atom.io';
|
|
6
|
-
import {
|
|
7
|
-
import * as Internal from 'atom.io/internal';
|
|
5
|
+
import { getJoin } from 'atom.io/data';
|
|
8
6
|
|
|
9
7
|
// internal/src/arbitrary.ts
|
|
10
8
|
function arbitrary(random = Math.random) {
|
|
@@ -63,26 +61,14 @@ function newest(scion) {
|
|
|
63
61
|
|
|
64
62
|
// internal/src/store/deposit.ts
|
|
65
63
|
function deposit(state) {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case `readonly_selector`:
|
|
73
|
-
case `transaction`: {
|
|
74
|
-
const token = {
|
|
75
|
-
key: state.key,
|
|
76
|
-
type: state.type
|
|
77
|
-
};
|
|
78
|
-
if (`family` in state) {
|
|
79
|
-
token.family = state.family;
|
|
80
|
-
}
|
|
81
|
-
return token;
|
|
82
|
-
}
|
|
83
|
-
case `molecule`:
|
|
84
|
-
return state.token;
|
|
64
|
+
const token = {
|
|
65
|
+
key: state.key,
|
|
66
|
+
type: state.type
|
|
67
|
+
};
|
|
68
|
+
if (`family` in state) {
|
|
69
|
+
token.family = state.family;
|
|
85
70
|
}
|
|
71
|
+
return token;
|
|
86
72
|
}
|
|
87
73
|
|
|
88
74
|
// internal/src/subject.ts
|
|
@@ -437,21 +423,27 @@ function createSelectorFamily(options, store) {
|
|
|
437
423
|
}
|
|
438
424
|
return createReadonlySelectorFamily(options, store);
|
|
439
425
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
break;
|
|
426
|
+
|
|
427
|
+
// internal/src/transaction/abort-transaction.ts
|
|
428
|
+
var abortTransaction = (store) => {
|
|
429
|
+
const target = newest(store);
|
|
430
|
+
if (!isChildStore(target)) {
|
|
431
|
+
store.logger.warn(
|
|
432
|
+
`\u{1F41E}`,
|
|
433
|
+
`transaction`,
|
|
434
|
+
`???`,
|
|
435
|
+
`abortTransaction called outside of a transaction. This is probably a bug in AtomIO.`
|
|
436
|
+
);
|
|
437
|
+
return;
|
|
453
438
|
}
|
|
454
|
-
|
|
439
|
+
store.logger.info(
|
|
440
|
+
`\u{1FA82}`,
|
|
441
|
+
`transaction`,
|
|
442
|
+
target.transactionMeta.update.key,
|
|
443
|
+
`Aborting transaction`
|
|
444
|
+
);
|
|
445
|
+
target.parent.child = null;
|
|
446
|
+
};
|
|
455
447
|
|
|
456
448
|
// internal/src/not-found-error.ts
|
|
457
449
|
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
@@ -479,27 +471,6 @@ var NotFoundError = class extends Error {
|
|
|
479
471
|
}
|
|
480
472
|
};
|
|
481
473
|
|
|
482
|
-
// internal/src/transaction/abort-transaction.ts
|
|
483
|
-
var abortTransaction = (store) => {
|
|
484
|
-
const target = newest(store);
|
|
485
|
-
if (!isChildStore(target)) {
|
|
486
|
-
store.logger.warn(
|
|
487
|
-
`\u{1F41E}`,
|
|
488
|
-
`transaction`,
|
|
489
|
-
`???`,
|
|
490
|
-
`abortTransaction called outside of a transaction. This is probably a bug in AtomIO.`
|
|
491
|
-
);
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
store.logger.info(
|
|
495
|
-
`\u{1FA82}`,
|
|
496
|
-
`transaction`,
|
|
497
|
-
target.transactionMeta.update.key,
|
|
498
|
-
`Aborting transaction`
|
|
499
|
-
);
|
|
500
|
-
target.parent.child = null;
|
|
501
|
-
};
|
|
502
|
-
|
|
503
474
|
// internal/src/transaction/act-upon-store.ts
|
|
504
475
|
function actUponStore(token, id, store) {
|
|
505
476
|
return (...parameters) => {
|
|
@@ -770,6 +741,155 @@ function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
|
770
741
|
}
|
|
771
742
|
setIntoStore(token, value, store);
|
|
772
743
|
}
|
|
744
|
+
|
|
745
|
+
// internal/src/molecule/create-molecule-family.ts
|
|
746
|
+
function createMoleculeFamily(options, store) {
|
|
747
|
+
var _a;
|
|
748
|
+
const subject = new Subject();
|
|
749
|
+
const token = {
|
|
750
|
+
type: `molecule_family`,
|
|
751
|
+
key: options.key,
|
|
752
|
+
dependsOn: (_a = options.dependsOn) != null ? _a : `all`
|
|
753
|
+
};
|
|
754
|
+
const family = __spreadProps(__spreadValues({}, token), {
|
|
755
|
+
subject,
|
|
756
|
+
new: options.new
|
|
757
|
+
});
|
|
758
|
+
store.moleculeFamilies.set(options.key, family);
|
|
759
|
+
return token;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// internal/src/molecule/grow-molecule-in-store.ts
|
|
763
|
+
function growMoleculeInStore(molecule, family, store) {
|
|
764
|
+
const stateToken = initFamilyMemberInStore(family, molecule.key, store);
|
|
765
|
+
molecule.tokens.set(stateToken.key, stateToken);
|
|
766
|
+
const isTransaction = isChildStore(store) && store.transactionMeta.phase === `building`;
|
|
767
|
+
if (isTransaction) {
|
|
768
|
+
store.transactionMeta.update.updates.push({
|
|
769
|
+
type: `state_creation`,
|
|
770
|
+
token: stateToken
|
|
771
|
+
});
|
|
772
|
+
} else {
|
|
773
|
+
molecule.subject.next({ type: `state_creation`, token: stateToken });
|
|
774
|
+
}
|
|
775
|
+
return stateToken;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// internal/src/get-environment-data.ts
|
|
779
|
+
function getEnvironmentData(store) {
|
|
780
|
+
return {
|
|
781
|
+
store
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// internal/src/get-state/get-from-store.ts
|
|
786
|
+
function getFromStore(token, store) {
|
|
787
|
+
const state = withdraw(token, store);
|
|
788
|
+
return readOrComputeValue(state, store);
|
|
789
|
+
}
|
|
790
|
+
var Molecule = class {
|
|
791
|
+
constructor(ctx, key, family) {
|
|
792
|
+
this.key = key;
|
|
793
|
+
this.type = `molecule`;
|
|
794
|
+
this.subject = new Subject();
|
|
795
|
+
this.tokens = /* @__PURE__ */ new Map();
|
|
796
|
+
this.above = /* @__PURE__ */ new Map();
|
|
797
|
+
this.below = /* @__PURE__ */ new Map();
|
|
798
|
+
this.joins = /* @__PURE__ */ new Map();
|
|
799
|
+
this.stringKey = stringifyJson(key);
|
|
800
|
+
if (family) {
|
|
801
|
+
this.family = family;
|
|
802
|
+
}
|
|
803
|
+
if (ctx) {
|
|
804
|
+
if (Array.isArray(ctx)) {
|
|
805
|
+
for (const molecule of ctx) {
|
|
806
|
+
this.above.set(molecule.stringKey, molecule);
|
|
807
|
+
}
|
|
808
|
+
} else {
|
|
809
|
+
this.above.set(ctx.stringKey, ctx);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
// internal/src/molecule/make-molecule-in-store.ts
|
|
816
|
+
function makeMoleculeInStore(store, context, familyToken, key, ...params) {
|
|
817
|
+
const target = newest(store);
|
|
818
|
+
const token = {
|
|
819
|
+
type: `molecule`,
|
|
820
|
+
key,
|
|
821
|
+
family: familyToken
|
|
822
|
+
};
|
|
823
|
+
const contextArray = Array.isArray(context) ? context : [context];
|
|
824
|
+
const owners = contextArray.map((ctx) => {
|
|
825
|
+
if (ctx instanceof Molecule) {
|
|
826
|
+
return ctx;
|
|
827
|
+
}
|
|
828
|
+
const stringKey = stringifyJson(ctx.key);
|
|
829
|
+
const molecule2 = store.molecules.get(stringKey);
|
|
830
|
+
if (!molecule2) {
|
|
831
|
+
throw new Error(
|
|
832
|
+
`Molecule ${stringKey} not found in store "${store.config.name}"`
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
return molecule2;
|
|
836
|
+
});
|
|
837
|
+
const family = withdraw(familyToken, store);
|
|
838
|
+
const molecule = new Molecule(owners, key, family);
|
|
839
|
+
target.molecules.set(stringifyJson(key), molecule);
|
|
840
|
+
for (const owner of owners) {
|
|
841
|
+
owner.below.set(molecule.stringKey, molecule);
|
|
842
|
+
}
|
|
843
|
+
const transactors = {
|
|
844
|
+
get: (t) => getFromStore(t, newest(store)),
|
|
845
|
+
set: (t, newValue) => {
|
|
846
|
+
setIntoStore(t, newValue, newest(store));
|
|
847
|
+
},
|
|
848
|
+
seek: (t, k) => seekInStore(t, k, newest(store)),
|
|
849
|
+
json: (t) => getJsonToken(t, newest(store)),
|
|
850
|
+
run: (t, i = arbitrary()) => actUponStore(t, i, newest(store)),
|
|
851
|
+
make: (ctx, f, k, ...args) => makeMoleculeInStore(newest(store), ctx, f, k, ...args),
|
|
852
|
+
dispose: (t) => {
|
|
853
|
+
disposeFromStore(t, newest(store));
|
|
854
|
+
},
|
|
855
|
+
env: () => getEnvironmentData(newest(store)),
|
|
856
|
+
bond: (f) => growMoleculeInStore(
|
|
857
|
+
molecule,
|
|
858
|
+
withdraw(f, store),
|
|
859
|
+
newest(store)
|
|
860
|
+
),
|
|
861
|
+
join: (joinToken) => {
|
|
862
|
+
const join = getJoin(joinToken, store);
|
|
863
|
+
join.molecules.set(stringifyJson(key), molecule);
|
|
864
|
+
molecule.joins.set(joinToken.key, join);
|
|
865
|
+
},
|
|
866
|
+
spawn: (f, k, ...p) => makeMoleculeInStore(
|
|
867
|
+
newest(store),
|
|
868
|
+
[molecule],
|
|
869
|
+
withdraw(f, store),
|
|
870
|
+
k,
|
|
871
|
+
...p
|
|
872
|
+
)
|
|
873
|
+
};
|
|
874
|
+
const Constructor = family.new;
|
|
875
|
+
molecule.instance = new Constructor(transactors, token.key, ...params);
|
|
876
|
+
const update = {
|
|
877
|
+
type: `molecule_creation`,
|
|
878
|
+
token,
|
|
879
|
+
family,
|
|
880
|
+
context: contextArray,
|
|
881
|
+
params
|
|
882
|
+
};
|
|
883
|
+
const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
|
|
884
|
+
if (isTransaction) {
|
|
885
|
+
target.transactionMeta.update.updates.push(update);
|
|
886
|
+
} else {
|
|
887
|
+
family.subject.next(update);
|
|
888
|
+
}
|
|
889
|
+
return token;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// internal/src/ingest-updates/ingest-creation-disposal.ts
|
|
773
893
|
function ingestCreationEvent(update, applying, store) {
|
|
774
894
|
switch (applying) {
|
|
775
895
|
case `newValue`: {
|
|
@@ -801,13 +921,13 @@ function createInStore(token, store) {
|
|
|
801
921
|
if (family) {
|
|
802
922
|
const molecule = store.molecules.get(token.family.subKey);
|
|
803
923
|
if (molecule) {
|
|
804
|
-
molecule
|
|
924
|
+
growMoleculeInStore(molecule, family, store);
|
|
805
925
|
return;
|
|
806
926
|
}
|
|
807
927
|
if (store.config.lifespan === `immortal`) {
|
|
808
928
|
throw new Error(`No molecule found for key "${token.family.subKey}"`);
|
|
809
929
|
}
|
|
810
|
-
|
|
930
|
+
initFamilyMemberInStore(family, parseJson(token.family.subKey), store);
|
|
811
931
|
}
|
|
812
932
|
}
|
|
813
933
|
}
|
|
@@ -823,14 +943,14 @@ function ingestMoleculeCreationEvent(update, applying, store) {
|
|
|
823
943
|
);
|
|
824
944
|
break;
|
|
825
945
|
case `oldValue`:
|
|
826
|
-
|
|
946
|
+
disposeFromStore(update.token, store);
|
|
827
947
|
break;
|
|
828
948
|
}
|
|
829
949
|
}
|
|
830
950
|
function ingestMoleculeDisposalEvent(update, applying, store) {
|
|
831
951
|
switch (applying) {
|
|
832
952
|
case `newValue`:
|
|
833
|
-
|
|
953
|
+
disposeFromStore(update.token, store);
|
|
834
954
|
break;
|
|
835
955
|
case `oldValue`:
|
|
836
956
|
makeMoleculeInStore(
|
|
@@ -968,21 +1088,6 @@ function assignTransactionToContinuity(continuityKey, transactionKey, store) {
|
|
|
968
1088
|
}
|
|
969
1089
|
}
|
|
970
1090
|
|
|
971
|
-
// internal/src/get-environment-data.ts
|
|
972
|
-
function getEnvironmentData(store) {
|
|
973
|
-
return {
|
|
974
|
-
window: typeof window === `undefined` ? void 0 : window,
|
|
975
|
-
global: typeof global === `undefined` ? void 0 : global,
|
|
976
|
-
store
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
// internal/src/get-state/get-from-store.ts
|
|
981
|
-
function getFromStore(token, store) {
|
|
982
|
-
const state = withdraw(token, store);
|
|
983
|
-
return readOrComputeValue(state, store);
|
|
984
|
-
}
|
|
985
|
-
|
|
986
1091
|
// internal/src/lazy-map.ts
|
|
987
1092
|
var LazyMap = class extends Map {
|
|
988
1093
|
constructor(source) {
|
|
@@ -1138,8 +1243,88 @@ function getEpochNumberOfAction(transactionKey, store) {
|
|
|
1138
1243
|
// internal/src/transaction/index.ts
|
|
1139
1244
|
var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
1140
1245
|
|
|
1246
|
+
// internal/src/molecule/dispose-molecule.ts
|
|
1247
|
+
function disposeMolecule(token, store) {
|
|
1248
|
+
var _a;
|
|
1249
|
+
let molecule;
|
|
1250
|
+
try {
|
|
1251
|
+
molecule = withdraw(token, store);
|
|
1252
|
+
} catch (thrown) {
|
|
1253
|
+
if (thrown instanceof Error) {
|
|
1254
|
+
store.logger.error(
|
|
1255
|
+
`\u{1F41E}`,
|
|
1256
|
+
`molecule`,
|
|
1257
|
+
JSON.stringify(token.key),
|
|
1258
|
+
`Failed to dispose molecule, because it was not found in the store.`,
|
|
1259
|
+
thrown.message
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
const { family } = token;
|
|
1265
|
+
if (family) {
|
|
1266
|
+
const Formula = withdraw(family, store);
|
|
1267
|
+
const disposalEvent = {
|
|
1268
|
+
type: `molecule_disposal`,
|
|
1269
|
+
token,
|
|
1270
|
+
family,
|
|
1271
|
+
context: [...molecule.above.values()].map((m) => deposit(m)),
|
|
1272
|
+
familyKeys: [...molecule.tokens.values()].map((t) => {
|
|
1273
|
+
var _a2;
|
|
1274
|
+
return (_a2 = t.family) == null ? void 0 : _a2.key;
|
|
1275
|
+
}).filter((k) => typeof k === `string`)
|
|
1276
|
+
};
|
|
1277
|
+
if (token.family) {
|
|
1278
|
+
disposalEvent.family = token.family;
|
|
1279
|
+
}
|
|
1280
|
+
const isTransaction = isChildStore(store) && store.transactionMeta.phase === `building`;
|
|
1281
|
+
if (isTransaction) {
|
|
1282
|
+
store.transactionMeta.update.updates.push(disposalEvent);
|
|
1283
|
+
} else {
|
|
1284
|
+
Formula.subject.next(disposalEvent);
|
|
1285
|
+
}
|
|
1286
|
+
store.molecules.delete(molecule.stringKey);
|
|
1287
|
+
}
|
|
1288
|
+
for (const state of molecule.tokens.values()) {
|
|
1289
|
+
disposeFromStore(state, store);
|
|
1290
|
+
}
|
|
1291
|
+
for (const child of molecule.below.values()) {
|
|
1292
|
+
if (((_a = child.family) == null ? void 0 : _a.dependsOn) === `all`) {
|
|
1293
|
+
disposeMolecule(child, store);
|
|
1294
|
+
} else {
|
|
1295
|
+
child.above.delete(molecule.stringKey);
|
|
1296
|
+
if (child.above.size === 0) {
|
|
1297
|
+
disposeMolecule(child, store);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
for (const join of molecule.joins.values()) {
|
|
1302
|
+
join.molecules.delete(molecule.stringKey);
|
|
1303
|
+
}
|
|
1304
|
+
for (const parent of molecule.above.values()) {
|
|
1305
|
+
parent.below.delete(molecule.stringKey);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// internal/src/families/dispose-from-store.ts
|
|
1310
|
+
function disposeFromStore(token, store = IMPLICIT.STORE) {
|
|
1311
|
+
switch (token.type) {
|
|
1312
|
+
case `atom`:
|
|
1313
|
+
case `mutable_atom`:
|
|
1314
|
+
disposeAtom(token, store);
|
|
1315
|
+
break;
|
|
1316
|
+
case `selector`:
|
|
1317
|
+
case `readonly_selector`:
|
|
1318
|
+
disposeSelector(token, store);
|
|
1319
|
+
break;
|
|
1320
|
+
case `molecule`:
|
|
1321
|
+
disposeMolecule(token, store);
|
|
1322
|
+
break;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1141
1326
|
// internal/src/families/init-family-member.ts
|
|
1142
|
-
function
|
|
1327
|
+
function initFamilyMemberInStore(token, key, store) {
|
|
1143
1328
|
const familyKey = token.key;
|
|
1144
1329
|
const family = store.families.get(familyKey);
|
|
1145
1330
|
if (family === void 0) {
|
|
@@ -1207,7 +1392,7 @@ function findInStore(token, key, store) {
|
|
|
1207
1392
|
if (state) {
|
|
1208
1393
|
return state;
|
|
1209
1394
|
}
|
|
1210
|
-
state =
|
|
1395
|
+
state = initFamilyMemberInStore(token, key, store);
|
|
1211
1396
|
return state;
|
|
1212
1397
|
}
|
|
1213
1398
|
|
|
@@ -1424,7 +1609,7 @@ function createStandaloneSelector(options, store) {
|
|
|
1424
1609
|
}
|
|
1425
1610
|
|
|
1426
1611
|
// internal/src/selector/dispose-selector.ts
|
|
1427
|
-
function
|
|
1612
|
+
function disposeSelector(selectorToken, store) {
|
|
1428
1613
|
var _a;
|
|
1429
1614
|
const target = newest(store);
|
|
1430
1615
|
const { key } = selectorToken;
|
|
@@ -1482,7 +1667,7 @@ function disposeSelector2(selectorToken, store) {
|
|
|
1482
1667
|
);
|
|
1483
1668
|
for (const downstreamToken of downstreamTokens) {
|
|
1484
1669
|
if (downstreamToken) {
|
|
1485
|
-
|
|
1670
|
+
disposeSelector(downstreamToken, store);
|
|
1486
1671
|
}
|
|
1487
1672
|
}
|
|
1488
1673
|
target.selectorGraph.delete(key);
|
|
@@ -1846,7 +2031,7 @@ var FamilyTracker = class {
|
|
|
1846
2031
|
`store=${store.config.name}::tracker-atom-family`,
|
|
1847
2032
|
(event) => {
|
|
1848
2033
|
if (event.token.family) {
|
|
1849
|
-
const key = parseJson
|
|
2034
|
+
const key = parseJson(event.token.family.subKey);
|
|
1850
2035
|
seekInStore(this.latestUpdateAtoms, key, store);
|
|
1851
2036
|
new Tracker(event.token, store);
|
|
1852
2037
|
}
|
|
@@ -1856,7 +2041,7 @@ var FamilyTracker = class {
|
|
|
1856
2041
|
`store=${store.config.name}::tracker-atom-family`,
|
|
1857
2042
|
(event) => {
|
|
1858
2043
|
if (event.token.family) {
|
|
1859
|
-
const key = parseJson
|
|
2044
|
+
const key = parseJson(event.token.family.subKey);
|
|
1860
2045
|
const mutableAtomToken = seekInStore(this.mutableAtoms, key, store);
|
|
1861
2046
|
if (mutableAtomToken) {
|
|
1862
2047
|
new Tracker(mutableAtomToken, store);
|
|
@@ -2120,7 +2305,7 @@ function createStandaloneAtom(options, store) {
|
|
|
2120
2305
|
}
|
|
2121
2306
|
|
|
2122
2307
|
// internal/src/atom/dispose-atom.ts
|
|
2123
|
-
function
|
|
2308
|
+
function disposeAtom(atomToken, store) {
|
|
2124
2309
|
var _a, _b;
|
|
2125
2310
|
const target = newest(store);
|
|
2126
2311
|
const { key } = atomToken;
|
|
@@ -2150,7 +2335,7 @@ function disposeAtom2(atomToken, store) {
|
|
|
2150
2335
|
for (const selectorKey of selectorKeys) {
|
|
2151
2336
|
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
2152
2337
|
if (token) {
|
|
2153
|
-
|
|
2338
|
+
disposeSelector(token, store);
|
|
2154
2339
|
}
|
|
2155
2340
|
}
|
|
2156
2341
|
}
|
|
@@ -2159,7 +2344,7 @@ function disposeAtom2(atomToken, store) {
|
|
|
2159
2344
|
target.timelineAtoms.delete(key);
|
|
2160
2345
|
if (atomToken.type === `mutable_atom`) {
|
|
2161
2346
|
const updateToken = getUpdateToken(atomToken);
|
|
2162
|
-
|
|
2347
|
+
disposeAtom(updateToken, store);
|
|
2163
2348
|
store.trackers.delete(key);
|
|
2164
2349
|
}
|
|
2165
2350
|
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
@@ -2494,7 +2679,7 @@ function createTimeline(options, store, data) {
|
|
|
2494
2679
|
tl.history.push(event);
|
|
2495
2680
|
tl.at = tl.history.length;
|
|
2496
2681
|
tl.subject.next(event);
|
|
2497
|
-
for (const token2 of molecule.tokens) {
|
|
2682
|
+
for (const token2 of molecule.tokens.values()) {
|
|
2498
2683
|
switch (token2.type) {
|
|
2499
2684
|
case `atom`:
|
|
2500
2685
|
case `mutable_atom`:
|
|
@@ -2644,4 +2829,4 @@ var timeTravel = (action, token, store) => {
|
|
|
2644
2829
|
);
|
|
2645
2830
|
};
|
|
2646
2831
|
|
|
2647
|
-
export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit,
|
|
2832
|
+
export { FamilyTracker, Future, IMPLICIT, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import type { ReadableToken } from "atom.io"
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import type { MoleculeToken, ReadableToken } from "atom.io"
|
|
2
|
+
|
|
3
|
+
import { disposeAtom } from "../atom"
|
|
4
|
+
import { disposeMolecule } from "../molecule/dispose-molecule"
|
|
5
|
+
import { disposeSelector } from "../selector"
|
|
6
|
+
import type { Store } from "../store"
|
|
7
|
+
import { IMPLICIT } from "../store"
|
|
4
8
|
|
|
5
9
|
export function disposeFromStore(
|
|
6
|
-
token: MoleculeToken<any
|
|
7
|
-
store:
|
|
10
|
+
token: MoleculeToken<any> | ReadableToken<any>,
|
|
11
|
+
store: Store = IMPLICIT.STORE,
|
|
8
12
|
): void {
|
|
9
13
|
switch (token.type) {
|
|
10
14
|
case `atom`:
|
|
11
15
|
case `mutable_atom`:
|
|
12
|
-
|
|
16
|
+
disposeAtom(token, store)
|
|
13
17
|
break
|
|
14
18
|
case `selector`:
|
|
15
19
|
case `readonly_selector`:
|
|
16
|
-
|
|
20
|
+
disposeSelector(token, store)
|
|
17
21
|
break
|
|
18
22
|
case `molecule`:
|
|
19
23
|
disposeMolecule(token, store)
|
|
@@ -20,7 +20,7 @@ import type { Json } from "atom.io/json"
|
|
|
20
20
|
|
|
21
21
|
import type { Transceiver } from "../mutable"
|
|
22
22
|
import type { Store } from "../store"
|
|
23
|
-
import {
|
|
23
|
+
import { initFamilyMemberInStore } from "./init-family-member"
|
|
24
24
|
import { seekInStore } from "./seek-in-store"
|
|
25
25
|
|
|
26
26
|
export function findInStore<
|
|
@@ -90,6 +90,6 @@ export function findInStore(
|
|
|
90
90
|
if (state) {
|
|
91
91
|
return state
|
|
92
92
|
}
|
|
93
|
-
state =
|
|
93
|
+
state = initFamilyMemberInStore(token, key, store)
|
|
94
94
|
return state
|
|
95
95
|
}
|
|
@@ -24,7 +24,7 @@ import { NotFoundError } from "../not-found-error"
|
|
|
24
24
|
import type { Store } from "../store"
|
|
25
25
|
import { isChildStore } from "../transaction"
|
|
26
26
|
|
|
27
|
-
export function
|
|
27
|
+
export function initFamilyMemberInStore<
|
|
28
28
|
T extends Transceiver<any>,
|
|
29
29
|
J extends Json.Serializable,
|
|
30
30
|
K extends Json.Serializable,
|
|
@@ -35,49 +35,61 @@ export function initFamilyMember<
|
|
|
35
35
|
store: Store,
|
|
36
36
|
): MutableAtomToken<T, J>
|
|
37
37
|
|
|
38
|
-
export function
|
|
38
|
+
export function initFamilyMemberInStore<
|
|
39
|
+
T,
|
|
40
|
+
K extends Json.Serializable,
|
|
41
|
+
Key extends K,
|
|
42
|
+
>(
|
|
39
43
|
token: RegularAtomFamilyToken<T, K>,
|
|
40
44
|
key: Key,
|
|
41
45
|
store: Store,
|
|
42
46
|
): RegularAtomToken<T>
|
|
43
47
|
|
|
44
|
-
export function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
): AtomToken<T>
|
|
48
|
+
export function initFamilyMemberInStore<
|
|
49
|
+
T,
|
|
50
|
+
K extends Json.Serializable,
|
|
51
|
+
Key extends K,
|
|
52
|
+
>(token: AtomFamilyToken<T, K>, key: Key, store: Store): AtomToken<T>
|
|
49
53
|
|
|
50
|
-
export function
|
|
54
|
+
export function initFamilyMemberInStore<
|
|
55
|
+
T,
|
|
56
|
+
K extends Json.Serializable,
|
|
57
|
+
Key extends K,
|
|
58
|
+
>(
|
|
51
59
|
token: WritableSelectorFamilyToken<T, K>,
|
|
52
60
|
key: Key,
|
|
53
61
|
store: Store,
|
|
54
62
|
): WritableSelectorToken<T>
|
|
55
63
|
|
|
56
|
-
export function
|
|
64
|
+
export function initFamilyMemberInStore<
|
|
65
|
+
T,
|
|
66
|
+
K extends Json.Serializable,
|
|
67
|
+
Key extends K,
|
|
68
|
+
>(
|
|
57
69
|
token: ReadonlySelectorFamilyToken<T, K>,
|
|
58
70
|
key: Key,
|
|
59
71
|
store: Store,
|
|
60
72
|
): ReadonlySelectorToken<T>
|
|
61
73
|
|
|
62
|
-
export function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
): SelectorToken<T>
|
|
74
|
+
export function initFamilyMemberInStore<
|
|
75
|
+
T,
|
|
76
|
+
K extends Json.Serializable,
|
|
77
|
+
Key extends K,
|
|
78
|
+
>(token: SelectorFamilyToken<T, K>, key: Key, store: Store): SelectorToken<T>
|
|
67
79
|
|
|
68
|
-
export function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
): WritableToken<T>
|
|
80
|
+
export function initFamilyMemberInStore<
|
|
81
|
+
T,
|
|
82
|
+
K extends Json.Serializable,
|
|
83
|
+
Key extends K,
|
|
84
|
+
>(token: WritableFamilyToken<T, K>, key: Key, store: Store): WritableToken<T>
|
|
73
85
|
|
|
74
|
-
export function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
): ReadableToken<T>
|
|
86
|
+
export function initFamilyMemberInStore<
|
|
87
|
+
T,
|
|
88
|
+
K extends Json.Serializable,
|
|
89
|
+
Key extends K,
|
|
90
|
+
>(token: ReadableFamilyToken<T, K>, key: Key, store: Store): ReadableToken<T>
|
|
79
91
|
|
|
80
|
-
export function
|
|
92
|
+
export function initFamilyMemberInStore(
|
|
81
93
|
token: ReadableFamilyToken<any, any>,
|
|
82
94
|
key: Json.Serializable,
|
|
83
95
|
store: Store,
|