@symbo.ls/utils 3.14.16 → 3.14.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
3
9
  ## 3.14.16
4
10
 
5
11
  ### Patch Changes
@@ -1,14 +1,13 @@
1
- "use strict";var P=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var o in t)P(e,o,{get:t[o],enumerable:!0})},H=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of q(t))!B.call(e,n)&&n!==o&&P(e,n,{get:()=>t[n],enumerable:!(r=F(t,n))||r.enumerable});return e};var J=e=>H(P({},"__esModule",{value:!0}),e);var _e={};G(_e,{clone:()=>z,createNestedObject:()=>pe,createObjectWithoutPrototype:()=>W,deepClone:()=>R,deepContains:()=>ue,deepDestringifyFunctions:()=>A,deepMerge:()=>b,deepStringifyFunctions:()=>k,destringifyGlobalScope:()=>ne,detectInfiniteLoop:()=>we,excludeKeysFromObject:()=>ge,exec:()=>x,getInObjectByPath:()=>de,hasFunction:()=>S,hasOwnProperty:()=>oe,isCyclic:()=>Oe,isEmpty:()=>C,isEmptyObject:()=>se,isEqualDeep:()=>M,makeObjectWithoutPrototype:()=>ie,map:()=>U,merge:()=>V,objectToString:()=>E,overwrite:()=>ce,overwriteDeep:()=>I,overwriteShallow:()=>fe,removeFromObject:()=>ae,removeNestedKeyByPath:()=>ye,setInObjectByPath:()=>he,stringToObject:()=>re});module.exports=J(_e);var _=require("./globals.js"),c=require("./types.js"),T=require("./array.js"),N=require("./string.js"),O=require("./node.js"),D=require("./keys.js");const $="production",g=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,x=(e,t,o,r)=>{if((0,c.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,r||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,c.isArray)(e)||(0,c.isObject)(e)&&!(0,O.isDOMNode)(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const i=s.resolveHandler(e,t);if(typeof i=="function")return x(i,t,o,r)}}return e},U=(e,t,o)=>{for(const r in t)e[r]=x(t[r],o)},V=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(g(n)||(r?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},b=(e,t,o=D.METHODS_EXL)=>v(e,t,o,null),v=(e,t,o,r)=>{if(e===t)return e;if(r){for(let s=0;s<r.length;s+=2)if(r[s]===e&&r[s+1]===t)return e}const n=o instanceof Set;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||g(s)||s==="constructor"||s==="prototype"||(n?o.has(s):o.includes(s)))continue;const i=e[s],f=t[s];if((0,c.isObjectLike)(i)&&(0,c.isObjectLike)(f)){const l=r||[];l.push(e,t),v(i,f,o,l),l.length-=2}else i===void 0&&(e[s]=f)}return e},z=(e,t=[])=>{const o=t instanceof Set,r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(g(n)||(o?t.has(n):t.includes(n))||(r[n]=e[n]));return r},R=(e,t={})=>{const{exclude:o=[],cleanUndefined:r=!1,cleanNull:n=!1,window:s,visited:i=new WeakMap,handleExtends:f=!1}=t,l=s||_.window||globalThis;if(!(0,c.isObjectLike)(e)||(0,O.isDOMNode)(e))return e;if(i.has(e))return i.get(e);const a=(0,c.isArray)(e)?[]:{};i.set(e,a);const h=o instanceof Set?o:o.length>3?new Set(o):null;for(const p in e){if(!Object.prototype.hasOwnProperty.call(e,p)||g(p)||p==="__proto__"||(h?h.has(p):o.includes(p)))continue;const y=e[p];if(!(r&&y===void 0)&&!(n&&y===null)){if((0,O.isDOMNode)(y)){a[p]=y;continue}if(f&&p==="extends"&&(0,c.isArray)(y)){a[p]=(0,T.unstackArrayOfObjects)(y,o);continue}if((0,c.isFunction)(y)){a[p]=y;continue}(0,c.isObjectLike)(y)?a[p]=R(y,{...t,visited:i}):a[p]=y}}return a},k=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const r=e[o];if((0,c.isFunction)(r))t[o]=r.toString();else if((0,c.isObject)(r))t[o]={},k(r,t[o]);else if((0,c.isArray)(r)){const n=t[o]=[];for(let s=0;s<r.length;s++){const i=r[s];(0,c.isObject)(i)?(n[s]={},k(i,n[s])):(0,c.isFunction)(i)?n[s]=i.toString():n[s]=i}}else t[o]=r}return t},K=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),E=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let o=!1;for(const s in e){o=!0;break}if(!o)return"{}";const r=" ".repeat(t);let n=`{
2
- `;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];let f=!1;for(let u=0;u<s.length;u++)if(K.has(s[u])){f=!0;break}const l=f?`'${s}'`:s;if(n+=`${r} ${l}: `,(0,c.isArray)(i)){n+=`[
3
- `;for(const u of i)(0,c.isObjectLike)(u)&&u!==null?n+=`${r} ${E(u,t+2)},
4
- `:(0,c.isString)(u)?n+=`${r} '${u}',
5
- `:n+=`${r} ${u},
6
- `;n+=`${r} ]`}else(0,c.isObjectLike)(i)?n+=E(i,t+1):(0,c.isString)(i)?n+=(0,N.stringIncludesAny)(i,[`
1
+ "use strict";var x=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var q=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},B=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of F(t))!b.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(o=W(t,n))||o.enumerable});return e};var G=e=>B(x({},"__esModule",{value:!0}),e);var Se={};q(Se,{clone:()=>V,createNestedObject:()=>ye,createObjectWithoutPrototype:()=>R,deepClone:()=>z,deepContains:()=>ae,deepDestringifyFunctions:()=>j,deepMerge:()=>U,deepStringifyFunctions:()=>k,destringifyGlobalScope:()=>re,detectInfiniteLoop:()=>ge,excludeKeysFromObject:()=>_e,exec:()=>P,getInObjectByPath:()=>we,hasFunction:()=>S,hasOwnProperty:()=>se,isCyclic:()=>Oe,isEmpty:()=>D,isEmptyObject:()=>ie,isEqualDeep:()=>M,makeObjectWithoutPrototype:()=>ce,map:()=>H,merge:()=>J,objectToString:()=>E,overwrite:()=>fe,overwriteDeep:()=>I,overwriteShallow:()=>le,removeFromObject:()=>pe,removeNestedKeyByPath:()=>he,setInObjectByPath:()=>de,stringToObject:()=>oe});module.exports=G(Se);var _=require("./globals.js"),c=require("./types.js"),T=require("./array.js"),N=require("./string.js"),g=require("./node.js"),C=require("./keys.js");const A="production",O=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,P=(e,t,r,o)=>{if((0,c.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,o||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,c.isArray)(e)||(0,c.isObject)(e)&&!(0,g.isDOMNode)(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const i=s.resolveHandler(e,t);if(typeof i=="function")return P(i,t,r,o)}}return e},H=(e,t,r)=>{for(const o in t)e[o]=P(t[o],r)},J=(e,t,r=[])=>{const o=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(O(n)||(o?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},U=(e,t,r=C.METHODS_EXL)=>$(e,t,r,null),$=(e,t,r,o)=>{if(e===t)return e;if(o){for(let s=0;s<o.length;s+=2)if(o[s]===e&&o[s+1]===t)return e}const n=r instanceof Set;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||O(s)||s==="constructor"||s==="prototype"||(n?r.has(s):r.includes(s)))continue;const i=e[s],f=t[s];if((0,c.isObjectLike)(i)&&(0,c.isObjectLike)(f)){const l=o||[];l.push(e,t),$(i,f,r,l),l.length-=2}else i===void 0&&(e[s]=f)}return e},V=(e,t=[])=>{const r=t instanceof Set,o={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(O(n)||(r?t.has(n):t.includes(n))||(o[n]=e[n]));return o},z=(e,t={})=>{const{exclude:r=[],cleanUndefined:o=!1,cleanNull:n=!1,visited:s=new WeakMap,handleExtends:i=!1}=t;if(!(0,c.isObjectLike)(e)||(0,g.isDOMNode)(e))return e;if(s.has(e))return s.get(e);const f=r instanceof Set?r:r.length>3?new Set(r):null,l=p=>f?f.has(p):r.includes(p),u=(0,c.isArray)(e)?[]:{};s.set(e,u);const y=[[e,u]];for(;y.length;){const[p,d]=y.pop();for(const h in p){if(!Object.prototype.hasOwnProperty.call(p,h)||O(h)||h==="__proto__"||l(h))continue;const a=p[h];if(!(o&&a===void 0)&&!(n&&a===null)){if((0,g.isDOMNode)(a)){d[h]=a;continue}if(i&&h==="extends"&&(0,c.isArray)(a)){d[h]=(0,T.unstackArrayOfObjects)(a,r);continue}if((0,c.isFunction)(a)){d[h]=a;continue}if((0,c.isObjectLike)(a))if(s.has(a))d[h]=s.get(a);else{const w=(0,c.isArray)(a)?[]:{};s.set(a,w),d[h]=w,y.push([a,w])}else d[h]=a}}}return u},k=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const r in e){const o=e[r];if((0,c.isFunction)(o))t[r]=o.toString();else if((0,c.isObject)(o))t[r]={},k(o,t[r]);else if((0,c.isArray)(o)){const n=t[r]=[];for(let s=0;s<o.length;s++){const i=o[s];(0,c.isObject)(i)?(n[s]={},k(i,n[s])):(0,c.isFunction)(i)?n[s]=i.toString():n[s]=i}}else t[r]=o}return t},K=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),E=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const s in e){r=!0;break}if(!r)return"{}";const o=" ".repeat(t);let n=`{
2
+ `;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];let f=!1;for(let u=0;u<s.length;u++)if(K.has(s[u])){f=!0;break}const l=f?`'${s}'`:s;if(n+=`${o} ${l}: `,(0,c.isArray)(i)){n+=`[
3
+ `;for(const u of i)(0,c.isObjectLike)(u)&&u!==null?n+=`${o} ${E(u,t+2)},
4
+ `:(0,c.isString)(u)?n+=`${o} '${u}',
5
+ `:n+=`${o} ${u},
6
+ `;n+=`${o} ]`}else(0,c.isObjectLike)(i)?n+=E(i,t+1):(0,c.isString)(i)?n+=(0,N.stringIncludesAny)(i,[`
7
7
  `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
- `}return n+=`${r}}`,n},X=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],Y=/^["[{]/,Z=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||Z.test(t)||!X.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||Y.test(t)&&!n)},m=e=>(0,eval)(e),Q=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const r=o[0].length,n=[];let s=r,i=1,f=null;const l=e.length,u=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;s<l&&i>0;){const h=e[s];if(h==="/"&&e[s+1]==="/"){const p=e.indexOf(`
9
- `,s);s=p===-1?l:p;continue}if(h==="/"&&e[s+1]==="*"){const p=e.indexOf("*/",s+2);s=p===-1?l:p+2;continue}if(h==='"'||h==="'"||h==="`"){const p=h;for(s++;s<l;){if(e[s]==="\\"){s+=2;continue}if(e[s]===p){s++;break}if(p==="`"&&e[s]==="$"&&e[s+1]==="{"){s+=2;let y=1;for(;s<l&&y>0;)e[s]==="{"?y++:e[s]==="}"&&y--,s++;continue}s++}continue}if(h==="{"){i++,s++;continue}if(h==="}"){i--,s++;continue}if(i===1&&u.test(e.slice(s))){const p=s;let y=0,d=s;for(;d<l;){const w=e[d];if(w==='"'||w==="'"||w==="`"){const L=w;for(d++;d<l;){if(e[d]==="\\"){d+=2;continue}if(e[d]===L){d++;break}d++}continue}if(w==="("||w==="["||w==="{"){y++,d++;continue}if(w===")"||w==="]"||w==="}"){if(y===0)break;y--,d++;continue}if(y===0&&(w===";"||w===`
10
- `)){d++;break}d++}n.push([p,d]),s=d;continue}s++}if(!n.length)return null;let a=e;for(let h=n.length-1;h>=0;h--)a=a.slice(0,n[h][0])+a.slice(n[h][1]);return a},A=(e,t={},o={window:{eval:m}})=>{for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const n=e[r];if((0,c.isString)(n))if(S(n))try{t[r]=o.window.eval(`(${n})`)}catch(s){const i=s&&s.message?s.message:String(s),f=/await is only valid in async/.test(i),l=/Identifier '([^']+)' has already been declared/.exec(i);let u=null;if(f){const a=String(n).trim();if(/^function[\s(]/.test(a))try{u=o.window.eval("(async "+a+")")}catch{}}else if(l){let a=String(n),h=l[1];for(let p=0;p<5;p++){const y=Q(a,h);if(!y||y===a)break;a=y;try{u=o.window.eval("("+a+")");break}catch(d){const w=/Identifier '([^']+)' has already been declared/.exec(d&&d.message||String(d));if(!w||w[1]!==h)break}}}u?t[r]=u:(typeof console<"u"&&console.warn&&console.warn('[smbls] deepDestringifyFunctions: eval failed on "'+r+'" \u2014 function will be left as a string and el.call("'+r+'") will silently no-op. Reason: '+i+`.
11
- First 200 chars of source: `+String(n).slice(0,200)),t[r]=n)}else t[r]=n;else if((0,c.isArray)(n)){const s=t[r]=[];for(let i=0;i<n.length;i++){const f=n[i];if((0,c.isString)(f))if(S(f))try{s.push(o.window.eval(`(${f})`))}catch(l){typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed in array at index ${i} (prop "${r}"). Reason: ${l&&l.message?l.message:String(l)}.
12
- First 200 chars: ${String(f).slice(0,200)}`),s.push(f)}else s.push(f);else(0,c.isObject)(f)?s.push(A(f)):s.push(f)}}else(0,c.isObject)(n)?t[r]=A(n,t[r]):t[r]=n}return t},j="Set",ee="Map",te=e=>!e||typeof e!="object"?e:e.__type===j&&Array.isArray(e.values)?new Set(e.values):e.__type===ee&&Array.isArray(e.entries)?new Map(e.entries):e,ne=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const r of Object.keys(e)){const n=e[r];(0,c.isString)(n)&&S(n)?o.push([r,n]):t[r]=te(n)}for(const[r,n]of o)try{const s=Object.keys(t).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
13
- `);t[r]=_.window.eval(`(function(__gs__) { ${s}
14
- return (${n}); })`)(t)}catch{try{t[r]=_.window.eval(`(${n})`)}catch{t[r]=n}}return t},re=(e,t={verbose:!0})=>{try{return e?_.window.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},oe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),C=e=>{for(const t in e)return!1;return!0},se=e=>(0,c.isObject)(e)&&C(e),ie=()=>Object.create(null),ce=(e,t,o={})=>{const r=o.exclude||[],n=o.preventUnderscore;for(const s in t)r.includes(s)||!n&&g(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},fe=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)g(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n))||(e[n]=t[n]);return e},I=(e,t,o={},r=new WeakMap)=>{if(!(0,c.isObjectLike)(e)||!(0,c.isObjectLike)(t)||(0,O.isDOMNode)(e)||(0,O.isDOMNode)(t))return t;if(r.has(e))return r.get(e);r.set(e,e);const n=o.exclude,s=n?n instanceof Set?n:new Set(n):null,i=!o.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||s&&s.has(f)||i&&g(f)||f==="constructor"||f==="prototype")continue;const l=e[f],u=t[f];(0,O.isDOMNode)(u)?e[f]=u:(0,c.isObjectLike)(l)&&(0,c.isObjectLike)(u)?e[f]=I(l,u,o,r):u!==void 0&&(e[f]=u)}return e},M=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++){const i=r[s];if(!Object.prototype.hasOwnProperty.call(t,i)||!M(e[i],t[i],o))return!1}return!0},le=new Set(["node","__ref"]),ue=(e,t,o=le)=>{if(e===t)return!0;if(!(0,c.isObjectLike)(e)||!(0,c.isObjectLike)(t)||(0,O.isDOMNode)(e)||(0,O.isDOMNode)(t))return e===t;const r=o instanceof Set?o:new Set(o),n=new WeakSet;function s(i,f){if(n.has(f))return!0;n.add(f);for(const l in f){if(!Object.prototype.hasOwnProperty.call(f,l)||r.has(l))continue;if(!Object.prototype.hasOwnProperty.call(i,l))return!1;const u=f[l],a=i[l];if((0,O.isDOMNode)(u)||(0,O.isDOMNode)(a)){if(u!==a)return!1}else if((0,c.isObjectLike)(u)&&(0,c.isObjectLike)(a)){if(!s(a,u))return!1}else if(u!==a)return!1}return!0}return s(e,t)},ae=(e,t)=>{if(t==null)return e;if((0,c.is)(t)("string","number"))delete e[t];else if((0,c.isArray)(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},W=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=W(e[o]));return t},pe=(e,t)=>{if(e.length===0)return t;const o={};let r=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?r[e[n]]=t:(r[e[n]]={},r=r[e[n]]);return o},ye=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++){if(o[t[n]]===void 0)return;o=o[t[n]]}const r=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,r)&&delete o[r]},he=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++)(!r[t[n]]||typeof r[t[n]]!="object")&&(r[t[n]]={}),r=r[t[n]];return r[t[t.length-1]]=o,e},de=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length;r++){if(o==null)return;o=o[t[r]]}return o},we=e=>{let o=[],r=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?r++:(o=[e[n-1],e[n]],r=1),r>=20)return($==="test"||$==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Oe=e=>{const t=new WeakSet;function o(r){if(r&&typeof r=="object"){if(t.has(r))return!0;t.add(r);for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&o(r[n]))return console.log(r,"cycle at "+n),!0}return!1}return o(e)},ge=(e,t)=>{const o=t instanceof Set?t:new Set(t),r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(r[n]=e[n]);return r};
8
+ `}return n+=`${o}}`,n},X=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],Y=/^["[{]/,Z=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||Z.test(t)||!X.some(s=>s.test(t)))return!1;const o=t.charCodeAt(0),n=t.includes("=>");return!(o===123&&!n||o===91||Y.test(t)&&!n)},Q=e=>(0,eval)(e),m=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const o=r[0].length,n=[];let s=o,i=1,f=null;const l=e.length,u=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;s<l&&i>0;){const p=e[s];if(p==="/"&&e[s+1]==="/"){const d=e.indexOf(`
9
+ `,s);s=d===-1?l:d;continue}if(p==="/"&&e[s+1]==="*"){const d=e.indexOf("*/",s+2);s=d===-1?l:d+2;continue}if(p==='"'||p==="'"||p==="`"){const d=p;for(s++;s<l;){if(e[s]==="\\"){s+=2;continue}if(e[s]===d){s++;break}if(d==="`"&&e[s]==="$"&&e[s+1]==="{"){s+=2;let h=1;for(;s<l&&h>0;)e[s]==="{"?h++:e[s]==="}"&&h--,s++;continue}s++}continue}if(p==="{"){i++,s++;continue}if(p==="}"){i--,s++;continue}if(i===1&&u.test(e.slice(s))){const d=s;let h=0,a=s;for(;a<l;){const w=e[a];if(w==='"'||w==="'"||w==="`"){const L=w;for(a++;a<l;){if(e[a]==="\\"){a+=2;continue}if(e[a]===L){a++;break}a++}continue}if(w==="("||w==="["||w==="{"){h++,a++;continue}if(w===")"||w==="]"||w==="}"){if(h===0)break;h--,a++;continue}if(h===0&&(w===";"||w===`
10
+ `)){a++;break}a++}n.push([d,a]),s=a;continue}s++}if(!n.length)return null;let y=e;for(let p=n.length-1;p>=0;p--)y=y.slice(0,n[p][0])+y.slice(n[p][1]);return y},v=(e,t,r)=>{try{return r.window.eval(`(${e})`)}catch(o){const n=o&&o.message?o.message:String(o),s=/await is only valid in async/.test(n),i=/Identifier '([^']+)' has already been declared/.exec(n);let f=null;if(s){const l=String(e).trim();if(/^function[\s(]/.test(l))try{f=r.window.eval("(async "+l+")")}catch{}}else if(i){let l=String(e),u=i[1];for(let y=0;y<5;y++){const p=m(l,u);if(!p||p===l)break;l=p;try{f=r.window.eval("("+l+")");break}catch(d){const h=/Identifier '([^']+)' has already been declared/.exec(d&&d.message||String(d));if(!h||h[1]!==u)break}}}return f||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+n+`.
11
+ First 200 chars of source: `+String(e).slice(0,200)),e)}},j=(e,t={},r={window:{eval:Q}})=>{if(!e||typeof e!="object")return t;const o=[[e,t]];for(;o.length;){const[n,s]=o.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=n[i];if((0,c.isString)(f))S(f)?s[i]=v(f,`"${i}"`,r):s[i]=f;else if((0,c.isArray)(f)){const l=s[i]=[];for(let u=0;u<f.length;u++){const y=f[u];if((0,c.isString)(y))l.push(S(y)?v(y,`array index ${u} (prop "${i}")`,r):y);else if((0,c.isObject)(y)){const p={};l.push(p),o.push([y,p])}else l.push(y)}}else if((0,c.isObject)(f)){const l=s[i]&&typeof s[i]=="object"&&!(0,c.isArray)(s[i])?s[i]:s[i]={};o.push([f,l])}else s[i]=f}}return t},ee="Set",te="Map",ne=e=>!e||typeof e!="object"?e:e.__type===ee&&Array.isArray(e.values)?new Set(e.values):e.__type===te&&Array.isArray(e.entries)?new Map(e.entries):e,re=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const o of Object.keys(e)){const n=e[o];(0,c.isString)(n)&&S(n)?r.push([o,n]):t[o]=ne(n)}for(const[o,n]of r)try{const s=Object.keys(t).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
12
+ `);t[o]=_.window.eval(`(function(__gs__) { ${s}
13
+ return (${n}); })`)(t)}catch{try{t[o]=_.window.eval(`(${n})`)}catch{t[o]=n}}return t},oe=(e,t={verbose:!0})=>{try{return e?_.window.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},se=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),D=e=>{for(const t in e)return!1;return!0},ie=e=>(0,c.isObject)(e)&&D(e),ce=()=>Object.create(null),fe=(e,t,r={})=>{const o=r.exclude||[],n=r.preventUnderscore;for(const s in t)o.includes(s)||!n&&O(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},le=(e,t,r=[])=>{const o=r instanceof Set;for(const n in t)O(n)||n==="constructor"||n==="prototype"||(o?r.has(n):r.includes(n))||(e[n]=t[n]);return e},I=(e,t,r={},o=new WeakMap)=>{if(!(0,c.isObjectLike)(e)||!(0,c.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return t;if(o.has(e))return o.get(e);o.set(e,e);const n=r.exclude,s=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||s&&s.has(f)||i&&O(f)||f==="constructor"||f==="prototype")continue;const l=e[f],u=t[f];(0,g.isDOMNode)(u)?e[f]=u:(0,c.isObjectLike)(l)&&(0,c.isObjectLike)(u)?e[f]=I(l,u,r,o):u!==void 0&&(e[f]=u)}return e},M=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const o=Object.keys(e),n=Object.keys(t);if(o.length!==n.length)return!1;for(let s=0;s<o.length;s++){const i=o[s];if(!Object.prototype.hasOwnProperty.call(t,i)||!M(e[i],t[i],r))return!1}return!0},ue=new Set(["node","__ref"]),ae=(e,t,r=ue)=>{if(e===t)return!0;if(!(0,c.isObjectLike)(e)||!(0,c.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return e===t;const o=r instanceof Set?r:new Set(r),n=new WeakSet;function s(i,f){if(n.has(f))return!0;n.add(f);for(const l in f){if(!Object.prototype.hasOwnProperty.call(f,l)||o.has(l))continue;if(!Object.prototype.hasOwnProperty.call(i,l))return!1;const u=f[l],y=i[l];if((0,g.isDOMNode)(u)||(0,g.isDOMNode)(y)){if(u!==y)return!1}else if((0,c.isObjectLike)(u)&&(0,c.isObjectLike)(y)){if(!s(y,u))return!1}else if(u!==y)return!1}return!0}return s(e,t)},pe=(e,t)=>{if(t==null)return e;if((0,c.is)(t)("string","number"))delete e[t];else if((0,c.isArray)(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},R=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=R(e[r]));return t},ye=(e,t)=>{if(e.length===0)return t;const r={};let o=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?o[e[n]]=t:(o[e[n]]={},o=o[e[n]]);return r},he=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const o=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]},de=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++)(!o[t[n]]||typeof o[t[n]]!="object")&&(o[t[n]]={}),o=o[t[n]];return o[t[t.length-1]]=r,e},we=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let o=0;o<t.length;o++){if(r==null)return;r=r[t[o]]}return r},ge=e=>{let r=[],o=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?o++:(r=[e[n-1],e[n]],o=1),o>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Oe=e=>{const t=new WeakSet;function r(o){if(o&&typeof o=="object"){if(t.has(o))return!0;t.add(o);for(const n in o)if(Object.prototype.hasOwnProperty.call(o,n)&&r(o[n]))return console.log(o,"cycle at "+n),!0}return!1}return r(e)},_e=(e,t)=>{const r=t instanceof Set?t:new Set(t),o={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(o[n]=e[n]);return o};
@@ -1,14 +1,13 @@
1
- import{window as x}from"./globals.js";import{isFunction as k,isObjectLike as w,isObject as S,isArray as g,isString as P,is as C}from"./types.js";import{unstackArrayOfObjects as I}from"./array.js";import{stringIncludesAny as M}from"./string.js";import{isDOMNode as O}from"./node.js";import{METHODS_EXL as W}from"./keys.js";const A="production",_=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,$=(e,t,o,r)=>{if(k(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,r||t.context):void 0;if(e!=null&&t?.context?.plugins&&(g(e)||S(e)&&!O(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const i=s.resolveHandler(e,t);if(typeof i=="function")return $(i,t,o,r)}}return e},re=(e,t,o)=>{for(const r in t)e[r]=$(t[r],o)},oe=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(_(n)||(r?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},se=(e,t,o=W)=>v(e,t,o,null),v=(e,t,o,r)=>{if(e===t)return e;if(r){for(let s=0;s<r.length;s+=2)if(r[s]===e&&r[s+1]===t)return e}const n=o instanceof Set;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||_(s)||s==="constructor"||s==="prototype"||(n?o.has(s):o.includes(s)))continue;const i=e[s],c=t[s];if(w(i)&&w(c)){const f=r||[];f.push(e,t),v(i,c,o,f),f.length-=2}else i===void 0&&(e[s]=c)}return e},ie=(e,t=[])=>{const o=t instanceof Set,r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(n)||(o?t.has(n):t.includes(n))||(r[n]=e[n]));return r},L=(e,t={})=>{const{exclude:o=[],cleanUndefined:r=!1,cleanNull:n=!1,window:s,visited:i=new WeakMap,handleExtends:c=!1}=t,f=s||x||globalThis;if(!w(e)||O(e))return e;if(i.has(e))return i.get(e);const u=g(e)?[]:{};i.set(e,u);const y=o instanceof Set?o:o.length>3?new Set(o):null;for(const a in e){if(!Object.prototype.hasOwnProperty.call(e,a)||_(a)||a==="__proto__"||(y?y.has(a):o.includes(a)))continue;const p=e[a];if(!(r&&p===void 0)&&!(n&&p===null)){if(O(p)){u[a]=p;continue}if(c&&a==="extends"&&g(p)){u[a]=I(p,o);continue}if(k(p)){u[a]=p;continue}w(p)?u[a]=L(p,{...t,visited:i}):u[a]=p}}return u},T=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const r=e[o];if(k(r))t[o]=r.toString();else if(S(r))t[o]={},T(r,t[o]);else if(g(r)){const n=t[o]=[];for(let s=0;s<r.length;s++){const i=r[s];S(i)?(n[s]={},T(i,n[s])):k(i)?n[s]=i.toString():n[s]=i}}else t[o]=r}return t},F=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),N=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let o=!1;for(const s in e){o=!0;break}if(!o)return"{}";const r=" ".repeat(t);let n=`{
2
- `;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];let c=!1;for(let l=0;l<s.length;l++)if(F.has(s[l])){c=!0;break}const f=c?`'${s}'`:s;if(n+=`${r} ${f}: `,g(i)){n+=`[
3
- `;for(const l of i)w(l)&&l!==null?n+=`${r} ${N(l,t+2)},
4
- `:P(l)?n+=`${r} '${l}',
5
- `:n+=`${r} ${l},
6
- `;n+=`${r} ]`}else w(i)?n+=N(i,t+1):P(i)?n+=M(i,[`
1
+ import{window as k}from"./globals.js";import{isFunction as P,isObjectLike as w,isObject as S,isArray as O,isString as x,is as I}from"./types.js";import{unstackArrayOfObjects as M}from"./array.js";import{stringIncludesAny as R}from"./string.js";import{isDOMNode as g}from"./node.js";import{METHODS_EXL as L}from"./keys.js";const A="production",_=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,$=(e,t,r,o)=>{if(P(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,o||t.context):void 0;if(e!=null&&t?.context?.plugins&&(O(e)||S(e)&&!g(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const i=s.resolveHandler(e,t);if(typeof i=="function")return $(i,t,r,o)}}return e},ne=(e,t,r)=>{for(const o in t)e[o]=$(t[o],r)},re=(e,t,r=[])=>{const o=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(_(n)||(o?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},oe=(e,t,r=L)=>v(e,t,r,null),v=(e,t,r,o)=>{if(e===t)return e;if(o){for(let s=0;s<o.length;s+=2)if(o[s]===e&&o[s+1]===t)return e}const n=r instanceof Set;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||_(s)||s==="constructor"||s==="prototype"||(n?r.has(s):r.includes(s)))continue;const i=e[s],c=t[s];if(w(i)&&w(c)){const f=o||[];f.push(e,t),v(i,c,r,f),f.length-=2}else i===void 0&&(e[s]=c)}return e},se=(e,t=[])=>{const r=t instanceof Set,o={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(n)||(r?t.has(n):t.includes(n))||(o[n]=e[n]));return o},ie=(e,t={})=>{const{exclude:r=[],cleanUndefined:o=!1,cleanNull:n=!1,visited:s=new WeakMap,handleExtends:i=!1}=t;if(!w(e)||g(e))return e;if(s.has(e))return s.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,f=a=>c?c.has(a):r.includes(a),l=O(e)?[]:{};s.set(e,l);const p=[[e,l]];for(;p.length;){const[a,h]=p.pop();for(const y in a){if(!Object.prototype.hasOwnProperty.call(a,y)||_(y)||y==="__proto__"||f(y))continue;const u=a[y];if(!(o&&u===void 0)&&!(n&&u===null)){if(g(u)){h[y]=u;continue}if(i&&y==="extends"&&O(u)){h[y]=M(u,r);continue}if(P(u)){h[y]=u;continue}if(w(u))if(s.has(u))h[y]=s.get(u);else{const d=O(u)?[]:{};s.set(u,d),h[y]=d,p.push([u,d])}else h[y]=u}}}return l},T=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const r in e){const o=e[r];if(P(o))t[r]=o.toString();else if(S(o))t[r]={},T(o,t[r]);else if(O(o)){const n=t[r]=[];for(let s=0;s<o.length;s++){const i=o[s];S(i)?(n[s]={},T(i,n[s])):P(i)?n[s]=i.toString():n[s]=i}}else t[r]=o}return t},W=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),N=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const s in e){r=!0;break}if(!r)return"{}";const o=" ".repeat(t);let n=`{
2
+ `;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const i=e[s];let c=!1;for(let l=0;l<s.length;l++)if(W.has(s[l])){c=!0;break}const f=c?`'${s}'`:s;if(n+=`${o} ${f}: `,O(i)){n+=`[
3
+ `;for(const l of i)w(l)&&l!==null?n+=`${o} ${N(l,t+2)},
4
+ `:x(l)?n+=`${o} '${l}',
5
+ `:n+=`${o} ${l},
6
+ `;n+=`${o} ]`}else w(i)?n+=N(i,t+1):x(i)?n+=R(i,[`
7
7
  `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
- `}return n+=`${r}}`,n},q=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],B=/^["[{]/,G=/^(export|import)\s/,E=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||G.test(t)||!q.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||B.test(t)&&!n)},H=e=>(0,eval)(e),J=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const r=o[0].length,n=[];let s=r,i=1,c=null;const f=e.length,l=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;s<f&&i>0;){const y=e[s];if(y==="/"&&e[s+1]==="/"){const a=e.indexOf(`
9
- `,s);s=a===-1?f:a;continue}if(y==="/"&&e[s+1]==="*"){const a=e.indexOf("*/",s+2);s=a===-1?f:a+2;continue}if(y==='"'||y==="'"||y==="`"){const a=y;for(s++;s<f;){if(e[s]==="\\"){s+=2;continue}if(e[s]===a){s++;break}if(a==="`"&&e[s]==="$"&&e[s+1]==="{"){s+=2;let p=1;for(;s<f&&p>0;)e[s]==="{"?p++:e[s]==="}"&&p--,s++;continue}s++}continue}if(y==="{"){i++,s++;continue}if(y==="}"){i--,s++;continue}if(i===1&&l.test(e.slice(s))){const a=s;let p=0,h=s;for(;h<f;){const d=e[h];if(d==='"'||d==="'"||d==="`"){const R=d;for(h++;h<f;){if(e[h]==="\\"){h+=2;continue}if(e[h]===R){h++;break}h++}continue}if(d==="("||d==="["||d==="{"){p++,h++;continue}if(d===")"||d==="]"||d==="}"){if(p===0)break;p--,h++;continue}if(p===0&&(d===";"||d===`
10
- `)){h++;break}h++}n.push([a,h]),s=h;continue}s++}if(!n.length)return null;let u=e;for(let y=n.length-1;y>=0;y--)u=u.slice(0,n[y][0])+u.slice(n[y][1]);return u},D=(e,t={},o={window:{eval:H}})=>{for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const n=e[r];if(P(n))if(E(n))try{t[r]=o.window.eval(`(${n})`)}catch(s){const i=s&&s.message?s.message:String(s),c=/await is only valid in async/.test(i),f=/Identifier '([^']+)' has already been declared/.exec(i);let l=null;if(c){const u=String(n).trim();if(/^function[\s(]/.test(u))try{l=o.window.eval("(async "+u+")")}catch{}}else if(f){let u=String(n),y=f[1];for(let a=0;a<5;a++){const p=J(u,y);if(!p||p===u)break;u=p;try{l=o.window.eval("("+u+")");break}catch(h){const d=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!d||d[1]!==y)break}}}l?t[r]=l:(typeof console<"u"&&console.warn&&console.warn('[smbls] deepDestringifyFunctions: eval failed on "'+r+'" \u2014 function will be left as a string and el.call("'+r+'") will silently no-op. Reason: '+i+`.
11
- First 200 chars of source: `+String(n).slice(0,200)),t[r]=n)}else t[r]=n;else if(g(n)){const s=t[r]=[];for(let i=0;i<n.length;i++){const c=n[i];if(P(c))if(E(c))try{s.push(o.window.eval(`(${c})`))}catch(f){typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed in array at index ${i} (prop "${r}"). Reason: ${f&&f.message?f.message:String(f)}.
12
- First 200 chars: ${String(c).slice(0,200)}`),s.push(c)}else s.push(c);else S(c)?s.push(D(c)):s.push(c)}}else S(n)?t[r]=D(n,t[r]):t[r]=n}return t},U="Set",V="Map",b=e=>!e||typeof e!="object"?e:e.__type===U&&Array.isArray(e.values)?new Set(e.values):e.__type===V&&Array.isArray(e.entries)?new Map(e.entries):e,ce=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const r of Object.keys(e)){const n=e[r];P(n)&&E(n)?o.push([r,n]):t[r]=b(n)}for(const[r,n]of o)try{const s=Object.keys(t).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
13
- `);t[r]=x.eval(`(function(__gs__) { ${s}
14
- return (${n}); })`)(t)}catch{try{t[r]=x.eval(`(${n})`)}catch{t[r]=n}}return t},fe=(e,t={verbose:!0})=>{try{return e?x.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},le=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),z=e=>{for(const t in e)return!1;return!0},ue=e=>S(e)&&z(e),ae=()=>Object.create(null),pe=(e,t,o={})=>{const r=o.exclude||[],n=o.preventUnderscore;for(const s in t)r.includes(s)||!n&&_(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},ye=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)_(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n))||(e[n]=t[n]);return e},K=(e,t,o={},r=new WeakMap)=>{if(!w(e)||!w(t)||O(e)||O(t))return t;if(r.has(e))return r.get(e);r.set(e,e);const n=o.exclude,s=n?n instanceof Set?n:new Set(n):null,i=!o.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||s&&s.has(c)||i&&_(c)||c==="constructor"||c==="prototype")continue;const f=e[c],l=t[c];O(l)?e[c]=l:w(f)&&w(l)?e[c]=K(f,l,o,r):l!==void 0&&(e[c]=l)}return e},X=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++){const i=r[s];if(!Object.prototype.hasOwnProperty.call(t,i)||!X(e[i],t[i],o))return!1}return!0},Y=new Set(["node","__ref"]),he=(e,t,o=Y)=>{if(e===t)return!0;if(!w(e)||!w(t)||O(e)||O(t))return e===t;const r=o instanceof Set?o:new Set(o),n=new WeakSet;function s(i,c){if(n.has(c))return!0;n.add(c);for(const f in c){if(!Object.prototype.hasOwnProperty.call(c,f)||r.has(f))continue;if(!Object.prototype.hasOwnProperty.call(i,f))return!1;const l=c[f],u=i[f];if(O(l)||O(u)){if(l!==u)return!1}else if(w(l)&&w(u)){if(!s(u,l))return!1}else if(l!==u)return!1}return!0}return s(e,t)},de=(e,t)=>{if(t==null)return e;if(C(t)("string","number"))delete e[t];else if(g(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},Z=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=Z(e[o]));return t},we=(e,t)=>{if(e.length===0)return t;const o={};let r=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?r[e[n]]=t:(r[e[n]]={},r=r[e[n]]);return o},Oe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++){if(o[t[n]]===void 0)return;o=o[t[n]]}const r=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,r)&&delete o[r]},ge=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++)(!r[t[n]]||typeof r[t[n]]!="object")&&(r[t[n]]={}),r=r[t[n]];return r[t[t.length-1]]=o,e},_e=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length;r++){if(o==null)return;o=o[t[r]]}return o},Se=e=>{let o=[],r=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?r++:(o=[e[n-1],e[n]],r=1),r>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Pe=e=>{const t=new WeakSet;function o(r){if(r&&typeof r=="object"){if(t.has(r))return!0;t.add(r);for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&o(r[n]))return console.log(r,"cycle at "+n),!0}return!1}return o(e)},xe=(e,t)=>{const o=t instanceof Set?t:new Set(t),r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(r[n]=e[n]);return r};export{ie as clone,we as createNestedObject,Z as createObjectWithoutPrototype,L as deepClone,he as deepContains,D as deepDestringifyFunctions,se as deepMerge,T as deepStringifyFunctions,ce as destringifyGlobalScope,Se as detectInfiniteLoop,xe as excludeKeysFromObject,$ as exec,_e as getInObjectByPath,E as hasFunction,le as hasOwnProperty,Pe as isCyclic,z as isEmpty,ue as isEmptyObject,X as isEqualDeep,ae as makeObjectWithoutPrototype,re as map,oe as merge,N as objectToString,pe as overwrite,K as overwriteDeep,ye as overwriteShallow,de as removeFromObject,Oe as removeNestedKeyByPath,ge as setInObjectByPath,fe as stringToObject};
8
+ `}return n+=`${o}}`,n},F=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],b=/^["[{]/,q=/^(export|import)\s/,E=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||q.test(t)||!F.some(s=>s.test(t)))return!1;const o=t.charCodeAt(0),n=t.includes("=>");return!(o===123&&!n||o===91||b.test(t)&&!n)},B=e=>(0,eval)(e),G=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const o=r[0].length,n=[];let s=o,i=1,c=null;const f=e.length,l=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;s<f&&i>0;){const a=e[s];if(a==="/"&&e[s+1]==="/"){const h=e.indexOf(`
9
+ `,s);s=h===-1?f:h;continue}if(a==="/"&&e[s+1]==="*"){const h=e.indexOf("*/",s+2);s=h===-1?f:h+2;continue}if(a==='"'||a==="'"||a==="`"){const h=a;for(s++;s<f;){if(e[s]==="\\"){s+=2;continue}if(e[s]===h){s++;break}if(h==="`"&&e[s]==="$"&&e[s+1]==="{"){s+=2;let y=1;for(;s<f&&y>0;)e[s]==="{"?y++:e[s]==="}"&&y--,s++;continue}s++}continue}if(a==="{"){i++,s++;continue}if(a==="}"){i--,s++;continue}if(i===1&&l.test(e.slice(s))){const h=s;let y=0,u=s;for(;u<f;){const d=e[u];if(d==='"'||d==="'"||d==="`"){const D=d;for(u++;u<f;){if(e[u]==="\\"){u+=2;continue}if(e[u]===D){u++;break}u++}continue}if(d==="("||d==="["||d==="{"){y++,u++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,u++;continue}if(y===0&&(d===";"||d===`
10
+ `)){u++;break}u++}n.push([h,u]),s=u;continue}s++}if(!n.length)return null;let p=e;for(let a=n.length-1;a>=0;a--)p=p.slice(0,n[a][0])+p.slice(n[a][1]);return p},C=(e,t,r)=>{try{return r.window.eval(`(${e})`)}catch(o){const n=o&&o.message?o.message:String(o),s=/await is only valid in async/.test(n),i=/Identifier '([^']+)' has already been declared/.exec(n);let c=null;if(s){const f=String(e).trim();if(/^function[\s(]/.test(f))try{c=r.window.eval("(async "+f+")")}catch{}}else if(i){let f=String(e),l=i[1];for(let p=0;p<5;p++){const a=G(f,l);if(!a||a===f)break;f=a;try{c=r.window.eval("("+f+")");break}catch(h){const y=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!y||y[1]!==l)break}}}return c||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+n+`.
11
+ First 200 chars of source: `+String(e).slice(0,200)),e)}},ce=(e,t={},r={window:{eval:B}})=>{if(!e||typeof e!="object")return t;const o=[[e,t]];for(;o.length;){const[n,s]=o.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if(x(c))E(c)?s[i]=C(c,`"${i}"`,r):s[i]=c;else if(O(c)){const f=s[i]=[];for(let l=0;l<c.length;l++){const p=c[l];if(x(p))f.push(E(p)?C(p,`array index ${l} (prop "${i}")`,r):p);else if(S(p)){const a={};f.push(a),o.push([p,a])}else f.push(p)}}else if(S(c)){const f=s[i]&&typeof s[i]=="object"&&!O(s[i])?s[i]:s[i]={};o.push([c,f])}else s[i]=c}}return t},H="Set",J="Map",U=e=>!e||typeof e!="object"?e:e.__type===H&&Array.isArray(e.values)?new Set(e.values):e.__type===J&&Array.isArray(e.entries)?new Map(e.entries):e,fe=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const o of Object.keys(e)){const n=e[o];x(n)&&E(n)?r.push([o,n]):t[o]=U(n)}for(const[o,n]of r)try{const s=Object.keys(t).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
12
+ `);t[o]=k.eval(`(function(__gs__) { ${s}
13
+ return (${n}); })`)(t)}catch{try{t[o]=k.eval(`(${n})`)}catch{t[o]=n}}return t},le=(e,t={verbose:!0})=>{try{return e?k.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},ue=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),V=e=>{for(const t in e)return!1;return!0},ae=e=>S(e)&&V(e),pe=()=>Object.create(null),ye=(e,t,r={})=>{const o=r.exclude||[],n=r.preventUnderscore;for(const s in t)o.includes(s)||!n&&_(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},he=(e,t,r=[])=>{const o=r instanceof Set;for(const n in t)_(n)||n==="constructor"||n==="prototype"||(o?r.has(n):r.includes(n))||(e[n]=t[n]);return e},z=(e,t,r={},o=new WeakMap)=>{if(!w(e)||!w(t)||g(e)||g(t))return t;if(o.has(e))return o.get(e);o.set(e,e);const n=r.exclude,s=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||s&&s.has(c)||i&&_(c)||c==="constructor"||c==="prototype")continue;const f=e[c],l=t[c];g(l)?e[c]=l:w(f)&&w(l)?e[c]=z(f,l,r,o):l!==void 0&&(e[c]=l)}return e},K=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const o=Object.keys(e),n=Object.keys(t);if(o.length!==n.length)return!1;for(let s=0;s<o.length;s++){const i=o[s];if(!Object.prototype.hasOwnProperty.call(t,i)||!K(e[i],t[i],r))return!1}return!0},X=new Set(["node","__ref"]),de=(e,t,r=X)=>{if(e===t)return!0;if(!w(e)||!w(t)||g(e)||g(t))return e===t;const o=r instanceof Set?r:new Set(r),n=new WeakSet;function s(i,c){if(n.has(c))return!0;n.add(c);for(const f in c){if(!Object.prototype.hasOwnProperty.call(c,f)||o.has(f))continue;if(!Object.prototype.hasOwnProperty.call(i,f))return!1;const l=c[f],p=i[f];if(g(l)||g(p)){if(l!==p)return!1}else if(w(l)&&w(p)){if(!s(p,l))return!1}else if(l!==p)return!1}return!0}return s(e,t)},we=(e,t)=>{if(t==null)return e;if(I(t)("string","number"))delete e[t];else if(O(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},Y=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Y(e[r]));return t},ge=(e,t)=>{if(e.length===0)return t;const r={};let o=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?o[e[n]]=t:(o[e[n]]={},o=o[e[n]]);return r},Oe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const o=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]},_e=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++)(!o[t[n]]||typeof o[t[n]]!="object")&&(o[t[n]]={}),o=o[t[n]];return o[t[t.length-1]]=r,e},Se=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let o=0;o<t.length;o++){if(r==null)return;r=r[t[o]]}return r},xe=e=>{let r=[],o=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?o++:(r=[e[n-1],e[n]],o=1),o>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Pe=e=>{const t=new WeakSet;function r(o){if(o&&typeof o=="object"){if(t.has(o))return!0;t.add(o);for(const n in o)if(Object.prototype.hasOwnProperty.call(o,n)&&r(o[n]))return console.log(o,"cycle at "+n),!0}return!1}return r(e)},ke=(e,t)=>{const r=t instanceof Set?t:new Set(t),o={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(o[n]=e[n]);return o};export{se as clone,ge as createNestedObject,Y as createObjectWithoutPrototype,ie as deepClone,de as deepContains,ce as deepDestringifyFunctions,oe as deepMerge,T as deepStringifyFunctions,fe as destringifyGlobalScope,xe as detectInfiniteLoop,ke as excludeKeysFromObject,$ as exec,Se as getInObjectByPath,E as hasFunction,ue as hasOwnProperty,Pe as isCyclic,V as isEmpty,ae as isEmptyObject,K as isEqualDeep,pe as makeObjectWithoutPrototype,ne as map,re as merge,N as objectToString,ye as overwrite,z as overwriteDeep,he as overwriteShallow,we as removeFromObject,Oe as removeNestedKeyByPath,_e as setInObjectByPath,le as stringToObject};
package/object.js CHANGED
@@ -145,30 +145,20 @@ export const deepClone = (obj, options = {}) => {
145
145
  exclude = [],
146
146
  cleanUndefined = false,
147
147
  cleanNull = false,
148
- window: targetWindow,
149
148
  visited = new WeakMap(),
150
149
  handleExtends = false
151
150
  } = options
152
151
 
153
- const contentWindow = targetWindow || window || globalThis
154
-
155
152
  // Handle non-object types and special cases
156
153
  if (!isObjectLike(obj) || isDOMNode(obj)) {
157
154
  return obj
158
155
  }
159
156
 
160
- // Handle circular references
157
+ // Handle circular references at the root
161
158
  if (visited.has(obj)) {
162
159
  return visited.get(obj)
163
160
  }
164
161
 
165
- // Create appropriate container based on type and window context
166
- const isArr = isArray(obj)
167
- const clone = isArr ? [] : {}
168
-
169
- // Store the clone to handle circular references
170
- visited.set(obj, clone)
171
-
172
162
  // Convert exclude to Set for O(1) lookups when list is non-trivial
173
163
  const excludeSet =
174
164
  exclude instanceof Set
@@ -176,54 +166,65 @@ export const deepClone = (obj, options = {}) => {
176
166
  : exclude.length > 3
177
167
  ? new Set(exclude)
178
168
  : null
169
+ const isExcluded = (key) =>
170
+ excludeSet ? excludeSet.has(key) : exclude.includes(key)
171
+
172
+ // Iterative walk with explicit stack. Previously recursive; converted so
173
+ // deeply-nested project data (DOMQL component trees + nested designSystem
174
+ // branches) no longer trips V8's default ~10000-frame stack. The visited
175
+ // WeakMap still backstops cycles — every clone is registered BEFORE its
176
+ // children are processed so a back-edge resolves to the same clone the
177
+ // recursive form would have produced.
178
+ const rootClone = isArray(obj) ? [] : {}
179
+ visited.set(obj, rootClone)
180
+ const stack = [[obj, rootClone]]
181
+
182
+ while (stack.length) {
183
+ const [src, dest] = stack.pop()
184
+ for (const key in src) {
185
+ if (!Object.prototype.hasOwnProperty.call(src, key)) continue
186
+
187
+ // Skip excluded properties
188
+ if (_startsWithDunder(key) || key === '__proto__') continue
189
+ if (isExcluded(key)) continue
190
+
191
+ const value = src[key]
192
+
193
+ // Skip based on cleanup options
194
+ if (cleanUndefined && value === undefined) continue
195
+ if (cleanNull && value === null) continue
196
+
197
+ // Handle special cases
198
+ if (isDOMNode(value)) { dest[key] = value; continue }
199
+
200
+ // Handle 'extends' array if enabled
201
+ if (handleExtends && key === 'extends' && isArray(value)) {
202
+ dest[key] = unstackArrayOfObjects(value, exclude)
203
+ continue
204
+ }
179
205
 
180
- // Clone properties
181
- for (const key in obj) {
182
- if (!Object.prototype.hasOwnProperty.call(obj, key)) continue
183
-
184
- // Skip excluded properties
185
- if (_startsWithDunder(key) || key === '__proto__') continue
186
- if (excludeSet ? excludeSet.has(key) : exclude.includes(key)) continue
187
-
188
- const value = obj[key]
189
-
190
- // Skip based on cleanup options
191
- if (cleanUndefined && value === undefined) continue
192
- if (cleanNull && value === null) continue
193
-
194
- // Handle special cases
195
- if (isDOMNode(value)) {
196
- clone[key] = value
197
- continue
198
- }
199
-
200
- // Handle 'extends' array if enabled
201
- if (handleExtends && key === 'extends' && isArray(value)) {
202
- clone[key] = unstackArrayOfObjects(value, exclude)
203
- continue
204
- }
205
-
206
- // Handle functions in cross-frame scenario
207
- // Keep original function references — DOMQL handles window/document
208
- // isolation via element.context, so eval'ing into iframe scope is
209
- // unnecessary and breaks closure-dependent functions (e.g. resolveTheme)
210
- if (isFunction(value)) {
211
- clone[key] = value
212
- continue
213
- }
206
+ // Keep original function references — DOMQL handles window/document
207
+ // isolation via element.context, so eval'ing into iframe scope is
208
+ // unnecessary and breaks closure-dependent functions (e.g. resolveTheme)
209
+ if (isFunction(value)) { dest[key] = value; continue }
214
210
 
215
- // Recursively clone objects
216
- if (isObjectLike(value)) {
217
- clone[key] = deepClone(value, {
218
- ...options,
219
- visited
220
- })
221
- } else {
222
- clone[key] = value
211
+ // Clone nested object/array iteratively
212
+ if (isObjectLike(value)) {
213
+ if (visited.has(value)) {
214
+ dest[key] = visited.get(value)
215
+ } else {
216
+ const childClone = isArray(value) ? [] : {}
217
+ visited.set(value, childClone)
218
+ dest[key] = childClone
219
+ stack.push([value, childClone])
220
+ }
221
+ } else {
222
+ dest[key] = value
223
+ }
223
224
  }
224
225
  }
225
226
 
226
- return clone
227
+ return rootClone
227
228
  }
228
229
 
229
230
  /**
@@ -487,133 +488,118 @@ const stripTopLevelDeclaration = (src, name) => {
487
488
  return out
488
489
  }
489
490
 
491
+ // Evaluate a single function-source string with the same recovery passes
492
+ // the structural walker used inline. Returns either the eval'd value or
493
+ // the original string (with a console.warn) so callers can assign the
494
+ // result directly. `label` is used in warning messages so the surface
495
+ // of the failure (object key vs array index) is identifiable.
496
+ const _destringifyFnString = (str, label, opts) => {
497
+ try {
498
+ return opts.window.eval(`(${str})`)
499
+ } catch (e) {
500
+ const msg = e && e.message ? e.message : String(e)
501
+ const isTopLevelAwait = /await is only valid in async/.test(msg)
502
+ // SyntaxError signature for duplicate-declaration:
503
+ // "Identifier 'el' has already been declared"
504
+ // Prefer the parameter (smbls invocation convention) and strip the
505
+ // conflicting top-level `const|let|var <name>` from the body. Nested-
506
+ // scope declarations of the same name remain untouched.
507
+ const dupMatch = /Identifier '([^']+)' has already been declared/.exec(msg)
508
+ let recovered = null
509
+ if (isTopLevelAwait) {
510
+ const trimmed = String(str).trim()
511
+ if (/^function[\s(]/.test(trimmed)) {
512
+ try { recovered = opts.window.eval('(async ' + trimmed + ')') }
513
+ catch (_) { /* fall through to warning */ }
514
+ }
515
+ } else if (dupMatch) {
516
+ // Iteratively strip duplicate top-level declarations. Handles N
517
+ // duplicates whether they came from double-/triple-rewrite or
518
+ // user-supplied collisions (SMBLS-DEEPDESTRINGIFY-DUPSCOPE-1).
519
+ let candidate = String(str)
520
+ let dupName = dupMatch[1]
521
+ for (let pass = 0; pass < 5; pass++) {
522
+ const stripped = stripTopLevelDeclaration(candidate, dupName)
523
+ if (!stripped || stripped === candidate) break
524
+ candidate = stripped
525
+ try {
526
+ recovered = opts.window.eval('(' + candidate + ')')
527
+ break
528
+ } catch (e2) {
529
+ const m2 = /Identifier '([^']+)' has already been declared/.exec(
530
+ (e2 && e2.message) || String(e2)
531
+ )
532
+ if (!m2 || m2[1] !== dupName) break
533
+ }
534
+ }
535
+ }
536
+ if (recovered) return recovered
537
+ // FR-1 (FRANK-RUNNER.md): make the silent fallback loud so consumers
538
+ // notice when a handler ends up stored as a string instead of a
539
+ // function (el.call(name) would silently no-op).
540
+ if (typeof console !== 'undefined' && console.warn) {
541
+ console.warn(
542
+ `[smbls] deepDestringifyFunctions: eval failed on ${label} — ` +
543
+ 'value will be left as a string. Reason: ' + msg + '.\n' +
544
+ 'First 200 chars of source: ' + String(str).slice(0, 200)
545
+ )
546
+ }
547
+ return str
548
+ }
549
+ }
550
+
490
551
  export const deepDestringifyFunctions = (
491
552
  obj,
492
553
  destringified = {},
493
554
  opts = { window: { eval: __globalEval } }
494
555
  ) => {
495
- for (const prop in obj) {
496
- if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
497
-
498
- const objProp = obj[prop]
499
-
500
- if (isString(objProp)) {
501
- if (hasFunction(objProp)) {
502
- try {
503
- destringified[prop] = opts.window.eval(`(${objProp})`)
504
- } catch (e) {
505
- // Recover from top-level `await` in a non-async `function() {…}`.
506
- // Some snapshots ship handlers whose body uses `await fetch(…)` but
507
- // serialize as plain `function`. We retry once by prepending
508
- // `async ` so the body parses; silently fall through on any other
509
- // error to the FR-1 warning path below.
510
- const msg = e && e.message ? e.message : String(e)
511
- const isTopLevelAwait = /await is only valid in async/.test(msg)
512
- // SyntaxError signature for duplicate-declaration:
513
- // "Identifier 'el' has already been declared"
514
- // We can't tell statically whether the inner const|let|var or the
515
- // function parameter was the user's intent — so prefer the parameter
516
- // (it's the smbls invocation convention) and strip the conflicting
517
- // top-level `const|let|var <name>` from the body. Nested-scope
518
- // declarations of the same name remain untouched.
519
- const dupMatch = /Identifier '([^']+)' has already been declared/.exec(msg)
520
- let recovered = null
521
- if (isTopLevelAwait) {
522
- const trimmed = String(objProp).trim()
523
- // Only retry if the source actually starts with `function` (or
524
- // `function name(`) — arrow forms already produce a useful error.
525
- if (/^function[\s(]/.test(trimmed)) {
526
- try {
527
- recovered = opts.window.eval('(async ' + trimmed + ')')
528
- } catch (_) { /* fall through to warning */ }
529
- }
530
- } else if (dupMatch) {
531
- // Iteratively strip duplicate top-level declarations. A single
532
- // strip handles the common case (one extra `const __scope` from
533
- // a double-rewrite at publish), but pathological bundles can
534
- // accumulate N duplicates if frank's scope-rewriter ran more
535
- // than twice or if the source had user-supplied declarations
536
- // colliding with injected ones (caught live on
537
- // /nikoloza/hackernews via `commentsDataToCommentsCards2` —
538
- // SMBLS-DEEPDESTRINGIFY-DUPSCOPE-1). Loop up to 5 times,
539
- // re-classifying the error on each pass so we only keep
540
- // stripping the SAME identifier — any new error (or a
541
- // different duplicate name) breaks out so we don't mask a
542
- // genuinely broken function.
543
- let candidate = String(objProp)
544
- let dupName = dupMatch[1]
545
- for (let pass = 0; pass < 5; pass++) {
546
- const stripped = stripTopLevelDeclaration(candidate, dupName)
547
- if (!stripped || stripped === candidate) break
548
- candidate = stripped
549
- try {
550
- recovered = opts.window.eval('(' + candidate + ')')
551
- break
552
- } catch (e2) {
553
- const m2 = /Identifier '([^']+)' has already been declared/.exec(
554
- (e2 && e2.message) || String(e2)
555
- )
556
- if (!m2 || m2[1] !== dupName) break
557
- }
558
- }
559
- }
560
- if (recovered) {
561
- destringified[prop] = recovered
562
- } else {
563
- // FR-1 (FRANK-RUNNER.md): the silent string-fallback used to
564
- // mask broken serialization — eight aihouse functions stored
565
- // as strings instead of functions, `el.call(name)` no-op'd
566
- // with no error. Surface the failure so consumers can audit
567
- // what frank produced. Keep the fallback (don't crash boot)
568
- // but make it loud.
569
- if (typeof console !== 'undefined' && console.warn) {
570
- console.warn(
571
- '[smbls] deepDestringifyFunctions: eval failed on "' + prop + '" — ' +
572
- 'function will be left as a string and el.call("' + prop + '") ' +
573
- 'will silently no-op. Reason: ' + msg + '.\n' +
574
- 'First 200 chars of source: ' + String(objProp).slice(0, 200)
575
- )
576
- }
577
- destringified[prop] = objProp
578
- }
556
+ if (!obj || typeof obj !== 'object') return destringified
557
+
558
+ // Iterative walk with explicit stack so deeply-nested project data
559
+ // (a frank-readback of a complex DOMQL tree, for instance) doesn't
560
+ // trip V8's default ~10000-frame stack the way the prior recursive
561
+ // form did. Stack frame: [src, dest] where dest is the container
562
+ // results land in. Array items handled in-place; nested objects /
563
+ // arrays get a fresh child container pushed onto the stack.
564
+ const stack = [[obj, destringified]]
565
+ while (stack.length) {
566
+ const [src, dest] = stack.pop()
567
+ for (const prop in src) {
568
+ if (!Object.prototype.hasOwnProperty.call(src, prop)) continue
569
+ const objProp = src[prop]
570
+ if (isString(objProp)) {
571
+ if (hasFunction(objProp)) {
572
+ dest[prop] = _destringifyFnString(objProp, `"${prop}"`, opts)
573
+ } else {
574
+ dest[prop] = objProp
579
575
  }
580
- } else {
581
- destringified[prop] = objProp
582
- }
583
- } else if (isArray(objProp)) {
584
- const arr = (destringified[prop] = [])
585
- for (let i = 0; i < objProp.length; i++) {
586
- const arrProp = objProp[i]
587
- if (isString(arrProp)) {
588
- if (hasFunction(arrProp)) {
589
- try {
590
- arr.push(opts.window.eval(`(${arrProp})`))
591
- } catch (e) {
592
- if (typeof console !== 'undefined' && console.warn) {
593
- console.warn(
594
- `[smbls] deepDestringifyFunctions: eval failed in array at index ${i} ` +
595
- `(prop "${prop}"). Reason: ${e && e.message ? e.message : String(e)}.\n` +
596
- `First 200 chars: ${String(arrProp).slice(0, 200)}`
597
- )
598
- }
599
- arr.push(arrProp)
600
- }
576
+ } else if (isArray(objProp)) {
577
+ const arr = (dest[prop] = [])
578
+ for (let i = 0; i < objProp.length; i++) {
579
+ const arrProp = objProp[i]
580
+ if (isString(arrProp)) {
581
+ arr.push(hasFunction(arrProp)
582
+ ? _destringifyFnString(arrProp, `array index ${i} (prop "${prop}")`, opts)
583
+ : arrProp)
584
+ } else if (isObject(arrProp)) {
585
+ const child = {}
586
+ arr.push(child)
587
+ stack.push([arrProp, child])
601
588
  } else {
602
589
  arr.push(arrProp)
603
590
  }
604
- } else if (isObject(arrProp)) {
605
- arr.push(deepDestringifyFunctions(arrProp))
606
- } else {
607
- arr.push(arrProp)
608
591
  }
592
+ } else if (isObject(objProp)) {
593
+ // Preserve any pre-existing container the caller passed in for this
594
+ // key (matches the legacy `destringified[prop]` argument); otherwise
595
+ // allocate one.
596
+ const child = (dest[prop] && typeof dest[prop] === 'object' && !isArray(dest[prop]))
597
+ ? dest[prop]
598
+ : (dest[prop] = {})
599
+ stack.push([objProp, child])
600
+ } else {
601
+ dest[prop] = objProp
609
602
  }
610
- } else if (isObject(objProp)) {
611
- destringified[prop] = deepDestringifyFunctions(
612
- objProp,
613
- destringified[prop]
614
- )
615
- } else {
616
- destringified[prop] = objProp
617
603
  }
618
604
  }
619
605
  return destringified
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.16",
3
+ "version": "3.14.17",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",