@symbo.ls/utils 3.14.780 → 3.14.782
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/dist/cjs/metadata.js +2 -2
- package/dist/cjs/object.js +12 -12
- package/dist/esm/metadata.js +1 -1
- package/dist/esm/object.js +13 -13
- package/metadata.js +7 -2
- package/object.js +42 -6
- package/package.json +1 -1
package/dist/cjs/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var
|
|
2
|
-
`)},
|
|
1
|
+
"use strict";var j=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var D=(e,s)=>{for(var t in s)j(e,t,{get:s[t],enumerable:!0})},P=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of T(s))!F.call(e,r)&&r!==t&&j(e,r,{get:()=>s[r],enumerable:!(n=x(s,r))||n.enumerable});return e};var R=e=>P(j({},"__esModule",{value:!0}),e);var Y={};D(Y,{fileEntryUrl:()=>E,generateHeadArrayTags:()=>L,generateMetaTags:()=>q,getPageMetadata:()=>N,hashContent:()=>b,resolveFileReferences:()=>W});module.exports=R(Y);var w=require("./types.js"),M=require("./function.js");const g=e=>{if(e==null)return"";const s={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.toString().replace(/[&<>"']/g,t=>s[t])},U=e=>Object.entries(e||{}).filter(([s,t])=>t!==void 0).map(([s,t])=>`${s}="${g(t)}"`).join(" "),b=e=>{let s=5381;const t=String(e);for(let n=0;n<t.length;n++)s=(s*33^t.charCodeAt(n))>>>0;return s.toString(36)},_=new Set(["jsonLd","styles","scripts"]),L=e=>{const s=[];if(Array.isArray(e.jsonLd))for(const t of e.jsonLd){if(t==null)continue;const n=typeof t=="string"?t:JSON.stringify(t),r=String(n).replace(/<\/script/gi,"<\\/script");s.push(`<script type="application/ld+json" data-smbls-jsonld="${b(n)}">${r}<\/script>`)}if(Array.isArray(e.styles))for(const t of e.styles){if(t==null||!String(t).trim())continue;const n=String(t).replace(/<\/style/gi,"<\\/style");s.push(`<style data-smbls-style="${b(n)}">${n}</style>`)}if(Array.isArray(e.scripts))for(const t of e.scripts){if(!t)continue;const n=typeof t=="string",r=n?t:t.src;if(!r&&!t.body)continue;const o=[];r&&o.push(`src="${g(r)}"`),n||(t.type&&o.push(`type="${g(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${g(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${g(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${g(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${g(r||b(t.body||""))}"`;if(!n&&t.body){const h=String(t.body).replace(/<\/script/gi,"<\\/script");s.push(`<script ${o.join(" ")}${l}>${h}<\/script>`)}else s.push(`<script ${o.join(" ")}${l}><\/script>`)}return s},q=(e,s)=>{s||(e={...e,robots:"noindex"});const t=Object.entries(e).reduce((n,[r,o])=>{if(!o&&o!==0&&o!==!1||_.has(r))return n;if(r==="title")return n.push(`<title>${g(o)}</title>`),n;if(r==="canonical")return n.push(`<link rel="canonical" href="${g(o)}">`),n;if(r==="manifest")return n.push(`<link rel="manifest" href="${g(o)}">`),n;if(r==="favicon"||r==="favicons"||r==="icon"||r==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{if(typeof c=="string")n.push(`<link rel="icon" href="${g(c)}">`);else if(typeof c=="object"){const u=U(c);/rel=/.test(u)?n.push(`<link ${u}>`):n.push(`<link rel="icon" ${u}>`)}}),n;if(r==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(typeof c=="object"){const u=Object.entries(c).filter(([i,p])=>p!==void 0).map(([i,p])=>`${i}="${g(p)}"`).join(" ");n.push(`<link rel="alternate" ${u}>`)}}),n;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`<meta ${u}="${g(f)}" content="${g(c)}">`);else if(Array.isArray(c))c.forEach(i=>{if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")n.push(`<meta ${u}="${g(f)}" content="${g(i)}">`);else if(typeof i=="object"){const p=Object.entries(i).filter(([m,a])=>a!==void 0).map(([m,a])=>`${m}="${g(a)}"`).join(" ");n.push(`<meta ${p}>`)}});else if(typeof c=="object"){const i=Object.entries(c).filter(([p,m])=>m!==void 0).map(([p,m])=>`${p}="${g(m)}"`).join(" ");n.push(`<meta ${i}>`)}};if(r.startsWith("http-equiv:")){const f=r.replace("http-equiv:","");return l(f,o,"http-equiv"),n}if(r.startsWith("itemprop:")){const f=r.replace("itemprop:","");return l(f,o,"itemprop"),n}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>r.startsWith(f));if(y){const f=r.replace(y,"");return l(`${y.replace(":","")}:${f}`,o,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),n}if(r.startsWith("apple:")||r.startsWith("msapplication:")){const f=r.startsWith("apple:")?"apple-":"msapplication-",c=r.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),n}return l(r,o),n},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...L(e)),t.join(`
|
|
2
|
+
`)},K=e=>typeof e=="string"&&e.length>0&&!e.startsWith("/")&&!e.startsWith("http"),S=e=>typeof e=="string"&&e.length>0,E=e=>{if(!e||typeof e!="object")return null;if(S(e.src))return e.src;const s=e.content;return!s||typeof s!="object"?null:S(s.src)?s.src:S(s.storageUrl)?s.storageUrl:null};function W(e,s){if(!s||typeof s!="object")return e;const t=r=>!K(r)||!Object.prototype.hasOwnProperty.call(s,r)?r:E(s[r])||r,n={...e};for(const[r,o]of Object.entries(n))typeof o=="string"?n[r]=t(o):Array.isArray(o)&&(n[r]=o.map(l=>typeof l=="string"?t(l):l));return n}function A(e,s){if(!e||!s)return;const t=s.split(".");let n=e;for(const r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function C(e,s){const t=A(e,s);if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&!(0,M.isStringFunction)(t))return t}function H(e,s,t){const r=(s.config||s.settings||{}).polyglot||s.polyglot,o=t?.lang||r?.defaultLang||"en",h=(r?.translations||{})[o]||{},y=[t?.state,s.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const i of y){const p=C(i,u);if(p!==void 0)return p}},c={...e};for(const[u,i]of Object.entries(c))typeof i!="string"||!i.includes("{{")||(c[u]=i.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(p,m,a)=>{const d=m.trim();if(a==="polyglot")return h[d]??A(h,d)??p;if(a==="getLocalStateLang")return f(d+o)??p;const $=f(d);return $!==void 0?$:h[d]??A(h,d)??p}));return c}function O(e){if(!(0,w.isObject)(e))return{};const s={...e};for(const[t,n]of Object.entries(s))if(typeof n=="function"){const r=n.toString(),o=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){s[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){s[t]=`{{ ${l[1]} | polyglot }}`;continue}const h=r.match(/s\.(\w+(?:\.\w+)+)/);if(h){s[t]=`{{ ${h[1]} }}`;continue}delete s[t]}else if(typeof n=="string"){const r=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(r){s[t]=`{{ ${r[1]} | getLocalStateLang }}`;continue}const o=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){s[t]=`{{ ${o[1]} | polyglot }}`;continue}if(n.includes("=>")&&n.includes("s.")){const l=n.match(/s\.(\w+(?:\.\w+)+)/);if(l){s[t]=`{{ ${l[1]} }}`;continue}}(0,M.isStringFunction)(n)&&delete s[t]}return s}function N(e,s,t,{isProduction:n=!1,channel:r="production"}={}){const o=e.pages?.[s],l=(0,w.isObject)(o?.state)&&o?.state,h=o?.metadata||o?.helmet||l||{},y=O(h),f=new Set(Object.keys(y)),c=e.app?.metadata||{},u=O(c);let i={};if(e.integrations?.seo?i={...e.integrations.seo,...u,...y}:Object.keys(u).length?i={...u,...y}:i={...y},!i.title){const a=e.name||e.key;a?n?i.title=a:r==="development"?i.title=`${a} / dev:symbo.ls`:r==="staging"?i.title=`${a} / staging:symbo.ls`:i.title=`${a} / symbo.ls`:i.title="Symbols demo"}i=H(i,e,t),i.title&&(f.has("title")||!i["og:title"])&&(f.has("og:title")||(i["og:title"]=i.title)),i.description&&(f.has("description")||!i["og:description"])&&(f.has("og:description")||(i["og:description"]=i.description)),i.title&&!i["twitter:title"]&&(i["twitter:title"]=i.title),i.description&&!i["twitter:description"]&&(i["twitter:description"]=i.description);const p=t?.actualPathname||s;if(i["og:url"]||i.url){const a=(i["og:url"]||i.url||"").replace(/\/$/,"");if(a&&p&&p!=="/"){const d=p.startsWith("/")?p:"/"+p;i["og:url"]=a+d}}i=W(i,e.files);const m=e.name||e.app?.metadata?.title||e.app?.name||"";for(const[a,d]of Object.entries(i))if(typeof d=="string"&&d.includes("{{")){const $=d.replace(/\{\{[^}]*\}\}/g,"").trim();$?i[a]=$:a==="title"?i[a]=m:delete i[a]}return i}
|
package/dist/cjs/object.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var
|
|
2
|
-
`,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},
|
|
3
|
-
`;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],u=
|
|
1
|
+
"use strict";var P=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ce(t))!se.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=ie(t,r))||o.enumerable});return e};var ue=e=>le(P({},"__esModule",{value:!0}),e);var it={};fe(it,{REVIVED_MARK:()=>C,clone:()=>de,createNestedObject:()=>Qe,createObjectWithoutPrototype:()=>oe,deepClone:()=>he,deepContains:()=>Je,deepDestringifyFunctions:()=>Me,deepMerge:()=>ye,deepStringifyFunctions:()=>N,destringifyGlobalScope:()=>Ze,detectInfiniteLoop:()=>nt,excludeKeysFromObject:()=>ot,exec:()=>R,getFunctionSource:()=>me,getInObjectByPath:()=>tt,hasFunction:()=>k,hasOwnProperty:()=>He,isCyclic:()=>rt,isEmpty:()=>te,isEmptyObject:()=>Ke,isEqualDeep:()=>re,isFailedRevival:()=>be,isLazyFunction:()=>Le,isRevived:()=>Ye,isStringTag:()=>We,makeObjectWithoutPrototype:()=>Be,map:()=>ae,markRevived:()=>ee,merge:()=>pe,objectToString:()=>D,overwrite:()=>Ue,overwriteDeep:()=>ne,overwriteShallow:()=>qe,removeFromObject:()=>Xe,removeNestedKeyByPath:()=>je,setInObjectByPath:()=>et,stringToObject:()=>Ge});module.exports=ue(it);var S=require("./globals.js"),l=require("./types.js"),X=require("./array.js"),Q=require("./string.js"),_=require("./node.js"),j=require("./keys.js");const z="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,R=(e,t,n,o)=>{if((0,l.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,n||t.state,o||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,l.isArray)(e)||(0,l.isObject)(e)&&!(0,_.isDOMNode)(e))){const r=t.context.plugins;for(const i of r)if(i.resolveHandler){const c=i.resolveHandler(e,t);if(typeof c=="function")return R(c,t,n,o)}}return e},ae=(e,t,n)=>{for(const o in t)e[o]=R(t[o],n)},pe=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(w(r)||(o?n.has(r):n.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},ye=(e,t,n=j.METHODS_EXL)=>L(e,t,n,null),L=(e,t,n,o)=>{if(e===t)return e;if(o){for(let i=0;i<o.length;i+=2)if(o[i]===e&&o[i+1]===t)return e}const r=n instanceof Set;for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||w(i)||i==="constructor"||i==="prototype"||(r?n.has(i):n.includes(i)))continue;const c=e[i],u=t[i];if((0,l.isObjectLike)(c)&&(0,l.isObjectLike)(u)){const s=o||[];s.push(e,t),L(c,u,n,s),s.length-=2}else c===void 0&&(e[i]=u)}return e},de=(e,t=[])=>{const n=t instanceof Set,o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(w(r)||(n?t.has(r):t.includes(r))||(o[r]=e[r]));return o},he=(e,t={})=>{const{exclude:n=[],cleanUndefined:o=!1,cleanNull:r=!1,visited:i=new WeakMap,handleExtends:c=!1}=t;if(!(0,l.isObjectLike)(e)||(0,_.isDOMNode)(e))return e;if(i.has(e))return i.get(e);const u=n instanceof Set?n:n.length>3?new Set(n):null,s=a=>u?u.has(a):n.includes(a),y=(0,l.isArray)(e)?[]:{};i.set(e,y);const f=[[e,y]];for(;f.length;){const[a,g]=f.pop();for(const d in a){if(!Object.prototype.hasOwnProperty.call(a,d)||w(d)||d==="__proto__"||s(d))continue;const p=a[d];if(!(o&&p===void 0)&&!(r&&p===null)){if((0,_.isDOMNode)(p)){g[d]=p;continue}if(c&&d==="extends"&&(0,l.isArray)(p)){g[d]=(0,X.unstackArrayOfObjects)(p,n);continue}if((0,l.isFunction)(p)){g[d]=p;continue}if((0,l.isObjectLike)(p))if(i.has(p))g[d]=i.get(p);else{const h=(0,l.isArray)(p)?[]:{};i.set(p,h),g[d]=h,f.push([p,h])}else g[d]=p}}}return y},N=(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 n in e){const o=e[n];if((0,l.isFunction)(o))t[n]=o.toString();else if((0,l.isObject)(o))t[n]={},N(o,t[n]);else if((0,l.isArray)(o)){const r=t[n]=[];for(let i=0;i<o.length;i++){const c=o[i];(0,l.isObject)(c)?(r[i]={},N(c,r[i])):(0,l.isFunction)(c)?r[i]=c.toString():r[i]=c}}else t[n]=o}return t},ge=/^[A-Za-z_$][A-Za-z0-9_$]*$/,_e=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,m=e=>{const t=String(e);return(0,Q.stringIncludesAny)(t,[`
|
|
2
|
+
`,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},D=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let n=!1;for(const i in e){n=!0;break}if(!n)return"{}";const o=" ".repeat(t);let r=`{
|
|
3
|
+
`;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],u=ge.test(i)?i:_e(i);if(r+=`${o} ${u}: `,c instanceof RegExp)r+=String(c);else if((0,l.isArray)(c)){r+=`[
|
|
4
4
|
`;for(const s of c)s instanceof RegExp?r+=`${o} ${String(s)},
|
|
5
|
-
`:(0,l.isObjectLike)(s)&&s!==null?r+=`${o} ${
|
|
6
|
-
`:(0,l.isString)(s)?r+=`${o} ${
|
|
5
|
+
`:(0,l.isObjectLike)(s)&&s!==null?r+=`${o} ${D(s,t+2)},
|
|
6
|
+
`:(0,l.isString)(s)?r+=`${o} ${m(s)},
|
|
7
7
|
`:r+=`${o} ${s},
|
|
8
|
-
`;r+=`${o} ]`}else(0,l.isObjectLike)(c)?r+=
|
|
9
|
-
`}return r+=`${o}}`,r},
|
|
10
|
-
`,i);i=g===-1?s:g;continue}if(a==="/"&&e[i+1]==="*"){const g=e.indexOf("*/",i+2);i=g===-1?s:g+2;continue}if(a==='"'||a==="'"||a==="`"){const g=a;for(i++;i<s;){if(e[i]==="\\"){i+=2;continue}if(e[i]===g){i++;break}if(g==="`"&&e[i]==="$"&&e[i+1]==="{"){i+=2;let d=1;for(;i<s&&d>0;)e[i]==="{"?d++:e[i]==="}"&&d--,i++;continue}i++}continue}if(a==="{"){c++,i++;continue}if(a==="}"){c--,i++;continue}if(c===1&&y.test(e.slice(i))){const g=i;let d=0,p=i;for(;p<s;){const h=e[p];if(h==='"'||h==="'"||h==="`"){const
|
|
11
|
-
`)){p++;break}p++}r.push([g,p]),i=p;continue}i++}if(!r.length)return null;let f=e;for(let a=r.length-1;a>=0;a--)f=f.slice(0,r[a][0])+f.slice(r[a][1]);return f},
|
|
12
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},F=1,T=2,O=new WeakMap,
|
|
13
|
-
First 200 chars of source: `+String(e.src).slice(0,200))),e.fn=n,e.opts=null,n},
|
|
8
|
+
`;r+=`${o} ]`}else(0,l.isObjectLike)(c)?r+=D(c,t+1):(0,l.isString)(c)?r+=m(c):r+=c;r+=`,
|
|
9
|
+
`}return r+=`${o}}`,r},we=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],Oe=/^["[{]/,Se=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim();if(t===""||t==="{}"||t==="[]")return!1;const n=t.includes("=>");if(!n&&t.charCodeAt(0)!==40&&!t.startsWith("function")&&!t.startsWith("async")&&!(t.charCodeAt(t.length-1)===125&&t.includes("("))||Se.test(t)||!we.some(i=>i.test(t)))return!1;const r=t.charCodeAt(0);return!(r===123&&!n||r===91||Oe.test(t)&&!n)},b=e=>(0,eval)(e),Ee=(e,t)=>{const n=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!n)return null;const o=n[0].length,r=[];let i=o,c=1,u=null;const s=e.length,y=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;i<s&&c>0;){const a=e[i];if(a==="/"&&e[i+1]==="/"){const g=e.indexOf(`
|
|
10
|
+
`,i);i=g===-1?s:g;continue}if(a==="/"&&e[i+1]==="*"){const g=e.indexOf("*/",i+2);i=g===-1?s:g+2;continue}if(a==='"'||a==="'"||a==="`"){const g=a;for(i++;i<s;){if(e[i]==="\\"){i+=2;continue}if(e[i]===g){i++;break}if(g==="`"&&e[i]==="$"&&e[i+1]==="{"){i+=2;let d=1;for(;i<s&&d>0;)e[i]==="{"?d++:e[i]==="}"&&d--,i++;continue}i++}continue}if(a==="{"){c++,i++;continue}if(a==="}"){c--,i++;continue}if(c===1&&y.test(e.slice(i))){const g=i;let d=0,p=i;for(;p<s;){const h=e[p];if(h==='"'||h==="'"||h==="`"){const x=h;for(p++;p<s;){if(e[p]==="\\"){p+=2;continue}if(e[p]===x){p++;break}p++}continue}if(h==="("||h==="["||h==="{"){d++,p++;continue}if(h===")"||h==="]"||h==="}"){if(d===0)break;d--,p++;continue}if(d===0&&(h===";"||h===`
|
|
11
|
+
`)){p++;break}p++}r.push([g,p]),i=p;continue}i++}if(!r.length)return null;let f=e;for(let a=r.length-1;a>=0;a--)f=f.slice(0,r[a][0])+f.slice(r[a][1]);return f},A=(e,t,n,o)=>{const r=String(e).trimStart();if(/^(export|import)\s/.test(r))return e;try{return n.window.eval(`(${e})`)}catch(i){const c=i&&i.message?i.message:String(i),u=/await is only valid in async/.test(c),s=/Identifier '([^']+)' has already been declared/.exec(c);let y=null;if(u){const f=String(e).trim();if(/^function[\s(]/.test(f))try{y=n.window.eval("(async "+f+")")}catch{}}else if(s){let f=String(e),a=s[1];for(let g=0;g<5;g++){const d=Ee(f,a);if(!d||d===f)break;f=d;try{y=n.window.eval("("+f+")");break}catch(p){const h=/Identifier '([^']+)' has already been declared/.exec(p&&p.message||String(p));if(!h||h[1]!==a)break}}}if(!y&&/Unexpected (token '\{'|identifier)/.test(c))try{const f=n.window.eval("({"+e+"})");if(f&&typeof f=="object"){const a=Object.keys(f);a.length===1&&typeof f[a[0]]=="function"&&(y=f[a[0]])}}catch{}return y||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 `+(o?"revived lazily, so its source compiled on this first use; it acts as the string it replaces (a call returns the source text, el.call treats it as not callable). Reason: ":"value will be left as a string. Reason: ")+c+`.
|
|
12
|
+
First 200 chars of source: `+String(e).slice(0,200)),e)}},F=1,T=2,O=new WeakMap,xe=/^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,Ae=/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/,$e=/^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/,ke=/^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,Pe=new Set(["if","for","while","switch","catch","with","do","return","typeof","void","delete","new","in","of","instanceof","function","class","const","let","var","await","yield","import","export","try","else","throw","case","default","break","continue","debugger","finally","super","this","null","true","false","async","get","set","static"]),v=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===36||e===95,Te=(e,t,n)=>{let o=e.indexOf(t,n);for(;o!==-1;){const r=o+t.length;if((o===0||!v(e.charCodeAt(o-1)))&&(r>=e.length||!v(e.charCodeAt(r))))return!0;o=e.indexOf(t,r)}return!1},M=e=>{let t=e.length-1;for(;t>=0&&e.charCodeAt(t)<=32;)t--;return t<0?-1:e.charCodeAt(t)},Re=e=>{let t=e,n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;n&&(t=t.slice(n));let o=xe.exec(t);if(o){if(o[2]||M(t)!==125)return null;const r=o[3]||"";return r&&Te(t,r,o[0].indexOf("("))||t.indexOf("arguments.callee")!==-1?null:{src:e,name:r,kind:o[1]?T:F,async:!!o[1],fn:void 0}}return o=Ae.exec(t)||$e.exec(t),o?{src:e,name:"",kind:T,async:!!o[1],fn:void 0}:(o=ke.exec(t),o&&!Pe.has(o[2])&&M(t)===125?t.indexOf("arguments.callee")!==-1?null:{src:e,name:o[2],kind:T,async:!!o[1],fn:void 0}:null)},W=e=>e.index===-1?`"${e.key}"`:`array index ${e.index} (prop "${e.key}")`,$=e=>{const t=A(e.src,W(e),e.opts,!0);let n=null;return typeof t=="function"?n=t:(e.value=t,typeof t!="string"&&typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: ${W(e)} did not evaluate to a function \u2014 the lazily revived function returns that value.
|
|
13
|
+
First 200 chars of source: `+String(e.src).slice(0,200))),e.fn=n,e.opts=null,n},Ne=(e,t,n)=>Reflect.construct(e,t,n);function De(){const e=O.get(this);return e?e.src.trim():Function.prototype.toString.call(this)}const Ce={length:{get(){const e=O.get(this);if(!e)return 0;const t=e.fn===void 0?$(e):e.fn;return t?t.length:0},configurable:!0},name:{get(){const e=O.get(this);return e?e.name:""},configurable:!0},toString:{value:De,writable:!0,configurable:!0}},Ie=Object.getPrototypeOf(async function(){}),ze=e=>{let t;return e.kind===F?t=function(){const n=e.fn===void 0?$(e):e.fn;return n===null?e.value:new.target?Ne(n,arguments,new.target):n.apply(this,arguments)}:t={lazy(){const n=e.fn===void 0?$(e):e.fn;return n===null?e.value:n.apply(this,arguments)}}.lazy,O.set(t,e),Object.defineProperties(t,Ce),e.async&&Object.setPrototypeOf(t,Ie),t},Y=(e,t,n,o)=>{const r=Re(e);return r?(r.key=t,r.index=n,r.opts=o,ze(r)):A(e,n===-1?`"${t}"`:`array index ${n} (prop "${t}")`,o)},Le=e=>typeof e=="function"&&O.has(e),me=e=>{const t=O.get(e);return t?t.src.trim():Function.prototype.toString.call(e)},be=e=>{const t=typeof e=="function"?O.get(e):void 0;return t?(t.fn===void 0?$(t):t.fn)===null:!1},Fe=new Set(["components","pages","functions","methods","snippets","app","globalScope"]),ve={window:{eval:b}},Me=(e,t={},n=ve)=>{if(!e||typeof e!="object")return t;(!n||!n.window||typeof n.window.eval!="function")&&(n={...n,window:{eval:b}});const o=n.lazy===!0,r=n.lazy==="context",i=(u,s,y)=>o||r&&(u===e?Fe.has(s):y),c=[[e,t,o]];for(;c.length;){const[u,s,y]=c.pop();for(const f in u){if(!Object.prototype.hasOwnProperty.call(u,f))continue;const a=u[f];if((0,l.isString)(a))k(a)?s[f]=y?Y(a,f,-1,n):A(a,`"${f}"`,n):s[f]=a;else if((0,l.isArray)(a)){const g=s[f]=[],d=i(u,f,y);for(let p=0;p<a.length;p++){const h=a[p];if((0,l.isString)(h))g.push(k(h)?d?Y(h,f,p,n):A(h,`array index ${p} (prop "${f}")`,n):h);else if((0,l.isObject)(h)){const x=J(h);if(x!==null)g.push(x);else{const I={};g.push(I),c.push([h,I,d])}}else g.push(h)}}else if((0,l.isObject)(a)){const g=J(a);if(g!==null){s[f]=g;continue}const d=s[f]&&typeof s[f]=="object"&&!(0,l.isArray)(s[f])?s[f]:s[f]={};c.push([a,d,i(u,f,y)])}else s[f]=a}}return ee(t)},Z="Set",G="Map",H="RegExp",K="WeakMap",B="WeakSet",U="String",q=e=>{if(!e||typeof e!="object"||e.__type!==U||!(0,l.isString)(e.value))return!1;const t=Object.keys(e);return t.length===2&&t.includes("value")},We=q,C=Symbol.for("smbls.revived"),ee=e=>{if(e&&typeof e=="object")try{e[C]=!0}catch{}return e},Ye=e=>!!(e&&typeof e=="object"&&e[C]===!0),V=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},E=(e,t)=>{if(!e||typeof e!="object")return e;if(q(e))return e.value;const n=i=>E(i,t||(t=new WeakMap));if(e.__type===Z&&(0,l.isArray)(e.values))return new Set(e.values.map(n));if(e.__type===G&&(0,l.isArray)(e.entries))return new Map(e.entries.map(i=>(0,l.isArray)(i)?[n(i[0]),n(i[1])]:i));if(e.__type===K&&V(e))return new WeakMap;if(e.__type===B&&V(e))return new WeakSet;if(e.__type===H&&(0,l.isString)(e.source))try{return new RegExp(e.source,(0,l.isString)(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let o=!1;if((0,l.isArray)(e)){const i=new Array(e.length);t.set(e,i);for(let c=0;c<e.length;c++)i[c]=E(e[c],t),i[c]!==e[c]&&(o=!0);return o||t.set(e,e),o?i:e}const r={};t.set(e,r);for(const i of Object.keys(e))r[i]=E(e[i],t),r[i]!==e[i]&&(o=!0);return o||t.set(e,e),o?r:e},J=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==H&&t!==Z&&t!==G&&t!==K&&t!==B&&t!==U)return null;const n=E(e);return n===e?null:n},Ze=e=>{if(!e||typeof e!="object")return e;const t={},n=[];for(const c of Object.keys(e)){const u=e[c];(0,l.isString)(u)&&k(u)?n.push([c,u]):t[c]=E(u)}if(n.length===0)return t;const o=c=>/^[A-Za-z_$][\w$]*$/.test(c),r=n.filter(([c])=>o(c)),i=Object.keys(t).filter(o).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
|
|
14
14
|
`);try{const c=r.map(([y,f])=>`var ${y} = (${f});`).join(`
|
|
15
15
|
`),u="{ "+r.map(([y])=>`${JSON.stringify(y)}: ${y}`).join(", ")+" }",s=S.window.eval(`(function(__gs__) { ${i}
|
|
16
16
|
${c}
|
|
17
17
|
return ${u}; })`)(t);Object.assign(t,s)}catch{for(const[u,s]of r)try{const y=Object.keys(t).filter(o).map(f=>`var ${f} = __gs__[${JSON.stringify(f)}];`).join(`
|
|
18
18
|
`);t[u]=S.window.eval(`(function(__gs__) { ${y}
|
|
19
|
-
return (${s}); })`)(t)}catch{try{t[u]=S.window.eval(`(${s})`)}catch{t[u]=s}}}for(const[c,u]of n)if(!o(c))try{t[c]=S.window.eval(`(${u})`)}catch{t[c]=u}return t},
|
|
19
|
+
return (${s}); })`)(t)}catch{try{t[u]=S.window.eval(`(${s})`)}catch{t[u]=s}}}for(const[c,u]of n)if(!o(c))try{t[c]=S.window.eval(`(${u})`)}catch{t[c]=u}return t},Ge=(e,t={verbose:!0})=>{try{return e?S.window.eval("("+e+")"):{}}catch(n){t.verbose&&console.warn(n)}},He=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),te=e=>{for(const t in e)return!1;return!0},Ke=e=>(0,l.isObject)(e)&&te(e),Be=()=>Object.create(null),Ue=(e,t,n={})=>{const o=n.exclude||[],r=n.preventUnderscore;for(const i in t)o.includes(i)||!r&&w(i)||i==="constructor"||i==="prototype"||t[i]!==void 0&&(e[i]=t[i]);return e},qe=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)w(r)||r==="constructor"||r==="prototype"||(o?n.has(r):n.includes(r))||(e[r]=t[r]);return e},ne=(e,t,n={},o=new WeakMap)=>{if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return t;if(o.has(e))return o.get(e);o.set(e,e);const r=n.exclude,i=r?r instanceof Set?r:new Set(r):null,c=!n.preventForce;for(const u in t){if(!Object.prototype.hasOwnProperty.call(t,u)||i&&i.has(u)||c&&w(u)||u==="constructor"||u==="prototype")continue;const s=e[u],y=t[u];(0,_.isDOMNode)(y)?e[u]=y:(0,l.isObjectLike)(s)&&(0,l.isObjectLike)(y)?e[u]=ne(s,y,n,o):y!==void 0&&(e[u]=y)}return e},re=(e,t,n=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(let i=0;i<o.length;i++){const c=o[i];if(!Object.prototype.hasOwnProperty.call(t,c)||!re(e[c],t[c],n))return!1}return!0},Ve=new Set(["node","__ref"]),Je=(e,t,n=Ve)=>{if(e===t)return!0;if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return e===t;const o=n instanceof Set?n:new Set(n),r=new WeakSet;function i(c,u){if(r.has(u))return!0;r.add(u);for(const s in u){if(!Object.prototype.hasOwnProperty.call(u,s)||o.has(s))continue;if(!Object.prototype.hasOwnProperty.call(c,s))return!1;const y=u[s],f=c[s];if((0,_.isDOMNode)(y)||(0,_.isDOMNode)(f)){if(y!==f)return!1}else if((0,l.isObjectLike)(y)&&(0,l.isObjectLike)(f)){if(!i(f,y))return!1}else if(y!==f)return!1}return!0}return i(e,t)},Xe=(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 n=0;n<t.length;n++)delete e[t[n]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},oe=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=oe(e[n]));return t},Qe=(e,t)=>{if(e.length===0)return t;const n={};let o=n;for(let r=0;r<e.length;r++)r===e.length-1&&t?o[e[r]]=t:(o[e[r]]={},o=o[e[r]]);return n},je=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let r=0;r<t.length-1;r++){if(n[t[r]]===void 0)return;n=n[t[r]]}const o=t[t.length-1];n&&Object.prototype.hasOwnProperty.call(n,o)&&delete n[o]},et=(e,t,n)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length-1;r++)(!o[t[r]]||typeof o[t[r]]!="object")&&(o[t[r]]={}),o=o[t[r]];return o[t[t.length-1]]=n,e},tt=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let o=0;o<t.length;o++){if(n==null)return;n=n[t[o]]}return n},nt=e=>{let n=[],o=0;for(let r=0;r<e.length;r++)if(n.length<2)n.push(e[r]);else if(e[r]===n[r%2]?o++:(n=[e[r-1],e[r]],o=1),o>=20)return(z==="test"||z==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",n),!0},rt=e=>{const t=new WeakSet;function n(o){if(o&&typeof o=="object"){if(t.has(o))return!0;t.add(o);for(const r in o)if(Object.prototype.hasOwnProperty.call(o,r)&&n(o[r]))return console.log(o,"cycle at "+r),!0}return!1}return n(e)},ot=(e,t)=>{const n=t instanceof Set?t:new Set(t),o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!n.has(r)&&(o[r]=e[r]);return o};
|
package/dist/esm/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{isObject as A}from"./types.js";import{isStringFunction as w}from"./function.js";const g=n=>{if(n==null)return"";const r={"&":"&","<":"<",">":">",'"':""","'":"'"};return n.toString().replace(/[&<>"']/g,t=>r[t])},O=n=>Object.entries(n||{}).filter(([r,t])=>t!==void 0).map(([r,t])=>`${r}="${g(t)}"`).join(" "),b=n=>{let r=5381;const t=String(n);for(let e=0;e<t.length;e++)r=(r*33^t.charCodeAt(e))>>>0;return r.toString(36)},L=new Set(["jsonLd","styles","scripts"]),E=n=>{const r=[];if(Array.isArray(n.jsonLd))for(const t of n.jsonLd){if(t==null)continue;const e=typeof t=="string"?t:JSON.stringify(t),i=String(e).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${b(e)}">${i}<\/script>`)}if(Array.isArray(n.styles))for(const t of n.styles){if(t==null||!String(t).trim())continue;const e=String(t).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${b(e)}">${e}</style>`)}if(Array.isArray(n.scripts))for(const t of n.scripts){if(!t)continue;const e=typeof t=="string",i=e?t:t.src;if(!i&&!t.body)continue;const o=[];i&&o.push(`src="${g(i)}"`),e||(t.type&&o.push(`type="${g(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${g(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${g(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${g(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${g(i||b(t.body||""))}"`;if(!e&&t.body){const h=String(t.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${l}>${h}<\/script>`)}else r.push(`<script ${o.join(" ")}${l}><\/script>`)}return r},U=(n,r)=>{r||(n={...n,robots:"noindex"});const t=Object.entries(n).reduce((e,[i,o])=>{if(!o&&o!==0&&o!==!1||L.has(i))return e;if(i==="title")return e.push(`<title>${g(o)}</title>`),e;if(i==="canonical")return e.push(`<link rel="canonical" href="${g(o)}">`),e;if(i==="manifest")return e.push(`<link rel="manifest" href="${g(o)}">`),e;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{if(typeof c=="string")e.push(`<link rel="icon" href="${g(c)}">`);else if(typeof c=="object"){const u=O(c);/rel=/.test(u)?e.push(`<link ${u}>`):e.push(`<link rel="icon" ${u}>`)}}),e;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(typeof c=="object"){const u=Object.entries(c).filter(([s,p])=>p!==void 0).map(([s,p])=>`${s}="${g(p)}"`).join(" ");e.push(`<link rel="alternate" ${u}>`)}}),e;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")e.push(`<meta ${u}="${g(f)}" content="${g(c)}">`);else if(Array.isArray(c))c.forEach(s=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")e.push(`<meta ${u}="${g(f)}" content="${g(s)}">`);else if(typeof s=="object"){const p=Object.entries(s).filter(([m,a])=>a!==void 0).map(([m,a])=>`${m}="${g(a)}"`).join(" ");e.push(`<meta ${p}>`)}});else if(typeof c=="object"){const s=Object.entries(c).filter(([p,m])=>m!==void 0).map(([p,m])=>`${p}="${g(m)}"`).join(" ");e.push(`<meta ${s}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return l(f,o,"http-equiv"),e}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return l(f,o,"itemprop"),e}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(y){const f=i.replace(y,"");return l(`${y.replace(":","")}:${f}`,o,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),e}if(i.startsWith("apple:")||i.startsWith("msapplication:")){const f=i.startsWith("apple:")?"apple-":"msapplication-",c=i.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),e}return l(i,o),e},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...E(n)),t.join(`
|
|
2
|
-
`)},W=n=>typeof n=="string"&&n.length>0&&!n.startsWith("/")&&!n.startsWith("http"),j=n=>typeof n=="string"&&n.length>0,
|
|
2
|
+
`)},W=n=>typeof n=="string"&&n.length>0&&!n.startsWith("/")&&!n.startsWith("http"),j=n=>typeof n=="string"&&n.length>0,x=n=>{if(!n||typeof n!="object")return null;if(j(n.src))return n.src;const r=n.content;return!r||typeof r!="object"?null:j(r.src)?r.src:j(r.storageUrl)?r.storageUrl:null};function T(n,r){if(!r||typeof r!="object")return n;const t=i=>!W(i)||!Object.prototype.hasOwnProperty.call(r,i)?i:x(r[i])||i,e={...n};for(const[i,o]of Object.entries(e))typeof o=="string"?e[i]=t(o):Array.isArray(o)&&(e[i]=o.map(l=>typeof l=="string"?t(l):l));return e}function S(n,r){if(!n||!r)return;const t=r.split(".");let e=n;for(const i of t){if(e==null||typeof e!="object")return;e=e[i]}return e}function F(n,r){const t=S(n,r);if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&!w(t))return t}function D(n,r,t){const i=(r.config||r.settings||{}).polyglot||r.polyglot,o=t?.lang||i?.defaultLang||"en",h=(i?.translations||{})[o]||{},y=[t?.state,r.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const s of y){const p=F(s,u);if(p!==void 0)return p}},c={...n};for(const[u,s]of Object.entries(c))typeof s!="string"||!s.includes("{{")||(c[u]=s.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(p,m,a)=>{const d=m.trim();if(a==="polyglot")return h[d]??S(h,d)??p;if(a==="getLocalStateLang")return f(d+o)??p;const $=f(d);return $!==void 0?$:h[d]??S(h,d)??p}));return c}function M(n){if(!A(n))return{};const r={...n};for(const[t,e]of Object.entries(r))if(typeof e=="function"){const i=e.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){r[t]=`{{ ${l[1]} | polyglot }}`;continue}const h=i.match(/s\.(\w+(?:\.\w+)+)/);if(h){r[t]=`{{ ${h[1]} }}`;continue}delete r[t]}else if(typeof e=="string"){const i=e.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){r[t]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=e.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | polyglot }}`;continue}if(e.includes("=>")&&e.includes("s.")){const l=e.match(/s\.(\w+(?:\.\w+)+)/);if(l){r[t]=`{{ ${l[1]} }}`;continue}}w(e)&&delete r[t]}return r}function _(n,r,t,{isProduction:e=!1,channel:i="production"}={}){const o=n.pages?.[r],l=A(o?.state)&&o?.state,h=o?.metadata||o?.helmet||l||{},y=M(h),f=new Set(Object.keys(y)),c=n.app?.metadata||{},u=M(c);let s={};if(n.integrations?.seo?s={...n.integrations.seo,...u,...y}:Object.keys(u).length?s={...u,...y}:s={...y},!s.title){const a=n.name||n.key;a?e?s.title=a:i==="development"?s.title=`${a} / dev:symbo.ls`:i==="staging"?s.title=`${a} / staging:symbo.ls`:s.title=`${a} / symbo.ls`:s.title="Symbols demo"}s=D(s,n,t),s.title&&(f.has("title")||!s["og:title"])&&(f.has("og:title")||(s["og:title"]=s.title)),s.description&&(f.has("description")||!s["og:description"])&&(f.has("og:description")||(s["og:description"]=s.description)),s.title&&!s["twitter:title"]&&(s["twitter:title"]=s.title),s.description&&!s["twitter:description"]&&(s["twitter:description"]=s.description);const p=t?.actualPathname||r;if(s["og:url"]||s.url){const a=(s["og:url"]||s.url||"").replace(/\/$/,"");if(a&&p&&p!=="/"){const d=p.startsWith("/")?p:"/"+p;s["og:url"]=a+d}}s=T(s,n.files);const m=n.name||n.app?.metadata?.title||n.app?.name||"";for(const[a,d]of Object.entries(s))if(typeof d=="string"&&d.includes("{{")){const $=d.replace(/\{\{[^}]*\}\}/g,"").trim();$?s[a]=$:a==="title"?s[a]=m:delete s[a]}return s}export{x as fileEntryUrl,E as generateHeadArrayTags,U as generateMetaTags,_ as getPageMetadata,b as hashContent,T as resolveFileReferences};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{window as
|
|
2
|
-
`,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},
|
|
3
|
-
`;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],l=
|
|
1
|
+
import{window as A}from"./globals.js";import{isFunction as P,isObjectLike as g,isObject as x,isArray as _,isString as O,is as ee}from"./types.js";import{unstackArrayOfObjects as te}from"./array.js";import{stringIncludesAny as ne}from"./string.js";import{isDOMNode as w}from"./node.js";import{METHODS_EXL as re}from"./keys.js";const I="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,z=(e,t,n,o)=>{if(P(e))return t?typeof e.call!="function"?e:e.call(t,t,n||t.state,o||t.context):void 0;if(e!=null&&t?.context?.plugins&&(_(e)||x(e)&&!w(e))){const r=t.context.plugins;for(const i of r)if(i.resolveHandler){const c=i.resolveHandler(e,t);if(typeof c=="function")return z(c,t,n,o)}}return e},be=(e,t,n)=>{for(const o in t)e[o]=z(t[o],n)},Fe=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(S(r)||(o?n.has(r):n.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},ve=(e,t,n=re)=>L(e,t,n,null),L=(e,t,n,o)=>{if(e===t)return e;if(o){for(let i=0;i<o.length;i+=2)if(o[i]===e&&o[i+1]===t)return e}const r=n instanceof Set;for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||S(i)||i==="constructor"||i==="prototype"||(r?n.has(i):n.includes(i)))continue;const c=e[i],l=t[i];if(g(c)&&g(l)){const s=o||[];s.push(e,t),L(c,l,n,s),s.length-=2}else c===void 0&&(e[i]=l)}return e},Me=(e,t=[])=>{const n=t instanceof Set,o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(S(r)||(n?t.has(r):t.includes(r))||(o[r]=e[r]));return o},We=(e,t={})=>{const{exclude:n=[],cleanUndefined:o=!1,cleanNull:r=!1,visited:i=new WeakMap,handleExtends:c=!1}=t;if(!g(e)||w(e))return e;if(i.has(e))return i.get(e);const l=n instanceof Set?n:n.length>3?new Set(n):null,s=u=>l?l.has(u):n.includes(u),p=_(e)?[]:{};i.set(e,p);const f=[[e,p]];for(;f.length;){const[u,h]=f.pop();for(const y in u){if(!Object.prototype.hasOwnProperty.call(u,y)||S(y)||y==="__proto__"||s(y))continue;const a=u[y];if(!(o&&a===void 0)&&!(r&&a===null)){if(w(a)){h[y]=a;continue}if(c&&y==="extends"&&_(a)){h[y]=te(a,n);continue}if(P(a)){h[y]=a;continue}if(g(a))if(i.has(a))h[y]=i.get(a);else{const d=_(a)?[]:{};i.set(a,d),h[y]=d,f.push([a,d])}else h[y]=a}}}return p},m=(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 n in e){const o=e[n];if(P(o))t[n]=o.toString();else if(x(o))t[n]={},m(o,t[n]);else if(_(o)){const r=t[n]=[];for(let i=0;i<o.length;i++){const c=o[i];x(c)?(r[i]={},m(c,r[i])):P(c)?r[i]=c.toString():r[i]=c}}else t[n]=o}return t},oe=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ie=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,b=e=>{const t=String(e);return ne(t,[`
|
|
2
|
+
`,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},F=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let n=!1;for(const i in e){n=!0;break}if(!n)return"{}";const o=" ".repeat(t);let r=`{
|
|
3
|
+
`;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],l=oe.test(i)?i:ie(i);if(r+=`${o} ${l}: `,c instanceof RegExp)r+=String(c);else if(_(c)){r+=`[
|
|
4
4
|
`;for(const s of c)s instanceof RegExp?r+=`${o} ${String(s)},
|
|
5
|
-
`:g(s)&&s!==null?r+=`${o} ${
|
|
6
|
-
`:O(s)?r+=`${o} ${
|
|
5
|
+
`:g(s)&&s!==null?r+=`${o} ${F(s,t+2)},
|
|
6
|
+
`:O(s)?r+=`${o} ${b(s)},
|
|
7
7
|
`:r+=`${o} ${s},
|
|
8
|
-
`;r+=`${o} ]`}else g(c)?r+=
|
|
9
|
-
`}return r+=`${o}}`,r},
|
|
8
|
+
`;r+=`${o} ]`}else g(c)?r+=F(c,t+1):O(c)?r+=b(c):r+=c;r+=`,
|
|
9
|
+
`}return r+=`${o}}`,r},ce=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],se=/^["[{]/,fe=/^(export|import)\s/,N=e=>{if(!e)return!1;const t=e.trim();if(t===""||t==="{}"||t==="[]")return!1;const n=t.includes("=>");if(!n&&t.charCodeAt(0)!==40&&!t.startsWith("function")&&!t.startsWith("async")&&!(t.charCodeAt(t.length-1)===125&&t.includes("("))||fe.test(t)||!ce.some(i=>i.test(t)))return!1;const r=t.charCodeAt(0);return!(r===123&&!n||r===91||se.test(t)&&!n)},v=e=>(0,eval)(e),le=(e,t)=>{const n=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!n)return null;const o=n[0].length,r=[];let i=o,c=1,l=null;const s=e.length,p=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;i<s&&c>0;){const u=e[i];if(u==="/"&&e[i+1]==="/"){const h=e.indexOf(`
|
|
10
10
|
`,i);i=h===-1?s:h;continue}if(u==="/"&&e[i+1]==="*"){const h=e.indexOf("*/",i+2);i=h===-1?s:h+2;continue}if(u==='"'||u==="'"||u==="`"){const h=u;for(i++;i<s;){if(e[i]==="\\"){i+=2;continue}if(e[i]===h){i++;break}if(h==="`"&&e[i]==="$"&&e[i+1]==="{"){i+=2;let y=1;for(;i<s&&y>0;)e[i]==="{"?y++:e[i]==="}"&&y--,i++;continue}i++}continue}if(u==="{"){c++,i++;continue}if(u==="}"){c--,i++;continue}if(c===1&&p.test(e.slice(i))){const h=i;let y=0,a=i;for(;a<s;){const d=e[a];if(d==='"'||d==="'"||d==="`"){const k=d;for(a++;a<s;){if(e[a]==="\\"){a+=2;continue}if(e[a]===k){a++;break}a++}continue}if(d==="("||d==="["||d==="{"){y++,a++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,a++;continue}if(y===0&&(d===";"||d===`
|
|
11
|
-
`)){a++;break}a++}r.push([h,a]),i=a;continue}i++}if(!r.length)return null;let f=e;for(let u=r.length-1;u>=0;u--)f=f.slice(0,r[u][0])+f.slice(r[u][1]);return f},T=(e,t,n,o)=>{const r=String(e).trimStart();if(/^(export|import)\s/.test(r))return e;try{return n.window.eval(`(${e})`)}catch(i){const c=i&&i.message?i.message:String(i),l=/await is only valid in async/.test(c),s=/Identifier '([^']+)' has already been declared/.exec(c);let p=null;if(l){const f=String(e).trim();if(/^function[\s(]/.test(f))try{p=n.window.eval("(async "+f+")")}catch{}}else if(s){let f=String(e),u=s[1];for(let h=0;h<5;h++){const y=
|
|
12
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},
|
|
13
|
-
First 200 chars of source: `+String(e.src).slice(0,200))),e.fn=n,e.opts=null,n},
|
|
11
|
+
`)){a++;break}a++}r.push([h,a]),i=a;continue}i++}if(!r.length)return null;let f=e;for(let u=r.length-1;u>=0;u--)f=f.slice(0,r[u][0])+f.slice(r[u][1]);return f},T=(e,t,n,o)=>{const r=String(e).trimStart();if(/^(export|import)\s/.test(r))return e;try{return n.window.eval(`(${e})`)}catch(i){const c=i&&i.message?i.message:String(i),l=/await is only valid in async/.test(c),s=/Identifier '([^']+)' has already been declared/.exec(c);let p=null;if(l){const f=String(e).trim();if(/^function[\s(]/.test(f))try{p=n.window.eval("(async "+f+")")}catch{}}else if(s){let f=String(e),u=s[1];for(let h=0;h<5;h++){const y=le(f,u);if(!y||y===f)break;f=y;try{p=n.window.eval("("+f+")");break}catch(a){const d=/Identifier '([^']+)' has already been declared/.exec(a&&a.message||String(a));if(!d||d[1]!==u)break}}}if(!p&&/Unexpected (token '\{'|identifier)/.test(c))try{const f=n.window.eval("({"+e+"})");if(f&&typeof f=="object"){const u=Object.keys(f);u.length===1&&typeof f[u[0]]=="function"&&(p=f[u[0]])}}catch{}return p||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 `+(o?"revived lazily, so its source compiled on this first use; it acts as the string it replaces (a call returns the source text, el.call treats it as not callable). Reason: ":"value will be left as a string. Reason: ")+c+`.
|
|
12
|
+
First 200 chars of source: `+String(e).slice(0,200)),e)}},M=1,D=2,E=new WeakMap,ue=/^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,ae=/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/,pe=/^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/,ye=/^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,de=new Set(["if","for","while","switch","catch","with","do","return","typeof","void","delete","new","in","of","instanceof","function","class","const","let","var","await","yield","import","export","try","else","throw","case","default","break","continue","debugger","finally","super","this","null","true","false","async","get","set","static"]),W=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===36||e===95,he=(e,t,n)=>{let o=e.indexOf(t,n);for(;o!==-1;){const r=o+t.length;if((o===0||!W(e.charCodeAt(o-1)))&&(r>=e.length||!W(e.charCodeAt(r))))return!0;o=e.indexOf(t,r)}return!1},Y=e=>{let t=e.length-1;for(;t>=0&&e.charCodeAt(t)<=32;)t--;return t<0?-1:e.charCodeAt(t)},ge=e=>{let t=e,n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;n&&(t=t.slice(n));let o=ue.exec(t);if(o){if(o[2]||Y(t)!==125)return null;const r=o[3]||"";return r&&he(t,r,o[0].indexOf("("))||t.indexOf("arguments.callee")!==-1?null:{src:e,name:r,kind:o[1]?D:M,async:!!o[1],fn:void 0}}return o=ae.exec(t)||pe.exec(t),o?{src:e,name:"",kind:D,async:!!o[1],fn:void 0}:(o=ye.exec(t),o&&!de.has(o[2])&&Y(t)===125?t.indexOf("arguments.callee")!==-1?null:{src:e,name:o[2],kind:D,async:!!o[1],fn:void 0}:null)},Z=e=>e.index===-1?`"${e.key}"`:`array index ${e.index} (prop "${e.key}")`,R=e=>{const t=T(e.src,Z(e),e.opts,!0);let n=null;return typeof t=="function"?n=t:(e.value=t,typeof t!="string"&&typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: ${Z(e)} did not evaluate to a function \u2014 the lazily revived function returns that value.
|
|
13
|
+
First 200 chars of source: `+String(e.src).slice(0,200))),e.fn=n,e.opts=null,n},_e=(e,t,n)=>Reflect.construct(e,t,n);function we(){const e=E.get(this);return e?e.src.trim():Function.prototype.toString.call(this)}const Oe={length:{get(){const e=E.get(this);if(!e)return 0;const t=e.fn===void 0?R(e):e.fn;return t?t.length:0},configurable:!0},name:{get(){const e=E.get(this);return e?e.name:""},configurable:!0},toString:{value:we,writable:!0,configurable:!0}},Se=Object.getPrototypeOf(async function(){}),Ee=e=>{let t;return e.kind===M?t=function(){const n=e.fn===void 0?R(e):e.fn;return n===null?e.value:new.target?_e(n,arguments,new.target):n.apply(this,arguments)}:t={lazy(){const n=e.fn===void 0?R(e):e.fn;return n===null?e.value:n.apply(this,arguments)}}.lazy,E.set(t,e),Object.defineProperties(t,Oe),e.async&&Object.setPrototypeOf(t,Se),t},G=(e,t,n,o)=>{const r=ge(e);return r?(r.key=t,r.index=n,r.opts=o,Ee(r)):T(e,n===-1?`"${t}"`:`array index ${n} (prop "${t}")`,o)},Ye=e=>typeof e=="function"&&E.has(e),Ze=e=>{const t=E.get(e);return t?t.src.trim():Function.prototype.toString.call(e)},Ge=e=>{const t=typeof e=="function"?E.get(e):void 0;return t?(t.fn===void 0?R(t):t.fn)===null:!1},xe=new Set(["components","pages","functions","methods","snippets","app","globalScope"]),Ae={window:{eval:v}},He=(e,t={},n=Ae)=>{if(!e||typeof e!="object")return t;(!n||!n.window||typeof n.window.eval!="function")&&(n={...n,window:{eval:v}});const o=n.lazy===!0,r=n.lazy==="context",i=(l,s,p)=>o||r&&(l===e?xe.has(s):p),c=[[e,t,o]];for(;c.length;){const[l,s,p]=c.pop();for(const f in l){if(!Object.prototype.hasOwnProperty.call(l,f))continue;const u=l[f];if(O(u))N(u)?s[f]=p?G(u,f,-1,n):T(u,`"${f}"`,n):s[f]=u;else if(_(u)){const h=s[f]=[],y=i(l,f,p);for(let a=0;a<u.length;a++){const d=u[a];if(O(d))h.push(N(d)?y?G(d,f,a,n):T(d,`array index ${a} (prop "${f}")`,n):d);else if(x(d)){const k=j(d);if(k!==null)h.push(k);else{const C={};h.push(C),c.push([d,C,y])}}else h.push(d)}}else if(x(u)){const h=j(u);if(h!==null){s[f]=h;continue}const y=s[f]&&typeof s[f]=="object"&&!_(s[f])?s[f]:s[f]={};c.push([u,y,i(l,f,p)])}else s[f]=u}}return $e(t)},H="Set",K="Map",B="RegExp",U="WeakMap",q="WeakSet",V="String",J=e=>{if(!e||typeof e!="object"||e.__type!==V||!O(e.value))return!1;const t=Object.keys(e);return t.length===2&&t.includes("value")},Ke=J,X=Symbol.for("smbls.revived"),$e=e=>{if(e&&typeof e=="object")try{e[X]=!0}catch{}return e},Be=e=>!!(e&&typeof e=="object"&&e[X]===!0),Q=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},$=(e,t)=>{if(!e||typeof e!="object")return e;if(J(e))return e.value;const n=i=>$(i,t||(t=new WeakMap));if(e.__type===H&&_(e.values))return new Set(e.values.map(n));if(e.__type===K&&_(e.entries))return new Map(e.entries.map(i=>_(i)?[n(i[0]),n(i[1])]:i));if(e.__type===U&&Q(e))return new WeakMap;if(e.__type===q&&Q(e))return new WeakSet;if(e.__type===B&&O(e.source))try{return new RegExp(e.source,O(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let o=!1;if(_(e)){const i=new Array(e.length);t.set(e,i);for(let c=0;c<e.length;c++)i[c]=$(e[c],t),i[c]!==e[c]&&(o=!0);return o||t.set(e,e),o?i:e}const r={};t.set(e,r);for(const i of Object.keys(e))r[i]=$(e[i],t),r[i]!==e[i]&&(o=!0);return o||t.set(e,e),o?r:e},j=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==B&&t!==H&&t!==K&&t!==U&&t!==q&&t!==V)return null;const n=$(e);return n===e?null:n},Ue=e=>{if(!e||typeof e!="object")return e;const t={},n=[];for(const c of Object.keys(e)){const l=e[c];O(l)&&N(l)?n.push([c,l]):t[c]=$(l)}if(n.length===0)return t;const o=c=>/^[A-Za-z_$][\w$]*$/.test(c),r=n.filter(([c])=>o(c)),i=Object.keys(t).filter(o).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
|
|
14
14
|
`);try{const c=r.map(([p,f])=>`var ${p} = (${f});`).join(`
|
|
15
|
-
`),l="{ "+r.map(([p])=>`${JSON.stringify(p)}: ${p}`).join(", ")+" }",s=
|
|
15
|
+
`),l="{ "+r.map(([p])=>`${JSON.stringify(p)}: ${p}`).join(", ")+" }",s=A.eval(`(function(__gs__) { ${i}
|
|
16
16
|
${c}
|
|
17
17
|
return ${l}; })`)(t);Object.assign(t,s)}catch{for(const[l,s]of r)try{const p=Object.keys(t).filter(o).map(f=>`var ${f} = __gs__[${JSON.stringify(f)}];`).join(`
|
|
18
|
-
`);t[l]=
|
|
19
|
-
return (${s}); })`)(t)}catch{try{t[l]=
|
|
18
|
+
`);t[l]=A.eval(`(function(__gs__) { ${p}
|
|
19
|
+
return (${s}); })`)(t)}catch{try{t[l]=A.eval(`(${s})`)}catch{t[l]=s}}}for(const[c,l]of n)if(!o(c))try{t[c]=A.eval(`(${l})`)}catch{t[c]=l}return t},qe=(e,t={verbose:!0})=>{try{return e?A.eval("("+e+")"):{}}catch(n){t.verbose&&console.warn(n)}},Ve=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),ke=e=>{for(const t in e)return!1;return!0},Je=e=>x(e)&&ke(e),Xe=()=>Object.create(null),Qe=(e,t,n={})=>{const o=n.exclude||[],r=n.preventUnderscore;for(const i in t)o.includes(i)||!r&&S(i)||i==="constructor"||i==="prototype"||t[i]!==void 0&&(e[i]=t[i]);return e},je=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)S(r)||r==="constructor"||r==="prototype"||(o?n.has(r):n.includes(r))||(e[r]=t[r]);return e},Pe=(e,t,n={},o=new WeakMap)=>{if(!g(e)||!g(t)||w(e)||w(t))return t;if(o.has(e))return o.get(e);o.set(e,e);const r=n.exclude,i=r?r instanceof Set?r:new Set(r):null,c=!n.preventForce;for(const l in t){if(!Object.prototype.hasOwnProperty.call(t,l)||i&&i.has(l)||c&&S(l)||l==="constructor"||l==="prototype")continue;const s=e[l],p=t[l];w(p)?e[l]=p:g(s)&&g(p)?e[l]=Pe(s,p,n,o):p!==void 0&&(e[l]=p)}return e},Te=(e,t,n=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(let i=0;i<o.length;i++){const c=o[i];if(!Object.prototype.hasOwnProperty.call(t,c)||!Te(e[c],t[c],n))return!1}return!0},Re=new Set(["node","__ref"]),et=(e,t,n=Re)=>{if(e===t)return!0;if(!g(e)||!g(t)||w(e)||w(t))return e===t;const o=n instanceof Set?n:new Set(n),r=new WeakSet;function i(c,l){if(r.has(l))return!0;r.add(l);for(const s in l){if(!Object.prototype.hasOwnProperty.call(l,s)||o.has(s))continue;if(!Object.prototype.hasOwnProperty.call(c,s))return!1;const p=l[s],f=c[s];if(w(p)||w(f)){if(p!==f)return!1}else if(g(p)&&g(f)){if(!i(f,p))return!1}else if(p!==f)return!1}return!0}return i(e,t)},tt=(e,t)=>{if(t==null)return e;if(ee(t)("string","number"))delete e[t];else if(_(t))for(let n=0;n<t.length;n++)delete e[t[n]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},Ne=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=Ne(e[n]));return t},nt=(e,t)=>{if(e.length===0)return t;const n={};let o=n;for(let r=0;r<e.length;r++)r===e.length-1&&t?o[e[r]]=t:(o[e[r]]={},o=o[e[r]]);return n},rt=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let r=0;r<t.length-1;r++){if(n[t[r]]===void 0)return;n=n[t[r]]}const o=t[t.length-1];n&&Object.prototype.hasOwnProperty.call(n,o)&&delete n[o]},ot=(e,t,n)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length-1;r++)(!o[t[r]]||typeof o[t[r]]!="object")&&(o[t[r]]={}),o=o[t[r]];return o[t[t.length-1]]=n,e},it=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let o=0;o<t.length;o++){if(n==null)return;n=n[t[o]]}return n},ct=e=>{let n=[],o=0;for(let r=0;r<e.length;r++)if(n.length<2)n.push(e[r]);else if(e[r]===n[r%2]?o++:(n=[e[r-1],e[r]],o=1),o>=20)return(I==="test"||I==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",n),!0},st=e=>{const t=new WeakSet;function n(o){if(o&&typeof o=="object"){if(t.has(o))return!0;t.add(o);for(const r in o)if(Object.prototype.hasOwnProperty.call(o,r)&&n(o[r]))return console.log(o,"cycle at "+r),!0}return!1}return n(e)},ft=(e,t)=>{const n=t instanceof Set?t:new Set(t),o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!n.has(r)&&(o[r]=e[r]);return o};export{X as REVIVED_MARK,Me as clone,nt as createNestedObject,Ne as createObjectWithoutPrototype,We as deepClone,et as deepContains,He as deepDestringifyFunctions,ve as deepMerge,m as deepStringifyFunctions,Ue as destringifyGlobalScope,ct as detectInfiniteLoop,ft as excludeKeysFromObject,z as exec,Ze as getFunctionSource,it as getInObjectByPath,N as hasFunction,Ve as hasOwnProperty,st as isCyclic,ke as isEmpty,Je as isEmptyObject,Te as isEqualDeep,Ge as isFailedRevival,Ye as isLazyFunction,Be as isRevived,Ke as isStringTag,Xe as makeObjectWithoutPrototype,be as map,$e as markRevived,Fe as merge,F as objectToString,Qe as overwrite,Pe as overwriteDeep,je as overwriteShallow,tt as removeFromObject,rt as removeNestedKeyByPath,ot as setInObjectByPath,qe as stringToObject};
|
package/metadata.js
CHANGED
|
@@ -291,7 +291,7 @@ const nonEmptyString = (v) => typeof v === 'string' && v.length > 0
|
|
|
291
291
|
* renders for the same key, so the head and the body agree; then
|
|
292
292
|
* `content.storageUrl`.
|
|
293
293
|
*/
|
|
294
|
-
const fileEntryUrl = (entry) => {
|
|
294
|
+
export const fileEntryUrl = (entry) => {
|
|
295
295
|
if (!entry || typeof entry !== 'object') return null
|
|
296
296
|
if (nonEmptyString(entry.src)) return entry.src
|
|
297
297
|
const content = entry.content
|
|
@@ -306,8 +306,13 @@ const fileEntryUrl = (entry) => {
|
|
|
306
306
|
* If a metadata value is a plain filename (e.g. "logo.png") and a matching
|
|
307
307
|
* entry exists in `data.files`, replace it with the file's URL
|
|
308
308
|
* (`fileEntryUrl`).
|
|
309
|
+
*
|
|
310
|
+
* The ONE rule for a files key in metadata: the static head here and every
|
|
311
|
+
* helmet path (extractMetadata, and the browser's create/update/define apply
|
|
312
|
+
* against `element.context.files`) call it, so the live <head> carries the
|
|
313
|
+
* same URL the server rendered instead of overwriting it with the bare key.
|
|
309
314
|
*/
|
|
310
|
-
function resolveFileReferences (metadata, files) {
|
|
315
|
+
export function resolveFileReferences (metadata, files) {
|
|
311
316
|
if (!files || typeof files !== 'object') return metadata
|
|
312
317
|
|
|
313
318
|
const resolve = (val) => {
|
package/object.js
CHANGED
|
@@ -1003,7 +1003,7 @@ export const deepDestringifyFunctions = (
|
|
|
1003
1003
|
: arrProp)
|
|
1004
1004
|
} else if (isObject(arrProp)) {
|
|
1005
1005
|
const tagged = _rehydrateTagged(arrProp)
|
|
1006
|
-
if (tagged) {
|
|
1006
|
+
if (tagged !== null) {
|
|
1007
1007
|
arr.push(tagged)
|
|
1008
1008
|
} else {
|
|
1009
1009
|
const child = {}
|
|
@@ -1021,7 +1021,7 @@ export const deepDestringifyFunctions = (
|
|
|
1021
1021
|
// (FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1,
|
|
1022
1022
|
// FRANK-GLOBALSCOPE-CONST-PROTOTYPE-LOSS-1).
|
|
1023
1023
|
const tagged = _rehydrateTagged(objProp)
|
|
1024
|
-
if (tagged) {
|
|
1024
|
+
if (tagged !== null) {
|
|
1025
1025
|
dest[prop] = tagged
|
|
1026
1026
|
continue
|
|
1027
1027
|
}
|
|
@@ -1037,7 +1037,7 @@ export const deepDestringifyFunctions = (
|
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
|
-
return destringified
|
|
1040
|
+
return markRevived(destringified)
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
1043
|
// Tag values must stay in lockstep with plugins/frank/globalScopeBuilder.js
|
|
@@ -1048,6 +1048,40 @@ const TYPE_TAG_MAP = 'Map'
|
|
|
1048
1048
|
const TYPE_TAG_REGEXP = 'RegExp'
|
|
1049
1049
|
const TYPE_TAG_WEAKMAP = 'WeakMap'
|
|
1050
1050
|
const TYPE_TAG_WEAKSET = 'WeakSet'
|
|
1051
|
+
// FW-FRANK-TEXT-STRINGS-STAY-STRINGS: frank writes `{ __type: 'String', value }`
|
|
1052
|
+
// for a value that was a STRING in source but that the shape rule below
|
|
1053
|
+
// (`hasFunction`) would read as a function — documentation prose such as
|
|
1054
|
+
// `'() => MY_CONSTANT'` or `'useEffect(() => {}, [dep])'`. The tag records
|
|
1055
|
+
// the value's ORIGIN, so every revive hands back the plain string and never
|
|
1056
|
+
// evals it. Exactly two own keys (`__type`, `value`) and a string `value`:
|
|
1057
|
+
// a user object that merely carries `__type: 'String'` beside other data
|
|
1058
|
+
// passes through. Untagged data keeps the shape rule (legacy records: on the
|
|
1059
|
+
// dev docs record 2784 strings revive by shape, in every kind of key).
|
|
1060
|
+
const TYPE_TAG_STRING = 'String'
|
|
1061
|
+
const _isStringTag = (val) => {
|
|
1062
|
+
if (!val || typeof val !== 'object' || val.__type !== TYPE_TAG_STRING) return false
|
|
1063
|
+
if (!isString(val.value)) return false
|
|
1064
|
+
const keys = Object.keys(val)
|
|
1065
|
+
return keys.length === 2 && keys.includes('value')
|
|
1066
|
+
}
|
|
1067
|
+
export const isStringTag = _isStringTag
|
|
1068
|
+
|
|
1069
|
+
// A project tree that has been through a revive pass (the runner / mermaid
|
|
1070
|
+
// boot pass, fetchOnCreate, …) carries this mark on its root. A second pass
|
|
1071
|
+
// over it — smbls createDomql — must not run the shape rule again: the first
|
|
1072
|
+
// pass already turned every String tag back into a plain string, and a second
|
|
1073
|
+
// shape pass would eval that prose after all. Global-registry symbol, so a
|
|
1074
|
+
// separate copy of the reviver (mermaid's) sets the same key; ENUMERABLE, so
|
|
1075
|
+
// the `{ ...options }` spread in smbls `create()` carries it; a symbol, so
|
|
1076
|
+
// JSON, Object.keys and for…in never see it.
|
|
1077
|
+
export const REVIVED_MARK = Symbol.for('smbls.revived')
|
|
1078
|
+
export const markRevived = (obj) => {
|
|
1079
|
+
if (obj && typeof obj === 'object') {
|
|
1080
|
+
try { obj[REVIVED_MARK] = true } catch (e) { /* frozen / exotic: leave unmarked */ }
|
|
1081
|
+
}
|
|
1082
|
+
return obj
|
|
1083
|
+
}
|
|
1084
|
+
export const isRevived = (obj) => !!(obj && typeof obj === 'object' && obj[REVIVED_MARK] === true)
|
|
1051
1085
|
|
|
1052
1086
|
// A weak tag carries NO payload (frank cannot read one out of a WeakMap, and no
|
|
1053
1087
|
// consumer could use one — the keys are object identities the transport drops),
|
|
@@ -1086,6 +1120,7 @@ const _isBareTag = (val) => {
|
|
|
1086
1120
|
*/
|
|
1087
1121
|
const _rehydrateTaggedValue = (val, seen) => {
|
|
1088
1122
|
if (!val || typeof val !== 'object') return val
|
|
1123
|
+
if (_isStringTag(val)) return val.value
|
|
1089
1124
|
const walk = (v) => _rehydrateTaggedValue(v, seen || (seen = new WeakMap()))
|
|
1090
1125
|
if (val.__type === TYPE_TAG_SET && isArray(val.values)) return new Set(val.values.map(walk))
|
|
1091
1126
|
if (val.__type === TYPE_TAG_MAP && isArray(val.entries)) {
|
|
@@ -1130,13 +1165,14 @@ const _rehydrateTaggedValue = (val, seen) => {
|
|
|
1130
1165
|
// them in FRANK-WEAKMAP-CONST-STILL-DIES-TO-EMPTY-OBJECT-1: `const
|
|
1131
1166
|
// _columnIndexCache = new WeakMap()` read from an element-scope method threw
|
|
1132
1167
|
// `this._columnIndexCache.get is not a function` on a live board. Returns null
|
|
1133
|
-
// (never a revived value) when `val` is not a tagged form
|
|
1134
|
-
// objects, so null is unambiguous
|
|
1168
|
+
// (never a revived value) when `val` is not a tagged form. Five revive to
|
|
1169
|
+
// objects and the String tag to a string, so null is unambiguous — callers test
|
|
1170
|
+
// `!== null`, never truthiness (a String tag's value could in principle be '').
|
|
1135
1171
|
const _rehydrateTagged = (val) => {
|
|
1136
1172
|
if (!val || typeof val !== 'object') return null
|
|
1137
1173
|
const tag = val.__type
|
|
1138
1174
|
if (tag !== TYPE_TAG_REGEXP && tag !== TYPE_TAG_SET && tag !== TYPE_TAG_MAP &&
|
|
1139
|
-
tag !== TYPE_TAG_WEAKMAP && tag !== TYPE_TAG_WEAKSET) return null
|
|
1175
|
+
tag !== TYPE_TAG_WEAKMAP && tag !== TYPE_TAG_WEAKSET && tag !== TYPE_TAG_STRING) return null
|
|
1140
1176
|
const revived = _rehydrateTaggedValue(val)
|
|
1141
1177
|
return revived === val ? null : revived
|
|
1142
1178
|
}
|