@oimdb/core 4.1.0 → 4.3.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.js CHANGED
@@ -1,4 +1,4 @@
1
- // src/engine/schedule/OIMFlushSchedulerService.ts
1
+ // src/schedule/OIMFlushSchedulerService.ts
2
2
  var _OIMFlushSchedulerService = class _OIMFlushSchedulerService {
3
3
  isScheduled(flushSchedulerSlot) {
4
4
  return flushSchedulerSlot.scheduledCallback !== void 0;
@@ -33,15 +33,15 @@ var _OIMFlushSchedulerService = class _OIMFlushSchedulerService {
33
33
  _OIMFlushSchedulerService.INSTANCE = new _OIMFlushSchedulerService();
34
34
  var OIMFlushSchedulerService = _OIMFlushSchedulerService;
35
35
 
36
- // src/engine/slot/constants/OIM_SLOT_FLAG_RELEASED.ts
36
+ // src/slot/constants/OIM_SLOT_FLAG_RELEASED.ts
37
37
  var OIM_SLOT_FLAG_RELEASED = 2;
38
38
 
39
- // src/engine/slot/utils/oimUnholdSlotIfAlive.ts
39
+ // src/slot/utils/oimUnholdSlotIfAlive.ts
40
40
  function oimUnholdSlotIfAlive(slot) {
41
41
  if ((slot.slotFlags & OIM_SLOT_FLAG_RELEASED) === 0) slot.owner.unholdSlot(slot);
42
42
  }
43
43
 
44
- // src/engine/collector/OIMUnusedSlotCollectorService.ts
44
+ // src/collector/OIMUnusedSlotCollectorService.ts
45
45
  var _OIMUnusedSlotCollectorService = class _OIMUnusedSlotCollectorService {
46
46
  holdSlotUntilFlush(unusedSlotCollectorSlot, slot) {
47
47
  slot.owner.holdSlot(slot);
@@ -87,16 +87,16 @@ var _OIMUnusedSlotCollectorService = class _OIMUnusedSlotCollectorService {
87
87
  _OIMUnusedSlotCollectorService.INSTANCE = new _OIMUnusedSlotCollectorService();
88
88
  var OIMUnusedSlotCollectorService = _OIMUnusedSlotCollectorService;
89
89
 
90
- // src/engine/channel/constants/OIM_REVISIONS_PER_EPOCH.ts
90
+ // src/channel/constants/OIM_REVISIONS_PER_EPOCH.ts
91
91
  var OIM_REVISIONS_PER_EPOCH = 2 ** 30;
92
92
 
93
- // src/engine/channel/utils/oimIsRevisionAfter.ts
93
+ // src/channel/utils/oimIsRevisionAfter.ts
94
94
  function oimIsRevisionAfter(revision, epoch, sinceRevision, sinceEpoch) {
95
- if (epoch !== sinceEpoch) return epoch > sinceEpoch;
95
+ if (epoch !== sinceEpoch) return (epoch - sinceEpoch | 0) > 0;
96
96
  return revision > sinceRevision;
97
97
  }
98
98
 
99
- // src/engine/channel/OIMChannelService.ts
99
+ // src/channel/OIMChannelService.ts
100
100
  var _OIMChannelService = class _OIMChannelService {
101
101
  scheduleEffectRun(channelSlot, effect) {
102
102
  channelSlot.effectChannelQueue.enqueueEntry(effect);
@@ -156,24 +156,24 @@ var _OIMChannelService = class _OIMChannelService {
156
156
  const clock = channelSlot.clock;
157
157
  if (clock.revision >= OIM_REVISIONS_PER_EPOCH - 1) {
158
158
  clock.revision = 0;
159
- clock.epoch++;
159
+ clock.epoch = clock.epoch + 1 | 0;
160
160
  } else {
161
161
  clock.revision++;
162
162
  }
163
- const dependents = slot.effects;
164
- const slotEditable = slot;
163
+ const effects = slot.effects;
164
+ const editableSlot = slot;
165
165
  const effectChannelQueue = channelSlot.effectChannelQueue;
166
166
  let owesAFrame = false;
167
- if (dependents !== void 0 && dependents.length !== 0 && !this.isChangedInCurrentFrame(channelSlot, slot)) {
168
- const owed = dependents.length;
167
+ if (effects !== void 0 && effects.length !== 0 && !this.isChangedInCurrentFrame(channelSlot, slot)) {
168
+ const owed = effects.length;
169
169
  for (let i = 0; i < owed; i++) {
170
- const dependent = dependents[i];
171
- if (dependent.effectService.markEffectRunScheduled(dependent, false)) effectChannelQueue.enqueueEntry(dependent);
170
+ const effect = effects[i];
171
+ if (effect.effectService.markEffectRunScheduled(effect, false)) effectChannelQueue.enqueueEntry(effect);
172
172
  }
173
173
  owesAFrame = true;
174
174
  }
175
- slotEditable.changedAtRevision = clock.revision;
176
- slotEditable.changedAtEpoch = clock.epoch;
175
+ editableSlot.changedAtRevision = clock.revision;
176
+ editableSlot.changedAtEpoch = clock.epoch;
177
177
  if (!owesAFrame && (channelSlot.flushRequested || channelSlot.frame.afterEachFrame.size === 0 && effectChannelQueue.getEntryCount() === 0)) return;
178
178
  if (channelSlot.timer === void 0) return;
179
179
  this.requestFlush(channelSlot);
@@ -298,7 +298,7 @@ var _OIMChannelService = class _OIMChannelService {
298
298
  _OIMChannelService.INSTANCE = new _OIMChannelService();
299
299
  var OIMChannelService = _OIMChannelService;
300
300
 
301
- // src/engine/channel/OIMChannelQueue.ts
301
+ // src/channel/OIMChannelQueue.ts
302
302
  var OIMChannelQueue = class {
303
303
  constructor() {
304
304
  this.entries = [];
@@ -332,7 +332,7 @@ var OIMChannelQueue = class {
332
332
  }
333
333
  };
334
334
 
335
- // src/engine/channel/utils/createOIMChannelSlot.ts
335
+ // src/channel/utils/createOIMChannelSlot.ts
336
336
  function createOIMChannelSlot(options) {
337
337
  return {
338
338
  timer: options.timer,
@@ -354,12 +354,12 @@ function createOIMChannelSlot(options) {
354
354
  };
355
355
  }
356
356
 
357
- // src/engine/collector/utils/createOIMUnusedSlotCollectorSlot.ts
357
+ // src/collector/utils/createOIMUnusedSlotCollectorSlot.ts
358
358
  function createOIMUnusedSlotCollectorSlot() {
359
359
  return { unusedSlotChannelQueue: new OIMChannelQueue(), openDepth: 0, isFlushing: false };
360
360
  }
361
361
 
362
- // src/engine/collector/utils/createOIMCollectorSlot.ts
362
+ // src/collector/utils/createOIMCollectorSlot.ts
363
363
  function createOIMCollectorSlot(options) {
364
364
  return {
365
365
  unusedSlotCollectorSlot: createOIMUnusedSlotCollectorSlot(),
@@ -370,18 +370,18 @@ function createOIMCollectorSlot(options) {
370
370
  };
371
371
  }
372
372
 
373
- // src/engine/schedule/constants/OIM_NOTHING_TO_DISPOSE.ts
373
+ // src/schedule/constants/OIM_NOTHING_TO_DISPOSE.ts
374
374
  var OIM_NOTHING_TO_DISPOSE = () => {
375
375
  return;
376
376
  };
377
377
 
378
- // src/engine/schedule/utils/oimTimerOfChannelScheduler.ts
378
+ // src/schedule/utils/oimTimerOfChannelScheduler.ts
379
379
  var oimTimerOfChannelScheduler = (scheduler) => (run) => {
380
380
  scheduler(run);
381
381
  return OIM_NOTHING_TO_DISPOSE;
382
382
  };
383
383
 
384
- // src/engine/schedule/constants/OIM_TIMER_ON_TIMEOUT.ts
384
+ // src/schedule/constants/OIM_TIMER_ON_TIMEOUT.ts
385
385
  var OIM_TIMER_ON_TIMEOUT = (run, inMs) => {
386
386
  const handle = setTimeout(run, inMs);
387
387
  handle.unref?.();
@@ -390,7 +390,7 @@ var OIM_TIMER_ON_TIMEOUT = (run, inMs) => {
390
390
  };
391
391
  };
392
392
 
393
- // src/engine/error/OIMLogAndContinueErrorPolicy.ts
393
+ // src/error/OIMLogAndContinueErrorPolicy.ts
394
394
  var _OIMLogAndContinueErrorPolicy = class _OIMLogAndContinueErrorPolicy {
395
395
  constructor(options) {
396
396
  this.onError = options?.onError;
@@ -403,7 +403,7 @@ var _OIMLogAndContinueErrorPolicy = class _OIMLogAndContinueErrorPolicy {
403
403
  _OIMLogAndContinueErrorPolicy.INSTANCE = new _OIMLogAndContinueErrorPolicy();
404
404
  var OIMLogAndContinueErrorPolicy = _OIMLogAndContinueErrorPolicy;
405
405
 
406
- // src/factories/OIMDB.ts
406
+ // src/db/OIMDB.ts
407
407
  var OIMDB = class {
408
408
  constructor(options) {
409
409
  this.clock = { revision: 0, epoch: 0 };
@@ -421,17 +421,13 @@ var OIMDB = class {
421
421
  timer: channelScheduler === void 0 ? void 0 : oimTimerOfChannelScheduler(channelScheduler),
422
422
  onBeforeFlush: options?.onBeforeFlush
423
423
  });
424
- this.entityWriter = options?.entityWriter;
425
- this.slotStamp = options?.slotStamp;
426
- this.slotReleasePolicy = options?.slotReleasePolicy;
427
- this.indexKeysService = options?.indexKeysService;
428
424
  }
429
425
  flush() {
430
426
  OIMChannelService.INSTANCE.flush(this.defaultChannelSlot);
431
427
  }
432
428
  };
433
429
 
434
- // src/factories/defaults/oimRegisterCoreInstance.ts
430
+ // src/db/utils/oimRegisterCoreInstance.ts
435
431
  var OIM_CORE_INSTANCE_KEY = Symbol.for("@oimdb/core");
436
432
  function oimRegisterCoreInstance(coreInstance) {
437
433
  const globalThisRecord = globalThis;
@@ -442,11 +438,11 @@ function oimRegisterCoreInstance(coreInstance) {
442
438
  }
443
439
  if (registeredCoreInstance === coreInstance) return;
444
440
  throw new Error(
445
- "@oimdb/core is loaded twice in this process \u2014 usually `import` in one place and `require` in another, or two installed copies. Each copy keeps its own OIMDefaults, so a default set through one never reaches collections built by the other. Load @oimdb/core one way everywhere, including inside every @oimdb package."
441
+ "@oimdb/core is loaded twice in this process \u2014 usually `import` in one place and `require` in another, or two installed copies. Each copy keeps its own built-in defaults and its own classes, so services built by the two copies share nothing. Load @oimdb/core one way everywhere, including inside every @oimdb package."
446
442
  );
447
443
  }
448
444
 
449
- // src/engine/slot/OIMNoStoreSlotListener.ts
445
+ // src/slot/OIMNoStoreSlotListener.ts
450
446
  var _OIMNoStoreSlotListener = class _OIMNoStoreSlotListener {
451
447
  onStoreSlotCreated() {
452
448
  return;
@@ -455,7 +451,7 @@ var _OIMNoStoreSlotListener = class _OIMNoStoreSlotListener {
455
451
  _OIMNoStoreSlotListener.INSTANCE = new _OIMNoStoreSlotListener();
456
452
  var OIMNoStoreSlotListener = _OIMNoStoreSlotListener;
457
453
 
458
- // src/engine/slot/OIMNoSlotSubscriptionListener.ts
454
+ // src/slot/OIMNoSlotSubscriptionListener.ts
459
455
  var _OIMNoSlotSubscriptionListener = class _OIMNoSlotSubscriptionListener {
460
456
  onSlotFirstSubscribed() {
461
457
  return;
@@ -467,20 +463,20 @@ var _OIMNoSlotSubscriptionListener = class _OIMNoSlotSubscriptionListener {
467
463
  _OIMNoSlotSubscriptionListener.INSTANCE = new _OIMNoSlotSubscriptionListener();
468
464
  var OIMNoSlotSubscriptionListener = _OIMNoSlotSubscriptionListener;
469
465
 
470
- // src/engine/slot/constants/OIM_SLOT_FLAG_EMPTY.ts
466
+ // src/slot/constants/OIM_SLOT_FLAG_EMPTY.ts
471
467
  var OIM_SLOT_FLAG_EMPTY = 1;
472
468
 
473
- // src/engine/slot/utils/oimIsSlotEmpty.ts
469
+ // src/slot/utils/oimIsSlotEmpty.ts
474
470
  function oimIsSlotEmpty(slot) {
475
471
  return (slot.slotFlags & OIM_SLOT_FLAG_EMPTY) !== 0;
476
472
  }
477
473
 
478
- // src/engine/slot/utils/oimIsSlotReleased.ts
474
+ // src/slot/utils/oimIsSlotReleased.ts
479
475
  function oimIsSlotReleased(slot) {
480
476
  return (slot.slotFlags & OIM_SLOT_FLAG_RELEASED) !== 0;
481
477
  }
482
478
 
483
- // src/engine/slot/utils/oimAssertSlotNotReleased.ts
479
+ // src/slot/utils/oimAssertSlotNotReleased.ts
484
480
  var oimAssertSlotNotReleased = (slot) => {
485
481
  if ((slot.slotFlags & OIM_SLOT_FLAG_RELEASED) === 0) return;
486
482
  throw new Error(
@@ -488,7 +484,7 @@ var oimAssertSlotNotReleased = (slot) => {
488
484
  );
489
485
  };
490
486
 
491
- // src/engine/slot/OIMSlotOwner.ts
487
+ // src/slot/OIMSlotOwner.ts
492
488
  var OIMSlotOwner = class {
493
489
  holdSlot(slot) {
494
490
  this.assertNotReleased(slot);
@@ -508,10 +504,10 @@ var OIMSlotOwner = class {
508
504
  }
509
505
  subscribeToSlot(slot, effect, edge) {
510
506
  this.holdSlot(slot);
511
- const slotEditable = slot;
512
- const subscribers = slotEditable.effects ?? (slotEditable.effects = []);
507
+ const editableSlot = slot;
508
+ const subscribers = editableSlot.effects ?? (editableSlot.effects = []);
513
509
  subscribers.push(effect);
514
- (slotEditable.effectEdges ?? (slotEditable.effectEdges = [])).push(edge);
510
+ (editableSlot.effectEdges ?? (editableSlot.effectEdges = [])).push(edge);
515
511
  if (subscribers.length === 1) this.onSlotFirstSubscribed(slot);
516
512
  return subscribers.length - 1;
517
513
  }
@@ -558,30 +554,30 @@ var OIMSlotOwner = class {
558
554
  }
559
555
  };
560
556
 
561
- // src/engine/column/constants/OIM_COLUMN_GROUP_KEY_SEPARATOR.ts
557
+ // src/column/constants/OIM_COLUMN_GROUP_KEY_SEPARATOR.ts
562
558
  var OIM_COLUMN_GROUP_KEY_SEPARATOR = "\0";
563
559
 
564
- // src/engine/column/utils/oimColumnGroupKeyOfColumnNames.ts
560
+ // src/column/utils/oimColumnGroupKeyOfColumnNames.ts
565
561
  function oimColumnGroupKeyOfColumnNames(sortedColumnNames) {
566
562
  return `${OIM_COLUMN_GROUP_KEY_SEPARATOR}${sortedColumnNames.join(OIM_COLUMN_GROUP_KEY_SEPARATOR)}`;
567
563
  }
568
564
 
569
- // src/engine/column/constants/OIM_ANY_COLUMN_KEY.ts
565
+ // src/column/constants/OIM_ANY_COLUMN_KEY.ts
570
566
  var OIM_ANY_COLUMN_KEY = OIM_COLUMN_GROUP_KEY_SEPARATOR;
571
567
 
572
- // src/engine/column/utils/oimColumnNamesOfKey.ts
568
+ // src/column/utils/oimColumnNamesOfKey.ts
573
569
  function oimColumnNamesOfKey(columnKey) {
574
570
  if (!columnKey.startsWith(OIM_COLUMN_GROUP_KEY_SEPARATOR)) return [columnKey];
575
571
  const joinedColumnNames = columnKey.slice(OIM_COLUMN_GROUP_KEY_SEPARATOR.length);
576
572
  return joinedColumnNames === "" ? [] : joinedColumnNames.split(OIM_COLUMN_GROUP_KEY_SEPARATOR);
577
573
  }
578
574
 
579
- // src/engine/slot/utils/oimMarkSlotReleased.ts
575
+ // src/slot/utils/oimMarkSlotReleased.ts
580
576
  function oimMarkSlotReleased(slot) {
581
577
  slot.slotFlags |= OIM_SLOT_FLAG_RELEASED;
582
578
  }
583
579
 
584
- // src/engine/column/OIMColumnSlotOwner.ts
580
+ // src/column/OIMColumnSlotOwner.ts
585
581
  var OIMColumnSlotOwner = class extends OIMSlotOwner {
586
582
  constructor(columnSlotStoreService) {
587
583
  super();
@@ -686,8 +682,8 @@ var OIMColumnSlotOwner = class extends OIMSlotOwner {
686
682
  }
687
683
  fileColumnSlot(carrierSlot, key) {
688
684
  const columnSlotStoreService = this.columnSlotStoreService;
689
- const carrierSlotEditable = carrierSlot;
690
- const columnSlotStore = carrierSlotEditable.columnSlotStore ?? (carrierSlotEditable.columnSlotStore = columnSlotStoreService.createStore());
685
+ const editableCarrierSlot = carrierSlot;
686
+ const columnSlotStore = editableCarrierSlot.columnSlotStore ?? (editableCarrierSlot.columnSlotStore = columnSlotStoreService.createStore());
691
687
  const columnSlot = this.createColumnSlot(carrierSlot, key);
692
688
  columnSlotStoreService.set(columnSlotStore, key, columnSlot);
693
689
  return columnSlot;
@@ -745,7 +741,7 @@ function forgetColumnReadersIfUnread(storeSlot, columnName, columnReaders) {
745
741
  storeSlot.columnReadersByColumnName.delete(columnName);
746
742
  }
747
743
 
748
- // src/engine/column/OIMColumnSlotOrdinalStoreService.ts
744
+ // src/column/OIMColumnSlotOrdinalStoreService.ts
749
745
  var OIMColumnSlotOrdinalStoreService = class {
750
746
  constructor(options) {
751
747
  this.ordinalsByColumnName = /* @__PURE__ */ new Map();
@@ -811,19 +807,19 @@ var OIMColumnSlotOrdinalStoreService = class {
811
807
  }
812
808
  };
813
809
 
814
- // src/engine/column/utils/oimColumnSlotStoreServiceOfColumnOwnerOptions.ts
815
- function oimColumnSlotStoreServiceOfColumnOwnerOptions(columnSlotOwnerOptions) {
810
+ // src/column/utils/oimColumnSlotStoreServiceOfColumnSlotOwnerOptions.ts
811
+ function oimColumnSlotStoreServiceOfColumnSlotOwnerOptions(columnSlotOwnerOptions) {
816
812
  if (columnSlotOwnerOptions.columnNames !== void 0) {
817
813
  return new OIMColumnSlotOrdinalStoreService({ columnNames: columnSlotOwnerOptions.columnNames });
818
814
  }
819
815
  return columnSlotOwnerOptions.columnSlotStoreService;
820
816
  }
821
817
 
822
- // src/engine/computed/constants/OIM_FROZEN_EMPTY_COMPUTED_SLOTS.ts
818
+ // src/computed/constants/OIM_FROZEN_EMPTY_COMPUTED_SLOTS.ts
823
819
  var OIM_FROZEN_EMPTY_COMPUTED_SLOTS = Object.freeze([]);
824
820
 
825
- // src/engine/computed/utils/createOIMComputedSlot.ts
826
- function createOIMComputedSlot(key, owner, computedValueService, initialValue, storeSlot = void 0) {
821
+ // src/computed/utils/createOIMComputedSlot.ts
822
+ function createOIMComputedSlot(key, owner, computedValueService, initialValue, storeSlot, sourceTracker) {
827
823
  return {
828
824
  effects: void 0,
829
825
  changedAtRevision: 0,
@@ -848,11 +844,12 @@ function createOIMComputedSlot(key, owner, computedValueService, initialValue, s
848
844
  checkedAtRevision: -1,
849
845
  checkedAtEpoch: -1,
850
846
  isDeriving: false,
851
- allRootSlots: void 0
847
+ allRootSlots: void 0,
848
+ sourceTracker
852
849
  };
853
850
  }
854
851
 
855
- // src/engine/computed/utils/oimRefreshSourceComputeds.ts
852
+ // src/computed/utils/oimRefreshSourceComputeds.ts
856
853
  function oimRefreshSourceComputeds(sourceComputeds) {
857
854
  for (let i = 0; i < sourceComputeds.length; i++) {
858
855
  const sourceComputedSlot = sourceComputeds[i];
@@ -860,7 +857,7 @@ function oimRefreshSourceComputeds(sourceComputeds) {
860
857
  }
861
858
  }
862
859
 
863
- // src/engine/channel/utils/oimIsAnySlotChangedAfter.ts
860
+ // src/channel/utils/oimIsAnySlotChangedAfter.ts
864
861
  function oimIsAnySlotChangedAfter(slots, revision, epoch) {
865
862
  for (let i = 0; i < slots.length; i++) {
866
863
  const slot = slots[i];
@@ -869,52 +866,67 @@ function oimIsAnySlotChangedAfter(slots, revision, epoch) {
869
866
  return false;
870
867
  }
871
868
 
872
- // src/engine/computed/utils/oimHasSourceChangedSinceLastRun.ts
869
+ // src/computed/utils/oimHasSourceChangedSinceLastRun.ts
873
870
  function oimHasSourceChangedSinceLastRun(derivation) {
874
871
  return oimIsAnySlotChangedAfter(derivation.sourceComputeds, derivation.ranAtRevision, derivation.ranAtEpoch) || oimIsAnySlotChangedAfter(derivation.sourceSlots, derivation.ranAtRevision, derivation.ranAtEpoch);
875
872
  }
876
873
 
877
- // src/engine/computed/utils/oimRefreshComputedSlot.ts
878
- function oimRefreshComputedSlot(computedSlot, derive, sameValueGuard, channelClock) {
874
+ // src/computed/utils/oimRefreshComputedSlot.ts
875
+ function oimRefreshComputedSlot(computedSlot, derive, sameValueGuard, releaseValue, channelClock) {
879
876
  if (computedSlot.isDeriving) return;
880
877
  if (computedSlot.checkedAtRevision === channelClock.revision && computedSlot.checkedAtEpoch === channelClock.epoch) return;
881
- const computedSlotEditable = computedSlot;
878
+ const editableComputedSlot = computedSlot;
882
879
  oimRefreshSourceComputeds(computedSlot.sourceComputeds);
883
880
  if (computedSlot.ranAtRevision !== -1 && !oimHasSourceChangedSinceLastRun(computedSlot)) {
884
- computedSlotEditable.checkedAtRevision = channelClock.revision;
885
- computedSlotEditable.checkedAtEpoch = channelClock.epoch;
881
+ editableComputedSlot.checkedAtRevision = channelClock.revision;
882
+ editableComputedSlot.checkedAtEpoch = channelClock.epoch;
886
883
  return;
887
884
  }
888
- computedSlotEditable.isDeriving = true;
885
+ const hasDerived = computedSlot.ranAtRevision !== -1;
886
+ editableComputedSlot.isDeriving = true;
889
887
  let next;
890
888
  try {
891
889
  next = derive(computedSlot);
892
890
  } finally {
893
- computedSlotEditable.isDeriving = false;
894
- }
895
- const isSameValue = sameValueGuard(computedSlot.value, next);
896
- computedSlotEditable.ranAtRevision = channelClock.revision;
897
- computedSlotEditable.ranAtEpoch = channelClock.epoch;
898
- computedSlotEditable.checkedAtRevision = channelClock.revision;
899
- computedSlotEditable.checkedAtEpoch = channelClock.epoch;
900
- if (isSameValue) return;
901
- computedSlotEditable.value = next;
891
+ editableComputedSlot.isDeriving = false;
892
+ }
893
+ if ((computedSlot.slotFlags & OIM_SLOT_FLAG_RELEASED) !== 0) {
894
+ releaseValue(next);
895
+ return;
896
+ }
897
+ const prevValue = computedSlot.value;
898
+ const isSameValue = sameValueGuard(prevValue, next);
899
+ editableComputedSlot.ranAtRevision = channelClock.revision;
900
+ editableComputedSlot.ranAtEpoch = channelClock.epoch;
901
+ editableComputedSlot.checkedAtRevision = channelClock.revision;
902
+ editableComputedSlot.checkedAtEpoch = channelClock.epoch;
903
+ if (isSameValue) {
904
+ if (next !== prevValue) releaseValue(next);
905
+ return;
906
+ }
907
+ editableComputedSlot.value = next;
908
+ if (hasDerived) releaseValue(prevValue);
902
909
  const sourceSlots = computedSlot.sourceSlots;
903
910
  const sourceComputeds = computedSlot.sourceComputeds;
904
911
  const sourceCount = sourceSlots.length + sourceComputeds.length;
905
912
  let newestSourceRevision = -1;
906
913
  let newestSourceEpoch = -1;
907
914
  for (let i = 0; i < sourceCount; i++) {
908
- const source = i < sourceSlots.length ? sourceSlots[i] : sourceComputeds[i - sourceSlots.length];
909
- if (!oimIsRevisionAfter(source.changedAtRevision, source.changedAtEpoch, newestSourceRevision, newestSourceEpoch)) continue;
910
- newestSourceRevision = source.changedAtRevision;
911
- newestSourceEpoch = source.changedAtEpoch;
915
+ const sourceSlot = i < sourceSlots.length ? sourceSlots[i] : sourceComputeds[i - sourceSlots.length];
916
+ if (!oimIsRevisionAfter(sourceSlot.changedAtRevision, sourceSlot.changedAtEpoch, newestSourceRevision, newestSourceEpoch)) continue;
917
+ newestSourceRevision = sourceSlot.changedAtRevision;
918
+ newestSourceEpoch = sourceSlot.changedAtEpoch;
912
919
  }
913
- computedSlotEditable.changedAtRevision = sourceCount === 0 ? channelClock.revision : newestSourceRevision;
914
- computedSlotEditable.changedAtEpoch = sourceCount === 0 ? channelClock.epoch : newestSourceEpoch;
920
+ editableComputedSlot.changedAtRevision = sourceCount === 0 ? channelClock.revision : newestSourceRevision;
921
+ editableComputedSlot.changedAtEpoch = sourceCount === 0 ? channelClock.epoch : newestSourceEpoch;
922
+ }
923
+
924
+ // src/computed/utils/oimReleaseNoValue.ts
925
+ function oimReleaseNoValue() {
926
+ return;
915
927
  }
916
928
 
917
- // src/engine/column/OIMPullColumnSlotOwner.ts
929
+ // src/column/OIMPullColumnSlotOwner.ts
918
930
  var columnValueOf = (value, columnName) => typeof value === "object" && value !== null ? value[columnName] : void 0;
919
931
  var isSameColumnValues = (prevColumnValues, nextColumnValues) => {
920
932
  if (!Array.isArray(prevColumnValues) || !Array.isArray(nextColumnValues)) return false;
@@ -926,7 +938,7 @@ var isSameColumnValues = (prevColumnValues, nextColumnValues) => {
926
938
  };
927
939
  var OIMPullColumnSlotOwner = class extends OIMColumnSlotOwner {
928
940
  constructor(options) {
929
- super(oimColumnSlotStoreServiceOfColumnOwnerOptions(options));
941
+ super(oimColumnSlotStoreServiceOfColumnSlotOwnerOptions(options));
930
942
  this.deriveColumnSlotValue = (columnSlot) => {
931
943
  const columnGroup = this.getColumnGroupsByKeyOf(this.carrierSlotOf(columnSlot))?.get(columnSlot.key);
932
944
  return columnGroup === void 0 ? this.deriveColumnValue(columnSlot) : this.deriveColumnValues(columnSlot, columnGroup.columnNames);
@@ -935,17 +947,18 @@ var OIMPullColumnSlotOwner = class extends OIMColumnSlotOwner {
935
947
  getValueForSlot(computedSlot) {
936
948
  this.assertNotReleased(computedSlot);
937
949
  const columnSlot = computedSlot;
938
- const carrierStoreSlot = this.carrierSlotOf(columnSlot).storeSlot;
950
+ const carrierStoreSlot = columnSlot.storeSlot;
939
951
  oimRefreshComputedSlot(
940
952
  columnSlot,
941
953
  this.deriveColumnSlotValue,
942
954
  carrierStoreSlot.columnGroupsByKey?.has(columnSlot.key) === true ? isSameColumnValues : Object.is,
955
+ oimReleaseNoValue,
943
956
  carrierStoreSlot.channelSlot.clock
944
957
  );
945
958
  return columnSlot.value;
946
959
  }
947
960
  createColumnSlot(carrierSlot, key) {
948
- const columnSlot = createOIMComputedSlot(key, this, this, void 0);
961
+ const columnSlot = createOIMComputedSlot(key, this, this, void 0, carrierSlot.storeSlot, void 0);
949
962
  columnSlot.sourceComputeds = [carrierSlot];
950
963
  this.getValueForSlot(columnSlot);
951
964
  return columnSlot;
@@ -965,19 +978,19 @@ var OIMPullColumnSlotOwner = class extends OIMColumnSlotOwner {
965
978
  }
966
979
  };
967
980
 
968
- // src/engine/slot/utils/oimSameValueZeroGuard.ts
981
+ // src/slot/utils/oimSameValueZeroGuard.ts
969
982
  function oimSameValueZeroGuard(prevValue, nextValue) {
970
983
  return prevValue === nextValue || prevValue !== prevValue && nextValue !== nextValue;
971
984
  }
972
985
 
973
- // src/engine/bucket/utils/oimSameSlotSequence.ts
986
+ // src/bucket/utils/oimSameSlotSequence.ts
974
987
  function oimSameSlotSequence(prev, next) {
975
988
  if (prev.length !== next.length) return false;
976
989
  for (let i = 0; i < prev.length; i++) if (prev[i] !== next[i]) return false;
977
990
  return true;
978
991
  }
979
992
 
980
- // src/engine/key/utils/oimSameKeySequence.ts
993
+ // src/key/utils/oimSameKeySequence.ts
981
994
  function oimSameKeySequence(keys, otherKeys) {
982
995
  if (keys === otherKeys) return true;
983
996
  if (keys.length !== otherKeys.length) return false;
@@ -987,25 +1000,25 @@ function oimSameKeySequence(keys, otherKeys) {
987
1000
  return true;
988
1001
  }
989
1002
 
990
- // src/engine/slot/utils/oimHoldSlots.ts
1003
+ // src/slot/utils/oimHoldSlots.ts
991
1004
  function oimHoldSlots(slots) {
992
1005
  for (let i = 0; i < slots.length; i++) slots[i].owner.holdSlot(slots[i]);
993
1006
  }
994
1007
 
995
- // src/engine/slot/utils/oimUnholdSlotsIfAlive.ts
1008
+ // src/slot/utils/oimUnholdSlotsIfAlive.ts
996
1009
  function oimUnholdSlotsIfAlive(slots) {
997
1010
  for (let i = 0; i < slots.length; i++) oimUnholdSlotIfAlive(slots[i]);
998
1011
  }
999
1012
 
1000
- // src/engine/error/OIMThrowAtOnceErrorPolicy.ts
1013
+ // src/error/OIMThrowAtOnceErrorPolicy.ts
1001
1014
  var OIMThrowAtOnceErrorPolicy = class {
1002
1015
  onErrorCaught(error) {
1003
1016
  throw error;
1004
1017
  }
1005
1018
  };
1006
1019
 
1007
- // src/engine/computed/OIMEffectSourceList.ts
1008
- var OIMEffectSourceList = class {
1020
+ // src/computed/OIMSourceList.ts
1021
+ var OIMSourceList = class {
1009
1022
  constructor() {
1010
1023
  this.committedSources = [];
1011
1024
  this.trackedSources = [];
@@ -1054,6 +1067,9 @@ var OIMEffectSourceList = class {
1054
1067
  this.isTrackedSourcesChanged = true;
1055
1068
  return true;
1056
1069
  }
1070
+ getCommittedSources() {
1071
+ return this.committedSources;
1072
+ }
1057
1073
  getTrackedSources() {
1058
1074
  return this.isTrackedSourcesChanged ? this.trackedSources : this.committedSources;
1059
1075
  }
@@ -1072,7 +1088,7 @@ var OIMEffectSourceList = class {
1072
1088
  }
1073
1089
  };
1074
1090
 
1075
- // src/engine/computed/utils/oimMergeRootSlots.ts
1091
+ // src/computed/utils/oimMergeRootSlots.ts
1076
1092
  var scannedRootSlotLimit = 16;
1077
1093
  function oimMergeRootSlots(sourceSlots, sourceComputeds) {
1078
1094
  if (sourceComputeds.length === 0) return sourceSlots;
@@ -1102,7 +1118,7 @@ function pushIfAbsent(mergedRootSlots, distinctRootSlots, rootSlot) {
1102
1118
  return mergedRootSlots.length > scannedRootSlotLimit ? new Set(mergedRootSlots) : void 0;
1103
1119
  }
1104
1120
 
1105
- // src/engine/computed/utils/oimGetAllRootSlots.ts
1121
+ // src/computed/utils/oimGetAllRootSlots.ts
1106
1122
  function oimGetAllRootSlots(computedSlot) {
1107
1123
  const allRootSlots = computedSlot.allRootSlots;
1108
1124
  if (allRootSlots !== void 0) return allRootSlots;
@@ -1111,62 +1127,85 @@ function oimGetAllRootSlots(computedSlot) {
1111
1127
  return mergedRootSlots;
1112
1128
  }
1113
1129
 
1114
- // src/engine/computed/OIMEffectSourceTracker.ts
1115
- var OIMEffectSourceTracker = class {
1130
+ // src/computed/OIMSourceTracker.ts
1131
+ var OIMSourceTracker = class {
1116
1132
  constructor() {
1117
- this.slotEffectSourceList = new OIMEffectSourceList();
1118
- this.computedEffectSourceList = void 0;
1133
+ this.slotSourceList = new OIMSourceList();
1134
+ this.computedSourceList = void 0;
1119
1135
  this.committedAllRootSlots = [];
1120
1136
  this.trackedAllRootSlots = [];
1121
1137
  this.isTrackedAllRootSlotsChanged = false;
1138
+ this.committedComputedRootSlots = [];
1139
+ this.trackedComputedRootSlots = [];
1122
1140
  }
1123
1141
  readSourceSlot(slot) {
1124
- this.slotEffectSourceList.trackSource(slot);
1142
+ this.slotSourceList.trackSource(slot);
1125
1143
  return slot;
1126
1144
  }
1127
1145
  readSourceComputedValue(computedSlot) {
1128
1146
  const value = computedSlot.computedValueService.getValueForSlot(computedSlot);
1129
- (this.computedEffectSourceList ?? (this.computedEffectSourceList = new OIMEffectSourceList())).trackSource(computedSlot);
1147
+ (this.computedSourceList ?? (this.computedSourceList = new OIMSourceList())).trackSource(computedSlot);
1130
1148
  return value;
1131
1149
  }
1132
1150
  openSourceTracking() {
1133
- this.slotEffectSourceList.openSourceTracking();
1134
- this.computedEffectSourceList?.openSourceTracking();
1151
+ this.slotSourceList.openSourceTracking();
1152
+ this.computedSourceList?.openSourceTracking();
1135
1153
  this.isTrackedAllRootSlotsChanged = false;
1136
1154
  }
1137
1155
  closeSourceTracking() {
1138
- const isSourceSlotsChanged = this.slotEffectSourceList.closeSourceTracking();
1139
- const isSourceComputedsChanged = this.computedEffectSourceList?.closeSourceTracking() ?? false;
1140
- if (!isSourceSlotsChanged && !isSourceComputedsChanged) return false;
1156
+ const isSourceSlotsChanged = this.slotSourceList.closeSourceTracking();
1157
+ const isSourceComputedsChanged = this.computedSourceList?.closeSourceTracking() ?? false;
1158
+ if (!isSourceSlotsChanged && !isSourceComputedsChanged && !this.isAnyComputedRootSlotsReplaced()) return false;
1159
+ this.trackAllRootSlots();
1160
+ return true;
1161
+ }
1162
+ isAnyComputedRootSlotsReplaced() {
1163
+ const computedSourceList = this.computedSourceList;
1164
+ if (computedSourceList === void 0) return false;
1165
+ const committedSourceComputeds = computedSourceList.getCommittedSources();
1166
+ const committedComputedRootSlots = this.committedComputedRootSlots;
1167
+ for (let i = 0; i < committedSourceComputeds.length; i++) {
1168
+ if (oimGetAllRootSlots(committedSourceComputeds[i]) !== committedComputedRootSlots[i]) return true;
1169
+ }
1170
+ return false;
1171
+ }
1172
+ trackReplacedRootSlots() {
1173
+ if (!this.isAnyComputedRootSlotsReplaced()) return false;
1141
1174
  this.trackAllRootSlots();
1142
1175
  return true;
1143
1176
  }
1144
1177
  getTrackedSourceSlots() {
1145
- return this.slotEffectSourceList.getTrackedSources();
1178
+ return this.slotSourceList.getTrackedSources();
1146
1179
  }
1147
1180
  getTrackedSourceComputeds() {
1148
- return this.computedEffectSourceList?.getTrackedSources() ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
1181
+ return this.computedSourceList?.getTrackedSources() ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
1149
1182
  }
1150
1183
  getTrackedAllRootSlots() {
1151
1184
  return this.isTrackedAllRootSlotsChanged ? this.trackedAllRootSlots : this.committedAllRootSlots;
1152
1185
  }
1153
1186
  commitTrackedSources() {
1154
- this.slotEffectSourceList.commitTrackedSources();
1155
- this.computedEffectSourceList?.commitTrackedSources();
1187
+ this.slotSourceList.commitTrackedSources();
1188
+ this.computedSourceList?.commitTrackedSources();
1156
1189
  if (!this.isTrackedAllRootSlotsChanged) return;
1157
1190
  const committedAllRootSlots = this.committedAllRootSlots;
1158
1191
  this.committedAllRootSlots = this.trackedAllRootSlots;
1159
1192
  this.trackedAllRootSlots = committedAllRootSlots;
1193
+ const committedComputedRootSlots = this.committedComputedRootSlots;
1194
+ this.committedComputedRootSlots = this.trackedComputedRootSlots;
1195
+ this.trackedComputedRootSlots = committedComputedRootSlots;
1160
1196
  this.isTrackedAllRootSlotsChanged = false;
1161
1197
  }
1162
1198
  trackAllRootSlots() {
1163
- const sourceSlots = this.slotEffectSourceList.getTrackedSources();
1199
+ const sourceSlots = this.slotSourceList.getTrackedSources();
1164
1200
  const sourceComputeds = this.getTrackedSourceComputeds();
1165
1201
  const trackedAllRootSlots = this.trackedAllRootSlots;
1202
+ const trackedComputedRootSlots = this.trackedComputedRootSlots;
1203
+ if (trackedComputedRootSlots.length !== sourceComputeds.length) trackedComputedRootSlots.length = sourceComputeds.length;
1166
1204
  let rootSlotCount = 0;
1167
1205
  for (let i = 0; i < sourceSlots.length; i++) trackedAllRootSlots[rootSlotCount++] = sourceSlots[i];
1168
1206
  for (let i = 0; i < sourceComputeds.length; i++) {
1169
1207
  const computedRootSlots = oimGetAllRootSlots(sourceComputeds[i]);
1208
+ trackedComputedRootSlots[i] = computedRootSlots;
1170
1209
  for (let j = 0; j < computedRootSlots.length; j++) trackedAllRootSlots[rootSlotCount++] = computedRootSlots[j];
1171
1210
  }
1172
1211
  if (trackedAllRootSlots.length !== rootSlotCount) trackedAllRootSlots.length = rootSlotCount;
@@ -1174,23 +1213,26 @@ var OIMEffectSourceTracker = class {
1174
1213
  }
1175
1214
  };
1176
1215
 
1177
- // src/engine/computed/constants/OIM_EFFECT_FLAG_DISPOSED.ts
1216
+ // src/effect/constants/OIM_EFFECT_FLAG_DISPOSED.ts
1178
1217
  var OIM_EFFECT_FLAG_DISPOSED = 2;
1179
1218
 
1180
- // src/engine/computed/utils/oimIsEffectDisposed.ts
1219
+ // src/effect/utils/oimIsEffectDisposed.ts
1181
1220
  function oimIsEffectDisposed(effect) {
1182
1221
  return (effect.effectFlags & OIM_EFFECT_FLAG_DISPOSED) !== 0;
1183
1222
  }
1184
1223
 
1185
- // src/engine/computed/constants/OIM_EFFECT_FLAG_RUN_SCHEDULED.ts
1224
+ // src/effect/constants/OIM_EFFECT_FLAG_RUN_SCHEDULED.ts
1186
1225
  var OIM_EFFECT_FLAG_RUN_SCHEDULED = 1;
1187
1226
 
1188
- // src/engine/computed/constants/OIM_EFFECT_FLAG_SOURCE_CHECK_OWED.ts
1227
+ // src/effect/constants/OIM_EFFECT_FLAG_SOURCE_CHECK_OWED.ts
1189
1228
  var OIM_EFFECT_FLAG_SOURCE_CHECK_OWED = 4;
1190
1229
 
1191
- // src/engine/computed/OIMEffectService.ts
1230
+ // src/effect/OIMEffectService.ts
1192
1231
  var _OIMEffectService = class _OIMEffectService {
1193
- createEffect(channelMap, sourceSlots, sourceComputeds, body) {
1232
+ createEffect(channelMap, body, sourceSlots = OIM_FROZEN_EMPTY_COMPUTED_SLOTS, sourceComputeds = OIM_FROZEN_EMPTY_COMPUTED_SLOTS, sourceTrackingComputeds = OIM_FROZEN_EMPTY_COMPUTED_SLOTS) {
1233
+ if (sourceTrackingComputeds.length !== 0) {
1234
+ return this.createEffectOverSourceTrackingComputeds(channelMap, body, sourceSlots, sourceComputeds, sourceTrackingComputeds);
1235
+ }
1194
1236
  let distinctSourceComputeds = sourceComputeds;
1195
1237
  if (sourceComputeds.length > 1) {
1196
1238
  const distinctSourceComputedSet = new Set(sourceComputeds);
@@ -1211,7 +1253,8 @@ var _OIMEffectService = class _OIMEffectService {
1211
1253
  ranAtEpoch: clock.epoch,
1212
1254
  effectFlags: 0,
1213
1255
  body,
1214
- cleanup: void 0
1256
+ cleanup: void 0,
1257
+ sourceTracker: void 0
1215
1258
  };
1216
1259
  try {
1217
1260
  for (let i = 0; i < allRootSlots.length; i++) {
@@ -1227,20 +1270,17 @@ var _OIMEffectService = class _OIMEffectService {
1227
1270
  this.disposeEffect(effect);
1228
1271
  throw failure;
1229
1272
  }
1230
- const frame = channelSlot.frame;
1231
- if (!frame.isRunning && oimIsRevisionAfter(clock.revision, clock.epoch, frame.openedAtRevision, frame.openedAtEpoch) && this.markEffectRunScheduled(effect, true)) {
1232
- OIMChannelService.INSTANCE.scheduleEffectRun(channelSlot, effect);
1233
- }
1273
+ this.scheduleEffectRunIfWrittenSinceFrameOpened(effect);
1234
1274
  return effect;
1235
1275
  }
1236
- subscribeEffect(channelMap, sourceSlots, sourceComputeds, body) {
1237
- const effect = this.createEffect(channelMap, sourceSlots, sourceComputeds, body);
1276
+ subscribeEffect(channelMap, body, sourceSlots = OIM_FROZEN_EMPTY_COMPUTED_SLOTS, sourceComputeds = OIM_FROZEN_EMPTY_COMPUTED_SLOTS, sourceTrackingComputeds = OIM_FROZEN_EMPTY_COMPUTED_SLOTS) {
1277
+ const effect = this.createEffect(channelMap, body, sourceSlots, sourceComputeds, sourceTrackingComputeds);
1238
1278
  return () => {
1239
1279
  this.disposeEffect(effect);
1240
1280
  };
1241
1281
  }
1242
- createEffectImmediate(channelMap, sourceSlots, sourceComputeds, body) {
1243
- const effect = this.createEffect(channelMap, sourceSlots, sourceComputeds, body);
1282
+ createAndRunEffect(channelMap, body, sourceSlots = OIM_FROZEN_EMPTY_COMPUTED_SLOTS, sourceComputeds = OIM_FROZEN_EMPTY_COMPUTED_SLOTS, sourceTrackingComputeds = OIM_FROZEN_EMPTY_COMPUTED_SLOTS) {
1283
+ const effect = this.createEffect(channelMap, body, sourceSlots, sourceComputeds, sourceTrackingComputeds);
1244
1284
  try {
1245
1285
  this.runEffect(effect);
1246
1286
  } catch (refusal) {
@@ -1249,31 +1289,63 @@ var _OIMEffectService = class _OIMEffectService {
1249
1289
  }
1250
1290
  return effect;
1251
1291
  }
1252
- createEffectWithSourceTracking(channelMap, effectBodyWithSourceTracking) {
1253
- const effectSourceTracker = new OIMEffectSourceTracker();
1292
+ createSourceTrackingEffect(channelMap, sourceTrackingEffectBody) {
1293
+ const sourceTracker = new OIMSourceTracker();
1294
+ const effect = this.createEffectOverSourceTracker(
1295
+ channelMap,
1296
+ sourceTracker,
1297
+ () => this.runSourceTrackingEffectBody(effect, sourceTracker, sourceTrackingEffectBody)
1298
+ );
1299
+ try {
1300
+ this.runEffect(effect);
1301
+ } catch (failure) {
1302
+ this.disposeEffect(effect);
1303
+ throw failure;
1304
+ }
1305
+ return effect;
1306
+ }
1307
+ createEffectOverSourceTrackingComputeds(channelMap, body, sourceSlots, sourceComputeds, sourceTrackingComputeds) {
1308
+ const sourceTracker = new OIMSourceTracker();
1309
+ const effect = this.createEffectOverSourceTracker(channelMap, sourceTracker, body);
1310
+ try {
1311
+ sourceTracker.openSourceTracking();
1312
+ for (let i = 0; i < sourceSlots.length; i++) sourceTracker.readSourceSlot(sourceSlots[i]);
1313
+ for (let i = 0; i < sourceComputeds.length; i++) sourceTracker.readSourceComputedValue(sourceComputeds[i]);
1314
+ for (let i = 0; i < sourceTrackingComputeds.length; i++) sourceTracker.readSourceComputedValue(sourceTrackingComputeds[i]);
1315
+ if (sourceTracker.closeSourceTracking()) this.resubscribeToTrackedSources(effect, sourceTracker);
1316
+ } catch (failure) {
1317
+ this.disposeEffect(effect);
1318
+ throw failure;
1319
+ }
1320
+ this.scheduleEffectRunIfWrittenSinceFrameOpened(effect);
1321
+ return effect;
1322
+ }
1323
+ createEffectOverSourceTracker(channelMap, sourceTracker, body) {
1254
1324
  const channelSlot = channelMap.defaultChannelSlot;
1255
1325
  const clock = channelSlot.clock;
1256
- const effect = {
1326
+ return {
1257
1327
  effectService: this,
1258
1328
  channelSlot,
1259
- sourceSlots: effectSourceTracker.getTrackedSourceSlots(),
1260
- sourceComputeds: effectSourceTracker.getTrackedSourceComputeds(),
1261
- allRootSlots: effectSourceTracker.getTrackedAllRootSlots(),
1329
+ sourceSlots: sourceTracker.getTrackedSourceSlots(),
1330
+ sourceComputeds: sourceTracker.getTrackedSourceComputeds(),
1331
+ allRootSlots: sourceTracker.getTrackedAllRootSlots(),
1262
1332
  positionInFirstSubscribedSlot: -1,
1263
1333
  positionsInOtherSubscribedSlots: void 0,
1264
1334
  ranAtRevision: clock.revision,
1265
1335
  ranAtEpoch: clock.epoch,
1266
1336
  effectFlags: 0,
1267
- body: () => this.runEffectBodyWithSourceTracking(effect, effectSourceTracker, effectBodyWithSourceTracking),
1268
- cleanup: void 0
1337
+ body,
1338
+ cleanup: void 0,
1339
+ sourceTracker
1269
1340
  };
1270
- try {
1271
- this.runEffect(effect);
1272
- } catch (failure) {
1273
- this.disposeEffect(effect);
1274
- throw failure;
1341
+ }
1342
+ scheduleEffectRunIfWrittenSinceFrameOpened(effect) {
1343
+ const channelSlot = effect.channelSlot;
1344
+ const clock = channelSlot.clock;
1345
+ const frame = channelSlot.frame;
1346
+ if (!frame.isRunning && oimIsRevisionAfter(clock.revision, clock.epoch, frame.openedAtRevision, frame.openedAtEpoch) && this.markEffectRunScheduled(effect, true)) {
1347
+ OIMChannelService.INSTANCE.scheduleEffectRun(channelSlot, effect);
1275
1348
  }
1276
- return effect;
1277
1349
  }
1278
1350
  markEffectRunScheduled(effect, isSourceCheckOwed) {
1279
1351
  const effectFlags = effect.effectFlags;
@@ -1297,8 +1369,11 @@ var _OIMEffectService = class _OIMEffectService {
1297
1369
  }
1298
1370
  runEffectIfSourcesChanged(effect) {
1299
1371
  oimRefreshSourceComputeds(effect.sourceComputeds);
1300
- if (!oimHasSourceChangedSinceLastRun(effect)) return;
1301
- this.runEffect(effect);
1372
+ if (oimHasSourceChangedSinceLastRun(effect)) this.runEffect(effect);
1373
+ const sourceTracker = effect.sourceTracker;
1374
+ if (sourceTracker !== void 0 && !oimIsEffectDisposed(effect) && sourceTracker.trackReplacedRootSlots()) {
1375
+ this.resubscribeToTrackedSources(effect, sourceTracker);
1376
+ }
1302
1377
  }
1303
1378
  runEffect(effect) {
1304
1379
  const channelClock = effect.channelSlot.clock;
@@ -1340,11 +1415,11 @@ var _OIMEffectService = class _OIMEffectService {
1340
1415
  }
1341
1416
  (effect.positionsInOtherSubscribedSlots ?? (effect.positionsInOtherSubscribedSlots = []))[edge - 1] = positionInSlot;
1342
1417
  }
1343
- runEffectBodyWithSourceTracking(effect, effectSourceTracker, effectBodyWithSourceTracking) {
1344
- effectSourceTracker.openSourceTracking();
1345
- const undo = effectBodyWithSourceTracking(effectSourceTracker);
1418
+ runSourceTrackingEffectBody(effect, sourceTracker, sourceTrackingEffectBody) {
1419
+ sourceTracker.openSourceTracking();
1420
+ const undo = sourceTrackingEffectBody(sourceTracker);
1346
1421
  try {
1347
- if (effectSourceTracker.closeSourceTracking()) this.resubscribeToTrackedSources(effect, effectSourceTracker);
1422
+ if (sourceTracker.closeSourceTracking()) this.resubscribeToTrackedSources(effect, sourceTracker);
1348
1423
  } catch (failure) {
1349
1424
  this.disposeEffect(effect);
1350
1425
  if (typeof undo === "function") undo();
@@ -1352,11 +1427,11 @@ var _OIMEffectService = class _OIMEffectService {
1352
1427
  }
1353
1428
  return undo;
1354
1429
  }
1355
- resubscribeToTrackedSources(effect, effectSourceTracker) {
1430
+ resubscribeToTrackedSources(effect, sourceTracker) {
1356
1431
  const committedAllRootSlots = effect.allRootSlots;
1357
1432
  const committedSourceComputeds = effect.sourceComputeds;
1358
- const trackedAllRootSlots = effectSourceTracker.getTrackedAllRootSlots();
1359
- const trackedSourceComputeds = effectSourceTracker.getTrackedSourceComputeds();
1433
+ const trackedAllRootSlots = sourceTracker.getTrackedAllRootSlots();
1434
+ const trackedSourceComputeds = sourceTracker.getTrackedSourceComputeds();
1360
1435
  const committedEdgeCount = committedAllRootSlots.length + committedSourceComputeds.length;
1361
1436
  const trackedEdgeCount = trackedAllRootSlots.length + trackedSourceComputeds.length;
1362
1437
  const sharedEdgeCount = committedEdgeCount < trackedEdgeCount ? committedEdgeCount : trackedEdgeCount;
@@ -1381,11 +1456,11 @@ var _OIMEffectService = class _OIMEffectService {
1381
1456
  if (positionsInOtherSubscribedSlots !== void 0 && positionsInOtherSubscribedSlots.length > otherEdgeCount) {
1382
1457
  positionsInOtherSubscribedSlots.length = otherEdgeCount;
1383
1458
  }
1384
- const effectEditable = effect;
1385
- effectEditable.sourceSlots = effectSourceTracker.getTrackedSourceSlots();
1386
- effectEditable.sourceComputeds = trackedSourceComputeds;
1387
- effectEditable.allRootSlots = trackedAllRootSlots;
1388
- effectSourceTracker.commitTrackedSources();
1459
+ const editableEffect = effect;
1460
+ editableEffect.sourceSlots = sourceTracker.getTrackedSourceSlots();
1461
+ editableEffect.sourceComputeds = trackedSourceComputeds;
1462
+ editableEffect.allRootSlots = trackedAllRootSlots;
1463
+ sourceTracker.commitTrackedSources();
1389
1464
  const channelSlot = effect.channelSlot;
1390
1465
  const isFrameRunning = channelSlot.frame.isRunning;
1391
1466
  for (let edge = firstChangedEdge; edge < trackedEdgeCount; edge++) {
@@ -1420,11 +1495,12 @@ var _OIMEffectService = class _OIMEffectService {
1420
1495
  _OIMEffectService.INSTANCE = new _OIMEffectService();
1421
1496
  var OIMEffectService = _OIMEffectService;
1422
1497
 
1423
- // src/engine/computed/OIMComputedValueService.ts
1498
+ // src/computed/OIMComputedValueService.ts
1424
1499
  var OIMComputedValueService = class {
1425
1500
  constructor(options) {
1426
1501
  this.derive = options.derive;
1427
1502
  this.sameValueGuard = options.sameValueGuard ?? Object.is;
1503
+ this.releaseValue = options.releaseValue ?? oimReleaseNoValue;
1428
1504
  }
1429
1505
  getValueForSlot(computedSlot) {
1430
1506
  oimAssertSlotNotReleased(computedSlot);
@@ -1434,22 +1510,26 @@ var OIMComputedValueService = class {
1434
1510
  computedSlot,
1435
1511
  derive,
1436
1512
  this.sameValueGuard,
1513
+ this.releaseValue,
1437
1514
  computedStoreSlot.channelSlot.clock
1438
1515
  );
1439
1516
  return computedSlot.value;
1440
1517
  }
1518
+ releaseSlotValue(computedSlot) {
1519
+ if (computedSlot.ranAtRevision !== -1) this.releaseValue(computedSlot.value);
1520
+ }
1441
1521
  };
1442
1522
 
1443
- // src/engine/slot/OIMContentChangeListenerService.ts
1444
- var _OIMContentChangeListenerService = class _OIMContentChangeListenerService {
1523
+ // src/slot/OIMSlotContentChangeListenerService.ts
1524
+ var _OIMSlotContentChangeListenerService = class _OIMSlotContentChangeListenerService {
1445
1525
  addContentChangeListener(storeSlot, listener, readColumnNames) {
1446
- const storeSlotEditable = storeSlot;
1447
- if (storeSlotEditable.contentChangeListeners === void 0) {
1448
- storeSlotEditable.contentChangeListeners = [];
1449
- storeSlotEditable.contentChangeListenerReadColumnNames = [];
1526
+ const editableStoreSlot = storeSlot;
1527
+ if (editableStoreSlot.contentChangeListeners === void 0) {
1528
+ editableStoreSlot.contentChangeListeners = [];
1529
+ editableStoreSlot.contentChangeListenerReadColumnNames = [];
1450
1530
  }
1451
- storeSlotEditable.contentChangeListeners.push(listener);
1452
- storeSlotEditable.contentChangeListenerReadColumnNames.push(readColumnNames);
1531
+ editableStoreSlot.contentChangeListeners.push(listener);
1532
+ editableStoreSlot.contentChangeListenerReadColumnNames.push(readColumnNames);
1453
1533
  if (readColumnNames === void 0) this.addReadAnyColumn(storeSlot);
1454
1534
  else for (let i = 0; i < readColumnNames.length; i++) this.addReadColumn(storeSlot, readColumnNames[i]);
1455
1535
  }
@@ -1485,15 +1565,15 @@ var _OIMContentChangeListenerService = class _OIMContentChangeListenerService {
1485
1565
  if (storeSlot.allColumnsListenerCount !== 0) storeSlot.allColumnsListenerCount--;
1486
1566
  }
1487
1567
  };
1488
- _OIMContentChangeListenerService.INSTANCE = new _OIMContentChangeListenerService();
1489
- var OIMContentChangeListenerService = _OIMContentChangeListenerService;
1568
+ _OIMSlotContentChangeListenerService.INSTANCE = new _OIMSlotContentChangeListenerService();
1569
+ var OIMSlotContentChangeListenerService = _OIMSlotContentChangeListenerService;
1490
1570
 
1491
- // src/engine/slot/utils/oimGetChannelSlot.ts
1571
+ // src/slot/utils/oimGetChannelSlot.ts
1492
1572
  function oimGetChannelSlot(slot) {
1493
1573
  return slot.storeSlot.channelSlot;
1494
1574
  }
1495
1575
 
1496
- // src/facade/column/OIMColumnSlotService.ts
1576
+ // src/column/OIMColumnSlotService.ts
1497
1577
  var OIMColumnSlotService = class {
1498
1578
  constructor(columnSlotOwner) {
1499
1579
  this.columnSlotOwner = columnSlotOwner;
@@ -1521,8 +1601,11 @@ var OIMColumnSlotService = class {
1521
1601
  }
1522
1602
  };
1523
1603
 
1524
- // src/engine/slot/OIMContentChangeDeliveryService.ts
1525
- var _OIMContentChangeDeliveryService = class _OIMContentChangeDeliveryService {
1604
+ // src/slot/constants/OIM_SLOT_FLAG_QUEUED_IN_BATCH.ts
1605
+ var OIM_SLOT_FLAG_QUEUED_IN_BATCH = 32;
1606
+
1607
+ // src/slot/OIMSlotContentChangeDeliveryService.ts
1608
+ var _OIMSlotContentChangeDeliveryService = class _OIMSlotContentChangeDeliveryService {
1526
1609
  isBatchOpen(storeSlot) {
1527
1610
  return storeSlot.batchDepth > 0;
1528
1611
  }
@@ -1530,23 +1613,23 @@ var _OIMContentChangeDeliveryService = class _OIMContentChangeDeliveryService {
1530
1613
  storeSlot.batchDepth++;
1531
1614
  }
1532
1615
  closeBatch(storeSlot) {
1533
- const storeSlotEditable = storeSlot;
1534
- if (--storeSlotEditable.batchDepth > 0) return;
1616
+ const editableStoreSlot = storeSlot;
1617
+ if (editableStoreSlot.batchDepth === 0) {
1618
+ throw new Error(
1619
+ "OIMSlotContentChangeDeliveryService.closeBatch: no batch is open on this store slot, so there is nothing to close. A close without its open would leave the next batch delivering every write at once."
1620
+ );
1621
+ }
1622
+ if (--editableStoreSlot.batchDepth > 0) return;
1535
1623
  const batchSlotChannelQueue = storeSlot.batchSlotChannelQueue;
1536
1624
  if (batchSlotChannelQueue === void 0 || batchSlotChannelQueue.getEntryCount() === 0) return;
1537
1625
  this.deliverBatch(storeSlot, batchSlotChannelQueue);
1538
1626
  }
1539
1627
  enqueueContentChange(storeSlot, slot, patch, changedColumns) {
1540
- const storeSlotEditable = storeSlot;
1541
- (storeSlotEditable.batchSlotChannelQueue ?? (storeSlotEditable.batchSlotChannelQueue = new OIMChannelQueue())).enqueueEntry(slot);
1542
- (storeSlotEditable.batchPatchChannelQueue ?? (storeSlotEditable.batchPatchChannelQueue = new OIMChannelQueue())).enqueueEntry(patch);
1543
- (storeSlotEditable.batchChangedColumnsChannelQueue ?? (storeSlotEditable.batchChangedColumnsChannelQueue = new OIMChannelQueue())).enqueueEntry(changedColumns === void 0 ? void 0 : changedColumns.slice());
1544
- }
1545
- isLastEnqueuedSlot(storeSlot, slot) {
1546
- const batchSlotChannelQueue = storeSlot.batchSlotChannelQueue;
1547
- if (batchSlotChannelQueue === void 0) return false;
1548
- const batchSlotCount = batchSlotChannelQueue.getEntryCount();
1549
- return batchSlotCount !== 0 && batchSlotChannelQueue.getEntryAt(batchSlotCount - 1) === slot;
1628
+ const editableStoreSlot = storeSlot;
1629
+ (editableStoreSlot.batchSlotChannelQueue ?? (editableStoreSlot.batchSlotChannelQueue = new OIMChannelQueue())).enqueueEntry(slot);
1630
+ slot.slotFlags |= OIM_SLOT_FLAG_QUEUED_IN_BATCH;
1631
+ (editableStoreSlot.batchPatchChannelQueue ?? (editableStoreSlot.batchPatchChannelQueue = new OIMChannelQueue())).enqueueEntry(patch);
1632
+ (editableStoreSlot.batchChangedColumnsChannelQueue ?? (editableStoreSlot.batchChangedColumnsChannelQueue = new OIMChannelQueue())).enqueueEntry(changedColumns === void 0 ? void 0 : changedColumns.slice());
1550
1633
  }
1551
1634
  deliverBatch(storeSlot, batchSlotChannelQueue) {
1552
1635
  const batchPatchChannelQueue = storeSlot.batchPatchChannelQueue;
@@ -1561,10 +1644,13 @@ var _OIMContentChangeDeliveryService = class _OIMContentChangeDeliveryService {
1561
1644
  for (let i = 0; i < listeners.length; i++) listeners[i].onContentChanged(slot, patch, changedColumns);
1562
1645
  } else {
1563
1646
  for (let i = 0; i < listeners.length; i++) {
1564
- listeners[i].onContentChangedMany(batchSlotChannelQueue, batchPatchChannelQueue, batchChangedColumnsChannelQueue);
1647
+ listeners[i].onManyContentsChanged(batchSlotChannelQueue, batchPatchChannelQueue, batchChangedColumnsChannelQueue);
1565
1648
  }
1566
1649
  }
1567
1650
  } finally {
1651
+ for (let i = 0; i < batchSlotChannelQueue.getEntryCount(); i++) {
1652
+ batchSlotChannelQueue.getEntryAt(i).slotFlags &= ~OIM_SLOT_FLAG_QUEUED_IN_BATCH;
1653
+ }
1568
1654
  try {
1569
1655
  for (let i = 0; i < batchSlotChannelQueue.getEntryCount(); i++) {
1570
1656
  const slot = batchSlotChannelQueue.getEntryAt(i);
@@ -1578,10 +1664,10 @@ var _OIMContentChangeDeliveryService = class _OIMContentChangeDeliveryService {
1578
1664
  }
1579
1665
  }
1580
1666
  };
1581
- _OIMContentChangeDeliveryService.INSTANCE = new _OIMContentChangeDeliveryService();
1582
- var OIMContentChangeDeliveryService = _OIMContentChangeDeliveryService;
1667
+ _OIMSlotContentChangeDeliveryService.INSTANCE = new _OIMSlotContentChangeDeliveryService();
1668
+ var OIMSlotContentChangeDeliveryService = _OIMSlotContentChangeDeliveryService;
1583
1669
 
1584
- // src/engine/collector/OIMSlotAtEmptyReleasePolicy.ts
1670
+ // src/collector/OIMSlotAtEmptyReleasePolicy.ts
1585
1671
  var _OIMSlotAtEmptyReleasePolicy = class _OIMSlotAtEmptyReleasePolicy {
1586
1672
  constructor() {
1587
1673
  this.releasesWrittenSlots = false;
@@ -1609,7 +1695,7 @@ var _OIMSlotAtEmptyReleasePolicy = class _OIMSlotAtEmptyReleasePolicy {
1609
1695
  _OIMSlotAtEmptyReleasePolicy.INSTANCE = new _OIMSlotAtEmptyReleasePolicy();
1610
1696
  var OIMSlotAtEmptyReleasePolicy = _OIMSlotAtEmptyReleasePolicy;
1611
1697
 
1612
- // src/engine/slot/OIMSlotOwnerService.ts
1698
+ // src/slot/OIMSlotOwnerService.ts
1613
1699
  var OIMSlotOwnerService = class extends OIMSlotOwner {
1614
1700
  constructor(options) {
1615
1701
  super();
@@ -1631,26 +1717,22 @@ var OIMSlotOwnerService = class extends OIMSlotOwner {
1631
1717
  return slot.columnSlotStore !== void 0;
1632
1718
  }
1633
1719
  hasContentChangeListeners(slot) {
1634
- const storeSlot = slot.storeSlot;
1635
- if (storeSlot === void 0) return false;
1636
- const listeners = storeSlot.contentChangeListeners;
1720
+ const listeners = slot.storeSlot.contentChangeListeners;
1637
1721
  return listeners !== void 0 && listeners.length !== 0;
1638
1722
  }
1639
1723
  dispatchContentChange(slot, patch, changedColumns) {
1640
1724
  const storeSlot = slot.storeSlot;
1641
- if (storeSlot === void 0) return;
1642
1725
  const listeners = storeSlot.contentChangeListeners;
1643
1726
  if (listeners === void 0 || listeners.length === 0) return;
1644
1727
  if (changedColumns !== void 0 && !this.isAnyColumnRead(storeSlot, changedColumns)) return;
1645
1728
  if (storeSlot.batchDepth > 0) {
1646
- OIMContentChangeDeliveryService.INSTANCE.enqueueContentChange(storeSlot, slot, patch, changedColumns);
1729
+ OIMSlotContentChangeDeliveryService.INSTANCE.enqueueContentChange(storeSlot, slot, patch, changedColumns);
1647
1730
  return;
1648
1731
  }
1649
1732
  for (let i = 0; i < listeners.length; i++) listeners[i].onContentChanged(slot, patch, changedColumns);
1650
1733
  }
1651
1734
  isAnyColumnReferenced(slot, changedColumns) {
1652
1735
  const storeSlot = slot.storeSlot;
1653
- if (storeSlot === void 0) return false;
1654
1736
  return slot.columnSlotStore !== void 0 && this.columnSlotOwner.isAnyColumnReferenced(storeSlot, changedColumns) || this.isAnyColumnRead(storeSlot, changedColumns);
1655
1737
  }
1656
1738
  isAnyColumnRead(storeSlot, changedColumns) {
@@ -1669,8 +1751,7 @@ var OIMSlotOwnerService = class extends OIMSlotOwner {
1669
1751
  return changedColumnNames;
1670
1752
  }
1671
1753
  releaseSlotIfUnheldAfterListeners(slot) {
1672
- const storeSlot = slot.storeSlot;
1673
- if (storeSlot !== void 0 && storeSlot.batchDepth > 0 && OIMContentChangeDeliveryService.INSTANCE.isLastEnqueuedSlot(storeSlot, slot)) return;
1754
+ if ((slot.slotFlags & OIM_SLOT_FLAG_QUEUED_IN_BATCH) !== 0) return;
1674
1755
  this.releaseSlotIfUnheld(slot);
1675
1756
  }
1676
1757
  releaseWrittenSlotIfUnheld(slot) {
@@ -1709,7 +1790,7 @@ var OIMSlotOwnerService = class extends OIMSlotOwner {
1709
1790
  }
1710
1791
  onSlotIdle(slot) {
1711
1792
  if (oimIsSlotEmpty(slot)) return;
1712
- if (this.slotReleasePolicy.onSlotIdle(slot)) this.releaseSlotIfUnheld(slot);
1793
+ this.slotReleasePolicy.onSlotIdle(slot);
1713
1794
  }
1714
1795
  onSlotFirstSubscribed(slot) {
1715
1796
  this.slotSubscriptionListener.onSlotFirstSubscribed(slot);
@@ -1728,14 +1809,7 @@ var OIMSlotOwnerService = class extends OIMSlotOwner {
1728
1809
  if (!isEmpty && !this.releasesWrittenSlots) return;
1729
1810
  if (!this.isReleasable(ownSlot)) return;
1730
1811
  if (isEmpty ? !this.slotReleasePolicy.isEmptySlotReleasable(ownSlot) : !this.slotReleasePolicy.isSlotReleasable(ownSlot)) return;
1731
- if (!isEmpty) {
1732
- const channelSlot = oimGetChannelSlot(ownSlot);
1733
- if (OIMChannelService.INSTANCE.isRefusingWrites(channelSlot)) {
1734
- OIMUnusedSlotCollectorService.INSTANCE.holdSlotUntilFlush(channelSlot.collectorSlot.unusedSlotCollectorSlot, ownSlot);
1735
- return;
1736
- }
1737
- }
1738
- this.releaseSlot(ownSlot, isEmpty);
1812
+ this.releaseSlot(ownSlot);
1739
1813
  }
1740
1814
  isReleasable(slot) {
1741
1815
  if (slot.holdCount > 0) return false;
@@ -1743,18 +1817,16 @@ var OIMSlotOwnerService = class extends OIMSlotOwner {
1743
1817
  if (slot.columnSlotStore !== void 0) return false;
1744
1818
  return !this.slotContentService.hasReference(slot);
1745
1819
  }
1746
- releaseSlot(slot, isEmpty) {
1747
- if (!isEmpty) this.assertWritable(slot);
1748
- this.slotContentService.releaseSlotContent(slot, this);
1820
+ releaseSlot(slot) {
1821
+ this.slotContentService.releaseSlotContent(slot);
1749
1822
  slot.slotFlags |= OIM_SLOT_FLAG_EMPTY;
1750
1823
  this.slotReleasePolicy.cancelSlotRelease(slot);
1751
- const storeSlot = slot.storeSlot;
1752
- if (storeSlot !== void 0) this.slotFilingService.unfileSlot(storeSlot.store, slot);
1824
+ this.slotFilingService.unfileSlot(slot.storeSlot.store, slot);
1753
1825
  oimMarkSlotReleased(slot);
1754
1826
  }
1755
1827
  };
1756
1828
 
1757
- // src/engine/slot/utils/createOIMStoreSlot.ts
1829
+ // src/slot/utils/createOIMStoreSlot.ts
1758
1830
  function createOIMStoreSlot(store, channelSlot, slotService, sourceStoreSlot) {
1759
1831
  return {
1760
1832
  store,
@@ -1791,7 +1863,45 @@ function createOIMStoreSlot(store, channelSlot, slotService, sourceStoreSlot) {
1791
1863
  };
1792
1864
  }
1793
1865
 
1794
- // src/facade/slot/OIMSlotCollectionService.ts
1866
+ // src/slot/OIMSlotCollectionStoreAggregate.ts
1867
+ var OIMSlotCollectionStoreAggregate = class {
1868
+ constructor(slotService, storeSlot) {
1869
+ this.slotService = slotService;
1870
+ this.storeSlot = storeSlot;
1871
+ }
1872
+ get slotContentService() {
1873
+ return this.slotService.slotContentService;
1874
+ }
1875
+ findSlotByKey(key) {
1876
+ return this.slotService.findSlotByKey(this.storeSlot, key);
1877
+ }
1878
+ hasSlotContentByKey(key) {
1879
+ return this.slotService.hasSlotContentByKey(this.storeSlot, key);
1880
+ }
1881
+ getSlotByKey(key) {
1882
+ return this.slotService.getSlotByKey(this.storeSlot, key);
1883
+ }
1884
+ holdSlotByKey(key) {
1885
+ return this.slotService.holdSlotByKey(this.storeSlot, key);
1886
+ }
1887
+ getSlots() {
1888
+ return this.slotService.getSlots(this.storeSlot);
1889
+ }
1890
+ getSlotCount() {
1891
+ return this.slotService.getSlotCount(this.storeSlot);
1892
+ }
1893
+ openBatch() {
1894
+ this.slotService.openBatch(this.storeSlot);
1895
+ }
1896
+ closeBatch() {
1897
+ this.slotService.closeBatch(this.storeSlot);
1898
+ }
1899
+ writeInBatch(write) {
1900
+ return this.slotService.writeInBatch(this.storeSlot, write);
1901
+ }
1902
+ };
1903
+
1904
+ // src/slot/OIMSlotCollectionService.ts
1795
1905
  var OIMSlotCollectionService = class {
1796
1906
  constructor(options) {
1797
1907
  const slotOwnerService = new OIMSlotOwnerService({ ...options, slotFilingService: options.slotStoreService });
@@ -1807,17 +1917,20 @@ var OIMSlotCollectionService = class {
1807
1917
  }
1808
1918
  createStoreSlot(channelMap) {
1809
1919
  const channelSlot = channelMap.defaultChannelSlot;
1810
- return this.createStoreSlotWith((store) => createOIMStoreSlot(store, channelSlot, this));
1920
+ return this.createStoreSlotOverNewStore((store) => createOIMStoreSlot(store, channelSlot, this));
1811
1921
  }
1812
1922
  createStoreSlotFrom(sourceStoreSlot) {
1813
- return this.createStoreSlotWith((store) => createOIMStoreSlot(
1923
+ return this.createStoreSlotOverNewStore((store) => createOIMStoreSlot(
1814
1924
  store,
1815
1925
  sourceStoreSlot.channelSlot,
1816
1926
  this,
1817
1927
  sourceStoreSlot
1818
1928
  ));
1819
1929
  }
1820
- createStoreSlotWith(createStoreSlotLiteral) {
1930
+ createStoreAggregate(storeSlot) {
1931
+ return new OIMSlotCollectionStoreAggregate(this, storeSlot);
1932
+ }
1933
+ createStoreSlotOverNewStore(createStoreSlotLiteral) {
1821
1934
  const storeSlot = createStoreSlotLiteral(this.slotStoreService.createStore());
1822
1935
  if (this.storeSlotListener !== void 0) this.storeSlotListener.onStoreSlotCreated(storeSlot);
1823
1936
  return storeSlot;
@@ -1851,13 +1964,13 @@ var OIMSlotCollectionService = class {
1851
1964
  return this.slotStoreService.isSameKey(key, otherKey);
1852
1965
  }
1853
1966
  openBatch(storeSlot) {
1854
- OIMContentChangeDeliveryService.INSTANCE.openBatch(storeSlot);
1967
+ OIMSlotContentChangeDeliveryService.INSTANCE.openBatch(storeSlot);
1855
1968
  }
1856
1969
  closeBatch(storeSlot) {
1857
- OIMContentChangeDeliveryService.INSTANCE.closeBatch(storeSlot);
1970
+ OIMSlotContentChangeDeliveryService.INSTANCE.closeBatch(storeSlot);
1858
1971
  }
1859
1972
  writeInBatch(storeSlot, write) {
1860
- const contentChangeDeliveryService = OIMContentChangeDeliveryService.INSTANCE;
1973
+ const contentChangeDeliveryService = OIMSlotContentChangeDeliveryService.INSTANCE;
1861
1974
  contentChangeDeliveryService.openBatch(storeSlot);
1862
1975
  try {
1863
1976
  return write();
@@ -1878,8 +1991,18 @@ var OIMSlotCollectionService = class {
1878
1991
  }
1879
1992
  };
1880
1993
 
1881
- // src/facade/slot/OIMWritableSlotCollectionService.ts
1994
+ // src/slot/OIMWritableSlotCollectionStoreAggregate.ts
1995
+ var OIMWritableSlotCollectionStoreAggregate = class extends OIMSlotCollectionStoreAggregate {
1996
+ writeSlotContentByKey(key, content, changedSlots) {
1997
+ return this.slotService.writeSlotContentByKey(this.storeSlot, key, content, changedSlots);
1998
+ }
1999
+ };
2000
+
2001
+ // src/slot/OIMWritableSlotCollectionService.ts
1882
2002
  var OIMWritableSlotCollectionService = class extends OIMSlotCollectionService {
2003
+ createStoreAggregate(storeSlot) {
2004
+ return new OIMWritableSlotCollectionStoreAggregate(this, storeSlot);
2005
+ }
1883
2006
  writeSlotContentByKey(storeSlot, key, content, changedSlots) {
1884
2007
  const filed = this.slotStoreService.get(storeSlot.store, key);
1885
2008
  if (filed !== void 0) {
@@ -1892,7 +2015,30 @@ var OIMWritableSlotCollectionService = class extends OIMSlotCollectionService {
1892
2015
  }
1893
2016
  };
1894
2017
 
1895
- // src/facade/slot/OIMSingleSlotService.ts
2018
+ // src/slot/OIMSingleSlotStoreAggregate.ts
2019
+ var OIMSingleSlotStoreAggregate = class {
2020
+ constructor(slotService, storeSlot) {
2021
+ this.slotService = slotService;
2022
+ this.storeSlot = storeSlot;
2023
+ }
2024
+ get slotContentService() {
2025
+ return this.slotService.slotContentService;
2026
+ }
2027
+ findSingleSlot() {
2028
+ return this.slotService.findSingleSlot(this.storeSlot);
2029
+ }
2030
+ hasSingleSlotContent() {
2031
+ return this.slotService.hasSingleSlotContent(this.storeSlot);
2032
+ }
2033
+ getSingleSlot() {
2034
+ return this.slotService.getSingleSlot(this.storeSlot);
2035
+ }
2036
+ holdSingleSlot() {
2037
+ return this.slotService.holdSingleSlot(this.storeSlot);
2038
+ }
2039
+ };
2040
+
2041
+ // src/slot/OIMSingleSlotService.ts
1896
2042
  var OIMSingleSlotService = class {
1897
2043
  constructor(options) {
1898
2044
  const slotOwnerService = new OIMSlotOwnerService({ ...options, slotFilingService: options.slotStoreService });
@@ -1915,6 +2061,9 @@ var OIMSingleSlotService = class {
1915
2061
  if (this.storeSlotListener !== void 0) this.storeSlotListener.onStoreSlotCreated(storeSlot);
1916
2062
  return storeSlot;
1917
2063
  }
2064
+ createStoreAggregate(storeSlot) {
2065
+ return new OIMSingleSlotStoreAggregate(this, storeSlot);
2066
+ }
1918
2067
  findSingleSlot(storeSlot) {
1919
2068
  return this.slotStoreService.getSingleSlot(storeSlot.store);
1920
2069
  }
@@ -1943,8 +2092,21 @@ var OIMSingleSlotService = class {
1943
2092
  }
1944
2093
  };
1945
2094
 
1946
- // src/facade/slot/OIMWritableSingleSlotService.ts
2095
+ // src/slot/OIMWritableSingleSlotStoreAggregate.ts
2096
+ var OIMWritableSingleSlotStoreAggregate = class extends OIMSingleSlotStoreAggregate {
2097
+ writeSingleSlotContent(content, changedSlots) {
2098
+ return this.slotService.writeSingleSlotContent(this.storeSlot, content, changedSlots);
2099
+ }
2100
+ clearSingleSlotContent() {
2101
+ this.slotService.clearSingleSlotContent(this.storeSlot);
2102
+ }
2103
+ };
2104
+
2105
+ // src/slot/OIMWritableSingleSlotService.ts
1947
2106
  var OIMWritableSingleSlotService = class extends OIMSingleSlotService {
2107
+ createStoreAggregate(storeSlot) {
2108
+ return new OIMWritableSingleSlotStoreAggregate(this, storeSlot);
2109
+ }
1948
2110
  writeSingleSlotContent(storeSlot, content, changedSlots) {
1949
2111
  const filed = this.slotStoreService.getSingleSlot(storeSlot.store);
1950
2112
  if (filed !== void 0) {
@@ -1961,7 +2123,7 @@ var OIMWritableSingleSlotService = class extends OIMSingleSlotService {
1961
2123
  }
1962
2124
  };
1963
2125
 
1964
- // src/engine/entity/OIMSlotEntityPresenceEmptinessPolicy.ts
2126
+ // src/entity/OIMSlotEntityPresenceEmptinessPolicy.ts
1965
2127
  var _OIMSlotEntityPresenceEmptinessPolicy = class _OIMSlotEntityPresenceEmptinessPolicy {
1966
2128
  isEmpty(entitySlot) {
1967
2129
  return entitySlot.entity === void 0;
@@ -1970,8 +2132,8 @@ var _OIMSlotEntityPresenceEmptinessPolicy = class _OIMSlotEntityPresenceEmptines
1970
2132
  _OIMSlotEntityPresenceEmptinessPolicy.INSTANCE = new _OIMSlotEntityPresenceEmptinessPolicy();
1971
2133
  var OIMSlotEntityPresenceEmptinessPolicy = _OIMSlotEntityPresenceEmptinessPolicy;
1972
2134
 
1973
- // src/engine/entity/utils/createOIMEntitySlot.ts
1974
- function createOIMEntitySlot(key, owner, storeSlot = void 0) {
2135
+ // src/entity/utils/createOIMEntitySlot.ts
2136
+ function createOIMEntitySlot(key, owner, storeSlot) {
1975
2137
  return {
1976
2138
  effects: void 0,
1977
2139
  changedAtRevision: 0,
@@ -1992,8 +2154,8 @@ function createOIMEntitySlot(key, owner, storeSlot = void 0) {
1992
2154
  };
1993
2155
  }
1994
2156
 
1995
- // src/engine/entity/utils/createOIMSingleEntitySlot.ts
1996
- function createOIMSingleEntitySlot(owner, storeSlot) {
2157
+ // src/entity/utils/createOIMEntityContentSlot.ts
2158
+ function createOIMEntityContentSlot(owner, storeSlot) {
1997
2159
  const singleEntitySlot = {
1998
2160
  effects: void 0,
1999
2161
  changedAtRevision: 0,
@@ -2015,7 +2177,15 @@ function createOIMSingleEntitySlot(owner, storeSlot) {
2015
2177
  return singleEntitySlot;
2016
2178
  }
2017
2179
 
2018
- // src/engine/entity/OIMSlotContentEntityService.ts
2180
+ // src/slot/utils/oimAssertSlotUnheld.ts
2181
+ var oimAssertSlotUnheld = (slot) => {
2182
+ if (slot.holdCount === 0) return;
2183
+ throw new Error(
2184
+ "releaseSlotContent: this slot is still held, so its identity is not going. The slot owner calls releaseSlotContent when it releases a slot nothing holds; to empty a held slot, use clearSlotContent."
2185
+ );
2186
+ };
2187
+
2188
+ // src/entity/OIMSlotContentEntityService.ts
2019
2189
  var OIMSlotContentEntityService = class {
2020
2190
  constructor(options) {
2021
2191
  this.entityWriter = options.entityWriter;
@@ -2026,7 +2196,7 @@ var OIMSlotContentEntityService = class {
2026
2196
  return createOIMEntitySlot(key, slotOwner, storeSlot);
2027
2197
  }
2028
2198
  createSingleSlot(storeSlot, slotOwner) {
2029
- return createOIMSingleEntitySlot(slotOwner, storeSlot);
2199
+ return createOIMEntityContentSlot(slotOwner, storeSlot);
2030
2200
  }
2031
2201
  isSlotEmpty(entitySlot) {
2032
2202
  return this.slotEmptinessPolicy.isEmpty(entitySlot);
@@ -2168,7 +2338,7 @@ var OIMSlotContentEntityService = class {
2168
2338
  slotOwnerService.assertWritable(entitySlot);
2169
2339
  const channelSlot = oimGetChannelSlot(entitySlot);
2170
2340
  if (!this.isOnFastPath(entitySlot)) {
2171
- this.releaseSlotContent(entitySlot);
2341
+ this.clearEntityAndMarkColumns(entitySlot);
2172
2342
  slotOwnerService.settleEmptiness(entitySlot, this.slotEmptinessPolicy.isEmpty(entitySlot));
2173
2343
  slotOwnerService.dispatchContentChange(entitySlot);
2174
2344
  slotOwnerService.releaseSlotIfUnheldAfterListeners(entitySlot);
@@ -2231,9 +2401,12 @@ var OIMSlotContentEntityService = class {
2231
2401
  slotOwnerService.releaseSlotIfUnheldAfterListeners(entitySlot);
2232
2402
  }
2233
2403
  releaseSlotContent(entitySlot) {
2404
+ oimAssertSlotUnheld(entitySlot);
2405
+ this.clearEntityAndMarkColumns(entitySlot);
2406
+ }
2407
+ clearEntityAndMarkColumns(entitySlot) {
2234
2408
  const entity = entitySlot.entity;
2235
2409
  if (entity === void 0) return;
2236
- this.slotOwnerServiceOf(entitySlot).assertWritable(entitySlot);
2237
2410
  this.entityWriter.clearEntity(entitySlot);
2238
2411
  this.dispatchColumnsChanged(entitySlot, entity, void 0);
2239
2412
  }
@@ -2265,34 +2438,21 @@ var OIMSlotContentEntityService = class {
2265
2438
  }
2266
2439
  };
2267
2440
 
2268
- // src/factories/defaults/OIMDefaultValue.ts
2441
+ // src/db/OIMDefaultValue.ts
2269
2442
  var OIMDefaultValue = class {
2270
- constructor(name, createValue) {
2443
+ constructor(createValue) {
2271
2444
  this.defaultValue = void 0;
2272
- this.isHandedOut = false;
2273
- this.name = name;
2274
2445
  this.createValue = createValue;
2275
2446
  }
2276
2447
  getValue() {
2277
- this.isHandedOut = true;
2278
2448
  return this.defaultValue ?? (this.defaultValue = this.createValue());
2279
2449
  }
2280
- setValue(value) {
2281
- this.assertNoLateOverride();
2282
- this.defaultValue = value;
2283
- }
2284
- assertNoLateOverride() {
2285
- if (!this.isHandedOut) return;
2286
- throw new Error(
2287
- `OIMDefaults.${this.name} has already been handed out, and whoever took it keeps it \u2014 so replacing it now leaves two implementations live in one process, the older one inside every object built before this call. Set it at startup, before anything reads it.`
2288
- );
2289
- }
2290
2450
  };
2291
2451
 
2292
- // src/factories/defaults/OIM_DEFAULT_STORE_SLOT_LISTENER.ts
2293
- var OIM_DEFAULT_STORE_SLOT_LISTENER = /* @__PURE__ */ new OIMDefaultValue("STORE_SLOT_LISTENER", () => OIMNoStoreSlotListener.INSTANCE);
2452
+ // src/db/constants/OIM_DEFAULT_STORE_SLOT_LISTENER.ts
2453
+ var OIM_DEFAULT_STORE_SLOT_LISTENER = /* @__PURE__ */ new OIMDefaultValue(() => OIMNoStoreSlotListener.INSTANCE);
2294
2454
 
2295
- // src/engine/store/OIMSlotMapStoreService.ts
2455
+ // src/store/OIMSlotMapStoreService.ts
2296
2456
  var _OIMSlotMapStoreService = class _OIMSlotMapStoreService {
2297
2457
  createStore() {
2298
2458
  return /* @__PURE__ */ new Map();
@@ -2328,16 +2488,32 @@ var _OIMSlotMapStoreService = class _OIMSlotMapStoreService {
2328
2488
  _OIMSlotMapStoreService.INSTANCE = new _OIMSlotMapStoreService();
2329
2489
  var OIMSlotMapStoreService = _OIMSlotMapStoreService;
2330
2490
 
2331
- // src/factories/utils/oimSlotStoreServiceWithDefault.ts
2332
- function oimSlotStoreServiceWithDefault(slotStoreService) {
2491
+ // src/store/utils/oimResolveSlotStoreService.ts
2492
+ function oimResolveSlotStoreService(slotStoreService) {
2333
2493
  return slotStoreService ?? OIMSlotMapStoreService.INSTANCE;
2334
2494
  }
2335
2495
 
2336
- // src/engine/column/OIMPushColumnSlotOwner.ts
2496
+ // src/db/OIMDefaults.ts
2497
+ var _OIMDefaults = class _OIMDefaults {
2498
+ constructor(options = {}) {
2499
+ this.slotStamp = options.slotStamp;
2500
+ this.slotReleasePolicy = options.slotReleasePolicy;
2501
+ this.entityWriter = options.entityWriter;
2502
+ this.entitySlotEmptinessPolicy = options.entitySlotEmptinessPolicy;
2503
+ this.indexKeysService = options.indexKeysService;
2504
+ this.columnSlotStoreService = options.columnSlotStoreService;
2505
+ this.computedColumnSlotStoreService = options.computedColumnSlotStoreService;
2506
+ this.storeSlotListener = options.storeSlotListener;
2507
+ }
2508
+ };
2509
+ _OIMDefaults.INSTANCE = new _OIMDefaults();
2510
+ var OIMDefaults = _OIMDefaults;
2511
+
2512
+ // src/column/OIMPushColumnSlotOwner.ts
2337
2513
  var hasValueColumn = (value, columnName) => Object.prototype.hasOwnProperty.call(value, columnName) && value[columnName] !== void 0;
2338
2514
  var OIMPushColumnSlotOwner = class extends OIMColumnSlotOwner {
2339
2515
  constructor(options) {
2340
- super(oimColumnSlotStoreServiceOfColumnOwnerOptions(options));
2516
+ super(oimColumnSlotStoreServiceOfColumnSlotOwnerOptions(options));
2341
2517
  }
2342
2518
  createColumnSlot(carrierSlot, key) {
2343
2519
  return {
@@ -2351,7 +2527,7 @@ var OIMPushColumnSlotOwner = class extends OIMColumnSlotOwner {
2351
2527
  releaseDueAfterUnholdMs: -1,
2352
2528
  slotFlags: OIM_SLOT_FLAG_EMPTY,
2353
2529
  columnSlotStore: void 0,
2354
- storeSlot: void 0,
2530
+ storeSlot: carrierSlot.storeSlot,
2355
2531
  owner: this,
2356
2532
  key,
2357
2533
  carrierSlot
@@ -2420,51 +2596,51 @@ var OIMPushColumnSlotOwner = class extends OIMColumnSlotOwner {
2420
2596
  }
2421
2597
  };
2422
2598
 
2423
- // src/engine/column/utils/createOIMPushColumnSlotOwner.ts
2599
+ // src/column/utils/createOIMPushColumnSlotOwner.ts
2424
2600
  var createOIMPushColumnSlotOwner = (columnSlotOwnerOptions) => new OIMPushColumnSlotOwner(columnSlotOwnerOptions);
2425
2601
 
2426
- // src/factories/defaults/OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.ts
2427
- var OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue("COLUMN_SLOT_STORE_SERVICE", () => OIMSlotMapStoreService.INSTANCE);
2602
+ // src/db/constants/OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.ts
2603
+ var OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue(() => OIMSlotMapStoreService.INSTANCE);
2428
2604
 
2429
- // src/engine/column/utils/oimColumnOwnerOptions.ts
2430
- function oimColumnOwnerOptions(columnSlotOwnerOptions) {
2605
+ // src/column/utils/oimColumnSlotOwnerOptions.ts
2606
+ function oimColumnSlotOwnerOptions(columnSlotOwnerOptions) {
2431
2607
  return columnSlotOwnerOptions.columnNames !== void 0 ? { columnNames: columnSlotOwnerOptions.columnNames } : { columnSlotStoreService: columnSlotOwnerOptions.columnSlotStoreService };
2432
2608
  }
2433
2609
 
2434
- // src/factories/utils/oimColumnOwnerOptionsWithDefault.ts
2435
- function oimColumnOwnerOptionsWithDefault(columnSlotStoreService, columnNames, defaultColumnSlotStoreService) {
2436
- return oimColumnOwnerOptions({ columnNames, columnSlotStoreService: columnSlotStoreService ?? defaultColumnSlotStoreService });
2610
+ // src/column/utils/oimResolveColumnSlotOwnerOptions.ts
2611
+ function oimResolveColumnSlotOwnerOptions(columnSlotStoreService, columnNames, defaultColumnSlotStoreService) {
2612
+ return oimColumnSlotOwnerOptions({ columnNames, columnSlotStoreService: columnSlotStoreService ?? defaultColumnSlotStoreService });
2437
2613
  }
2438
2614
 
2439
- // src/factories/utils/oimSlotOwnerOptionsWithDefault.ts
2440
- function oimSlotOwnerOptionsWithDefault(db, options) {
2615
+ // src/slot/utils/oimResolveSlotOwnerServiceOptions.ts
2616
+ function oimResolveSlotOwnerServiceOptions(defaults, options) {
2441
2617
  return {
2442
- slotStamp: db.slotStamp,
2443
- slotReleasePolicy: options.slotReleasePolicy ?? db.slotReleasePolicy,
2618
+ slotStamp: defaults.slotStamp,
2619
+ slotReleasePolicy: options.slotReleasePolicy ?? defaults.slotReleasePolicy,
2444
2620
  slotSubscriptionListener: options.slotSubscriptionListener,
2445
- columnSlotOwnerOptions: oimColumnOwnerOptionsWithDefault(
2621
+ columnSlotOwnerOptions: oimResolveColumnSlotOwnerOptions(
2446
2622
  options.columnSlotStoreService,
2447
2623
  options.columnNames,
2448
- OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.getValue()
2624
+ defaults.columnSlotStoreService ?? OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.getValue()
2449
2625
  ),
2450
2626
  createColumnSlotOwner: createOIMPushColumnSlotOwner
2451
2627
  };
2452
2628
  }
2453
2629
 
2454
- // src/factories/createOIMSlotCollectionService.ts
2455
- function createOIMSlotCollectionService(db, options) {
2630
+ // src/slot/createOIMSlotCollectionService.ts
2631
+ function createOIMSlotCollectionService(options) {
2456
2632
  return new OIMWritableSlotCollectionService({
2457
- ...oimSlotOwnerOptionsWithDefault(db, options),
2458
- slotStoreService: oimSlotStoreServiceWithDefault(options.slotStoreService),
2633
+ ...oimResolveSlotOwnerServiceOptions(options.defaults ?? OIMDefaults.INSTANCE, options),
2634
+ slotStoreService: oimResolveSlotStoreService(options.slotStoreService),
2459
2635
  slotContentService: options.slotContentService,
2460
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
2636
+ storeSlotListener: options.defaults?.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
2461
2637
  });
2462
2638
  }
2463
2639
 
2464
- // src/engine/slot/constants/OIM_FROZEN_EMPTY_SLOTS.ts
2640
+ // src/slot/constants/OIM_FROZEN_EMPTY_SLOTS.ts
2465
2641
  var OIM_FROZEN_EMPTY_SLOTS = Object.freeze([]);
2466
2642
 
2467
- // src/engine/store/OIMSingleSlotStoreService.ts
2643
+ // src/store/OIMSingleSlotStoreService.ts
2468
2644
  var _OIMSingleSlotStoreService = class _OIMSingleSlotStoreService {
2469
2645
  createStore() {
2470
2646
  return { slot: void 0 };
@@ -2489,36 +2665,48 @@ var _OIMSingleSlotStoreService = class _OIMSingleSlotStoreService {
2489
2665
  _OIMSingleSlotStoreService.INSTANCE = new _OIMSingleSlotStoreService();
2490
2666
  var OIMSingleSlotStoreService = _OIMSingleSlotStoreService;
2491
2667
 
2492
- // src/factories/createOIMSingleSlotService.ts
2493
- function createOIMSingleSlotService(db, options) {
2668
+ // src/slot/createOIMSingleSlotService.ts
2669
+ function createOIMSingleSlotService(options) {
2494
2670
  return new OIMWritableSingleSlotService({
2495
- ...oimSlotOwnerOptionsWithDefault(db, options),
2671
+ ...oimResolveSlotOwnerServiceOptions(options.defaults ?? OIMDefaults.INSTANCE, options),
2496
2672
  slotStoreService: OIMSingleSlotStoreService.INSTANCE,
2497
2673
  slotContentService: options.slotContentService,
2498
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
2674
+ storeSlotListener: options.defaults?.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
2499
2675
  });
2500
2676
  }
2501
2677
 
2502
- // src/factories/defaults/OIM_DEFAULT_ENTITY_SLOT_EMPTINESS.ts
2503
- var OIM_DEFAULT_ENTITY_SLOT_EMPTINESS = /* @__PURE__ */ new OIMDefaultValue("ENTITY_SLOT_EMPTINESS", () => OIMSlotEntityPresenceEmptinessPolicy.INSTANCE);
2678
+ // src/slot/createOIMSlotCollectionStoreAggregate.ts
2679
+ function createOIMSlotCollectionStoreAggregate(channelMap, options) {
2680
+ const slotCollectionService = createOIMSlotCollectionService(options);
2681
+ return slotCollectionService.createStoreAggregate(slotCollectionService.createStoreSlot(channelMap));
2682
+ }
2683
+
2684
+ // src/slot/createOIMSingleSlotStoreAggregate.ts
2685
+ function createOIMSingleSlotStoreAggregate(channelMap, options) {
2686
+ const singleSlotService = createOIMSingleSlotService(options);
2687
+ return singleSlotService.createStoreAggregate(singleSlotService.createStoreSlot(channelMap));
2688
+ }
2689
+
2690
+ // src/db/constants/OIM_DEFAULT_ENTITY_SLOT_EMPTINESS_POLICY.ts
2691
+ var OIM_DEFAULT_ENTITY_SLOT_EMPTINESS_POLICY = /* @__PURE__ */ new OIMDefaultValue(() => OIMSlotEntityPresenceEmptinessPolicy.INSTANCE);
2504
2692
 
2505
- // src/engine/entity/utils/oimClearEntity.ts
2693
+ // src/entity/utils/oimClearEntity.ts
2506
2694
  function oimClearEntity(entitySlot) {
2507
2695
  entitySlot.entity = void 0;
2508
2696
  }
2509
2697
 
2510
- // src/engine/entity/constants/OIM_FROZEN_EMPTY_COLUMN_NAMES.ts
2698
+ // src/entity/constants/OIM_FROZEN_EMPTY_COLUMN_NAMES.ts
2511
2699
  var OIM_FROZEN_EMPTY_COLUMN_NAMES = Object.freeze([]);
2512
2700
 
2513
- // src/engine/entity/constants/OIM_PROTO_KEY.ts
2701
+ // src/entity/constants/OIM_PROTO_KEY.ts
2514
2702
  var OIM_PROTO_KEY = "__proto__";
2515
2703
 
2516
- // src/engine/entity/utils/oimIsProtoKey.ts
2704
+ // src/entity/utils/oimIsProtoKey.ts
2517
2705
  function oimIsProtoKey(name) {
2518
2706
  return name === OIM_PROTO_KEY;
2519
2707
  }
2520
2708
 
2521
- // src/engine/entity/utils/oimOwnedColumnNames.ts
2709
+ // src/entity/utils/oimOwnedColumnNames.ts
2522
2710
  function oimOwnedColumnNames(slot, names) {
2523
2711
  const entity = slot.entity;
2524
2712
  if (entity === void 0) return void 0;
@@ -2532,12 +2720,12 @@ function oimOwnedColumnNames(slot, names) {
2532
2720
  return owned;
2533
2721
  }
2534
2722
 
2535
- // src/engine/entity/utils/oimInsertEntityWithoutCopy.ts
2723
+ // src/entity/utils/oimInsertEntityWithoutCopy.ts
2536
2724
  function oimInsertEntityWithoutCopy(slot, entity) {
2537
2725
  slot.entity = entity;
2538
2726
  }
2539
2727
 
2540
- // src/engine/entity/utils/oimPatchEntityColumns.ts
2728
+ // src/entity/utils/oimPatchEntityColumns.ts
2541
2729
  function oimPatchEntityColumns(slot, patch, sameValueGuard, changedColumnNames, targetOf) {
2542
2730
  const entity = slot.entity;
2543
2731
  if (entity === void 0) return void 0;
@@ -2551,7 +2739,7 @@ function oimPatchEntityColumns(slot, patch, sameValueGuard, changedColumnNames,
2551
2739
  return target;
2552
2740
  }
2553
2741
 
2554
- // src/engine/entity/utils/oimPatchEntityColumn.ts
2742
+ // src/entity/utils/oimPatchEntityColumn.ts
2555
2743
  function oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, targetOf) {
2556
2744
  const entity = slot.entity;
2557
2745
  if (entity === void 0) return void 0;
@@ -2562,7 +2750,7 @@ function oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedCo
2562
2750
  return target;
2563
2751
  }
2564
2752
 
2565
- // src/engine/entity/utils/oimClearDepartedEntityColumns.ts
2753
+ // src/entity/utils/oimClearDepartedEntityColumns.ts
2566
2754
  function oimClearDepartedEntityColumns(prevColumns, prevEntity, entity, patchedTarget, changedColumnNames, targetOf) {
2567
2755
  let target = patchedTarget;
2568
2756
  for (const name in prevColumns) {
@@ -2574,7 +2762,7 @@ function oimClearDepartedEntityColumns(prevColumns, prevEntity, entity, patchedT
2574
2762
  return target;
2575
2763
  }
2576
2764
 
2577
- // src/engine/entity/utils/oimPutEntityColumns.ts
2765
+ // src/entity/utils/oimPutEntityColumns.ts
2578
2766
  function oimPutEntityColumns(slot, entity, sameValueGuard, changedColumnNames, targetOf) {
2579
2767
  const prevEntity = slot.entity;
2580
2768
  if (prevEntity === void 0) return void 0;
@@ -2582,8 +2770,8 @@ function oimPutEntityColumns(slot, entity, sameValueGuard, changedColumnNames, t
2582
2770
  return oimClearDepartedEntityColumns(prevEntity, prevEntity, entity, target, changedColumnNames, targetOf);
2583
2771
  }
2584
2772
 
2585
- // src/factories/utils/oimEntityWriterOptionsWithDefault.ts
2586
- function oimEntityWriterOptionsWithDefault(options) {
2773
+ // src/entity/utils/oimResolveEntityWriterOptions.ts
2774
+ function oimResolveEntityWriterOptions(options) {
2587
2775
  return {
2588
2776
  sameValueGuard: options?.sameValueGuard ?? oimSameValueZeroGuard,
2589
2777
  entityInserter: options?.entityInserter ?? oimInsertEntityWithoutCopy,
@@ -2593,7 +2781,7 @@ function oimEntityWriterOptionsWithDefault(options) {
2593
2781
  };
2594
2782
  }
2595
2783
 
2596
- // src/factories/createOIMEntityWriterInPlace.ts
2784
+ // src/entity/createOIMInPlaceEntityWriter.ts
2597
2785
  var theEntityItself = (entity) => entity;
2598
2786
  function deleteColumnsInPlace(slot, names) {
2599
2787
  const deleted = oimOwnedColumnNames(slot, names);
@@ -2602,14 +2790,14 @@ function deleteColumnsInPlace(slot, names) {
2602
2790
  for (let i = 0; i < deleted.length; i++) entity[deleted[i]] = void 0;
2603
2791
  return deleted;
2604
2792
  }
2605
- function createOIMEntityWriterInPlace(options) {
2793
+ function createOIMInPlaceEntityWriter(options) {
2606
2794
  const {
2607
2795
  sameValueGuard,
2608
2796
  entityInserter,
2609
2797
  putEntityColumns,
2610
2798
  patchEntityColumns,
2611
2799
  patchEntityColumn
2612
- } = oimEntityWriterOptionsWithDefault(options);
2800
+ } = oimResolveEntityWriterOptions(options);
2613
2801
  return {
2614
2802
  fillEntity: entityInserter,
2615
2803
  clearEntity: oimClearEntity,
@@ -2620,19 +2808,20 @@ function createOIMEntityWriterInPlace(options) {
2620
2808
  };
2621
2809
  }
2622
2810
 
2623
- // src/factories/defaults/OIM_DEFAULT_ENTITY_WRITER.ts
2624
- var OIM_DEFAULT_ENTITY_WRITER = /* @__PURE__ */ new OIMDefaultValue("ENTITY_WRITER", () => createOIMEntityWriterInPlace());
2811
+ // src/db/constants/OIM_DEFAULT_ENTITY_WRITER.ts
2812
+ var OIM_DEFAULT_ENTITY_WRITER = /* @__PURE__ */ new OIMDefaultValue(() => createOIMInPlaceEntityWriter());
2625
2813
 
2626
- // src/factories/createOIMSlotContentEntityService.ts
2627
- function createOIMSlotContentEntityService(db, options = {}) {
2814
+ // src/entity/createOIMSlotContentEntityService.ts
2815
+ function createOIMSlotContentEntityService(options = {}) {
2816
+ const defaults = options.defaults ?? OIMDefaults.INSTANCE;
2628
2817
  return new OIMSlotContentEntityService({
2629
- entityWriter: options.entityWriter ?? db.entityWriter ?? OIM_DEFAULT_ENTITY_WRITER.getValue(),
2630
- slotEmptinessPolicy: options.slotEmptinessPolicy ?? OIM_DEFAULT_ENTITY_SLOT_EMPTINESS.getValue()
2818
+ entityWriter: options.entityWriter ?? defaults.entityWriter ?? OIM_DEFAULT_ENTITY_WRITER.getValue(),
2819
+ slotEmptinessPolicy: options.slotEmptinessPolicy ?? defaults.entitySlotEmptinessPolicy ?? OIM_DEFAULT_ENTITY_SLOT_EMPTINESS_POLICY.getValue()
2631
2820
  });
2632
2821
  }
2633
2822
 
2634
- // src/engine/bucket/utils/createOIMSingleBucketSlot.ts
2635
- function createOIMSingleBucketSlot(owner, bucketSlotsStore, storeSlot) {
2823
+ // src/bucket/utils/createOIMBucketContentSlot.ts
2824
+ function createOIMBucketContentSlot(owner, bucketSlotsStore, storeSlot) {
2636
2825
  const singleBucketSlot = {
2637
2826
  effects: void 0,
2638
2827
  changedAtRevision: 0,
@@ -2657,7 +2846,7 @@ function createOIMSingleBucketSlot(owner, bucketSlotsStore, storeSlot) {
2657
2846
  return singleBucketSlot;
2658
2847
  }
2659
2848
 
2660
- // src/engine/bucket/commands/OIMNoBucketCommands.ts
2849
+ // src/bucket/commands/OIMNoBucketCommands.ts
2661
2850
  var _OIMNoBucketCommands = class _OIMNoBucketCommands {
2662
2851
  recordInsert() {
2663
2852
  return;
@@ -2675,13 +2864,13 @@ var _OIMNoBucketCommands = class _OIMNoBucketCommands {
2675
2864
  _OIMNoBucketCommands.INSTANCE = new _OIMNoBucketCommands();
2676
2865
  var OIMNoBucketCommands = _OIMNoBucketCommands;
2677
2866
 
2678
- // src/engine/bucket/constants/OIM_NOTHING_WAS_REMOVED.ts
2867
+ // src/bucket/constants/OIM_NOTHING_WAS_REMOVED.ts
2679
2868
  var OIM_NOTHING_WAS_REMOVED = -1;
2680
2869
 
2681
- // src/engine/bucket/constants/OIM_REMOVED_WITHOUT_A_POSITION.ts
2870
+ // src/bucket/constants/OIM_REMOVED_WITHOUT_A_POSITION.ts
2682
2871
  var OIM_REMOVED_WITHOUT_A_POSITION = -2;
2683
2872
 
2684
- // src/engine/bucket/utils/createOIMBucketSlot.ts
2873
+ // src/bucket/utils/createOIMBucketSlot.ts
2685
2874
  function createOIMBucketSlot(key, owner, bucketSlotsStore, storeSlot) {
2686
2875
  return {
2687
2876
  effects: void 0,
@@ -2706,16 +2895,16 @@ function createOIMBucketSlot(key, owner, bucketSlotsStore, storeSlot) {
2706
2895
  };
2707
2896
  }
2708
2897
 
2709
- // src/engine/channel/utils/oimGetChannelQueueAtDepth.ts
2898
+ // src/channel/utils/oimGetChannelQueueAtDepth.ts
2710
2899
  function oimGetChannelQueueAtDepth(channelQueues, depth) {
2711
- const found = channelQueues[depth];
2712
- if (found !== void 0) return found;
2713
- const made = new OIMChannelQueue();
2714
- channelQueues[depth] = made;
2715
- return made;
2900
+ const existingChannelQueue = channelQueues[depth];
2901
+ if (existingChannelQueue !== void 0) return existingChannelQueue;
2902
+ const channelQueue = new OIMChannelQueue();
2903
+ channelQueues[depth] = channelQueue;
2904
+ return channelQueue;
2716
2905
  }
2717
2906
 
2718
- // src/facade/bucket/OIMSlotContentBucketService.ts
2907
+ // src/bucket/OIMSlotContentBucketService.ts
2719
2908
  var OIMSlotContentBucketService = class {
2720
2909
  constructor(options) {
2721
2910
  this.bucketCommands = options.bucketCommands ?? OIMNoBucketCommands.INSTANCE;
@@ -2737,7 +2926,7 @@ var OIMSlotContentBucketService = class {
2737
2926
  );
2738
2927
  }
2739
2928
  createSingleSlot(storeSlot, slotOwner) {
2740
- return createOIMSingleBucketSlot(
2929
+ return createOIMBucketContentSlot(
2741
2930
  slotOwner,
2742
2931
  this.createBucketMemberSlotsStore(),
2743
2932
  storeSlot
@@ -2749,11 +2938,9 @@ var OIMSlotContentBucketService = class {
2749
2938
  hasReference() {
2750
2939
  return false;
2751
2940
  }
2752
- releaseSlotContent(bucketSlot, slotOwnerService) {
2753
- if (this.getBucketMemberSlotCount(bucketSlot) === 0) return;
2754
- slotOwnerService.assertWritable(bucketSlot);
2941
+ releaseSlotContent(bucketSlot) {
2942
+ oimAssertSlotUnheld(bucketSlot);
2755
2943
  this.unholdAllBucketMemberSlots(bucketSlot);
2756
- slotOwnerService.dispatchContentChange(bucketSlot);
2757
2944
  }
2758
2945
  markContentChanged(bucketSlot) {
2759
2946
  bucketSlot.owner.assertWritable(bucketSlot);
@@ -2792,10 +2979,10 @@ var OIMSlotContentBucketService = class {
2792
2979
  removeBucketMemberSlots(bucketSlot, bucketMemberSlots) {
2793
2980
  const slotOwnerService = bucketSlot.owner;
2794
2981
  slotOwnerService.assertWritable(bucketSlot);
2795
- const storeSlotEditable = bucketSlot.storeSlot;
2796
- const writeDepth = storeSlotEditable.writeDepth++;
2797
- const removedChannelQueue = oimGetChannelQueueAtDepth(storeSlotEditable.departedBucketMemberSlotChannelQueues ?? (storeSlotEditable.departedBucketMemberSlotChannelQueues = []), writeDepth);
2798
- const removedAtChannelQueue = oimGetChannelQueueAtDepth(storeSlotEditable.removedAtChannelQueues ?? (storeSlotEditable.removedAtChannelQueues = []), writeDepth);
2982
+ const editableStoreSlot = bucketSlot.storeSlot;
2983
+ const writeDepth = editableStoreSlot.writeDepth++;
2984
+ const removedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.departedBucketMemberSlotChannelQueues ?? (editableStoreSlot.departedBucketMemberSlotChannelQueues = []), writeDepth);
2985
+ const removedAtChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.removedAtChannelQueues ?? (editableStoreSlot.removedAtChannelQueues = []), writeDepth);
2799
2986
  try {
2800
2987
  this.removeSlots(bucketSlot, bucketMemberSlots, removedChannelQueue, removedAtChannelQueue);
2801
2988
  const removedCount = removedChannelQueue.getEntryCount();
@@ -2806,7 +2993,7 @@ var OIMSlotContentBucketService = class {
2806
2993
  } finally {
2807
2994
  removedChannelQueue.keepFirstEntries(0);
2808
2995
  removedAtChannelQueue.keepFirstEntries(0);
2809
- storeSlotEditable.writeDepth = writeDepth;
2996
+ editableStoreSlot.writeDepth = writeDepth;
2810
2997
  }
2811
2998
  }
2812
2999
  insertSlotContent(bucketSlot, bucketMemberSlots, changedBucketSlots) {
@@ -2879,10 +3066,10 @@ var OIMSlotContentBucketService = class {
2879
3066
  }
2880
3067
  reconcileBucketMemberSlots(bucketSlot, bucketMemberSlots) {
2881
3068
  this.assertBucketMemberSlotsNotReleased(bucketMemberSlots);
2882
- const storeSlotEditable = bucketSlot.storeSlot;
2883
- const writeDepth = storeSlotEditable.writeDepth++;
2884
- const arrivedChannelQueue = oimGetChannelQueueAtDepth(storeSlotEditable.arrivedBucketMemberSlotChannelQueues ?? (storeSlotEditable.arrivedBucketMemberSlotChannelQueues = []), writeDepth);
2885
- const departedChannelQueue = oimGetChannelQueueAtDepth(storeSlotEditable.departedBucketMemberSlotChannelQueues ?? (storeSlotEditable.departedBucketMemberSlotChannelQueues = []), writeDepth);
3069
+ const editableStoreSlot = bucketSlot.storeSlot;
3070
+ const writeDepth = editableStoreSlot.writeDepth++;
3071
+ const arrivedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.arrivedBucketMemberSlotChannelQueues ?? (editableStoreSlot.arrivedBucketMemberSlotChannelQueues = []), writeDepth);
3072
+ const departedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.departedBucketMemberSlotChannelQueues ?? (editableStoreSlot.departedBucketMemberSlotChannelQueues = []), writeDepth);
2886
3073
  try {
2887
3074
  this.reconcileSlots(bucketSlot, bucketMemberSlots, arrivedChannelQueue, departedChannelQueue);
2888
3075
  const arrivedCount = arrivedChannelQueue.getEntryCount();
@@ -2898,7 +3085,7 @@ var OIMSlotContentBucketService = class {
2898
3085
  } finally {
2899
3086
  arrivedChannelQueue.keepFirstEntries(0);
2900
3087
  departedChannelQueue.keepFirstEntries(0);
2901
- storeSlotEditable.writeDepth = writeDepth;
3088
+ editableStoreSlot.writeDepth = writeDepth;
2902
3089
  }
2903
3090
  }
2904
3091
  drainBucketMemberSlots(bucketSlot) {
@@ -2908,9 +3095,9 @@ var OIMSlotContentBucketService = class {
2908
3095
  return true;
2909
3096
  }
2910
3097
  unholdAllBucketMemberSlots(bucketSlot) {
2911
- const storeSlotEditable = bucketSlot.storeSlot;
2912
- const writeDepth = storeSlotEditable.writeDepth++;
2913
- const departedChannelQueue = oimGetChannelQueueAtDepth(storeSlotEditable.departedBucketMemberSlotChannelQueues ?? (storeSlotEditable.departedBucketMemberSlotChannelQueues = []), writeDepth);
3098
+ const editableStoreSlot = bucketSlot.storeSlot;
3099
+ const writeDepth = editableStoreSlot.writeDepth++;
3100
+ const departedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.departedBucketMemberSlotChannelQueues ?? (editableStoreSlot.departedBucketMemberSlotChannelQueues = []), writeDepth);
2914
3101
  try {
2915
3102
  this.drainSlots(bucketSlot, departedChannelQueue);
2916
3103
  const drainedCount = departedChannelQueue.getEntryCount();
@@ -2918,12 +3105,12 @@ var OIMSlotContentBucketService = class {
2918
3105
  return drainedCount;
2919
3106
  } finally {
2920
3107
  departedChannelQueue.keepFirstEntries(0);
2921
- storeSlotEditable.writeDepth = writeDepth;
3108
+ editableStoreSlot.writeDepth = writeDepth;
2922
3109
  }
2923
3110
  }
2924
3111
  };
2925
3112
 
2926
- // src/facade/bucket/OIMSlotContentSetBucketService.ts
3113
+ // src/bucket/OIMSlotContentSetBucketService.ts
2927
3114
  var OIMSlotContentSetBucketService = class extends OIMSlotContentBucketService {
2928
3115
  constructor(options = {}) {
2929
3116
  super(options);
@@ -2978,7 +3165,7 @@ var OIMSlotContentSetBucketService = class extends OIMSlotContentBucketService {
2978
3165
  }
2979
3166
  };
2980
3167
 
2981
- // src/engine/bucket/array/OIMBucketMemberSlotsArrayService.ts
3168
+ // src/bucket/array/OIMBucketMemberSlotsArrayService.ts
2982
3169
  var insertionTailLimit = 8;
2983
3170
  var _OIMBucketMemberSlotsArrayService = class _OIMBucketMemberSlotsArrayService {
2984
3171
  createBucketSlotsArrayStore() {
@@ -3107,7 +3294,7 @@ function reverseRange(bucketMemberSlots, first, last) {
3107
3294
  }
3108
3295
  }
3109
3296
 
3110
- // src/facade/bucket/OIMSlotContentArrayBucketService.ts
3297
+ // src/bucket/OIMSlotContentArrayBucketService.ts
3111
3298
  var OIMSlotContentArrayBucketService = class extends OIMSlotContentBucketService {
3112
3299
  constructor(options) {
3113
3300
  super(options);
@@ -3168,10 +3355,10 @@ var OIMSlotContentArrayBucketService = class extends OIMSlotContentBucketService
3168
3355
  }
3169
3356
  };
3170
3357
 
3171
- // src/engine/bucket/constants/OIM_NOTHING_WAS_INSERTED.ts
3358
+ // src/bucket/constants/OIM_NOTHING_WAS_INSERTED.ts
3172
3359
  var OIM_NOTHING_WAS_INSERTED = -1;
3173
3360
 
3174
- // src/engine/bucket/array/utils/oimAssertWholePosition.ts
3361
+ // src/bucket/array/utils/oimAssertWholePosition.ts
3175
3362
  function oimAssertWholePosition(position) {
3176
3363
  if (position === Math.trunc(position)) return;
3177
3364
  throw new Error(
@@ -3179,7 +3366,7 @@ function oimAssertWholePosition(position) {
3179
3366
  );
3180
3367
  }
3181
3368
 
3182
- // src/facade/bucket/OIMSlotContentPositionalArrayBucketService.ts
3369
+ // src/bucket/OIMSlotContentPositionalArrayBucketService.ts
3183
3370
  var OIMSlotContentPositionalArrayBucketService = class extends OIMSlotContentArrayBucketService {
3184
3371
  constructor(options = {}) {
3185
3372
  super(options);
@@ -3252,7 +3439,7 @@ var OIMSlotContentPositionalArrayBucketService = class extends OIMSlotContentArr
3252
3439
  }
3253
3440
  };
3254
3441
 
3255
- // src/engine/bucket/utils/oimSameUniqueSlotSequence.ts
3442
+ // src/bucket/utils/oimSameUniqueSlotSequence.ts
3256
3443
  function oimSameUniqueSlotSequence(heldBucketMemberSlots, bucketMemberSlots) {
3257
3444
  const seenBucketMemberSlots = /* @__PURE__ */ new Set();
3258
3445
  let at = 0;
@@ -3266,7 +3453,7 @@ function oimSameUniqueSlotSequence(heldBucketMemberSlots, bucketMemberSlots) {
3266
3453
  return at === heldBucketMemberSlots.length;
3267
3454
  }
3268
3455
 
3269
- // src/engine/bucket/array/OIMBucketUniqueMemberSlotsArrayService.ts
3456
+ // src/bucket/array/OIMBucketUniqueMemberSlotsArrayService.ts
3270
3457
  var _OIMBucketUniqueMemberSlotsArrayService = class _OIMBucketUniqueMemberSlotsArrayService extends OIMBucketMemberSlotsArrayService {
3271
3458
  createBucketSlotsArrayStore() {
3272
3459
  return { bucketMemberSlots: [], uniqueBucketMemberSlots: /* @__PURE__ */ new Set(), sortedCount: 0 };
@@ -3325,7 +3512,7 @@ function uniqueBucketMemberSlotsOf(bucketSlotsArrayStore) {
3325
3512
  return bucketSlotsArrayStore.uniqueBucketMemberSlots;
3326
3513
  }
3327
3514
 
3328
- // src/facade/bucket/OIMSlotContentSortedArrayBucketService.ts
3515
+ // src/bucket/OIMSlotContentSortedArrayBucketService.ts
3329
3516
  var OIMSlotContentSortedArrayBucketService = class extends OIMSlotContentArrayBucketService {
3330
3517
  constructor(options) {
3331
3518
  super(options);
@@ -3355,169 +3542,7 @@ var OIMSlotContentSortedArrayBucketService = class extends OIMSlotContentArrayBu
3355
3542
  }
3356
3543
  };
3357
3544
 
3358
- // src/factories/defaults/OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.ts
3359
- var OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue("COMPUTED_COLUMN_SLOT_STORE_SERVICE", () => OIMSlotMapStoreService.INSTANCE);
3360
-
3361
- // src/engine/index/OIMIndexKeysService.ts
3362
- var OIMIndexKeysService = class {
3363
- createPositions() {
3364
- return { nextPosition: 0, freePositions: [] };
3365
- }
3366
- get(slot, position) {
3367
- const indexKeys = slot.indexKeys;
3368
- return indexKeys === void 0 || position >= indexKeys.length ? void 0 : indexKeys[position];
3369
- }
3370
- set(slot, position, indexKey) {
3371
- const indexKeys = slot.indexKeys;
3372
- if (indexKeys !== void 0) {
3373
- if (position < indexKeys.length) {
3374
- indexKeys[position] = indexKey;
3375
- return;
3376
- }
3377
- if (indexKey === void 0) return;
3378
- while (indexKeys.length < position) indexKeys.push(void 0);
3379
- indexKeys.push(indexKey);
3380
- return;
3381
- }
3382
- if (indexKey === void 0) return;
3383
- const created = [];
3384
- while (created.length < position) created.push(void 0);
3385
- created.push(indexKey);
3386
- slot.indexKeys = created;
3387
- }
3388
- };
3389
-
3390
- // src/engine/index/OIMAppendingIndexKeysService.ts
3391
- var _OIMAppendingIndexKeysService = class _OIMAppendingIndexKeysService extends OIMIndexKeysService {
3392
- allocatePosition(positions) {
3393
- return positions.nextPosition++;
3394
- }
3395
- releasePosition() {
3396
- return;
3397
- }
3398
- };
3399
- _OIMAppendingIndexKeysService.INSTANCE = new _OIMAppendingIndexKeysService();
3400
- var OIMAppendingIndexKeysService = _OIMAppendingIndexKeysService;
3401
-
3402
- // src/factories/defaults/OIM_DEFAULT_INDEX_KEYS_SERVICE.ts
3403
- var OIM_DEFAULT_INDEX_KEYS_SERVICE = /* @__PURE__ */ new OIMDefaultValue("INDEX_KEYS_SERVICE", () => OIMAppendingIndexKeysService.INSTANCE);
3404
-
3405
- // src/engine/key/OIMKeyTreeWalk.ts
3406
- var OIMKeyTreeWalk = class {
3407
- mintNodeAt(rootCompositeKeyNode, compositeKey) {
3408
- if (compositeKey.length === 0) throw new Error("OIMKeyTreeWalk: an empty key is not a key.");
3409
- let compositeKeyNode = rootCompositeKeyNode;
3410
- let firstMintedDepth = -1;
3411
- let parentOfFirstMintedCompositeKeyNode = rootCompositeKeyNode;
3412
- for (let i = 0; i < compositeKey.length; i++) {
3413
- const compositeKeyPart = compositeKey[i];
3414
- let nextCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKeyPart);
3415
- if (nextCompositeKeyNode === void 0) {
3416
- try {
3417
- this.holdCompositeKeyPart(compositeKeyPart);
3418
- } catch (failure) {
3419
- if (firstMintedDepth >= 0) {
3420
- parentOfFirstMintedCompositeKeyNode.childNodes?.delete(compositeKey[firstMintedDepth]);
3421
- for (let j = i - 1; j >= firstMintedDepth; j--) this.unholdCompositeKeyPart(compositeKey[j]);
3422
- }
3423
- throw failure;
3424
- }
3425
- nextCompositeKeyNode = { childNodes: void 0, atThisKey: void 0 };
3426
- (compositeKeyNode.childNodes ?? (compositeKeyNode.childNodes = /* @__PURE__ */ new Map())).set(compositeKeyPart, nextCompositeKeyNode);
3427
- if (firstMintedDepth < 0) {
3428
- firstMintedDepth = i;
3429
- parentOfFirstMintedCompositeKeyNode = compositeKeyNode;
3430
- }
3431
- }
3432
- compositeKeyNode = nextCompositeKeyNode;
3433
- }
3434
- return compositeKeyNode;
3435
- }
3436
- nodeAt(rootCompositeKeyNode, compositeKey) {
3437
- let compositeKeyNode = rootCompositeKeyNode;
3438
- for (let i = 0; i < compositeKey.length; i++) {
3439
- compositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[i]);
3440
- if (compositeKeyNode === void 0) return void 0;
3441
- }
3442
- return compositeKeyNode;
3443
- }
3444
- deleteKey(rootCompositeKeyNode, compositeKey) {
3445
- const lastDepth = compositeKey.length - 1;
3446
- if (lastDepth < 0) return void 0;
3447
- let compositeKeyNode = rootCompositeKeyNode;
3448
- let keptCompositeKeyNode = rootCompositeKeyNode;
3449
- let firstUnlinkedDepth = 0;
3450
- for (let i = 0; i < lastDepth; i++) {
3451
- const nextCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[i]);
3452
- if (nextCompositeKeyNode === void 0) return void 0;
3453
- compositeKeyNode = nextCompositeKeyNode;
3454
- if (compositeKeyNode.atThisKey !== void 0 || (compositeKeyNode.childNodes?.size ?? 0) > 1) {
3455
- keptCompositeKeyNode = compositeKeyNode;
3456
- firstUnlinkedDepth = i + 1;
3457
- }
3458
- }
3459
- const lastCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[lastDepth]);
3460
- if (lastCompositeKeyNode === void 0) return void 0;
3461
- const deletedAtKey = lastCompositeKeyNode.atThisKey;
3462
- if (deletedAtKey === void 0) return void 0;
3463
- lastCompositeKeyNode.atThisKey = void 0;
3464
- if ((lastCompositeKeyNode.childNodes?.size ?? 0) > 0) return deletedAtKey;
3465
- keptCompositeKeyNode.childNodes?.delete(compositeKey[firstUnlinkedDepth]);
3466
- for (let i = lastDepth; i >= firstUnlinkedDepth; i--) this.unholdCompositeKeyPart(compositeKey[i]);
3467
- return deletedAtKey;
3468
- }
3469
- };
3470
-
3471
- // src/engine/key/OIMCompositeKeyTreeWalk.ts
3472
- var _OIMCompositeKeyTreeWalk = class _OIMCompositeKeyTreeWalk extends OIMKeyTreeWalk {
3473
- holdCompositeKeyPart(entitySlot) {
3474
- entitySlot.owner.holdSlot(entitySlot);
3475
- }
3476
- unholdCompositeKeyPart(entitySlot) {
3477
- oimUnholdSlotIfAlive(entitySlot);
3478
- }
3479
- };
3480
- _OIMCompositeKeyTreeWalk.INSTANCE = new _OIMCompositeKeyTreeWalk();
3481
- var OIMCompositeKeyTreeWalk = _OIMCompositeKeyTreeWalk;
3482
-
3483
- // src/factories/defaults/OIM_DEFAULT_KEY_TREE_WALK_COMPOSITE.ts
3484
- var OIM_DEFAULT_KEY_TREE_WALK_COMPOSITE = /* @__PURE__ */ new OIMDefaultValue("KEY_TREE_WALK_COMPOSITE", () => OIMCompositeKeyTreeWalk.INSTANCE);
3485
-
3486
- // src/engine/key/OIMScalarKeyTreeWalk.ts
3487
- var _OIMScalarKeyTreeWalk = class _OIMScalarKeyTreeWalk extends OIMKeyTreeWalk {
3488
- holdCompositeKeyPart() {
3489
- return;
3490
- }
3491
- unholdCompositeKeyPart() {
3492
- return;
3493
- }
3494
- };
3495
- _OIMScalarKeyTreeWalk.INSTANCE = new _OIMScalarKeyTreeWalk();
3496
- var OIMScalarKeyTreeWalk = _OIMScalarKeyTreeWalk;
3497
-
3498
- // src/factories/defaults/OIM_DEFAULT_KEY_TREE_WALK_SCALAR.ts
3499
- var OIM_DEFAULT_KEY_TREE_WALK_SCALAR = /* @__PURE__ */ new OIMDefaultValue("KEY_TREE_WALK_SCALAR", () => OIMScalarKeyTreeWalk.INSTANCE);
3500
-
3501
- // src/factories/defaults/OIM_DEFAULT_STANDALONE_SLOT_OWNER.ts
3502
- var OIM_DEFAULT_STANDALONE_SLOT_OWNER = /* @__PURE__ */ new OIMDefaultValue("STANDALONE_SLOT_OWNER", () => new OIMSlotOwner());
3503
-
3504
- // src/factories/OIMDefaults.ts
3505
- var OIMDefaults = class {
3506
- };
3507
- OIMDefaults.COLUMN_SLOT_STORE_SERVICE = OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE;
3508
- OIMDefaults.COMPUTED_COLUMN_SLOT_STORE_SERVICE = OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE;
3509
- OIMDefaults.KEY_TREE_WALK_SCALAR = OIM_DEFAULT_KEY_TREE_WALK_SCALAR;
3510
- OIMDefaults.KEY_TREE_WALK_COMPOSITE = OIM_DEFAULT_KEY_TREE_WALK_COMPOSITE;
3511
- OIMDefaults.STANDALONE_SLOT_OWNER = OIM_DEFAULT_STANDALONE_SLOT_OWNER;
3512
- OIMDefaults.ENTITY_WRITER = OIM_DEFAULT_ENTITY_WRITER;
3513
- OIMDefaults.ENTITY_SLOT_EMPTINESS = OIM_DEFAULT_ENTITY_SLOT_EMPTINESS;
3514
- OIMDefaults.INDEX_KEYS_SERVICE = OIM_DEFAULT_INDEX_KEYS_SERVICE;
3515
- OIMDefaults.STORE_SLOT_LISTENER = OIM_DEFAULT_STORE_SLOT_LISTENER;
3516
-
3517
- // src/engine/column/utils/createOIMPullColumnSlotOwner.ts
3518
- var createOIMPullColumnSlotOwner = (columnSlotOwnerOptions) => new OIMPullColumnSlotOwner(columnSlotOwnerOptions);
3519
-
3520
- // src/engine/computed/OIMComputedSourcesService.ts
3545
+ // src/computed/OIMComputedSourcesService.ts
3521
3546
  var _OIMComputedSourcesService = class _OIMComputedSourcesService {
3522
3547
  holdSources(derivation) {
3523
3548
  oimHoldSlots(derivation.sourceSlots);
@@ -3533,8 +3558,8 @@ var _OIMComputedSourcesService = class _OIMComputedSourcesService {
3533
3558
  _OIMComputedSourcesService.INSTANCE = new _OIMComputedSourcesService();
3534
3559
  var OIMComputedSourcesService = _OIMComputedSourcesService;
3535
3560
 
3536
- // src/engine/computed/utils/createOIMSingleComputedSlot.ts
3537
- function createOIMSingleComputedSlot(owner, computedValueService, initialValue, storeSlot) {
3561
+ // src/computed/utils/createOIMComputedContentSlot.ts
3562
+ function createOIMComputedContentSlot(owner, computedValueService, initialValue, storeSlot, sourceTracker) {
3538
3563
  const singleComputedSlot = {
3539
3564
  effects: void 0,
3540
3565
  changedAtRevision: 0,
@@ -3559,12 +3584,13 @@ function createOIMSingleComputedSlot(owner, computedValueService, initialValue,
3559
3584
  checkedAtRevision: -1,
3560
3585
  checkedAtEpoch: -1,
3561
3586
  isDeriving: false,
3562
- allRootSlots: void 0
3587
+ allRootSlots: void 0,
3588
+ sourceTracker
3563
3589
  };
3564
3590
  return singleComputedSlot;
3565
3591
  }
3566
3592
 
3567
- // src/engine/computed/OIMSlotContentComputedService.ts
3593
+ // src/computed/OIMSlotContentComputedService.ts
3568
3594
  var OIMSlotContentComputedService = class {
3569
3595
  constructor(options) {
3570
3596
  this.computedValueService = options.computedValueService;
@@ -3577,13 +3603,20 @@ var OIMSlotContentComputedService = class {
3577
3603
  slotOwner,
3578
3604
  this.computedValueService,
3579
3605
  this.initialValue,
3580
- storeSlot
3606
+ storeSlot,
3607
+ this.createSourceTracker()
3581
3608
  );
3582
3609
  this.attachSources(computedSlot, storeSlot);
3583
3610
  return computedSlot;
3584
3611
  }
3585
3612
  createSingleSlot(storeSlot, slotOwner) {
3586
- const computedSlot = createOIMSingleComputedSlot(slotOwner, this.computedValueService, this.initialValue, storeSlot);
3613
+ const computedSlot = createOIMComputedContentSlot(
3614
+ slotOwner,
3615
+ this.computedValueService,
3616
+ this.initialValue,
3617
+ storeSlot,
3618
+ this.createSourceTracker()
3619
+ );
3587
3620
  this.attachSources(computedSlot, storeSlot);
3588
3621
  return computedSlot;
3589
3622
  }
@@ -3591,56 +3624,67 @@ var OIMSlotContentComputedService = class {
3591
3624
  return false;
3592
3625
  }
3593
3626
  releaseSlotContent(computedSlot) {
3627
+ oimAssertSlotUnheld(computedSlot);
3594
3628
  OIMComputedSourcesService.INSTANCE.unholdSources(computedSlot);
3629
+ this.computedValueService.releaseSlotValue(computedSlot);
3595
3630
  }
3596
3631
  hasReference() {
3597
3632
  return false;
3598
3633
  }
3634
+ createSourceTracker() {
3635
+ return void 0;
3636
+ }
3599
3637
  attachSources(computedSlot, storeSlot) {
3600
3638
  const createSources = storeSlot.createSources ?? this.createSources;
3601
3639
  const computedSources = createSources(computedSlot);
3602
- const computedSlotEditable = computedSlot;
3603
- computedSlotEditable.sourceSlots = computedSources.sourceSlots ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
3604
- computedSlotEditable.sourceComputeds = computedSources.sourceComputeds ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
3640
+ const editableComputedSlot = computedSlot;
3641
+ editableComputedSlot.sourceSlots = computedSources.sourceSlots ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
3642
+ editableComputedSlot.sourceComputeds = computedSources.sourceComputeds ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
3605
3643
  OIMComputedSourcesService.INSTANCE.holdSources(computedSlot);
3606
3644
  }
3607
3645
  };
3608
3646
 
3609
- // src/facade/computed/utils/createOIMComputedCollectionService.ts
3610
- function createOIMComputedCollectionService(options) {
3647
+ // src/column/utils/createOIMPullColumnSlotOwner.ts
3648
+ var createOIMPullColumnSlotOwner = (columnSlotOwnerOptions) => new OIMPullColumnSlotOwner(columnSlotOwnerOptions);
3649
+
3650
+ // src/computed/utils/createOIMComputedSlotCollectionService.ts
3651
+ function createOIMComputedSlotCollectionService(options) {
3611
3652
  return new OIMSlotCollectionService({
3612
3653
  slotReleasePolicy: options.slotReleasePolicy,
3613
3654
  slotStoreService: options.computedSlotStoreService,
3614
- slotContentService: new OIMSlotContentComputedService(options),
3655
+ slotContentService: options.slotContentService,
3615
3656
  columnSlotOwnerOptions: options.columnSlotOwnerOptions,
3616
3657
  createColumnSlotOwner: createOIMPullColumnSlotOwner,
3617
3658
  storeSlotListener: options.storeSlotListener
3618
3659
  });
3619
3660
  }
3620
3661
 
3621
- // src/facade/computed/utils/oimAttachComputedDerivation.ts
3662
+ // src/computed/utils/oimAttachComputedDerivation.ts
3622
3663
  function oimAttachComputedDerivation(computedStoreSlot, hasServiceDerive, hasServiceCreateSources, derive, createSources) {
3623
3664
  if (derive === void 0 && !hasServiceDerive || createSources === void 0 && !hasServiceCreateSources) {
3624
3665
  throw new Error(
3625
3666
  "A computed store slot needs a derive and a createSources, from the store slot or from the service options. Pass the missing one when creating the store slot or to the service."
3626
3667
  );
3627
3668
  }
3628
- const computedStoreSlotEditable = computedStoreSlot;
3629
- computedStoreSlotEditable.derive = derive;
3630
- computedStoreSlotEditable.createSources = createSources;
3669
+ const editableComputedStoreSlot = computedStoreSlot;
3670
+ editableComputedStoreSlot.derive = derive;
3671
+ editableComputedStoreSlot.createSources = createSources;
3631
3672
  return computedStoreSlot;
3632
3673
  }
3633
3674
 
3634
- // src/facade/computed/OIMComputedService.ts
3675
+ // src/computed/OIMComputedService.ts
3635
3676
  var OIMComputedService = class {
3636
3677
  constructor(options) {
3637
- this.computedCollectionService = createOIMComputedCollectionService({
3638
- computedValueService: new OIMComputedValueService({
3639
- derive: options.derive,
3640
- sameValueGuard: options.sameValueGuard
3678
+ this.computedCollectionService = createOIMComputedSlotCollectionService({
3679
+ slotContentService: new OIMSlotContentComputedService({
3680
+ computedValueService: new OIMComputedValueService({
3681
+ derive: options.derive,
3682
+ sameValueGuard: options.sameValueGuard,
3683
+ releaseValue: options.releaseValue
3684
+ }),
3685
+ createSources: options.createSources,
3686
+ initialValue: options.initialValue
3641
3687
  }),
3642
- createSources: options.createSources,
3643
- initialValue: options.initialValue,
3644
3688
  slotReleasePolicy: options.slotReleasePolicy,
3645
3689
  computedSlotStoreService: options.computedSlotStoreService,
3646
3690
  columnSlotOwnerOptions: options.columnSlotOwnerOptions,
@@ -3660,7 +3704,7 @@ var OIMComputedService = class {
3660
3704
  }
3661
3705
  };
3662
3706
 
3663
- // src/engine/collector/OIMSlotAtUnholdReleasePolicy.ts
3707
+ // src/collector/OIMSlotAtUnholdReleasePolicy.ts
3664
3708
  var _OIMSlotAtUnholdReleasePolicy = class _OIMSlotAtUnholdReleasePolicy {
3665
3709
  constructor() {
3666
3710
  this.releasesWrittenSlots = true;
@@ -3688,25 +3732,37 @@ var _OIMSlotAtUnholdReleasePolicy = class _OIMSlotAtUnholdReleasePolicy {
3688
3732
  _OIMSlotAtUnholdReleasePolicy.INSTANCE = new _OIMSlotAtUnholdReleasePolicy();
3689
3733
  var OIMSlotAtUnholdReleasePolicy = _OIMSlotAtUnholdReleasePolicy;
3690
3734
 
3691
- // src/factories/createOIMComputedService.ts
3692
- function createOIMComputedService(options) {
3693
- return new OIMComputedService({
3694
- computedSlotStoreService: oimSlotStoreServiceWithDefault(options.computedSlotStoreService),
3695
- columnSlotOwnerOptions: oimColumnOwnerOptionsWithDefault(
3735
+ // src/db/constants/OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.ts
3736
+ var OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue(() => OIMSlotMapStoreService.INSTANCE);
3737
+
3738
+ // src/computed/utils/oimResolveComputedDerivationOptions.ts
3739
+ function oimResolveComputedDerivationOptions(options) {
3740
+ const defaults = options.defaults ?? OIMDefaults.INSTANCE;
3741
+ return {
3742
+ columnSlotOwnerOptions: oimResolveColumnSlotOwnerOptions(
3696
3743
  options.columnSlotStoreService,
3697
3744
  options.columnNames,
3698
- OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue()
3745
+ defaults.computedColumnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue()
3699
3746
  ),
3700
3747
  slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
3701
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
3702
- createSources: options.createSources,
3703
- derive: options.derive,
3748
+ storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
3704
3749
  sameValueGuard: options.sameValueGuard,
3750
+ releaseValue: options.releaseValue,
3705
3751
  initialValue: options.initialValue
3752
+ };
3753
+ }
3754
+
3755
+ // src/computed/createOIMComputedService.ts
3756
+ function createOIMComputedService(options) {
3757
+ return new OIMComputedService({
3758
+ computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
3759
+ ...oimResolveComputedDerivationOptions(options),
3760
+ createSources: options.createSources,
3761
+ derive: options.derive
3706
3762
  });
3707
3763
  }
3708
3764
 
3709
- // src/facade/computed/OIMSingleComputedService.ts
3765
+ // src/computed/OIMSingleComputedService.ts
3710
3766
  var OIMSingleComputedService = class {
3711
3767
  constructor(options) {
3712
3768
  this.computedSingleSlotService = new OIMSingleSlotService({
@@ -3715,7 +3771,8 @@ var OIMSingleComputedService = class {
3715
3771
  slotContentService: new OIMSlotContentComputedService({
3716
3772
  computedValueService: new OIMComputedValueService({
3717
3773
  derive: options.derive,
3718
- sameValueGuard: options.sameValueGuard
3774
+ sameValueGuard: options.sameValueGuard,
3775
+ releaseValue: options.releaseValue
3719
3776
  }),
3720
3777
  createSources: options.createSources,
3721
3778
  initialValue: options.initialValue
@@ -3738,30 +3795,133 @@ var OIMSingleComputedService = class {
3738
3795
  }
3739
3796
  };
3740
3797
 
3741
- // src/factories/createOIMSingleComputedService.ts
3798
+ // src/computed/createOIMSingleComputedService.ts
3742
3799
  function createOIMSingleComputedService(options = {}) {
3743
3800
  return new OIMSingleComputedService({
3744
- columnSlotOwnerOptions: oimColumnOwnerOptionsWithDefault(
3745
- options.columnSlotStoreService,
3746
- options.columnNames,
3747
- OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue()
3748
- ),
3749
- slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
3750
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
3801
+ ...oimResolveComputedDerivationOptions(options),
3751
3802
  createSources: options.createSources,
3752
- derive: options.derive,
3753
- sameValueGuard: options.sameValueGuard,
3754
- initialValue: options.initialValue
3803
+ derive: options.derive
3804
+ });
3805
+ }
3806
+
3807
+ // src/computed/OIMSourceTrackingComputedValueService.ts
3808
+ var OIMSourceTrackingComputedValueService = class extends OIMComputedValueService {
3809
+ constructor(options) {
3810
+ super({ sameValueGuard: options.sameValueGuard, releaseValue: options.releaseValue });
3811
+ this.deriveTrackingSources = (computedSlot) => {
3812
+ const sourceTracker = computedSlot.sourceTracker;
3813
+ sourceTracker.openSourceTracking();
3814
+ const value = this.sourceTrackingDerive(computedSlot, sourceTracker);
3815
+ if (sourceTracker.closeSourceTracking() && !oimIsSlotReleased(computedSlot)) this.replaceSources(computedSlot, sourceTracker);
3816
+ return value;
3817
+ };
3818
+ this.sourceTrackingDerive = options.derive;
3819
+ }
3820
+ getValueForSlot(computedSlot) {
3821
+ oimAssertSlotNotReleased(computedSlot);
3822
+ const sourceTracker = computedSlot.sourceTracker;
3823
+ oimRefreshComputedSlot(computedSlot, this.deriveTrackingSources, this.sameValueGuard, this.releaseValue, computedSlot.storeSlot.channelSlot.clock);
3824
+ if (sourceTracker.trackReplacedRootSlots()) {
3825
+ sourceTracker.commitTrackedSources();
3826
+ computedSlot.allRootSlots = void 0;
3827
+ }
3828
+ return computedSlot.value;
3829
+ }
3830
+ replaceSources(computedSlot, sourceTracker) {
3831
+ const trackedSourceSlots = sourceTracker.getTrackedSourceSlots().slice();
3832
+ const trackedSourceComputeds = sourceTracker.getTrackedSourceComputeds().slice();
3833
+ oimHoldSlots(trackedSourceSlots);
3834
+ oimHoldSlots(trackedSourceComputeds);
3835
+ OIMComputedSourcesService.INSTANCE.unholdSources(computedSlot);
3836
+ const editableComputedSlot = computedSlot;
3837
+ editableComputedSlot.sourceSlots = trackedSourceSlots;
3838
+ editableComputedSlot.sourceComputeds = trackedSourceComputeds;
3839
+ editableComputedSlot.allRootSlots = void 0;
3840
+ sourceTracker.commitTrackedSources();
3841
+ }
3842
+ };
3843
+
3844
+ // src/computed/OIMSlotContentSourceTrackingComputedService.ts
3845
+ var OIMSlotContentSourceTrackingComputedService = class extends OIMSlotContentComputedService {
3846
+ createSourceTracker() {
3847
+ return new OIMSourceTracker();
3848
+ }
3849
+ attachSources() {
3850
+ return;
3851
+ }
3852
+ };
3853
+
3854
+ // src/computed/OIMSourceTrackingComputedService.ts
3855
+ var OIMSourceTrackingComputedService = class {
3856
+ constructor(options) {
3857
+ this.computedCollectionService = createOIMComputedSlotCollectionService({
3858
+ slotContentService: new OIMSlotContentSourceTrackingComputedService({
3859
+ computedValueService: new OIMSourceTrackingComputedValueService({
3860
+ derive: options.derive,
3861
+ sameValueGuard: options.sameValueGuard,
3862
+ releaseValue: options.releaseValue
3863
+ }),
3864
+ initialValue: options.initialValue
3865
+ }),
3866
+ slotReleasePolicy: options.slotReleasePolicy,
3867
+ computedSlotStoreService: options.computedSlotStoreService,
3868
+ columnSlotOwnerOptions: options.columnSlotOwnerOptions,
3869
+ storeSlotListener: options.storeSlotListener
3870
+ });
3871
+ }
3872
+ createComputedStoreSlot(channelMap) {
3873
+ return this.computedCollectionService.createStoreSlot(channelMap);
3874
+ }
3875
+ };
3876
+
3877
+ // src/computed/OIMSingleSourceTrackingComputedService.ts
3878
+ var OIMSingleSourceTrackingComputedService = class {
3879
+ constructor(options) {
3880
+ this.computedSingleSlotService = new OIMSingleSlotService({
3881
+ slotReleasePolicy: options.slotReleasePolicy,
3882
+ slotStoreService: OIMSingleSlotStoreService.INSTANCE,
3883
+ slotContentService: new OIMSlotContentSourceTrackingComputedService({
3884
+ computedValueService: new OIMSourceTrackingComputedValueService({
3885
+ derive: options.derive,
3886
+ sameValueGuard: options.sameValueGuard,
3887
+ releaseValue: options.releaseValue
3888
+ }),
3889
+ initialValue: options.initialValue
3890
+ }),
3891
+ columnSlotOwnerOptions: options.columnSlotOwnerOptions,
3892
+ createColumnSlotOwner: createOIMPullColumnSlotOwner,
3893
+ storeSlotListener: options.storeSlotListener
3894
+ });
3895
+ }
3896
+ createComputedStoreSlot(channelMap) {
3897
+ return this.computedSingleSlotService.createStoreSlot(channelMap);
3898
+ }
3899
+ };
3900
+
3901
+ // src/computed/createOIMSourceTrackingComputedService.ts
3902
+ function createOIMSourceTrackingComputedService(options) {
3903
+ return new OIMSourceTrackingComputedService({
3904
+ computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
3905
+ ...oimResolveComputedDerivationOptions(options),
3906
+ derive: options.derive
3907
+ });
3908
+ }
3909
+
3910
+ // src/computed/createOIMSingleSourceTrackingComputedService.ts
3911
+ function createOIMSingleSourceTrackingComputedService(options) {
3912
+ return new OIMSingleSourceTrackingComputedService({
3913
+ ...oimResolveComputedDerivationOptions(options),
3914
+ derive: options.derive
3755
3915
  });
3756
3916
  }
3757
3917
 
3758
- // src/facade/computed/utils/oimColumnsComparator.ts
3918
+ // src/computed/utils/oimColumnsComparator.ts
3759
3919
  function oimColumnsComparator(columns) {
3760
3920
  return (left, right) => {
3761
3921
  for (let i = 0; i < columns.length; i++) {
3762
- const column = columns[i].column;
3763
- const leftValue = left[column];
3764
- const rightValue = right[column];
3922
+ const columnName = columns[i].columnName;
3923
+ const leftValue = left[columnName];
3924
+ const rightValue = right[columnName];
3765
3925
  if (leftValue === rightValue) continue;
3766
3926
  const isLeftMissing = leftValue === void 0 || leftValue === null || leftValue !== leftValue;
3767
3927
  const isRightMissing = rightValue === void 0 || rightValue === null || rightValue !== rightValue;
@@ -3775,7 +3935,7 @@ function oimColumnsComparator(columns) {
3775
3935
  };
3776
3936
  }
3777
3937
 
3778
- // src/facade/computed/utils/oimEntitySlotsComparator.ts
3938
+ // src/computed/utils/oimEntitySlotsComparator.ts
3779
3939
  function oimEntitySlotsComparator(compareEntities) {
3780
3940
  return (leftEntitySlot, rightEntitySlot) => {
3781
3941
  const leftEntity = leftEntitySlot.entity;
@@ -3786,7 +3946,7 @@ function oimEntitySlotsComparator(compareEntities) {
3786
3946
  };
3787
3947
  }
3788
3948
 
3789
- // src/facade/computed/OIMSortedComputedService.ts
3949
+ // src/computed/OIMSortedComputedService.ts
3790
3950
  var OIMSortedComputedService = class {
3791
3951
  constructor(options) {
3792
3952
  const indexService = options.indexService;
@@ -3800,16 +3960,18 @@ var OIMSortedComputedService = class {
3800
3960
  derive: (computedSlot) => sortBucketMemberSlots(computedSlot, bucketContentService, compareEntitySlots),
3801
3961
  sameValueGuard: oimSameSlotSequence
3802
3962
  });
3803
- this.computedCollectionService = createOIMComputedCollectionService({
3804
- computedValueService,
3805
- createSources: (computedSlot) => createSortedSources(
3806
- computedSlot.key,
3807
- computedSlot.storeSlot,
3808
- indexService,
3809
- sortColumns,
3810
- hasComparator
3811
- ),
3812
- initialValue: OIM_FROZEN_EMPTY_SLOTS,
3963
+ this.computedCollectionService = createOIMComputedSlotCollectionService({
3964
+ slotContentService: new OIMSlotContentComputedService({
3965
+ computedValueService,
3966
+ createSources: (computedSlot) => createSortedComputedSources(
3967
+ computedSlot.key,
3968
+ computedSlot.storeSlot,
3969
+ indexService,
3970
+ sortColumns,
3971
+ hasComparator
3972
+ ),
3973
+ initialValue: OIM_FROZEN_EMPTY_SLOTS
3974
+ }),
3813
3975
  slotReleasePolicy: options.slotReleasePolicy,
3814
3976
  computedSlotStoreService: options.computedSlotStoreService,
3815
3977
  columnSlotOwnerOptions: { columnSlotStoreService: options.columnSlotStoreService },
@@ -3823,12 +3985,12 @@ var OIMSortedComputedService = class {
3823
3985
  function compareNothing() {
3824
3986
  return 0;
3825
3987
  }
3826
- function createSortedSources(key, storeSlot, indexService, sortColumns, hasComparator) {
3988
+ function createSortedComputedSources(key, storeSlot, indexService, sortColumns, hasComparator) {
3827
3989
  const indexStoreSlot = storeSlot.sourceStoreSlot;
3828
3990
  const sourceSlots = [indexService.getSlotByKey(indexStoreSlot, key)];
3829
3991
  if (sortColumns !== void 0) {
3830
3992
  for (let i = 0; i < sortColumns.length; i++) {
3831
- sourceSlots.push(indexService.getBucketColumnByKey(indexStoreSlot, key, sortColumns[i].column));
3993
+ sourceSlots.push(indexService.getBucketColumnByKey(indexStoreSlot, key, sortColumns[i].columnName));
3832
3994
  }
3833
3995
  } else if (hasComparator) {
3834
3996
  sourceSlots.push(indexService.getAnyBucketColumnByKey(indexStoreSlot, key));
@@ -3893,20 +4055,21 @@ function reconcileArrayWithEveryBucketMemberSlot(entitySlots, bucketMemberSlots)
3893
4055
  return next;
3894
4056
  }
3895
4057
 
3896
- // src/factories/createOIMSortedComputedService.ts
4058
+ // src/computed/createOIMSortedComputedService.ts
3897
4059
  function createOIMSortedComputedService(options) {
4060
+ const defaults = options.defaults ?? OIMDefaults.INSTANCE;
3898
4061
  return new OIMSortedComputedService({
3899
4062
  indexService: options.indexService,
3900
- computedSlotStoreService: oimSlotStoreServiceWithDefault(options.computedSlotStoreService),
3901
- columnSlotStoreService: options.columnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
4063
+ computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
4064
+ columnSlotStoreService: options.columnSlotStoreService ?? defaults.computedColumnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
3902
4065
  sortColumns: options.sortColumns,
3903
4066
  comparator: options.comparator,
3904
4067
  slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
3905
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
4068
+ storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
3906
4069
  });
3907
4070
  }
3908
4071
 
3909
- // src/facade/computed/OIMBucketMemoComputedService.ts
4072
+ // src/computed/OIMBucketMemoComputedService.ts
3910
4073
  var OIMBucketMemoComputedService = class {
3911
4074
  constructor(options) {
3912
4075
  const bucketCollectionService = options.bucketCollectionService;
@@ -3915,10 +4078,12 @@ var OIMBucketMemoComputedService = class {
3915
4078
  derive: (computedSlot) => deriveBucketMemo(computedSlot, bucketContentService),
3916
4079
  sameValueGuard: oimSameSlotSequence
3917
4080
  });
3918
- this.computedCollectionService = createOIMComputedCollectionService({
3919
- computedValueService,
3920
- createSources: (computedSlot) => createBucketMemoSources(computedSlot.key, computedSlot.storeSlot, bucketCollectionService),
3921
- initialValue: OIM_FROZEN_EMPTY_SLOTS,
4081
+ this.computedCollectionService = createOIMComputedSlotCollectionService({
4082
+ slotContentService: new OIMSlotContentComputedService({
4083
+ computedValueService,
4084
+ createSources: (computedSlot) => createBucketMemoComputedSources(computedSlot.key, computedSlot.storeSlot, bucketCollectionService),
4085
+ initialValue: OIM_FROZEN_EMPTY_SLOTS
4086
+ }),
3922
4087
  slotReleasePolicy: options.slotReleasePolicy,
3923
4088
  computedSlotStoreService: options.computedSlotStoreService,
3924
4089
  columnSlotOwnerOptions: { columnSlotStoreService: options.columnSlotStoreService },
@@ -3932,26 +4097,27 @@ var OIMBucketMemoComputedService = class {
3932
4097
  function deriveBucketMemo(computedSlot, bucketContentService) {
3933
4098
  return Array.from(bucketContentService.getBucketMemberSlots(computedSlot.sourceSlots[0]));
3934
4099
  }
3935
- function createBucketMemoSources(key, storeSlot, bucketCollectionService) {
4100
+ function createBucketMemoComputedSources(key, storeSlot, bucketCollectionService) {
3936
4101
  const bucketStoreSlot = storeSlot.sourceStoreSlot;
3937
4102
  return { sourceSlots: [bucketCollectionService.getSlotByKey(bucketStoreSlot, key)] };
3938
4103
  }
3939
4104
 
3940
- // src/factories/createOIMBucketMemoComputedService.ts
4105
+ // src/computed/createOIMBucketMemoComputedService.ts
3941
4106
  function createOIMBucketMemoComputedService(options) {
4107
+ const defaults = options.defaults ?? OIMDefaults.INSTANCE;
3942
4108
  return new OIMBucketMemoComputedService({
3943
4109
  bucketCollectionService: options.bucketCollectionService,
3944
- computedSlotStoreService: oimSlotStoreServiceWithDefault(options.computedSlotStoreService),
3945
- columnSlotStoreService: options.columnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
4110
+ computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
4111
+ columnSlotStoreService: options.columnSlotStoreService ?? defaults.computedColumnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
3946
4112
  slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
3947
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
4113
+ storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
3948
4114
  });
3949
4115
  }
3950
4116
 
3951
- // src/engine/bucket/commands/constants/OIM_MAX_COMMANDS_PER_SLOT.ts
4117
+ // src/bucket/commands/constants/OIM_MAX_COMMANDS_PER_SLOT.ts
3952
4118
  var OIM_MAX_COMMANDS_PER_SLOT = 1;
3953
4119
 
3954
- // src/facade/bucket/OIMBucketCommands.ts
4120
+ // src/bucket/OIMBucketCommands.ts
3955
4121
  var OIMBucketCommands = class {
3956
4122
  constructor(options) {
3957
4123
  this.maxCommandsPerSlot = options.maxCommandsPerSlot ?? OIM_MAX_COMMANDS_PER_SLOT;
@@ -3966,40 +4132,40 @@ var OIMBucketCommands = class {
3966
4132
  this.recordCommand(bucketSlot, { type: "move", from, to }, bucketMemberSlotCount);
3967
4133
  }
3968
4134
  recordWholeList(bucketSlot) {
3969
- const bucketSlotEditable = enlistInFlush(bucketSlot);
3970
- const commands = bucketSlotEditable.commands;
4135
+ const editableBucketSlot = enlistInFlush(bucketSlot);
4136
+ const commands = editableBucketSlot.commands;
3971
4137
  if (commands !== void 0 && commands.length !== 0) commands.length = 0;
3972
- bucketSlotEditable.isWholeListRecorded = true;
4138
+ editableBucketSlot.isWholeListRecorded = true;
3973
4139
  }
3974
4140
  recordCommand(bucketSlot, orderedListCommand, bucketMemberSlotCount) {
3975
- const bucketSlotEditable = enlistInFlush(bucketSlot);
3976
- if (bucketSlotEditable.isWholeListRecorded) return;
3977
- const commands = bucketSlotEditable.commands ?? (bucketSlotEditable.commands = []);
4141
+ const editableBucketSlot = enlistInFlush(bucketSlot);
4142
+ if (editableBucketSlot.isWholeListRecorded) return;
4143
+ const commands = editableBucketSlot.commands ?? (editableBucketSlot.commands = []);
3978
4144
  commands.push(orderedListCommand);
3979
4145
  if (commands.length > this.maxCommandsPerSlot * bucketMemberSlotCount) {
3980
4146
  commands.length = 0;
3981
- bucketSlotEditable.isWholeListRecorded = true;
4147
+ editableBucketSlot.isWholeListRecorded = true;
3982
4148
  }
3983
4149
  }
3984
4150
  };
3985
4151
  function enlistInFlush(bucketSlot) {
3986
- const bucketSlotEditable = bucketSlot;
4152
+ const editableBucketSlot = bucketSlot;
3987
4153
  const storeSlot = bucketSlot.storeSlot;
3988
4154
  const channelSlot = storeSlot.channelSlot;
3989
- const commands = bucketSlotEditable.commands;
3990
- const hasScript = commands !== void 0 && commands.length > 0 || bucketSlotEditable.isWholeListRecorded;
3991
- if (hasScript && !isScriptStale(channelSlot, bucketSlotEditable)) return bucketSlotEditable;
4155
+ const commands = editableBucketSlot.commands;
4156
+ const hasScript = commands !== void 0 && commands.length > 0 || editableBucketSlot.isWholeListRecorded;
4157
+ if (hasScript && !isScriptStale(channelSlot, editableBucketSlot)) return editableBucketSlot;
3992
4158
  if (hasScript) {
3993
- clearScript(bucketSlotEditable);
4159
+ clearScript(editableBucketSlot);
3994
4160
  } else {
3995
4161
  const commandsBucketSlotChannelQueue = storeSlot.commandsBucketSlotChannelQueue ?? (storeSlot.commandsBucketSlotChannelQueue = new OIMChannelQueue());
3996
4162
  if (commandsBucketSlotChannelQueue.getEntryCount() === 0) getCommandsStoreSlotChannelQueue(channelSlot).enqueueEntry(storeSlot);
3997
- commandsBucketSlotChannelQueue.enqueueEntry(bucketSlotEditable);
4163
+ commandsBucketSlotChannelQueue.enqueueEntry(editableBucketSlot);
3998
4164
  }
3999
4165
  const clock = channelSlot.clock;
4000
- bucketSlotEditable.commandsStartedAtRevision = clock.revision;
4001
- bucketSlotEditable.commandsStartedAtEpoch = clock.epoch;
4002
- return bucketSlotEditable;
4166
+ editableBucketSlot.commandsStartedAtRevision = clock.revision;
4167
+ editableBucketSlot.commandsStartedAtEpoch = clock.epoch;
4168
+ return editableBucketSlot;
4003
4169
  }
4004
4170
  function getCommandsStoreSlotChannelQueue(channelSlot) {
4005
4171
  const commandsStoreSlotChannelQueue = channelSlot.commandsStoreSlotChannelQueue;
@@ -4020,10 +4186,10 @@ function isScriptStale(channelSlot, bucketSlot) {
4020
4186
  bucketSlot.commandsStartedAtEpoch
4021
4187
  );
4022
4188
  }
4023
- function clearScript(bucketSlotEditable) {
4024
- const commands = bucketSlotEditable.commands;
4189
+ function clearScript(editableBucketSlot) {
4190
+ const commands = editableBucketSlot.commands;
4025
4191
  if (commands !== void 0 && commands.length !== 0) commands.length = 0;
4026
- bucketSlotEditable.isWholeListRecorded = false;
4192
+ editableBucketSlot.isWholeListRecorded = false;
4027
4193
  }
4028
4194
  function clearStaleScripts(channelSlot, commandsStoreSlotChannelQueue) {
4029
4195
  let keptStoreSlotCount = 0;
@@ -4032,12 +4198,12 @@ function clearStaleScripts(channelSlot, commandsStoreSlotChannelQueue) {
4032
4198
  const commandsBucketSlotChannelQueue = storeSlot.commandsBucketSlotChannelQueue;
4033
4199
  let keptBucketSlotCount = 0;
4034
4200
  for (let j = 0; j < commandsBucketSlotChannelQueue.getEntryCount(); j++) {
4035
- const bucketSlotEditable = commandsBucketSlotChannelQueue.getEntryAt(j);
4036
- if (!isScriptStale(channelSlot, bucketSlotEditable)) {
4037
- commandsBucketSlotChannelQueue.setEntryAt(keptBucketSlotCount++, bucketSlotEditable);
4201
+ const editableBucketSlot = commandsBucketSlotChannelQueue.getEntryAt(j);
4202
+ if (!isScriptStale(channelSlot, editableBucketSlot)) {
4203
+ commandsBucketSlotChannelQueue.setEntryAt(keptBucketSlotCount++, editableBucketSlot);
4038
4204
  continue;
4039
4205
  }
4040
- clearScript(bucketSlotEditable);
4206
+ clearScript(editableBucketSlot);
4041
4207
  }
4042
4208
  commandsBucketSlotChannelQueue.keepFirstEntries(keptBucketSlotCount);
4043
4209
  if (keptBucketSlotCount !== 0) commandsStoreSlotChannelQueue.setEntryAt(keptStoreSlotCount++, storeSlot);
@@ -4045,7 +4211,7 @@ function clearStaleScripts(channelSlot, commandsStoreSlotChannelQueue) {
4045
4211
  commandsStoreSlotChannelQueue.keepFirstEntries(keptStoreSlotCount);
4046
4212
  }
4047
4213
 
4048
- // src/engine/index/utils/createOIMIndexStoreSlot.ts
4214
+ // src/index/utils/createOIMIndexStoreSlot.ts
4049
4215
  function createOIMIndexStoreSlot(store, slotService, sourceStoreSlot, contentChangeListener) {
4050
4216
  return {
4051
4217
  ...createOIMStoreSlot(store, sourceStoreSlot.channelSlot, slotService),
@@ -4059,7 +4225,35 @@ function createOIMIndexStoreSlot(store, slotService, sourceStoreSlot, contentCha
4059
4225
  };
4060
4226
  }
4061
4227
 
4062
- // src/facade/index/OIMSlotCollectionIndexService.ts
4228
+ // src/index/OIMSlotCollectionIndexStoreAggregate.ts
4229
+ var OIMSlotCollectionIndexStoreAggregate = class extends OIMSlotCollectionStoreAggregate {
4230
+ getEntitiesByKey(key) {
4231
+ return this.slotService.getEntitiesByKey(this.storeSlot, key);
4232
+ }
4233
+ getSlotsByKeys(keys) {
4234
+ return this.slotService.getSlotsByKeys(this.storeSlot, keys);
4235
+ }
4236
+ holdSlotsByKeys(keys) {
4237
+ return this.slotService.holdSlotsByKeys(this.storeSlot, keys);
4238
+ }
4239
+ getAnyBucketColumnByKey(key) {
4240
+ return this.slotService.getAnyBucketColumnByKey(this.storeSlot, key);
4241
+ }
4242
+ holdAnyBucketColumnByKey(key) {
4243
+ return this.slotService.holdAnyBucketColumnByKey(this.storeSlot, key);
4244
+ }
4245
+ getBucketColumnByKey(key, columnName) {
4246
+ return this.slotService.getBucketColumnByKey(this.storeSlot, key, columnName);
4247
+ }
4248
+ holdBucketColumnByKey(key, columnName) {
4249
+ return this.slotService.holdBucketColumnByKey(this.storeSlot, key, columnName);
4250
+ }
4251
+ disposeIndexStoreSlot() {
4252
+ this.slotService.disposeIndexStoreSlot(this.storeSlot);
4253
+ }
4254
+ };
4255
+
4256
+ // src/index/OIMSlotCollectionIndexService.ts
4063
4257
  var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4064
4258
  constructor(options) {
4065
4259
  super(options);
@@ -4074,26 +4268,29 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4074
4268
  onContentChanged: (entitySlot, patch, changedColumns) => {
4075
4269
  this.updateIndexKeyForSlot(indexStoreSlot, entitySlot, patch, changedColumns);
4076
4270
  },
4077
- onContentChangedMany: (entitySlotChannelQueue, patchChannelQueue, changedColumnsChannelQueue) => {
4271
+ onManyContentsChanged: (entitySlotChannelQueue, patchChannelQueue, changedColumnsChannelQueue) => {
4078
4272
  this.updateIndexKeysForSlots(indexStoreSlot, entitySlotChannelQueue, patchChannelQueue, changedColumnsChannelQueue);
4079
4273
  }
4080
4274
  };
4081
- const indexStoreSlot = this.createStoreSlotWith((store) => createOIMIndexStoreSlot(store, this, sourceStoreSlot, contentChangeListener));
4275
+ const indexStoreSlot = this.createStoreSlotOverNewStore((store) => createOIMIndexStoreSlot(store, this, sourceStoreSlot, contentChangeListener));
4082
4276
  const indexKeysService = this.indexKeysService;
4083
4277
  const indexKeysPositions = sourceStoreSlot.indexKeysPositions ?? (sourceStoreSlot.indexKeysPositions = indexKeysService.createPositions());
4084
4278
  indexStoreSlot.indexKeysPosition = indexKeysService.allocatePosition(indexKeysPositions);
4085
- OIMContentChangeListenerService.INSTANCE.addContentChangeListener(sourceStoreSlot, contentChangeListener, this.keyColumns);
4279
+ OIMSlotContentChangeListenerService.INSTANCE.addContentChangeListener(sourceStoreSlot, contentChangeListener, this.keyColumns);
4086
4280
  return indexStoreSlot;
4087
4281
  }
4282
+ createStoreAggregate(indexStoreSlot) {
4283
+ return new OIMSlotCollectionIndexStoreAggregate(this, indexStoreSlot);
4284
+ }
4088
4285
  disposeIndexStoreSlot(indexStoreSlot) {
4089
4286
  this.assertNotDisposed(indexStoreSlot);
4090
4287
  OIMChannelService.INSTANCE.assertNotFlushing(indexStoreSlot.channelSlot);
4091
4288
  const sourceStoreSlot = indexStoreSlot.sourceStoreSlot;
4092
- OIMContentChangeListenerService.INSTANCE.removeContentChangeListener(sourceStoreSlot, indexStoreSlot.contentChangeListener);
4289
+ OIMSlotContentChangeListenerService.INSTANCE.removeContentChangeListener(sourceStoreSlot, indexStoreSlot.contentChangeListener);
4093
4290
  for (const bucketColumnName of indexStoreSlot.bucketColumnNames) {
4094
- OIMContentChangeListenerService.INSTANCE.removeReadColumn(sourceStoreSlot, bucketColumnName);
4291
+ OIMSlotContentChangeListenerService.INSTANCE.removeReadColumn(sourceStoreSlot, bucketColumnName);
4095
4292
  }
4096
- if (indexStoreSlot.isAnyBucketColumnRead) OIMContentChangeListenerService.INSTANCE.removeReadAnyColumn(sourceStoreSlot);
4293
+ if (indexStoreSlot.isAnyBucketColumnRead) OIMSlotContentChangeListenerService.INSTANCE.removeReadAnyColumn(sourceStoreSlot);
4097
4294
  const indexKeysPositions = sourceStoreSlot.indexKeysPositions;
4098
4295
  if (indexKeysPositions !== void 0) {
4099
4296
  this.indexKeysService.releasePosition(
@@ -4140,10 +4337,10 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4140
4337
  }
4141
4338
  walkSlotsByKeys(indexStoreSlot, keys, takeFoundSlot, slotByKeyDoor) {
4142
4339
  this.assertNotDisposed(indexStoreSlot);
4143
- const indexStoreSlotEditable = indexStoreSlot;
4340
+ const editableIndexStoreSlot = indexStoreSlot;
4144
4341
  const bucketSlots = [];
4145
4342
  let entitySlotsByMintedBucketSlot;
4146
- indexStoreSlotEditable.requestedKeys = keys;
4343
+ editableIndexStoreSlot.requestedKeys = keys;
4147
4344
  try {
4148
4345
  for (let i = 0; i < keys.length; i++) {
4149
4346
  const foundBucketSlot = this.findSlotByKey(indexStoreSlot, keys[i]);
@@ -4157,7 +4354,7 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4157
4354
  bucketSlots.push(bucketSlot);
4158
4355
  }
4159
4356
  } finally {
4160
- indexStoreSlotEditable.requestedKeys = void 0;
4357
+ editableIndexStoreSlot.requestedKeys = void 0;
4161
4358
  if (entitySlotsByMintedBucketSlot !== void 0) this.fillMintedBucketSlots(indexStoreSlot, entitySlotsByMintedBucketSlot);
4162
4359
  }
4163
4360
  return bucketSlots;
@@ -4189,18 +4386,14 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4189
4386
  const bucketColumnNames = indexStoreSlot.bucketColumnNames;
4190
4387
  if (bucketColumnNames.has(columnName)) return;
4191
4388
  bucketColumnNames.add(columnName);
4192
- OIMContentChangeListenerService.INSTANCE.addReadColumn(indexStoreSlot.sourceStoreSlot, columnName);
4389
+ OIMSlotContentChangeListenerService.INSTANCE.addReadColumn(indexStoreSlot.sourceStoreSlot, columnName);
4193
4390
  }
4194
4391
  onBucketColumnsChanged(_indexStoreSlot, _bucketSlot, _entitySlot, _changedColumns) {
4195
4392
  return;
4196
4393
  }
4197
4394
  onSlotMinted(indexStoreSlot, bucketSlot) {
4198
4395
  if (indexStoreSlot.requestedKeys !== void 0) return;
4199
- const key = bucketSlot.key;
4200
- this.slotContentBucketService.fillBucketMemberSlots(
4201
- bucketSlot,
4202
- this.setIndexKeyForSlots(indexStoreSlot, this.collectSourceSlotsForKey(indexStoreSlot, key), key)
4203
- );
4396
+ this.fillBucketSlotWithSourceSlots(indexStoreSlot, bucketSlot, this.collectSourceSlotsForKey(indexStoreSlot, bucketSlot.key));
4204
4397
  }
4205
4398
  assertNotDisposed(storeSlot) {
4206
4399
  if (!storeSlot.isDisposed) return;
@@ -4211,7 +4404,7 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4211
4404
  addAnyBucketColumnRead(indexStoreSlot) {
4212
4405
  if (indexStoreSlot.isAnyBucketColumnRead) return;
4213
4406
  indexStoreSlot.isAnyBucketColumnRead = true;
4214
- OIMContentChangeListenerService.INSTANCE.addReadAnyColumn(indexStoreSlot.sourceStoreSlot);
4407
+ OIMSlotContentChangeListenerService.INSTANCE.addReadAnyColumn(indexStoreSlot.sourceStoreSlot);
4215
4408
  }
4216
4409
  fillMintedBucketSlots(indexStoreSlot, entitySlotsByMintedBucketSlot) {
4217
4410
  for (const entitySlot of this.sourceSlotCollectionService.getSlots(indexStoreSlot.sourceStoreSlot)) {
@@ -4223,7 +4416,7 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4223
4416
  const slotContentService = this.slotContentBucketService;
4224
4417
  const slotOwnerService = this.slotOwnerService;
4225
4418
  for (const [bucketSlot, entitySlots] of entitySlotsByMintedBucketSlot) {
4226
- slotContentService.fillBucketMemberSlots(bucketSlot, this.setIndexKeyForSlots(indexStoreSlot, entitySlots, bucketSlot.key));
4419
+ this.fillBucketSlotWithSourceSlots(indexStoreSlot, bucketSlot, entitySlots);
4227
4420
  slotOwnerService.settleEmptiness(bucketSlot, slotContentService.isSlotEmpty(bucketSlot));
4228
4421
  }
4229
4422
  }
@@ -4363,40 +4556,42 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
4363
4556
  }
4364
4557
  return matchingEntitySlots;
4365
4558
  }
4366
- setIndexKeyForSlots(indexStoreSlot, entitySlots, key) {
4559
+ fillBucketSlotWithSourceSlots(indexStoreSlot, bucketSlot, entitySlots) {
4367
4560
  const indexKeysService = this.indexKeysService;
4368
4561
  const indexKeysPosition = indexStoreSlot.indexKeysPosition;
4369
- const channelSlot = indexStoreSlot.channelSlot;
4370
- const isRefusingWrites = OIMChannelService.INSTANCE.isRefusingWrites(channelSlot);
4371
- let movableEntitySlots;
4562
+ const key = bucketSlot.key;
4563
+ const isRefusingWrites = OIMChannelService.INSTANCE.isRefusingWrites(indexStoreSlot.channelSlot);
4564
+ const fillingEntitySlots = [];
4565
+ const prevKeys = [];
4566
+ const movingEntitySlots = [];
4372
4567
  for (let i = 0; i < entitySlots.length; i++) {
4373
4568
  const entitySlot = entitySlots[i];
4374
4569
  const prevKey = indexKeysService.get(entitySlot, indexKeysPosition);
4375
4570
  const isMoving = prevKey !== void 0 && !this.isSameKey(prevKey, key);
4376
- if (isMoving && isRefusingWrites) {
4377
- movableEntitySlots ?? (movableEntitySlots = entitySlots.slice(0, i));
4378
- continue;
4379
- }
4380
- movableEntitySlots?.push(entitySlot);
4571
+ if (isMoving && isRefusingWrites) continue;
4572
+ fillingEntitySlots.push(entitySlot);
4381
4573
  indexKeysService.set(entitySlot, indexKeysPosition, key);
4382
4574
  if (!isMoving) continue;
4383
- OIMUnusedSlotCollectorService.INSTANCE.holdSlotUntilFlush(channelSlot.collectorSlot.unusedSlotCollectorSlot, entitySlot);
4384
- const prevBucketSlot = this.findSlotByKey(indexStoreSlot, prevKey);
4385
- if (prevBucketSlot !== void 0) this.slotContentBucketService.removeBucketMemberSlot(prevBucketSlot, entitySlot);
4575
+ prevKeys.push(prevKey);
4576
+ movingEntitySlots.push(entitySlot);
4577
+ }
4578
+ this.slotContentBucketService.fillBucketMemberSlots(bucketSlot, fillingEntitySlots);
4579
+ for (let i = 0; i < movingEntitySlots.length; i++) {
4580
+ const prevBucketSlot = this.findSlotByKey(indexStoreSlot, prevKeys[i]);
4581
+ if (prevBucketSlot !== void 0) this.slotContentBucketService.removeBucketMemberSlot(prevBucketSlot, movingEntitySlots[i]);
4386
4582
  }
4387
- return movableEntitySlots ?? entitySlots;
4388
4583
  }
4389
4584
  };
4390
4585
  function takeNothing() {
4391
4586
  return;
4392
4587
  }
4393
4588
 
4394
- // src/facade/index/OIMSlotCollectionSortedArrayIndexService.ts
4589
+ // src/index/OIMSlotCollectionSortedArrayIndexService.ts
4395
4590
  var OIMSlotCollectionSortedArrayIndexService = class extends OIMSlotCollectionIndexService {
4396
4591
  constructor(options) {
4397
4592
  super(options);
4398
4593
  const sortColumnNames = /* @__PURE__ */ new Set();
4399
- for (let i = 0; i < options.sortColumns.length; i++) sortColumnNames.add(options.sortColumns[i].column);
4594
+ for (let i = 0; i < options.sortColumns.length; i++) sortColumnNames.add(options.sortColumns[i].columnName);
4400
4595
  this.sortColumnNames = sortColumnNames;
4401
4596
  }
4402
4597
  createIndexStoreSlot(sourceStoreSlot) {
@@ -4418,7 +4613,51 @@ var OIMSlotCollectionSortedArrayIndexService = class extends OIMSlotCollectionIn
4418
4613
  }
4419
4614
  };
4420
4615
 
4421
- // src/factories/utils/oimKeyOfColumns.ts
4616
+ // src/index/OIMIndexKeysService.ts
4617
+ var OIMIndexKeysService = class {
4618
+ createPositions() {
4619
+ return { nextPosition: 0, freePositions: [] };
4620
+ }
4621
+ get(slot, position) {
4622
+ const indexKeys = slot.indexKeys;
4623
+ return indexKeys === void 0 || position >= indexKeys.length ? void 0 : indexKeys[position];
4624
+ }
4625
+ set(slot, position, indexKey) {
4626
+ const indexKeys = slot.indexKeys;
4627
+ if (indexKeys !== void 0) {
4628
+ if (position < indexKeys.length) {
4629
+ indexKeys[position] = indexKey;
4630
+ return;
4631
+ }
4632
+ if (indexKey === void 0) return;
4633
+ while (indexKeys.length < position) indexKeys.push(void 0);
4634
+ indexKeys.push(indexKey);
4635
+ return;
4636
+ }
4637
+ if (indexKey === void 0) return;
4638
+ const created = [];
4639
+ while (created.length < position) created.push(void 0);
4640
+ created.push(indexKey);
4641
+ slot.indexKeys = created;
4642
+ }
4643
+ };
4644
+
4645
+ // src/index/OIMAppendingIndexKeysService.ts
4646
+ var _OIMAppendingIndexKeysService = class _OIMAppendingIndexKeysService extends OIMIndexKeysService {
4647
+ allocatePosition(positions) {
4648
+ return positions.nextPosition++;
4649
+ }
4650
+ releasePosition() {
4651
+ return;
4652
+ }
4653
+ };
4654
+ _OIMAppendingIndexKeysService.INSTANCE = new _OIMAppendingIndexKeysService();
4655
+ var OIMAppendingIndexKeysService = _OIMAppendingIndexKeysService;
4656
+
4657
+ // src/db/constants/OIM_DEFAULT_INDEX_KEYS_SERVICE.ts
4658
+ var OIM_DEFAULT_INDEX_KEYS_SERVICE = /* @__PURE__ */ new OIMDefaultValue(() => OIMAppendingIndexKeysService.INSTANCE);
4659
+
4660
+ // src/index/utils/oimKeyOfColumns.ts
4422
4661
  function oimKeyOfColumns(columns) {
4423
4662
  if (columns.length === 1) {
4424
4663
  const column = columns[0];
@@ -4431,47 +4670,47 @@ function oimKeyOfColumns(columns) {
4431
4670
  };
4432
4671
  }
4433
4672
 
4434
- // src/factories/utils/oimSlotCollectionIndexServiceOptionsWithDefault.ts
4435
- function oimSlotCollectionIndexServiceOptionsWithDefault(db, options, slotStoreService, slotContentService) {
4673
+ // src/index/utils/oimResolveSlotCollectionIndexServiceOptions.ts
4674
+ function oimResolveSlotCollectionIndexServiceOptions(defaults, options, slotStoreService, slotContentService) {
4436
4675
  return {
4437
- ...oimSlotOwnerOptionsWithDefault(db, options),
4676
+ ...oimResolveSlotOwnerServiceOptions(defaults, options),
4438
4677
  slotStoreService,
4439
4678
  slotContentService,
4440
- storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
4679
+ storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
4441
4680
  keyOf: options.keyOf ?? oimKeyOfColumns(options.columns),
4442
4681
  columns: options.columns,
4443
4682
  sourceSlotCollectionService: options.entityService,
4444
- indexKeysService: db.indexKeysService ?? OIM_DEFAULT_INDEX_KEYS_SERVICE.getValue()
4683
+ indexKeysService: defaults.indexKeysService ?? OIM_DEFAULT_INDEX_KEYS_SERVICE.getValue()
4445
4684
  };
4446
4685
  }
4447
4686
 
4448
- // src/factories/createOIMSlotCollectionIndexService.ts
4449
- function createOIMSlotCollectionIndexService(db, options) {
4450
- return new OIMSlotCollectionIndexService(oimSlotCollectionIndexServiceOptionsWithDefault(
4451
- db,
4687
+ // src/index/createOIMSlotCollectionIndexService.ts
4688
+ function createOIMSlotCollectionIndexService(options) {
4689
+ return new OIMSlotCollectionIndexService(oimResolveSlotCollectionIndexServiceOptions(
4690
+ options.defaults ?? OIMDefaults.INSTANCE,
4452
4691
  options,
4453
- oimSlotStoreServiceWithDefault(options.bucketSlotStoreService),
4692
+ oimResolveSlotStoreService(options.bucketSlotStoreService),
4454
4693
  options.slotContentService ?? new OIMSlotContentPositionalArrayBucketService()
4455
4694
  ));
4456
4695
  }
4457
4696
 
4458
- // src/factories/createOIMSlotCollectionSortedArrayIndexService.ts
4459
- function createOIMSlotCollectionSortedArrayIndexService(db, options) {
4697
+ // src/index/createOIMSlotCollectionSortedArrayIndexService.ts
4698
+ function createOIMSlotCollectionSortedArrayIndexService(options) {
4460
4699
  const slotContentService = new OIMSlotContentSortedArrayBucketService({
4461
4700
  compareBucketMemberSlots: oimEntitySlotsComparator(oimColumnsComparator(options.sortColumns))
4462
4701
  });
4463
4702
  return new OIMSlotCollectionSortedArrayIndexService({
4464
- ...oimSlotCollectionIndexServiceOptionsWithDefault(
4465
- db,
4703
+ ...oimResolveSlotCollectionIndexServiceOptions(
4704
+ options.defaults ?? OIMDefaults.INSTANCE,
4466
4705
  options,
4467
- oimSlotStoreServiceWithDefault(options.bucketSlotStoreService),
4706
+ oimResolveSlotStoreService(options.bucketSlotStoreService),
4468
4707
  slotContentService
4469
4708
  ),
4470
4709
  sortColumns: options.sortColumns
4471
4710
  });
4472
4711
  }
4473
4712
 
4474
- // src/engine/index/OIMReclaimingIndexKeysService.ts
4713
+ // src/index/OIMReclaimingIndexKeysService.ts
4475
4714
  var OIMReclaimingIndexKeysService = class extends OIMIndexKeysService {
4476
4715
  allocatePosition(positions) {
4477
4716
  const freePosition = positions.freePositions.pop();
@@ -4486,18 +4725,18 @@ var OIMReclaimingIndexKeysService = class extends OIMIndexKeysService {
4486
4725
  }
4487
4726
  };
4488
4727
 
4489
- // src/engine/entity/utils/oimCopyEntity.ts
4728
+ // src/entity/utils/oimCopyEntity.ts
4490
4729
  function oimCopyEntity(entity) {
4491
4730
  return { ...entity };
4492
4731
  }
4493
4732
 
4494
- // src/factories/createOIMEntityWriterReplacing.ts
4733
+ // src/entity/createOIMReplacingEntityWriter.ts
4495
4734
  function storeReplacement(slot, next) {
4496
4735
  if (next === void 0) return false;
4497
4736
  slot.entity = next;
4498
4737
  return true;
4499
4738
  }
4500
- function deleteColumnsReplacing(slot, names) {
4739
+ function deleteColumnsInCopy(slot, names) {
4501
4740
  const deleted = oimOwnedColumnNames(slot, names);
4502
4741
  if (deleted === void 0) return OIM_FROZEN_EMPTY_COLUMN_NAMES;
4503
4742
  const next = oimCopyEntity(slot.entity);
@@ -4505,61 +4744,61 @@ function deleteColumnsReplacing(slot, names) {
4505
4744
  slot.entity = next;
4506
4745
  return deleted;
4507
4746
  }
4508
- function createOIMEntityWriterReplacing(options) {
4747
+ function createOIMReplacingEntityWriter(options) {
4509
4748
  const {
4510
4749
  sameValueGuard,
4511
4750
  entityInserter,
4512
4751
  putEntityColumns,
4513
4752
  patchEntityColumns,
4514
4753
  patchEntityColumn
4515
- } = oimEntityWriterOptionsWithDefault(options);
4754
+ } = oimResolveEntityWriterOptions(options);
4516
4755
  return {
4517
4756
  fillEntity: entityInserter,
4518
4757
  clearEntity: oimClearEntity,
4519
4758
  putEntity: (slot, entity, changedColumnNames) => storeReplacement(slot, putEntityColumns(slot, entity, sameValueGuard, changedColumnNames, oimCopyEntity)),
4520
4759
  patchEntity: (slot, patch, changedColumnNames) => storeReplacement(slot, patchEntityColumns(slot, patch, sameValueGuard, changedColumnNames, oimCopyEntity)),
4521
4760
  patchColumn: (slot, columnName, value, changedColumnNames) => storeReplacement(slot, patchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, oimCopyEntity)),
4522
- deleteColumns: deleteColumnsReplacing
4761
+ deleteColumns: deleteColumnsInCopy
4523
4762
  };
4524
4763
  }
4525
4764
 
4526
- // src/engine/entity/utils/oimInsertEntityWithCopy.ts
4765
+ // src/entity/utils/oimInsertEntityWithCopy.ts
4527
4766
  function oimInsertEntityWithCopy(slot, entity) {
4528
4767
  slot.entity = oimCopyEntity(entity);
4529
4768
  }
4530
4769
 
4531
- // src/engine/entity/utils/oimCopyEntitySanitized.ts
4532
- function oimCopyEntitySanitized(entity) {
4770
+ // src/entity/utils/oimSanitizedCopyEntity.ts
4771
+ function oimSanitizedCopyEntity(entity) {
4533
4772
  const copy = { ...entity };
4534
4773
  if (Object.hasOwn(copy, OIM_PROTO_KEY)) delete copy[OIM_PROTO_KEY];
4535
4774
  return copy;
4536
4775
  }
4537
4776
 
4538
- // src/engine/entity/utils/oimInsertEntityWithSanitizedCopy.ts
4777
+ // src/entity/utils/oimInsertEntityWithSanitizedCopy.ts
4539
4778
  function oimInsertEntityWithSanitizedCopy(slot, entity) {
4540
- slot.entity = oimCopyEntitySanitized(entity);
4779
+ slot.entity = oimSanitizedCopyEntity(entity);
4541
4780
  }
4542
4781
 
4543
- // src/engine/entity/utils/oimIsPlain.ts
4544
- function oimIsPlain(source) {
4782
+ // src/entity/utils/oimIsPlainObject.ts
4783
+ function oimIsPlainObject(source) {
4545
4784
  const proto = Object.getPrototypeOf(source);
4546
4785
  return proto === Object.prototype || proto === null;
4547
4786
  }
4548
4787
 
4549
- // src/engine/entity/utils/oimOwnEntityColumns.ts
4788
+ // src/entity/utils/oimOwnEntityColumns.ts
4550
4789
  function oimOwnEntityColumns(entity) {
4551
- if (oimIsPlain(entity) && !Object.hasOwn(entity, OIM_PROTO_KEY)) return entity;
4552
- return oimCopyEntitySanitized(entity);
4790
+ if (oimIsPlainObject(entity) && !Object.hasOwn(entity, OIM_PROTO_KEY)) return entity;
4791
+ return oimSanitizedCopyEntity(entity);
4553
4792
  }
4554
4793
 
4555
- // src/engine/entity/utils/oimPatchEntityColumnsGuarded.ts
4556
- var oimPatchEntityColumnsGuarded = (slot, patch, sameValueGuard, changedColumnNames, targetOf) => oimPatchEntityColumns(slot, oimOwnEntityColumns(patch), sameValueGuard, changedColumnNames, targetOf);
4794
+ // src/entity/utils/oimGuardedPatchEntityColumns.ts
4795
+ var oimGuardedPatchEntityColumns = (slot, patch, sameValueGuard, changedColumnNames, targetOf) => oimPatchEntityColumns(slot, oimOwnEntityColumns(patch), sameValueGuard, changedColumnNames, targetOf);
4557
4796
 
4558
- // src/engine/entity/utils/oimPatchEntityColumnGuarded.ts
4559
- var oimPatchEntityColumnGuarded = (slot, columnName, value, sameValueGuard, changedColumnNames, targetOf) => oimIsProtoKey(columnName) ? void 0 : oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, targetOf);
4797
+ // src/entity/utils/oimGuardedPatchEntityColumn.ts
4798
+ var oimGuardedPatchEntityColumn = (slot, columnName, value, sameValueGuard, changedColumnNames, targetOf) => oimIsProtoKey(columnName) ? void 0 : oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, targetOf);
4560
4799
 
4561
- // src/engine/entity/utils/oimPutEntityColumnsGuarded.ts
4562
- var oimPutEntityColumnsGuarded = (slot, entity, sameValueGuard, changedColumnNames, targetOf) => {
4800
+ // src/entity/utils/oimGuardedPutEntityColumns.ts
4801
+ var oimGuardedPutEntityColumns = (slot, entity, sameValueGuard, changedColumnNames, targetOf) => {
4563
4802
  const prevEntity = slot.entity;
4564
4803
  if (prevEntity === void 0) return void 0;
4565
4804
  const ownColumns = oimOwnEntityColumns(entity);
@@ -4574,13 +4813,13 @@ var oimPutEntityColumnsGuarded = (slot, entity, sameValueGuard, changedColumnNam
4574
4813
  );
4575
4814
  };
4576
4815
 
4577
- // src/engine/collector/constants/OIM_SLICE_LENGTH_MS.ts
4816
+ // src/collector/constants/OIM_SLICE_LENGTH_MS.ts
4578
4817
  var OIM_SLICE_LENGTH_MS = 1024;
4579
4818
 
4580
- // src/engine/collector/utils/oimSliceOfMs.ts
4819
+ // src/collector/utils/oimSliceOfMs.ts
4581
4820
  var oimSliceOfMs = (ms) => Math.floor(ms / OIM_SLICE_LENGTH_MS);
4582
4821
 
4583
- // src/engine/collector/OIMSlotWheel.ts
4822
+ // src/collector/OIMSlotWheel.ts
4584
4823
  var OIMSlotWheel = class {
4585
4824
  constructor(options) {
4586
4825
  this.scheduledCallback = void 0;
@@ -4718,7 +4957,7 @@ var OIMSlotWheel = class {
4718
4957
  }
4719
4958
  };
4720
4959
 
4721
- // src/engine/collector/OIMSlotReleaseWheel.ts
4960
+ // src/collector/OIMSlotReleaseWheel.ts
4722
4961
  var OIMSlotReleaseWheel = class extends OIMSlotWheel {
4723
4962
  constructor(options) {
4724
4963
  super(options);
@@ -4779,20 +5018,20 @@ var OIMSlotReleaseWheel = class extends OIMSlotWheel {
4779
5018
  }
4780
5019
  };
4781
5020
 
4782
- // src/engine/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_WRITE.ts
5021
+ // src/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_WRITE.ts
4783
5022
  var OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_WRITE = 8;
4784
5023
 
4785
- // src/engine/slot/utils/oimGetReleaseDueAfterWriteMs.ts
5024
+ // src/slot/utils/oimGetReleaseDueAfterWriteMs.ts
4786
5025
  function oimGetReleaseDueAfterWriteMs(slot) {
4787
5026
  return slot.releaseDueAfterWriteMs;
4788
5027
  }
4789
5028
 
4790
- // src/engine/slot/utils/oimSetReleaseDueAfterWriteMs.ts
5029
+ // src/slot/utils/oimSetReleaseDueAfterWriteMs.ts
4791
5030
  function oimSetReleaseDueAfterWriteMs(slot, releaseDueMs) {
4792
5031
  slot.releaseDueAfterWriteMs = releaseDueMs;
4793
5032
  }
4794
5033
 
4795
- // src/engine/collector/utils/oimMintAfterWriteSlotReleaseWheel.ts
5034
+ // src/collector/utils/oimMintAfterWriteSlotReleaseWheel.ts
4796
5035
  function oimMintAfterWriteSlotReleaseWheel(collectorSlot) {
4797
5036
  return collectorSlot.afterWriteSlotReleaseWheel ?? (collectorSlot.afterWriteSlotReleaseWheel = new OIMSlotReleaseWheel({
4798
5037
  ...collectorSlot.slotWheelOptions,
@@ -4802,20 +5041,20 @@ function oimMintAfterWriteSlotReleaseWheel(collectorSlot) {
4802
5041
  }));
4803
5042
  }
4804
5043
 
4805
- // src/engine/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_IDLE.ts
5044
+ // src/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_IDLE.ts
4806
5045
  var OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_IDLE = 4;
4807
5046
 
4808
- // src/engine/slot/utils/oimGetReleaseDueAfterIdleMs.ts
5047
+ // src/slot/utils/oimGetReleaseDueAfterIdleMs.ts
4809
5048
  function oimGetReleaseDueAfterIdleMs(slot) {
4810
5049
  return slot.releaseDueAfterIdleMs;
4811
5050
  }
4812
5051
 
4813
- // src/engine/slot/utils/oimSetReleaseDueAfterIdleMs.ts
5052
+ // src/slot/utils/oimSetReleaseDueAfterIdleMs.ts
4814
5053
  function oimSetReleaseDueAfterIdleMs(slot, releaseDueMs) {
4815
5054
  slot.releaseDueAfterIdleMs = releaseDueMs;
4816
5055
  }
4817
5056
 
4818
- // src/engine/collector/utils/oimMintAfterIdleSlotReleaseWheel.ts
5057
+ // src/collector/utils/oimMintAfterIdleSlotReleaseWheel.ts
4819
5058
  function oimMintAfterIdleSlotReleaseWheel(collectorSlot) {
4820
5059
  return collectorSlot.afterIdleSlotReleaseWheel ?? (collectorSlot.afterIdleSlotReleaseWheel = new OIMSlotReleaseWheel({
4821
5060
  ...collectorSlot.slotWheelOptions,
@@ -4825,20 +5064,20 @@ function oimMintAfterIdleSlotReleaseWheel(collectorSlot) {
4825
5064
  }));
4826
5065
  }
4827
5066
 
4828
- // src/engine/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_UNHOLD.ts
5067
+ // src/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_UNHOLD.ts
4829
5068
  var OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_UNHOLD = 16;
4830
5069
 
4831
- // src/engine/slot/utils/oimGetReleaseDueAfterUnholdMs.ts
5070
+ // src/slot/utils/oimGetReleaseDueAfterUnholdMs.ts
4832
5071
  function oimGetReleaseDueAfterUnholdMs(slot) {
4833
5072
  return slot.releaseDueAfterUnholdMs;
4834
5073
  }
4835
5074
 
4836
- // src/engine/slot/utils/oimSetReleaseDueAfterUnholdMs.ts
5075
+ // src/slot/utils/oimSetReleaseDueAfterUnholdMs.ts
4837
5076
  function oimSetReleaseDueAfterUnholdMs(slot, releaseDueMs) {
4838
5077
  slot.releaseDueAfterUnholdMs = releaseDueMs;
4839
5078
  }
4840
5079
 
4841
- // src/engine/collector/utils/oimMintAfterUnholdSlotReleaseWheel.ts
5080
+ // src/collector/utils/oimMintAfterUnholdSlotReleaseWheel.ts
4842
5081
  function oimMintAfterUnholdSlotReleaseWheel(collectorSlot) {
4843
5082
  return collectorSlot.afterUnholdSlotReleaseWheel ?? (collectorSlot.afterUnholdSlotReleaseWheel = new OIMSlotReleaseWheel({
4844
5083
  ...collectorSlot.slotWheelOptions,
@@ -4848,7 +5087,7 @@ function oimMintAfterUnholdSlotReleaseWheel(collectorSlot) {
4848
5087
  }));
4849
5088
  }
4850
5089
 
4851
- // src/engine/collector/OIMSlotRefetchWheel.ts
5090
+ // src/collector/OIMSlotRefetchWheel.ts
4852
5091
  var OIMSlotRefetchWheel = class extends OIMSlotWheel {
4853
5092
  constructor(options) {
4854
5093
  super({
@@ -4882,7 +5121,7 @@ var OIMSlotRefetchWheel = class extends OIMSlotWheel {
4882
5121
  }
4883
5122
  };
4884
5123
 
4885
- // src/engine/collector/OIMSlotReleaseAutoDueFramePolicy.ts
5124
+ // src/collector/OIMSlotReleaseAutoDueFramePolicy.ts
4886
5125
  var _OIMSlotReleaseAutoDueFramePolicy = class _OIMSlotReleaseAutoDueFramePolicy {
4887
5126
  isSlotReleaseDueFrameOpen() {
4888
5127
  return true;
@@ -4891,7 +5130,7 @@ var _OIMSlotReleaseAutoDueFramePolicy = class _OIMSlotReleaseAutoDueFramePolicy
4891
5130
  _OIMSlotReleaseAutoDueFramePolicy.INSTANCE = new _OIMSlotReleaseAutoDueFramePolicy();
4892
5131
  var OIMSlotReleaseAutoDueFramePolicy = _OIMSlotReleaseAutoDueFramePolicy;
4893
5132
 
4894
- // src/engine/collector/OIMSlotAfterWriteReleasePolicy.ts
5133
+ // src/collector/OIMSlotAfterWriteReleasePolicy.ts
4895
5134
  var OIMSlotAfterWriteReleasePolicy = class {
4896
5135
  constructor(options) {
4897
5136
  this.releasesWrittenSlots = true;
@@ -4920,7 +5159,7 @@ var OIMSlotAfterWriteReleasePolicy = class {
4920
5159
  }
4921
5160
  };
4922
5161
 
4923
- // src/engine/collector/OIMSlotReleaseManualDueFramePolicy.ts
5162
+ // src/collector/OIMSlotReleaseManualDueFramePolicy.ts
4924
5163
  var OIMSlotReleaseManualDueFramePolicy = class {
4925
5164
  constructor() {
4926
5165
  this.slotReleaseDueFrameDepth = 0;
@@ -4949,7 +5188,7 @@ var OIMSlotReleaseManualDueFramePolicy = class {
4949
5188
  }
4950
5189
  };
4951
5190
 
4952
- // src/engine/collector/OIMSlotAfterIdleReleasePolicy.ts
5191
+ // src/collector/OIMSlotAfterIdleReleasePolicy.ts
4953
5192
  var OIMSlotAfterIdleReleasePolicy = class {
4954
5193
  constructor(options) {
4955
5194
  this.releasesWrittenSlots = true;
@@ -4980,7 +5219,7 @@ var OIMSlotAfterIdleReleasePolicy = class {
4980
5219
  }
4981
5220
  };
4982
5221
 
4983
- // src/engine/collector/OIMSlotNeverReleasePolicy.ts
5222
+ // src/collector/OIMSlotNeverReleasePolicy.ts
4984
5223
  var _OIMSlotNeverReleasePolicy = class _OIMSlotNeverReleasePolicy {
4985
5224
  constructor() {
4986
5225
  this.releasesWrittenSlots = false;
@@ -5008,7 +5247,7 @@ var _OIMSlotNeverReleasePolicy = class _OIMSlotNeverReleasePolicy {
5008
5247
  _OIMSlotNeverReleasePolicy.INSTANCE = new _OIMSlotNeverReleasePolicy();
5009
5248
  var OIMSlotNeverReleasePolicy = _OIMSlotNeverReleasePolicy;
5010
5249
 
5011
- // src/engine/collector/OIMSlotAfterUnholdReleasePolicy.ts
5250
+ // src/collector/OIMSlotAfterUnholdReleasePolicy.ts
5012
5251
  var OIMSlotAfterUnholdReleasePolicy = class {
5013
5252
  constructor(options) {
5014
5253
  this.releasesWrittenSlots = true;
@@ -5035,7 +5274,7 @@ var OIMSlotAfterUnholdReleasePolicy = class {
5035
5274
  }
5036
5275
  };
5037
5276
 
5038
- // src/engine/collector/OIMSlotEarliestReleasePolicy.ts
5277
+ // src/collector/OIMSlotEarliestReleasePolicy.ts
5039
5278
  var askOnSlotIdle = (slotReleasePolicy, slot) => slotReleasePolicy.onSlotIdle(slot);
5040
5279
  var askIsSlotReleasable = (slotReleasePolicy, slot) => slotReleasePolicy.isSlotReleasable(slot);
5041
5280
  var askIsEmptySlotReleasable = (slotReleasePolicy, slot) => slotReleasePolicy.isEmptySlotReleasable(slot);
@@ -5082,13 +5321,13 @@ var OIMSlotEarliestReleasePolicy = class {
5082
5321
  }
5083
5322
  };
5084
5323
 
5085
- // src/engine/store/OIMSlotTreeStoreService.ts
5324
+ // src/store/OIMSlotTreeStoreService.ts
5086
5325
  var OIMSlotTreeStoreService = class {
5087
5326
  constructor(keyTreeWalk) {
5088
5327
  this.keyTreeWalk = keyTreeWalk;
5089
5328
  }
5090
5329
  createStore() {
5091
- return { root: { childNodes: void 0, atThisKey: void 0 }, slots: /* @__PURE__ */ new Set() };
5330
+ return { rootCompositeKeyNode: { childNodes: void 0, atThisKey: void 0 }, slots: /* @__PURE__ */ new Set() };
5092
5331
  }
5093
5332
  ownKey(compositeKey) {
5094
5333
  return compositeKey.slice();
@@ -5097,17 +5336,17 @@ var OIMSlotTreeStoreService = class {
5097
5336
  return oimSameKeySequence(compositeKey, otherCompositeKey);
5098
5337
  }
5099
5338
  get(slotStoreTree, compositeKey) {
5100
- return this.keyTreeWalk.nodeAt(slotStoreTree.root, compositeKey)?.atThisKey;
5339
+ return this.keyTreeWalk.nodeAt(slotStoreTree.rootCompositeKeyNode, compositeKey)?.atThisKey;
5101
5340
  }
5102
5341
  set(slotStoreTree, compositeKey, slot) {
5103
- const compositeKeyNode = this.keyTreeWalk.mintNodeAt(slotStoreTree.root, compositeKey);
5342
+ const compositeKeyNode = this.keyTreeWalk.mintNodeAt(slotStoreTree.rootCompositeKeyNode, compositeKey);
5104
5343
  const filedSlot = compositeKeyNode.atThisKey;
5105
5344
  if (filedSlot !== void 0 && filedSlot !== slot) slotStoreTree.slots.delete(filedSlot);
5106
5345
  compositeKeyNode.atThisKey = slot;
5107
5346
  slotStoreTree.slots.add(slot);
5108
5347
  }
5109
5348
  remove(slotStoreTree, compositeKey) {
5110
- const slot = this.keyTreeWalk.deleteKey(slotStoreTree.root, compositeKey);
5349
+ const slot = this.keyTreeWalk.deleteKey(slotStoreTree.rootCompositeKeyNode, compositeKey);
5111
5350
  if (slot !== void 0) slotStoreTree.slots.delete(slot);
5112
5351
  }
5113
5352
  fileSlot(slotStoreTree, slot) {
@@ -5124,10 +5363,100 @@ var OIMSlotTreeStoreService = class {
5124
5363
  }
5125
5364
  };
5126
5365
 
5127
- // src/engine/bucket/commands/constants/OIM_MAX_DIFF_SCRATCH_SLOTS.ts
5366
+ // src/key/OIMKeyTreeWalk.ts
5367
+ var OIMKeyTreeWalk = class {
5368
+ mintNodeAt(rootCompositeKeyNode, compositeKey) {
5369
+ if (compositeKey.length === 0) throw new Error("OIMKeyTreeWalk: an empty key is not a key.");
5370
+ let compositeKeyNode = rootCompositeKeyNode;
5371
+ let firstMintedDepth = -1;
5372
+ let parentOfFirstMintedCompositeKeyNode = rootCompositeKeyNode;
5373
+ for (let i = 0; i < compositeKey.length; i++) {
5374
+ const compositeKeyPart = compositeKey[i];
5375
+ let nextCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKeyPart);
5376
+ if (nextCompositeKeyNode === void 0) {
5377
+ try {
5378
+ this.holdCompositeKeyPart(compositeKeyPart);
5379
+ } catch (failure) {
5380
+ if (firstMintedDepth >= 0) {
5381
+ parentOfFirstMintedCompositeKeyNode.childNodes?.delete(compositeKey[firstMintedDepth]);
5382
+ for (let j = i - 1; j >= firstMintedDepth; j--) this.unholdCompositeKeyPart(compositeKey[j]);
5383
+ }
5384
+ throw failure;
5385
+ }
5386
+ nextCompositeKeyNode = { childNodes: void 0, atThisKey: void 0 };
5387
+ (compositeKeyNode.childNodes ?? (compositeKeyNode.childNodes = /* @__PURE__ */ new Map())).set(compositeKeyPart, nextCompositeKeyNode);
5388
+ if (firstMintedDepth < 0) {
5389
+ firstMintedDepth = i;
5390
+ parentOfFirstMintedCompositeKeyNode = compositeKeyNode;
5391
+ }
5392
+ }
5393
+ compositeKeyNode = nextCompositeKeyNode;
5394
+ }
5395
+ return compositeKeyNode;
5396
+ }
5397
+ nodeAt(rootCompositeKeyNode, compositeKey) {
5398
+ let compositeKeyNode = rootCompositeKeyNode;
5399
+ for (let i = 0; i < compositeKey.length; i++) {
5400
+ compositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[i]);
5401
+ if (compositeKeyNode === void 0) return void 0;
5402
+ }
5403
+ return compositeKeyNode;
5404
+ }
5405
+ deleteKey(rootCompositeKeyNode, compositeKey) {
5406
+ const lastDepth = compositeKey.length - 1;
5407
+ if (lastDepth < 0) return void 0;
5408
+ let compositeKeyNode = rootCompositeKeyNode;
5409
+ let keptCompositeKeyNode = rootCompositeKeyNode;
5410
+ let firstUnlinkedDepth = 0;
5411
+ for (let i = 0; i < lastDepth; i++) {
5412
+ const nextCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[i]);
5413
+ if (nextCompositeKeyNode === void 0) return void 0;
5414
+ compositeKeyNode = nextCompositeKeyNode;
5415
+ if (compositeKeyNode.atThisKey !== void 0 || (compositeKeyNode.childNodes?.size ?? 0) > 1) {
5416
+ keptCompositeKeyNode = compositeKeyNode;
5417
+ firstUnlinkedDepth = i + 1;
5418
+ }
5419
+ }
5420
+ const lastCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[lastDepth]);
5421
+ if (lastCompositeKeyNode === void 0) return void 0;
5422
+ const deletedAtKey = lastCompositeKeyNode.atThisKey;
5423
+ if (deletedAtKey === void 0) return void 0;
5424
+ lastCompositeKeyNode.atThisKey = void 0;
5425
+ if ((lastCompositeKeyNode.childNodes?.size ?? 0) > 0) return deletedAtKey;
5426
+ keptCompositeKeyNode.childNodes?.delete(compositeKey[firstUnlinkedDepth]);
5427
+ for (let i = lastDepth; i >= firstUnlinkedDepth; i--) this.unholdCompositeKeyPart(compositeKey[i]);
5428
+ return deletedAtKey;
5429
+ }
5430
+ };
5431
+
5432
+ // src/key/OIMCompositeKeyTreeWalk.ts
5433
+ var _OIMCompositeKeyTreeWalk = class _OIMCompositeKeyTreeWalk extends OIMKeyTreeWalk {
5434
+ holdCompositeKeyPart(entitySlot) {
5435
+ entitySlot.owner.holdSlot(entitySlot);
5436
+ }
5437
+ unholdCompositeKeyPart(entitySlot) {
5438
+ oimUnholdSlotIfAlive(entitySlot);
5439
+ }
5440
+ };
5441
+ _OIMCompositeKeyTreeWalk.INSTANCE = new _OIMCompositeKeyTreeWalk();
5442
+ var OIMCompositeKeyTreeWalk = _OIMCompositeKeyTreeWalk;
5443
+
5444
+ // src/key/OIMScalarKeyTreeWalk.ts
5445
+ var _OIMScalarKeyTreeWalk = class _OIMScalarKeyTreeWalk extends OIMKeyTreeWalk {
5446
+ holdCompositeKeyPart() {
5447
+ return;
5448
+ }
5449
+ unholdCompositeKeyPart() {
5450
+ return;
5451
+ }
5452
+ };
5453
+ _OIMScalarKeyTreeWalk.INSTANCE = new _OIMScalarKeyTreeWalk();
5454
+ var OIMScalarKeyTreeWalk = _OIMScalarKeyTreeWalk;
5455
+
5456
+ // src/bucket/commands/constants/OIM_MAX_DIFF_SCRATCH_SLOTS.ts
5128
5457
  var OIM_MAX_DIFF_SCRATCH_SLOTS = 4096;
5129
5458
 
5130
- // src/engine/bucket/commands/utils/oimOrderedListCommandsOfTransition.ts
5459
+ // src/bucket/commands/utils/oimOrderedListCommandsOfTransition.ts
5131
5460
  var indexInNext = /* @__PURE__ */ new Map();
5132
5461
  var occurrenceAfter = new Int32Array(0);
5133
5462
  var removedPrevIndices = new Int32Array(0);
@@ -5239,7 +5568,6 @@ export {
5239
5568
  OIMCompositeKeyTreeWalk,
5240
5569
  OIMComputedService,
5241
5570
  OIMComputedValueService,
5242
- OIMContentChangeListenerService,
5243
5571
  OIMDB,
5244
5572
  OIMDefaultValue,
5245
5573
  OIMDefaults,
@@ -5255,17 +5583,22 @@ export {
5255
5583
  OIMScalarKeyTreeWalk,
5256
5584
  OIMSingleComputedService,
5257
5585
  OIMSingleSlotService,
5586
+ OIMSingleSlotStoreAggregate,
5258
5587
  OIMSingleSlotStoreService,
5588
+ OIMSingleSourceTrackingComputedService,
5259
5589
  OIMSlotAfterIdleReleasePolicy,
5260
5590
  OIMSlotAfterUnholdReleasePolicy,
5261
5591
  OIMSlotAfterWriteReleasePolicy,
5262
5592
  OIMSlotAtEmptyReleasePolicy,
5263
5593
  OIMSlotAtUnholdReleasePolicy,
5264
5594
  OIMSlotCollectionIndexService,
5595
+ OIMSlotCollectionIndexStoreAggregate,
5265
5596
  OIMSlotCollectionService,
5266
5597
  OIMSlotCollectionSortedArrayIndexService,
5598
+ OIMSlotCollectionStoreAggregate,
5267
5599
  OIMSlotContentArrayBucketService,
5268
5600
  OIMSlotContentBucketService,
5601
+ OIMSlotContentChangeListenerService,
5269
5602
  OIMSlotContentEntityService,
5270
5603
  OIMSlotContentPositionalArrayBucketService,
5271
5604
  OIMSlotContentSetBucketService,
@@ -5281,10 +5614,13 @@ export {
5281
5614
  OIMSlotTreeStoreService,
5282
5615
  OIMSlotWheel,
5283
5616
  OIMSortedComputedService,
5617
+ OIMSourceTrackingComputedService,
5284
5618
  OIMThrowAtOnceErrorPolicy,
5285
5619
  OIMUnusedSlotCollectorService,
5286
5620
  OIMWritableSingleSlotService,
5621
+ OIMWritableSingleSlotStoreAggregate,
5287
5622
  OIMWritableSlotCollectionService,
5623
+ OIMWritableSlotCollectionStoreAggregate,
5288
5624
  OIM_FROZEN_EMPTY_SLOTS,
5289
5625
  OIM_NOTHING_WAS_INSERTED,
5290
5626
  OIM_NOTHING_WAS_REMOVED,
@@ -5294,17 +5630,24 @@ export {
5294
5630
  createOIMChannelSlot,
5295
5631
  createOIMCollectorSlot,
5296
5632
  createOIMComputedService,
5297
- createOIMEntityWriterInPlace,
5298
- createOIMEntityWriterReplacing,
5633
+ createOIMInPlaceEntityWriter,
5634
+ createOIMReplacingEntityWriter,
5299
5635
  createOIMSingleComputedService,
5300
5636
  createOIMSingleSlotService,
5637
+ createOIMSingleSlotStoreAggregate,
5638
+ createOIMSingleSourceTrackingComputedService,
5301
5639
  createOIMSlotCollectionIndexService,
5302
5640
  createOIMSlotCollectionService,
5303
5641
  createOIMSlotCollectionSortedArrayIndexService,
5642
+ createOIMSlotCollectionStoreAggregate,
5304
5643
  createOIMSlotContentEntityService,
5305
5644
  createOIMSortedComputedService,
5645
+ createOIMSourceTrackingComputedService,
5306
5646
  createOIMUnusedSlotCollectorSlot,
5307
5647
  oimColumnsComparator,
5648
+ oimGuardedPatchEntityColumn,
5649
+ oimGuardedPatchEntityColumns,
5650
+ oimGuardedPutEntityColumns,
5308
5651
  oimHoldSlots,
5309
5652
  oimInsertEntityWithCopy,
5310
5653
  oimInsertEntityWithSanitizedCopy,
@@ -5317,11 +5660,8 @@ export {
5317
5660
  oimMintAfterWriteSlotReleaseWheel,
5318
5661
  oimOrderedListCommandsOfTransition,
5319
5662
  oimPatchEntityColumn,
5320
- oimPatchEntityColumnGuarded,
5321
5663
  oimPatchEntityColumns,
5322
- oimPatchEntityColumnsGuarded,
5323
5664
  oimPutEntityColumns,
5324
- oimPutEntityColumnsGuarded,
5325
5665
  oimRefreshSourceComputeds,
5326
5666
  oimSameKeySequence,
5327
5667
  oimSameSlotSequence,