@oimdb/core 2.1.0 → 3.0.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 +488 -124
- package/dist/index.d.cts +173 -19
- package/dist/index.d.ts +173 -19
- package/dist/index.js +486 -124
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,13 @@ type TOIMPk = string | number;
|
|
|
3
3
|
type TOIMEntitySlot<TEntity extends object, TPk extends TOIMPk> = {
|
|
4
4
|
pk: TPk;
|
|
5
5
|
item: TEntity | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Per-pk subscribers, attached lazily by the slot-based keyed emitter so
|
|
8
|
+
* notification needs no per-key map lookup. The slot is retained while this
|
|
9
|
+
* is non-empty (even with `item: undefined`) so a subscription survives a
|
|
10
|
+
* remove → re-add of its entity. Undefined when nothing is subscribed.
|
|
11
|
+
*/
|
|
12
|
+
subscribers?: Set<() => void>;
|
|
6
13
|
};
|
|
7
14
|
type TOIMAnyEntitySlot<TPk extends TOIMPk> = TOIMEntitySlot<object, TPk>;
|
|
8
15
|
type TOIMEntitySlotResolver<TPk extends TOIMPk> = (pk: TPk) => TOIMAnyEntitySlot<TPk> | undefined;
|
|
@@ -10,6 +17,19 @@ type TOIMEntitySlotResolver<TPk extends TOIMPk> = (pk: TPk) => TOIMAnyEntitySlot
|
|
|
10
17
|
declare abstract class OIMCollectionStore<TEntity extends object, TPk extends TOIMPk> {
|
|
11
18
|
abstract setOneByPk(pk: TPk, entity: TEntity): TOIMEntitySlot<TEntity, TPk>;
|
|
12
19
|
abstract getSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk> | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the canonical slot for `pk`, creating a reserved empty slot
|
|
22
|
+
* (`item: undefined`) if no entity exists yet. The reserved slot is a stable
|
|
23
|
+
* reference that fills in when the entity is later written, so indexes can
|
|
24
|
+
* hold it ahead of the entity's arrival without crashing.
|
|
25
|
+
*/
|
|
26
|
+
abstract getOrReserveSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the existing slot for `pk` (live or reserved) without creating
|
|
29
|
+
* one. Used by the slot-based emitter to resolve a slot for delivery /
|
|
30
|
+
* unsubscribe without side effects.
|
|
31
|
+
*/
|
|
32
|
+
abstract findSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk> | undefined;
|
|
13
33
|
abstract getSlotsByPks(pks: readonly TPk[]): TOIMEntitySlot<TEntity, TPk>[];
|
|
14
34
|
abstract getAllSlots(): TOIMEntitySlot<TEntity, TPk>[];
|
|
15
35
|
abstract removeOneByPk(pk: TPk): void;
|
|
@@ -76,8 +96,8 @@ declare abstract class OIMIndex<TKey extends TOIMPk, TPk extends TOIMPk, TBucket
|
|
|
76
96
|
getKeySize(key: TKey): number;
|
|
77
97
|
get size(): number;
|
|
78
98
|
get isEmpty(): boolean;
|
|
79
|
-
getEntitiesByKey<TEntity extends object = object>(key: TKey): TEntity[];
|
|
80
|
-
getEntitiesByKeys<TEntity extends object = object>(keys: readonly TKey[]): Map<TKey, TEntity[]>;
|
|
99
|
+
getEntitiesByKey<TEntity extends object = object>(key: TKey): (TEntity | undefined)[];
|
|
100
|
+
getEntitiesByKeys<TEntity extends object = object>(keys: readonly TKey[]): Map<TKey, (TEntity | undefined)[]>;
|
|
81
101
|
getMetrics(): {
|
|
82
102
|
totalKeys: number;
|
|
83
103
|
totalPks: number;
|
|
@@ -88,7 +108,15 @@ declare abstract class OIMIndex<TKey extends TOIMPk, TPk extends TOIMPk, TBucket
|
|
|
88
108
|
destroy(): void;
|
|
89
109
|
protected emitUpdate(keys: TKey[]): void;
|
|
90
110
|
protected emitUpdateOne(key: TKey): void;
|
|
91
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Maps a bucket's slots to entities, preserving positional holes: a slot
|
|
113
|
+
* whose entity is not present yet (reserved by an index ahead of its data)
|
|
114
|
+
* or was removed yields `undefined` at its position rather than being
|
|
115
|
+
* dropped. This keeps the result aligned with `getPksByKey`, so callers can
|
|
116
|
+
* render a per-item loading/placeholder state instead of a silently shorter
|
|
117
|
+
* list.
|
|
118
|
+
*/
|
|
119
|
+
protected slotsToEntities<TEntity extends object>(slots: Iterable<TOIMAnyEntitySlot<TPk>>): (TEntity | undefined)[];
|
|
92
120
|
}
|
|
93
121
|
|
|
94
122
|
declare abstract class OIMIndexStoreSetBased<TKey extends TOIMPk, TPk extends TOIMPk> {
|
|
@@ -257,12 +285,19 @@ declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
|
|
|
257
285
|
markAllUpdated(): void;
|
|
258
286
|
protected readonly onFlush: () => void;
|
|
259
287
|
private deliverImmediate;
|
|
288
|
+
/**
|
|
289
|
+
* Notifies all handlers for a key. The overwhelmingly common case is a
|
|
290
|
+
* single subscriber per key (one component per pk), handled without any
|
|
291
|
+
* allocation. For multiple subscribers a snapshot is taken so a handler may
|
|
292
|
+
* (un)subscribe during iteration without corrupting the walk.
|
|
293
|
+
*/
|
|
294
|
+
private notifyHandlers;
|
|
260
295
|
private readonly onAfterFlush;
|
|
261
296
|
/**
|
|
262
297
|
* Deliver updated keys and notify handlers once.
|
|
263
298
|
* Re-entrant updates during delivery are forbidden and will throw in markUpdatedKeys().
|
|
264
299
|
*/
|
|
265
|
-
protected runSinglePass(
|
|
300
|
+
protected runSinglePass(): void;
|
|
266
301
|
destroy(): void;
|
|
267
302
|
/**
|
|
268
303
|
* Get performance metrics for monitoring and debugging
|
|
@@ -296,8 +331,8 @@ declare abstract class OIMReactiveIndex<TKey extends TOIMPk, TPk extends TOIMPk,
|
|
|
296
331
|
readonly index: TIndex;
|
|
297
332
|
protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
|
|
298
333
|
constructor(queue: OIMEventQueue, createIndex: (updateEmitter: OIMUpdateEventEmitter<TKey>) => TIndex);
|
|
299
|
-
getEntitiesByKey<TEntity extends object = object>(key: TKey): TEntity[];
|
|
300
|
-
getEntitiesByKeys<TEntity extends object = object>(keys: readonly TKey[]): Map<TKey, TEntity[]>;
|
|
334
|
+
getEntitiesByKey<TEntity extends object = object>(key: TKey): (TEntity | undefined)[];
|
|
335
|
+
getEntitiesByKeys<TEntity extends object = object>(keys: readonly TKey[]): Map<TKey, (TEntity | undefined)[]>;
|
|
301
336
|
hasKey(key: TKey): boolean;
|
|
302
337
|
getKeys(): readonly TKey[];
|
|
303
338
|
getKeySize(key: TKey): number;
|
|
@@ -381,6 +416,7 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
|
|
|
381
416
|
getOneByPk(pk: TPk): TEntity | undefined;
|
|
382
417
|
getManyByPks(pks: readonly TPk[]): TEntity[];
|
|
383
418
|
getSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk> | undefined;
|
|
419
|
+
getOrReserveSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk>;
|
|
384
420
|
getSlotsByPks(pks: readonly TPk[]): TOIMEntitySlot<TEntity, TPk>[];
|
|
385
421
|
getAllSlots(): TOIMEntitySlot<TEntity, TPk>[];
|
|
386
422
|
upsertOneByPk(pk: TPk, entity: Partial<TEntity>): TOIMEntitySlot<TEntity, TPk>;
|
|
@@ -399,9 +435,76 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
|
|
|
399
435
|
destroy(): void;
|
|
400
436
|
}
|
|
401
437
|
|
|
438
|
+
/**
|
|
439
|
+
* A carrier that can hold per-key subscribers directly on itself, so the keyed
|
|
440
|
+
* emitter delivers without a per-key map lookup. Implemented by the entity slot
|
|
441
|
+
* (collection carrier) and the index bucket (index carrier).
|
|
442
|
+
*/
|
|
443
|
+
interface IOIMSubscribable {
|
|
444
|
+
subscribers?: Set<() => void>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Resolves a key to its carrier — the object that holds the key's subscribers.
|
|
449
|
+
* `getOrReserveCarrier` is used on subscribe (creates the carrier if absent so a
|
|
450
|
+
* subscription can exist before its data); `findCarrier` resolves an existing
|
|
451
|
+
* carrier for delivery/unsubscribe without creating one.
|
|
452
|
+
*
|
|
453
|
+
* Collection carrier = the entity slot (by pk); index carrier = the bucket
|
|
454
|
+
* (by index key).
|
|
455
|
+
*/
|
|
456
|
+
interface IOIMCarrierResolver<TKey extends TOIMPk, TCarrier> {
|
|
457
|
+
getOrReserveCarrier(key: TKey): TCarrier;
|
|
458
|
+
findCarrier(key: TKey): TCarrier | undefined;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Keyed (per-key) pub/sub that stores handlers ON the carrier object
|
|
462
|
+
* (`carrier.subscribers`) instead of a `Map<key, handlers>`. The hot path —
|
|
463
|
+
* marking a written carrier dirty and delivering — needs no per-key map lookup
|
|
464
|
+
* or hashing: the writer already holds the carrier.
|
|
465
|
+
*
|
|
466
|
+
* Same public surface as `OIMUpdateEventEmitter` (queue delivery) plus a fast
|
|
467
|
+
* `markUpdatedCarrier(carrier)`, so it is a drop-in for the collection's and
|
|
468
|
+
* index's keyed emitter. Reused with carrier = slot (collection) or carrier =
|
|
469
|
+
* bucket (index).
|
|
470
|
+
*/
|
|
471
|
+
declare class OIMCarrierKeyedEmitter<TKey extends TOIMPk, TCarrier extends IOIMSubscribable> {
|
|
472
|
+
private readonly queue;
|
|
473
|
+
private readonly resolver;
|
|
474
|
+
private readonly subscribedCarriers;
|
|
475
|
+
private dirtyCarriers;
|
|
476
|
+
private isFlushEnqueued;
|
|
477
|
+
private dequeueFlush?;
|
|
478
|
+
constructor(queue: OIMEventQueue, resolver: IOIMCarrierResolver<TKey, TCarrier>);
|
|
479
|
+
subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
|
|
480
|
+
subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
|
|
481
|
+
unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
|
|
482
|
+
unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
|
|
483
|
+
private addHandler;
|
|
484
|
+
private removeHandler;
|
|
485
|
+
/** Fast path: the writer already holds the carrier. */
|
|
486
|
+
markUpdatedCarrier(carrier: TCarrier): void;
|
|
487
|
+
markUpdatedKey(key: TKey): void;
|
|
488
|
+
markUpdatedKeys(keys: readonly TKey[]): void;
|
|
489
|
+
markAllUpdated(): void;
|
|
490
|
+
hasSubscriptions(): boolean;
|
|
491
|
+
getHandlerCount(key: TKey): number;
|
|
492
|
+
getMetrics(): {
|
|
493
|
+
totalKeys: number;
|
|
494
|
+
totalHandlers: number;
|
|
495
|
+
averageHandlersPerKey: number;
|
|
496
|
+
queueLength: number;
|
|
497
|
+
};
|
|
498
|
+
destroy(): void;
|
|
499
|
+
private assertNotInFlush;
|
|
500
|
+
private scheduleFlush;
|
|
501
|
+
private readonly onFlush;
|
|
502
|
+
private notify;
|
|
503
|
+
}
|
|
504
|
+
|
|
402
505
|
declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> implements IOIMKeyedSubscription<TPk> {
|
|
403
506
|
private readonly queue;
|
|
404
|
-
protected readonly updateEmitter:
|
|
507
|
+
protected readonly updateEmitter: OIMCarrierKeyedEmitter<TPk, TOIMEntitySlot<TEntity, TPk>>;
|
|
405
508
|
private readonly anyUpdateHandlers;
|
|
406
509
|
private pendingAnyUpdatePks;
|
|
407
510
|
private isAnyUpdateClearPending;
|
|
@@ -422,6 +525,8 @@ declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk>
|
|
|
422
525
|
queueLength: number;
|
|
423
526
|
};
|
|
424
527
|
subscribeOnAnyUpdate(handler: (pks: readonly TPk[]) => void): () => void;
|
|
528
|
+
private notifyLegacy;
|
|
529
|
+
private notifyLegacyMany;
|
|
425
530
|
upsertOneByPk(pk: TPk, entity: Partial<TEntity>): TOIMEntitySlot<TEntity, TPk>;
|
|
426
531
|
upsertOne(entity: TEntity | Partial<TEntity>): TOIMEntitySlot<TEntity, TPk>;
|
|
427
532
|
upsertMany(entities: (TEntity | Partial<TEntity>)[]): TOIMEntitySlot<TEntity, TPk>[];
|
|
@@ -559,8 +664,8 @@ declare class OIMCollectionIndexManualOrderedArrayBased<TKey extends TOIMPk, TPk
|
|
|
559
664
|
push(key: TKey, pk: TPk): number;
|
|
560
665
|
insertAt(key: TKey, index: number, pk: TPk): number;
|
|
561
666
|
reset(key: TKey, pks: readonly TPk[]): void;
|
|
562
|
-
getEntitiesByKey<TItem extends object = TEntity>(key: TKey): TItem[];
|
|
563
|
-
getEntitiesByKeys<TItem extends object = TEntity>(keys: readonly TKey[]): Map<TKey, TItem[]>;
|
|
667
|
+
getEntitiesByKey<TItem extends object = TEntity>(key: TKey): (TItem | undefined)[];
|
|
668
|
+
getEntitiesByKeys<TItem extends object = TEntity>(keys: readonly TKey[]): Map<TKey, (TItem | undefined)[]>;
|
|
564
669
|
resolvePk(pk: TPk): TOIMAnyEntitySlot<TPk>;
|
|
565
670
|
private resolveSlots;
|
|
566
671
|
private resolveRequiredSlot;
|
|
@@ -609,7 +714,7 @@ declare class OIMOrderedListCommandStream<TKey extends TOIMPk, TPk extends TOIMP
|
|
|
609
714
|
constructor(queue: OIMEventQueue, index?: OIMIndexManualOrderedArrayBased<TKey, TPk>);
|
|
610
715
|
getPksByKey(key: TKey): readonly TPk[];
|
|
611
716
|
getSlotsByKey(key: TKey): readonly TOIMEntitySlot<TEntity, TPk>[];
|
|
612
|
-
getEntitiesByKey(key: TKey): TEntity[];
|
|
717
|
+
getEntitiesByKey(key: TKey): (TEntity | undefined)[];
|
|
613
718
|
hasKey(key: TKey): boolean;
|
|
614
719
|
getKeys(): readonly TKey[];
|
|
615
720
|
pushSlot(key: TKey, slot: TOIMEntitySlot<TEntity, TPk>): void;
|
|
@@ -641,7 +746,7 @@ declare class OIMCollectionOrderedListCommandStream<TKey extends TOIMPk, TPk ext
|
|
|
641
746
|
insertAt(key: TKey, index: number, pk: TPk): void;
|
|
642
747
|
set(key: TKey, pks: readonly TPk[]): void;
|
|
643
748
|
getSlotsByKey(key: TKey): readonly TOIMEntitySlot<TEntity, TPk>[];
|
|
644
|
-
getEntitiesByKey(key: TKey): TEntity[];
|
|
749
|
+
getEntitiesByKey(key: TKey): (TEntity | undefined)[];
|
|
645
750
|
private resolvePk;
|
|
646
751
|
}
|
|
647
752
|
|
|
@@ -655,6 +760,12 @@ declare class OIMIndexManualArrayBased<TIndexKey extends TOIMPk, TPk extends TOI
|
|
|
655
760
|
store?: OIMIndexStoreArrayBased<TIndexKey, TPk>;
|
|
656
761
|
});
|
|
657
762
|
setSlots(key: TIndexKey, slots: TOIMAnyEntitySlot<TPk>[]): void;
|
|
763
|
+
/**
|
|
764
|
+
* Appends pre-deduplicated slots to a key's bucket IN PLACE (no copy of the
|
|
765
|
+
* existing bucket) and emits once. Callers own dedup (so this stays O(added),
|
|
766
|
+
* not O(bucket)); used by collection-bound indexes for fast `addPks`.
|
|
767
|
+
*/
|
|
768
|
+
appendSlots(key: TIndexKey, slots: readonly TOIMAnyEntitySlot<TPk>[]): void;
|
|
658
769
|
/**
|
|
659
770
|
* Clear all primary keys for a specific index key, or all keys if no key specified
|
|
660
771
|
*/
|
|
@@ -669,6 +780,7 @@ declare class OIMReactiveIndexManualArrayBased<TKey extends TOIMPk, TPk extends
|
|
|
669
780
|
};
|
|
670
781
|
});
|
|
671
782
|
setSlots(key: TKey, slots: TOIMAnyEntitySlot<TPk>[]): void;
|
|
783
|
+
appendSlots(key: TKey, slots: readonly TOIMAnyEntitySlot<TPk>[]): void;
|
|
672
784
|
clear(key?: TKey): void;
|
|
673
785
|
}
|
|
674
786
|
|
|
@@ -680,12 +792,19 @@ declare class OIMReactiveIndexManualArrayBased<TKey extends TOIMPk, TPk extends
|
|
|
680
792
|
*/
|
|
681
793
|
declare class OIMReactiveCollectionIndexManualArrayBased<TKey extends TOIMPk, TPk extends TOIMPk, TEntity extends object = object> extends OIMReactiveIndexManualArrayBased<TKey, TPk> {
|
|
682
794
|
private readonly resolveSlot;
|
|
795
|
+
private readonly pksByKey;
|
|
683
796
|
constructor(queue: OIMEventQueue, opts: TOIMCollectionIndexArrayBasedOptions<TEntity, TKey, TPk>);
|
|
684
797
|
setPks(key: TKey, pks: readonly TPk[]): void;
|
|
685
798
|
addPks(key: TKey, pks: readonly TPk[]): void;
|
|
686
799
|
removePks(key: TKey, pks: readonly TPk[]): void;
|
|
687
|
-
|
|
688
|
-
|
|
800
|
+
clear(key?: TKey): void;
|
|
801
|
+
/**
|
|
802
|
+
* The membership set for a key, lazily seeded from the current bucket so it
|
|
803
|
+
* stays correct even if slots were set through a lower-level path.
|
|
804
|
+
*/
|
|
805
|
+
private membershipOf;
|
|
806
|
+
getEntitiesByKey<TItem extends object = TEntity>(key: TKey): (TItem | undefined)[];
|
|
807
|
+
getEntitiesByKeys<TItem extends object = TEntity>(keys: readonly TKey[]): Map<TKey, (TItem | undefined)[]>;
|
|
689
808
|
private resolveSlots;
|
|
690
809
|
private resolveRequiredSlot;
|
|
691
810
|
}
|
|
@@ -700,6 +819,15 @@ declare class OIMIndexManualSetBased<TIndexKey extends TOIMPk, TPk extends TOIMP
|
|
|
700
819
|
store?: OIMIndexStoreSetBased<TIndexKey, TPk>;
|
|
701
820
|
});
|
|
702
821
|
setSlots(key: TIndexKey, slots: Iterable<TOIMAnyEntitySlot<TPk>>): void;
|
|
822
|
+
/**
|
|
823
|
+
* Adds slots to a key's bucket IN PLACE (no copy of the existing Set) and
|
|
824
|
+
* emits once. O(added). Used by collection-bound indexes for fast `addPks`.
|
|
825
|
+
*/
|
|
826
|
+
addSlots(key: TIndexKey, slots: readonly TOIMAnyEntitySlot<TPk>[]): void;
|
|
827
|
+
/**
|
|
828
|
+
* Removes slots from a key's bucket IN PLACE (O(removed)) and emits once.
|
|
829
|
+
*/
|
|
830
|
+
removeSlots(key: TIndexKey, slots: readonly TOIMAnyEntitySlot<TPk>[]): void;
|
|
703
831
|
/**
|
|
704
832
|
* Clear all primary keys for a specific index key, or all keys if no key specified
|
|
705
833
|
*/
|
|
@@ -714,6 +842,8 @@ declare class OIMReactiveIndexManualSetBased<TKey extends TOIMPk, TPk extends TO
|
|
|
714
842
|
};
|
|
715
843
|
});
|
|
716
844
|
setSlots(key: TKey, slots: Iterable<TOIMAnyEntitySlot<TPk>>): void;
|
|
845
|
+
addSlots(key: TKey, slots: readonly TOIMAnyEntitySlot<TPk>[]): void;
|
|
846
|
+
removeSlots(key: TKey, slots: readonly TOIMAnyEntitySlot<TPk>[]): void;
|
|
717
847
|
clear(key?: TKey): void;
|
|
718
848
|
}
|
|
719
849
|
|
|
@@ -725,13 +855,19 @@ declare class OIMReactiveIndexManualSetBased<TKey extends TOIMPk, TPk extends TO
|
|
|
725
855
|
*/
|
|
726
856
|
declare class OIMReactiveCollectionIndexManualSetBased<TKey extends TOIMPk, TPk extends TOIMPk, TEntity extends object = object> extends OIMReactiveIndexManualSetBased<TKey, TPk> {
|
|
727
857
|
private readonly resolveSlot;
|
|
858
|
+
private readonly slotByPk;
|
|
728
859
|
constructor(queue: OIMEventQueue, opts: TOIMCollectionIndexSetBasedOptions<TEntity, TKey, TPk>);
|
|
729
860
|
setPks(key: TKey, pks: readonly TPk[]): void;
|
|
730
861
|
addPks(key: TKey, pks: readonly TPk[]): void;
|
|
731
862
|
removePks(key: TKey, pks: readonly TPk[]): void;
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
863
|
+
clear(key?: TKey): void;
|
|
864
|
+
/**
|
|
865
|
+
* The pk→slot map for a key, lazily seeded from the current bucket so it
|
|
866
|
+
* stays correct even if slots were set through a lower-level path.
|
|
867
|
+
*/
|
|
868
|
+
private membershipOf;
|
|
869
|
+
getEntitiesByKey<TItem extends object = TEntity>(key: TKey): (TItem | undefined)[];
|
|
870
|
+
getEntitiesByKeys<TItem extends object = TEntity>(keys: readonly TKey[]): Map<TKey, (TItem | undefined)[]>;
|
|
735
871
|
private resolveRequiredSlot;
|
|
736
872
|
}
|
|
737
873
|
|
|
@@ -768,13 +904,12 @@ declare class OIMDerivedCollectionIndexArrayBased<TKey extends TOIMPk, TPk exten
|
|
|
768
904
|
private readonly orderBy?;
|
|
769
905
|
private readonly unsubscribeFromCollection;
|
|
770
906
|
private readonly keysByPk;
|
|
907
|
+
private readonly orderValueByPk;
|
|
771
908
|
constructor(queue: OIMEventQueue, collection: OIMReactiveCollection<TEntity, TPk>, opts: TOIMDerivedCollectionIndexArrayBasedOptions<TEntity, TKey, TPk>);
|
|
772
909
|
rebuildFromCollection(): void;
|
|
773
910
|
clear(key?: TKey): void;
|
|
774
911
|
destroy(): void;
|
|
775
912
|
private readonly onCollectionUpdate;
|
|
776
|
-
private trackPkKeys;
|
|
777
|
-
private rebuildKey;
|
|
778
913
|
private sortSlots;
|
|
779
914
|
private normalizeKeys;
|
|
780
915
|
}
|
|
@@ -849,9 +984,13 @@ declare class OIMReactiveObject<TKey extends string, TValue> extends OIMObject<T
|
|
|
849
984
|
|
|
850
985
|
declare class OIMCollectionStoreMapDriven<TEntity extends object, TPk extends TOIMPk> extends OIMCollectionStore<TEntity, TPk> {
|
|
851
986
|
protected readonly slots: Map<TPk, TOIMEntitySlot<TEntity, TPk>>;
|
|
987
|
+
protected readonly reservedSlots: Map<TPk, TOIMEntitySlot<TEntity, TPk>>;
|
|
852
988
|
setOneByPk(pk: TPk, entity: TEntity): TOIMEntitySlot<TEntity, TPk>;
|
|
989
|
+
getOrReserveSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk>;
|
|
853
990
|
setManyByPks(pks: readonly TPk[], entities: TEntity[]): TOIMEntitySlot<TEntity, TPk>[];
|
|
854
991
|
getSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk> | undefined;
|
|
992
|
+
findSlotByPk(pk: TPk): TOIMEntitySlot<TEntity, TPk> | undefined;
|
|
993
|
+
private hasSubscribers;
|
|
855
994
|
getSlotsByPks(pks: readonly TPk[]): TOIMEntitySlot<TEntity, TPk>[];
|
|
856
995
|
getAllSlots(): TOIMEntitySlot<TEntity, TPk>[];
|
|
857
996
|
removeOneByPk(pk: TPk): void;
|
|
@@ -938,6 +1077,21 @@ declare class OIMEntityUpdaterFactory<TEntity extends object> {
|
|
|
938
1077
|
createMergeEntityUpdater(): TOIMEntityUpdater<TEntity>;
|
|
939
1078
|
}
|
|
940
1079
|
|
|
1080
|
+
/**
|
|
1081
|
+
* Entity updater that mutates the existing entity in place instead of building a
|
|
1082
|
+
* new merged object. It skips the per-update allocation/copy of the default
|
|
1083
|
+
* merge updater (`{ ...prev, ...draft }`), which is the single biggest data-layer
|
|
1084
|
+
* cost on update-heavy workloads.
|
|
1085
|
+
*
|
|
1086
|
+
* Pair it with a signal-driven binding (re-read the entity on the keyed
|
|
1087
|
+
* notification, e.g. `@oimdb/react`'s `*Signal` hooks): since the stored entity
|
|
1088
|
+
* reference stays stable across updates, reference-comparison bindings
|
|
1089
|
+
* (React's `Object.is` / `useSyncExternalStore`, `React.memo` on entities,
|
|
1090
|
+
* prev/next diffing, time-travel) will NOT see the change. Use only where every
|
|
1091
|
+
* reader is subscription-driven.
|
|
1092
|
+
*/
|
|
1093
|
+
declare function createInPlaceEntityUpdater<TEntity extends object>(): TOIMEntityUpdater<TEntity>;
|
|
1094
|
+
|
|
941
1095
|
/**
|
|
942
1096
|
* Factory for creating index comparators.
|
|
943
1097
|
* Provides common comparison strategies for primary key arrays.
|
|
@@ -1479,4 +1633,4 @@ declare class OIMEntitiesByIndexKeyArrayBasedSelector<TEntity extends object, TP
|
|
|
1479
1633
|
protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
|
|
1480
1634
|
}
|
|
1481
1635
|
|
|
1482
|
-
export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMIndexStore, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandStream, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotResolver, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createOIMCollectionIndexFactory, createOIMCollectionKit };
|
|
1636
|
+
export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierResolver, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMIndexStore, type IOIMSubscribable, OIMCarrierKeyedEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandStream, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotResolver, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit };
|