atom.io 0.19.3 → 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.
@@ -2,6 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var utils = require('@typescript-eslint/utils');
6
+
5
7
  var __defProp = Object.defineProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -11,8 +13,58 @@ var __export = (target, all) => {
11
13
  // eslint-plugin/src/rules/index.ts
12
14
  var rules_exports = {};
13
15
  __export(rules_exports, {
16
+ explicitStateTypes: () => explicitStateTypes,
14
17
  synchronousSelectorDependencies: () => synchronousSelectorDependencies
15
18
  });
19
+ var createRule = utils.ESLintUtils.RuleCreator(
20
+ (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
21
+ );
22
+ var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
23
+ var explicitStateTypes = createRule({
24
+ name: `explicit-state-types`,
25
+ meta: {
26
+ type: `problem`,
27
+ docs: {
28
+ description: `State declarations must have generic type arguments directly passed to them`
29
+ },
30
+ messages: {
31
+ noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
32
+ },
33
+ schema: []
34
+ // no options
35
+ },
36
+ defaultOptions: [],
37
+ create(context) {
38
+ return {
39
+ CallExpression(node) {
40
+ const { callee } = node;
41
+ switch (callee.type) {
42
+ case `Identifier`: {
43
+ if (STATE_FUNCTIONS.includes(callee.name)) {
44
+ if (!node.typeArguments) {
45
+ context.report({
46
+ node,
47
+ messageId: `noTypeArgument`
48
+ });
49
+ }
50
+ }
51
+ break;
52
+ }
53
+ case `MemberExpression`: {
54
+ if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
55
+ if (!node.typeArguments) {
56
+ context.report({
57
+ node,
58
+ messageId: `noTypeArgument`
59
+ });
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ };
66
+ }
67
+ });
16
68
 
17
69
  // eslint-plugin/src/rules/synchronous-selector-dependencies.ts
18
70
  function walk(node, callback, depth = 0) {
@@ -172,6 +224,7 @@ var synchronousSelectorDependencies = {
172
224
  // eslint-plugin/src/index.ts
173
225
  var src_default = {
174
226
  rules: {
227
+ "explicit-state-types": explicitStateTypes,
175
228
  "synchronous-selector-dependencies": synchronousSelectorDependencies
176
229
  }
177
230
  };
@@ -1,10 +1,61 @@
1
1
  import { __export } from '../../dist/chunk-F2X4B4VY.js';
2
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
3
 
3
4
  // eslint-plugin/src/rules/index.ts
4
5
  var rules_exports = {};
5
6
  __export(rules_exports, {
7
+ explicitStateTypes: () => explicitStateTypes,
6
8
  synchronousSelectorDependencies: () => synchronousSelectorDependencies
7
9
  });
10
+ var createRule = ESLintUtils.RuleCreator(
11
+ (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
12
+ );
13
+ var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
14
+ var explicitStateTypes = createRule({
15
+ name: `explicit-state-types`,
16
+ meta: {
17
+ type: `problem`,
18
+ docs: {
19
+ description: `State declarations must have generic type arguments directly passed to them`
20
+ },
21
+ messages: {
22
+ noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
23
+ },
24
+ schema: []
25
+ // no options
26
+ },
27
+ defaultOptions: [],
28
+ create(context) {
29
+ return {
30
+ CallExpression(node) {
31
+ const { callee } = node;
32
+ switch (callee.type) {
33
+ case `Identifier`: {
34
+ if (STATE_FUNCTIONS.includes(callee.name)) {
35
+ if (!node.typeArguments) {
36
+ context.report({
37
+ node,
38
+ messageId: `noTypeArgument`
39
+ });
40
+ }
41
+ }
42
+ break;
43
+ }
44
+ case `MemberExpression`: {
45
+ if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
46
+ if (!node.typeArguments) {
47
+ context.report({
48
+ node,
49
+ messageId: `noTypeArgument`
50
+ });
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ };
57
+ }
58
+ });
8
59
 
9
60
  // eslint-plugin/src/rules/synchronous-selector-dependencies.ts
10
61
  function walk(node, callback, depth = 0) {
@@ -164,6 +215,7 @@ var synchronousSelectorDependencies = {
164
215
  // eslint-plugin/src/index.ts
165
216
  var src_default = {
166
217
  rules: {
218
+ "explicit-state-types": explicitStateTypes,
167
219
  "synchronous-selector-dependencies": synchronousSelectorDependencies
168
220
  }
169
221
  };
@@ -6,6 +6,7 @@ export { Rules }
6
6
 
7
7
  export default {
8
8
  rules: {
9
+ "explicit-state-types": Rules.explicitStateTypes as any,
9
10
  "synchronous-selector-dependencies": Rules.synchronousSelectorDependencies,
10
11
  },
11
12
  } satisfies ESLint.Plugin
@@ -0,0 +1,55 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils"
2
+
3
+ const createRule = ESLintUtils.RuleCreator(
4
+ (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,
5
+ )
6
+
7
+ const STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`]
8
+
9
+ export const explicitStateTypes = createRule({
10
+ name: `explicit-state-types`,
11
+ meta: {
12
+ type: `problem`,
13
+ docs: {
14
+ description: `State declarations must have generic type arguments directly passed to them`,
15
+ },
16
+ messages: {
17
+ noTypeArgument: `State declarations must have generic type arguments directly passed to them.`,
18
+ },
19
+ schema: [], // no options
20
+ },
21
+ defaultOptions: [],
22
+ create(context) {
23
+ return {
24
+ CallExpression(node) {
25
+ const { callee } = node
26
+ switch (callee.type) {
27
+ case `Identifier`: {
28
+ if (STATE_FUNCTIONS.includes(callee.name)) {
29
+ if (!node.typeArguments) {
30
+ context.report({
31
+ node,
32
+ messageId: `noTypeArgument`,
33
+ })
34
+ }
35
+ }
36
+ break
37
+ }
38
+ case `MemberExpression`: {
39
+ if (
40
+ callee.property.type === `Identifier` &&
41
+ STATE_FUNCTIONS.includes(callee.property.name)
42
+ ) {
43
+ if (!node.typeArguments) {
44
+ context.report({
45
+ node,
46
+ messageId: `noTypeArgument`,
47
+ })
48
+ }
49
+ }
50
+ }
51
+ }
52
+ },
53
+ }
54
+ },
55
+ })
@@ -1 +1,2 @@
1
+ export * from "./explicit-state-types"
1
2
  export * from "./synchronous-selector-dependencies"
@@ -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) {
@@ -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) {
@@ -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.3",
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,
@@ -49,20 +49,23 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@testing-library/react": "15.0.2",
52
- "@types/eslint": "8.56.9",
52
+ "@types/eslint": "npm:@types/eslint@8.56.9",
53
+ "@types/eslint-9": "npm:@types/eslint@8.56.9",
53
54
  "@types/estree": "1.0.5",
54
55
  "@types/http-proxy": "1.17.14",
55
56
  "@types/npmlog": "7.0.0",
56
- "@types/react": "18.2.78",
57
+ "@types/react": "18.2.79",
57
58
  "@types/tmp": "0.2.6",
58
59
  "@typescript-eslint/parser": "7.7.0",
60
+ "@typescript-eslint/rule-tester": "7.7.0",
59
61
  "@vitest/coverage-v8": "1.5.0",
60
62
  "@vitest/ui": "1.5.0",
61
63
  "concurrently": "8.2.2",
62
64
  "drizzle-kit": "0.20.14",
63
65
  "drizzle-orm": "0.30.8",
64
- "eslint": "9.0.0",
65
- "framer-motion": "11.0.28",
66
+ "eslint": "npm:eslint@8.57.0",
67
+ "eslint-v9": "npm:eslint@9.0.0",
68
+ "framer-motion": "11.1.1",
66
69
  "happy-dom": "14.7.1",
67
70
  "http-proxy": "1.18.1",
68
71
  "npmlog": "7.0.1",
@@ -76,7 +79,7 @@
76
79
  "tmp": "0.2.3",
77
80
  "tsup": "8.0.2",
78
81
  "typescript": "5.4.5",
79
- "vite": "5.2.8",
82
+ "vite": "5.2.9",
80
83
  "vite-tsconfig-paths": "4.3.2",
81
84
  "vitest": "1.5.0"
82
85
  },
@@ -245,7 +248,7 @@
245
248
  "build:realtime-testing": "cd realtime-testing && tsup",
246
249
  "build:transceivers:set-rtx": "cd transceivers/set-rtx && tsup",
247
250
  "lint:biome": "biome check -- .",
248
- "lint:eslint": "eslint . --ignore-pattern={**/dist/**,**/coverage/**}",
251
+ "lint:eslint": "eslint .",
249
252
  "lint:eslint:build": "bun run build:main",
250
253
  "lint:types": "tsc --noEmit",
251
254
  "lint": "bun run lint:biome && bun run lint:eslint && bun run lint:types",
@@ -131,9 +131,6 @@ main.atom_io_devtools {
131
131
  }
132
132
  section.transaction_log {
133
133
  margin-top: 0;
134
- header: {
135
- padding: 5px;
136
- }
137
134
  main {
138
135
  display: flex;
139
136
  flex-flow: row wrap;
@@ -130,9 +130,6 @@ main.atom_io_devtools {
130
130
  }
131
131
  section.transaction_log {
132
132
  margin-top: 0;
133
- header: {
134
- padding: 5px;
135
- }
136
133
  main {
137
134
  display: flex;
138
135
  flex-flow: row wrap;
@@ -12,7 +12,7 @@ export const usersInThisRoomIndex = atom<SetRTX<string>, SetRTXJson<string>>({
12
12
  fromJson: (json) => SetRTX.fromJSON(json),
13
13
  })
14
14
 
15
- export const roomIndex = atom({
15
+ export const roomIndex = atom<SetRTX<string>, SetRTXJson<string>>({
16
16
  key: `roomIndex`,
17
17
  default: () => new SetRTX<string>(),
18
18
  mutable: true,
@@ -6,8 +6,7 @@ import * as AtomIO from 'atom.io';
6
6
  import { TransactionUpdateContent, TransactionUpdate, WritableToken } from 'atom.io';
7
7
  import * as atom_io_data from 'atom.io/data';
8
8
  import { Loadable } from 'atom.io/data';
9
- import * as atom_io_transceivers_set_rtx from 'atom.io/transceivers/set-rtx';
10
- import { SetRTX } from 'atom.io/transceivers/set-rtx';
9
+ import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
11
10
 
12
11
  type Events = Json.Object<string, Json.Serializable[]>;
13
12
  type StringifiedEvent<Key extends string, Params extends Json.Serializable[]> = Stringified<[Key, ...Params]>;
@@ -104,8 +103,8 @@ declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyTokenWithCall<{
104
103
  declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyTokenWithCall<Pick<TransactionUpdate<any>, "key" | "epoch" | "id" | "updates" | "output">[], string>;
105
104
 
106
105
  declare const socketAtoms: AtomIO.RegularAtomFamilyTokenWithCall<Socket | null, string>;
107
- declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>>;
108
- declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>>;
106
+ declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
107
+ declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
109
108
  declare const usersOfSockets: atom_io_data.JoinToken<"user", "socket", "1:1", null>;
110
109
 
111
110
  type StateProvider = ReturnType<typeof realtimeStateProvider>;
@@ -1,5 +1,6 @@
1
1
  import { atom, atomFamily } from "atom.io"
2
2
  import { join } from "atom.io/data"
3
+ import type { SetRTXJson } from "atom.io/transceivers/set-rtx"
3
4
  import { SetRTX } from "atom.io/transceivers/set-rtx"
4
5
 
5
6
  import type { Socket } from ".."
@@ -9,14 +10,14 @@ export const socketAtoms = atomFamily<Socket | null, string>({
9
10
  default: null,
10
11
  })
11
12
 
12
- export const socketIndex = atom({
13
+ export const socketIndex = atom<SetRTX<string>, SetRTXJson<string>>({
13
14
  key: `socketsIndex`,
14
15
  mutable: true,
15
16
  default: () => new SetRTX<string>(),
16
17
  toJson: (set) => set.toJSON(),
17
18
  fromJson: (json) => SetRTX.fromJSON(json),
18
19
  })
19
- export const userIndex = atom({
20
+ export const userIndex = atom<SetRTX<string>, SetRTXJson<string>>({
20
21
  key: `usersIndex`,
21
22
  mutable: true,
22
23
  default: () => new SetRTX<string>(),