@oimdb/core 3.9.0 → 3.10.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 CHANGED
@@ -1844,6 +1844,7 @@ var OIMCollectionIndexManualOrderedArrayBased = class extends OIMIndexManualOrde
1844
1844
  var EOIMEventQueueEventType = /* @__PURE__ */ ((EOIMEventQueueEventType2) => {
1845
1845
  EOIMEventQueueEventType2[EOIMEventQueueEventType2["AFTER_FLUSH"] = 0] = "AFTER_FLUSH";
1846
1846
  EOIMEventQueueEventType2[EOIMEventQueueEventType2["BEFORE_FLUSH"] = 1] = "BEFORE_FLUSH";
1847
+ EOIMEventQueueEventType2[EOIMEventQueueEventType2["FLUSH_ERROR"] = 2] = "FLUSH_ERROR";
1847
1848
  return EOIMEventQueueEventType2;
1848
1849
  })(EOIMEventQueueEventType || {});
1849
1850
 
@@ -4381,6 +4382,7 @@ var OIMEventQueue = class {
4381
4382
  this.tasksSpare = /* @__PURE__ */ new Set();
4382
4383
  this.isFlushing = false;
4383
4384
  this.scheduler = options.scheduler;
4385
+ this.onError = options.onError;
4384
4386
  if (this.scheduler) {
4385
4387
  this.flushBound = () => this.flush();
4386
4388
  this.scheduler.on(
@@ -4420,12 +4422,34 @@ var OIMEventQueue = class {
4420
4422
  const flushing = this.tasks;
4421
4423
  this.tasks = this.tasksSpare;
4422
4424
  this.flushing = flushing;
4423
- for (const task of flushing) task();
4424
- flushing.clear();
4425
- this.tasksSpare = flushing;
4426
- this.flushing = void 0;
4427
- this.isFlushing = false;
4425
+ let errors;
4426
+ try {
4427
+ for (const task of flushing) {
4428
+ try {
4429
+ task();
4430
+ } catch (error) {
4431
+ (errors ?? (errors = [])).push(error);
4432
+ this.emitter.emit(2 /* FLUSH_ERROR */, {
4433
+ error
4434
+ });
4435
+ this.onError?.(error);
4436
+ }
4437
+ }
4438
+ } finally {
4439
+ flushing.clear();
4440
+ this.tasksSpare = flushing;
4441
+ this.flushing = void 0;
4442
+ this.isFlushing = false;
4443
+ }
4428
4444
  this.emitter.emit(0 /* AFTER_FLUSH */, void 0);
4445
+ if (errors && this.onError === void 0) {
4446
+ if (errors.length === 1) throw errors[0];
4447
+ const AggregateErrorCtor = globalThis.AggregateError;
4448
+ throw AggregateErrorCtor ? new AggregateErrorCtor(
4449
+ errors,
4450
+ "Errors thrown during queue flush"
4451
+ ) : errors[0];
4452
+ }
4429
4453
  }
4430
4454
  /**
4431
4455
  * Get the current number of queued functions.
package/dist/index.d.cts CHANGED
@@ -384,18 +384,34 @@ type TOIMEventQueueOptions = {
384
384
  * If not provided, flush() must be called manually.
385
385
  */
386
386
  scheduler?: OIMEventQueueScheduler;
387
+ /**
388
+ * Handler for an error thrown by a task during flush. When set, the queue
389
+ * treats the error as handled — it is NOT re-raised out of `flush()`. When
390
+ * NOT set, the error propagates (loud by default: uncaught in async/scheduled
391
+ * mode, thrown to the caller of a manual `flush()`).
392
+ *
393
+ * Either way the queue's own state is always restored (one failing task never
394
+ * wedges the queue) and a `FLUSH_ERROR` event is emitted for tooling.
395
+ */
396
+ onError?: (error: unknown) => void;
387
397
  };
388
398
 
389
- declare enum EOIMEventQueueEventType {
390
- AFTER_FLUSH = 0,
391
- BEFORE_FLUSH = 1
392
- }
399
+ /** Payload of the `EOIMEventQueueEventType.FLUSH_ERROR` event. */
400
+ type TOIMFlushError = {
401
+ /** The value a queue task threw (not necessarily an `Error`). */
402
+ error: unknown;
403
+ };
393
404
 
394
405
  /**
395
406
  * Event queue that can optionally integrate with a scheduler for automatic flushing.
396
407
  */
397
408
  declare class OIMEventQueue {
398
- readonly emitter: OIMEventEmitter<Record<EOIMEventQueueEventType, void>>;
409
+ readonly emitter: OIMEventEmitter<{
410
+ 1: void;
411
+ 0: void;
412
+ 2: TOIMFlushError;
413
+ }>;
414
+ protected readonly onError?: (error: unknown) => void;
399
415
  protected tasks: Set<() => void>;
400
416
  protected tasksSpare: Set<() => void>;
401
417
  protected flushing?: Set<() => void>;
@@ -2894,6 +2910,18 @@ declare enum EOIMIndexEventType {
2894
2910
  UPDATE = 0
2895
2911
  }
2896
2912
 
2913
+ declare enum EOIMEventQueueEventType {
2914
+ AFTER_FLUSH = 0,
2915
+ BEFORE_FLUSH = 1,
2916
+ /**
2917
+ * A task threw during flush. Emitted once per failing task, ALWAYS (whether
2918
+ * or not an `onError` handler is installed) — an observation channel for
2919
+ * tooling (devtools / MCP). It does not replace the error being raised: with
2920
+ * no `onError` handler the error still propagates out of `flush()`.
2921
+ */
2922
+ FLUSH_ERROR = 2
2923
+ }
2924
+
2897
2925
  declare enum EOIMObjectEventType {
2898
2926
  UPDATE = 0
2899
2927
  }
@@ -3158,4 +3186,4 @@ declare class OIMEntitiesByGlobalIndexArrayBasedSelector<TEntity extends object,
3158
3186
  protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
3159
3187
  }
3160
3188
 
3161
- export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierBucketStore, type IOIMCarrierProvider, type IOIMComputedEventSource, type IOIMDisposable, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMGlobalIndexSlotSource, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedMap, type IOIMKeyedSet, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMPkCodec, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMBucketCarrierProvider, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMCollectionStoreTrieDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMDisposeScope, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMGlobalIndexSlotMap, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMIndexStoreTrieDrivenArrayBased, OIMIndexStoreTrieDrivenSetBased, OIMKeyPathCarrierProvider, OIMKeyedBucketArrayBased, OIMKeyedBucketSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkCodecKeyPath, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexCompositeTrieArrayBased, OIMReactiveCollectionIndexCompositeTrieSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, OIMTrieMap, OIMTrieSet, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexCompositeArrayBasedOptions, type TOIMCollectionIndexCompositeSetBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMDisposable, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotGetter, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMKey, type TOIMKeyPath, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsCompositeArrayIndexOptions, type TOIMRelationsCompositeSetIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMDisposeScope, createOIMGlobalIndexSlotMap, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
3189
+ export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierBucketStore, type IOIMCarrierProvider, type IOIMComputedEventSource, type IOIMDisposable, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMGlobalIndexSlotSource, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedMap, type IOIMKeyedSet, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMPkCodec, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMBucketCarrierProvider, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMCollectionStoreTrieDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMDisposeScope, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMGlobalIndexSlotMap, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMIndexStoreTrieDrivenArrayBased, OIMIndexStoreTrieDrivenSetBased, OIMKeyPathCarrierProvider, OIMKeyedBucketArrayBased, OIMKeyedBucketSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkCodecKeyPath, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexCompositeTrieArrayBased, OIMReactiveCollectionIndexCompositeTrieSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, OIMTrieMap, OIMTrieSet, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexCompositeArrayBasedOptions, type TOIMCollectionIndexCompositeSetBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMDisposable, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotGetter, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMFlushError, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMKey, type TOIMKeyPath, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsCompositeArrayIndexOptions, type TOIMRelationsCompositeSetIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMDisposeScope, createOIMGlobalIndexSlotMap, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
package/dist/index.d.ts CHANGED
@@ -384,18 +384,34 @@ type TOIMEventQueueOptions = {
384
384
  * If not provided, flush() must be called manually.
385
385
  */
386
386
  scheduler?: OIMEventQueueScheduler;
387
+ /**
388
+ * Handler for an error thrown by a task during flush. When set, the queue
389
+ * treats the error as handled — it is NOT re-raised out of `flush()`. When
390
+ * NOT set, the error propagates (loud by default: uncaught in async/scheduled
391
+ * mode, thrown to the caller of a manual `flush()`).
392
+ *
393
+ * Either way the queue's own state is always restored (one failing task never
394
+ * wedges the queue) and a `FLUSH_ERROR` event is emitted for tooling.
395
+ */
396
+ onError?: (error: unknown) => void;
387
397
  };
388
398
 
389
- declare enum EOIMEventQueueEventType {
390
- AFTER_FLUSH = 0,
391
- BEFORE_FLUSH = 1
392
- }
399
+ /** Payload of the `EOIMEventQueueEventType.FLUSH_ERROR` event. */
400
+ type TOIMFlushError = {
401
+ /** The value a queue task threw (not necessarily an `Error`). */
402
+ error: unknown;
403
+ };
393
404
 
394
405
  /**
395
406
  * Event queue that can optionally integrate with a scheduler for automatic flushing.
396
407
  */
397
408
  declare class OIMEventQueue {
398
- readonly emitter: OIMEventEmitter<Record<EOIMEventQueueEventType, void>>;
409
+ readonly emitter: OIMEventEmitter<{
410
+ 1: void;
411
+ 0: void;
412
+ 2: TOIMFlushError;
413
+ }>;
414
+ protected readonly onError?: (error: unknown) => void;
399
415
  protected tasks: Set<() => void>;
400
416
  protected tasksSpare: Set<() => void>;
401
417
  protected flushing?: Set<() => void>;
@@ -2894,6 +2910,18 @@ declare enum EOIMIndexEventType {
2894
2910
  UPDATE = 0
2895
2911
  }
2896
2912
 
2913
+ declare enum EOIMEventQueueEventType {
2914
+ AFTER_FLUSH = 0,
2915
+ BEFORE_FLUSH = 1,
2916
+ /**
2917
+ * A task threw during flush. Emitted once per failing task, ALWAYS (whether
2918
+ * or not an `onError` handler is installed) — an observation channel for
2919
+ * tooling (devtools / MCP). It does not replace the error being raised: with
2920
+ * no `onError` handler the error still propagates out of `flush()`.
2921
+ */
2922
+ FLUSH_ERROR = 2
2923
+ }
2924
+
2897
2925
  declare enum EOIMObjectEventType {
2898
2926
  UPDATE = 0
2899
2927
  }
@@ -3158,4 +3186,4 @@ declare class OIMEntitiesByGlobalIndexArrayBasedSelector<TEntity extends object,
3158
3186
  protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
3159
3187
  }
3160
3188
 
3161
- export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierBucketStore, type IOIMCarrierProvider, type IOIMComputedEventSource, type IOIMDisposable, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMGlobalIndexSlotSource, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedMap, type IOIMKeyedSet, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMPkCodec, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMBucketCarrierProvider, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMCollectionStoreTrieDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMDisposeScope, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMGlobalIndexSlotMap, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMIndexStoreTrieDrivenArrayBased, OIMIndexStoreTrieDrivenSetBased, OIMKeyPathCarrierProvider, OIMKeyedBucketArrayBased, OIMKeyedBucketSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkCodecKeyPath, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexCompositeTrieArrayBased, OIMReactiveCollectionIndexCompositeTrieSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, OIMTrieMap, OIMTrieSet, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexCompositeArrayBasedOptions, type TOIMCollectionIndexCompositeSetBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMDisposable, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotGetter, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMKey, type TOIMKeyPath, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsCompositeArrayIndexOptions, type TOIMRelationsCompositeSetIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMDisposeScope, createOIMGlobalIndexSlotMap, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
3189
+ export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierBucketStore, type IOIMCarrierProvider, type IOIMComputedEventSource, type IOIMDisposable, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMGlobalIndexSlotSource, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedMap, type IOIMKeyedSet, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMPkCodec, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMBucketCarrierProvider, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMCollectionStoreTrieDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMDisposeScope, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMGlobalIndexSlotMap, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMIndexStoreTrieDrivenArrayBased, OIMIndexStoreTrieDrivenSetBased, OIMKeyPathCarrierProvider, OIMKeyedBucketArrayBased, OIMKeyedBucketSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkCodecKeyPath, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexCompositeTrieArrayBased, OIMReactiveCollectionIndexCompositeTrieSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, OIMTrieMap, OIMTrieSet, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexCompositeArrayBasedOptions, type TOIMCollectionIndexCompositeSetBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMDisposable, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotGetter, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMFlushError, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMKey, type TOIMKeyPath, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsCompositeArrayIndexOptions, type TOIMRelationsCompositeSetIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMDisposeScope, createOIMGlobalIndexSlotMap, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
package/dist/index.js CHANGED
@@ -1699,6 +1699,7 @@ var OIMCollectionIndexManualOrderedArrayBased = class extends OIMIndexManualOrde
1699
1699
  var EOIMEventQueueEventType = /* @__PURE__ */ ((EOIMEventQueueEventType2) => {
1700
1700
  EOIMEventQueueEventType2[EOIMEventQueueEventType2["AFTER_FLUSH"] = 0] = "AFTER_FLUSH";
1701
1701
  EOIMEventQueueEventType2[EOIMEventQueueEventType2["BEFORE_FLUSH"] = 1] = "BEFORE_FLUSH";
1702
+ EOIMEventQueueEventType2[EOIMEventQueueEventType2["FLUSH_ERROR"] = 2] = "FLUSH_ERROR";
1702
1703
  return EOIMEventQueueEventType2;
1703
1704
  })(EOIMEventQueueEventType || {});
1704
1705
 
@@ -4236,6 +4237,7 @@ var OIMEventQueue = class {
4236
4237
  this.tasksSpare = /* @__PURE__ */ new Set();
4237
4238
  this.isFlushing = false;
4238
4239
  this.scheduler = options.scheduler;
4240
+ this.onError = options.onError;
4239
4241
  if (this.scheduler) {
4240
4242
  this.flushBound = () => this.flush();
4241
4243
  this.scheduler.on(
@@ -4275,12 +4277,34 @@ var OIMEventQueue = class {
4275
4277
  const flushing = this.tasks;
4276
4278
  this.tasks = this.tasksSpare;
4277
4279
  this.flushing = flushing;
4278
- for (const task of flushing) task();
4279
- flushing.clear();
4280
- this.tasksSpare = flushing;
4281
- this.flushing = void 0;
4282
- this.isFlushing = false;
4280
+ let errors;
4281
+ try {
4282
+ for (const task of flushing) {
4283
+ try {
4284
+ task();
4285
+ } catch (error) {
4286
+ (errors ?? (errors = [])).push(error);
4287
+ this.emitter.emit(2 /* FLUSH_ERROR */, {
4288
+ error
4289
+ });
4290
+ this.onError?.(error);
4291
+ }
4292
+ }
4293
+ } finally {
4294
+ flushing.clear();
4295
+ this.tasksSpare = flushing;
4296
+ this.flushing = void 0;
4297
+ this.isFlushing = false;
4298
+ }
4283
4299
  this.emitter.emit(0 /* AFTER_FLUSH */, void 0);
4300
+ if (errors && this.onError === void 0) {
4301
+ if (errors.length === 1) throw errors[0];
4302
+ const AggregateErrorCtor = globalThis.AggregateError;
4303
+ throw AggregateErrorCtor ? new AggregateErrorCtor(
4304
+ errors,
4305
+ "Errors thrown during queue flush"
4306
+ ) : errors[0];
4307
+ }
4284
4308
  }
4285
4309
  /**
4286
4310
  * Get the current number of queued functions.
package/llms.txt CHANGED
@@ -30,6 +30,7 @@ import { OIMEventQueue, OIMEventQueueSchedulerImmediate } from '@oimdb/core';
30
30
 
31
31
  const queue = new OIMEventQueue({
32
32
  scheduler: new OIMEventQueueSchedulerImmediate(), // macrotask: setImmediate (Node), fallback MessageChannel / setTimeout(0) (browser)
33
+ onError: (e) => reportToSentry(e), // optional; see below
33
34
  });
34
35
  // or: OIMEventQueueSchedulerMicrotask (next microtask, before paint — lowest latency),
35
36
  // OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerTimeout
@@ -38,6 +39,8 @@ const queue = new OIMEventQueue({
38
39
  // debug/diagnostic only: swap in at the root to test if a bug is coalescing-related.
39
40
  ```
40
41
 
42
+ **Errors during flush.** If a task (subscriber / effect / computed) throws while the queue is flushing, the other tasks in that flush still run (each is isolated) and the queue's internal state is always restored — one bad task never wedges the queue. By default the error is then **raised, not swallowed**: it propagates out of `flush()` (thrown to the caller of a manual flush, or uncaught in async/scheduled mode). Pass `onError` to handle it instead (then it is NOT re-raised). Regardless of `onError`, a `EOIMEventQueueEventType.FLUSH_ERROR` event (payload `TOIMFlushError = { error }`) is emitted per failing task — the channel `@oimdb/devtools` `trackFlushErrors` / MCP use to surface failed flushes.
43
+
41
44
  ### Collections
42
45
 
43
46
  `OIMCollection` — base CRUD store. `OIMReactiveCollection` — same + emits events on flush.
@@ -352,10 +355,10 @@ Trade-offs (use only when every reader is subscription-driven): NOT Concurrent-s
352
355
  ## Exodra (`@oimdb/exodra`)
353
356
 
354
357
  ```bash
355
- npm install @oimdb/exodra @exodra/reactivity @oimdb/core
358
+ npm install @oimdb/exodra @oimdb/core
356
359
  ```
357
360
 
358
- The [Exodra](https://exodra.org) counterpart of `@oimdb/react`: instead of a hook + re-render, every OIMDB source becomes a read-only Exodra bindable (`TExoBindable<T> = { getValue(): T; subscribe(update): () => void }`). No React. Built on `@oimdb/core`'s `OIMSelector` (`{ getValue, watch }`) — the fine-grained subscription already lives there, so this is a thin adapter. Bindables are read-only, lazy (subscribe upstream only while they have a downstream subscriber → cost O(visible)) and SSR-safe (`getValue()` reads fresh, valid without an active subscription).
361
+ Depends only on the type-only `@exodra/reactivity-types` (never the reactivity runtime); peer dep `@oimdb/core`. Your Exodra app already provides `@exodra/reactivity` for the runtime (`bindable`, `derive`, `h`). The [Exodra](https://exodra.org) counterpart of `@oimdb/react`: instead of a hook + re-render, every OIMDB source becomes a read-only Exodra bindable (`TExoBindable<T> = { getValue(): T; subscribe(update): () => void }`). No React. Built on `@oimdb/core`'s `OIMSelector` (`{ getValue, watch }`) — the fine-grained subscription already lives there, so this is a thin adapter. Bindables are read-only, lazy (subscribe upstream only while they have a downstream subscriber → cost O(visible)) and SSR-safe (`getValue()` reads fresh, valid without an active subscription).
359
362
 
360
363
  ```ts
361
364
  import { fromSelector, bindSelectors, fromComputed, combine, entityRows } from '@oimdb/exodra';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oimdb/core",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "description": "Core in-memory data library with type-safe indices, reactive subscriptions, and event processing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",