@symbo.ls/utils 3.14.15 → 3.14.16
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 +8 -2
- package/dist/cjs/object.js +7 -7
- package/dist/esm/object.js +8 -8
- package/object.js +26 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
# @symbo.ls/utils
|
|
2
2
|
|
|
3
|
-
## 3.14.
|
|
3
|
+
## 3.14.16
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Manual patch bump triggered via workflow_dispatch (scope:
|
|
7
|
+
- Manual patch bump triggered via workflow_dispatch (scope: all).
|
|
8
8
|
No source change behind this bump — released to refresh dist or
|
|
9
9
|
coordinate a cross-package version line.
|
|
10
10
|
- Updated dependencies
|
|
11
11
|
- @symbo.ls/fetch@3.14.10
|
|
12
12
|
|
|
13
|
+
## 3.14.15
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Auto-generated cross-repo patch release.
|
|
18
|
+
|
|
13
19
|
## 3.14.14
|
|
14
20
|
|
|
15
21
|
### Patch Changes
|
package/dist/cjs/object.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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:()=>
|
|
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(
|
|
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
3
|
`;for(const u of i)(0,c.isObjectLike)(u)&&u!==null?n+=`${r} ${E(u,t+2)},
|
|
4
4
|
`:(0,c.isString)(u)?n+=`${r} '${u}',
|
|
5
5
|
`:n+=`${r} ${u},
|
|
6
|
-
`;n+=`${r} ]`}else(0,c.isObjectLike)(i)?n+=E(i,t+1):(0,c.isString)(i)?n+=(0,
|
|
6
|
+
`;n+=`${r} ]`}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},
|
|
9
|
-
`,s);s=
|
|
10
|
-
`)){d++;break}d++}n.push([
|
|
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
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
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
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},
|
|
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};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{window as x}from"./globals.js";import{isFunction as k,isObjectLike as
|
|
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
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)
|
|
3
|
+
`;for(const l of i)w(l)&&l!==null?n+=`${r} ${N(l,t+2)},
|
|
4
4
|
`:P(l)?n+=`${r} '${l}',
|
|
5
5
|
`:n+=`${r} ${l},
|
|
6
|
-
`;n+=`${r} ]`}else
|
|
6
|
+
`;n+=`${r} ]`}else w(i)?n+=N(i,t+1):P(i)?n+=M(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
|
|
9
|
-
`,s);s=
|
|
10
|
-
`)){h++;break}h++}n.push([
|
|
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
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(
|
|
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
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),
|
|
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};
|
package/object.js
CHANGED
|
@@ -528,12 +528,33 @@ export const deepDestringifyFunctions = (
|
|
|
528
528
|
} catch (_) { /* fall through to warning */ }
|
|
529
529
|
}
|
|
530
530
|
} else if (dupMatch) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
|
534
549
|
try {
|
|
535
|
-
recovered = opts.window.eval('(' +
|
|
536
|
-
|
|
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
|
+
}
|
|
537
558
|
}
|
|
538
559
|
}
|
|
539
560
|
if (recovered) {
|