mnfst 0.5.36 → 0.5.38

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.
@@ -1310,15 +1310,31 @@ function setNestedValue(obj, path, value) {
1310
1310
  for (let i = 0; i < keys.length - 1; i++) {
1311
1311
  const key = keys[i];
1312
1312
  const nextKey = keys[i + 1];
1313
+ const nextIsIndex = /^\d+$/.test(nextKey);
1314
+
1313
1315
  if (!(key in current)) {
1314
- current[key] = /^\d+$/.test(nextKey) ? [] : {};
1316
+ current[key] = nextIsIndex ? [] : {};
1317
+ } else if (nextIsIndex && !Array.isArray(current[key]) && current[key] && typeof current[key] === 'object') {
1318
+ // If we later discover this container should be an array, coerce numeric-key objects.
1319
+ const existing = current[key];
1320
+ const existingKeys = Object.keys(existing);
1321
+ const numericOnly = existingKeys.every(k => /^\d+$/.test(k));
1322
+ if (numericOnly) {
1323
+ const arr = [];
1324
+ existingKeys.forEach(k => {
1325
+ arr[parseInt(k, 10)] = existing[k];
1326
+ });
1327
+ current[key] = arr;
1328
+ }
1315
1329
  }
1330
+
1316
1331
  if (Array.isArray(current) && /^\d+$/.test(key)) {
1317
1332
  const idx = parseInt(key, 10);
1318
1333
  if (current[idx] == null || typeof current[idx] !== 'object') {
1319
- current[idx] = {};
1334
+ current[idx] = nextIsIndex ? [] : {};
1320
1335
  }
1321
1336
  }
1337
+
1322
1338
  current = current[key];
1323
1339
  }
1324
1340
 
@@ -2353,6 +2369,9 @@ function getLoadingBranch(depth) {
2353
2369
  const d = depth == null ? 0 : Math.min(Math.max(0, depth), MAX_LOADING_BRANCH_DEPTH);
2354
2370
  if (loadingBranchByDepth[d]) return loadingBranchByDepth[d];
2355
2371
  const emptyStr = function () { return ''; };
2372
+ const emptyArray = [];
2373
+ const attachArrayMethods = window.ManifestDataProxies?.attachArrayMethods;
2374
+ const arrayWithMethods = attachArrayMethods ? attachArrayMethods(emptyArray, '', null) : emptyArray;
2356
2375
  const nextDepth = d + 1;
2357
2376
  const getReturnForStringKey = () =>
2358
2377
  nextDepth <= MAX_LOADING_BRANCH_DEPTH ? getLoadingBranch(nextDepth) : '';
@@ -2364,6 +2383,12 @@ function getLoadingBranch(depth) {
2364
2383
  if (key === '$route' || key === '$search' || key === '$query') {
2365
2384
  return function () { return getLoadingBranch(nextDepth <= MAX_LOADING_BRANCH_DEPTH ? nextDepth : MAX_LOADING_BRANCH_DEPTH); };
2366
2385
  }
2386
+ if (typeof key === 'string' && typeof Array.prototype[key] === 'function') {
2387
+ if (key in arrayWithMethods && typeof arrayWithMethods[key] === 'function') {
2388
+ return arrayWithMethods[key].bind(arrayWithMethods);
2389
+ }
2390
+ return Array.prototype[key].bind(arrayWithMethods);
2391
+ }
2367
2392
  if (key === 'length') return 0;
2368
2393
  if (typeof key === 'string') return getReturnForStringKey();
2369
2394
  if (typeof key === 'symbol') return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.36",
3
+ "version": "0.5.38",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",