atom.io 0.40.7 → 0.40.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/index.js +1 -2
- package/dist/data/index.js.map +1 -1
- package/dist/employ-socket-D6wgByWh.js.map +1 -1
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/{has-role-hv4-hJMw.js → has-role-CMlaUlaf.js} +30 -46
- package/dist/has-role-CMlaUlaf.js.map +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +103 -174
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js +13 -32
- package/dist/introspection/index.js.map +1 -1
- package/dist/is-fn-DY1wZ-md.js.map +1 -1
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +1 -2
- package/dist/main/index.js.map +1 -1
- package/dist/mutex-store-CSvxY9i3.js.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.d.ts.map +1 -1
- package/dist/react-devtools/index.js +2 -4
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +2 -3
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +1 -4
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +5 -20
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +2 -5
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +4 -15
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +36 -44
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +125 -171
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.d.ts +4 -2
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/realtime-testing/index.js +13 -7
- package/dist/realtime-testing/index.js.map +1 -1
- package/dist/{shared-room-store-COGGKqes.js → shared-room-store-BfW3nWif.js} +2 -3
- package/dist/{shared-room-store-COGGKqes.js.map → shared-room-store-BfW3nWif.js.map} +1 -1
- package/dist/shared-room-store-D2o4ZLjC.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.js +4 -8
- package/dist/transceivers/set-rtx/index.js.map +1 -1
- package/dist/web/index.js.map +1 -1
- package/package.json +11 -11
- package/src/internal/mutable/tracker.ts +66 -51
- package/src/internal/subscribe/subscribe-to-state.ts +9 -0
- package/src/realtime-client/index.ts +0 -1
- package/src/realtime-react/index.ts +0 -1
- package/src/realtime-server/continuity/continuity-store.ts +1 -26
- package/src/realtime-server/continuity/provide-continuity.ts +50 -0
- package/src/realtime-server/continuity/{subscribe-to-continuity-actions.ts → provide-outcomes.ts} +14 -12
- package/src/realtime-server/continuity/{subscribe-to-continuity-perpectives.ts → provide-perspectives.ts} +10 -8
- package/src/realtime-server/continuity/{prepare-to-send-initial-payload.ts → provide-startup-payloads.ts} +6 -4
- package/src/realtime-server/continuity/receive-action-requests.ts +68 -0
- package/src/realtime-server/continuity/{prepare-to-track-client-acknowledgement.ts → track-acknowledgements.ts} +15 -8
- package/src/realtime-server/index.ts +1 -2
- package/src/realtime-server/ipc-sockets/custom-socket.ts +3 -3
- package/src/realtime-server/ipc-sockets/parent-socket.ts +19 -13
- package/src/realtime-server/server-config.ts +0 -1
- package/src/realtime-testing/setup-realtime-test.tsx +20 -14
- package/dist/has-role-hv4-hJMw.js.map +0 -1
- package/src/realtime-client/server-action.ts +0 -23
- package/src/realtime-react/use-server-action.ts +0 -19
- package/src/realtime-server/continuity/prepare-to-serve-transaction-request.ts +0 -59
- package/src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts +0 -145
- package/src/realtime-server/realtime-action-receiver.ts +0 -40
package/dist/internal/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DO_NOT_CREATE, Future, INTERNAL_ROLES, JOIN_OP, NotFoundError, RESET_STATE, StatefulSubject, Subject, Tracker, become, closeOperation, createRegularAtom, deposit, eldest, evictCachedValue, evictDownstreamFromAtom, evictDownstreamFromSelector, getFallback, getFamilyOfToken, getFromStore, getSelectorDependencyKeys, hasRole, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, markDone, mintInStore, newest, openOperation, operateOnStore, readFromCache, readOrComputeValue, recallState, reduceReference, resetAtomOrSelector, resetInStore, seekInStore, setAtomOrSelector, setIntoStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, traceRootSelectorAtoms, withdraw, writeToCache } from "../has-role-
|
|
1
|
+
import { DO_NOT_CREATE, Future, INTERNAL_ROLES, JOIN_OP, NotFoundError, RESET_STATE, StatefulSubject, Subject, Tracker, become, closeOperation, createRegularAtom, deposit, eldest, evictCachedValue, evictDownstreamFromAtom, evictDownstreamFromSelector, getFallback, getFamilyOfToken, getFromStore, getSelectorDependencyKeys, hasRole, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, markDone, mintInStore, newest, openOperation, operateOnStore, readFromCache, readOrComputeValue, recallState, reduceReference, resetAtomOrSelector, resetInStore, seekInStore, setAtomOrSelector, setIntoStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, traceRootSelectorAtoms, withdraw, writeToCache } from "../has-role-CMlaUlaf.js";
|
|
2
2
|
import { isFn } from "../is-fn-DY1wZ-md.js";
|
|
3
3
|
import { Anarchy, AtomIOLogger, PRETTY_TOKEN_TYPES } from "atom.io";
|
|
4
4
|
import { parseJson, stringifyJson } from "atom.io/json";
|
|
@@ -48,13 +48,8 @@ var MapOverlay = class extends Map {
|
|
|
48
48
|
this.source = source;
|
|
49
49
|
}
|
|
50
50
|
get(key) {
|
|
51
|
-
|
|
52
|
-
if (has) return
|
|
53
|
-
if (!this.deleted.has(key) && this.source.has(key)) {
|
|
54
|
-
const value = this.source.get(key);
|
|
55
|
-
return value;
|
|
56
|
-
}
|
|
57
|
-
return void 0;
|
|
51
|
+
if (super.has(key)) return super.get(key);
|
|
52
|
+
if (!this.deleted.has(key) && this.source.has(key)) return this.source.get(key);
|
|
58
53
|
}
|
|
59
54
|
set(key, value) {
|
|
60
55
|
this.deleted.delete(key);
|
|
@@ -156,15 +151,13 @@ var RelationsOverlay = class extends Map {
|
|
|
156
151
|
this.source = source;
|
|
157
152
|
}
|
|
158
153
|
get(key) {
|
|
159
|
-
|
|
160
|
-
if (has) return super.get(key);
|
|
154
|
+
if (super.has(key)) return super.get(key);
|
|
161
155
|
if (!this.deleted.has(key) && this.source.has(key)) {
|
|
162
156
|
const value = this.source.get(key);
|
|
163
157
|
const valueOverlay = new SetOverlay(value);
|
|
164
158
|
super.set(key, valueOverlay);
|
|
165
159
|
return valueOverlay;
|
|
166
160
|
}
|
|
167
|
-
return void 0;
|
|
168
161
|
}
|
|
169
162
|
set(key, value) {
|
|
170
163
|
this.deleted.delete(key);
|
|
@@ -438,10 +431,7 @@ var Junction = class Junction {
|
|
|
438
431
|
return [];
|
|
439
432
|
}
|
|
440
433
|
has(a, b) {
|
|
441
|
-
if (b)
|
|
442
|
-
const setA = this.getRelatedKeys(a);
|
|
443
|
-
return setA?.has(b) ?? false;
|
|
444
|
-
}
|
|
434
|
+
if (b) return this.getRelatedKeys(a)?.has(b) ?? false;
|
|
445
435
|
return this.relations.has(a);
|
|
446
436
|
}
|
|
447
437
|
overlay() {
|
|
@@ -487,8 +477,7 @@ const abortTransaction = (target) => {
|
|
|
487
477
|
//#region src/internal/transaction/act-upon-store.ts
|
|
488
478
|
function actUponStore(store, token, id) {
|
|
489
479
|
return (...parameters) => {
|
|
490
|
-
|
|
491
|
-
return tx.run(parameters, id);
|
|
480
|
+
return withdraw(store, token).run(parameters, id);
|
|
492
481
|
};
|
|
493
482
|
}
|
|
494
483
|
|
|
@@ -496,8 +485,7 @@ function actUponStore(store, token, id) {
|
|
|
496
485
|
//#region src/internal/events/ingest-atom-update.ts
|
|
497
486
|
function ingestAtomUpdateEvent(store, event, applying) {
|
|
498
487
|
const { token, update: { newValue, oldValue } } = event;
|
|
499
|
-
|
|
500
|
-
setIntoStore(store, token, value);
|
|
488
|
+
setIntoStore(store, token, applying === `newValue` ? newValue : oldValue);
|
|
501
489
|
}
|
|
502
490
|
|
|
503
491
|
//#endregion
|
|
@@ -526,14 +514,12 @@ function allocateIntoStore(store, provenance, key, dependsOn = `any`) {
|
|
|
526
514
|
const target = newest(store);
|
|
527
515
|
if (Array.isArray(origin)) for (const formerClaim of origin) {
|
|
528
516
|
const claimString = stringifyJson(formerClaim);
|
|
529
|
-
|
|
530
|
-
if (claim) store.moleculeGraph.set(claimString, stringKey, { source: claimString });
|
|
517
|
+
if (target.molecules.get(claimString)) store.moleculeGraph.set(claimString, stringKey, { source: claimString });
|
|
531
518
|
else invalidKeys.push(claimString);
|
|
532
519
|
}
|
|
533
520
|
else {
|
|
534
521
|
const claimString = stringifyJson(origin);
|
|
535
|
-
|
|
536
|
-
if (claim) store.moleculeGraph.set(claimString, stringKey, { source: claimString });
|
|
522
|
+
if (target.molecules.get(claimString)) store.moleculeGraph.set(claimString, stringKey, { source: claimString });
|
|
537
523
|
else invalidKeys.push(claimString);
|
|
538
524
|
}
|
|
539
525
|
if (invalidKeys.length === 0) target.molecules.set(stringKey, {
|
|
@@ -547,8 +533,7 @@ function allocateIntoStore(store, provenance, key, dependsOn = `any`) {
|
|
|
547
533
|
provenance: origin,
|
|
548
534
|
timestamp: Date.now()
|
|
549
535
|
};
|
|
550
|
-
|
|
551
|
-
if (isTransaction) target.transactionMeta.update.subEvents.push(creationEvent);
|
|
536
|
+
if (isChildStore(target) && target.transactionMeta.phase === `building`) target.transactionMeta.update.subEvents.push(creationEvent);
|
|
552
537
|
else target.on.moleculeCreation.next(creationEvent);
|
|
553
538
|
for (const claim of invalidKeys) {
|
|
554
539
|
const disposal = store.disposalTraces.buffer.find((item) => item?.key === claim);
|
|
@@ -558,8 +543,7 @@ function allocateIntoStore(store, provenance, key, dependsOn = `any`) {
|
|
|
558
543
|
}
|
|
559
544
|
function fuseWithinStore(store, type, sideA, sideB) {
|
|
560
545
|
const compoundKey = `T$--${type}==${sideA}++${sideB}`;
|
|
561
|
-
|
|
562
|
-
allocateIntoStore(store, above, compoundKey, `all`);
|
|
546
|
+
allocateIntoStore(store, [sideA, sideB], compoundKey, `all`);
|
|
563
547
|
return compoundKey;
|
|
564
548
|
}
|
|
565
549
|
function createDeallocateTX(store) {
|
|
@@ -657,8 +641,7 @@ function claimWithinStore(store, newProvenance, claim, exclusive) {
|
|
|
657
641
|
to: [newProvenanceMolecule.key],
|
|
658
642
|
timestamp: Date.now()
|
|
659
643
|
};
|
|
660
|
-
|
|
661
|
-
if (isTransaction) target.transactionMeta.update.subEvents.push(transferEvent);
|
|
644
|
+
if (isChildStore(target) && target.transactionMeta.phase === `building`) target.transactionMeta.update.subEvents.push(transferEvent);
|
|
662
645
|
return claim;
|
|
663
646
|
}
|
|
664
647
|
|
|
@@ -780,16 +763,14 @@ function ingestTransactionOutcomeEvent(store, event, applying) {
|
|
|
780
763
|
//#endregion
|
|
781
764
|
//#region src/internal/transaction/get-epoch-number.ts
|
|
782
765
|
function getContinuityKey(store, transactionKey) {
|
|
783
|
-
|
|
784
|
-
return continuity;
|
|
766
|
+
return store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
785
767
|
}
|
|
786
768
|
function getEpochNumberOfContinuity(store, continuityKey) {
|
|
787
|
-
|
|
788
|
-
return epoch;
|
|
769
|
+
return store.transactionMeta.epoch.get(continuityKey);
|
|
789
770
|
}
|
|
790
771
|
function getEpochNumberOfAction(store, transactionKey) {
|
|
791
772
|
const continuityKey = getContinuityKey(store, transactionKey);
|
|
792
|
-
if (continuityKey === void 0) return
|
|
773
|
+
if (continuityKey === void 0) return;
|
|
793
774
|
return getEpochNumberOfContinuity(store, continuityKey);
|
|
794
775
|
}
|
|
795
776
|
|
|
@@ -817,11 +798,10 @@ function applyTransaction(store, output) {
|
|
|
817
798
|
ingestTransactionOutcomeEvent(parent, child.transactionMeta.update, `newValue`);
|
|
818
799
|
if (isRootStore(parent)) {
|
|
819
800
|
setEpochNumberOfAction(parent, child.transactionMeta.update.token.key, child.transactionMeta.update.epoch);
|
|
820
|
-
|
|
801
|
+
withdraw(store, {
|
|
821
802
|
key: child.transactionMeta.update.token.key,
|
|
822
803
|
type: `transaction`
|
|
823
|
-
});
|
|
824
|
-
myTransaction?.subject.next(child.transactionMeta.update);
|
|
804
|
+
})?.subject.next(child.transactionMeta.update);
|
|
825
805
|
store.logger.info(`🛬`, `transaction`, child.transactionMeta.update.token.key, `applied`);
|
|
826
806
|
} else if (isChildStore(parent)) parent.transactionMeta.update.subEvents.push(child.transactionMeta.update);
|
|
827
807
|
parent.on.transactionApplying.next(null);
|
|
@@ -920,14 +900,14 @@ function createTransaction(store, options) {
|
|
|
920
900
|
type: `transaction`,
|
|
921
901
|
run: (params, id) => {
|
|
922
902
|
const token$1 = deposit(newTransaction);
|
|
923
|
-
const target
|
|
903
|
+
const target = buildTransaction(store, token$1, params, id);
|
|
924
904
|
try {
|
|
925
|
-
const { toolkit } = target
|
|
905
|
+
const { toolkit } = target.transactionMeta;
|
|
926
906
|
const output = options.do(toolkit, ...params);
|
|
927
|
-
applyTransaction(target
|
|
907
|
+
applyTransaction(target, output);
|
|
928
908
|
return output;
|
|
929
909
|
} catch (thrown) {
|
|
930
|
-
abortTransaction(target
|
|
910
|
+
abortTransaction(target);
|
|
931
911
|
store.logger.warn(`💥`, `transaction`, key, `caught:`, thrown);
|
|
932
912
|
throw thrown;
|
|
933
913
|
}
|
|
@@ -935,8 +915,7 @@ function createTransaction(store, options) {
|
|
|
935
915
|
install: (s) => createTransaction(s, options),
|
|
936
916
|
subject: new Subject()
|
|
937
917
|
};
|
|
938
|
-
|
|
939
|
-
target.transactions.set(key, newTransaction);
|
|
918
|
+
newest(store).transactions.set(key, newTransaction);
|
|
940
919
|
const token = deposit(newTransaction);
|
|
941
920
|
if (!transactionAlreadyExists) store.on.transactionCreation.next(token);
|
|
942
921
|
return token;
|
|
@@ -1085,8 +1064,7 @@ function findInStore(store, familyToken, key) {
|
|
|
1085
1064
|
const family = withdraw(store, familyToken);
|
|
1086
1065
|
const existingStateToken = seekInStore(store, familyToken, key);
|
|
1087
1066
|
if (existingStateToken) return existingStateToken;
|
|
1088
|
-
|
|
1089
|
-
return newStateToken;
|
|
1067
|
+
return mintInStore(DO_NOT_CREATE, store, family, key);
|
|
1090
1068
|
}
|
|
1091
1069
|
|
|
1092
1070
|
//#endregion
|
|
@@ -1123,8 +1101,7 @@ function createReadonlyPureSelectorFamily(store, options, internalRoles) {
|
|
|
1123
1101
|
subject,
|
|
1124
1102
|
install: (s) => createReadonlyPureSelectorFamily(s, options),
|
|
1125
1103
|
default: (key) => {
|
|
1126
|
-
|
|
1127
|
-
return getFn({
|
|
1104
|
+
return options.get(key)({
|
|
1128
1105
|
get: ((...args) => getFromStore(store, ...args)),
|
|
1129
1106
|
find: ((...args) => findInStore(store, ...args)),
|
|
1130
1107
|
json: (token) => getJsonToken(store, token)
|
|
@@ -1287,8 +1264,7 @@ function createWritablePureSelectorFamily(store, options, internalRoles) {
|
|
|
1287
1264
|
subject,
|
|
1288
1265
|
install: (s) => createWritablePureSelectorFamily(s, options),
|
|
1289
1266
|
default: (key) => {
|
|
1290
|
-
|
|
1291
|
-
return getFn({
|
|
1267
|
+
return options.get(key)({
|
|
1292
1268
|
get: ((...args) => getFromStore(store, ...args)),
|
|
1293
1269
|
find: ((...args) => findInStore(store, ...args)),
|
|
1294
1270
|
json: (token) => getJsonToken(store, token)
|
|
@@ -1318,8 +1294,7 @@ function disposeFromStore(store, ...params) {
|
|
|
1318
1294
|
else {
|
|
1319
1295
|
const family = params[0];
|
|
1320
1296
|
const key = params[1];
|
|
1321
|
-
|
|
1322
|
-
token = maybeToken;
|
|
1297
|
+
token = findInStore(store, family, key);
|
|
1323
1298
|
}
|
|
1324
1299
|
try {
|
|
1325
1300
|
withdraw(store, token);
|
|
@@ -1602,73 +1577,60 @@ function disposeSelector(store, selectorToken) {
|
|
|
1602
1577
|
const { key, type, family: familyMeta } = selectorToken;
|
|
1603
1578
|
if (!familyMeta) store.logger.error(`❌`, type, key, `Standalone selectors cannot be disposed.`);
|
|
1604
1579
|
else {
|
|
1605
|
-
|
|
1606
|
-
if (molecule) target.moleculeData.delete(familyMeta.subKey, familyMeta.key);
|
|
1580
|
+
if (target.molecules.get(familyMeta.subKey)) target.moleculeData.delete(familyMeta.subKey, familyMeta.key);
|
|
1607
1581
|
let familyToken;
|
|
1608
1582
|
switch (selectorToken.type) {
|
|
1609
1583
|
case `writable_held_selector`:
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
timestamp: Date.now()
|
|
1622
|
-
});
|
|
1623
|
-
}
|
|
1584
|
+
target.writableSelectors.delete(key);
|
|
1585
|
+
familyToken = {
|
|
1586
|
+
key: familyMeta.key,
|
|
1587
|
+
type: `writable_held_selector_family`
|
|
1588
|
+
};
|
|
1589
|
+
withdraw(store, familyToken).subject.next({
|
|
1590
|
+
type: `state_disposal`,
|
|
1591
|
+
subType: `selector`,
|
|
1592
|
+
token: selectorToken,
|
|
1593
|
+
timestamp: Date.now()
|
|
1594
|
+
});
|
|
1624
1595
|
break;
|
|
1625
1596
|
case `writable_pure_selector`:
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
timestamp: Date.now()
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1597
|
+
target.writableSelectors.delete(key);
|
|
1598
|
+
familyToken = {
|
|
1599
|
+
key: familyMeta.key,
|
|
1600
|
+
type: `writable_pure_selector_family`
|
|
1601
|
+
};
|
|
1602
|
+
withdraw(store, familyToken).subject.next({
|
|
1603
|
+
type: `state_disposal`,
|
|
1604
|
+
subType: `selector`,
|
|
1605
|
+
token: selectorToken,
|
|
1606
|
+
timestamp: Date.now()
|
|
1607
|
+
});
|
|
1640
1608
|
break;
|
|
1641
1609
|
case `readonly_held_selector`:
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
timestamp: Date.now()
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1610
|
+
target.readonlySelectors.delete(key);
|
|
1611
|
+
familyToken = {
|
|
1612
|
+
key: familyMeta.key,
|
|
1613
|
+
type: `readonly_held_selector_family`
|
|
1614
|
+
};
|
|
1615
|
+
withdraw(store, familyToken).subject.next({
|
|
1616
|
+
type: `state_disposal`,
|
|
1617
|
+
subType: `selector`,
|
|
1618
|
+
token: selectorToken,
|
|
1619
|
+
timestamp: Date.now()
|
|
1620
|
+
});
|
|
1656
1621
|
break;
|
|
1657
1622
|
case `readonly_pure_selector`:
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
timestamp: Date.now()
|
|
1670
|
-
});
|
|
1671
|
-
}
|
|
1623
|
+
target.readonlySelectors.delete(key);
|
|
1624
|
+
familyToken = {
|
|
1625
|
+
key: familyMeta.key,
|
|
1626
|
+
type: `readonly_pure_selector_family`
|
|
1627
|
+
};
|
|
1628
|
+
withdraw(store, familyToken).subject.next({
|
|
1629
|
+
type: `state_disposal`,
|
|
1630
|
+
subType: `selector`,
|
|
1631
|
+
token: selectorToken,
|
|
1632
|
+
timestamp: Date.now()
|
|
1633
|
+
});
|
|
1672
1634
|
break;
|
|
1673
1635
|
}
|
|
1674
1636
|
target.valueMap.delete(key);
|
|
@@ -1855,8 +1817,7 @@ function createMutableAtomFamily(store, options, internalRoles) {
|
|
|
1855
1817
|
const getJsonFamily = (mutableAtomFamily, store) => {
|
|
1856
1818
|
const target = newest(store);
|
|
1857
1819
|
const key = `${mutableAtomFamily.key}:JSON`;
|
|
1858
|
-
|
|
1859
|
-
return jsonFamily;
|
|
1820
|
+
return target.families.get(key);
|
|
1860
1821
|
};
|
|
1861
1822
|
|
|
1862
1823
|
//#endregion
|
|
@@ -1864,21 +1825,18 @@ const getJsonFamily = (mutableAtomFamily, store) => {
|
|
|
1864
1825
|
const getJsonToken = (store, mutableAtomToken) => {
|
|
1865
1826
|
if (mutableAtomToken.family) {
|
|
1866
1827
|
const target = newest(store);
|
|
1867
|
-
const jsonFamilyKey = `${mutableAtomToken.family.key}:JSON`;
|
|
1868
1828
|
const jsonFamilyToken = {
|
|
1869
|
-
key:
|
|
1829
|
+
key: `${mutableAtomToken.family.key}:JSON`,
|
|
1870
1830
|
type: `writable_pure_selector_family`
|
|
1871
1831
|
};
|
|
1872
1832
|
const family = withdraw(target, jsonFamilyToken);
|
|
1873
1833
|
const subKey = parseJson(mutableAtomToken.family.subKey);
|
|
1874
|
-
|
|
1875
|
-
return jsonToken;
|
|
1834
|
+
return findInStore(store, family, subKey);
|
|
1876
1835
|
}
|
|
1877
|
-
|
|
1836
|
+
return {
|
|
1878
1837
|
type: `writable_pure_selector`,
|
|
1879
1838
|
key: `${mutableAtomToken.key}:JSON`
|
|
1880
1839
|
};
|
|
1881
|
-
return token;
|
|
1882
1840
|
};
|
|
1883
1841
|
|
|
1884
1842
|
//#endregion
|
|
@@ -1886,17 +1844,15 @@ const getJsonToken = (store, mutableAtomToken) => {
|
|
|
1886
1844
|
const getUpdateFamily = (mutableAtomFamily, store) => {
|
|
1887
1845
|
const target = newest(store);
|
|
1888
1846
|
const key = `*${mutableAtomFamily.key}`;
|
|
1889
|
-
|
|
1890
|
-
return updateFamily;
|
|
1847
|
+
return target.families.get(key);
|
|
1891
1848
|
};
|
|
1892
1849
|
|
|
1893
1850
|
//#endregion
|
|
1894
1851
|
//#region src/internal/mutable/get-update-token.ts
|
|
1895
1852
|
const getUpdateToken = (mutableAtomToken) => {
|
|
1896
|
-
const key = `*${mutableAtomToken.key}`;
|
|
1897
1853
|
const updateToken = {
|
|
1898
1854
|
type: `atom`,
|
|
1899
|
-
key
|
|
1855
|
+
key: `*${mutableAtomToken.key}`
|
|
1900
1856
|
};
|
|
1901
1857
|
if (mutableAtomToken.family) updateToken.family = {
|
|
1902
1858
|
key: `*${mutableAtomToken.family.key}`,
|
|
@@ -1916,8 +1872,7 @@ function disposeAtom(store, atomToken) {
|
|
|
1916
1872
|
atom.cleanup?.();
|
|
1917
1873
|
const lastValue = store.valueMap.get(atom.key);
|
|
1918
1874
|
const familyToken = getFamilyOfToken(store, atomToken);
|
|
1919
|
-
const
|
|
1920
|
-
const subject = atomFamily$1.subject;
|
|
1875
|
+
const subject = withdraw(store, familyToken).subject;
|
|
1921
1876
|
const disposalEvent = {
|
|
1922
1877
|
type: `state_disposal`,
|
|
1923
1878
|
subType: `atom`,
|
|
@@ -1941,8 +1896,7 @@ function disposeAtom(store, atomToken) {
|
|
|
1941
1896
|
store.logger.info(`🔥`, `atom`, key, `deleted`);
|
|
1942
1897
|
if (isChild && target.transactionMeta.phase === `building`) {
|
|
1943
1898
|
const mostRecentUpdate = target.transactionMeta.update.subEvents.at(-1);
|
|
1944
|
-
const
|
|
1945
|
-
const updateAlreadyCaptured = wasMoleculeDisposal && mostRecentUpdate.values.some(([k]) => k === atom.family?.key);
|
|
1899
|
+
const updateAlreadyCaptured = mostRecentUpdate?.type === `molecule_disposal` && mostRecentUpdate.values.some(([k]) => k === atom.family?.key);
|
|
1946
1900
|
const isTracker = hasRole(atom, `tracker:signal`);
|
|
1947
1901
|
if (!updateAlreadyCaptured && !isTracker) target.transactionMeta.update.subEvents.push(disposalEvent);
|
|
1948
1902
|
} else store.on.atomDisposal.next(atomToken);
|
|
@@ -1976,10 +1930,7 @@ function installIntoStore(tokens, target, source) {
|
|
|
1976
1930
|
target.logger.error(`❌`, `transaction`, targetNewest.transactionMeta.update.token.key, `could not install the following tokens into store "${target.config.name} from "${source.config.name}":`, tokens, `${targetNewest.config.name} is undergoing a transaction.`);
|
|
1977
1931
|
return;
|
|
1978
1932
|
}
|
|
1979
|
-
for (const token of tokens)
|
|
1980
|
-
const resource = withdraw(source, token);
|
|
1981
|
-
resource.install(target);
|
|
1982
|
-
}
|
|
1933
|
+
for (const token of tokens) withdraw(source, token).install(target);
|
|
1983
1934
|
}
|
|
1984
1935
|
|
|
1985
1936
|
//#endregion
|
|
@@ -2046,8 +1997,7 @@ var Join = class {
|
|
|
2046
1997
|
const relationsOfAState = find(relatedKeysAtoms, a);
|
|
2047
1998
|
const currentRelationsOfA = get(relationsOfAState);
|
|
2048
1999
|
for (const currentRelationB of currentRelationsOfA) {
|
|
2049
|
-
|
|
2050
|
-
if (remainsRelated) continue;
|
|
2000
|
+
if (newRelationsOfA.includes(currentRelationB)) continue;
|
|
2051
2001
|
set(relatedKeysAtoms, currentRelationB, (relationsOfB) => {
|
|
2052
2002
|
relationsOfB.delete(a);
|
|
2053
2003
|
return relationsOfB;
|
|
@@ -2130,17 +2080,15 @@ var Join = class {
|
|
|
2130
2080
|
const setContent = ({ set }, key, content) => {
|
|
2131
2081
|
set(contentAtoms, key, content);
|
|
2132
2082
|
};
|
|
2133
|
-
|
|
2083
|
+
externalStore = Object.assign(baseExternalStoreConfiguration, {
|
|
2134
2084
|
getContent: (contentKey) => {
|
|
2135
|
-
|
|
2136
|
-
return content;
|
|
2085
|
+
return getContent(this.toolkit, contentKey);
|
|
2137
2086
|
},
|
|
2138
2087
|
setContent: (contentKey, content) => {
|
|
2139
2088
|
setContent(this.toolkit, contentKey, content);
|
|
2140
2089
|
},
|
|
2141
2090
|
deleteContent: (_) => {}
|
|
2142
|
-
};
|
|
2143
|
-
externalStore = Object.assign(baseExternalStoreConfiguration, externalStoreWithContentConfiguration);
|
|
2091
|
+
});
|
|
2144
2092
|
} else externalStore = baseExternalStoreConfiguration;
|
|
2145
2093
|
const relations = new Junction(options, {
|
|
2146
2094
|
externalStore,
|
|
@@ -2173,8 +2121,7 @@ var Join = class {
|
|
|
2173
2121
|
key: `${options.key}/multipleRelatedKeys`,
|
|
2174
2122
|
get: (key) => ({ get }) => {
|
|
2175
2123
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
2176
|
-
|
|
2177
|
-
return json.members;
|
|
2124
|
+
return get(jsonFamily, key).members;
|
|
2178
2125
|
}
|
|
2179
2126
|
}, [`join`, `keys`]);
|
|
2180
2127
|
};
|
|
@@ -2198,8 +2145,7 @@ var Join = class {
|
|
|
2198
2145
|
key: `${options.key}/multipleRelatedEntries`,
|
|
2199
2146
|
get: (x) => ({ get }) => {
|
|
2200
2147
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
2201
|
-
|
|
2202
|
-
return json.members.map((y) => {
|
|
2148
|
+
return get(jsonFamily, x).members.map((y) => {
|
|
2203
2149
|
let a = relations.isAType?.(x) ? x : void 0;
|
|
2204
2150
|
let b = a === void 0 ? x : void 0;
|
|
2205
2151
|
a ??= y;
|
|
@@ -2289,14 +2235,13 @@ var Join = class {
|
|
|
2289
2235
|
//#region src/internal/join/create-join.ts
|
|
2290
2236
|
function createJoin(store, options, defaultContent) {
|
|
2291
2237
|
store.joins.set(options.key, new Join(options, defaultContent, store));
|
|
2292
|
-
|
|
2238
|
+
return {
|
|
2293
2239
|
key: options.key,
|
|
2294
2240
|
type: `join`,
|
|
2295
2241
|
a: options.between[0],
|
|
2296
2242
|
b: options.between[1],
|
|
2297
2243
|
cardinality: options.cardinality
|
|
2298
2244
|
};
|
|
2299
|
-
return token;
|
|
2300
2245
|
}
|
|
2301
2246
|
|
|
2302
2247
|
//#endregion
|
|
@@ -2304,8 +2249,7 @@ function createJoin(store, options, defaultContent) {
|
|
|
2304
2249
|
function getJoin(token, store) {
|
|
2305
2250
|
let myJoin = store.joins.get(token.key);
|
|
2306
2251
|
if (myJoin === void 0) {
|
|
2307
|
-
const
|
|
2308
|
-
const rootJoin = rootJoinMap.get(token.key);
|
|
2252
|
+
const rootJoin = IMPLICIT.STORE.joins.get(token.key);
|
|
2309
2253
|
if (rootJoin === void 0) throw new Error(`Join "${token.key}" not found in store "${store.config.name}"`);
|
|
2310
2254
|
const root = eldest(store);
|
|
2311
2255
|
myJoin = new Join(rootJoin.options, rootJoin.defaultContent, root);
|
|
@@ -2339,13 +2283,11 @@ function findRelationsInStore(token, key, store) {
|
|
|
2339
2283
|
relations = {
|
|
2340
2284
|
get [keyAB]() {
|
|
2341
2285
|
const familyAB = myJoin.states[keyAB];
|
|
2342
|
-
|
|
2343
|
-
return state;
|
|
2286
|
+
return findInStore(store, familyAB, key);
|
|
2344
2287
|
},
|
|
2345
2288
|
get [keyBA]() {
|
|
2346
2289
|
const familyBA = myJoin.states[keyBA];
|
|
2347
|
-
|
|
2348
|
-
return state;
|
|
2290
|
+
return findInStore(store, familyBA, key);
|
|
2349
2291
|
}
|
|
2350
2292
|
};
|
|
2351
2293
|
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
@@ -2354,13 +2296,11 @@ function findRelationsInStore(token, key, store) {
|
|
|
2354
2296
|
Object.assign(relations, {
|
|
2355
2297
|
get [entryAB]() {
|
|
2356
2298
|
const familyAB = myJoin.states[entryAB];
|
|
2357
|
-
|
|
2358
|
-
return state;
|
|
2299
|
+
return findInStore(store, familyAB, key);
|
|
2359
2300
|
},
|
|
2360
2301
|
get [entryBA]() {
|
|
2361
2302
|
const familyBA = myJoin.states[entryBA];
|
|
2362
|
-
|
|
2363
|
-
return state;
|
|
2303
|
+
return findInStore(store, familyBA, key);
|
|
2364
2304
|
}
|
|
2365
2305
|
});
|
|
2366
2306
|
}
|
|
@@ -2372,13 +2312,11 @@ function findRelationsInStore(token, key, store) {
|
|
|
2372
2312
|
relations = {
|
|
2373
2313
|
get [keyAB]() {
|
|
2374
2314
|
const familyAB = myJoin.states[keyAB];
|
|
2375
|
-
|
|
2376
|
-
return state;
|
|
2315
|
+
return findInStore(store, familyAB, key);
|
|
2377
2316
|
},
|
|
2378
2317
|
get [keysBA]() {
|
|
2379
2318
|
const familyBA = myJoin.states[keysBA];
|
|
2380
|
-
|
|
2381
|
-
return state;
|
|
2319
|
+
return findInStore(store, familyBA, key);
|
|
2382
2320
|
}
|
|
2383
2321
|
};
|
|
2384
2322
|
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
@@ -2387,13 +2325,11 @@ function findRelationsInStore(token, key, store) {
|
|
|
2387
2325
|
Object.assign(relations, {
|
|
2388
2326
|
get [entryAB]() {
|
|
2389
2327
|
const familyAB = myJoin.states[entryAB];
|
|
2390
|
-
|
|
2391
|
-
return state;
|
|
2328
|
+
return findInStore(store, familyAB, key);
|
|
2392
2329
|
},
|
|
2393
2330
|
get [entriesBA]() {
|
|
2394
2331
|
const familyBA = myJoin.states[entriesBA];
|
|
2395
|
-
|
|
2396
|
-
return state;
|
|
2332
|
+
return findInStore(store, familyBA, key);
|
|
2397
2333
|
}
|
|
2398
2334
|
});
|
|
2399
2335
|
}
|
|
@@ -2405,13 +2341,11 @@ function findRelationsInStore(token, key, store) {
|
|
|
2405
2341
|
relations = {
|
|
2406
2342
|
get [keysAB]() {
|
|
2407
2343
|
const familyAB = myJoin.states[keysAB];
|
|
2408
|
-
|
|
2409
|
-
return state;
|
|
2344
|
+
return findInStore(store, familyAB, key);
|
|
2410
2345
|
},
|
|
2411
2346
|
get [keysBA]() {
|
|
2412
2347
|
const familyBA = myJoin.states[keysBA];
|
|
2413
|
-
|
|
2414
|
-
return state;
|
|
2348
|
+
return findInStore(store, familyBA, key);
|
|
2415
2349
|
}
|
|
2416
2350
|
};
|
|
2417
2351
|
const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`;
|
|
@@ -2420,13 +2354,11 @@ function findRelationsInStore(token, key, store) {
|
|
|
2420
2354
|
Object.assign(relations, {
|
|
2421
2355
|
get [entriesAB]() {
|
|
2422
2356
|
const familyAB = myJoin.states[entriesAB];
|
|
2423
|
-
|
|
2424
|
-
return state;
|
|
2357
|
+
return findInStore(store, familyAB, key);
|
|
2425
2358
|
},
|
|
2426
2359
|
get [entriesBA]() {
|
|
2427
2360
|
const familyBA = myJoin.states[entriesBA];
|
|
2428
|
-
|
|
2429
|
-
return state;
|
|
2361
|
+
return findInStore(store, familyBA, key);
|
|
2430
2362
|
}
|
|
2431
2363
|
});
|
|
2432
2364
|
}
|
|
@@ -2438,9 +2370,7 @@ function findRelationsInStore(token, key, store) {
|
|
|
2438
2370
|
//#endregion
|
|
2439
2371
|
//#region src/internal/join/get-internal-relations-from-store.ts
|
|
2440
2372
|
function getInternalRelationsFromStore(token, store) {
|
|
2441
|
-
|
|
2442
|
-
const family = myJoin.core.relatedKeysAtoms;
|
|
2443
|
-
return family;
|
|
2373
|
+
return getJoin(token, store).core.relatedKeysAtoms;
|
|
2444
2374
|
}
|
|
2445
2375
|
|
|
2446
2376
|
//#endregion
|
|
@@ -2554,11 +2484,10 @@ function addAtomFamilyToTimeline(store, atomFamilyToken, tl) {
|
|
|
2554
2484
|
function joinTransaction(store, tl, txUpdateInProgress) {
|
|
2555
2485
|
const currentTxKey = txUpdateInProgress.token.key;
|
|
2556
2486
|
const currentTxInstanceId = txUpdateInProgress.id;
|
|
2557
|
-
const
|
|
2487
|
+
const currentTransaction = withdraw(store, {
|
|
2558
2488
|
key: currentTxKey,
|
|
2559
2489
|
type: `transaction`
|
|
2560
|
-
};
|
|
2561
|
-
const currentTransaction = withdraw(store, currentTxToken);
|
|
2490
|
+
});
|
|
2562
2491
|
if (currentTxKey && tl.transactionKey === null) {
|
|
2563
2492
|
tl.transactionKey = currentTxKey;
|
|
2564
2493
|
const unsubscribe = currentTransaction.subject.subscribe(`timeline:${tl.key}`, (transactionUpdate) => {
|