atom.io 0.19.2 → 0.19.4

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.
Files changed (43) hide show
  1. package/data/dist/index.js +1 -1
  2. package/data/package.json +1 -1
  3. package/dist/{chunk-U2IICNHQ.js → chunk-F2X4B4VY.js} +5 -1
  4. package/dist/index.js +1 -1
  5. package/eslint-plugin/dist/index.cjs +233 -0
  6. package/eslint-plugin/dist/index.js +223 -0
  7. package/eslint-plugin/package.json +16 -0
  8. package/eslint-plugin/src/index.ts +12 -0
  9. package/eslint-plugin/src/rules/explicit-state-types.ts +55 -0
  10. package/eslint-plugin/src/rules/index.ts +2 -0
  11. package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +190 -0
  12. package/internal/dist/index.js +1 -1
  13. package/internal/package.json +1 -1
  14. package/introspection/dist/index.js +1 -1
  15. package/introspection/package.json +1 -1
  16. package/json/dist/index.cjs +5 -5
  17. package/json/dist/index.js +6 -6
  18. package/json/package.json +1 -1
  19. package/json/src/select-json-family.ts +5 -5
  20. package/package.json +27 -9
  21. package/react/dist/index.js +1 -1
  22. package/react/package.json +1 -1
  23. package/react-devtools/dist/index.cjs +92 -105
  24. package/react-devtools/dist/index.css +0 -3
  25. package/react-devtools/dist/index.js +70 -83
  26. package/react-devtools/package.json +1 -1
  27. package/react-devtools/src/Updates.tsx +10 -7
  28. package/react-devtools/src/devtools.scss +0 -3
  29. package/realtime/dist/index.js +1 -1
  30. package/realtime/package.json +1 -1
  31. package/realtime/src/shared-room-store.ts +1 -1
  32. package/realtime-client/dist/index.js +1 -1
  33. package/realtime-client/package.json +1 -1
  34. package/realtime-react/dist/index.js +1 -1
  35. package/realtime-react/package.json +1 -1
  36. package/realtime-server/dist/index.d.ts +3 -4
  37. package/realtime-server/dist/index.js +1 -1
  38. package/realtime-server/package.json +1 -1
  39. package/realtime-server/src/realtime-server-stores/server-user-store.ts +3 -2
  40. package/realtime-testing/dist/index.js +1 -1
  41. package/realtime-testing/package.json +1 -1
  42. package/transceivers/set-rtx/dist/index.js +1 -1
  43. package/transceivers/set-rtx/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ import type { Rule } from "eslint"
2
+ import type * as ESTree from "estree"
3
+
4
+ function walk(
5
+ node: ESTree.Node,
6
+ callback: (node: ESTree.Node, depth: number) => void,
7
+ depth = 0,
8
+ ) {
9
+ callback(node, depth)
10
+
11
+ switch (node.type) {
12
+ case `FunctionDeclaration`:
13
+ case `FunctionExpression`:
14
+ case `ArrowFunctionExpression`:
15
+ for (const param of node.params) {
16
+ walk(param, callback, depth + 1)
17
+ }
18
+ walk(node.body, callback, depth + 1)
19
+ break
20
+ case `BlockStatement`:
21
+ for (const statement of node.body) {
22
+ walk(statement, callback, depth + 1)
23
+ }
24
+ break
25
+ case `IfStatement`:
26
+ walk(node.test, callback, depth)
27
+ walk(node.consequent, callback, depth)
28
+ if (node.alternate) {
29
+ walk(node.alternate, callback, depth)
30
+ }
31
+ break
32
+ case `SwitchStatement`:
33
+ walk(node.discriminant, callback, depth + 1)
34
+ for (const caseOrDefault of node.cases) {
35
+ walk(caseOrDefault, callback, depth)
36
+ }
37
+ break
38
+ case `ReturnStatement`:
39
+ if (node.argument) {
40
+ walk(node.argument, callback, depth)
41
+ }
42
+ break
43
+ case `SwitchCase`:
44
+ if (node.test) {
45
+ walk(node.test, callback, depth)
46
+ }
47
+ for (const statement of node.consequent) {
48
+ walk(statement, callback, depth)
49
+ }
50
+ break
51
+ case `VariableDeclaration`:
52
+ for (const declaration of node.declarations) {
53
+ walk(declaration, callback, depth)
54
+ if (declaration.init) {
55
+ walk(declaration.init, callback, depth)
56
+ }
57
+ }
58
+ break
59
+ case `BinaryExpression`:
60
+ walk(node.left, callback, depth)
61
+ walk(node.right, callback, depth)
62
+ break
63
+ case `MemberExpression`:
64
+ walk(node.object, callback, depth)
65
+ walk(node.property, callback, depth)
66
+ break
67
+ }
68
+ }
69
+
70
+ export const synchronousSelectorDependencies = {
71
+ meta: {
72
+ type: `problem`,
73
+ docs: {
74
+ description: `disallow await before calling get on the parameter's get method inside selector`,
75
+ category: `Possible Errors`,
76
+ recommended: false,
77
+ url: ``, // URL to documentation page for this rule
78
+ },
79
+ schema: [], // no options
80
+ },
81
+ create(context) {
82
+ return {
83
+ CallExpression(node) {
84
+ let selectorComputation: ESTree.Node | undefined
85
+ if (`name` in node.callee && node.callee.name === `selectorFamily`) {
86
+ if (node.arguments[0].type === `ObjectExpression`) {
87
+ const selectorLookupProperty = node.arguments[0].properties.find(
88
+ (prop): prop is ESTree.Property => {
89
+ return (
90
+ `key` in prop && `name` in prop.key && prop.key.name === `get`
91
+ )
92
+ },
93
+ )
94
+ const selectorLookup = selectorLookupProperty?.value
95
+ if (
96
+ selectorLookup?.type === `FunctionExpression` ||
97
+ selectorLookup?.type === `ArrowFunctionExpression`
98
+ ) {
99
+ if (selectorLookup.body.type === `BlockStatement`) {
100
+ for (const statement of selectorLookup.body.body) {
101
+ if (
102
+ statement.type === `ReturnStatement` &&
103
+ statement.argument
104
+ ) {
105
+ selectorComputation = statement.argument
106
+ }
107
+ }
108
+ } else if (
109
+ selectorLookup.body.type === `FunctionExpression` ||
110
+ selectorLookup.body.type === `ArrowFunctionExpression`
111
+ ) {
112
+ selectorComputation = selectorLookup.body
113
+ }
114
+ }
115
+ }
116
+ }
117
+ if (`name` in node.callee && node.callee.name === `selector`) {
118
+ if (node.arguments[0].type === `ObjectExpression`) {
119
+ const selectorComputationProperty =
120
+ node.arguments[0].properties.find(
121
+ (prop): prop is ESTree.Property => {
122
+ return (
123
+ `key` in prop &&
124
+ `name` in prop.key &&
125
+ prop.key.name === `get`
126
+ )
127
+ },
128
+ )
129
+ selectorComputation = selectorComputationProperty?.value
130
+ }
131
+ }
132
+ if (
133
+ selectorComputation?.type === `FunctionExpression` ||
134
+ selectorComputation?.type === `ArrowFunctionExpression`
135
+ ) {
136
+ const nonDestructuredTransactorsName =
137
+ selectorComputation.params[0] &&
138
+ `name` in selectorComputation.params[0]
139
+ ? selectorComputation.params[0].name
140
+ : undefined
141
+ let awaited: number | undefined
142
+ let awaitNode: ESTree.AwaitExpression | undefined
143
+ walk(selectorComputation, (n, depth) => {
144
+ // console.log(`${`\t`.repeat(depth)}${n.type} ${n.name ?? ``}`)
145
+ if (typeof awaited === `number`) {
146
+ if (awaited > depth) {
147
+ awaited = undefined
148
+ awaitNode = undefined
149
+ }
150
+ }
151
+ switch (n.type) {
152
+ case `AwaitExpression`:
153
+ awaited = depth
154
+ awaitNode = n
155
+ break
156
+ case `CallExpression`:
157
+ if (awaitNode) {
158
+ let willReport = false
159
+ switch (n.callee.type) {
160
+ case `MemberExpression`:
161
+ if (
162
+ n.callee.object.type === `Identifier` &&
163
+ n.callee.object.name ===
164
+ nonDestructuredTransactorsName &&
165
+ n.callee.property.type === `Identifier` &&
166
+ n.callee.property.name === `get`
167
+ ) {
168
+ willReport = true
169
+ }
170
+ break
171
+ case `Identifier`:
172
+ if (n.callee.name === `get`) {
173
+ willReport = true
174
+ }
175
+ break
176
+ }
177
+ if (willReport) {
178
+ context.report({
179
+ node: awaitNode,
180
+ message: `Using await before calling the 'get' transactor is not allowed.`,
181
+ })
182
+ }
183
+ }
184
+ }
185
+ })
186
+ }
187
+ },
188
+ }
189
+ },
190
+ } satisfies Rule.RuleModule
@@ -1,5 +1,5 @@
1
1
  import { Junction } from '../../dist/chunk-FTONNX2R.js';
2
- import { __spreadValues, __spreadProps } from '../../dist/chunk-U2IICNHQ.js';
2
+ 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
 
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "private": true,
5
5
  "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
@@ -1,4 +1,4 @@
1
- import { __spreadValues, __spreadProps } from '../../dist/chunk-U2IICNHQ.js';
1
+ import { __spreadValues, __spreadProps } from '../../dist/chunk-F2X4B4VY.js';
2
2
  import * as Internal from 'atom.io/internal';
3
3
  import { createRegularAtom, newest, createStandaloneSelector, IMPLICIT, createRegularAtomFamily, Subject, createSelectorFamily } from 'atom.io/internal';
4
4
 
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "private": true,
5
5
  "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
@@ -56,18 +56,18 @@ var selectJson = (atom, transform, store = internal.IMPLICIT.STORE) => {
56
56
  store
57
57
  );
58
58
  };
59
- function selectJsonFamily(atomFamily, transform, store = internal.IMPLICIT.STORE) {
59
+ function selectJsonFamily(family, transform, store = internal.IMPLICIT.STORE) {
60
60
  const jsonFamily = internal.createSelectorFamily(
61
61
  {
62
- key: `${atomFamily.key}:JSON`,
63
- get: (key) => ({ get }) => transform.toJson(get(atomFamily(key))),
62
+ key: `${family.key}:JSON`,
63
+ get: (key) => ({ get }) => transform.toJson(get(family(key))),
64
64
  set: (key) => ({ set }, newValue) => {
65
- set(atomFamily(key), transform.fromJson(newValue));
65
+ set(family(key), transform.fromJson(newValue));
66
66
  }
67
67
  },
68
68
  store
69
69
  );
70
- atomFamily.subject.subscribe(
70
+ family.subject.subscribe(
71
71
  `store=${store.config.name}::json-selector-family`,
72
72
  (token) => {
73
73
  if (token.family) {
@@ -1,6 +1,6 @@
1
1
  import { parseJson } from '../../dist/chunk-BF4MVQF6.js';
2
2
  export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson } from '../../dist/chunk-BF4MVQF6.js';
3
- import '../../dist/chunk-U2IICNHQ.js';
3
+ import '../../dist/chunk-F2X4B4VY.js';
4
4
  import { createStandaloneSelector, IMPLICIT, createSelectorFamily } from 'atom.io/internal';
5
5
 
6
6
  var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
@@ -15,18 +15,18 @@ var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
15
15
  store
16
16
  );
17
17
  };
18
- function selectJsonFamily(atomFamily, transform, store = IMPLICIT.STORE) {
18
+ function selectJsonFamily(family, transform, store = IMPLICIT.STORE) {
19
19
  const jsonFamily = createSelectorFamily(
20
20
  {
21
- key: `${atomFamily.key}:JSON`,
22
- get: (key) => ({ get }) => transform.toJson(get(atomFamily(key))),
21
+ key: `${family.key}:JSON`,
22
+ get: (key) => ({ get }) => transform.toJson(get(family(key))),
23
23
  set: (key) => ({ set }, newValue) => {
24
- set(atomFamily(key), transform.fromJson(newValue));
24
+ set(family(key), transform.fromJson(newValue));
25
25
  }
26
26
  },
27
27
  store
28
28
  );
29
- atomFamily.subject.subscribe(
29
+ family.subject.subscribe(
30
30
  `store=${store.config.name}::json-selector-family`,
31
31
  (token) => {
32
32
  if (token.family) {
package/json/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "private": true,
5
5
  "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
@@ -28,7 +28,7 @@ export function selectJsonFamily<
28
28
  J extends Json.Serializable,
29
29
  K extends Json.Serializable,
30
30
  >(
31
- atomFamily:
31
+ family:
32
32
  | AtomIO.MutableAtomFamily<T extends Transceiver<any> ? T : never, J, K>
33
33
  | AtomIO.RegularAtomFamily<T, K>,
34
34
  transform: JsonInterface<T, J>,
@@ -36,20 +36,20 @@ export function selectJsonFamily<
36
36
  ): AtomIO.WritableSelectorFamily<J, K> {
37
37
  const jsonFamily = createSelectorFamily<J, K>(
38
38
  {
39
- key: `${atomFamily.key}:JSON`,
39
+ key: `${family.key}:JSON`,
40
40
  get:
41
41
  (key) =>
42
42
  ({ get }) =>
43
- transform.toJson(get(atomFamily(key))),
43
+ transform.toJson(get(family(key))),
44
44
  set:
45
45
  (key) =>
46
46
  ({ set }, newValue) => {
47
- set(atomFamily(key), transform.fromJson(newValue))
47
+ set(family(key), transform.fromJson(newValue))
48
48
  },
49
49
  },
50
50
  store,
51
51
  )
52
- atomFamily.subject.subscribe(
52
+ family.subject.subscribe(
53
53
  `store=${store.config.name}::json-selector-family`,
54
54
  (token) => {
55
55
  if (token.family) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -48,17 +48,24 @@
48
48
  }
49
49
  },
50
50
  "devDependencies": {
51
- "@testing-library/react": "15.0.0",
51
+ "@testing-library/react": "15.0.2",
52
+ "@types/eslint": "npm:@types/eslint@8.56.9",
53
+ "@types/eslint-9": "npm:@types/eslint@8.56.9",
54
+ "@types/estree": "1.0.5",
52
55
  "@types/http-proxy": "1.17.14",
53
56
  "@types/npmlog": "7.0.0",
54
- "@types/react": "18.2.75",
57
+ "@types/react": "18.2.79",
55
58
  "@types/tmp": "0.2.6",
56
- "@vitest/coverage-v8": "1.4.0",
57
- "@vitest/ui": "1.4.0",
59
+ "@typescript-eslint/parser": "7.7.0",
60
+ "@typescript-eslint/rule-tester": "7.7.0",
61
+ "@vitest/coverage-v8": "1.5.0",
62
+ "@vitest/ui": "1.5.0",
58
63
  "concurrently": "8.2.2",
59
64
  "drizzle-kit": "0.20.14",
60
- "drizzle-orm": "0.30.7",
61
- "framer-motion": "11.0.27",
65
+ "drizzle-orm": "0.30.8",
66
+ "eslint": "npm:eslint@8.57.0",
67
+ "eslint-v9": "npm:eslint@9.0.0",
68
+ "framer-motion": "11.1.1",
62
69
  "happy-dom": "14.7.1",
63
70
  "http-proxy": "1.18.1",
64
71
  "npmlog": "7.0.1",
@@ -72,9 +79,9 @@
72
79
  "tmp": "0.2.3",
73
80
  "tsup": "8.0.2",
74
81
  "typescript": "5.4.5",
75
- "vite": "5.2.8",
82
+ "vite": "5.2.9",
76
83
  "vite-tsconfig-paths": "4.3.2",
77
- "vitest": "1.4.0"
84
+ "vitest": "1.5.0"
78
85
  },
79
86
  "main": "dist/index.js",
80
87
  "types": "dist/index.d.ts",
@@ -85,6 +92,9 @@
85
92
  "data/dist",
86
93
  "data/package.json",
87
94
  "data/src",
95
+ "eslint-plugin/dist",
96
+ "eslint-plugin/package.json",
97
+ "eslint-plugin/src",
88
98
  "internal/dist",
89
99
  "internal/package.json",
90
100
  "internal/src",
@@ -134,6 +144,13 @@
134
144
  "import": "./data/dist/index.js",
135
145
  "require": "./data/dist/index.cjs"
136
146
  },
147
+ "./eslint-plugin/package.json": "./eslint-plugin/package.json",
148
+ "./eslint-plugin": {
149
+ "types": "./eslint-plugin/dist/index.d.ts",
150
+ "browser": "./eslint-plugin/dist/index.js",
151
+ "import": "./eslint-plugin/dist/index.js",
152
+ "require": "./eslint-plugin/dist/index.cjs"
153
+ },
137
154
  "./internal/package.json": "./internal/package.json",
138
155
  "./internal": {
139
156
  "types": "./internal/dist/index.d.ts",
@@ -232,6 +249,7 @@
232
249
  "build:transceivers:set-rtx": "cd transceivers/set-rtx && tsup",
233
250
  "lint:biome": "biome check -- .",
234
251
  "lint:eslint": "eslint .",
252
+ "lint:eslint:build": "bun run build:main",
235
253
  "lint:types": "tsc --noEmit",
236
254
  "lint": "bun run lint:biome && bun run lint:eslint && bun run lint:types",
237
255
  "test": "vitest",
@@ -1,4 +1,4 @@
1
- import '../../dist/chunk-U2IICNHQ.js';
1
+ import '../../dist/chunk-F2X4B4VY.js';
2
2
  import { IMPLICIT, findInStore, setIntoStore, subscribeToState, getFromStore, getJsonToken, withdraw, subscribeToTimeline } from 'atom.io/internal';
3
3
  import * as React5 from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "private": true,
5
5
  "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {