cogsbox-state 0.5.464 → 0.5.465
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/CogsState.d.ts +10 -30
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +1466 -1490
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Functions.d.ts.map +1 -1
- package/dist/Functions.jsx +23 -16
- package/dist/Functions.jsx.map +1 -1
- package/dist/index.js +26 -26
- package/dist/store.d.ts +39 -47
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +259 -295
- package/dist/store.js.map +1 -1
- package/dist/utility.d.ts +0 -1
- package/dist/utility.d.ts.map +1 -1
- package/dist/utility.js +121 -158
- package/dist/utility.js.map +1 -1
- package/package.json +5 -4
- package/src/CogsState.tsx +1047 -1392
- package/src/Functions.tsx +27 -7
- package/src/store.ts +489 -593
- package/src/utility.ts +0 -65
package/src/utility.ts
CHANGED
|
@@ -162,71 +162,6 @@ export function deleteNestedProperty(path: string[], state: any): any {
|
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
export function getNestedValue<TStateObject extends unknown>(
|
|
166
|
-
obj: TStateObject,
|
|
167
|
-
pathArray: string[],
|
|
168
|
-
stateKey: string // <-- ADD THIS ARGUMENT
|
|
169
|
-
) {
|
|
170
|
-
let value: any = obj;
|
|
171
|
-
|
|
172
|
-
for (let i = 0; i < pathArray.length; i++) {
|
|
173
|
-
const key = pathArray[i]!;
|
|
174
|
-
if (value === undefined || value === null) {
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (typeof key === 'string' && key.startsWith('id:')) {
|
|
179
|
-
if (!Array.isArray(value)) {
|
|
180
|
-
console.error("Path segment with 'id:' requires an array.", {
|
|
181
|
-
path: pathArray,
|
|
182
|
-
currentValue: value,
|
|
183
|
-
});
|
|
184
|
-
return undefined;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// --- START OF THE SURGICAL FIX ---
|
|
188
|
-
|
|
189
|
-
// 1. Construct the FULL path of the item we are looking for.
|
|
190
|
-
const parentPath = pathArray.slice(0, i);
|
|
191
|
-
const fullItemPathToFind = [stateKey, ...parentPath, key].join('.');
|
|
192
|
-
|
|
193
|
-
// 2. Get the metadata for the PARENT array.
|
|
194
|
-
const parentShadowKey = [stateKey, ...parentPath].join('.');
|
|
195
|
-
const parentShadowMeta = getGlobalStore
|
|
196
|
-
.getState()
|
|
197
|
-
.shadowStateStore.get(parentShadowKey);
|
|
198
|
-
|
|
199
|
-
if (!parentShadowMeta?.arrayKeys) {
|
|
200
|
-
console.error(
|
|
201
|
-
'No arrayKeys found in shadow state for parent path:',
|
|
202
|
-
parentShadowKey
|
|
203
|
-
);
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// 3. Find the INDEX of the full item path in the parent's arrayKeys.
|
|
208
|
-
const itemIndex = parentShadowMeta.arrayKeys.indexOf(fullItemPathToFind);
|
|
209
|
-
|
|
210
|
-
if (itemIndex === -1) {
|
|
211
|
-
console.error(
|
|
212
|
-
`Item key ${fullItemPathToFind} not found in parent's arrayKeys:`,
|
|
213
|
-
parentShadowMeta.arrayKeys
|
|
214
|
-
);
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// 4. Use that index to get the item from the plain JS array.
|
|
219
|
-
value = value[itemIndex];
|
|
220
|
-
|
|
221
|
-
// --- END OF THE SURGICAL FIX ---
|
|
222
|
-
} else if (Array.isArray(value)) {
|
|
223
|
-
value = value[parseInt(key)];
|
|
224
|
-
} else {
|
|
225
|
-
value = value[key];
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return value;
|
|
229
|
-
}
|
|
230
165
|
|
|
231
166
|
type DifferencePaths = string[];
|
|
232
167
|
|