atom.io 0.25.6 → 0.26.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.js +33 -25
- package/data/package.json +1 -4
- package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
- package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
- package/dist/chunk-XWL6SNVU.js +7 -0
- package/dist/index.js +33 -21
- package/ephemeral/dist/index.js +1 -1
- package/ephemeral/package.json +1 -4
- package/eslint-plugin/dist/index.js +7 -8
- package/eslint-plugin/package.json +1 -4
- package/immortal/dist/index.js +1 -1
- package/immortal/package.json +1 -4
- package/internal/dist/index.js +173 -160
- package/internal/package.json +1 -4
- package/introspection/dist/index.js +32 -30
- package/introspection/package.json +1 -4
- package/json/dist/index.js +1 -1
- package/json/package.json +1 -4
- package/package.json +18 -50
- package/react/dist/index.js +2 -2
- package/react/package.json +1 -4
- package/react-devtools/dist/index.js +75 -68
- package/react-devtools/package.json +1 -4
- package/realtime/dist/index.js +8 -9
- package/realtime/package.json +1 -4
- package/realtime-client/dist/index.js +6 -6
- package/realtime-client/package.json +1 -4
- package/realtime-react/dist/index.js +9 -11
- package/realtime-react/package.json +1 -4
- package/realtime-server/dist/index.js +59 -54
- package/realtime-server/package.json +1 -4
- package/realtime-testing/dist/index.js +3 -3
- package/realtime-testing/package.json +1 -4
- package/transceivers/set-rtx/dist/index.js +11 -11
- package/transceivers/set-rtx/package.json +1 -4
- package/data/dist/index.cjs +0 -953
- package/dist/chunk-S4N6XNPH.js +0 -38
- package/dist/index.cjs +0 -215
- package/ephemeral/dist/index.cjs +0 -11
- package/eslint-plugin/dist/index.cjs +0 -388
- package/immortal/dist/index.cjs +0 -14
- package/internal/dist/index.cjs +0 -3405
- package/introspection/dist/index.cjs +0 -449
- package/json/dist/index.cjs +0 -128
- package/react/dist/index.cjs +0 -118
- package/react-devtools/dist/index.cjs +0 -2191
- package/realtime/dist/index.cjs +0 -120
- package/realtime-client/dist/index.cjs +0 -569
- package/realtime-react/dist/index.cjs +0 -189
- package/realtime-server/dist/index.cjs +0 -965
- package/realtime-testing/dist/index.cjs +0 -201
- package/transceivers/set-rtx/dist/index.cjs +0 -215
package/internal/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Junction } from '../../dist/chunk-
|
|
2
|
-
import
|
|
1
|
+
import { Junction } from '../../dist/chunk-IBTHB2PI.js';
|
|
2
|
+
import '../../dist/chunk-XWL6SNVU.js';
|
|
3
3
|
import { stringifyJson, parseJson, selectJson, selectJsonFamily } from 'atom.io/json';
|
|
4
4
|
import { AtomIOLogger } from 'atom.io';
|
|
5
5
|
import { getJoin, findRelations } from 'atom.io/data';
|
|
@@ -11,6 +11,9 @@ function arbitrary(random = Math.random) {
|
|
|
11
11
|
|
|
12
12
|
// internal/src/future.ts
|
|
13
13
|
var Future = class extends Promise {
|
|
14
|
+
fate;
|
|
15
|
+
resolve;
|
|
16
|
+
reject;
|
|
14
17
|
constructor(executor) {
|
|
15
18
|
let superResolve;
|
|
16
19
|
let superReject;
|
|
@@ -79,9 +82,8 @@ function deposit(state) {
|
|
|
79
82
|
|
|
80
83
|
// internal/src/subject.ts
|
|
81
84
|
var Subject = class {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
+
Subscriber;
|
|
86
|
+
subscribers = /* @__PURE__ */ new Map();
|
|
85
87
|
subscribe(key, subscriber) {
|
|
86
88
|
this.subscribers.set(key, subscriber);
|
|
87
89
|
const unsubscribe = () => {
|
|
@@ -100,6 +102,7 @@ var Subject = class {
|
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
104
|
var StatefulSubject = class extends Subject {
|
|
105
|
+
state;
|
|
103
106
|
constructor(initialState) {
|
|
104
107
|
super();
|
|
105
108
|
this.state = initialState;
|
|
@@ -311,7 +314,7 @@ var evictDownStream = (atom, store) => {
|
|
|
311
314
|
atom.type,
|
|
312
315
|
atom.key,
|
|
313
316
|
downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`,
|
|
314
|
-
downstreamKeys
|
|
317
|
+
downstreamKeys ?? `to evict`
|
|
315
318
|
);
|
|
316
319
|
if (downstreamKeys) {
|
|
317
320
|
if (target.operation.open) {
|
|
@@ -358,10 +361,11 @@ var stowUpdate = (state, update, store) => {
|
|
|
358
361
|
if (!shouldStow) {
|
|
359
362
|
return;
|
|
360
363
|
}
|
|
361
|
-
const atomUpdate =
|
|
364
|
+
const atomUpdate = {
|
|
362
365
|
type: `atom_update`,
|
|
363
|
-
key
|
|
364
|
-
|
|
366
|
+
key,
|
|
367
|
+
...update
|
|
368
|
+
};
|
|
365
369
|
if (state.family) {
|
|
366
370
|
atomUpdate.family = state.family;
|
|
367
371
|
}
|
|
@@ -663,12 +667,14 @@ var createReadonlySelector = (options, family, store) => {
|
|
|
663
667
|
covered.clear();
|
|
664
668
|
return value;
|
|
665
669
|
};
|
|
666
|
-
const readonlySelector =
|
|
670
|
+
const readonlySelector = {
|
|
671
|
+
...options,
|
|
667
672
|
subject,
|
|
668
673
|
install: (s) => createReadonlySelector(options, family, s),
|
|
669
674
|
get: getSelf,
|
|
670
|
-
type: `readonly_selector
|
|
671
|
-
|
|
675
|
+
type: `readonly_selector`,
|
|
676
|
+
...family && { family }
|
|
677
|
+
};
|
|
672
678
|
target.readonlySelectors.set(options.key, readonlySelector);
|
|
673
679
|
const initialValue = getSelf();
|
|
674
680
|
store.logger.info(
|
|
@@ -723,13 +729,15 @@ var createWritableSelector = (options, family, store) => {
|
|
|
723
729
|
}
|
|
724
730
|
options.set(toolkit, newValue);
|
|
725
731
|
};
|
|
726
|
-
const mySelector =
|
|
732
|
+
const mySelector = {
|
|
733
|
+
...options,
|
|
727
734
|
subject,
|
|
728
735
|
install: (s) => createWritableSelector(options, family, s),
|
|
729
736
|
get: getSelf,
|
|
730
737
|
set: setSelf,
|
|
731
|
-
type: `selector
|
|
732
|
-
|
|
738
|
+
type: `selector`,
|
|
739
|
+
...family && { family }
|
|
740
|
+
};
|
|
733
741
|
target.selectors.set(options.key, mySelector);
|
|
734
742
|
const initialValue = getSelf();
|
|
735
743
|
store.logger.info(`\u2728`, mySelector.type, mySelector.key, `=`, initialValue);
|
|
@@ -758,10 +766,9 @@ function createStandaloneSelector(options, store) {
|
|
|
758
766
|
|
|
759
767
|
// internal/src/selector/dispose-selector.ts
|
|
760
768
|
function disposeSelector(selectorToken, store) {
|
|
761
|
-
var _a;
|
|
762
769
|
const target = newest(store);
|
|
763
770
|
const { key } = selectorToken;
|
|
764
|
-
const selector =
|
|
771
|
+
const selector = target.selectors.get(key) ?? target.readonlySelectors.get(key);
|
|
765
772
|
if (!selector) {
|
|
766
773
|
store.logger.info(
|
|
767
774
|
`\u274C`,
|
|
@@ -812,10 +819,7 @@ function disposeSelector(selectorToken, store) {
|
|
|
812
819
|
target.valueMap.delete(key);
|
|
813
820
|
target.selectorAtoms.delete(key);
|
|
814
821
|
const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
|
|
815
|
-
([downstreamSelectorKey]) =>
|
|
816
|
-
var _a2;
|
|
817
|
-
return (_a2 = target.selectors.get(downstreamSelectorKey)) != null ? _a2 : target.readonlySelectors.get(downstreamSelectorKey);
|
|
818
|
-
}
|
|
822
|
+
([downstreamSelectorKey]) => target.selectors.get(downstreamSelectorKey) ?? target.readonlySelectors.get(downstreamSelectorKey)
|
|
819
823
|
);
|
|
820
824
|
for (const downstreamToken of downstreamTokens) {
|
|
821
825
|
if (downstreamToken) {
|
|
@@ -907,7 +911,6 @@ function createSelectorFamily(options, store) {
|
|
|
907
911
|
|
|
908
912
|
// internal/src/molecule/dispose-molecule.ts
|
|
909
913
|
function disposeMolecule(token, store) {
|
|
910
|
-
var _a;
|
|
911
914
|
let molecule;
|
|
912
915
|
try {
|
|
913
916
|
molecule = withdraw(token, store);
|
|
@@ -949,7 +952,7 @@ function disposeMolecule(token, store) {
|
|
|
949
952
|
disposeFromStore(state, store);
|
|
950
953
|
}
|
|
951
954
|
for (const child of molecule.below.values()) {
|
|
952
|
-
if (
|
|
955
|
+
if (child.family?.dependsOn === `all`) {
|
|
953
956
|
disposeMolecule(child, store);
|
|
954
957
|
} else {
|
|
955
958
|
child.above.delete(molecule.stringKey);
|
|
@@ -1135,17 +1138,17 @@ function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
|
1135
1138
|
|
|
1136
1139
|
// internal/src/molecule/create-molecule-family.ts
|
|
1137
1140
|
function createMoleculeFamily(options, store) {
|
|
1138
|
-
var _a;
|
|
1139
1141
|
const subject = new Subject();
|
|
1140
1142
|
const token = {
|
|
1141
1143
|
type: `molecule_family`,
|
|
1142
1144
|
key: options.key,
|
|
1143
|
-
dependsOn:
|
|
1145
|
+
dependsOn: options.dependsOn ?? `all`
|
|
1144
1146
|
};
|
|
1145
|
-
const family =
|
|
1147
|
+
const family = {
|
|
1148
|
+
...token,
|
|
1146
1149
|
subject,
|
|
1147
1150
|
new: options.new
|
|
1148
|
-
}
|
|
1151
|
+
};
|
|
1149
1152
|
store.moleculeFamilies.set(options.key, family);
|
|
1150
1153
|
return token;
|
|
1151
1154
|
}
|
|
@@ -1171,12 +1174,6 @@ function getEnvironmentData(store) {
|
|
|
1171
1174
|
var Molecule = class {
|
|
1172
1175
|
constructor(ctx, key, family) {
|
|
1173
1176
|
this.key = key;
|
|
1174
|
-
this.type = `molecule`;
|
|
1175
|
-
this.subject = new Subject();
|
|
1176
|
-
this.tokens = /* @__PURE__ */ new Map();
|
|
1177
|
-
this.above = /* @__PURE__ */ new Map();
|
|
1178
|
-
this.below = /* @__PURE__ */ new Map();
|
|
1179
|
-
this.joins = /* @__PURE__ */ new Map();
|
|
1180
1177
|
this.stringKey = stringifyJson(key);
|
|
1181
1178
|
if (family) {
|
|
1182
1179
|
this.family = family;
|
|
@@ -1191,6 +1188,15 @@ var Molecule = class {
|
|
|
1191
1188
|
}
|
|
1192
1189
|
}
|
|
1193
1190
|
}
|
|
1191
|
+
type = `molecule`;
|
|
1192
|
+
stringKey;
|
|
1193
|
+
family;
|
|
1194
|
+
subject = new Subject();
|
|
1195
|
+
tokens = /* @__PURE__ */ new Map();
|
|
1196
|
+
above = /* @__PURE__ */ new Map();
|
|
1197
|
+
below = /* @__PURE__ */ new Map();
|
|
1198
|
+
joins = /* @__PURE__ */ new Map();
|
|
1199
|
+
instance;
|
|
1194
1200
|
};
|
|
1195
1201
|
|
|
1196
1202
|
// internal/src/molecule/make-molecule-in-store.ts
|
|
@@ -1459,10 +1465,9 @@ function setEpochNumberOfAction(transactionKey, newEpoch, store) {
|
|
|
1459
1465
|
|
|
1460
1466
|
// internal/src/transaction/apply-transaction.ts
|
|
1461
1467
|
var applyTransaction = (output, store) => {
|
|
1462
|
-
var _a;
|
|
1463
1468
|
const child = newest(store);
|
|
1464
1469
|
const { parent } = child;
|
|
1465
|
-
if (parent === null || !isChildStore(child) ||
|
|
1470
|
+
if (parent === null || !isChildStore(child) || child.transactionMeta?.phase !== `building`) {
|
|
1466
1471
|
store.logger.warn(
|
|
1467
1472
|
`\u{1F41E}`,
|
|
1468
1473
|
`transaction`,
|
|
@@ -1494,7 +1499,7 @@ var applyTransaction = (output, store) => {
|
|
|
1494
1499
|
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
1495
1500
|
store
|
|
1496
1501
|
);
|
|
1497
|
-
myTransaction
|
|
1502
|
+
myTransaction?.subject.next(child.transactionMeta.update);
|
|
1498
1503
|
store.logger.info(
|
|
1499
1504
|
`\u{1F6EC}`,
|
|
1500
1505
|
`transaction`,
|
|
@@ -1525,8 +1530,8 @@ var LazyMap = class extends Map {
|
|
|
1525
1530
|
constructor(source) {
|
|
1526
1531
|
super();
|
|
1527
1532
|
this.source = source;
|
|
1528
|
-
this.deleted = /* @__PURE__ */ new Set();
|
|
1529
1533
|
}
|
|
1534
|
+
deleted = /* @__PURE__ */ new Set();
|
|
1530
1535
|
get(key) {
|
|
1531
1536
|
const has = super.has(key);
|
|
1532
1537
|
if (has) {
|
|
@@ -1678,89 +1683,92 @@ var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
|
1678
1683
|
|
|
1679
1684
|
// internal/src/store/store.ts
|
|
1680
1685
|
var Store = class {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1686
|
+
parent = null;
|
|
1687
|
+
child = null;
|
|
1688
|
+
valueMap = /* @__PURE__ */ new Map();
|
|
1689
|
+
atoms = /* @__PURE__ */ new Map();
|
|
1690
|
+
selectors = /* @__PURE__ */ new Map();
|
|
1691
|
+
readonlySelectors = /* @__PURE__ */ new Map();
|
|
1692
|
+
atomsThatAreDefault = /* @__PURE__ */ new Set();
|
|
1693
|
+
selectorAtoms = new Junction({
|
|
1694
|
+
between: [`selectorKey`, `atomKey`],
|
|
1695
|
+
cardinality: `n:n`
|
|
1696
|
+
});
|
|
1697
|
+
selectorGraph = new Junction(
|
|
1698
|
+
{
|
|
1699
|
+
between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
|
|
1691
1700
|
cardinality: `n:n`
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
)
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
this.transactions = /* @__PURE__ */ new Map();
|
|
1705
|
-
this.transactionMeta = {
|
|
1706
|
-
epoch: /* @__PURE__ */ new Map(),
|
|
1707
|
-
actionContinuities: new Junction({
|
|
1708
|
-
between: [`continuity`, `action`],
|
|
1709
|
-
cardinality: `1:n`
|
|
1710
|
-
})
|
|
1711
|
-
};
|
|
1712
|
-
this.timelines = /* @__PURE__ */ new Map();
|
|
1713
|
-
this.timelineTopics = new Junction({
|
|
1714
|
-
between: [`timelineKey`, `topicKey`],
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
makeContentKey: (...keys) => keys.sort().join(`:`)
|
|
1704
|
+
}
|
|
1705
|
+
);
|
|
1706
|
+
trackers = /* @__PURE__ */ new Map();
|
|
1707
|
+
families = /* @__PURE__ */ new Map();
|
|
1708
|
+
transactions = /* @__PURE__ */ new Map();
|
|
1709
|
+
transactionMeta = {
|
|
1710
|
+
epoch: /* @__PURE__ */ new Map(),
|
|
1711
|
+
actionContinuities: new Junction({
|
|
1712
|
+
between: [`continuity`, `action`],
|
|
1715
1713
|
cardinality: `1:n`
|
|
1716
|
-
})
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1714
|
+
})
|
|
1715
|
+
};
|
|
1716
|
+
timelines = /* @__PURE__ */ new Map();
|
|
1717
|
+
timelineTopics = new Junction({
|
|
1718
|
+
between: [`timelineKey`, `topicKey`],
|
|
1719
|
+
cardinality: `1:n`
|
|
1720
|
+
});
|
|
1721
|
+
molecules = /* @__PURE__ */ new Map();
|
|
1722
|
+
moleculeFamilies = /* @__PURE__ */ new Map();
|
|
1723
|
+
moleculeInProgress = null;
|
|
1724
|
+
miscResources = /* @__PURE__ */ new Map();
|
|
1725
|
+
on = {
|
|
1726
|
+
atomCreation: new Subject(),
|
|
1727
|
+
atomDisposal: new Subject(),
|
|
1728
|
+
selectorCreation: new Subject(),
|
|
1729
|
+
selectorDisposal: new Subject(),
|
|
1730
|
+
timelineCreation: new Subject(),
|
|
1731
|
+
transactionCreation: new Subject(),
|
|
1732
|
+
transactionApplying: new StatefulSubject(
|
|
1733
|
+
null
|
|
1734
|
+
),
|
|
1735
|
+
operationClose: new Subject(),
|
|
1736
|
+
moleculeCreationStart: new Subject(),
|
|
1737
|
+
moleculeCreationDone: new Subject(),
|
|
1738
|
+
moleculeDisposal: new Subject()
|
|
1739
|
+
};
|
|
1740
|
+
operation = { open: false };
|
|
1741
|
+
config = {
|
|
1742
|
+
name: `IMPLICIT_STORE`,
|
|
1743
|
+
lifespan: `ephemeral`
|
|
1744
|
+
};
|
|
1745
|
+
loggers = [
|
|
1746
|
+
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
|
|
1747
|
+
];
|
|
1748
|
+
logger = {
|
|
1749
|
+
error: (...messages) => {
|
|
1750
|
+
for (const logger of this.loggers) logger.error(...messages);
|
|
1751
|
+
},
|
|
1752
|
+
info: (...messages) => {
|
|
1753
|
+
for (const logger of this.loggers) logger.info(...messages);
|
|
1754
|
+
},
|
|
1755
|
+
warn: (...messages) => {
|
|
1756
|
+
for (const logger of this.loggers) logger.warn(...messages);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
constructor(config, store = null) {
|
|
1737
1760
|
this.config = {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
};
|
|
1741
|
-
this.loggers = [
|
|
1742
|
-
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
|
|
1743
|
-
];
|
|
1744
|
-
this.logger = {
|
|
1745
|
-
error: (...messages) => {
|
|
1746
|
-
for (const logger of this.loggers) logger.error(...messages);
|
|
1747
|
-
},
|
|
1748
|
-
info: (...messages) => {
|
|
1749
|
-
for (const logger of this.loggers) logger.info(...messages);
|
|
1750
|
-
},
|
|
1751
|
-
warn: (...messages) => {
|
|
1752
|
-
for (const logger of this.loggers) logger.warn(...messages);
|
|
1753
|
-
}
|
|
1761
|
+
...store?.config,
|
|
1762
|
+
...config
|
|
1754
1763
|
};
|
|
1755
|
-
this.config = __spreadValues(__spreadValues({}, store == null ? void 0 : store.config), config);
|
|
1756
1764
|
if (store !== null) {
|
|
1757
|
-
this.valueMap = new Map(store
|
|
1758
|
-
this.operation =
|
|
1765
|
+
this.valueMap = new Map(store?.valueMap);
|
|
1766
|
+
this.operation = { ...store?.operation };
|
|
1759
1767
|
if (isRootStore(store)) {
|
|
1760
1768
|
this.transactionMeta = {
|
|
1761
|
-
epoch: new Map(store
|
|
1769
|
+
epoch: new Map(store?.transactionMeta.epoch),
|
|
1762
1770
|
actionContinuities: new Junction(
|
|
1763
|
-
store
|
|
1771
|
+
store?.transactionMeta.actionContinuities.toJSON()
|
|
1764
1772
|
)
|
|
1765
1773
|
};
|
|
1766
1774
|
}
|
|
@@ -1999,8 +2007,8 @@ var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
|
1999
2007
|
|
|
2000
2008
|
// internal/src/mutable/tracker.ts
|
|
2001
2009
|
var Tracker = class {
|
|
2010
|
+
Update;
|
|
2002
2011
|
initializeState(mutableState, store) {
|
|
2003
|
-
var _a;
|
|
2004
2012
|
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
2005
2013
|
store.atoms.delete(latestUpdateStateKey);
|
|
2006
2014
|
store.valueMap.delete(latestUpdateStateKey);
|
|
@@ -2016,12 +2024,14 @@ var Tracker = class {
|
|
|
2016
2024
|
familyMetaData,
|
|
2017
2025
|
store
|
|
2018
2026
|
);
|
|
2019
|
-
if (
|
|
2027
|
+
if (store.parent?.valueMap.has(latestUpdateStateKey)) {
|
|
2020
2028
|
const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
|
|
2021
2029
|
store.valueMap.set(latestUpdateStateKey, parentValue);
|
|
2022
2030
|
}
|
|
2023
2031
|
return latestUpdateState;
|
|
2024
2032
|
}
|
|
2033
|
+
unsubscribeFromInnerValue;
|
|
2034
|
+
unsubscribeFromState;
|
|
2025
2035
|
observeCore(mutableState, latestUpdateState, target) {
|
|
2026
2036
|
const subscriptionKey = `tracker:${target.config.name}:${isChildStore(target) ? target.transactionMeta.update.key : `main`}:${mutableState.key}`;
|
|
2027
2037
|
const originalInnerValue = getFromStore(mutableState, target);
|
|
@@ -2058,7 +2068,7 @@ var Tracker = class {
|
|
|
2058
2068
|
);
|
|
2059
2069
|
if (timelineId) {
|
|
2060
2070
|
const timelineData = target.timelines.get(timelineId);
|
|
2061
|
-
if (timelineData
|
|
2071
|
+
if (timelineData?.timeTraveling) {
|
|
2062
2072
|
const unsubscribe2 = subscribeToTimeline(
|
|
2063
2073
|
{ key: timelineId, type: `timeline` },
|
|
2064
2074
|
(update) => {
|
|
@@ -2110,6 +2120,9 @@ var Tracker = class {
|
|
|
2110
2120
|
target
|
|
2111
2121
|
);
|
|
2112
2122
|
}
|
|
2123
|
+
mutableState;
|
|
2124
|
+
latestUpdateState;
|
|
2125
|
+
dispose;
|
|
2113
2126
|
constructor(mutableState, store) {
|
|
2114
2127
|
this.mutableState = mutableState;
|
|
2115
2128
|
const target = newest(store);
|
|
@@ -2145,7 +2158,8 @@ function createMutableAtom(options, family, store) {
|
|
|
2145
2158
|
return deposit(existing);
|
|
2146
2159
|
}
|
|
2147
2160
|
const subject = new Subject();
|
|
2148
|
-
const newAtom =
|
|
2161
|
+
const newAtom = {
|
|
2162
|
+
...options,
|
|
2149
2163
|
type: `mutable_atom`,
|
|
2150
2164
|
install: (s) => {
|
|
2151
2165
|
s.logger.info(
|
|
@@ -2157,7 +2171,7 @@ function createMutableAtom(options, family, store) {
|
|
|
2157
2171
|
return createMutableAtom(options, family, s);
|
|
2158
2172
|
},
|
|
2159
2173
|
subject
|
|
2160
|
-
}
|
|
2174
|
+
};
|
|
2161
2175
|
if (family) {
|
|
2162
2176
|
newAtom.family = family;
|
|
2163
2177
|
}
|
|
@@ -2194,6 +2208,9 @@ function createMutableAtom(options, family, store) {
|
|
|
2194
2208
|
return token;
|
|
2195
2209
|
}
|
|
2196
2210
|
var FamilyTracker = class {
|
|
2211
|
+
Update;
|
|
2212
|
+
latestUpdateAtoms;
|
|
2213
|
+
mutableAtoms;
|
|
2197
2214
|
constructor(mutableAtoms, store) {
|
|
2198
2215
|
this.latestUpdateAtoms = createRegularAtomFamily(
|
|
2199
2216
|
{
|
|
@@ -2367,11 +2384,10 @@ var readCachedValue = (token, target) => {
|
|
|
2367
2384
|
return value;
|
|
2368
2385
|
};
|
|
2369
2386
|
var evictCachedValue = (key, target) => {
|
|
2370
|
-
var _a;
|
|
2371
2387
|
const currentValue = target.valueMap.get(key);
|
|
2372
2388
|
if (currentValue instanceof Future) {
|
|
2373
2389
|
const future = currentValue;
|
|
2374
|
-
const selector =
|
|
2390
|
+
const selector = target.selectors.get(key) ?? target.readonlySelectors.get(key);
|
|
2375
2391
|
if (selector) {
|
|
2376
2392
|
future.use(selector.get());
|
|
2377
2393
|
}
|
|
@@ -2419,7 +2435,8 @@ function createRegularAtom(options, family, store) {
|
|
|
2419
2435
|
return deposit(existing);
|
|
2420
2436
|
}
|
|
2421
2437
|
const subject = new Subject();
|
|
2422
|
-
const newAtom =
|
|
2438
|
+
const newAtom = {
|
|
2439
|
+
...options,
|
|
2423
2440
|
type: `atom`,
|
|
2424
2441
|
install: (s) => {
|
|
2425
2442
|
s.logger.info(
|
|
@@ -2431,7 +2448,7 @@ function createRegularAtom(options, family, store) {
|
|
|
2431
2448
|
return createRegularAtom(options, family, s);
|
|
2432
2449
|
},
|
|
2433
2450
|
subject
|
|
2434
|
-
}
|
|
2451
|
+
};
|
|
2435
2452
|
if (family) {
|
|
2436
2453
|
newAtom.family = family;
|
|
2437
2454
|
}
|
|
@@ -2482,7 +2499,6 @@ function createStandaloneAtom(options, store) {
|
|
|
2482
2499
|
|
|
2483
2500
|
// internal/src/atom/dispose-atom.ts
|
|
2484
2501
|
function disposeAtom(atomToken, store) {
|
|
2485
|
-
var _a, _b;
|
|
2486
2502
|
const target = newest(store);
|
|
2487
2503
|
const { key } = atomToken;
|
|
2488
2504
|
const atom = target.atoms.get(key);
|
|
@@ -2496,7 +2512,7 @@ function disposeAtom(atomToken, store) {
|
|
|
2496
2512
|
} else if (!atom.family) {
|
|
2497
2513
|
store.logger.error(`\u274C`, `atom`, key, `Standalone atoms cannot be disposed.`);
|
|
2498
2514
|
} else {
|
|
2499
|
-
|
|
2515
|
+
atom.cleanup?.();
|
|
2500
2516
|
const lastValue = store.valueMap.get(atom.key);
|
|
2501
2517
|
const family = withdraw({ key: atom.family.key, type: `atom_family` }, store);
|
|
2502
2518
|
family.subject.next({
|
|
@@ -2513,7 +2529,7 @@ function disposeAtom(atomToken, store) {
|
|
|
2513
2529
|
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
2514
2530
|
if (selectorKeys) {
|
|
2515
2531
|
for (const selectorKey of selectorKeys) {
|
|
2516
|
-
const token =
|
|
2532
|
+
const token = target.selectors.get(selectorKey) ?? target.readonlySelectors.get(selectorKey);
|
|
2517
2533
|
if (token) {
|
|
2518
2534
|
disposeSelector(token, store);
|
|
2519
2535
|
}
|
|
@@ -2539,20 +2555,19 @@ function disposeAtom(atomToken, store) {
|
|
|
2539
2555
|
}
|
|
2540
2556
|
}
|
|
2541
2557
|
function createTimeline(options, store, data) {
|
|
2542
|
-
|
|
2543
|
-
const tl = __spreadProps(__spreadValues({
|
|
2558
|
+
const tl = {
|
|
2544
2559
|
type: `timeline`,
|
|
2545
2560
|
key: options.key,
|
|
2546
2561
|
at: 0,
|
|
2547
2562
|
timeTraveling: null,
|
|
2548
2563
|
selectorTime: null,
|
|
2549
|
-
transactionKey: null
|
|
2550
|
-
|
|
2551
|
-
history:
|
|
2564
|
+
transactionKey: null,
|
|
2565
|
+
...data,
|
|
2566
|
+
history: data?.history.map((update) => ({ ...update })) ?? [],
|
|
2552
2567
|
install: (s) => createTimeline(options, s, tl),
|
|
2553
2568
|
subject: new Subject(),
|
|
2554
2569
|
subscriptions: /* @__PURE__ */ new Map()
|
|
2555
|
-
}
|
|
2570
|
+
};
|
|
2556
2571
|
if (options.shouldCapture) {
|
|
2557
2572
|
tl.shouldCapture = options.shouldCapture;
|
|
2558
2573
|
}
|
|
@@ -2650,11 +2665,10 @@ function addAtomToTimeline(atomToken, tl, store) {
|
|
|
2650
2665
|
tl.subscriptions.set(
|
|
2651
2666
|
atom.key,
|
|
2652
2667
|
atom.subject.subscribe(`timeline`, (update) => {
|
|
2653
|
-
var _a, _b, _c, _d, _e;
|
|
2654
2668
|
const target = newest(store);
|
|
2655
2669
|
const currentSelectorKey = store.operation.open && store.operation.token.type === `selector` ? store.operation.token.key : null;
|
|
2656
2670
|
const currentSelectorTime = store.operation.open && store.operation.token.type === `selector` ? store.operation.time : null;
|
|
2657
|
-
const txUpdateInProgress =
|
|
2671
|
+
const txUpdateInProgress = target.on.transactionApplying.state?.update;
|
|
2658
2672
|
store.logger.info(
|
|
2659
2673
|
`\u23F3`,
|
|
2660
2674
|
`timeline`,
|
|
@@ -2679,10 +2693,11 @@ function addAtomToTimeline(atomToken, tl, store) {
|
|
|
2679
2693
|
key: currentSelectorKey,
|
|
2680
2694
|
atomUpdates: []
|
|
2681
2695
|
};
|
|
2682
|
-
latestUpdate.atomUpdates.push(
|
|
2696
|
+
latestUpdate.atomUpdates.push({
|
|
2683
2697
|
key: atom.key,
|
|
2684
|
-
type: `atom_update
|
|
2685
|
-
|
|
2698
|
+
type: `atom_update`,
|
|
2699
|
+
...update
|
|
2700
|
+
});
|
|
2686
2701
|
if (tl.at !== tl.history.length) {
|
|
2687
2702
|
tl.history.splice(tl.at);
|
|
2688
2703
|
}
|
|
@@ -2697,22 +2712,23 @@ function addAtomToTimeline(atomToken, tl, store) {
|
|
|
2697
2712
|
tl.at = tl.history.length;
|
|
2698
2713
|
tl.selectorTime = currentSelectorTime;
|
|
2699
2714
|
} else {
|
|
2700
|
-
if (
|
|
2701
|
-
latestUpdate.atomUpdates.push(
|
|
2715
|
+
if (latestUpdate?.type === `selector_update`) {
|
|
2716
|
+
latestUpdate.atomUpdates.push({
|
|
2702
2717
|
key: atom.key,
|
|
2703
|
-
type: `atom_update
|
|
2704
|
-
|
|
2718
|
+
type: `atom_update`,
|
|
2719
|
+
...update
|
|
2720
|
+
});
|
|
2705
2721
|
store.logger.info(
|
|
2706
2722
|
`\u231B`,
|
|
2707
2723
|
`timeline`,
|
|
2708
2724
|
tl.key,
|
|
2709
2725
|
`set selector_update "${currentSelectorKey}" to`,
|
|
2710
|
-
latestUpdate
|
|
2726
|
+
latestUpdate?.atomUpdates.map((atomUpdate) => atomUpdate.key)
|
|
2711
2727
|
);
|
|
2712
2728
|
}
|
|
2713
2729
|
}
|
|
2714
2730
|
if (latestUpdate) {
|
|
2715
|
-
const willCaptureSelectorUpdate =
|
|
2731
|
+
const willCaptureSelectorUpdate = tl.shouldCapture?.(latestUpdate, tl) ?? true;
|
|
2716
2732
|
if (willCaptureSelectorUpdate) {
|
|
2717
2733
|
tl.subject.next(latestUpdate);
|
|
2718
2734
|
} else {
|
|
@@ -2736,7 +2752,7 @@ function addAtomToTimeline(atomToken, tl, store) {
|
|
|
2736
2752
|
if (atom.family) {
|
|
2737
2753
|
atomUpdate.family = atom.family;
|
|
2738
2754
|
}
|
|
2739
|
-
const willCapture =
|
|
2755
|
+
const willCapture = tl.shouldCapture?.(atomUpdate, tl) ?? true;
|
|
2740
2756
|
store.logger.info(
|
|
2741
2757
|
`\u231B`,
|
|
2742
2758
|
`timeline`,
|
|
@@ -2754,7 +2770,6 @@ function addAtomToTimeline(atomToken, tl, store) {
|
|
|
2754
2770
|
);
|
|
2755
2771
|
}
|
|
2756
2772
|
function addAtomFamilyToTimeline(atomFamilyToken, tl, store) {
|
|
2757
|
-
var _a;
|
|
2758
2773
|
const family = withdraw(atomFamilyToken, store);
|
|
2759
2774
|
store.timelineTopics.set(
|
|
2760
2775
|
{ topicKey: family.key, timelineKey: tl.key },
|
|
@@ -2767,7 +2782,7 @@ function addAtomFamilyToTimeline(atomFamilyToken, tl, store) {
|
|
|
2767
2782
|
})
|
|
2768
2783
|
);
|
|
2769
2784
|
for (const atom of store.atoms.values()) {
|
|
2770
|
-
if (
|
|
2785
|
+
if (atom.family?.key === family.key) {
|
|
2771
2786
|
addAtomToTimeline(atom, tl, store);
|
|
2772
2787
|
}
|
|
2773
2788
|
}
|
|
@@ -2782,7 +2797,6 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
|
|
|
2782
2797
|
tl.subscriptions.set(
|
|
2783
2798
|
familyToken.key,
|
|
2784
2799
|
family.subject.subscribe(`timeline:${tl.key}`, (creationOrDisposal) => {
|
|
2785
|
-
var _a, _b, _c, _d;
|
|
2786
2800
|
store.logger.info(
|
|
2787
2801
|
`\u{1F41E}`,
|
|
2788
2802
|
`timeline`,
|
|
@@ -2800,7 +2814,7 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
|
|
|
2800
2814
|
},
|
|
2801
2815
|
{ topicType: `molecule` }
|
|
2802
2816
|
);
|
|
2803
|
-
const txUpdateInProgress =
|
|
2817
|
+
const txUpdateInProgress = newest(store).on.transactionApplying.state?.update;
|
|
2804
2818
|
if (txUpdateInProgress) {
|
|
2805
2819
|
joinTransaction(tl, txUpdateInProgress, store);
|
|
2806
2820
|
} else if (tl.timeTraveling === null) {
|
|
@@ -2833,7 +2847,7 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
|
|
|
2833
2847
|
break;
|
|
2834
2848
|
case `molecule_disposal`:
|
|
2835
2849
|
{
|
|
2836
|
-
const txUpdateInProgress =
|
|
2850
|
+
const txUpdateInProgress = newest(store).on.transactionApplying.state?.update;
|
|
2837
2851
|
if (txUpdateInProgress) {
|
|
2838
2852
|
joinTransaction(tl, txUpdateInProgress, store);
|
|
2839
2853
|
} else if (tl.timeTraveling === null) {
|
|
@@ -2845,11 +2859,11 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
|
|
|
2845
2859
|
tl.subject.next(event);
|
|
2846
2860
|
}
|
|
2847
2861
|
const moleculeKey = creationOrDisposal.token.key;
|
|
2848
|
-
|
|
2862
|
+
tl.subscriptions.get(moleculeKey)?.();
|
|
2849
2863
|
tl.subscriptions.delete(moleculeKey);
|
|
2850
2864
|
for (const [familyKey] of creationOrDisposal.values) {
|
|
2851
2865
|
const stateKey = `${familyKey}(${stringifyJson(moleculeKey)})`;
|
|
2852
|
-
|
|
2866
|
+
tl.subscriptions.get(stateKey)?.();
|
|
2853
2867
|
tl.subscriptions.delete(stateKey);
|
|
2854
2868
|
store.timelineTopics.delete(stateKey);
|
|
2855
2869
|
}
|
|
@@ -2873,7 +2887,6 @@ function joinTransaction(tl, txUpdateInProgress, store) {
|
|
|
2873
2887
|
const unsubscribe = currentTransaction.subject.subscribe(
|
|
2874
2888
|
`timeline:${tl.key}`,
|
|
2875
2889
|
(transactionUpdate) => {
|
|
2876
|
-
var _a, _b;
|
|
2877
2890
|
unsubscribe();
|
|
2878
2891
|
tl.transactionKey = null;
|
|
2879
2892
|
if (tl.timeTraveling === null && currentTxInstanceId) {
|
|
@@ -2885,12 +2898,12 @@ function joinTransaction(tl, txUpdateInProgress, store) {
|
|
|
2885
2898
|
transactionUpdate.updates,
|
|
2886
2899
|
timelineTopics
|
|
2887
2900
|
);
|
|
2888
|
-
const timelineTransactionUpdate =
|
|
2889
|
-
timestamp: Date.now()
|
|
2890
|
-
|
|
2901
|
+
const timelineTransactionUpdate = {
|
|
2902
|
+
timestamp: Date.now(),
|
|
2903
|
+
...transactionUpdate,
|
|
2891
2904
|
updates
|
|
2892
|
-
}
|
|
2893
|
-
const willCapture =
|
|
2905
|
+
};
|
|
2906
|
+
const willCapture = tl.shouldCapture?.(timelineTransactionUpdate, tl) ?? true;
|
|
2894
2907
|
if (willCapture) {
|
|
2895
2908
|
tl.history.push(timelineTransactionUpdate);
|
|
2896
2909
|
tl.at = tl.history.length;
|
|
@@ -2921,24 +2934,24 @@ function filterTransactionUpdates(updates, timelineTopics) {
|
|
|
2921
2934
|
return timelineTopics.has(key);
|
|
2922
2935
|
}).map((updateFromTx) => {
|
|
2923
2936
|
if (`updates` in updateFromTx) {
|
|
2924
|
-
return
|
|
2937
|
+
return {
|
|
2938
|
+
...updateFromTx,
|
|
2925
2939
|
updates: filterTransactionUpdates(
|
|
2926
2940
|
updateFromTx.updates,
|
|
2927
2941
|
timelineTopics
|
|
2928
2942
|
)
|
|
2929
|
-
}
|
|
2943
|
+
};
|
|
2930
2944
|
}
|
|
2931
2945
|
return updateFromTx;
|
|
2932
2946
|
});
|
|
2933
2947
|
}
|
|
2934
2948
|
function handleStateLifecycleEvent(event, tl, store) {
|
|
2935
|
-
var _a, _b;
|
|
2936
2949
|
const timestamp = Date.now();
|
|
2937
2950
|
const timelineEvent = Object.assign(event, {
|
|
2938
2951
|
timestamp
|
|
2939
2952
|
});
|
|
2940
2953
|
if (!tl.timeTraveling) {
|
|
2941
|
-
const txUpdateInProgress =
|
|
2954
|
+
const txUpdateInProgress = newest(store).on.transactionApplying.state?.update;
|
|
2942
2955
|
if (txUpdateInProgress) {
|
|
2943
2956
|
joinTransaction(tl, txUpdateInProgress, store);
|
|
2944
2957
|
} else {
|
|
@@ -2952,7 +2965,7 @@ function handleStateLifecycleEvent(event, tl, store) {
|
|
|
2952
2965
|
addAtomToTimeline(event.token, tl, store);
|
|
2953
2966
|
break;
|
|
2954
2967
|
case `state_disposal`:
|
|
2955
|
-
|
|
2968
|
+
tl.subscriptions.get(event.token.key)?.();
|
|
2956
2969
|
tl.subscriptions.delete(event.token.key);
|
|
2957
2970
|
break;
|
|
2958
2971
|
}
|