atom.io 0.6.2 → 0.6.3

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 (110) hide show
  1. package/dist/index.d.mts +2 -2
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.js +7 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +7 -2
  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/package.json +13 -3
  14. package/react/dist/index.d.mts +24 -0
  15. package/react/dist/index.d.ts +24 -0
  16. package/react/dist/index.js +83 -0
  17. package/react/dist/index.js.map +1 -0
  18. package/react/dist/index.mjs +41 -0
  19. package/react/dist/index.mjs.map +1 -0
  20. package/react-devtools/dist/index.css +26 -0
  21. package/react-devtools/dist/index.css.map +1 -0
  22. package/react-devtools/dist/index.d.mts +15 -0
  23. package/react-devtools/dist/index.d.ts +15 -0
  24. package/react-devtools/dist/index.js +1596 -0
  25. package/react-devtools/dist/index.js.map +1 -0
  26. package/react-devtools/dist/index.mjs +1568 -0
  27. package/react-devtools/dist/index.mjs.map +1 -0
  28. package/realtime/dist/index.d.mts +27 -0
  29. package/realtime/dist/index.d.ts +27 -0
  30. package/realtime/dist/index.js +191 -0
  31. package/realtime/dist/index.js.map +1 -0
  32. package/realtime/dist/index.mjs +152 -0
  33. package/realtime/dist/index.mjs.map +1 -0
  34. package/realtime-react/dist/index.d.mts +45 -0
  35. package/realtime-react/dist/index.d.ts +45 -0
  36. package/realtime-react/dist/index.js +213 -0
  37. package/realtime-react/dist/index.js.map +1 -0
  38. package/realtime-react/dist/index.mjs +168 -0
  39. package/realtime-react/dist/index.mjs.map +1 -0
  40. package/realtime-testing/dist/index.d.mts +49 -0
  41. package/realtime-testing/dist/index.d.ts +49 -0
  42. package/realtime-testing/dist/index.js +153 -0
  43. package/realtime-testing/dist/index.js.map +1 -0
  44. package/realtime-testing/dist/index.mjs +117 -0
  45. package/realtime-testing/dist/index.mjs.map +1 -0
  46. package/realtime-testing/package.json +15 -0
  47. package/src/atom.ts +15 -15
  48. package/src/index.ts +59 -59
  49. package/src/internal/atom-internal.ts +36 -36
  50. package/src/internal/families-internal.ts +114 -114
  51. package/src/internal/get.ts +83 -83
  52. package/src/internal/is-default.ts +17 -17
  53. package/src/internal/meta/attach-meta.ts +7 -7
  54. package/src/internal/meta/meta-state.ts +115 -115
  55. package/src/internal/operation.ts +93 -93
  56. package/src/internal/selector/create-read-write-selector.ts +46 -46
  57. package/src/internal/selector/create-readonly-selector.ts +37 -37
  58. package/src/internal/selector/lookup-selector-sources.ts +9 -9
  59. package/src/internal/selector/register-selector.ts +44 -44
  60. package/src/internal/selector/trace-selector-atoms.ts +30 -30
  61. package/src/internal/selector/update-selector-atoms.ts +25 -25
  62. package/src/internal/selector-internal.ts +37 -37
  63. package/src/internal/set.ts +78 -78
  64. package/src/internal/store.ts +118 -118
  65. package/src/internal/subscribe-internal.ts +62 -62
  66. package/src/internal/time-travel-internal.ts +76 -76
  67. package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
  68. package/src/internal/timeline-internal.ts +80 -80
  69. package/src/internal/transaction/abort-transaction.ts +8 -8
  70. package/src/internal/transaction/apply-transaction.ts +41 -41
  71. package/src/internal/transaction/build-transaction.ts +28 -28
  72. package/src/internal/transaction/index.ts +7 -7
  73. package/src/internal/transaction/redo-transaction.ts +13 -13
  74. package/src/internal/transaction/undo-transaction.ts +13 -13
  75. package/src/internal/transaction-internal.ts +48 -48
  76. package/src/json/select-json.ts +12 -12
  77. package/src/logger.ts +30 -30
  78. package/src/react/store-context.tsx +4 -4
  79. package/src/react/store-hooks.ts +18 -18
  80. package/src/react-devtools/AtomIODevtools.tsx +83 -82
  81. package/src/react-devtools/StateEditor.tsx +53 -53
  82. package/src/react-devtools/TokenList.tsx +47 -42
  83. package/src/react-explorer/AtomIOExplorer.tsx +197 -185
  84. package/src/react-explorer/explorer-effects.ts +11 -11
  85. package/src/react-explorer/explorer-states.ts +186 -193
  86. package/src/react-explorer/index.ts +11 -11
  87. package/src/react-explorer/space-states.ts +48 -50
  88. package/src/react-explorer/view-states.ts +25 -25
  89. package/src/realtime/hook-composition/expose-family.ts +81 -81
  90. package/src/realtime/hook-composition/expose-single.ts +26 -26
  91. package/src/realtime/hook-composition/expose-timeline.ts +60 -0
  92. package/src/realtime/hook-composition/index.ts +2 -2
  93. package/src/realtime/hook-composition/receive-state.ts +18 -18
  94. package/src/realtime/hook-composition/receive-transaction.ts +8 -8
  95. package/src/realtime-react/realtime-context.tsx +17 -17
  96. package/src/realtime-react/realtime-hooks.ts +17 -17
  97. package/src/realtime-react/realtime-state.ts +4 -4
  98. package/src/realtime-react/use-pull-family-member.ts +15 -15
  99. package/src/realtime-react/use-pull-family.ts +13 -13
  100. package/src/realtime-react/use-pull.ts +12 -12
  101. package/src/realtime-react/use-push.ts +15 -15
  102. package/src/realtime-react/use-server-action.ts +21 -21
  103. package/src/realtime-testing/index.ts +1 -0
  104. package/src/realtime-testing/setup-realtime-test.tsx +160 -0
  105. package/src/selector.ts +25 -25
  106. package/src/silo.ts +38 -38
  107. package/src/subscribe.ts +68 -68
  108. package/src/timeline.ts +13 -13
  109. package/src/transaction.ts +28 -28
  110. 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
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,11 +63,18 @@
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
75
  "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}",
76
+ "build": "tsup & (cd json && tsup) & (cd react && tsup) & (cd react-devtools && tsup) & (cd realtime && tsup) & (cd realtime-react && tsup) & (cd realtime-testing && tsup)",
77
+ "lint": "rome check .",
69
78
  "test": "vitest",
70
79
  "test:once": "vitest run"
71
80
  },
@@ -98,6 +107,7 @@
98
107
  "@testing-library/react": "14.0.0",
99
108
  "@types/mock-fs": "4.13.1",
100
109
  "eslint": "8.44.0",
110
+ "happy-dom": "10.3.0",
101
111
  "mock-fs": "5.2.0",
102
112
  "react": "18.2.0",
103
113
  "react-dom": "18.2.0",
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import * as AtomIO from 'atom.io';
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 React from 'react';
2
+ import * as AtomIO from 'atom.io';
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,83 @@
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 React = __toESM(require("react"));
44
+ var AtomIO = __toESM(require("atom.io"));
45
+ var import_jsx_runtime = require("react/jsx-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_runtime.jsx)(StoreContext.Provider, { value: store, children });
50
+
51
+ // ../src/react/store-hooks.ts
52
+ var React2 = __toESM(require("react"));
53
+ var AtomIO2 = __toESM(require("atom.io"));
54
+ var storeHooks = { useI, useO, useIO };
55
+ function useI(token) {
56
+ const store = React2.useContext(StoreContext);
57
+ const update = (next) => AtomIO2.setState(token, next, store);
58
+ return update;
59
+ }
60
+ function useO(token) {
61
+ const store = React2.useContext(StoreContext);
62
+ return React2.useSyncExternalStore(
63
+ (observe) => AtomIO2.subscribe(token, observe, store),
64
+ () => AtomIO2.getState(token, store)
65
+ );
66
+ }
67
+ function useIO(token) {
68
+ return [useO(token), useI(token)];
69
+ }
70
+ function useStore(token) {
71
+ return token.type === `readonly_selector` ? useO(token) : useIO(token);
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ StoreContext,
76
+ StoreProvider,
77
+ storeHooks,
78
+ useI,
79
+ useIO,
80
+ useO,
81
+ useStore
82
+ });
83
+ //# 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 React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\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 React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\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,YAAuB;AAEvB,aAAwB;AAUvB;AARM,IAAM,eAAqB;AAAA,EAC1B,oBAAa,SAAS;AAC9B;AAEO,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAe,oBAAa,SAAS,MAAM,MAC5D,4CAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;;;ACZhD,IAAAA,SAAuB;AAEvB,IAAAC,UAAwB;AAWjB,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":["React","AtomIO"]}
@@ -0,0 +1,41 @@
1
+ // ../src/react/store-context.tsx
2
+ import * as React from "react";
3
+ import * as AtomIO from "atom.io";
4
+ import { jsx } from "react/jsx-runtime";
5
+ var StoreContext = React.createContext(
6
+ AtomIO.__INTERNAL__.IMPLICIT.STORE
7
+ );
8
+ var StoreProvider = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children });
9
+
10
+ // ../src/react/store-hooks.ts
11
+ import * as React2 from "react";
12
+ import * as AtomIO2 from "atom.io";
13
+ var storeHooks = { useI, useO, useIO };
14
+ function useI(token) {
15
+ const store = React2.useContext(StoreContext);
16
+ const update = (next) => AtomIO2.setState(token, next, store);
17
+ return update;
18
+ }
19
+ function useO(token) {
20
+ const store = React2.useContext(StoreContext);
21
+ return React2.useSyncExternalStore(
22
+ (observe) => AtomIO2.subscribe(token, observe, store),
23
+ () => AtomIO2.getState(token, store)
24
+ );
25
+ }
26
+ function useIO(token) {
27
+ return [useO(token), useI(token)];
28
+ }
29
+ function useStore(token) {
30
+ return token.type === `readonly_selector` ? useO(token) : useIO(token);
31
+ }
32
+ export {
33
+ StoreContext,
34
+ StoreProvider,
35
+ storeHooks,
36
+ useI,
37
+ useIO,
38
+ useO,
39
+ useStore
40
+ };
41
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/store-context.tsx","../../src/react/store-hooks.ts"],"sourcesContent":["import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\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 React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\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,WAAW;AAEvB,YAAY,YAAY;AAUvB;AARM,IAAM,eAAqB;AAAA,EAC1B,oBAAa,SAAS;AAC9B;AAEO,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAe,oBAAa,SAAS,MAAM,MAC5D,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;;;ACZhD,YAAYA,YAAW;AAEvB,YAAYC,aAAY;AAWjB,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":["React","AtomIO"]}
@@ -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 };