@symbo.ls/utils 3.14.446 → 3.14.568
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 +12 -0
- package/dist/cjs/metadata.js +2 -2
- package/dist/cjs/object.js +16 -12
- package/dist/esm/metadata.js +2 -2
- package/dist/esm/object.js +16 -12
- package/metadata.js +3 -1
- package/object.js +50 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var A=(s,i)=>{for(var r in i)j(s,r,{get:i[r],enumerable:!0})},W=(s,i,r,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of L(i))!S.call(s,n)&&n!==r&&j(s,n,{get:()=>i[n],enumerable:!(e=O(i,n))||e.enumerable});return s};var E=s=>W(j({},"__esModule",{value:!0}),s);var K={};A(K,{generateMetaTags:()=>q,getPageMetadata:()=>
|
|
2
|
-
`)),
|
|
1
|
+
"use strict";var j=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var A=(s,i)=>{for(var r in i)j(s,r,{get:i[r],enumerable:!0})},W=(s,i,r,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of L(i))!S.call(s,n)&&n!==r&&j(s,n,{get:()=>i[n],enumerable:!(e=O(i,n))||e.enumerable});return s};var E=s=>W(j({},"__esModule",{value:!0}),s);var K={};A(K,{generateMetaTags:()=>q,getPageMetadata:()=>x});module.exports=E(K);var w=require("./types.js");const h=s=>{if(s==null)return"";const i={"&":"&","<":"<",">":">",'"':""","'":"'"};return s.toString().replace(/[&<>"']/g,r=>i[r])},T=s=>Object.entries(s||{}).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}="${h(r)}"`).join(" "),q=(s,i)=>(i||(s={...s,robots:"noindex"}),Object.entries(s).reduce((e,[n,o])=>{if(!o&&o!==0&&o!==!1)return e;if(n==="title")return e.push(`<title>${h(o)}</title>`),e;if(n==="canonical")return e.push(`<link rel="canonical" href="${h(o)}">`),e;if(n==="manifest")return e.push(`<link rel="manifest" href="${h(o)}">`),e;if(n==="favicon"||n==="favicons"||n==="icon"||n==="icons")return(Array.isArray(o)?o:[o]).forEach(f=>{if(typeof f=="string")e.push(`<link rel="icon" href="${h(f)}">`);else if(typeof f=="object"){const a=T(f);/rel=/.test(a)?e.push(`<link ${a}>`):e.push(`<link rel="icon" ${a}>`)}}),e;if(n==="alternate")return(Array.isArray(o)?o:[o]).forEach(f=>{if(typeof f=="object"){const a=Object.entries(f).filter(([t,u])=>u!==void 0).map(([t,u])=>`${t}="${h(u)}"`).join(" ");e.push(`<link rel="alternate" ${a}>`)}}),e;const p=(c,f,a="name")=>{if(typeof f=="string"||typeof f=="number"||typeof f=="boolean")e.push(`<meta ${a}="${h(c)}" content="${h(f)}">`);else if(Array.isArray(f))f.forEach(t=>{if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")e.push(`<meta ${a}="${h(c)}" content="${h(t)}">`);else if(typeof t=="object"){const u=Object.entries(t).filter(([m,l])=>l!==void 0).map(([m,l])=>`${m}="${h(l)}"`).join(" ");e.push(`<meta ${u}>`)}});else if(typeof f=="object"){const t=Object.entries(f).filter(([u,m])=>m!==void 0).map(([u,m])=>`${u}="${h(m)}"`).join(" ");e.push(`<meta ${t}>`)}};if(n.startsWith("http-equiv:")){const c=n.replace("http-equiv:","");return p(c,o,"http-equiv"),e}if(n.startsWith("itemprop:")){const c=n.replace("itemprop:","");return p(c,o,"itemprop"),e}const g=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(c=>n.startsWith(c));if(g){const c=n.replace(g,"");return p(`${g.replace(":","")}:${c}`,o,g==="twitter:"||g==="DC:"||g==="DCTERMS:"?"name":"property"),e}if(n.startsWith("apple:")||n.startsWith("msapplication:")){const c=n.startsWith("apple:")?"apple-":"msapplication-",f=n.replace(/^apple:|^msapplication:/,"");return p(`${c}${f}`,o,"name"),e}return p(n,o),e},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']).join(`
|
|
2
|
+
`)),D=s=>typeof s=="string"&&s.length>0&&!s.startsWith("/")&&!s.startsWith("http");function F(s,i){if(!i||typeof i!="object")return s;const r=n=>{if(!D(n))return n;const o=i[n];return o?.src?o.src:n},e={...s};for(const[n,o]of Object.entries(e))typeof o=="string"?e[n]=r(o):Array.isArray(o)&&(e[n]=o.map(p=>typeof p=="string"?r(p):p));return e}function y(s,i){if(!s||!i)return;const r=i.split(".");let e=s;for(const n of r){if(e==null||typeof e!="object")return;e=e[n]}return e}function P(s,i,r){const n=(i.config||i.settings||{}).polyglot||i.polyglot,o=r?.lang||n?.defaultLang||"en",d=(n?.translations||{})[o]||{},g=r?.state||{},c={...s};for(const[f,a]of Object.entries(c))typeof a!="string"||!a.includes("{{")||(c[f]=a.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(t,u,m)=>{const l=u.trim();if(m==="polyglot")return d[l]??y(d,l)??t;if(m==="getLocalStateLang")return y(g,l+o)??t;const $=y(g,l);return $!==void 0?$:d[l]??y(d,l)??t}));return c}function M(s){const i={...s};for(const[r,e]of Object.entries(i))if(typeof e=="function"){const n=e.toString(),o=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){i[r]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const p=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(p){i[r]=`{{ ${p[1]} | polyglot }}`;continue}const d=n.match(/s\.(\w+(?:\.\w+)+)/);if(d){i[r]=`{{ ${d[1]} }}`;continue}delete i[r]}else if(typeof e=="string"){const n=e.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(n){i[r]=`{{ ${n[1]} | getLocalStateLang }}`;continue}const o=e.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){i[r]=`{{ ${o[1]} | polyglot }}`;continue}if(e.includes("=>")&&e.includes("s.")){const p=e.match(/s\.(\w+(?:\.\w+)+)/);if(p){i[r]=`{{ ${p[1]} }}`;continue}}}return i}function x(s,i,r,{isProduction:e=!1,channel:n="production"}={}){const o=s.pages?.[i],p=(0,w.isObject)(o?.state)&&o?.state,d=o?.metadata||o?.helmet||p||{},g=M(d),c=new Set(Object.keys(g)),f=s.app?.metadata||{},a=M(f);let t={};if(s.integrations?.seo?t={...s.integrations.seo,...a,...g}:Object.keys(a).length?t={...a,...g}:t={...g},!t.title){const l=s.name||s.key;l?e?t.title=l:n==="development"?t.title=`${l} / dev:symbo.ls`:n==="staging"?t.title=`${l} / staging:symbo.ls`:t.title=`${l} / symbo.ls`:t.title="Symbols demo"}t=P(t,s,r),t.title&&(c.has("title")||!t["og:title"])&&(c.has("og:title")||(t["og:title"]=t.title)),t.description&&(c.has("description")||!t["og:description"])&&(c.has("og:description")||(t["og:description"]=t.description)),t.title&&!t["twitter:title"]&&(t["twitter:title"]=t.title),t.description&&!t["twitter:description"]&&(t["twitter:description"]=t.description);const u=r?.actualPathname||i;if(t["og:url"]||t.url){const l=(t["og:url"]||t.url||"").replace(/\/$/,"");if(l&&u&&u!=="/"){const $=u.startsWith("/")?u:"/"+u;t["og:url"]=l+$}}t=F(t,s.files);const m=s.name||s.app?.metadata?.title||s.app?.name||"";for(const[l,$]of Object.entries(t))if(typeof $=="string"&&$.includes("{{")){const b=$.replace(/\{\{[^}]*\}\}/g,"").trim();b?t[l]=b:l==="title"?t[l]=m:delete t[l]}return t}
|
package/dist/cjs/object.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
`;for(const
|
|
3
|
-
`;for(const f of i)(0,
|
|
4
|
-
`:(0,
|
|
5
|
-
`:n+=`${
|
|
6
|
-
`;n+=`${
|
|
1
|
+
"use strict";var x=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b(t))!F.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(s=W(t,n))||s.enumerable});return e};var B=e=>q(x({},"__esModule",{value:!0}),e);var Se={};J(Se,{clone:()=>z,createNestedObject:()=>ye,createObjectWithoutPrototype:()=>R,deepClone:()=>U,deepContains:()=>ae,deepDestringifyFunctions:()=>j,deepMerge:()=>m,deepStringifyFunctions:()=>$,destringifyGlobalScope:()=>re,detectInfiniteLoop:()=>ge,excludeKeysFromObject:()=>_e,exec:()=>P,getInObjectByPath:()=>we,hasFunction:()=>S,hasOwnProperty:()=>se,isCyclic:()=>Oe,isEmpty:()=>C,isEmptyObject:()=>ie,isEqualDeep:()=>M,makeObjectWithoutPrototype:()=>ce,map:()=>G,merge:()=>H,objectToString:()=>k,overwrite:()=>fe,overwriteDeep:()=>I,overwriteShallow:()=>le,removeFromObject:()=>pe,removeNestedKeyByPath:()=>he,setInObjectByPath:()=>de,stringToObject:()=>oe});module.exports=B(Se);var _=require("./globals.js"),l=require("./types.js"),T=require("./array.js"),N=require("./string.js"),g=require("./node.js"),D=require("./keys.js");const E="production",O=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,P=(e,t,r,s)=>{if((0,l.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,l.isArray)(e)||(0,l.isObject)(e)&&!(0,g.isDOMNode)(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return P(i,t,r,s)}}return e},G=(e,t,r)=>{for(const s in t)e[s]=P(t[s],r)},H=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(O(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},m=(e,t,r=D.METHODS_EXL)=>v(e,t,r,null),v=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||O(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],c=t[o];if((0,l.isObjectLike)(i)&&(0,l.isObjectLike)(c)){const u=s||[];u.push(e,t),v(i,c,r,u),u.length-=2}else i===void 0&&(e[o]=c)}return e},z=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(O(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},U=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!(0,l.isObjectLike)(e)||(0,g.isDOMNode)(e))return e;if(o.has(e))return o.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,u=y=>c?c.has(y):r.includes(y),f=(0,l.isArray)(e)?[]:{};o.set(e,f);const p=[[e,f]];for(;p.length;){const[y,d]=p.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||O(h)||h==="__proto__"||u(h))continue;const a=y[h];if(!(s&&a===void 0)&&!(n&&a===null)){if((0,g.isDOMNode)(a)){d[h]=a;continue}if(i&&h==="extends"&&(0,l.isArray)(a)){d[h]=(0,T.unstackArrayOfObjects)(a,r);continue}if((0,l.isFunction)(a)){d[h]=a;continue}if((0,l.isObjectLike)(a))if(o.has(a))d[h]=o.get(a);else{const w=(0,l.isArray)(a)?[]:{};o.set(a,w),d[h]=w,p.push([a,w])}else d[h]=a}}}return f},$=(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 s=e[r];if((0,l.isFunction)(s))t[r]=s.toString();else if((0,l.isObject)(s))t[r]={},$(s,t[r]);else if((0,l.isArray)(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];(0,l.isObject)(i)?(n[o]={},$(i,n[o])):(0,l.isFunction)(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},V=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),k=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
|
|
2
|
+
`;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let c=!1;for(let f=0;f<o.length;f++)if(V.has(o[f])){c=!0;break}const u=c?`'${o}'`:o;if(n+=`${s} ${u}: `,(0,l.isArray)(i)){n+=`[
|
|
3
|
+
`;for(const f of i)(0,l.isObjectLike)(f)&&f!==null?n+=`${s} ${k(f,t+2)},
|
|
4
|
+
`:(0,l.isString)(f)?n+=`${s} '${f}',
|
|
5
|
+
`:n+=`${s} ${f},
|
|
6
|
+
`;n+=`${s} ]`}else(0,l.isObjectLike)(i)?n+=k(i,t+1):(0,l.isString)(i)?n+=(0,N.stringIncludesAny)(i,[`
|
|
7
7
|
`,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
|
|
8
|
-
`}return n+=`${
|
|
9
|
-
`,
|
|
10
|
-
`)){a++;break}a++}n.push([d,a]),
|
|
11
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},j=(e,t={},r={window:{eval:
|
|
12
|
-
`);
|
|
13
|
-
|
|
8
|
+
`}return n+=`${s}}`,n},Z=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],K=/^["[{]/,X=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||X.test(t)||!Z.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||K.test(t)&&!n)},Y=e=>(0,eval)(e),Q=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,c=null;const u=e.length,f=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<u&&i>0;){const y=e[o];if(y==="/"&&e[o+1]==="/"){const d=e.indexOf(`
|
|
9
|
+
`,o);o=d===-1?u:d;continue}if(y==="/"&&e[o+1]==="*"){const d=e.indexOf("*/",o+2);o=d===-1?u:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(o++;o<u;){if(e[o]==="\\"){o+=2;continue}if(e[o]===d){o++;break}if(d==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let h=1;for(;o<u&&h>0;)e[o]==="{"?h++:e[o]==="}"&&h--,o++;continue}o++}continue}if(y==="{"){i++,o++;continue}if(y==="}"){i--,o++;continue}if(i===1&&f.test(e.slice(o))){const d=o;let h=0,a=o;for(;a<u;){const w=e[a];if(w==='"'||w==="'"||w==="`"){const L=w;for(a++;a<u;){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]),o=a;continue}o++}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,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),c=/Identifier '([^']+)' has already been declared/.exec(o);let u=null;if(i){const f=String(e).trim();if(/^function[\s(]/.test(f))try{u=r.window.eval("(async "+f+")")}catch{}}else if(c){let f=String(e),p=c[1];for(let y=0;y<5;y++){const d=Q(f,p);if(!d||d===f)break;f=d;try{u=r.window.eval("("+f+")");break}catch(h){const a=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!a||a[1]!==p)break}}}return u||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
|
|
11
|
+
First 200 chars of source: `+String(e).slice(0,200)),e)}},j=(e,t={},r={window:{eval:Y}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if((0,l.isString)(c))S(c)?o[i]=A(c,`"${i}"`,r):o[i]=c;else if((0,l.isArray)(c)){const u=o[i]=[];for(let f=0;f<c.length;f++){const p=c[f];if((0,l.isString)(p))u.push(S(p)?A(p,`array index ${f} (prop "${i}")`,r):p);else if((0,l.isObject)(p)){const y={};u.push(y),s.push([p,y])}else u.push(p)}}else if((0,l.isObject)(c)){const u=o[i]&&typeof o[i]=="object"&&!(0,l.isArray)(o[i])?o[i]:o[i]={};s.push([c,u])}else o[i]=c}}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 i of Object.keys(e)){const c=e[i];(0,l.isString)(c)&&S(c)?r.push([i,c]):t[i]=ne(c)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
|
|
12
|
+
`);try{const i=n.map(([f,p])=>`var ${f} = (${p});`).join(`
|
|
13
|
+
`),c="{ "+n.map(([f])=>`${JSON.stringify(f)}: ${f}`).join(", ")+" }",u=_.window.eval(`(function(__gs__) { ${o}
|
|
14
|
+
${i}
|
|
15
|
+
return ${c}; })`)(t);Object.assign(t,u)}catch{for(const[c,u]of n)try{const f=Object.keys(t).filter(s).map(p=>`var ${p} = __gs__[${JSON.stringify(p)}];`).join(`
|
|
16
|
+
`);t[c]=_.window.eval(`(function(__gs__) { ${f}
|
|
17
|
+
return (${u}); })`)(t)}catch{try{t[c]=_.window.eval(`(${u})`)}catch{t[c]=u}}}for(const[i,c]of r)if(!s(i))try{t[i]=_.window.eval(`(${c})`)}catch{t[i]=c}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),C=e=>{for(const t in e)return!1;return!0},ie=e=>(0,l.isObject)(e)&&C(e),ce=()=>Object.create(null),fe=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&O(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},le=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)O(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},I=(e,t,r={},s=new WeakMap)=>{if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||o&&o.has(c)||i&&O(c)||c==="constructor"||c==="prototype")continue;const u=e[c],f=t[c];(0,g.isDOMNode)(f)?e[c]=f:(0,l.isObjectLike)(u)&&(0,l.isObjectLike)(f)?e[c]=I(u,f,r,s):f!==void 0&&(e[c]=f)}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 s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];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,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,c){if(n.has(c))return!0;n.add(c);for(const u in c){if(!Object.prototype.hasOwnProperty.call(c,u)||s.has(u))continue;if(!Object.prototype.hasOwnProperty.call(i,u))return!1;const f=c[u],p=i[u];if((0,g.isDOMNode)(f)||(0,g.isDOMNode)(p)){if(f!==p)return!1}else if((0,l.isObjectLike)(f)&&(0,l.isObjectLike)(p)){if(!o(p,f))return!1}else if(f!==p)return!1}return!0}return o(e,t)},pe=(e,t)=>{if(t==null)return e;if((0,l.is)(t)("string","number"))delete e[t];else if((0,l.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 s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[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 s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},de=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[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 s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},ge=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(E==="test"||E==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Oe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},_e=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};
|
package/dist/esm/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isObject as M}from"./types.js";const
|
|
2
|
-
`)),O=i=>typeof i=="string"&&i.length>0&&!i.startsWith("/")&&!i.startsWith("http");function L(i,o){if(!o||typeof o!="object")return i;const r=n=>{if(!O(n))return n;const s=o[n];return s?.src?s.src:n},e={...i};for(const[n,s]of Object.entries(e))typeof s=="string"?e[n]=r(s):Array.isArray(s)&&(e[n]=s.map(p=>typeof p=="string"?r(p):p));return e}function y(i,o){if(!i||!o)return;const r=o.split(".");let e=i;for(const n of r){if(e==null||typeof e!="object")return;e=e[n]}return e}function S(i,o,r){const n=(o.config||o.settings||{}).polyglot||o.polyglot,s=r?.lang||n?.defaultLang||"en",d=(n?.translations||{})[s]||{},g=r?.state||{},c={...i};for(const[f,a]of Object.entries(c))typeof a!="string"||!a.includes("{{")||(c[f]=a.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(t,u,
|
|
1
|
+
import{isObject as M}from"./types.js";const h=i=>{if(i==null)return"";const o={"&":"&","<":"<",">":">",'"':""","'":"'"};return i.toString().replace(/[&<>"']/g,r=>o[r])},w=i=>Object.entries(i||{}).filter(([o,r])=>r!==void 0).map(([o,r])=>`${o}="${h(r)}"`).join(" "),W=(i,o)=>(o||(i={...i,robots:"noindex"}),Object.entries(i).reduce((e,[n,s])=>{if(!s&&s!==0&&s!==!1)return e;if(n==="title")return e.push(`<title>${h(s)}</title>`),e;if(n==="canonical")return e.push(`<link rel="canonical" href="${h(s)}">`),e;if(n==="manifest")return e.push(`<link rel="manifest" href="${h(s)}">`),e;if(n==="favicon"||n==="favicons"||n==="icon"||n==="icons")return(Array.isArray(s)?s:[s]).forEach(f=>{if(typeof f=="string")e.push(`<link rel="icon" href="${h(f)}">`);else if(typeof f=="object"){const a=w(f);/rel=/.test(a)?e.push(`<link ${a}>`):e.push(`<link rel="icon" ${a}>`)}}),e;if(n==="alternate")return(Array.isArray(s)?s:[s]).forEach(f=>{if(typeof f=="object"){const a=Object.entries(f).filter(([t,u])=>u!==void 0).map(([t,u])=>`${t}="${h(u)}"`).join(" ");e.push(`<link rel="alternate" ${a}>`)}}),e;const p=(c,f,a="name")=>{if(typeof f=="string"||typeof f=="number"||typeof f=="boolean")e.push(`<meta ${a}="${h(c)}" content="${h(f)}">`);else if(Array.isArray(f))f.forEach(t=>{if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")e.push(`<meta ${a}="${h(c)}" content="${h(t)}">`);else if(typeof t=="object"){const u=Object.entries(t).filter(([m,l])=>l!==void 0).map(([m,l])=>`${m}="${h(l)}"`).join(" ");e.push(`<meta ${u}>`)}});else if(typeof f=="object"){const t=Object.entries(f).filter(([u,m])=>m!==void 0).map(([u,m])=>`${u}="${h(m)}"`).join(" ");e.push(`<meta ${t}>`)}};if(n.startsWith("http-equiv:")){const c=n.replace("http-equiv:","");return p(c,s,"http-equiv"),e}if(n.startsWith("itemprop:")){const c=n.replace("itemprop:","");return p(c,s,"itemprop"),e}const g=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(c=>n.startsWith(c));if(g){const c=n.replace(g,"");return p(`${g.replace(":","")}:${c}`,s,g==="twitter:"||g==="DC:"||g==="DCTERMS:"?"name":"property"),e}if(n.startsWith("apple:")||n.startsWith("msapplication:")){const c=n.startsWith("apple:")?"apple-":"msapplication-",f=n.replace(/^apple:|^msapplication:/,"");return p(`${c}${f}`,s,"name"),e}return p(n,s),e},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']).join(`
|
|
2
|
+
`)),O=i=>typeof i=="string"&&i.length>0&&!i.startsWith("/")&&!i.startsWith("http");function L(i,o){if(!o||typeof o!="object")return i;const r=n=>{if(!O(n))return n;const s=o[n];return s?.src?s.src:n},e={...i};for(const[n,s]of Object.entries(e))typeof s=="string"?e[n]=r(s):Array.isArray(s)&&(e[n]=s.map(p=>typeof p=="string"?r(p):p));return e}function y(i,o){if(!i||!o)return;const r=o.split(".");let e=i;for(const n of r){if(e==null||typeof e!="object")return;e=e[n]}return e}function S(i,o,r){const n=(o.config||o.settings||{}).polyglot||o.polyglot,s=r?.lang||n?.defaultLang||"en",d=(n?.translations||{})[s]||{},g=r?.state||{},c={...i};for(const[f,a]of Object.entries(c))typeof a!="string"||!a.includes("{{")||(c[f]=a.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(t,u,m)=>{const l=u.trim();if(m==="polyglot")return d[l]??y(d,l)??t;if(m==="getLocalStateLang")return y(g,l+s)??t;const $=y(g,l);return $!==void 0?$:d[l]??y(d,l)??t}));return c}function j(i){const o={...i};for(const[r,e]of Object.entries(o))if(typeof e=="function"){const n=e.toString(),s=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){o[r]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const p=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(p){o[r]=`{{ ${p[1]} | polyglot }}`;continue}const d=n.match(/s\.(\w+(?:\.\w+)+)/);if(d){o[r]=`{{ ${d[1]} }}`;continue}delete o[r]}else if(typeof e=="string"){const n=e.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(n){o[r]=`{{ ${n[1]} | getLocalStateLang }}`;continue}const s=e.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){o[r]=`{{ ${s[1]} | polyglot }}`;continue}if(e.includes("=>")&&e.includes("s.")){const p=e.match(/s\.(\w+(?:\.\w+)+)/);if(p){o[r]=`{{ ${p[1]} }}`;continue}}}return o}function E(i,o,r,{isProduction:e=!1,channel:n="production"}={}){const s=i.pages?.[o],p=M(s?.state)&&s?.state,d=s?.metadata||s?.helmet||p||{},g=j(d),c=new Set(Object.keys(g)),f=i.app?.metadata||{},a=j(f);let t={};if(i.integrations?.seo?t={...i.integrations.seo,...a,...g}:Object.keys(a).length?t={...a,...g}:t={...g},!t.title){const l=i.name||i.key;l?e?t.title=l:n==="development"?t.title=`${l} / dev:symbo.ls`:n==="staging"?t.title=`${l} / staging:symbo.ls`:t.title=`${l} / symbo.ls`:t.title="Symbols demo"}t=S(t,i,r),t.title&&(c.has("title")||!t["og:title"])&&(c.has("og:title")||(t["og:title"]=t.title)),t.description&&(c.has("description")||!t["og:description"])&&(c.has("og:description")||(t["og:description"]=t.description)),t.title&&!t["twitter:title"]&&(t["twitter:title"]=t.title),t.description&&!t["twitter:description"]&&(t["twitter:description"]=t.description);const u=r?.actualPathname||o;if(t["og:url"]||t.url){const l=(t["og:url"]||t.url||"").replace(/\/$/,"");if(l&&u&&u!=="/"){const $=u.startsWith("/")?u:"/"+u;t["og:url"]=l+$}}t=L(t,i.files);const m=i.name||i.app?.metadata?.title||i.app?.name||"";for(const[l,$]of Object.entries(t))if(typeof $=="string"&&$.includes("{{")){const b=$.replace(/\{\{[^}]*\}\}/g,"").trim();b?t[l]=b:l==="title"?t[l]=m:delete t[l]}return t}export{W as generateMetaTags,E as getPageMetadata};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import{window as
|
|
2
|
-
`;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let
|
|
3
|
-
`;for(const
|
|
4
|
-
`:
|
|
5
|
-
`:n+=`${s} ${
|
|
6
|
-
`;n+=`${s} ]`}else w(i)?n+=N(i,t+1):
|
|
1
|
+
import{window as x}from"./globals.js";import{isFunction as $,isObjectLike as w,isObject as S,isArray as O,isString as P,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 E="production",_=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,v=(e,t,r,s)=>{if($(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&(O(e)||S(e)&&!g(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return v(i,t,r,s)}}return e},ne=(e,t,r)=>{for(const s in t)e[s]=v(t[s],r)},re=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(_(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},oe=(e,t,r=L)=>A(e,t,r,null),A=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||_(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],c=t[o];if(w(i)&&w(c)){const l=s||[];l.push(e,t),A(i,c,r,l),l.length-=2}else i===void 0&&(e[o]=c)}return e},se=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},ie=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!w(e)||g(e))return e;if(o.has(e))return o.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,l=p=>c?c.has(p):r.includes(p),f=O(e)?[]:{};o.set(e,f);const a=[[e,f]];for(;a.length;){const[p,h]=a.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||_(y)||y==="__proto__"||l(y))continue;const u=p[y];if(!(s&&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($(u)){h[y]=u;continue}if(w(u))if(o.has(u))h[y]=o.get(u);else{const d=O(u)?[]:{};o.set(u,d),h[y]=d,a.push([u,d])}else h[y]=u}}}return f},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 s=e[r];if($(s))t[r]=s.toString();else if(S(s))t[r]={},T(s,t[r]);else if(O(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];S(i)?(n[o]={},T(i,n[o])):$(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},W=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),N=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
|
|
2
|
+
`;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let c=!1;for(let f=0;f<o.length;f++)if(W.has(o[f])){c=!0;break}const l=c?`'${o}'`:o;if(n+=`${s} ${l}: `,O(i)){n+=`[
|
|
3
|
+
`;for(const f of i)w(f)&&f!==null?n+=`${s} ${N(f,t+2)},
|
|
4
|
+
`:P(f)?n+=`${s} '${f}',
|
|
5
|
+
`:n+=`${s} ${f},
|
|
6
|
+
`;n+=`${s} ]`}else w(i)?n+=N(i,t+1):P(i)?n+=R(i,[`
|
|
7
7
|
`,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
|
|
8
|
-
`}return n+=`${s}}`,n},
|
|
9
|
-
`,o);o=h===-1?l:h;continue}if(p==="/"&&e[o+1]==="*"){const h=e.indexOf("*/",o+2);o=h===-1?l:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(o++;o<l;){if(e[o]==="\\"){o+=2;continue}if(e[o]===h){o++;break}if(h==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let y=1;for(;o<l&&y>0;)e[o]==="{"?y++:e[o]==="}"&&y--,o++;continue}o++}continue}if(p==="{"){i++,o++;continue}if(p==="}"){i--,o++;continue}if(i===1&&
|
|
10
|
-
`)){u++;break}u++}n.push([h,u]),o=u;continue}o++}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},
|
|
11
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},ce=(e,t={},r={window:{eval:
|
|
12
|
-
`);
|
|
13
|
-
|
|
8
|
+
`}return n+=`${s}}`,n},b=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],F=/^["[{]/,J=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||J.test(t)||!b.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||F.test(t)&&!n)},q=e=>(0,eval)(e),B=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,c=null;const l=e.length,f=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<l&&i>0;){const p=e[o];if(p==="/"&&e[o+1]==="/"){const h=e.indexOf(`
|
|
9
|
+
`,o);o=h===-1?l:h;continue}if(p==="/"&&e[o+1]==="*"){const h=e.indexOf("*/",o+2);o=h===-1?l:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(o++;o<l;){if(e[o]==="\\"){o+=2;continue}if(e[o]===h){o++;break}if(h==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let y=1;for(;o<l&&y>0;)e[o]==="{"?y++:e[o]==="}"&&y--,o++;continue}o++}continue}if(p==="{"){i++,o++;continue}if(p==="}"){i--,o++;continue}if(i===1&&f.test(e.slice(o))){const h=o;let y=0,u=o;for(;u<l;){const d=e[u];if(d==='"'||d==="'"||d==="`"){const C=d;for(u++;u<l;){if(e[u]==="\\"){u+=2;continue}if(e[u]===C){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]),o=u;continue}o++}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},D=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),c=/Identifier '([^']+)' has already been declared/.exec(o);let l=null;if(i){const f=String(e).trim();if(/^function[\s(]/.test(f))try{l=r.window.eval("(async "+f+")")}catch{}}else if(c){let f=String(e),a=c[1];for(let p=0;p<5;p++){const h=B(f,a);if(!h||h===f)break;f=h;try{l=r.window.eval("("+f+")");break}catch(y){const u=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!u||u[1]!==a)break}}}return l||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
|
|
11
|
+
First 200 chars of source: `+String(e).slice(0,200)),e)}},ce=(e,t={},r={window:{eval:q}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if(P(c))k(c)?o[i]=D(c,`"${i}"`,r):o[i]=c;else if(O(c)){const l=o[i]=[];for(let f=0;f<c.length;f++){const a=c[f];if(P(a))l.push(k(a)?D(a,`array index ${f} (prop "${i}")`,r):a);else if(S(a)){const p={};l.push(p),s.push([a,p])}else l.push(a)}}else if(S(c)){const l=o[i]&&typeof o[i]=="object"&&!O(o[i])?o[i]:o[i]={};s.push([c,l])}else o[i]=c}}return t},G="Set",H="Map",m=e=>!e||typeof e!="object"?e:e.__type===G&&Array.isArray(e.values)?new Set(e.values):e.__type===H&&Array.isArray(e.entries)?new Map(e.entries):e,fe=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const c=e[i];P(c)&&k(c)?r.push([i,c]):t[i]=m(c)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
|
|
12
|
+
`);try{const i=n.map(([f,a])=>`var ${f} = (${a});`).join(`
|
|
13
|
+
`),c="{ "+n.map(([f])=>`${JSON.stringify(f)}: ${f}`).join(", ")+" }",l=x.eval(`(function(__gs__) { ${o}
|
|
14
|
+
${i}
|
|
15
|
+
return ${c}; })`)(t);Object.assign(t,l)}catch{for(const[c,l]of n)try{const f=Object.keys(t).filter(s).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
|
|
16
|
+
`);t[c]=x.eval(`(function(__gs__) { ${f}
|
|
17
|
+
return (${l}); })`)(t)}catch{try{t[c]=x.eval(`(${l})`)}catch{t[c]=l}}}for(const[i,c]of r)if(!s(i))try{t[i]=x.eval(`(${c})`)}catch{t[i]=c}return t},le=(e,t={verbose:!0})=>{try{return e?x.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},ue=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),z=e=>{for(const t in e)return!1;return!0},ae=e=>S(e)&&z(e),pe=()=>Object.create(null),ye=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&_(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},he=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)_(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},U=(e,t,r={},s=new WeakMap)=>{if(!w(e)||!w(t)||g(e)||g(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||o&&o.has(c)||i&&_(c)||c==="constructor"||c==="prototype")continue;const l=e[c],f=t[c];g(f)?e[c]=f:w(l)&&w(f)?e[c]=U(l,f,r,s):f!==void 0&&(e[c]=f)}return e},V=(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 s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!V(e[i],t[i],r))return!1}return!0},Z=new Set(["node","__ref"]),de=(e,t,r=Z)=>{if(e===t)return!0;if(!w(e)||!w(t)||g(e)||g(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,c){if(n.has(c))return!0;n.add(c);for(const l in c){if(!Object.prototype.hasOwnProperty.call(c,l)||s.has(l))continue;if(!Object.prototype.hasOwnProperty.call(i,l))return!1;const f=c[l],a=i[l];if(g(f)||g(a)){if(f!==a)return!1}else if(w(f)&&w(a)){if(!o(a,f))return!1}else if(f!==a)return!1}return!0}return o(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},K=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]=K(e[r]));return t},ge=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[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 s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},_e=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[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 s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},xe=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(E==="test"||E==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Pe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},$e=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};export{se as clone,ge as createNestedObject,K as createObjectWithoutPrototype,ie as deepClone,de as deepContains,ce as deepDestringifyFunctions,oe as deepMerge,T as deepStringifyFunctions,fe as destringifyGlobalScope,xe as detectInfiniteLoop,$e as excludeKeysFromObject,v as exec,Se as getInObjectByPath,k as hasFunction,ue as hasOwnProperty,Pe as isCyclic,z as isEmpty,ae as isEmptyObject,V as isEqualDeep,pe as makeObjectWithoutPrototype,ne as map,re as merge,N as objectToString,ye as overwrite,U as overwriteDeep,he as overwriteShallow,we as removeFromObject,Oe as removeNestedKeyByPath,_e as setInObjectByPath,le as stringToObject};
|
package/metadata.js
CHANGED
|
@@ -142,7 +142,9 @@ export const generateMetaTags = (metadata, isProduction) => {
|
|
|
142
142
|
},
|
|
143
143
|
[
|
|
144
144
|
'<meta charset="UTF-8">',
|
|
145
|
-
|
|
145
|
+
// Never disable pinch-zoom by default (user-scalable=no / maximum-scale=1
|
|
146
|
+
// is a WCAG 1.4.4 violation); apps that truly need it can override.
|
|
147
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">'
|
|
146
148
|
]
|
|
147
149
|
)
|
|
148
150
|
|
package/object.js
CHANGED
|
@@ -658,26 +658,62 @@ export const destringifyGlobalScope = (gs) => {
|
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
661
|
+
if (fnEntries.length === 0) return result
|
|
662
|
+
|
|
663
|
+
// globalScope keys are free-variable names → valid identifiers, so they're
|
|
664
|
+
// safe to use as `var` names. Guard anyway: a stray non-identifier key would
|
|
665
|
+
// make the generated `var <key>` a syntax error and take down the whole block.
|
|
666
|
+
const isIdent = (k) => /^[A-Za-z_$][\w$]*$/.test(k)
|
|
667
|
+
const identFns = fnEntries.filter(([k]) => isIdent(k))
|
|
668
|
+
const constDecls = Object.keys(result)
|
|
669
|
+
.filter(isIdent)
|
|
670
|
+
.map((k) => `var ${k} = __gs__[${JSON.stringify(k)}];`)
|
|
671
|
+
.join('\n')
|
|
672
|
+
|
|
673
|
+
// Second pass: eval ALL helper functions together in ONE shared closure so a
|
|
674
|
+
// helper can reference ANY other helper (or constant) regardless of the order
|
|
675
|
+
// they happen to appear in `gs`. The previous per-function loop declared only
|
|
676
|
+
// the entries eval'd BEFORE the current one (`Object.keys(result)` so far), so
|
|
677
|
+
// a helper calling a LATER-ordered helper — e.g. `ck()` → `chatScopeOf()` —
|
|
678
|
+
// threw `ReferenceError: chatScopeOf is not defined` in brender/serialized
|
|
679
|
+
// consumers. Declaring every helper as a sibling `var` in one scope makes
|
|
680
|
+
// cross-helper chains resolve by hoisting — the behaviour this function's
|
|
681
|
+
// contract has always promised. Function BODIES run at call time (after the
|
|
682
|
+
// closure returns), so declaration order among the helpers is irrelevant.
|
|
683
|
+
try {
|
|
684
|
+
const fnDecls = identFns.map(([k, fnStr]) => `var ${k} = (${fnStr});`).join('\n')
|
|
685
|
+
const ret = '{ ' + identFns.map(([k]) => `${JSON.stringify(k)}: ${k}`).join(', ') + ' }'
|
|
686
|
+
const built = window.eval(
|
|
687
|
+
`(function(__gs__) { ${constDecls}\n${fnDecls}\n return ${ret}; })`
|
|
688
|
+
)(result)
|
|
689
|
+
Object.assign(result, built)
|
|
690
|
+
} catch (e) {
|
|
691
|
+
// A single malformed helper string can take down the combined block; fall
|
|
692
|
+
// back to the original per-function eval so one bad entry can't break every
|
|
693
|
+
// helper (order-dependence returns for THIS project, but nothing regresses
|
|
694
|
+
// vs. the prior behaviour).
|
|
695
|
+
for (const [key, fnStr] of identFns) {
|
|
673
696
|
try {
|
|
674
|
-
|
|
697
|
+
const varDecls = Object.keys(result)
|
|
698
|
+
.filter(isIdent)
|
|
699
|
+
.map((k) => `var ${k} = __gs__[${JSON.stringify(k)}];`)
|
|
700
|
+
.join('\n')
|
|
701
|
+
result[key] = window.eval(
|
|
702
|
+
`(function(__gs__) { ${varDecls}\n return (${fnStr}); })`
|
|
703
|
+
)(result)
|
|
675
704
|
} catch (_) {
|
|
676
|
-
result[key] = fnStr
|
|
705
|
+
try { result[key] = window.eval(`(${fnStr})`) } catch (__) { result[key] = fnStr }
|
|
677
706
|
}
|
|
678
707
|
}
|
|
679
708
|
}
|
|
680
709
|
|
|
710
|
+
// Defensive: any non-identifier-keyed function entries (shouldn't occur) —
|
|
711
|
+
// eval standalone, matching the original best-effort behaviour.
|
|
712
|
+
for (const [key, fnStr] of fnEntries) {
|
|
713
|
+
if (isIdent(key)) continue
|
|
714
|
+
try { result[key] = window.eval(`(${fnStr})`) } catch (_) { result[key] = fnStr }
|
|
715
|
+
}
|
|
716
|
+
|
|
681
717
|
return result
|
|
682
718
|
}
|
|
683
719
|
|