@oimdb/core 1.4.0 → 1.4.1

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.cts CHANGED
@@ -41,6 +41,7 @@ type TOIMEventHandler<T> = (payload: T) => void;
41
41
 
42
42
  declare class OIMEventEmitter<T extends Record<string, unknown>> {
43
43
  private buckets;
44
+ hasHandlers<K extends keyof T>(event: K): boolean;
44
45
  private getOrCreateBucket;
45
46
  /**
46
47
  * Compacts the handlers array by removing null entries (tombstones) left by handler removal.
@@ -161,6 +162,10 @@ declare abstract class OIMIndexSetBased<TKey extends TOIMPk, TPk extends TOIMPk>
161
162
  * Emit update event with changed keys
162
163
  */
163
164
  protected emitUpdate(keys: TKey[]): void;
165
+ /**
166
+ * Emit update event for a single key (fast-path override point).
167
+ */
168
+ protected emitUpdateOne(key: TKey): void;
164
169
  }
165
170
 
166
171
  /**
@@ -228,83 +233,10 @@ declare abstract class OIMIndexArrayBased<TKey extends TOIMPk, TPk extends TOIMP
228
233
  * Emit update event with changed keys
229
234
  */
230
235
  protected emitUpdate(keys: TKey[]): void;
231
- }
232
-
233
- /**
234
- * Manual Set-based index that allows direct manipulation of key-to-primary-keys mappings.
235
- * Extends the abstract OIMIndexSetBased with manual control methods and optional comparison.
236
- */
237
- declare class OIMIndexManualSetBased<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndexSetBased<TIndexKey, TPk> {
238
- constructor(options?: {
239
- comparePks?: TOIMIndexComparator<TPk>;
240
- store?: OIMIndexStoreSetBased<TIndexKey, TPk>;
241
- });
242
- /**
243
- * Set primary keys for a specific index key, replacing any existing values.
244
- * Uses optional comparator to skip updates if PKs haven't actually changed.
245
- */
246
- setPks(key: TIndexKey, pks: TPk[]): void;
247
- /**
248
- * Add primary keys to a specific index key
249
- */
250
- addPks(key: TIndexKey, pks: readonly TPk[]): void;
251
- /**
252
- * Remove primary keys from a specific index key
253
- */
254
- removePks(key: TIndexKey, pks: readonly TPk[]): void;
255
236
  /**
256
- * Clear all primary keys for a specific index key, or all keys if no key specified
237
+ * Emit update event for a single key (fast-path override point).
257
238
  */
258
- clear(key?: TIndexKey): void;
259
- }
260
-
261
- /**
262
- * Static class containing OIMDB settings and constants.
263
- * Provides access to configuration values used throughout the library.
264
- */
265
- declare class OIMDBSettings {
266
- /**
267
- * Fixed key used in the manual index to store updated keys set in coalescers.
268
- * This constant is exported so users can create their own indexes and pass them to coalescers.
269
- */
270
- static readonly UPDATED_KEYS_INDEX_KEY: "__updatedKeys__";
271
- static readonly FLUSHING_KEYS_INDEX_KEY: "__flushingKeys__";
272
- }
273
-
274
- /**
275
- * Base abstract coalescer that groups updates by keys and emits consolidated events.
276
- * Designed to be extended for different entity types (collections, indexes, etc.).
277
- * Uses SetBased indexes for efficient key tracking.
278
- */
279
- declare abstract class OIMUpdateEventCoalescer<TKey extends TOIMPk> {
280
- readonly emitter: OIMEventEmitter<{
281
- 0: void;
282
- 1: void;
283
- 2: void;
284
- }>;
285
- protected readonly updatedKeysIndex: OIMIndexManualSetBased<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>;
286
- protected readonly flushingUpdatedKeysIndex: OIMIndexManualSetBased<typeof OIMDBSettings.FLUSHING_KEYS_INDEX_KEY, TKey>;
287
- private hasEmittedChanges;
288
- constructor(index?: OIMIndexManualSetBased<typeof OIMDBSettings.UPDATED_KEYS_INDEX_KEY, TKey>, flushingIndex?: OIMIndexManualSetBased<typeof OIMDBSettings.FLUSHING_KEYS_INDEX_KEY, TKey>);
289
- /**
290
- * Get the set of keys that have been updated since last clear
291
- */
292
- getUpdatedKeys(): Set<TKey>;
293
- getFlushingUpdatedKeys(): Set<TKey>;
294
- markUpdatedKeysAsFlushing(): void;
295
- /**
296
- * Clear all updated keys and reset the changed state
297
- */
298
- clearUpdatedKeys(): void;
299
- clearFlushingUpdatedKeys(): void;
300
- /**
301
- * Add keys to the updated set and emit HAS_CHANGES event if needed
302
- */
303
- protected addUpdatedKeys(keys: readonly TKey[]): void;
304
- /**
305
- * Clean up event listeners when coalescer is no longer needed
306
- */
307
- abstract destroy(): void;
239
+ protected emitUpdateOne(key: TKey): void;
308
240
  }
309
241
 
310
242
  /**
@@ -329,20 +261,26 @@ declare enum EOIMEventQueueEventType {
329
261
  */
330
262
  declare class OIMEventQueue {
331
263
  readonly emitter: OIMEventEmitter<Record<EOIMEventQueueEventType, void>>;
332
- protected queue: (() => void)[];
264
+ protected tasks: Set<() => void>;
333
265
  protected readonly scheduler?: OIMEventQueueScheduler;
334
266
  protected flushBound?: () => void;
335
267
  protected isFlushing: boolean;
336
- protected pendingSchedule: boolean;
337
268
  constructor(options?: TOIMEventQueueOptions);
338
269
  /**
339
- * Add a function to the queue. If scheduler is configured and autoSchedule is enabled,
340
- * automatically schedules a flush operation.
270
+ * Enqueue a one-shot task to be executed on the next flush.
271
+ * Returns a dequeue function that can be called to cancel the task before it runs.
341
272
  */
342
- enqueue(fn: () => void): void;
273
+ enqueue(fn: () => void): () => void;
274
+ get isInFlush(): boolean;
343
275
  /**
344
- * Execute all queued functions and clear the queue.
345
- * This method is safe to call multiple times and handles reentrancy.
276
+ * Dequeue (cancel) a previously enqueued task by its dequeue function.
277
+ */
278
+ dequeue(dequeueFn: () => void): void;
279
+ /**
280
+ * Execute all pending tasks.
281
+ *
282
+ * This flush drains until the queue is empty. If tasks enqueue more tasks, they will be
283
+ * executed within the same flush.
346
284
  */
347
285
  flush(): void;
348
286
  /**
@@ -357,41 +295,44 @@ declare class OIMEventQueue {
357
295
  * Clear the queue without executing functions and cancel any scheduled flush.
358
296
  */
359
297
  clear(): void;
298
+ protected ensureScheduled(): void;
360
299
  /**
361
300
  * Clean up scheduler subscription when queue is no longer needed.
362
301
  */
363
302
  destroy(): void;
364
303
  }
365
304
 
366
- /**
367
- * Options for creating an update event emitter */
368
- type TOIMUpdateEventEmitterOptions<TKey extends TOIMPk> = {
369
- coalescer: OIMUpdateEventCoalescer<TKey>;
370
- queue: OIMEventQueue;
371
- };
372
-
305
+ type TOIMUpdateEventEmitterDeliveryMode = 'queue' | 'after_flush' | 'immediate';
373
306
  /**
374
307
  * Universal event emitter that handles subscriptions and notifications for any key type.
375
308
  * Optimized for performance with adaptive algorithms and memory management.
376
309
  */
377
310
  declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
378
- protected keyHandlersBeforeFlush: Map<TKey, Set<TOIMEventHandler<void>>>;
379
311
  protected keyHandlers: Map<TKey, Set<TOIMEventHandler<void>>>;
380
- protected coalescer: OIMUpdateEventCoalescer<TKey>;
381
312
  protected queue: OIMEventQueue;
382
- private isDestroyed;
383
- private isDispatching;
384
- private isInPrePhase;
385
- private hasPendingDuringPrePhase;
313
+ private readonly deliveryMode;
386
314
  private isFlushEnqueued;
387
- constructor(opts: TOIMUpdateEventEmitterOptions<TKey>);
388
- protected handleHasChanges: () => void;
315
+ private dequeueFlush?;
316
+ private updatedKeys;
317
+ private isAfterFlushDeliveryScheduled;
318
+ private unsubscribeAfterFlushDelivery?;
319
+ constructor(queue: OIMEventQueue, deliveryMode?: TOIMUpdateEventEmitterDeliveryMode);
320
+ /**
321
+ * Mark keys as updated and schedule delivery.
322
+ *
323
+ * If there are no subscriptions, this is a no-op and does not allocate or retain keys.
324
+ */
325
+ markUpdatedKeys(keys: readonly TKey[]): void;
326
+ markUpdatedKey(key: TKey): void;
327
+ markAllUpdated(): void;
389
328
  protected readonly onFlush: () => void;
329
+ private deliverImmediate;
330
+ private readonly onAfterFlush;
390
331
  /**
391
- * Helps to run computed values etc.
332
+ * Deliver updated keys and notify handlers once.
333
+ * Re-entrant updates during delivery are forbidden and will throw in markUpdatedKeys().
392
334
  */
393
- protected runPrePhaseDrain(makeHandlerSnapshot: (handlers: Set<TOIMEventHandler<void>>) => TOIMEventHandler<void>[]): Set<TKey>;
394
- protected runHandlersPhase(allKeysForNormalPhase: ReadonlySet<TKey>, makeHandlerSnapshot: (handlers: Set<TOIMEventHandler<void>>) => TOIMEventHandler<void>[]): void;
335
+ protected runSinglePass(makeHandlerSnapshot: (handlers: Set<TOIMEventHandler<void>>) => TOIMEventHandler<void>[]): void;
395
336
  destroy(): void;
396
337
  /**
397
338
  * Get performance metrics for monitoring and debugging
@@ -410,44 +351,21 @@ declare class OIMUpdateEventEmitter<TKey extends TOIMPk> {
410
351
  * Get the number of handlers for a specific key
411
352
  */
412
353
  getHandlerCount(key: TKey): number;
413
- subscribeOnKeyBeforeFlush(key: TKey, handler: TOIMEventHandler<void>): () => void;
414
- unsubscribeFromKeyBeforeFlush(key: TKey, handler: TOIMEventHandler<void>): void;
415
354
  subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
416
355
  unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
417
356
  subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
418
- subscribeOnKeysBeforeFlush(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
419
- unsubscribeFromKeysBeforeFlush(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
420
357
  unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
421
358
  }
422
359
 
423
- declare enum EOIMIndexEventType {
424
- UPDATE = 0
425
- }
426
-
427
- /**
428
- * Index-specific coalescer that tracks index key updates and emits consolidated change events.
429
- * Takes an event emitter directly instead of the whole index to avoid circular dependencies.
430
- */
431
- declare class OIMUpdateEventCoalescerIndex<TIndexKey extends TOIMPk> extends OIMUpdateEventCoalescer<TIndexKey> {
432
- private readonly indexEmitter;
433
- constructor(indexEmitter: OIMEventEmitter<{
434
- [EOIMIndexEventType.UPDATE]: TOIMIndexUpdatePayload<TIndexKey>;
435
- }>);
436
- destroy(): void;
437
- /**
438
- * When the index is updated, we keep track of the updated keys.
439
- */
440
- private handleUpdate;
360
+ interface IOIMKeyedSubscription<TKey extends TOIMPk> {
361
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
362
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
441
363
  }
442
364
 
443
- declare abstract class OIMReactiveIndexSetBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> {
365
+ declare abstract class OIMReactiveIndexSetBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> implements IOIMKeyedSubscription<TKey> {
444
366
  readonly index: TIndex;
445
- readonly updateEventEmitter: OIMUpdateEventEmitter<TKey>;
446
- readonly coalescer: OIMUpdateEventCoalescerIndex<TKey>;
447
- constructor(queue: OIMEventQueue, opts?: {
448
- index: TIndex;
449
- });
450
- protected abstract createDefaultIndex(): TIndex;
367
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
368
+ constructor(queue: OIMEventQueue, createIndex: (updateEmitter: OIMUpdateEventEmitter<TKey>) => TIndex);
451
369
  getPksByKey(key: TKey): Set<TPk>;
452
370
  getPksByKeys(keys: readonly TKey[]): Map<TKey, Set<TPk>>;
453
371
  hasKey(key: TKey): boolean;
@@ -462,17 +380,25 @@ declare abstract class OIMReactiveIndexSetBased<TKey extends TOIMPk, TPk extends
462
380
  maxBucketSize: number;
463
381
  minBucketSize: number;
464
382
  };
383
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
384
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
385
+ unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
386
+ unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
387
+ hasSubscriptions(): boolean;
388
+ getHandlerCount(key: TKey): number;
389
+ getSubscriptionMetrics(): {
390
+ totalKeys: number;
391
+ totalHandlers: number;
392
+ averageHandlersPerKey: number;
393
+ queueLength: number;
394
+ };
465
395
  destroy(): void;
466
396
  }
467
397
 
468
- declare abstract class OIMReactiveIndexArrayBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> {
398
+ declare abstract class OIMReactiveIndexArrayBased<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> implements IOIMKeyedSubscription<TKey> {
469
399
  readonly index: TIndex;
470
- readonly updateEventEmitter: OIMUpdateEventEmitter<TKey>;
471
- readonly coalescer: OIMUpdateEventCoalescerIndex<TKey>;
472
- constructor(queue: OIMEventQueue, opts?: {
473
- index: TIndex;
474
- });
475
- protected abstract createDefaultIndex(): TIndex;
400
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
401
+ constructor(queue: OIMEventQueue, createIndex: (updateEmitter: OIMUpdateEventEmitter<TKey>) => TIndex);
476
402
  getPksByKey(key: TKey): TPk[];
477
403
  getPksByKeys(keys: readonly TKey[]): Map<TKey, TPk[]>;
478
404
  hasKey(key: TKey): boolean;
@@ -487,6 +413,18 @@ declare abstract class OIMReactiveIndexArrayBased<TKey extends TOIMPk, TPk exten
487
413
  maxBucketSize: number;
488
414
  minBucketSize: number;
489
415
  };
416
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
417
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
418
+ unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
419
+ unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
420
+ hasSubscriptions(): boolean;
421
+ getHandlerCount(key: TKey): number;
422
+ getSubscriptionMetrics(): {
423
+ totalKeys: number;
424
+ totalHandlers: number;
425
+ averageHandlersPerKey: number;
426
+ queueLength: number;
427
+ };
490
428
  destroy(): void;
491
429
  }
492
430
 
@@ -523,7 +461,7 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
523
461
  readonly emitter: OIMEventEmitter<{
524
462
  0: TOIMCollectionUpdatePayload<TPk>;
525
463
  }>;
526
- protected readonly selectPk: TOIMPkSelector<TEntity, TPk>;
464
+ readonly selectPk: TOIMPkSelector<TEntity, TPk>;
527
465
  protected readonly store: OIMCollectionStore<TEntity, TPk>;
528
466
  protected readonly updateEntity: TOIMEntityUpdater<TEntity>;
529
467
  constructor(opts?: TOIMCollectionOptions<TEntity, TPk>);
@@ -545,30 +483,42 @@ declare class OIMCollection<TEntity extends object, TPk extends TOIMPk> {
545
483
  destroy(): void;
546
484
  }
547
485
 
548
- declare enum EOIMCollectionEventType {
549
- UPDATE = 0
550
- }
551
-
552
- /**
553
- * Collection-specific coalescer that tracks primary key updates and emits consolidated change events.
554
- * Takes an event emitter directly instead of the whole collection to avoid circular dependencies.
555
- */
556
- declare class OIMUpdateEventCoalescerCollection<TPk extends TOIMPk> extends OIMUpdateEventCoalescer<TPk> {
557
- private readonly collectionEmitter;
558
- constructor(collectionEmitter: OIMEventEmitter<{
559
- [EOIMCollectionEventType.UPDATE]: TOIMCollectionUpdatePayload<TPk>;
560
- }>);
561
- destroy(): void;
562
- /**
563
- * When the collection is updated, we keep track of the updated pks.
564
- */
565
- private handleUpdate;
566
- }
567
-
568
- declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> {
569
- readonly updateEventEmitter: OIMUpdateEventEmitter<TPk>;
570
- readonly coalescer: OIMUpdateEventCoalescerCollection<TPk>;
486
+ declare class OIMReactiveCollection<TEntity extends object, TPk extends TOIMPk> extends OIMCollection<TEntity, TPk> implements IOIMKeyedSubscription<TPk> {
487
+ private readonly queue;
488
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TPk>;
489
+ private readonly anyUpdateHandlers;
490
+ private pendingAnyUpdatePks;
491
+ private isAnyUpdateClearPending;
492
+ private isAnyUpdateScheduled;
493
+ private dequeueAnyUpdate?;
571
494
  constructor(queue: OIMEventQueue, opts?: TOIMCollectionOptions<TEntity, TPk>);
495
+ subscribeOnKey(pk: TPk, handler: TOIMEventHandler<void>): () => void;
496
+ subscribeOnKeys(pks: readonly TPk[], handler: TOIMEventHandler<void>): () => void;
497
+ unsubscribeFromKey(pk: TPk, handler: TOIMEventHandler<void>): void;
498
+ unsubscribeFromKeys(pks: readonly TPk[], handler: TOIMEventHandler<void>): void;
499
+ destroySubscriptions(): void;
500
+ hasSubscriptions(): boolean;
501
+ getHandlerCount(pk: TPk): number;
502
+ getMetrics(): {
503
+ totalKeys: number;
504
+ totalHandlers: number;
505
+ averageHandlersPerKey: number;
506
+ queueLength: number;
507
+ };
508
+ subscribeOnAnyUpdate(handler: (pks: readonly TPk[]) => void): () => void;
509
+ upsertOneByPk(pk: TPk, entity: Partial<TEntity>): void;
510
+ upsertOne(entity: TEntity | Partial<TEntity>): void;
511
+ upsertMany(entities: (TEntity | Partial<TEntity>)[]): void;
512
+ removeOne(entity: TEntity): void;
513
+ removeMany(entities: TEntity[]): void;
514
+ removeOneByPk(pk: TPk): void;
515
+ removeManyByPks(pks: readonly TPk[]): void;
516
+ clear(): void;
517
+ private trackAnyUpdatePk;
518
+ private trackAnyUpdatePks;
519
+ private trackAnyUpdateClear;
520
+ private ensureAnyUpdateEnqueued;
521
+ private readonly runAnyUpdate;
572
522
  destroy(): void;
573
523
  }
574
524
 
@@ -602,38 +552,59 @@ declare class OIMObject<TKey extends string, TValue> {
602
552
  destroy(): void;
603
553
  }
604
554
 
605
- declare enum EOIMObjectEventType {
606
- UPDATE = 0
555
+ declare class OIMReactiveObject<TKey extends string, TValue> extends OIMObject<TKey, TValue> implements IOIMKeyedSubscription<TKey> {
556
+ protected readonly updateEmitter: OIMUpdateEventEmitter<TKey>;
557
+ constructor(queue: OIMEventQueue, opts?: TOIMObjectOptions<TKey, TValue>);
558
+ subscribeOnKey(key: TKey, handler: TOIMEventHandler<void>): () => void;
559
+ subscribeOnKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): () => void;
560
+ unsubscribeFromKey(key: TKey, handler: TOIMEventHandler<void>): void;
561
+ unsubscribeFromKeys(keys: readonly TKey[], handler: TOIMEventHandler<void>): void;
562
+ hasSubscriptions(): boolean;
563
+ getHandlerCount(key: TKey): number;
564
+ getMetrics(): {
565
+ totalKeys: number;
566
+ totalHandlers: number;
567
+ averageHandlersPerKey: number;
568
+ queueLength: number;
569
+ };
570
+ destroy(): void;
607
571
  }
608
572
 
609
573
  /**
610
- * Object-specific coalescer that tracks property key updates and emits consolidated change events.
611
- * Takes an event emitter directly instead of the whole object to avoid circular dependencies.
574
+ * Manual Set-based index that allows direct manipulation of key-to-primary-keys mappings.
575
+ * Extends the abstract OIMIndexSetBased with manual control methods and optional comparison.
612
576
  */
613
- declare class OIMUpdateEventCoalescerObject<TKey extends string> extends OIMUpdateEventCoalescer<TKey> {
614
- private readonly objectEmitter;
615
- constructor(objectEmitter: OIMEventEmitter<{
616
- [EOIMObjectEventType.UPDATE]: TOIMUpdatePayload<TKey>;
617
- }>);
618
- destroy(): void;
577
+ declare class OIMIndexManualSetBased<TIndexKey extends TOIMPk, TPk extends TOIMPk> extends OIMIndexSetBased<TIndexKey, TPk> {
578
+ constructor(options?: {
579
+ comparePks?: TOIMIndexComparator<TPk>;
580
+ store?: OIMIndexStoreSetBased<TIndexKey, TPk>;
581
+ });
619
582
  /**
620
- * When the object is updated, we keep track of the updated keys.
583
+ * Set primary keys for a specific index key, replacing any existing values.
584
+ * Uses optional comparator to skip updates if PKs haven't actually changed.
621
585
  */
622
- private handleUpdate;
623
- }
624
-
625
- declare class OIMReactiveObject<TKey extends string, TValue> extends OIMObject<TKey, TValue> {
626
- readonly updateEventEmitter: OIMUpdateEventEmitter<TKey>;
627
- readonly coalescer: OIMUpdateEventCoalescerObject<TKey>;
628
- constructor(queue: OIMEventQueue, opts?: TOIMObjectOptions<TKey, TValue>);
629
- destroy(): void;
586
+ setPks(key: TIndexKey, pks: TPk[]): void;
587
+ /**
588
+ * Add primary keys to a specific index key
589
+ */
590
+ addPks(key: TIndexKey, pks: readonly TPk[]): void;
591
+ /**
592
+ * Remove primary keys from a specific index key
593
+ */
594
+ removePks(key: TIndexKey, pks: readonly TPk[]): void;
595
+ /**
596
+ * Clear all primary keys for a specific index key, or all keys if no key specified
597
+ */
598
+ clear(key?: TIndexKey): void;
630
599
  }
631
600
 
632
601
  declare class OIMReactiveIndexManualSetBased<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMReactiveIndexSetBased<TKey, TPk, OIMIndexManualSetBased<TKey, TPk>> {
633
602
  constructor(queue: OIMEventQueue, opts?: {
634
- index: OIMIndexManualSetBased<TKey, TPk>;
603
+ indexOptions?: {
604
+ comparePks?: TOIMIndexComparator<TPk>;
605
+ store?: OIMIndexStoreSetBased<TKey, TPk>;
606
+ };
635
607
  });
636
- protected createDefaultIndex(): OIMIndexManualSetBased<TKey, TPk>;
637
608
  setPks(key: TKey, pks: TPk[]): void;
638
609
  addPks(key: TKey, pks: readonly TPk[]): void;
639
610
  removePks(key: TKey, pks: readonly TPk[]): void;
@@ -670,9 +641,11 @@ declare class OIMIndexManualArrayBased<TIndexKey extends TOIMPk, TPk extends TOI
670
641
 
671
642
  declare class OIMReactiveIndexManualArrayBased<TKey extends TOIMPk, TPk extends TOIMPk> extends OIMReactiveIndexArrayBased<TKey, TPk, OIMIndexManualArrayBased<TKey, TPk>> {
672
643
  constructor(queue: OIMEventQueue, opts?: {
673
- index: OIMIndexManualArrayBased<TKey, TPk>;
644
+ indexOptions?: {
645
+ comparePks?: TOIMIndexComparator<TPk>;
646
+ store?: OIMIndexStoreArrayBased<TKey, TPk>;
647
+ };
674
648
  });
675
- protected createDefaultIndex(): OIMIndexManualArrayBased<TKey, TPk>;
676
649
  setPks(key: TKey, pks: TPk[]): void;
677
650
  addPks(key: TKey, pks: readonly TPk[]): void;
678
651
  removePks(key: TKey, pks: readonly TPk[]): void;
@@ -820,29 +793,22 @@ declare class OIMPkSelectorFactory<TEntity extends object, TPk extends TOIMPk> {
820
793
  }, TPk>;
821
794
  }
822
795
 
823
- /**
824
- * Manual coalescer: you mark keys as updated explicitly.
825
- *
826
- * Useful for wrappers that maintain their own "derived" state (e.g. change-sets, command streams)
827
- * and want to reuse `OIMUpdateEventEmitter` batching/reentrancy semantics without piggybacking
828
- * on a collection/index/object emitter payload.
829
- */
830
- declare class OIMUpdateEventCoalescerManual<TKey extends TOIMPk> extends OIMUpdateEventCoalescer<TKey> {
831
- markUpdatedKeys(keys: readonly TKey[]): void;
832
- destroy(): void;
833
- }
834
-
835
796
  type TOIMFieldKey<TEntity extends object> = keyof TEntity & string;
836
797
  /**
837
- * Wrapper around `OIMReactiveCollection` that tracks "changed fields" per entity PK.
798
+ * Wrapper around `OIMCollection` that tracks "changed fields" per entity PK.
838
799
  *
839
800
  * Important: to get field-level info, you must perform writes through this wrapper.
840
- * If you mutate the underlying collection directly, this wrapper will not be able
841
- * to infer which fields changed (core update payloads carry only PKs).
801
+ *
802
+ * DX: if the underlying collection is mutated directly (bypassing this wrapper), we detect it
803
+ * via collection update events and infer changed fields by diffing the last observed entity snapshot.
842
804
  */
843
805
  declare class OIMCollectionChangedFieldsWrapper<TEntity extends object, TPk extends TOIMPk> {
844
- readonly collection: OIMReactiveCollection<TEntity, TPk>;
806
+ readonly collection: OIMCollection<TEntity, TPk>;
845
807
  private readonly selectPk;
808
+ private readonly unsubscribeAfterFlush;
809
+ private readonly unsubscribeFromCollectionEmitter;
810
+ private isInWrite;
811
+ private readonly lastEntitySnapshotByPk;
846
812
  /**
847
813
  * Emits updates scoped by PK. Subscribe, then read state via `getChangedFieldsByPk(...)`
848
814
  * or drain via `consumeChangedFieldsByPk(...)`.
@@ -855,9 +821,7 @@ declare class OIMCollectionChangedFieldsWrapper<TEntity extends object, TPk exte
855
821
  readonly changedFieldsEventEmitter: OIMUpdateEventEmitter<TOIMFieldKey<TEntity>>;
856
822
  private readonly changedFieldsByPk;
857
823
  private readonly changedPksByField;
858
- private readonly changedPksCoalescer;
859
- private readonly changedFieldsCoalescer;
860
- constructor(queue: OIMEventQueue, collection: OIMReactiveCollection<TEntity, TPk>, opts?: {
824
+ constructor(queue: OIMEventQueue, collection: OIMCollection<TEntity, TPk>, opts?: {
861
825
  /**
862
826
  * Optional PK selector for convenience APIs like `upsertOne(...)`.
863
827
  * If not provided, only `upsertOneByPk(...)` should be used.
@@ -873,6 +837,13 @@ declare class OIMCollectionChangedFieldsWrapper<TEntity extends object, TPk exte
873
837
  consumeChangedPksByField(field: TOIMFieldKey<TEntity>): Set<TPk>;
874
838
  clear(): void;
875
839
  destroy(): void;
840
+ private readonly onAfterFlush;
841
+ private readonly onCollectionUpdate;
842
+ private withWrite;
843
+ private trackExternalMutationByPk;
844
+ private diffChangedKeys;
845
+ private updateEntitySnapshot;
846
+ private trackChangedKeys;
876
847
  private trackPatch;
877
848
  }
878
849
 
@@ -910,7 +881,10 @@ type TOIMOrderedListCommand<TPk extends TOIMPk> = {
910
881
  fromIndex: number;
911
882
  toIndex: number;
912
883
  } | {
913
- type: 'reset';
884
+ /**
885
+ * Replace the whole list for this key (preferred name).
886
+ */
887
+ type: 'set';
914
888
  keys: readonly TPk[];
915
889
  };
916
890
 
@@ -923,11 +897,13 @@ type TOIMOrderedListCommand<TPk extends TOIMPk> = {
923
897
  * Notes:
924
898
  * - Commands are buffered per key and delivered batched per queue flush.
925
899
  * - Order of commands is preserved.
926
- * - A future optimizer can collapse the command buffer into `reset(...)` if needed.
900
+ * - A future optimizer can collapse the command buffer into `set(...)` if needed.
927
901
  */
928
902
  declare class OIMOrderedListIndexCommandStreamWrapper<TKey extends TOIMPk, TItemKey extends TOIMPk> {
929
903
  readonly commandsEventEmitter: OIMUpdateEventEmitter<TKey>;
930
- private readonly coalescer;
904
+ private readonly unsubscribeAfterFlush;
905
+ private readonly unsubscribeFromIndexEmitter;
906
+ private isInWrite;
931
907
  private readonly commandsByKey;
932
908
  /** Underlying ordered index (source of truth for the list). */
933
909
  readonly index: OIMIndexManualOrderedArrayBased<TKey, TItemKey>;
@@ -938,7 +914,7 @@ declare class OIMOrderedListIndexCommandStreamWrapper<TKey extends TOIMPk, TItem
938
914
  push(key: TKey, itemKey: TItemKey): void;
939
915
  removeAt(key: TKey, index: number): void;
940
916
  move(key: TKey, fromIndex: number, toIndex: number): void;
941
- reset(key: TKey, keys: readonly TItemKey[]): void;
917
+ set(key: TKey, keys: readonly TItemKey[]): void;
942
918
  /**
943
919
  * Read-only peek at buffered commands without clearing them.
944
920
  */
@@ -950,6 +926,9 @@ declare class OIMOrderedListIndexCommandStreamWrapper<TKey extends TOIMPk, TItem
950
926
  consumeCommands(key: TKey): TOIMOrderedListCommand<TItemKey>[];
951
927
  clear(key?: TKey): void;
952
928
  destroy(): void;
929
+ private readonly onAfterFlush;
930
+ private readonly onIndexUpdate;
931
+ private withWrite;
953
932
  private appendCommand;
954
933
  }
955
934
 
@@ -1050,21 +1029,16 @@ declare class OIMEventQueueSchedulerFactory {
1050
1029
  static createImmediate(): OIMEventQueueSchedulerImmediate;
1051
1030
  }
1052
1031
 
1053
- /**
1054
- * Event types for update coalescers */
1055
- declare enum EOIMUpdateEventCoalescerEventType {
1056
- /**
1057
- * @description Emitted when there are any first changes to the updated keys
1058
- */
1059
- HAS_CHANGES = 0,
1060
- /**
1061
- * @description Emitted before the flush of the updated keys
1062
- */
1063
- BEFORE_FLUSH = 1,
1064
- /**
1065
- * @description Emitted after the flush of the updated keys
1066
- */
1067
- AFTER_FLUSH = 2
1032
+ declare enum EOIMCollectionEventType {
1033
+ UPDATE = 0
1034
+ }
1035
+
1036
+ declare enum EOIMIndexEventType {
1037
+ UPDATE = 0
1038
+ }
1039
+
1040
+ declare enum EOIMObjectEventType {
1041
+ UPDATE = 0
1068
1042
  }
1069
1043
 
1070
1044
  type TOIMIndexKey = string | number | bigint;
@@ -1091,13 +1065,21 @@ type TOIMIndexPksUpdatePayload<TKey extends TOIMPk, TPk extends TOIMPk> = {
1091
1065
  pks: readonly TPk[];
1092
1066
  };
1093
1067
 
1094
- declare enum EOIMEffectPhase {
1095
- PRE = "pre",
1096
- HANDLERS = "handlers"
1068
+ /**
1069
+ * Static class containing OIMDB settings and constants.
1070
+ * Provides access to configuration values used throughout the library.
1071
+ */
1072
+ declare class OIMDBSettings {
1073
+ /**
1074
+ * Fixed key used in the manual index to store updated keys set in coalescers.
1075
+ * This constant is exported so users can create their own indexes and pass them to coalescers.
1076
+ */
1077
+ static readonly UPDATED_KEYS_INDEX_KEY: "__updatedKeys__";
1078
+ static readonly FLUSHING_KEYS_INDEX_KEY: "__flushingKeys__";
1097
1079
  }
1098
1080
 
1099
1081
  interface IOIMEffectDependency {
1100
- subscribe(phase: EOIMEffectPhase, onInvalidate: () => void): () => void;
1082
+ subscribe(onUpdate: () => void): () => void;
1101
1083
  }
1102
1084
 
1103
1085
  type TOIMComputedOptions<TValue> = {
@@ -1110,17 +1092,30 @@ type TOIMComputedUpdatePayload<TKey extends TOIMPk> = {
1110
1092
  keys: readonly TKey[];
1111
1093
  };
1112
1094
 
1113
- declare enum EOIMComputedEventType {
1114
- UPDATE = "update"
1115
- }
1116
-
1117
- declare class OIMUpdateEventCoalescerComputed<TKey extends TOIMPk> extends OIMUpdateEventCoalescer<TKey> {
1118
- private readonly computedEmitter;
1119
- constructor(computedEmitter: OIMEventEmitter<{
1120
- [EOIMComputedEventType.UPDATE]: TOIMComputedUpdatePayload<TKey>;
1121
- }>);
1122
- destroy(): void;
1123
- private handleUpdate;
1095
+ /**
1096
+ * Computative runtime that schedules derived computations by levels and runs them
1097
+ * on `queue.flush()` boundary (AFTER_FLUSH).
1098
+ */
1099
+ declare class OIMComputativeRuntime {
1100
+ readonly queue: OIMEventQueue;
1101
+ private isFlushScheduled;
1102
+ private isFlushing;
1103
+ private minLevel;
1104
+ private maxLevel;
1105
+ private readonly dirtyByLevel;
1106
+ private readonly afterFlushTasks;
1107
+ constructor(queue: OIMEventQueue);
1108
+ /**
1109
+ * Schedule a one-shot task to run on the next `queue.flush()` (AFTER_FLUSH),
1110
+ * ordered by `level` ascending.
1111
+ */
1112
+ schedule(task: () => void, level?: number): () => void;
1113
+ /**
1114
+ * Run once at the start of the next runtime flush (i.e. after queue.flush()).
1115
+ * Useful for resubscribing dependencies exactly once per source flush.
1116
+ */
1117
+ scheduleAfterFlush(task: () => void): () => void;
1118
+ private flush;
1124
1119
  }
1125
1120
 
1126
1121
  type TOIMComputedKey$2 = 'value';
@@ -1128,27 +1123,26 @@ declare class OIMComputed<TValue> {
1128
1123
  readonly emitter: OIMEventEmitter<{
1129
1124
  update: TOIMComputedUpdatePayload<TOIMComputedKey$2>;
1130
1125
  }>;
1131
- readonly coalescer: OIMUpdateEventCoalescerComputed<TOIMComputedKey$2>;
1132
1126
  readonly updateEventEmitter: OIMUpdateEventEmitter<TOIMComputedKey$2>;
1133
- private readonly queue;
1127
+ private readonly runtime;
1134
1128
  private readonly compute;
1135
1129
  private readonly compare;
1136
1130
  private readonly deps;
1137
1131
  private value;
1138
1132
  private hasValue;
1139
1133
  private isDirty;
1140
- private isInFlush;
1141
- private hasRecomputedInThisFlush;
1142
1134
  private readonly effect;
1143
- private readonly handleQueueBeforeFlush;
1144
- private readonly handleQueueAfterFlush;
1145
- constructor(queue: OIMEventQueue, opts: TOIMComputedOptions<TValue>);
1135
+ constructor(runtime: OIMComputativeRuntime, opts: TOIMComputedOptions<TValue>);
1146
1136
  get(): TValue;
1147
1137
  getIfReady(): TValue | undefined;
1148
1138
  destroy(): void;
1149
1139
  private recomputeAndEmitIfChanged;
1150
1140
  }
1151
1141
 
1142
+ declare enum EOIMComputedEventType {
1143
+ UPDATE = "update"
1144
+ }
1145
+
1152
1146
  type TOIMComputedKey$1 = 'value';
1153
1147
  interface IOIMComputedEventSource {
1154
1148
  emitter: OIMEventEmitter<{
@@ -1158,62 +1152,64 @@ interface IOIMComputedEventSource {
1158
1152
 
1159
1153
  type TOIMEffectOptions = {
1160
1154
  deps?: readonly IOIMEffectDependency[];
1161
- phase: EOIMEffectPhase;
1162
- onInvalidate?: () => void;
1155
+ onUpdate?: () => void;
1163
1156
  run: () => void;
1164
1157
  };
1165
1158
 
1166
1159
  declare class OIMEffect {
1167
- private readonly queue;
1168
- private readonly phase;
1169
- private readonly onInvalidate?;
1160
+ private readonly runtime;
1161
+ private readonly onUpdate?;
1170
1162
  private readonly run;
1171
1163
  private readonly deps;
1172
- private unsubscribers;
1173
- private isDestroyed;
1174
- private isInFlush;
1175
- private hasRunInThisFlush;
1164
+ private readonly sourceDeps;
1165
+ private readonly computedDeps;
1166
+ private sourceUnsubscribers;
1167
+ private computedUnsubscribers;
1168
+ private dequeueResubscribe?;
1169
+ private isResubscribeEnqueued;
1170
+ private isTemporarilyUnsubscribedForFlush;
1176
1171
  private isScheduled;
1177
- private readonly handleQueueBeforeFlush;
1178
- private readonly handleQueueAfterFlush;
1172
+ private dequeueScheduled?;
1179
1173
  private readonly runTask;
1180
- constructor(queue: OIMEventQueue, opts: TOIMEffectOptions);
1174
+ constructor(runtime: OIMComputativeRuntime, opts: TOIMEffectOptions);
1181
1175
  destroy(): void;
1182
- private invalidate;
1176
+ private onSourceInvalidate;
1177
+ private onComputedInvalidate;
1183
1178
  private runOnce;
1179
+ private subscribeToDeps;
1180
+ private unsubscribeFromSourceDeps;
1181
+ private unsubscribeFromAllDeps;
1182
+ private ensureResubscribeAfterFlush;
1183
+ private readonly onAfterFlush;
1184
1184
  }
1185
1185
 
1186
1186
  declare class OIMEffectDependencyKeyed<TKey extends TOIMPk> implements IOIMEffectDependency {
1187
- private readonly updateEventEmitter;
1187
+ private readonly subscription;
1188
1188
  private readonly key;
1189
1189
  private readonly keys;
1190
- constructor(updateEventEmitter: OIMUpdateEventEmitter<TKey>, keyOrKeys: TKey | readonly TKey[]);
1191
- subscribe(phase: EOIMEffectPhase, onInvalidate: () => void): () => void;
1190
+ constructor(subscription: IOIMKeyedSubscription<TKey>, keyOrKeys: TKey | readonly TKey[]);
1191
+ subscribe(onUpdate: () => void): () => void;
1192
1192
  }
1193
1193
 
1194
1194
  declare class OIMEffectDependencyKeyedObject<TKey extends string, TValue> implements IOIMEffectDependency {
1195
1195
  private readonly dep;
1196
1196
  constructor(object: OIMReactiveObject<TKey, TValue>, key: TKey);
1197
1197
  constructor(object: OIMReactiveObject<TKey, TValue>, keys: readonly TKey[]);
1198
- subscribe(phase: EOIMEffectPhase, onInvalidate: () => void): () => void;
1198
+ subscribe(onUpdate: () => void): () => void;
1199
1199
  }
1200
1200
 
1201
1201
  declare class OIMEffectDependencyKeyedCollection<TEntity extends object, TPk extends TOIMPk> implements IOIMEffectDependency {
1202
1202
  private readonly dep;
1203
1203
  constructor(collection: OIMReactiveCollection<TEntity, TPk>, pk: TPk);
1204
1204
  constructor(collection: OIMReactiveCollection<TEntity, TPk>, pks: readonly TPk[]);
1205
- subscribe(phase: EOIMEffectPhase, onInvalidate: () => void): () => void;
1205
+ subscribe(onUpdate: () => void): () => void;
1206
1206
  }
1207
1207
 
1208
1208
  declare class OIMEffectDependencyKeyedIndex<TKey extends TOIMPk> implements IOIMEffectDependency {
1209
1209
  private readonly dep;
1210
- constructor(index: {
1211
- updateEventEmitter: OIMUpdateEventEmitter<TKey>;
1212
- }, key: TKey);
1213
- constructor(index: {
1214
- updateEventEmitter: OIMUpdateEventEmitter<TKey>;
1215
- }, keys: readonly TKey[]);
1216
- subscribe(phase: EOIMEffectPhase, onInvalidate: () => void): () => void;
1210
+ constructor(index: IOIMKeyedSubscription<TKey>, key: TKey);
1211
+ constructor(index: IOIMKeyedSubscription<TKey>, keys: readonly TKey[]);
1212
+ subscribe(onUpdate: () => void): () => void;
1217
1213
  }
1218
1214
 
1219
1215
  type TOIMComputedKey = 'value';
@@ -1225,14 +1221,132 @@ type TOIMComputedLike = {
1225
1221
  };
1226
1222
  /**
1227
1223
  * Effect dependency on a computed.
1228
- *
1229
- * - PRE: subscribe directly to computed.emitter for immediate invalidation during pre-drain.
1230
- * - HANDLERS: subscribe via computed.updateEventEmitter (normal handlers) which is delivered through queue.
1231
1224
  */
1232
1225
  declare class OIMEffectDependencyComputed implements IOIMEffectDependency {
1233
1226
  private readonly computed;
1234
1227
  constructor(computed: TOIMComputedLike);
1235
- subscribe(phase: EOIMEffectPhase, onInvalidate: () => void): () => void;
1228
+ subscribe(onUpdate: () => void): () => void;
1229
+ }
1230
+
1231
+ interface IOIMSelectorComputedDependency {
1232
+ subscribe(onUpdate: () => void): () => void;
1233
+ }
1234
+
1235
+ interface IOIMSelectorSourceDependency {
1236
+ subscribe(onUpdate: () => void): () => void;
1237
+ }
1238
+
1239
+ declare abstract class OIMSelector<TValue> {
1240
+ protected readonly runtime: OIMComputativeRuntime;
1241
+ protected readonly sourceDeps: readonly IOIMSelectorSourceDependency[];
1242
+ protected readonly computedDeps: readonly IOIMSelectorComputedDependency[];
1243
+ private readonly listeners;
1244
+ private sourceUnsubscribers;
1245
+ private computedUnsubscribers;
1246
+ private dequeueResubscribe?;
1247
+ private isResubscribeEnqueued;
1248
+ private isTemporarilyUnsubscribedForFlush;
1249
+ private isDeliveryEnqueued;
1250
+ private dequeueDelivery?;
1251
+ private hasLastValue;
1252
+ private lastValue;
1253
+ protected get queue(): OIMEventQueue;
1254
+ protected constructor(runtime: OIMComputativeRuntime, sourceDeps: readonly IOIMSelectorSourceDependency[], computedDeps?: readonly IOIMSelectorComputedDependency[]);
1255
+ abstract getValue(): TValue;
1256
+ /**
1257
+ * Start watching this selector. The callback is called immediately with the current value,
1258
+ * then coalesced and delivered on `queue.flush()` when the selector invalidates.
1259
+ */
1260
+ watch(onValue: (value: TValue) => void): () => void;
1261
+ protected areEqual(prev: TValue, next: TValue): boolean;
1262
+ private readonly onSourceInvalidate;
1263
+ private readonly onComputedInvalidate;
1264
+ private readonly deliver;
1265
+ private setLastValue;
1266
+ private subscribeToDeps;
1267
+ private unsubscribeFromSourceDeps;
1268
+ private unsubscribeFromAllDeps;
1269
+ private ensureResubscribeAfterFlush;
1270
+ private readonly onAfterFlush;
1271
+ }
1272
+
1273
+ declare class OIMCollectionByPkSelector<TEntity extends object, TPk extends TOIMPk> extends OIMSelector<TEntity | undefined> {
1274
+ private readonly collection;
1275
+ private readonly pk;
1276
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, pk: TPk);
1277
+ getValue(): TEntity | undefined;
1278
+ }
1279
+
1280
+ declare class OIMCollectionByPksSelector<TEntity extends object, TPk extends TOIMPk> extends OIMSelector<readonly (TEntity | undefined)[]> {
1281
+ private readonly collection;
1282
+ private readonly pks;
1283
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, pks: readonly TPk[]);
1284
+ getValue(): readonly (TEntity | undefined)[];
1285
+ protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
1286
+ }
1287
+
1288
+ declare class OIMObjectValueByKeySelector<TKey extends string, TValue> extends OIMSelector<TValue | undefined> {
1289
+ private readonly obj;
1290
+ private readonly key;
1291
+ constructor(runtime: OIMComputativeRuntime, obj: OIMReactiveObject<TKey, TValue>, key: TKey);
1292
+ getValue(): TValue | undefined;
1293
+ }
1294
+
1295
+ declare class OIMObjectValuesByKeysSelector<TKey extends string, TValue> extends OIMSelector<readonly (TValue | undefined)[]> {
1296
+ private readonly obj;
1297
+ private readonly keys;
1298
+ constructor(runtime: OIMComputativeRuntime, obj: OIMReactiveObject<TKey, TValue>, keys: readonly TKey[]);
1299
+ getValue(): readonly (TValue | undefined)[];
1300
+ protected areEqual(prev: readonly (TValue | undefined)[], next: readonly (TValue | undefined)[]): boolean;
1301
+ }
1302
+
1303
+ declare class OIMIndexPksByKeySetBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> extends OIMSelector<Set<TPk>> {
1304
+ private readonly reactiveIndex;
1305
+ private readonly key;
1306
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexSetBased<TKey, TPk, TIndex>, key: TKey);
1307
+ getValue(): Set<TPk>;
1308
+ }
1309
+
1310
+ declare class OIMIndexPksByKeyArrayBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> extends OIMSelector<readonly TPk[]> {
1311
+ private readonly reactiveIndex;
1312
+ private readonly key;
1313
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexArrayBased<TKey, TPk, TIndex>, key: TKey);
1314
+ getValue(): readonly TPk[];
1315
+ protected areEqual(prev: readonly TPk[], next: readonly TPk[]): boolean;
1316
+ }
1317
+
1318
+ declare class OIMIndexPksByKeysSetBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> extends OIMSelector<readonly TPk[]> {
1319
+ private readonly reactiveIndex;
1320
+ private readonly keys;
1321
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexSetBased<TKey, TPk, TIndex>, keys: readonly TKey[]);
1322
+ getValue(): readonly TPk[];
1323
+ protected areEqual(prev: readonly TPk[], next: readonly TPk[]): boolean;
1324
+ }
1325
+
1326
+ declare class OIMIndexPksByKeysArrayBasedSelector<TKey extends TOIMPk, TPk extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> extends OIMSelector<readonly TPk[]> {
1327
+ private readonly reactiveIndex;
1328
+ private readonly keys;
1329
+ constructor(runtime: OIMComputativeRuntime, reactiveIndex: OIMReactiveIndexArrayBased<TKey, TPk, TIndex>, keys: readonly TKey[]);
1330
+ getValue(): readonly TPk[];
1331
+ protected areEqual(prev: readonly TPk[], next: readonly TPk[]): boolean;
1332
+ }
1333
+
1334
+ declare class OIMEntitiesByIndexKeySetBasedSelector<TEntity extends object, TPk extends TOIMPk, TKey extends TOIMPk, TIndex extends OIMIndexSetBased<TKey, TPk>> extends OIMSelector<readonly (TEntity | undefined)[]> {
1335
+ private readonly collection;
1336
+ private readonly reactiveIndex;
1337
+ private readonly key;
1338
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, reactiveIndex: OIMReactiveIndexSetBased<TKey, TPk, TIndex>, key: TKey);
1339
+ getValue(): readonly (TEntity | undefined)[];
1340
+ protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
1341
+ }
1342
+
1343
+ declare class OIMEntitiesByIndexKeyArrayBasedSelector<TEntity extends object, TPk extends TOIMPk, TKey extends TOIMPk, TIndex extends OIMIndexArrayBased<TKey, TPk>> extends OIMSelector<readonly (TEntity | undefined)[]> {
1344
+ private readonly collection;
1345
+ private readonly reactiveIndex;
1346
+ private readonly key;
1347
+ constructor(runtime: OIMComputativeRuntime, collection: OIMReactiveCollection<TEntity, TPk>, reactiveIndex: OIMReactiveIndexArrayBased<TKey, TPk, TIndex>, key: TKey);
1348
+ getValue(): readonly (TEntity | undefined)[];
1349
+ protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
1236
1350
  }
1237
1351
 
1238
- export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEffectPhase, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, EOIMUpdateEventCoalescerEventType, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionChangedFieldsWrapper, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputed, OIMDBSettings, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexSetBased, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMOrderedListIndexCommandStreamWrapper, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMUpdateEventCoalescer, OIMUpdateEventCoalescerCollection, OIMUpdateEventCoalescerComputed, OIMUpdateEventCoalescerIndex, OIMUpdateEventCoalescerManual, OIMUpdateEventCoalescerObject, OIMUpdateEventEmitter, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMEffectOptions, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdateEventEmitterOptions, type TOIMUpdatePayload };
1352
+ export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFieldsWrapper, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputativeRuntime, OIMComputed, OIMDBSettings, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerTimeout, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListIndexCommandStreamWrapper, OIMPkSelectorFactory, OIMRICollection, OIMReactiveCollection, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMCollectionOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMEffectOptions, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptions, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMPk, type TOIMPkSelector, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload };