flightdeck 0.2.16 → 0.2.18
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/{chunk-AP2UJF2F.js → chunk-RNOG4E3Q.js} +428 -424
- package/dist/chunk-RNOG4E3Q.js.map +1 -0
- package/dist/flightdeck.x.js +5 -4
- package/dist/flightdeck.x.js.map +1 -1
- package/dist/lib.js +1 -1
- package/package.json +6 -6
- package/src/flightdeck.x.ts +2 -1
- package/dist/chunk-AP2UJF2F.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn, execSync } from 'node:child_process';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { resolve } from 'node:path';
|
|
@@ -58,7 +58,7 @@ var Future = class extends Promise {
|
|
|
58
58
|
);
|
|
59
59
|
} else {
|
|
60
60
|
this.resolve(value);
|
|
61
|
-
this.fate =
|
|
61
|
+
this.fate = void 0;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -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(
|
|
@@ -556,7 +575,9 @@ var emitUpdate = (state, update, store) => {
|
|
|
556
575
|
state.subject.subscribers
|
|
557
576
|
);
|
|
558
577
|
break;
|
|
559
|
-
|
|
578
|
+
case `atom`:
|
|
579
|
+
case `selector`:
|
|
580
|
+
case `readonly_selector`:
|
|
560
581
|
store.logger.info(
|
|
561
582
|
`\u{1F4E2}`,
|
|
562
583
|
state.type,
|
|
@@ -573,7 +594,7 @@ var emitUpdate = (state, update, store) => {
|
|
|
573
594
|
};
|
|
574
595
|
|
|
575
596
|
// ../atom.io/internal/src/set-state/evict-downstream.ts
|
|
576
|
-
var evictDownStream = (
|
|
597
|
+
var evictDownStream = (store, atom2) => {
|
|
577
598
|
const target = newest(store);
|
|
578
599
|
const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom2.key);
|
|
579
600
|
target.logger.info(
|
|
@@ -612,7 +633,7 @@ function shouldUpdateBeStowed(key, update) {
|
|
|
612
633
|
}
|
|
613
634
|
return true;
|
|
614
635
|
}
|
|
615
|
-
var stowUpdate = (state, update
|
|
636
|
+
var stowUpdate = (store, state, update) => {
|
|
616
637
|
const { key } = state;
|
|
617
638
|
const target = newest(store);
|
|
618
639
|
if (!isChildStore(target) || target.transactionMeta.phase !== `building`) {
|
|
@@ -651,44 +672,44 @@ var stowUpdate = (state, update, store) => {
|
|
|
651
672
|
|
|
652
673
|
// ../atom.io/internal/src/set-state/set-atom.ts
|
|
653
674
|
var setAtom = (atom2, next, target) => {
|
|
654
|
-
const oldValue = readOrComputeValue(
|
|
675
|
+
const oldValue = readOrComputeValue(target, atom2);
|
|
655
676
|
let newValue = oldValue;
|
|
656
677
|
if (atom2.type === `mutable_atom` && isChildStore(target)) {
|
|
657
678
|
const { parent } = target;
|
|
658
|
-
const copiedValue = copyMutableIfNeeded(atom2, parent
|
|
679
|
+
const copiedValue = copyMutableIfNeeded(target, atom2, parent);
|
|
659
680
|
newValue = copiedValue;
|
|
660
681
|
}
|
|
661
682
|
newValue = become(next)(newValue);
|
|
662
683
|
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
|
|
684
|
+
newValue = cacheValue(target, atom2.key, newValue, atom2.subject);
|
|
685
|
+
if (isAtomDefault(target, atom2.key)) {
|
|
686
|
+
markAtomAsNotDefault(target, atom2.key);
|
|
666
687
|
}
|
|
667
688
|
markDone(target, atom2.key);
|
|
668
|
-
evictDownStream(
|
|
689
|
+
evictDownStream(target, atom2);
|
|
669
690
|
const update = { oldValue, newValue };
|
|
670
691
|
if (isRootStore(target)) {
|
|
671
|
-
emitUpdate(atom2, update
|
|
692
|
+
emitUpdate(target, atom2, update);
|
|
672
693
|
} else if (target.parent) {
|
|
673
694
|
if (target.on.transactionApplying.state === null) {
|
|
674
|
-
stowUpdate(atom2, update
|
|
695
|
+
stowUpdate(target, atom2, update);
|
|
675
696
|
} else if (atom2.key.startsWith(`*`)) {
|
|
676
697
|
const mutableKey = atom2.key.slice(1);
|
|
677
698
|
const mutableAtom = target.atoms.get(mutableKey);
|
|
678
699
|
let transceiver = target.valueMap.get(mutableKey);
|
|
679
700
|
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
680
701
|
const { parent } = target;
|
|
681
|
-
const copiedValue = copyMutableIfNeeded(mutableAtom, parent
|
|
702
|
+
const copiedValue = copyMutableIfNeeded(target, mutableAtom, parent);
|
|
682
703
|
transceiver = copiedValue;
|
|
683
704
|
}
|
|
684
705
|
const accepted = transceiver.do(update.newValue) === null;
|
|
685
|
-
if (accepted) evictDownStream(
|
|
706
|
+
if (accepted) evictDownStream(target, mutableAtom);
|
|
686
707
|
}
|
|
687
708
|
}
|
|
688
709
|
};
|
|
689
710
|
|
|
690
711
|
// ../atom.io/internal/src/set-state/set-atom-or-selector.ts
|
|
691
|
-
var setAtomOrSelector = (state, value
|
|
712
|
+
var setAtomOrSelector = (store, state, value) => {
|
|
692
713
|
switch (state.type) {
|
|
693
714
|
case `atom`:
|
|
694
715
|
case `mutable_atom`:
|
|
@@ -762,8 +783,8 @@ ${disposal.trace}` : `No previous disposal trace was found.`
|
|
|
762
783
|
);
|
|
763
784
|
return;
|
|
764
785
|
}
|
|
765
|
-
const state = withdraw(
|
|
766
|
-
setAtomOrSelector(state, value
|
|
786
|
+
const state = withdraw(store, token);
|
|
787
|
+
setAtomOrSelector(store, state, value);
|
|
767
788
|
closeOperation(store);
|
|
768
789
|
}
|
|
769
790
|
|
|
@@ -1137,13 +1158,13 @@ function ingestTransactionUpdate(applying, transactionUpdate, store) {
|
|
|
1137
1158
|
}
|
|
1138
1159
|
|
|
1139
1160
|
// ../atom.io/internal/src/transaction/set-epoch-number.ts
|
|
1140
|
-
function setEpochNumberOfAction(transactionKey, newEpoch
|
|
1161
|
+
function setEpochNumberOfAction(store, transactionKey, newEpoch) {
|
|
1141
1162
|
const isRoot = isRootStore(store);
|
|
1142
1163
|
if (!isRoot) {
|
|
1143
1164
|
return;
|
|
1144
1165
|
}
|
|
1145
1166
|
const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
1146
|
-
if (continuityKey !==
|
|
1167
|
+
if (continuityKey !== void 0) {
|
|
1147
1168
|
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
1148
1169
|
}
|
|
1149
1170
|
}
|
|
@@ -1176,14 +1197,14 @@ var applyTransaction = (output, store) => {
|
|
|
1176
1197
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
1177
1198
|
if (isRootStore(parent)) {
|
|
1178
1199
|
setEpochNumberOfAction(
|
|
1200
|
+
parent,
|
|
1179
1201
|
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
|
|
1202
|
+
child.transactionMeta.update.epoch
|
|
1186
1203
|
);
|
|
1204
|
+
const myTransaction = withdraw(store, {
|
|
1205
|
+
key: child.transactionMeta.update.key,
|
|
1206
|
+
type: `transaction`
|
|
1207
|
+
});
|
|
1187
1208
|
myTransaction?.subject.next(child.transactionMeta.update);
|
|
1188
1209
|
store.logger.info(
|
|
1189
1210
|
`\u{1F6EC}`,
|
|
@@ -1239,13 +1260,13 @@ ${disposal.trace}` : `No previous disposal trace was found.`
|
|
|
1239
1260
|
if (store.defaults.has(family.key)) {
|
|
1240
1261
|
return store.defaults.get(token.family.key);
|
|
1241
1262
|
}
|
|
1242
|
-
const defaultValue = withdraw(
|
|
1263
|
+
const defaultValue = withdraw(store, family).default(subKey);
|
|
1243
1264
|
store.defaults.set(family.key, defaultValue);
|
|
1244
1265
|
return defaultValue;
|
|
1245
1266
|
}
|
|
1246
1267
|
}
|
|
1247
1268
|
}
|
|
1248
|
-
return readOrComputeValue(withdraw(
|
|
1269
|
+
return readOrComputeValue(store, withdraw(store, token));
|
|
1249
1270
|
}
|
|
1250
1271
|
|
|
1251
1272
|
// ../atom.io/internal/src/junction.ts
|
|
@@ -1304,8 +1325,8 @@ var Junction = class {
|
|
|
1304
1325
|
}
|
|
1305
1326
|
replaceRelationsSafely(x, ys) {
|
|
1306
1327
|
const xRelationsPrev = this.relations.get(x);
|
|
1307
|
-
let a = this.isAType?.(x) ? x :
|
|
1308
|
-
let b = a ===
|
|
1328
|
+
let a = this.isAType?.(x) ? x : void 0;
|
|
1329
|
+
let b = a === void 0 ? x : void 0;
|
|
1309
1330
|
if (xRelationsPrev) {
|
|
1310
1331
|
for (const y of xRelationsPrev) {
|
|
1311
1332
|
a ??= y;
|
|
@@ -1387,8 +1408,8 @@ var Junction = class {
|
|
|
1387
1408
|
};
|
|
1388
1409
|
}
|
|
1389
1410
|
for (const [x, ys] of data.relations ?? []) {
|
|
1390
|
-
let a = this.isAType?.(x) ? x :
|
|
1391
|
-
let b = a ===
|
|
1411
|
+
let a = this.isAType?.(x) ? x : void 0;
|
|
1412
|
+
let b = a === void 0 ? x : void 0;
|
|
1392
1413
|
for (const y of ys) {
|
|
1393
1414
|
a ??= y;
|
|
1394
1415
|
b ??= y;
|
|
@@ -1422,7 +1443,7 @@ var Junction = class {
|
|
|
1422
1443
|
const relation = params[0];
|
|
1423
1444
|
a = relation[this.a];
|
|
1424
1445
|
b = relation[this.b];
|
|
1425
|
-
content =
|
|
1446
|
+
content = void 0;
|
|
1426
1447
|
break;
|
|
1427
1448
|
}
|
|
1428
1449
|
case 2: {
|
|
@@ -1449,10 +1470,12 @@ var Junction = class {
|
|
|
1449
1470
|
const bPrev = this.getRelatedKey(a);
|
|
1450
1471
|
if (bPrev && bPrev !== b) this.delete(a, bPrev);
|
|
1451
1472
|
}
|
|
1452
|
-
case `1:n`:
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1473
|
+
case `1:n`:
|
|
1474
|
+
{
|
|
1475
|
+
const aPrev = this.getRelatedKey(b);
|
|
1476
|
+
if (aPrev && aPrev !== a) this.delete(aPrev, b);
|
|
1477
|
+
}
|
|
1478
|
+
break;
|
|
1456
1479
|
}
|
|
1457
1480
|
if (content) {
|
|
1458
1481
|
const contentKey = this.makeContentKey(a, b);
|
|
@@ -1467,7 +1490,7 @@ var Junction = class {
|
|
|
1467
1490
|
// @ts-expect-error we deduce that this.a may index x
|
|
1468
1491
|
typeof x === `string` ? x : x[this.a]
|
|
1469
1492
|
);
|
|
1470
|
-
if (a ===
|
|
1493
|
+
if (a === void 0 && typeof b === `string`) {
|
|
1471
1494
|
const bRelations = this.getRelatedKeys(b);
|
|
1472
1495
|
if (bRelations) {
|
|
1473
1496
|
for (const bRelation of bRelations) {
|
|
@@ -1475,7 +1498,7 @@ var Junction = class {
|
|
|
1475
1498
|
}
|
|
1476
1499
|
}
|
|
1477
1500
|
}
|
|
1478
|
-
if (typeof a === `string` && b ===
|
|
1501
|
+
if (typeof a === `string` && b === void 0) {
|
|
1479
1502
|
const aRelations = this.getRelatedKeys(a);
|
|
1480
1503
|
if (aRelations) {
|
|
1481
1504
|
for (const aRelation of aRelations) {
|
|
@@ -1532,7 +1555,7 @@ var Junction = class {
|
|
|
1532
1555
|
getRelationEntries(input) {
|
|
1533
1556
|
const a = input[this.a];
|
|
1534
1557
|
const b = input[this.b];
|
|
1535
|
-
if (a !==
|
|
1558
|
+
if (a !== void 0 && b === void 0) {
|
|
1536
1559
|
const aRelations = this.getRelatedKeys(a);
|
|
1537
1560
|
if (aRelations) {
|
|
1538
1561
|
return [...aRelations].map((aRelation) => {
|
|
@@ -1540,7 +1563,7 @@ var Junction = class {
|
|
|
1540
1563
|
});
|
|
1541
1564
|
}
|
|
1542
1565
|
}
|
|
1543
|
-
if (a ===
|
|
1566
|
+
if (a === void 0 && b !== void 0) {
|
|
1544
1567
|
const bRelations = this.getRelatedKeys(b);
|
|
1545
1568
|
if (bRelations) {
|
|
1546
1569
|
return [...bRelations].map((bRelation) => {
|
|
@@ -1575,7 +1598,7 @@ var LazyMap = class extends Map {
|
|
|
1575
1598
|
const value = this.source.get(key);
|
|
1576
1599
|
return value;
|
|
1577
1600
|
}
|
|
1578
|
-
return
|
|
1601
|
+
return void 0;
|
|
1579
1602
|
}
|
|
1580
1603
|
set(key, value) {
|
|
1581
1604
|
this.deleted.delete(key);
|
|
@@ -1594,7 +1617,7 @@ var LazyMap = class extends Map {
|
|
|
1594
1617
|
};
|
|
1595
1618
|
|
|
1596
1619
|
// ../atom.io/internal/src/transaction/build-transaction.ts
|
|
1597
|
-
var buildTransaction = (key, params,
|
|
1620
|
+
var buildTransaction = (store, key, params, id) => {
|
|
1598
1621
|
const parent = newest(store);
|
|
1599
1622
|
const childBase = {
|
|
1600
1623
|
parent,
|
|
@@ -1633,26 +1656,25 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
1633
1656
|
}),
|
|
1634
1657
|
miscResources: new LazyMap(parent.miscResources)
|
|
1635
1658
|
};
|
|
1636
|
-
const epoch = getEpochNumberOfAction(
|
|
1659
|
+
const epoch = getEpochNumberOfAction(store, key);
|
|
1637
1660
|
const transactionMeta = {
|
|
1638
1661
|
phase: `building`,
|
|
1639
1662
|
update: {
|
|
1640
1663
|
type: `transaction_update`,
|
|
1641
1664
|
key,
|
|
1642
1665
|
id,
|
|
1643
|
-
epoch: epoch ===
|
|
1666
|
+
epoch: epoch === void 0 ? Number.NaN : epoch + 1,
|
|
1644
1667
|
updates: [],
|
|
1645
1668
|
params,
|
|
1646
|
-
output:
|
|
1669
|
+
output: void 0
|
|
1647
1670
|
},
|
|
1648
1671
|
toolkit: {
|
|
1649
1672
|
get: (...ps) => getFromStore(child, ...ps),
|
|
1650
1673
|
set: (...ps) => {
|
|
1651
1674
|
setIntoStore(child, ...ps);
|
|
1652
1675
|
},
|
|
1653
|
-
run: (token, identifier = arbitrary()) => actUponStore(token, identifier
|
|
1676
|
+
run: (token, identifier = arbitrary()) => actUponStore(child, token, identifier),
|
|
1654
1677
|
find: (token, k) => findInStore(child, token, k),
|
|
1655
|
-
seek: (token, k) => seekInStore(child, token, k),
|
|
1656
1678
|
json: (token) => getJsonToken(child, token),
|
|
1657
1679
|
dispose: (...ps) => {
|
|
1658
1680
|
disposeFromStore(child, ...ps);
|
|
@@ -1675,12 +1697,12 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
1675
1697
|
};
|
|
1676
1698
|
|
|
1677
1699
|
// ../atom.io/internal/src/transaction/create-transaction.ts
|
|
1678
|
-
function createTransaction(
|
|
1700
|
+
function createTransaction(store, options) {
|
|
1679
1701
|
const newTransaction = {
|
|
1680
1702
|
key: options.key,
|
|
1681
1703
|
type: `transaction`,
|
|
1682
1704
|
run: (params, id) => {
|
|
1683
|
-
const childStore = buildTransaction(options.key, params,
|
|
1705
|
+
const childStore = buildTransaction(store, options.key, params, id);
|
|
1684
1706
|
try {
|
|
1685
1707
|
const target2 = newest(store);
|
|
1686
1708
|
const { toolkit } = childStore.transactionMeta;
|
|
@@ -1693,7 +1715,7 @@ function createTransaction(options, store) {
|
|
|
1693
1715
|
throw thrown;
|
|
1694
1716
|
}
|
|
1695
1717
|
},
|
|
1696
|
-
install: (s) => createTransaction(
|
|
1718
|
+
install: (s) => createTransaction(s, options),
|
|
1697
1719
|
subject: new Subject()
|
|
1698
1720
|
};
|
|
1699
1721
|
const target = newest(store);
|
|
@@ -1704,16 +1726,16 @@ function createTransaction(options, store) {
|
|
|
1704
1726
|
}
|
|
1705
1727
|
|
|
1706
1728
|
// ../atom.io/internal/src/transaction/get-epoch-number.ts
|
|
1707
|
-
function getEpochNumberOfAction(
|
|
1729
|
+
function getEpochNumberOfAction(store, transactionKey) {
|
|
1708
1730
|
const isRoot = isRootStore(store);
|
|
1709
|
-
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) :
|
|
1710
|
-
const epoch = isRoot && continuity !==
|
|
1731
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
1732
|
+
const epoch = isRoot && continuity !== void 0 ? store.transactionMeta.epoch.get(continuity) : void 0;
|
|
1711
1733
|
return epoch;
|
|
1712
1734
|
}
|
|
1713
1735
|
|
|
1714
1736
|
// ../atom.io/src/transaction.ts
|
|
1715
1737
|
function transaction(options) {
|
|
1716
|
-
return createTransaction(
|
|
1738
|
+
return createTransaction(IMPLICIT.STORE, options);
|
|
1717
1739
|
}
|
|
1718
1740
|
|
|
1719
1741
|
// ../atom.io/internal/src/store/store.ts
|
|
@@ -1884,7 +1906,7 @@ var IMPLICIT = {
|
|
|
1884
1906
|
};
|
|
1885
1907
|
|
|
1886
1908
|
// ../atom.io/internal/src/store/withdraw.ts
|
|
1887
|
-
function withdraw(
|
|
1909
|
+
function withdraw(store, token) {
|
|
1888
1910
|
let withdrawn;
|
|
1889
1911
|
let target = store;
|
|
1890
1912
|
while (target !== null) {
|
|
@@ -1923,7 +1945,7 @@ function withdraw(token, store) {
|
|
|
1923
1945
|
// ../atom.io/internal/src/families/init-family-member.ts
|
|
1924
1946
|
function initFamilyMemberInStore(store, token, key) {
|
|
1925
1947
|
const family = store.families.get(token.key);
|
|
1926
|
-
if (family ===
|
|
1948
|
+
if (family === void 0) {
|
|
1927
1949
|
throw new NotFoundError(token, store);
|
|
1928
1950
|
}
|
|
1929
1951
|
const state = family(key);
|
|
@@ -2012,40 +2034,37 @@ function disposeFromStore(store, ...params) {
|
|
|
2012
2034
|
token = maybeToken;
|
|
2013
2035
|
}
|
|
2014
2036
|
try {
|
|
2015
|
-
withdraw(
|
|
2037
|
+
withdraw(store, token);
|
|
2016
2038
|
} catch (thrown) {
|
|
2017
2039
|
store.logger.error(
|
|
2018
2040
|
`\u274C`,
|
|
2019
2041
|
token.type,
|
|
2020
2042
|
token.key,
|
|
2021
2043
|
`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
2044
|
);
|
|
2026
2045
|
return;
|
|
2027
2046
|
}
|
|
2028
2047
|
switch (token.type) {
|
|
2029
2048
|
case `atom`:
|
|
2030
2049
|
case `mutable_atom`:
|
|
2031
|
-
disposeAtom(
|
|
2050
|
+
disposeAtom(store, token);
|
|
2032
2051
|
break;
|
|
2033
2052
|
case `selector`:
|
|
2034
2053
|
case `readonly_selector`:
|
|
2035
|
-
disposeSelector(
|
|
2054
|
+
disposeSelector(store, token);
|
|
2036
2055
|
break;
|
|
2037
2056
|
}
|
|
2038
2057
|
}
|
|
2039
2058
|
|
|
2040
2059
|
// ../atom.io/internal/src/keys.ts
|
|
2041
|
-
var isAtomKey = (
|
|
2042
|
-
var isSelectorKey = (
|
|
2043
|
-
var isReadonlySelectorKey = (
|
|
2044
|
-
var isStateKey = (
|
|
2060
|
+
var isAtomKey = (store, key) => newest(store).atoms.has(key);
|
|
2061
|
+
var isSelectorKey = (store, key) => newest(store).selectors.has(key);
|
|
2062
|
+
var isReadonlySelectorKey = (store, key) => newest(store).readonlySelectors.has(key);
|
|
2063
|
+
var isStateKey = (store, key) => isAtomKey(store, key) || isSelectorKey(store, key) || isReadonlySelectorKey(store, key);
|
|
2045
2064
|
|
|
2046
2065
|
// ../atom.io/internal/src/selector/get-selector-dependency-keys.ts
|
|
2047
2066
|
var getSelectorDependencyKeys = (key, store) => {
|
|
2048
|
-
const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(
|
|
2067
|
+
const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(store, source));
|
|
2049
2068
|
return sources;
|
|
2050
2069
|
};
|
|
2051
2070
|
|
|
@@ -2062,7 +2081,7 @@ var traceSelectorAtoms = (directDependencyKey, covered, store) => {
|
|
|
2062
2081
|
continue;
|
|
2063
2082
|
}
|
|
2064
2083
|
covered.add(indirectDependencyKey);
|
|
2065
|
-
if (!isAtomKey(
|
|
2084
|
+
if (!isAtomKey(store, indirectDependencyKey)) {
|
|
2066
2085
|
indirectDependencyKeys.push(
|
|
2067
2086
|
...getSelectorDependencyKeys(indirectDependencyKey, store)
|
|
2068
2087
|
);
|
|
@@ -2077,7 +2096,7 @@ var traceAllSelectorAtoms = (selector, store) => {
|
|
|
2077
2096
|
const directDependencyKeys = getSelectorDependencyKeys(selectorKey, store);
|
|
2078
2097
|
const covered = /* @__PURE__ */ new Set();
|
|
2079
2098
|
return directDependencyKeys.flatMap(
|
|
2080
|
-
(depKey) => isAtomKey(
|
|
2099
|
+
(depKey) => isAtomKey(store, depKey) ? depKey : traceSelectorAtoms(depKey, covered, store)
|
|
2081
2100
|
);
|
|
2082
2101
|
};
|
|
2083
2102
|
|
|
@@ -2124,8 +2143,8 @@ var registerSelector = (selectorKey, covered, store) => ({
|
|
|
2124
2143
|
} else {
|
|
2125
2144
|
[dependency] = params;
|
|
2126
2145
|
}
|
|
2127
|
-
const dependencyState = withdraw(
|
|
2128
|
-
const dependencyValue = readOrComputeValue(
|
|
2146
|
+
const dependencyState = withdraw(store, dependency);
|
|
2147
|
+
const dependencyValue = readOrComputeValue(store, dependencyState);
|
|
2129
2148
|
store.logger.info(
|
|
2130
2149
|
`\u{1F50C}`,
|
|
2131
2150
|
`selector`,
|
|
@@ -2159,11 +2178,10 @@ var registerSelector = (selectorKey, covered, store) => ({
|
|
|
2159
2178
|
token = findInStore(store, family, key);
|
|
2160
2179
|
}
|
|
2161
2180
|
const target = newest(store);
|
|
2162
|
-
const state = withdraw(
|
|
2163
|
-
setAtomOrSelector(state, value
|
|
2181
|
+
const state = withdraw(target, token);
|
|
2182
|
+
setAtomOrSelector(target, state, value);
|
|
2164
2183
|
},
|
|
2165
2184
|
find: (token, key) => findInStore(store, token, key),
|
|
2166
|
-
seek: (token, key) => seekInStore(store, token, key),
|
|
2167
2185
|
json: (token) => getJsonToken(store, token)
|
|
2168
2186
|
});
|
|
2169
2187
|
|
|
@@ -2172,14 +2190,10 @@ var createReadonlySelector = (store, options, family) => {
|
|
|
2172
2190
|
const target = newest(store);
|
|
2173
2191
|
const subject = new Subject();
|
|
2174
2192
|
const covered = /* @__PURE__ */ new Set();
|
|
2175
|
-
const { get, find,
|
|
2176
|
-
options.key,
|
|
2177
|
-
covered,
|
|
2178
|
-
target
|
|
2179
|
-
);
|
|
2193
|
+
const { get, find, json } = registerSelector(options.key, covered, target);
|
|
2180
2194
|
const getSelf = () => {
|
|
2181
|
-
const value = options.get({ get, find,
|
|
2182
|
-
cacheValue(options.key, value, subject
|
|
2195
|
+
const value = options.get({ get, find, json });
|
|
2196
|
+
cacheValue(newest(store), options.key, value, subject);
|
|
2183
2197
|
covered.clear();
|
|
2184
2198
|
return value;
|
|
2185
2199
|
};
|
|
@@ -2216,11 +2230,11 @@ var createWritableSelector = (store, options, family) => {
|
|
|
2216
2230
|
const subject = new Subject();
|
|
2217
2231
|
const covered = /* @__PURE__ */ new Set();
|
|
2218
2232
|
const setterToolkit = registerSelector(options.key, covered, target);
|
|
2219
|
-
const { find, get,
|
|
2220
|
-
const getterToolkit = { find, get,
|
|
2233
|
+
const { find, get, json } = setterToolkit;
|
|
2234
|
+
const getterToolkit = { find, get, json };
|
|
2221
2235
|
const getSelf = (getFn = options.get, innerTarget = newest(store)) => {
|
|
2222
2236
|
const value = getFn(getterToolkit);
|
|
2223
|
-
cacheValue(options.key, value, subject
|
|
2237
|
+
cacheValue(innerTarget, options.key, value, subject);
|
|
2224
2238
|
covered.clear();
|
|
2225
2239
|
return value;
|
|
2226
2240
|
};
|
|
@@ -2238,7 +2252,7 @@ var createWritableSelector = (store, options, family) => {
|
|
|
2238
2252
|
newValue,
|
|
2239
2253
|
`)`
|
|
2240
2254
|
);
|
|
2241
|
-
cacheValue(options.key, newValue, subject
|
|
2255
|
+
cacheValue(innerTarget, options.key, newValue, subject);
|
|
2242
2256
|
markDone(innerTarget, options.key);
|
|
2243
2257
|
if (isRootStore(innerTarget)) {
|
|
2244
2258
|
subject.next({ newValue, oldValue });
|
|
@@ -2271,20 +2285,20 @@ var createWritableSelector = (store, options, family) => {
|
|
|
2271
2285
|
function createStandaloneSelector(store, options) {
|
|
2272
2286
|
const isWritable = `set` in options;
|
|
2273
2287
|
if (isWritable) {
|
|
2274
|
-
const state2 = createWritableSelector(store, options,
|
|
2288
|
+
const state2 = createWritableSelector(store, options, void 0);
|
|
2275
2289
|
store.on.selectorCreation.next(state2);
|
|
2276
2290
|
return state2;
|
|
2277
2291
|
}
|
|
2278
|
-
const state = createReadonlySelector(store, options,
|
|
2292
|
+
const state = createReadonlySelector(store, options, void 0);
|
|
2279
2293
|
store.on.selectorCreation.next(state);
|
|
2280
2294
|
return state;
|
|
2281
2295
|
}
|
|
2282
2296
|
|
|
2283
2297
|
// ../atom.io/internal/src/selector/dispose-selector.ts
|
|
2284
|
-
function disposeSelector(
|
|
2298
|
+
function disposeSelector(store, selectorToken) {
|
|
2285
2299
|
const target = newest(store);
|
|
2286
2300
|
const { key } = selectorToken;
|
|
2287
|
-
const selector = withdraw(
|
|
2301
|
+
const selector = withdraw(target, selectorToken);
|
|
2288
2302
|
if (!selector.family) {
|
|
2289
2303
|
store.logger.error(
|
|
2290
2304
|
`\u274C`,
|
|
@@ -2297,23 +2311,31 @@ function disposeSelector(selectorToken, store) {
|
|
|
2297
2311
|
if (molecule) {
|
|
2298
2312
|
target.moleculeData.delete(selector.family.subKey, selector.family.key);
|
|
2299
2313
|
}
|
|
2314
|
+
let familyToken;
|
|
2300
2315
|
switch (selectorToken.type) {
|
|
2301
2316
|
case `selector`:
|
|
2302
2317
|
{
|
|
2303
2318
|
target.selectors.delete(key);
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2319
|
+
familyToken = {
|
|
2320
|
+
key: selector.family.key,
|
|
2321
|
+
type: `selector_family`
|
|
2322
|
+
};
|
|
2323
|
+
const family = withdraw(store, familyToken);
|
|
2324
|
+
family.subject.next({
|
|
2325
|
+
type: `state_disposal`,
|
|
2326
|
+
subType: `selector`,
|
|
2327
|
+
token: selectorToken
|
|
2328
|
+
});
|
|
2308
2329
|
}
|
|
2309
2330
|
break;
|
|
2310
2331
|
case `readonly_selector`:
|
|
2311
2332
|
{
|
|
2312
2333
|
target.readonlySelectors.delete(key);
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2334
|
+
familyToken = {
|
|
2335
|
+
key: selector.family.key,
|
|
2336
|
+
type: `readonly_selector_family`
|
|
2337
|
+
};
|
|
2338
|
+
const family = withdraw(store, familyToken);
|
|
2317
2339
|
family.subject.next({
|
|
2318
2340
|
type: `state_disposal`,
|
|
2319
2341
|
subType: `selector`,
|
|
@@ -2382,7 +2404,6 @@ function createWritableSelectorFamily(store, options, internalRoles) {
|
|
|
2382
2404
|
return getFn({
|
|
2383
2405
|
get: (...ps) => getFromStore(store, ...ps),
|
|
2384
2406
|
find: (token, k) => findInStore(store, token, k),
|
|
2385
|
-
seek: (token, k) => seekInStore(store, token, k),
|
|
2386
2407
|
json: (token) => getJsonToken(store, token)
|
|
2387
2408
|
});
|
|
2388
2409
|
}
|
|
@@ -2392,7 +2413,7 @@ function createWritableSelectorFamily(store, options, internalRoles) {
|
|
|
2392
2413
|
}
|
|
2393
2414
|
|
|
2394
2415
|
// ../atom.io/json/src/select-json-family.ts
|
|
2395
|
-
function selectJsonFamily(atomFamilyToken, transform
|
|
2416
|
+
function selectJsonFamily(store, atomFamilyToken, transform) {
|
|
2396
2417
|
const jsonFamily = createWritableSelectorFamily(
|
|
2397
2418
|
store,
|
|
2398
2419
|
{
|
|
@@ -2407,15 +2428,6 @@ function selectJsonFamily(atomFamilyToken, transform, store = IMPLICIT.STORE) {
|
|
|
2407
2428
|
},
|
|
2408
2429
|
[`mutable`, `json`]
|
|
2409
2430
|
);
|
|
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
2431
|
return jsonFamily;
|
|
2420
2432
|
}
|
|
2421
2433
|
|
|
@@ -2424,7 +2436,7 @@ var parseJson = (str) => JSON.parse(str);
|
|
|
2424
2436
|
var stringifyJson = (json) => JSON.stringify(json);
|
|
2425
2437
|
|
|
2426
2438
|
// ../atom.io/internal/src/subscribe/recall-state.ts
|
|
2427
|
-
var recallState = (
|
|
2439
|
+
var recallState = (store, state) => {
|
|
2428
2440
|
const target = newest(store);
|
|
2429
2441
|
if (target.operation.open) {
|
|
2430
2442
|
return target.operation.prev.get(state.key);
|
|
@@ -2433,12 +2445,12 @@ var recallState = (state, store) => {
|
|
|
2433
2445
|
};
|
|
2434
2446
|
|
|
2435
2447
|
// ../atom.io/internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
2436
|
-
var subscribeToRootAtoms = (
|
|
2448
|
+
var subscribeToRootAtoms = (store, selector) => {
|
|
2437
2449
|
const target = newest(store);
|
|
2438
2450
|
const dependencySubscriptions = traceAllSelectorAtoms(selector, store).map(
|
|
2439
2451
|
(atomKey) => {
|
|
2440
2452
|
const atom2 = target.atoms.get(atomKey);
|
|
2441
|
-
if (atom2 ===
|
|
2453
|
+
if (atom2 === void 0) {
|
|
2442
2454
|
throw new Error(
|
|
2443
2455
|
`Atom "${atomKey}", a dependency of selector "${selector.key}", not found in store "${store.config.name}".`
|
|
2444
2456
|
);
|
|
@@ -2457,8 +2469,8 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
2457
2469
|
`->`,
|
|
2458
2470
|
atomChange.newValue
|
|
2459
2471
|
);
|
|
2460
|
-
const oldValue = recallState(
|
|
2461
|
-
const newValue = readOrComputeValue(
|
|
2472
|
+
const oldValue = recallState(target, selector);
|
|
2473
|
+
const newValue = readOrComputeValue(target, selector);
|
|
2462
2474
|
store.logger.info(
|
|
2463
2475
|
`\u2728`,
|
|
2464
2476
|
selector.type,
|
|
@@ -2477,7 +2489,7 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
2477
2489
|
};
|
|
2478
2490
|
|
|
2479
2491
|
// ../atom.io/internal/src/subscribe/subscribe-to-state.ts
|
|
2480
|
-
function subscribeToState(
|
|
2492
|
+
function subscribeToState(store, token, key, handleUpdate) {
|
|
2481
2493
|
function safelyHandleUpdate(update) {
|
|
2482
2494
|
if (store.operation.open) {
|
|
2483
2495
|
const unsubscribe2 = store.on.operationClose.subscribe(
|
|
@@ -2491,17 +2503,17 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
2491
2503
|
handleUpdate(update);
|
|
2492
2504
|
}
|
|
2493
2505
|
}
|
|
2494
|
-
const state = withdraw(
|
|
2506
|
+
const state = withdraw(store, token);
|
|
2495
2507
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
2496
2508
|
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
2497
2509
|
let dependencyUnsubFunctions = null;
|
|
2498
2510
|
let updateHandler = safelyHandleUpdate;
|
|
2499
2511
|
if (isSelector) {
|
|
2500
|
-
dependencyUnsubFunctions = subscribeToRootAtoms(
|
|
2512
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(store, state);
|
|
2501
2513
|
updateHandler = (update) => {
|
|
2502
2514
|
if (dependencyUnsubFunctions) {
|
|
2503
2515
|
dependencyUnsubFunctions.length = 0;
|
|
2504
|
-
dependencyUnsubFunctions.push(...subscribeToRootAtoms(
|
|
2516
|
+
dependencyUnsubFunctions.push(...subscribeToRootAtoms(store, state));
|
|
2505
2517
|
}
|
|
2506
2518
|
safelyHandleUpdate(update);
|
|
2507
2519
|
};
|
|
@@ -2525,8 +2537,8 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
2525
2537
|
}
|
|
2526
2538
|
|
|
2527
2539
|
// ../atom.io/internal/src/subscribe/subscribe-to-timeline.ts
|
|
2528
|
-
var subscribeToTimeline = (
|
|
2529
|
-
const tl = withdraw(
|
|
2540
|
+
var subscribeToTimeline = (store, token, key, handleUpdate) => {
|
|
2541
|
+
const tl = withdraw(store, token);
|
|
2530
2542
|
store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
|
|
2531
2543
|
const unsubscribe = tl.subject.subscribe(key, handleUpdate);
|
|
2532
2544
|
return () => {
|
|
@@ -2550,7 +2562,7 @@ var Tracker = class {
|
|
|
2550
2562
|
const familyMetaData = mutableState.family ? {
|
|
2551
2563
|
key: `*${mutableState.family.key}`,
|
|
2552
2564
|
subKey: mutableState.family.subKey
|
|
2553
|
-
} :
|
|
2565
|
+
} : void 0;
|
|
2554
2566
|
const latestUpdateState = createRegularAtom(
|
|
2555
2567
|
store,
|
|
2556
2568
|
{
|
|
@@ -2577,7 +2589,9 @@ var Tracker = class {
|
|
|
2577
2589
|
}
|
|
2578
2590
|
);
|
|
2579
2591
|
this.unsubscribeFromState = subscribeToState(
|
|
2592
|
+
target,
|
|
2580
2593
|
mutableState,
|
|
2594
|
+
subscriptionKey,
|
|
2581
2595
|
(update) => {
|
|
2582
2596
|
if (update.newValue !== update.oldValue) {
|
|
2583
2597
|
this.unsubscribeFromInnerValue();
|
|
@@ -2588,15 +2602,15 @@ var Tracker = class {
|
|
|
2588
2602
|
}
|
|
2589
2603
|
);
|
|
2590
2604
|
}
|
|
2591
|
-
}
|
|
2592
|
-
subscriptionKey,
|
|
2593
|
-
target
|
|
2605
|
+
}
|
|
2594
2606
|
);
|
|
2595
2607
|
}
|
|
2596
2608
|
updateCore(mutableState, latestUpdateState, target) {
|
|
2597
2609
|
const subscriptionKey = `tracker:${target.config.name}:${isChildStore(target) ? target.transactionMeta.update.key : `main`}:${mutableState.key}`;
|
|
2598
2610
|
subscribeToState(
|
|
2611
|
+
target,
|
|
2599
2612
|
latestUpdateState,
|
|
2613
|
+
subscriptionKey,
|
|
2600
2614
|
({ newValue, oldValue }) => {
|
|
2601
2615
|
const timelineId = target.timelineTopics.getRelatedKey(
|
|
2602
2616
|
latestUpdateState.key
|
|
@@ -2605,7 +2619,9 @@ var Tracker = class {
|
|
|
2605
2619
|
const timelineData = target.timelines.get(timelineId);
|
|
2606
2620
|
if (timelineData?.timeTraveling) {
|
|
2607
2621
|
const unsubscribe2 = subscribeToTimeline(
|
|
2622
|
+
target,
|
|
2608
2623
|
{ key: timelineId, type: `timeline` },
|
|
2624
|
+
subscriptionKey,
|
|
2609
2625
|
(update) => {
|
|
2610
2626
|
unsubscribe2();
|
|
2611
2627
|
setIntoStore(target, mutableState, (transceiver) => {
|
|
@@ -2616,9 +2632,7 @@ var Tracker = class {
|
|
|
2616
2632
|
}
|
|
2617
2633
|
return transceiver;
|
|
2618
2634
|
});
|
|
2619
|
-
}
|
|
2620
|
-
subscriptionKey,
|
|
2621
|
-
target
|
|
2635
|
+
}
|
|
2622
2636
|
);
|
|
2623
2637
|
return;
|
|
2624
2638
|
}
|
|
@@ -2646,14 +2660,12 @@ var Tracker = class {
|
|
|
2646
2660
|
}
|
|
2647
2661
|
}
|
|
2648
2662
|
);
|
|
2649
|
-
}
|
|
2650
|
-
subscriptionKey,
|
|
2651
|
-
target
|
|
2663
|
+
}
|
|
2652
2664
|
);
|
|
2653
2665
|
}
|
|
2654
2666
|
mutableState;
|
|
2655
2667
|
latestUpdateState;
|
|
2656
|
-
dispose;
|
|
2668
|
+
[Symbol.dispose];
|
|
2657
2669
|
constructor(mutableState, store) {
|
|
2658
2670
|
this.mutableState = mutableState;
|
|
2659
2671
|
const target = newest(store);
|
|
@@ -2661,7 +2673,7 @@ var Tracker = class {
|
|
|
2661
2673
|
this.observeCore(mutableState, this.latestUpdateState, target);
|
|
2662
2674
|
this.updateCore(mutableState, this.latestUpdateState, target);
|
|
2663
2675
|
target.trackers.set(mutableState.key, this);
|
|
2664
|
-
this.dispose = () => {
|
|
2676
|
+
this[Symbol.dispose] = () => {
|
|
2665
2677
|
this.unsubscribeFromInnerValue();
|
|
2666
2678
|
this.unsubscribeFromState();
|
|
2667
2679
|
target.trackers.delete(mutableState.key);
|
|
@@ -2708,8 +2720,8 @@ function createMutableAtom(store, options, family) {
|
|
|
2708
2720
|
}
|
|
2709
2721
|
const initialValue = options.default();
|
|
2710
2722
|
target.atoms.set(newAtom.key, newAtom);
|
|
2711
|
-
markAtomAsDefault(options.key
|
|
2712
|
-
cacheValue(options.key, initialValue, subject
|
|
2723
|
+
markAtomAsDefault(store, options.key);
|
|
2724
|
+
cacheValue(target, options.key, initialValue, subject);
|
|
2713
2725
|
const token = deposit(newAtom);
|
|
2714
2726
|
if (options.effects) {
|
|
2715
2727
|
let effectIndex = 0;
|
|
@@ -2719,7 +2731,7 @@ function createMutableAtom(store, options, family) {
|
|
|
2719
2731
|
setSelf: (next) => {
|
|
2720
2732
|
setIntoStore(store, token, next);
|
|
2721
2733
|
},
|
|
2722
|
-
onSet: (handle) => subscribeToState(
|
|
2734
|
+
onSet: (handle) => subscribeToState(store, token, `effect[${effectIndex}]`, handle)
|
|
2723
2735
|
});
|
|
2724
2736
|
if (cleanup) {
|
|
2725
2737
|
cleanupFunctions.push(cleanup);
|
|
@@ -2741,6 +2753,7 @@ function createMutableAtom(store, options, family) {
|
|
|
2741
2753
|
|
|
2742
2754
|
// ../atom.io/internal/src/mutable/tracker-family.ts
|
|
2743
2755
|
var FamilyTracker = class {
|
|
2756
|
+
trackers = /* @__PURE__ */ new Map();
|
|
2744
2757
|
Update;
|
|
2745
2758
|
latestUpdateAtoms;
|
|
2746
2759
|
mutableAtoms;
|
|
@@ -2753,26 +2766,27 @@ var FamilyTracker = class {
|
|
|
2753
2766
|
},
|
|
2754
2767
|
[`mutable`, `updates`]
|
|
2755
2768
|
);
|
|
2756
|
-
this.latestUpdateAtoms = withdraw(
|
|
2769
|
+
this.latestUpdateAtoms = withdraw(store, updateAtoms);
|
|
2757
2770
|
this.mutableAtoms = mutableAtoms;
|
|
2758
2771
|
this.mutableAtoms.subject.subscribe(
|
|
2759
2772
|
`store=${store.config.name}::tracker-atom-family`,
|
|
2760
2773
|
(event) => {
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2774
|
+
const { type, token } = event;
|
|
2775
|
+
if (token.family) {
|
|
2776
|
+
const key = parseJson(token.family.subKey);
|
|
2777
|
+
switch (type) {
|
|
2778
|
+
case `state_creation`:
|
|
2779
|
+
this.trackers.set(key, new Tracker(token, store));
|
|
2780
|
+
break;
|
|
2781
|
+
case `state_disposal`:
|
|
2782
|
+
{
|
|
2783
|
+
const tracker = this.trackers.get(key);
|
|
2784
|
+
if (tracker) {
|
|
2785
|
+
tracker[Symbol.dispose]();
|
|
2786
|
+
this.trackers.delete(key);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
break;
|
|
2776
2790
|
}
|
|
2777
2791
|
}
|
|
2778
2792
|
}
|
|
@@ -2825,7 +2839,7 @@ function createMutableAtomFamily(store, options, internalRoles) {
|
|
|
2825
2839
|
internalRoles
|
|
2826
2840
|
});
|
|
2827
2841
|
store.families.set(options.key, atomFamily2);
|
|
2828
|
-
selectJsonFamily(atomFamily2, options
|
|
2842
|
+
selectJsonFamily(store, atomFamily2, options);
|
|
2829
2843
|
new FamilyTracker(atomFamily2, store);
|
|
2830
2844
|
return familyToken;
|
|
2831
2845
|
}
|
|
@@ -2847,7 +2861,7 @@ var getJsonToken = (store, mutableAtomToken) => {
|
|
|
2847
2861
|
key: jsonFamilyKey,
|
|
2848
2862
|
type: `selector_family`
|
|
2849
2863
|
};
|
|
2850
|
-
const family = withdraw(
|
|
2864
|
+
const family = withdraw(target, jsonFamilyToken);
|
|
2851
2865
|
const subKey = JSON.parse(mutableAtomToken.family.subKey);
|
|
2852
2866
|
const jsonToken = findInStore(store, family, subKey);
|
|
2853
2867
|
return jsonToken;
|
|
@@ -2878,11 +2892,11 @@ function isTransceiver(value) {
|
|
|
2878
2892
|
}
|
|
2879
2893
|
|
|
2880
2894
|
// ../atom.io/internal/src/set-state/copy-mutable-if-needed.ts
|
|
2881
|
-
function copyMutableIfNeeded(atom2, origin
|
|
2895
|
+
function copyMutableIfNeeded(target, atom2, origin) {
|
|
2882
2896
|
const originValue = origin.valueMap.get(atom2.key);
|
|
2883
2897
|
const targetValue = target.valueMap.get(atom2.key);
|
|
2884
2898
|
if (originValue === targetValue) {
|
|
2885
|
-
if (originValue ===
|
|
2899
|
+
if (originValue === void 0) {
|
|
2886
2900
|
return typeof atom2.default === `function` ? atom2.default() : atom2.default;
|
|
2887
2901
|
}
|
|
2888
2902
|
origin.logger.info(`\u{1F4C3}`, `atom`, atom2.key, `copying`);
|
|
@@ -2896,7 +2910,7 @@ function copyMutableIfNeeded(atom2, origin, target) {
|
|
|
2896
2910
|
}
|
|
2897
2911
|
|
|
2898
2912
|
// ../atom.io/internal/src/caching.ts
|
|
2899
|
-
function cacheValue(key, value, subject
|
|
2913
|
+
function cacheValue(target, key, value, subject) {
|
|
2900
2914
|
const currentValue = target.valueMap.get(key);
|
|
2901
2915
|
if (currentValue instanceof Future) {
|
|
2902
2916
|
const future = currentValue;
|
|
@@ -2906,7 +2920,7 @@ function cacheValue(key, value, subject, target) {
|
|
|
2906
2920
|
const future = new Future(value);
|
|
2907
2921
|
target.valueMap.set(key, future);
|
|
2908
2922
|
future.then((resolved) => {
|
|
2909
|
-
cacheValue(key, resolved, subject
|
|
2923
|
+
cacheValue(target, key, resolved, subject);
|
|
2910
2924
|
subject.next({ newValue: resolved, oldValue: future });
|
|
2911
2925
|
}).catch((thrown) => {
|
|
2912
2926
|
target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
@@ -2920,7 +2934,7 @@ var readCachedValue = (token, target) => {
|
|
|
2920
2934
|
let value = target.valueMap.get(token.key);
|
|
2921
2935
|
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
2922
2936
|
const { parent } = target;
|
|
2923
|
-
const copiedValue = copyMutableIfNeeded(token, parent
|
|
2937
|
+
const copiedValue = copyMutableIfNeeded(target, token, parent);
|
|
2924
2938
|
value = copiedValue;
|
|
2925
2939
|
}
|
|
2926
2940
|
return value;
|
|
@@ -2943,15 +2957,15 @@ var evictCachedValue = (key, target) => {
|
|
|
2943
2957
|
};
|
|
2944
2958
|
|
|
2945
2959
|
// ../atom.io/internal/src/atom/is-default.ts
|
|
2946
|
-
var isAtomDefault = (
|
|
2960
|
+
var isAtomDefault = (store, key) => {
|
|
2947
2961
|
const core = newest(store);
|
|
2948
2962
|
return core.atomsThatAreDefault.has(key);
|
|
2949
2963
|
};
|
|
2950
|
-
var markAtomAsDefault = (
|
|
2964
|
+
var markAtomAsDefault = (store, key) => {
|
|
2951
2965
|
const core = newest(store);
|
|
2952
2966
|
core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key);
|
|
2953
2967
|
};
|
|
2954
|
-
var markAtomAsNotDefault = (
|
|
2968
|
+
var markAtomAsNotDefault = (store, key) => {
|
|
2955
2969
|
const core = newest(store);
|
|
2956
2970
|
core.atomsThatAreDefault = new Set(newest(store).atomsThatAreDefault);
|
|
2957
2971
|
core.atomsThatAreDefault.delete(key);
|
|
@@ -2999,8 +3013,8 @@ function createRegularAtom(store, options, family) {
|
|
|
2999
3013
|
initialValue = options.default();
|
|
3000
3014
|
}
|
|
3001
3015
|
target.atoms.set(newAtom.key, newAtom);
|
|
3002
|
-
markAtomAsDefault(options.key
|
|
3003
|
-
cacheValue(options.key, initialValue, subject
|
|
3016
|
+
markAtomAsDefault(store, options.key);
|
|
3017
|
+
cacheValue(target, options.key, initialValue, subject);
|
|
3004
3018
|
const token = deposit(newAtom);
|
|
3005
3019
|
if (options.effects) {
|
|
3006
3020
|
let effectIndex = 0;
|
|
@@ -3010,7 +3024,7 @@ function createRegularAtom(store, options, family) {
|
|
|
3010
3024
|
setSelf: (next) => {
|
|
3011
3025
|
setIntoStore(store, token, next);
|
|
3012
3026
|
},
|
|
3013
|
-
onSet: (handle) => subscribeToState(
|
|
3027
|
+
onSet: (handle) => subscribeToState(store, token, `effect[${effectIndex}]`, handle)
|
|
3014
3028
|
});
|
|
3015
3029
|
if (cleanup) {
|
|
3016
3030
|
cleanupFunctions.push(cleanup);
|
|
@@ -3030,26 +3044,26 @@ function createRegularAtom(store, options, family) {
|
|
|
3030
3044
|
function createStandaloneAtom(store, options) {
|
|
3031
3045
|
const isMutable = `mutable` in options;
|
|
3032
3046
|
if (isMutable) {
|
|
3033
|
-
const state2 = createMutableAtom(store, options,
|
|
3047
|
+
const state2 = createMutableAtom(store, options, void 0);
|
|
3034
3048
|
store.on.atomCreation.next(state2);
|
|
3035
3049
|
return state2;
|
|
3036
3050
|
}
|
|
3037
|
-
const state = createRegularAtom(store, options,
|
|
3051
|
+
const state = createRegularAtom(store, options, void 0);
|
|
3038
3052
|
store.on.atomCreation.next(state);
|
|
3039
3053
|
return state;
|
|
3040
3054
|
}
|
|
3041
3055
|
|
|
3042
3056
|
// ../atom.io/internal/src/atom/dispose-atom.ts
|
|
3043
|
-
function disposeAtom(
|
|
3057
|
+
function disposeAtom(store, atomToken) {
|
|
3044
3058
|
const target = newest(store);
|
|
3045
3059
|
const { key, family } = atomToken;
|
|
3046
|
-
const atom2 = withdraw(
|
|
3060
|
+
const atom2 = withdraw(target, atomToken);
|
|
3047
3061
|
if (!family) {
|
|
3048
3062
|
store.logger.error(`\u274C`, `atom`, key, `Standalone atoms cannot be disposed.`);
|
|
3049
3063
|
} else {
|
|
3050
3064
|
atom2.cleanup?.();
|
|
3051
3065
|
const lastValue = store.valueMap.get(atom2.key);
|
|
3052
|
-
const atomFamily2 = withdraw({ key: family.key, type: `atom_family` }
|
|
3066
|
+
const atomFamily2 = withdraw(store, { key: family.key, type: `atom_family` });
|
|
3053
3067
|
const disposal = {
|
|
3054
3068
|
type: `state_disposal`,
|
|
3055
3069
|
subType: `atom`,
|
|
@@ -3065,7 +3079,7 @@ function disposeAtom(atomToken, store) {
|
|
|
3065
3079
|
store.timelineTopics.delete(key);
|
|
3066
3080
|
if (atomToken.type === `mutable_atom`) {
|
|
3067
3081
|
const updateToken = getUpdateToken(atomToken);
|
|
3068
|
-
disposeAtom(
|
|
3082
|
+
disposeAtom(store, updateToken);
|
|
3069
3083
|
store.trackers.delete(key);
|
|
3070
3084
|
}
|
|
3071
3085
|
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
@@ -3082,211 +3096,6 @@ function disposeAtom(atomToken, store) {
|
|
|
3082
3096
|
}
|
|
3083
3097
|
}
|
|
3084
3098
|
|
|
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
3099
|
// ../atom.io/transceivers/set-rtx/src/set-rtx.ts
|
|
3291
3100
|
var SetRTX = class _SetRTX extends Set {
|
|
3292
3101
|
mode = `record`;
|
|
@@ -3499,10 +3308,7 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
3499
3308
|
}
|
|
3500
3309
|
};
|
|
3501
3310
|
|
|
3502
|
-
// ../atom.io/
|
|
3503
|
-
function capitalize2(string) {
|
|
3504
|
-
return string[0].toUpperCase() + string.slice(1);
|
|
3505
|
-
}
|
|
3311
|
+
// ../atom.io/internal/src/join/join-internal.ts
|
|
3506
3312
|
var Join = class {
|
|
3507
3313
|
toolkit;
|
|
3508
3314
|
options;
|
|
@@ -3534,7 +3340,6 @@ var Join = class {
|
|
|
3534
3340
|
setIntoStore(store, ...ps);
|
|
3535
3341
|
},
|
|
3536
3342
|
find: (...ps) => findInStore(store, ...ps),
|
|
3537
|
-
seek: (...ps) => seekInStore(store, ...ps),
|
|
3538
3343
|
json: (token) => getJsonToken(store, token)
|
|
3539
3344
|
};
|
|
3540
3345
|
const aSide = options.between[0];
|
|
@@ -3764,8 +3569,8 @@ var Join = class {
|
|
|
3764
3569
|
get: (x) => ({ get }) => {
|
|
3765
3570
|
const relatedKeys = get(relatedKeysAtoms, x);
|
|
3766
3571
|
for (const y of relatedKeys) {
|
|
3767
|
-
let a = relations.isAType?.(x) ? x :
|
|
3768
|
-
let b = a ===
|
|
3572
|
+
let a = relations.isAType?.(x) ? x : void 0;
|
|
3573
|
+
let b = a === void 0 ? x : void 0;
|
|
3769
3574
|
a ??= y;
|
|
3770
3575
|
b ??= y;
|
|
3771
3576
|
const contentKey = relations.makeContentKey(a, b);
|
|
@@ -3785,8 +3590,8 @@ var Join = class {
|
|
|
3785
3590
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
3786
3591
|
const json = get(jsonFamily, x);
|
|
3787
3592
|
return json.members.map((y) => {
|
|
3788
|
-
let a = relations.isAType?.(x) ? x :
|
|
3789
|
-
let b = a ===
|
|
3593
|
+
let a = relations.isAType?.(x) ? x : void 0;
|
|
3594
|
+
let b = a === void 0 ? x : void 0;
|
|
3790
3595
|
a ??= y;
|
|
3791
3596
|
b ??= y;
|
|
3792
3597
|
const contentKey = relations.makeContentKey(a, b);
|
|
@@ -3800,8 +3605,8 @@ var Join = class {
|
|
|
3800
3605
|
switch (options.cardinality) {
|
|
3801
3606
|
case `1:1`: {
|
|
3802
3607
|
const singleRelatedKeySelectors = createSingleKeySelectorFamily();
|
|
3803
|
-
const stateKeyA = `${aSide}KeyOf${
|
|
3804
|
-
const stateKeyB = `${bSide}KeyOf${
|
|
3608
|
+
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
3609
|
+
const stateKeyB = `${bSide}KeyOf${capitalize(aSide)}`;
|
|
3805
3610
|
const baseStates = {
|
|
3806
3611
|
[stateKeyA]: singleRelatedKeySelectors,
|
|
3807
3612
|
[stateKeyB]: singleRelatedKeySelectors
|
|
@@ -3809,8 +3614,8 @@ var Join = class {
|
|
|
3809
3614
|
let states;
|
|
3810
3615
|
if (defaultContent) {
|
|
3811
3616
|
const singleEntrySelectors = createSingleEntrySelectorFamily();
|
|
3812
|
-
const entriesStateKeyA = `${aSide}EntryOf${
|
|
3813
|
-
const entriesStateKeyB = `${bSide}EntryOf${
|
|
3617
|
+
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
3618
|
+
const entriesStateKeyB = `${bSide}EntryOf${capitalize(aSide)}`;
|
|
3814
3619
|
const contentStates = {
|
|
3815
3620
|
[entriesStateKeyA]: singleEntrySelectors,
|
|
3816
3621
|
[entriesStateKeyB]: singleEntrySelectors
|
|
@@ -3826,8 +3631,8 @@ var Join = class {
|
|
|
3826
3631
|
case `1:n`: {
|
|
3827
3632
|
const singleRelatedKeySelectors = createSingleKeySelectorFamily();
|
|
3828
3633
|
const multipleRelatedKeysSelectors = getMultipleKeySelectorFamily();
|
|
3829
|
-
const stateKeyA = `${aSide}KeyOf${
|
|
3830
|
-
const stateKeyB = `${bSide}KeysOf${
|
|
3634
|
+
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
3635
|
+
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
3831
3636
|
const baseStates = {
|
|
3832
3637
|
[stateKeyA]: singleRelatedKeySelectors,
|
|
3833
3638
|
[stateKeyB]: multipleRelatedKeysSelectors
|
|
@@ -3836,8 +3641,8 @@ var Join = class {
|
|
|
3836
3641
|
if (defaultContent) {
|
|
3837
3642
|
const singleRelatedEntrySelectors = createSingleEntrySelectorFamily();
|
|
3838
3643
|
const multipleRelatedEntriesSelectors = getMultipleEntrySelectorFamily();
|
|
3839
|
-
const entriesStateKeyA = `${aSide}EntryOf${
|
|
3840
|
-
const entriesStateKeyB = `${bSide}EntriesOf${
|
|
3644
|
+
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
3645
|
+
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(
|
|
3841
3646
|
aSide
|
|
3842
3647
|
)}`;
|
|
3843
3648
|
const contentStates = {
|
|
@@ -3852,10 +3657,10 @@ var Join = class {
|
|
|
3852
3657
|
this.states = states;
|
|
3853
3658
|
break;
|
|
3854
3659
|
}
|
|
3855
|
-
|
|
3660
|
+
case `n:n`: {
|
|
3856
3661
|
const multipleRelatedKeysSelectors = getMultipleKeySelectorFamily();
|
|
3857
|
-
const stateKeyA = `${aSide}KeysOf${
|
|
3858
|
-
const stateKeyB = `${bSide}KeysOf${
|
|
3662
|
+
const stateKeyA = `${aSide}KeysOf${capitalize(bSide)}`;
|
|
3663
|
+
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
3859
3664
|
const baseStates = {
|
|
3860
3665
|
[stateKeyA]: multipleRelatedKeysSelectors,
|
|
3861
3666
|
[stateKeyB]: multipleRelatedKeysSelectors
|
|
@@ -3863,10 +3668,10 @@ var Join = class {
|
|
|
3863
3668
|
let states;
|
|
3864
3669
|
if (defaultContent) {
|
|
3865
3670
|
const multipleRelatedEntriesSelectors = getMultipleEntrySelectorFamily();
|
|
3866
|
-
const entriesStateKeyA = `${aSide}EntriesOf${
|
|
3671
|
+
const entriesStateKeyA = `${aSide}EntriesOf${capitalize(
|
|
3867
3672
|
bSide
|
|
3868
3673
|
)}`;
|
|
3869
|
-
const entriesStateKeyB = `${bSide}EntriesOf${
|
|
3674
|
+
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(
|
|
3870
3675
|
aSide
|
|
3871
3676
|
)}`;
|
|
3872
3677
|
const contentStates = {
|
|
@@ -3883,23 +3688,14 @@ var Join = class {
|
|
|
3883
3688
|
}
|
|
3884
3689
|
}
|
|
3885
3690
|
};
|
|
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
|
-
}
|
|
3691
|
+
|
|
3692
|
+
// ../atom.io/internal/src/join/get-join.ts
|
|
3897
3693
|
function getJoin(token, store) {
|
|
3898
3694
|
let myJoin = store.joins.get(token.key);
|
|
3899
|
-
if (myJoin ===
|
|
3695
|
+
if (myJoin === void 0) {
|
|
3900
3696
|
const rootJoinMap = IMPLICIT.STORE.joins;
|
|
3901
3697
|
const rootJoin = rootJoinMap.get(token.key);
|
|
3902
|
-
if (rootJoin ===
|
|
3698
|
+
if (rootJoin === void 0) {
|
|
3903
3699
|
throw new Error(
|
|
3904
3700
|
`Join "${token.key}" not found in store "${store.config.name}"`
|
|
3905
3701
|
);
|
|
@@ -3909,6 +3705,8 @@ function getJoin(token, store) {
|
|
|
3909
3705
|
}
|
|
3910
3706
|
return myJoin;
|
|
3911
3707
|
}
|
|
3708
|
+
|
|
3709
|
+
// ../atom.io/internal/src/join/edit-relations-in-store.ts
|
|
3912
3710
|
function editRelationsInStore(token, change, store) {
|
|
3913
3711
|
const myJoin = getJoin(token, store);
|
|
3914
3712
|
const target = newest(store);
|
|
@@ -3921,14 +3719,218 @@ function editRelationsInStore(token, change, store) {
|
|
|
3921
3719
|
change(myJoin.relations);
|
|
3922
3720
|
}
|
|
3923
3721
|
}
|
|
3722
|
+
|
|
3723
|
+
// ../atom.io/internal/src/join/get-internal-relations-from-store.ts
|
|
3924
3724
|
function getInternalRelationsFromStore(token, store) {
|
|
3925
3725
|
const myJoin = getJoin(token, store);
|
|
3926
3726
|
const family = myJoin.core.relatedKeysAtoms;
|
|
3927
3727
|
return family;
|
|
3928
3728
|
}
|
|
3929
|
-
|
|
3930
|
-
|
|
3729
|
+
|
|
3730
|
+
// ../atom.io/introspection/src/refinery.ts
|
|
3731
|
+
var Refinery = class {
|
|
3732
|
+
supported;
|
|
3733
|
+
constructor(supported) {
|
|
3734
|
+
this.supported = supported;
|
|
3735
|
+
}
|
|
3736
|
+
refine(input) {
|
|
3737
|
+
for (const [key, refiner] of Object.entries(this.supported)) {
|
|
3738
|
+
try {
|
|
3739
|
+
if (
|
|
3740
|
+
// @ts-expect-error that's the point
|
|
3741
|
+
refiner(input) === true && refiner !== Boolean
|
|
3742
|
+
) {
|
|
3743
|
+
return { type: key, data: input };
|
|
3744
|
+
}
|
|
3745
|
+
} catch (_) {
|
|
3746
|
+
try {
|
|
3747
|
+
if (input instanceof refiner) {
|
|
3748
|
+
return { type: key, data: input };
|
|
3749
|
+
}
|
|
3750
|
+
} catch (__) {
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
return null;
|
|
3755
|
+
}
|
|
3756
|
+
};
|
|
3757
|
+
var primitiveRefinery = new Refinery({
|
|
3758
|
+
number: (input) => typeof input === `number`,
|
|
3759
|
+
string: (input) => typeof input === `string`,
|
|
3760
|
+
boolean: (input) => typeof input === `boolean`,
|
|
3761
|
+
null: (input) => input === null
|
|
3762
|
+
});
|
|
3763
|
+
function isPlainObject(input) {
|
|
3764
|
+
if (!input) {
|
|
3765
|
+
return false;
|
|
3766
|
+
}
|
|
3767
|
+
const prototype = Object.getPrototypeOf(input);
|
|
3768
|
+
return prototype === Object.prototype;
|
|
3769
|
+
}
|
|
3770
|
+
var jsonTreeRefinery = new Refinery({
|
|
3771
|
+
object: isPlainObject,
|
|
3772
|
+
array: (input) => Array.isArray(input)
|
|
3773
|
+
});
|
|
3774
|
+
var jsonRefinery = new Refinery({
|
|
3775
|
+
...primitiveRefinery.supported,
|
|
3776
|
+
...jsonTreeRefinery.supported
|
|
3777
|
+
});
|
|
3778
|
+
var discoverType = (input) => {
|
|
3779
|
+
if (input === void 0) {
|
|
3780
|
+
return `undefined`;
|
|
3781
|
+
}
|
|
3782
|
+
const refined = jsonRefinery.refine(input);
|
|
3783
|
+
if (refined) {
|
|
3784
|
+
return refined.type;
|
|
3785
|
+
}
|
|
3786
|
+
return Object.getPrototypeOf(input).constructor.name;
|
|
3787
|
+
};
|
|
3788
|
+
|
|
3789
|
+
// ../atom.io/introspection/src/sprawl.ts
|
|
3790
|
+
var sprawl = (tree, inspector) => {
|
|
3791
|
+
const walk = (path, node) => {
|
|
3792
|
+
const inspect2 = (p, n) => {
|
|
3793
|
+
const result2 = inspector(p, n);
|
|
3794
|
+
if (result2) return result2;
|
|
3795
|
+
return null;
|
|
3796
|
+
};
|
|
3797
|
+
const result = inspect2(path, node);
|
|
3798
|
+
if (result?.jobComplete ?? result?.pathComplete) {
|
|
3799
|
+
return result;
|
|
3800
|
+
}
|
|
3801
|
+
const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
|
|
3802
|
+
for (const [k, v] of childEntries) {
|
|
3803
|
+
const subResult = walk([...path, k], v);
|
|
3804
|
+
if (subResult?.jobComplete) {
|
|
3805
|
+
return subResult;
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
return {};
|
|
3809
|
+
};
|
|
3810
|
+
walk([], tree);
|
|
3811
|
+
};
|
|
3812
|
+
|
|
3813
|
+
// ../atom.io/introspection/src/differ.ts
|
|
3814
|
+
function diffNumber(a, b) {
|
|
3815
|
+
const sign = a < b ? `+` : `-`;
|
|
3816
|
+
return {
|
|
3817
|
+
summary: `${sign}${Math.abs(a - b)} (${a} \u2192 ${b})`
|
|
3818
|
+
};
|
|
3819
|
+
}
|
|
3820
|
+
function diffString(a, b) {
|
|
3821
|
+
const sign = a.length < b.length ? `+` : `-`;
|
|
3822
|
+
return {
|
|
3823
|
+
summary: `${sign}${Math.abs(a.length - b.length)} ("${a}" \u2192 "${b}")`
|
|
3824
|
+
};
|
|
3931
3825
|
}
|
|
3826
|
+
function diffBoolean(a, b) {
|
|
3827
|
+
return {
|
|
3828
|
+
summary: `${a} \u2192 ${b}`
|
|
3829
|
+
};
|
|
3830
|
+
}
|
|
3831
|
+
function diffObject(a, b, recurse) {
|
|
3832
|
+
let summary = ``;
|
|
3833
|
+
const added = [];
|
|
3834
|
+
const removed = [];
|
|
3835
|
+
const changed = [];
|
|
3836
|
+
sprawl(a, (path, nodeA) => {
|
|
3837
|
+
let key;
|
|
3838
|
+
for (key of path) {
|
|
3839
|
+
const nodeB = b[key];
|
|
3840
|
+
if (nodeB === void 0) {
|
|
3841
|
+
removed.push([key, JSON.stringify(nodeA)]);
|
|
3842
|
+
} else {
|
|
3843
|
+
const delta = recurse(nodeA, nodeB);
|
|
3844
|
+
if (delta.summary !== `No Change`) {
|
|
3845
|
+
changed.push([key, delta]);
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
sprawl(b, (path, nodeB) => {
|
|
3851
|
+
let key;
|
|
3852
|
+
for (key of path) {
|
|
3853
|
+
const nodeA = a[key];
|
|
3854
|
+
if (nodeA === void 0) {
|
|
3855
|
+
added.push([key, JSON.stringify(nodeB)]);
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
});
|
|
3859
|
+
summary = `\uFF5E${changed.length} \uFF0B${added.length} \uFF0D${removed.length}`;
|
|
3860
|
+
return {
|
|
3861
|
+
summary,
|
|
3862
|
+
added,
|
|
3863
|
+
removed,
|
|
3864
|
+
changed
|
|
3865
|
+
};
|
|
3866
|
+
}
|
|
3867
|
+
function diffArray(a, b, recurse) {
|
|
3868
|
+
return diffObject(a, b, recurse);
|
|
3869
|
+
}
|
|
3870
|
+
var Differ = class {
|
|
3871
|
+
leafRefinery;
|
|
3872
|
+
treeRefinery;
|
|
3873
|
+
leafDiffers;
|
|
3874
|
+
treeDiffers;
|
|
3875
|
+
constructor(leafRefinery, treeRefinery, diffFunctions) {
|
|
3876
|
+
this.leafRefinery = leafRefinery;
|
|
3877
|
+
this.treeRefinery = treeRefinery;
|
|
3878
|
+
this.leafDiffers = {};
|
|
3879
|
+
this.treeDiffers = {};
|
|
3880
|
+
for (const key of Object.keys(leafRefinery.supported)) {
|
|
3881
|
+
const diffFunction = diffFunctions[key];
|
|
3882
|
+
this.leafDiffers[key] = diffFunction;
|
|
3883
|
+
}
|
|
3884
|
+
for (const key of Object.keys(treeRefinery.supported)) {
|
|
3885
|
+
const diffFunction = diffFunctions[key];
|
|
3886
|
+
this.treeDiffers[key] = diffFunction;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
diff(a, b) {
|
|
3890
|
+
if (a === b) {
|
|
3891
|
+
return { summary: `No Change` };
|
|
3892
|
+
}
|
|
3893
|
+
const aRefined = this.leafRefinery.refine(a) ?? this.treeRefinery.refine(a);
|
|
3894
|
+
const bRefined = this.leafRefinery.refine(b) ?? this.treeRefinery.refine(b);
|
|
3895
|
+
if (aRefined !== null && bRefined !== null) {
|
|
3896
|
+
if (aRefined.type === bRefined.type) {
|
|
3897
|
+
if (aRefined.type in this.leafDiffers) {
|
|
3898
|
+
const delta = this.leafDiffers[aRefined.type](
|
|
3899
|
+
aRefined.data,
|
|
3900
|
+
bRefined.data
|
|
3901
|
+
);
|
|
3902
|
+
return delta;
|
|
3903
|
+
}
|
|
3904
|
+
if (aRefined.type in this.treeDiffers) {
|
|
3905
|
+
const delta = this.treeDiffers[aRefined.type](
|
|
3906
|
+
aRefined.data,
|
|
3907
|
+
bRefined.data,
|
|
3908
|
+
(x, y) => this.diff(x, y)
|
|
3909
|
+
);
|
|
3910
|
+
return delta;
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
const typeA = discoverType(a);
|
|
3915
|
+
const typeB = discoverType(b);
|
|
3916
|
+
if (typeA === typeB) {
|
|
3917
|
+
return {
|
|
3918
|
+
summary: `${typeA} \u2192 ${typeB}`
|
|
3919
|
+
};
|
|
3920
|
+
}
|
|
3921
|
+
return {
|
|
3922
|
+
summary: `Type change: ${typeA} \u2192 ${typeB}`
|
|
3923
|
+
};
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
new Differ(primitiveRefinery, jsonTreeRefinery, {
|
|
3927
|
+
number: diffNumber,
|
|
3928
|
+
string: diffString,
|
|
3929
|
+
boolean: diffBoolean,
|
|
3930
|
+
null: () => ({ summary: `No Change` }),
|
|
3931
|
+
object: diffObject,
|
|
3932
|
+
array: diffArray
|
|
3933
|
+
});
|
|
3932
3934
|
|
|
3933
3935
|
// ../atom.io/realtime/src/shared-room-store.ts
|
|
3934
3936
|
atom({
|
|
@@ -4041,6 +4043,8 @@ var ChildSocket = class extends CustomSocket {
|
|
|
4041
4043
|
case `e`:
|
|
4042
4044
|
this.logger.error(...rest);
|
|
4043
4045
|
break;
|
|
4046
|
+
default:
|
|
4047
|
+
return;
|
|
4044
4048
|
}
|
|
4045
4049
|
}
|
|
4046
4050
|
}
|
|
@@ -4288,7 +4292,7 @@ var FlightDeck = class {
|
|
|
4288
4292
|
this.logger = new FlightDeckLogger(
|
|
4289
4293
|
this.options.packageName,
|
|
4290
4294
|
process.pid,
|
|
4291
|
-
|
|
4295
|
+
void 0,
|
|
4292
4296
|
{ jsonLogging: this.options.jsonLogging ?? false }
|
|
4293
4297
|
);
|
|
4294
4298
|
this.serviceLoggers = fromEntries(
|
|
@@ -4311,7 +4315,7 @@ var FlightDeck = class {
|
|
|
4311
4315
|
this.storage = new FilesystemStorage({
|
|
4312
4316
|
path: resolve(flightdeckRootDir, `storage`, options.packageName)
|
|
4313
4317
|
});
|
|
4314
|
-
if (FLIGHTDECK_SECRET ===
|
|
4318
|
+
if (FLIGHTDECK_SECRET === void 0) {
|
|
4315
4319
|
this.logger.warn(
|
|
4316
4320
|
`No FLIGHTDECK_SECRET environment variable found. FlightDeck will not run an update server.`
|
|
4317
4321
|
);
|
|
@@ -4764,5 +4768,5 @@ var FlightDeckLogger = class {
|
|
|
4764
4768
|
};
|
|
4765
4769
|
|
|
4766
4770
|
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-
|
|
4771
|
+
//# sourceMappingURL=chunk-RNOG4E3Q.js.map
|
|
4772
|
+
//# sourceMappingURL=chunk-RNOG4E3Q.js.map
|