atom.io 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +82 -66
- package/dist/index.d.ts +82 -66
- package/dist/index.js +482 -360
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +481 -360
- package/dist/index.mjs.map +1 -1
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs.map +1 -1
- package/package.json +12 -5
- package/react/dist/index.d.mts +18 -11
- package/react/dist/index.d.ts +18 -11
- package/react/dist/index.js +45 -21
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +31 -21
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.d.mts +4 -4
- package/react-devtools/dist/index.d.ts +4 -4
- package/react-devtools/dist/index.js +14 -14
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +14 -14
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +3 -1
- package/realtime/dist/index.d.ts +3 -1
- package/realtime/dist/index.js +23 -0
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +22 -0
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +45 -0
- package/realtime-react/dist/index.d.ts +45 -0
- package/realtime-react/dist/index.js +213 -0
- package/realtime-react/dist/index.js.map +1 -0
- package/realtime-react/dist/index.mjs +168 -0
- package/realtime-react/dist/index.mjs.map +1 -0
- package/realtime-react/package.json +15 -0
- package/src/index.ts +0 -6
- package/src/internal/get.ts +17 -3
- package/src/internal/index.ts +2 -0
- package/src/internal/meta/meta-state.ts +1 -1
- package/src/internal/operation.ts +3 -1
- package/src/internal/selector/create-read-write-selector.ts +62 -0
- package/src/internal/selector/create-readonly-selector.ts +52 -0
- package/src/internal/selector/index.ts +4 -0
- package/src/internal/selector/lookup-selector-sources.ts +16 -0
- package/src/internal/selector/register-selector.ts +57 -0
- package/src/internal/selector/trace-selector-atoms.ts +43 -0
- package/src/internal/selector/update-selector-atoms.ts +33 -0
- package/src/internal/selector-internal.ts +9 -207
- package/src/internal/store.ts +43 -16
- package/src/internal/subscribe-internal.ts +1 -1
- package/src/internal/time-travel-internal.ts +7 -7
- package/src/internal/timeline/add-atom-to-timeline.ts +164 -0
- package/src/internal/timeline/index.ts +1 -0
- package/src/internal/timeline-internal.ts +37 -156
- package/src/internal/transaction/abort-transaction.ts +12 -0
- package/src/internal/transaction/apply-transaction.ts +54 -0
- package/src/internal/transaction/build-transaction.ts +33 -0
- package/src/internal/transaction/index.ts +25 -0
- package/src/internal/transaction/redo-transaction.ts +23 -0
- package/src/internal/transaction/undo-transaction.ts +23 -0
- package/src/internal/transaction-internal.ts +14 -146
- package/src/react/index.ts +2 -46
- package/src/react/store-context.tsx +14 -0
- package/src/react/store-hooks.ts +48 -0
- package/src/react-devtools/AtomIODevtools.tsx +1 -1
- package/src/react-explorer/AtomIOExplorer.tsx +2 -2
- package/src/react-explorer/space-states.ts +2 -2
- package/src/realtime/README.md +33 -0
- package/src/realtime/hook-composition/index.ts +1 -0
- package/src/realtime/hook-composition/receive-state.ts +29 -0
- package/src/realtime/hook-composition/receive-transaction.ts +2 -3
- package/src/realtime-react/index.ts +3 -0
- package/src/realtime-react/realtime-context.tsx +31 -0
- package/src/realtime-react/realtime-hooks.ts +39 -0
- package/src/realtime-react/realtime-state.ts +10 -0
- package/src/realtime-react/use-pull-family-member.ts +27 -0
- package/src/realtime-react/use-pull-family.ts +25 -0
- package/src/realtime-react/use-pull.ts +23 -0
- package/src/realtime-react/use-push.ts +26 -0
- package/src/realtime-react/use-server-action.ts +34 -0
- package/src/silo.ts +12 -4
- package/src/subscribe.ts +30 -2
- package/src/timeline.ts +10 -0
- package/src/transaction.ts +15 -10
- package/src/realtime-client/hook-composition/compose-realtime-hooks.ts +0 -62
- package/src/realtime-client/hook-composition/realtime-client-family-member.ts +0 -28
- package/src/realtime-client/hook-composition/realtime-client-family.ts +0 -26
- package/src/realtime-client/hook-composition/realtime-client-single.ts +0 -24
- package/src/realtime-client/hook-composition/realtime-client-transaction.ts +0 -35
- package/src/realtime-client/index.ts +0 -1
package/json/dist/index.js.map
CHANGED
|
@@ -1 +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 atom: AtomIO.AtomToken<T>,\n transform: JsonInterface<T, J>,\n store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE\n): AtomIO.SelectorToken<J> =>\n AtomIO.__INTERNAL__.selector__INTERNAL(\n {\n key: `${atom.key}JSON`,\n get: ({ get }) => transform.toJson(get(atom)),\n set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n },\n undefined,\n store\n )\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,aAAwB;AAIjB,IAAM,aAAa,CACxB,MACA,WACA,QAA6B,oBAAa,SAAS,UAE5C,oBAAa;AAAA,EAClB;AAAA,IACE,KAAK,GAAG,KAAK;AAAA,
|
|
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 atom: AtomIO.AtomToken<T>,\n transform: JsonInterface<T, J>,\n store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE\n): AtomIO.SelectorToken<J> =>\n AtomIO.__INTERNAL__.selector__INTERNAL(\n {\n key: `${atom.key}JSON`,\n get: ({ get }) => transform.toJson(get(atom)),\n set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n },\n undefined,\n store\n )\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,aAAwB;AAIjB,IAAM,aAAa,CACxB,MACA,WACA,QAA6B,oBAAa,SAAS,UAE5C,oBAAa;AAAA,EAClB;AAAA,IACE,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,EACpE;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/json/dist/index.mjs.map
CHANGED
|
@@ -1 +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 atom: AtomIO.AtomToken<T>,\n transform: JsonInterface<T, J>,\n store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE\n): AtomIO.SelectorToken<J> =>\n AtomIO.__INTERNAL__.selector__INTERNAL(\n {\n key: `${atom.key}JSON`,\n get: ({ get }) => transform.toJson(get(atom)),\n set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n },\n undefined,\n store\n )\n"],"mappings":";AAAA,YAAY,YAAY;AAIjB,IAAM,aAAa,CACxB,MACA,WACA,QAA6B,oBAAa,SAAS,UAE5C,oBAAa;AAAA,EAClB;AAAA,IACE,KAAK,GAAG,KAAK;AAAA,
|
|
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 atom: AtomIO.AtomToken<T>,\n transform: JsonInterface<T, J>,\n store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE\n): AtomIO.SelectorToken<J> =>\n AtomIO.__INTERNAL__.selector__INTERNAL(\n {\n key: `${atom.key}JSON`,\n get: ({ get }) => transform.toJson(get(atom)),\n set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),\n },\n undefined,\n store\n )\n"],"mappings":";AAAA,YAAY,YAAY;AAIjB,IAAM,aAAa,CACxB,MACA,WACA,QAA6B,oBAAa,SAAS,UAE5C,oBAAa;AAAA,EAClB;AAAA,IACE,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,EACpE;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Reactive state graph for React, Preact, and vanilla",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"react-devtools/package.json",
|
|
16
16
|
"realtime/dist",
|
|
17
17
|
"realtime/package.json",
|
|
18
|
+
"realtime-react/dist",
|
|
19
|
+
"realtime-react/package.json",
|
|
18
20
|
"src"
|
|
19
21
|
],
|
|
20
22
|
"exports": {
|
|
@@ -52,10 +54,17 @@
|
|
|
52
54
|
"browser": "./realtime/dist/index.mjs",
|
|
53
55
|
"import": "./realtime/dist/index.mjs",
|
|
54
56
|
"require": "./realtime/dist/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./realtime-react/package.json": "./realtime-react/package.json",
|
|
59
|
+
"./realtime-react": {
|
|
60
|
+
"types": "./realtime-react/dist/index.d.ts",
|
|
61
|
+
"browser": "./realtime-react/dist/index.mjs",
|
|
62
|
+
"import": "./realtime-react/dist/index.mjs",
|
|
63
|
+
"require": "./realtime-react/dist/index.js"
|
|
55
64
|
}
|
|
56
65
|
},
|
|
57
66
|
"scripts": {
|
|
58
|
-
"build": "tsup & (cd json && tsup) & (cd react && tsup) & (cd react-devtools && tsup) & (cd realtime && tsup)",
|
|
67
|
+
"build": "tsup & (cd json && tsup) & (cd react && tsup) & (cd react-devtools && tsup) & (cd realtime && tsup) & (cd realtime-react && tsup)",
|
|
59
68
|
"lint": "eslint ./**/*.ts{,x}",
|
|
60
69
|
"test": "vitest",
|
|
61
70
|
"test:once": "vitest run"
|
|
@@ -86,18 +95,16 @@
|
|
|
86
95
|
"rxjs": "7.8.1"
|
|
87
96
|
},
|
|
88
97
|
"devDependencies": {
|
|
89
|
-
"@testing-library/preact": "3.2.3",
|
|
90
98
|
"@testing-library/react": "14.0.0",
|
|
91
99
|
"@types/mock-fs": "4.13.1",
|
|
92
100
|
"eslint": "8.44.0",
|
|
93
101
|
"mock-fs": "5.2.0",
|
|
94
|
-
"preact": "10.15.1",
|
|
95
102
|
"react": "18.2.0",
|
|
96
103
|
"react-dom": "18.2.0",
|
|
97
104
|
"react-router-dom": "6.14.1",
|
|
98
105
|
"tsup": "7.1.0",
|
|
99
106
|
"vite-tsconfig-paths": "4.2.0",
|
|
100
|
-
"vitest": "0.
|
|
107
|
+
"vitest": "0.33.0"
|
|
101
108
|
},
|
|
102
109
|
"repository": {
|
|
103
110
|
"type": "git",
|
package/react/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
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
|
+
}>;
|
|
2
9
|
|
|
3
10
|
type Modifier<T> = (thing: T) => T;
|
|
4
11
|
|
|
5
12
|
type StoreHooks = {
|
|
6
|
-
useI: <T>(token: StateToken<T>) => (next: Modifier<T> | T) => void;
|
|
7
|
-
useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T;
|
|
8
|
-
useIO: <T>(token: StateToken<T>) => [T, (next: Modifier<T> | T) => void];
|
|
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];
|
|
9
16
|
};
|
|
10
|
-
declare const
|
|
11
|
-
declare
|
|
12
|
-
declare
|
|
13
|
-
declare
|
|
14
|
-
declare function useStore<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void];
|
|
15
|
-
declare function useStore<T>(token: ReadonlySelectorToken<T>): T;
|
|
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;
|
|
16
23
|
|
|
17
|
-
export { StoreHooks,
|
|
24
|
+
export { StoreContext, StoreHooks, StoreProvider, storeHooks, useI, useIO, useO, useStore };
|
package/react/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
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
|
+
}>;
|
|
2
9
|
|
|
3
10
|
type Modifier<T> = (thing: T) => T;
|
|
4
11
|
|
|
5
12
|
type StoreHooks = {
|
|
6
|
-
useI: <T>(token: StateToken<T>) => (next: Modifier<T> | T) => void;
|
|
7
|
-
useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T;
|
|
8
|
-
useIO: <T>(token: StateToken<T>) => [T, (next: Modifier<T> | T) => void];
|
|
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];
|
|
9
16
|
};
|
|
10
|
-
declare const
|
|
11
|
-
declare
|
|
12
|
-
declare
|
|
13
|
-
declare
|
|
14
|
-
declare function useStore<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void];
|
|
15
|
-
declare function useStore<T>(token: ReadonlySelectorToken<T>): T;
|
|
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;
|
|
16
23
|
|
|
17
|
-
export { StoreHooks,
|
|
24
|
+
export { StoreContext, StoreHooks, StoreProvider, storeHooks, useI, useIO, useO, useStore };
|
package/react/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,43 +16,65 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// ../src/react/index.ts
|
|
20
30
|
var react_exports = {};
|
|
21
31
|
__export(react_exports, {
|
|
22
|
-
|
|
32
|
+
StoreContext: () => StoreContext,
|
|
33
|
+
StoreProvider: () => StoreProvider,
|
|
34
|
+
storeHooks: () => storeHooks,
|
|
23
35
|
useI: () => useI,
|
|
24
36
|
useIO: () => useIO,
|
|
25
37
|
useO: () => useO,
|
|
26
38
|
useStore: () => useStore
|
|
27
39
|
});
|
|
28
40
|
module.exports = __toCommonJS(react_exports);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
}
|
|
48
70
|
function useStore(token) {
|
|
49
71
|
return token.type === `readonly_selector` ? useO(token) : useIO(token);
|
|
50
72
|
}
|
|
51
73
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
74
|
0 && (module.exports = {
|
|
53
|
-
|
|
75
|
+
StoreContext,
|
|
76
|
+
StoreProvider,
|
|
77
|
+
storeHooks,
|
|
54
78
|
useI,
|
|
55
79
|
useIO,
|
|
56
80
|
useO,
|
package/react/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/index.ts"],"sourcesContent":["import
|
|
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 AtomIO.__INTERNAL__.IMPLICIT.STORE\n)\n\nexport const StoreProvider: React.FC<{\n children: React.ReactNode\n store?: AtomIO.Store\n}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (\n <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 useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void\n useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T\n useIO: <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 token: AtomIO.StateToken<T>\n): (next: Modifier<T> | T) => void {\n const store = React.useContext(StoreContext)\n const update = (next: Modifier<T> | T) => AtomIO.setState(token, next, store)\n return update\n}\n\nexport function useO<T>(\n token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>\n): T {\n const store = React.useContext(StoreContext)\n return React.useSyncExternalStore<T>(\n (observe) => AtomIO.subscribe(token, observe, store),\n () => AtomIO.getState(token, store)\n )\n}\n\nexport function useIO<T>(\n token: AtomIO.StateToken<T>\n): [T, (next: Modifier<T> | T) => void] {\n return [useO(token), useI(token)]\n}\n\nexport function useStore<T>(\n token: AtomIO.StateToken<T>\n): [T, (next: Modifier<T> | T) => void]\nexport function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T\nexport function useStore<T>(\n token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>\n): T | [T, (next: Modifier<T> | T) => void] {\n return 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;AAUtB;AARK,IAAM,eAAqB;AAAA,EACzB,oBAAa,SAAS;AAC/B;AAEO,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAe,oBAAa,SAAS,MAAM,MAC3D,4CAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;;;ACZjD,IAAAA,SAAuB;AAEvB,IAAAC,UAAwB;AAWjB,IAAM,aAAyB,EAAE,MAAM,MAAM,MAAM;AAEnD,SAAS,KACd,OACiC;AACjC,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAAS,CAAC,SAAiC,iBAAS,OAAO,MAAM,KAAK;AAC5E,SAAO;AACT;AAEO,SAAS,KACd,OACG;AACH,QAAM,QAAc,kBAAW,YAAY;AAC3C,SAAa;AAAA,IACX,CAAC,YAAmB,kBAAU,OAAO,SAAS,KAAK;AAAA,IACnD,MAAa,iBAAS,OAAO,KAAK;AAAA,EACpC;AACF;AAEO,SAAS,MACd,OACsC;AACtC,SAAO,CAAC,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AAClC;AAMO,SAAS,SACd,OAC0C;AAC1C,SAAO,MAAM,SAAS,sBAAsB,KAAK,KAAK,IAAI,MAAM,KAAK;AACvE;","names":["React","AtomIO"]}
|
package/react/dist/index.mjs
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
|
-
// ../src/react/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
}
|
|
21
29
|
function useStore(token) {
|
|
22
30
|
return token.type === `readonly_selector` ? useO(token) : useIO(token);
|
|
23
31
|
}
|
|
24
32
|
export {
|
|
25
|
-
|
|
33
|
+
StoreContext,
|
|
34
|
+
StoreProvider,
|
|
35
|
+
storeHooks,
|
|
26
36
|
useI,
|
|
27
37
|
useIO,
|
|
28
38
|
useO,
|
package/react/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/
|
|
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 AtomIO.__INTERNAL__.IMPLICIT.STORE\n)\n\nexport const StoreProvider: React.FC<{\n children: React.ReactNode\n store?: AtomIO.Store\n}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (\n <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 useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void\n useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T\n useIO: <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 token: AtomIO.StateToken<T>\n): (next: Modifier<T> | T) => void {\n const store = React.useContext(StoreContext)\n const update = (next: Modifier<T> | T) => AtomIO.setState(token, next, store)\n return update\n}\n\nexport function useO<T>(\n token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>\n): T {\n const store = React.useContext(StoreContext)\n return React.useSyncExternalStore<T>(\n (observe) => AtomIO.subscribe(token, observe, store),\n () => AtomIO.getState(token, store)\n )\n}\n\nexport function useIO<T>(\n token: AtomIO.StateToken<T>\n): [T, (next: Modifier<T> | T) => void] {\n return [useO(token), useI(token)]\n}\n\nexport function useStore<T>(\n token: AtomIO.StateToken<T>\n): [T, (next: Modifier<T> | T) => void]\nexport function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T\nexport function useStore<T>(\n token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>\n): T | [T, (next: Modifier<T> | T) => void] {\n return token.type === `readonly_selector` ? useO(token) : useIO(token)\n}\n"],"mappings":";AAAA,YAAY,WAAW;AAEvB,YAAY,YAAY;AAUtB;AARK,IAAM,eAAqB;AAAA,EACzB,oBAAa,SAAS;AAC/B;AAEO,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAe,oBAAa,SAAS,MAAM,MAC3D,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;;;ACZjD,YAAYA,YAAW;AAEvB,YAAYC,aAAY;AAWjB,IAAM,aAAyB,EAAE,MAAM,MAAM,MAAM;AAEnD,SAAS,KACd,OACiC;AACjC,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAAS,CAAC,SAAiC,iBAAS,OAAO,MAAM,KAAK;AAC5E,SAAO;AACT;AAEO,SAAS,KACd,OACG;AACH,QAAM,QAAc,kBAAW,YAAY;AAC3C,SAAa;AAAA,IACX,CAAC,YAAmB,kBAAU,OAAO,SAAS,KAAK;AAAA,IACnD,MAAa,iBAAS,OAAO,KAAK;AAAA,EACpC;AACF;AAEO,SAAS,MACd,OACsC;AACtC,SAAO,CAAC,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AAClC;AAMO,SAAS,SACd,OAC0C;AAC1C,SAAO,MAAM,SAAS,sBAAsB,KAAK,KAAK,IAAI,MAAM,KAAK;AACvE;","names":["React","AtomIO"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import * as AtomIO from 'atom.io';
|
|
3
3
|
|
|
4
4
|
type Modifier<T> = (thing: T) => T;
|
|
5
5
|
|
|
6
6
|
type StoreHooks = {
|
|
7
|
-
useI: <T>(token: StateToken<T>) => (next: Modifier<T> | T) => void;
|
|
8
|
-
useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T;
|
|
9
|
-
useIO: <T>(token: StateToken<T>) => [T, (next: Modifier<T> | T) => void];
|
|
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
10
|
};
|
|
11
11
|
|
|
12
12
|
declare const composeDevtools: (storeHooks: StoreHooks) => FC;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import * as AtomIO from 'atom.io';
|
|
3
3
|
|
|
4
4
|
type Modifier<T> = (thing: T) => T;
|
|
5
5
|
|
|
6
6
|
type StoreHooks = {
|
|
7
|
-
useI: <T>(token: StateToken<T>) => (next: Modifier<T> | T) => void;
|
|
8
|
-
useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T;
|
|
9
|
-
useIO: <T>(token: StateToken<T>) => [T, (next: Modifier<T> | T) => void];
|
|
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
10
|
};
|
|
11
11
|
|
|
12
12
|
declare const composeDevtools: (storeHooks: StoreHooks) => FC;
|
|
@@ -211,7 +211,7 @@ var JSON_DEFAULTS = {
|
|
|
211
211
|
|
|
212
212
|
// ../../hamr/src/react-elastic-input/ElasticInput.tsx
|
|
213
213
|
var import_react = require("react");
|
|
214
|
-
var import_jsx_runtime = require("
|
|
214
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
215
215
|
var ElasticInput = (0, import_react.forwardRef)(function ElasticInputFC(props, ref) {
|
|
216
216
|
var _a2, _b, _c, _d;
|
|
217
217
|
const inputRef = (0, import_react.useRef)(null);
|
|
@@ -277,7 +277,7 @@ var import_function7 = require("fp-ts/function");
|
|
|
277
277
|
var clampInto = ([min, max]) => (value) => value < min ? min : value > max ? max : value;
|
|
278
278
|
|
|
279
279
|
// ../../hamr/src/react-elastic-input/NumberInput.tsx
|
|
280
|
-
var import_jsx_runtime2 = require("
|
|
280
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
281
281
|
function round(value, decimalPlaces) {
|
|
282
282
|
if (decimalPlaces === void 0)
|
|
283
283
|
return value;
|
|
@@ -408,7 +408,7 @@ var NumberInput = ({
|
|
|
408
408
|
};
|
|
409
409
|
|
|
410
410
|
// ../../hamr/src/react-elastic-input/TextInput.tsx
|
|
411
|
-
var import_jsx_runtime3 = require("
|
|
411
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
412
412
|
var TextInput = ({
|
|
413
413
|
value,
|
|
414
414
|
set,
|
|
@@ -451,7 +451,7 @@ var makeElementSetters = (data, set) => data.map(
|
|
|
451
451
|
);
|
|
452
452
|
|
|
453
453
|
// ../../hamr/src/react-json-editor/json-editor-internal.tsx
|
|
454
|
-
var import_jsx_runtime4 = require("
|
|
454
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
455
455
|
var JsonEditor_INTERNAL = ({
|
|
456
456
|
data,
|
|
457
457
|
set,
|
|
@@ -516,7 +516,7 @@ var JsonEditor_INTERNAL = ({
|
|
|
516
516
|
};
|
|
517
517
|
|
|
518
518
|
// ../../hamr/src/react-json-editor/editors-by-type/array-editor.tsx
|
|
519
|
-
var import_jsx_runtime5 = require("
|
|
519
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
520
520
|
var ArrayEditor = ({
|
|
521
521
|
path = [],
|
|
522
522
|
isReadonly = () => false,
|
|
@@ -1106,7 +1106,7 @@ var makePropertySorter = (data, set, sortFn) => () => {
|
|
|
1106
1106
|
};
|
|
1107
1107
|
|
|
1108
1108
|
// ../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx
|
|
1109
|
-
var import_jsx_runtime6 = require("
|
|
1109
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1110
1110
|
var PropertyAdder = ({
|
|
1111
1111
|
addProperty,
|
|
1112
1112
|
disabled,
|
|
@@ -1201,7 +1201,7 @@ var ObjectEditor = ({
|
|
|
1201
1201
|
};
|
|
1202
1202
|
|
|
1203
1203
|
// ../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx
|
|
1204
|
-
var import_jsx_runtime7 = require("
|
|
1204
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1205
1205
|
var BooleanEditor = ({
|
|
1206
1206
|
data,
|
|
1207
1207
|
set
|
|
@@ -1249,7 +1249,7 @@ var import_react4 = require("react");
|
|
|
1249
1249
|
var import_recoil = require("recoil");
|
|
1250
1250
|
|
|
1251
1251
|
// ../../hamr/src/react-error-boundary/DefaultFallback.tsx
|
|
1252
|
-
var import_jsx_runtime8 = require("
|
|
1252
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1253
1253
|
var DefaultFallback = ({ error, errorInfo }) => {
|
|
1254
1254
|
var _a2, _b;
|
|
1255
1255
|
const component = errorInfo == null ? void 0 : errorInfo.componentStack.split(` `).filter(Boolean)[2];
|
|
@@ -1299,7 +1299,7 @@ var DefaultFallback = ({ error, errorInfo }) => {
|
|
|
1299
1299
|
};
|
|
1300
1300
|
|
|
1301
1301
|
// ../../hamr/src/react-error-boundary/ErrorBoundary.tsx
|
|
1302
|
-
var import_jsx_runtime9 = require("
|
|
1302
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1303
1303
|
var ErrorBoundary = class extends import_react4.Component {
|
|
1304
1304
|
constructor(props) {
|
|
1305
1305
|
super(props);
|
|
@@ -1325,7 +1325,7 @@ var findErrorBoundaryState = (0, import_recoil.atomFamily)({
|
|
|
1325
1325
|
});
|
|
1326
1326
|
|
|
1327
1327
|
// ../../hamr/src/react-json-editor/default-components.tsx
|
|
1328
|
-
var import_jsx_runtime10 = require("
|
|
1328
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1329
1329
|
var DEFAULT_JSON_EDITOR_COMPONENTS = {
|
|
1330
1330
|
ErrorBoundary: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ErrorBoundary, { children }),
|
|
1331
1331
|
Button: ({ onClick, children, disabled }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "json_editor_button", onClick, disabled, children }),
|
|
@@ -1364,7 +1364,7 @@ var DEFAULT_JSON_EDITOR_COMPONENTS = {
|
|
|
1364
1364
|
// ../../hamr/src/react-json-editor/developer-interface.tsx
|
|
1365
1365
|
var import_react5 = require("react");
|
|
1366
1366
|
var import_ajv = __toESM(require("ajv"));
|
|
1367
|
-
var import_jsx_runtime11 = require("
|
|
1367
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1368
1368
|
var JsonEditor = ({
|
|
1369
1369
|
data,
|
|
1370
1370
|
set,
|
|
@@ -1417,7 +1417,7 @@ var SubEditors = {
|
|
|
1417
1417
|
};
|
|
1418
1418
|
|
|
1419
1419
|
// ../src/react-devtools/StateEditor.tsx
|
|
1420
|
-
var import_jsx_runtime12 = require("
|
|
1420
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1421
1421
|
var StateEditor = ({ storeHooks, token }) => {
|
|
1422
1422
|
const [data, set] = storeHooks.useIO(token);
|
|
1423
1423
|
return isPlainJson(data) ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(JsonEditor, { data, set, schema: true }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "json_editor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -1454,7 +1454,7 @@ var StoreEditor = ({ storeHooks, token }) => {
|
|
|
1454
1454
|
};
|
|
1455
1455
|
|
|
1456
1456
|
// ../src/react-devtools/TokenList.tsx
|
|
1457
|
-
var import_jsx_runtime13 = require("
|
|
1457
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1458
1458
|
var TokenList = ({ storeHooks, tokenIndex }) => {
|
|
1459
1459
|
const tokenIds = storeHooks.useO(tokenIndex);
|
|
1460
1460
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: Object.entries(tokenIds).map(([key, token]) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.Fragment, { children: key.startsWith(`\u{1F441}\u200D\u{1F5E8}_`) ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "node", children: `type` in token ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
@@ -1486,7 +1486,7 @@ var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, on
|
|
|
1486
1486
|
var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
|
|
1487
1487
|
|
|
1488
1488
|
// ../src/react-devtools/AtomIODevtools.tsx
|
|
1489
|
-
var import_jsx_runtime14 = require("
|
|
1489
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1490
1490
|
var { atomTokenIndexState, selectorTokenIndexState } = import_atom2.__INTERNAL__.META.attachMetaState();
|
|
1491
1491
|
var devtoolsAreOpenState = (0, import_atom2.atom)({
|
|
1492
1492
|
key: `\u{1F441}\u200D\u{1F5E8}_devtools_are_open`,
|