@oimdb/react 3.0.0 → 3.1.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 +24 -31
- package/dist/index.cjs +49 -45
- package/dist/index.d.cts +17 -13
- package/dist/index.d.ts +17 -13
- package/dist/index.js +44 -40
- package/llms.txt +962 -1042
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -31,12 +31,12 @@ var OIMSnapshotVersion = class {
|
|
|
31
31
|
this.version = 0;
|
|
32
32
|
this.getVersion = () => this.version;
|
|
33
33
|
}
|
|
34
|
-
subscribeEffect(channelMap, sourceSlots, sourceComputeds
|
|
34
|
+
subscribeEffect(channelMap, onStoreChange, sourceSlots, sourceComputeds) {
|
|
35
35
|
this.version++;
|
|
36
|
-
return OIMEffectService.INSTANCE.subscribeEffect(channelMap,
|
|
36
|
+
return OIMEffectService.INSTANCE.subscribeEffect(channelMap, () => {
|
|
37
37
|
this.version++;
|
|
38
38
|
onStoreChange();
|
|
39
|
-
});
|
|
39
|
+
}, sourceSlots, sourceComputeds);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -56,9 +56,9 @@ function useOIMValue(binding) {
|
|
|
56
56
|
snapshotVersion,
|
|
57
57
|
subscribe: (onStoreChange) => snapshotVersion.subscribeEffect(
|
|
58
58
|
db,
|
|
59
|
+
onStoreChange,
|
|
59
60
|
binding.sourceSlots ?? OIM_FROZEN_EMPTY_SLOTS,
|
|
60
|
-
sourceComputeds
|
|
61
|
-
onStoreChange
|
|
61
|
+
sourceComputeds
|
|
62
62
|
)
|
|
63
63
|
};
|
|
64
64
|
}, [db, binding, sourceComputeds]);
|
|
@@ -83,13 +83,23 @@ import { OIM_FROZEN_EMPTY_SLOTS as OIM_FROZEN_EMPTY_SLOTS2 } from "@oimdb/core";
|
|
|
83
83
|
|
|
84
84
|
// src/oimAssertOneChannel.ts
|
|
85
85
|
function oimAssertOneChannel(channelMap, slot, door) {
|
|
86
|
-
|
|
87
|
-
if (storeSlot === void 0 || storeSlot.channelSlot === channelMap.defaultChannelSlot) return;
|
|
86
|
+
if (slot.storeSlot.channelSlot === channelMap.defaultChannelSlot) return;
|
|
88
87
|
throw new Error(
|
|
89
88
|
`${door}: the slot was filed on another OIMDB than the one <OIMDBProvider> was given, so a write would never wake this component. Build the services and their store slots on the one OIMDB the provider holds.`
|
|
90
89
|
);
|
|
91
90
|
}
|
|
92
91
|
|
|
92
|
+
// src/oimSubscribeHeldSlot.ts
|
|
93
|
+
function oimSubscribeHeldSlot(channelMap, hookName, snapshotVersion, holdingSlot, sourcesOfSlot, onStoreChange) {
|
|
94
|
+
try {
|
|
95
|
+
oimAssertOneChannel(channelMap, holdingSlot, hookName);
|
|
96
|
+
const [sourceSlots, sourceComputeds] = sourcesOfSlot(holdingSlot);
|
|
97
|
+
return snapshotVersion.subscribeEffect(channelMap, onStoreChange, sourceSlots, sourceComputeds);
|
|
98
|
+
} finally {
|
|
99
|
+
holdingSlot.owner.unholdSlot(holdingSlot);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
// src/useOIMSlotByKey.ts
|
|
94
104
|
var sourcesOfRootSlot = (rootSlot) => [[rootSlot], OIM_FROZEN_EMPTY_SLOTS2];
|
|
95
105
|
function useOIMSlotByKey(hookName, slotCollectionService, storeSlot, key, sourcesOfSlot = sourcesOfRootSlot) {
|
|
@@ -110,18 +120,12 @@ function useOIMSlotByKey(hookName, slotCollectionService, storeSlot, key, source
|
|
|
110
120
|
snapshotVersion,
|
|
111
121
|
subscribe: (onStoreChange) => {
|
|
112
122
|
const holdingSlot = slotCollectionService.holdSlotByKey(storeSlot, settledKey);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
subscribedSlot = void 0;
|
|
120
|
-
disposeEffect();
|
|
121
|
-
};
|
|
122
|
-
} finally {
|
|
123
|
-
holdingSlot.owner.unholdSlot(holdingSlot);
|
|
124
|
-
}
|
|
123
|
+
const effectDisposer = oimSubscribeHeldSlot(db, hookName, snapshotVersion, holdingSlot, sourcesOfSlot, onStoreChange);
|
|
124
|
+
subscribedSlot = holdingSlot;
|
|
125
|
+
return () => {
|
|
126
|
+
subscribedSlot = void 0;
|
|
127
|
+
effectDisposer();
|
|
128
|
+
};
|
|
125
129
|
},
|
|
126
130
|
getSlot: () => subscribedSlot ?? slotCollectionService.getSlotByKey(storeSlot, settledKey)
|
|
127
131
|
};
|
|
@@ -137,7 +141,9 @@ function useOIMEntity(entityCollectionService, entityStoreSlot, key) {
|
|
|
137
141
|
|
|
138
142
|
// src/useOIMSingleSlot.ts
|
|
139
143
|
import { useMemo as useMemo4 } from "react";
|
|
140
|
-
|
|
144
|
+
import { OIM_FROZEN_EMPTY_SLOTS as OIM_FROZEN_EMPTY_SLOTS3 } from "@oimdb/core";
|
|
145
|
+
var sourcesOfRootSlot2 = (rootSlot) => [[rootSlot], OIM_FROZEN_EMPTY_SLOTS3];
|
|
146
|
+
function useOIMSingleSlot(hookName, singleSlotService, singleSlotStoreSlot, sourcesOfSlot = sourcesOfRootSlot2) {
|
|
141
147
|
const db = useOIMDB();
|
|
142
148
|
const store = useMemo4(() => {
|
|
143
149
|
const snapshotVersion = new OIMSnapshotVersion();
|
|
@@ -146,21 +152,16 @@ function useOIMSingleSlot(hookName, singleSlotService, singleSlotStoreSlot) {
|
|
|
146
152
|
snapshotVersion,
|
|
147
153
|
subscribe: (onStoreChange) => {
|
|
148
154
|
const holdingSlot = singleSlotService.holdSingleSlot(singleSlotStoreSlot);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
subscribedSlot =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
disposeEffect();
|
|
156
|
-
};
|
|
157
|
-
} finally {
|
|
158
|
-
holdingSlot.owner.unholdSlot(holdingSlot);
|
|
159
|
-
}
|
|
155
|
+
const effectDisposer = oimSubscribeHeldSlot(db, hookName, snapshotVersion, holdingSlot, sourcesOfSlot, onStoreChange);
|
|
156
|
+
subscribedSlot = holdingSlot;
|
|
157
|
+
return () => {
|
|
158
|
+
subscribedSlot = void 0;
|
|
159
|
+
effectDisposer();
|
|
160
|
+
};
|
|
160
161
|
},
|
|
161
162
|
getSlot: () => subscribedSlot ?? singleSlotService.getSingleSlot(singleSlotStoreSlot)
|
|
162
163
|
};
|
|
163
|
-
}, [hookName, db, singleSlotService, singleSlotStoreSlot]);
|
|
164
|
+
}, [hookName, db, singleSlotService, singleSlotStoreSlot, sourcesOfSlot]);
|
|
164
165
|
useOIMSnapshotVersion(store.snapshotVersion, store.subscribe);
|
|
165
166
|
return store.getSlot();
|
|
166
167
|
}
|
|
@@ -213,9 +214,8 @@ function useOIMField(entityCollectionService, slot, name) {
|
|
|
213
214
|
snapshotVersion,
|
|
214
215
|
subscribe: (onStoreChange) => holdWhileSubscribed(holds, () => snapshotVersion.subscribeEffect(
|
|
215
216
|
db,
|
|
216
|
-
|
|
217
|
-
[]
|
|
218
|
-
onStoreChange
|
|
217
|
+
onStoreChange,
|
|
218
|
+
[entityCollectionService.columnSlotService.getColumn(slot, name)]
|
|
219
219
|
))
|
|
220
220
|
};
|
|
221
221
|
}, [db, entityCollectionService, slot, name]);
|
|
@@ -293,8 +293,8 @@ function useOIMSlotsByKeys(slotCollectionService, storeSlot, keys) {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
// src/useOIMComputedValueByKey.ts
|
|
296
|
-
import { OIM_FROZEN_EMPTY_SLOTS as
|
|
297
|
-
var sourcesOfComputedSlot = (computedSlot) => [
|
|
296
|
+
import { OIM_FROZEN_EMPTY_SLOTS as OIM_FROZEN_EMPTY_SLOTS4 } from "@oimdb/core";
|
|
297
|
+
var sourcesOfComputedSlot = (computedSlot) => [OIM_FROZEN_EMPTY_SLOTS4, [computedSlot]];
|
|
298
298
|
function useOIMComputedValueByKey(computedCollectionService, computedStoreSlot, key) {
|
|
299
299
|
const computedSlot = useOIMSlotByKey(
|
|
300
300
|
"useOIMComputedValueByKey",
|
|
@@ -308,6 +308,8 @@ function useOIMComputedValueByKey(computedCollectionService, computedStoreSlot,
|
|
|
308
308
|
|
|
309
309
|
// src/useOIMSingleComputedValue.ts
|
|
310
310
|
import { useMemo as useMemo7 } from "react";
|
|
311
|
+
import { OIM_FROZEN_EMPTY_SLOTS as OIM_FROZEN_EMPTY_SLOTS5 } from "@oimdb/core";
|
|
312
|
+
var sourcesOfComputedSlot2 = (computedSlot) => [OIM_FROZEN_EMPTY_SLOTS5, [computedSlot]];
|
|
311
313
|
function useOIMSingleComputedValue(computedService, derive, createSources, dependencyList) {
|
|
312
314
|
const db = useOIMDB();
|
|
313
315
|
const computedStoreSlot = useMemo7(
|
|
@@ -315,11 +317,13 @@ function useOIMSingleComputedValue(computedService, derive, createSources, depen
|
|
|
315
317
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- the caller's list is checked at the call site
|
|
316
318
|
[db, computedService, ...dependencyList]
|
|
317
319
|
);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
+
const computedSlot = useOIMSingleSlot(
|
|
321
|
+
"useOIMSingleComputedValue",
|
|
322
|
+
computedService.computedSingleSlotService,
|
|
320
323
|
computedStoreSlot,
|
|
321
|
-
|
|
324
|
+
sourcesOfComputedSlot2
|
|
322
325
|
);
|
|
326
|
+
return computedSlot.computedValueService.getValueForSlot(computedSlot);
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
// src/useOIMComputedCollection.ts
|