flightdeck 0.2.16 → 0.2.17
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.
|
@@ -218,9 +218,8 @@ function createReadonlySelectorFamily(store, options, internalRoles) {
|
|
|
218
218
|
default: (key) => {
|
|
219
219
|
const getFn = options.get(key);
|
|
220
220
|
return getFn({
|
|
221
|
-
get: (...
|
|
222
|
-
find: (
|
|
223
|
-
seek: (token, k) => seekInStore(store, token, k),
|
|
221
|
+
get: (...args) => getFromStore(store, ...args),
|
|
222
|
+
find: (...args) => findInStore(store, ...args),
|
|
224
223
|
json: (token) => getJsonToken(store, token)
|
|
225
224
|
});
|
|
226
225
|
}
|
|
@@ -314,6 +313,22 @@ function atomFamily(options) {
|
|
|
314
313
|
return createAtomFamily(IMPLICIT.STORE, options);
|
|
315
314
|
}
|
|
316
315
|
|
|
316
|
+
// ../atom.io/src/join.ts
|
|
317
|
+
function join(options, defaultContent, store = IMPLICIT.STORE) {
|
|
318
|
+
store.joins.set(options.key, new Join(options, defaultContent, store));
|
|
319
|
+
const token = {
|
|
320
|
+
key: options.key,
|
|
321
|
+
type: `join`,
|
|
322
|
+
a: options.between[0],
|
|
323
|
+
b: options.between[1],
|
|
324
|
+
cardinality: options.cardinality
|
|
325
|
+
};
|
|
326
|
+
return token;
|
|
327
|
+
}
|
|
328
|
+
function getInternalRelations(token) {
|
|
329
|
+
return getInternalRelationsFromStore(token, IMPLICIT.STORE);
|
|
330
|
+
}
|
|
331
|
+
|
|
317
332
|
// ../atom.io/src/logger.ts
|
|
318
333
|
var simpleLog = (logLevel) => (icon, denomination, tokenKey, message, ...rest) => {
|
|
319
334
|
console[logLevel](
|
|
@@ -429,8 +444,12 @@ var abortTransaction = (store) => {
|
|
|
429
444
|
target.parent.child = null;
|
|
430
445
|
};
|
|
431
446
|
|
|
447
|
+
// ../atom.io/internal/src/capitalize.ts
|
|
448
|
+
function capitalize(string) {
|
|
449
|
+
return string[0].toUpperCase() + string.slice(1);
|
|
450
|
+
}
|
|
451
|
+
|
|
432
452
|
// ../atom.io/internal/src/pretty-print.ts
|
|
433
|
-
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
434
453
|
function prettyPrintTokenType(token) {
|
|
435
454
|
return token.type.split(`_`).map(capitalize).join(` `);
|
|
436
455
|
}
|
|
@@ -445,9 +464,9 @@ var NotFoundError = class extends Error {
|
|
|
445
464
|
};
|
|
446
465
|
|
|
447
466
|
// ../atom.io/internal/src/transaction/act-upon-store.ts
|
|
448
|
-
function actUponStore(token, id
|
|
467
|
+
function actUponStore(store, token, id) {
|
|
449
468
|
return (...parameters) => {
|
|
450
|
-
const tx = withdraw(
|
|
469
|
+
const tx = withdraw(store, token);
|
|
451
470
|
if (tx) {
|
|
452
471
|
return tx.run(parameters, id);
|
|
453
472
|
}
|
|
@@ -459,7 +478,7 @@ function actUponStore(token, id, store) {
|
|
|
459
478
|
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(originalThing) : nextVersionOfThing;
|
|
460
479
|
|
|
461
480
|
// ../atom.io/internal/src/get-state/read-or-compute-value.ts
|
|
462
|
-
var readOrComputeValue = (
|
|
481
|
+
var readOrComputeValue = (target, state) => {
|
|
463
482
|
if (target.valueMap.has(state.key)) {
|
|
464
483
|
target.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
|
|
465
484
|
return readCachedValue(state, target);
|
|
@@ -543,7 +562,7 @@ var markDone = (store, key) => {
|
|
|
543
562
|
};
|
|
544
563
|
|
|
545
564
|
// ../atom.io/internal/src/set-state/emit-update.ts
|
|
546
|
-
var emitUpdate = (state, update
|
|
565
|
+
var emitUpdate = (store, state, update) => {
|
|
547
566
|
switch (state.type) {
|
|
548
567
|
case `mutable_atom`:
|
|
549
568
|
store.logger.info(
|
|
@@ -573,7 +592,7 @@ var emitUpdate = (state, update, store) => {
|
|
|
573
592
|
};
|
|
574
593
|
|
|
575
594
|
// ../atom.io/internal/src/set-state/evict-downstream.ts
|
|
576
|
-
var evictDownStream = (
|
|
595
|
+
var evictDownStream = (store, atom2) => {
|
|
577
596
|
const target = newest(store);
|
|
578
597
|
const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom2.key);
|
|
579
598
|
target.logger.info(
|
|
@@ -612,7 +631,7 @@ function shouldUpdateBeStowed(key, update) {
|
|
|
612
631
|
}
|
|
613
632
|
return true;
|
|
614
633
|
}
|
|
615
|
-
var stowUpdate = (state, update
|
|
634
|
+
var stowUpdate = (store, state, update) => {
|
|
616
635
|
const { key } = state;
|
|
617
636
|
const target = newest(store);
|
|
618
637
|
if (!isChildStore(target) || target.transactionMeta.phase !== `building`) {
|
|
@@ -651,44 +670,44 @@ var stowUpdate = (state, update, store) => {
|
|
|
651
670
|
|
|
652
671
|
// ../atom.io/internal/src/set-state/set-atom.ts
|
|
653
672
|
var setAtom = (atom2, next, target) => {
|
|
654
|
-
const oldValue = readOrComputeValue(
|
|
673
|
+
const oldValue = readOrComputeValue(target, atom2);
|
|
655
674
|
let newValue = oldValue;
|
|
656
675
|
if (atom2.type === `mutable_atom` && isChildStore(target)) {
|
|
657
676
|
const { parent } = target;
|
|
658
|
-
const copiedValue = copyMutableIfNeeded(atom2, parent
|
|
677
|
+
const copiedValue = copyMutableIfNeeded(target, atom2, parent);
|
|
659
678
|
newValue = copiedValue;
|
|
660
679
|
}
|
|
661
680
|
newValue = become(next)(newValue);
|
|
662
681
|
target.logger.info(`\u{1F4DD}`, `atom`, atom2.key, `set to`, newValue);
|
|
663
|
-
newValue = cacheValue(atom2.key, newValue, atom2.subject
|
|
664
|
-
if (isAtomDefault(atom2.key
|
|
665
|
-
markAtomAsNotDefault(atom2.key
|
|
682
|
+
newValue = cacheValue(target, atom2.key, newValue, atom2.subject);
|
|
683
|
+
if (isAtomDefault(target, atom2.key)) {
|
|
684
|
+
markAtomAsNotDefault(target, atom2.key);
|
|
666
685
|
}
|
|
667
686
|
markDone(target, atom2.key);
|
|
668
|
-
evictDownStream(
|
|
687
|
+
evictDownStream(target, atom2);
|
|
669
688
|
const update = { oldValue, newValue };
|
|
670
689
|
if (isRootStore(target)) {
|
|
671
|
-
emitUpdate(atom2, update
|
|
690
|
+
emitUpdate(target, atom2, update);
|
|
672
691
|
} else if (target.parent) {
|
|
673
692
|
if (target.on.transactionApplying.state === null) {
|
|
674
|
-
stowUpdate(atom2, update
|
|
693
|
+
stowUpdate(target, atom2, update);
|
|
675
694
|
} else if (atom2.key.startsWith(`*`)) {
|
|
676
695
|
const mutableKey = atom2.key.slice(1);
|
|
677
696
|
const mutableAtom = target.atoms.get(mutableKey);
|
|
678
697
|
let transceiver = target.valueMap.get(mutableKey);
|
|
679
698
|
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
680
699
|
const { parent } = target;
|
|
681
|
-
const copiedValue = copyMutableIfNeeded(mutableAtom, parent
|
|
700
|
+
const copiedValue = copyMutableIfNeeded(target, mutableAtom, parent);
|
|
682
701
|
transceiver = copiedValue;
|
|
683
702
|
}
|
|
684
703
|
const accepted = transceiver.do(update.newValue) === null;
|
|
685
|
-
if (accepted) evictDownStream(
|
|
704
|
+
if (accepted) evictDownStream(target, mutableAtom);
|
|
686
705
|
}
|
|
687
706
|
}
|
|
688
707
|
};
|
|
689
708
|
|
|
690
709
|
// ../atom.io/internal/src/set-state/set-atom-or-selector.ts
|
|
691
|
-
var setAtomOrSelector = (state, value
|
|
710
|
+
var setAtomOrSelector = (store, state, value) => {
|
|
692
711
|
switch (state.type) {
|
|
693
712
|
case `atom`:
|
|
694
713
|
case `mutable_atom`:
|
|
@@ -762,8 +781,8 @@ ${disposal.trace}` : `No previous disposal trace was found.`
|
|
|
762
781
|
);
|
|
763
782
|
return;
|
|
764
783
|
}
|
|
765
|
-
const state = withdraw(
|
|
766
|
-
setAtomOrSelector(state, value
|
|
784
|
+
const state = withdraw(store, token);
|
|
785
|
+
setAtomOrSelector(store, state, value);
|
|
767
786
|
closeOperation(store);
|
|
768
787
|
}
|
|
769
788
|
|
|
@@ -1137,7 +1156,7 @@ function ingestTransactionUpdate(applying, transactionUpdate, store) {
|
|
|
1137
1156
|
}
|
|
1138
1157
|
|
|
1139
1158
|
// ../atom.io/internal/src/transaction/set-epoch-number.ts
|
|
1140
|
-
function setEpochNumberOfAction(transactionKey, newEpoch
|
|
1159
|
+
function setEpochNumberOfAction(store, transactionKey, newEpoch) {
|
|
1141
1160
|
const isRoot = isRootStore(store);
|
|
1142
1161
|
if (!isRoot) {
|
|
1143
1162
|
return;
|
|
@@ -1176,14 +1195,14 @@ var applyTransaction = (output, store) => {
|
|
|
1176
1195
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
1177
1196
|
if (isRootStore(parent)) {
|
|
1178
1197
|
setEpochNumberOfAction(
|
|
1198
|
+
parent,
|
|
1179
1199
|
child.transactionMeta.update.key,
|
|
1180
|
-
child.transactionMeta.update.epoch
|
|
1181
|
-
parent
|
|
1182
|
-
);
|
|
1183
|
-
const myTransaction = withdraw(
|
|
1184
|
-
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
1185
|
-
store
|
|
1200
|
+
child.transactionMeta.update.epoch
|
|
1186
1201
|
);
|
|
1202
|
+
const myTransaction = withdraw(store, {
|
|
1203
|
+
key: child.transactionMeta.update.key,
|
|
1204
|
+
type: `transaction`
|
|
1205
|
+
});
|
|
1187
1206
|
myTransaction?.subject.next(child.transactionMeta.update);
|
|
1188
1207
|
store.logger.info(
|
|
1189
1208
|
`\u{1F6EC}`,
|
|
@@ -1239,13 +1258,13 @@ ${disposal.trace}` : `No previous disposal trace was found.`
|
|
|
1239
1258
|
if (store.defaults.has(family.key)) {
|
|
1240
1259
|
return store.defaults.get(token.family.key);
|
|
1241
1260
|
}
|
|
1242
|
-
const defaultValue = withdraw(
|
|
1261
|
+
const defaultValue = withdraw(store, family).default(subKey);
|
|
1243
1262
|
store.defaults.set(family.key, defaultValue);
|
|
1244
1263
|
return defaultValue;
|
|
1245
1264
|
}
|
|
1246
1265
|
}
|
|
1247
1266
|
}
|
|
1248
|
-
return readOrComputeValue(withdraw(
|
|
1267
|
+
return readOrComputeValue(store, withdraw(store, token));
|
|
1249
1268
|
}
|
|
1250
1269
|
|
|
1251
1270
|
// ../atom.io/internal/src/junction.ts
|
|
@@ -1594,7 +1613,7 @@ var LazyMap = class extends Map {
|
|
|
1594
1613
|
};
|
|
1595
1614
|
|
|
1596
1615
|
// ../atom.io/internal/src/transaction/build-transaction.ts
|
|
1597
|
-
var buildTransaction = (key, params,
|
|
1616
|
+
var buildTransaction = (store, key, params, id) => {
|
|
1598
1617
|
const parent = newest(store);
|
|
1599
1618
|
const childBase = {
|
|
1600
1619
|
parent,
|
|
@@ -1633,7 +1652,7 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
1633
1652
|
}),
|
|
1634
1653
|
miscResources: new LazyMap(parent.miscResources)
|
|
1635
1654
|
};
|
|
1636
|
-
const epoch = getEpochNumberOfAction(
|
|
1655
|
+
const epoch = getEpochNumberOfAction(store, key);
|
|
1637
1656
|
const transactionMeta = {
|
|
1638
1657
|
phase: `building`,
|
|
1639
1658
|
update: {
|
|
@@ -1650,9 +1669,8 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
1650
1669
|
set: (...ps) => {
|
|
1651
1670
|
setIntoStore(child, ...ps);
|
|
1652
1671
|
},
|
|
1653
|
-
run: (token, identifier = arbitrary()) => actUponStore(token, identifier
|
|
1672
|
+
run: (token, identifier = arbitrary()) => actUponStore(child, token, identifier),
|
|
1654
1673
|
find: (token, k) => findInStore(child, token, k),
|
|
1655
|
-
seek: (token, k) => seekInStore(child, token, k),
|
|
1656
1674
|
json: (token) => getJsonToken(child, token),
|
|
1657
1675
|
dispose: (...ps) => {
|
|
1658
1676
|
disposeFromStore(child, ...ps);
|
|
@@ -1675,12 +1693,12 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
1675
1693
|
};
|
|
1676
1694
|
|
|
1677
1695
|
// ../atom.io/internal/src/transaction/create-transaction.ts
|
|
1678
|
-
function createTransaction(
|
|
1696
|
+
function createTransaction(store, options) {
|
|
1679
1697
|
const newTransaction = {
|
|
1680
1698
|
key: options.key,
|
|
1681
1699
|
type: `transaction`,
|
|
1682
1700
|
run: (params, id) => {
|
|
1683
|
-
const childStore = buildTransaction(options.key, params,
|
|
1701
|
+
const childStore = buildTransaction(store, options.key, params, id);
|
|
1684
1702
|
try {
|
|
1685
1703
|
const target2 = newest(store);
|
|
1686
1704
|
const { toolkit } = childStore.transactionMeta;
|
|
@@ -1693,7 +1711,7 @@ function createTransaction(options, store) {
|
|
|
1693
1711
|
throw thrown;
|
|
1694
1712
|
}
|
|
1695
1713
|
},
|
|
1696
|
-
install: (s) => createTransaction(
|
|
1714
|
+
install: (s) => createTransaction(s, options),
|
|
1697
1715
|
subject: new Subject()
|
|
1698
1716
|
};
|
|
1699
1717
|
const target = newest(store);
|
|
@@ -1704,7 +1722,7 @@ function createTransaction(options, store) {
|
|
|
1704
1722
|
}
|
|
1705
1723
|
|
|
1706
1724
|
// ../atom.io/internal/src/transaction/get-epoch-number.ts
|
|
1707
|
-
function getEpochNumberOfAction(
|
|
1725
|
+
function getEpochNumberOfAction(store, transactionKey) {
|
|
1708
1726
|
const isRoot = isRootStore(store);
|
|
1709
1727
|
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : undefined;
|
|
1710
1728
|
const epoch = isRoot && continuity !== undefined ? store.transactionMeta.epoch.get(continuity) : undefined;
|
|
@@ -1713,7 +1731,7 @@ function getEpochNumberOfAction(transactionKey, store) {
|
|
|
1713
1731
|
|
|
1714
1732
|
// ../atom.io/src/transaction.ts
|
|
1715
1733
|
function transaction(options) {
|
|
1716
|
-
return createTransaction(
|
|
1734
|
+
return createTransaction(IMPLICIT.STORE, options);
|
|
1717
1735
|
}
|
|
1718
1736
|
|
|
1719
1737
|
// ../atom.io/internal/src/store/store.ts
|
|
@@ -1884,7 +1902,7 @@ var IMPLICIT = {
|
|
|
1884
1902
|
};
|
|
1885
1903
|
|
|
1886
1904
|
// ../atom.io/internal/src/store/withdraw.ts
|
|
1887
|
-
function withdraw(
|
|
1905
|
+
function withdraw(store, token) {
|
|
1888
1906
|
let withdrawn;
|
|
1889
1907
|
let target = store;
|
|
1890
1908
|
while (target !== null) {
|
|
@@ -2012,40 +2030,37 @@ function disposeFromStore(store, ...params) {
|
|
|
2012
2030
|
token = maybeToken;
|
|
2013
2031
|
}
|
|
2014
2032
|
try {
|
|
2015
|
-
withdraw(
|
|
2033
|
+
withdraw(store, token);
|
|
2016
2034
|
} catch (thrown) {
|
|
2017
2035
|
store.logger.error(
|
|
2018
2036
|
`\u274C`,
|
|
2019
2037
|
token.type,
|
|
2020
2038
|
token.key,
|
|
2021
2039
|
`could not be disposed because it was not found in the store "${store.config.name}".`
|
|
2022
|
-
// disposal
|
|
2023
|
-
// ? `\n This state was most recently disposed\n${disposal.trace}`
|
|
2024
|
-
// : `No previous disposal trace was found.`,
|
|
2025
2040
|
);
|
|
2026
2041
|
return;
|
|
2027
2042
|
}
|
|
2028
2043
|
switch (token.type) {
|
|
2029
2044
|
case `atom`:
|
|
2030
2045
|
case `mutable_atom`:
|
|
2031
|
-
disposeAtom(
|
|
2046
|
+
disposeAtom(store, token);
|
|
2032
2047
|
break;
|
|
2033
2048
|
case `selector`:
|
|
2034
2049
|
case `readonly_selector`:
|
|
2035
|
-
disposeSelector(
|
|
2050
|
+
disposeSelector(store, token);
|
|
2036
2051
|
break;
|
|
2037
2052
|
}
|
|
2038
2053
|
}
|
|
2039
2054
|
|
|
2040
2055
|
// ../atom.io/internal/src/keys.ts
|
|
2041
|
-
var isAtomKey = (
|
|
2042
|
-
var isSelectorKey = (
|
|
2043
|
-
var isReadonlySelectorKey = (
|
|
2044
|
-
var isStateKey = (
|
|
2056
|
+
var isAtomKey = (store, key) => newest(store).atoms.has(key);
|
|
2057
|
+
var isSelectorKey = (store, key) => newest(store).selectors.has(key);
|
|
2058
|
+
var isReadonlySelectorKey = (store, key) => newest(store).readonlySelectors.has(key);
|
|
2059
|
+
var isStateKey = (store, key) => isAtomKey(store, key) || isSelectorKey(store, key) || isReadonlySelectorKey(store, key);
|
|
2045
2060
|
|
|
2046
2061
|
// ../atom.io/internal/src/selector/get-selector-dependency-keys.ts
|
|
2047
2062
|
var getSelectorDependencyKeys = (key, store) => {
|
|
2048
|
-
const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(
|
|
2063
|
+
const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(store, source));
|
|
2049
2064
|
return sources;
|
|
2050
2065
|
};
|
|
2051
2066
|
|
|
@@ -2062,7 +2077,7 @@ var traceSelectorAtoms = (directDependencyKey, covered, store) => {
|
|
|
2062
2077
|
continue;
|
|
2063
2078
|
}
|
|
2064
2079
|
covered.add(indirectDependencyKey);
|
|
2065
|
-
if (!isAtomKey(
|
|
2080
|
+
if (!isAtomKey(store, indirectDependencyKey)) {
|
|
2066
2081
|
indirectDependencyKeys.push(
|
|
2067
2082
|
...getSelectorDependencyKeys(indirectDependencyKey, store)
|
|
2068
2083
|
);
|
|
@@ -2077,7 +2092,7 @@ var traceAllSelectorAtoms = (selector, store) => {
|
|
|
2077
2092
|
const directDependencyKeys = getSelectorDependencyKeys(selectorKey, store);
|
|
2078
2093
|
const covered = /* @__PURE__ */ new Set();
|
|
2079
2094
|
return directDependencyKeys.flatMap(
|
|
2080
|
-
(depKey) => isAtomKey(
|
|
2095
|
+
(depKey) => isAtomKey(store, depKey) ? depKey : traceSelectorAtoms(depKey, covered, store)
|
|
2081
2096
|
);
|
|
2082
2097
|
};
|
|
2083
2098
|
|
|
@@ -2124,8 +2139,8 @@ var registerSelector = (selectorKey, covered, store) => ({
|
|
|
2124
2139
|
} else {
|
|
2125
2140
|
[dependency] = params;
|
|
2126
2141
|
}
|
|
2127
|
-
const dependencyState = withdraw(
|
|
2128
|
-
const dependencyValue = readOrComputeValue(
|
|
2142
|
+
const dependencyState = withdraw(store, dependency);
|
|
2143
|
+
const dependencyValue = readOrComputeValue(store, dependencyState);
|
|
2129
2144
|
store.logger.info(
|
|
2130
2145
|
`\u{1F50C}`,
|
|
2131
2146
|
`selector`,
|
|
@@ -2159,11 +2174,10 @@ var registerSelector = (selectorKey, covered, store) => ({
|
|
|
2159
2174
|
token = findInStore(store, family, key);
|
|
2160
2175
|
}
|
|
2161
2176
|
const target = newest(store);
|
|
2162
|
-
const state = withdraw(
|
|
2163
|
-
setAtomOrSelector(state, value
|
|
2177
|
+
const state = withdraw(target, token);
|
|
2178
|
+
setAtomOrSelector(target, state, value);
|
|
2164
2179
|
},
|
|
2165
2180
|
find: (token, key) => findInStore(store, token, key),
|
|
2166
|
-
seek: (token, key) => seekInStore(store, token, key),
|
|
2167
2181
|
json: (token) => getJsonToken(store, token)
|
|
2168
2182
|
});
|
|
2169
2183
|
|
|
@@ -2172,14 +2186,10 @@ var createReadonlySelector = (store, options, family) => {
|
|
|
2172
2186
|
const target = newest(store);
|
|
2173
2187
|
const subject = new Subject();
|
|
2174
2188
|
const covered = /* @__PURE__ */ new Set();
|
|
2175
|
-
const { get, find,
|
|
2176
|
-
options.key,
|
|
2177
|
-
covered,
|
|
2178
|
-
target
|
|
2179
|
-
);
|
|
2189
|
+
const { get, find, json } = registerSelector(options.key, covered, target);
|
|
2180
2190
|
const getSelf = () => {
|
|
2181
|
-
const value = options.get({ get, find,
|
|
2182
|
-
cacheValue(options.key, value, subject
|
|
2191
|
+
const value = options.get({ get, find, json });
|
|
2192
|
+
cacheValue(newest(store), options.key, value, subject);
|
|
2183
2193
|
covered.clear();
|
|
2184
2194
|
return value;
|
|
2185
2195
|
};
|
|
@@ -2216,11 +2226,11 @@ var createWritableSelector = (store, options, family) => {
|
|
|
2216
2226
|
const subject = new Subject();
|
|
2217
2227
|
const covered = /* @__PURE__ */ new Set();
|
|
2218
2228
|
const setterToolkit = registerSelector(options.key, covered, target);
|
|
2219
|
-
const { find, get,
|
|
2220
|
-
const getterToolkit = { find, get,
|
|
2229
|
+
const { find, get, json } = setterToolkit;
|
|
2230
|
+
const getterToolkit = { find, get, json };
|
|
2221
2231
|
const getSelf = (getFn = options.get, innerTarget = newest(store)) => {
|
|
2222
2232
|
const value = getFn(getterToolkit);
|
|
2223
|
-
cacheValue(options.key, value, subject
|
|
2233
|
+
cacheValue(innerTarget, options.key, value, subject);
|
|
2224
2234
|
covered.clear();
|
|
2225
2235
|
return value;
|
|
2226
2236
|
};
|
|
@@ -2238,7 +2248,7 @@ var createWritableSelector = (store, options, family) => {
|
|
|
2238
2248
|
newValue,
|
|
2239
2249
|
`)`
|
|
2240
2250
|
);
|
|
2241
|
-
cacheValue(options.key, newValue, subject
|
|
2251
|
+
cacheValue(innerTarget, options.key, newValue, subject);
|
|
2242
2252
|
markDone(innerTarget, options.key);
|
|
2243
2253
|
if (isRootStore(innerTarget)) {
|
|
2244
2254
|
subject.next({ newValue, oldValue });
|
|
@@ -2281,10 +2291,10 @@ function createStandaloneSelector(store, options) {
|
|
|
2281
2291
|
}
|
|
2282
2292
|
|
|
2283
2293
|
// ../atom.io/internal/src/selector/dispose-selector.ts
|
|
2284
|
-
function disposeSelector(
|
|
2294
|
+
function disposeSelector(store, selectorToken) {
|
|
2285
2295
|
const target = newest(store);
|
|
2286
2296
|
const { key } = selectorToken;
|
|
2287
|
-
const selector = withdraw(
|
|
2297
|
+
const selector = withdraw(target, selectorToken);
|
|
2288
2298
|
if (!selector.family) {
|
|
2289
2299
|
store.logger.error(
|
|
2290
2300
|
`\u274C`,
|
|
@@ -2297,23 +2307,31 @@ function disposeSelector(selectorToken, store) {
|
|
|
2297
2307
|
if (molecule) {
|
|
2298
2308
|
target.moleculeData.delete(selector.family.subKey, selector.family.key);
|
|
2299
2309
|
}
|
|
2310
|
+
let familyToken;
|
|
2300
2311
|
switch (selectorToken.type) {
|
|
2301
2312
|
case `selector`:
|
|
2302
2313
|
{
|
|
2303
2314
|
target.selectors.delete(key);
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2315
|
+
familyToken = {
|
|
2316
|
+
key: selector.family.key,
|
|
2317
|
+
type: `selector_family`
|
|
2318
|
+
};
|
|
2319
|
+
const family = withdraw(store, familyToken);
|
|
2320
|
+
family.subject.next({
|
|
2321
|
+
type: `state_disposal`,
|
|
2322
|
+
subType: `selector`,
|
|
2323
|
+
token: selectorToken
|
|
2324
|
+
});
|
|
2308
2325
|
}
|
|
2309
2326
|
break;
|
|
2310
2327
|
case `readonly_selector`:
|
|
2311
2328
|
{
|
|
2312
2329
|
target.readonlySelectors.delete(key);
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2330
|
+
familyToken = {
|
|
2331
|
+
key: selector.family.key,
|
|
2332
|
+
type: `readonly_selector_family`
|
|
2333
|
+
};
|
|
2334
|
+
const family = withdraw(store, familyToken);
|
|
2317
2335
|
family.subject.next({
|
|
2318
2336
|
type: `state_disposal`,
|
|
2319
2337
|
subType: `selector`,
|
|
@@ -2382,7 +2400,6 @@ function createWritableSelectorFamily(store, options, internalRoles) {
|
|
|
2382
2400
|
return getFn({
|
|
2383
2401
|
get: (...ps) => getFromStore(store, ...ps),
|
|
2384
2402
|
find: (token, k) => findInStore(store, token, k),
|
|
2385
|
-
seek: (token, k) => seekInStore(store, token, k),
|
|
2386
2403
|
json: (token) => getJsonToken(store, token)
|
|
2387
2404
|
});
|
|
2388
2405
|
}
|
|
@@ -2392,7 +2409,7 @@ function createWritableSelectorFamily(store, options, internalRoles) {
|
|
|
2392
2409
|
}
|
|
2393
2410
|
|
|
2394
2411
|
// ../atom.io/json/src/select-json-family.ts
|
|
2395
|
-
function selectJsonFamily(atomFamilyToken, transform
|
|
2412
|
+
function selectJsonFamily(store, atomFamilyToken, transform) {
|
|
2396
2413
|
const jsonFamily = createWritableSelectorFamily(
|
|
2397
2414
|
store,
|
|
2398
2415
|
{
|
|
@@ -2407,15 +2424,6 @@ function selectJsonFamily(atomFamilyToken, transform, store = IMPLICIT.STORE) {
|
|
|
2407
2424
|
},
|
|
2408
2425
|
[`mutable`, `json`]
|
|
2409
2426
|
);
|
|
2410
|
-
const atomFamily2 = withdraw(atomFamilyToken, store);
|
|
2411
|
-
atomFamily2.subject.subscribe(
|
|
2412
|
-
`store=${store.config.name}::json-selector-family`,
|
|
2413
|
-
(event) => {
|
|
2414
|
-
if (event.token.family) {
|
|
2415
|
-
seekInStore(store, jsonFamily, parseJson(event.token.family.subKey));
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
);
|
|
2419
2427
|
return jsonFamily;
|
|
2420
2428
|
}
|
|
2421
2429
|
|
|
@@ -2424,7 +2432,7 @@ var parseJson = (str) => JSON.parse(str);
|
|
|
2424
2432
|
var stringifyJson = (json) => JSON.stringify(json);
|
|
2425
2433
|
|
|
2426
2434
|
// ../atom.io/internal/src/subscribe/recall-state.ts
|
|
2427
|
-
var recallState = (
|
|
2435
|
+
var recallState = (store, state) => {
|
|
2428
2436
|
const target = newest(store);
|
|
2429
2437
|
if (target.operation.open) {
|
|
2430
2438
|
return target.operation.prev.get(state.key);
|
|
@@ -2433,7 +2441,7 @@ var recallState = (state, store) => {
|
|
|
2433
2441
|
};
|
|
2434
2442
|
|
|
2435
2443
|
// ../atom.io/internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
2436
|
-
var subscribeToRootAtoms = (
|
|
2444
|
+
var subscribeToRootAtoms = (store, selector) => {
|
|
2437
2445
|
const target = newest(store);
|
|
2438
2446
|
const dependencySubscriptions = traceAllSelectorAtoms(selector, store).map(
|
|
2439
2447
|
(atomKey) => {
|
|
@@ -2457,8 +2465,8 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
2457
2465
|
`->`,
|
|
2458
2466
|
atomChange.newValue
|
|
2459
2467
|
);
|
|
2460
|
-
const oldValue = recallState(
|
|
2461
|
-
const newValue = readOrComputeValue(
|
|
2468
|
+
const oldValue = recallState(target, selector);
|
|
2469
|
+
const newValue = readOrComputeValue(target, selector);
|
|
2462
2470
|
store.logger.info(
|
|
2463
2471
|
`\u2728`,
|
|
2464
2472
|
selector.type,
|
|
@@ -2477,7 +2485,7 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
2477
2485
|
};
|
|
2478
2486
|
|
|
2479
2487
|
// ../atom.io/internal/src/subscribe/subscribe-to-state.ts
|
|
2480
|
-
function subscribeToState(
|
|
2488
|
+
function subscribeToState(store, token, key, handleUpdate) {
|
|
2481
2489
|
function safelyHandleUpdate(update) {
|
|
2482
2490
|
if (store.operation.open) {
|
|
2483
2491
|
const unsubscribe2 = store.on.operationClose.subscribe(
|
|
@@ -2491,17 +2499,17 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
2491
2499
|
handleUpdate(update);
|
|
2492
2500
|
}
|
|
2493
2501
|
}
|
|
2494
|
-
const state = withdraw(
|
|
2502
|
+
const state = withdraw(store, token);
|
|
2495
2503
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
2496
2504
|
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
2497
2505
|
let dependencyUnsubFunctions = null;
|
|
2498
2506
|
let updateHandler = safelyHandleUpdate;
|
|
2499
2507
|
if (isSelector) {
|
|
2500
|
-
dependencyUnsubFunctions = subscribeToRootAtoms(
|
|
2508
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(store, state);
|
|
2501
2509
|
updateHandler = (update) => {
|
|
2502
2510
|
if (dependencyUnsubFunctions) {
|
|
2503
2511
|
dependencyUnsubFunctions.length = 0;
|
|
2504
|
-
dependencyUnsubFunctions.push(...subscribeToRootAtoms(
|
|
2512
|
+
dependencyUnsubFunctions.push(...subscribeToRootAtoms(store, state));
|
|
2505
2513
|
}
|
|
2506
2514
|
safelyHandleUpdate(update);
|
|
2507
2515
|
};
|
|
@@ -2525,8 +2533,8 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
2525
2533
|
}
|
|
2526
2534
|
|
|
2527
2535
|
// ../atom.io/internal/src/subscribe/subscribe-to-timeline.ts
|
|
2528
|
-
var subscribeToTimeline = (
|
|
2529
|
-
const tl = withdraw(
|
|
2536
|
+
var subscribeToTimeline = (store, token, key, handleUpdate) => {
|
|
2537
|
+
const tl = withdraw(store, token);
|
|
2530
2538
|
store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
|
|
2531
2539
|
const unsubscribe = tl.subject.subscribe(key, handleUpdate);
|
|
2532
2540
|
return () => {
|
|
@@ -2577,7 +2585,9 @@ var Tracker = class {
|
|
|
2577
2585
|
}
|
|
2578
2586
|
);
|
|
2579
2587
|
this.unsubscribeFromState = subscribeToState(
|
|
2588
|
+
target,
|
|
2580
2589
|
mutableState,
|
|
2590
|
+
subscriptionKey,
|
|
2581
2591
|
(update) => {
|
|
2582
2592
|
if (update.newValue !== update.oldValue) {
|
|
2583
2593
|
this.unsubscribeFromInnerValue();
|
|
@@ -2588,15 +2598,15 @@ var Tracker = class {
|
|
|
2588
2598
|
}
|
|
2589
2599
|
);
|
|
2590
2600
|
}
|
|
2591
|
-
}
|
|
2592
|
-
subscriptionKey,
|
|
2593
|
-
target
|
|
2601
|
+
}
|
|
2594
2602
|
);
|
|
2595
2603
|
}
|
|
2596
2604
|
updateCore(mutableState, latestUpdateState, target) {
|
|
2597
2605
|
const subscriptionKey = `tracker:${target.config.name}:${isChildStore(target) ? target.transactionMeta.update.key : `main`}:${mutableState.key}`;
|
|
2598
2606
|
subscribeToState(
|
|
2607
|
+
target,
|
|
2599
2608
|
latestUpdateState,
|
|
2609
|
+
subscriptionKey,
|
|
2600
2610
|
({ newValue, oldValue }) => {
|
|
2601
2611
|
const timelineId = target.timelineTopics.getRelatedKey(
|
|
2602
2612
|
latestUpdateState.key
|
|
@@ -2605,7 +2615,9 @@ var Tracker = class {
|
|
|
2605
2615
|
const timelineData = target.timelines.get(timelineId);
|
|
2606
2616
|
if (timelineData?.timeTraveling) {
|
|
2607
2617
|
const unsubscribe2 = subscribeToTimeline(
|
|
2618
|
+
target,
|
|
2608
2619
|
{ key: timelineId, type: `timeline` },
|
|
2620
|
+
subscriptionKey,
|
|
2609
2621
|
(update) => {
|
|
2610
2622
|
unsubscribe2();
|
|
2611
2623
|
setIntoStore(target, mutableState, (transceiver) => {
|
|
@@ -2616,9 +2628,7 @@ var Tracker = class {
|
|
|
2616
2628
|
}
|
|
2617
2629
|
return transceiver;
|
|
2618
2630
|
});
|
|
2619
|
-
}
|
|
2620
|
-
subscriptionKey,
|
|
2621
|
-
target
|
|
2631
|
+
}
|
|
2622
2632
|
);
|
|
2623
2633
|
return;
|
|
2624
2634
|
}
|
|
@@ -2646,14 +2656,12 @@ var Tracker = class {
|
|
|
2646
2656
|
}
|
|
2647
2657
|
}
|
|
2648
2658
|
);
|
|
2649
|
-
}
|
|
2650
|
-
subscriptionKey,
|
|
2651
|
-
target
|
|
2659
|
+
}
|
|
2652
2660
|
);
|
|
2653
2661
|
}
|
|
2654
2662
|
mutableState;
|
|
2655
2663
|
latestUpdateState;
|
|
2656
|
-
dispose;
|
|
2664
|
+
[Symbol.dispose];
|
|
2657
2665
|
constructor(mutableState, store) {
|
|
2658
2666
|
this.mutableState = mutableState;
|
|
2659
2667
|
const target = newest(store);
|
|
@@ -2661,7 +2669,7 @@ var Tracker = class {
|
|
|
2661
2669
|
this.observeCore(mutableState, this.latestUpdateState, target);
|
|
2662
2670
|
this.updateCore(mutableState, this.latestUpdateState, target);
|
|
2663
2671
|
target.trackers.set(mutableState.key, this);
|
|
2664
|
-
this.dispose = () => {
|
|
2672
|
+
this[Symbol.dispose] = () => {
|
|
2665
2673
|
this.unsubscribeFromInnerValue();
|
|
2666
2674
|
this.unsubscribeFromState();
|
|
2667
2675
|
target.trackers.delete(mutableState.key);
|
|
@@ -2708,8 +2716,8 @@ function createMutableAtom(store, options, family) {
|
|
|
2708
2716
|
}
|
|
2709
2717
|
const initialValue = options.default();
|
|
2710
2718
|
target.atoms.set(newAtom.key, newAtom);
|
|
2711
|
-
markAtomAsDefault(options.key
|
|
2712
|
-
cacheValue(options.key, initialValue, subject
|
|
2719
|
+
markAtomAsDefault(store, options.key);
|
|
2720
|
+
cacheValue(target, options.key, initialValue, subject);
|
|
2713
2721
|
const token = deposit(newAtom);
|
|
2714
2722
|
if (options.effects) {
|
|
2715
2723
|
let effectIndex = 0;
|
|
@@ -2719,7 +2727,7 @@ function createMutableAtom(store, options, family) {
|
|
|
2719
2727
|
setSelf: (next) => {
|
|
2720
2728
|
setIntoStore(store, token, next);
|
|
2721
2729
|
},
|
|
2722
|
-
onSet: (handle) => subscribeToState(
|
|
2730
|
+
onSet: (handle) => subscribeToState(store, token, `effect[${effectIndex}]`, handle)
|
|
2723
2731
|
});
|
|
2724
2732
|
if (cleanup) {
|
|
2725
2733
|
cleanupFunctions.push(cleanup);
|
|
@@ -2741,6 +2749,7 @@ function createMutableAtom(store, options, family) {
|
|
|
2741
2749
|
|
|
2742
2750
|
// ../atom.io/internal/src/mutable/tracker-family.ts
|
|
2743
2751
|
var FamilyTracker = class {
|
|
2752
|
+
trackers = /* @__PURE__ */ new Map();
|
|
2744
2753
|
Update;
|
|
2745
2754
|
latestUpdateAtoms;
|
|
2746
2755
|
mutableAtoms;
|
|
@@ -2753,26 +2762,27 @@ var FamilyTracker = class {
|
|
|
2753
2762
|
},
|
|
2754
2763
|
[`mutable`, `updates`]
|
|
2755
2764
|
);
|
|
2756
|
-
this.latestUpdateAtoms = withdraw(
|
|
2765
|
+
this.latestUpdateAtoms = withdraw(store, updateAtoms);
|
|
2757
2766
|
this.mutableAtoms = mutableAtoms;
|
|
2758
2767
|
this.mutableAtoms.subject.subscribe(
|
|
2759
2768
|
`store=${store.config.name}::tracker-atom-family`,
|
|
2760
2769
|
(event) => {
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2770
|
+
const { type, token } = event;
|
|
2771
|
+
if (token.family) {
|
|
2772
|
+
const key = parseJson(token.family.subKey);
|
|
2773
|
+
switch (type) {
|
|
2774
|
+
case `state_creation`:
|
|
2775
|
+
this.trackers.set(key, new Tracker(token, store));
|
|
2776
|
+
break;
|
|
2777
|
+
case `state_disposal`:
|
|
2778
|
+
{
|
|
2779
|
+
const tracker = this.trackers.get(key);
|
|
2780
|
+
if (tracker) {
|
|
2781
|
+
tracker[Symbol.dispose]();
|
|
2782
|
+
this.trackers.delete(key);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
break;
|
|
2776
2786
|
}
|
|
2777
2787
|
}
|
|
2778
2788
|
}
|
|
@@ -2825,7 +2835,7 @@ function createMutableAtomFamily(store, options, internalRoles) {
|
|
|
2825
2835
|
internalRoles
|
|
2826
2836
|
});
|
|
2827
2837
|
store.families.set(options.key, atomFamily2);
|
|
2828
|
-
selectJsonFamily(atomFamily2, options
|
|
2838
|
+
selectJsonFamily(store, atomFamily2, options);
|
|
2829
2839
|
new FamilyTracker(atomFamily2, store);
|
|
2830
2840
|
return familyToken;
|
|
2831
2841
|
}
|
|
@@ -2847,7 +2857,7 @@ var getJsonToken = (store, mutableAtomToken) => {
|
|
|
2847
2857
|
key: jsonFamilyKey,
|
|
2848
2858
|
type: `selector_family`
|
|
2849
2859
|
};
|
|
2850
|
-
const family = withdraw(
|
|
2860
|
+
const family = withdraw(target, jsonFamilyToken);
|
|
2851
2861
|
const subKey = JSON.parse(mutableAtomToken.family.subKey);
|
|
2852
2862
|
const jsonToken = findInStore(store, family, subKey);
|
|
2853
2863
|
return jsonToken;
|
|
@@ -2878,7 +2888,7 @@ function isTransceiver(value) {
|
|
|
2878
2888
|
}
|
|
2879
2889
|
|
|
2880
2890
|
// ../atom.io/internal/src/set-state/copy-mutable-if-needed.ts
|
|
2881
|
-
function copyMutableIfNeeded(atom2, origin
|
|
2891
|
+
function copyMutableIfNeeded(target, atom2, origin) {
|
|
2882
2892
|
const originValue = origin.valueMap.get(atom2.key);
|
|
2883
2893
|
const targetValue = target.valueMap.get(atom2.key);
|
|
2884
2894
|
if (originValue === targetValue) {
|
|
@@ -2896,7 +2906,7 @@ function copyMutableIfNeeded(atom2, origin, target) {
|
|
|
2896
2906
|
}
|
|
2897
2907
|
|
|
2898
2908
|
// ../atom.io/internal/src/caching.ts
|
|
2899
|
-
function cacheValue(key, value, subject
|
|
2909
|
+
function cacheValue(target, key, value, subject) {
|
|
2900
2910
|
const currentValue = target.valueMap.get(key);
|
|
2901
2911
|
if (currentValue instanceof Future) {
|
|
2902
2912
|
const future = currentValue;
|
|
@@ -2906,7 +2916,7 @@ function cacheValue(key, value, subject, target) {
|
|
|
2906
2916
|
const future = new Future(value);
|
|
2907
2917
|
target.valueMap.set(key, future);
|
|
2908
2918
|
future.then((resolved) => {
|
|
2909
|
-
cacheValue(key, resolved, subject
|
|
2919
|
+
cacheValue(target, key, resolved, subject);
|
|
2910
2920
|
subject.next({ newValue: resolved, oldValue: future });
|
|
2911
2921
|
}).catch((thrown) => {
|
|
2912
2922
|
target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
@@ -2920,7 +2930,7 @@ var readCachedValue = (token, target) => {
|
|
|
2920
2930
|
let value = target.valueMap.get(token.key);
|
|
2921
2931
|
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
2922
2932
|
const { parent } = target;
|
|
2923
|
-
const copiedValue = copyMutableIfNeeded(token, parent
|
|
2933
|
+
const copiedValue = copyMutableIfNeeded(target, token, parent);
|
|
2924
2934
|
value = copiedValue;
|
|
2925
2935
|
}
|
|
2926
2936
|
return value;
|
|
@@ -2943,15 +2953,15 @@ var evictCachedValue = (key, target) => {
|
|
|
2943
2953
|
};
|
|
2944
2954
|
|
|
2945
2955
|
// ../atom.io/internal/src/atom/is-default.ts
|
|
2946
|
-
var isAtomDefault = (
|
|
2956
|
+
var isAtomDefault = (store, key) => {
|
|
2947
2957
|
const core = newest(store);
|
|
2948
2958
|
return core.atomsThatAreDefault.has(key);
|
|
2949
2959
|
};
|
|
2950
|
-
var markAtomAsDefault = (
|
|
2960
|
+
var markAtomAsDefault = (store, key) => {
|
|
2951
2961
|
const core = newest(store);
|
|
2952
2962
|
core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key);
|
|
2953
2963
|
};
|
|
2954
|
-
var markAtomAsNotDefault = (
|
|
2964
|
+
var markAtomAsNotDefault = (store, key) => {
|
|
2955
2965
|
const core = newest(store);
|
|
2956
2966
|
core.atomsThatAreDefault = new Set(newest(store).atomsThatAreDefault);
|
|
2957
2967
|
core.atomsThatAreDefault.delete(key);
|
|
@@ -2999,8 +3009,8 @@ function createRegularAtom(store, options, family) {
|
|
|
2999
3009
|
initialValue = options.default();
|
|
3000
3010
|
}
|
|
3001
3011
|
target.atoms.set(newAtom.key, newAtom);
|
|
3002
|
-
markAtomAsDefault(options.key
|
|
3003
|
-
cacheValue(options.key, initialValue, subject
|
|
3012
|
+
markAtomAsDefault(store, options.key);
|
|
3013
|
+
cacheValue(target, options.key, initialValue, subject);
|
|
3004
3014
|
const token = deposit(newAtom);
|
|
3005
3015
|
if (options.effects) {
|
|
3006
3016
|
let effectIndex = 0;
|
|
@@ -3010,7 +3020,7 @@ function createRegularAtom(store, options, family) {
|
|
|
3010
3020
|
setSelf: (next) => {
|
|
3011
3021
|
setIntoStore(store, token, next);
|
|
3012
3022
|
},
|
|
3013
|
-
onSet: (handle) => subscribeToState(
|
|
3023
|
+
onSet: (handle) => subscribeToState(store, token, `effect[${effectIndex}]`, handle)
|
|
3014
3024
|
});
|
|
3015
3025
|
if (cleanup) {
|
|
3016
3026
|
cleanupFunctions.push(cleanup);
|
|
@@ -3040,16 +3050,16 @@ function createStandaloneAtom(store, options) {
|
|
|
3040
3050
|
}
|
|
3041
3051
|
|
|
3042
3052
|
// ../atom.io/internal/src/atom/dispose-atom.ts
|
|
3043
|
-
function disposeAtom(
|
|
3053
|
+
function disposeAtom(store, atomToken) {
|
|
3044
3054
|
const target = newest(store);
|
|
3045
3055
|
const { key, family } = atomToken;
|
|
3046
|
-
const atom2 = withdraw(
|
|
3056
|
+
const atom2 = withdraw(target, atomToken);
|
|
3047
3057
|
if (!family) {
|
|
3048
3058
|
store.logger.error(`\u274C`, `atom`, key, `Standalone atoms cannot be disposed.`);
|
|
3049
3059
|
} else {
|
|
3050
3060
|
atom2.cleanup?.();
|
|
3051
3061
|
const lastValue = store.valueMap.get(atom2.key);
|
|
3052
|
-
const atomFamily2 = withdraw({ key: family.key, type: `atom_family` }
|
|
3062
|
+
const atomFamily2 = withdraw(store, { key: family.key, type: `atom_family` });
|
|
3053
3063
|
const disposal = {
|
|
3054
3064
|
type: `state_disposal`,
|
|
3055
3065
|
subType: `atom`,
|
|
@@ -3065,7 +3075,7 @@ function disposeAtom(atomToken, store) {
|
|
|
3065
3075
|
store.timelineTopics.delete(key);
|
|
3066
3076
|
if (atomToken.type === `mutable_atom`) {
|
|
3067
3077
|
const updateToken = getUpdateToken(atomToken);
|
|
3068
|
-
disposeAtom(
|
|
3078
|
+
disposeAtom(store, updateToken);
|
|
3069
3079
|
store.trackers.delete(key);
|
|
3070
3080
|
}
|
|
3071
3081
|
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
@@ -3082,211 +3092,6 @@ function disposeAtom(atomToken, store) {
|
|
|
3082
3092
|
}
|
|
3083
3093
|
}
|
|
3084
3094
|
|
|
3085
|
-
// ../atom.io/introspection/src/refinery.ts
|
|
3086
|
-
var Refinery = class {
|
|
3087
|
-
supported;
|
|
3088
|
-
constructor(supported) {
|
|
3089
|
-
this.supported = supported;
|
|
3090
|
-
}
|
|
3091
|
-
refine(input) {
|
|
3092
|
-
for (const [key, refiner] of Object.entries(this.supported)) {
|
|
3093
|
-
try {
|
|
3094
|
-
if (
|
|
3095
|
-
// @ts-expect-error that's the point
|
|
3096
|
-
refiner(input) === true && refiner !== Boolean
|
|
3097
|
-
) {
|
|
3098
|
-
return { type: key, data: input };
|
|
3099
|
-
}
|
|
3100
|
-
} catch (_) {
|
|
3101
|
-
try {
|
|
3102
|
-
if (input instanceof refiner) {
|
|
3103
|
-
return { type: key, data: input };
|
|
3104
|
-
}
|
|
3105
|
-
} catch (__) {
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
}
|
|
3109
|
-
return null;
|
|
3110
|
-
}
|
|
3111
|
-
};
|
|
3112
|
-
var primitiveRefinery = new Refinery({
|
|
3113
|
-
number: (input) => typeof input === `number`,
|
|
3114
|
-
string: (input) => typeof input === `string`,
|
|
3115
|
-
boolean: (input) => typeof input === `boolean`,
|
|
3116
|
-
null: (input) => input === null
|
|
3117
|
-
});
|
|
3118
|
-
function isPlainObject(input) {
|
|
3119
|
-
if (!input) {
|
|
3120
|
-
return false;
|
|
3121
|
-
}
|
|
3122
|
-
const prototype = Object.getPrototypeOf(input);
|
|
3123
|
-
return prototype === Object.prototype;
|
|
3124
|
-
}
|
|
3125
|
-
var jsonTreeRefinery = new Refinery({
|
|
3126
|
-
object: isPlainObject,
|
|
3127
|
-
array: (input) => Array.isArray(input)
|
|
3128
|
-
});
|
|
3129
|
-
var jsonRefinery = new Refinery({
|
|
3130
|
-
...primitiveRefinery.supported,
|
|
3131
|
-
...jsonTreeRefinery.supported
|
|
3132
|
-
});
|
|
3133
|
-
var discoverType = (input) => {
|
|
3134
|
-
if (input === undefined) {
|
|
3135
|
-
return `undefined`;
|
|
3136
|
-
}
|
|
3137
|
-
const refined = jsonRefinery.refine(input);
|
|
3138
|
-
if (refined) {
|
|
3139
|
-
return refined.type;
|
|
3140
|
-
}
|
|
3141
|
-
return Object.getPrototypeOf(input).constructor.name;
|
|
3142
|
-
};
|
|
3143
|
-
|
|
3144
|
-
// ../atom.io/introspection/src/sprawl.ts
|
|
3145
|
-
var sprawl = (tree, inspector) => {
|
|
3146
|
-
const walk = (path, node) => {
|
|
3147
|
-
const inspect2 = (p, n) => {
|
|
3148
|
-
const result2 = inspector(p, n);
|
|
3149
|
-
if (result2) return result2;
|
|
3150
|
-
return null;
|
|
3151
|
-
};
|
|
3152
|
-
const result = inspect2(path, node);
|
|
3153
|
-
if (result?.jobComplete ?? result?.pathComplete) {
|
|
3154
|
-
return result;
|
|
3155
|
-
}
|
|
3156
|
-
const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
|
|
3157
|
-
for (const [k, v] of childEntries) {
|
|
3158
|
-
const subResult = walk([...path, k], v);
|
|
3159
|
-
if (subResult?.jobComplete) {
|
|
3160
|
-
return subResult;
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
return {};
|
|
3164
|
-
};
|
|
3165
|
-
walk([], tree);
|
|
3166
|
-
};
|
|
3167
|
-
|
|
3168
|
-
// ../atom.io/introspection/src/differ.ts
|
|
3169
|
-
function diffNumber(a, b) {
|
|
3170
|
-
const sign = a < b ? `+` : `-`;
|
|
3171
|
-
return {
|
|
3172
|
-
summary: `${sign}${Math.abs(a - b)} (${a} \u2192 ${b})`
|
|
3173
|
-
};
|
|
3174
|
-
}
|
|
3175
|
-
function diffString(a, b) {
|
|
3176
|
-
const sign = a.length < b.length ? `+` : `-`;
|
|
3177
|
-
return {
|
|
3178
|
-
summary: `${sign}${Math.abs(a.length - b.length)} ("${a}" \u2192 "${b}")`
|
|
3179
|
-
};
|
|
3180
|
-
}
|
|
3181
|
-
function diffBoolean(a, b) {
|
|
3182
|
-
return {
|
|
3183
|
-
summary: `${a} \u2192 ${b}`
|
|
3184
|
-
};
|
|
3185
|
-
}
|
|
3186
|
-
function diffObject(a, b, recurse) {
|
|
3187
|
-
let summary = ``;
|
|
3188
|
-
const added = [];
|
|
3189
|
-
const removed = [];
|
|
3190
|
-
const changed = [];
|
|
3191
|
-
sprawl(a, (path, nodeA) => {
|
|
3192
|
-
let key;
|
|
3193
|
-
for (key of path) {
|
|
3194
|
-
const nodeB = b[key];
|
|
3195
|
-
if (nodeB === undefined) {
|
|
3196
|
-
removed.push([key, JSON.stringify(nodeA)]);
|
|
3197
|
-
} else {
|
|
3198
|
-
const delta = recurse(nodeA, nodeB);
|
|
3199
|
-
if (delta.summary !== `No Change`) {
|
|
3200
|
-
changed.push([key, delta]);
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
}
|
|
3204
|
-
});
|
|
3205
|
-
sprawl(b, (path, nodeB) => {
|
|
3206
|
-
let key;
|
|
3207
|
-
for (key of path) {
|
|
3208
|
-
const nodeA = a[key];
|
|
3209
|
-
if (nodeA === undefined) {
|
|
3210
|
-
added.push([key, JSON.stringify(nodeB)]);
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
});
|
|
3214
|
-
summary = `\uFF5E${changed.length} \uFF0B${added.length} \uFF0D${removed.length}`;
|
|
3215
|
-
return {
|
|
3216
|
-
summary,
|
|
3217
|
-
added,
|
|
3218
|
-
removed,
|
|
3219
|
-
changed
|
|
3220
|
-
};
|
|
3221
|
-
}
|
|
3222
|
-
function diffArray(a, b, recurse) {
|
|
3223
|
-
return diffObject(a, b, recurse);
|
|
3224
|
-
}
|
|
3225
|
-
var Differ = class {
|
|
3226
|
-
leafRefinery;
|
|
3227
|
-
treeRefinery;
|
|
3228
|
-
leafDiffers;
|
|
3229
|
-
treeDiffers;
|
|
3230
|
-
constructor(leafRefinery, treeRefinery, diffFunctions) {
|
|
3231
|
-
this.leafRefinery = leafRefinery;
|
|
3232
|
-
this.treeRefinery = treeRefinery;
|
|
3233
|
-
this.leafDiffers = {};
|
|
3234
|
-
this.treeDiffers = {};
|
|
3235
|
-
for (const key of Object.keys(leafRefinery.supported)) {
|
|
3236
|
-
const diffFunction = diffFunctions[key];
|
|
3237
|
-
this.leafDiffers[key] = diffFunction;
|
|
3238
|
-
}
|
|
3239
|
-
for (const key of Object.keys(treeRefinery.supported)) {
|
|
3240
|
-
const diffFunction = diffFunctions[key];
|
|
3241
|
-
this.treeDiffers[key] = diffFunction;
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
|
-
diff(a, b) {
|
|
3245
|
-
if (a === b) {
|
|
3246
|
-
return { summary: `No Change` };
|
|
3247
|
-
}
|
|
3248
|
-
const aRefined = this.leafRefinery.refine(a) ?? this.treeRefinery.refine(a);
|
|
3249
|
-
const bRefined = this.leafRefinery.refine(b) ?? this.treeRefinery.refine(b);
|
|
3250
|
-
if (aRefined !== null && bRefined !== null) {
|
|
3251
|
-
if (aRefined.type === bRefined.type) {
|
|
3252
|
-
if (aRefined.type in this.leafDiffers) {
|
|
3253
|
-
const delta = this.leafDiffers[aRefined.type](
|
|
3254
|
-
aRefined.data,
|
|
3255
|
-
bRefined.data
|
|
3256
|
-
);
|
|
3257
|
-
return delta;
|
|
3258
|
-
}
|
|
3259
|
-
if (aRefined.type in this.treeDiffers) {
|
|
3260
|
-
const delta = this.treeDiffers[aRefined.type](
|
|
3261
|
-
aRefined.data,
|
|
3262
|
-
bRefined.data,
|
|
3263
|
-
(x, y) => this.diff(x, y)
|
|
3264
|
-
);
|
|
3265
|
-
return delta;
|
|
3266
|
-
}
|
|
3267
|
-
}
|
|
3268
|
-
}
|
|
3269
|
-
const typeA = discoverType(a);
|
|
3270
|
-
const typeB = discoverType(b);
|
|
3271
|
-
if (typeA === typeB) {
|
|
3272
|
-
return {
|
|
3273
|
-
summary: `${typeA} \u2192 ${typeB}`
|
|
3274
|
-
};
|
|
3275
|
-
}
|
|
3276
|
-
return {
|
|
3277
|
-
summary: `Type change: ${typeA} \u2192 ${typeB}`
|
|
3278
|
-
};
|
|
3279
|
-
}
|
|
3280
|
-
};
|
|
3281
|
-
new Differ(primitiveRefinery, jsonTreeRefinery, {
|
|
3282
|
-
number: diffNumber,
|
|
3283
|
-
string: diffString,
|
|
3284
|
-
boolean: diffBoolean,
|
|
3285
|
-
null: () => ({ summary: `No Change` }),
|
|
3286
|
-
object: diffObject,
|
|
3287
|
-
array: diffArray
|
|
3288
|
-
});
|
|
3289
|
-
|
|
3290
3095
|
// ../atom.io/transceivers/set-rtx/src/set-rtx.ts
|
|
3291
3096
|
var SetRTX = class _SetRTX extends Set {
|
|
3292
3097
|
mode = `record`;
|
|
@@ -3499,10 +3304,7 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
3499
3304
|
}
|
|
3500
3305
|
};
|
|
3501
3306
|
|
|
3502
|
-
// ../atom.io/
|
|
3503
|
-
function capitalize2(string) {
|
|
3504
|
-
return string[0].toUpperCase() + string.slice(1);
|
|
3505
|
-
}
|
|
3307
|
+
// ../atom.io/internal/src/join/join-internal.ts
|
|
3506
3308
|
var Join = class {
|
|
3507
3309
|
toolkit;
|
|
3508
3310
|
options;
|
|
@@ -3534,7 +3336,6 @@ var Join = class {
|
|
|
3534
3336
|
setIntoStore(store, ...ps);
|
|
3535
3337
|
},
|
|
3536
3338
|
find: (...ps) => findInStore(store, ...ps),
|
|
3537
|
-
seek: (...ps) => seekInStore(store, ...ps),
|
|
3538
3339
|
json: (token) => getJsonToken(store, token)
|
|
3539
3340
|
};
|
|
3540
3341
|
const aSide = options.between[0];
|
|
@@ -3800,8 +3601,8 @@ var Join = class {
|
|
|
3800
3601
|
switch (options.cardinality) {
|
|
3801
3602
|
case `1:1`: {
|
|
3802
3603
|
const singleRelatedKeySelectors = createSingleKeySelectorFamily();
|
|
3803
|
-
const stateKeyA = `${aSide}KeyOf${
|
|
3804
|
-
const stateKeyB = `${bSide}KeyOf${
|
|
3604
|
+
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
3605
|
+
const stateKeyB = `${bSide}KeyOf${capitalize(aSide)}`;
|
|
3805
3606
|
const baseStates = {
|
|
3806
3607
|
[stateKeyA]: singleRelatedKeySelectors,
|
|
3807
3608
|
[stateKeyB]: singleRelatedKeySelectors
|
|
@@ -3809,8 +3610,8 @@ var Join = class {
|
|
|
3809
3610
|
let states;
|
|
3810
3611
|
if (defaultContent) {
|
|
3811
3612
|
const singleEntrySelectors = createSingleEntrySelectorFamily();
|
|
3812
|
-
const entriesStateKeyA = `${aSide}EntryOf${
|
|
3813
|
-
const entriesStateKeyB = `${bSide}EntryOf${
|
|
3613
|
+
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
3614
|
+
const entriesStateKeyB = `${bSide}EntryOf${capitalize(aSide)}`;
|
|
3814
3615
|
const contentStates = {
|
|
3815
3616
|
[entriesStateKeyA]: singleEntrySelectors,
|
|
3816
3617
|
[entriesStateKeyB]: singleEntrySelectors
|
|
@@ -3826,8 +3627,8 @@ var Join = class {
|
|
|
3826
3627
|
case `1:n`: {
|
|
3827
3628
|
const singleRelatedKeySelectors = createSingleKeySelectorFamily();
|
|
3828
3629
|
const multipleRelatedKeysSelectors = getMultipleKeySelectorFamily();
|
|
3829
|
-
const stateKeyA = `${aSide}KeyOf${
|
|
3830
|
-
const stateKeyB = `${bSide}KeysOf${
|
|
3630
|
+
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
3631
|
+
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
3831
3632
|
const baseStates = {
|
|
3832
3633
|
[stateKeyA]: singleRelatedKeySelectors,
|
|
3833
3634
|
[stateKeyB]: multipleRelatedKeysSelectors
|
|
@@ -3836,8 +3637,8 @@ var Join = class {
|
|
|
3836
3637
|
if (defaultContent) {
|
|
3837
3638
|
const singleRelatedEntrySelectors = createSingleEntrySelectorFamily();
|
|
3838
3639
|
const multipleRelatedEntriesSelectors = getMultipleEntrySelectorFamily();
|
|
3839
|
-
const entriesStateKeyA = `${aSide}EntryOf${
|
|
3840
|
-
const entriesStateKeyB = `${bSide}EntriesOf${
|
|
3640
|
+
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
3641
|
+
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(
|
|
3841
3642
|
aSide
|
|
3842
3643
|
)}`;
|
|
3843
3644
|
const contentStates = {
|
|
@@ -3854,8 +3655,8 @@ var Join = class {
|
|
|
3854
3655
|
}
|
|
3855
3656
|
default: {
|
|
3856
3657
|
const multipleRelatedKeysSelectors = getMultipleKeySelectorFamily();
|
|
3857
|
-
const stateKeyA = `${aSide}KeysOf${
|
|
3858
|
-
const stateKeyB = `${bSide}KeysOf${
|
|
3658
|
+
const stateKeyA = `${aSide}KeysOf${capitalize(bSide)}`;
|
|
3659
|
+
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
3859
3660
|
const baseStates = {
|
|
3860
3661
|
[stateKeyA]: multipleRelatedKeysSelectors,
|
|
3861
3662
|
[stateKeyB]: multipleRelatedKeysSelectors
|
|
@@ -3863,10 +3664,10 @@ var Join = class {
|
|
|
3863
3664
|
let states;
|
|
3864
3665
|
if (defaultContent) {
|
|
3865
3666
|
const multipleRelatedEntriesSelectors = getMultipleEntrySelectorFamily();
|
|
3866
|
-
const entriesStateKeyA = `${aSide}EntriesOf${
|
|
3667
|
+
const entriesStateKeyA = `${aSide}EntriesOf${capitalize(
|
|
3867
3668
|
bSide
|
|
3868
3669
|
)}`;
|
|
3869
|
-
const entriesStateKeyB = `${bSide}EntriesOf${
|
|
3670
|
+
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(
|
|
3870
3671
|
aSide
|
|
3871
3672
|
)}`;
|
|
3872
3673
|
const contentStates = {
|
|
@@ -3883,17 +3684,8 @@ var Join = class {
|
|
|
3883
3684
|
}
|
|
3884
3685
|
}
|
|
3885
3686
|
};
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
const token = {
|
|
3889
|
-
key: options.key,
|
|
3890
|
-
type: `join`,
|
|
3891
|
-
a: options.between[0],
|
|
3892
|
-
b: options.between[1],
|
|
3893
|
-
cardinality: options.cardinality
|
|
3894
|
-
};
|
|
3895
|
-
return token;
|
|
3896
|
-
}
|
|
3687
|
+
|
|
3688
|
+
// ../atom.io/internal/src/join/get-join.ts
|
|
3897
3689
|
function getJoin(token, store) {
|
|
3898
3690
|
let myJoin = store.joins.get(token.key);
|
|
3899
3691
|
if (myJoin === undefined) {
|
|
@@ -3909,6 +3701,8 @@ function getJoin(token, store) {
|
|
|
3909
3701
|
}
|
|
3910
3702
|
return myJoin;
|
|
3911
3703
|
}
|
|
3704
|
+
|
|
3705
|
+
// ../atom.io/internal/src/join/edit-relations-in-store.ts
|
|
3912
3706
|
function editRelationsInStore(token, change, store) {
|
|
3913
3707
|
const myJoin = getJoin(token, store);
|
|
3914
3708
|
const target = newest(store);
|
|
@@ -3921,14 +3715,218 @@ function editRelationsInStore(token, change, store) {
|
|
|
3921
3715
|
change(myJoin.relations);
|
|
3922
3716
|
}
|
|
3923
3717
|
}
|
|
3718
|
+
|
|
3719
|
+
// ../atom.io/internal/src/join/get-internal-relations-from-store.ts
|
|
3924
3720
|
function getInternalRelationsFromStore(token, store) {
|
|
3925
3721
|
const myJoin = getJoin(token, store);
|
|
3926
3722
|
const family = myJoin.core.relatedKeysAtoms;
|
|
3927
3723
|
return family;
|
|
3928
3724
|
}
|
|
3929
|
-
|
|
3930
|
-
|
|
3725
|
+
|
|
3726
|
+
// ../atom.io/introspection/src/refinery.ts
|
|
3727
|
+
var Refinery = class {
|
|
3728
|
+
supported;
|
|
3729
|
+
constructor(supported) {
|
|
3730
|
+
this.supported = supported;
|
|
3731
|
+
}
|
|
3732
|
+
refine(input) {
|
|
3733
|
+
for (const [key, refiner] of Object.entries(this.supported)) {
|
|
3734
|
+
try {
|
|
3735
|
+
if (
|
|
3736
|
+
// @ts-expect-error that's the point
|
|
3737
|
+
refiner(input) === true && refiner !== Boolean
|
|
3738
|
+
) {
|
|
3739
|
+
return { type: key, data: input };
|
|
3740
|
+
}
|
|
3741
|
+
} catch (_) {
|
|
3742
|
+
try {
|
|
3743
|
+
if (input instanceof refiner) {
|
|
3744
|
+
return { type: key, data: input };
|
|
3745
|
+
}
|
|
3746
|
+
} catch (__) {
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
return null;
|
|
3751
|
+
}
|
|
3752
|
+
};
|
|
3753
|
+
var primitiveRefinery = new Refinery({
|
|
3754
|
+
number: (input) => typeof input === `number`,
|
|
3755
|
+
string: (input) => typeof input === `string`,
|
|
3756
|
+
boolean: (input) => typeof input === `boolean`,
|
|
3757
|
+
null: (input) => input === null
|
|
3758
|
+
});
|
|
3759
|
+
function isPlainObject(input) {
|
|
3760
|
+
if (!input) {
|
|
3761
|
+
return false;
|
|
3762
|
+
}
|
|
3763
|
+
const prototype = Object.getPrototypeOf(input);
|
|
3764
|
+
return prototype === Object.prototype;
|
|
3765
|
+
}
|
|
3766
|
+
var jsonTreeRefinery = new Refinery({
|
|
3767
|
+
object: isPlainObject,
|
|
3768
|
+
array: (input) => Array.isArray(input)
|
|
3769
|
+
});
|
|
3770
|
+
var jsonRefinery = new Refinery({
|
|
3771
|
+
...primitiveRefinery.supported,
|
|
3772
|
+
...jsonTreeRefinery.supported
|
|
3773
|
+
});
|
|
3774
|
+
var discoverType = (input) => {
|
|
3775
|
+
if (input === undefined) {
|
|
3776
|
+
return `undefined`;
|
|
3777
|
+
}
|
|
3778
|
+
const refined = jsonRefinery.refine(input);
|
|
3779
|
+
if (refined) {
|
|
3780
|
+
return refined.type;
|
|
3781
|
+
}
|
|
3782
|
+
return Object.getPrototypeOf(input).constructor.name;
|
|
3783
|
+
};
|
|
3784
|
+
|
|
3785
|
+
// ../atom.io/introspection/src/sprawl.ts
|
|
3786
|
+
var sprawl = (tree, inspector) => {
|
|
3787
|
+
const walk = (path, node) => {
|
|
3788
|
+
const inspect2 = (p, n) => {
|
|
3789
|
+
const result2 = inspector(p, n);
|
|
3790
|
+
if (result2) return result2;
|
|
3791
|
+
return null;
|
|
3792
|
+
};
|
|
3793
|
+
const result = inspect2(path, node);
|
|
3794
|
+
if (result?.jobComplete ?? result?.pathComplete) {
|
|
3795
|
+
return result;
|
|
3796
|
+
}
|
|
3797
|
+
const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
|
|
3798
|
+
for (const [k, v] of childEntries) {
|
|
3799
|
+
const subResult = walk([...path, k], v);
|
|
3800
|
+
if (subResult?.jobComplete) {
|
|
3801
|
+
return subResult;
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
return {};
|
|
3805
|
+
};
|
|
3806
|
+
walk([], tree);
|
|
3807
|
+
};
|
|
3808
|
+
|
|
3809
|
+
// ../atom.io/introspection/src/differ.ts
|
|
3810
|
+
function diffNumber(a, b) {
|
|
3811
|
+
const sign = a < b ? `+` : `-`;
|
|
3812
|
+
return {
|
|
3813
|
+
summary: `${sign}${Math.abs(a - b)} (${a} \u2192 ${b})`
|
|
3814
|
+
};
|
|
3815
|
+
}
|
|
3816
|
+
function diffString(a, b) {
|
|
3817
|
+
const sign = a.length < b.length ? `+` : `-`;
|
|
3818
|
+
return {
|
|
3819
|
+
summary: `${sign}${Math.abs(a.length - b.length)} ("${a}" \u2192 "${b}")`
|
|
3820
|
+
};
|
|
3931
3821
|
}
|
|
3822
|
+
function diffBoolean(a, b) {
|
|
3823
|
+
return {
|
|
3824
|
+
summary: `${a} \u2192 ${b}`
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
function diffObject(a, b, recurse) {
|
|
3828
|
+
let summary = ``;
|
|
3829
|
+
const added = [];
|
|
3830
|
+
const removed = [];
|
|
3831
|
+
const changed = [];
|
|
3832
|
+
sprawl(a, (path, nodeA) => {
|
|
3833
|
+
let key;
|
|
3834
|
+
for (key of path) {
|
|
3835
|
+
const nodeB = b[key];
|
|
3836
|
+
if (nodeB === undefined) {
|
|
3837
|
+
removed.push([key, JSON.stringify(nodeA)]);
|
|
3838
|
+
} else {
|
|
3839
|
+
const delta = recurse(nodeA, nodeB);
|
|
3840
|
+
if (delta.summary !== `No Change`) {
|
|
3841
|
+
changed.push([key, delta]);
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
});
|
|
3846
|
+
sprawl(b, (path, nodeB) => {
|
|
3847
|
+
let key;
|
|
3848
|
+
for (key of path) {
|
|
3849
|
+
const nodeA = a[key];
|
|
3850
|
+
if (nodeA === undefined) {
|
|
3851
|
+
added.push([key, JSON.stringify(nodeB)]);
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
});
|
|
3855
|
+
summary = `\uFF5E${changed.length} \uFF0B${added.length} \uFF0D${removed.length}`;
|
|
3856
|
+
return {
|
|
3857
|
+
summary,
|
|
3858
|
+
added,
|
|
3859
|
+
removed,
|
|
3860
|
+
changed
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
function diffArray(a, b, recurse) {
|
|
3864
|
+
return diffObject(a, b, recurse);
|
|
3865
|
+
}
|
|
3866
|
+
var Differ = class {
|
|
3867
|
+
leafRefinery;
|
|
3868
|
+
treeRefinery;
|
|
3869
|
+
leafDiffers;
|
|
3870
|
+
treeDiffers;
|
|
3871
|
+
constructor(leafRefinery, treeRefinery, diffFunctions) {
|
|
3872
|
+
this.leafRefinery = leafRefinery;
|
|
3873
|
+
this.treeRefinery = treeRefinery;
|
|
3874
|
+
this.leafDiffers = {};
|
|
3875
|
+
this.treeDiffers = {};
|
|
3876
|
+
for (const key of Object.keys(leafRefinery.supported)) {
|
|
3877
|
+
const diffFunction = diffFunctions[key];
|
|
3878
|
+
this.leafDiffers[key] = diffFunction;
|
|
3879
|
+
}
|
|
3880
|
+
for (const key of Object.keys(treeRefinery.supported)) {
|
|
3881
|
+
const diffFunction = diffFunctions[key];
|
|
3882
|
+
this.treeDiffers[key] = diffFunction;
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
diff(a, b) {
|
|
3886
|
+
if (a === b) {
|
|
3887
|
+
return { summary: `No Change` };
|
|
3888
|
+
}
|
|
3889
|
+
const aRefined = this.leafRefinery.refine(a) ?? this.treeRefinery.refine(a);
|
|
3890
|
+
const bRefined = this.leafRefinery.refine(b) ?? this.treeRefinery.refine(b);
|
|
3891
|
+
if (aRefined !== null && bRefined !== null) {
|
|
3892
|
+
if (aRefined.type === bRefined.type) {
|
|
3893
|
+
if (aRefined.type in this.leafDiffers) {
|
|
3894
|
+
const delta = this.leafDiffers[aRefined.type](
|
|
3895
|
+
aRefined.data,
|
|
3896
|
+
bRefined.data
|
|
3897
|
+
);
|
|
3898
|
+
return delta;
|
|
3899
|
+
}
|
|
3900
|
+
if (aRefined.type in this.treeDiffers) {
|
|
3901
|
+
const delta = this.treeDiffers[aRefined.type](
|
|
3902
|
+
aRefined.data,
|
|
3903
|
+
bRefined.data,
|
|
3904
|
+
(x, y) => this.diff(x, y)
|
|
3905
|
+
);
|
|
3906
|
+
return delta;
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
const typeA = discoverType(a);
|
|
3911
|
+
const typeB = discoverType(b);
|
|
3912
|
+
if (typeA === typeB) {
|
|
3913
|
+
return {
|
|
3914
|
+
summary: `${typeA} \u2192 ${typeB}`
|
|
3915
|
+
};
|
|
3916
|
+
}
|
|
3917
|
+
return {
|
|
3918
|
+
summary: `Type change: ${typeA} \u2192 ${typeB}`
|
|
3919
|
+
};
|
|
3920
|
+
}
|
|
3921
|
+
};
|
|
3922
|
+
new Differ(primitiveRefinery, jsonTreeRefinery, {
|
|
3923
|
+
number: diffNumber,
|
|
3924
|
+
string: diffString,
|
|
3925
|
+
boolean: diffBoolean,
|
|
3926
|
+
null: () => ({ summary: `No Change` }),
|
|
3927
|
+
object: diffObject,
|
|
3928
|
+
array: diffArray
|
|
3929
|
+
});
|
|
3932
3930
|
|
|
3933
3931
|
// ../atom.io/realtime/src/shared-room-store.ts
|
|
3934
3932
|
atom({
|
|
@@ -4764,5 +4762,5 @@ var FlightDeckLogger = class {
|
|
|
4764
4762
|
};
|
|
4765
4763
|
|
|
4766
4764
|
export { FLIGHTDECK_ERROR, FLIGHTDECK_INFO, FLIGHTDECK_LNAV_FORMAT, FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FLIGHTDECK_WARN, FlightDeck, FlightDeckLogger, flightDeckLogSchema, isVersionNumber };
|
|
4767
|
-
//# sourceMappingURL=chunk-
|
|
4768
|
-
//# sourceMappingURL=chunk-
|
|
4765
|
+
//# sourceMappingURL=chunk-7KMVUPT3.js.map
|
|
4766
|
+
//# sourceMappingURL=chunk-7KMVUPT3.js.map
|