atom.io 0.5.0 → 0.6.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.
- 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.map +1 -1
- 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/dist/index.d.mts
CHANGED
|
@@ -80,9 +80,8 @@ interface Store {
|
|
|
80
80
|
source: string;
|
|
81
81
|
}>;
|
|
82
82
|
selectors: Hamt<Selector<any>, string>;
|
|
83
|
-
timelines: Hamt<Timeline, string>;
|
|
84
83
|
timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
|
|
85
|
-
|
|
84
|
+
timelines: Hamt<Timeline, string>;
|
|
86
85
|
transactions: Hamt<Transaction<any>, string>;
|
|
87
86
|
valueMap: Hamt<any, string>;
|
|
88
87
|
subject: {
|
|
@@ -99,7 +98,7 @@ interface Store {
|
|
|
99
98
|
logger__INTERNAL: Logger;
|
|
100
99
|
};
|
|
101
100
|
}
|
|
102
|
-
declare const createStore: (name: string) => Store;
|
|
101
|
+
declare const createStore: (name: string, store?: Store | null) => Store;
|
|
103
102
|
declare const IMPLICIT: {
|
|
104
103
|
STORE_INTERNAL: Store | undefined;
|
|
105
104
|
readonly STORE: Store;
|
|
@@ -157,6 +156,7 @@ declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Sele
|
|
|
157
156
|
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | null;
|
|
158
157
|
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends ƒn ? T : never> | null;
|
|
159
158
|
declare function withdraw<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T> | null;
|
|
159
|
+
declare function withdraw<T>(token: TimelineToken, store: Store): Timeline | null;
|
|
160
160
|
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
161
161
|
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
162
162
|
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
@@ -224,31 +224,11 @@ declare const storeSelector: (selector: Selector<any>, store?: Store) => void;
|
|
|
224
224
|
declare const storeReadonlySelector: (selector: ReadonlySelector<any>, store?: Store) => void;
|
|
225
225
|
declare const hasKeyBeenUsed: (key: string, store?: Store) => boolean;
|
|
226
226
|
|
|
227
|
-
type Transactors = {
|
|
228
|
-
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
229
|
-
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
230
|
-
};
|
|
231
|
-
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
232
|
-
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
233
|
-
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
234
|
-
type TransactionOptions<ƒ extends ƒn> = {
|
|
235
|
-
key: string;
|
|
236
|
-
do: Write<ƒ>;
|
|
237
|
-
};
|
|
238
|
-
type Transaction<ƒ extends ƒn> = {
|
|
239
|
-
key: string;
|
|
240
|
-
type: `transaction`;
|
|
241
|
-
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
242
|
-
subject: Rx.Subject<TransactionUpdate<ƒ>>;
|
|
243
|
-
};
|
|
244
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
245
|
-
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
246
|
-
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
247
|
-
|
|
248
227
|
type Selector<T> = {
|
|
249
228
|
key: string;
|
|
250
229
|
type: `selector`;
|
|
251
230
|
family?: FamilyMetadata;
|
|
231
|
+
install: (store: Store) => void;
|
|
252
232
|
subject: Rx.Subject<{
|
|
253
233
|
newValue: T;
|
|
254
234
|
oldValue: T;
|
|
@@ -260,19 +240,50 @@ type ReadonlySelector<T> = {
|
|
|
260
240
|
key: string;
|
|
261
241
|
type: `readonly_selector`;
|
|
262
242
|
family?: FamilyMetadata;
|
|
243
|
+
install: (store: Store) => void;
|
|
263
244
|
subject: Rx.Subject<{
|
|
264
245
|
newValue: T;
|
|
265
246
|
oldValue: T;
|
|
266
247
|
}>;
|
|
267
248
|
get: () => T;
|
|
268
249
|
};
|
|
250
|
+
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
251
|
+
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
252
|
+
|
|
269
253
|
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>)[];
|
|
254
|
+
|
|
255
|
+
type TransactionToken<_> = {
|
|
256
|
+
key: string;
|
|
257
|
+
type: `transaction`;
|
|
258
|
+
__brand?: _;
|
|
259
|
+
};
|
|
260
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
261
|
+
key: string;
|
|
262
|
+
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
263
|
+
params: Parameters<ƒ>;
|
|
264
|
+
output: ReturnType<ƒ>;
|
|
265
|
+
};
|
|
266
|
+
type Transactors = {
|
|
267
|
+
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
268
|
+
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
269
|
+
};
|
|
270
|
+
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
271
|
+
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
272
|
+
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
273
|
+
type TransactionOptions<ƒ extends ƒn> = {
|
|
274
|
+
key: string;
|
|
275
|
+
do: Write<ƒ>;
|
|
276
|
+
};
|
|
277
|
+
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
278
|
+
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
279
|
+
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
280
|
+
|
|
281
|
+
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
282
|
+
|
|
270
283
|
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
271
284
|
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
285
|
+
|
|
272
286
|
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
273
|
-
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
274
|
-
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
275
|
-
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
276
287
|
|
|
277
288
|
declare const evictDownStream: <T>(state: Atom<T>, store?: Store) => void;
|
|
278
289
|
declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
@@ -289,62 +300,68 @@ declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>
|
|
|
289
300
|
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
290
301
|
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
291
302
|
|
|
292
|
-
type
|
|
303
|
+
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
293
304
|
key: string;
|
|
294
|
-
type: `timeline`;
|
|
295
|
-
next: () => void;
|
|
296
|
-
prev: () => void;
|
|
297
|
-
};
|
|
298
|
-
type TimelineAtomUpdate = KeyedStateUpdate<unknown> & {
|
|
299
305
|
type: `atom_update`;
|
|
306
|
+
timestamp: number;
|
|
300
307
|
};
|
|
301
308
|
type TimelineSelectorUpdate = {
|
|
302
309
|
key: string;
|
|
303
310
|
type: `selector_update`;
|
|
304
|
-
|
|
311
|
+
timestamp: number;
|
|
312
|
+
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
305
313
|
};
|
|
306
314
|
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
315
|
+
key: string;
|
|
307
316
|
type: `transaction_update`;
|
|
317
|
+
timestamp: number;
|
|
308
318
|
};
|
|
309
|
-
type
|
|
319
|
+
type Timeline = {
|
|
320
|
+
key: string;
|
|
310
321
|
at: number;
|
|
311
322
|
timeTraveling: boolean;
|
|
312
|
-
history:
|
|
323
|
+
history: TimelineUpdate[];
|
|
313
324
|
selectorTime: number | null;
|
|
314
325
|
transactionKey: string | null;
|
|
326
|
+
install: (store: Store) => void;
|
|
327
|
+
subject: Rx.Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
|
|
315
328
|
};
|
|
316
|
-
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store): TimelineToken;
|
|
329
|
+
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
317
330
|
|
|
318
|
-
|
|
319
|
-
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
320
|
-
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
321
|
-
key: string;
|
|
322
|
-
};
|
|
323
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
331
|
+
type Transaction<ƒ extends ƒn> = {
|
|
324
332
|
key: string;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
type: `transaction`;
|
|
334
|
+
install: (store: Store) => void;
|
|
335
|
+
subject: Rx.Subject<TransactionUpdate<ƒ>>;
|
|
336
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
328
337
|
};
|
|
338
|
+
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
339
|
+
declare const target: (store?: Store) => StoreCore;
|
|
340
|
+
|
|
341
|
+
declare const abortTransaction: (store: Store) => void;
|
|
342
|
+
|
|
343
|
+
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
344
|
+
|
|
345
|
+
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
346
|
+
|
|
347
|
+
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
348
|
+
|
|
349
|
+
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
350
|
+
|
|
351
|
+
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
352
|
+
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
329
353
|
type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
330
354
|
phase: `applying` | `building`;
|
|
355
|
+
time: number;
|
|
331
356
|
core: StoreCore;
|
|
332
357
|
};
|
|
333
358
|
type TransactionIdle = {
|
|
334
359
|
phase: `idle`;
|
|
335
360
|
};
|
|
336
361
|
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
337
|
-
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
338
|
-
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
339
|
-
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
340
|
-
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
341
|
-
declare const abortTransaction: (store: Store) => void;
|
|
342
|
-
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
343
|
-
declare const target: (store?: Store) => StoreCore;
|
|
344
362
|
|
|
345
363
|
type index_Atom<T> = Atom<T>;
|
|
346
364
|
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
347
|
-
type index_KeyedStateUpdate<T> = KeyedStateUpdate<T>;
|
|
348
365
|
type index_OperationProgress = OperationProgress;
|
|
349
366
|
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
350
367
|
type index_Selector<T> = Selector<T>;
|
|
@@ -353,13 +370,12 @@ type index_StoreCore = StoreCore;
|
|
|
353
370
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
354
371
|
type index_Timeline = Timeline;
|
|
355
372
|
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
356
|
-
type index_TimelineData = TimelineData;
|
|
357
373
|
type index_TimelineSelectorUpdate = TimelineSelectorUpdate;
|
|
358
374
|
type index_TimelineTransactionUpdate = TimelineTransactionUpdate;
|
|
375
|
+
type index_Transaction<ƒ extends ƒn> = Transaction<ƒ>;
|
|
359
376
|
type index_TransactionIdle = TransactionIdle;
|
|
360
377
|
type index_TransactionPhase = TransactionPhase;
|
|
361
378
|
type index_TransactionStatus<ƒ extends ƒn> = TransactionStatus<ƒ>;
|
|
362
|
-
type index_TransactionUpdate<ƒ extends ƒn> = TransactionUpdate<ƒ>;
|
|
363
379
|
type index_TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdateInProgress<ƒ>;
|
|
364
380
|
declare const index_abortTransaction: typeof abortTransaction;
|
|
365
381
|
declare const index_applyTransaction: typeof applyTransaction;
|
|
@@ -417,7 +433,6 @@ declare namespace index {
|
|
|
417
433
|
export {
|
|
418
434
|
index_Atom as Atom,
|
|
419
435
|
index_IMPLICIT as IMPLICIT,
|
|
420
|
-
index_KeyedStateUpdate as KeyedStateUpdate,
|
|
421
436
|
index$1 as META,
|
|
422
437
|
index_OperationProgress as OperationProgress,
|
|
423
438
|
index_ReadonlySelector as ReadonlySelector,
|
|
@@ -427,13 +442,12 @@ declare namespace index {
|
|
|
427
442
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
428
443
|
index_Timeline as Timeline,
|
|
429
444
|
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
430
|
-
index_TimelineData as TimelineData,
|
|
431
445
|
index_TimelineSelectorUpdate as TimelineSelectorUpdate,
|
|
432
446
|
index_TimelineTransactionUpdate as TimelineTransactionUpdate,
|
|
447
|
+
index_Transaction as Transaction,
|
|
433
448
|
index_TransactionIdle as TransactionIdle,
|
|
434
449
|
index_TransactionPhase as TransactionPhase,
|
|
435
450
|
index_TransactionStatus as TransactionStatus,
|
|
436
|
-
index_TransactionUpdate as TransactionUpdate,
|
|
437
451
|
index_TransactionUpdateInProgress as TransactionUpdateInProgress,
|
|
438
452
|
index_abortTransaction as abortTransaction,
|
|
439
453
|
index_applyTransaction as applyTransaction,
|
|
@@ -529,7 +543,7 @@ declare function selectorFamily<T, K extends Serializable>(options: SelectorFami
|
|
|
529
543
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
530
544
|
|
|
531
545
|
type Silo = ReturnType<typeof silo>;
|
|
532
|
-
declare const silo: (name: string) => {
|
|
546
|
+
declare const silo: (name: string, fromStore?: Store | null) => {
|
|
533
547
|
store: Store;
|
|
534
548
|
atom: typeof atom;
|
|
535
549
|
atomFamily: typeof atomFamily;
|
|
@@ -540,16 +554,22 @@ declare const silo: (name: string) => {
|
|
|
540
554
|
getState: typeof getState;
|
|
541
555
|
setState: typeof setState;
|
|
542
556
|
subscribe: typeof subscribe;
|
|
557
|
+
undo: typeof undo;
|
|
558
|
+
redo: typeof redo;
|
|
543
559
|
};
|
|
544
560
|
|
|
545
561
|
type StateUpdate<T> = {
|
|
546
562
|
newValue: T;
|
|
547
563
|
oldValue: T;
|
|
548
564
|
};
|
|
565
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
566
|
+
key: string;
|
|
567
|
+
};
|
|
549
568
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
550
569
|
declare const subscribe: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, store?: Store) => (() => void);
|
|
551
570
|
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
552
571
|
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, store?: Store) => (() => void);
|
|
572
|
+
declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate) => void, store?: Store) => (() => void);
|
|
553
573
|
|
|
554
574
|
type TimelineToken = {
|
|
555
575
|
key: string;
|
|
@@ -559,6 +579,7 @@ type TimelineOptions = {
|
|
|
559
579
|
key: string;
|
|
560
580
|
atoms: (AtomFamily<any> | AtomToken<any>)[];
|
|
561
581
|
};
|
|
582
|
+
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
562
583
|
declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
563
584
|
declare const redo: (token: TimelineToken) => void;
|
|
564
585
|
declare const undo: (token: TimelineToken) => void;
|
|
@@ -586,13 +607,8 @@ type FamilyMetadata = {
|
|
|
586
607
|
key: string;
|
|
587
608
|
subKey: string;
|
|
588
609
|
};
|
|
589
|
-
type TransactionToken<_> = {
|
|
590
|
-
key: string;
|
|
591
|
-
type: `transaction`;
|
|
592
|
-
__brand?: _;
|
|
593
|
-
};
|
|
594
610
|
declare const getState: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Store) => T;
|
|
595
611
|
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
596
612
|
declare const isDefault: (token: ReadonlySelectorToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
597
613
|
|
|
598
|
-
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Serializable, Silo, StateToken, StateUpdate, Store, TimelineOptions, TimelineToken,
|
|
614
|
+
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, KeyedStateUpdate, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Serializable, Silo, StateToken, StateUpdate, Store, TimelineOptions, TimelineToken, TimelineUpdate, TransactionIO, TransactionOptions, TransactionToken, TransactionUpdate, TransactionUpdateHandler, Transactors, UpdateHandler, Write, index as __INTERNAL__, atom, atomFamily, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState, silo, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo, useLogger };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,9 +80,8 @@ interface Store {
|
|
|
80
80
|
source: string;
|
|
81
81
|
}>;
|
|
82
82
|
selectors: Hamt<Selector<any>, string>;
|
|
83
|
-
timelines: Hamt<Timeline, string>;
|
|
84
83
|
timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
|
|
85
|
-
|
|
84
|
+
timelines: Hamt<Timeline, string>;
|
|
86
85
|
transactions: Hamt<Transaction<any>, string>;
|
|
87
86
|
valueMap: Hamt<any, string>;
|
|
88
87
|
subject: {
|
|
@@ -99,7 +98,7 @@ interface Store {
|
|
|
99
98
|
logger__INTERNAL: Logger;
|
|
100
99
|
};
|
|
101
100
|
}
|
|
102
|
-
declare const createStore: (name: string) => Store;
|
|
101
|
+
declare const createStore: (name: string, store?: Store | null) => Store;
|
|
103
102
|
declare const IMPLICIT: {
|
|
104
103
|
STORE_INTERNAL: Store | undefined;
|
|
105
104
|
readonly STORE: Store;
|
|
@@ -157,6 +156,7 @@ declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Sele
|
|
|
157
156
|
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | null;
|
|
158
157
|
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends ƒn ? T : never> | null;
|
|
159
158
|
declare function withdraw<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T> | null;
|
|
159
|
+
declare function withdraw<T>(token: TimelineToken, store: Store): Timeline | null;
|
|
160
160
|
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
161
161
|
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
162
162
|
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
@@ -224,31 +224,11 @@ declare const storeSelector: (selector: Selector<any>, store?: Store) => void;
|
|
|
224
224
|
declare const storeReadonlySelector: (selector: ReadonlySelector<any>, store?: Store) => void;
|
|
225
225
|
declare const hasKeyBeenUsed: (key: string, store?: Store) => boolean;
|
|
226
226
|
|
|
227
|
-
type Transactors = {
|
|
228
|
-
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
229
|
-
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
230
|
-
};
|
|
231
|
-
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
232
|
-
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
233
|
-
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
234
|
-
type TransactionOptions<ƒ extends ƒn> = {
|
|
235
|
-
key: string;
|
|
236
|
-
do: Write<ƒ>;
|
|
237
|
-
};
|
|
238
|
-
type Transaction<ƒ extends ƒn> = {
|
|
239
|
-
key: string;
|
|
240
|
-
type: `transaction`;
|
|
241
|
-
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
242
|
-
subject: Rx.Subject<TransactionUpdate<ƒ>>;
|
|
243
|
-
};
|
|
244
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
245
|
-
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
246
|
-
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
247
|
-
|
|
248
227
|
type Selector<T> = {
|
|
249
228
|
key: string;
|
|
250
229
|
type: `selector`;
|
|
251
230
|
family?: FamilyMetadata;
|
|
231
|
+
install: (store: Store) => void;
|
|
252
232
|
subject: Rx.Subject<{
|
|
253
233
|
newValue: T;
|
|
254
234
|
oldValue: T;
|
|
@@ -260,19 +240,50 @@ type ReadonlySelector<T> = {
|
|
|
260
240
|
key: string;
|
|
261
241
|
type: `readonly_selector`;
|
|
262
242
|
family?: FamilyMetadata;
|
|
243
|
+
install: (store: Store) => void;
|
|
263
244
|
subject: Rx.Subject<{
|
|
264
245
|
newValue: T;
|
|
265
246
|
oldValue: T;
|
|
266
247
|
}>;
|
|
267
248
|
get: () => T;
|
|
268
249
|
};
|
|
250
|
+
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
251
|
+
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
252
|
+
|
|
269
253
|
declare const lookupSelectorSources: (key: string, store: Store) => (AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>)[];
|
|
254
|
+
|
|
255
|
+
type TransactionToken<_> = {
|
|
256
|
+
key: string;
|
|
257
|
+
type: `transaction`;
|
|
258
|
+
__brand?: _;
|
|
259
|
+
};
|
|
260
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
261
|
+
key: string;
|
|
262
|
+
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
263
|
+
params: Parameters<ƒ>;
|
|
264
|
+
output: ReturnType<ƒ>;
|
|
265
|
+
};
|
|
266
|
+
type Transactors = {
|
|
267
|
+
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
268
|
+
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
269
|
+
};
|
|
270
|
+
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
271
|
+
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
272
|
+
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
273
|
+
type TransactionOptions<ƒ extends ƒn> = {
|
|
274
|
+
key: string;
|
|
275
|
+
do: Write<ƒ>;
|
|
276
|
+
};
|
|
277
|
+
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
278
|
+
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
279
|
+
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
280
|
+
|
|
281
|
+
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
282
|
+
|
|
270
283
|
declare const traceSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => AtomToken<unknown>[];
|
|
271
284
|
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomToken<unknown>[];
|
|
285
|
+
|
|
272
286
|
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
273
|
-
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
274
|
-
declare function selector__INTERNAL<T>(options: SelectorOptions<T>, family?: FamilyMetadata, store?: Store): SelectorToken<T>;
|
|
275
|
-
declare function selector__INTERNAL<T>(options: ReadonlySelectorOptions<T>, family?: FamilyMetadata, store?: Store): ReadonlySelectorToken<T>;
|
|
276
287
|
|
|
277
288
|
declare const evictDownStream: <T>(state: Atom<T>, store?: Store) => void;
|
|
278
289
|
declare const setAtomState: <T>(atom: Atom<T>, next: T | ((oldValue: T) => T), store?: Store) => void;
|
|
@@ -289,62 +300,68 @@ declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>
|
|
|
289
300
|
declare const redo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
290
301
|
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
291
302
|
|
|
292
|
-
type
|
|
303
|
+
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
293
304
|
key: string;
|
|
294
|
-
type: `timeline`;
|
|
295
|
-
next: () => void;
|
|
296
|
-
prev: () => void;
|
|
297
|
-
};
|
|
298
|
-
type TimelineAtomUpdate = KeyedStateUpdate<unknown> & {
|
|
299
305
|
type: `atom_update`;
|
|
306
|
+
timestamp: number;
|
|
300
307
|
};
|
|
301
308
|
type TimelineSelectorUpdate = {
|
|
302
309
|
key: string;
|
|
303
310
|
type: `selector_update`;
|
|
304
|
-
|
|
311
|
+
timestamp: number;
|
|
312
|
+
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
305
313
|
};
|
|
306
314
|
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
315
|
+
key: string;
|
|
307
316
|
type: `transaction_update`;
|
|
317
|
+
timestamp: number;
|
|
308
318
|
};
|
|
309
|
-
type
|
|
319
|
+
type Timeline = {
|
|
320
|
+
key: string;
|
|
310
321
|
at: number;
|
|
311
322
|
timeTraveling: boolean;
|
|
312
|
-
history:
|
|
323
|
+
history: TimelineUpdate[];
|
|
313
324
|
selectorTime: number | null;
|
|
314
325
|
transactionKey: string | null;
|
|
326
|
+
install: (store: Store) => void;
|
|
327
|
+
subject: Rx.Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate>;
|
|
315
328
|
};
|
|
316
|
-
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store): TimelineToken;
|
|
329
|
+
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
317
330
|
|
|
318
|
-
|
|
319
|
-
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
320
|
-
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
321
|
-
key: string;
|
|
322
|
-
};
|
|
323
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
331
|
+
type Transaction<ƒ extends ƒn> = {
|
|
324
332
|
key: string;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
type: `transaction`;
|
|
334
|
+
install: (store: Store) => void;
|
|
335
|
+
subject: Rx.Subject<TransactionUpdate<ƒ>>;
|
|
336
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
328
337
|
};
|
|
338
|
+
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
339
|
+
declare const target: (store?: Store) => StoreCore;
|
|
340
|
+
|
|
341
|
+
declare const abortTransaction: (store: Store) => void;
|
|
342
|
+
|
|
343
|
+
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
344
|
+
|
|
345
|
+
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
346
|
+
|
|
347
|
+
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
348
|
+
|
|
349
|
+
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
350
|
+
|
|
351
|
+
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
352
|
+
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
329
353
|
type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
330
354
|
phase: `applying` | `building`;
|
|
355
|
+
time: number;
|
|
331
356
|
core: StoreCore;
|
|
332
357
|
};
|
|
333
358
|
type TransactionIdle = {
|
|
334
359
|
phase: `idle`;
|
|
335
360
|
};
|
|
336
361
|
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
337
|
-
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
338
|
-
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
339
|
-
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
340
|
-
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
341
|
-
declare const abortTransaction: (store: Store) => void;
|
|
342
|
-
declare function transaction__INTERNAL<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store?: Store): TransactionToken<ƒ>;
|
|
343
|
-
declare const target: (store?: Store) => StoreCore;
|
|
344
362
|
|
|
345
363
|
type index_Atom<T> = Atom<T>;
|
|
346
364
|
declare const index_IMPLICIT: typeof IMPLICIT;
|
|
347
|
-
type index_KeyedStateUpdate<T> = KeyedStateUpdate<T>;
|
|
348
365
|
type index_OperationProgress = OperationProgress;
|
|
349
366
|
type index_ReadonlySelector<T> = ReadonlySelector<T>;
|
|
350
367
|
type index_Selector<T> = Selector<T>;
|
|
@@ -353,13 +370,12 @@ type index_StoreCore = StoreCore;
|
|
|
353
370
|
declare const index_TRANSACTION_PHASES: typeof TRANSACTION_PHASES;
|
|
354
371
|
type index_Timeline = Timeline;
|
|
355
372
|
type index_TimelineAtomUpdate = TimelineAtomUpdate;
|
|
356
|
-
type index_TimelineData = TimelineData;
|
|
357
373
|
type index_TimelineSelectorUpdate = TimelineSelectorUpdate;
|
|
358
374
|
type index_TimelineTransactionUpdate = TimelineTransactionUpdate;
|
|
375
|
+
type index_Transaction<ƒ extends ƒn> = Transaction<ƒ>;
|
|
359
376
|
type index_TransactionIdle = TransactionIdle;
|
|
360
377
|
type index_TransactionPhase = TransactionPhase;
|
|
361
378
|
type index_TransactionStatus<ƒ extends ƒn> = TransactionStatus<ƒ>;
|
|
362
|
-
type index_TransactionUpdate<ƒ extends ƒn> = TransactionUpdate<ƒ>;
|
|
363
379
|
type index_TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdateInProgress<ƒ>;
|
|
364
380
|
declare const index_abortTransaction: typeof abortTransaction;
|
|
365
381
|
declare const index_applyTransaction: typeof applyTransaction;
|
|
@@ -417,7 +433,6 @@ declare namespace index {
|
|
|
417
433
|
export {
|
|
418
434
|
index_Atom as Atom,
|
|
419
435
|
index_IMPLICIT as IMPLICIT,
|
|
420
|
-
index_KeyedStateUpdate as KeyedStateUpdate,
|
|
421
436
|
index$1 as META,
|
|
422
437
|
index_OperationProgress as OperationProgress,
|
|
423
438
|
index_ReadonlySelector as ReadonlySelector,
|
|
@@ -427,13 +442,12 @@ declare namespace index {
|
|
|
427
442
|
index_TRANSACTION_PHASES as TRANSACTION_PHASES,
|
|
428
443
|
index_Timeline as Timeline,
|
|
429
444
|
index_TimelineAtomUpdate as TimelineAtomUpdate,
|
|
430
|
-
index_TimelineData as TimelineData,
|
|
431
445
|
index_TimelineSelectorUpdate as TimelineSelectorUpdate,
|
|
432
446
|
index_TimelineTransactionUpdate as TimelineTransactionUpdate,
|
|
447
|
+
index_Transaction as Transaction,
|
|
433
448
|
index_TransactionIdle as TransactionIdle,
|
|
434
449
|
index_TransactionPhase as TransactionPhase,
|
|
435
450
|
index_TransactionStatus as TransactionStatus,
|
|
436
|
-
index_TransactionUpdate as TransactionUpdate,
|
|
437
451
|
index_TransactionUpdateInProgress as TransactionUpdateInProgress,
|
|
438
452
|
index_abortTransaction as abortTransaction,
|
|
439
453
|
index_applyTransaction as applyTransaction,
|
|
@@ -529,7 +543,7 @@ declare function selectorFamily<T, K extends Serializable>(options: SelectorFami
|
|
|
529
543
|
declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
530
544
|
|
|
531
545
|
type Silo = ReturnType<typeof silo>;
|
|
532
|
-
declare const silo: (name: string) => {
|
|
546
|
+
declare const silo: (name: string, fromStore?: Store | null) => {
|
|
533
547
|
store: Store;
|
|
534
548
|
atom: typeof atom;
|
|
535
549
|
atomFamily: typeof atomFamily;
|
|
@@ -540,16 +554,22 @@ declare const silo: (name: string) => {
|
|
|
540
554
|
getState: typeof getState;
|
|
541
555
|
setState: typeof setState;
|
|
542
556
|
subscribe: typeof subscribe;
|
|
557
|
+
undo: typeof undo;
|
|
558
|
+
redo: typeof redo;
|
|
543
559
|
};
|
|
544
560
|
|
|
545
561
|
type StateUpdate<T> = {
|
|
546
562
|
newValue: T;
|
|
547
563
|
oldValue: T;
|
|
548
564
|
};
|
|
565
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
566
|
+
key: string;
|
|
567
|
+
};
|
|
549
568
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
550
569
|
declare const subscribe: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, store?: Store) => (() => void);
|
|
551
570
|
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
552
571
|
declare const subscribeToTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, store?: Store) => (() => void);
|
|
572
|
+
declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate) => void, store?: Store) => (() => void);
|
|
553
573
|
|
|
554
574
|
type TimelineToken = {
|
|
555
575
|
key: string;
|
|
@@ -559,6 +579,7 @@ type TimelineOptions = {
|
|
|
559
579
|
key: string;
|
|
560
580
|
atoms: (AtomFamily<any> | AtomToken<any>)[];
|
|
561
581
|
};
|
|
582
|
+
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
562
583
|
declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
563
584
|
declare const redo: (token: TimelineToken) => void;
|
|
564
585
|
declare const undo: (token: TimelineToken) => void;
|
|
@@ -586,13 +607,8 @@ type FamilyMetadata = {
|
|
|
586
607
|
key: string;
|
|
587
608
|
subKey: string;
|
|
588
609
|
};
|
|
589
|
-
type TransactionToken<_> = {
|
|
590
|
-
key: string;
|
|
591
|
-
type: `transaction`;
|
|
592
|
-
__brand?: _;
|
|
593
|
-
};
|
|
594
610
|
declare const getState: <T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Store) => T;
|
|
595
611
|
declare const setState: <T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store) => void;
|
|
596
612
|
declare const isDefault: (token: ReadonlySelectorToken<unknown> | StateToken<unknown>, store?: Store) => boolean;
|
|
597
613
|
|
|
598
|
-
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Serializable, Silo, StateToken, StateUpdate, Store, TimelineOptions, TimelineToken,
|
|
614
|
+
export { AtomEffect, AtomFamily, AtomFamilyOptions, AtomOptions, AtomToken, Effectors, FamilyMetadata, KeyedStateUpdate, LOG_LEVELS, Logger, Read, ReadonlySelectorFamily, ReadonlySelectorFamilyOptions, ReadonlySelectorOptions, ReadonlySelectorToken, ReadonlyTransactors, SelectorFamily, SelectorFamilyOptions, SelectorOptions, SelectorToken, Serializable, Silo, StateToken, StateUpdate, Store, TimelineOptions, TimelineToken, TimelineUpdate, TransactionIO, TransactionOptions, TransactionToken, TransactionUpdate, TransactionUpdateHandler, Transactors, UpdateHandler, Write, index as __INTERNAL__, atom, atomFamily, getState, isDefault, redo, runTransaction, selector, selectorFamily, setLogLevel, setState, silo, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo, useLogger };
|