mnfst 0.5.27 → 0.5.29

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.
@@ -1324,6 +1324,20 @@ function setNestedValue(obj, path, value) {
1324
1324
  current[keys[keys.length - 1]] = value;
1325
1325
  }
1326
1326
 
1327
+ // If the key-value result has only numeric top-level keys (e.g. 0.path, 1.path), convert to array
1328
+ // so $route/$search/$query work and the shape matches YAML/JSON array sources.
1329
+ function numericKeyObjectToArray(obj) {
1330
+ if (obj == null || Array.isArray(obj) || typeof obj !== 'object') {
1331
+ return obj;
1332
+ }
1333
+ const keys = Object.keys(obj);
1334
+ if (keys.length === 0) return obj;
1335
+ const numericKeys = keys.filter(k => /^\d+$/.test(k));
1336
+ if (numericKeys.length !== keys.length) return obj;
1337
+ const sorted = numericKeys.map(k => parseInt(k, 10)).sort((a, b) => a - b);
1338
+ return sorted.map(i => obj[String(i)]);
1339
+ }
1340
+
1327
1341
  // Parse CSV text to nested object structure
1328
1342
  function parseCSVToNestedObject(csvText, options = {}) {
1329
1343
  const {
@@ -1427,7 +1441,7 @@ function parseCSVToNestedObject(csvText, options = {}) {
1427
1441
  setNestedValue(result, key, value);
1428
1442
  }
1429
1443
 
1430
- return result;
1444
+ return numericKeyObjectToArray(result);
1431
1445
  }
1432
1446
  } else {
1433
1447
  // Fallback simple parser (if PapaParse not loaded)
@@ -1539,7 +1553,7 @@ function parseCSVToNestedObject(csvText, options = {}) {
1539
1553
  setNestedValue(result, key, value);
1540
1554
  }
1541
1555
 
1542
- return result;
1556
+ return numericKeyObjectToArray(result);
1543
1557
  }
1544
1558
  }
1545
1559
  }
@@ -2315,26 +2329,33 @@ function getLoadingBranchSafe() {
2315
2329
  return cachedLoadingBranchSafe;
2316
2330
  }
2317
2331
 
2318
- // Chainable loading branch: return self for string keys, callable for $route. Used for
2319
- // json/yaml/etc so $x.json.products.$route('path').name and deep paths don't throw.
2320
- let cachedLoadingBranch = null;
2321
- function getLoadingBranch() {
2322
- if (cachedLoadingBranch) return cachedLoadingBranch;
2323
- const returnSelf = function () { return cachedLoadingBranch; };
2332
+ // Max depth for loading placeholder chain; beyond this, string keys return '' to avoid stack overflow.
2333
+ const MAX_LOADING_BRANCH_DEPTH = 10;
2334
+
2335
+ const loadingBranchByDepth = Object.create(null);
2336
+ function getLoadingBranch(depth) {
2337
+ const d = depth == null ? 0 : Math.min(Math.max(0, depth), MAX_LOADING_BRANCH_DEPTH);
2338
+ if (loadingBranchByDepth[d]) return loadingBranchByDepth[d];
2324
2339
  const emptyStr = function () { return ''; };
2325
- cachedLoadingBranch = new Proxy(Object.create(null), {
2340
+ const nextDepth = d + 1;
2341
+ const getReturnForStringKey = () =>
2342
+ nextDepth <= MAX_LOADING_BRANCH_DEPTH ? getLoadingBranch(nextDepth) : '';
2343
+ loadingBranchByDepth[d] = new Proxy(Object.create(null), {
2326
2344
  get(_, key) {
2327
2345
  if (key === Symbol.toPrimitive || key === 'valueOf' || key === 'toString') return emptyStr;
2328
2346
  if (key === 'then' || key === 'catch' || key === 'finally') return undefined;
2329
2347
  if (key === Symbol.iterator) return function* () { };
2330
- if (key === '$route' || key === '$search' || key === '$query') return returnSelf;
2348
+ if (key === '$route' || key === '$search' || key === '$query') {
2349
+ return function () { return getLoadingBranch(nextDepth <= MAX_LOADING_BRANCH_DEPTH ? nextDepth : MAX_LOADING_BRANCH_DEPTH); };
2350
+ }
2331
2351
  if (key === 'length') return 0;
2332
- if (typeof key === 'string') return cachedLoadingBranch;
2333
- return undefined;
2352
+ if (typeof key === 'string') return getReturnForStringKey();
2353
+ if (typeof key === 'symbol') return undefined;
2354
+ return getLoadingBranch(MAX_LOADING_BRANCH_DEPTH);
2334
2355
  },
2335
2356
  has() { return true; }
2336
2357
  });
2337
- return cachedLoadingBranch;
2358
+ return loadingBranchByDepth[d];
2338
2359
  }
2339
2360
 
2340
2361
  // Create a simple fallback object that returns empty strings for all properties.
@@ -506,15 +506,16 @@ async function initializeMarkdownPlugin() {
506
506
  }
507
507
  lastProcessedContent = markdownContent;
508
508
 
509
- // Skip empty content
510
- if (!markdownContent || markdownContent.trim() === '') {
509
+ // Ensure we have a string (e.g. $route('path')?.content can be a proxy while loading)
510
+ const contentStr = typeof markdownContent === 'string' ? markdownContent : '';
511
+ if (!contentStr || contentStr.trim() === '') {
511
512
  el.style.opacity = '0';
512
513
  hasContent = false;
513
514
  return;
514
515
  }
515
516
 
516
517
  const marked = await loadMarkedJS();
517
- let html = marked.parse(markdownContent);
518
+ let html = marked.parse(contentStr);
518
519
 
519
520
  // Post-process HTML to enable checkboxes (remove disabled attribute)
520
521
  html = enableCheckboxes(html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.27",
3
+ "version": "0.5.29",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter"