mnfst 0.5.27 → 0.5.28

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.
@@ -2315,26 +2315,33 @@ function getLoadingBranchSafe() {
2315
2315
  return cachedLoadingBranchSafe;
2316
2316
  }
2317
2317
 
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; };
2318
+ // Max depth for loading placeholder chain; beyond this, string keys return '' to avoid stack overflow.
2319
+ const MAX_LOADING_BRANCH_DEPTH = 10;
2320
+
2321
+ const loadingBranchByDepth = Object.create(null);
2322
+ function getLoadingBranch(depth) {
2323
+ const d = depth == null ? 0 : Math.min(Math.max(0, depth), MAX_LOADING_BRANCH_DEPTH);
2324
+ if (loadingBranchByDepth[d]) return loadingBranchByDepth[d];
2324
2325
  const emptyStr = function () { return ''; };
2325
- cachedLoadingBranch = new Proxy(Object.create(null), {
2326
+ const nextDepth = d + 1;
2327
+ const getReturnForStringKey = () =>
2328
+ nextDepth <= MAX_LOADING_BRANCH_DEPTH ? getLoadingBranch(nextDepth) : '';
2329
+ loadingBranchByDepth[d] = new Proxy(Object.create(null), {
2326
2330
  get(_, key) {
2327
2331
  if (key === Symbol.toPrimitive || key === 'valueOf' || key === 'toString') return emptyStr;
2328
2332
  if (key === 'then' || key === 'catch' || key === 'finally') return undefined;
2329
2333
  if (key === Symbol.iterator) return function* () { };
2330
- if (key === '$route' || key === '$search' || key === '$query') return returnSelf;
2334
+ if (key === '$route' || key === '$search' || key === '$query') {
2335
+ return function () { return getLoadingBranch(nextDepth <= MAX_LOADING_BRANCH_DEPTH ? nextDepth : MAX_LOADING_BRANCH_DEPTH); };
2336
+ }
2331
2337
  if (key === 'length') return 0;
2332
- if (typeof key === 'string') return cachedLoadingBranch;
2333
- return undefined;
2338
+ if (typeof key === 'string') return getReturnForStringKey();
2339
+ if (typeof key === 'symbol') return undefined;
2340
+ return getLoadingBranch(MAX_LOADING_BRANCH_DEPTH);
2334
2341
  },
2335
2342
  has() { return true; }
2336
2343
  });
2337
- return cachedLoadingBranch;
2344
+ return loadingBranchByDepth[d];
2338
2345
  }
2339
2346
 
2340
2347
  // Create a simple fallback object that returns empty strings for all properties.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.27",
3
+ "version": "0.5.28",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter"