atom.io 0.20.0 â 0.20.2
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/index.d.ts +1 -0
- package/internal/dist/index.cjs +30 -22
- package/internal/dist/index.js +30 -22
- package/internal/src/operation.ts +3 -3
- package/internal/src/set-state/set-into-store.ts +7 -1
- package/internal/src/subscribe/subscribe-to-state.ts +28 -33
- package/package.json +8 -8
- package/src/logger.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -174,6 +174,7 @@ declare const LoggerIconDictionary: {
|
|
|
174
174
|
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
175
175
|
readonly "\u2705": "Realtime transaction success";
|
|
176
176
|
readonly "\u2728": "Computation complete";
|
|
177
|
+
readonly "\u2757": "Must wait to proceed with attempted action";
|
|
177
178
|
readonly "\u274C": "Conflict prevents attempted action";
|
|
178
179
|
readonly "\u2B55": "Operation start";
|
|
179
180
|
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
package/internal/dist/index.cjs
CHANGED
|
@@ -774,11 +774,11 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
|
|
|
774
774
|
// internal/src/operation.ts
|
|
775
775
|
var openOperation = (token, store) => {
|
|
776
776
|
if (store.operation.open) {
|
|
777
|
-
store.logger.
|
|
778
|
-
`\
|
|
777
|
+
store.logger.warn(
|
|
778
|
+
`\u2757`,
|
|
779
779
|
token.type,
|
|
780
780
|
token.key,
|
|
781
|
-
`
|
|
781
|
+
`tried to setState, but must wait until setState for "${store.operation.token.key}" completes`
|
|
782
782
|
);
|
|
783
783
|
return `rejection`;
|
|
784
784
|
}
|
|
@@ -991,6 +991,13 @@ var setAtomOrSelector = (state, value, store) => {
|
|
|
991
991
|
function setIntoStore(token, value, store) {
|
|
992
992
|
const rejection = openOperation(token, store);
|
|
993
993
|
if (rejection) {
|
|
994
|
+
const unsubscribe = store.on.operationClose.subscribe(
|
|
995
|
+
`waiting to set "${token.key}"`,
|
|
996
|
+
() => {
|
|
997
|
+
unsubscribe();
|
|
998
|
+
setIntoStore(token, value, store);
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
994
1001
|
return;
|
|
995
1002
|
}
|
|
996
1003
|
const state = withdrawOrCreate(token, store);
|
|
@@ -1291,32 +1298,33 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
1291
1298
|
// internal/src/subscribe/subscribe-to-state.ts
|
|
1292
1299
|
function subscribeToState(token, handleUpdate, key, store) {
|
|
1293
1300
|
const state = withdrawOrCreate(token, store);
|
|
1294
|
-
if (state === void 0) {
|
|
1295
|
-
throw new Error(
|
|
1296
|
-
`State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
1297
|
-
);
|
|
1298
|
-
}
|
|
1299
|
-
const unsubFunction = state.subject.subscribe(key, handleUpdate);
|
|
1300
1301
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1302
|
+
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
1303
|
+
let dependencyUnsubFunctions = null;
|
|
1304
|
+
let updateHandler = handleUpdate;
|
|
1305
|
+
if (isSelector) {
|
|
1306
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1307
|
+
updateHandler = (update) => {
|
|
1308
|
+
if (dependencyUnsubFunctions) {
|
|
1309
|
+
dependencyUnsubFunctions.length = 0;
|
|
1310
|
+
}
|
|
1311
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1312
|
+
handleUpdate(update);
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
const mainUnsubFunction = state.subject.subscribe(key, updateHandler);
|
|
1316
|
+
const unsubscribe = () => {
|
|
1311
1317
|
store.logger.info(
|
|
1312
1318
|
`\u{1F648}`,
|
|
1313
1319
|
state.type,
|
|
1314
1320
|
state.key,
|
|
1315
1321
|
`Removing subscription "${key}"`
|
|
1316
1322
|
);
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
unsubFromDependency
|
|
1323
|
+
mainUnsubFunction();
|
|
1324
|
+
if (dependencyUnsubFunctions) {
|
|
1325
|
+
for (const unsubFromDependency of dependencyUnsubFunctions) {
|
|
1326
|
+
unsubFromDependency();
|
|
1327
|
+
}
|
|
1320
1328
|
}
|
|
1321
1329
|
};
|
|
1322
1330
|
return unsubscribe;
|
package/internal/dist/index.js
CHANGED
|
@@ -496,11 +496,11 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
|
|
|
496
496
|
// internal/src/operation.ts
|
|
497
497
|
var openOperation = (token, store) => {
|
|
498
498
|
if (store.operation.open) {
|
|
499
|
-
store.logger.
|
|
500
|
-
`\
|
|
499
|
+
store.logger.warn(
|
|
500
|
+
`\u2757`,
|
|
501
501
|
token.type,
|
|
502
502
|
token.key,
|
|
503
|
-
`
|
|
503
|
+
`tried to setState, but must wait until setState for "${store.operation.token.key}" completes`
|
|
504
504
|
);
|
|
505
505
|
return `rejection`;
|
|
506
506
|
}
|
|
@@ -713,6 +713,13 @@ var setAtomOrSelector = (state, value, store) => {
|
|
|
713
713
|
function setIntoStore(token, value, store) {
|
|
714
714
|
const rejection = openOperation(token, store);
|
|
715
715
|
if (rejection) {
|
|
716
|
+
const unsubscribe = store.on.operationClose.subscribe(
|
|
717
|
+
`waiting to set "${token.key}"`,
|
|
718
|
+
() => {
|
|
719
|
+
unsubscribe();
|
|
720
|
+
setIntoStore(token, value, store);
|
|
721
|
+
}
|
|
722
|
+
);
|
|
716
723
|
return;
|
|
717
724
|
}
|
|
718
725
|
const state = withdrawOrCreate(token, store);
|
|
@@ -1013,32 +1020,33 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
1013
1020
|
// internal/src/subscribe/subscribe-to-state.ts
|
|
1014
1021
|
function subscribeToState(token, handleUpdate, key, store) {
|
|
1015
1022
|
const state = withdrawOrCreate(token, store);
|
|
1016
|
-
if (state === void 0) {
|
|
1017
|
-
throw new Error(
|
|
1018
|
-
`State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
1019
|
-
);
|
|
1020
|
-
}
|
|
1021
|
-
const unsubFunction = state.subject.subscribe(key, handleUpdate);
|
|
1022
1023
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1024
|
+
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
1025
|
+
let dependencyUnsubFunctions = null;
|
|
1026
|
+
let updateHandler = handleUpdate;
|
|
1027
|
+
if (isSelector) {
|
|
1028
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1029
|
+
updateHandler = (update) => {
|
|
1030
|
+
if (dependencyUnsubFunctions) {
|
|
1031
|
+
dependencyUnsubFunctions.length = 0;
|
|
1032
|
+
}
|
|
1033
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1034
|
+
handleUpdate(update);
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
const mainUnsubFunction = state.subject.subscribe(key, updateHandler);
|
|
1038
|
+
const unsubscribe = () => {
|
|
1033
1039
|
store.logger.info(
|
|
1034
1040
|
`\u{1F648}`,
|
|
1035
1041
|
state.type,
|
|
1036
1042
|
state.key,
|
|
1037
1043
|
`Removing subscription "${key}"`
|
|
1038
1044
|
);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
unsubFromDependency
|
|
1045
|
+
mainUnsubFunction();
|
|
1046
|
+
if (dependencyUnsubFunctions) {
|
|
1047
|
+
for (const unsubFromDependency of dependencyUnsubFunctions) {
|
|
1048
|
+
unsubFromDependency();
|
|
1049
|
+
}
|
|
1042
1050
|
}
|
|
1043
1051
|
};
|
|
1044
1052
|
return unsubscribe;
|
|
@@ -21,11 +21,11 @@ export const openOperation = (
|
|
|
21
21
|
store: Store,
|
|
22
22
|
): `rejection` | undefined => {
|
|
23
23
|
if (store.operation.open) {
|
|
24
|
-
store.logger.
|
|
25
|
-
|
|
24
|
+
store.logger.warn(
|
|
25
|
+
`â`,
|
|
26
26
|
token.type,
|
|
27
27
|
token.key,
|
|
28
|
-
`
|
|
28
|
+
`tried to setState, but must wait until setState for "${store.operation.token.key}" completes`,
|
|
29
29
|
)
|
|
30
30
|
return `rejection`
|
|
31
31
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { WritableToken } from "atom.io"
|
|
2
2
|
|
|
3
|
-
import { NotFoundError } from "../not-found-error"
|
|
4
3
|
import { closeOperation, openOperation } from "../operation"
|
|
5
4
|
import type { Store } from "../store"
|
|
6
5
|
import { withdrawOrCreate } from "../store"
|
|
@@ -13,6 +12,13 @@ export function setIntoStore<T, New extends T>(
|
|
|
13
12
|
): void {
|
|
14
13
|
const rejection = openOperation(token, store)
|
|
15
14
|
if (rejection) {
|
|
15
|
+
const unsubscribe = store.on.operationClose.subscribe(
|
|
16
|
+
`waiting to set "${token.key}"`,
|
|
17
|
+
() => {
|
|
18
|
+
unsubscribe()
|
|
19
|
+
setIntoStore(token, value, store)
|
|
20
|
+
},
|
|
21
|
+
)
|
|
16
22
|
return
|
|
17
23
|
}
|
|
18
24
|
const state = withdrawOrCreate(token, store)
|
|
@@ -11,41 +11,36 @@ export function subscribeToState<T>(
|
|
|
11
11
|
store: Store,
|
|
12
12
|
): () => void {
|
|
13
13
|
const state = withdrawOrCreate(token, store)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
store.logger.info(`đ`, state.type, state.key, `Adding subscription "${key}"`)
|
|
15
|
+
const isSelector =
|
|
16
|
+
state.type === `selector` || state.type === `readonly_selector`
|
|
17
|
+
let dependencyUnsubFunctions: (() => void)[] | null = null
|
|
18
|
+
let updateHandler: UpdateHandler<T> = handleUpdate
|
|
19
|
+
if (isSelector) {
|
|
20
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(state, store)
|
|
21
|
+
updateHandler = (update) => {
|
|
22
|
+
if (dependencyUnsubFunctions) {
|
|
23
|
+
dependencyUnsubFunctions.length = 0
|
|
24
|
+
}
|
|
25
|
+
dependencyUnsubFunctions = subscribeToRootAtoms(state, store)
|
|
26
|
+
handleUpdate(update)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const mainUnsubFunction = state.subject.subscribe(key, updateHandler)
|
|
30
|
+
const unsubscribe = () => {
|
|
31
|
+
store.logger.info(
|
|
32
|
+
`đ`,
|
|
33
|
+
state.type,
|
|
34
|
+
state.key,
|
|
35
|
+
`Removing subscription "${key}"`,
|
|
17
36
|
)
|
|
37
|
+
mainUnsubFunction()
|
|
38
|
+
if (dependencyUnsubFunctions) {
|
|
39
|
+
for (const unsubFromDependency of dependencyUnsubFunctions) {
|
|
40
|
+
unsubFromDependency()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
18
43
|
}
|
|
19
|
-
const unsubFunction = state.subject.subscribe(key, handleUpdate)
|
|
20
|
-
store.logger.info(`đ`, state.type, state.key, `Adding subscription "${key}"`)
|
|
21
|
-
const dependencyUnsubFunctions =
|
|
22
|
-
state.type !== `atom` && state.type !== `mutable_atom`
|
|
23
|
-
? subscribeToRootAtoms(state, store)
|
|
24
|
-
: null
|
|
25
|
-
|
|
26
|
-
const unsubscribe =
|
|
27
|
-
dependencyUnsubFunctions === null
|
|
28
|
-
? () => {
|
|
29
|
-
store.logger.info(
|
|
30
|
-
`đ`,
|
|
31
|
-
state.type,
|
|
32
|
-
state.key,
|
|
33
|
-
`Removing subscription "${key}"`,
|
|
34
|
-
)
|
|
35
|
-
unsubFunction()
|
|
36
|
-
}
|
|
37
|
-
: () => {
|
|
38
|
-
store.logger.info(
|
|
39
|
-
`đ`,
|
|
40
|
-
state.type,
|
|
41
|
-
state.key,
|
|
42
|
-
`Removing subscription "${key}"`,
|
|
43
|
-
)
|
|
44
|
-
unsubFunction()
|
|
45
|
-
for (const unsubFromDependency of dependencyUnsubFunctions) {
|
|
46
|
-
unsubFromDependency()
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
44
|
|
|
50
45
|
return unsubscribe
|
|
51
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,18 +48,18 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@testing-library/react": "15.0.
|
|
51
|
+
"@testing-library/react": "15.0.5",
|
|
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",
|
|
55
55
|
"@types/http-proxy": "1.17.14",
|
|
56
56
|
"@types/npmlog": "7.0.0",
|
|
57
|
-
"@types/react": "18.
|
|
57
|
+
"@types/react": "18.3.0",
|
|
58
58
|
"@types/tmp": "0.2.6",
|
|
59
59
|
"@typescript-eslint/parser": "7.7.1",
|
|
60
60
|
"@typescript-eslint/rule-tester": "7.7.1",
|
|
61
|
-
"@vitest/coverage-v8": "1.5.
|
|
62
|
-
"@vitest/ui": "1.5.
|
|
61
|
+
"@vitest/coverage-v8": "1.5.2",
|
|
62
|
+
"@vitest/ui": "1.5.2",
|
|
63
63
|
"concurrently": "8.2.2",
|
|
64
64
|
"drizzle-kit": "0.20.17",
|
|
65
65
|
"drizzle-orm": "0.30.9",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"npmlog": "7.0.1",
|
|
72
72
|
"postgres": "3.4.4",
|
|
73
73
|
"preact": "10.20.2",
|
|
74
|
-
"react": "18.
|
|
75
|
-
"react-dom": "18.
|
|
74
|
+
"react": "18.3.0",
|
|
75
|
+
"react-dom": "18.3.0",
|
|
76
76
|
"react-router-dom": "6.23.0",
|
|
77
77
|
"socket.io": "4.7.5",
|
|
78
78
|
"socket.io-client": "4.7.5",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"typescript": "5.4.5",
|
|
82
82
|
"vite": "5.2.10",
|
|
83
83
|
"vite-tsconfig-paths": "4.3.2",
|
|
84
|
-
"vitest": "1.5.
|
|
84
|
+
"vitest": "1.5.2"
|
|
85
85
|
},
|
|
86
86
|
"main": "dist/index.js",
|
|
87
87
|
"types": "dist/index.d.ts",
|
package/src/logger.ts
CHANGED
|
@@ -8,6 +8,7 @@ const LoggerIconDictionary = {
|
|
|
8
8
|
"âšī¸": `Time-travel complete`,
|
|
9
9
|
"â
": `Realtime transaction success`,
|
|
10
10
|
"â¨": `Computation complete`,
|
|
11
|
+
"â": `Must wait to proceed with attempted action`,
|
|
11
12
|
"â": `Conflict prevents attempted action`,
|
|
12
13
|
"â": `Operation start`,
|
|
13
14
|
"đ": `Possible bug in AtomIO`,
|