atom.io 0.3.0 → 0.4.0

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 (55) hide show
  1. package/README.md +14 -8
  2. package/dist/index.d.ts +117 -62
  3. package/dist/index.js +577 -287
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +574 -285
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +16 -6
  8. package/react/dist/index.d.ts +12 -17
  9. package/react/dist/index.js +25 -34
  10. package/react/dist/index.js.map +1 -1
  11. package/react/dist/index.mjs +21 -34
  12. package/react/dist/index.mjs.map +1 -1
  13. package/react-devtools/dist/index.css +26 -0
  14. package/react-devtools/dist/index.css.map +1 -0
  15. package/react-devtools/dist/index.d.ts +15 -0
  16. package/react-devtools/dist/index.js +1579 -0
  17. package/react-devtools/dist/index.js.map +1 -0
  18. package/react-devtools/dist/index.mjs +1551 -0
  19. package/react-devtools/dist/index.mjs.map +1 -0
  20. package/react-devtools/package.json +15 -0
  21. package/src/index.ts +14 -8
  22. package/src/internal/atom-internal.ts +10 -5
  23. package/src/internal/families-internal.ts +7 -7
  24. package/src/internal/get.ts +9 -9
  25. package/src/internal/index.ts +2 -1
  26. package/src/internal/meta/attach-meta.ts +17 -0
  27. package/src/internal/meta/index.ts +4 -0
  28. package/src/internal/meta/meta-state.ts +135 -0
  29. package/src/internal/meta/meta-timelines.ts +1 -0
  30. package/src/internal/meta/meta-transactions.ts +1 -0
  31. package/src/internal/operation.ts +14 -3
  32. package/src/internal/selector-internal.ts +37 -15
  33. package/src/internal/store.ts +35 -6
  34. package/src/internal/time-travel-internal.ts +89 -0
  35. package/src/internal/timeline-internal.ts +110 -93
  36. package/src/internal/transaction-internal.ts +14 -5
  37. package/src/{internal/logger.ts → logger.ts} +2 -2
  38. package/src/react/index.ts +28 -46
  39. package/src/react-devtools/AtomIODevtools.tsx +107 -0
  40. package/src/react-devtools/StateEditor.tsx +73 -0
  41. package/src/react-devtools/TokenList.tsx +49 -0
  42. package/src/react-devtools/devtools.scss +130 -0
  43. package/src/react-devtools/index.ts +1 -0
  44. package/src/react-explorer/AtomIOExplorer.tsx +208 -0
  45. package/src/react-explorer/explorer-effects.ts +20 -0
  46. package/src/react-explorer/explorer-states.ts +224 -0
  47. package/src/react-explorer/index.ts +23 -0
  48. package/src/react-explorer/space-states.ts +73 -0
  49. package/src/react-explorer/view-states.ts +43 -0
  50. package/src/selector.ts +11 -11
  51. package/src/subscribe.ts +3 -3
  52. package/src/timeline.ts +3 -12
  53. package/src/transaction.ts +9 -4
  54. package/src/web-effects/index.ts +1 -0
  55. package/src/web-effects/storage.ts +30 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Reactive state graph for React, Preact, and vanilla",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,6 +9,8 @@
9
9
  "dist",
10
10
  "react/dist",
11
11
  "react/package.json",
12
+ "react-devtools/dist",
13
+ "react-devtools/package.json",
12
14
  "src"
13
15
  ],
14
16
  "exports": {
@@ -25,10 +27,17 @@
25
27
  "browser": "./react/dist/index.mjs",
26
28
  "import": "./react/dist/index.mjs",
27
29
  "require": "./react/dist/index.js"
30
+ },
31
+ "./react-devtools/package.json": "./react-devtools/package.json",
32
+ "./react-devtools": {
33
+ "types": "./react-devtools/dist/index.d.ts",
34
+ "browser": "./react-devtools/dist/index.mjs",
35
+ "import": "./react-devtools/dist/index.mjs",
36
+ "require": "./react-devtools/dist/index.js"
28
37
  }
29
38
  },
30
39
  "scripts": {
31
- "build": "tsup && cd react && tsup",
40
+ "build": "tsup && (cd react && tsup) && (cd react-devtools && tsup)",
32
41
  "lint": "eslint",
33
42
  "test": "vitest",
34
43
  "test:once": "vitest run"
@@ -46,21 +55,22 @@
46
55
  }
47
56
  },
48
57
  "dependencies": {
49
- "fp-ts": "2.14.0",
58
+ "fp-ts": "2.16.0",
50
59
  "hamt_plus": "1.0.2",
51
- "rxjs": "7.8.0"
60
+ "rxjs": "7.8.1"
52
61
  },
53
62
  "devDependencies": {
54
63
  "@testing-library/preact": "3.2.3",
55
64
  "@testing-library/react": "14.0.0",
56
65
  "@types/mock-fs": "4.13.1",
57
66
  "mock-fs": "5.2.0",
58
- "preact": "10.13.2",
67
+ "preact": "10.15.0",
59
68
  "react": "18.2.0",
60
69
  "react-dom": "18.2.0",
70
+ "react-router-dom": "6.11.2",
61
71
  "tsup": "6.7.0",
62
72
  "vite-tsconfig-paths": "4.2.0",
63
- "vitest": "0.30.1"
73
+ "vitest": "0.31.1"
64
74
  },
65
75
  "repository": {
66
76
  "type": "git",
@@ -1,22 +1,17 @@
1
- import Preact from 'preact/hooks';
2
- import React from 'react';
3
- import { __INTERNAL__, StateToken, ReadonlyValueToken } from 'atom.io';
1
+ import { StateToken, ReadonlySelectorToken, __INTERNAL__ } from 'atom.io';
4
2
 
5
3
  type Modifier<T> = (thing: T) => T;
6
4
 
7
- type AtomStoreReactConfig = {
8
- useState: typeof Preact.useState | typeof React.useState;
9
- useEffect: typeof Preact.useEffect | typeof React.useEffect;
10
- store?: __INTERNAL__.Store;
11
- };
12
- declare const composeStoreHooks: ({ useState, useEffect, store, }: AtomStoreReactConfig) => {
13
- useI: <T>(token: StateToken<T>) => (next: T | Modifier<T>) => void;
14
- useO: <T_1>(token: ReadonlyValueToken<T_1> | StateToken<T_1>) => T_1;
15
- useIO: <T_2>(token: StateToken<T_2>) => [T_2, (next: T_2 | Modifier<T_2>) => void];
16
- useStore: {
17
- <T_3>(token: StateToken<T_3>): [T_3, (next: T_3 | Modifier<T_3>) => void];
18
- <T_4>(token: ReadonlyValueToken<T_4>): T_4;
19
- };
5
+ 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];
20
9
  };
10
+ declare const composeStoreHooks: (store?: __INTERNAL__.Store) => StoreHooks;
11
+ declare const useI: <T>(token: StateToken<T>) => (next: T | Modifier<T>) => void;
12
+ declare const useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T;
13
+ declare const useIO: <T>(token: StateToken<T>) => [T, (next: T | Modifier<T>) => void];
14
+ declare function useStore<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void];
15
+ declare function useStore<T>(token: ReadonlySelectorToken<T>): T;
21
16
 
22
- export { AtomStoreReactConfig, composeStoreHooks };
17
+ export { StoreHooks, composeStoreHooks, useI, useIO, useO, useStore };
@@ -19,50 +19,41 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // ../src/react/index.ts
20
20
  var react_exports = {};
21
21
  __export(react_exports, {
22
- composeStoreHooks: () => composeStoreHooks
22
+ composeStoreHooks: () => composeStoreHooks,
23
+ useI: () => useI,
24
+ useIO: () => useIO,
25
+ useO: () => useO,
26
+ useStore: () => useStore
23
27
  });
24
28
  module.exports = __toCommonJS(react_exports);
29
+ var import_react = require("react");
25
30
  var import_atom = require("atom.io");
26
- var composeStoreHooks = ({
27
- useState,
28
- useEffect,
29
- store = import_atom.__INTERNAL__.IMPLICIT.STORE
30
- }) => {
31
- function useI(token) {
31
+ var composeStoreHooks = (store = import_atom.__INTERNAL__.IMPLICIT.STORE) => {
32
+ function useI2(token) {
32
33
  const updateState = (next) => (0, import_atom.setState)(token, next, store);
33
34
  return updateState;
34
35
  }
35
- function useO(token) {
36
- const state = import_atom.__INTERNAL__.withdraw(token, store);
37
- const initialValue = import_atom.__INTERNAL__.getState__INTERNAL(state, store);
38
- const [current, dispatch] = useState(initialValue);
39
- useEffect(() => {
40
- const unsubscribe = (0, import_atom.subscribe)(
41
- token,
42
- ({ newValue, oldValue }) => {
43
- if (oldValue !== newValue) {
44
- dispatch(newValue);
45
- }
46
- },
47
- store
48
- );
49
- return unsubscribe;
50
- }, []);
51
- return current;
36
+ function useO2(token) {
37
+ return (0, import_react.useSyncExternalStore)(
38
+ (observe) => (0, import_atom.subscribe)(token, observe, store),
39
+ () => (0, import_atom.getState)(token, store)
40
+ );
52
41
  }
53
- function useIO(token) {
54
- return [useO(token), useI(token)];
42
+ function useIO2(token) {
43
+ return [useO2(token), useI2(token)];
55
44
  }
56
- function useStore(token) {
57
- if (token.type === `readonly_selector`) {
58
- return useO(token);
59
- }
60
- return useIO(token);
61
- }
62
- return { useI, useO, useIO, useStore };
45
+ return { useI: useI2, useO: useO2, useIO: useIO2 };
63
46
  };
47
+ var { useI, useO, useIO } = composeStoreHooks();
48
+ function useStore(token) {
49
+ return token.type === `readonly_selector` ? useO(token) : useIO(token);
50
+ }
64
51
  // Annotate the CommonJS export names for ESM import in node:
65
52
  0 && (module.exports = {
66
- composeStoreHooks
53
+ composeStoreHooks,
54
+ useI,
55
+ useIO,
56
+ useO,
57
+ useStore
67
58
  });
68
59
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/index.ts"],"sourcesContent":["import type Preact from \"preact/hooks\"\n\nimport type React from \"react\"\n\nimport { subscribe, setState, __INTERNAL__ } from \"atom.io\"\nimport type { ReadonlyValueToken, StateToken } from \"atom.io\"\n\nimport type { Modifier } from \"~/packages/anvl/src/function\"\n\nexport type AtomStoreReactConfig = {\n useState: typeof Preact.useState | typeof React.useState\n useEffect: typeof Preact.useEffect | typeof React.useEffect\n store?: __INTERNAL__.Store\n}\n\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nexport const composeStoreHooks = ({\n useState,\n useEffect,\n store = __INTERNAL__.IMPLICIT.STORE,\n}: AtomStoreReactConfig) => {\n function useI<T>(token: StateToken<T>): (next: Modifier<T> | T) => void {\n const updateState = (next: Modifier<T> | T) => setState(token, next, store)\n return updateState\n }\n\n function useO<T>(token: ReadonlyValueToken<T> | StateToken<T>): T {\n const state = __INTERNAL__.withdraw(token, store)\n const initialValue = __INTERNAL__.getState__INTERNAL(state, store)\n const [current, dispatch] = useState(initialValue)\n useEffect(() => {\n const unsubscribe = subscribe(\n token,\n ({ newValue, oldValue }) => {\n if (oldValue !== newValue) {\n dispatch(newValue)\n }\n },\n store\n )\n return unsubscribe\n }, [])\n\n return current\n }\n\n function useIO<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void] {\n return [useO(token), useI(token)]\n }\n\n function useStore<T>(\n token: StateToken<T>\n ): [T, (next: Modifier<T> | T) => void]\n function useStore<T>(token: ReadonlyValueToken<T>): T\n function useStore<T>(\n token: ReadonlyValueToken<T> | StateToken<T>\n ): T | [T, (next: Modifier<T> | T) => void] {\n if (token.type === `readonly_selector`) {\n return useO(token)\n }\n return useIO(token)\n }\n return { useI, useO, useIO, useStore }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAkD;AAY3C,IAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA,QAAQ,yBAAa,SAAS;AAChC,MAA4B;AAC1B,WAAS,KAAQ,OAAuD;AACtE,UAAM,cAAc,CAAC,aAA0B,sBAAS,OAAO,MAAM,KAAK;AAC1E,WAAO;AAAA,EACT;AAEA,WAAS,KAAQ,OAAiD;AAChE,UAAM,QAAQ,yBAAa,SAAS,OAAO,KAAK;AAChD,UAAM,eAAe,yBAAa,mBAAmB,OAAO,KAAK;AACjE,UAAM,CAAC,SAAS,QAAQ,IAAI,SAAS,YAAY;AACjD,cAAU,MAAM;AACd,YAAM,kBAAc;AAAA,QAClB;AAAA,QACA,CAAC,EAAE,UAAU,SAAS,MAAM;AAC1B,cAAI,aAAa,UAAU;AACzB,qBAAS,QAAQ;AAAA,UACnB;AAAA,QACF;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAEL,WAAO;AAAA,EACT;AAEA,WAAS,MAAS,OAA4D;AAC5E,WAAO,CAAC,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AAAA,EAClC;AAMA,WAAS,SACP,OAC0C;AAC1C,QAAI,MAAM,SAAS,qBAAqB;AACtC,aAAO,KAAK,KAAK;AAAA,IACnB;AACA,WAAO,MAAM,KAAK;AAAA,EACpB;AACA,SAAO,EAAE,MAAM,MAAM,OAAO,SAAS;AACvC;","names":[]}
1
+ {"version":3,"sources":["../../src/react/index.ts"],"sourcesContent":["import { useSyncExternalStore } from \"react\"\n\nimport { subscribe, setState, __INTERNAL__, getState } from \"atom.io\"\nimport type { ReadonlySelectorToken, StateToken } from \"atom.io\"\n\nimport type { Modifier } from \"~/packages/anvl/src/function\"\n\nexport type StoreHooks = {\n useI: <T>(token: StateToken<T>) => (next: Modifier<T> | T) => void\n useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T\n useIO: <T>(token: StateToken<T>) => [T, (next: Modifier<T> | T) => void]\n}\n\nexport const composeStoreHooks = (\n store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE\n): StoreHooks => {\n function useI<T>(token: StateToken<T>): (next: Modifier<T> | T) => void {\n const updateState = (next: Modifier<T> | T) => setState(token, next, store)\n return updateState\n }\n\n function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T {\n return useSyncExternalStore<T>(\n (observe) => subscribe(token, observe, store),\n () => getState(token, store)\n )\n }\n\n function useIO<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void] {\n return [useO(token), useI(token)]\n }\n\n return { useI, useO, useIO }\n}\n\nexport const { useI, useO, useIO } = composeStoreHooks()\n\nexport function useStore<T>(\n token: StateToken<T>\n): [T, (next: Modifier<T> | T) => void]\nexport function useStore<T>(token: ReadonlySelectorToken<T>): T\nexport function useStore<T>(\n token: ReadonlySelectorToken<T> | 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,mBAAqC;AAErC,kBAA4D;AAWrD,IAAM,oBAAoB,CAC/B,QAA4B,yBAAa,SAAS,UACnC;AACf,WAASA,MAAQ,OAAuD;AACtE,UAAM,cAAc,CAAC,aAA0B,sBAAS,OAAO,MAAM,KAAK;AAC1E,WAAO;AAAA,EACT;AAEA,WAASC,MAAQ,OAAoD;AACnE,eAAO;AAAA,MACL,CAAC,gBAAY,uBAAU,OAAO,SAAS,KAAK;AAAA,MAC5C,UAAM,sBAAS,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF;AAEA,WAASC,OAAS,OAA4D;AAC5E,WAAO,CAACD,MAAK,KAAK,GAAGD,MAAK,KAAK,CAAC;AAAA,EAClC;AAEA,SAAO,EAAE,MAAAA,OAAM,MAAAC,OAAM,OAAAC,OAAM;AAC7B;AAEO,IAAM,EAAE,MAAM,MAAM,MAAM,IAAI,kBAAkB;AAMhD,SAAS,SACd,OAC0C;AAC1C,SAAO,MAAM,SAAS,sBAAsB,KAAK,KAAK,IAAI,MAAM,KAAK;AACvE;","names":["useI","useO","useIO"]}
@@ -1,44 +1,31 @@
1
1
  // ../src/react/index.ts
2
- import { subscribe, setState, __INTERNAL__ } from "atom.io";
3
- var composeStoreHooks = ({
4
- useState,
5
- useEffect,
6
- store = __INTERNAL__.IMPLICIT.STORE
7
- }) => {
8
- function useI(token) {
2
+ import { useSyncExternalStore } from "react";
3
+ import { subscribe, setState, __INTERNAL__, getState } from "atom.io";
4
+ var composeStoreHooks = (store = __INTERNAL__.IMPLICIT.STORE) => {
5
+ function useI2(token) {
9
6
  const updateState = (next) => setState(token, next, store);
10
7
  return updateState;
11
8
  }
12
- function useO(token) {
13
- const state = __INTERNAL__.withdraw(token, store);
14
- const initialValue = __INTERNAL__.getState__INTERNAL(state, store);
15
- const [current, dispatch] = useState(initialValue);
16
- useEffect(() => {
17
- const unsubscribe = subscribe(
18
- token,
19
- ({ newValue, oldValue }) => {
20
- if (oldValue !== newValue) {
21
- dispatch(newValue);
22
- }
23
- },
24
- store
25
- );
26
- return unsubscribe;
27
- }, []);
28
- return current;
9
+ function useO2(token) {
10
+ return useSyncExternalStore(
11
+ (observe) => subscribe(token, observe, store),
12
+ () => getState(token, store)
13
+ );
29
14
  }
30
- function useIO(token) {
31
- return [useO(token), useI(token)];
15
+ function useIO2(token) {
16
+ return [useO2(token), useI2(token)];
32
17
  }
33
- function useStore(token) {
34
- if (token.type === `readonly_selector`) {
35
- return useO(token);
36
- }
37
- return useIO(token);
38
- }
39
- return { useI, useO, useIO, useStore };
18
+ return { useI: useI2, useO: useO2, useIO: useIO2 };
40
19
  };
20
+ var { useI, useO, useIO } = composeStoreHooks();
21
+ function useStore(token) {
22
+ return token.type === `readonly_selector` ? useO(token) : useIO(token);
23
+ }
41
24
  export {
42
- composeStoreHooks
25
+ composeStoreHooks,
26
+ useI,
27
+ useIO,
28
+ useO,
29
+ useStore
43
30
  };
44
31
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/index.ts"],"sourcesContent":["import type Preact from \"preact/hooks\"\n\nimport type React from \"react\"\n\nimport { subscribe, setState, __INTERNAL__ } from \"atom.io\"\nimport type { ReadonlyValueToken, StateToken } from \"atom.io\"\n\nimport type { Modifier } from \"~/packages/anvl/src/function\"\n\nexport type AtomStoreReactConfig = {\n useState: typeof Preact.useState | typeof React.useState\n useEffect: typeof Preact.useEffect | typeof React.useEffect\n store?: __INTERNAL__.Store\n}\n\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nexport const composeStoreHooks = ({\n useState,\n useEffect,\n store = __INTERNAL__.IMPLICIT.STORE,\n}: AtomStoreReactConfig) => {\n function useI<T>(token: StateToken<T>): (next: Modifier<T> | T) => void {\n const updateState = (next: Modifier<T> | T) => setState(token, next, store)\n return updateState\n }\n\n function useO<T>(token: ReadonlyValueToken<T> | StateToken<T>): T {\n const state = __INTERNAL__.withdraw(token, store)\n const initialValue = __INTERNAL__.getState__INTERNAL(state, store)\n const [current, dispatch] = useState(initialValue)\n useEffect(() => {\n const unsubscribe = subscribe(\n token,\n ({ newValue, oldValue }) => {\n if (oldValue !== newValue) {\n dispatch(newValue)\n }\n },\n store\n )\n return unsubscribe\n }, [])\n\n return current\n }\n\n function useIO<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void] {\n return [useO(token), useI(token)]\n }\n\n function useStore<T>(\n token: StateToken<T>\n ): [T, (next: Modifier<T> | T) => void]\n function useStore<T>(token: ReadonlyValueToken<T>): T\n function useStore<T>(\n token: ReadonlyValueToken<T> | StateToken<T>\n ): T | [T, (next: Modifier<T> | T) => void] {\n if (token.type === `readonly_selector`) {\n return useO(token)\n }\n return useIO(token)\n }\n return { useI, useO, useIO, useStore }\n}\n"],"mappings":";AAIA,SAAS,WAAW,UAAU,oBAAoB;AAY3C,IAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA,QAAQ,aAAa,SAAS;AAChC,MAA4B;AAC1B,WAAS,KAAQ,OAAuD;AACtE,UAAM,cAAc,CAAC,SAA0B,SAAS,OAAO,MAAM,KAAK;AAC1E,WAAO;AAAA,EACT;AAEA,WAAS,KAAQ,OAAiD;AAChE,UAAM,QAAQ,aAAa,SAAS,OAAO,KAAK;AAChD,UAAM,eAAe,aAAa,mBAAmB,OAAO,KAAK;AACjE,UAAM,CAAC,SAAS,QAAQ,IAAI,SAAS,YAAY;AACjD,cAAU,MAAM;AACd,YAAM,cAAc;AAAA,QAClB;AAAA,QACA,CAAC,EAAE,UAAU,SAAS,MAAM;AAC1B,cAAI,aAAa,UAAU;AACzB,qBAAS,QAAQ;AAAA,UACnB;AAAA,QACF;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAEL,WAAO;AAAA,EACT;AAEA,WAAS,MAAS,OAA4D;AAC5E,WAAO,CAAC,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;AAAA,EAClC;AAMA,WAAS,SACP,OAC0C;AAC1C,QAAI,MAAM,SAAS,qBAAqB;AACtC,aAAO,KAAK,KAAK;AAAA,IACnB;AACA,WAAO,MAAM,KAAK;AAAA,EACpB;AACA,SAAO,EAAE,MAAM,MAAM,OAAO,SAAS;AACvC;","names":[]}
1
+ {"version":3,"sources":["../../src/react/index.ts"],"sourcesContent":["import { useSyncExternalStore } from \"react\"\n\nimport { subscribe, setState, __INTERNAL__, getState } from \"atom.io\"\nimport type { ReadonlySelectorToken, StateToken } from \"atom.io\"\n\nimport type { Modifier } from \"~/packages/anvl/src/function\"\n\nexport type StoreHooks = {\n useI: <T>(token: StateToken<T>) => (next: Modifier<T> | T) => void\n useO: <T>(token: ReadonlySelectorToken<T> | StateToken<T>) => T\n useIO: <T>(token: StateToken<T>) => [T, (next: Modifier<T> | T) => void]\n}\n\nexport const composeStoreHooks = (\n store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE\n): StoreHooks => {\n function useI<T>(token: StateToken<T>): (next: Modifier<T> | T) => void {\n const updateState = (next: Modifier<T> | T) => setState(token, next, store)\n return updateState\n }\n\n function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T {\n return useSyncExternalStore<T>(\n (observe) => subscribe(token, observe, store),\n () => getState(token, store)\n )\n }\n\n function useIO<T>(token: StateToken<T>): [T, (next: Modifier<T> | T) => void] {\n return [useO(token), useI(token)]\n }\n\n return { useI, useO, useIO }\n}\n\nexport const { useI, useO, useIO } = composeStoreHooks()\n\nexport function useStore<T>(\n token: StateToken<T>\n): [T, (next: Modifier<T> | T) => void]\nexport function useStore<T>(token: ReadonlySelectorToken<T>): T\nexport function useStore<T>(\n token: ReadonlySelectorToken<T> | StateToken<T>\n): T | [T, (next: Modifier<T> | T) => void] {\n return token.type === `readonly_selector` ? useO(token) : useIO(token)\n}\n"],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,WAAW,UAAU,cAAc,gBAAgB;AAWrD,IAAM,oBAAoB,CAC/B,QAA4B,aAAa,SAAS,UACnC;AACf,WAASA,MAAQ,OAAuD;AACtE,UAAM,cAAc,CAAC,SAA0B,SAAS,OAAO,MAAM,KAAK;AAC1E,WAAO;AAAA,EACT;AAEA,WAASC,MAAQ,OAAoD;AACnE,WAAO;AAAA,MACL,CAAC,YAAY,UAAU,OAAO,SAAS,KAAK;AAAA,MAC5C,MAAM,SAAS,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF;AAEA,WAASC,OAAS,OAA4D;AAC5E,WAAO,CAACD,MAAK,KAAK,GAAGD,MAAK,KAAK,CAAC;AAAA,EAClC;AAEA,SAAO,EAAE,MAAAA,OAAM,MAAAC,OAAM,OAAAC,OAAM;AAC7B;AAEO,IAAM,EAAE,MAAM,MAAM,MAAM,IAAI,kBAAkB;AAMhD,SAAS,SACd,OAC0C;AAC1C,SAAO,MAAM,SAAS,sBAAsB,KAAK,KAAK,IAAI,MAAM,KAAK;AACvE;","names":["useI","useO","useIO"]}
@@ -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 { StateToken, ReadonlySelectorToken } from 'atom.io';
3
+
4
+ type Modifier<T> = (thing: T) => T;
5
+
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];
10
+ };
11
+
12
+ declare const composeDevtools: (storeHooks: StoreHooks) => FC;
13
+ declare const AtomIODevtools: FC;
14
+
15
+ export { AtomIODevtools, composeDevtools };