atom.io 0.6.5 → 0.6.7

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 (72) hide show
  1. package/README.md +32 -78
  2. package/dist/index.d.mts +11 -43
  3. package/dist/index.d.ts +11 -43
  4. package/dist/index.js +111 -291
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +108 -278
  7. package/dist/index.mjs.map +1 -1
  8. package/introspection/dist/index.d.mts +273 -0
  9. package/introspection/dist/index.d.ts +273 -0
  10. package/introspection/dist/index.js +350 -0
  11. package/introspection/dist/index.js.map +1 -0
  12. package/introspection/dist/index.mjs +327 -0
  13. package/introspection/dist/index.mjs.map +1 -0
  14. package/introspection/package.json +15 -0
  15. package/package.json +22 -12
  16. package/react-devtools/dist/index.css +22 -5
  17. package/react-devtools/dist/index.css.map +1 -1
  18. package/react-devtools/dist/index.d.mts +347 -10
  19. package/react-devtools/dist/index.d.ts +347 -10
  20. package/react-devtools/dist/index.js +2743 -696
  21. package/react-devtools/dist/index.js.map +1 -1
  22. package/react-devtools/dist/index.mjs +2739 -701
  23. package/react-devtools/dist/index.mjs.map +1 -1
  24. package/src/internal/atom-internal.ts +5 -6
  25. package/src/internal/get.ts +7 -9
  26. package/src/internal/index.ts +0 -1
  27. package/src/internal/operation.ts +15 -21
  28. package/src/internal/selector/create-read-write-selector.ts +8 -4
  29. package/src/internal/selector/create-readonly-selector.ts +1 -7
  30. package/src/internal/selector-internal.ts +1 -3
  31. package/src/internal/set.ts +1 -4
  32. package/src/internal/store.ts +22 -24
  33. package/src/internal/subscribe-internal.ts +7 -1
  34. package/src/internal/time-travel-internal.ts +2 -0
  35. package/src/internal/timeline/add-atom-to-timeline.ts +11 -12
  36. package/src/internal/timeline-internal.ts +6 -4
  37. package/src/internal/transaction/apply-transaction.ts +9 -6
  38. package/src/internal/transaction/build-transaction.ts +6 -6
  39. package/src/internal/transaction-internal.ts +1 -7
  40. package/src/introspection/attach-atom-index.ts +73 -0
  41. package/src/introspection/attach-introspection-states.ts +42 -0
  42. package/src/introspection/attach-selector-index.ts +77 -0
  43. package/src/introspection/attach-timeline-family.ts +59 -0
  44. package/src/introspection/attach-timeline-index.ts +36 -0
  45. package/src/introspection/attach-transaction-index.ts +38 -0
  46. package/src/introspection/attach-transaction-logs.ts +40 -0
  47. package/src/introspection/index.ts +20 -0
  48. package/src/react-devtools/AtomIODevtools.tsx +97 -97
  49. package/src/react-devtools/Button.tsx +24 -0
  50. package/src/react-devtools/StateEditor.tsx +14 -16
  51. package/src/react-devtools/StateIndex.tsx +153 -0
  52. package/src/react-devtools/TimelineIndex.tsx +92 -0
  53. package/src/react-devtools/TransactionIndex.tsx +70 -0
  54. package/src/react-devtools/Updates.tsx +145 -0
  55. package/src/react-devtools/devtools.scss +196 -15
  56. package/src/react-devtools/index.ts +71 -0
  57. package/src/react-explorer/AtomIOExplorer.tsx +3 -4
  58. package/src/react-explorer/explorer-states.ts +1 -1
  59. package/src/react-explorer/space-states.ts +3 -1
  60. package/src/react-explorer/view-states.ts +0 -2
  61. package/realtime-testing/dist/index.d.mts +0 -49
  62. package/realtime-testing/dist/index.d.ts +0 -49
  63. package/realtime-testing/dist/index.js +0 -165
  64. package/realtime-testing/dist/index.js.map +0 -1
  65. package/realtime-testing/dist/index.mjs +0 -129
  66. package/realtime-testing/dist/index.mjs.map +0 -1
  67. package/src/internal/meta/attach-meta.ts +0 -17
  68. package/src/internal/meta/index.ts +0 -4
  69. package/src/internal/meta/meta-state.ts +0 -135
  70. package/src/internal/meta/meta-timelines.ts +0 -1
  71. package/src/internal/meta/meta-transactions.ts +0 -1
  72. package/src/react-devtools/TokenList.tsx +0 -61
package/README.md CHANGED
@@ -1,78 +1,32 @@
1
- ## features
2
- - [x] atoms and selectors
3
- - [x] implicit store
4
- - [x] readonly selectors
5
- - [x] settable selectors
6
- - [x] "tokens" safely expose atoms and selectors
7
- - [x] give atoms and selectors separate types with a common base
8
- - [x] utility function to pass logger to your store
9
- - [x] selector memoization
10
- - [x] atom and selector families
11
- - [x] atom effects
12
- - [x] transactions
13
- - [x] async effects
14
- - [x] atom default as function
15
- - [x] check whether an atom is "default" (never set)
16
- - [x] customizable logging
17
- - [x] subscribe to transactions
18
- - [x] timelines
19
- - [x] subscribe to families
20
-
21
- # atom.io
22
- ## upcoming features
23
- - [ ] suppressor: ({oldValue, newValue}) => boolean
24
- - [ ] resettable atoms
25
- - [ ] resettable selectors
26
-
27
- ## documentation
28
- - [ ] document atom and selector families
29
- - [ ] document atom and selector
30
- - [ ] document transactions
31
-
32
- # src/internal/meta
33
- - [x] subscribe to creation of atom tokens
34
- - [x] subscribe to creation of selector tokens
35
- - [x] subscribe to creation of readonly selector tokens
36
- - [ ] reimplement state indices as selectors
37
- - [ ] subscribe to creation of transaction tokens
38
- - [ ] subscribe to creation of timeline tokens
39
- - [ ] subscribe to changes in store configuration
40
-
41
- # /react-devtools
42
- - [ ]
43
-
44
- # /react
45
- ## features
46
- - [x] useStore
47
- - [x] useI, useO, useIO
48
- - [ ] useTimeline
49
- - [ ] useStoreIndex
50
- - [ ] useTransactionIO
51
-
52
- # /realtime
53
- - [x] expose single atom and selector
54
- - [x] expose atom family and selector family
55
- - [ ] receive single atom and selector
56
- - [ ] receive atom family and selector family
57
- - [x] receive transaction params, run transaction
58
- - [ ] assess transaction impact (active subscriptions influenced by transaction)
59
- - [ ] return transaction impact as timeline event
60
- - [ ] identity-based exposure and receipt
61
- - [ ] expose selector as atom
62
-
63
- # /react-realtime
64
- example: what's in the box? (options: green apple, green banana, red apple, red banana)
65
- - no player gets to see what's in the box
66
- - player 1 can see the color of the item in the box
67
- - a register must be kept allocating "subscription permissions" per player
68
- - sometimes permissions may refer to "true" or "global" state; sometimes to state that is "virtual" or "local" to the player
69
- - player 2 can see the type of the item in the box
70
- - atom<`${string}____${string}`> boxItem
71
- - selector boxItemColor
72
- - selector boxItemType
73
- -
74
- -
75
-
76
- # /web-fx
77
- ## features
78
- - [ ] localStorage and sessionStorage effects
1
+ <hr>
2
+
3
+ <div align="center">
4
+ <img alt="corners logo" src="https://raw.githubusercontent.com/jeremybanka/wayforge/main/packages/atom.io/assets/logo.png"/>
5
+ </div>
6
+
7
+ <br>
8
+
9
+ <p align="center">
10
+ <a href="https://bundlephobia.com/result?p=atom.io">
11
+ <img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/atom.io?style=for-the-badge&labelColor=333">
12
+ </a>
13
+ <a aria-label="Types" href="https://www.npmjs.com/package/atom.io">
14
+ <img alt="Types" src="https://img.shields.io/npm/types/atom.io?style=for-the-badge&labelColor=333">
15
+ </a>
16
+ <a aria-label="Build status" href="https://github.com/jeremybanka/wayforge/actions/workflows/integration.yml">
17
+ <img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/jeremybanka/wayforge/integration.yml?branch=main&style=for-the-badge&labelColor=333">
18
+ </a>
19
+ <a aria-label="NPM version" href="https://www.npmjs.com/package/atom.io">
20
+ <img alt="NPM Version" src="https://img.shields.io/npm/v/atom.io?style=for-the-badge&labelColor=333">
21
+ </a>
22
+ </p>
23
+
24
+ ```shell
25
+ npm i atom.io
26
+ ```
27
+ ```shell
28
+ pnpm add atom.io
29
+ ```
30
+ <hr>
31
+
32
+ Reactive state graph for node and the browser inspired by [Recoil](https://recoiljs.org/).
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { Hamt } from 'hamt_plus';
2
- import { Refinement } from 'fp-ts/lib/Refinement';
1
+ import { Refinement } from 'fp-ts/Refinement';
3
2
 
4
3
  type ƒn = (...parameters: any[]) => any;
5
4
 
@@ -71,23 +70,24 @@ declare class Join<CONTENT extends JsonObj | null = null, A extends string = `fr
71
70
 
72
71
  type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
73
72
  interface Store {
74
- atoms: Hamt<Atom<any>, string>;
73
+ atoms: Map<string, Atom<any>>;
75
74
  atomsThatAreDefault: Set<string>;
76
- readonlySelectors: Hamt<ReadonlySelector<any>, string>;
75
+ readonlySelectors: Map<string, ReadonlySelector<any>>;
77
76
  selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
78
77
  selectorGraph: Join<{
79
78
  source: string;
80
79
  }>;
81
- selectors: Hamt<Selector<any>, string>;
80
+ selectors: Map<string, Selector<any>>;
82
81
  timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
83
- timelines: Hamt<Timeline, string>;
84
- transactions: Hamt<Transaction<any>, string>;
85
- valueMap: Hamt<any, string>;
82
+ timelines: Map<string, Timeline>;
83
+ transactions: Map<string, Transaction<any>>;
84
+ valueMap: Map<string, any>;
86
85
  subject: {
87
86
  atomCreation: Subject<AtomToken<unknown>>;
88
87
  selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
89
- transactionCreation: Subject<TransactionToken<unknown>>;
88
+ transactionCreation: Subject<TransactionToken<ƒn>>;
90
89
  timelineCreation: Subject<TimelineToken>;
90
+ operationStatus: Subject<OperationProgress>;
91
91
  };
92
92
  operation: OperationProgress;
93
93
  transactionStatus: TransactionStatus<ƒn>;
@@ -169,43 +169,12 @@ declare const markAtomAsDefault: (key: string, store?: Store) => void;
169
169
  declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
170
170
  declare const isSelectorDefault: (key: string, store?: Store) => boolean;
171
171
 
172
- type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, Token | {
173
- key: string;
174
- familyMembers: Record<string, Token>;
175
- }>;
176
- type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
177
- type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
178
- declare const attachMetaAtoms: (store?: Store) => ReadonlySelectorToken<AtomTokenIndex>;
179
- declare const attachMetaSelectors: (store?: Store) => ReadonlySelectorToken<SelectorTokenIndex>;
180
-
181
- declare const attachMetaState: (store?: Store) => {
182
- atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>;
183
- selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>;
184
- };
185
-
186
- type index$1_AtomTokenIndex = AtomTokenIndex;
187
- type index$1_SelectorTokenIndex = SelectorTokenIndex;
188
- type index$1_StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = StateTokenIndex<Token>;
189
- declare const index$1_attachMetaAtoms: typeof attachMetaAtoms;
190
- declare const index$1_attachMetaSelectors: typeof attachMetaSelectors;
191
- declare const index$1_attachMetaState: typeof attachMetaState;
192
- declare namespace index$1 {
193
- export {
194
- index$1_AtomTokenIndex as AtomTokenIndex,
195
- index$1_SelectorTokenIndex as SelectorTokenIndex,
196
- index$1_StateTokenIndex as StateTokenIndex,
197
- index$1_attachMetaAtoms as attachMetaAtoms,
198
- index$1_attachMetaSelectors as attachMetaSelectors,
199
- index$1_attachMetaState as attachMetaState,
200
- };
201
- }
202
-
203
172
  type OperationProgress = {
204
173
  open: false;
205
174
  } | {
206
175
  open: true;
207
176
  done: Set<string>;
208
- prev: Hamt<any, string>;
177
+ prev: Map<string, any>;
209
178
  time: number;
210
179
  token: StateToken<any>;
211
180
  };
@@ -333,7 +302,7 @@ type Timeline = {
333
302
  selectorTime: number | null;
334
303
  transactionKey: string | null;
335
304
  install: (store: Store) => void;
336
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
305
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
337
306
  };
338
307
  declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
339
308
 
@@ -444,7 +413,6 @@ declare namespace index {
444
413
  export {
445
414
  index_Atom as Atom,
446
415
  index_IMPLICIT as IMPLICIT,
447
- index$1 as META,
448
416
  index_OperationProgress as OperationProgress,
449
417
  index_ReadonlySelector as ReadonlySelector,
450
418
  index_Selector as Selector,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { Hamt } from 'hamt_plus';
2
- import { Refinement } from 'fp-ts/lib/Refinement';
1
+ import { Refinement } from 'fp-ts/Refinement';
3
2
 
4
3
  type ƒn = (...parameters: any[]) => any;
5
4
 
@@ -71,23 +70,24 @@ declare class Join<CONTENT extends JsonObj | null = null, A extends string = `fr
71
70
 
72
71
  type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
73
72
  interface Store {
74
- atoms: Hamt<Atom<any>, string>;
73
+ atoms: Map<string, Atom<any>>;
75
74
  atomsThatAreDefault: Set<string>;
76
- readonlySelectors: Hamt<ReadonlySelector<any>, string>;
75
+ readonlySelectors: Map<string, ReadonlySelector<any>>;
77
76
  selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
78
77
  selectorGraph: Join<{
79
78
  source: string;
80
79
  }>;
81
- selectors: Hamt<Selector<any>, string>;
80
+ selectors: Map<string, Selector<any>>;
82
81
  timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
83
- timelines: Hamt<Timeline, string>;
84
- transactions: Hamt<Transaction<any>, string>;
85
- valueMap: Hamt<any, string>;
82
+ timelines: Map<string, Timeline>;
83
+ transactions: Map<string, Transaction<any>>;
84
+ valueMap: Map<string, any>;
86
85
  subject: {
87
86
  atomCreation: Subject<AtomToken<unknown>>;
88
87
  selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
89
- transactionCreation: Subject<TransactionToken<unknown>>;
88
+ transactionCreation: Subject<TransactionToken<ƒn>>;
90
89
  timelineCreation: Subject<TimelineToken>;
90
+ operationStatus: Subject<OperationProgress>;
91
91
  };
92
92
  operation: OperationProgress;
93
93
  transactionStatus: TransactionStatus<ƒn>;
@@ -169,43 +169,12 @@ declare const markAtomAsDefault: (key: string, store?: Store) => void;
169
169
  declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
170
170
  declare const isSelectorDefault: (key: string, store?: Store) => boolean;
171
171
 
172
- type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, Token | {
173
- key: string;
174
- familyMembers: Record<string, Token>;
175
- }>;
176
- type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
177
- type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
178
- declare const attachMetaAtoms: (store?: Store) => ReadonlySelectorToken<AtomTokenIndex>;
179
- declare const attachMetaSelectors: (store?: Store) => ReadonlySelectorToken<SelectorTokenIndex>;
180
-
181
- declare const attachMetaState: (store?: Store) => {
182
- atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>;
183
- selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>;
184
- };
185
-
186
- type index$1_AtomTokenIndex = AtomTokenIndex;
187
- type index$1_SelectorTokenIndex = SelectorTokenIndex;
188
- type index$1_StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = StateTokenIndex<Token>;
189
- declare const index$1_attachMetaAtoms: typeof attachMetaAtoms;
190
- declare const index$1_attachMetaSelectors: typeof attachMetaSelectors;
191
- declare const index$1_attachMetaState: typeof attachMetaState;
192
- declare namespace index$1 {
193
- export {
194
- index$1_AtomTokenIndex as AtomTokenIndex,
195
- index$1_SelectorTokenIndex as SelectorTokenIndex,
196
- index$1_StateTokenIndex as StateTokenIndex,
197
- index$1_attachMetaAtoms as attachMetaAtoms,
198
- index$1_attachMetaSelectors as attachMetaSelectors,
199
- index$1_attachMetaState as attachMetaState,
200
- };
201
- }
202
-
203
172
  type OperationProgress = {
204
173
  open: false;
205
174
  } | {
206
175
  open: true;
207
176
  done: Set<string>;
208
- prev: Hamt<any, string>;
177
+ prev: Map<string, any>;
209
178
  time: number;
210
179
  token: StateToken<any>;
211
180
  };
@@ -333,7 +302,7 @@ type Timeline = {
333
302
  selectorTime: number | null;
334
303
  transactionKey: string | null;
335
304
  install: (store: Store) => void;
336
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
305
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
337
306
  };
338
307
  declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
339
308
 
@@ -444,7 +413,6 @@ declare namespace index {
444
413
  export {
445
414
  index_Atom as Atom,
446
415
  index_IMPLICIT as IMPLICIT,
447
- index$1 as META,
448
416
  index_OperationProgress as OperationProgress,
449
417
  index_ReadonlySelector as ReadonlySelector,
450
418
  index_Selector as Selector,