@oimdb/core 3.8.0 → 3.9.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/README.md +23 -4
- package/dist/index.cjs +209 -246
- package/dist/index.d.cts +120 -178
- package/dist/index.d.ts +120 -178
- package/dist/index.js +207 -242
- package/llms.txt +40 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
EOIMEventQueueSchedulerEventType: () => EOIMEventQueueSchedulerEventType,
|
|
27
27
|
EOIMIndexEventType: () => EOIMIndexEventType,
|
|
28
28
|
EOIMObjectEventType: () => EOIMObjectEventType,
|
|
29
|
-
|
|
29
|
+
OIMBucketCarrierProvider: () => OIMBucketCarrierProvider,
|
|
30
30
|
OIMCarrierKeyedEmitter: () => OIMCarrierKeyedEmitter,
|
|
31
31
|
OIMCarrierSingleEmitter: () => OIMCarrierSingleEmitter,
|
|
32
32
|
OIMCollection: () => OIMCollection,
|
|
@@ -93,9 +93,7 @@ __export(index_exports, {
|
|
|
93
93
|
OIMIndexStoreSetBased: () => OIMIndexStoreSetBased,
|
|
94
94
|
OIMIndexStoreTrieDrivenArrayBased: () => OIMIndexStoreTrieDrivenArrayBased,
|
|
95
95
|
OIMIndexStoreTrieDrivenSetBased: () => OIMIndexStoreTrieDrivenSetBased,
|
|
96
|
-
|
|
97
|
-
OIMKeyDomainTrie: () => OIMKeyDomainTrie,
|
|
98
|
-
OIMKeyPathCarrierResolver: () => OIMKeyPathCarrierResolver,
|
|
96
|
+
OIMKeyPathCarrierProvider: () => OIMKeyPathCarrierProvider,
|
|
99
97
|
OIMKeyedBucketArrayBased: () => OIMKeyedBucketArrayBased,
|
|
100
98
|
OIMKeyedBucketSetBased: () => OIMKeyedBucketSetBased,
|
|
101
99
|
OIMMap2Keys: () => OIMMap2Keys,
|
|
@@ -697,7 +695,7 @@ var OIMIndexArrayBased = class extends OIMIndex {
|
|
|
697
695
|
|
|
698
696
|
// src/core/OIMCarrierKeyedEmitter.ts
|
|
699
697
|
var OIMCarrierKeyedEmitter = class {
|
|
700
|
-
constructor(queue,
|
|
698
|
+
constructor(queue, carrierProvider) {
|
|
701
699
|
// Carriers with at least one subscriber — for markAllUpdated / metrics.
|
|
702
700
|
this.subscribedCarriers = /* @__PURE__ */ new Set();
|
|
703
701
|
// Pending flush batch. A plain array + a `carrier.dirty` flag for dedup —
|
|
@@ -722,17 +720,17 @@ var OIMCarrierKeyedEmitter = class {
|
|
|
722
720
|
}
|
|
723
721
|
};
|
|
724
722
|
this.queue = queue;
|
|
725
|
-
this.
|
|
723
|
+
this.carrierProvider = carrierProvider;
|
|
726
724
|
}
|
|
727
725
|
subscribeOnKey(key, handler) {
|
|
728
|
-
const carrier = this.
|
|
726
|
+
const carrier = this.carrierProvider.getOrReserveCarrier(key);
|
|
729
727
|
this.addHandler(carrier, handler);
|
|
730
728
|
return () => this.removeHandler(carrier, handler);
|
|
731
729
|
}
|
|
732
730
|
subscribeOnKeys(keys, handler) {
|
|
733
731
|
const carriers = [];
|
|
734
732
|
for (let i = 0; i < keys.length; i++) {
|
|
735
|
-
const carrier = this.
|
|
733
|
+
const carrier = this.carrierProvider.getOrReserveCarrier(keys[i]);
|
|
736
734
|
this.addHandler(carrier, handler);
|
|
737
735
|
carriers.push(carrier);
|
|
738
736
|
}
|
|
@@ -743,7 +741,7 @@ var OIMCarrierKeyedEmitter = class {
|
|
|
743
741
|
};
|
|
744
742
|
}
|
|
745
743
|
unsubscribeFromKey(key, handler) {
|
|
746
|
-
const carrier = this.
|
|
744
|
+
const carrier = this.carrierProvider.findCarrier(key);
|
|
747
745
|
if (carrier) this.removeHandler(carrier, handler);
|
|
748
746
|
}
|
|
749
747
|
unsubscribeFromKeys(keys, handler) {
|
|
@@ -766,7 +764,7 @@ var OIMCarrierKeyedEmitter = class {
|
|
|
766
764
|
subscribers.delete(handler);
|
|
767
765
|
if (subscribers.size === 0) {
|
|
768
766
|
this.subscribedCarriers.delete(carrier);
|
|
769
|
-
this.
|
|
767
|
+
this.carrierProvider.onCarrierEmptied?.(carrier);
|
|
770
768
|
}
|
|
771
769
|
}
|
|
772
770
|
/** Fast path: the writer already holds the carrier. */
|
|
@@ -784,7 +782,7 @@ var OIMCarrierKeyedEmitter = class {
|
|
|
784
782
|
this.assertNotInFlush();
|
|
785
783
|
return;
|
|
786
784
|
}
|
|
787
|
-
const carrier = this.
|
|
785
|
+
const carrier = this.carrierProvider.findCarrier(key);
|
|
788
786
|
if (carrier) this.markUpdatedCarrier(carrier);
|
|
789
787
|
else this.assertNotInFlush();
|
|
790
788
|
}
|
|
@@ -809,7 +807,7 @@ var OIMCarrierKeyedEmitter = class {
|
|
|
809
807
|
return this.subscribedCarriers.size > 0;
|
|
810
808
|
}
|
|
811
809
|
getHandlerCount(key) {
|
|
812
|
-
return this.
|
|
810
|
+
return this.carrierProvider.findCarrier(key)?.subscribers?.size ?? 0;
|
|
813
811
|
}
|
|
814
812
|
getMetrics() {
|
|
815
813
|
let totalHandlers = 0;
|
|
@@ -869,8 +867,8 @@ var OIMCarrierKeyedEmitter = class {
|
|
|
869
867
|
}
|
|
870
868
|
};
|
|
871
869
|
|
|
872
|
-
// src/core/
|
|
873
|
-
var
|
|
870
|
+
// src/core/OIMKeyedCarrierProvider.ts
|
|
871
|
+
var OIMKeyedCarrierProvider = class {
|
|
874
872
|
constructor() {
|
|
875
873
|
this.carriers = /* @__PURE__ */ new Map();
|
|
876
874
|
}
|
|
@@ -892,8 +890,8 @@ var OIMKeyedCarrierResolver = class {
|
|
|
892
890
|
|
|
893
891
|
// src/abstract/OIMReactiveIndex.ts
|
|
894
892
|
var OIMReactiveIndex = class {
|
|
895
|
-
constructor(queue, createIndex,
|
|
896
|
-
this.updateEmitter = new OIMCarrierKeyedEmitter(queue,
|
|
893
|
+
constructor(queue, createIndex, createCarrierProvider = () => new OIMKeyedCarrierProvider()) {
|
|
894
|
+
this.updateEmitter = new OIMCarrierKeyedEmitter(queue, createCarrierProvider());
|
|
897
895
|
this.index = createIndex(this.updateEmitter);
|
|
898
896
|
}
|
|
899
897
|
getEntitiesByKey(key) {
|
|
@@ -949,8 +947,8 @@ var OIMReactiveIndex = class {
|
|
|
949
947
|
|
|
950
948
|
// src/abstract/OIMReactiveIndexSetBased.ts
|
|
951
949
|
var OIMReactiveIndexSetBased = class extends OIMReactiveIndex {
|
|
952
|
-
constructor(queue, createIndex,
|
|
953
|
-
super(queue, createIndex,
|
|
950
|
+
constructor(queue, createIndex, createCarrierProvider) {
|
|
951
|
+
super(queue, createIndex, createCarrierProvider);
|
|
954
952
|
}
|
|
955
953
|
getPksByKey(key) {
|
|
956
954
|
return this.index.getPksByKey(key);
|
|
@@ -968,8 +966,8 @@ var OIMReactiveIndexSetBased = class extends OIMReactiveIndex {
|
|
|
968
966
|
|
|
969
967
|
// src/abstract/OIMReactiveIndexArrayBased.ts
|
|
970
968
|
var OIMReactiveIndexArrayBased = class extends OIMReactiveIndex {
|
|
971
|
-
constructor(queue, createIndex,
|
|
972
|
-
super(queue, createIndex,
|
|
969
|
+
constructor(queue, createIndex, createCarrierProvider) {
|
|
970
|
+
super(queue, createIndex, createCarrierProvider);
|
|
973
971
|
}
|
|
974
972
|
getPksByKey(key) {
|
|
975
973
|
return this.index.getPksByKey(key);
|
|
@@ -1244,24 +1242,10 @@ var OIMPkSelectorFactory = class {
|
|
|
1244
1242
|
}
|
|
1245
1243
|
};
|
|
1246
1244
|
|
|
1247
|
-
// src/core/OIMKeyDomainNative.ts
|
|
1248
|
-
var OIMKeyDomainNative = class {
|
|
1249
|
-
createMap() {
|
|
1250
|
-
return /* @__PURE__ */ new Map();
|
|
1251
|
-
}
|
|
1252
|
-
createSet() {
|
|
1253
|
-
return /* @__PURE__ */ new Set();
|
|
1254
|
-
}
|
|
1255
|
-
canonicalize(key) {
|
|
1256
|
-
return key;
|
|
1257
|
-
}
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
1245
|
// src/core/OIMCollectionStoreMapDriven.ts
|
|
1261
1246
|
var OIMCollectionStoreMapDriven = class extends OIMCollectionStore {
|
|
1262
1247
|
constructor() {
|
|
1263
1248
|
super(...arguments);
|
|
1264
|
-
this.keyDomain = new OIMKeyDomainNative();
|
|
1265
1249
|
this.slots = /* @__PURE__ */ new Map();
|
|
1266
1250
|
// Slots reserved by indexes for PKs whose entity has not arrived yet.
|
|
1267
1251
|
// They carry `item: undefined` and live apart from `slots` so they do not
|
|
@@ -1434,10 +1418,6 @@ var OIMCollection = class {
|
|
|
1434
1418
|
this.store = opts?.store ?? new OIMCollectionStoreMapDriven();
|
|
1435
1419
|
this.updateEntity = opts?.updateEntity ?? new OIMEntityUpdaterFactory().createMergeEntityUpdater();
|
|
1436
1420
|
}
|
|
1437
|
-
/** The collection's PK keying strategy — read by indexes and wrappers. */
|
|
1438
|
-
get keyDomain() {
|
|
1439
|
-
return this.store.keyDomain;
|
|
1440
|
-
}
|
|
1441
1421
|
getOneByPk(pk) {
|
|
1442
1422
|
return this.store.getOneByPk(pk);
|
|
1443
1423
|
}
|
|
@@ -1450,6 +1430,14 @@ var OIMCollection = class {
|
|
|
1450
1430
|
getOrReserveSlotByPk(pk) {
|
|
1451
1431
|
return this.store.getOrReserveSlotByPk(pk);
|
|
1452
1432
|
}
|
|
1433
|
+
/**
|
|
1434
|
+
* The existing slot for `pk` (live or reserved) WITHOUT creating one — used
|
|
1435
|
+
* by indexes to resolve a pk to its canonical slot for removal (delete by
|
|
1436
|
+
* reference), with no side effect for a pk that is not present.
|
|
1437
|
+
*/
|
|
1438
|
+
findSlotByPk(pk) {
|
|
1439
|
+
return this.store.findSlotByPk(pk);
|
|
1440
|
+
}
|
|
1453
1441
|
getSlotsByPks(pks) {
|
|
1454
1442
|
return this.store.getSlotsByPks(pks);
|
|
1455
1443
|
}
|
|
@@ -1536,7 +1524,9 @@ var OIMReactiveCollection = class extends OIMCollection {
|
|
|
1536
1524
|
constructor(queue, opts) {
|
|
1537
1525
|
super(opts);
|
|
1538
1526
|
this.anyUpdateHandlers = /* @__PURE__ */ new Set();
|
|
1539
|
-
|
|
1527
|
+
// Only ever holds `slot.pk` (one canonical reference per logical key), so a
|
|
1528
|
+
// native `Set` dedups correctly by reference even for composite pks.
|
|
1529
|
+
this.pendingAnyUpdatePks = /* @__PURE__ */ new Set();
|
|
1540
1530
|
this.isAnyUpdateClearPending = false;
|
|
1541
1531
|
this.isAnyUpdateScheduled = false;
|
|
1542
1532
|
this.runAnyUpdate = () => {
|
|
@@ -1812,16 +1802,16 @@ var OIMIndexManualOrderedArrayBased = class extends OIMIndexArrayBased {
|
|
|
1812
1802
|
var OIMCollectionIndexManualOrderedArrayBased = class extends OIMIndexManualOrderedArrayBased {
|
|
1813
1803
|
constructor(opts) {
|
|
1814
1804
|
super();
|
|
1815
|
-
this.
|
|
1805
|
+
this.getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getSlotByPk(pk) : opts.getSlot;
|
|
1816
1806
|
}
|
|
1817
1807
|
push(key, pk) {
|
|
1818
|
-
return this.pushSlot(key, this.
|
|
1808
|
+
return this.pushSlot(key, this.getRequiredSlot(pk));
|
|
1819
1809
|
}
|
|
1820
1810
|
insertAt(key, index, pk) {
|
|
1821
|
-
return this.insertSlotAt(key, index, this.
|
|
1811
|
+
return this.insertSlotAt(key, index, this.getRequiredSlot(pk));
|
|
1822
1812
|
}
|
|
1823
1813
|
reset(key, pks) {
|
|
1824
|
-
this.resetSlots(key, this.
|
|
1814
|
+
this.resetSlots(key, this.getRequiredSlots(pks));
|
|
1825
1815
|
}
|
|
1826
1816
|
getEntitiesByKey(key) {
|
|
1827
1817
|
return super.getEntitiesByKey(key);
|
|
@@ -1829,26 +1819,25 @@ var OIMCollectionIndexManualOrderedArrayBased = class extends OIMIndexManualOrde
|
|
|
1829
1819
|
getEntitiesByKeys(keys) {
|
|
1830
1820
|
return super.getEntitiesByKeys(keys);
|
|
1831
1821
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1822
|
+
// Gets the slot for a pk, throwing if the (custom) getter has none — this
|
|
1823
|
+
// ordered index requires a real slot to place in order.
|
|
1824
|
+
getRequiredSlot(pk) {
|
|
1825
|
+
const slot = this.getSlot(pk);
|
|
1826
|
+
if (!slot) {
|
|
1827
|
+
throw new Error(
|
|
1828
|
+
`[OIMCollectionIndexManualOrderedArrayBased]: no slot for PK "${String(pk)}".`
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
return slot;
|
|
1834
1832
|
}
|
|
1835
|
-
|
|
1833
|
+
getRequiredSlots(pks) {
|
|
1836
1834
|
const slots = [];
|
|
1837
1835
|
slots.length = pks.length;
|
|
1838
1836
|
for (let i = 0; i < pks.length; i++) {
|
|
1839
|
-
slots[i] = this.
|
|
1837
|
+
slots[i] = this.getRequiredSlot(pks[i]);
|
|
1840
1838
|
}
|
|
1841
1839
|
return slots;
|
|
1842
1840
|
}
|
|
1843
|
-
resolveRequiredSlot(pk) {
|
|
1844
|
-
const slot = this.resolveSlot(pk);
|
|
1845
|
-
if (!slot) {
|
|
1846
|
-
throw new Error(
|
|
1847
|
-
`[OIMCollectionIndexManualOrderedArrayBased]: Unable to resolve slot for PK "${String(pk)}".`
|
|
1848
|
-
);
|
|
1849
|
-
}
|
|
1850
|
-
return slot;
|
|
1851
|
-
}
|
|
1852
1841
|
};
|
|
1853
1842
|
|
|
1854
1843
|
// src/enums/EOIMEventQueueEventType.ts
|
|
@@ -2267,18 +2256,18 @@ var OIMOrderedListCommandStream = class extends OIMOrderedListCommandBuffer {
|
|
|
2267
2256
|
var OIMCollectionOrderedListCommandStream = class extends OIMOrderedListCommandStream {
|
|
2268
2257
|
constructor(queue, opts) {
|
|
2269
2258
|
const index = opts.index ?? new OIMCollectionIndexManualOrderedArrayBased(
|
|
2270
|
-
opts.collection !== void 0 ? { collection: opts.collection } : {
|
|
2259
|
+
opts.collection !== void 0 ? { collection: opts.collection } : { getSlot: opts.getSlot }
|
|
2271
2260
|
);
|
|
2272
2261
|
super(queue, index);
|
|
2273
2262
|
this.index = index;
|
|
2274
2263
|
}
|
|
2275
2264
|
push(key, pk) {
|
|
2276
|
-
const slot = this.
|
|
2265
|
+
const slot = this.getRequiredSlot(pk);
|
|
2277
2266
|
const index = this.index.pushSlot(key, slot);
|
|
2278
2267
|
this.appendCommand(key, { type: "insert", index, item: slot });
|
|
2279
2268
|
}
|
|
2280
2269
|
insertAt(key, index, pk) {
|
|
2281
|
-
const slot = this.
|
|
2270
|
+
const slot = this.getRequiredSlot(pk);
|
|
2282
2271
|
const safeIndex = this.index.insertSlotAt(key, index, slot);
|
|
2283
2272
|
this.appendCommand(key, {
|
|
2284
2273
|
type: "insert",
|
|
@@ -2288,7 +2277,7 @@ var OIMCollectionOrderedListCommandStream = class extends OIMOrderedListCommandS
|
|
|
2288
2277
|
}
|
|
2289
2278
|
/** Replace the element at `index` with the slot for `pk`, in place. */
|
|
2290
2279
|
setAt(key, index, pk) {
|
|
2291
|
-
const slot = this.
|
|
2280
|
+
const slot = this.getRequiredSlot(pk);
|
|
2292
2281
|
const safeIndex = this.index.setSlotAt(key, index, slot);
|
|
2293
2282
|
if (safeIndex < 0) return;
|
|
2294
2283
|
this.appendCommand(key, {
|
|
@@ -2298,7 +2287,7 @@ var OIMCollectionOrderedListCommandStream = class extends OIMOrderedListCommandS
|
|
|
2298
2287
|
});
|
|
2299
2288
|
}
|
|
2300
2289
|
set(key, pks) {
|
|
2301
|
-
const slots = pks.map((pk) => this.
|
|
2290
|
+
const slots = pks.map((pk) => this.getRequiredSlot(pk));
|
|
2302
2291
|
this.index.resetSlots(key, slots);
|
|
2303
2292
|
this.appendResetCommand(key, slots);
|
|
2304
2293
|
}
|
|
@@ -2310,8 +2299,8 @@ var OIMCollectionOrderedListCommandStream = class extends OIMOrderedListCommandS
|
|
|
2310
2299
|
getEntitiesByKey(key) {
|
|
2311
2300
|
return this.index.getEntitiesByKey(key);
|
|
2312
2301
|
}
|
|
2313
|
-
|
|
2314
|
-
return this.index.
|
|
2302
|
+
getRequiredSlot(pk) {
|
|
2303
|
+
return this.index.getRequiredSlot(
|
|
2315
2304
|
pk
|
|
2316
2305
|
);
|
|
2317
2306
|
}
|
|
@@ -2371,8 +2360,8 @@ var OIMIndexManualArrayBased = class extends OIMIndexArrayBased {
|
|
|
2371
2360
|
}
|
|
2372
2361
|
};
|
|
2373
2362
|
|
|
2374
|
-
// src/core/
|
|
2375
|
-
var
|
|
2363
|
+
// src/core/OIMBucketCarrierProvider.ts
|
|
2364
|
+
var OIMBucketCarrierProvider = class {
|
|
2376
2365
|
constructor(store) {
|
|
2377
2366
|
this.store = store;
|
|
2378
2367
|
}
|
|
@@ -2413,7 +2402,7 @@ var OIMReactiveIndexManualArrayBased = class extends OIMReactiveIndexArrayBased
|
|
|
2413
2402
|
comparePks: opts?.indexOptions?.comparePks,
|
|
2414
2403
|
store
|
|
2415
2404
|
}),
|
|
2416
|
-
() => new
|
|
2405
|
+
() => new OIMBucketCarrierProvider(store)
|
|
2417
2406
|
);
|
|
2418
2407
|
}
|
|
2419
2408
|
setSlots(key, slots) {
|
|
@@ -2430,52 +2419,61 @@ var OIMReactiveIndexManualArrayBased = class extends OIMReactiveIndexArrayBased
|
|
|
2430
2419
|
// src/core/OIMReactiveCollectionIndexManualArrayBased.ts
|
|
2431
2420
|
var OIMReactiveCollectionIndexManualArrayBased = class extends OIMReactiveIndexManualArrayBased {
|
|
2432
2421
|
constructor(queue, opts) {
|
|
2433
|
-
const
|
|
2434
|
-
const pkDomain = opts.collection?.keyDomain ?? new OIMKeyDomainNative();
|
|
2422
|
+
const getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getOrReserveSlotByPk(pk) : opts.getSlot;
|
|
2435
2423
|
super(queue, {
|
|
2436
2424
|
indexOptions: opts.indexOptions
|
|
2437
2425
|
});
|
|
2438
|
-
// Persistent per-key
|
|
2439
|
-
//
|
|
2440
|
-
|
|
2441
|
-
this.
|
|
2442
|
-
this.
|
|
2426
|
+
// Persistent per-key membership for O(1) `addPks` dedup, keyed by the
|
|
2427
|
+
// canonical slot reference (correct for composite pks with a native Set — no
|
|
2428
|
+
// content-addressing needed, since slots are one reference per logical key).
|
|
2429
|
+
this.slotsByKey = /* @__PURE__ */ new Map();
|
|
2430
|
+
this.getSlot = getSlot;
|
|
2431
|
+
this.findSlotForRemoval = opts.collection !== void 0 ? (pk) => opts.collection.findSlotByPk(pk) : opts.getSlot;
|
|
2443
2432
|
}
|
|
2444
2433
|
setPks(key, pks) {
|
|
2445
|
-
const
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
super.setSlots(key, this.resolveSlots(pks));
|
|
2434
|
+
const slots = this.getSlotsOrTransient(pks);
|
|
2435
|
+
this.slotsByKey.set(key, new Set(slots));
|
|
2436
|
+
super.setSlots(key, slots);
|
|
2449
2437
|
}
|
|
2450
2438
|
addPks(key, pks) {
|
|
2451
2439
|
if (pks.length === 0) return;
|
|
2452
|
-
const
|
|
2440
|
+
const slotSet = this.membershipOf(key);
|
|
2453
2441
|
const newSlots = [];
|
|
2454
2442
|
for (const pk of pks) {
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2443
|
+
const slot = this.getSlotOrTransient(pk);
|
|
2444
|
+
if (slotSet.has(slot)) continue;
|
|
2445
|
+
slotSet.add(slot);
|
|
2446
|
+
newSlots.push(slot);
|
|
2458
2447
|
}
|
|
2459
2448
|
if (newSlots.length > 0) this.appendSlots(key, newSlots);
|
|
2460
2449
|
}
|
|
2461
2450
|
removePks(key, pks) {
|
|
2462
2451
|
if (pks.length === 0) return;
|
|
2463
|
-
const
|
|
2452
|
+
const slotsToRemove = /* @__PURE__ */ new Set();
|
|
2453
|
+
const pksToRemove = /* @__PURE__ */ new Set();
|
|
2454
|
+
for (let i = 0; i < pks.length; i++) {
|
|
2455
|
+
const slot = this.findSlotForRemoval(pks[i]);
|
|
2456
|
+
if (slot) slotsToRemove.add(slot);
|
|
2457
|
+
else pksToRemove.add(pks[i]);
|
|
2458
|
+
}
|
|
2464
2459
|
const existingSlots = this.index.getSlotsByKey(key);
|
|
2465
|
-
const
|
|
2466
|
-
|
|
2467
|
-
)
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2460
|
+
const slotSet = this.slotsByKey.get(key);
|
|
2461
|
+
const nextSlots = [];
|
|
2462
|
+
for (let i = 0; i < existingSlots.length; i++) {
|
|
2463
|
+
const slot = existingSlots[i];
|
|
2464
|
+
if (slotsToRemove.has(slot) || pksToRemove.has(slot.pk)) {
|
|
2465
|
+
slotSet?.delete(slot);
|
|
2466
|
+
} else {
|
|
2467
|
+
nextSlots.push(slot);
|
|
2468
|
+
}
|
|
2472
2469
|
}
|
|
2470
|
+
if (nextSlots.length === existingSlots.length) return;
|
|
2473
2471
|
if (nextSlots.length === 0) this.clear(key);
|
|
2474
2472
|
else super.setSlots(key, nextSlots);
|
|
2475
2473
|
}
|
|
2476
2474
|
clear(key) {
|
|
2477
|
-
if (key === void 0) this.
|
|
2478
|
-
else this.
|
|
2475
|
+
if (key === void 0) this.slotsByKey.clear();
|
|
2476
|
+
else this.slotsByKey.delete(key);
|
|
2479
2477
|
super.clear(key);
|
|
2480
2478
|
}
|
|
2481
2479
|
/**
|
|
@@ -2483,16 +2481,12 @@ var OIMReactiveCollectionIndexManualArrayBased = class extends OIMReactiveIndexM
|
|
|
2483
2481
|
* stays correct even if slots were set through a lower-level path.
|
|
2484
2482
|
*/
|
|
2485
2483
|
membershipOf(key) {
|
|
2486
|
-
let
|
|
2487
|
-
if (!
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
for (let i = 0; i < existing.length; i++) {
|
|
2491
|
-
pkSet.add(existing[i].pk);
|
|
2492
|
-
}
|
|
2493
|
-
this.pksByKey.set(key, pkSet);
|
|
2484
|
+
let slotSet = this.slotsByKey.get(key);
|
|
2485
|
+
if (!slotSet) {
|
|
2486
|
+
slotSet = new Set(this.index.getSlotsByKey(key));
|
|
2487
|
+
this.slotsByKey.set(key, slotSet);
|
|
2494
2488
|
}
|
|
2495
|
-
return
|
|
2489
|
+
return slotSet;
|
|
2496
2490
|
}
|
|
2497
2491
|
getEntitiesByKey(key) {
|
|
2498
2492
|
return super.getEntitiesByKey(key);
|
|
@@ -2500,16 +2494,16 @@ var OIMReactiveCollectionIndexManualArrayBased = class extends OIMReactiveIndexM
|
|
|
2500
2494
|
getEntitiesByKeys(keys) {
|
|
2501
2495
|
return super.getEntitiesByKeys(keys);
|
|
2502
2496
|
}
|
|
2503
|
-
|
|
2497
|
+
getSlotsOrTransient(pks) {
|
|
2504
2498
|
const slots = [];
|
|
2505
2499
|
slots.length = pks.length;
|
|
2506
2500
|
for (let i = 0; i < pks.length; i++) {
|
|
2507
|
-
slots[i] = this.
|
|
2501
|
+
slots[i] = this.getSlotOrTransient(pks[i]);
|
|
2508
2502
|
}
|
|
2509
2503
|
return slots;
|
|
2510
2504
|
}
|
|
2511
|
-
|
|
2512
|
-
const slot = this.
|
|
2505
|
+
getSlotOrTransient(pk) {
|
|
2506
|
+
const slot = this.getSlot(pk);
|
|
2513
2507
|
if (!slot) return { pk, item: void 0 };
|
|
2514
2508
|
return slot;
|
|
2515
2509
|
}
|
|
@@ -2519,7 +2513,6 @@ var OIMReactiveCollectionIndexManualArrayBased = class extends OIMReactiveIndexM
|
|
|
2519
2513
|
var OIMIndexManualSetBased = class extends OIMIndexSetBased {
|
|
2520
2514
|
constructor(options = {}) {
|
|
2521
2515
|
super(options);
|
|
2522
|
-
this.pkDomain = options.pkDomain ?? new OIMKeyDomainNative();
|
|
2523
2516
|
}
|
|
2524
2517
|
setSlots(key, slots) {
|
|
2525
2518
|
const bucket = this.setStore.getOrReserveBucket(key);
|
|
@@ -2528,27 +2521,28 @@ var OIMIndexManualSetBased = class extends OIMIndexSetBased {
|
|
|
2528
2521
|
// --- pk-oriented writes: resolve the bucket ONCE and use its own membership
|
|
2529
2522
|
// (pk → slot) for dedup/removal, so a composite (trie) key is walked a single
|
|
2530
2523
|
// time instead of once for the bucket and once for a separate membership map.
|
|
2531
|
-
setPks(key, pks,
|
|
2524
|
+
setPks(key, pks, getSlot) {
|
|
2532
2525
|
const bucket = this.setStore.getOrReserveBucket(key);
|
|
2533
2526
|
const slots = [];
|
|
2534
|
-
for (let i = 0; i < pks.length; i++) slots.push(
|
|
2527
|
+
for (let i = 0; i < pks.length; i++) slots.push(getSlot(pks[i]));
|
|
2535
2528
|
this.replaceBucketContents(bucket, slots);
|
|
2536
|
-
const membership = bucket.membership ?? (bucket.membership =
|
|
2529
|
+
const membership = bucket.membership ?? (bucket.membership = /* @__PURE__ */ new Map());
|
|
2537
2530
|
membership.clear();
|
|
2538
|
-
for (let i = 0; i <
|
|
2539
|
-
if (!membership.has(
|
|
2531
|
+
for (let i = 0; i < slots.length; i++) {
|
|
2532
|
+
if (!membership.has(slots[i].pk)) {
|
|
2533
|
+
membership.set(slots[i].pk, slots[i]);
|
|
2534
|
+
}
|
|
2540
2535
|
}
|
|
2541
2536
|
}
|
|
2542
|
-
addPks(key, pks,
|
|
2537
|
+
addPks(key, pks, getSlot) {
|
|
2543
2538
|
if (pks.length === 0) return;
|
|
2544
2539
|
const bucket = this.setStore.getOrReserveBucket(key);
|
|
2545
2540
|
const membership = this.membershipOf(bucket);
|
|
2546
2541
|
let changed = false;
|
|
2547
2542
|
for (let i = 0; i < pks.length; i++) {
|
|
2548
|
-
const
|
|
2549
|
-
if (membership.has(pk)) continue;
|
|
2550
|
-
|
|
2551
|
-
membership.set(pk, slot);
|
|
2543
|
+
const slot = getSlot(pks[i]);
|
|
2544
|
+
if (membership.has(slot.pk)) continue;
|
|
2545
|
+
membership.set(slot.pk, slot);
|
|
2552
2546
|
if (!bucket.has(slot)) {
|
|
2553
2547
|
bucket.add(slot);
|
|
2554
2548
|
changed = true;
|
|
@@ -2558,6 +2552,11 @@ var OIMIndexManualSetBased = class extends OIMIndexSetBased {
|
|
|
2558
2552
|
this.setStore.retainBucket(bucket);
|
|
2559
2553
|
this.emitBucketChanged(bucket);
|
|
2560
2554
|
}
|
|
2555
|
+
/**
|
|
2556
|
+
* Removes by pk. `pks` must be canonical `slot.pk` references (membership is
|
|
2557
|
+
* keyed by them): for primitive pks that is just the pk; a collection-bound
|
|
2558
|
+
* composite index canonicalizes raw pks to `slot.pk` before calling this.
|
|
2559
|
+
*/
|
|
2561
2560
|
removePks(key, pks) {
|
|
2562
2561
|
if (pks.length === 0) return;
|
|
2563
2562
|
const bucket = this.setStore.findBucket(key);
|
|
@@ -2583,7 +2582,7 @@ var OIMIndexManualSetBased = class extends OIMIndexSetBased {
|
|
|
2583
2582
|
membershipOf(bucket) {
|
|
2584
2583
|
let membership = bucket.membership;
|
|
2585
2584
|
if (!membership) {
|
|
2586
|
-
membership =
|
|
2585
|
+
membership = /* @__PURE__ */ new Map();
|
|
2587
2586
|
bucket.membership = membership;
|
|
2588
2587
|
}
|
|
2589
2588
|
if (membership.size === 0 && bucket.size > 0) {
|
|
@@ -2692,10 +2691,9 @@ var OIMReactiveIndexManualSetBased = class extends OIMReactiveIndexSetBased {
|
|
|
2692
2691
|
queue,
|
|
2693
2692
|
(updateEmitter) => new OIMIndexManualSetBasedReactive(updateEmitter, {
|
|
2694
2693
|
comparePks: opts?.indexOptions?.comparePks,
|
|
2695
|
-
store
|
|
2696
|
-
pkDomain: opts?.pkDomain
|
|
2694
|
+
store
|
|
2697
2695
|
}),
|
|
2698
|
-
() => new
|
|
2696
|
+
() => new OIMBucketCarrierProvider(store)
|
|
2699
2697
|
);
|
|
2700
2698
|
}
|
|
2701
2699
|
setSlots(key, slots) {
|
|
@@ -2715,28 +2713,33 @@ var OIMReactiveIndexManualSetBased = class extends OIMReactiveIndexSetBased {
|
|
|
2715
2713
|
// src/core/OIMReactiveCollectionIndexManualSetBased.ts
|
|
2716
2714
|
var OIMReactiveCollectionIndexManualSetBased = class extends OIMReactiveIndexManualSetBased {
|
|
2717
2715
|
constructor(queue, opts) {
|
|
2718
|
-
const
|
|
2716
|
+
const getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getOrReserveSlotByPk(pk) : opts.getSlot;
|
|
2719
2717
|
super(queue, {
|
|
2720
|
-
indexOptions: opts.indexOptions
|
|
2721
|
-
pkDomain: opts.collection?.keyDomain
|
|
2718
|
+
indexOptions: opts.indexOptions
|
|
2722
2719
|
});
|
|
2723
2720
|
// Bound once so the hot pk-write path passes a stable function (no per-call
|
|
2724
2721
|
// closure allocation).
|
|
2725
|
-
this.
|
|
2726
|
-
const slot = this.
|
|
2722
|
+
this.getSlotOrTransient = (pk) => {
|
|
2723
|
+
const slot = this.getSlot(pk);
|
|
2727
2724
|
if (!slot) return { pk, item: void 0 };
|
|
2728
2725
|
return slot;
|
|
2729
2726
|
};
|
|
2730
|
-
this.
|
|
2727
|
+
this.getSlot = getSlot;
|
|
2728
|
+
this.findSlotForRemoval = opts.collection !== void 0 ? (pk) => opts.collection.findSlotByPk(pk) : opts.getSlot;
|
|
2731
2729
|
}
|
|
2732
2730
|
setPks(key, pks) {
|
|
2733
|
-
this.index.setPks(key, pks, this.
|
|
2731
|
+
this.index.setPks(key, pks, this.getSlotOrTransient);
|
|
2734
2732
|
}
|
|
2735
2733
|
addPks(key, pks) {
|
|
2736
|
-
this.index.addPks(key, pks, this.
|
|
2734
|
+
this.index.addPks(key, pks, this.getSlotOrTransient);
|
|
2737
2735
|
}
|
|
2738
2736
|
removePks(key, pks) {
|
|
2739
|
-
|
|
2737
|
+
const canonical = [];
|
|
2738
|
+
for (let i = 0; i < pks.length; i++) {
|
|
2739
|
+
const slot = this.findSlotForRemoval(pks[i]);
|
|
2740
|
+
canonical.push(slot ? slot.pk : pks[i]);
|
|
2741
|
+
}
|
|
2742
|
+
this.index.removePks(key, canonical);
|
|
2740
2743
|
}
|
|
2741
2744
|
getEntitiesByKey(key) {
|
|
2742
2745
|
return super.getEntitiesByKey(key);
|
|
@@ -2945,29 +2948,34 @@ var OIMIndexStoreTrieDrivenSetBased = class extends OIMIndexStoreSetBased {
|
|
|
2945
2948
|
// src/core/OIMReactiveCollectionIndexCompositeTrieSetBased.ts
|
|
2946
2949
|
var OIMReactiveCollectionIndexCompositeTrieSetBased = class extends OIMReactiveIndexManualSetBased {
|
|
2947
2950
|
constructor(queue, opts) {
|
|
2948
|
-
const
|
|
2951
|
+
const getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getOrReserveSlotByPk(pk) : opts.getSlot;
|
|
2949
2952
|
super(queue, {
|
|
2950
2953
|
indexOptions: {
|
|
2951
2954
|
comparePks: opts.indexOptions?.comparePks,
|
|
2952
2955
|
store: opts.indexOptions?.store ?? new OIMIndexStoreTrieDrivenSetBased()
|
|
2953
|
-
}
|
|
2954
|
-
pkDomain: opts.collection?.keyDomain
|
|
2956
|
+
}
|
|
2955
2957
|
});
|
|
2956
|
-
this.
|
|
2957
|
-
const slot = this.
|
|
2958
|
+
this.getSlotOrTransient = (pk) => {
|
|
2959
|
+
const slot = this.getSlot(pk);
|
|
2958
2960
|
if (!slot) return { pk, item: void 0 };
|
|
2959
2961
|
return slot;
|
|
2960
2962
|
};
|
|
2961
|
-
this.
|
|
2963
|
+
this.getSlot = getSlot;
|
|
2964
|
+
this.findSlotForRemoval = opts.collection !== void 0 ? (pk) => opts.collection.findSlotByPk(pk) : opts.getSlot;
|
|
2962
2965
|
}
|
|
2963
2966
|
setPks(key, pks) {
|
|
2964
|
-
this.index.setPks(key, pks, this.
|
|
2967
|
+
this.index.setPks(key, pks, this.getSlotOrTransient);
|
|
2965
2968
|
}
|
|
2966
2969
|
addPks(key, pks) {
|
|
2967
|
-
this.index.addPks(key, pks, this.
|
|
2970
|
+
this.index.addPks(key, pks, this.getSlotOrTransient);
|
|
2968
2971
|
}
|
|
2969
2972
|
removePks(key, pks) {
|
|
2970
|
-
|
|
2973
|
+
const canonical = [];
|
|
2974
|
+
for (let i = 0; i < pks.length; i++) {
|
|
2975
|
+
const slot = this.findSlotForRemoval(pks[i]);
|
|
2976
|
+
canonical.push(slot ? slot.pk : pks[i]);
|
|
2977
|
+
}
|
|
2978
|
+
this.index.removePks(key, canonical);
|
|
2971
2979
|
}
|
|
2972
2980
|
getEntitiesByKey(key) {
|
|
2973
2981
|
return super.getEntitiesByKey(key);
|
|
@@ -3074,7 +3082,7 @@ var OIMIndexStoreTrieDrivenArrayBased = class extends OIMIndexStoreArrayBased {
|
|
|
3074
3082
|
// src/core/OIMReactiveCollectionIndexCompositeTrieArrayBased.ts
|
|
3075
3083
|
var OIMReactiveCollectionIndexCompositeTrieArrayBased = class extends OIMReactiveIndexManualArrayBased {
|
|
3076
3084
|
constructor(queue, opts) {
|
|
3077
|
-
const
|
|
3085
|
+
const getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getOrReserveSlotByPk(pk) : opts.getSlot;
|
|
3078
3086
|
super(queue, {
|
|
3079
3087
|
indexOptions: {
|
|
3080
3088
|
comparePks: opts.indexOptions?.comparePks,
|
|
@@ -3084,13 +3092,13 @@ var OIMReactiveCollectionIndexCompositeTrieArrayBased = class extends OIMReactiv
|
|
|
3084
3092
|
// Persistent per-key-path pk membership for O(1) `addPks` dedup. Trie-keyed
|
|
3085
3093
|
// so a rebuilt key path matches by content.
|
|
3086
3094
|
this.pksByKey = new OIMTrieMap();
|
|
3087
|
-
this.
|
|
3095
|
+
this.getSlot = getSlot;
|
|
3088
3096
|
}
|
|
3089
3097
|
setPks(key, pks) {
|
|
3090
3098
|
const pkSet = /* @__PURE__ */ new Set();
|
|
3091
3099
|
for (let i = 0; i < pks.length; i++) pkSet.add(pks[i]);
|
|
3092
3100
|
this.pksByKey.set(key, pkSet);
|
|
3093
|
-
super.setSlots(key, this.
|
|
3101
|
+
super.setSlots(key, this.getSlotsOrTransient(pks));
|
|
3094
3102
|
}
|
|
3095
3103
|
addPks(key, pks) {
|
|
3096
3104
|
if (pks.length === 0) return;
|
|
@@ -3099,7 +3107,7 @@ var OIMReactiveCollectionIndexCompositeTrieArrayBased = class extends OIMReactiv
|
|
|
3099
3107
|
for (const pk of pks) {
|
|
3100
3108
|
if (pkSet.has(pk)) continue;
|
|
3101
3109
|
pkSet.add(pk);
|
|
3102
|
-
newSlots.push(this.
|
|
3110
|
+
newSlots.push(this.getSlotOrTransient(pk));
|
|
3103
3111
|
}
|
|
3104
3112
|
if (newSlots.length > 0) this.appendSlots(key, newSlots);
|
|
3105
3113
|
}
|
|
@@ -3145,16 +3153,16 @@ var OIMReactiveCollectionIndexCompositeTrieArrayBased = class extends OIMReactiv
|
|
|
3145
3153
|
getEntitiesByKeys(keys) {
|
|
3146
3154
|
return super.getEntitiesByKeys(keys);
|
|
3147
3155
|
}
|
|
3148
|
-
|
|
3156
|
+
getSlotsOrTransient(pks) {
|
|
3149
3157
|
const slots = [];
|
|
3150
3158
|
slots.length = pks.length;
|
|
3151
3159
|
for (let i = 0; i < pks.length; i++) {
|
|
3152
|
-
slots[i] = this.
|
|
3160
|
+
slots[i] = this.getSlotOrTransient(pks[i]);
|
|
3153
3161
|
}
|
|
3154
3162
|
return slots;
|
|
3155
3163
|
}
|
|
3156
|
-
|
|
3157
|
-
const slot = this.
|
|
3164
|
+
getSlotOrTransient(pk) {
|
|
3165
|
+
const slot = this.getSlot(pk);
|
|
3158
3166
|
if (!slot) return { pk, item: void 0 };
|
|
3159
3167
|
return slot;
|
|
3160
3168
|
}
|
|
@@ -3467,20 +3475,20 @@ var OIMReactiveGlobalIndexManualArrayBased = class extends OIMReactiveGlobalInde
|
|
|
3467
3475
|
// src/core/OIMReactiveCollectionGlobalIndexManualArrayBased.ts
|
|
3468
3476
|
var OIMReactiveCollectionGlobalIndexManualArrayBased = class extends OIMReactiveGlobalIndexManualArrayBased {
|
|
3469
3477
|
constructor(queue, opts) {
|
|
3470
|
-
const
|
|
3478
|
+
const getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getOrReserveSlotByPk(pk) : opts.getSlot;
|
|
3471
3479
|
super(queue, { indexOptions: opts.indexOptions });
|
|
3472
3480
|
// Single pk membership set for O(1) `addPks` dedup. Lazily seeded from the
|
|
3473
3481
|
// bucket so it stays correct even after a raw `setSlots` (e.g. derived
|
|
3474
3482
|
// rebuild), matching the keyed index's `membershipOf`.
|
|
3475
3483
|
this.membership = /* @__PURE__ */ new Set();
|
|
3476
3484
|
this.membershipSeeded = false;
|
|
3477
|
-
this.
|
|
3485
|
+
this.getSlot = getSlot;
|
|
3478
3486
|
}
|
|
3479
3487
|
setPks(pks) {
|
|
3480
3488
|
this.membership.clear();
|
|
3481
3489
|
for (let i = 0; i < pks.length; i++) this.membership.add(pks[i]);
|
|
3482
3490
|
this.membershipSeeded = true;
|
|
3483
|
-
super.setSlots(this.
|
|
3491
|
+
super.setSlots(this.getSlotsOrTransient(pks));
|
|
3484
3492
|
}
|
|
3485
3493
|
addPks(pks) {
|
|
3486
3494
|
if (pks.length === 0) return;
|
|
@@ -3489,7 +3497,7 @@ var OIMReactiveCollectionGlobalIndexManualArrayBased = class extends OIMReactive
|
|
|
3489
3497
|
for (const pk of pks) {
|
|
3490
3498
|
if (membership.has(pk)) continue;
|
|
3491
3499
|
membership.add(pk);
|
|
3492
|
-
newSlots.push(this.
|
|
3500
|
+
newSlots.push(this.getSlotOrTransient(pk));
|
|
3493
3501
|
}
|
|
3494
3502
|
if (newSlots.length > 0) super.appendSlots(newSlots);
|
|
3495
3503
|
}
|
|
@@ -3526,16 +3534,16 @@ var OIMReactiveCollectionGlobalIndexManualArrayBased = class extends OIMReactive
|
|
|
3526
3534
|
getEntities() {
|
|
3527
3535
|
return super.getEntities();
|
|
3528
3536
|
}
|
|
3529
|
-
|
|
3537
|
+
getSlotsOrTransient(pks) {
|
|
3530
3538
|
const slots = [];
|
|
3531
3539
|
slots.length = pks.length;
|
|
3532
3540
|
for (let i = 0; i < pks.length; i++) {
|
|
3533
|
-
slots[i] = this.
|
|
3541
|
+
slots[i] = this.getSlotOrTransient(pks[i]);
|
|
3534
3542
|
}
|
|
3535
3543
|
return slots;
|
|
3536
3544
|
}
|
|
3537
|
-
|
|
3538
|
-
const slot = this.
|
|
3545
|
+
getSlotOrTransient(pk) {
|
|
3546
|
+
const slot = this.getSlot(pk);
|
|
3539
3547
|
if (!slot) return { pk, item: void 0 };
|
|
3540
3548
|
return slot;
|
|
3541
3549
|
}
|
|
@@ -3615,18 +3623,18 @@ var OIMReactiveGlobalIndexManualSetBased = class extends OIMReactiveGlobalIndexS
|
|
|
3615
3623
|
// src/core/OIMReactiveCollectionGlobalIndexManualSetBased.ts
|
|
3616
3624
|
var OIMReactiveCollectionGlobalIndexManualSetBased = class extends OIMReactiveGlobalIndexManualSetBased {
|
|
3617
3625
|
constructor(queue, opts) {
|
|
3618
|
-
const
|
|
3626
|
+
const getSlot = opts.collection !== void 0 ? (pk) => opts.collection.getOrReserveSlotByPk(pk) : opts.getSlot;
|
|
3619
3627
|
super(queue, { indexOptions: opts.indexOptions });
|
|
3620
3628
|
this.membership = /* @__PURE__ */ new Map();
|
|
3621
3629
|
this.membershipSeeded = false;
|
|
3622
|
-
this.
|
|
3630
|
+
this.getSlot = getSlot;
|
|
3623
3631
|
}
|
|
3624
3632
|
setPks(pks) {
|
|
3625
3633
|
this.membership.clear();
|
|
3626
3634
|
const slots = [];
|
|
3627
3635
|
for (let i = 0; i < pks.length; i++) {
|
|
3628
3636
|
const pk = pks[i];
|
|
3629
|
-
const slot = this.
|
|
3637
|
+
const slot = this.getSlotOrTransient(pk);
|
|
3630
3638
|
if (!this.membership.has(pk)) this.membership.set(pk, slot);
|
|
3631
3639
|
slots.push(slot);
|
|
3632
3640
|
}
|
|
@@ -3639,7 +3647,7 @@ var OIMReactiveCollectionGlobalIndexManualSetBased = class extends OIMReactiveGl
|
|
|
3639
3647
|
const newSlots = [];
|
|
3640
3648
|
for (const pk of pks) {
|
|
3641
3649
|
if (membership.has(pk)) continue;
|
|
3642
|
-
const slot = this.
|
|
3650
|
+
const slot = this.getSlotOrTransient(pk);
|
|
3643
3651
|
membership.set(pk, slot);
|
|
3644
3652
|
newSlots.push(slot);
|
|
3645
3653
|
}
|
|
@@ -3678,8 +3686,8 @@ var OIMReactiveCollectionGlobalIndexManualSetBased = class extends OIMReactiveGl
|
|
|
3678
3686
|
getEntities() {
|
|
3679
3687
|
return super.getEntities();
|
|
3680
3688
|
}
|
|
3681
|
-
|
|
3682
|
-
const slot = this.
|
|
3689
|
+
getSlotOrTransient(pk) {
|
|
3690
|
+
const slot = this.getSlot(pk);
|
|
3683
3691
|
if (!slot) return { pk, item: void 0 };
|
|
3684
3692
|
return slot;
|
|
3685
3693
|
}
|
|
@@ -4088,7 +4096,7 @@ var OIMObject = class {
|
|
|
4088
4096
|
var OIMReactiveObject = class extends OIMObject {
|
|
4089
4097
|
constructor(queue, opts) {
|
|
4090
4098
|
super(opts);
|
|
4091
|
-
this.updateEmitter = new OIMCarrierKeyedEmitter(queue, new
|
|
4099
|
+
this.updateEmitter = new OIMCarrierKeyedEmitter(queue, new OIMKeyedCarrierProvider());
|
|
4092
4100
|
}
|
|
4093
4101
|
/**
|
|
4094
4102
|
* Mark the written key(s) on the keyed emitter directly — no general-event
|
|
@@ -4130,57 +4138,10 @@ var OIMReactiveObject = class extends OIMObject {
|
|
|
4130
4138
|
}
|
|
4131
4139
|
};
|
|
4132
4140
|
|
|
4133
|
-
// src/core/OIMTrieSet.ts
|
|
4134
|
-
var OIMTrieSet = class {
|
|
4135
|
-
constructor() {
|
|
4136
|
-
this.map = new OIMTrieMap();
|
|
4137
|
-
}
|
|
4138
|
-
get size() {
|
|
4139
|
-
return this.map.size;
|
|
4140
|
-
}
|
|
4141
|
-
add(key) {
|
|
4142
|
-
this.map.set(key, true);
|
|
4143
|
-
}
|
|
4144
|
-
has(key) {
|
|
4145
|
-
return this.map.has(key);
|
|
4146
|
-
}
|
|
4147
|
-
delete(key) {
|
|
4148
|
-
return this.map.delete(key);
|
|
4149
|
-
}
|
|
4150
|
-
*values() {
|
|
4151
|
-
yield* this.map.keys();
|
|
4152
|
-
}
|
|
4153
|
-
clear() {
|
|
4154
|
-
this.map.clear();
|
|
4155
|
-
}
|
|
4156
|
-
};
|
|
4157
|
-
|
|
4158
|
-
// src/core/OIMKeyDomainTrie.ts
|
|
4159
|
-
var OIMKeyDomainTrie = class {
|
|
4160
|
-
constructor() {
|
|
4161
|
-
// Interning pool: logical key (by content) → the one canonical reference.
|
|
4162
|
-
this.pool = new OIMTrieMap();
|
|
4163
|
-
}
|
|
4164
|
-
createMap() {
|
|
4165
|
-
return new OIMTrieMap();
|
|
4166
|
-
}
|
|
4167
|
-
createSet() {
|
|
4168
|
-
return new OIMTrieSet();
|
|
4169
|
-
}
|
|
4170
|
-
canonicalize(key) {
|
|
4171
|
-
const existing = this.pool.get(key);
|
|
4172
|
-
if (existing !== void 0) return existing;
|
|
4173
|
-
const canonical = Object.freeze(key.slice());
|
|
4174
|
-
this.pool.set(canonical, canonical);
|
|
4175
|
-
return canonical;
|
|
4176
|
-
}
|
|
4177
|
-
};
|
|
4178
|
-
|
|
4179
4141
|
// src/core/OIMCollectionStoreTrieDriven.ts
|
|
4180
4142
|
var OIMCollectionStoreTrieDriven = class extends OIMCollectionStore {
|
|
4181
|
-
constructor(
|
|
4182
|
-
super();
|
|
4183
|
-
this.keyDomain = keyDomain;
|
|
4143
|
+
constructor() {
|
|
4144
|
+
super(...arguments);
|
|
4184
4145
|
this.slots = new OIMTrieMap();
|
|
4185
4146
|
this.reservedSlots = new OIMTrieMap();
|
|
4186
4147
|
}
|
|
@@ -4198,7 +4159,7 @@ var OIMCollectionStoreTrieDriven = class extends OIMCollectionStore {
|
|
|
4198
4159
|
return reserved;
|
|
4199
4160
|
}
|
|
4200
4161
|
const nextSlot = {
|
|
4201
|
-
pk
|
|
4162
|
+
pk,
|
|
4202
4163
|
item: entity
|
|
4203
4164
|
};
|
|
4204
4165
|
this.slots.set(pk, nextSlot);
|
|
@@ -4209,7 +4170,7 @@ var OIMCollectionStoreTrieDriven = class extends OIMCollectionStore {
|
|
|
4209
4170
|
if (slot) return slot;
|
|
4210
4171
|
let reserved = this.reservedSlots.get(pk);
|
|
4211
4172
|
if (!reserved) {
|
|
4212
|
-
reserved = { pk
|
|
4173
|
+
reserved = { pk, item: void 0 };
|
|
4213
4174
|
this.reservedSlots.set(pk, reserved);
|
|
4214
4175
|
}
|
|
4215
4176
|
return reserved;
|
|
@@ -4366,8 +4327,8 @@ var OIMObjectStoreMapDriven = class extends OIMObjectStore {
|
|
|
4366
4327
|
}
|
|
4367
4328
|
};
|
|
4368
4329
|
|
|
4369
|
-
// src/core/
|
|
4370
|
-
var
|
|
4330
|
+
// src/core/OIMKeyPathCarrierProvider.ts
|
|
4331
|
+
var OIMKeyPathCarrierProvider = class {
|
|
4371
4332
|
constructor() {
|
|
4372
4333
|
this.carriers = new OIMTrieMap();
|
|
4373
4334
|
}
|
|
@@ -4667,6 +4628,31 @@ function createOIMDisposeScope() {
|
|
|
4667
4628
|
return new OIMDisposeScope();
|
|
4668
4629
|
}
|
|
4669
4630
|
|
|
4631
|
+
// src/core/OIMTrieSet.ts
|
|
4632
|
+
var OIMTrieSet = class {
|
|
4633
|
+
constructor() {
|
|
4634
|
+
this.map = new OIMTrieMap();
|
|
4635
|
+
}
|
|
4636
|
+
get size() {
|
|
4637
|
+
return this.map.size;
|
|
4638
|
+
}
|
|
4639
|
+
add(key) {
|
|
4640
|
+
this.map.set(key, true);
|
|
4641
|
+
}
|
|
4642
|
+
has(key) {
|
|
4643
|
+
return this.map.has(key);
|
|
4644
|
+
}
|
|
4645
|
+
delete(key) {
|
|
4646
|
+
return this.map.delete(key);
|
|
4647
|
+
}
|
|
4648
|
+
*values() {
|
|
4649
|
+
yield* this.map.keys();
|
|
4650
|
+
}
|
|
4651
|
+
clear() {
|
|
4652
|
+
this.map.clear();
|
|
4653
|
+
}
|
|
4654
|
+
};
|
|
4655
|
+
|
|
4670
4656
|
// src/core/OIMPkCodecKeyPath.ts
|
|
4671
4657
|
var OIMPkCodecKeyPath = class {
|
|
4672
4658
|
encode(pk) {
|
|
@@ -6314,35 +6300,20 @@ var OIMComputed = class {
|
|
|
6314
6300
|
};
|
|
6315
6301
|
|
|
6316
6302
|
// src/modules/effect/core/OIMEffectDependencyKeyed.ts
|
|
6317
|
-
function isReadonlyArray(value) {
|
|
6318
|
-
return Array.isArray(value);
|
|
6319
|
-
}
|
|
6320
6303
|
var OIMEffectDependencyKeyed = class {
|
|
6321
|
-
constructor(source,
|
|
6304
|
+
constructor(source, key) {
|
|
6322
6305
|
this.source = source;
|
|
6323
|
-
|
|
6324
|
-
this.keys = keyOrKeys;
|
|
6325
|
-
} else {
|
|
6326
|
-
this.key = keyOrKeys;
|
|
6327
|
-
}
|
|
6306
|
+
this.key = key;
|
|
6328
6307
|
}
|
|
6329
6308
|
subscribe(onUpdate) {
|
|
6330
|
-
if (this.keys !== void 0) {
|
|
6331
|
-
return this.source.subscribeOnKeys(this.keys, onUpdate);
|
|
6332
|
-
}
|
|
6333
|
-
if (this.key === void 0) return () => {
|
|
6334
|
-
};
|
|
6335
6309
|
return this.source.subscribeOnKey(this.key, onUpdate);
|
|
6336
6310
|
}
|
|
6337
6311
|
};
|
|
6338
6312
|
|
|
6339
6313
|
// src/modules/effect/core/OIMEffectDependencyKeyedObject.ts
|
|
6340
6314
|
var OIMEffectDependencyKeyedObject = class {
|
|
6341
|
-
constructor(object,
|
|
6342
|
-
this.dep = new OIMEffectDependencyKeyed(
|
|
6343
|
-
object,
|
|
6344
|
-
keyOrKeys
|
|
6345
|
-
);
|
|
6315
|
+
constructor(object, key) {
|
|
6316
|
+
this.dep = new OIMEffectDependencyKeyed(object, key);
|
|
6346
6317
|
}
|
|
6347
6318
|
get source() {
|
|
6348
6319
|
return this.dep.source;
|
|
@@ -6354,11 +6325,8 @@ var OIMEffectDependencyKeyedObject = class {
|
|
|
6354
6325
|
|
|
6355
6326
|
// src/modules/effect/core/OIMEffectDependencyKeyedCollection.ts
|
|
6356
6327
|
var OIMEffectDependencyKeyedCollection = class {
|
|
6357
|
-
constructor(collection,
|
|
6358
|
-
this.dep = new OIMEffectDependencyKeyed(
|
|
6359
|
-
collection,
|
|
6360
|
-
pkOrPks
|
|
6361
|
-
);
|
|
6328
|
+
constructor(collection, pk) {
|
|
6329
|
+
this.dep = new OIMEffectDependencyKeyed(collection, pk);
|
|
6362
6330
|
}
|
|
6363
6331
|
get source() {
|
|
6364
6332
|
return this.dep.source;
|
|
@@ -6370,11 +6338,8 @@ var OIMEffectDependencyKeyedCollection = class {
|
|
|
6370
6338
|
|
|
6371
6339
|
// src/modules/effect/core/OIMEffectDependencyKeyedIndex.ts
|
|
6372
6340
|
var OIMEffectDependencyKeyedIndex = class {
|
|
6373
|
-
constructor(index,
|
|
6374
|
-
this.dep = new OIMEffectDependencyKeyed(
|
|
6375
|
-
index,
|
|
6376
|
-
keyOrKeys
|
|
6377
|
-
);
|
|
6341
|
+
constructor(index, key) {
|
|
6342
|
+
this.dep = new OIMEffectDependencyKeyed(index, key);
|
|
6378
6343
|
}
|
|
6379
6344
|
get source() {
|
|
6380
6345
|
return this.dep.source;
|
|
@@ -6522,7 +6487,7 @@ var OIMIndexPksByKeysArrayBasedSelector = class extends OIMSelector {
|
|
|
6522
6487
|
EOIMEventQueueSchedulerEventType,
|
|
6523
6488
|
EOIMIndexEventType,
|
|
6524
6489
|
EOIMObjectEventType,
|
|
6525
|
-
|
|
6490
|
+
OIMBucketCarrierProvider,
|
|
6526
6491
|
OIMCarrierKeyedEmitter,
|
|
6527
6492
|
OIMCarrierSingleEmitter,
|
|
6528
6493
|
OIMCollection,
|
|
@@ -6589,9 +6554,7 @@ var OIMIndexPksByKeysArrayBasedSelector = class extends OIMSelector {
|
|
|
6589
6554
|
OIMIndexStoreSetBased,
|
|
6590
6555
|
OIMIndexStoreTrieDrivenArrayBased,
|
|
6591
6556
|
OIMIndexStoreTrieDrivenSetBased,
|
|
6592
|
-
|
|
6593
|
-
OIMKeyDomainTrie,
|
|
6594
|
-
OIMKeyPathCarrierResolver,
|
|
6557
|
+
OIMKeyPathCarrierProvider,
|
|
6595
6558
|
OIMKeyedBucketArrayBased,
|
|
6596
6559
|
OIMKeyedBucketSetBased,
|
|
6597
6560
|
OIMMap2Keys,
|