atom.io 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/index.d.mts +27 -15
  2. package/dist/index.d.ts +27 -15
  3. package/dist/index.js +44 -24
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +44 -24
  6. package/dist/index.mjs.map +1 -1
  7. package/json/dist/index.d.mts +18 -0
  8. package/json/dist/index.d.ts +18 -0
  9. package/json/dist/index.js +51 -0
  10. package/json/dist/index.js.map +1 -0
  11. package/json/dist/index.mjs +15 -0
  12. package/json/dist/index.mjs.map +1 -0
  13. package/json/package.json +13 -13
  14. package/package.json +31 -12
  15. package/react/dist/index.d.mts +24 -0
  16. package/react/dist/index.d.ts +24 -0
  17. package/react/dist/index.js +87 -0
  18. package/react/dist/index.js.map +1 -0
  19. package/react/dist/index.mjs +45 -0
  20. package/react/dist/index.mjs.map +1 -0
  21. package/react/package.json +13 -13
  22. package/react-devtools/dist/index.css +26 -0
  23. package/react-devtools/dist/index.css.map +1 -0
  24. package/react-devtools/dist/index.d.mts +15 -0
  25. package/react-devtools/dist/index.d.ts +15 -0
  26. package/react-devtools/dist/index.js +2108 -0
  27. package/react-devtools/dist/index.js.map +1 -0
  28. package/react-devtools/dist/index.mjs +2080 -0
  29. package/react-devtools/dist/index.mjs.map +1 -0
  30. package/react-devtools/package.json +13 -13
  31. package/realtime/dist/index.d.mts +27 -0
  32. package/realtime/dist/index.d.ts +27 -0
  33. package/realtime/dist/index.js +191 -0
  34. package/realtime/dist/index.js.map +1 -0
  35. package/realtime/dist/index.mjs +152 -0
  36. package/realtime/dist/index.mjs.map +1 -0
  37. package/realtime/package.json +13 -13
  38. package/realtime-react/dist/index.d.mts +45 -0
  39. package/realtime-react/dist/index.d.ts +45 -0
  40. package/realtime-react/dist/index.js +217 -0
  41. package/realtime-react/dist/index.js.map +1 -0
  42. package/realtime-react/dist/index.mjs +172 -0
  43. package/realtime-react/dist/index.mjs.map +1 -0
  44. package/realtime-react/package.json +13 -13
  45. package/realtime-testing/dist/index.d.mts +49 -0
  46. package/realtime-testing/dist/index.d.ts +49 -0
  47. package/realtime-testing/dist/index.js +165 -0
  48. package/realtime-testing/dist/index.js.map +1 -0
  49. package/realtime-testing/dist/index.mjs +129 -0
  50. package/realtime-testing/dist/index.mjs.map +1 -0
  51. package/realtime-testing/package.json +15 -0
  52. package/src/atom.ts +16 -17
  53. package/src/index.ts +59 -59
  54. package/src/internal/atom-internal.ts +37 -37
  55. package/src/internal/families-internal.ts +115 -116
  56. package/src/internal/get.ts +83 -83
  57. package/src/internal/index.ts +1 -0
  58. package/src/internal/is-default.ts +17 -17
  59. package/src/internal/meta/attach-meta.ts +7 -7
  60. package/src/internal/meta/meta-state.ts +115 -115
  61. package/src/internal/operation.ts +93 -93
  62. package/src/internal/selector/create-read-write-selector.ts +47 -47
  63. package/src/internal/selector/create-readonly-selector.ts +38 -38
  64. package/src/internal/selector/lookup-selector-sources.ts +9 -9
  65. package/src/internal/selector/register-selector.ts +44 -44
  66. package/src/internal/selector/trace-selector-atoms.ts +30 -30
  67. package/src/internal/selector/update-selector-atoms.ts +25 -25
  68. package/src/internal/selector-internal.ts +38 -39
  69. package/src/internal/set.ts +78 -78
  70. package/src/internal/store.ts +119 -119
  71. package/src/internal/subject.ts +24 -0
  72. package/src/internal/subscribe-internal.ts +62 -62
  73. package/src/internal/time-travel-internal.ts +76 -76
  74. package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
  75. package/src/internal/timeline-internal.ts +81 -82
  76. package/src/internal/transaction/abort-transaction.ts +8 -8
  77. package/src/internal/transaction/apply-transaction.ts +41 -41
  78. package/src/internal/transaction/build-transaction.ts +28 -28
  79. package/src/internal/transaction/index.ts +7 -7
  80. package/src/internal/transaction/redo-transaction.ts +13 -13
  81. package/src/internal/transaction/undo-transaction.ts +13 -13
  82. package/src/internal/transaction-internal.ts +49 -49
  83. package/src/json/select-json.ts +12 -12
  84. package/src/logger.ts +30 -30
  85. package/src/react/store-context.tsx +5 -6
  86. package/src/react/store-hooks.ts +19 -20
  87. package/src/react-devtools/AtomIODevtools.tsx +85 -85
  88. package/src/react-devtools/StateEditor.tsx +54 -55
  89. package/src/react-devtools/TokenList.tsx +49 -45
  90. package/src/react-explorer/AtomIOExplorer.tsx +198 -187
  91. package/src/react-explorer/explorer-effects.ts +11 -11
  92. package/src/react-explorer/explorer-states.ts +186 -193
  93. package/src/react-explorer/index.ts +11 -11
  94. package/src/react-explorer/space-states.ts +48 -50
  95. package/src/react-explorer/view-states.ts +25 -25
  96. package/src/realtime/hook-composition/expose-family.ts +81 -81
  97. package/src/realtime/hook-composition/expose-single.ts +26 -26
  98. package/src/realtime/hook-composition/expose-timeline.ts +60 -0
  99. package/src/realtime/hook-composition/index.ts +2 -2
  100. package/src/realtime/hook-composition/receive-state.ts +18 -18
  101. package/src/realtime/hook-composition/receive-transaction.ts +8 -8
  102. package/src/realtime-react/realtime-context.tsx +18 -19
  103. package/src/realtime-react/realtime-hooks.ts +17 -17
  104. package/src/realtime-react/realtime-state.ts +4 -4
  105. package/src/realtime-react/use-pull-family-member.ts +16 -17
  106. package/src/realtime-react/use-pull-family.ts +14 -15
  107. package/src/realtime-react/use-pull.ts +13 -14
  108. package/src/realtime-react/use-push.ts +16 -17
  109. package/src/realtime-react/use-server-action.ts +22 -23
  110. package/src/realtime-testing/index.ts +1 -0
  111. package/src/realtime-testing/setup-realtime-test.tsx +159 -0
  112. package/src/selector.ts +26 -27
  113. package/src/silo.ts +38 -38
  114. package/src/subscribe.ts +68 -68
  115. package/src/timeline.ts +13 -13
  116. package/src/transaction.ts +28 -28
  117. package/src/web-effects/storage.ts +17 -17
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import * as Rx from 'rxjs';
2
1
  import { Hamt } from 'hamt_plus';
3
2
  import { Refinement } from 'fp-ts/lib/Refinement';
4
3
 
@@ -22,7 +21,7 @@ type Identified = {
22
21
  };
23
22
 
24
23
  declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
25
- type RelationType = (typeof RELATION_TYPES)[number];
24
+ type RelationType = typeof RELATION_TYPES[number];
26
25
  type RelationData<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> = {
27
26
  contents: JsonObj<string, CONTENT>;
28
27
  relations: JsonObj<string, string[]>;
@@ -85,10 +84,10 @@ interface Store {
85
84
  transactions: Hamt<Transaction<any>, string>;
86
85
  valueMap: Hamt<any, string>;
87
86
  subject: {
88
- atomCreation: Rx.Subject<AtomToken<unknown>>;
89
- selectorCreation: Rx.Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
90
- transactionCreation: Rx.Subject<TransactionToken<unknown>>;
91
- timelineCreation: Rx.Subject<TimelineToken>;
87
+ atomCreation: Subject<AtomToken<unknown>>;
88
+ selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
89
+ transactionCreation: Subject<TransactionToken<unknown>>;
90
+ timelineCreation: Subject<TimelineToken>;
92
91
  };
93
92
  operation: OperationProgress;
94
93
  transactionStatus: TransactionStatus<ƒn>;
@@ -127,7 +126,7 @@ type AtomFamilyOptions<T, K extends Serializable> = {
127
126
  type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
128
127
  key: string;
129
128
  type: `atom_family`;
130
- subject: Rx.Subject<AtomToken<T>>;
129
+ subject: Subject<AtomToken<T>>;
131
130
  };
132
131
  declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
133
132
 
@@ -135,7 +134,7 @@ type Atom<T> = {
135
134
  key: string;
136
135
  type: `atom`;
137
136
  family?: FamilyMetadata;
138
- subject: Rx.Subject<{
137
+ subject: Subject<{
139
138
  newValue: T;
140
139
  oldValue: T;
141
140
  }>;
@@ -229,7 +228,7 @@ type Selector<T> = {
229
228
  type: `selector`;
230
229
  family?: FamilyMetadata;
231
230
  install: (store: Store) => void;
232
- subject: Rx.Subject<{
231
+ subject: Subject<{
233
232
  newValue: T;
234
233
  oldValue: T;
235
234
  }>;
@@ -241,7 +240,7 @@ type ReadonlySelector<T> = {
241
240
  type: `readonly_selector`;
242
241
  family?: FamilyMetadata;
243
242
  install: (store: Store) => void;
244
- subject: Rx.Subject<{
243
+ subject: Subject<{
245
244
  newValue: T;
246
245
  oldValue: T;
247
246
  }>;
@@ -290,6 +289,16 @@ declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), s
290
289
  declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
291
290
  declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
292
291
 
292
+ type Subscriber<T> = (value: T) => void;
293
+ declare class Subject<T> {
294
+ subscribers: Subscriber<T>[];
295
+ subscribe(subscriber: Subscriber<T>): {
296
+ unsubscribe: () => void;
297
+ };
298
+ private unsubscribe;
299
+ next(value: T): void;
300
+ }
301
+
293
302
  declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
294
303
  declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
295
304
  declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
@@ -324,7 +333,7 @@ type Timeline = {
324
333
  selectorTime: number | null;
325
334
  transactionKey: string | null;
326
335
  install: (store: Store) => void;
327
- subject: Rx.Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
336
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
328
337
  };
329
338
  declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
330
339
 
@@ -332,7 +341,7 @@ type Transaction<ƒ extends ƒn> = {
332
341
  key: string;
333
342
  type: `transaction`;
334
343
  install: (store: Store) => void;
335
- subject: Rx.Subject<TransactionUpdate<ƒ>>;
344
+ subject: Subject<TransactionUpdate<ƒ>>;
336
345
  run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
337
346
  };
338
347
  declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
@@ -349,7 +358,7 @@ declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<
349
358
  declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
350
359
 
351
360
  declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
352
- type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
361
+ type TransactionPhase = typeof TRANSACTION_PHASES[number];
353
362
  type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
354
363
  phase: `applying` | `building`;
355
364
  time: number;
@@ -367,6 +376,8 @@ type index_ReadonlySelector<T> = ReadonlySelector<T>;
367
376
  type index_Selector<T> = Selector<T>;
368
377
  type index_Store = Store;
369
378
  type index_StoreCore = StoreCore;
379
+ type index_Subject<T> = Subject<T>;
380
+ declare const index_Subject: typeof Subject;
370
381
  declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
371
382
  type index_Timeline = Timeline;
372
383
  type index_TimelineAtomUpdate = TimelineAtomUpdate;
@@ -439,6 +450,7 @@ declare namespace index {
439
450
  index_Selector as Selector,
440
451
  index_Store as Store,
441
452
  index_StoreCore as StoreCore,
453
+ index_Subject as Subject,
442
454
  index_TRANSACTION_PHASES as TRANSACTION_PHASES,
443
455
  index_Timeline as Timeline,
444
456
  index_TimelineAtomUpdate as TimelineAtomUpdate,
@@ -532,12 +544,12 @@ type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
532
544
  type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
533
545
  key: string;
534
546
  type: `selector_family`;
535
- subject: Rx.Subject<SelectorToken<T>>;
547
+ subject: Subject<SelectorToken<T>>;
536
548
  };
537
549
  type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
538
550
  key: string;
539
551
  type: `readonly_selector_family`;
540
- subject: Rx.Subject<ReadonlySelectorToken<T>>;
552
+ subject: Subject<ReadonlySelectorToken<T>>;
541
553
  };
542
554
  declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
543
555
  declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as Rx from 'rxjs';
2
1
  import { Hamt } from 'hamt_plus';
3
2
  import { Refinement } from 'fp-ts/lib/Refinement';
4
3
 
@@ -22,7 +21,7 @@ type Identified = {
22
21
  };
23
22
 
24
23
  declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
25
- type RelationType = (typeof RELATION_TYPES)[number];
24
+ type RelationType = typeof RELATION_TYPES[number];
26
25
  type RelationData<CONTENT extends JsonObj | null = null, A extends string = `from`, B extends string = `to`> = {
27
26
  contents: JsonObj<string, CONTENT>;
28
27
  relations: JsonObj<string, string[]>;
@@ -85,10 +84,10 @@ interface Store {
85
84
  transactions: Hamt<Transaction<any>, string>;
86
85
  valueMap: Hamt<any, string>;
87
86
  subject: {
88
- atomCreation: Rx.Subject<AtomToken<unknown>>;
89
- selectorCreation: Rx.Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
90
- transactionCreation: Rx.Subject<TransactionToken<unknown>>;
91
- timelineCreation: Rx.Subject<TimelineToken>;
87
+ atomCreation: Subject<AtomToken<unknown>>;
88
+ selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
89
+ transactionCreation: Subject<TransactionToken<unknown>>;
90
+ timelineCreation: Subject<TimelineToken>;
92
91
  };
93
92
  operation: OperationProgress;
94
93
  transactionStatus: TransactionStatus<ƒn>;
@@ -127,7 +126,7 @@ type AtomFamilyOptions<T, K extends Serializable> = {
127
126
  type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
128
127
  key: string;
129
128
  type: `atom_family`;
130
- subject: Rx.Subject<AtomToken<T>>;
129
+ subject: Subject<AtomToken<T>>;
131
130
  };
132
131
  declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
133
132
 
@@ -135,7 +134,7 @@ type Atom<T> = {
135
134
  key: string;
136
135
  type: `atom`;
137
136
  family?: FamilyMetadata;
138
- subject: Rx.Subject<{
137
+ subject: Subject<{
139
138
  newValue: T;
140
139
  oldValue: T;
141
140
  }>;
@@ -229,7 +228,7 @@ type Selector<T> = {
229
228
  type: `selector`;
230
229
  family?: FamilyMetadata;
231
230
  install: (store: Store) => void;
232
- subject: Rx.Subject<{
231
+ subject: Subject<{
233
232
  newValue: T;
234
233
  oldValue: T;
235
234
  }>;
@@ -241,7 +240,7 @@ type ReadonlySelector<T> = {
241
240
  type: `readonly_selector`;
242
241
  family?: FamilyMetadata;
243
242
  install: (store: Store) => void;
244
- subject: Rx.Subject<{
243
+ subject: Subject<{
245
244
  newValue: T;
246
245
  oldValue: T;
247
246
  }>;
@@ -290,6 +289,16 @@ declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), s
290
289
  declare const setSelectorState: <T>(selector: Selector<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
291
290
  declare const setState__INTERNAL: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store?: Store) => void;
292
291
 
292
+ type Subscriber<T> = (value: T) => void;
293
+ declare class Subject<T> {
294
+ subscribers: Subscriber<T>[];
295
+ subscribe(subscriber: Subscriber<T>): {
296
+ unsubscribe: () => void;
297
+ };
298
+ private unsubscribe;
299
+ next(value: T): void;
300
+ }
301
+
293
302
  declare const prepareUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => StateUpdate<T>;
294
303
  declare const stowUpdate: <T>(state: Atom<T>, update: StateUpdate<T>, store: Store) => void;
295
304
  declare const emitUpdate: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, update: StateUpdate<T>, store: Store) => void;
@@ -324,7 +333,7 @@ type Timeline = {
324
333
  selectorTime: number | null;
325
334
  transactionKey: string | null;
326
335
  install: (store: Store) => void;
327
- subject: Rx.Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
336
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
328
337
  };
329
338
  declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
330
339
 
@@ -332,7 +341,7 @@ type Transaction<ƒ extends ƒn> = {
332
341
  key: string;
333
342
  type: `transaction`;
334
343
  install: (store: Store) => void;
335
- subject: Rx.Subject<TransactionUpdate<ƒ>>;
344
+ subject: Subject<TransactionUpdate<ƒ>>;
336
345
  run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
337
346
  };
338
347
  declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
@@ -349,7 +358,7 @@ declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<
349
358
  declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
350
359
 
351
360
  declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
352
- type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
361
+ type TransactionPhase = typeof TRANSACTION_PHASES[number];
353
362
  type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
354
363
  phase: `applying` | `building`;
355
364
  time: number;
@@ -367,6 +376,8 @@ type index_ReadonlySelector<T> = ReadonlySelector<T>;
367
376
  type index_Selector<T> = Selector<T>;
368
377
  type index_Store = Store;
369
378
  type index_StoreCore = StoreCore;
379
+ type index_Subject<T> = Subject<T>;
380
+ declare const index_Subject: typeof Subject;
370
381
  declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
371
382
  type index_Timeline = Timeline;
372
383
  type index_TimelineAtomUpdate = TimelineAtomUpdate;
@@ -439,6 +450,7 @@ declare namespace index {
439
450
  index_Selector as Selector,
440
451
  index_Store as Store,
441
452
  index_StoreCore as StoreCore,
453
+ index_Subject as Subject,
442
454
  index_TRANSACTION_PHASES as TRANSACTION_PHASES,
443
455
  index_Timeline as Timeline,
444
456
  index_TimelineAtomUpdate as TimelineAtomUpdate,
@@ -532,12 +544,12 @@ type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
532
544
  type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
533
545
  key: string;
534
546
  type: `selector_family`;
535
- subject: Rx.Subject<SelectorToken<T>>;
547
+ subject: Subject<SelectorToken<T>>;
536
548
  };
537
549
  type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
538
550
  key: string;
539
551
  type: `readonly_selector_family`;
540
- subject: Rx.Subject<ReadonlySelectorToken<T>>;
552
+ subject: Subject<ReadonlySelectorToken<T>>;
541
553
  };
542
554
  declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
543
555
  declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
package/dist/index.js CHANGED
@@ -89,6 +89,7 @@ var internal_exports = {};
89
89
  __export(internal_exports, {
90
90
  IMPLICIT: () => IMPLICIT,
91
91
  META: () => meta_exports,
92
+ Subject: () => Subject,
92
93
  TRANSACTION_PHASES: () => TRANSACTION_PHASES,
93
94
  abortTransaction: () => abortTransaction,
94
95
  applyTransaction: () => applyTransaction,
@@ -146,7 +147,6 @@ __export(internal_exports, {
146
147
 
147
148
  // src/internal/atom-internal.ts
148
149
  var import_hamt_plus5 = __toESM(require("hamt_plus"));
149
- var Rx3 = __toESM(require("rxjs"));
150
150
 
151
151
  // src/internal/get.ts
152
152
  var import_hamt_plus = __toESM(require("hamt_plus"));
@@ -207,7 +207,6 @@ var import_hamt_plus3 = __toESM(require("hamt_plus"));
207
207
 
208
208
  // src/internal/store.ts
209
209
  var import_hamt_plus2 = __toESM(require("hamt_plus"));
210
- var Rx = __toESM(require("rxjs"));
211
210
 
212
211
  // ../anvl/src/function/index.ts
213
212
  var doNothing = () => void 0;
@@ -674,10 +673,10 @@ var createStore = (name, store = null) => {
674
673
  timelines: import_hamt_plus2.default.make(),
675
674
  timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
676
675
  subject: __spreadValues({
677
- atomCreation: new Rx.Subject(),
678
- selectorCreation: new Rx.Subject(),
679
- transactionCreation: new Rx.Subject(),
680
- timelineCreation: new Rx.Subject()
676
+ atomCreation: new Subject(),
677
+ selectorCreation: new Subject(),
678
+ transactionCreation: new Subject(),
679
+ timelineCreation: new Subject()
681
680
  }, store == null ? void 0 : store.subject),
682
681
  operation: __spreadValues({
683
682
  open: false
@@ -695,7 +694,7 @@ var createStore = (name, store = null) => {
695
694
  })
696
695
  });
697
696
  store == null ? void 0 : store.atoms.forEach((atom2) => {
698
- const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Rx.Subject() });
697
+ const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
699
698
  copiedStore.atoms = import_hamt_plus2.default.set(atom2.key, copiedAtom, copiedStore.atoms);
700
699
  });
701
700
  store == null ? void 0 : store.readonlySelectors.forEach((selector2) => {
@@ -818,7 +817,6 @@ var hasKeyBeenUsed = (key, store = IMPLICIT.STORE) => {
818
817
 
819
818
  // src/internal/transaction-internal.ts
820
819
  var import_hamt_plus4 = __toESM(require("hamt_plus"));
821
- var Rx2 = __toESM(require("rxjs"));
822
820
  function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
823
821
  const newTransaction = {
824
822
  key: options.key,
@@ -843,7 +841,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
843
841
  }
844
842
  },
845
843
  install: (store2) => transaction__INTERNAL(options, store2),
846
- subject: new Rx2.Subject()
844
+ subject: new Subject()
847
845
  };
848
846
  const core = target(store);
849
847
  core.transactions = import_hamt_plus4.default.set(
@@ -868,7 +866,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
868
866
  );
869
867
  return deposit(core.atoms.get(options.key));
870
868
  }
871
- const subject = new Rx3.Subject();
869
+ const subject = new Subject();
872
870
  const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
873
871
  subject,
874
872
  type: `atom`
@@ -888,16 +886,13 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
888
886
  return token;
889
887
  }
890
888
 
891
- // src/internal/families-internal.ts
892
- var Rx4 = __toESM(require("rxjs"));
893
-
894
889
  // ../anvl/src/json/index.ts
895
890
  var import_function8 = require("fp-ts/function");
896
891
  var stringifyJson = (json) => JSON.stringify(json);
897
892
 
898
893
  // src/internal/families-internal.ts
899
894
  function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
900
- const subject = new Rx4.Subject();
895
+ const subject = new Subject();
901
896
  return Object.assign(
902
897
  (key) => {
903
898
  var _a;
@@ -926,7 +921,7 @@ function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
926
921
  }
927
922
  function readonlySelectorFamily__INTERNAL(options, store) {
928
923
  const core = target(store);
929
- const subject = new Rx4.Subject();
924
+ const subject = new Subject();
930
925
  return Object.assign(
931
926
  (key) => {
932
927
  const subKey = stringifyJson(key);
@@ -958,7 +953,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
958
953
  return readonlySelectorFamily__INTERNAL(options, store);
959
954
  }
960
955
  const core = target(store);
961
- const subject = new Rx4.Subject();
956
+ const subject = new Subject();
962
957
  return Object.assign(
963
958
  (key) => {
964
959
  const subKey = stringifyJson(key);
@@ -1106,10 +1101,9 @@ var import_hamt_plus9 = __toESM(require("hamt_plus"));
1106
1101
 
1107
1102
  // src/internal/selector/create-read-write-selector.ts
1108
1103
  var import_hamt_plus6 = __toESM(require("hamt_plus"));
1109
- var Rx5 = __toESM(require("rxjs"));
1110
1104
  var createReadWriteSelector = (options, family, store, core) => {
1111
1105
  var _a;
1112
- const subject = new Rx5.Subject();
1106
+ const subject = new Subject();
1113
1107
  const { get, set } = registerSelector(options.key, store);
1114
1108
  const getSelf = () => {
1115
1109
  const value = options.get({ get });
@@ -1149,7 +1143,6 @@ var createReadWriteSelector = (options, family, store, core) => {
1149
1143
 
1150
1144
  // src/internal/selector/create-readonly-selector.ts
1151
1145
  var import_hamt_plus8 = __toESM(require("hamt_plus"));
1152
- var Rx6 = __toESM(require("rxjs"));
1153
1146
 
1154
1147
  // src/internal/selector/lookup-selector-sources.ts
1155
1148
  var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
@@ -1326,7 +1319,7 @@ var registerSelector = (selectorKey, store = IMPLICIT.STORE) => ({
1326
1319
  // src/internal/selector/create-readonly-selector.ts
1327
1320
  var createReadonlySelector = (options, family, store, core) => {
1328
1321
  var _a;
1329
- const subject = new Rx6.Subject();
1322
+ const subject = new Subject();
1330
1323
  const { get } = registerSelector(options.key, store);
1331
1324
  const getSelf = () => {
1332
1325
  const value = options.get({ get });
@@ -1370,6 +1363,29 @@ function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
1370
1363
  return createReadWriteSelector(options, family, store, core);
1371
1364
  }
1372
1365
 
1366
+ // src/internal/subject.ts
1367
+ var Subject = class {
1368
+ constructor() {
1369
+ this.subscribers = [];
1370
+ }
1371
+ subscribe(subscriber) {
1372
+ this.subscribers.push(subscriber);
1373
+ const unsubscribe = () => this.unsubscribe(subscriber);
1374
+ return { unsubscribe };
1375
+ }
1376
+ unsubscribe(subscriber) {
1377
+ const subscriberIndex = this.subscribers.indexOf(subscriber);
1378
+ if (subscriberIndex !== -1) {
1379
+ this.subscribers.splice(subscriberIndex, 1);
1380
+ }
1381
+ }
1382
+ next(value) {
1383
+ for (const subscriber of this.subscribers) {
1384
+ subscriber(value);
1385
+ }
1386
+ }
1387
+ };
1388
+
1373
1389
  // src/internal/subscribe-internal.ts
1374
1390
  var prepareUpdate = (state, store) => {
1375
1391
  const oldValue = recallState(state, store);
@@ -1509,7 +1525,6 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1509
1525
 
1510
1526
  // src/internal/timeline-internal.ts
1511
1527
  var import_hamt_plus10 = __toESM(require("hamt_plus"));
1512
- var Rx7 = __toESM(require("rxjs"));
1513
1528
 
1514
1529
  // src/internal/timeline/add-atom-to-timeline.ts
1515
1530
  var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
@@ -1535,6 +1550,11 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1535
1550
  if (tl.timeTraveling === false) {
1536
1551
  if (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {
1537
1552
  const mostRecentUpdate = tl.history.at(-1);
1553
+ if (mostRecentUpdate === void 0) {
1554
+ throw new Error(
1555
+ `Timeline "${tl.key}" has a selectorTime, but no history. This is most likely a bug in AtomIO.`
1556
+ );
1557
+ }
1538
1558
  if (mostRecentUpdate.type === `selector_update`) {
1539
1559
  tl.subject.next(mostRecentUpdate);
1540
1560
  }
@@ -1652,7 +1672,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
1652
1672
  }, data), {
1653
1673
  history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
1654
1674
  install: (store2) => timeline__INTERNAL(options, store2, tl),
1655
- subject: new Rx7.Subject()
1675
+ subject: new Subject()
1656
1676
  });
1657
1677
  const core = target(store);
1658
1678
  for (const tokenOrFamily of options.atoms) {
@@ -1956,10 +1976,10 @@ var timeline = (options) => {
1956
1976
  return timeline__INTERNAL(options);
1957
1977
  };
1958
1978
  var redo = (token) => {
1959
- return redo__INTERNAL(token, IMPLICIT.STORE);
1979
+ redo__INTERNAL(token, IMPLICIT.STORE);
1960
1980
  };
1961
1981
  var undo = (token) => {
1962
- return undo__INTERNAL(token, IMPLICIT.STORE);
1982
+ undo__INTERNAL(token, IMPLICIT.STORE);
1963
1983
  };
1964
1984
 
1965
1985
  // src/transaction.ts