@flurryx/store 1.0.0 → 1.1.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.cjs +550 -324
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -14
- package/dist/index.d.ts +76 -14
- package/dist/index.js +540 -315
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -67,6 +67,8 @@ type StoreSnapshot<TData extends StoreDataShape<TData>, TKey extends StoreKey<TD
|
|
|
67
67
|
}>;
|
|
68
68
|
/** Delivery status of a broker message: `"pending"` → `"acknowledged"` or `"dead-letter"`. */
|
|
69
69
|
type StoreMessageStatus = "pending" | "acknowledged" | "dead-letter";
|
|
70
|
+
/** Error message thrown when `restoreResource()` receives a key that is not a valid store key. */
|
|
71
|
+
declare const INVALID_STORE_KEY_ERROR = "Invalid store key";
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Persisted broker message record stored in the active message channel.
|
|
@@ -256,7 +258,7 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
256
258
|
/**
|
|
257
259
|
* Re-executes previously published channel message id(s).
|
|
258
260
|
*
|
|
259
|
-
* Unlike `
|
|
261
|
+
* Unlike `restoreStoreAt(...)`, replay goes back through the broker/consumer path,
|
|
260
262
|
* so it can mutate the store again, truncate future history after time
|
|
261
263
|
* travel, and record new acknowledged history entries.
|
|
262
264
|
*/
|
|
@@ -266,7 +268,19 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
266
268
|
*
|
|
267
269
|
* This navigates snapshots only and does not re-run any message.
|
|
268
270
|
*/
|
|
269
|
-
|
|
271
|
+
restoreStoreAt: StoreHistory<TData>["restoreStoreAt"];
|
|
272
|
+
/**
|
|
273
|
+
* Restores a single store key to its state at a specific history index.
|
|
274
|
+
*
|
|
275
|
+
* Unlike `restoreStoreAt(index)` which restores the full snapshot, this method
|
|
276
|
+
* only restores the specified key while leaving other keys unaffected.
|
|
277
|
+
* This is snapshot navigation only. It does not publish or acknowledge any
|
|
278
|
+
* message and does not create a new history entry.
|
|
279
|
+
*
|
|
280
|
+
* @param key - The store key to restore.
|
|
281
|
+
* @param index - Optional history index. Defaults to the current index.
|
|
282
|
+
*/
|
|
283
|
+
restoreResource: StoreHistory<TData>["restoreResource"];
|
|
270
284
|
/** Moves one step backward in the recorded snapshot history when possible. */
|
|
271
285
|
undo: StoreHistory<TData>["undo"];
|
|
272
286
|
/** Moves one step forward in the recorded snapshot history when possible. */
|
|
@@ -293,7 +307,7 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
293
307
|
replayDeadLetter: StoreHistory<TData>["replayDeadLetter"];
|
|
294
308
|
/** Attempts to replay all current dead-letter messages once. */
|
|
295
309
|
replayDeadLetters: StoreHistory<TData>["replayDeadLetters"];
|
|
296
|
-
/** Returns the currently restored snapshot index used by `
|
|
310
|
+
/** Returns the currently restored snapshot index used by `restoreStoreAt`, `undo`, and `redo`. */
|
|
297
311
|
getCurrentIndex: StoreHistory<TData>["getCurrentIndex"];
|
|
298
312
|
/** Merges a single entity into a keyed slot and sets its status to `'Success'`. */
|
|
299
313
|
updateKeyedOne<K extends StoreKey<TData>>(key: K, resourceKey: KeyedResourceKey, entity: unknown): void;
|
|
@@ -306,6 +320,14 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
306
320
|
* @returns A cleanup function that removes the listener.
|
|
307
321
|
*/
|
|
308
322
|
onUpdate<K extends StoreKey<TData>>(key: K, callback: (state: TData[K], previousState: TData[K]) => void): () => void;
|
|
323
|
+
/** Reactive signal containing the full history entries. */
|
|
324
|
+
readonly history: Signal<readonly StoreHistoryEntry<TData>[]>;
|
|
325
|
+
/** Reactive signal containing all channel message records. */
|
|
326
|
+
readonly messages: Signal<readonly StoreMessageRecord<TData>[]>;
|
|
327
|
+
/** Reactive signal containing the current history index. */
|
|
328
|
+
readonly currentIndex: Signal<number>;
|
|
329
|
+
/** Reactive signal containing all registered store keys. */
|
|
330
|
+
readonly keys: Signal<readonly StoreKey<TData>[]>;
|
|
309
331
|
}
|
|
310
332
|
|
|
311
333
|
/**
|
|
@@ -337,7 +359,7 @@ declare function createSnapshotRestorePatch<TState extends ResourceState<unknown
|
|
|
337
359
|
interface StoreHistoryEntry<TData extends StoreDataShape<TData>, TKey extends StoreKey<TData> = StoreKey<TData>> {
|
|
338
360
|
/** Stable message id used by `replay(...)`; `null` for the initial snapshot entry. */
|
|
339
361
|
readonly id: number | null;
|
|
340
|
-
/** Snapshot position used by `
|
|
362
|
+
/** Snapshot position used by `restoreStoreAt(index)`, `undo()`, and `redo()`. */
|
|
341
363
|
readonly index: number;
|
|
342
364
|
/** Acknowledged message that produced this snapshot; `null` for the initial entry. */
|
|
343
365
|
readonly message: StoreMessage<TData, TKey> | null;
|
|
@@ -365,7 +387,7 @@ interface StoreDeadLetterEntry<TData extends StoreDataShape<TData>, TKey extends
|
|
|
365
387
|
/**
|
|
366
388
|
* Public history and recovery API exposed on every store instance.
|
|
367
389
|
*
|
|
368
|
-
* `
|
|
390
|
+
* `restoreStoreAt(...)` navigates snapshots by history index, while `replay(...)`
|
|
369
391
|
* re-executes previously published channel messages by their stable message ids.
|
|
370
392
|
*/
|
|
371
393
|
interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKey<TData> = StoreKey<TData>> {
|
|
@@ -398,11 +420,25 @@ interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKe
|
|
|
398
420
|
*
|
|
399
421
|
* @throws {Error} When the index is outside the recorded history range.
|
|
400
422
|
*/
|
|
401
|
-
|
|
423
|
+
restoreStoreAt(index: number): void;
|
|
424
|
+
/**
|
|
425
|
+
* Restores a single store key to its state at a specific history index.
|
|
426
|
+
*
|
|
427
|
+
* Unlike `restoreStoreAt(index)` which restores the full snapshot, this method
|
|
428
|
+
* only restores the specified key while leaving other keys unaffected.
|
|
429
|
+
* This is snapshot navigation only. It does not publish or acknowledge any
|
|
430
|
+
* message and does not create a new history entry.
|
|
431
|
+
*
|
|
432
|
+
* @param key - The store key to restore.
|
|
433
|
+
* @param index - Optional history index. Defaults to the current index.
|
|
434
|
+
* @throws {Error} When the key is not a valid store key.
|
|
435
|
+
* @throws {Error} When the index is outside the recorded history range.
|
|
436
|
+
*/
|
|
437
|
+
restoreResource<K extends TKey>(key: K, index?: number): void;
|
|
402
438
|
/**
|
|
403
439
|
* Moves to the previous recorded snapshot.
|
|
404
440
|
*
|
|
405
|
-
* Equivalent to `
|
|
441
|
+
* Equivalent to `restoreStoreAt(getCurrentIndex() - 1)` when possible.
|
|
406
442
|
*
|
|
407
443
|
* @returns `true` when the pointer moved, otherwise `false` at the initial snapshot.
|
|
408
444
|
*/
|
|
@@ -410,7 +446,7 @@ interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKe
|
|
|
410
446
|
/**
|
|
411
447
|
* Moves to the next recorded snapshot when history exists ahead of the current pointer.
|
|
412
448
|
*
|
|
413
|
-
* Equivalent to `
|
|
449
|
+
* Equivalent to `restoreStoreAt(getCurrentIndex() + 1)` when possible.
|
|
414
450
|
*
|
|
415
451
|
* @returns `true` when the pointer moved, otherwise `false` at the latest snapshot.
|
|
416
452
|
*/
|
|
@@ -449,6 +485,12 @@ interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKe
|
|
|
449
485
|
replayDeadLetters(): number;
|
|
450
486
|
/** Returns the currently restored history index used by snapshot navigation. */
|
|
451
487
|
getCurrentIndex(): number;
|
|
488
|
+
/** Reactive signal containing the full history entries. */
|
|
489
|
+
readonly historySignal: Signal<readonly StoreHistoryEntry<TData, TKey>[]>;
|
|
490
|
+
/** Reactive signal containing all channel message records. */
|
|
491
|
+
readonly messagesSignal: Signal<readonly StoreMessageRecord<TData, TKey>[]>;
|
|
492
|
+
/** Reactive signal containing the current history index. */
|
|
493
|
+
readonly currentIndexSignal: Signal<number>;
|
|
452
494
|
}
|
|
453
495
|
|
|
454
496
|
/**
|
|
@@ -469,9 +511,11 @@ declare abstract class BaseStore<TEnum extends Record<string, string | number>,
|
|
|
469
511
|
protected readonly storeEnum: TEnum;
|
|
470
512
|
private readonly signalsState;
|
|
471
513
|
private readonly storeKeys;
|
|
472
|
-
private readonly
|
|
514
|
+
private readonly historyDriver;
|
|
515
|
+
/** @inheritDoc */
|
|
516
|
+
readonly restoreStoreAt: (index: number) => void;
|
|
473
517
|
/** @inheritDoc */
|
|
474
|
-
readonly
|
|
518
|
+
readonly restoreResource: <K extends StoreKey<TData>>(key: K, index?: number) => void;
|
|
475
519
|
/** @inheritDoc */
|
|
476
520
|
readonly undo: () => boolean;
|
|
477
521
|
/** @inheritDoc */
|
|
@@ -485,6 +529,14 @@ declare abstract class BaseStore<TEnum extends Record<string, string | number>,
|
|
|
485
529
|
/** @inheritDoc */
|
|
486
530
|
readonly getCurrentIndex: () => number;
|
|
487
531
|
/** @inheritDoc */
|
|
532
|
+
readonly history: Signal<readonly StoreHistoryEntry<TData>[]>;
|
|
533
|
+
/** @inheritDoc */
|
|
534
|
+
readonly messages: Signal<readonly StoreMessageRecord<TData>[]>;
|
|
535
|
+
/** @inheritDoc */
|
|
536
|
+
readonly currentIndex: Signal<number>;
|
|
537
|
+
/** @inheritDoc */
|
|
538
|
+
readonly keys: Signal<readonly StoreKey<TData>[]>;
|
|
539
|
+
/** @inheritDoc */
|
|
488
540
|
replay(id: number): number;
|
|
489
541
|
/** @inheritDoc */
|
|
490
542
|
replay(ids: readonly number[]): number;
|
|
@@ -580,9 +632,11 @@ declare abstract class BaseStore<TEnum extends Record<string, string | number>,
|
|
|
580
632
|
declare class LazyStore<TData extends StoreDataShape<TData>> implements IStore<TData> {
|
|
581
633
|
private readonly signals;
|
|
582
634
|
private readonly hooks;
|
|
583
|
-
private readonly
|
|
635
|
+
private readonly historyDriver;
|
|
584
636
|
/** @inheritDoc */
|
|
585
|
-
readonly
|
|
637
|
+
readonly restoreStoreAt: (index: number) => void;
|
|
638
|
+
/** @inheritDoc */
|
|
639
|
+
readonly restoreResource: <K extends StoreKey<TData>>(key: K, index?: number) => void;
|
|
586
640
|
/** @inheritDoc */
|
|
587
641
|
readonly undo: () => boolean;
|
|
588
642
|
/** @inheritDoc */
|
|
@@ -591,7 +645,6 @@ declare class LazyStore<TData extends StoreDataShape<TData>> implements IStore<T
|
|
|
591
645
|
getMessages(): readonly StoreMessageRecord<TData>[];
|
|
592
646
|
/** @inheritDoc */
|
|
593
647
|
getMessages<K extends StoreKey<TData>>(key: K): readonly StoreMessageRecord<TData, K>[];
|
|
594
|
-
/** @inheritDoc */
|
|
595
648
|
readonly getDeadLetters: () => readonly StoreDeadLetterEntry<TData, StoreKey<TData>>[];
|
|
596
649
|
/** @inheritDoc */
|
|
597
650
|
readonly replayDeadLetter: (id: number) => boolean;
|
|
@@ -600,6 +653,15 @@ declare class LazyStore<TData extends StoreDataShape<TData>> implements IStore<T
|
|
|
600
653
|
/** @inheritDoc */
|
|
601
654
|
readonly getCurrentIndex: () => number;
|
|
602
655
|
/** @inheritDoc */
|
|
656
|
+
readonly history: Signal<readonly StoreHistoryEntry<TData>[]>;
|
|
657
|
+
/** @inheritDoc */
|
|
658
|
+
readonly messages: Signal<readonly StoreMessageRecord<TData>[]>;
|
|
659
|
+
/** @inheritDoc */
|
|
660
|
+
readonly currentIndex: Signal<number>;
|
|
661
|
+
/** @inheritDoc */
|
|
662
|
+
readonly keys: Signal<readonly StoreKey<TData>[]>;
|
|
663
|
+
private readonly keysSignal;
|
|
664
|
+
/** @inheritDoc */
|
|
603
665
|
replay(id: number): number;
|
|
604
666
|
/** @inheritDoc */
|
|
605
667
|
replay(ids: readonly number[]): number;
|
|
@@ -938,4 +1000,4 @@ interface CollectKeyedOptions<TEntity> {
|
|
|
938
1000
|
*/
|
|
939
1001
|
declare function collectKeyed<TSource extends StoreDataShape<TSource>, TTarget extends StoreDataShape<TTarget>, TEntity = unknown>(source: IStore<TSource>, sourceKey: StoreKey<TSource>, target: IStore<TTarget>, targetKeyOrOptions?: StoreKey<TTarget> | CollectKeyedOptions<TEntity>, options?: CollectKeyedOptions<TEntity>): () => void;
|
|
940
1002
|
|
|
941
|
-
export { BaseStore, type BrowserStorageStoreMessageChannelOptions, type ClearAllStoreMessage, type ClearKeyedOneStoreMessage, type ClearStoreMessage, type CollectKeyedOptions, type CompositeStoreMessageChannelOptions, type ConfigToData, type IStore, LazyStore, type MirrorOptions, type StartKeyedLoadingStoreMessage, type StartLoadingStoreMessage, type StopLoadingStoreMessage, type StorageStoreMessageChannelOptions, Store, type StoreDeadLetterEntry, type StoreHistory, type StoreHistoryEntry, type StoreMessage, type StoreMessageChannel, type StoreMessageChannelOptions, type StoreMessageChannelStorage, type StoreMessageRecord, type StoreMessageStatus, type StoreOptions, type StoreSnapshot, type UpdateKeyedOneStoreMessage, type UpdateStoreMessage, clearAllStores, cloneValue, collectKeyed, createCompositeStoreMessageChannel, createInMemoryStoreMessageChannel, createLocalStorageStoreMessageChannel, createSessionStorageStoreMessageChannel, createSnapshotRestorePatch, createStorageStoreMessageChannel, mirrorKey };
|
|
1003
|
+
export { BaseStore, type BrowserStorageStoreMessageChannelOptions, type ClearAllStoreMessage, type ClearKeyedOneStoreMessage, type ClearStoreMessage, type CollectKeyedOptions, type CompositeStoreMessageChannelOptions, type ConfigToData, INVALID_STORE_KEY_ERROR, type IStore, LazyStore, type MirrorOptions, type StartKeyedLoadingStoreMessage, type StartLoadingStoreMessage, type StopLoadingStoreMessage, type StorageStoreMessageChannelOptions, Store, type StoreDeadLetterEntry, type StoreHistory, type StoreHistoryEntry, type StoreMessage, type StoreMessageChannel, type StoreMessageChannelOptions, type StoreMessageChannelStorage, type StoreMessageRecord, type StoreMessageStatus, type StoreOptions, type StoreSnapshot, type UpdateKeyedOneStoreMessage, type UpdateStoreMessage, clearAllStores, cloneValue, collectKeyed, createCompositeStoreMessageChannel, createInMemoryStoreMessageChannel, createLocalStorageStoreMessageChannel, createSessionStorageStoreMessageChannel, createSnapshotRestorePatch, createStorageStoreMessageChannel, mirrorKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ type StoreSnapshot<TData extends StoreDataShape<TData>, TKey extends StoreKey<TD
|
|
|
67
67
|
}>;
|
|
68
68
|
/** Delivery status of a broker message: `"pending"` → `"acknowledged"` or `"dead-letter"`. */
|
|
69
69
|
type StoreMessageStatus = "pending" | "acknowledged" | "dead-letter";
|
|
70
|
+
/** Error message thrown when `restoreResource()` receives a key that is not a valid store key. */
|
|
71
|
+
declare const INVALID_STORE_KEY_ERROR = "Invalid store key";
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Persisted broker message record stored in the active message channel.
|
|
@@ -256,7 +258,7 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
256
258
|
/**
|
|
257
259
|
* Re-executes previously published channel message id(s).
|
|
258
260
|
*
|
|
259
|
-
* Unlike `
|
|
261
|
+
* Unlike `restoreStoreAt(...)`, replay goes back through the broker/consumer path,
|
|
260
262
|
* so it can mutate the store again, truncate future history after time
|
|
261
263
|
* travel, and record new acknowledged history entries.
|
|
262
264
|
*/
|
|
@@ -266,7 +268,19 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
266
268
|
*
|
|
267
269
|
* This navigates snapshots only and does not re-run any message.
|
|
268
270
|
*/
|
|
269
|
-
|
|
271
|
+
restoreStoreAt: StoreHistory<TData>["restoreStoreAt"];
|
|
272
|
+
/**
|
|
273
|
+
* Restores a single store key to its state at a specific history index.
|
|
274
|
+
*
|
|
275
|
+
* Unlike `restoreStoreAt(index)` which restores the full snapshot, this method
|
|
276
|
+
* only restores the specified key while leaving other keys unaffected.
|
|
277
|
+
* This is snapshot navigation only. It does not publish or acknowledge any
|
|
278
|
+
* message and does not create a new history entry.
|
|
279
|
+
*
|
|
280
|
+
* @param key - The store key to restore.
|
|
281
|
+
* @param index - Optional history index. Defaults to the current index.
|
|
282
|
+
*/
|
|
283
|
+
restoreResource: StoreHistory<TData>["restoreResource"];
|
|
270
284
|
/** Moves one step backward in the recorded snapshot history when possible. */
|
|
271
285
|
undo: StoreHistory<TData>["undo"];
|
|
272
286
|
/** Moves one step forward in the recorded snapshot history when possible. */
|
|
@@ -293,7 +307,7 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
293
307
|
replayDeadLetter: StoreHistory<TData>["replayDeadLetter"];
|
|
294
308
|
/** Attempts to replay all current dead-letter messages once. */
|
|
295
309
|
replayDeadLetters: StoreHistory<TData>["replayDeadLetters"];
|
|
296
|
-
/** Returns the currently restored snapshot index used by `
|
|
310
|
+
/** Returns the currently restored snapshot index used by `restoreStoreAt`, `undo`, and `redo`. */
|
|
297
311
|
getCurrentIndex: StoreHistory<TData>["getCurrentIndex"];
|
|
298
312
|
/** Merges a single entity into a keyed slot and sets its status to `'Success'`. */
|
|
299
313
|
updateKeyedOne<K extends StoreKey<TData>>(key: K, resourceKey: KeyedResourceKey, entity: unknown): void;
|
|
@@ -306,6 +320,14 @@ interface IStore<TData extends StoreDataShape<TData>> {
|
|
|
306
320
|
* @returns A cleanup function that removes the listener.
|
|
307
321
|
*/
|
|
308
322
|
onUpdate<K extends StoreKey<TData>>(key: K, callback: (state: TData[K], previousState: TData[K]) => void): () => void;
|
|
323
|
+
/** Reactive signal containing the full history entries. */
|
|
324
|
+
readonly history: Signal<readonly StoreHistoryEntry<TData>[]>;
|
|
325
|
+
/** Reactive signal containing all channel message records. */
|
|
326
|
+
readonly messages: Signal<readonly StoreMessageRecord<TData>[]>;
|
|
327
|
+
/** Reactive signal containing the current history index. */
|
|
328
|
+
readonly currentIndex: Signal<number>;
|
|
329
|
+
/** Reactive signal containing all registered store keys. */
|
|
330
|
+
readonly keys: Signal<readonly StoreKey<TData>[]>;
|
|
309
331
|
}
|
|
310
332
|
|
|
311
333
|
/**
|
|
@@ -337,7 +359,7 @@ declare function createSnapshotRestorePatch<TState extends ResourceState<unknown
|
|
|
337
359
|
interface StoreHistoryEntry<TData extends StoreDataShape<TData>, TKey extends StoreKey<TData> = StoreKey<TData>> {
|
|
338
360
|
/** Stable message id used by `replay(...)`; `null` for the initial snapshot entry. */
|
|
339
361
|
readonly id: number | null;
|
|
340
|
-
/** Snapshot position used by `
|
|
362
|
+
/** Snapshot position used by `restoreStoreAt(index)`, `undo()`, and `redo()`. */
|
|
341
363
|
readonly index: number;
|
|
342
364
|
/** Acknowledged message that produced this snapshot; `null` for the initial entry. */
|
|
343
365
|
readonly message: StoreMessage<TData, TKey> | null;
|
|
@@ -365,7 +387,7 @@ interface StoreDeadLetterEntry<TData extends StoreDataShape<TData>, TKey extends
|
|
|
365
387
|
/**
|
|
366
388
|
* Public history and recovery API exposed on every store instance.
|
|
367
389
|
*
|
|
368
|
-
* `
|
|
390
|
+
* `restoreStoreAt(...)` navigates snapshots by history index, while `replay(...)`
|
|
369
391
|
* re-executes previously published channel messages by their stable message ids.
|
|
370
392
|
*/
|
|
371
393
|
interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKey<TData> = StoreKey<TData>> {
|
|
@@ -398,11 +420,25 @@ interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKe
|
|
|
398
420
|
*
|
|
399
421
|
* @throws {Error} When the index is outside the recorded history range.
|
|
400
422
|
*/
|
|
401
|
-
|
|
423
|
+
restoreStoreAt(index: number): void;
|
|
424
|
+
/**
|
|
425
|
+
* Restores a single store key to its state at a specific history index.
|
|
426
|
+
*
|
|
427
|
+
* Unlike `restoreStoreAt(index)` which restores the full snapshot, this method
|
|
428
|
+
* only restores the specified key while leaving other keys unaffected.
|
|
429
|
+
* This is snapshot navigation only. It does not publish or acknowledge any
|
|
430
|
+
* message and does not create a new history entry.
|
|
431
|
+
*
|
|
432
|
+
* @param key - The store key to restore.
|
|
433
|
+
* @param index - Optional history index. Defaults to the current index.
|
|
434
|
+
* @throws {Error} When the key is not a valid store key.
|
|
435
|
+
* @throws {Error} When the index is outside the recorded history range.
|
|
436
|
+
*/
|
|
437
|
+
restoreResource<K extends TKey>(key: K, index?: number): void;
|
|
402
438
|
/**
|
|
403
439
|
* Moves to the previous recorded snapshot.
|
|
404
440
|
*
|
|
405
|
-
* Equivalent to `
|
|
441
|
+
* Equivalent to `restoreStoreAt(getCurrentIndex() - 1)` when possible.
|
|
406
442
|
*
|
|
407
443
|
* @returns `true` when the pointer moved, otherwise `false` at the initial snapshot.
|
|
408
444
|
*/
|
|
@@ -410,7 +446,7 @@ interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKe
|
|
|
410
446
|
/**
|
|
411
447
|
* Moves to the next recorded snapshot when history exists ahead of the current pointer.
|
|
412
448
|
*
|
|
413
|
-
* Equivalent to `
|
|
449
|
+
* Equivalent to `restoreStoreAt(getCurrentIndex() + 1)` when possible.
|
|
414
450
|
*
|
|
415
451
|
* @returns `true` when the pointer moved, otherwise `false` at the latest snapshot.
|
|
416
452
|
*/
|
|
@@ -449,6 +485,12 @@ interface StoreHistory<TData extends StoreDataShape<TData>, TKey extends StoreKe
|
|
|
449
485
|
replayDeadLetters(): number;
|
|
450
486
|
/** Returns the currently restored history index used by snapshot navigation. */
|
|
451
487
|
getCurrentIndex(): number;
|
|
488
|
+
/** Reactive signal containing the full history entries. */
|
|
489
|
+
readonly historySignal: Signal<readonly StoreHistoryEntry<TData, TKey>[]>;
|
|
490
|
+
/** Reactive signal containing all channel message records. */
|
|
491
|
+
readonly messagesSignal: Signal<readonly StoreMessageRecord<TData, TKey>[]>;
|
|
492
|
+
/** Reactive signal containing the current history index. */
|
|
493
|
+
readonly currentIndexSignal: Signal<number>;
|
|
452
494
|
}
|
|
453
495
|
|
|
454
496
|
/**
|
|
@@ -469,9 +511,11 @@ declare abstract class BaseStore<TEnum extends Record<string, string | number>,
|
|
|
469
511
|
protected readonly storeEnum: TEnum;
|
|
470
512
|
private readonly signalsState;
|
|
471
513
|
private readonly storeKeys;
|
|
472
|
-
private readonly
|
|
514
|
+
private readonly historyDriver;
|
|
515
|
+
/** @inheritDoc */
|
|
516
|
+
readonly restoreStoreAt: (index: number) => void;
|
|
473
517
|
/** @inheritDoc */
|
|
474
|
-
readonly
|
|
518
|
+
readonly restoreResource: <K extends StoreKey<TData>>(key: K, index?: number) => void;
|
|
475
519
|
/** @inheritDoc */
|
|
476
520
|
readonly undo: () => boolean;
|
|
477
521
|
/** @inheritDoc */
|
|
@@ -485,6 +529,14 @@ declare abstract class BaseStore<TEnum extends Record<string, string | number>,
|
|
|
485
529
|
/** @inheritDoc */
|
|
486
530
|
readonly getCurrentIndex: () => number;
|
|
487
531
|
/** @inheritDoc */
|
|
532
|
+
readonly history: Signal<readonly StoreHistoryEntry<TData>[]>;
|
|
533
|
+
/** @inheritDoc */
|
|
534
|
+
readonly messages: Signal<readonly StoreMessageRecord<TData>[]>;
|
|
535
|
+
/** @inheritDoc */
|
|
536
|
+
readonly currentIndex: Signal<number>;
|
|
537
|
+
/** @inheritDoc */
|
|
538
|
+
readonly keys: Signal<readonly StoreKey<TData>[]>;
|
|
539
|
+
/** @inheritDoc */
|
|
488
540
|
replay(id: number): number;
|
|
489
541
|
/** @inheritDoc */
|
|
490
542
|
replay(ids: readonly number[]): number;
|
|
@@ -580,9 +632,11 @@ declare abstract class BaseStore<TEnum extends Record<string, string | number>,
|
|
|
580
632
|
declare class LazyStore<TData extends StoreDataShape<TData>> implements IStore<TData> {
|
|
581
633
|
private readonly signals;
|
|
582
634
|
private readonly hooks;
|
|
583
|
-
private readonly
|
|
635
|
+
private readonly historyDriver;
|
|
584
636
|
/** @inheritDoc */
|
|
585
|
-
readonly
|
|
637
|
+
readonly restoreStoreAt: (index: number) => void;
|
|
638
|
+
/** @inheritDoc */
|
|
639
|
+
readonly restoreResource: <K extends StoreKey<TData>>(key: K, index?: number) => void;
|
|
586
640
|
/** @inheritDoc */
|
|
587
641
|
readonly undo: () => boolean;
|
|
588
642
|
/** @inheritDoc */
|
|
@@ -591,7 +645,6 @@ declare class LazyStore<TData extends StoreDataShape<TData>> implements IStore<T
|
|
|
591
645
|
getMessages(): readonly StoreMessageRecord<TData>[];
|
|
592
646
|
/** @inheritDoc */
|
|
593
647
|
getMessages<K extends StoreKey<TData>>(key: K): readonly StoreMessageRecord<TData, K>[];
|
|
594
|
-
/** @inheritDoc */
|
|
595
648
|
readonly getDeadLetters: () => readonly StoreDeadLetterEntry<TData, StoreKey<TData>>[];
|
|
596
649
|
/** @inheritDoc */
|
|
597
650
|
readonly replayDeadLetter: (id: number) => boolean;
|
|
@@ -600,6 +653,15 @@ declare class LazyStore<TData extends StoreDataShape<TData>> implements IStore<T
|
|
|
600
653
|
/** @inheritDoc */
|
|
601
654
|
readonly getCurrentIndex: () => number;
|
|
602
655
|
/** @inheritDoc */
|
|
656
|
+
readonly history: Signal<readonly StoreHistoryEntry<TData>[]>;
|
|
657
|
+
/** @inheritDoc */
|
|
658
|
+
readonly messages: Signal<readonly StoreMessageRecord<TData>[]>;
|
|
659
|
+
/** @inheritDoc */
|
|
660
|
+
readonly currentIndex: Signal<number>;
|
|
661
|
+
/** @inheritDoc */
|
|
662
|
+
readonly keys: Signal<readonly StoreKey<TData>[]>;
|
|
663
|
+
private readonly keysSignal;
|
|
664
|
+
/** @inheritDoc */
|
|
603
665
|
replay(id: number): number;
|
|
604
666
|
/** @inheritDoc */
|
|
605
667
|
replay(ids: readonly number[]): number;
|
|
@@ -938,4 +1000,4 @@ interface CollectKeyedOptions<TEntity> {
|
|
|
938
1000
|
*/
|
|
939
1001
|
declare function collectKeyed<TSource extends StoreDataShape<TSource>, TTarget extends StoreDataShape<TTarget>, TEntity = unknown>(source: IStore<TSource>, sourceKey: StoreKey<TSource>, target: IStore<TTarget>, targetKeyOrOptions?: StoreKey<TTarget> | CollectKeyedOptions<TEntity>, options?: CollectKeyedOptions<TEntity>): () => void;
|
|
940
1002
|
|
|
941
|
-
export { BaseStore, type BrowserStorageStoreMessageChannelOptions, type ClearAllStoreMessage, type ClearKeyedOneStoreMessage, type ClearStoreMessage, type CollectKeyedOptions, type CompositeStoreMessageChannelOptions, type ConfigToData, type IStore, LazyStore, type MirrorOptions, type StartKeyedLoadingStoreMessage, type StartLoadingStoreMessage, type StopLoadingStoreMessage, type StorageStoreMessageChannelOptions, Store, type StoreDeadLetterEntry, type StoreHistory, type StoreHistoryEntry, type StoreMessage, type StoreMessageChannel, type StoreMessageChannelOptions, type StoreMessageChannelStorage, type StoreMessageRecord, type StoreMessageStatus, type StoreOptions, type StoreSnapshot, type UpdateKeyedOneStoreMessage, type UpdateStoreMessage, clearAllStores, cloneValue, collectKeyed, createCompositeStoreMessageChannel, createInMemoryStoreMessageChannel, createLocalStorageStoreMessageChannel, createSessionStorageStoreMessageChannel, createSnapshotRestorePatch, createStorageStoreMessageChannel, mirrorKey };
|
|
1003
|
+
export { BaseStore, type BrowserStorageStoreMessageChannelOptions, type ClearAllStoreMessage, type ClearKeyedOneStoreMessage, type ClearStoreMessage, type CollectKeyedOptions, type CompositeStoreMessageChannelOptions, type ConfigToData, INVALID_STORE_KEY_ERROR, type IStore, LazyStore, type MirrorOptions, type StartKeyedLoadingStoreMessage, type StartLoadingStoreMessage, type StopLoadingStoreMessage, type StorageStoreMessageChannelOptions, Store, type StoreDeadLetterEntry, type StoreHistory, type StoreHistoryEntry, type StoreMessage, type StoreMessageChannel, type StoreMessageChannelOptions, type StoreMessageChannelStorage, type StoreMessageRecord, type StoreMessageStatus, type StoreOptions, type StoreSnapshot, type UpdateKeyedOneStoreMessage, type UpdateStoreMessage, clearAllStores, cloneValue, collectKeyed, createCompositeStoreMessageChannel, createInMemoryStoreMessageChannel, createLocalStorageStoreMessageChannel, createSessionStorageStoreMessageChannel, createSnapshotRestorePatch, createStorageStoreMessageChannel, mirrorKey };
|