atom.io 0.19.3 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.js +1 -1
- package/data/src/dict.ts +1 -1
- package/data/src/join.ts +1 -1
- package/data/src/struct-family.ts +1 -1
- package/data/src/struct.ts +5 -3
- package/eslint-plugin/dist/index.cjs +53 -0
- package/eslint-plugin/dist/index.js +52 -0
- package/eslint-plugin/src/index.ts +1 -0
- package/eslint-plugin/src/rules/explicit-state-types.ts +55 -0
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/internal/dist/index.cjs +127 -92
- package/internal/dist/index.d.ts +13 -9
- package/internal/dist/index.js +127 -92
- package/internal/src/atom/index.ts +1 -1
- package/internal/src/caching.ts +13 -9
- package/internal/src/families/create-atom-family.ts +1 -1
- package/internal/src/families/find-in-store.ts +2 -2
- package/internal/src/families/index.ts +1 -1
- package/internal/src/future.ts +52 -15
- package/internal/src/index.ts +2 -2
- package/internal/src/mutable/create-mutable-atom-family.ts +2 -3
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-update-token.ts +1 -0
- package/internal/src/selector/delete-selector.ts +1 -1
- package/internal/src/selector/register-selector.ts +1 -1
- package/internal/src/store/deposit.ts +1 -1
- package/internal/src/store/store.ts +2 -2
- package/internal/src/store/withdraw-new-family-member.ts +1 -1
- package/internal/src/store/withdraw.ts +2 -3
- package/internal/src/subscribe/subscribe-to-state.ts +1 -0
- package/internal/src/subscribe/subscribe-to-timeline.ts +1 -0
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +1 -1
- package/internal/src/transaction/act-upon-store.ts +1 -1
- package/internal/src/transaction/apply-transaction.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +2 -2
- package/internal/src/transaction/create-transaction.ts +2 -2
- package/internal/src/transaction/index.ts +1 -1
- package/internal/src/transaction/is-root-store.ts +1 -1
- package/introspection/src/attach-atom-index.ts +1 -1
- package/introspection/src/attach-introspection-states.ts +2 -2
- package/introspection/src/attach-selector-index.ts +1 -1
- package/introspection/src/attach-timeline-family.ts +2 -2
- package/introspection/src/attach-timeline-index.ts +1 -1
- package/introspection/src/attach-transaction-index.ts +2 -2
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.cjs +35 -33
- package/json/dist/index.d.ts +5 -5
- package/json/dist/index.js +5 -5
- package/json/src/index.ts +2 -3
- package/json/src/select-json-family.ts +6 -6
- package/json/src/select-json.ts +1 -2
- package/package.json +18 -15
- package/react/src/use-tl.ts +1 -1
- package/react-devtools/dist/index.cjs +99 -99
- package/react-devtools/dist/index.css +0 -3
- package/react-devtools/dist/index.d.ts +2 -2
- package/react-devtools/dist/index.js +77 -77
- package/react-devtools/src/AtomIODevtools.tsx +2 -2
- package/react-devtools/src/TransactionIndex.tsx +2 -2
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/devtools.scss +0 -3
- package/react-devtools/src/index.ts +1 -1
- package/realtime/src/realtime-continuity.ts +1 -1
- package/realtime/src/shared-room-store.ts +1 -1
- package/realtime-client/dist/index.js +1 -1
- package/realtime-client/src/pull-atom-family-member.ts +1 -1
- package/realtime-client/src/pull-atom.ts +1 -1
- package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
- package/realtime-client/src/sync-continuity.ts +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-react/src/use-realtime-service.ts +1 -0
- package/realtime-react/src/use-sync-continuity.ts +2 -1
- package/realtime-server/dist/index.cjs +98 -98
- package/realtime-server/dist/index.d.ts +17 -18
- package/realtime-server/dist/index.js +100 -100
- package/realtime-server/src/index.ts +5 -5
- package/realtime-server/src/ipc-sockets/parent-socket.ts +3 -3
- package/realtime-server/src/realtime-action-receiver.ts +1 -1
- package/realtime-server/src/realtime-continuity-synchronizer.ts +2 -3
- package/realtime-server/src/realtime-family-provider.ts +1 -1
- package/realtime-server/src/realtime-mutable-family-provider.ts +1 -1
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -0
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +3 -2
- package/realtime-server/src/realtime-state-provider.ts +1 -1
- package/realtime-server/src/realtime-state-synchronizer.ts +1 -1
- package/realtime-testing/dist/index.js +2 -2
- package/realtime-testing/src/setup-realtime-test.tsx +3 -2
- package/src/atom.ts +1 -1
- package/src/find-state.ts +1 -1
- package/src/index.ts +1 -0
- package/src/selector.ts +1 -1
- package/src/silo.ts +4 -4
- package/src/subscribe.ts +2 -2
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +3 -3
- package/transceivers/set-rtx/src/set-rtx.ts +1 -1
- package/dist/{chunk-ATKDGVTV.js → chunk-2AIFLP2B.js} +0 -0
- package/dist/{chunk-CC7IF7QF.js → chunk-3V3VWQ7X.js} +6 -6
- /package/dist/{chunk-MSCJWACE.js → chunk-SMZRGPN6.js} +0 -0
package/internal/dist/index.js
CHANGED
|
@@ -3,6 +3,67 @@ import { __spreadValues, __spreadProps } from '../../dist/chunk-F2X4B4VY.js';
|
|
|
3
3
|
import { stringifyJson, selectJson, parseJson, selectJsonFamily } from 'atom.io/json';
|
|
4
4
|
import { AtomIOLogger } from 'atom.io';
|
|
5
5
|
|
|
6
|
+
// internal/src/arbitrary.ts
|
|
7
|
+
function arbitrary(random = Math.random) {
|
|
8
|
+
return random().toString(36).slice(2);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// internal/src/future.ts
|
|
12
|
+
var Future = class extends Promise {
|
|
13
|
+
constructor(executor) {
|
|
14
|
+
let promise;
|
|
15
|
+
let superResolve;
|
|
16
|
+
let superReject;
|
|
17
|
+
super((resolve, reject) => {
|
|
18
|
+
superResolve = resolve;
|
|
19
|
+
superReject = reject;
|
|
20
|
+
promise = executor instanceof Promise ? executor : new Promise(executor);
|
|
21
|
+
promise.then(
|
|
22
|
+
(value) => {
|
|
23
|
+
if (promise) {
|
|
24
|
+
this.pass(promise, value);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
(reason) => {
|
|
28
|
+
if (promise) {
|
|
29
|
+
this.fail(promise, reason);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
this.destiny = promise;
|
|
35
|
+
this.resolve = superResolve;
|
|
36
|
+
this.reject = superReject;
|
|
37
|
+
}
|
|
38
|
+
pass(promise, value) {
|
|
39
|
+
if (promise === this.destiny) {
|
|
40
|
+
this.resolve(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
fail(promise, reason) {
|
|
44
|
+
if (promise === this.destiny) {
|
|
45
|
+
this.reject(reason);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
use(value) {
|
|
49
|
+
if (value instanceof Promise) {
|
|
50
|
+
const promise = value;
|
|
51
|
+
this.destiny = promise;
|
|
52
|
+
promise.then(
|
|
53
|
+
(resolved) => {
|
|
54
|
+
this.pass(promise, resolved);
|
|
55
|
+
},
|
|
56
|
+
(reason) => {
|
|
57
|
+
this.fail(promise, reason);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
} else {
|
|
61
|
+
this.resolve(value);
|
|
62
|
+
this.destiny = void 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
6
67
|
// internal/src/lineage.ts
|
|
7
68
|
function newest(scion) {
|
|
8
69
|
while (scion.child !== null) {
|
|
@@ -261,93 +322,6 @@ function withdrawOrCreate(token, store) {
|
|
|
261
322
|
}
|
|
262
323
|
}
|
|
263
324
|
|
|
264
|
-
// internal/src/future.ts
|
|
265
|
-
var Future = class extends Promise {
|
|
266
|
-
constructor(executor) {
|
|
267
|
-
super((resolve, reject) => {
|
|
268
|
-
const pass = (value) => {
|
|
269
|
-
this.isCanceled ? reject(`canceled`) : resolve(value);
|
|
270
|
-
};
|
|
271
|
-
const fail = (reason) => {
|
|
272
|
-
this.isCanceled ? reject(`canceled`) : reject(reason);
|
|
273
|
-
};
|
|
274
|
-
if (typeof executor === `function`) {
|
|
275
|
-
executor(pass, fail);
|
|
276
|
-
} else {
|
|
277
|
-
executor.then(pass, fail);
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
this.isCanceled = false;
|
|
281
|
-
}
|
|
282
|
-
cancel() {
|
|
283
|
-
this.isCanceled = true;
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
288
|
-
function copyMutableIfNeeded(atom, origin, target) {
|
|
289
|
-
const originValue = origin.valueMap.get(atom.key);
|
|
290
|
-
const targetValue = target.valueMap.get(atom.key);
|
|
291
|
-
if (originValue === targetValue) {
|
|
292
|
-
if (originValue === void 0) {
|
|
293
|
-
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
294
|
-
}
|
|
295
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
|
|
296
|
-
const jsonValue = atom.toJson(originValue);
|
|
297
|
-
const copiedValue = atom.fromJson(jsonValue);
|
|
298
|
-
target.valueMap.set(atom.key, copiedValue);
|
|
299
|
-
new Tracker(atom, origin);
|
|
300
|
-
return copiedValue;
|
|
301
|
-
}
|
|
302
|
-
return targetValue;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// internal/src/caching.ts
|
|
306
|
-
function cacheValue(key, value, subject, target) {
|
|
307
|
-
const currentValue = target.valueMap.get(key);
|
|
308
|
-
if (currentValue instanceof Future) {
|
|
309
|
-
currentValue.cancel();
|
|
310
|
-
}
|
|
311
|
-
if (value instanceof Promise) {
|
|
312
|
-
const future = new Future(value);
|
|
313
|
-
target.valueMap.set(key, future);
|
|
314
|
-
future.then((resolved) => {
|
|
315
|
-
if (future.isCanceled) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
cacheValue(key, resolved, subject, target);
|
|
319
|
-
subject.next({ newValue: resolved, oldValue: future });
|
|
320
|
-
}).catch((thrown) => {
|
|
321
|
-
if (thrown !== `canceled`) {
|
|
322
|
-
target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
return future;
|
|
326
|
-
}
|
|
327
|
-
target.valueMap.set(key, value);
|
|
328
|
-
return value;
|
|
329
|
-
}
|
|
330
|
-
var readCachedValue = (token, target) => {
|
|
331
|
-
let value = target.valueMap.get(token.key);
|
|
332
|
-
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
333
|
-
const { parent } = target;
|
|
334
|
-
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
335
|
-
value = copiedValue;
|
|
336
|
-
}
|
|
337
|
-
return value;
|
|
338
|
-
};
|
|
339
|
-
var evictCachedValue = (key, target) => {
|
|
340
|
-
const currentValue = target.valueMap.get(key);
|
|
341
|
-
if (currentValue instanceof Future) {
|
|
342
|
-
currentValue.cancel();
|
|
343
|
-
}
|
|
344
|
-
if (target.operation.open) {
|
|
345
|
-
target.operation.prev.set(key, currentValue);
|
|
346
|
-
}
|
|
347
|
-
target.valueMap.delete(key);
|
|
348
|
-
target.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
|
|
349
|
-
};
|
|
350
|
-
|
|
351
325
|
// internal/src/get-state/read-or-compute-value.ts
|
|
352
326
|
var readOrComputeValue = (state, target) => {
|
|
353
327
|
if (target.valueMap.has(state.key)) {
|
|
@@ -1449,6 +1423,72 @@ function isTransceiver(value) {
|
|
|
1449
1423
|
return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
|
|
1450
1424
|
}
|
|
1451
1425
|
|
|
1426
|
+
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
1427
|
+
function copyMutableIfNeeded(atom, origin, target) {
|
|
1428
|
+
const originValue = origin.valueMap.get(atom.key);
|
|
1429
|
+
const targetValue = target.valueMap.get(atom.key);
|
|
1430
|
+
if (originValue === targetValue) {
|
|
1431
|
+
if (originValue === void 0) {
|
|
1432
|
+
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
1433
|
+
}
|
|
1434
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
|
|
1435
|
+
const jsonValue = atom.toJson(originValue);
|
|
1436
|
+
const copiedValue = atom.fromJson(jsonValue);
|
|
1437
|
+
target.valueMap.set(atom.key, copiedValue);
|
|
1438
|
+
new Tracker(atom, origin);
|
|
1439
|
+
return copiedValue;
|
|
1440
|
+
}
|
|
1441
|
+
return targetValue;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// internal/src/caching.ts
|
|
1445
|
+
function cacheValue(key, value, subject, target) {
|
|
1446
|
+
const currentValue = target.valueMap.get(key);
|
|
1447
|
+
if (currentValue instanceof Future) {
|
|
1448
|
+
const future = currentValue;
|
|
1449
|
+
future.use(value);
|
|
1450
|
+
}
|
|
1451
|
+
if (value instanceof Promise) {
|
|
1452
|
+
const future = new Future(value);
|
|
1453
|
+
target.valueMap.set(key, future);
|
|
1454
|
+
future.then((resolved) => {
|
|
1455
|
+
cacheValue(key, resolved, subject, target);
|
|
1456
|
+
subject.next({ newValue: resolved, oldValue: future });
|
|
1457
|
+
}).catch((thrown) => {
|
|
1458
|
+
target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
1459
|
+
});
|
|
1460
|
+
return future;
|
|
1461
|
+
}
|
|
1462
|
+
target.valueMap.set(key, value);
|
|
1463
|
+
return value;
|
|
1464
|
+
}
|
|
1465
|
+
var readCachedValue = (token, target) => {
|
|
1466
|
+
let value = target.valueMap.get(token.key);
|
|
1467
|
+
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
1468
|
+
const { parent } = target;
|
|
1469
|
+
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
1470
|
+
value = copiedValue;
|
|
1471
|
+
}
|
|
1472
|
+
return value;
|
|
1473
|
+
};
|
|
1474
|
+
var evictCachedValue = (key, target) => {
|
|
1475
|
+
var _a;
|
|
1476
|
+
const currentValue = target.valueMap.get(key);
|
|
1477
|
+
if (currentValue instanceof Future) {
|
|
1478
|
+
const future = currentValue;
|
|
1479
|
+
const selector = (_a = target.selectors.get(key)) != null ? _a : target.readonlySelectors.get(key);
|
|
1480
|
+
if (selector) {
|
|
1481
|
+
future.use(selector.get());
|
|
1482
|
+
}
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
if (target.operation.open) {
|
|
1486
|
+
target.operation.prev.set(key, currentValue);
|
|
1487
|
+
}
|
|
1488
|
+
target.valueMap.delete(key);
|
|
1489
|
+
target.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1452
1492
|
// internal/src/atom/is-default.ts
|
|
1453
1493
|
var isAtomDefault = (key, store) => {
|
|
1454
1494
|
const core = newest(store);
|
|
@@ -1578,11 +1618,6 @@ function deleteAtom(atomToken, store) {
|
|
|
1578
1618
|
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1579
1619
|
}
|
|
1580
1620
|
|
|
1581
|
-
// internal/src/arbitrary.ts
|
|
1582
|
-
function arbitrary(random = Math.random) {
|
|
1583
|
-
return random().toString(36).slice(2);
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
1621
|
// internal/src/get-environment-data.ts
|
|
1587
1622
|
function getEnvironmentData(store) {
|
|
1588
1623
|
return {
|
package/internal/src/caching.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { StateUpdate } from "atom.io"
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import type { ReadableState } from "."
|
|
4
|
+
import { isChildStore } from "."
|
|
3
5
|
import { Future } from "./future"
|
|
4
6
|
import { copyMutableIfNeeded } from "./set-state/copy-mutable-if-needed"
|
|
5
7
|
import type { Store } from "./store"
|
|
@@ -25,23 +27,19 @@ export function cacheValue<T>(
|
|
|
25
27
|
): Future<T> | T {
|
|
26
28
|
const currentValue = target.valueMap.get(key)
|
|
27
29
|
if (currentValue instanceof Future) {
|
|
28
|
-
currentValue
|
|
30
|
+
const future = currentValue
|
|
31
|
+
future.use(value)
|
|
29
32
|
}
|
|
30
33
|
if (value instanceof Promise) {
|
|
31
34
|
const future = new Future<T>(value)
|
|
32
35
|
target.valueMap.set(key, future)
|
|
33
36
|
future
|
|
34
37
|
.then((resolved) => {
|
|
35
|
-
if (future.isCanceled) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
38
|
cacheValue(key, resolved, subject, target)
|
|
39
39
|
subject.next({ newValue: resolved, oldValue: future })
|
|
40
40
|
})
|
|
41
41
|
.catch((thrown) => {
|
|
42
|
-
|
|
43
|
-
target.logger.error(`💥`, `state`, key, `rejected:`, thrown)
|
|
44
|
-
}
|
|
42
|
+
target.logger.error(`💥`, `state`, key, `rejected:`, thrown)
|
|
45
43
|
})
|
|
46
44
|
return future
|
|
47
45
|
}
|
|
@@ -65,7 +63,13 @@ export const readCachedValue = <T>(
|
|
|
65
63
|
export const evictCachedValue = (key: string, target: Store): void => {
|
|
66
64
|
const currentValue = target.valueMap.get(key)
|
|
67
65
|
if (currentValue instanceof Future) {
|
|
68
|
-
currentValue
|
|
66
|
+
const future = currentValue
|
|
67
|
+
const selector =
|
|
68
|
+
target.selectors.get(key) ?? target.readonlySelectors.get(key)
|
|
69
|
+
if (selector) {
|
|
70
|
+
future.use(selector.get())
|
|
71
|
+
}
|
|
72
|
+
return
|
|
69
73
|
}
|
|
70
74
|
if (target.operation.open) {
|
|
71
75
|
target.operation.prev.set(key, currentValue)
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
} from "atom.io"
|
|
7
7
|
import type { Json } from "atom.io/json"
|
|
8
8
|
|
|
9
|
-
import { type Transceiver
|
|
9
|
+
import { createMutableAtomFamily, type Transceiver } from "../mutable"
|
|
10
10
|
import type { Store } from "../store"
|
|
11
11
|
import { createRegularAtomFamily } from "./create-regular-atom-family"
|
|
12
12
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Json } from "atom.io/json"
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
AtomFamilyToken,
|
|
5
3
|
AtomToken,
|
|
@@ -18,6 +16,8 @@ import type {
|
|
|
18
16
|
WritableSelectorToken,
|
|
19
17
|
WritableToken,
|
|
20
18
|
} from "atom.io"
|
|
19
|
+
import type { Json } from "atom.io/json"
|
|
20
|
+
|
|
21
21
|
import type { Transceiver } from "../mutable"
|
|
22
22
|
import { NotFoundError } from "../not-found-error"
|
|
23
23
|
import type { Store } from "../store"
|
package/internal/src/future.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A Promise
|
|
2
|
+
* A Promise whose incoming value can be hot swapped.
|
|
3
3
|
* @internal
|
|
4
4
|
* @private
|
|
5
5
|
* @typeParam T The type of the value that the promise will resolve to.
|
|
@@ -8,29 +8,66 @@
|
|
|
8
8
|
* Can be constructed like a Promise, or from an existing Promise.
|
|
9
9
|
*/
|
|
10
10
|
export class Future<T> extends Promise<T> {
|
|
11
|
-
|
|
11
|
+
private destiny: Promise<T> | undefined
|
|
12
|
+
private resolve: (value: T) => void
|
|
13
|
+
private reject: (reason?: any) => void
|
|
12
14
|
|
|
13
15
|
public constructor(
|
|
14
16
|
executor:
|
|
15
17
|
| Promise<T>
|
|
16
18
|
| ((resolve: (value: T) => void, reject: (reason?: any) => void) => void),
|
|
17
19
|
) {
|
|
20
|
+
let promise: Promise<T> | undefined
|
|
21
|
+
let superResolve: ((value: T) => void) | undefined
|
|
22
|
+
let superReject: ((reason?: any) => void) | undefined
|
|
18
23
|
super((resolve, reject) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
superResolve = resolve
|
|
25
|
+
superReject = reject
|
|
26
|
+
promise = executor instanceof Promise ? executor : new Promise(executor)
|
|
27
|
+
promise.then(
|
|
28
|
+
(value) => {
|
|
29
|
+
if (promise) {
|
|
30
|
+
this.pass(promise, value)
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
(reason) => {
|
|
34
|
+
if (promise) {
|
|
35
|
+
this.fail(promise, reason)
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
)
|
|
30
39
|
})
|
|
40
|
+
this.destiny = promise
|
|
41
|
+
this.resolve = superResolve as (value: T) => void
|
|
42
|
+
this.reject = superReject as (reason?: any) => void
|
|
31
43
|
}
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
this.
|
|
45
|
+
private pass(promise: Promise<T>, value: T) {
|
|
46
|
+
if (promise === this.destiny) {
|
|
47
|
+
this.resolve(value)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
private fail(promise: Promise<T>, reason: any) {
|
|
51
|
+
if (promise === this.destiny) {
|
|
52
|
+
this.reject(reason)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public use(value: Promise<T> | T): void {
|
|
57
|
+
if (value instanceof Promise) {
|
|
58
|
+
const promise = value
|
|
59
|
+
this.destiny = promise
|
|
60
|
+
promise.then(
|
|
61
|
+
(resolved) => {
|
|
62
|
+
this.pass(promise, resolved)
|
|
63
|
+
},
|
|
64
|
+
(reason) => {
|
|
65
|
+
this.fail(promise, reason)
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
} else {
|
|
69
|
+
this.resolve(value)
|
|
70
|
+
this.destiny = undefined
|
|
71
|
+
}
|
|
35
72
|
}
|
|
36
73
|
}
|
package/internal/src/index.ts
CHANGED
|
@@ -5,10 +5,9 @@ import type { Transceiver } from "./mutable"
|
|
|
5
5
|
import type { Store } from "./store"
|
|
6
6
|
import type { Subject } from "./subject"
|
|
7
7
|
|
|
8
|
-
export * from "./atom"
|
|
9
8
|
export * from "./arbitrary"
|
|
9
|
+
export * from "./atom"
|
|
10
10
|
export * from "./caching"
|
|
11
|
-
export * from "./lineage"
|
|
12
11
|
export * from "./families"
|
|
13
12
|
export * from "./future"
|
|
14
13
|
export * from "./get-environment-data"
|
|
@@ -16,6 +15,7 @@ export * from "./get-state"
|
|
|
16
15
|
export * from "./ingest-updates"
|
|
17
16
|
export * from "./keys"
|
|
18
17
|
export * from "./lazy-map"
|
|
18
|
+
export * from "./lineage"
|
|
19
19
|
export * from "./mutable"
|
|
20
20
|
export * from "./not-found-error"
|
|
21
21
|
export * from "./operation"
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
FamilyMetadata,
|
|
2
3
|
MutableAtomFamily,
|
|
3
4
|
MutableAtomFamilyOptions,
|
|
4
5
|
MutableAtomOptions,
|
|
5
6
|
MutableAtomToken,
|
|
6
7
|
} from "atom.io"
|
|
7
|
-
import type { FamilyMetadata } from "atom.io"
|
|
8
8
|
import type { Json } from "atom.io/json"
|
|
9
|
-
import { selectJsonFamily } from "atom.io/json"
|
|
10
|
-
import { stringifyJson } from "atom.io/json"
|
|
9
|
+
import { selectJsonFamily, stringifyJson } from "atom.io/json"
|
|
11
10
|
|
|
12
11
|
import { newest } from "../lineage"
|
|
13
12
|
import { createMutableAtom } from "../mutable"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { UpdateHandler } from "atom.io"
|
|
2
1
|
import type {
|
|
3
2
|
FamilyMetadata,
|
|
4
3
|
MutableAtomOptions,
|
|
5
4
|
MutableAtomToken,
|
|
5
|
+
UpdateHandler,
|
|
6
6
|
} from "atom.io"
|
|
7
7
|
import type { Json } from "atom.io/json"
|
|
8
8
|
import { selectJson } from "atom.io/json"
|
|
9
9
|
|
|
10
|
-
import { type MutableAtom,
|
|
10
|
+
import { cacheValue, type MutableAtom, setIntoStore } from ".."
|
|
11
11
|
import { markAtomAsDefault } from "../atom"
|
|
12
12
|
import { newest } from "../lineage"
|
|
13
|
-
import { type Store
|
|
13
|
+
import { deposit, type Store } from "../store"
|
|
14
14
|
import { Subject } from "../subject"
|
|
15
15
|
import { subscribeToState } from "../subscribe"
|
|
16
16
|
import { Tracker } from "./tracker"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReadonlySelectorToken, WritableSelectorToken } from "atom.io"
|
|
2
2
|
|
|
3
|
-
import { newest } from ".."
|
|
4
3
|
import type { Store } from ".."
|
|
4
|
+
import { newest } from ".."
|
|
5
5
|
|
|
6
6
|
export function deleteSelector(
|
|
7
7
|
selectorToken: ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AtomIOLogger } from "atom.io"
|
|
2
1
|
import type {
|
|
3
2
|
AtomToken,
|
|
3
|
+
Func,
|
|
4
4
|
Logger,
|
|
5
5
|
MutableAtomFamily,
|
|
6
6
|
ReadonlySelectorFamily,
|
|
@@ -10,8 +10,8 @@ import type {
|
|
|
10
10
|
TransactionToken,
|
|
11
11
|
WritableSelectorFamily,
|
|
12
12
|
WritableSelectorToken,
|
|
13
|
-
Func,
|
|
14
13
|
} from "atom.io"
|
|
14
|
+
import { AtomIOLogger } from "atom.io"
|
|
15
15
|
|
|
16
16
|
import { Junction } from "~/packages/rel8/junction/src"
|
|
17
17
|
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
AtomFamily,
|
|
3
3
|
AtomFamilyToken,
|
|
4
4
|
AtomToken,
|
|
5
|
+
Func,
|
|
5
6
|
MutableAtomFamily,
|
|
6
7
|
MutableAtomFamilyToken,
|
|
7
8
|
MutableAtomToken,
|
|
@@ -22,10 +23,9 @@ import type {
|
|
|
22
23
|
WritableSelectorFamilyToken,
|
|
23
24
|
WritableSelectorToken,
|
|
24
25
|
WritableToken,
|
|
25
|
-
Func,
|
|
26
26
|
} from "atom.io"
|
|
27
|
-
|
|
28
27
|
import type { Json } from "atom.io/json"
|
|
28
|
+
|
|
29
29
|
import type {
|
|
30
30
|
Atom,
|
|
31
31
|
MutableAtom,
|
|
@@ -38,7 +38,6 @@ import type {
|
|
|
38
38
|
WritableState,
|
|
39
39
|
} from ".."
|
|
40
40
|
import { NotFoundError } from ".."
|
|
41
|
-
|
|
42
41
|
import type { Timeline } from "../timeline"
|
|
43
42
|
import type { Transaction } from "../transaction"
|
|
44
43
|
import type { Store } from "./store"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AtomToken,
|
|
3
|
+
Func,
|
|
4
|
+
TimelineUpdate,
|
|
3
5
|
TransactionToken,
|
|
4
6
|
TransactionUpdate,
|
|
5
|
-
Func,
|
|
6
7
|
} from "atom.io"
|
|
7
|
-
import type { TimelineUpdate } from "atom.io"
|
|
8
8
|
|
|
9
9
|
import { newest } from "../lineage"
|
|
10
10
|
import { getUpdateToken } from "../mutable"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AtomFamilyToken,
|
|
3
3
|
FamilyMetadata,
|
|
4
|
+
Func,
|
|
4
5
|
StateUpdate,
|
|
5
6
|
TimelineManageable,
|
|
6
7
|
TimelineOptions,
|
|
@@ -8,7 +9,6 @@ import type {
|
|
|
8
9
|
TimelineUpdate,
|
|
9
10
|
TokenType,
|
|
10
11
|
TransactionUpdate,
|
|
11
|
-
Func,
|
|
12
12
|
} from "atom.io"
|
|
13
13
|
|
|
14
14
|
import { newest } from "../lineage"
|
|
@@ -2,8 +2,8 @@ import type { Func } from "atom.io"
|
|
|
2
2
|
|
|
3
3
|
import { ingestTransactionUpdate } from "../ingest-updates"
|
|
4
4
|
import { newest } from "../lineage"
|
|
5
|
-
import { withdraw } from "../store"
|
|
6
5
|
import type { Store } from "../store"
|
|
6
|
+
import { withdraw } from "../store"
|
|
7
7
|
import { isChildStore, isRootStore } from "./is-root-store"
|
|
8
8
|
import { setEpochNumberOfAction } from "./set-epoch-number"
|
|
9
9
|
|
|
@@ -2,8 +2,6 @@ import type { findState, Func } from "atom.io"
|
|
|
2
2
|
|
|
3
3
|
import { Junction } from "~/packages/rel8/junction/src"
|
|
4
4
|
|
|
5
|
-
import type { TransactionProgress } from "."
|
|
6
|
-
import { actUponStore, getEpochNumberOfAction } from "."
|
|
7
5
|
import { arbitrary } from "../arbitrary"
|
|
8
6
|
import { findInStore } from "../families"
|
|
9
7
|
import { getEnvironmentData } from "../get-environment-data"
|
|
@@ -12,6 +10,8 @@ import { LazyMap } from "../lazy-map"
|
|
|
12
10
|
import { newest } from "../lineage"
|
|
13
11
|
import { setIntoStore } from "../set-state"
|
|
14
12
|
import type { Store } from "../store"
|
|
13
|
+
import type { TransactionProgress } from "."
|
|
14
|
+
import { actUponStore, getEpochNumberOfAction } from "."
|
|
15
15
|
import type { ChildStore, RootStore } from "./is-root-store"
|
|
16
16
|
|
|
17
17
|
export const buildTransaction = (
|