@symbo.ls/utils 3.14.13 → 3.14.14

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.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
3
9
  ## 3.14.13
4
10
 
5
11
  ### Patch Changes
@@ -1,12 +1,14 @@
1
- "use strict";var _=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var o in t)_(e,o,{get:t[o],enumerable:!0})},B=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of R(t))!F.call(e,n)&&n!==o&&_(e,n,{get:()=>t[n],enumerable:!(r=M(t,n))||r.enumerable});return e};var G=e=>B(_({},"__esModule",{value:!0}),e);var he={};L(he,{clone:()=>q,createNestedObject:()=>ie,createObjectWithoutPrototype:()=>I,deepClone:()=>N,deepContains:()=>se,deepDestringifyFunctions:()=>x,deepMerge:()=>V,deepStringifyFunctions:()=>S,destringifyGlobalScope:()=>m,detectInfiniteLoop:()=>ae,excludeKeysFromObject:()=>ye,exec:()=>g,getInObjectByPath:()=>ue,hasFunction:()=>d,hasOwnProperty:()=>j,isCyclic:()=>pe,isEmpty:()=>D,isEmptyObject:()=>ee,isEqualDeep:()=>W,makeObjectWithoutPrototype:()=>te,map:()=>H,merge:()=>J,objectToString:()=>P,overwrite:()=>ne,overwriteDeep:()=>C,overwriteShallow:()=>re,removeFromObject:()=>ce,removeNestedKeyByPath:()=>fe,setInObjectByPath:()=>le,stringToObject:()=>b});module.exports=G(he);var O=require("./globals.js"),i=require("./types.js"),$=require("./array.js"),v=require("./string.js"),h=require("./node.js"),T=require("./keys.js");const k="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,g=(e,t,o,r)=>{if((0,i.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,i.isArray)(e)||(0,i.isObject)(e)&&!(0,h.isDOMNode)(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const c=s.resolveHandler(e,t);if(typeof c=="function")return g(c,t,o,r)}}return e},H=(e,t,o)=>{for(const r in t)e[r]=g(t[r],o)},J=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(w(n)||(r?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},V=(e,t,o=T.METHODS_EXL)=>E(e,t,o,null),E=(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)||w(s)||s==="constructor"||s==="prototype"||(n?o.has(s):o.includes(s)))continue;const c=e[s],f=t[s];if((0,i.isObjectLike)(c)&&(0,i.isObjectLike)(f)){const u=r||[];u.push(e,t),E(c,f,o,u),u.length-=2}else c===void 0&&(e[s]=f)}return e},q=(e,t=[])=>{const o=t instanceof Set,r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(w(n)||(o?t.has(n):t.includes(n))||(r[n]=e[n]));return r},N=(e,t={})=>{const{exclude:o=[],cleanUndefined:r=!1,cleanNull:n=!1,window:s,visited:c=new WeakMap,handleExtends:f=!1}=t,u=s||O.window||globalThis;if(!(0,i.isObjectLike)(e)||(0,h.isDOMNode)(e))return e;if(c.has(e))return c.get(e);const a=(0,i.isArray)(e)?[]:{};c.set(e,a);const A=o instanceof Set?o:o.length>3?new Set(o):null;for(const p in e){if(!Object.prototype.hasOwnProperty.call(e,p)||w(p)||p==="__proto__"||(A?A.has(p):o.includes(p)))continue;const y=e[p];if(!(r&&y===void 0)&&!(n&&y===null)){if((0,h.isDOMNode)(y)){a[p]=y;continue}if(f&&p==="extends"&&(0,i.isArray)(y)){a[p]=(0,$.unstackArrayOfObjects)(y,o);continue}if((0,i.isFunction)(y)){a[p]=y;continue}(0,i.isObjectLike)(y)?a[p]=N(y,{...t,visited:c}):a[p]=y}}return a},S=(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,i.isFunction)(r))t[o]=r.toString();else if((0,i.isObject)(r))t[o]={},S(r,t[o]);else if((0,i.isArray)(r)){const n=t[o]=[];for(let s=0;s<r.length;s++){const c=r[s];(0,i.isObject)(c)?(n[s]={},S(c,n[s])):(0,i.isFunction)(c)?n[s]=c.toString():n[s]=c}}else t[o]=r}return t},z=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),P=(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 c=e[s];let f=!1;for(let l=0;l<s.length;l++)if(z.has(s[l])){f=!0;break}const u=f?`'${s}'`:s;if(n+=`${r} ${u}: `,(0,i.isArray)(c)){n+=`[
3
- `;for(const l of c)(0,i.isObjectLike)(l)&&l!==null?n+=`${r} ${P(l,t+2)},
4
- `:(0,i.isString)(l)?n+=`${r} '${l}',
5
- `:n+=`${r} ${l},
6
- `;n+=`${r} ]`}else(0,i.isObjectLike)(c)?n+=P(c,t+1):(0,i.isString)(c)?n+=(0,v.stringIncludesAny)(c,[`
7
- `,"'"])?`\`${c}\``:`'${c}'`:n+=c;n+=`,
8
- `}return n+=`${r}}`,n},K=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],U=/^["[{]/,d=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||!K.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||U.test(t)&&!n)},Y=e=>(0,eval)(e),x=(e,t={},o={window:{eval:Y}})=>{for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const n=e[r];if((0,i.isString)(n))if(d(n))try{t[r]=o.window.eval(`(${n})`)}catch(s){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: '+(s&&s.message?s.message:String(s))+`.
9
- First 200 chars of source: `+String(n).slice(0,200)),t[r]=n}else t[r]=n;else if((0,i.isArray)(n)){const s=t[r]=[];for(let c=0;c<n.length;c++){const f=n[c];if((0,i.isString)(f))if(d(f))try{s.push(o.window.eval(`(${f})`))}catch(u){typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed in array at index ${c} (prop "${r}"). Reason: ${u&&u.message?u.message:String(u)}.
10
- First 200 chars: ${String(f).slice(0,200)}`),s.push(f)}else s.push(f);else(0,i.isObject)(f)?s.push(x(f)):s.push(f)}}else(0,i.isObject)(n)?t[r]=x(n,t[r]):t[r]=n}return t},Z="Set",Q="Map",X=e=>!e||typeof e!="object"?e:e.__type===Z&&Array.isArray(e.values)?new Set(e.values):e.__type===Q&&Array.isArray(e.entries)?new Map(e.entries):e,m=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const r of Object.keys(e)){const n=e[r];(0,i.isString)(n)&&d(n)?o.push([r,n]):t[r]=X(n)}for(const[r,n]of o)try{const s=Object.keys(t).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
11
- `);t[r]=O.window.eval(`(function(__gs__) { ${s}
12
- return (${n}); })`)(t)}catch{try{t[r]=O.window.eval(`(${n})`)}catch{t[r]=n}}return t},b=(e,t={verbose:!0})=>{try{return e?O.window.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},j=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),D=e=>{for(const t in e)return!1;return!0},ee=e=>(0,i.isObject)(e)&&D(e),te=()=>Object.create(null),ne=(e,t,o={})=>{const r=o.exclude||[],n=o.preventUnderscore;for(const s in t)r.includes(s)||!n&&w(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},re=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)w(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n))||(e[n]=t[n]);return e},C=(e,t,o={},r=new WeakMap)=>{if(!(0,i.isObjectLike)(e)||!(0,i.isObjectLike)(t)||(0,h.isDOMNode)(e)||(0,h.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,c=!o.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||s&&s.has(f)||c&&w(f)||f==="constructor"||f==="prototype")continue;const u=e[f],l=t[f];(0,h.isDOMNode)(l)?e[f]=l:(0,i.isObjectLike)(u)&&(0,i.isObjectLike)(l)?e[f]=C(u,l,o,r):l!==void 0&&(e[f]=l)}return e},W=(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 c=r[s];if(!Object.prototype.hasOwnProperty.call(t,c)||!W(e[c],t[c],o))return!1}return!0},oe=new Set(["node","__ref"]),se=(e,t,o=oe)=>{if(e===t)return!0;if(!(0,i.isObjectLike)(e)||!(0,i.isObjectLike)(t)||(0,h.isDOMNode)(e)||(0,h.isDOMNode)(t))return e===t;const r=o instanceof Set?o:new Set(o),n=new WeakSet;function s(c,f){if(n.has(f))return!0;n.add(f);for(const u in f){if(!Object.prototype.hasOwnProperty.call(f,u)||r.has(u))continue;if(!Object.prototype.hasOwnProperty.call(c,u))return!1;const l=f[u],a=c[u];if((0,h.isDOMNode)(l)||(0,h.isDOMNode)(a)){if(l!==a)return!1}else if((0,i.isObjectLike)(l)&&(0,i.isObjectLike)(a)){if(!s(a,l))return!1}else if(l!==a)return!1}return!0}return s(e,t)},ce=(e,t)=>{if(t==null)return e;if((0,i.is)(t)("string","number"))delete e[t];else if((0,i.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},I=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]=I(e[o]));return t},ie=(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},fe=(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]},le=(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},ue=(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},ae=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(k==="test"||k==="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)},ye=(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};
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:()=>K,createNestedObject:()=>pe,createObjectWithoutPrototype:()=>W,deepClone:()=>R,deepContains:()=>ue,deepDestringifyFunctions:()=>A,deepMerge:()=>z,deepStringifyFunctions:()=>k,destringifyGlobalScope:()=>ne,detectInfiniteLoop:()=>we,excludeKeysFromObject:()=>ge,exec:()=>x,getInObjectByPath:()=>de,hasFunction:()=>S,hasOwnProperty:()=>oe,isCyclic:()=>Oe,isEmpty:()=>C,isEmptyObject:()=>se,isEqualDeep:()=>I,makeObjectWithoutPrototype:()=>ie,map:()=>U,merge:()=>V,objectToString:()=>E,overwrite:()=>ce,overwriteDeep:()=>M,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"),D=require("./string.js"),O=require("./node.js"),N=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},z=(e,t,o=N.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},K=(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 p=(0,c.isArray)(e)?[]:{};i.set(e,p);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)||g(a)||a==="__proto__"||(y?y.has(a):o.includes(a)))continue;const h=e[a];if(!(r&&h===void 0)&&!(n&&h===null)){if((0,O.isDOMNode)(h)){p[a]=h;continue}if(f&&a==="extends"&&(0,c.isArray)(h)){p[a]=(0,T.unstackArrayOfObjects)(h,o);continue}if((0,c.isFunction)(h)){p[a]=h;continue}(0,c.isObjectLike)(h)?p[a]=R(h,{...t,visited:i}):p[a]=h}}return p},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},X=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(X.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,D.stringIncludesAny)(i,[`
7
+ `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
+ `}return n+=`${r}}`,n},Y=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],Z=/^["[{]/,Q=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||Q.test(t)||!Y.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||Z.test(t)&&!n)},m=e=>(0,eval)(e),b=(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 y=e[s];if(y==="/"&&e[s+1]==="/"){const a=e.indexOf(`
9
+ `,s);s=a===-1?l:a;continue}if(y==="/"&&e[s+1]==="*"){const a=e.indexOf("*/",s+2);s=a===-1?l:a+2;continue}if(y==='"'||y==="'"||y==="`"){const a=y;for(s++;s<l;){if(e[s]==="\\"){s+=2;continue}if(e[s]===a){s++;break}if(a==="`"&&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(y==="{"){i++,s++;continue}if(y==="}"){i--,s++;continue}if(i===1&&u.test(e.slice(s))){const a=s;let h=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==="{"){h++,d++;continue}if(w===")"||w==="]"||w==="}"){if(h===0)break;h--,d++;continue}if(h===0&&(w===";"||w===`
10
+ `)){d++;break}d++}n.push([a,d]),s=d;continue}s++}if(!n.length)return null;let p=e;for(let y=n.length-1;y>=0;y--)p=p.slice(0,n[y][0])+p.slice(n[y][1]);return p},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 p=String(n).trim();if(/^function[\s(]/.test(p))try{u=o.window.eval("(async "+p+")")}catch{}}else if(l){const p=l[1],y=b(String(n),p);if(y&&y!==n)try{u=o.window.eval("("+y+")")}catch{}}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},M=(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]=M(l,u,o,r):u!==void 0&&(e[f]=u)}return e},I=(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)||!I(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],p=i[l];if((0,O.isDOMNode)(u)||(0,O.isDOMNode)(p)){if(u!==p)return!1}else if((0,c.isObjectLike)(u)&&(0,c.isObjectLike)(p)){if(!s(p,u))return!1}else if(u!==p)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};
@@ -1,12 +1,14 @@
1
- import{window as g}from"./globals.js";import{isFunction as S,isObjectLike as u,isObject as d,isArray as w,isString as _,is as N}from"./types.js";import{unstackArrayOfObjects as D}from"./array.js";import{stringIncludesAny as C}from"./string.js";import{isDOMNode as h}from"./node.js";import{METHODS_EXL as W}from"./keys.js";const A="production",O=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,k=(e,t,o,r)=>{if(S(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&&(w(e)||d(e)&&!h(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const c=s.resolveHandler(e,t);if(typeof c=="function")return k(c,t,o,r)}}return e},b=(e,t,o)=>{for(const r in t)e[r]=k(t[r],o)},j=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(O(n)||(r?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},ee=(e,t,o=W)=>E(e,t,o,null),E=(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)||O(s)||s==="constructor"||s==="prototype"||(n?o.has(s):o.includes(s)))continue;const c=e[s],i=t[s];if(u(c)&&u(i)){const l=r||[];l.push(e,t),E(c,i,o,l),l.length-=2}else c===void 0&&(e[s]=i)}return e},te=(e,t=[])=>{const o=t instanceof Set,r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(O(n)||(o?t.has(n):t.includes(n))||(r[n]=e[n]));return r},I=(e,t={})=>{const{exclude:o=[],cleanUndefined:r=!1,cleanNull:n=!1,window:s,visited:c=new WeakMap,handleExtends:i=!1}=t,l=s||g||globalThis;if(!u(e)||h(e))return e;if(c.has(e))return c.get(e);const a=w(e)?[]:{};c.set(e,a);const x=o instanceof Set?o:o.length>3?new Set(o):null;for(const p in e){if(!Object.prototype.hasOwnProperty.call(e,p)||O(p)||p==="__proto__"||(x?x.has(p):o.includes(p)))continue;const y=e[p];if(!(r&&y===void 0)&&!(n&&y===null)){if(h(y)){a[p]=y;continue}if(i&&p==="extends"&&w(y)){a[p]=D(y,o);continue}if(S(y)){a[p]=y;continue}u(y)?a[p]=I(y,{...t,visited:c}):a[p]=y}}return a},$=(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(S(r))t[o]=r.toString();else if(d(r))t[o]={},$(r,t[o]);else if(w(r)){const n=t[o]=[];for(let s=0;s<r.length;s++){const c=r[s];d(c)?(n[s]={},$(c,n[s])):S(c)?n[s]=c.toString():n[s]=c}}else t[o]=r}return t},M=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),v=(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 c=e[s];let i=!1;for(let f=0;f<s.length;f++)if(M.has(s[f])){i=!0;break}const l=i?`'${s}'`:s;if(n+=`${r} ${l}: `,w(c)){n+=`[
3
- `;for(const f of c)u(f)&&f!==null?n+=`${r} ${v(f,t+2)},
4
- `:_(f)?n+=`${r} '${f}',
5
- `:n+=`${r} ${f},
6
- `;n+=`${r} ]`}else u(c)?n+=v(c,t+1):_(c)?n+=C(c,[`
7
- `,"'"])?`\`${c}\``:`'${c}'`:n+=c;n+=`,
8
- `}return n+=`${r}}`,n},R=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],F=/^["[{]/,P=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||!R.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||F.test(t)&&!n)},L=e=>(0,eval)(e),T=(e,t={},o={window:{eval:L}})=>{for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const n=e[r];if(_(n))if(P(n))try{t[r]=o.window.eval(`(${n})`)}catch(s){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: '+(s&&s.message?s.message:String(s))+`.
9
- First 200 chars of source: `+String(n).slice(0,200)),t[r]=n}else t[r]=n;else if(w(n)){const s=t[r]=[];for(let c=0;c<n.length;c++){const i=n[c];if(_(i))if(P(i))try{s.push(o.window.eval(`(${i})`))}catch(l){typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed in array at index ${c} (prop "${r}"). Reason: ${l&&l.message?l.message:String(l)}.
10
- First 200 chars: ${String(i).slice(0,200)}`),s.push(i)}else s.push(i);else d(i)?s.push(T(i)):s.push(i)}}else d(n)?t[r]=T(n,t[r]):t[r]=n}return t},B="Set",G="Map",H=e=>!e||typeof e!="object"?e:e.__type===B&&Array.isArray(e.values)?new Set(e.values):e.__type===G&&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];_(n)&&P(n)?o.push([r,n]):t[r]=H(n)}for(const[r,n]of o)try{const s=Object.keys(t).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
11
- `);t[r]=g.eval(`(function(__gs__) { ${s}
12
- return (${n}); })`)(t)}catch{try{t[r]=g.eval(`(${n})`)}catch{t[r]=n}}return t},re=(e,t={verbose:!0})=>{try{return e?g.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},oe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),J=e=>{for(const t in e)return!1;return!0},se=e=>d(e)&&J(e),ce=()=>Object.create(null),ie=(e,t,o={})=>{const r=o.exclude||[],n=o.preventUnderscore;for(const s in t)r.includes(s)||!n&&O(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)O(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n))||(e[n]=t[n]);return e},V=(e,t,o={},r=new WeakMap)=>{if(!u(e)||!u(t)||h(e)||h(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,c=!o.preventForce;for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||s&&s.has(i)||c&&O(i)||i==="constructor"||i==="prototype")continue;const l=e[i],f=t[i];h(f)?e[i]=f:u(l)&&u(f)?e[i]=V(l,f,o,r):f!==void 0&&(e[i]=f)}return e},q=(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 c=r[s];if(!Object.prototype.hasOwnProperty.call(t,c)||!q(e[c],t[c],o))return!1}return!0},z=new Set(["node","__ref"]),le=(e,t,o=z)=>{if(e===t)return!0;if(!u(e)||!u(t)||h(e)||h(t))return e===t;const r=o instanceof Set?o:new Set(o),n=new WeakSet;function s(c,i){if(n.has(i))return!0;n.add(i);for(const l in i){if(!Object.prototype.hasOwnProperty.call(i,l)||r.has(l))continue;if(!Object.prototype.hasOwnProperty.call(c,l))return!1;const f=i[l],a=c[l];if(h(f)||h(a)){if(f!==a)return!1}else if(u(f)&&u(a)){if(!s(a,f))return!1}else if(f!==a)return!1}return!0}return s(e,t)},ue=(e,t)=>{if(t==null)return e;if(N(t)("string","number"))delete e[t];else if(w(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},K=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]=K(e[o]));return t},ae=(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},pe=(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]},ye=(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},he=(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(A==="test"||A==="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)},de=(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{te as clone,ae as createNestedObject,K as createObjectWithoutPrototype,I as deepClone,le as deepContains,T as deepDestringifyFunctions,ee as deepMerge,$ as deepStringifyFunctions,ne as destringifyGlobalScope,we as detectInfiniteLoop,de as excludeKeysFromObject,k as exec,he as getInObjectByPath,P as hasFunction,oe as hasOwnProperty,Oe as isCyclic,J as isEmpty,se as isEmptyObject,q as isEqualDeep,ce as makeObjectWithoutPrototype,b as map,j as merge,v as objectToString,ie as overwrite,V as overwriteDeep,fe as overwriteShallow,ue as removeFromObject,pe as removeNestedKeyByPath,ye as setInObjectByPath,re as stringToObject};
1
+ import{window as x}from"./globals.js";import{isFunction as k,isObjectLike as d,isObject as S,isArray as g,isString as P,is as C}from"./types.js";import{unstackArrayOfObjects as M}from"./array.js";import{stringIncludesAny as I}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(d(i)&&d(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(!d(e)||O(e))return e;if(i.has(e))return i.get(e);const a=g(e)?[]:{};i.set(e,a);const p=o instanceof Set?o:o.length>3?new Set(o):null;for(const u in e){if(!Object.prototype.hasOwnProperty.call(e,u)||_(u)||u==="__proto__"||(p?p.has(u):o.includes(u)))continue;const y=e[u];if(!(r&&y===void 0)&&!(n&&y===null)){if(O(y)){a[u]=y;continue}if(c&&u==="extends"&&g(y)){a[u]=M(y,o);continue}if(k(y)){a[u]=y;continue}d(y)?a[u]=L(y,{...t,visited:i}):a[u]=y}}return a},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(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),D=(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)d(l)&&l!==null?n+=`${r} ${D(l,t+2)},
4
+ `:P(l)?n+=`${r} '${l}',
5
+ `:n+=`${r} ${l},
6
+ `;n+=`${r} ]`}else d(i)?n+=D(i,t+1):P(i)?n+=I(i,[`
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 p=e[s];if(p==="/"&&e[s+1]==="/"){const u=e.indexOf(`
9
+ `,s);s=u===-1?f:u;continue}if(p==="/"&&e[s+1]==="*"){const u=e.indexOf("*/",s+2);s=u===-1?f:u+2;continue}if(p==='"'||p==="'"||p==="`"){const u=p;for(s++;s<f;){if(e[s]==="\\"){s+=2;continue}if(e[s]===u){s++;break}if(u==="`"&&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(p==="{"){i++,s++;continue}if(p==="}"){i--,s++;continue}if(i===1&&l.test(e.slice(s))){const u=s;let y=0,h=s;for(;h<f;){const w=e[h];if(w==='"'||w==="'"||w==="`"){const R=w;for(h++;h<f;){if(e[h]==="\\"){h+=2;continue}if(e[h]===R){h++;break}h++}continue}if(w==="("||w==="["||w==="{"){y++,h++;continue}if(w===")"||w==="]"||w==="}"){if(y===0)break;y--,h++;continue}if(y===0&&(w===";"||w===`
10
+ `)){h++;break}h++}n.push([u,h]),s=h;continue}s++}if(!n.length)return null;let a=e;for(let p=n.length-1;p>=0;p--)a=a.slice(0,n[p][0])+a.slice(n[p][1]);return a},N=(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 a=String(n).trim();if(/^function[\s(]/.test(a))try{l=o.window.eval("(async "+a+")")}catch{}}else if(f){const a=f[1],p=J(String(n),a);if(p&&p!==n)try{l=o.window.eval("("+p+")")}catch{}}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(N(c)):s.push(c)}}else S(n)?t[r]=N(n,t[r]):t[r]=n}return t},U="Set",V="Map",z=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]=z(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),K=e=>{for(const t in e)return!1;return!0},ue=e=>S(e)&&K(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},X=(e,t,o={},r=new WeakMap)=>{if(!d(e)||!d(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:d(f)&&d(l)?e[c]=X(f,l,o,r):l!==void 0&&(e[c]=l)}return e},Y=(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)||!Y(e[i],t[i],o))return!1}return!0},Z=new Set(["node","__ref"]),he=(e,t,o=Z)=>{if(e===t)return!0;if(!d(e)||!d(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],a=i[f];if(O(l)||O(a)){if(l!==a)return!1}else if(d(l)&&d(a)){if(!s(a,l))return!1}else if(l!==a)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},Q=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]=Q(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,Q as createObjectWithoutPrototype,L as deepClone,he as deepContains,N 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,K as isEmpty,ue as isEmptyObject,Y as isEqualDeep,ae as makeObjectWithoutPrototype,re as map,oe as merge,D as objectToString,pe as overwrite,X as overwriteDeep,ye as overwriteShallow,de as removeFromObject,Oe as removeNestedKeyByPath,ge as setInObjectByPath,fe as stringToObject};
package/object.js CHANGED
@@ -350,6 +350,12 @@ const FN_PATTERNS = [
350
350
  /^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/
351
351
  ]
352
352
  const RE_JSON_LIKE = /^["[{]/
353
+ // Module-source prefixes. A string starting with `export ` or `import ` is a
354
+ // module body (stored verbatim for the editor / AI to display), never a
355
+ // runtime handler. The arrow-function regex above otherwise misfires on
356
+ // `export default { foo: (e) => ... }` because `[^=]*` greedily walks into
357
+ // the inner arrow.
358
+ const RE_MODULE_PREFIX = /^(export|import)\s/
353
359
 
354
360
  export const hasFunction = (str) => {
355
361
  if (!str) return false
@@ -357,6 +363,7 @@ export const hasFunction = (str) => {
357
363
  const trimmed = str.trim().replace(/\n\s*/g, ' ').trim()
358
364
 
359
365
  if (trimmed === '' || trimmed === '{}' || trimmed === '[]') return false
366
+ if (RE_MODULE_PREFIX.test(trimmed)) return false
360
367
 
361
368
  const isFn = FN_PATTERNS.some((pattern) => pattern.test(trimmed))
362
369
  if (!isFn) return false
@@ -376,6 +383,110 @@ export const hasFunction = (str) => {
376
383
  // passes that hit prepareContext without a real DOM.
377
384
  const __globalEval = (src) => (0, eval)(src) // eslint-disable-line no-eval
378
385
 
386
+ // Strip a top-level `const|let|var <name> = …;` declaration from a function
387
+ // body. Used to recover from project-data that double-declares a parameter
388
+ // name (e.g. `function fn(el) { const el = … }` — illegal JS the user can't
389
+ // have actually been running, but we still want the rest of the body to eval
390
+ // instead of leaving the whole handler as a silent string).
391
+ //
392
+ // Only removes declarations at the function body's top brace depth — nested
393
+ // blocks keep their own `const <name>` (which is valid scope-shadowing in
394
+ // inner blocks). Returns the modified source, or null when no top-level
395
+ // declaration was found.
396
+ const stripTopLevelDeclaration = (src, name) => {
397
+ // Find the function body's opening `{`.
398
+ const headMatch = /^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(src)
399
+ if (!headMatch) return null
400
+ const bodyStart = headMatch[0].length
401
+ // Walk the body, tracking brace depth so we only touch declarations at depth
402
+ // 1 (the function body's own top level). Skip strings, template literals,
403
+ // regex literals, and comments — naive `indexOf` would falsely match inside
404
+ // them. Keep a list of (start, end) ranges to splice.
405
+ const ranges = []
406
+ let i = bodyStart
407
+ let depth = 1 // we entered the function body
408
+ let lastTokenType = null
409
+ const len = src.length
410
+ const declRe = new RegExp('^(?:const|let|var)\\s+' + name + '\\b')
411
+ while (i < len && depth > 0) {
412
+ const ch = src[i]
413
+ // Skip comments
414
+ if (ch === '/' && src[i + 1] === '/') {
415
+ const nl = src.indexOf('\n', i)
416
+ i = nl === -1 ? len : nl
417
+ continue
418
+ }
419
+ if (ch === '/' && src[i + 1] === '*') {
420
+ const end = src.indexOf('*/', i + 2)
421
+ i = end === -1 ? len : end + 2
422
+ continue
423
+ }
424
+ // Skip strings
425
+ if (ch === '"' || ch === "'" || ch === '`') {
426
+ const quote = ch
427
+ i++
428
+ while (i < len) {
429
+ if (src[i] === '\\') { i += 2; continue }
430
+ if (src[i] === quote) { i++; break }
431
+ if (quote === '`' && src[i] === '$' && src[i + 1] === '{') {
432
+ // Skip nested template expression — track braces.
433
+ i += 2
434
+ let td = 1
435
+ while (i < len && td > 0) {
436
+ if (src[i] === '{') td++
437
+ else if (src[i] === '}') td--
438
+ i++
439
+ }
440
+ continue
441
+ }
442
+ i++
443
+ }
444
+ continue
445
+ }
446
+ if (ch === '{') { depth++; i++; continue }
447
+ if (ch === '}') { depth--; i++; continue }
448
+ // Only consider declarations at the function body's top level.
449
+ if (depth === 1 && declRe.test(src.slice(i))) {
450
+ // Find the terminating semicolon (or newline) at this depth.
451
+ const declStart = i
452
+ // Walk forward respecting strings, parens, braces, brackets.
453
+ let d = 0
454
+ let j = i
455
+ while (j < len) {
456
+ const c = src[j]
457
+ if (c === '"' || c === "'" || c === '`') {
458
+ const q = c
459
+ j++
460
+ while (j < len) {
461
+ if (src[j] === '\\') { j += 2; continue }
462
+ if (src[j] === q) { j++; break }
463
+ j++
464
+ }
465
+ continue
466
+ }
467
+ if (c === '(' || c === '[' || c === '{') { d++; j++; continue }
468
+ if (c === ')' || c === ']' || c === '}') {
469
+ if (d === 0) break
470
+ d--; j++; continue
471
+ }
472
+ if (d === 0 && (c === ';' || c === '\n')) { j++; break }
473
+ j++
474
+ }
475
+ ranges.push([declStart, j])
476
+ i = j
477
+ continue
478
+ }
479
+ i++
480
+ }
481
+ if (!ranges.length) return null
482
+ // Splice ranges from the end so earlier offsets stay valid.
483
+ let out = src
484
+ for (let r = ranges.length - 1; r >= 0; r--) {
485
+ out = out.slice(0, ranges[r][0]) + out.slice(ranges[r][1])
486
+ }
487
+ return out
488
+ }
489
+
379
490
  export const deepDestringifyFunctions = (
380
491
  obj,
381
492
  destringified = {},
@@ -391,21 +502,59 @@ export const deepDestringifyFunctions = (
391
502
  try {
392
503
  destringified[prop] = opts.window.eval(`(${objProp})`)
393
504
  } catch (e) {
394
- // FR-1 (FRANK-RUNNER.md): the silent string-fallback used to
395
- // mask broken serialization eight aihouse functions stored
396
- // as strings instead of functions, `el.call(name)` no-op'd
397
- // with no error. Surface the failure so consumers can audit
398
- // what frank produced. Keep the fallback (don't crash boot)
399
- // but make it loud.
400
- if (typeof console !== 'undefined' && console.warn) {
401
- console.warn(
402
- '[smbls] deepDestringifyFunctions: eval failed on "' + prop + '" — ' +
403
- 'function will be left as a string and el.call("' + prop + '") ' +
404
- 'will silently no-op. Reason: ' + (e && e.message ? e.message : String(e)) + '.\n' +
405
- 'First 200 chars of source: ' + String(objProp).slice(0, 200)
406
- )
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
+ const name = dupMatch[1]
532
+ const stripped = stripTopLevelDeclaration(String(objProp), name)
533
+ if (stripped && stripped !== objProp) {
534
+ try {
535
+ recovered = opts.window.eval('(' + stripped + ')')
536
+ } catch (_) { /* fall through to warning */ }
537
+ }
538
+ }
539
+ if (recovered) {
540
+ destringified[prop] = recovered
541
+ } else {
542
+ // FR-1 (FRANK-RUNNER.md): the silent string-fallback used to
543
+ // mask broken serialization — eight aihouse functions stored
544
+ // as strings instead of functions, `el.call(name)` no-op'd
545
+ // with no error. Surface the failure so consumers can audit
546
+ // what frank produced. Keep the fallback (don't crash boot)
547
+ // but make it loud.
548
+ if (typeof console !== 'undefined' && console.warn) {
549
+ console.warn(
550
+ '[smbls] deepDestringifyFunctions: eval failed on "' + prop + '" — ' +
551
+ 'function will be left as a string and el.call("' + prop + '") ' +
552
+ 'will silently no-op. Reason: ' + msg + '.\n' +
553
+ 'First 200 chars of source: ' + String(objProp).slice(0, 200)
554
+ )
555
+ }
556
+ destringified[prop] = objProp
407
557
  }
408
- destringified[prop] = objProp
409
558
  }
410
559
  } else {
411
560
  destringified[prop] = objProp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.13",
3
+ "version": "3.14.14",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",