atom.io 0.6.2 → 0.6.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 (117) hide show
  1. package/dist/index.d.mts +27 -15
  2. package/dist/index.d.ts +27 -15
  3. package/dist/index.js +44 -24
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +44 -24
  6. package/dist/index.mjs.map +1 -1
  7. package/json/dist/index.d.mts +18 -0
  8. package/json/dist/index.d.ts +18 -0
  9. package/json/dist/index.js +51 -0
  10. package/json/dist/index.js.map +1 -0
  11. package/json/dist/index.mjs +15 -0
  12. package/json/dist/index.mjs.map +1 -0
  13. package/json/package.json +13 -13
  14. package/package.json +31 -12
  15. package/react/dist/index.d.mts +24 -0
  16. package/react/dist/index.d.ts +24 -0
  17. package/react/dist/index.js +87 -0
  18. package/react/dist/index.js.map +1 -0
  19. package/react/dist/index.mjs +45 -0
  20. package/react/dist/index.mjs.map +1 -0
  21. package/react/package.json +13 -13
  22. package/react-devtools/dist/index.css +26 -0
  23. package/react-devtools/dist/index.css.map +1 -0
  24. package/react-devtools/dist/index.d.mts +15 -0
  25. package/react-devtools/dist/index.d.ts +15 -0
  26. package/react-devtools/dist/index.js +2108 -0
  27. package/react-devtools/dist/index.js.map +1 -0
  28. package/react-devtools/dist/index.mjs +2080 -0
  29. package/react-devtools/dist/index.mjs.map +1 -0
  30. package/react-devtools/package.json +13 -13
  31. package/realtime/dist/index.d.mts +27 -0
  32. package/realtime/dist/index.d.ts +27 -0
  33. package/realtime/dist/index.js +191 -0
  34. package/realtime/dist/index.js.map +1 -0
  35. package/realtime/dist/index.mjs +152 -0
  36. package/realtime/dist/index.mjs.map +1 -0
  37. package/realtime/package.json +13 -13
  38. package/realtime-react/dist/index.d.mts +45 -0
  39. package/realtime-react/dist/index.d.ts +45 -0
  40. package/realtime-react/dist/index.js +217 -0
  41. package/realtime-react/dist/index.js.map +1 -0
  42. package/realtime-react/dist/index.mjs +172 -0
  43. package/realtime-react/dist/index.mjs.map +1 -0
  44. package/realtime-react/package.json +13 -13
  45. package/realtime-testing/dist/index.d.mts +49 -0
  46. package/realtime-testing/dist/index.d.ts +49 -0
  47. package/realtime-testing/dist/index.js +165 -0
  48. package/realtime-testing/dist/index.js.map +1 -0
  49. package/realtime-testing/dist/index.mjs +129 -0
  50. package/realtime-testing/dist/index.mjs.map +1 -0
  51. package/realtime-testing/package.json +15 -0
  52. package/src/atom.ts +16 -17
  53. package/src/index.ts +59 -59
  54. package/src/internal/atom-internal.ts +37 -37
  55. package/src/internal/families-internal.ts +115 -116
  56. package/src/internal/get.ts +83 -83
  57. package/src/internal/index.ts +1 -0
  58. package/src/internal/is-default.ts +17 -17
  59. package/src/internal/meta/attach-meta.ts +7 -7
  60. package/src/internal/meta/meta-state.ts +115 -115
  61. package/src/internal/operation.ts +93 -93
  62. package/src/internal/selector/create-read-write-selector.ts +47 -47
  63. package/src/internal/selector/create-readonly-selector.ts +38 -38
  64. package/src/internal/selector/lookup-selector-sources.ts +9 -9
  65. package/src/internal/selector/register-selector.ts +44 -44
  66. package/src/internal/selector/trace-selector-atoms.ts +30 -30
  67. package/src/internal/selector/update-selector-atoms.ts +25 -25
  68. package/src/internal/selector-internal.ts +38 -39
  69. package/src/internal/set.ts +78 -78
  70. package/src/internal/store.ts +119 -119
  71. package/src/internal/subject.ts +24 -0
  72. package/src/internal/subscribe-internal.ts +62 -62
  73. package/src/internal/time-travel-internal.ts +76 -76
  74. package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
  75. package/src/internal/timeline-internal.ts +81 -82
  76. package/src/internal/transaction/abort-transaction.ts +8 -8
  77. package/src/internal/transaction/apply-transaction.ts +41 -41
  78. package/src/internal/transaction/build-transaction.ts +28 -28
  79. package/src/internal/transaction/index.ts +7 -7
  80. package/src/internal/transaction/redo-transaction.ts +13 -13
  81. package/src/internal/transaction/undo-transaction.ts +13 -13
  82. package/src/internal/transaction-internal.ts +49 -49
  83. package/src/json/select-json.ts +12 -12
  84. package/src/logger.ts +30 -30
  85. package/src/react/store-context.tsx +5 -6
  86. package/src/react/store-hooks.ts +19 -20
  87. package/src/react-devtools/AtomIODevtools.tsx +85 -85
  88. package/src/react-devtools/StateEditor.tsx +54 -55
  89. package/src/react-devtools/TokenList.tsx +49 -45
  90. package/src/react-explorer/AtomIOExplorer.tsx +198 -187
  91. package/src/react-explorer/explorer-effects.ts +11 -11
  92. package/src/react-explorer/explorer-states.ts +186 -193
  93. package/src/react-explorer/index.ts +11 -11
  94. package/src/react-explorer/space-states.ts +48 -50
  95. package/src/react-explorer/view-states.ts +25 -25
  96. package/src/realtime/hook-composition/expose-family.ts +81 -81
  97. package/src/realtime/hook-composition/expose-single.ts +26 -26
  98. package/src/realtime/hook-composition/expose-timeline.ts +60 -0
  99. package/src/realtime/hook-composition/index.ts +2 -2
  100. package/src/realtime/hook-composition/receive-state.ts +18 -18
  101. package/src/realtime/hook-composition/receive-transaction.ts +8 -8
  102. package/src/realtime-react/realtime-context.tsx +18 -19
  103. package/src/realtime-react/realtime-hooks.ts +17 -17
  104. package/src/realtime-react/realtime-state.ts +4 -4
  105. package/src/realtime-react/use-pull-family-member.ts +16 -17
  106. package/src/realtime-react/use-pull-family.ts +14 -15
  107. package/src/realtime-react/use-pull.ts +13 -14
  108. package/src/realtime-react/use-push.ts +16 -17
  109. package/src/realtime-react/use-server-action.ts +22 -23
  110. package/src/realtime-testing/index.ts +1 -0
  111. package/src/realtime-testing/setup-realtime-test.tsx +159 -0
  112. package/src/selector.ts +26 -27
  113. package/src/silo.ts +38 -38
  114. package/src/subscribe.ts +68 -68
  115. package/src/timeline.ts +13 -13
  116. package/src/transaction.ts +28 -28
  117. package/src/web-effects/storage.ts +17 -17
@@ -0,0 +1,18 @@
1
+ import * as AtomIO from 'atom.io';
2
+
3
+ type JsonInterface<T, J extends Json = Json> = {
4
+ toJson: (t: T) => J;
5
+ fromJson: (json: J) => T;
6
+ };
7
+
8
+ type Primitive = boolean | number | string | null;
9
+ type Serializable = Primitive | Readonly<{
10
+ [key: string]: Serializable;
11
+ }> | ReadonlyArray<Serializable>;
12
+ type JsonObj<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
13
+ type JsonArr<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
14
+ type Json = JsonArr | JsonObj | Primitive;
15
+
16
+ declare const selectJson: <T, J extends Json>(atom: AtomIO.AtomToken<T>, transform: JsonInterface<T, J>, store?: AtomIO.Store) => AtomIO.SelectorToken<J>;
17
+
18
+ export { selectJson };
@@ -0,0 +1,18 @@
1
+ import * as AtomIO from 'atom.io';
2
+
3
+ type JsonInterface<T, J extends Json = Json> = {
4
+ toJson: (t: T) => J;
5
+ fromJson: (json: J) => T;
6
+ };
7
+
8
+ type Primitive = boolean | number | string | null;
9
+ type Serializable = Primitive | Readonly<{
10
+ [key: string]: Serializable;
11
+ }> | ReadonlyArray<Serializable>;
12
+ type JsonObj<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
13
+ type JsonArr<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
14
+ type Json = JsonArr | JsonObj | Primitive;
15
+
16
+ declare const selectJson: <T, J extends Json>(atom: AtomIO.AtomToken<T>, transform: JsonInterface<T, J>, store?: AtomIO.Store) => AtomIO.SelectorToken<J>;
17
+
18
+ export { selectJson };
@@ -0,0 +1,51 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // ../src/json/index.ts
30
+ var json_exports = {};
31
+ __export(json_exports, {
32
+ selectJson: () => selectJson
33
+ });
34
+ module.exports = __toCommonJS(json_exports);
35
+
36
+ // ../src/json/select-json.ts
37
+ var AtomIO = __toESM(require("atom.io"));
38
+ var selectJson = (atom, transform, store = AtomIO.__INTERNAL__.IMPLICIT.STORE) => AtomIO.__INTERNAL__.selector__INTERNAL(
39
+ {
40
+ key: `${atom.key}JSON`,
41
+ get: ({ get }) => transform.toJson(get(atom)),
42
+ set: ({ set }, newValue) => set(atom, transform.fromJson(newValue))
43
+ },
44
+ void 0,
45
+ store
46
+ );
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ selectJson
50
+ });
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/json/index.ts","../../src/json/select-json.ts"],"sourcesContent":["export * from \"./select-json\"\n","import * as AtomIO from \"atom.io\"\n\nimport type { Json, JsonInterface } from \"~/packages/anvl/src/json\"\n\nexport const selectJson = <T, J extends Json>(\n\tatom: AtomIO.AtomToken<T>,\n\ttransform: JsonInterface<T, J>,\n\tstore: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE,\n): AtomIO.SelectorToken<J> =>\n\tAtomIO.__INTERNAL__.selector__INTERNAL(\n\t\t{\n\t\t\tkey: `${atom.key}JSON`,\n\t\t\tget: ({ get }) => transform.toJson(get(atom)),\n\t\t\tset: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,aAAwB;AAIjB,IAAM,aAAa,CACzB,MACA,WACA,QAA6B,oBAAa,SAAS,UAE5C,oBAAa;AAAA,EACnB;AAAA,IACC,KAAK,GAAG,KAAK,GAAG;AAAA,IAChB,KAAK,CAAC,EAAE,IAAI,MAAM,UAAU,OAAO,IAAI,IAAI,CAAC;AAAA,IAC5C,KAAK,CAAC,EAAE,IAAI,GAAG,aAAa,IAAI,MAAM,UAAU,SAAS,QAAQ,CAAC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AACD;","names":[]}
@@ -0,0 +1,15 @@
1
+ // ../src/json/select-json.ts
2
+ import * as AtomIO from "atom.io";
3
+ var selectJson = (atom, transform, store = AtomIO.__INTERNAL__.IMPLICIT.STORE) => AtomIO.__INTERNAL__.selector__INTERNAL(
4
+ {
5
+ key: `${atom.key}JSON`,
6
+ get: ({ get }) => transform.toJson(get(atom)),
7
+ set: ({ set }, newValue) => set(atom, transform.fromJson(newValue))
8
+ },
9
+ void 0,
10
+ store
11
+ );
12
+ export {
13
+ selectJson
14
+ };
15
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/json/select-json.ts"],"sourcesContent":["import * as AtomIO from \"atom.io\"\n\nimport type { Json, JsonInterface } from \"~/packages/anvl/src/json\"\n\nexport const selectJson = <T, J extends Json>(\n\tatom: AtomIO.AtomToken<T>,\n\ttransform: JsonInterface<T, J>,\n\tstore: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE,\n): AtomIO.SelectorToken<J> =>\n\tAtomIO.__INTERNAL__.selector__INTERNAL(\n\t\t{\n\t\t\tkey: `${atom.key}JSON`,\n\t\t\tget: ({ get }) => transform.toJson(get(atom)),\n\t\t\tset: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n"],"mappings":";AAAA,YAAY,YAAY;AAIjB,IAAM,aAAa,CACzB,MACA,WACA,QAA6B,oBAAa,SAAS,UAE5C,oBAAa;AAAA,EACnB;AAAA,IACC,KAAK,GAAG,KAAK,GAAG;AAAA,IAChB,KAAK,CAAC,EAAE,IAAI,MAAM,UAAU,OAAO,IAAI,IAAI,CAAC;AAAA,IAC5C,KAAK,CAAC,EAAE,IAAI,GAAG,aAAa,IAAI,MAAM,UAAU,SAAS,QAAQ,CAAC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AACD;","names":[]}
package/json/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
- "name": "atom.io-json",
3
- "private": true,
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "module": "dist/index.mjs",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "browser": "./dist/index.mjs",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- }
2
+ "name": "atom.io-json",
3
+ "private": true,
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "browser": "./dist/index.mjs",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ }
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Reactive state graph for React, Preact, and vanilla",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,8 @@
17
17
  "realtime/package.json",
18
18
  "realtime-react/dist",
19
19
  "realtime-react/package.json",
20
+ "realtime-testing/dist",
21
+ "realtime-testing/package.json",
20
22
  "src"
21
23
  ],
22
24
  "exports": {
@@ -61,14 +63,15 @@
61
63
  "browser": "./realtime-react/dist/index.mjs",
62
64
  "import": "./realtime-react/dist/index.mjs",
63
65
  "require": "./realtime-react/dist/index.js"
66
+ },
67
+ "./realtime-testing/package.json": "./realtime-testing/package.json",
68
+ "./realtime-testing": {
69
+ "types": "./realtime-testing/dist/index.d.ts",
70
+ "browser": "./realtime-testing/dist/index.mjs",
71
+ "import": "./realtime-testing/dist/index.mjs",
72
+ "require": "./realtime-testing/dist/index.js"
64
73
  }
65
74
  },
66
- "scripts": {
67
- "build": "tsup & (cd json && tsup) & (cd react && tsup) & (cd react-devtools && tsup) & (cd realtime && tsup) & (cd realtime-react && tsup)",
68
- "lint": "eslint ./**/*.ts{,x}",
69
- "test": "vitest",
70
- "test:once": "vitest run"
71
- },
72
75
  "peerDependencies": {
73
76
  "preact": ">=10.0.0",
74
77
  "react": ">=16.8.0",
@@ -91,18 +94,26 @@
91
94
  },
92
95
  "dependencies": {
93
96
  "fp-ts": "2.16.0",
94
- "hamt_plus": "1.0.2",
95
- "rxjs": "7.8.1"
97
+ "hamt_plus": "1.0.2"
96
98
  },
97
99
  "devDependencies": {
100
+ "@emotion/react": "11.11.1",
98
101
  "@testing-library/react": "14.0.0",
99
102
  "@types/mock-fs": "4.13.1",
100
- "eslint": "8.44.0",
101
- "mock-fs": "5.2.0",
103
+ "@types/react": "18.2.15",
104
+ "@types/tmp": "0.2.3",
105
+ "eslint": "8.45.0",
106
+ "framer-motion": "10.12.22",
107
+ "happy-dom": "10.5.1",
102
108
  "react": "18.2.0",
103
109
  "react-dom": "18.2.0",
104
110
  "react-router-dom": "6.14.1",
111
+ "socket.io": "4.7.1",
112
+ "socket.io-client": "4.7.1",
113
+ "tmp": "0.2.1",
105
114
  "tsup": "7.1.0",
115
+ "typescript": "5.1.6",
116
+ "vite": "4.4.4",
106
117
  "vite-tsconfig-paths": "4.2.0",
107
118
  "vitest": "0.33.0"
108
119
  },
@@ -115,5 +126,13 @@
115
126
  "author": "Jeremy Banka",
116
127
  "publishConfig": {
117
128
  "access": "public"
129
+ },
130
+ "scripts": {
131
+ "build": "tsup & (cd json && tsup) & (cd react && tsup) & (cd react-devtools && tsup) & (cd realtime && tsup) & (cd realtime-react && tsup) & (cd realtime-testing && tsup)",
132
+ "lint:rome": "rome check .",
133
+ "lint:eslint": "eslint .",
134
+ "lint": "npm run lint:rome && npm run lint:eslint",
135
+ "test": "vitest",
136
+ "test:once": "vitest run"
118
137
  }
119
- }
138
+ }
@@ -0,0 +1,24 @@
1
+ import * as AtomIO from 'atom.io';
2
+ import * as React from 'react';
3
+
4
+ declare const StoreContext: React.Context<AtomIO.__INTERNAL__.Store>;
5
+ declare const StoreProvider: React.FC<{
6
+ children: React.ReactNode;
7
+ store?: AtomIO.Store;
8
+ }>;
9
+
10
+ type Modifier<T> = (thing: T) => T;
11
+
12
+ type StoreHooks = {
13
+ useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void;
14
+ useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T;
15
+ useIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void];
16
+ };
17
+ declare const storeHooks: StoreHooks;
18
+ declare function useI<T>(token: AtomIO.StateToken<T>): (next: Modifier<T> | T) => void;
19
+ declare function useO<T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>): T;
20
+ declare function useIO<T>(token: AtomIO.StateToken<T>): [T, (next: Modifier<T> | T) => void];
21
+ declare function useStore<T>(token: AtomIO.StateToken<T>): [T, (next: Modifier<T> | T) => void];
22
+ declare function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T;
23
+
24
+ export { StoreContext, StoreHooks, StoreProvider, storeHooks, useI, useIO, useO, useStore };
@@ -0,0 +1,24 @@
1
+ import * as AtomIO from 'atom.io';
2
+ import * as React from 'react';
3
+
4
+ declare const StoreContext: React.Context<AtomIO.__INTERNAL__.Store>;
5
+ declare const StoreProvider: React.FC<{
6
+ children: React.ReactNode;
7
+ store?: AtomIO.Store;
8
+ }>;
9
+
10
+ type Modifier<T> = (thing: T) => T;
11
+
12
+ type StoreHooks = {
13
+ useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void;
14
+ useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T;
15
+ useIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void];
16
+ };
17
+ declare const storeHooks: StoreHooks;
18
+ declare function useI<T>(token: AtomIO.StateToken<T>): (next: Modifier<T> | T) => void;
19
+ declare function useO<T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>): T;
20
+ declare function useIO<T>(token: AtomIO.StateToken<T>): [T, (next: Modifier<T> | T) => void];
21
+ declare function useStore<T>(token: AtomIO.StateToken<T>): [T, (next: Modifier<T> | T) => void];
22
+ declare function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T;
23
+
24
+ export { StoreContext, StoreHooks, StoreProvider, storeHooks, useI, useIO, useO, useStore };
@@ -0,0 +1,87 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // ../src/react/index.ts
30
+ var react_exports = {};
31
+ __export(react_exports, {
32
+ StoreContext: () => StoreContext,
33
+ StoreProvider: () => StoreProvider,
34
+ storeHooks: () => storeHooks,
35
+ useI: () => useI,
36
+ useIO: () => useIO,
37
+ useO: () => useO,
38
+ useStore: () => useStore
39
+ });
40
+ module.exports = __toCommonJS(react_exports);
41
+
42
+ // ../src/react/store-context.tsx
43
+ var AtomIO = __toESM(require("atom.io"));
44
+ var React = __toESM(require("react"));
45
+ var import_jsx_dev_runtime = require("react/jsx-dev-runtime");
46
+ var StoreContext = React.createContext(
47
+ AtomIO.__INTERNAL__.IMPLICIT.STORE
48
+ );
49
+ var StoreProvider = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(StoreContext.Provider, { value: store, children }, void 0, false, {
50
+ fileName: "../src/react/store-context.tsx",
51
+ lineNumber: 12,
52
+ columnNumber: 2
53
+ }, this);
54
+
55
+ // ../src/react/store-hooks.ts
56
+ var AtomIO2 = __toESM(require("atom.io"));
57
+ var React2 = __toESM(require("react"));
58
+ var storeHooks = { useI, useO, useIO };
59
+ function useI(token) {
60
+ const store = React2.useContext(StoreContext);
61
+ const update = (next) => AtomIO2.setState(token, next, store);
62
+ return update;
63
+ }
64
+ function useO(token) {
65
+ const store = React2.useContext(StoreContext);
66
+ return React2.useSyncExternalStore(
67
+ (observe) => AtomIO2.subscribe(token, observe, store),
68
+ () => AtomIO2.getState(token, store)
69
+ );
70
+ }
71
+ function useIO(token) {
72
+ return [useO(token), useI(token)];
73
+ }
74
+ function useStore(token) {
75
+ return token.type === `readonly_selector` ? useO(token) : useIO(token);
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ StoreContext,
80
+ StoreProvider,
81
+ storeHooks,
82
+ useI,
83
+ useIO,
84
+ useO,
85
+ useStore
86
+ });
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/index.ts","../../src/react/store-context.tsx","../../src/react/store-hooks.ts"],"sourcesContent":["export * from \"./store-context\"\nexport * from \"./store-hooks\"\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<AtomIO.Store>(\n\tAtomIO.__INTERNAL__.IMPLICIT.STORE,\n)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: AtomIO.Store\n}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nimport type { Modifier } from \"~/packages/anvl/src/function\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport type StoreHooks = {\n\tuseI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void\n\tuseO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T\n\tuseIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void]\n}\nexport const storeHooks: StoreHooks = { useI, useO, useIO }\n\nexport function useI<T>(\n\ttoken: AtomIO.StateToken<T>,\n): (next: Modifier<T> | T) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst update = (next: Modifier<T> | T) => AtomIO.setState(token, next, store)\n\treturn update\n}\n\nexport function useO<T>(\n\ttoken: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,\n): T {\n\tconst store = React.useContext(StoreContext)\n\treturn React.useSyncExternalStore<T>(\n\t\t(observe) => AtomIO.subscribe(token, observe, store),\n\t\t() => AtomIO.getState(token, store),\n\t)\n}\n\nexport function useIO<T>(\n\ttoken: AtomIO.StateToken<T>,\n): [T, (next: Modifier<T> | T) => void] {\n\treturn [useO(token), useI(token)]\n}\n\nexport function useStore<T>(\n\ttoken: AtomIO.StateToken<T>,\n): [T, (next: Modifier<T> | T) => void]\nexport function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T\nexport function useStore<T>(\n\ttoken: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,\n): T | [T, (next: Modifier<T> | T) => void] {\n\treturn token.type === `readonly_selector` ? useO(token) : useIO(token)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,aAAwB;AACxB,YAAuB;AAUtB;AARM,IAAM,eAAqB;AAAA,EAC1B,oBAAa,SAAS;AAC9B;AAEO,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAe,oBAAa,SAAS,MAAM,MAC5D,mDAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,YAAtC;AAAA;AAAA;AAAA;AAAA,OAA+C;;;ACXhD,IAAAA,UAAwB;AACxB,IAAAC,SAAuB;AAWhB,IAAM,aAAyB,EAAE,MAAM,MAAM,MAAM;AAEnD,SAAS,KACf,OACkC;AAClC,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAAS,CAAC,SAAiC,iBAAS,OAAO,MAAM,KAAK;AAC5E,SAAO;AACR;AAEO,SAAS,KACf,OACI;AACJ,QAAM,QAAc,kBAAW,YAAY;AAC3C,SAAa;AAAA,IACZ,CAAC,YAAmB,kBAAU,OAAO,SAAS,KAAK;AAAA,IACnD,MAAa,iBAAS,OAAO,KAAK;AAAA,EACnC;AACD;AAEO,SAAS,MACf,OACuC;AACvC,SAAO,CAAC,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AACjC;AAMO,SAAS,SACf,OAC2C;AAC3C,SAAO,MAAM,SAAS,sBAAsB,KAAK,KAAK,IAAI,MAAM,KAAK;AACtE;","names":["AtomIO","React"]}
@@ -0,0 +1,45 @@
1
+ // ../src/react/store-context.tsx
2
+ import * as AtomIO from "atom.io";
3
+ import * as React from "react";
4
+ import { jsxDEV } from "react/jsx-dev-runtime";
5
+ var StoreContext = React.createContext(
6
+ AtomIO.__INTERNAL__.IMPLICIT.STORE
7
+ );
8
+ var StoreProvider = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => /* @__PURE__ */ jsxDEV(StoreContext.Provider, { value: store, children }, void 0, false, {
9
+ fileName: "../src/react/store-context.tsx",
10
+ lineNumber: 12,
11
+ columnNumber: 2
12
+ }, this);
13
+
14
+ // ../src/react/store-hooks.ts
15
+ import * as AtomIO2 from "atom.io";
16
+ import * as React2 from "react";
17
+ var storeHooks = { useI, useO, useIO };
18
+ function useI(token) {
19
+ const store = React2.useContext(StoreContext);
20
+ const update = (next) => AtomIO2.setState(token, next, store);
21
+ return update;
22
+ }
23
+ function useO(token) {
24
+ const store = React2.useContext(StoreContext);
25
+ return React2.useSyncExternalStore(
26
+ (observe) => AtomIO2.subscribe(token, observe, store),
27
+ () => AtomIO2.getState(token, store)
28
+ );
29
+ }
30
+ function useIO(token) {
31
+ return [useO(token), useI(token)];
32
+ }
33
+ function useStore(token) {
34
+ return token.type === `readonly_selector` ? useO(token) : useIO(token);
35
+ }
36
+ export {
37
+ StoreContext,
38
+ StoreProvider,
39
+ storeHooks,
40
+ useI,
41
+ useIO,
42
+ useO,
43
+ useStore
44
+ };
45
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/store-context.tsx","../../src/react/store-hooks.ts"],"sourcesContent":["import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<AtomIO.Store>(\n\tAtomIO.__INTERNAL__.IMPLICIT.STORE,\n)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: AtomIO.Store\n}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nimport type { Modifier } from \"~/packages/anvl/src/function\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport type StoreHooks = {\n\tuseI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void\n\tuseO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T\n\tuseIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void]\n}\nexport const storeHooks: StoreHooks = { useI, useO, useIO }\n\nexport function useI<T>(\n\ttoken: AtomIO.StateToken<T>,\n): (next: Modifier<T> | T) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst update = (next: Modifier<T> | T) => AtomIO.setState(token, next, store)\n\treturn update\n}\n\nexport function useO<T>(\n\ttoken: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,\n): T {\n\tconst store = React.useContext(StoreContext)\n\treturn React.useSyncExternalStore<T>(\n\t\t(observe) => AtomIO.subscribe(token, observe, store),\n\t\t() => AtomIO.getState(token, store),\n\t)\n}\n\nexport function useIO<T>(\n\ttoken: AtomIO.StateToken<T>,\n): [T, (next: Modifier<T> | T) => void] {\n\treturn [useO(token), useI(token)]\n}\n\nexport function useStore<T>(\n\ttoken: AtomIO.StateToken<T>,\n): [T, (next: Modifier<T> | T) => void]\nexport function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T\nexport function useStore<T>(\n\ttoken: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,\n): T | [T, (next: Modifier<T> | T) => void] {\n\treturn token.type === `readonly_selector` ? useO(token) : useIO(token)\n}\n"],"mappings":";AAAA,YAAY,YAAY;AACxB,YAAY,WAAW;AAUtB;AARM,IAAM,eAAqB;AAAA,EAC1B,oBAAa,SAAS;AAC9B;AAEO,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAe,oBAAa,SAAS,MAAM,MAC5D,uBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,YAAtC;AAAA;AAAA;AAAA;AAAA,OAA+C;;;ACXhD,YAAYA,aAAY;AACxB,YAAYC,YAAW;AAWhB,IAAM,aAAyB,EAAE,MAAM,MAAM,MAAM;AAEnD,SAAS,KACf,OACkC;AAClC,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAAS,CAAC,SAAiC,iBAAS,OAAO,MAAM,KAAK;AAC5E,SAAO;AACR;AAEO,SAAS,KACf,OACI;AACJ,QAAM,QAAc,kBAAW,YAAY;AAC3C,SAAa;AAAA,IACZ,CAAC,YAAmB,kBAAU,OAAO,SAAS,KAAK;AAAA,IACnD,MAAa,iBAAS,OAAO,KAAK;AAAA,EACnC;AACD;AAEO,SAAS,MACf,OACuC;AACvC,SAAO,CAAC,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AACjC;AAMO,SAAS,SACf,OAC2C;AAC3C,SAAO,MAAM,SAAS,sBAAsB,KAAK,KAAK,IAAI,MAAM,KAAK;AACtE;","names":["AtomIO","React"]}
@@ -1,15 +1,15 @@
1
1
  {
2
- "name": "atom.io-react",
3
- "private": true,
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "module": "dist/index.mjs",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "browser": "./dist/index.mjs",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- }
2
+ "name": "atom.io-react",
3
+ "private": true,
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "browser": "./dist/index.mjs",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ }
15
15
  }
@@ -0,0 +1,26 @@
1
+ /* ../src/react-devtools/devtools.scss */
2
+ main.atom_io_devtools {
3
+ --fg-color: #eee;
4
+ --bg-color: #111;
5
+ @media (prefers-color-scheme: light) {
6
+ --fg-color: #222;
7
+ --bg-color: #ccc;
8
+ }
9
+ box-sizing: border-box;
10
+ color: var(--fg-color);
11
+ background-color: var(--bg-color);
12
+ border: 2px solid var(--fg-color);
13
+ position: fixed;
14
+ right: 0;
15
+ bottom: 0;
16
+ height: 100%;
17
+ display: flex;
18
+ flex-flow: column;
19
+ max-height: 800px;
20
+ width: 100%;
21
+ max-width: 460px;
22
+ overflow-y: scroll;
23
+ padding: 5px;
24
+ header { display: flex; justify-content: space-between; h1 { font-size: inherit; margin: 0; } } main { overflow-y: scroll; flex-grow: 1; section { margin-top: 30px; h2 { font-size: inherit; margin: 0; } .node { border: 1px solid var(--fg-color); padding: 5px; margin: 5px; overflow-x: scroll; } } } footer { display: flex; justify-content: flex-end; button { cursor: pointer; background: none; border: none; padding: none; position: absolute; right: 0; bottom: 0; } } .json_editor { input { font-size: 20px; font-family: theia; border: none; border-bottom: 1px solid; background: none; &:disabled { border: none; } } button { background: none; margin-left: auto; color: #777; border: none; font-family: theia; font-size: 14px; margin: none; padding: 4px; padding-bottom: 6px; cursor: pointer; &:hover { color: #333; background-color: #aaa; } } select { font-family: theia; font-size: 14px; background: none; border: none; color: #777; @media (prefers-color-scheme: light) { color: #999; } } .json_editor_unofficial { background-color: #777; button { color: #333; } } .json_editor_missing { background-color: #f055; } .json_editor_key { input { color: #999; @media (prefers-color-scheme: light) { color: #777; } } } .json_editor_object { border-left: 2px solid #333; padding-left: 20px; @media (prefers-color-scheme: light) { border-color: #ccc; } .json_editor_properties { > * { border-bottom: 2px solid #333; margin-bottom: 2px; } } } };
25
+ }
26
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react-devtools/devtools.scss"],"sourcesContent":["main.atom_io_devtools {\n --fg-color: #eee;\n --bg-color: #111;\n @media (prefers-color-scheme: light) {\n --fg-color: #222;\n --bg-color: #ccc;\n }\n box-sizing: border-box;\n color: var(--fg-color);\n background-color: var(--bg-color);\n border: 2px solid var(--fg-color);\n position: fixed;\n right: 0;\n bottom: 0;\n height: 100%;\n display: flex;\n flex-flow: column;\n max-height: 800px;\n width: 100%;\n max-width: 460px;\n overflow-y: scroll;\n padding: 5px;\n header {\n display: flex;\n justify-content: space-between;\n h1 {\n font-size: inherit;\n margin: 0;\n }\n }\n main {\n overflow-y: scroll;\n flex-grow: 1;\n section {\n margin-top: 30px;\n h2 {\n font-size: inherit;\n margin: 0;\n }\n .node {\n border: 1px solid var(--fg-color);\n padding: 5px;\n margin: 5px;\n overflow-x: scroll;\n }\n }\n }\n footer {\n display: flex;\n justify-content: flex-end;\n button {\n cursor: pointer;\n background: none;\n border: none;\n padding: none;\n position: absolute;\n right: 0;\n bottom: 0;\n }\n }\n\n .json_editor {\n input {\n font-size: 20px;\n font-family: theia;\n border: none;\n border-bottom: 1px solid;\n background: none;\n &:disabled {\n border: none;\n }\n }\n button {\n background: none;\n margin-left: auto;\n color: #777;\n border: none;\n font-family: theia;\n font-size: 14px;\n margin: none;\n padding: 4px;\n padding-bottom: 6px;\n cursor: pointer;\n &:hover {\n color: #333;\n background-color: #aaa;\n }\n }\n select {\n font-family: theia;\n font-size: 14px;\n background: none;\n border: none;\n color: #777;\n @media (prefers-color-scheme: light) {\n color: #999;\n }\n }\n .json_editor_unofficial {\n background-color: #777;\n button {\n color: #333;\n }\n }\n .json_editor_missing {\n background-color: #f055;\n }\n .json_editor_key {\n input {\n color: #999;\n @media (prefers-color-scheme: light) {\n color: #777;\n }\n }\n }\n .json_editor_object {\n border-left: 2px solid #333;\n padding-left: 20px;\n @media (prefers-color-scheme: light) {\n border-color: #ccc;\n }\n .json_editor_properties {\n > * {\n border-bottom: 2px solid #333;\n margin-bottom: 2px;\n }\n }\n }\n }\n}\n"],"mappings":";AAAA;AACE;AACA;AACA;AACE;AACA;AAAA;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { FC } from 'react';
2
+ import * as AtomIO from 'atom.io';
3
+
4
+ type Modifier<T> = (thing: T) => T;
5
+
6
+ type StoreHooks = {
7
+ useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void;
8
+ useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T;
9
+ useIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void];
10
+ };
11
+
12
+ declare const composeDevtools: (storeHooks: StoreHooks) => FC;
13
+ declare const AtomIODevtools: FC;
14
+
15
+ export { AtomIODevtools, composeDevtools };
@@ -0,0 +1,15 @@
1
+ import { FC } from 'react';
2
+ import * as AtomIO from 'atom.io';
3
+
4
+ type Modifier<T> = (thing: T) => T;
5
+
6
+ type StoreHooks = {
7
+ useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void;
8
+ useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T;
9
+ useIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void];
10
+ };
11
+
12
+ declare const composeDevtools: (storeHooks: StoreHooks) => FC;
13
+ declare const AtomIODevtools: FC;
14
+
15
+ export { AtomIODevtools, composeDevtools };