@oimdb/core 4.1.0 → 4.2.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/CHANGELOG.md +47 -0
- package/README.md +164 -161
- package/dist/index.cjs +926 -722
- package/dist/index.d.cts +206 -137
- package/dist/index.d.ts +206 -137
- package/dist/index.js +916 -716
- package/llms.txt +314 -275
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
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/
|
|
36
|
+
// src/slot/constants/OIM_SLOT_FLAG_RELEASED.ts
|
|
37
37
|
var OIM_SLOT_FLAG_RELEASED = 2;
|
|
38
38
|
|
|
39
|
-
// src/
|
|
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/
|
|
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/
|
|
90
|
+
// src/channel/constants/OIM_REVISIONS_PER_EPOCH.ts
|
|
91
91
|
var OIM_REVISIONS_PER_EPOCH = 2 ** 30;
|
|
92
92
|
|
|
93
|
-
// src/
|
|
93
|
+
// src/channel/utils/oimIsRevisionAfter.ts
|
|
94
94
|
function oimIsRevisionAfter(revision, epoch, sinceRevision, sinceEpoch) {
|
|
95
|
-
if (epoch !== sinceEpoch) return epoch >
|
|
95
|
+
if (epoch !== sinceEpoch) return (epoch - sinceEpoch | 0) > 0;
|
|
96
96
|
return revision > sinceRevision;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// src/
|
|
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
|
|
164
|
-
const
|
|
163
|
+
const effects = slot.effects;
|
|
164
|
+
const editableSlot = slot;
|
|
165
165
|
const effectChannelQueue = channelSlot.effectChannelQueue;
|
|
166
166
|
let owesAFrame = false;
|
|
167
|
-
if (
|
|
168
|
-
const owed =
|
|
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
|
|
171
|
-
if (
|
|
170
|
+
const effect = effects[i];
|
|
171
|
+
if (effect.effectService.markEffectRunScheduled(effect, false)) effectChannelQueue.enqueueEntry(effect);
|
|
172
172
|
}
|
|
173
173
|
owesAFrame = true;
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
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/
|
|
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/
|
|
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/
|
|
466
|
+
// src/slot/constants/OIM_SLOT_FLAG_EMPTY.ts
|
|
471
467
|
var OIM_SLOT_FLAG_EMPTY = 1;
|
|
472
468
|
|
|
473
|
-
// src/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
512
|
-
const subscribers =
|
|
507
|
+
const editableSlot = slot;
|
|
508
|
+
const subscribers = editableSlot.effects ?? (editableSlot.effects = []);
|
|
513
509
|
subscribers.push(effect);
|
|
514
|
-
(
|
|
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/
|
|
557
|
+
// src/column/constants/OIM_COLUMN_GROUP_KEY_SEPARATOR.ts
|
|
562
558
|
var OIM_COLUMN_GROUP_KEY_SEPARATOR = "\0";
|
|
563
559
|
|
|
564
|
-
// src/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
690
|
-
const columnSlotStore =
|
|
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/
|
|
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/
|
|
815
|
-
function
|
|
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/
|
|
818
|
+
// src/computed/constants/OIM_FROZEN_EMPTY_COMPUTED_SLOTS.ts
|
|
823
819
|
var OIM_FROZEN_EMPTY_COMPUTED_SLOTS = Object.freeze([]);
|
|
824
820
|
|
|
825
|
-
// src/
|
|
826
|
-
function createOIMComputedSlot(key, owner, computedValueService, initialValue, storeSlot
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
878
|
+
const editableComputedSlot = computedSlot;
|
|
882
879
|
oimRefreshSourceComputeds(computedSlot.sourceComputeds);
|
|
883
880
|
if (computedSlot.ranAtRevision !== -1 && !oimHasSourceChangedSinceLastRun(computedSlot)) {
|
|
884
|
-
|
|
885
|
-
|
|
881
|
+
editableComputedSlot.checkedAtRevision = channelClock.revision;
|
|
882
|
+
editableComputedSlot.checkedAtEpoch = channelClock.epoch;
|
|
886
883
|
return;
|
|
887
884
|
}
|
|
888
|
-
|
|
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
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
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
|
|
909
|
-
if (!oimIsRevisionAfter(
|
|
910
|
-
newestSourceRevision =
|
|
911
|
-
newestSourceEpoch =
|
|
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
|
-
|
|
914
|
-
|
|
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/
|
|
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(
|
|
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 =
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
1008
|
-
var
|
|
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/
|
|
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/
|
|
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/
|
|
1115
|
-
var
|
|
1130
|
+
// src/computed/OIMSourceTracker.ts
|
|
1131
|
+
var OIMSourceTracker = class {
|
|
1116
1132
|
constructor() {
|
|
1117
|
-
this.
|
|
1118
|
-
this.
|
|
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.
|
|
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.
|
|
1147
|
+
(this.computedSourceList ?? (this.computedSourceList = new OIMSourceList())).trackSource(computedSlot);
|
|
1130
1148
|
return value;
|
|
1131
1149
|
}
|
|
1132
1150
|
openSourceTracking() {
|
|
1133
|
-
this.
|
|
1134
|
-
this.
|
|
1151
|
+
this.slotSourceList.openSourceTracking();
|
|
1152
|
+
this.computedSourceList?.openSourceTracking();
|
|
1135
1153
|
this.isTrackedAllRootSlotsChanged = false;
|
|
1136
1154
|
}
|
|
1137
1155
|
closeSourceTracking() {
|
|
1138
|
-
const isSourceSlotsChanged = this.
|
|
1139
|
-
const isSourceComputedsChanged = this.
|
|
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.
|
|
1178
|
+
return this.slotSourceList.getTrackedSources();
|
|
1146
1179
|
}
|
|
1147
1180
|
getTrackedSourceComputeds() {
|
|
1148
|
-
return this.
|
|
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.
|
|
1155
|
-
this.
|
|
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.
|
|
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/
|
|
1216
|
+
// src/effect/constants/OIM_EFFECT_FLAG_DISPOSED.ts
|
|
1178
1217
|
var OIM_EFFECT_FLAG_DISPOSED = 2;
|
|
1179
1218
|
|
|
1180
|
-
// src/
|
|
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/
|
|
1224
|
+
// src/effect/constants/OIM_EFFECT_FLAG_RUN_SCHEDULED.ts
|
|
1186
1225
|
var OIM_EFFECT_FLAG_RUN_SCHEDULED = 1;
|
|
1187
1226
|
|
|
1188
|
-
// src/
|
|
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/
|
|
1230
|
+
// src/effect/OIMEffectService.ts
|
|
1192
1231
|
var _OIMEffectService = class _OIMEffectService {
|
|
1193
|
-
createEffect(channelMap, sourceSlots, sourceComputeds,
|
|
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
|
-
|
|
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,
|
|
1237
|
-
const effect = this.createEffect(channelMap, sourceSlots, sourceComputeds,
|
|
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
|
-
|
|
1243
|
-
const effect = this.createEffect(channelMap, sourceSlots, sourceComputeds,
|
|
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
|
-
|
|
1253
|
-
const
|
|
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
|
-
|
|
1326
|
+
return {
|
|
1257
1327
|
effectService: this,
|
|
1258
1328
|
channelSlot,
|
|
1259
|
-
sourceSlots:
|
|
1260
|
-
sourceComputeds:
|
|
1261
|
-
allRootSlots:
|
|
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
|
|
1268
|
-
cleanup: void 0
|
|
1337
|
+
body,
|
|
1338
|
+
cleanup: void 0,
|
|
1339
|
+
sourceTracker
|
|
1269
1340
|
};
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
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 (
|
|
1301
|
-
|
|
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
|
-
|
|
1344
|
-
|
|
1345
|
-
const undo =
|
|
1418
|
+
runSourceTrackingEffectBody(effect, sourceTracker, sourceTrackingEffectBody) {
|
|
1419
|
+
sourceTracker.openSourceTracking();
|
|
1420
|
+
const undo = sourceTrackingEffectBody(sourceTracker);
|
|
1346
1421
|
try {
|
|
1347
|
-
if (
|
|
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,
|
|
1430
|
+
resubscribeToTrackedSources(effect, sourceTracker) {
|
|
1356
1431
|
const committedAllRootSlots = effect.allRootSlots;
|
|
1357
1432
|
const committedSourceComputeds = effect.sourceComputeds;
|
|
1358
|
-
const trackedAllRootSlots =
|
|
1359
|
-
const trackedSourceComputeds =
|
|
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
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
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/
|
|
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/
|
|
1444
|
-
var
|
|
1523
|
+
// src/slot/OIMSlotContentChangeListenerService.ts
|
|
1524
|
+
var _OIMSlotContentChangeListenerService = class _OIMSlotContentChangeListenerService {
|
|
1445
1525
|
addContentChangeListener(storeSlot, listener, readColumnNames) {
|
|
1446
|
-
const
|
|
1447
|
-
if (
|
|
1448
|
-
|
|
1449
|
-
|
|
1526
|
+
const editableStoreSlot = storeSlot;
|
|
1527
|
+
if (editableStoreSlot.contentChangeListeners === void 0) {
|
|
1528
|
+
editableStoreSlot.contentChangeListeners = [];
|
|
1529
|
+
editableStoreSlot.contentChangeListenerReadColumnNames = [];
|
|
1450
1530
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
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
|
-
|
|
1489
|
-
var
|
|
1568
|
+
_OIMSlotContentChangeListenerService.INSTANCE = new _OIMSlotContentChangeListenerService();
|
|
1569
|
+
var OIMSlotContentChangeListenerService = _OIMSlotContentChangeListenerService;
|
|
1490
1570
|
|
|
1491
|
-
// src/
|
|
1571
|
+
// src/slot/utils/oimGetChannelSlot.ts
|
|
1492
1572
|
function oimGetChannelSlot(slot) {
|
|
1493
1573
|
return slot.storeSlot.channelSlot;
|
|
1494
1574
|
}
|
|
1495
1575
|
|
|
1496
|
-
// src/
|
|
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/
|
|
1525
|
-
var
|
|
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
|
|
1534
|
-
if (
|
|
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
|
|
1541
|
-
(
|
|
1542
|
-
|
|
1543
|
-
(
|
|
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].
|
|
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
|
-
|
|
1582
|
-
var
|
|
1667
|
+
_OIMSlotContentChangeDeliveryService.INSTANCE = new _OIMSlotContentChangeDeliveryService();
|
|
1668
|
+
var OIMSlotContentChangeDeliveryService = _OIMSlotContentChangeDeliveryService;
|
|
1583
1669
|
|
|
1584
|
-
// src/
|
|
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/
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1747
|
-
|
|
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
|
-
|
|
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/
|
|
1829
|
+
// src/slot/utils/createOIMStoreSlot.ts
|
|
1758
1830
|
function createOIMStoreSlot(store, channelSlot, slotService, sourceStoreSlot) {
|
|
1759
1831
|
return {
|
|
1760
1832
|
store,
|
|
@@ -1791,7 +1863,7 @@ function createOIMStoreSlot(store, channelSlot, slotService, sourceStoreSlot) {
|
|
|
1791
1863
|
};
|
|
1792
1864
|
}
|
|
1793
1865
|
|
|
1794
|
-
// src/
|
|
1866
|
+
// src/slot/OIMSlotCollectionService.ts
|
|
1795
1867
|
var OIMSlotCollectionService = class {
|
|
1796
1868
|
constructor(options) {
|
|
1797
1869
|
const slotOwnerService = new OIMSlotOwnerService({ ...options, slotFilingService: options.slotStoreService });
|
|
@@ -1807,17 +1879,17 @@ var OIMSlotCollectionService = class {
|
|
|
1807
1879
|
}
|
|
1808
1880
|
createStoreSlot(channelMap) {
|
|
1809
1881
|
const channelSlot = channelMap.defaultChannelSlot;
|
|
1810
|
-
return this.
|
|
1882
|
+
return this.createStoreSlotOverNewStore((store) => createOIMStoreSlot(store, channelSlot, this));
|
|
1811
1883
|
}
|
|
1812
1884
|
createStoreSlotFrom(sourceStoreSlot) {
|
|
1813
|
-
return this.
|
|
1885
|
+
return this.createStoreSlotOverNewStore((store) => createOIMStoreSlot(
|
|
1814
1886
|
store,
|
|
1815
1887
|
sourceStoreSlot.channelSlot,
|
|
1816
1888
|
this,
|
|
1817
1889
|
sourceStoreSlot
|
|
1818
1890
|
));
|
|
1819
1891
|
}
|
|
1820
|
-
|
|
1892
|
+
createStoreSlotOverNewStore(createStoreSlotLiteral) {
|
|
1821
1893
|
const storeSlot = createStoreSlotLiteral(this.slotStoreService.createStore());
|
|
1822
1894
|
if (this.storeSlotListener !== void 0) this.storeSlotListener.onStoreSlotCreated(storeSlot);
|
|
1823
1895
|
return storeSlot;
|
|
@@ -1851,13 +1923,13 @@ var OIMSlotCollectionService = class {
|
|
|
1851
1923
|
return this.slotStoreService.isSameKey(key, otherKey);
|
|
1852
1924
|
}
|
|
1853
1925
|
openBatch(storeSlot) {
|
|
1854
|
-
|
|
1926
|
+
OIMSlotContentChangeDeliveryService.INSTANCE.openBatch(storeSlot);
|
|
1855
1927
|
}
|
|
1856
1928
|
closeBatch(storeSlot) {
|
|
1857
|
-
|
|
1929
|
+
OIMSlotContentChangeDeliveryService.INSTANCE.closeBatch(storeSlot);
|
|
1858
1930
|
}
|
|
1859
1931
|
writeInBatch(storeSlot, write) {
|
|
1860
|
-
const contentChangeDeliveryService =
|
|
1932
|
+
const contentChangeDeliveryService = OIMSlotContentChangeDeliveryService.INSTANCE;
|
|
1861
1933
|
contentChangeDeliveryService.openBatch(storeSlot);
|
|
1862
1934
|
try {
|
|
1863
1935
|
return write();
|
|
@@ -1878,7 +1950,7 @@ var OIMSlotCollectionService = class {
|
|
|
1878
1950
|
}
|
|
1879
1951
|
};
|
|
1880
1952
|
|
|
1881
|
-
// src/
|
|
1953
|
+
// src/slot/OIMWritableSlotCollectionService.ts
|
|
1882
1954
|
var OIMWritableSlotCollectionService = class extends OIMSlotCollectionService {
|
|
1883
1955
|
writeSlotContentByKey(storeSlot, key, content, changedSlots) {
|
|
1884
1956
|
const filed = this.slotStoreService.get(storeSlot.store, key);
|
|
@@ -1892,7 +1964,7 @@ var OIMWritableSlotCollectionService = class extends OIMSlotCollectionService {
|
|
|
1892
1964
|
}
|
|
1893
1965
|
};
|
|
1894
1966
|
|
|
1895
|
-
// src/
|
|
1967
|
+
// src/slot/OIMSingleSlotService.ts
|
|
1896
1968
|
var OIMSingleSlotService = class {
|
|
1897
1969
|
constructor(options) {
|
|
1898
1970
|
const slotOwnerService = new OIMSlotOwnerService({ ...options, slotFilingService: options.slotStoreService });
|
|
@@ -1943,7 +2015,7 @@ var OIMSingleSlotService = class {
|
|
|
1943
2015
|
}
|
|
1944
2016
|
};
|
|
1945
2017
|
|
|
1946
|
-
// src/
|
|
2018
|
+
// src/slot/OIMWritableSingleSlotService.ts
|
|
1947
2019
|
var OIMWritableSingleSlotService = class extends OIMSingleSlotService {
|
|
1948
2020
|
writeSingleSlotContent(storeSlot, content, changedSlots) {
|
|
1949
2021
|
const filed = this.slotStoreService.getSingleSlot(storeSlot.store);
|
|
@@ -1961,7 +2033,7 @@ var OIMWritableSingleSlotService = class extends OIMSingleSlotService {
|
|
|
1961
2033
|
}
|
|
1962
2034
|
};
|
|
1963
2035
|
|
|
1964
|
-
// src/
|
|
2036
|
+
// src/entity/OIMSlotEntityPresenceEmptinessPolicy.ts
|
|
1965
2037
|
var _OIMSlotEntityPresenceEmptinessPolicy = class _OIMSlotEntityPresenceEmptinessPolicy {
|
|
1966
2038
|
isEmpty(entitySlot) {
|
|
1967
2039
|
return entitySlot.entity === void 0;
|
|
@@ -1970,8 +2042,8 @@ var _OIMSlotEntityPresenceEmptinessPolicy = class _OIMSlotEntityPresenceEmptines
|
|
|
1970
2042
|
_OIMSlotEntityPresenceEmptinessPolicy.INSTANCE = new _OIMSlotEntityPresenceEmptinessPolicy();
|
|
1971
2043
|
var OIMSlotEntityPresenceEmptinessPolicy = _OIMSlotEntityPresenceEmptinessPolicy;
|
|
1972
2044
|
|
|
1973
|
-
// src/
|
|
1974
|
-
function createOIMEntitySlot(key, owner, storeSlot
|
|
2045
|
+
// src/entity/utils/createOIMEntitySlot.ts
|
|
2046
|
+
function createOIMEntitySlot(key, owner, storeSlot) {
|
|
1975
2047
|
return {
|
|
1976
2048
|
effects: void 0,
|
|
1977
2049
|
changedAtRevision: 0,
|
|
@@ -1992,8 +2064,8 @@ function createOIMEntitySlot(key, owner, storeSlot = void 0) {
|
|
|
1992
2064
|
};
|
|
1993
2065
|
}
|
|
1994
2066
|
|
|
1995
|
-
// src/
|
|
1996
|
-
function
|
|
2067
|
+
// src/entity/utils/createOIMEntityContentSlot.ts
|
|
2068
|
+
function createOIMEntityContentSlot(owner, storeSlot) {
|
|
1997
2069
|
const singleEntitySlot = {
|
|
1998
2070
|
effects: void 0,
|
|
1999
2071
|
changedAtRevision: 0,
|
|
@@ -2015,7 +2087,15 @@ function createOIMSingleEntitySlot(owner, storeSlot) {
|
|
|
2015
2087
|
return singleEntitySlot;
|
|
2016
2088
|
}
|
|
2017
2089
|
|
|
2018
|
-
// src/
|
|
2090
|
+
// src/slot/utils/oimAssertSlotUnheld.ts
|
|
2091
|
+
var oimAssertSlotUnheld = (slot) => {
|
|
2092
|
+
if (slot.holdCount === 0) return;
|
|
2093
|
+
throw new Error(
|
|
2094
|
+
"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."
|
|
2095
|
+
);
|
|
2096
|
+
};
|
|
2097
|
+
|
|
2098
|
+
// src/entity/OIMSlotContentEntityService.ts
|
|
2019
2099
|
var OIMSlotContentEntityService = class {
|
|
2020
2100
|
constructor(options) {
|
|
2021
2101
|
this.entityWriter = options.entityWriter;
|
|
@@ -2026,7 +2106,7 @@ var OIMSlotContentEntityService = class {
|
|
|
2026
2106
|
return createOIMEntitySlot(key, slotOwner, storeSlot);
|
|
2027
2107
|
}
|
|
2028
2108
|
createSingleSlot(storeSlot, slotOwner) {
|
|
2029
|
-
return
|
|
2109
|
+
return createOIMEntityContentSlot(slotOwner, storeSlot);
|
|
2030
2110
|
}
|
|
2031
2111
|
isSlotEmpty(entitySlot) {
|
|
2032
2112
|
return this.slotEmptinessPolicy.isEmpty(entitySlot);
|
|
@@ -2168,7 +2248,7 @@ var OIMSlotContentEntityService = class {
|
|
|
2168
2248
|
slotOwnerService.assertWritable(entitySlot);
|
|
2169
2249
|
const channelSlot = oimGetChannelSlot(entitySlot);
|
|
2170
2250
|
if (!this.isOnFastPath(entitySlot)) {
|
|
2171
|
-
this.
|
|
2251
|
+
this.clearEntityAndMarkColumns(entitySlot);
|
|
2172
2252
|
slotOwnerService.settleEmptiness(entitySlot, this.slotEmptinessPolicy.isEmpty(entitySlot));
|
|
2173
2253
|
slotOwnerService.dispatchContentChange(entitySlot);
|
|
2174
2254
|
slotOwnerService.releaseSlotIfUnheldAfterListeners(entitySlot);
|
|
@@ -2231,9 +2311,12 @@ var OIMSlotContentEntityService = class {
|
|
|
2231
2311
|
slotOwnerService.releaseSlotIfUnheldAfterListeners(entitySlot);
|
|
2232
2312
|
}
|
|
2233
2313
|
releaseSlotContent(entitySlot) {
|
|
2314
|
+
oimAssertSlotUnheld(entitySlot);
|
|
2315
|
+
this.clearEntityAndMarkColumns(entitySlot);
|
|
2316
|
+
}
|
|
2317
|
+
clearEntityAndMarkColumns(entitySlot) {
|
|
2234
2318
|
const entity = entitySlot.entity;
|
|
2235
2319
|
if (entity === void 0) return;
|
|
2236
|
-
this.slotOwnerServiceOf(entitySlot).assertWritable(entitySlot);
|
|
2237
2320
|
this.entityWriter.clearEntity(entitySlot);
|
|
2238
2321
|
this.dispatchColumnsChanged(entitySlot, entity, void 0);
|
|
2239
2322
|
}
|
|
@@ -2265,34 +2348,21 @@ var OIMSlotContentEntityService = class {
|
|
|
2265
2348
|
}
|
|
2266
2349
|
};
|
|
2267
2350
|
|
|
2268
|
-
// src/
|
|
2351
|
+
// src/db/OIMDefaultValue.ts
|
|
2269
2352
|
var OIMDefaultValue = class {
|
|
2270
|
-
constructor(
|
|
2353
|
+
constructor(createValue) {
|
|
2271
2354
|
this.defaultValue = void 0;
|
|
2272
|
-
this.isHandedOut = false;
|
|
2273
|
-
this.name = name;
|
|
2274
2355
|
this.createValue = createValue;
|
|
2275
2356
|
}
|
|
2276
2357
|
getValue() {
|
|
2277
|
-
this.isHandedOut = true;
|
|
2278
2358
|
return this.defaultValue ?? (this.defaultValue = this.createValue());
|
|
2279
2359
|
}
|
|
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
2360
|
};
|
|
2291
2361
|
|
|
2292
|
-
// src/
|
|
2293
|
-
var OIM_DEFAULT_STORE_SLOT_LISTENER = /* @__PURE__ */ new OIMDefaultValue(
|
|
2362
|
+
// src/db/constants/OIM_DEFAULT_STORE_SLOT_LISTENER.ts
|
|
2363
|
+
var OIM_DEFAULT_STORE_SLOT_LISTENER = /* @__PURE__ */ new OIMDefaultValue(() => OIMNoStoreSlotListener.INSTANCE);
|
|
2294
2364
|
|
|
2295
|
-
// src/
|
|
2365
|
+
// src/store/OIMSlotMapStoreService.ts
|
|
2296
2366
|
var _OIMSlotMapStoreService = class _OIMSlotMapStoreService {
|
|
2297
2367
|
createStore() {
|
|
2298
2368
|
return /* @__PURE__ */ new Map();
|
|
@@ -2328,16 +2398,32 @@ var _OIMSlotMapStoreService = class _OIMSlotMapStoreService {
|
|
|
2328
2398
|
_OIMSlotMapStoreService.INSTANCE = new _OIMSlotMapStoreService();
|
|
2329
2399
|
var OIMSlotMapStoreService = _OIMSlotMapStoreService;
|
|
2330
2400
|
|
|
2331
|
-
// src/
|
|
2332
|
-
function
|
|
2401
|
+
// src/store/utils/oimResolveSlotStoreService.ts
|
|
2402
|
+
function oimResolveSlotStoreService(slotStoreService) {
|
|
2333
2403
|
return slotStoreService ?? OIMSlotMapStoreService.INSTANCE;
|
|
2334
2404
|
}
|
|
2335
2405
|
|
|
2336
|
-
// src/
|
|
2406
|
+
// src/db/OIMDefaults.ts
|
|
2407
|
+
var _OIMDefaults = class _OIMDefaults {
|
|
2408
|
+
constructor(options = {}) {
|
|
2409
|
+
this.slotStamp = options.slotStamp;
|
|
2410
|
+
this.slotReleasePolicy = options.slotReleasePolicy;
|
|
2411
|
+
this.entityWriter = options.entityWriter;
|
|
2412
|
+
this.entitySlotEmptinessPolicy = options.entitySlotEmptinessPolicy;
|
|
2413
|
+
this.indexKeysService = options.indexKeysService;
|
|
2414
|
+
this.columnSlotStoreService = options.columnSlotStoreService;
|
|
2415
|
+
this.computedColumnSlotStoreService = options.computedColumnSlotStoreService;
|
|
2416
|
+
this.storeSlotListener = options.storeSlotListener;
|
|
2417
|
+
}
|
|
2418
|
+
};
|
|
2419
|
+
_OIMDefaults.INSTANCE = new _OIMDefaults();
|
|
2420
|
+
var OIMDefaults = _OIMDefaults;
|
|
2421
|
+
|
|
2422
|
+
// src/column/OIMPushColumnSlotOwner.ts
|
|
2337
2423
|
var hasValueColumn = (value, columnName) => Object.prototype.hasOwnProperty.call(value, columnName) && value[columnName] !== void 0;
|
|
2338
2424
|
var OIMPushColumnSlotOwner = class extends OIMColumnSlotOwner {
|
|
2339
2425
|
constructor(options) {
|
|
2340
|
-
super(
|
|
2426
|
+
super(oimColumnSlotStoreServiceOfColumnSlotOwnerOptions(options));
|
|
2341
2427
|
}
|
|
2342
2428
|
createColumnSlot(carrierSlot, key) {
|
|
2343
2429
|
return {
|
|
@@ -2351,7 +2437,7 @@ var OIMPushColumnSlotOwner = class extends OIMColumnSlotOwner {
|
|
|
2351
2437
|
releaseDueAfterUnholdMs: -1,
|
|
2352
2438
|
slotFlags: OIM_SLOT_FLAG_EMPTY,
|
|
2353
2439
|
columnSlotStore: void 0,
|
|
2354
|
-
storeSlot:
|
|
2440
|
+
storeSlot: carrierSlot.storeSlot,
|
|
2355
2441
|
owner: this,
|
|
2356
2442
|
key,
|
|
2357
2443
|
carrierSlot
|
|
@@ -2420,51 +2506,51 @@ var OIMPushColumnSlotOwner = class extends OIMColumnSlotOwner {
|
|
|
2420
2506
|
}
|
|
2421
2507
|
};
|
|
2422
2508
|
|
|
2423
|
-
// src/
|
|
2509
|
+
// src/column/utils/createOIMPushColumnSlotOwner.ts
|
|
2424
2510
|
var createOIMPushColumnSlotOwner = (columnSlotOwnerOptions) => new OIMPushColumnSlotOwner(columnSlotOwnerOptions);
|
|
2425
2511
|
|
|
2426
|
-
// src/
|
|
2427
|
-
var OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue(
|
|
2512
|
+
// src/db/constants/OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.ts
|
|
2513
|
+
var OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue(() => OIMSlotMapStoreService.INSTANCE);
|
|
2428
2514
|
|
|
2429
|
-
// src/
|
|
2430
|
-
function
|
|
2515
|
+
// src/column/utils/oimColumnSlotOwnerOptions.ts
|
|
2516
|
+
function oimColumnSlotOwnerOptions(columnSlotOwnerOptions) {
|
|
2431
2517
|
return columnSlotOwnerOptions.columnNames !== void 0 ? { columnNames: columnSlotOwnerOptions.columnNames } : { columnSlotStoreService: columnSlotOwnerOptions.columnSlotStoreService };
|
|
2432
2518
|
}
|
|
2433
2519
|
|
|
2434
|
-
// src/
|
|
2435
|
-
function
|
|
2436
|
-
return
|
|
2520
|
+
// src/column/utils/oimResolveColumnSlotOwnerOptions.ts
|
|
2521
|
+
function oimResolveColumnSlotOwnerOptions(columnSlotStoreService, columnNames, defaultColumnSlotStoreService) {
|
|
2522
|
+
return oimColumnSlotOwnerOptions({ columnNames, columnSlotStoreService: columnSlotStoreService ?? defaultColumnSlotStoreService });
|
|
2437
2523
|
}
|
|
2438
2524
|
|
|
2439
|
-
// src/
|
|
2440
|
-
function
|
|
2525
|
+
// src/slot/utils/oimResolveSlotOwnerServiceOptions.ts
|
|
2526
|
+
function oimResolveSlotOwnerServiceOptions(defaults, options) {
|
|
2441
2527
|
return {
|
|
2442
|
-
slotStamp:
|
|
2443
|
-
slotReleasePolicy: options.slotReleasePolicy ??
|
|
2528
|
+
slotStamp: defaults.slotStamp,
|
|
2529
|
+
slotReleasePolicy: options.slotReleasePolicy ?? defaults.slotReleasePolicy,
|
|
2444
2530
|
slotSubscriptionListener: options.slotSubscriptionListener,
|
|
2445
|
-
columnSlotOwnerOptions:
|
|
2531
|
+
columnSlotOwnerOptions: oimResolveColumnSlotOwnerOptions(
|
|
2446
2532
|
options.columnSlotStoreService,
|
|
2447
2533
|
options.columnNames,
|
|
2448
|
-
OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.getValue()
|
|
2534
|
+
defaults.columnSlotStoreService ?? OIM_DEFAULT_COLUMN_SLOT_STORE_SERVICE.getValue()
|
|
2449
2535
|
),
|
|
2450
2536
|
createColumnSlotOwner: createOIMPushColumnSlotOwner
|
|
2451
2537
|
};
|
|
2452
2538
|
}
|
|
2453
2539
|
|
|
2454
|
-
// src/
|
|
2455
|
-
function createOIMSlotCollectionService(
|
|
2540
|
+
// src/slot/createOIMSlotCollectionService.ts
|
|
2541
|
+
function createOIMSlotCollectionService(options) {
|
|
2456
2542
|
return new OIMWritableSlotCollectionService({
|
|
2457
|
-
...
|
|
2458
|
-
slotStoreService:
|
|
2543
|
+
...oimResolveSlotOwnerServiceOptions(options.defaults ?? OIMDefaults.INSTANCE, options),
|
|
2544
|
+
slotStoreService: oimResolveSlotStoreService(options.slotStoreService),
|
|
2459
2545
|
slotContentService: options.slotContentService,
|
|
2460
|
-
storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
2546
|
+
storeSlotListener: options.defaults?.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
2461
2547
|
});
|
|
2462
2548
|
}
|
|
2463
2549
|
|
|
2464
|
-
// src/
|
|
2550
|
+
// src/slot/constants/OIM_FROZEN_EMPTY_SLOTS.ts
|
|
2465
2551
|
var OIM_FROZEN_EMPTY_SLOTS = Object.freeze([]);
|
|
2466
2552
|
|
|
2467
|
-
// src/
|
|
2553
|
+
// src/store/OIMSingleSlotStoreService.ts
|
|
2468
2554
|
var _OIMSingleSlotStoreService = class _OIMSingleSlotStoreService {
|
|
2469
2555
|
createStore() {
|
|
2470
2556
|
return { slot: void 0 };
|
|
@@ -2489,36 +2575,36 @@ var _OIMSingleSlotStoreService = class _OIMSingleSlotStoreService {
|
|
|
2489
2575
|
_OIMSingleSlotStoreService.INSTANCE = new _OIMSingleSlotStoreService();
|
|
2490
2576
|
var OIMSingleSlotStoreService = _OIMSingleSlotStoreService;
|
|
2491
2577
|
|
|
2492
|
-
// src/
|
|
2493
|
-
function createOIMSingleSlotService(
|
|
2578
|
+
// src/slot/createOIMSingleSlotService.ts
|
|
2579
|
+
function createOIMSingleSlotService(options) {
|
|
2494
2580
|
return new OIMWritableSingleSlotService({
|
|
2495
|
-
...
|
|
2581
|
+
...oimResolveSlotOwnerServiceOptions(options.defaults ?? OIMDefaults.INSTANCE, options),
|
|
2496
2582
|
slotStoreService: OIMSingleSlotStoreService.INSTANCE,
|
|
2497
2583
|
slotContentService: options.slotContentService,
|
|
2498
|
-
storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
2584
|
+
storeSlotListener: options.defaults?.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
2499
2585
|
});
|
|
2500
2586
|
}
|
|
2501
2587
|
|
|
2502
|
-
// src/
|
|
2503
|
-
var
|
|
2588
|
+
// src/db/constants/OIM_DEFAULT_ENTITY_SLOT_EMPTINESS_POLICY.ts
|
|
2589
|
+
var OIM_DEFAULT_ENTITY_SLOT_EMPTINESS_POLICY = /* @__PURE__ */ new OIMDefaultValue(() => OIMSlotEntityPresenceEmptinessPolicy.INSTANCE);
|
|
2504
2590
|
|
|
2505
|
-
// src/
|
|
2591
|
+
// src/entity/utils/oimClearEntity.ts
|
|
2506
2592
|
function oimClearEntity(entitySlot) {
|
|
2507
2593
|
entitySlot.entity = void 0;
|
|
2508
2594
|
}
|
|
2509
2595
|
|
|
2510
|
-
// src/
|
|
2596
|
+
// src/entity/constants/OIM_FROZEN_EMPTY_COLUMN_NAMES.ts
|
|
2511
2597
|
var OIM_FROZEN_EMPTY_COLUMN_NAMES = Object.freeze([]);
|
|
2512
2598
|
|
|
2513
|
-
// src/
|
|
2599
|
+
// src/entity/constants/OIM_PROTO_KEY.ts
|
|
2514
2600
|
var OIM_PROTO_KEY = "__proto__";
|
|
2515
2601
|
|
|
2516
|
-
// src/
|
|
2602
|
+
// src/entity/utils/oimIsProtoKey.ts
|
|
2517
2603
|
function oimIsProtoKey(name) {
|
|
2518
2604
|
return name === OIM_PROTO_KEY;
|
|
2519
2605
|
}
|
|
2520
2606
|
|
|
2521
|
-
// src/
|
|
2607
|
+
// src/entity/utils/oimOwnedColumnNames.ts
|
|
2522
2608
|
function oimOwnedColumnNames(slot, names) {
|
|
2523
2609
|
const entity = slot.entity;
|
|
2524
2610
|
if (entity === void 0) return void 0;
|
|
@@ -2532,12 +2618,12 @@ function oimOwnedColumnNames(slot, names) {
|
|
|
2532
2618
|
return owned;
|
|
2533
2619
|
}
|
|
2534
2620
|
|
|
2535
|
-
// src/
|
|
2621
|
+
// src/entity/utils/oimInsertEntityWithoutCopy.ts
|
|
2536
2622
|
function oimInsertEntityWithoutCopy(slot, entity) {
|
|
2537
2623
|
slot.entity = entity;
|
|
2538
2624
|
}
|
|
2539
2625
|
|
|
2540
|
-
// src/
|
|
2626
|
+
// src/entity/utils/oimPatchEntityColumns.ts
|
|
2541
2627
|
function oimPatchEntityColumns(slot, patch, sameValueGuard, changedColumnNames, targetOf) {
|
|
2542
2628
|
const entity = slot.entity;
|
|
2543
2629
|
if (entity === void 0) return void 0;
|
|
@@ -2551,7 +2637,7 @@ function oimPatchEntityColumns(slot, patch, sameValueGuard, changedColumnNames,
|
|
|
2551
2637
|
return target;
|
|
2552
2638
|
}
|
|
2553
2639
|
|
|
2554
|
-
// src/
|
|
2640
|
+
// src/entity/utils/oimPatchEntityColumn.ts
|
|
2555
2641
|
function oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, targetOf) {
|
|
2556
2642
|
const entity = slot.entity;
|
|
2557
2643
|
if (entity === void 0) return void 0;
|
|
@@ -2562,7 +2648,7 @@ function oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedCo
|
|
|
2562
2648
|
return target;
|
|
2563
2649
|
}
|
|
2564
2650
|
|
|
2565
|
-
// src/
|
|
2651
|
+
// src/entity/utils/oimClearDepartedEntityColumns.ts
|
|
2566
2652
|
function oimClearDepartedEntityColumns(prevColumns, prevEntity, entity, patchedTarget, changedColumnNames, targetOf) {
|
|
2567
2653
|
let target = patchedTarget;
|
|
2568
2654
|
for (const name in prevColumns) {
|
|
@@ -2574,7 +2660,7 @@ function oimClearDepartedEntityColumns(prevColumns, prevEntity, entity, patchedT
|
|
|
2574
2660
|
return target;
|
|
2575
2661
|
}
|
|
2576
2662
|
|
|
2577
|
-
// src/
|
|
2663
|
+
// src/entity/utils/oimPutEntityColumns.ts
|
|
2578
2664
|
function oimPutEntityColumns(slot, entity, sameValueGuard, changedColumnNames, targetOf) {
|
|
2579
2665
|
const prevEntity = slot.entity;
|
|
2580
2666
|
if (prevEntity === void 0) return void 0;
|
|
@@ -2582,8 +2668,8 @@ function oimPutEntityColumns(slot, entity, sameValueGuard, changedColumnNames, t
|
|
|
2582
2668
|
return oimClearDepartedEntityColumns(prevEntity, prevEntity, entity, target, changedColumnNames, targetOf);
|
|
2583
2669
|
}
|
|
2584
2670
|
|
|
2585
|
-
// src/
|
|
2586
|
-
function
|
|
2671
|
+
// src/entity/utils/oimResolveEntityWriterOptions.ts
|
|
2672
|
+
function oimResolveEntityWriterOptions(options) {
|
|
2587
2673
|
return {
|
|
2588
2674
|
sameValueGuard: options?.sameValueGuard ?? oimSameValueZeroGuard,
|
|
2589
2675
|
entityInserter: options?.entityInserter ?? oimInsertEntityWithoutCopy,
|
|
@@ -2593,7 +2679,7 @@ function oimEntityWriterOptionsWithDefault(options) {
|
|
|
2593
2679
|
};
|
|
2594
2680
|
}
|
|
2595
2681
|
|
|
2596
|
-
// src/
|
|
2682
|
+
// src/entity/createOIMInPlaceEntityWriter.ts
|
|
2597
2683
|
var theEntityItself = (entity) => entity;
|
|
2598
2684
|
function deleteColumnsInPlace(slot, names) {
|
|
2599
2685
|
const deleted = oimOwnedColumnNames(slot, names);
|
|
@@ -2602,14 +2688,14 @@ function deleteColumnsInPlace(slot, names) {
|
|
|
2602
2688
|
for (let i = 0; i < deleted.length; i++) entity[deleted[i]] = void 0;
|
|
2603
2689
|
return deleted;
|
|
2604
2690
|
}
|
|
2605
|
-
function
|
|
2691
|
+
function createOIMInPlaceEntityWriter(options) {
|
|
2606
2692
|
const {
|
|
2607
2693
|
sameValueGuard,
|
|
2608
2694
|
entityInserter,
|
|
2609
2695
|
putEntityColumns,
|
|
2610
2696
|
patchEntityColumns,
|
|
2611
2697
|
patchEntityColumn
|
|
2612
|
-
} =
|
|
2698
|
+
} = oimResolveEntityWriterOptions(options);
|
|
2613
2699
|
return {
|
|
2614
2700
|
fillEntity: entityInserter,
|
|
2615
2701
|
clearEntity: oimClearEntity,
|
|
@@ -2620,19 +2706,20 @@ function createOIMEntityWriterInPlace(options) {
|
|
|
2620
2706
|
};
|
|
2621
2707
|
}
|
|
2622
2708
|
|
|
2623
|
-
// src/
|
|
2624
|
-
var OIM_DEFAULT_ENTITY_WRITER = /* @__PURE__ */ new OIMDefaultValue(
|
|
2709
|
+
// src/db/constants/OIM_DEFAULT_ENTITY_WRITER.ts
|
|
2710
|
+
var OIM_DEFAULT_ENTITY_WRITER = /* @__PURE__ */ new OIMDefaultValue(() => createOIMInPlaceEntityWriter());
|
|
2625
2711
|
|
|
2626
|
-
// src/
|
|
2627
|
-
function createOIMSlotContentEntityService(
|
|
2712
|
+
// src/entity/createOIMSlotContentEntityService.ts
|
|
2713
|
+
function createOIMSlotContentEntityService(options = {}) {
|
|
2714
|
+
const defaults = options.defaults ?? OIMDefaults.INSTANCE;
|
|
2628
2715
|
return new OIMSlotContentEntityService({
|
|
2629
|
-
entityWriter: options.entityWriter ??
|
|
2630
|
-
slotEmptinessPolicy: options.slotEmptinessPolicy ??
|
|
2716
|
+
entityWriter: options.entityWriter ?? defaults.entityWriter ?? OIM_DEFAULT_ENTITY_WRITER.getValue(),
|
|
2717
|
+
slotEmptinessPolicy: options.slotEmptinessPolicy ?? defaults.entitySlotEmptinessPolicy ?? OIM_DEFAULT_ENTITY_SLOT_EMPTINESS_POLICY.getValue()
|
|
2631
2718
|
});
|
|
2632
2719
|
}
|
|
2633
2720
|
|
|
2634
|
-
// src/
|
|
2635
|
-
function
|
|
2721
|
+
// src/bucket/utils/createOIMBucketContentSlot.ts
|
|
2722
|
+
function createOIMBucketContentSlot(owner, bucketSlotsStore, storeSlot) {
|
|
2636
2723
|
const singleBucketSlot = {
|
|
2637
2724
|
effects: void 0,
|
|
2638
2725
|
changedAtRevision: 0,
|
|
@@ -2657,7 +2744,7 @@ function createOIMSingleBucketSlot(owner, bucketSlotsStore, storeSlot) {
|
|
|
2657
2744
|
return singleBucketSlot;
|
|
2658
2745
|
}
|
|
2659
2746
|
|
|
2660
|
-
// src/
|
|
2747
|
+
// src/bucket/commands/OIMNoBucketCommands.ts
|
|
2661
2748
|
var _OIMNoBucketCommands = class _OIMNoBucketCommands {
|
|
2662
2749
|
recordInsert() {
|
|
2663
2750
|
return;
|
|
@@ -2675,13 +2762,13 @@ var _OIMNoBucketCommands = class _OIMNoBucketCommands {
|
|
|
2675
2762
|
_OIMNoBucketCommands.INSTANCE = new _OIMNoBucketCommands();
|
|
2676
2763
|
var OIMNoBucketCommands = _OIMNoBucketCommands;
|
|
2677
2764
|
|
|
2678
|
-
// src/
|
|
2765
|
+
// src/bucket/constants/OIM_NOTHING_WAS_REMOVED.ts
|
|
2679
2766
|
var OIM_NOTHING_WAS_REMOVED = -1;
|
|
2680
2767
|
|
|
2681
|
-
// src/
|
|
2768
|
+
// src/bucket/constants/OIM_REMOVED_WITHOUT_A_POSITION.ts
|
|
2682
2769
|
var OIM_REMOVED_WITHOUT_A_POSITION = -2;
|
|
2683
2770
|
|
|
2684
|
-
// src/
|
|
2771
|
+
// src/bucket/utils/createOIMBucketSlot.ts
|
|
2685
2772
|
function createOIMBucketSlot(key, owner, bucketSlotsStore, storeSlot) {
|
|
2686
2773
|
return {
|
|
2687
2774
|
effects: void 0,
|
|
@@ -2706,16 +2793,16 @@ function createOIMBucketSlot(key, owner, bucketSlotsStore, storeSlot) {
|
|
|
2706
2793
|
};
|
|
2707
2794
|
}
|
|
2708
2795
|
|
|
2709
|
-
// src/
|
|
2796
|
+
// src/channel/utils/oimGetChannelQueueAtDepth.ts
|
|
2710
2797
|
function oimGetChannelQueueAtDepth(channelQueues, depth) {
|
|
2711
|
-
const
|
|
2712
|
-
if (
|
|
2713
|
-
const
|
|
2714
|
-
channelQueues[depth] =
|
|
2715
|
-
return
|
|
2798
|
+
const existingChannelQueue = channelQueues[depth];
|
|
2799
|
+
if (existingChannelQueue !== void 0) return existingChannelQueue;
|
|
2800
|
+
const channelQueue = new OIMChannelQueue();
|
|
2801
|
+
channelQueues[depth] = channelQueue;
|
|
2802
|
+
return channelQueue;
|
|
2716
2803
|
}
|
|
2717
2804
|
|
|
2718
|
-
// src/
|
|
2805
|
+
// src/bucket/OIMSlotContentBucketService.ts
|
|
2719
2806
|
var OIMSlotContentBucketService = class {
|
|
2720
2807
|
constructor(options) {
|
|
2721
2808
|
this.bucketCommands = options.bucketCommands ?? OIMNoBucketCommands.INSTANCE;
|
|
@@ -2737,7 +2824,7 @@ var OIMSlotContentBucketService = class {
|
|
|
2737
2824
|
);
|
|
2738
2825
|
}
|
|
2739
2826
|
createSingleSlot(storeSlot, slotOwner) {
|
|
2740
|
-
return
|
|
2827
|
+
return createOIMBucketContentSlot(
|
|
2741
2828
|
slotOwner,
|
|
2742
2829
|
this.createBucketMemberSlotsStore(),
|
|
2743
2830
|
storeSlot
|
|
@@ -2749,11 +2836,9 @@ var OIMSlotContentBucketService = class {
|
|
|
2749
2836
|
hasReference() {
|
|
2750
2837
|
return false;
|
|
2751
2838
|
}
|
|
2752
|
-
releaseSlotContent(bucketSlot
|
|
2753
|
-
|
|
2754
|
-
slotOwnerService.assertWritable(bucketSlot);
|
|
2839
|
+
releaseSlotContent(bucketSlot) {
|
|
2840
|
+
oimAssertSlotUnheld(bucketSlot);
|
|
2755
2841
|
this.unholdAllBucketMemberSlots(bucketSlot);
|
|
2756
|
-
slotOwnerService.dispatchContentChange(bucketSlot);
|
|
2757
2842
|
}
|
|
2758
2843
|
markContentChanged(bucketSlot) {
|
|
2759
2844
|
bucketSlot.owner.assertWritable(bucketSlot);
|
|
@@ -2792,10 +2877,10 @@ var OIMSlotContentBucketService = class {
|
|
|
2792
2877
|
removeBucketMemberSlots(bucketSlot, bucketMemberSlots) {
|
|
2793
2878
|
const slotOwnerService = bucketSlot.owner;
|
|
2794
2879
|
slotOwnerService.assertWritable(bucketSlot);
|
|
2795
|
-
const
|
|
2796
|
-
const writeDepth =
|
|
2797
|
-
const removedChannelQueue = oimGetChannelQueueAtDepth(
|
|
2798
|
-
const removedAtChannelQueue = oimGetChannelQueueAtDepth(
|
|
2880
|
+
const editableStoreSlot = bucketSlot.storeSlot;
|
|
2881
|
+
const writeDepth = editableStoreSlot.writeDepth++;
|
|
2882
|
+
const removedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.departedBucketMemberSlotChannelQueues ?? (editableStoreSlot.departedBucketMemberSlotChannelQueues = []), writeDepth);
|
|
2883
|
+
const removedAtChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.removedAtChannelQueues ?? (editableStoreSlot.removedAtChannelQueues = []), writeDepth);
|
|
2799
2884
|
try {
|
|
2800
2885
|
this.removeSlots(bucketSlot, bucketMemberSlots, removedChannelQueue, removedAtChannelQueue);
|
|
2801
2886
|
const removedCount = removedChannelQueue.getEntryCount();
|
|
@@ -2806,7 +2891,7 @@ var OIMSlotContentBucketService = class {
|
|
|
2806
2891
|
} finally {
|
|
2807
2892
|
removedChannelQueue.keepFirstEntries(0);
|
|
2808
2893
|
removedAtChannelQueue.keepFirstEntries(0);
|
|
2809
|
-
|
|
2894
|
+
editableStoreSlot.writeDepth = writeDepth;
|
|
2810
2895
|
}
|
|
2811
2896
|
}
|
|
2812
2897
|
insertSlotContent(bucketSlot, bucketMemberSlots, changedBucketSlots) {
|
|
@@ -2879,10 +2964,10 @@ var OIMSlotContentBucketService = class {
|
|
|
2879
2964
|
}
|
|
2880
2965
|
reconcileBucketMemberSlots(bucketSlot, bucketMemberSlots) {
|
|
2881
2966
|
this.assertBucketMemberSlotsNotReleased(bucketMemberSlots);
|
|
2882
|
-
const
|
|
2883
|
-
const writeDepth =
|
|
2884
|
-
const arrivedChannelQueue = oimGetChannelQueueAtDepth(
|
|
2885
|
-
const departedChannelQueue = oimGetChannelQueueAtDepth(
|
|
2967
|
+
const editableStoreSlot = bucketSlot.storeSlot;
|
|
2968
|
+
const writeDepth = editableStoreSlot.writeDepth++;
|
|
2969
|
+
const arrivedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.arrivedBucketMemberSlotChannelQueues ?? (editableStoreSlot.arrivedBucketMemberSlotChannelQueues = []), writeDepth);
|
|
2970
|
+
const departedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.departedBucketMemberSlotChannelQueues ?? (editableStoreSlot.departedBucketMemberSlotChannelQueues = []), writeDepth);
|
|
2886
2971
|
try {
|
|
2887
2972
|
this.reconcileSlots(bucketSlot, bucketMemberSlots, arrivedChannelQueue, departedChannelQueue);
|
|
2888
2973
|
const arrivedCount = arrivedChannelQueue.getEntryCount();
|
|
@@ -2898,7 +2983,7 @@ var OIMSlotContentBucketService = class {
|
|
|
2898
2983
|
} finally {
|
|
2899
2984
|
arrivedChannelQueue.keepFirstEntries(0);
|
|
2900
2985
|
departedChannelQueue.keepFirstEntries(0);
|
|
2901
|
-
|
|
2986
|
+
editableStoreSlot.writeDepth = writeDepth;
|
|
2902
2987
|
}
|
|
2903
2988
|
}
|
|
2904
2989
|
drainBucketMemberSlots(bucketSlot) {
|
|
@@ -2908,9 +2993,9 @@ var OIMSlotContentBucketService = class {
|
|
|
2908
2993
|
return true;
|
|
2909
2994
|
}
|
|
2910
2995
|
unholdAllBucketMemberSlots(bucketSlot) {
|
|
2911
|
-
const
|
|
2912
|
-
const writeDepth =
|
|
2913
|
-
const departedChannelQueue = oimGetChannelQueueAtDepth(
|
|
2996
|
+
const editableStoreSlot = bucketSlot.storeSlot;
|
|
2997
|
+
const writeDepth = editableStoreSlot.writeDepth++;
|
|
2998
|
+
const departedChannelQueue = oimGetChannelQueueAtDepth(editableStoreSlot.departedBucketMemberSlotChannelQueues ?? (editableStoreSlot.departedBucketMemberSlotChannelQueues = []), writeDepth);
|
|
2914
2999
|
try {
|
|
2915
3000
|
this.drainSlots(bucketSlot, departedChannelQueue);
|
|
2916
3001
|
const drainedCount = departedChannelQueue.getEntryCount();
|
|
@@ -2918,12 +3003,12 @@ var OIMSlotContentBucketService = class {
|
|
|
2918
3003
|
return drainedCount;
|
|
2919
3004
|
} finally {
|
|
2920
3005
|
departedChannelQueue.keepFirstEntries(0);
|
|
2921
|
-
|
|
3006
|
+
editableStoreSlot.writeDepth = writeDepth;
|
|
2922
3007
|
}
|
|
2923
3008
|
}
|
|
2924
3009
|
};
|
|
2925
3010
|
|
|
2926
|
-
// src/
|
|
3011
|
+
// src/bucket/OIMSlotContentSetBucketService.ts
|
|
2927
3012
|
var OIMSlotContentSetBucketService = class extends OIMSlotContentBucketService {
|
|
2928
3013
|
constructor(options = {}) {
|
|
2929
3014
|
super(options);
|
|
@@ -2978,7 +3063,7 @@ var OIMSlotContentSetBucketService = class extends OIMSlotContentBucketService {
|
|
|
2978
3063
|
}
|
|
2979
3064
|
};
|
|
2980
3065
|
|
|
2981
|
-
// src/
|
|
3066
|
+
// src/bucket/array/OIMBucketMemberSlotsArrayService.ts
|
|
2982
3067
|
var insertionTailLimit = 8;
|
|
2983
3068
|
var _OIMBucketMemberSlotsArrayService = class _OIMBucketMemberSlotsArrayService {
|
|
2984
3069
|
createBucketSlotsArrayStore() {
|
|
@@ -3107,7 +3192,7 @@ function reverseRange(bucketMemberSlots, first, last) {
|
|
|
3107
3192
|
}
|
|
3108
3193
|
}
|
|
3109
3194
|
|
|
3110
|
-
// src/
|
|
3195
|
+
// src/bucket/OIMSlotContentArrayBucketService.ts
|
|
3111
3196
|
var OIMSlotContentArrayBucketService = class extends OIMSlotContentBucketService {
|
|
3112
3197
|
constructor(options) {
|
|
3113
3198
|
super(options);
|
|
@@ -3168,10 +3253,10 @@ var OIMSlotContentArrayBucketService = class extends OIMSlotContentBucketService
|
|
|
3168
3253
|
}
|
|
3169
3254
|
};
|
|
3170
3255
|
|
|
3171
|
-
// src/
|
|
3256
|
+
// src/bucket/constants/OIM_NOTHING_WAS_INSERTED.ts
|
|
3172
3257
|
var OIM_NOTHING_WAS_INSERTED = -1;
|
|
3173
3258
|
|
|
3174
|
-
// src/
|
|
3259
|
+
// src/bucket/array/utils/oimAssertWholePosition.ts
|
|
3175
3260
|
function oimAssertWholePosition(position) {
|
|
3176
3261
|
if (position === Math.trunc(position)) return;
|
|
3177
3262
|
throw new Error(
|
|
@@ -3179,7 +3264,7 @@ function oimAssertWholePosition(position) {
|
|
|
3179
3264
|
);
|
|
3180
3265
|
}
|
|
3181
3266
|
|
|
3182
|
-
// src/
|
|
3267
|
+
// src/bucket/OIMSlotContentPositionalArrayBucketService.ts
|
|
3183
3268
|
var OIMSlotContentPositionalArrayBucketService = class extends OIMSlotContentArrayBucketService {
|
|
3184
3269
|
constructor(options = {}) {
|
|
3185
3270
|
super(options);
|
|
@@ -3252,7 +3337,7 @@ var OIMSlotContentPositionalArrayBucketService = class extends OIMSlotContentArr
|
|
|
3252
3337
|
}
|
|
3253
3338
|
};
|
|
3254
3339
|
|
|
3255
|
-
// src/
|
|
3340
|
+
// src/bucket/utils/oimSameUniqueSlotSequence.ts
|
|
3256
3341
|
function oimSameUniqueSlotSequence(heldBucketMemberSlots, bucketMemberSlots) {
|
|
3257
3342
|
const seenBucketMemberSlots = /* @__PURE__ */ new Set();
|
|
3258
3343
|
let at = 0;
|
|
@@ -3266,7 +3351,7 @@ function oimSameUniqueSlotSequence(heldBucketMemberSlots, bucketMemberSlots) {
|
|
|
3266
3351
|
return at === heldBucketMemberSlots.length;
|
|
3267
3352
|
}
|
|
3268
3353
|
|
|
3269
|
-
// src/
|
|
3354
|
+
// src/bucket/array/OIMBucketUniqueMemberSlotsArrayService.ts
|
|
3270
3355
|
var _OIMBucketUniqueMemberSlotsArrayService = class _OIMBucketUniqueMemberSlotsArrayService extends OIMBucketMemberSlotsArrayService {
|
|
3271
3356
|
createBucketSlotsArrayStore() {
|
|
3272
3357
|
return { bucketMemberSlots: [], uniqueBucketMemberSlots: /* @__PURE__ */ new Set(), sortedCount: 0 };
|
|
@@ -3325,7 +3410,7 @@ function uniqueBucketMemberSlotsOf(bucketSlotsArrayStore) {
|
|
|
3325
3410
|
return bucketSlotsArrayStore.uniqueBucketMemberSlots;
|
|
3326
3411
|
}
|
|
3327
3412
|
|
|
3328
|
-
// src/
|
|
3413
|
+
// src/bucket/OIMSlotContentSortedArrayBucketService.ts
|
|
3329
3414
|
var OIMSlotContentSortedArrayBucketService = class extends OIMSlotContentArrayBucketService {
|
|
3330
3415
|
constructor(options) {
|
|
3331
3416
|
super(options);
|
|
@@ -3355,169 +3440,7 @@ var OIMSlotContentSortedArrayBucketService = class extends OIMSlotContentArrayBu
|
|
|
3355
3440
|
}
|
|
3356
3441
|
};
|
|
3357
3442
|
|
|
3358
|
-
// src/
|
|
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
|
|
3443
|
+
// src/computed/OIMComputedSourcesService.ts
|
|
3521
3444
|
var _OIMComputedSourcesService = class _OIMComputedSourcesService {
|
|
3522
3445
|
holdSources(derivation) {
|
|
3523
3446
|
oimHoldSlots(derivation.sourceSlots);
|
|
@@ -3533,8 +3456,8 @@ var _OIMComputedSourcesService = class _OIMComputedSourcesService {
|
|
|
3533
3456
|
_OIMComputedSourcesService.INSTANCE = new _OIMComputedSourcesService();
|
|
3534
3457
|
var OIMComputedSourcesService = _OIMComputedSourcesService;
|
|
3535
3458
|
|
|
3536
|
-
// src/
|
|
3537
|
-
function
|
|
3459
|
+
// src/computed/utils/createOIMComputedContentSlot.ts
|
|
3460
|
+
function createOIMComputedContentSlot(owner, computedValueService, initialValue, storeSlot, sourceTracker) {
|
|
3538
3461
|
const singleComputedSlot = {
|
|
3539
3462
|
effects: void 0,
|
|
3540
3463
|
changedAtRevision: 0,
|
|
@@ -3559,12 +3482,13 @@ function createOIMSingleComputedSlot(owner, computedValueService, initialValue,
|
|
|
3559
3482
|
checkedAtRevision: -1,
|
|
3560
3483
|
checkedAtEpoch: -1,
|
|
3561
3484
|
isDeriving: false,
|
|
3562
|
-
allRootSlots: void 0
|
|
3485
|
+
allRootSlots: void 0,
|
|
3486
|
+
sourceTracker
|
|
3563
3487
|
};
|
|
3564
3488
|
return singleComputedSlot;
|
|
3565
3489
|
}
|
|
3566
3490
|
|
|
3567
|
-
// src/
|
|
3491
|
+
// src/computed/OIMSlotContentComputedService.ts
|
|
3568
3492
|
var OIMSlotContentComputedService = class {
|
|
3569
3493
|
constructor(options) {
|
|
3570
3494
|
this.computedValueService = options.computedValueService;
|
|
@@ -3577,13 +3501,20 @@ var OIMSlotContentComputedService = class {
|
|
|
3577
3501
|
slotOwner,
|
|
3578
3502
|
this.computedValueService,
|
|
3579
3503
|
this.initialValue,
|
|
3580
|
-
storeSlot
|
|
3504
|
+
storeSlot,
|
|
3505
|
+
this.createSourceTracker()
|
|
3581
3506
|
);
|
|
3582
3507
|
this.attachSources(computedSlot, storeSlot);
|
|
3583
3508
|
return computedSlot;
|
|
3584
3509
|
}
|
|
3585
3510
|
createSingleSlot(storeSlot, slotOwner) {
|
|
3586
|
-
const computedSlot =
|
|
3511
|
+
const computedSlot = createOIMComputedContentSlot(
|
|
3512
|
+
slotOwner,
|
|
3513
|
+
this.computedValueService,
|
|
3514
|
+
this.initialValue,
|
|
3515
|
+
storeSlot,
|
|
3516
|
+
this.createSourceTracker()
|
|
3517
|
+
);
|
|
3587
3518
|
this.attachSources(computedSlot, storeSlot);
|
|
3588
3519
|
return computedSlot;
|
|
3589
3520
|
}
|
|
@@ -3591,56 +3522,67 @@ var OIMSlotContentComputedService = class {
|
|
|
3591
3522
|
return false;
|
|
3592
3523
|
}
|
|
3593
3524
|
releaseSlotContent(computedSlot) {
|
|
3525
|
+
oimAssertSlotUnheld(computedSlot);
|
|
3594
3526
|
OIMComputedSourcesService.INSTANCE.unholdSources(computedSlot);
|
|
3527
|
+
this.computedValueService.releaseSlotValue(computedSlot);
|
|
3595
3528
|
}
|
|
3596
3529
|
hasReference() {
|
|
3597
3530
|
return false;
|
|
3598
3531
|
}
|
|
3532
|
+
createSourceTracker() {
|
|
3533
|
+
return void 0;
|
|
3534
|
+
}
|
|
3599
3535
|
attachSources(computedSlot, storeSlot) {
|
|
3600
3536
|
const createSources = storeSlot.createSources ?? this.createSources;
|
|
3601
3537
|
const computedSources = createSources(computedSlot);
|
|
3602
|
-
const
|
|
3603
|
-
|
|
3604
|
-
|
|
3538
|
+
const editableComputedSlot = computedSlot;
|
|
3539
|
+
editableComputedSlot.sourceSlots = computedSources.sourceSlots ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
|
|
3540
|
+
editableComputedSlot.sourceComputeds = computedSources.sourceComputeds ?? OIM_FROZEN_EMPTY_COMPUTED_SLOTS;
|
|
3605
3541
|
OIMComputedSourcesService.INSTANCE.holdSources(computedSlot);
|
|
3606
3542
|
}
|
|
3607
3543
|
};
|
|
3608
3544
|
|
|
3609
|
-
// src/
|
|
3610
|
-
|
|
3545
|
+
// src/column/utils/createOIMPullColumnSlotOwner.ts
|
|
3546
|
+
var createOIMPullColumnSlotOwner = (columnSlotOwnerOptions) => new OIMPullColumnSlotOwner(columnSlotOwnerOptions);
|
|
3547
|
+
|
|
3548
|
+
// src/computed/utils/createOIMComputedSlotCollectionService.ts
|
|
3549
|
+
function createOIMComputedSlotCollectionService(options) {
|
|
3611
3550
|
return new OIMSlotCollectionService({
|
|
3612
3551
|
slotReleasePolicy: options.slotReleasePolicy,
|
|
3613
3552
|
slotStoreService: options.computedSlotStoreService,
|
|
3614
|
-
slotContentService:
|
|
3553
|
+
slotContentService: options.slotContentService,
|
|
3615
3554
|
columnSlotOwnerOptions: options.columnSlotOwnerOptions,
|
|
3616
3555
|
createColumnSlotOwner: createOIMPullColumnSlotOwner,
|
|
3617
3556
|
storeSlotListener: options.storeSlotListener
|
|
3618
3557
|
});
|
|
3619
3558
|
}
|
|
3620
3559
|
|
|
3621
|
-
// src/
|
|
3560
|
+
// src/computed/utils/oimAttachComputedDerivation.ts
|
|
3622
3561
|
function oimAttachComputedDerivation(computedStoreSlot, hasServiceDerive, hasServiceCreateSources, derive, createSources) {
|
|
3623
3562
|
if (derive === void 0 && !hasServiceDerive || createSources === void 0 && !hasServiceCreateSources) {
|
|
3624
3563
|
throw new Error(
|
|
3625
3564
|
"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
3565
|
);
|
|
3627
3566
|
}
|
|
3628
|
-
const
|
|
3629
|
-
|
|
3630
|
-
|
|
3567
|
+
const editableComputedStoreSlot = computedStoreSlot;
|
|
3568
|
+
editableComputedStoreSlot.derive = derive;
|
|
3569
|
+
editableComputedStoreSlot.createSources = createSources;
|
|
3631
3570
|
return computedStoreSlot;
|
|
3632
3571
|
}
|
|
3633
3572
|
|
|
3634
|
-
// src/
|
|
3573
|
+
// src/computed/OIMComputedService.ts
|
|
3635
3574
|
var OIMComputedService = class {
|
|
3636
3575
|
constructor(options) {
|
|
3637
|
-
this.computedCollectionService =
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3576
|
+
this.computedCollectionService = createOIMComputedSlotCollectionService({
|
|
3577
|
+
slotContentService: new OIMSlotContentComputedService({
|
|
3578
|
+
computedValueService: new OIMComputedValueService({
|
|
3579
|
+
derive: options.derive,
|
|
3580
|
+
sameValueGuard: options.sameValueGuard,
|
|
3581
|
+
releaseValue: options.releaseValue
|
|
3582
|
+
}),
|
|
3583
|
+
createSources: options.createSources,
|
|
3584
|
+
initialValue: options.initialValue
|
|
3641
3585
|
}),
|
|
3642
|
-
createSources: options.createSources,
|
|
3643
|
-
initialValue: options.initialValue,
|
|
3644
3586
|
slotReleasePolicy: options.slotReleasePolicy,
|
|
3645
3587
|
computedSlotStoreService: options.computedSlotStoreService,
|
|
3646
3588
|
columnSlotOwnerOptions: options.columnSlotOwnerOptions,
|
|
@@ -3660,7 +3602,7 @@ var OIMComputedService = class {
|
|
|
3660
3602
|
}
|
|
3661
3603
|
};
|
|
3662
3604
|
|
|
3663
|
-
// src/
|
|
3605
|
+
// src/collector/OIMSlotAtUnholdReleasePolicy.ts
|
|
3664
3606
|
var _OIMSlotAtUnholdReleasePolicy = class _OIMSlotAtUnholdReleasePolicy {
|
|
3665
3607
|
constructor() {
|
|
3666
3608
|
this.releasesWrittenSlots = true;
|
|
@@ -3688,25 +3630,37 @@ var _OIMSlotAtUnholdReleasePolicy = class _OIMSlotAtUnholdReleasePolicy {
|
|
|
3688
3630
|
_OIMSlotAtUnholdReleasePolicy.INSTANCE = new _OIMSlotAtUnholdReleasePolicy();
|
|
3689
3631
|
var OIMSlotAtUnholdReleasePolicy = _OIMSlotAtUnholdReleasePolicy;
|
|
3690
3632
|
|
|
3691
|
-
// src/
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3633
|
+
// src/db/constants/OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.ts
|
|
3634
|
+
var OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE = /* @__PURE__ */ new OIMDefaultValue(() => OIMSlotMapStoreService.INSTANCE);
|
|
3635
|
+
|
|
3636
|
+
// src/computed/utils/oimResolveComputedDerivationOptions.ts
|
|
3637
|
+
function oimResolveComputedDerivationOptions(options) {
|
|
3638
|
+
const defaults = options.defaults ?? OIMDefaults.INSTANCE;
|
|
3639
|
+
return {
|
|
3640
|
+
columnSlotOwnerOptions: oimResolveColumnSlotOwnerOptions(
|
|
3696
3641
|
options.columnSlotStoreService,
|
|
3697
3642
|
options.columnNames,
|
|
3698
|
-
OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue()
|
|
3643
|
+
defaults.computedColumnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue()
|
|
3699
3644
|
),
|
|
3700
3645
|
slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
|
|
3701
|
-
storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
|
|
3702
|
-
createSources: options.createSources,
|
|
3703
|
-
derive: options.derive,
|
|
3646
|
+
storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
|
|
3704
3647
|
sameValueGuard: options.sameValueGuard,
|
|
3648
|
+
releaseValue: options.releaseValue,
|
|
3705
3649
|
initialValue: options.initialValue
|
|
3650
|
+
};
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
// src/computed/createOIMComputedService.ts
|
|
3654
|
+
function createOIMComputedService(options) {
|
|
3655
|
+
return new OIMComputedService({
|
|
3656
|
+
computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
|
|
3657
|
+
...oimResolveComputedDerivationOptions(options),
|
|
3658
|
+
createSources: options.createSources,
|
|
3659
|
+
derive: options.derive
|
|
3706
3660
|
});
|
|
3707
3661
|
}
|
|
3708
3662
|
|
|
3709
|
-
// src/
|
|
3663
|
+
// src/computed/OIMSingleComputedService.ts
|
|
3710
3664
|
var OIMSingleComputedService = class {
|
|
3711
3665
|
constructor(options) {
|
|
3712
3666
|
this.computedSingleSlotService = new OIMSingleSlotService({
|
|
@@ -3715,7 +3669,8 @@ var OIMSingleComputedService = class {
|
|
|
3715
3669
|
slotContentService: new OIMSlotContentComputedService({
|
|
3716
3670
|
computedValueService: new OIMComputedValueService({
|
|
3717
3671
|
derive: options.derive,
|
|
3718
|
-
sameValueGuard: options.sameValueGuard
|
|
3672
|
+
sameValueGuard: options.sameValueGuard,
|
|
3673
|
+
releaseValue: options.releaseValue
|
|
3719
3674
|
}),
|
|
3720
3675
|
createSources: options.createSources,
|
|
3721
3676
|
initialValue: options.initialValue
|
|
@@ -3738,30 +3693,133 @@ var OIMSingleComputedService = class {
|
|
|
3738
3693
|
}
|
|
3739
3694
|
};
|
|
3740
3695
|
|
|
3741
|
-
// src/
|
|
3696
|
+
// src/computed/createOIMSingleComputedService.ts
|
|
3742
3697
|
function createOIMSingleComputedService(options = {}) {
|
|
3743
3698
|
return new OIMSingleComputedService({
|
|
3744
|
-
|
|
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(),
|
|
3699
|
+
...oimResolveComputedDerivationOptions(options),
|
|
3751
3700
|
createSources: options.createSources,
|
|
3752
|
-
derive: options.derive
|
|
3753
|
-
sameValueGuard: options.sameValueGuard,
|
|
3754
|
-
initialValue: options.initialValue
|
|
3701
|
+
derive: options.derive
|
|
3755
3702
|
});
|
|
3756
3703
|
}
|
|
3757
3704
|
|
|
3758
|
-
// src/
|
|
3705
|
+
// src/computed/OIMSourceTrackingComputedValueService.ts
|
|
3706
|
+
var OIMSourceTrackingComputedValueService = class extends OIMComputedValueService {
|
|
3707
|
+
constructor(options) {
|
|
3708
|
+
super({ sameValueGuard: options.sameValueGuard, releaseValue: options.releaseValue });
|
|
3709
|
+
this.deriveTrackingSources = (computedSlot) => {
|
|
3710
|
+
const sourceTracker = computedSlot.sourceTracker;
|
|
3711
|
+
sourceTracker.openSourceTracking();
|
|
3712
|
+
const value = this.sourceTrackingDerive(computedSlot, sourceTracker);
|
|
3713
|
+
if (sourceTracker.closeSourceTracking() && !oimIsSlotReleased(computedSlot)) this.replaceSources(computedSlot, sourceTracker);
|
|
3714
|
+
return value;
|
|
3715
|
+
};
|
|
3716
|
+
this.sourceTrackingDerive = options.derive;
|
|
3717
|
+
}
|
|
3718
|
+
getValueForSlot(computedSlot) {
|
|
3719
|
+
oimAssertSlotNotReleased(computedSlot);
|
|
3720
|
+
const sourceTracker = computedSlot.sourceTracker;
|
|
3721
|
+
oimRefreshComputedSlot(computedSlot, this.deriveTrackingSources, this.sameValueGuard, this.releaseValue, computedSlot.storeSlot.channelSlot.clock);
|
|
3722
|
+
if (sourceTracker.trackReplacedRootSlots()) {
|
|
3723
|
+
sourceTracker.commitTrackedSources();
|
|
3724
|
+
computedSlot.allRootSlots = void 0;
|
|
3725
|
+
}
|
|
3726
|
+
return computedSlot.value;
|
|
3727
|
+
}
|
|
3728
|
+
replaceSources(computedSlot, sourceTracker) {
|
|
3729
|
+
const trackedSourceSlots = sourceTracker.getTrackedSourceSlots().slice();
|
|
3730
|
+
const trackedSourceComputeds = sourceTracker.getTrackedSourceComputeds().slice();
|
|
3731
|
+
oimHoldSlots(trackedSourceSlots);
|
|
3732
|
+
oimHoldSlots(trackedSourceComputeds);
|
|
3733
|
+
OIMComputedSourcesService.INSTANCE.unholdSources(computedSlot);
|
|
3734
|
+
const editableComputedSlot = computedSlot;
|
|
3735
|
+
editableComputedSlot.sourceSlots = trackedSourceSlots;
|
|
3736
|
+
editableComputedSlot.sourceComputeds = trackedSourceComputeds;
|
|
3737
|
+
editableComputedSlot.allRootSlots = void 0;
|
|
3738
|
+
sourceTracker.commitTrackedSources();
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
|
|
3742
|
+
// src/computed/OIMSlotContentSourceTrackingComputedService.ts
|
|
3743
|
+
var OIMSlotContentSourceTrackingComputedService = class extends OIMSlotContentComputedService {
|
|
3744
|
+
createSourceTracker() {
|
|
3745
|
+
return new OIMSourceTracker();
|
|
3746
|
+
}
|
|
3747
|
+
attachSources() {
|
|
3748
|
+
return;
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
|
|
3752
|
+
// src/computed/OIMSourceTrackingComputedService.ts
|
|
3753
|
+
var OIMSourceTrackingComputedService = class {
|
|
3754
|
+
constructor(options) {
|
|
3755
|
+
this.computedCollectionService = createOIMComputedSlotCollectionService({
|
|
3756
|
+
slotContentService: new OIMSlotContentSourceTrackingComputedService({
|
|
3757
|
+
computedValueService: new OIMSourceTrackingComputedValueService({
|
|
3758
|
+
derive: options.derive,
|
|
3759
|
+
sameValueGuard: options.sameValueGuard,
|
|
3760
|
+
releaseValue: options.releaseValue
|
|
3761
|
+
}),
|
|
3762
|
+
initialValue: options.initialValue
|
|
3763
|
+
}),
|
|
3764
|
+
slotReleasePolicy: options.slotReleasePolicy,
|
|
3765
|
+
computedSlotStoreService: options.computedSlotStoreService,
|
|
3766
|
+
columnSlotOwnerOptions: options.columnSlotOwnerOptions,
|
|
3767
|
+
storeSlotListener: options.storeSlotListener
|
|
3768
|
+
});
|
|
3769
|
+
}
|
|
3770
|
+
createComputedStoreSlot(channelMap) {
|
|
3771
|
+
return this.computedCollectionService.createStoreSlot(channelMap);
|
|
3772
|
+
}
|
|
3773
|
+
};
|
|
3774
|
+
|
|
3775
|
+
// src/computed/OIMSingleSourceTrackingComputedService.ts
|
|
3776
|
+
var OIMSingleSourceTrackingComputedService = class {
|
|
3777
|
+
constructor(options) {
|
|
3778
|
+
this.computedSingleSlotService = new OIMSingleSlotService({
|
|
3779
|
+
slotReleasePolicy: options.slotReleasePolicy,
|
|
3780
|
+
slotStoreService: OIMSingleSlotStoreService.INSTANCE,
|
|
3781
|
+
slotContentService: new OIMSlotContentSourceTrackingComputedService({
|
|
3782
|
+
computedValueService: new OIMSourceTrackingComputedValueService({
|
|
3783
|
+
derive: options.derive,
|
|
3784
|
+
sameValueGuard: options.sameValueGuard,
|
|
3785
|
+
releaseValue: options.releaseValue
|
|
3786
|
+
}),
|
|
3787
|
+
initialValue: options.initialValue
|
|
3788
|
+
}),
|
|
3789
|
+
columnSlotOwnerOptions: options.columnSlotOwnerOptions,
|
|
3790
|
+
createColumnSlotOwner: createOIMPullColumnSlotOwner,
|
|
3791
|
+
storeSlotListener: options.storeSlotListener
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
createComputedStoreSlot(channelMap) {
|
|
3795
|
+
return this.computedSingleSlotService.createStoreSlot(channelMap);
|
|
3796
|
+
}
|
|
3797
|
+
};
|
|
3798
|
+
|
|
3799
|
+
// src/computed/createOIMSourceTrackingComputedService.ts
|
|
3800
|
+
function createOIMSourceTrackingComputedService(options) {
|
|
3801
|
+
return new OIMSourceTrackingComputedService({
|
|
3802
|
+
computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
|
|
3803
|
+
...oimResolveComputedDerivationOptions(options),
|
|
3804
|
+
derive: options.derive
|
|
3805
|
+
});
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
// src/computed/createOIMSingleSourceTrackingComputedService.ts
|
|
3809
|
+
function createOIMSingleSourceTrackingComputedService(options) {
|
|
3810
|
+
return new OIMSingleSourceTrackingComputedService({
|
|
3811
|
+
...oimResolveComputedDerivationOptions(options),
|
|
3812
|
+
derive: options.derive
|
|
3813
|
+
});
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3816
|
+
// src/computed/utils/oimColumnsComparator.ts
|
|
3759
3817
|
function oimColumnsComparator(columns) {
|
|
3760
3818
|
return (left, right) => {
|
|
3761
3819
|
for (let i = 0; i < columns.length; i++) {
|
|
3762
|
-
const
|
|
3763
|
-
const leftValue = left[
|
|
3764
|
-
const rightValue = right[
|
|
3820
|
+
const columnName = columns[i].columnName;
|
|
3821
|
+
const leftValue = left[columnName];
|
|
3822
|
+
const rightValue = right[columnName];
|
|
3765
3823
|
if (leftValue === rightValue) continue;
|
|
3766
3824
|
const isLeftMissing = leftValue === void 0 || leftValue === null || leftValue !== leftValue;
|
|
3767
3825
|
const isRightMissing = rightValue === void 0 || rightValue === null || rightValue !== rightValue;
|
|
@@ -3775,7 +3833,7 @@ function oimColumnsComparator(columns) {
|
|
|
3775
3833
|
};
|
|
3776
3834
|
}
|
|
3777
3835
|
|
|
3778
|
-
// src/
|
|
3836
|
+
// src/computed/utils/oimEntitySlotsComparator.ts
|
|
3779
3837
|
function oimEntitySlotsComparator(compareEntities) {
|
|
3780
3838
|
return (leftEntitySlot, rightEntitySlot) => {
|
|
3781
3839
|
const leftEntity = leftEntitySlot.entity;
|
|
@@ -3786,7 +3844,7 @@ function oimEntitySlotsComparator(compareEntities) {
|
|
|
3786
3844
|
};
|
|
3787
3845
|
}
|
|
3788
3846
|
|
|
3789
|
-
// src/
|
|
3847
|
+
// src/computed/OIMSortedComputedService.ts
|
|
3790
3848
|
var OIMSortedComputedService = class {
|
|
3791
3849
|
constructor(options) {
|
|
3792
3850
|
const indexService = options.indexService;
|
|
@@ -3800,16 +3858,18 @@ var OIMSortedComputedService = class {
|
|
|
3800
3858
|
derive: (computedSlot) => sortBucketMemberSlots(computedSlot, bucketContentService, compareEntitySlots),
|
|
3801
3859
|
sameValueGuard: oimSameSlotSequence
|
|
3802
3860
|
});
|
|
3803
|
-
this.computedCollectionService =
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
computedSlot
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3861
|
+
this.computedCollectionService = createOIMComputedSlotCollectionService({
|
|
3862
|
+
slotContentService: new OIMSlotContentComputedService({
|
|
3863
|
+
computedValueService,
|
|
3864
|
+
createSources: (computedSlot) => createSortedComputedSources(
|
|
3865
|
+
computedSlot.key,
|
|
3866
|
+
computedSlot.storeSlot,
|
|
3867
|
+
indexService,
|
|
3868
|
+
sortColumns,
|
|
3869
|
+
hasComparator
|
|
3870
|
+
),
|
|
3871
|
+
initialValue: OIM_FROZEN_EMPTY_SLOTS
|
|
3872
|
+
}),
|
|
3813
3873
|
slotReleasePolicy: options.slotReleasePolicy,
|
|
3814
3874
|
computedSlotStoreService: options.computedSlotStoreService,
|
|
3815
3875
|
columnSlotOwnerOptions: { columnSlotStoreService: options.columnSlotStoreService },
|
|
@@ -3823,12 +3883,12 @@ var OIMSortedComputedService = class {
|
|
|
3823
3883
|
function compareNothing() {
|
|
3824
3884
|
return 0;
|
|
3825
3885
|
}
|
|
3826
|
-
function
|
|
3886
|
+
function createSortedComputedSources(key, storeSlot, indexService, sortColumns, hasComparator) {
|
|
3827
3887
|
const indexStoreSlot = storeSlot.sourceStoreSlot;
|
|
3828
3888
|
const sourceSlots = [indexService.getSlotByKey(indexStoreSlot, key)];
|
|
3829
3889
|
if (sortColumns !== void 0) {
|
|
3830
3890
|
for (let i = 0; i < sortColumns.length; i++) {
|
|
3831
|
-
sourceSlots.push(indexService.getBucketColumnByKey(indexStoreSlot, key, sortColumns[i].
|
|
3891
|
+
sourceSlots.push(indexService.getBucketColumnByKey(indexStoreSlot, key, sortColumns[i].columnName));
|
|
3832
3892
|
}
|
|
3833
3893
|
} else if (hasComparator) {
|
|
3834
3894
|
sourceSlots.push(indexService.getAnyBucketColumnByKey(indexStoreSlot, key));
|
|
@@ -3893,20 +3953,21 @@ function reconcileArrayWithEveryBucketMemberSlot(entitySlots, bucketMemberSlots)
|
|
|
3893
3953
|
return next;
|
|
3894
3954
|
}
|
|
3895
3955
|
|
|
3896
|
-
// src/
|
|
3956
|
+
// src/computed/createOIMSortedComputedService.ts
|
|
3897
3957
|
function createOIMSortedComputedService(options) {
|
|
3958
|
+
const defaults = options.defaults ?? OIMDefaults.INSTANCE;
|
|
3898
3959
|
return new OIMSortedComputedService({
|
|
3899
3960
|
indexService: options.indexService,
|
|
3900
|
-
computedSlotStoreService:
|
|
3901
|
-
columnSlotStoreService: options.columnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
|
|
3961
|
+
computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
|
|
3962
|
+
columnSlotStoreService: options.columnSlotStoreService ?? defaults.computedColumnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
|
|
3902
3963
|
sortColumns: options.sortColumns,
|
|
3903
3964
|
comparator: options.comparator,
|
|
3904
3965
|
slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
|
|
3905
|
-
storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
3966
|
+
storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
3906
3967
|
});
|
|
3907
3968
|
}
|
|
3908
3969
|
|
|
3909
|
-
// src/
|
|
3970
|
+
// src/computed/OIMBucketMemoComputedService.ts
|
|
3910
3971
|
var OIMBucketMemoComputedService = class {
|
|
3911
3972
|
constructor(options) {
|
|
3912
3973
|
const bucketCollectionService = options.bucketCollectionService;
|
|
@@ -3915,10 +3976,12 @@ var OIMBucketMemoComputedService = class {
|
|
|
3915
3976
|
derive: (computedSlot) => deriveBucketMemo(computedSlot, bucketContentService),
|
|
3916
3977
|
sameValueGuard: oimSameSlotSequence
|
|
3917
3978
|
});
|
|
3918
|
-
this.computedCollectionService =
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3979
|
+
this.computedCollectionService = createOIMComputedSlotCollectionService({
|
|
3980
|
+
slotContentService: new OIMSlotContentComputedService({
|
|
3981
|
+
computedValueService,
|
|
3982
|
+
createSources: (computedSlot) => createBucketMemoComputedSources(computedSlot.key, computedSlot.storeSlot, bucketCollectionService),
|
|
3983
|
+
initialValue: OIM_FROZEN_EMPTY_SLOTS
|
|
3984
|
+
}),
|
|
3922
3985
|
slotReleasePolicy: options.slotReleasePolicy,
|
|
3923
3986
|
computedSlotStoreService: options.computedSlotStoreService,
|
|
3924
3987
|
columnSlotOwnerOptions: { columnSlotStoreService: options.columnSlotStoreService },
|
|
@@ -3932,26 +3995,27 @@ var OIMBucketMemoComputedService = class {
|
|
|
3932
3995
|
function deriveBucketMemo(computedSlot, bucketContentService) {
|
|
3933
3996
|
return Array.from(bucketContentService.getBucketMemberSlots(computedSlot.sourceSlots[0]));
|
|
3934
3997
|
}
|
|
3935
|
-
function
|
|
3998
|
+
function createBucketMemoComputedSources(key, storeSlot, bucketCollectionService) {
|
|
3936
3999
|
const bucketStoreSlot = storeSlot.sourceStoreSlot;
|
|
3937
4000
|
return { sourceSlots: [bucketCollectionService.getSlotByKey(bucketStoreSlot, key)] };
|
|
3938
4001
|
}
|
|
3939
4002
|
|
|
3940
|
-
// src/
|
|
4003
|
+
// src/computed/createOIMBucketMemoComputedService.ts
|
|
3941
4004
|
function createOIMBucketMemoComputedService(options) {
|
|
4005
|
+
const defaults = options.defaults ?? OIMDefaults.INSTANCE;
|
|
3942
4006
|
return new OIMBucketMemoComputedService({
|
|
3943
4007
|
bucketCollectionService: options.bucketCollectionService,
|
|
3944
|
-
computedSlotStoreService:
|
|
3945
|
-
columnSlotStoreService: options.columnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
|
|
4008
|
+
computedSlotStoreService: oimResolveSlotStoreService(options.computedSlotStoreService),
|
|
4009
|
+
columnSlotStoreService: options.columnSlotStoreService ?? defaults.computedColumnSlotStoreService ?? OIM_DEFAULT_COMPUTED_COLUMN_SLOT_STORE_SERVICE.getValue(),
|
|
3946
4010
|
slotReleasePolicy: options.slotReleasePolicy ?? OIMSlotAtUnholdReleasePolicy.INSTANCE,
|
|
3947
|
-
storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
4011
|
+
storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue()
|
|
3948
4012
|
});
|
|
3949
4013
|
}
|
|
3950
4014
|
|
|
3951
|
-
// src/
|
|
4015
|
+
// src/bucket/commands/constants/OIM_MAX_COMMANDS_PER_SLOT.ts
|
|
3952
4016
|
var OIM_MAX_COMMANDS_PER_SLOT = 1;
|
|
3953
4017
|
|
|
3954
|
-
// src/
|
|
4018
|
+
// src/bucket/OIMBucketCommands.ts
|
|
3955
4019
|
var OIMBucketCommands = class {
|
|
3956
4020
|
constructor(options) {
|
|
3957
4021
|
this.maxCommandsPerSlot = options.maxCommandsPerSlot ?? OIM_MAX_COMMANDS_PER_SLOT;
|
|
@@ -3966,40 +4030,40 @@ var OIMBucketCommands = class {
|
|
|
3966
4030
|
this.recordCommand(bucketSlot, { type: "move", from, to }, bucketMemberSlotCount);
|
|
3967
4031
|
}
|
|
3968
4032
|
recordWholeList(bucketSlot) {
|
|
3969
|
-
const
|
|
3970
|
-
const commands =
|
|
4033
|
+
const editableBucketSlot = enlistInFlush(bucketSlot);
|
|
4034
|
+
const commands = editableBucketSlot.commands;
|
|
3971
4035
|
if (commands !== void 0 && commands.length !== 0) commands.length = 0;
|
|
3972
|
-
|
|
4036
|
+
editableBucketSlot.isWholeListRecorded = true;
|
|
3973
4037
|
}
|
|
3974
4038
|
recordCommand(bucketSlot, orderedListCommand, bucketMemberSlotCount) {
|
|
3975
|
-
const
|
|
3976
|
-
if (
|
|
3977
|
-
const commands =
|
|
4039
|
+
const editableBucketSlot = enlistInFlush(bucketSlot);
|
|
4040
|
+
if (editableBucketSlot.isWholeListRecorded) return;
|
|
4041
|
+
const commands = editableBucketSlot.commands ?? (editableBucketSlot.commands = []);
|
|
3978
4042
|
commands.push(orderedListCommand);
|
|
3979
4043
|
if (commands.length > this.maxCommandsPerSlot * bucketMemberSlotCount) {
|
|
3980
4044
|
commands.length = 0;
|
|
3981
|
-
|
|
4045
|
+
editableBucketSlot.isWholeListRecorded = true;
|
|
3982
4046
|
}
|
|
3983
4047
|
}
|
|
3984
4048
|
};
|
|
3985
4049
|
function enlistInFlush(bucketSlot) {
|
|
3986
|
-
const
|
|
4050
|
+
const editableBucketSlot = bucketSlot;
|
|
3987
4051
|
const storeSlot = bucketSlot.storeSlot;
|
|
3988
4052
|
const channelSlot = storeSlot.channelSlot;
|
|
3989
|
-
const commands =
|
|
3990
|
-
const hasScript = commands !== void 0 && commands.length > 0 ||
|
|
3991
|
-
if (hasScript && !isScriptStale(channelSlot,
|
|
4053
|
+
const commands = editableBucketSlot.commands;
|
|
4054
|
+
const hasScript = commands !== void 0 && commands.length > 0 || editableBucketSlot.isWholeListRecorded;
|
|
4055
|
+
if (hasScript && !isScriptStale(channelSlot, editableBucketSlot)) return editableBucketSlot;
|
|
3992
4056
|
if (hasScript) {
|
|
3993
|
-
clearScript(
|
|
4057
|
+
clearScript(editableBucketSlot);
|
|
3994
4058
|
} else {
|
|
3995
4059
|
const commandsBucketSlotChannelQueue = storeSlot.commandsBucketSlotChannelQueue ?? (storeSlot.commandsBucketSlotChannelQueue = new OIMChannelQueue());
|
|
3996
4060
|
if (commandsBucketSlotChannelQueue.getEntryCount() === 0) getCommandsStoreSlotChannelQueue(channelSlot).enqueueEntry(storeSlot);
|
|
3997
|
-
commandsBucketSlotChannelQueue.enqueueEntry(
|
|
4061
|
+
commandsBucketSlotChannelQueue.enqueueEntry(editableBucketSlot);
|
|
3998
4062
|
}
|
|
3999
4063
|
const clock = channelSlot.clock;
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
return
|
|
4064
|
+
editableBucketSlot.commandsStartedAtRevision = clock.revision;
|
|
4065
|
+
editableBucketSlot.commandsStartedAtEpoch = clock.epoch;
|
|
4066
|
+
return editableBucketSlot;
|
|
4003
4067
|
}
|
|
4004
4068
|
function getCommandsStoreSlotChannelQueue(channelSlot) {
|
|
4005
4069
|
const commandsStoreSlotChannelQueue = channelSlot.commandsStoreSlotChannelQueue;
|
|
@@ -4020,10 +4084,10 @@ function isScriptStale(channelSlot, bucketSlot) {
|
|
|
4020
4084
|
bucketSlot.commandsStartedAtEpoch
|
|
4021
4085
|
);
|
|
4022
4086
|
}
|
|
4023
|
-
function clearScript(
|
|
4024
|
-
const commands =
|
|
4087
|
+
function clearScript(editableBucketSlot) {
|
|
4088
|
+
const commands = editableBucketSlot.commands;
|
|
4025
4089
|
if (commands !== void 0 && commands.length !== 0) commands.length = 0;
|
|
4026
|
-
|
|
4090
|
+
editableBucketSlot.isWholeListRecorded = false;
|
|
4027
4091
|
}
|
|
4028
4092
|
function clearStaleScripts(channelSlot, commandsStoreSlotChannelQueue) {
|
|
4029
4093
|
let keptStoreSlotCount = 0;
|
|
@@ -4032,12 +4096,12 @@ function clearStaleScripts(channelSlot, commandsStoreSlotChannelQueue) {
|
|
|
4032
4096
|
const commandsBucketSlotChannelQueue = storeSlot.commandsBucketSlotChannelQueue;
|
|
4033
4097
|
let keptBucketSlotCount = 0;
|
|
4034
4098
|
for (let j = 0; j < commandsBucketSlotChannelQueue.getEntryCount(); j++) {
|
|
4035
|
-
const
|
|
4036
|
-
if (!isScriptStale(channelSlot,
|
|
4037
|
-
commandsBucketSlotChannelQueue.setEntryAt(keptBucketSlotCount++,
|
|
4099
|
+
const editableBucketSlot = commandsBucketSlotChannelQueue.getEntryAt(j);
|
|
4100
|
+
if (!isScriptStale(channelSlot, editableBucketSlot)) {
|
|
4101
|
+
commandsBucketSlotChannelQueue.setEntryAt(keptBucketSlotCount++, editableBucketSlot);
|
|
4038
4102
|
continue;
|
|
4039
4103
|
}
|
|
4040
|
-
clearScript(
|
|
4104
|
+
clearScript(editableBucketSlot);
|
|
4041
4105
|
}
|
|
4042
4106
|
commandsBucketSlotChannelQueue.keepFirstEntries(keptBucketSlotCount);
|
|
4043
4107
|
if (keptBucketSlotCount !== 0) commandsStoreSlotChannelQueue.setEntryAt(keptStoreSlotCount++, storeSlot);
|
|
@@ -4045,7 +4109,7 @@ function clearStaleScripts(channelSlot, commandsStoreSlotChannelQueue) {
|
|
|
4045
4109
|
commandsStoreSlotChannelQueue.keepFirstEntries(keptStoreSlotCount);
|
|
4046
4110
|
}
|
|
4047
4111
|
|
|
4048
|
-
// src/
|
|
4112
|
+
// src/index/utils/createOIMIndexStoreSlot.ts
|
|
4049
4113
|
function createOIMIndexStoreSlot(store, slotService, sourceStoreSlot, contentChangeListener) {
|
|
4050
4114
|
return {
|
|
4051
4115
|
...createOIMStoreSlot(store, sourceStoreSlot.channelSlot, slotService),
|
|
@@ -4059,7 +4123,7 @@ function createOIMIndexStoreSlot(store, slotService, sourceStoreSlot, contentCha
|
|
|
4059
4123
|
};
|
|
4060
4124
|
}
|
|
4061
4125
|
|
|
4062
|
-
// src/
|
|
4126
|
+
// src/index/OIMSlotCollectionIndexService.ts
|
|
4063
4127
|
var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
4064
4128
|
constructor(options) {
|
|
4065
4129
|
super(options);
|
|
@@ -4074,26 +4138,26 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4074
4138
|
onContentChanged: (entitySlot, patch, changedColumns) => {
|
|
4075
4139
|
this.updateIndexKeyForSlot(indexStoreSlot, entitySlot, patch, changedColumns);
|
|
4076
4140
|
},
|
|
4077
|
-
|
|
4141
|
+
onManyContentsChanged: (entitySlotChannelQueue, patchChannelQueue, changedColumnsChannelQueue) => {
|
|
4078
4142
|
this.updateIndexKeysForSlots(indexStoreSlot, entitySlotChannelQueue, patchChannelQueue, changedColumnsChannelQueue);
|
|
4079
4143
|
}
|
|
4080
4144
|
};
|
|
4081
|
-
const indexStoreSlot = this.
|
|
4145
|
+
const indexStoreSlot = this.createStoreSlotOverNewStore((store) => createOIMIndexStoreSlot(store, this, sourceStoreSlot, contentChangeListener));
|
|
4082
4146
|
const indexKeysService = this.indexKeysService;
|
|
4083
4147
|
const indexKeysPositions = sourceStoreSlot.indexKeysPositions ?? (sourceStoreSlot.indexKeysPositions = indexKeysService.createPositions());
|
|
4084
4148
|
indexStoreSlot.indexKeysPosition = indexKeysService.allocatePosition(indexKeysPositions);
|
|
4085
|
-
|
|
4149
|
+
OIMSlotContentChangeListenerService.INSTANCE.addContentChangeListener(sourceStoreSlot, contentChangeListener, this.keyColumns);
|
|
4086
4150
|
return indexStoreSlot;
|
|
4087
4151
|
}
|
|
4088
4152
|
disposeIndexStoreSlot(indexStoreSlot) {
|
|
4089
4153
|
this.assertNotDisposed(indexStoreSlot);
|
|
4090
4154
|
OIMChannelService.INSTANCE.assertNotFlushing(indexStoreSlot.channelSlot);
|
|
4091
4155
|
const sourceStoreSlot = indexStoreSlot.sourceStoreSlot;
|
|
4092
|
-
|
|
4156
|
+
OIMSlotContentChangeListenerService.INSTANCE.removeContentChangeListener(sourceStoreSlot, indexStoreSlot.contentChangeListener);
|
|
4093
4157
|
for (const bucketColumnName of indexStoreSlot.bucketColumnNames) {
|
|
4094
|
-
|
|
4158
|
+
OIMSlotContentChangeListenerService.INSTANCE.removeReadColumn(sourceStoreSlot, bucketColumnName);
|
|
4095
4159
|
}
|
|
4096
|
-
if (indexStoreSlot.isAnyBucketColumnRead)
|
|
4160
|
+
if (indexStoreSlot.isAnyBucketColumnRead) OIMSlotContentChangeListenerService.INSTANCE.removeReadAnyColumn(sourceStoreSlot);
|
|
4097
4161
|
const indexKeysPositions = sourceStoreSlot.indexKeysPositions;
|
|
4098
4162
|
if (indexKeysPositions !== void 0) {
|
|
4099
4163
|
this.indexKeysService.releasePosition(
|
|
@@ -4140,10 +4204,10 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4140
4204
|
}
|
|
4141
4205
|
walkSlotsByKeys(indexStoreSlot, keys, takeFoundSlot, slotByKeyDoor) {
|
|
4142
4206
|
this.assertNotDisposed(indexStoreSlot);
|
|
4143
|
-
const
|
|
4207
|
+
const editableIndexStoreSlot = indexStoreSlot;
|
|
4144
4208
|
const bucketSlots = [];
|
|
4145
4209
|
let entitySlotsByMintedBucketSlot;
|
|
4146
|
-
|
|
4210
|
+
editableIndexStoreSlot.requestedKeys = keys;
|
|
4147
4211
|
try {
|
|
4148
4212
|
for (let i = 0; i < keys.length; i++) {
|
|
4149
4213
|
const foundBucketSlot = this.findSlotByKey(indexStoreSlot, keys[i]);
|
|
@@ -4157,7 +4221,7 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4157
4221
|
bucketSlots.push(bucketSlot);
|
|
4158
4222
|
}
|
|
4159
4223
|
} finally {
|
|
4160
|
-
|
|
4224
|
+
editableIndexStoreSlot.requestedKeys = void 0;
|
|
4161
4225
|
if (entitySlotsByMintedBucketSlot !== void 0) this.fillMintedBucketSlots(indexStoreSlot, entitySlotsByMintedBucketSlot);
|
|
4162
4226
|
}
|
|
4163
4227
|
return bucketSlots;
|
|
@@ -4189,18 +4253,14 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4189
4253
|
const bucketColumnNames = indexStoreSlot.bucketColumnNames;
|
|
4190
4254
|
if (bucketColumnNames.has(columnName)) return;
|
|
4191
4255
|
bucketColumnNames.add(columnName);
|
|
4192
|
-
|
|
4256
|
+
OIMSlotContentChangeListenerService.INSTANCE.addReadColumn(indexStoreSlot.sourceStoreSlot, columnName);
|
|
4193
4257
|
}
|
|
4194
4258
|
onBucketColumnsChanged(_indexStoreSlot, _bucketSlot, _entitySlot, _changedColumns) {
|
|
4195
4259
|
return;
|
|
4196
4260
|
}
|
|
4197
4261
|
onSlotMinted(indexStoreSlot, bucketSlot) {
|
|
4198
4262
|
if (indexStoreSlot.requestedKeys !== void 0) return;
|
|
4199
|
-
|
|
4200
|
-
this.slotContentBucketService.fillBucketMemberSlots(
|
|
4201
|
-
bucketSlot,
|
|
4202
|
-
this.setIndexKeyForSlots(indexStoreSlot, this.collectSourceSlotsForKey(indexStoreSlot, key), key)
|
|
4203
|
-
);
|
|
4263
|
+
this.fillBucketSlotWithSourceSlots(indexStoreSlot, bucketSlot, this.collectSourceSlotsForKey(indexStoreSlot, bucketSlot.key));
|
|
4204
4264
|
}
|
|
4205
4265
|
assertNotDisposed(storeSlot) {
|
|
4206
4266
|
if (!storeSlot.isDisposed) return;
|
|
@@ -4211,7 +4271,7 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4211
4271
|
addAnyBucketColumnRead(indexStoreSlot) {
|
|
4212
4272
|
if (indexStoreSlot.isAnyBucketColumnRead) return;
|
|
4213
4273
|
indexStoreSlot.isAnyBucketColumnRead = true;
|
|
4214
|
-
|
|
4274
|
+
OIMSlotContentChangeListenerService.INSTANCE.addReadAnyColumn(indexStoreSlot.sourceStoreSlot);
|
|
4215
4275
|
}
|
|
4216
4276
|
fillMintedBucketSlots(indexStoreSlot, entitySlotsByMintedBucketSlot) {
|
|
4217
4277
|
for (const entitySlot of this.sourceSlotCollectionService.getSlots(indexStoreSlot.sourceStoreSlot)) {
|
|
@@ -4223,7 +4283,7 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4223
4283
|
const slotContentService = this.slotContentBucketService;
|
|
4224
4284
|
const slotOwnerService = this.slotOwnerService;
|
|
4225
4285
|
for (const [bucketSlot, entitySlots] of entitySlotsByMintedBucketSlot) {
|
|
4226
|
-
|
|
4286
|
+
this.fillBucketSlotWithSourceSlots(indexStoreSlot, bucketSlot, entitySlots);
|
|
4227
4287
|
slotOwnerService.settleEmptiness(bucketSlot, slotContentService.isSlotEmpty(bucketSlot));
|
|
4228
4288
|
}
|
|
4229
4289
|
}
|
|
@@ -4363,40 +4423,42 @@ var OIMSlotCollectionIndexService = class extends OIMSlotCollectionService {
|
|
|
4363
4423
|
}
|
|
4364
4424
|
return matchingEntitySlots;
|
|
4365
4425
|
}
|
|
4366
|
-
|
|
4426
|
+
fillBucketSlotWithSourceSlots(indexStoreSlot, bucketSlot, entitySlots) {
|
|
4367
4427
|
const indexKeysService = this.indexKeysService;
|
|
4368
4428
|
const indexKeysPosition = indexStoreSlot.indexKeysPosition;
|
|
4369
|
-
const
|
|
4370
|
-
const isRefusingWrites = OIMChannelService.INSTANCE.isRefusingWrites(channelSlot);
|
|
4371
|
-
|
|
4429
|
+
const key = bucketSlot.key;
|
|
4430
|
+
const isRefusingWrites = OIMChannelService.INSTANCE.isRefusingWrites(indexStoreSlot.channelSlot);
|
|
4431
|
+
const fillingEntitySlots = [];
|
|
4432
|
+
const prevKeys = [];
|
|
4433
|
+
const movingEntitySlots = [];
|
|
4372
4434
|
for (let i = 0; i < entitySlots.length; i++) {
|
|
4373
4435
|
const entitySlot = entitySlots[i];
|
|
4374
4436
|
const prevKey = indexKeysService.get(entitySlot, indexKeysPosition);
|
|
4375
4437
|
const isMoving = prevKey !== void 0 && !this.isSameKey(prevKey, key);
|
|
4376
|
-
if (isMoving && isRefusingWrites)
|
|
4377
|
-
|
|
4378
|
-
continue;
|
|
4379
|
-
}
|
|
4380
|
-
movableEntitySlots?.push(entitySlot);
|
|
4438
|
+
if (isMoving && isRefusingWrites) continue;
|
|
4439
|
+
fillingEntitySlots.push(entitySlot);
|
|
4381
4440
|
indexKeysService.set(entitySlot, indexKeysPosition, key);
|
|
4382
4441
|
if (!isMoving) continue;
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4442
|
+
prevKeys.push(prevKey);
|
|
4443
|
+
movingEntitySlots.push(entitySlot);
|
|
4444
|
+
}
|
|
4445
|
+
this.slotContentBucketService.fillBucketMemberSlots(bucketSlot, fillingEntitySlots);
|
|
4446
|
+
for (let i = 0; i < movingEntitySlots.length; i++) {
|
|
4447
|
+
const prevBucketSlot = this.findSlotByKey(indexStoreSlot, prevKeys[i]);
|
|
4448
|
+
if (prevBucketSlot !== void 0) this.slotContentBucketService.removeBucketMemberSlot(prevBucketSlot, movingEntitySlots[i]);
|
|
4386
4449
|
}
|
|
4387
|
-
return movableEntitySlots ?? entitySlots;
|
|
4388
4450
|
}
|
|
4389
4451
|
};
|
|
4390
4452
|
function takeNothing() {
|
|
4391
4453
|
return;
|
|
4392
4454
|
}
|
|
4393
4455
|
|
|
4394
|
-
// src/
|
|
4456
|
+
// src/index/OIMSlotCollectionSortedArrayIndexService.ts
|
|
4395
4457
|
var OIMSlotCollectionSortedArrayIndexService = class extends OIMSlotCollectionIndexService {
|
|
4396
4458
|
constructor(options) {
|
|
4397
4459
|
super(options);
|
|
4398
4460
|
const sortColumnNames = /* @__PURE__ */ new Set();
|
|
4399
|
-
for (let i = 0; i < options.sortColumns.length; i++) sortColumnNames.add(options.sortColumns[i].
|
|
4461
|
+
for (let i = 0; i < options.sortColumns.length; i++) sortColumnNames.add(options.sortColumns[i].columnName);
|
|
4400
4462
|
this.sortColumnNames = sortColumnNames;
|
|
4401
4463
|
}
|
|
4402
4464
|
createIndexStoreSlot(sourceStoreSlot) {
|
|
@@ -4418,7 +4480,51 @@ var OIMSlotCollectionSortedArrayIndexService = class extends OIMSlotCollectionIn
|
|
|
4418
4480
|
}
|
|
4419
4481
|
};
|
|
4420
4482
|
|
|
4421
|
-
// src/
|
|
4483
|
+
// src/index/OIMIndexKeysService.ts
|
|
4484
|
+
var OIMIndexKeysService = class {
|
|
4485
|
+
createPositions() {
|
|
4486
|
+
return { nextPosition: 0, freePositions: [] };
|
|
4487
|
+
}
|
|
4488
|
+
get(slot, position) {
|
|
4489
|
+
const indexKeys = slot.indexKeys;
|
|
4490
|
+
return indexKeys === void 0 || position >= indexKeys.length ? void 0 : indexKeys[position];
|
|
4491
|
+
}
|
|
4492
|
+
set(slot, position, indexKey) {
|
|
4493
|
+
const indexKeys = slot.indexKeys;
|
|
4494
|
+
if (indexKeys !== void 0) {
|
|
4495
|
+
if (position < indexKeys.length) {
|
|
4496
|
+
indexKeys[position] = indexKey;
|
|
4497
|
+
return;
|
|
4498
|
+
}
|
|
4499
|
+
if (indexKey === void 0) return;
|
|
4500
|
+
while (indexKeys.length < position) indexKeys.push(void 0);
|
|
4501
|
+
indexKeys.push(indexKey);
|
|
4502
|
+
return;
|
|
4503
|
+
}
|
|
4504
|
+
if (indexKey === void 0) return;
|
|
4505
|
+
const created = [];
|
|
4506
|
+
while (created.length < position) created.push(void 0);
|
|
4507
|
+
created.push(indexKey);
|
|
4508
|
+
slot.indexKeys = created;
|
|
4509
|
+
}
|
|
4510
|
+
};
|
|
4511
|
+
|
|
4512
|
+
// src/index/OIMAppendingIndexKeysService.ts
|
|
4513
|
+
var _OIMAppendingIndexKeysService = class _OIMAppendingIndexKeysService extends OIMIndexKeysService {
|
|
4514
|
+
allocatePosition(positions) {
|
|
4515
|
+
return positions.nextPosition++;
|
|
4516
|
+
}
|
|
4517
|
+
releasePosition() {
|
|
4518
|
+
return;
|
|
4519
|
+
}
|
|
4520
|
+
};
|
|
4521
|
+
_OIMAppendingIndexKeysService.INSTANCE = new _OIMAppendingIndexKeysService();
|
|
4522
|
+
var OIMAppendingIndexKeysService = _OIMAppendingIndexKeysService;
|
|
4523
|
+
|
|
4524
|
+
// src/db/constants/OIM_DEFAULT_INDEX_KEYS_SERVICE.ts
|
|
4525
|
+
var OIM_DEFAULT_INDEX_KEYS_SERVICE = /* @__PURE__ */ new OIMDefaultValue(() => OIMAppendingIndexKeysService.INSTANCE);
|
|
4526
|
+
|
|
4527
|
+
// src/index/utils/oimKeyOfColumns.ts
|
|
4422
4528
|
function oimKeyOfColumns(columns) {
|
|
4423
4529
|
if (columns.length === 1) {
|
|
4424
4530
|
const column = columns[0];
|
|
@@ -4431,47 +4537,47 @@ function oimKeyOfColumns(columns) {
|
|
|
4431
4537
|
};
|
|
4432
4538
|
}
|
|
4433
4539
|
|
|
4434
|
-
// src/
|
|
4435
|
-
function
|
|
4540
|
+
// src/index/utils/oimResolveSlotCollectionIndexServiceOptions.ts
|
|
4541
|
+
function oimResolveSlotCollectionIndexServiceOptions(defaults, options, slotStoreService, slotContentService) {
|
|
4436
4542
|
return {
|
|
4437
|
-
...
|
|
4543
|
+
...oimResolveSlotOwnerServiceOptions(defaults, options),
|
|
4438
4544
|
slotStoreService,
|
|
4439
4545
|
slotContentService,
|
|
4440
|
-
storeSlotListener: OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
|
|
4546
|
+
storeSlotListener: defaults.storeSlotListener ?? OIM_DEFAULT_STORE_SLOT_LISTENER.getValue(),
|
|
4441
4547
|
keyOf: options.keyOf ?? oimKeyOfColumns(options.columns),
|
|
4442
4548
|
columns: options.columns,
|
|
4443
4549
|
sourceSlotCollectionService: options.entityService,
|
|
4444
|
-
indexKeysService:
|
|
4550
|
+
indexKeysService: defaults.indexKeysService ?? OIM_DEFAULT_INDEX_KEYS_SERVICE.getValue()
|
|
4445
4551
|
};
|
|
4446
4552
|
}
|
|
4447
4553
|
|
|
4448
|
-
// src/
|
|
4449
|
-
function createOIMSlotCollectionIndexService(
|
|
4450
|
-
return new OIMSlotCollectionIndexService(
|
|
4451
|
-
|
|
4554
|
+
// src/index/createOIMSlotCollectionIndexService.ts
|
|
4555
|
+
function createOIMSlotCollectionIndexService(options) {
|
|
4556
|
+
return new OIMSlotCollectionIndexService(oimResolveSlotCollectionIndexServiceOptions(
|
|
4557
|
+
options.defaults ?? OIMDefaults.INSTANCE,
|
|
4452
4558
|
options,
|
|
4453
|
-
|
|
4559
|
+
oimResolveSlotStoreService(options.bucketSlotStoreService),
|
|
4454
4560
|
options.slotContentService ?? new OIMSlotContentPositionalArrayBucketService()
|
|
4455
4561
|
));
|
|
4456
4562
|
}
|
|
4457
4563
|
|
|
4458
|
-
// src/
|
|
4459
|
-
function createOIMSlotCollectionSortedArrayIndexService(
|
|
4564
|
+
// src/index/createOIMSlotCollectionSortedArrayIndexService.ts
|
|
4565
|
+
function createOIMSlotCollectionSortedArrayIndexService(options) {
|
|
4460
4566
|
const slotContentService = new OIMSlotContentSortedArrayBucketService({
|
|
4461
4567
|
compareBucketMemberSlots: oimEntitySlotsComparator(oimColumnsComparator(options.sortColumns))
|
|
4462
4568
|
});
|
|
4463
4569
|
return new OIMSlotCollectionSortedArrayIndexService({
|
|
4464
|
-
...
|
|
4465
|
-
|
|
4570
|
+
...oimResolveSlotCollectionIndexServiceOptions(
|
|
4571
|
+
options.defaults ?? OIMDefaults.INSTANCE,
|
|
4466
4572
|
options,
|
|
4467
|
-
|
|
4573
|
+
oimResolveSlotStoreService(options.bucketSlotStoreService),
|
|
4468
4574
|
slotContentService
|
|
4469
4575
|
),
|
|
4470
4576
|
sortColumns: options.sortColumns
|
|
4471
4577
|
});
|
|
4472
4578
|
}
|
|
4473
4579
|
|
|
4474
|
-
// src/
|
|
4580
|
+
// src/index/OIMReclaimingIndexKeysService.ts
|
|
4475
4581
|
var OIMReclaimingIndexKeysService = class extends OIMIndexKeysService {
|
|
4476
4582
|
allocatePosition(positions) {
|
|
4477
4583
|
const freePosition = positions.freePositions.pop();
|
|
@@ -4486,18 +4592,18 @@ var OIMReclaimingIndexKeysService = class extends OIMIndexKeysService {
|
|
|
4486
4592
|
}
|
|
4487
4593
|
};
|
|
4488
4594
|
|
|
4489
|
-
// src/
|
|
4595
|
+
// src/entity/utils/oimCopyEntity.ts
|
|
4490
4596
|
function oimCopyEntity(entity) {
|
|
4491
4597
|
return { ...entity };
|
|
4492
4598
|
}
|
|
4493
4599
|
|
|
4494
|
-
// src/
|
|
4600
|
+
// src/entity/createOIMReplacingEntityWriter.ts
|
|
4495
4601
|
function storeReplacement(slot, next) {
|
|
4496
4602
|
if (next === void 0) return false;
|
|
4497
4603
|
slot.entity = next;
|
|
4498
4604
|
return true;
|
|
4499
4605
|
}
|
|
4500
|
-
function
|
|
4606
|
+
function deleteColumnsInCopy(slot, names) {
|
|
4501
4607
|
const deleted = oimOwnedColumnNames(slot, names);
|
|
4502
4608
|
if (deleted === void 0) return OIM_FROZEN_EMPTY_COLUMN_NAMES;
|
|
4503
4609
|
const next = oimCopyEntity(slot.entity);
|
|
@@ -4505,61 +4611,61 @@ function deleteColumnsReplacing(slot, names) {
|
|
|
4505
4611
|
slot.entity = next;
|
|
4506
4612
|
return deleted;
|
|
4507
4613
|
}
|
|
4508
|
-
function
|
|
4614
|
+
function createOIMReplacingEntityWriter(options) {
|
|
4509
4615
|
const {
|
|
4510
4616
|
sameValueGuard,
|
|
4511
4617
|
entityInserter,
|
|
4512
4618
|
putEntityColumns,
|
|
4513
4619
|
patchEntityColumns,
|
|
4514
4620
|
patchEntityColumn
|
|
4515
|
-
} =
|
|
4621
|
+
} = oimResolveEntityWriterOptions(options);
|
|
4516
4622
|
return {
|
|
4517
4623
|
fillEntity: entityInserter,
|
|
4518
4624
|
clearEntity: oimClearEntity,
|
|
4519
4625
|
putEntity: (slot, entity, changedColumnNames) => storeReplacement(slot, putEntityColumns(slot, entity, sameValueGuard, changedColumnNames, oimCopyEntity)),
|
|
4520
4626
|
patchEntity: (slot, patch, changedColumnNames) => storeReplacement(slot, patchEntityColumns(slot, patch, sameValueGuard, changedColumnNames, oimCopyEntity)),
|
|
4521
4627
|
patchColumn: (slot, columnName, value, changedColumnNames) => storeReplacement(slot, patchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, oimCopyEntity)),
|
|
4522
|
-
deleteColumns:
|
|
4628
|
+
deleteColumns: deleteColumnsInCopy
|
|
4523
4629
|
};
|
|
4524
4630
|
}
|
|
4525
4631
|
|
|
4526
|
-
// src/
|
|
4632
|
+
// src/entity/utils/oimInsertEntityWithCopy.ts
|
|
4527
4633
|
function oimInsertEntityWithCopy(slot, entity) {
|
|
4528
4634
|
slot.entity = oimCopyEntity(entity);
|
|
4529
4635
|
}
|
|
4530
4636
|
|
|
4531
|
-
// src/
|
|
4532
|
-
function
|
|
4637
|
+
// src/entity/utils/oimSanitizedCopyEntity.ts
|
|
4638
|
+
function oimSanitizedCopyEntity(entity) {
|
|
4533
4639
|
const copy = { ...entity };
|
|
4534
4640
|
if (Object.hasOwn(copy, OIM_PROTO_KEY)) delete copy[OIM_PROTO_KEY];
|
|
4535
4641
|
return copy;
|
|
4536
4642
|
}
|
|
4537
4643
|
|
|
4538
|
-
// src/
|
|
4644
|
+
// src/entity/utils/oimInsertEntityWithSanitizedCopy.ts
|
|
4539
4645
|
function oimInsertEntityWithSanitizedCopy(slot, entity) {
|
|
4540
|
-
slot.entity =
|
|
4646
|
+
slot.entity = oimSanitizedCopyEntity(entity);
|
|
4541
4647
|
}
|
|
4542
4648
|
|
|
4543
|
-
// src/
|
|
4544
|
-
function
|
|
4649
|
+
// src/entity/utils/oimIsPlainObject.ts
|
|
4650
|
+
function oimIsPlainObject(source) {
|
|
4545
4651
|
const proto = Object.getPrototypeOf(source);
|
|
4546
4652
|
return proto === Object.prototype || proto === null;
|
|
4547
4653
|
}
|
|
4548
4654
|
|
|
4549
|
-
// src/
|
|
4655
|
+
// src/entity/utils/oimOwnEntityColumns.ts
|
|
4550
4656
|
function oimOwnEntityColumns(entity) {
|
|
4551
|
-
if (
|
|
4552
|
-
return
|
|
4657
|
+
if (oimIsPlainObject(entity) && !Object.hasOwn(entity, OIM_PROTO_KEY)) return entity;
|
|
4658
|
+
return oimSanitizedCopyEntity(entity);
|
|
4553
4659
|
}
|
|
4554
4660
|
|
|
4555
|
-
// src/
|
|
4556
|
-
var
|
|
4661
|
+
// src/entity/utils/oimGuardedPatchEntityColumns.ts
|
|
4662
|
+
var oimGuardedPatchEntityColumns = (slot, patch, sameValueGuard, changedColumnNames, targetOf) => oimPatchEntityColumns(slot, oimOwnEntityColumns(patch), sameValueGuard, changedColumnNames, targetOf);
|
|
4557
4663
|
|
|
4558
|
-
// src/
|
|
4559
|
-
var
|
|
4664
|
+
// src/entity/utils/oimGuardedPatchEntityColumn.ts
|
|
4665
|
+
var oimGuardedPatchEntityColumn = (slot, columnName, value, sameValueGuard, changedColumnNames, targetOf) => oimIsProtoKey(columnName) ? void 0 : oimPatchEntityColumn(slot, columnName, value, sameValueGuard, changedColumnNames, targetOf);
|
|
4560
4666
|
|
|
4561
|
-
// src/
|
|
4562
|
-
var
|
|
4667
|
+
// src/entity/utils/oimGuardedPutEntityColumns.ts
|
|
4668
|
+
var oimGuardedPutEntityColumns = (slot, entity, sameValueGuard, changedColumnNames, targetOf) => {
|
|
4563
4669
|
const prevEntity = slot.entity;
|
|
4564
4670
|
if (prevEntity === void 0) return void 0;
|
|
4565
4671
|
const ownColumns = oimOwnEntityColumns(entity);
|
|
@@ -4574,13 +4680,13 @@ var oimPutEntityColumnsGuarded = (slot, entity, sameValueGuard, changedColumnNam
|
|
|
4574
4680
|
);
|
|
4575
4681
|
};
|
|
4576
4682
|
|
|
4577
|
-
// src/
|
|
4683
|
+
// src/collector/constants/OIM_SLICE_LENGTH_MS.ts
|
|
4578
4684
|
var OIM_SLICE_LENGTH_MS = 1024;
|
|
4579
4685
|
|
|
4580
|
-
// src/
|
|
4686
|
+
// src/collector/utils/oimSliceOfMs.ts
|
|
4581
4687
|
var oimSliceOfMs = (ms) => Math.floor(ms / OIM_SLICE_LENGTH_MS);
|
|
4582
4688
|
|
|
4583
|
-
// src/
|
|
4689
|
+
// src/collector/OIMSlotWheel.ts
|
|
4584
4690
|
var OIMSlotWheel = class {
|
|
4585
4691
|
constructor(options) {
|
|
4586
4692
|
this.scheduledCallback = void 0;
|
|
@@ -4718,7 +4824,7 @@ var OIMSlotWheel = class {
|
|
|
4718
4824
|
}
|
|
4719
4825
|
};
|
|
4720
4826
|
|
|
4721
|
-
// src/
|
|
4827
|
+
// src/collector/OIMSlotReleaseWheel.ts
|
|
4722
4828
|
var OIMSlotReleaseWheel = class extends OIMSlotWheel {
|
|
4723
4829
|
constructor(options) {
|
|
4724
4830
|
super(options);
|
|
@@ -4779,20 +4885,20 @@ var OIMSlotReleaseWheel = class extends OIMSlotWheel {
|
|
|
4779
4885
|
}
|
|
4780
4886
|
};
|
|
4781
4887
|
|
|
4782
|
-
// src/
|
|
4888
|
+
// src/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_WRITE.ts
|
|
4783
4889
|
var OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_WRITE = 8;
|
|
4784
4890
|
|
|
4785
|
-
// src/
|
|
4891
|
+
// src/slot/utils/oimGetReleaseDueAfterWriteMs.ts
|
|
4786
4892
|
function oimGetReleaseDueAfterWriteMs(slot) {
|
|
4787
4893
|
return slot.releaseDueAfterWriteMs;
|
|
4788
4894
|
}
|
|
4789
4895
|
|
|
4790
|
-
// src/
|
|
4896
|
+
// src/slot/utils/oimSetReleaseDueAfterWriteMs.ts
|
|
4791
4897
|
function oimSetReleaseDueAfterWriteMs(slot, releaseDueMs) {
|
|
4792
4898
|
slot.releaseDueAfterWriteMs = releaseDueMs;
|
|
4793
4899
|
}
|
|
4794
4900
|
|
|
4795
|
-
// src/
|
|
4901
|
+
// src/collector/utils/oimMintAfterWriteSlotReleaseWheel.ts
|
|
4796
4902
|
function oimMintAfterWriteSlotReleaseWheel(collectorSlot) {
|
|
4797
4903
|
return collectorSlot.afterWriteSlotReleaseWheel ?? (collectorSlot.afterWriteSlotReleaseWheel = new OIMSlotReleaseWheel({
|
|
4798
4904
|
...collectorSlot.slotWheelOptions,
|
|
@@ -4802,20 +4908,20 @@ function oimMintAfterWriteSlotReleaseWheel(collectorSlot) {
|
|
|
4802
4908
|
}));
|
|
4803
4909
|
}
|
|
4804
4910
|
|
|
4805
|
-
// src/
|
|
4911
|
+
// src/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_IDLE.ts
|
|
4806
4912
|
var OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_IDLE = 4;
|
|
4807
4913
|
|
|
4808
|
-
// src/
|
|
4914
|
+
// src/slot/utils/oimGetReleaseDueAfterIdleMs.ts
|
|
4809
4915
|
function oimGetReleaseDueAfterIdleMs(slot) {
|
|
4810
4916
|
return slot.releaseDueAfterIdleMs;
|
|
4811
4917
|
}
|
|
4812
4918
|
|
|
4813
|
-
// src/
|
|
4919
|
+
// src/slot/utils/oimSetReleaseDueAfterIdleMs.ts
|
|
4814
4920
|
function oimSetReleaseDueAfterIdleMs(slot, releaseDueMs) {
|
|
4815
4921
|
slot.releaseDueAfterIdleMs = releaseDueMs;
|
|
4816
4922
|
}
|
|
4817
4923
|
|
|
4818
|
-
// src/
|
|
4924
|
+
// src/collector/utils/oimMintAfterIdleSlotReleaseWheel.ts
|
|
4819
4925
|
function oimMintAfterIdleSlotReleaseWheel(collectorSlot) {
|
|
4820
4926
|
return collectorSlot.afterIdleSlotReleaseWheel ?? (collectorSlot.afterIdleSlotReleaseWheel = new OIMSlotReleaseWheel({
|
|
4821
4927
|
...collectorSlot.slotWheelOptions,
|
|
@@ -4825,20 +4931,20 @@ function oimMintAfterIdleSlotReleaseWheel(collectorSlot) {
|
|
|
4825
4931
|
}));
|
|
4826
4932
|
}
|
|
4827
4933
|
|
|
4828
|
-
// src/
|
|
4934
|
+
// src/collector/constants/OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_UNHOLD.ts
|
|
4829
4935
|
var OIM_SLOT_FLAG_RELEASE_SCHEDULED_AFTER_UNHOLD = 16;
|
|
4830
4936
|
|
|
4831
|
-
// src/
|
|
4937
|
+
// src/slot/utils/oimGetReleaseDueAfterUnholdMs.ts
|
|
4832
4938
|
function oimGetReleaseDueAfterUnholdMs(slot) {
|
|
4833
4939
|
return slot.releaseDueAfterUnholdMs;
|
|
4834
4940
|
}
|
|
4835
4941
|
|
|
4836
|
-
// src/
|
|
4942
|
+
// src/slot/utils/oimSetReleaseDueAfterUnholdMs.ts
|
|
4837
4943
|
function oimSetReleaseDueAfterUnholdMs(slot, releaseDueMs) {
|
|
4838
4944
|
slot.releaseDueAfterUnholdMs = releaseDueMs;
|
|
4839
4945
|
}
|
|
4840
4946
|
|
|
4841
|
-
// src/
|
|
4947
|
+
// src/collector/utils/oimMintAfterUnholdSlotReleaseWheel.ts
|
|
4842
4948
|
function oimMintAfterUnholdSlotReleaseWheel(collectorSlot) {
|
|
4843
4949
|
return collectorSlot.afterUnholdSlotReleaseWheel ?? (collectorSlot.afterUnholdSlotReleaseWheel = new OIMSlotReleaseWheel({
|
|
4844
4950
|
...collectorSlot.slotWheelOptions,
|
|
@@ -4848,7 +4954,7 @@ function oimMintAfterUnholdSlotReleaseWheel(collectorSlot) {
|
|
|
4848
4954
|
}));
|
|
4849
4955
|
}
|
|
4850
4956
|
|
|
4851
|
-
// src/
|
|
4957
|
+
// src/collector/OIMSlotRefetchWheel.ts
|
|
4852
4958
|
var OIMSlotRefetchWheel = class extends OIMSlotWheel {
|
|
4853
4959
|
constructor(options) {
|
|
4854
4960
|
super({
|
|
@@ -4882,7 +4988,7 @@ var OIMSlotRefetchWheel = class extends OIMSlotWheel {
|
|
|
4882
4988
|
}
|
|
4883
4989
|
};
|
|
4884
4990
|
|
|
4885
|
-
// src/
|
|
4991
|
+
// src/collector/OIMSlotReleaseAutoDueFramePolicy.ts
|
|
4886
4992
|
var _OIMSlotReleaseAutoDueFramePolicy = class _OIMSlotReleaseAutoDueFramePolicy {
|
|
4887
4993
|
isSlotReleaseDueFrameOpen() {
|
|
4888
4994
|
return true;
|
|
@@ -4891,7 +4997,7 @@ var _OIMSlotReleaseAutoDueFramePolicy = class _OIMSlotReleaseAutoDueFramePolicy
|
|
|
4891
4997
|
_OIMSlotReleaseAutoDueFramePolicy.INSTANCE = new _OIMSlotReleaseAutoDueFramePolicy();
|
|
4892
4998
|
var OIMSlotReleaseAutoDueFramePolicy = _OIMSlotReleaseAutoDueFramePolicy;
|
|
4893
4999
|
|
|
4894
|
-
// src/
|
|
5000
|
+
// src/collector/OIMSlotAfterWriteReleasePolicy.ts
|
|
4895
5001
|
var OIMSlotAfterWriteReleasePolicy = class {
|
|
4896
5002
|
constructor(options) {
|
|
4897
5003
|
this.releasesWrittenSlots = true;
|
|
@@ -4920,7 +5026,7 @@ var OIMSlotAfterWriteReleasePolicy = class {
|
|
|
4920
5026
|
}
|
|
4921
5027
|
};
|
|
4922
5028
|
|
|
4923
|
-
// src/
|
|
5029
|
+
// src/collector/OIMSlotReleaseManualDueFramePolicy.ts
|
|
4924
5030
|
var OIMSlotReleaseManualDueFramePolicy = class {
|
|
4925
5031
|
constructor() {
|
|
4926
5032
|
this.slotReleaseDueFrameDepth = 0;
|
|
@@ -4949,7 +5055,7 @@ var OIMSlotReleaseManualDueFramePolicy = class {
|
|
|
4949
5055
|
}
|
|
4950
5056
|
};
|
|
4951
5057
|
|
|
4952
|
-
// src/
|
|
5058
|
+
// src/collector/OIMSlotAfterIdleReleasePolicy.ts
|
|
4953
5059
|
var OIMSlotAfterIdleReleasePolicy = class {
|
|
4954
5060
|
constructor(options) {
|
|
4955
5061
|
this.releasesWrittenSlots = true;
|
|
@@ -4980,7 +5086,7 @@ var OIMSlotAfterIdleReleasePolicy = class {
|
|
|
4980
5086
|
}
|
|
4981
5087
|
};
|
|
4982
5088
|
|
|
4983
|
-
// src/
|
|
5089
|
+
// src/collector/OIMSlotNeverReleasePolicy.ts
|
|
4984
5090
|
var _OIMSlotNeverReleasePolicy = class _OIMSlotNeverReleasePolicy {
|
|
4985
5091
|
constructor() {
|
|
4986
5092
|
this.releasesWrittenSlots = false;
|
|
@@ -5008,7 +5114,7 @@ var _OIMSlotNeverReleasePolicy = class _OIMSlotNeverReleasePolicy {
|
|
|
5008
5114
|
_OIMSlotNeverReleasePolicy.INSTANCE = new _OIMSlotNeverReleasePolicy();
|
|
5009
5115
|
var OIMSlotNeverReleasePolicy = _OIMSlotNeverReleasePolicy;
|
|
5010
5116
|
|
|
5011
|
-
// src/
|
|
5117
|
+
// src/collector/OIMSlotAfterUnholdReleasePolicy.ts
|
|
5012
5118
|
var OIMSlotAfterUnholdReleasePolicy = class {
|
|
5013
5119
|
constructor(options) {
|
|
5014
5120
|
this.releasesWrittenSlots = true;
|
|
@@ -5035,7 +5141,7 @@ var OIMSlotAfterUnholdReleasePolicy = class {
|
|
|
5035
5141
|
}
|
|
5036
5142
|
};
|
|
5037
5143
|
|
|
5038
|
-
// src/
|
|
5144
|
+
// src/collector/OIMSlotEarliestReleasePolicy.ts
|
|
5039
5145
|
var askOnSlotIdle = (slotReleasePolicy, slot) => slotReleasePolicy.onSlotIdle(slot);
|
|
5040
5146
|
var askIsSlotReleasable = (slotReleasePolicy, slot) => slotReleasePolicy.isSlotReleasable(slot);
|
|
5041
5147
|
var askIsEmptySlotReleasable = (slotReleasePolicy, slot) => slotReleasePolicy.isEmptySlotReleasable(slot);
|
|
@@ -5082,13 +5188,13 @@ var OIMSlotEarliestReleasePolicy = class {
|
|
|
5082
5188
|
}
|
|
5083
5189
|
};
|
|
5084
5190
|
|
|
5085
|
-
// src/
|
|
5191
|
+
// src/store/OIMSlotTreeStoreService.ts
|
|
5086
5192
|
var OIMSlotTreeStoreService = class {
|
|
5087
5193
|
constructor(keyTreeWalk) {
|
|
5088
5194
|
this.keyTreeWalk = keyTreeWalk;
|
|
5089
5195
|
}
|
|
5090
5196
|
createStore() {
|
|
5091
|
-
return {
|
|
5197
|
+
return { rootCompositeKeyNode: { childNodes: void 0, atThisKey: void 0 }, slots: /* @__PURE__ */ new Set() };
|
|
5092
5198
|
}
|
|
5093
5199
|
ownKey(compositeKey) {
|
|
5094
5200
|
return compositeKey.slice();
|
|
@@ -5097,17 +5203,17 @@ var OIMSlotTreeStoreService = class {
|
|
|
5097
5203
|
return oimSameKeySequence(compositeKey, otherCompositeKey);
|
|
5098
5204
|
}
|
|
5099
5205
|
get(slotStoreTree, compositeKey) {
|
|
5100
|
-
return this.keyTreeWalk.nodeAt(slotStoreTree.
|
|
5206
|
+
return this.keyTreeWalk.nodeAt(slotStoreTree.rootCompositeKeyNode, compositeKey)?.atThisKey;
|
|
5101
5207
|
}
|
|
5102
5208
|
set(slotStoreTree, compositeKey, slot) {
|
|
5103
|
-
const compositeKeyNode = this.keyTreeWalk.mintNodeAt(slotStoreTree.
|
|
5209
|
+
const compositeKeyNode = this.keyTreeWalk.mintNodeAt(slotStoreTree.rootCompositeKeyNode, compositeKey);
|
|
5104
5210
|
const filedSlot = compositeKeyNode.atThisKey;
|
|
5105
5211
|
if (filedSlot !== void 0 && filedSlot !== slot) slotStoreTree.slots.delete(filedSlot);
|
|
5106
5212
|
compositeKeyNode.atThisKey = slot;
|
|
5107
5213
|
slotStoreTree.slots.add(slot);
|
|
5108
5214
|
}
|
|
5109
5215
|
remove(slotStoreTree, compositeKey) {
|
|
5110
|
-
const slot = this.keyTreeWalk.deleteKey(slotStoreTree.
|
|
5216
|
+
const slot = this.keyTreeWalk.deleteKey(slotStoreTree.rootCompositeKeyNode, compositeKey);
|
|
5111
5217
|
if (slot !== void 0) slotStoreTree.slots.delete(slot);
|
|
5112
5218
|
}
|
|
5113
5219
|
fileSlot(slotStoreTree, slot) {
|
|
@@ -5124,10 +5230,100 @@ var OIMSlotTreeStoreService = class {
|
|
|
5124
5230
|
}
|
|
5125
5231
|
};
|
|
5126
5232
|
|
|
5127
|
-
// src/
|
|
5233
|
+
// src/key/OIMKeyTreeWalk.ts
|
|
5234
|
+
var OIMKeyTreeWalk = class {
|
|
5235
|
+
mintNodeAt(rootCompositeKeyNode, compositeKey) {
|
|
5236
|
+
if (compositeKey.length === 0) throw new Error("OIMKeyTreeWalk: an empty key is not a key.");
|
|
5237
|
+
let compositeKeyNode = rootCompositeKeyNode;
|
|
5238
|
+
let firstMintedDepth = -1;
|
|
5239
|
+
let parentOfFirstMintedCompositeKeyNode = rootCompositeKeyNode;
|
|
5240
|
+
for (let i = 0; i < compositeKey.length; i++) {
|
|
5241
|
+
const compositeKeyPart = compositeKey[i];
|
|
5242
|
+
let nextCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKeyPart);
|
|
5243
|
+
if (nextCompositeKeyNode === void 0) {
|
|
5244
|
+
try {
|
|
5245
|
+
this.holdCompositeKeyPart(compositeKeyPart);
|
|
5246
|
+
} catch (failure) {
|
|
5247
|
+
if (firstMintedDepth >= 0) {
|
|
5248
|
+
parentOfFirstMintedCompositeKeyNode.childNodes?.delete(compositeKey[firstMintedDepth]);
|
|
5249
|
+
for (let j = i - 1; j >= firstMintedDepth; j--) this.unholdCompositeKeyPart(compositeKey[j]);
|
|
5250
|
+
}
|
|
5251
|
+
throw failure;
|
|
5252
|
+
}
|
|
5253
|
+
nextCompositeKeyNode = { childNodes: void 0, atThisKey: void 0 };
|
|
5254
|
+
(compositeKeyNode.childNodes ?? (compositeKeyNode.childNodes = /* @__PURE__ */ new Map())).set(compositeKeyPart, nextCompositeKeyNode);
|
|
5255
|
+
if (firstMintedDepth < 0) {
|
|
5256
|
+
firstMintedDepth = i;
|
|
5257
|
+
parentOfFirstMintedCompositeKeyNode = compositeKeyNode;
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
compositeKeyNode = nextCompositeKeyNode;
|
|
5261
|
+
}
|
|
5262
|
+
return compositeKeyNode;
|
|
5263
|
+
}
|
|
5264
|
+
nodeAt(rootCompositeKeyNode, compositeKey) {
|
|
5265
|
+
let compositeKeyNode = rootCompositeKeyNode;
|
|
5266
|
+
for (let i = 0; i < compositeKey.length; i++) {
|
|
5267
|
+
compositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[i]);
|
|
5268
|
+
if (compositeKeyNode === void 0) return void 0;
|
|
5269
|
+
}
|
|
5270
|
+
return compositeKeyNode;
|
|
5271
|
+
}
|
|
5272
|
+
deleteKey(rootCompositeKeyNode, compositeKey) {
|
|
5273
|
+
const lastDepth = compositeKey.length - 1;
|
|
5274
|
+
if (lastDepth < 0) return void 0;
|
|
5275
|
+
let compositeKeyNode = rootCompositeKeyNode;
|
|
5276
|
+
let keptCompositeKeyNode = rootCompositeKeyNode;
|
|
5277
|
+
let firstUnlinkedDepth = 0;
|
|
5278
|
+
for (let i = 0; i < lastDepth; i++) {
|
|
5279
|
+
const nextCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[i]);
|
|
5280
|
+
if (nextCompositeKeyNode === void 0) return void 0;
|
|
5281
|
+
compositeKeyNode = nextCompositeKeyNode;
|
|
5282
|
+
if (compositeKeyNode.atThisKey !== void 0 || (compositeKeyNode.childNodes?.size ?? 0) > 1) {
|
|
5283
|
+
keptCompositeKeyNode = compositeKeyNode;
|
|
5284
|
+
firstUnlinkedDepth = i + 1;
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
const lastCompositeKeyNode = compositeKeyNode.childNodes?.get(compositeKey[lastDepth]);
|
|
5288
|
+
if (lastCompositeKeyNode === void 0) return void 0;
|
|
5289
|
+
const deletedAtKey = lastCompositeKeyNode.atThisKey;
|
|
5290
|
+
if (deletedAtKey === void 0) return void 0;
|
|
5291
|
+
lastCompositeKeyNode.atThisKey = void 0;
|
|
5292
|
+
if ((lastCompositeKeyNode.childNodes?.size ?? 0) > 0) return deletedAtKey;
|
|
5293
|
+
keptCompositeKeyNode.childNodes?.delete(compositeKey[firstUnlinkedDepth]);
|
|
5294
|
+
for (let i = lastDepth; i >= firstUnlinkedDepth; i--) this.unholdCompositeKeyPart(compositeKey[i]);
|
|
5295
|
+
return deletedAtKey;
|
|
5296
|
+
}
|
|
5297
|
+
};
|
|
5298
|
+
|
|
5299
|
+
// src/key/OIMCompositeKeyTreeWalk.ts
|
|
5300
|
+
var _OIMCompositeKeyTreeWalk = class _OIMCompositeKeyTreeWalk extends OIMKeyTreeWalk {
|
|
5301
|
+
holdCompositeKeyPart(entitySlot) {
|
|
5302
|
+
entitySlot.owner.holdSlot(entitySlot);
|
|
5303
|
+
}
|
|
5304
|
+
unholdCompositeKeyPart(entitySlot) {
|
|
5305
|
+
oimUnholdSlotIfAlive(entitySlot);
|
|
5306
|
+
}
|
|
5307
|
+
};
|
|
5308
|
+
_OIMCompositeKeyTreeWalk.INSTANCE = new _OIMCompositeKeyTreeWalk();
|
|
5309
|
+
var OIMCompositeKeyTreeWalk = _OIMCompositeKeyTreeWalk;
|
|
5310
|
+
|
|
5311
|
+
// src/key/OIMScalarKeyTreeWalk.ts
|
|
5312
|
+
var _OIMScalarKeyTreeWalk = class _OIMScalarKeyTreeWalk extends OIMKeyTreeWalk {
|
|
5313
|
+
holdCompositeKeyPart() {
|
|
5314
|
+
return;
|
|
5315
|
+
}
|
|
5316
|
+
unholdCompositeKeyPart() {
|
|
5317
|
+
return;
|
|
5318
|
+
}
|
|
5319
|
+
};
|
|
5320
|
+
_OIMScalarKeyTreeWalk.INSTANCE = new _OIMScalarKeyTreeWalk();
|
|
5321
|
+
var OIMScalarKeyTreeWalk = _OIMScalarKeyTreeWalk;
|
|
5322
|
+
|
|
5323
|
+
// src/bucket/commands/constants/OIM_MAX_DIFF_SCRATCH_SLOTS.ts
|
|
5128
5324
|
var OIM_MAX_DIFF_SCRATCH_SLOTS = 4096;
|
|
5129
5325
|
|
|
5130
|
-
// src/
|
|
5326
|
+
// src/bucket/commands/utils/oimOrderedListCommandsOfTransition.ts
|
|
5131
5327
|
var indexInNext = /* @__PURE__ */ new Map();
|
|
5132
5328
|
var occurrenceAfter = new Int32Array(0);
|
|
5133
5329
|
var removedPrevIndices = new Int32Array(0);
|
|
@@ -5239,7 +5435,6 @@ export {
|
|
|
5239
5435
|
OIMCompositeKeyTreeWalk,
|
|
5240
5436
|
OIMComputedService,
|
|
5241
5437
|
OIMComputedValueService,
|
|
5242
|
-
OIMContentChangeListenerService,
|
|
5243
5438
|
OIMDB,
|
|
5244
5439
|
OIMDefaultValue,
|
|
5245
5440
|
OIMDefaults,
|
|
@@ -5256,6 +5451,7 @@ export {
|
|
|
5256
5451
|
OIMSingleComputedService,
|
|
5257
5452
|
OIMSingleSlotService,
|
|
5258
5453
|
OIMSingleSlotStoreService,
|
|
5454
|
+
OIMSingleSourceTrackingComputedService,
|
|
5259
5455
|
OIMSlotAfterIdleReleasePolicy,
|
|
5260
5456
|
OIMSlotAfterUnholdReleasePolicy,
|
|
5261
5457
|
OIMSlotAfterWriteReleasePolicy,
|
|
@@ -5266,6 +5462,7 @@ export {
|
|
|
5266
5462
|
OIMSlotCollectionSortedArrayIndexService,
|
|
5267
5463
|
OIMSlotContentArrayBucketService,
|
|
5268
5464
|
OIMSlotContentBucketService,
|
|
5465
|
+
OIMSlotContentChangeListenerService,
|
|
5269
5466
|
OIMSlotContentEntityService,
|
|
5270
5467
|
OIMSlotContentPositionalArrayBucketService,
|
|
5271
5468
|
OIMSlotContentSetBucketService,
|
|
@@ -5281,6 +5478,7 @@ export {
|
|
|
5281
5478
|
OIMSlotTreeStoreService,
|
|
5282
5479
|
OIMSlotWheel,
|
|
5283
5480
|
OIMSortedComputedService,
|
|
5481
|
+
OIMSourceTrackingComputedService,
|
|
5284
5482
|
OIMThrowAtOnceErrorPolicy,
|
|
5285
5483
|
OIMUnusedSlotCollectorService,
|
|
5286
5484
|
OIMWritableSingleSlotService,
|
|
@@ -5294,17 +5492,22 @@ export {
|
|
|
5294
5492
|
createOIMChannelSlot,
|
|
5295
5493
|
createOIMCollectorSlot,
|
|
5296
5494
|
createOIMComputedService,
|
|
5297
|
-
|
|
5298
|
-
|
|
5495
|
+
createOIMInPlaceEntityWriter,
|
|
5496
|
+
createOIMReplacingEntityWriter,
|
|
5299
5497
|
createOIMSingleComputedService,
|
|
5300
5498
|
createOIMSingleSlotService,
|
|
5499
|
+
createOIMSingleSourceTrackingComputedService,
|
|
5301
5500
|
createOIMSlotCollectionIndexService,
|
|
5302
5501
|
createOIMSlotCollectionService,
|
|
5303
5502
|
createOIMSlotCollectionSortedArrayIndexService,
|
|
5304
5503
|
createOIMSlotContentEntityService,
|
|
5305
5504
|
createOIMSortedComputedService,
|
|
5505
|
+
createOIMSourceTrackingComputedService,
|
|
5306
5506
|
createOIMUnusedSlotCollectorSlot,
|
|
5307
5507
|
oimColumnsComparator,
|
|
5508
|
+
oimGuardedPatchEntityColumn,
|
|
5509
|
+
oimGuardedPatchEntityColumns,
|
|
5510
|
+
oimGuardedPutEntityColumns,
|
|
5308
5511
|
oimHoldSlots,
|
|
5309
5512
|
oimInsertEntityWithCopy,
|
|
5310
5513
|
oimInsertEntityWithSanitizedCopy,
|
|
@@ -5317,11 +5520,8 @@ export {
|
|
|
5317
5520
|
oimMintAfterWriteSlotReleaseWheel,
|
|
5318
5521
|
oimOrderedListCommandsOfTransition,
|
|
5319
5522
|
oimPatchEntityColumn,
|
|
5320
|
-
oimPatchEntityColumnGuarded,
|
|
5321
5523
|
oimPatchEntityColumns,
|
|
5322
|
-
oimPatchEntityColumnsGuarded,
|
|
5323
5524
|
oimPutEntityColumns,
|
|
5324
|
-
oimPutEntityColumnsGuarded,
|
|
5325
5525
|
oimRefreshSourceComputeds,
|
|
5326
5526
|
oimSameKeySequence,
|
|
5327
5527
|
oimSameSlotSequence,
|