atom.io 0.35.0 → 0.36.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/dist/eslint-plugin/index.d.ts +2 -18
- package/dist/eslint-plugin/index.d.ts.map +1 -1
- package/dist/eslint-plugin/index.js +4 -141
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/internal/index.d.ts +100 -78
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +180 -163
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts +5 -6
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js +2 -3
- package/dist/introspection/index.js.map +1 -1
- package/dist/json/index.d.ts +2 -10
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +1 -31
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts +38 -39
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +15 -16
- package/dist/main/index.js.map +1 -1
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts +4 -4
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +2 -6
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +7 -8
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +3 -4
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +4 -4
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +18 -18
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +5 -9
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts +9 -2
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.js +3 -0
- package/dist/transceivers/set-rtx/index.js.map +1 -1
- package/package.json +6 -6
- package/src/eslint-plugin/index.ts +0 -1
- package/src/eslint-plugin/rules/explicit-state-types.ts +8 -1
- package/src/eslint-plugin/rules/index.ts +0 -1
- package/src/internal/atom/create-regular-atom.ts +5 -5
- package/src/internal/atom/dispose-atom.ts +1 -0
- package/src/internal/atom/has-role.ts +12 -0
- package/src/internal/atom/index.ts +1 -0
- package/src/internal/caching.ts +38 -16
- package/src/internal/families/find-in-store.ts +4 -5
- package/src/internal/families/get-family-of-token.ts +4 -5
- package/src/internal/families/init-family-member.ts +3 -4
- package/src/internal/families/seek-in-store.ts +4 -5
- package/src/internal/get-state/read-or-compute-value.ts +37 -16
- package/src/internal/index.ts +19 -21
- package/src/internal/ingest-updates/ingest-creation-disposal.ts +18 -15
- package/src/internal/ingest-updates/ingest-selector-update.ts +9 -5
- package/src/internal/join/get-internal-relations-from-store.ts +2 -2
- package/src/internal/join/join-internal.ts +10 -18
- package/src/internal/molecule.ts +1 -0
- package/src/internal/mutable/create-mutable-atom-family.ts +40 -22
- package/src/internal/mutable/create-mutable-atom.ts +16 -12
- package/src/internal/mutable/get-json-family.ts +7 -6
- package/src/internal/mutable/get-json-token.ts +6 -13
- package/src/internal/mutable/get-update-family.ts +7 -8
- package/src/internal/mutable/get-update-token.ts +5 -9
- package/src/internal/mutable/tracker-family.ts +31 -38
- package/src/internal/mutable/tracker.ts +86 -104
- package/src/internal/mutable/transceiver.ts +37 -9
- package/src/internal/selector/create-readonly-held-selector.ts +2 -2
- package/src/internal/selector/create-readonly-pure-selector.ts +2 -2
- package/src/internal/selector/create-writable-held-selector.ts +3 -3
- package/src/internal/selector/create-writable-pure-selector.ts +3 -3
- package/src/internal/selector/dispose-selector.ts +9 -9
- package/src/internal/set-state/reset-atom-or-selector.ts +11 -4
- package/src/internal/set-state/set-atom.ts +15 -22
- package/src/internal/set-state/set-into-store.ts +5 -4
- package/src/internal/store/counterfeit.ts +3 -4
- package/src/internal/store/deposit.ts +8 -11
- package/src/internal/store/store.ts +7 -7
- package/src/internal/store/withdraw.ts +8 -12
- package/src/internal/subscribe/subscribe-in-store.ts +2 -2
- package/src/internal/subscribe/subscribe-to-transaction.ts +2 -2
- package/src/internal/timeline/create-timeline.ts +3 -3
- package/src/internal/transaction/act-upon-store.ts +2 -2
- package/src/internal/transaction/apply-transaction.ts +2 -2
- package/src/internal/transaction/build-transaction.ts +2 -2
- package/src/internal/transaction/create-transaction.ts +3 -3
- package/src/internal/transaction/index.ts +2 -2
- package/src/internal/transaction/is-root-store.ts +4 -2
- package/src/internal/utility-types.ts +1 -1
- package/src/introspection/attach-introspection-states.ts +3 -3
- package/src/introspection/attach-transaction-index.ts +4 -4
- package/src/introspection/attach-transaction-logs.ts +4 -4
- package/src/introspection/auditor.ts +3 -3
- package/src/json/index.ts +0 -2
- package/src/main/atom.ts +24 -36
- package/src/main/dispose-state.ts +6 -5
- package/src/main/find-state.ts +3 -4
- package/src/main/get-state.ts +6 -5
- package/src/main/join.ts +2 -2
- package/src/main/logger.ts +7 -7
- package/src/main/reset-state.ts +3 -3
- package/src/main/set-state.ts +3 -3
- package/src/main/subscribe.ts +3 -3
- package/src/main/tokens.ts +8 -14
- package/src/main/transaction.ts +17 -13
- package/src/main/validators.ts +1 -1
- package/src/react/use-json.ts +14 -24
- package/src/react-devtools/TransactionIndex.tsx +3 -3
- package/src/react-devtools/Updates.tsx +2 -2
- package/src/realtime/shared-room-store.ts +11 -22
- package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +2 -2
- package/src/realtime-client/pull-mutable-atom-family-member.ts +8 -17
- package/src/realtime-client/pull-mutable-atom.ts +7 -14
- package/src/realtime-client/push-state.ts +6 -5
- package/src/realtime-client/server-action.ts +5 -4
- package/src/realtime-react/use-pull-mutable-atom.ts +3 -5
- package/src/realtime-react/use-pull-mutable-family-member.ts +3 -4
- package/src/realtime-react/use-server-action.ts +2 -2
- package/src/realtime-server/realtime-mutable-family-provider.ts +3 -4
- package/src/realtime-server/realtime-mutable-provider.ts +2 -3
- package/src/realtime-server/realtime-server-stores/server-room-external-actions.ts +6 -5
- package/src/realtime-server/realtime-server-stores/server-user-store.ts +8 -15
- package/src/transceivers/set-rtx/set-rtx.ts +14 -1
- package/src/eslint-plugin/rules/synchronous-selector-dependencies.ts +0 -140
- package/src/eslint-plugin/walk.ts +0 -81
- package/src/internal/set-state/copy-mutable-if-needed.ts +0 -27
- package/src/json/select-json-family.ts +0 -55
- package/src/json/select-json.ts +0 -19
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/switch-exhaustiveness-check */
|
|
2
|
-
import type * as ESTree from "estree"
|
|
3
|
-
|
|
4
|
-
export function walk(
|
|
5
|
-
node: ESTree.Node,
|
|
6
|
-
callback: (node: ESTree.Node, depth: number) => void,
|
|
7
|
-
depth = 0,
|
|
8
|
-
): void {
|
|
9
|
-
callback(node, depth)
|
|
10
|
-
|
|
11
|
-
switch (node.type) {
|
|
12
|
-
case `AwaitExpression`:
|
|
13
|
-
walk(node.argument, callback, depth + 1)
|
|
14
|
-
break
|
|
15
|
-
case `FunctionExpression`:
|
|
16
|
-
case `ArrowFunctionExpression`:
|
|
17
|
-
for (const param of node.params) {
|
|
18
|
-
walk(param, callback, depth + 1)
|
|
19
|
-
}
|
|
20
|
-
walk(node.body, callback, depth + 1)
|
|
21
|
-
break
|
|
22
|
-
case `BlockStatement`:
|
|
23
|
-
for (const statement of node.body) {
|
|
24
|
-
walk(statement, callback, depth + 1)
|
|
25
|
-
}
|
|
26
|
-
break
|
|
27
|
-
case `IfStatement`:
|
|
28
|
-
walk(node.test, callback, depth)
|
|
29
|
-
walk(node.consequent, callback, depth)
|
|
30
|
-
if (node.alternate) {
|
|
31
|
-
walk(node.alternate, callback, depth)
|
|
32
|
-
}
|
|
33
|
-
break
|
|
34
|
-
case `SwitchStatement`:
|
|
35
|
-
walk(node.discriminant, callback, depth + 1)
|
|
36
|
-
for (const caseOrDefault of node.cases) {
|
|
37
|
-
walk(caseOrDefault, callback, depth)
|
|
38
|
-
}
|
|
39
|
-
break
|
|
40
|
-
case `ReturnStatement`:
|
|
41
|
-
if (node.argument) {
|
|
42
|
-
walk(node.argument, callback, depth)
|
|
43
|
-
}
|
|
44
|
-
break
|
|
45
|
-
case `SwitchCase`:
|
|
46
|
-
if (node.test) {
|
|
47
|
-
walk(node.test, callback, depth)
|
|
48
|
-
}
|
|
49
|
-
for (const statement of node.consequent) {
|
|
50
|
-
walk(statement, callback, depth)
|
|
51
|
-
}
|
|
52
|
-
break
|
|
53
|
-
case `VariableDeclaration`:
|
|
54
|
-
for (const declaration of node.declarations) {
|
|
55
|
-
walk(declaration, callback, depth)
|
|
56
|
-
if (declaration.init) {
|
|
57
|
-
walk(declaration.init, callback, depth)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
break
|
|
61
|
-
case `BinaryExpression`:
|
|
62
|
-
walk(node.left, callback, depth)
|
|
63
|
-
walk(node.right, callback, depth)
|
|
64
|
-
break
|
|
65
|
-
case `ConditionalExpression`:
|
|
66
|
-
walk(node.test, callback, depth + 1)
|
|
67
|
-
walk(node.consequent, callback, depth + 1)
|
|
68
|
-
walk(node.alternate, callback, depth + 1)
|
|
69
|
-
break
|
|
70
|
-
case `MemberExpression`:
|
|
71
|
-
walk(node.object, callback, depth)
|
|
72
|
-
walk(node.property, callback, depth)
|
|
73
|
-
break
|
|
74
|
-
case `CallExpression`:
|
|
75
|
-
walk(node.callee, callback, depth)
|
|
76
|
-
for (const argument of node.arguments) {
|
|
77
|
-
walk(argument, callback, depth)
|
|
78
|
-
}
|
|
79
|
-
break
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { MutableAtom, Transceiver } from ".."
|
|
2
|
-
import { Tracker } from "../mutable"
|
|
3
|
-
import type { Store } from "../store"
|
|
4
|
-
|
|
5
|
-
export function copyMutableIfNeeded<T extends Transceiver<any>>(
|
|
6
|
-
target: Store,
|
|
7
|
-
atom: MutableAtom<T, any>,
|
|
8
|
-
origin: Store,
|
|
9
|
-
): T {
|
|
10
|
-
const originValue = origin.valueMap.get(atom.key)
|
|
11
|
-
const targetValue = target.valueMap.get(atom.key)
|
|
12
|
-
|
|
13
|
-
if (originValue !== targetValue) {
|
|
14
|
-
return targetValue
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (originValue === undefined) {
|
|
18
|
-
return atom.default()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
origin.logger.info(`📃`, `atom`, atom.key, `copying`)
|
|
22
|
-
const jsonValue = atom.toJson(originValue)
|
|
23
|
-
const copiedValue = atom.fromJson(jsonValue)
|
|
24
|
-
target.valueMap.set(atom.key, copiedValue)
|
|
25
|
-
new Tracker(atom, origin)
|
|
26
|
-
return copiedValue
|
|
27
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type * as AtomIO from "atom.io"
|
|
2
|
-
import type { Store, Transceiver } from "atom.io/internal"
|
|
3
|
-
import { createWritablePureSelectorFamily } from "atom.io/internal"
|
|
4
|
-
|
|
5
|
-
import type { Canonical, Json, JsonInterface } from "."
|
|
6
|
-
|
|
7
|
-
export function selectJsonFamily<
|
|
8
|
-
T extends Transceiver<any>,
|
|
9
|
-
J extends Json.Serializable,
|
|
10
|
-
K extends Canonical,
|
|
11
|
-
>(
|
|
12
|
-
store: Store,
|
|
13
|
-
atomFamilyToken: AtomIO.MutableAtomFamilyToken<T, J, K>,
|
|
14
|
-
transform: JsonInterface<T, J>,
|
|
15
|
-
): AtomIO.WritablePureSelectorFamilyToken<J, K>
|
|
16
|
-
export function selectJsonFamily<
|
|
17
|
-
T,
|
|
18
|
-
J extends Json.Serializable,
|
|
19
|
-
K extends Canonical,
|
|
20
|
-
>(
|
|
21
|
-
store: Store,
|
|
22
|
-
atomFamilyToken: AtomIO.RegularAtomFamilyToken<T, K>,
|
|
23
|
-
transform: JsonInterface<T, J>,
|
|
24
|
-
): AtomIO.WritablePureSelectorFamilyToken<J, K>
|
|
25
|
-
export function selectJsonFamily<
|
|
26
|
-
T,
|
|
27
|
-
J extends Json.Serializable,
|
|
28
|
-
K extends Canonical,
|
|
29
|
-
>(
|
|
30
|
-
store: Store,
|
|
31
|
-
atomFamilyToken:
|
|
32
|
-
| AtomIO.MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, J, K>
|
|
33
|
-
| AtomIO.RegularAtomFamilyToken<T, K>,
|
|
34
|
-
transform: JsonInterface<T, J>,
|
|
35
|
-
): AtomIO.WritablePureSelectorFamilyToken<J, K> {
|
|
36
|
-
const jsonFamily = createWritablePureSelectorFamily<J, K>(
|
|
37
|
-
store,
|
|
38
|
-
{
|
|
39
|
-
key: `${atomFamilyToken.key}:JSON`,
|
|
40
|
-
get:
|
|
41
|
-
(key) =>
|
|
42
|
-
({ get }) => {
|
|
43
|
-
const baseState = get(atomFamilyToken, key)
|
|
44
|
-
return transform.toJson(baseState)
|
|
45
|
-
},
|
|
46
|
-
set:
|
|
47
|
-
(key) =>
|
|
48
|
-
({ set }, newValue) => {
|
|
49
|
-
set(atomFamilyToken, key, transform.fromJson(newValue))
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
[`mutable`, `json`],
|
|
53
|
-
)
|
|
54
|
-
return jsonFamily
|
|
55
|
-
}
|
package/src/json/select-json.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type * as AtomIO from "atom.io"
|
|
2
|
-
import type { Store } from "atom.io/internal"
|
|
3
|
-
import { createStandaloneSelector, IMPLICIT } from "atom.io/internal"
|
|
4
|
-
|
|
5
|
-
import type { Json, JsonInterface } from "."
|
|
6
|
-
|
|
7
|
-
export const selectJson = <T, J extends Json.Serializable>(
|
|
8
|
-
atom: AtomIO.AtomToken<T>,
|
|
9
|
-
transform: JsonInterface<T, J>,
|
|
10
|
-
store: Store = IMPLICIT.STORE,
|
|
11
|
-
): AtomIO.WritablePureSelectorToken<J> => {
|
|
12
|
-
return createStandaloneSelector(store, {
|
|
13
|
-
key: `${atom.key}:JSON`,
|
|
14
|
-
get: ({ get }) => transform.toJson(get(atom)),
|
|
15
|
-
set: ({ set }, newValue) => {
|
|
16
|
-
set(atom, transform.fromJson(newValue))
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
}
|