atom.io 0.21.0 → 0.21.1
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.cjs +3 -3
- package/data/dist/index.js +1 -1
- package/data/src/join.ts +2 -7
- package/internal/dist/index.cjs +25 -48
- package/internal/dist/index.d.ts +1 -1
- package/internal/dist/index.js +25 -48
- package/internal/src/future.ts +6 -20
- package/internal/src/get-state/get-from-store.ts +1 -2
- package/internal/src/mutable/tracker.ts +2 -24
- package/internal/src/operation.ts +0 -1
- package/internal/src/subscribe/recall-state.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +16 -3
- package/introspection/dist/index.cjs +1 -13
- package/introspection/dist/index.js +1 -13
- package/introspection/src/attach-introspection-states.ts +0 -1
- package/introspection/src/attach-timeline-family.ts +2 -17
- package/package.json +5 -5
- package/realtime-server/dist/index.js +1 -1
- package/realtime-testing/dist/index.js +1 -1
- package/src/validators.ts +0 -6
- /package/dist/{chunk-KGZGBCYS.js → chunk-HITX3MO4.js} +0 -0
package/data/dist/index.cjs
CHANGED
|
@@ -5,14 +5,14 @@ var atom_io = require('atom.io');
|
|
|
5
5
|
var setRtx = require('atom.io/transceivers/set-rtx');
|
|
6
6
|
|
|
7
7
|
// data/src/dict.ts
|
|
8
|
-
function dict(
|
|
8
|
+
function dict(findState, index, store = internal.IMPLICIT.STORE) {
|
|
9
9
|
return internal.createStandaloneSelector(
|
|
10
10
|
{
|
|
11
|
-
key: `${
|
|
11
|
+
key: `${findState.key}Dict`,
|
|
12
12
|
get: ({ get }) => {
|
|
13
13
|
const keys = get(index);
|
|
14
14
|
return keys.reduce((acc, key) => {
|
|
15
|
-
acc[key] = get(internal.findInStore(
|
|
15
|
+
acc[key] = get(internal.findInStore(findState, key, store));
|
|
16
16
|
return acc;
|
|
17
17
|
}, {});
|
|
18
18
|
}
|
package/data/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-
|
|
1
|
+
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-HITX3MO4.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
3
|
import '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { createStandaloneSelector, findInStore, IMPLICIT, createRegularAtom, createRegularAtomFamily, createSelectorFamily } from 'atom.io/internal';
|
package/data/src/join.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
import type {
|
|
3
|
+
findState,
|
|
3
4
|
MutableAtomFamily,
|
|
4
5
|
MutableAtomFamilyToken,
|
|
5
6
|
MutableAtomToken,
|
|
@@ -10,7 +11,7 @@ import type {
|
|
|
10
11
|
Transactors,
|
|
11
12
|
Write,
|
|
12
13
|
} from "atom.io"
|
|
13
|
-
import { disposeState,
|
|
14
|
+
import { disposeState, getState, setState } from "atom.io"
|
|
14
15
|
import type { Store } from "atom.io/internal"
|
|
15
16
|
import {
|
|
16
17
|
createMutableAtomFamily,
|
|
@@ -37,12 +38,6 @@ import type {
|
|
|
37
38
|
import { Junction } from "~/packages/rel8/junction/src"
|
|
38
39
|
import type * as Rel8 from "~/packages/rel8/types/src"
|
|
39
40
|
|
|
40
|
-
const TRANSACTORS: Transactors = {
|
|
41
|
-
get: getState,
|
|
42
|
-
set: setState,
|
|
43
|
-
find: findState,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
function capitalize<S extends string>(string: S): Capitalize<S> {
|
|
47
42
|
return (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>
|
|
48
43
|
}
|
package/internal/dist/index.cjs
CHANGED
|
@@ -31,44 +31,30 @@ function arbitrary(random = Math.random) {
|
|
|
31
31
|
// internal/src/future.ts
|
|
32
32
|
var Future = class extends Promise {
|
|
33
33
|
constructor(executor) {
|
|
34
|
-
let promise;
|
|
35
34
|
let superResolve;
|
|
36
35
|
let superReject;
|
|
37
36
|
super((resolve, reject) => {
|
|
38
37
|
superResolve = resolve;
|
|
39
38
|
superReject = reject;
|
|
40
|
-
promise = executor instanceof Promise ? executor : new Promise(executor);
|
|
41
|
-
promise.then(
|
|
42
|
-
(value) => {
|
|
43
|
-
if (promise) {
|
|
44
|
-
this.pass(promise, value);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
(reason) => {
|
|
48
|
-
if (promise) {
|
|
49
|
-
this.fail(promise, reason);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
39
|
});
|
|
54
|
-
this.destiny = promise;
|
|
55
40
|
this.resolve = superResolve;
|
|
56
41
|
this.reject = superReject;
|
|
42
|
+
this.use(executor instanceof Promise ? executor : new Promise(executor));
|
|
57
43
|
}
|
|
58
44
|
pass(promise, value) {
|
|
59
|
-
if (promise === this.
|
|
45
|
+
if (promise === this.fate) {
|
|
60
46
|
this.resolve(value);
|
|
61
47
|
}
|
|
62
48
|
}
|
|
63
49
|
fail(promise, reason) {
|
|
64
|
-
if (promise === this.
|
|
50
|
+
if (promise === this.fate) {
|
|
65
51
|
this.reject(reason);
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
54
|
use(value) {
|
|
69
55
|
if (value instanceof Promise) {
|
|
70
56
|
const promise = value;
|
|
71
|
-
this.
|
|
57
|
+
this.fate = promise;
|
|
72
58
|
promise.then(
|
|
73
59
|
(resolved) => {
|
|
74
60
|
this.pass(promise, resolved);
|
|
@@ -79,7 +65,7 @@ var Future = class extends Promise {
|
|
|
79
65
|
);
|
|
80
66
|
} else {
|
|
81
67
|
this.resolve(value);
|
|
82
|
-
this.
|
|
68
|
+
this.fate = void 0;
|
|
83
69
|
}
|
|
84
70
|
}
|
|
85
71
|
};
|
|
@@ -1255,10 +1241,10 @@ function disposeSelector(selectorToken, store) {
|
|
|
1255
1241
|
// internal/src/subscribe/recall-state.ts
|
|
1256
1242
|
var recallState = (state, store) => {
|
|
1257
1243
|
const target = newest(store);
|
|
1258
|
-
if (
|
|
1259
|
-
return target.
|
|
1244
|
+
if (target.operation.open) {
|
|
1245
|
+
return target.operation.prev.get(state.key);
|
|
1260
1246
|
}
|
|
1261
|
-
return target.
|
|
1247
|
+
return target.valueMap.get(state.key);
|
|
1262
1248
|
};
|
|
1263
1249
|
|
|
1264
1250
|
// internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
@@ -1307,11 +1293,24 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
1307
1293
|
|
|
1308
1294
|
// internal/src/subscribe/subscribe-to-state.ts
|
|
1309
1295
|
function subscribeToState(token, handleUpdate, key, store) {
|
|
1296
|
+
function safelyHandleUpdate(update) {
|
|
1297
|
+
if (store.operation.open) {
|
|
1298
|
+
const unsubscribe2 = store.on.operationClose.subscribe(
|
|
1299
|
+
`state subscription ${key}`,
|
|
1300
|
+
() => {
|
|
1301
|
+
unsubscribe2();
|
|
1302
|
+
handleUpdate(update);
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
} else {
|
|
1306
|
+
handleUpdate(update);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1310
1309
|
const state = withdrawOrCreate(token, store);
|
|
1311
1310
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1312
1311
|
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
1313
1312
|
let dependencyUnsubFunctions = null;
|
|
1314
|
-
let updateHandler =
|
|
1313
|
+
let updateHandler = safelyHandleUpdate;
|
|
1315
1314
|
if (isSelector) {
|
|
1316
1315
|
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1317
1316
|
updateHandler = (update) => {
|
|
@@ -1319,7 +1318,7 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1319
1318
|
dependencyUnsubFunctions.length = 0;
|
|
1320
1319
|
dependencyUnsubFunctions.push(...subscribeToRootAtoms(state, store));
|
|
1321
1320
|
}
|
|
1322
|
-
|
|
1321
|
+
safelyHandleUpdate(update);
|
|
1323
1322
|
};
|
|
1324
1323
|
}
|
|
1325
1324
|
const mainUnsubFunction = state.subject.subscribe(key, updateHandler);
|
|
@@ -1408,18 +1407,7 @@ var Tracker = class {
|
|
|
1408
1407
|
this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
|
|
1409
1408
|
subscriptionKey,
|
|
1410
1409
|
(update) => {
|
|
1411
|
-
|
|
1412
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
1413
|
-
subscriptionKey,
|
|
1414
|
-
() => {
|
|
1415
|
-
unsubscribe();
|
|
1416
|
-
setIntoStore(latestUpdateState, update, target);
|
|
1417
|
-
}
|
|
1418
|
-
);
|
|
1419
|
-
} else {
|
|
1420
|
-
setIntoStore(mutableState, (current) => current, target);
|
|
1421
|
-
setIntoStore(latestUpdateState, update, target);
|
|
1422
|
-
}
|
|
1410
|
+
setIntoStore(latestUpdateState, update, target);
|
|
1423
1411
|
}
|
|
1424
1412
|
);
|
|
1425
1413
|
this.unsubscribeFromState = subscribeToState(
|
|
@@ -1430,18 +1418,7 @@ var Tracker = class {
|
|
|
1430
1418
|
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1431
1419
|
subscriptionKey,
|
|
1432
1420
|
(transceiverUpdate) => {
|
|
1433
|
-
|
|
1434
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
1435
|
-
subscriptionKey,
|
|
1436
|
-
() => {
|
|
1437
|
-
unsubscribe();
|
|
1438
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1439
|
-
}
|
|
1440
|
-
);
|
|
1441
|
-
} else {
|
|
1442
|
-
setIntoStore(mutableState, (current) => current, target);
|
|
1443
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1444
|
-
}
|
|
1421
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1445
1422
|
}
|
|
1446
1423
|
);
|
|
1447
1424
|
}
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -342,7 +342,7 @@ declare const markAtomAsNotDefault: (key: string, store: Store) => void;
|
|
|
342
342
|
* Can be constructed like a Promise, or from an existing Promise.
|
|
343
343
|
*/
|
|
344
344
|
declare class Future<T> extends Promise<T> {
|
|
345
|
-
private
|
|
345
|
+
private fate;
|
|
346
346
|
private resolve;
|
|
347
347
|
private reject;
|
|
348
348
|
constructor(executor: Promise<T> | ((resolve: (value: T) => void, reject: (reason?: any) => void) => void));
|
package/internal/dist/index.js
CHANGED
|
@@ -11,44 +11,30 @@ function arbitrary(random = Math.random) {
|
|
|
11
11
|
// internal/src/future.ts
|
|
12
12
|
var Future = class extends Promise {
|
|
13
13
|
constructor(executor) {
|
|
14
|
-
let promise;
|
|
15
14
|
let superResolve;
|
|
16
15
|
let superReject;
|
|
17
16
|
super((resolve, reject) => {
|
|
18
17
|
superResolve = resolve;
|
|
19
18
|
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
19
|
});
|
|
34
|
-
this.destiny = promise;
|
|
35
20
|
this.resolve = superResolve;
|
|
36
21
|
this.reject = superReject;
|
|
22
|
+
this.use(executor instanceof Promise ? executor : new Promise(executor));
|
|
37
23
|
}
|
|
38
24
|
pass(promise, value) {
|
|
39
|
-
if (promise === this.
|
|
25
|
+
if (promise === this.fate) {
|
|
40
26
|
this.resolve(value);
|
|
41
27
|
}
|
|
42
28
|
}
|
|
43
29
|
fail(promise, reason) {
|
|
44
|
-
if (promise === this.
|
|
30
|
+
if (promise === this.fate) {
|
|
45
31
|
this.reject(reason);
|
|
46
32
|
}
|
|
47
33
|
}
|
|
48
34
|
use(value) {
|
|
49
35
|
if (value instanceof Promise) {
|
|
50
36
|
const promise = value;
|
|
51
|
-
this.
|
|
37
|
+
this.fate = promise;
|
|
52
38
|
promise.then(
|
|
53
39
|
(resolved) => {
|
|
54
40
|
this.pass(promise, resolved);
|
|
@@ -59,7 +45,7 @@ var Future = class extends Promise {
|
|
|
59
45
|
);
|
|
60
46
|
} else {
|
|
61
47
|
this.resolve(value);
|
|
62
|
-
this.
|
|
48
|
+
this.fate = void 0;
|
|
63
49
|
}
|
|
64
50
|
}
|
|
65
51
|
};
|
|
@@ -977,10 +963,10 @@ function disposeSelector(selectorToken, store) {
|
|
|
977
963
|
// internal/src/subscribe/recall-state.ts
|
|
978
964
|
var recallState = (state, store) => {
|
|
979
965
|
const target = newest(store);
|
|
980
|
-
if (
|
|
981
|
-
return target.
|
|
966
|
+
if (target.operation.open) {
|
|
967
|
+
return target.operation.prev.get(state.key);
|
|
982
968
|
}
|
|
983
|
-
return target.
|
|
969
|
+
return target.valueMap.get(state.key);
|
|
984
970
|
};
|
|
985
971
|
|
|
986
972
|
// internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
@@ -1029,11 +1015,24 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
1029
1015
|
|
|
1030
1016
|
// internal/src/subscribe/subscribe-to-state.ts
|
|
1031
1017
|
function subscribeToState(token, handleUpdate, key, store) {
|
|
1018
|
+
function safelyHandleUpdate(update) {
|
|
1019
|
+
if (store.operation.open) {
|
|
1020
|
+
const unsubscribe2 = store.on.operationClose.subscribe(
|
|
1021
|
+
`state subscription ${key}`,
|
|
1022
|
+
() => {
|
|
1023
|
+
unsubscribe2();
|
|
1024
|
+
handleUpdate(update);
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
|
+
} else {
|
|
1028
|
+
handleUpdate(update);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1032
1031
|
const state = withdrawOrCreate(token, store);
|
|
1033
1032
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1034
1033
|
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
1035
1034
|
let dependencyUnsubFunctions = null;
|
|
1036
|
-
let updateHandler =
|
|
1035
|
+
let updateHandler = safelyHandleUpdate;
|
|
1037
1036
|
if (isSelector) {
|
|
1038
1037
|
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1039
1038
|
updateHandler = (update) => {
|
|
@@ -1041,7 +1040,7 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1041
1040
|
dependencyUnsubFunctions.length = 0;
|
|
1042
1041
|
dependencyUnsubFunctions.push(...subscribeToRootAtoms(state, store));
|
|
1043
1042
|
}
|
|
1044
|
-
|
|
1043
|
+
safelyHandleUpdate(update);
|
|
1045
1044
|
};
|
|
1046
1045
|
}
|
|
1047
1046
|
const mainUnsubFunction = state.subject.subscribe(key, updateHandler);
|
|
@@ -1130,18 +1129,7 @@ var Tracker = class {
|
|
|
1130
1129
|
this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
|
|
1131
1130
|
subscriptionKey,
|
|
1132
1131
|
(update) => {
|
|
1133
|
-
|
|
1134
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
1135
|
-
subscriptionKey,
|
|
1136
|
-
() => {
|
|
1137
|
-
unsubscribe();
|
|
1138
|
-
setIntoStore(latestUpdateState, update, target);
|
|
1139
|
-
}
|
|
1140
|
-
);
|
|
1141
|
-
} else {
|
|
1142
|
-
setIntoStore(mutableState, (current) => current, target);
|
|
1143
|
-
setIntoStore(latestUpdateState, update, target);
|
|
1144
|
-
}
|
|
1132
|
+
setIntoStore(latestUpdateState, update, target);
|
|
1145
1133
|
}
|
|
1146
1134
|
);
|
|
1147
1135
|
this.unsubscribeFromState = subscribeToState(
|
|
@@ -1152,18 +1140,7 @@ var Tracker = class {
|
|
|
1152
1140
|
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1153
1141
|
subscriptionKey,
|
|
1154
1142
|
(transceiverUpdate) => {
|
|
1155
|
-
|
|
1156
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
1157
|
-
subscriptionKey,
|
|
1158
|
-
() => {
|
|
1159
|
-
unsubscribe();
|
|
1160
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1161
|
-
}
|
|
1162
|
-
);
|
|
1163
|
-
} else {
|
|
1164
|
-
setIntoStore(mutableState, (current) => current, target);
|
|
1165
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1166
|
-
}
|
|
1143
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1167
1144
|
}
|
|
1168
1145
|
);
|
|
1169
1146
|
}
|
package/internal/src/future.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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
|
-
private
|
|
11
|
+
private fate: Promise<T> | undefined
|
|
12
12
|
private resolve: (value: T) => void
|
|
13
13
|
private reject: (reason?: any) => void
|
|
14
14
|
|
|
@@ -17,38 +17,24 @@ export class Future<T> extends Promise<T> {
|
|
|
17
17
|
| Promise<T>
|
|
18
18
|
| ((resolve: (value: T) => void, reject: (reason?: any) => void) => void),
|
|
19
19
|
) {
|
|
20
|
-
let promise: Promise<T> | undefined
|
|
21
20
|
let superResolve: ((value: T) => void) | undefined
|
|
22
21
|
let superReject: ((reason?: any) => void) | undefined
|
|
23
22
|
super((resolve, reject) => {
|
|
24
23
|
superResolve = resolve
|
|
25
24
|
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
|
-
)
|
|
39
25
|
})
|
|
40
|
-
this.destiny = promise
|
|
41
26
|
this.resolve = superResolve as (value: T) => void
|
|
42
27
|
this.reject = superReject as (reason?: any) => void
|
|
28
|
+
this.use(executor instanceof Promise ? executor : new Promise(executor))
|
|
43
29
|
}
|
|
44
30
|
|
|
45
31
|
private pass(promise: Promise<T>, value: T) {
|
|
46
|
-
if (promise === this.
|
|
32
|
+
if (promise === this.fate) {
|
|
47
33
|
this.resolve(value)
|
|
48
34
|
}
|
|
49
35
|
}
|
|
50
36
|
private fail(promise: Promise<T>, reason: any) {
|
|
51
|
-
if (promise === this.
|
|
37
|
+
if (promise === this.fate) {
|
|
52
38
|
this.reject(reason)
|
|
53
39
|
}
|
|
54
40
|
}
|
|
@@ -56,7 +42,7 @@ export class Future<T> extends Promise<T> {
|
|
|
56
42
|
public use(value: Promise<T> | T): void {
|
|
57
43
|
if (value instanceof Promise) {
|
|
58
44
|
const promise = value
|
|
59
|
-
this.
|
|
45
|
+
this.fate = promise
|
|
60
46
|
promise.then(
|
|
61
47
|
(resolved) => {
|
|
62
48
|
this.pass(promise, resolved)
|
|
@@ -67,7 +53,7 @@ export class Future<T> extends Promise<T> {
|
|
|
67
53
|
)
|
|
68
54
|
} else {
|
|
69
55
|
this.resolve(value)
|
|
70
|
-
this.
|
|
56
|
+
this.fate = undefined
|
|
71
57
|
}
|
|
72
58
|
}
|
|
73
59
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ReadableToken } from "atom.io"
|
|
2
2
|
|
|
3
|
-
import { NotFoundError } from "../not-found-error"
|
|
4
3
|
import type { Store } from "../store"
|
|
5
|
-
import {
|
|
4
|
+
import { withdrawOrCreate } from "../store"
|
|
6
5
|
import { readOrComputeValue } from "./read-or-compute-value"
|
|
7
6
|
|
|
8
7
|
export function getFromStore<T>(token: ReadableToken<T>, store: Store): T {
|
|
@@ -66,18 +66,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
|
|
|
66
66
|
this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
|
|
67
67
|
subscriptionKey,
|
|
68
68
|
(update) => {
|
|
69
|
-
|
|
70
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
71
|
-
subscriptionKey,
|
|
72
|
-
() => {
|
|
73
|
-
unsubscribe()
|
|
74
|
-
setIntoStore(latestUpdateState, update, target)
|
|
75
|
-
},
|
|
76
|
-
)
|
|
77
|
-
} else {
|
|
78
|
-
setIntoStore(mutableState, (current) => current, target)
|
|
79
|
-
setIntoStore(latestUpdateState, update, target)
|
|
80
|
-
}
|
|
69
|
+
setIntoStore(latestUpdateState, update, target)
|
|
81
70
|
},
|
|
82
71
|
)
|
|
83
72
|
this.unsubscribeFromState = subscribeToState(
|
|
@@ -88,18 +77,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
|
|
|
88
77
|
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
89
78
|
subscriptionKey,
|
|
90
79
|
(transceiverUpdate) => {
|
|
91
|
-
|
|
92
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
93
|
-
subscriptionKey,
|
|
94
|
-
() => {
|
|
95
|
-
unsubscribe()
|
|
96
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target)
|
|
97
|
-
},
|
|
98
|
-
)
|
|
99
|
-
} else {
|
|
100
|
-
setIntoStore(mutableState, (current) => current, target)
|
|
101
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target)
|
|
102
|
-
}
|
|
80
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target)
|
|
103
81
|
},
|
|
104
82
|
)
|
|
105
83
|
}
|
|
@@ -4,8 +4,8 @@ import type { Store } from "../store"
|
|
|
4
4
|
|
|
5
5
|
export const recallState = <T>(state: ReadableState<T>, store: Store): T => {
|
|
6
6
|
const target = newest(store)
|
|
7
|
-
if (
|
|
8
|
-
return target.
|
|
7
|
+
if (target.operation.open) {
|
|
8
|
+
return target.operation.prev.get(state.key)
|
|
9
9
|
}
|
|
10
|
-
return target.
|
|
10
|
+
return target.valueMap.get(state.key)
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReadableToken, UpdateHandler } from "atom.io"
|
|
1
|
+
import type { ReadableToken, StateUpdate, UpdateHandler } from "atom.io"
|
|
2
2
|
|
|
3
3
|
import type { Store } from "../store"
|
|
4
4
|
import { withdrawOrCreate } from "../store"
|
|
@@ -10,12 +10,25 @@ export function subscribeToState<T>(
|
|
|
10
10
|
key: string,
|
|
11
11
|
store: Store,
|
|
12
12
|
): () => void {
|
|
13
|
+
function safelyHandleUpdate(update: StateUpdate<any>): void {
|
|
14
|
+
if (store.operation.open) {
|
|
15
|
+
const unsubscribe = store.on.operationClose.subscribe(
|
|
16
|
+
`state subscription ${key}`,
|
|
17
|
+
() => {
|
|
18
|
+
unsubscribe()
|
|
19
|
+
handleUpdate(update)
|
|
20
|
+
},
|
|
21
|
+
)
|
|
22
|
+
} else {
|
|
23
|
+
handleUpdate(update)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
13
26
|
const state = withdrawOrCreate(token, store)
|
|
14
27
|
store.logger.info(`👀`, state.type, state.key, `Adding subscription "${key}"`)
|
|
15
28
|
const isSelector =
|
|
16
29
|
state.type === `selector` || state.type === `readonly_selector`
|
|
17
30
|
let dependencyUnsubFunctions: (() => void)[] | null = null
|
|
18
|
-
let updateHandler: UpdateHandler<T> =
|
|
31
|
+
let updateHandler: UpdateHandler<T> = safelyHandleUpdate
|
|
19
32
|
if (isSelector) {
|
|
20
33
|
dependencyUnsubFunctions = subscribeToRootAtoms(state, store)
|
|
21
34
|
updateHandler = (update) => {
|
|
@@ -23,7 +36,7 @@ export function subscribeToState<T>(
|
|
|
23
36
|
dependencyUnsubFunctions.length = 0
|
|
24
37
|
dependencyUnsubFunctions.push(...subscribeToRootAtoms(state, store))
|
|
25
38
|
}
|
|
26
|
-
|
|
39
|
+
safelyHandleUpdate(update)
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
const mainUnsubFunction = state.subject.subscribe(key, updateHandler)
|
|
@@ -245,19 +245,7 @@ var attachTimelineFamily = (store = Internal2.IMPLICIT.STORE) => {
|
|
|
245
245
|
({ setSelf }) => {
|
|
246
246
|
const tl = store.timelines.get(key);
|
|
247
247
|
tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
|
|
248
|
-
|
|
249
|
-
const unsubscribe = store.on.operationClose.subscribe(
|
|
250
|
-
`introspection`,
|
|
251
|
-
(operationClose) => {
|
|
252
|
-
if (operationClose.open === false) {
|
|
253
|
-
unsubscribe();
|
|
254
|
-
setSelf(__spreadValues({}, tl));
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
} else {
|
|
259
|
-
setSelf(__spreadValues({}, tl));
|
|
260
|
-
}
|
|
248
|
+
setSelf(__spreadValues({}, tl));
|
|
261
249
|
});
|
|
262
250
|
}
|
|
263
251
|
]
|
|
@@ -210,19 +210,7 @@ var attachTimelineFamily = (store = IMPLICIT.STORE) => {
|
|
|
210
210
|
({ setSelf }) => {
|
|
211
211
|
const tl = store.timelines.get(key);
|
|
212
212
|
tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
|
|
213
|
-
|
|
214
|
-
const unsubscribe = store.on.operationClose.subscribe(
|
|
215
|
-
`introspection`,
|
|
216
|
-
(operationClose) => {
|
|
217
|
-
if (operationClose.open === false) {
|
|
218
|
-
unsubscribe();
|
|
219
|
-
setSelf(__spreadValues({}, tl));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
);
|
|
223
|
-
} else {
|
|
224
|
-
setSelf(__spreadValues({}, tl));
|
|
225
|
-
}
|
|
213
|
+
setSelf(__spreadValues({}, tl));
|
|
226
214
|
});
|
|
227
215
|
}
|
|
228
216
|
]
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ReadonlySelectorFamily,
|
|
3
|
-
ReadonlySelectorFamilyToken,
|
|
4
|
-
} from "atom.io"
|
|
1
|
+
import type { ReadonlySelectorFamilyToken } from "atom.io"
|
|
5
2
|
import type { Store, Timeline } from "atom.io/internal"
|
|
6
3
|
import {
|
|
7
4
|
createRegularAtomFamily,
|
|
@@ -35,19 +32,7 @@ export const attachTimelineFamily = (
|
|
|
35
32
|
({ setSelf }) => {
|
|
36
33
|
const tl = store.timelines.get(key)
|
|
37
34
|
tl?.subject.subscribe(`introspection`, (_) => {
|
|
38
|
-
|
|
39
|
-
const unsubscribe = store.on.operationClose.subscribe(
|
|
40
|
-
`introspection`,
|
|
41
|
-
(operationClose) => {
|
|
42
|
-
if (operationClose.open === false) {
|
|
43
|
-
unsubscribe()
|
|
44
|
-
setSelf({ ...tl })
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
)
|
|
48
|
-
} else {
|
|
49
|
-
setSelf({ ...tl })
|
|
50
|
-
}
|
|
35
|
+
setSelf({ ...tl })
|
|
51
36
|
})
|
|
52
37
|
},
|
|
53
38
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@testing-library/react": "15.0.
|
|
51
|
+
"@testing-library/react": "15.0.7",
|
|
52
52
|
"@types/eslint": "npm:@types/eslint@8.56.10",
|
|
53
53
|
"@types/eslint-v9": "npm:@types/eslint@8.56.10",
|
|
54
54
|
"@types/estree": "1.0.5",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"@vitest/coverage-v8": "1.6.0",
|
|
62
62
|
"@vitest/ui": "1.6.0",
|
|
63
63
|
"concurrently": "8.2.2",
|
|
64
|
-
"drizzle-kit": "0.20.
|
|
64
|
+
"drizzle-kit": "0.20.18",
|
|
65
65
|
"drizzle-orm": "0.30.10",
|
|
66
66
|
"eslint": "npm:eslint@8.57.0",
|
|
67
67
|
"eslint-v9": "npm:eslint@9.2.0",
|
|
68
|
-
"framer-motion": "11.1.
|
|
69
|
-
"happy-dom": "14.
|
|
68
|
+
"framer-motion": "11.1.9",
|
|
69
|
+
"happy-dom": "14.10.1",
|
|
70
70
|
"http-proxy": "1.18.1",
|
|
71
71
|
"npmlog": "7.0.1",
|
|
72
72
|
"postgres": "3.4.4",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findRelationsInStore } from '../../dist/chunk-
|
|
1
|
+
import { findRelationsInStore } from '../../dist/chunk-HITX3MO4.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
3
|
import { __spreadProps, __spreadValues } from '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { parseJson, stringifyJson } from 'atom.io/json';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { myUsernameState } from '../../dist/chunk-O47EQUM6.js';
|
|
2
|
-
import { editRelationsInStore } from '../../dist/chunk-
|
|
2
|
+
import { editRelationsInStore } from '../../dist/chunk-HITX3MO4.js';
|
|
3
3
|
import '../../dist/chunk-FTONNX2R.js';
|
|
4
4
|
import { recordToEntries } from '../../dist/chunk-3V3VWQ7X.js';
|
|
5
5
|
import '../../dist/chunk-BWWVY5O5.js';
|
package/src/validators.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
MutableAtomFamily,
|
|
3
2
|
MutableAtomFamilyToken,
|
|
4
3
|
MutableAtomToken,
|
|
5
|
-
ReadableFamily,
|
|
6
4
|
ReadableFamilyToken,
|
|
7
5
|
ReadableToken,
|
|
8
|
-
ReadonlySelectorFamily,
|
|
9
6
|
ReadonlySelectorFamilyToken,
|
|
10
7
|
ReadonlySelectorToken,
|
|
11
|
-
RegularAtomFamily,
|
|
12
8
|
RegularAtomFamilyToken,
|
|
13
9
|
RegularAtomToken,
|
|
14
|
-
WritableFamily,
|
|
15
10
|
WritableFamilyToken,
|
|
16
|
-
WritableSelectorFamily,
|
|
17
11
|
WritableSelectorFamilyToken,
|
|
18
12
|
WritableSelectorToken,
|
|
19
13
|
WritableToken,
|
|
File without changes
|