atom.io 0.35.0 → 0.36.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/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 +47 -41
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +95 -78
- package/dist/internal/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 +24 -23
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +9 -9
- 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.d.ts.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 +2 -2
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +2 -2
- 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 +1 -1
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.js.map +1 -1
- package/package.json +5 -5
- 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/dispose-atom.ts +1 -0
- 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 +14 -2
- 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 +3 -14
- package/src/internal/molecule.ts +1 -0
- package/src/internal/mutable/create-mutable-atom-family.ts +37 -20
- 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 +10 -13
- package/src/internal/mutable/tracker.ts +66 -90
- package/src/internal/mutable/transceiver.ts +35 -8
- package/src/internal/selector/dispose-selector.ts +9 -9
- package/src/internal/set-state/copy-mutable-if-needed.ts +8 -6
- package/src/internal/set-state/reset-atom-or-selector.ts +11 -4
- package/src/internal/set-state/set-atom.ts +1 -1
- package/src/internal/store/counterfeit.ts +3 -4
- package/src/internal/store/deposit.ts +7 -9
- package/src/internal/store/store.ts +2 -2
- package/src/internal/store/withdraw.ts +7 -11
- package/src/json/index.ts +0 -2
- package/src/main/atom.ts +24 -36
- package/src/main/dispose-state.ts +4 -4
- package/src/main/find-state.ts +3 -4
- package/src/main/join.ts +2 -2
- package/src/main/logger.ts +7 -7
- package/src/main/tokens.ts +9 -11
- package/src/main/transaction.ts +11 -5
- package/src/main/validators.ts +1 -1
- package/src/react/use-json.ts +15 -25
- package/src/realtime/shared-room-store.ts +11 -22
- package/src/realtime-client/pull-mutable-atom-family-member.ts +5 -9
- package/src/realtime-client/pull-mutable-atom.ts +5 -9
- 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-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 +1 -1
- package/src/eslint-plugin/rules/synchronous-selector-dependencies.ts +0 -140
- package/src/eslint-plugin/walk.ts +0 -81
- package/src/json/select-json-family.ts +0 -55
- package/src/json/select-json.ts +0 -19
|
@@ -16,7 +16,7 @@ export interface SetRTXJson<P extends primitive> extends Json.Object {
|
|
|
16
16
|
}
|
|
17
17
|
export class SetRTX<P extends primitive>
|
|
18
18
|
extends Set<P>
|
|
19
|
-
implements Transceiver<NumberedSetUpdate
|
|
19
|
+
implements Transceiver<NumberedSetUpdate, SetRTXJson<P>>, Lineage
|
|
20
20
|
{
|
|
21
21
|
public mode: TransceiverMode = `record`
|
|
22
22
|
public readonly subject: Subject<SetUpdate> = new Subject<SetUpdate>()
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/switch-exhaustiveness-check */
|
|
2
|
-
import type { RuleType } from "@eslint/core"
|
|
3
|
-
import type { Rule } from "eslint"
|
|
4
|
-
import type * as ESTree from "estree"
|
|
5
|
-
|
|
6
|
-
import { walk } from "../walk"
|
|
7
|
-
|
|
8
|
-
export const synchronousSelectorDependencies: {
|
|
9
|
-
meta: {
|
|
10
|
-
type: RuleType
|
|
11
|
-
docs: {
|
|
12
|
-
description: string
|
|
13
|
-
category: string
|
|
14
|
-
recommended: boolean
|
|
15
|
-
url: string
|
|
16
|
-
}
|
|
17
|
-
schema: never[]
|
|
18
|
-
}
|
|
19
|
-
create(context: Rule.RuleContext): Rule.NodeListener
|
|
20
|
-
} = {
|
|
21
|
-
meta: {
|
|
22
|
-
type: `problem`,
|
|
23
|
-
docs: {
|
|
24
|
-
description: `disallow await before calling get on the parameter's get method inside selector`,
|
|
25
|
-
category: `Possible Errors`,
|
|
26
|
-
recommended: false,
|
|
27
|
-
url: ``, // URL to documentation page for this rule
|
|
28
|
-
},
|
|
29
|
-
schema: [], // no options
|
|
30
|
-
},
|
|
31
|
-
create(context) {
|
|
32
|
-
return {
|
|
33
|
-
CallExpression(node) {
|
|
34
|
-
let selectorComputation: ESTree.Node | undefined
|
|
35
|
-
if (`name` in node.callee && node.callee.name === `selectorFamily`) {
|
|
36
|
-
if (node.arguments[0].type === `ObjectExpression`) {
|
|
37
|
-
const selectorLookupProperty = node.arguments[0].properties.find(
|
|
38
|
-
(prop): prop is ESTree.Property => {
|
|
39
|
-
return (
|
|
40
|
-
`key` in prop && `name` in prop.key && prop.key.name === `get`
|
|
41
|
-
)
|
|
42
|
-
},
|
|
43
|
-
)
|
|
44
|
-
const selectorLookup = selectorLookupProperty?.value
|
|
45
|
-
if (
|
|
46
|
-
selectorLookup?.type === `FunctionExpression` ||
|
|
47
|
-
selectorLookup?.type === `ArrowFunctionExpression`
|
|
48
|
-
) {
|
|
49
|
-
if (selectorLookup.body.type === `BlockStatement`) {
|
|
50
|
-
for (const statement of selectorLookup.body.body) {
|
|
51
|
-
if (
|
|
52
|
-
statement.type === `ReturnStatement` &&
|
|
53
|
-
statement.argument
|
|
54
|
-
) {
|
|
55
|
-
selectorComputation = statement.argument
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else if (
|
|
59
|
-
selectorLookup.body.type === `FunctionExpression` ||
|
|
60
|
-
selectorLookup.body.type === `ArrowFunctionExpression`
|
|
61
|
-
) {
|
|
62
|
-
selectorComputation = selectorLookup.body
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (`name` in node.callee && node.callee.name === `selector`) {
|
|
68
|
-
if (node.arguments[0].type === `ObjectExpression`) {
|
|
69
|
-
const selectorComputationProperty =
|
|
70
|
-
node.arguments[0].properties.find(
|
|
71
|
-
(prop): prop is ESTree.Property => {
|
|
72
|
-
return (
|
|
73
|
-
`key` in prop &&
|
|
74
|
-
`name` in prop.key &&
|
|
75
|
-
prop.key.name === `get`
|
|
76
|
-
)
|
|
77
|
-
},
|
|
78
|
-
)
|
|
79
|
-
selectorComputation = selectorComputationProperty?.value
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
selectorComputation?.type === `FunctionExpression` ||
|
|
84
|
-
selectorComputation?.type === `ArrowFunctionExpression`
|
|
85
|
-
) {
|
|
86
|
-
const nonDestructuredTransactorsName =
|
|
87
|
-
selectorComputation.params[0] &&
|
|
88
|
-
`name` in selectorComputation.params[0]
|
|
89
|
-
? selectorComputation.params[0].name
|
|
90
|
-
: undefined
|
|
91
|
-
let awaited: number | undefined
|
|
92
|
-
let awaitNode: ESTree.AwaitExpression | undefined
|
|
93
|
-
walk(selectorComputation, (n, depth) => {
|
|
94
|
-
// console.log(`${`\t`.repeat(depth)}${n.type} ${n.name ?? ``}`)
|
|
95
|
-
if (typeof awaited === `number`) {
|
|
96
|
-
if (awaited > depth) {
|
|
97
|
-
awaited = undefined
|
|
98
|
-
awaitNode = undefined
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
switch (n.type) {
|
|
102
|
-
case `AwaitExpression`:
|
|
103
|
-
awaited = depth
|
|
104
|
-
awaitNode = n
|
|
105
|
-
break
|
|
106
|
-
case `CallExpression`:
|
|
107
|
-
if (awaitNode) {
|
|
108
|
-
let willReport = false
|
|
109
|
-
switch (n.callee.type) {
|
|
110
|
-
case `MemberExpression`:
|
|
111
|
-
if (
|
|
112
|
-
n.callee.object.type === `Identifier` &&
|
|
113
|
-
n.callee.object.name ===
|
|
114
|
-
nonDestructuredTransactorsName &&
|
|
115
|
-
n.callee.property.type === `Identifier` &&
|
|
116
|
-
n.callee.property.name === `get`
|
|
117
|
-
) {
|
|
118
|
-
willReport = true
|
|
119
|
-
}
|
|
120
|
-
break
|
|
121
|
-
case `Identifier`:
|
|
122
|
-
if (n.callee.name === `get`) {
|
|
123
|
-
willReport = true
|
|
124
|
-
}
|
|
125
|
-
break
|
|
126
|
-
}
|
|
127
|
-
if (willReport) {
|
|
128
|
-
context.report({
|
|
129
|
-
node: awaitNode,
|
|
130
|
-
message: `Using await before calling the 'get' transactor is not allowed.`,
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
} satisfies Rule.RuleModule
|
|
@@ -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,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
|
-
}
|