@oimdb/core 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +54 -0
- package/dist/index.d.cts +74 -4
- package/dist/index.d.ts +74 -4
- package/dist/index.js +52 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -71,6 +71,7 @@ __export(index_exports, {
|
|
|
71
71
|
OIMGlobalIndexManualArrayBased: () => OIMGlobalIndexManualArrayBased,
|
|
72
72
|
OIMGlobalIndexManualSetBased: () => OIMGlobalIndexManualSetBased,
|
|
73
73
|
OIMGlobalIndexSetBased: () => OIMGlobalIndexSetBased,
|
|
74
|
+
OIMGlobalIndexSlotMap: () => OIMGlobalIndexSlotMap,
|
|
74
75
|
OIMIndex: () => OIMIndex,
|
|
75
76
|
OIMIndexArrayBased: () => OIMIndexArrayBased,
|
|
76
77
|
OIMIndexComparatorFactory: () => OIMIndexComparatorFactory,
|
|
@@ -120,6 +121,7 @@ __export(index_exports, {
|
|
|
120
121
|
createMergeEntityUpdater: () => createMergeEntityUpdater,
|
|
121
122
|
createOIMCollectionIndexFactory: () => createOIMCollectionIndexFactory,
|
|
122
123
|
createOIMCollectionKit: () => createOIMCollectionKit,
|
|
124
|
+
createOIMGlobalIndexSlotMap: () => createOIMGlobalIndexSlotMap,
|
|
123
125
|
createOIMIndexSlotMap: () => createOIMIndexSlotMap,
|
|
124
126
|
createOIMOrderedListCommandStreamDiffDriven: () => createOIMOrderedListCommandStreamDiffDriven,
|
|
125
127
|
createOIMOrderedListMappedCommandStream: () => createOIMOrderedListMappedCommandStream,
|
|
@@ -4726,6 +4728,56 @@ function createOIMIndexSlotMap(index, create) {
|
|
|
4726
4728
|
return new OIMIndexSlotMap(index, create);
|
|
4727
4729
|
}
|
|
4728
4730
|
|
|
4731
|
+
// src/modules/wrapper/index/OIMGlobalIndexSlotMap.ts
|
|
4732
|
+
var OIMGlobalIndexSlotMap = class _OIMGlobalIndexSlotMap {
|
|
4733
|
+
constructor(index, create) {
|
|
4734
|
+
this.cache = /* @__PURE__ */ new WeakMap();
|
|
4735
|
+
this.index = index;
|
|
4736
|
+
this.create = create;
|
|
4737
|
+
}
|
|
4738
|
+
/** The mapped object for a slot, created once and cached by slot identity. */
|
|
4739
|
+
get(slot) {
|
|
4740
|
+
let mapped = this.cache.get(slot);
|
|
4741
|
+
if (mapped === void 0 && !this.cache.has(slot)) {
|
|
4742
|
+
mapped = this.create(slot);
|
|
4743
|
+
this.cache.set(slot, mapped);
|
|
4744
|
+
}
|
|
4745
|
+
return mapped;
|
|
4746
|
+
}
|
|
4747
|
+
/**
|
|
4748
|
+
* Mapped objects for every slot in the index, with stable references. For a
|
|
4749
|
+
* set-based global index the order is unspecified (as the set is); for an
|
|
4750
|
+
* array-based one it follows the index order.
|
|
4751
|
+
*/
|
|
4752
|
+
getAll() {
|
|
4753
|
+
const result = [];
|
|
4754
|
+
for (const slot of this.index.getSlots()) {
|
|
4755
|
+
result.push(this.get(slot));
|
|
4756
|
+
}
|
|
4757
|
+
return result;
|
|
4758
|
+
}
|
|
4759
|
+
/**
|
|
4760
|
+
* Chain another projection. `map(f)` returns a slot map over the SAME index
|
|
4761
|
+
* whose objects are `f(this.get(slot))`, cached by slot identity — both
|
|
4762
|
+
* levels hand back stable references and each `create` runs once per slot.
|
|
4763
|
+
*/
|
|
4764
|
+
map(create) {
|
|
4765
|
+
return new _OIMGlobalIndexSlotMap(
|
|
4766
|
+
this.index,
|
|
4767
|
+
(slot) => create(this.get(slot))
|
|
4768
|
+
);
|
|
4769
|
+
}
|
|
4770
|
+
/** Subscribe to the index's changes — passthrough to the index. */
|
|
4771
|
+
subscribe(handler) {
|
|
4772
|
+
return this.index.subscribe(handler);
|
|
4773
|
+
}
|
|
4774
|
+
};
|
|
4775
|
+
|
|
4776
|
+
// src/modules/wrapper/index/createOIMGlobalIndexSlotMap.ts
|
|
4777
|
+
function createOIMGlobalIndexSlotMap(index, create) {
|
|
4778
|
+
return new OIMGlobalIndexSlotMap(index, create);
|
|
4779
|
+
}
|
|
4780
|
+
|
|
4729
4781
|
// src/modules/wrapper/index/diffOrderedListByPk.ts
|
|
4730
4782
|
function diffOrderedListByPk(prev, next) {
|
|
4731
4783
|
const commands = [];
|
|
@@ -5523,6 +5575,7 @@ var OIMIndexPksByKeysArrayBasedSelector = class extends OIMSelector {
|
|
|
5523
5575
|
OIMGlobalIndexManualArrayBased,
|
|
5524
5576
|
OIMGlobalIndexManualSetBased,
|
|
5525
5577
|
OIMGlobalIndexSetBased,
|
|
5578
|
+
OIMGlobalIndexSlotMap,
|
|
5526
5579
|
OIMIndex,
|
|
5527
5580
|
OIMIndexArrayBased,
|
|
5528
5581
|
OIMIndexComparatorFactory,
|
|
@@ -5572,6 +5625,7 @@ var OIMIndexPksByKeysArrayBasedSelector = class extends OIMSelector {
|
|
|
5572
5625
|
createMergeEntityUpdater,
|
|
5573
5626
|
createOIMCollectionIndexFactory,
|
|
5574
5627
|
createOIMCollectionKit,
|
|
5628
|
+
createOIMGlobalIndexSlotMap,
|
|
5575
5629
|
createOIMIndexSlotMap,
|
|
5576
5630
|
createOIMOrderedListCommandStreamDiffDriven,
|
|
5577
5631
|
createOIMOrderedListMappedCommandStream,
|
package/dist/index.d.cts
CHANGED
|
@@ -1928,9 +1928,9 @@ interface IOIMIndexSlotSource<TKey extends TOIMPk, TPk extends TOIMPk> extends I
|
|
|
1928
1928
|
* and shared per pk). The cache is a `WeakMap`, so a mapped object is reclaimed
|
|
1929
1929
|
* by GC once its slot is dropped and unreferenced — there is no lifecycle
|
|
1930
1930
|
* callback and none is needed for plain values. If your mapped objects hold
|
|
1931
|
-
* resources that need explicit teardown (DOM nodes, subscriptions),
|
|
1932
|
-
* ordered command stream
|
|
1933
|
-
*
|
|
1931
|
+
* resources that need explicit teardown (DOM nodes, subscriptions), drive an
|
|
1932
|
+
* ordered command stream instead — its `remove` / `set` / `reset` commands are
|
|
1933
|
+
* the exact removal signal you tear down on.
|
|
1934
1934
|
*
|
|
1935
1935
|
* This is a thin wrapper: it holds no queue and no standing subscription of its
|
|
1936
1936
|
* own — `subscribeOnKey` is a passthrough to the index.
|
|
@@ -1976,6 +1976,76 @@ declare class OIMIndexSlotMap<TKey extends TOIMPk, TPk extends TOIMPk, TMapped>
|
|
|
1976
1976
|
*/
|
|
1977
1977
|
declare function createOIMIndexSlotMap<TKey extends TOIMPk, TPk extends TOIMPk, TMapped>(index: IOIMIndexSlotSource<TKey, TPk>, create: (slot: TOIMAnyEntitySlot<TPk>) => TMapped): OIMIndexSlotMap<TKey, TPk, TMapped>;
|
|
1978
1978
|
|
|
1979
|
+
/**
|
|
1980
|
+
* Minimal read/subscribe surface a keyless (whole-collection) index exposes for
|
|
1981
|
+
* slot mapping: iterate all slots and subscribe to the single bucket's changes.
|
|
1982
|
+
* The keyless counterpart of {@link IOIMIndexSlotSource}.
|
|
1983
|
+
*
|
|
1984
|
+
* Both `OIMReactiveGlobalIndexSetBased` (slots as a `ReadonlySet`) and
|
|
1985
|
+
* `OIMReactiveGlobalIndexArrayBased` (slots as a `readonly` array) satisfy it
|
|
1986
|
+
* structurally — a `Set` and an array are both `Iterable`.
|
|
1987
|
+
*/
|
|
1988
|
+
interface IOIMGlobalIndexSlotSource<TPk extends TOIMPk> extends IOIMSubscription {
|
|
1989
|
+
getSlots(): Iterable<TOIMAnyEntitySlot<TPk>>;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Stable slot→object memo over a keyless (whole-collection) set/array index —
|
|
1994
|
+
* the keyless counterpart of {@link OIMIndexSlotMap}.
|
|
1995
|
+
*
|
|
1996
|
+
* `create(slot)` runs once per canonical slot; every later read returns the
|
|
1997
|
+
* **same** object reference for the same slot, so a consumer can re-read on each
|
|
1998
|
+
* notification and still hand reference-equal objects to `React.memo` /
|
|
1999
|
+
* `Object.is` diffing, or reuse the same view-model.
|
|
2000
|
+
*
|
|
2001
|
+
* The cache is a `WeakMap` keyed by the slot object, so a mapped object is
|
|
2002
|
+
* reclaimed by GC once its slot is dropped. There is no teardown callback and
|
|
2003
|
+
* none is needed for plain values; if your mapped objects hold resources needing
|
|
2004
|
+
* explicit cleanup, drive an ordered command stream (whose `remove` / `set` /
|
|
2005
|
+
* `reset` commands are the exact removal signal) instead.
|
|
2006
|
+
*
|
|
2007
|
+
* Thin wrapper: no queue, no standing subscription of its own — `subscribe` is a
|
|
2008
|
+
* passthrough to the index.
|
|
2009
|
+
*/
|
|
2010
|
+
declare class OIMGlobalIndexSlotMap<TPk extends TOIMPk, TMapped> {
|
|
2011
|
+
private readonly index;
|
|
2012
|
+
private readonly create;
|
|
2013
|
+
private readonly cache;
|
|
2014
|
+
constructor(index: IOIMGlobalIndexSlotSource<TPk>, create: (slot: TOIMAnyEntitySlot<TPk>) => TMapped);
|
|
2015
|
+
/** The mapped object for a slot, created once and cached by slot identity. */
|
|
2016
|
+
get(slot: TOIMAnyEntitySlot<TPk>): TMapped;
|
|
2017
|
+
/**
|
|
2018
|
+
* Mapped objects for every slot in the index, with stable references. For a
|
|
2019
|
+
* set-based global index the order is unspecified (as the set is); for an
|
|
2020
|
+
* array-based one it follows the index order.
|
|
2021
|
+
*/
|
|
2022
|
+
getAll(): TMapped[];
|
|
2023
|
+
/**
|
|
2024
|
+
* Chain another projection. `map(f)` returns a slot map over the SAME index
|
|
2025
|
+
* whose objects are `f(this.get(slot))`, cached by slot identity — both
|
|
2026
|
+
* levels hand back stable references and each `create` runs once per slot.
|
|
2027
|
+
*/
|
|
2028
|
+
map<TNext>(create: (mapped: TMapped) => TNext): OIMGlobalIndexSlotMap<TPk, TNext>;
|
|
2029
|
+
/** Subscribe to the index's changes — passthrough to the index. */
|
|
2030
|
+
subscribe(handler: TOIMEventHandler<void>): () => void;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* Map the slots of a keyless (whole-collection) set/array index to stable
|
|
2035
|
+
* per-slot objects — the keyless counterpart of `createOIMIndexSlotMap`.
|
|
2036
|
+
*
|
|
2037
|
+
* ```ts
|
|
2038
|
+
* const everyone = users.indexFactory.derivedSetGlobalIndex();
|
|
2039
|
+
* const rows = createOIMGlobalIndexSlotMap(everyone, (slot) => makeRow(slot.item));
|
|
2040
|
+
*
|
|
2041
|
+
* rows.subscribe(render);
|
|
2042
|
+
* function render() {
|
|
2043
|
+
* for (const row of rows.getAll()) { /* same instance per slot *\/ }
|
|
2044
|
+
* }
|
|
2045
|
+
* ```
|
|
2046
|
+
*/
|
|
2047
|
+
declare function createOIMGlobalIndexSlotMap<TPk extends TOIMPk, TMapped>(index: IOIMGlobalIndexSlotSource<TPk>, create: (slot: TOIMAnyEntitySlot<TPk>) => TMapped): OIMGlobalIndexSlotMap<TPk, TMapped>;
|
|
2048
|
+
|
|
1979
2049
|
/**
|
|
1980
2050
|
* Options for {@link OIMOrderedListCommandStreamDiffDriven}.
|
|
1981
2051
|
*/
|
|
@@ -2462,4 +2532,4 @@ declare class OIMEntitiesByGlobalIndexArrayBasedSelector<TEntity extends object,
|
|
|
2462
2532
|
protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
|
|
2463
2533
|
}
|
|
2464
2534
|
|
|
2465
|
-
export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierResolver, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotResolver, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
|
|
2535
|
+
export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierResolver, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMGlobalIndexSlotSource, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMGlobalIndexSlotMap, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotResolver, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMGlobalIndexSlotMap, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
|
package/dist/index.d.ts
CHANGED
|
@@ -1928,9 +1928,9 @@ interface IOIMIndexSlotSource<TKey extends TOIMPk, TPk extends TOIMPk> extends I
|
|
|
1928
1928
|
* and shared per pk). The cache is a `WeakMap`, so a mapped object is reclaimed
|
|
1929
1929
|
* by GC once its slot is dropped and unreferenced — there is no lifecycle
|
|
1930
1930
|
* callback and none is needed for plain values. If your mapped objects hold
|
|
1931
|
-
* resources that need explicit teardown (DOM nodes, subscriptions),
|
|
1932
|
-
* ordered command stream
|
|
1933
|
-
*
|
|
1931
|
+
* resources that need explicit teardown (DOM nodes, subscriptions), drive an
|
|
1932
|
+
* ordered command stream instead — its `remove` / `set` / `reset` commands are
|
|
1933
|
+
* the exact removal signal you tear down on.
|
|
1934
1934
|
*
|
|
1935
1935
|
* This is a thin wrapper: it holds no queue and no standing subscription of its
|
|
1936
1936
|
* own — `subscribeOnKey` is a passthrough to the index.
|
|
@@ -1976,6 +1976,76 @@ declare class OIMIndexSlotMap<TKey extends TOIMPk, TPk extends TOIMPk, TMapped>
|
|
|
1976
1976
|
*/
|
|
1977
1977
|
declare function createOIMIndexSlotMap<TKey extends TOIMPk, TPk extends TOIMPk, TMapped>(index: IOIMIndexSlotSource<TKey, TPk>, create: (slot: TOIMAnyEntitySlot<TPk>) => TMapped): OIMIndexSlotMap<TKey, TPk, TMapped>;
|
|
1978
1978
|
|
|
1979
|
+
/**
|
|
1980
|
+
* Minimal read/subscribe surface a keyless (whole-collection) index exposes for
|
|
1981
|
+
* slot mapping: iterate all slots and subscribe to the single bucket's changes.
|
|
1982
|
+
* The keyless counterpart of {@link IOIMIndexSlotSource}.
|
|
1983
|
+
*
|
|
1984
|
+
* Both `OIMReactiveGlobalIndexSetBased` (slots as a `ReadonlySet`) and
|
|
1985
|
+
* `OIMReactiveGlobalIndexArrayBased` (slots as a `readonly` array) satisfy it
|
|
1986
|
+
* structurally — a `Set` and an array are both `Iterable`.
|
|
1987
|
+
*/
|
|
1988
|
+
interface IOIMGlobalIndexSlotSource<TPk extends TOIMPk> extends IOIMSubscription {
|
|
1989
|
+
getSlots(): Iterable<TOIMAnyEntitySlot<TPk>>;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Stable slot→object memo over a keyless (whole-collection) set/array index —
|
|
1994
|
+
* the keyless counterpart of {@link OIMIndexSlotMap}.
|
|
1995
|
+
*
|
|
1996
|
+
* `create(slot)` runs once per canonical slot; every later read returns the
|
|
1997
|
+
* **same** object reference for the same slot, so a consumer can re-read on each
|
|
1998
|
+
* notification and still hand reference-equal objects to `React.memo` /
|
|
1999
|
+
* `Object.is` diffing, or reuse the same view-model.
|
|
2000
|
+
*
|
|
2001
|
+
* The cache is a `WeakMap` keyed by the slot object, so a mapped object is
|
|
2002
|
+
* reclaimed by GC once its slot is dropped. There is no teardown callback and
|
|
2003
|
+
* none is needed for plain values; if your mapped objects hold resources needing
|
|
2004
|
+
* explicit cleanup, drive an ordered command stream (whose `remove` / `set` /
|
|
2005
|
+
* `reset` commands are the exact removal signal) instead.
|
|
2006
|
+
*
|
|
2007
|
+
* Thin wrapper: no queue, no standing subscription of its own — `subscribe` is a
|
|
2008
|
+
* passthrough to the index.
|
|
2009
|
+
*/
|
|
2010
|
+
declare class OIMGlobalIndexSlotMap<TPk extends TOIMPk, TMapped> {
|
|
2011
|
+
private readonly index;
|
|
2012
|
+
private readonly create;
|
|
2013
|
+
private readonly cache;
|
|
2014
|
+
constructor(index: IOIMGlobalIndexSlotSource<TPk>, create: (slot: TOIMAnyEntitySlot<TPk>) => TMapped);
|
|
2015
|
+
/** The mapped object for a slot, created once and cached by slot identity. */
|
|
2016
|
+
get(slot: TOIMAnyEntitySlot<TPk>): TMapped;
|
|
2017
|
+
/**
|
|
2018
|
+
* Mapped objects for every slot in the index, with stable references. For a
|
|
2019
|
+
* set-based global index the order is unspecified (as the set is); for an
|
|
2020
|
+
* array-based one it follows the index order.
|
|
2021
|
+
*/
|
|
2022
|
+
getAll(): TMapped[];
|
|
2023
|
+
/**
|
|
2024
|
+
* Chain another projection. `map(f)` returns a slot map over the SAME index
|
|
2025
|
+
* whose objects are `f(this.get(slot))`, cached by slot identity — both
|
|
2026
|
+
* levels hand back stable references and each `create` runs once per slot.
|
|
2027
|
+
*/
|
|
2028
|
+
map<TNext>(create: (mapped: TMapped) => TNext): OIMGlobalIndexSlotMap<TPk, TNext>;
|
|
2029
|
+
/** Subscribe to the index's changes — passthrough to the index. */
|
|
2030
|
+
subscribe(handler: TOIMEventHandler<void>): () => void;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* Map the slots of a keyless (whole-collection) set/array index to stable
|
|
2035
|
+
* per-slot objects — the keyless counterpart of `createOIMIndexSlotMap`.
|
|
2036
|
+
*
|
|
2037
|
+
* ```ts
|
|
2038
|
+
* const everyone = users.indexFactory.derivedSetGlobalIndex();
|
|
2039
|
+
* const rows = createOIMGlobalIndexSlotMap(everyone, (slot) => makeRow(slot.item));
|
|
2040
|
+
*
|
|
2041
|
+
* rows.subscribe(render);
|
|
2042
|
+
* function render() {
|
|
2043
|
+
* for (const row of rows.getAll()) { /* same instance per slot *\/ }
|
|
2044
|
+
* }
|
|
2045
|
+
* ```
|
|
2046
|
+
*/
|
|
2047
|
+
declare function createOIMGlobalIndexSlotMap<TPk extends TOIMPk, TMapped>(index: IOIMGlobalIndexSlotSource<TPk>, create: (slot: TOIMAnyEntitySlot<TPk>) => TMapped): OIMGlobalIndexSlotMap<TPk, TMapped>;
|
|
2048
|
+
|
|
1979
2049
|
/**
|
|
1980
2050
|
* Options for {@link OIMOrderedListCommandStreamDiffDriven}.
|
|
1981
2051
|
*/
|
|
@@ -2462,4 +2532,4 @@ declare class OIMEntitiesByGlobalIndexArrayBasedSelector<TEntity extends object,
|
|
|
2462
2532
|
protected areEqual(prev: readonly (TEntity | undefined)[], next: readonly (TEntity | undefined)[]): boolean;
|
|
2463
2533
|
}
|
|
2464
2534
|
|
|
2465
|
-
export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierResolver, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotResolver, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
|
|
2535
|
+
export { EOIMCollectionEventType, EOIMComputedEventType, EOIMEventQueueEventType, EOIMEventQueueSchedulerEventType, EOIMIndexEventType, EOIMObjectEventType, type IOIMCarrierResolver, type IOIMComputedEventSource, type IOIMEffectDependency, type IOIMEventQueueSchedulerEvents, type IOIMGlobalIndexSlotSource, type IOIMIndexSlotSource, type IOIMIndexStore, type IOIMKeyedUpdateEmitter, type IOIMOrderedListCommandSource, type IOIMSingleUpdateEmitter, type IOIMSubscribable, type IOIMSubscription, OIMCarrierKeyedEmitter, OIMCarrierSingleEmitter, OIMCollection, OIMCollectionByPkSelector, OIMCollectionByPksSelector, OIMCollectionChangedFields, OIMCollectionIndexFactory, OIMCollectionIndexManualOrderedArrayBased, OIMCollectionOrderedListCommandStream, OIMCollectionSelectors, OIMCollectionStore, OIMCollectionStoreMapDriven, OIMComparatorFactory, OIMComputeRuntime, OIMComputed, OIMDBSettings, OIMDerivedCollectionGlobalIndexArrayBased, OIMDerivedCollectionGlobalIndexSetBased, OIMDerivedCollectionIndexArrayBased, OIMDerivedCollectionIndexSetBased, OIMEffect, OIMEffectDependencyComputed, OIMEffectDependencyKeyed, OIMEffectDependencyKeyedCollection, OIMEffectDependencyKeyedIndex, OIMEffectDependencyKeyedObject, OIMEntitiesByGlobalIndexArrayBasedSelector, OIMEntitiesByGlobalIndexSetBasedSelector, OIMEntitiesByIndexKeyArrayBasedSelector, OIMEntitiesByIndexKeySetBasedSelector, OIMEntityUpdaterFactory, OIMEventEmitter, OIMEventQueue, OIMEventQueueScheduler, OIMEventQueueSchedulerAnimationFrame, OIMEventQueueSchedulerFactory, OIMEventQueueSchedulerImmediate, OIMEventQueueSchedulerMicrotask, OIMEventQueueSchedulerSync, OIMEventQueueSchedulerTimeout, OIMGlobalIndex, OIMGlobalIndexArrayBased, OIMGlobalIndexManualArrayBased, OIMGlobalIndexManualSetBased, OIMGlobalIndexSetBased, OIMGlobalIndexSlotMap, OIMIndex, OIMIndexArrayBased, OIMIndexComparatorFactory, OIMIndexManualArrayBased, OIMIndexManualOrderedArrayBased, OIMIndexManualSetBased, OIMIndexPksByKeyArrayBasedSelector, OIMIndexPksByKeySetBasedSelector, OIMIndexPksByKeysArrayBasedSelector, OIMIndexPksByKeysSetBasedSelector, OIMIndexSetBased, OIMIndexSlotMap, OIMIndexStoreArrayBased, OIMIndexStoreMapDrivenArrayBased, OIMIndexStoreMapDrivenSetBased, OIMIndexStoreSetBased, OIMMap2Keys, OIMObject, OIMObjectStore, OIMObjectStoreMapDriven, OIMObjectStoreRecordDriven, OIMObjectValueByKeySelector, OIMObjectValuesByKeysSelector, OIMOrderedListCommandBuffer, OIMOrderedListCommandStream, OIMOrderedListCommandStreamDiffDriven, OIMOrderedListMappedCommandStream, OIMPkSelectorFactory, OIMReactiveCollection, OIMReactiveCollectionGlobalIndexManualArrayBased, OIMReactiveCollectionGlobalIndexManualSetBased, OIMReactiveCollectionIndexManualArrayBased, OIMReactiveCollectionIndexManualSetBased, OIMReactiveGlobalIndex, OIMReactiveGlobalIndexArrayBased, OIMReactiveGlobalIndexManualArrayBased, OIMReactiveGlobalIndexManualSetBased, OIMReactiveGlobalIndexSetBased, OIMReactiveIndex, OIMReactiveIndexArrayBased, OIMReactiveIndexManualArrayBased, OIMReactiveIndexManualSetBased, OIMReactiveIndexSetBased, OIMReactiveObject, OIMSelector, type TOIMAnyEntitySlot, type TOIMCollectionEntitiesSelector, type TOIMCollectionEntitySelector, type TOIMCollectionGlobalIndexArrayBasedOptions, type TOIMCollectionGlobalIndexSetBasedOptions, type TOIMCollectionIndexArrayBasedOptions, type TOIMCollectionIndexSetBasedOptions, type TOIMCollectionKit, type TOIMCollectionOptions, type TOIMCollectionOrderedIndexOptions, type TOIMCollectionOrderedListCommandStreamOptions, type TOIMCollectionUpdatePayload, type TOIMComparator, type TOIMComputedOptions, type TOIMComputedUpdatePayload, type TOIMDerivedCollectionGlobalIndexArrayBasedOptions, type TOIMDerivedCollectionGlobalIndexSetBasedOptions, type TOIMDerivedCollectionIndexArrayBasedOptions, type TOIMDerivedCollectionIndexSetBasedOptions, type TOIMDerivedEntityComparator, type TOIMDerivedEntityOrderSelector, type TOIMDerivedEntityOrderValue, type TOIMDerivedIndexKeySelector, type TOIMEffectOptions, type TOIMEntitySlot, type TOIMEntitySlotResolver, type TOIMEntityUpdater, type TOIMEventHandler, type TOIMEventQueueOptions, type TOIMGlobalIndexFilter, type TOIMIndexComparator, type TOIMIndexKey, type TOIMIndexOptionsArrayBased, type TOIMIndexOptionsSetBased, type TOIMIndexPksUpdatePayload, type TOIMIndexUpdatePayload, type TOIMObjectOptions, type TOIMOrderedListCommand, type TOIMOrderedListDiffOptions, type TOIMPk, type TOIMPkSelector, type TOIMReactiveCollectionFactoryOptions, type TOIMRelationsArrayIndexOptions, type TOIMRelationsDerivedArrayIndexOptions, type TOIMRelationsDerivedGlobalArrayIndexOptions, type TOIMRelationsDerivedGlobalSetIndexOptions, type TOIMRelationsDerivedSetIndexOptions, type TOIMRelationsGlobalArrayIndexOptions, type TOIMRelationsGlobalSetIndexOptions, type TOIMRelationsOrderedListOptions, type TOIMRelationsSetIndexOptions, type TOIMSchedulerOptions, type TOIMSchedulerType, type TOIMUpdatePayload, createInPlaceEntityUpdater, createMergeEntityUpdater, createOIMCollectionIndexFactory, createOIMCollectionKit, createOIMGlobalIndexSlotMap, createOIMIndexSlotMap, createOIMOrderedListCommandStreamDiffDriven, createOIMOrderedListMappedCommandStream, diffOrderedListByPk };
|
package/dist/index.js
CHANGED
|
@@ -4597,6 +4597,56 @@ function createOIMIndexSlotMap(index, create) {
|
|
|
4597
4597
|
return new OIMIndexSlotMap(index, create);
|
|
4598
4598
|
}
|
|
4599
4599
|
|
|
4600
|
+
// src/modules/wrapper/index/OIMGlobalIndexSlotMap.ts
|
|
4601
|
+
var OIMGlobalIndexSlotMap = class _OIMGlobalIndexSlotMap {
|
|
4602
|
+
constructor(index, create) {
|
|
4603
|
+
this.cache = /* @__PURE__ */ new WeakMap();
|
|
4604
|
+
this.index = index;
|
|
4605
|
+
this.create = create;
|
|
4606
|
+
}
|
|
4607
|
+
/** The mapped object for a slot, created once and cached by slot identity. */
|
|
4608
|
+
get(slot) {
|
|
4609
|
+
let mapped = this.cache.get(slot);
|
|
4610
|
+
if (mapped === void 0 && !this.cache.has(slot)) {
|
|
4611
|
+
mapped = this.create(slot);
|
|
4612
|
+
this.cache.set(slot, mapped);
|
|
4613
|
+
}
|
|
4614
|
+
return mapped;
|
|
4615
|
+
}
|
|
4616
|
+
/**
|
|
4617
|
+
* Mapped objects for every slot in the index, with stable references. For a
|
|
4618
|
+
* set-based global index the order is unspecified (as the set is); for an
|
|
4619
|
+
* array-based one it follows the index order.
|
|
4620
|
+
*/
|
|
4621
|
+
getAll() {
|
|
4622
|
+
const result = [];
|
|
4623
|
+
for (const slot of this.index.getSlots()) {
|
|
4624
|
+
result.push(this.get(slot));
|
|
4625
|
+
}
|
|
4626
|
+
return result;
|
|
4627
|
+
}
|
|
4628
|
+
/**
|
|
4629
|
+
* Chain another projection. `map(f)` returns a slot map over the SAME index
|
|
4630
|
+
* whose objects are `f(this.get(slot))`, cached by slot identity — both
|
|
4631
|
+
* levels hand back stable references and each `create` runs once per slot.
|
|
4632
|
+
*/
|
|
4633
|
+
map(create) {
|
|
4634
|
+
return new _OIMGlobalIndexSlotMap(
|
|
4635
|
+
this.index,
|
|
4636
|
+
(slot) => create(this.get(slot))
|
|
4637
|
+
);
|
|
4638
|
+
}
|
|
4639
|
+
/** Subscribe to the index's changes — passthrough to the index. */
|
|
4640
|
+
subscribe(handler) {
|
|
4641
|
+
return this.index.subscribe(handler);
|
|
4642
|
+
}
|
|
4643
|
+
};
|
|
4644
|
+
|
|
4645
|
+
// src/modules/wrapper/index/createOIMGlobalIndexSlotMap.ts
|
|
4646
|
+
function createOIMGlobalIndexSlotMap(index, create) {
|
|
4647
|
+
return new OIMGlobalIndexSlotMap(index, create);
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4600
4650
|
// src/modules/wrapper/index/diffOrderedListByPk.ts
|
|
4601
4651
|
function diffOrderedListByPk(prev, next) {
|
|
4602
4652
|
const commands = [];
|
|
@@ -5393,6 +5443,7 @@ export {
|
|
|
5393
5443
|
OIMGlobalIndexManualArrayBased,
|
|
5394
5444
|
OIMGlobalIndexManualSetBased,
|
|
5395
5445
|
OIMGlobalIndexSetBased,
|
|
5446
|
+
OIMGlobalIndexSlotMap,
|
|
5396
5447
|
OIMIndex,
|
|
5397
5448
|
OIMIndexArrayBased,
|
|
5398
5449
|
OIMIndexComparatorFactory,
|
|
@@ -5442,6 +5493,7 @@ export {
|
|
|
5442
5493
|
createMergeEntityUpdater,
|
|
5443
5494
|
createOIMCollectionIndexFactory,
|
|
5444
5495
|
createOIMCollectionKit,
|
|
5496
|
+
createOIMGlobalIndexSlotMap,
|
|
5445
5497
|
createOIMIndexSlotMap,
|
|
5446
5498
|
createOIMOrderedListCommandStreamDiffDriven,
|
|
5447
5499
|
createOIMOrderedListMappedCommandStream,
|
package/llms.txt
CHANGED
|
@@ -156,7 +156,7 @@ const stream = createOIMOrderedListCommandStreamDiffDriven(queue, cardsByDeck);
|
|
|
156
156
|
stream.subscribeCommands('deck1', () => engine.apply(stream.consumeCommands('deck1'))); // insert/move/remove
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
**Mapping a plain index to stable objects** — for an ordinary set/array index (no commands), `createOIMIndexSlotMap(index, create)` / `OIMIndexSlotMap` memoizes `create(slot)` by slot identity (a `WeakMap`): the same slot returns the same object reference on every read, so `React.memo` / `Object.is` diffing works and view-models are reused. Same plain-function shape as the ordered mapper, no `destroy` (plain values, GC reclaims). `getByKey(key)` → mapped objects; `subscribeOnKey`/`subscribeOnKeys` passthrough to the index. New exports: `OIMIndexSlotMap`, `createOIMIndexSlotMap`, `IOIMIndexSlotSource`.
|
|
159
|
+
**Mapping a plain index to stable objects** — for an ordinary set/array index (no commands), `createOIMIndexSlotMap(index, create)` / `OIMIndexSlotMap` memoizes `create(slot)` by slot identity (a `WeakMap`): the same slot returns the same object reference on every read, so `React.memo` / `Object.is` diffing works and view-models are reused. Same plain-function shape as the ordered mapper, no `destroy` (plain values, GC reclaims). `getByKey(key)` → mapped objects; `.map(create)` chains; `subscribeOnKey`/`subscribeOnKeys` passthrough to the index. For a keyless global index use `createOIMGlobalIndexSlotMap(index, create)` / `OIMGlobalIndexSlotMap` — same memo with `getAll()` and `subscribe()` instead of the keyed variants. New exports: `OIMIndexSlotMap`, `createOIMIndexSlotMap`, `IOIMIndexSlotSource`, `OIMGlobalIndexSlotMap`, `createOIMGlobalIndexSlotMap`, `IOIMGlobalIndexSlotSource`.
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
162
|
const usersByTeam = users.indexFactory.derivedSetIndex((u) => u.teamId);
|