@symbo.ls/utils 3.14.784 → 3.14.785
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 +9 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/legacyScopePreamble.js +1 -0
- package/dist/cjs/object.js +9 -9
- package/dist/esm/index.js +1 -1
- package/dist/esm/legacyScopePreamble.js +1 -0
- package/dist/esm/object.js +7 -7
- package/index.js +1 -0
- package/legacyScopePreamble.js +93 -0
- package/object.js +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @symbo.ls/utils
|
|
2
2
|
|
|
3
|
+
## 3.14.785
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixes:
|
|
8
|
+
- frank: a declaration spelled inside a string literal (for example inside the inlined `smbls/iife-string`) no longer hides or replaces a real bundle binding — a canvas publish no longer blocks on `[unresolvable-identifier] globalScope.G`, and literal text no longer lands in globalScope values.
|
|
9
|
+
- utils (runtime): an arrow function emitted by frank < 3.14.827 reads its element again — old library payloads no longer throw `__scope.X is not a function` (docs.symbols.app `isViewNavRoute`). Only the exact old frank scope preamble in an arrow with an element parameter is rewritten.
|
|
10
|
+
- element: the "custom prop … is a function" dev warning stays quiet for minified code, `is*`/`has*` conditions and `routerOptions`, and fires once per declared function.
|
|
11
|
+
|
|
3
12
|
## 3.14.784
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./key.js"),module.exports);o(r,require("./env.js"),module.exports);o(r,require("./types.js"),module.exports);o(r,require("./object.js"),module.exports);o(r,require("./function.js"),module.exports);o(r,require("./array.js"),module.exports);o(r,require("./node.js"),module.exports);o(r,require("./if.js"),module.exports);o(r,require("./log.js"),module.exports);o(r,require("./string.js"),module.exports);o(r,require("./globals.js"),module.exports);o(r,require("./cookie.js"),module.exports);o(r,require("./tags.js"),module.exports);o(r,require("./component.js"),module.exports);o(r,require("./props.js"),module.exports);o(r,require("./extends.js"),module.exports);o(r,require("./element.js"),module.exports);o(r,require("./state.js"),module.exports);o(r,require("./keys.js"),module.exports);o(r,require("./scope.js"),module.exports);o(r,require("./methods.js"),module.exports);o(r,require("./cache.js"),module.exports);o(r,require("./update.js"),module.exports);o(r,require("./triggerEvent.js"),module.exports);o(r,require("./projectKeys.js"),module.exports);o(r,require("./browser.js"),module.exports);o(r,require("./cdn.js"),module.exports);o(r,require("./date.js"),module.exports);o(r,require("./detectHeight.js"),module.exports);o(r,require("./fibonacci.js"),module.exports);o(r,require("./files.js"),module.exports);o(r,require("./load.js"),module.exports);o(r,require("./metadata.js"),module.exports);o(r,require("./scaling.js"),module.exports);o(r,require("./sharedLibraries.js"),module.exports);o(r,require("./string-extra.js"),module.exports);o(r,require("./style.js"),module.exports);o(r,require("./assets.js"),module.exports);
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./key.js"),module.exports);o(r,require("./env.js"),module.exports);o(r,require("./types.js"),module.exports);o(r,require("./object.js"),module.exports);o(r,require("./function.js"),module.exports);o(r,require("./array.js"),module.exports);o(r,require("./node.js"),module.exports);o(r,require("./if.js"),module.exports);o(r,require("./log.js"),module.exports);o(r,require("./string.js"),module.exports);o(r,require("./globals.js"),module.exports);o(r,require("./cookie.js"),module.exports);o(r,require("./tags.js"),module.exports);o(r,require("./component.js"),module.exports);o(r,require("./props.js"),module.exports);o(r,require("./extends.js"),module.exports);o(r,require("./element.js"),module.exports);o(r,require("./state.js"),module.exports);o(r,require("./keys.js"),module.exports);o(r,require("./scope.js"),module.exports);o(r,require("./methods.js"),module.exports);o(r,require("./cache.js"),module.exports);o(r,require("./update.js"),module.exports);o(r,require("./triggerEvent.js"),module.exports);o(r,require("./projectKeys.js"),module.exports);o(r,require("./legacyScopePreamble.js"),module.exports);o(r,require("./browser.js"),module.exports);o(r,require("./cdn.js"),module.exports);o(r,require("./date.js"),module.exports);o(r,require("./detectHeight.js"),module.exports);o(r,require("./fibonacci.js"),module.exports);o(r,require("./files.js"),module.exports);o(r,require("./load.js"),module.exports);o(r,require("./metadata.js"),module.exports);o(r,require("./scaling.js"),module.exports);o(r,require("./sharedLibraries.js"),module.exports);o(r,require("./string-extra.js"),module.exports);o(r,require("./style.js"),module.exports);o(r,require("./assets.js"),module.exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var o in e)g(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of O(e))!b.call(t,n)&&n!==o&&g(t,n,{get:()=>e[n],enumerable:!(s=y(e,n))||s.enumerable});return t};var h=t=>u(g({},"__esModule",{value:!0}),t);var w={};R(w,{repairLegacyArrowScopePreamble:()=>d});module.exports=h(w);const $=["$R?.scope ?? $R?.context?.globalScope ?? {}","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()","(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"],p=(t,e)=>t.split("$R").join(e),P=$.map(t=>[p(t,"this"),t]),i="const __scope = ",j=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,a=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,x=/^[A-Za-z_$][\w$]*$/,c=(t,e)=>typeof t=="string"&&new RegExp("^"+e+"\\d*$").test(t),S=t=>t.length>=2&&c(t[0],"el")?t[0]:t.length>=2&&c(t[1],"el")?t[1]:t.length>=1&&c(t[0],"el")||c(t[0],"element")||c(t[0],"node")?t[0]:t.find(e=>c(e,"element"))||null,d=t=>{if(typeof t!="string"||t.indexOf(i)===-1||t.indexOf("this")===-1)return t;const e=a.exec(t);if(!e)return t;let o=e[0].length;if(!t.startsWith(i,o))return t;o+=i.length;const s=j.exec(t.slice(o,o+400));s&&(o+=s[0].length);const n=P.find(([r])=>t.startsWith(r,o));if(!n)return t;const l=o+n[0].length;if(t[l]!==(s?")":";"))return t;const f=(e[1]!==void 0?e[1]:e[2]).split(",").map(r=>r.split("=")[0].trim()).filter(Boolean);if(f.some(r=>!x.test(r)))return t;const _=S(f);return _?t.slice(0,o)+p(n[1],_)+t.slice(l):t};
|
package/dist/cjs/object.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var
|
|
1
|
+
"use strict";var P=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var le=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of se(t))!fe.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=ce(t,r))||o.enumerable});return e};var ae=e=>ue(P({},"__esModule",{value:!0}),e);var ct={};le(ct,{REVIVED_MARK:()=>C,clone:()=>he,createNestedObject:()=>je,createObjectWithoutPrototype:()=>ie,deepClone:()=>ge,deepContains:()=>Xe,deepDestringifyFunctions:()=>We,deepMerge:()=>de,deepStringifyFunctions:()=>N,destringifyGlobalScope:()=>Ge,detectInfiniteLoop:()=>rt,excludeKeysFromObject:()=>it,exec:()=>R,getFunctionSource:()=>be,getInObjectByPath:()=>nt,hasFunction:()=>k,hasOwnProperty:()=>Ke,isCyclic:()=>ot,isEmpty:()=>ne,isEmptyObject:()=>Be,isEqualDeep:()=>oe,isFailedRevival:()=>Fe,isLazyFunction:()=>ze,isRevived:()=>Ze,isStringTag:()=>Ye,makeObjectWithoutPrototype:()=>Ue,map:()=>pe,markRevived:()=>te,merge:()=>ye,objectToString:()=>D,overwrite:()=>qe,overwriteDeep:()=>re,overwriteShallow:()=>Ve,removeFromObject:()=>Qe,removeNestedKeyByPath:()=>et,setInObjectByPath:()=>tt,stringToObject:()=>He});module.exports=ae(ct);var S=require("./globals.js"),l=require("./types.js"),X=require("./array.js"),Q=require("./string.js"),_=require("./node.js"),j=require("./keys.js"),ee=require("./legacyScopePreamble.js");const I="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},pe=(e,t,n)=>{for(const o in t)e[o]=R(t[o],n)},ye=(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},de=(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},he=(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},ge=(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},_e=/^[A-Za-z_$][A-Za-z0-9_$]*$/,we=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,z=e=>{const t=String(e);return(0,Q.stringIncludesAny)(t,[`
|
|
2
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=
|
|
3
|
+
`;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],u=_e.test(i)?i:we(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
5
|
`:(0,l.isObjectLike)(s)&&s!==null?r+=`${o} ${D(s,t+2)},
|
|
6
|
-
`:(0,l.isString)(s)?r+=`${o} ${
|
|
6
|
+
`:(0,l.isString)(s)?r+=`${o} ${z(s)},
|
|
7
7
|
`:r+=`${o} ${s},
|
|
8
|
-
`;r+=`${o} ]`}else(0,l.isObjectLike)(c)?r+=D(c,t+1):(0,l.isString)(c)?r+=
|
|
9
|
-
`}return r+=`${o}}`,r},
|
|
8
|
+
`;r+=`${o} ]`}else(0,l.isObjectLike)(c)?r+=D(c,t+1):(0,l.isString)(c)?r+=z(c):r+=c;r+=`,
|
|
9
|
+
`}return r+=`${o}}`,r},Oe=[/^\(\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=/^["[{]/,Ee=/^(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("("))||Ee.test(t)||!Oe.some(i=>i.test(t)))return!1;const r=t.charCodeAt(0);return!(r===123&&!n||r===91||Se.test(t)&&!n)},b=e=>(0,eval)(e),xe=(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
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=
|
|
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},
|
|
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;e=(0,ee.repairLegacyArrowScopePreamble)(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=xe(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,Ae=/^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,$e=/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/,ke=/^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/,Pe=/^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,Te=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,Re=(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)},Ne=e=>{let t=e,n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;n&&(t=t.slice(n));let o=Ae.exec(t);if(o){if(o[2]||M(t)!==125)return null;const r=o[3]||"";return r&&Re(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=$e.exec(t)||ke.exec(t),o?{src:e,name:"",kind:T,async:!!o[1],fn:void 0}:(o=Pe.exec(t),o&&!Te.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},De=(e,t,n)=>Reflect.construct(e,t,n);function Ce(){const e=O.get(this);return e?e.src.trim():Function.prototype.toString.call(this)}const me={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:Ce,writable:!0,configurable:!0}},Ie=Object.getPrototypeOf(async function(){}),Le=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?De(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,me),e.async&&Object.setPrototypeOf(t,Ie),t},Y=(e,t,n,o)=>{const r=Ne(e);return r?(r.key=t,r.index=n,r.opts=o,Le(r)):A(e,n===-1?`"${t}"`:`array index ${n} (prop "${t}")`,o)},ze=e=>typeof e=="function"&&O.has(e),be=e=>{const t=O.get(e);return t?t.src.trim():Function.prototype.toString.call(e)},Fe=e=>{const t=typeof e=="function"?O.get(e):void 0;return t?(t.fn===void 0?$(t):t.fn)===null:!1},ve=new Set(["components","pages","functions","methods","snippets","app","globalScope"]),Me={window:{eval:b}},We=(e,t={},n=Me)=>{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?ve.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 m={};g.push(m),c.push([h,m,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 te(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")},Ye=q,C=Symbol.for("smbls.revived"),te=e=>{if(e&&typeof e=="object")try{e[C]=!0}catch{}return e},Ze=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},Ge=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},He=(e,t={verbose:!0})=>{try{return e?S.window.eval("("+e+")"):{}}catch(n){t.verbose&&console.warn(n)}},Ke=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),ne=e=>{for(const t in e)return!1;return!0},Be=e=>(0,l.isObject)(e)&&ne(e),Ue=()=>Object.create(null),qe=(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},Ve=(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},re=(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]=re(s,y,n,o):y!==void 0&&(e[u]=y)}return e},oe=(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)||!oe(e[c],t[c],n))return!1}return!0},Je=new Set(["node","__ref"]),Xe=(e,t,n=Je)=>{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)},Qe=(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},ie=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]=ie(e[n]));return t},je=(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},et=(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]},tt=(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},nt=(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},rt=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},ot=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)},it=(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/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./key.js";export*from"./env.js";export*from"./types.js";export*from"./object.js";export*from"./function.js";export*from"./array.js";export*from"./node.js";export*from"./if.js";export*from"./log.js";export*from"./string.js";export*from"./globals.js";export*from"./cookie.js";export*from"./tags.js";export*from"./component.js";export*from"./props.js";export*from"./extends.js";export*from"./element.js";export*from"./state.js";export*from"./keys.js";export*from"./scope.js";export*from"./methods.js";export*from"./cache.js";export*from"./update.js";export*from"./triggerEvent.js";export*from"./projectKeys.js";export*from"./browser.js";export*from"./cdn.js";export*from"./date.js";export*from"./detectHeight.js";export*from"./fibonacci.js";export*from"./files.js";export*from"./load.js";export*from"./metadata.js";export*from"./scaling.js";export*from"./sharedLibraries.js";export*from"./string-extra.js";export*from"./style.js";export*from"./assets.js";
|
|
1
|
+
export*from"./key.js";export*from"./env.js";export*from"./types.js";export*from"./object.js";export*from"./function.js";export*from"./array.js";export*from"./node.js";export*from"./if.js";export*from"./log.js";export*from"./string.js";export*from"./globals.js";export*from"./cookie.js";export*from"./tags.js";export*from"./component.js";export*from"./props.js";export*from"./extends.js";export*from"./element.js";export*from"./state.js";export*from"./keys.js";export*from"./scope.js";export*from"./methods.js";export*from"./cache.js";export*from"./update.js";export*from"./triggerEvent.js";export*from"./projectKeys.js";export*from"./legacyScopePreamble.js";export*from"./browser.js";export*from"./cdn.js";export*from"./date.js";export*from"./detectHeight.js";export*from"./fibonacci.js";export*from"./files.js";export*from"./load.js";export*from"./metadata.js";export*from"./scaling.js";export*from"./sharedLibraries.js";export*from"./string-extra.js";export*from"./style.js";export*from"./assets.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const p=["$R?.scope ?? $R?.context?.globalScope ?? {}","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()","(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"],_=(t,e)=>t.split("$R").join(e),y=p.map(t=>[_(t,"this"),t]),g="const __scope = ",O=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,b=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,R=/^[A-Za-z_$][\w$]*$/,n=(t,e)=>typeof t=="string"&&new RegExp("^"+e+"\\d*$").test(t),u=t=>t.length>=2&&n(t[0],"el")?t[0]:t.length>=2&&n(t[1],"el")?t[1]:t.length>=1&&n(t[0],"el")||n(t[0],"element")||n(t[0],"node")?t[0]:t.find(e=>n(e,"element"))||null,$=t=>{if(typeof t!="string"||t.indexOf(g)===-1||t.indexOf("this")===-1)return t;const e=b.exec(t);if(!e)return t;let o=e[0].length;if(!t.startsWith(g,o))return t;o+=g.length;const c=O.exec(t.slice(o,o+400));c&&(o+=c[0].length);const r=y.find(([s])=>t.startsWith(s,o));if(!r)return t;const i=o+r[0].length;if(t[i]!==(c?")":";"))return t;const l=(e[1]!==void 0?e[1]:e[2]).split(",").map(s=>s.split("=")[0].trim()).filter(Boolean);if(l.some(s=>!R.test(s)))return t;const f=u(l);return f?t.slice(0,o)+_(r[1],f)+t.slice(i):t};export{$ as repairLegacyArrowScopePreamble};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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
|
|
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";import{repairLegacyArrowScopePreamble as oe}from"./legacyScopePreamble.js";const m="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,I=(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 I(c,t,n,o)}}return e},ve=(e,t,n)=>{for(const o in t)e[o]=I(t[o],n)},Me=(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},We=(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},Ye=(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},Ze=(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},z=(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]={},z(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]={},z(c,r[i])):P(c)?r[i]=c.toString():r[i]=c}}else t[n]=o}return t},ie=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ce=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
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=
|
|
3
|
+
`;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],l=ie.test(i)?i:ce(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
5
|
`:g(s)&&s!==null?r+=`${o} ${F(s,t+2)},
|
|
6
6
|
`:O(s)?r+=`${o} ${b(s)},
|
|
7
7
|
`:r+=`${o} ${s},
|
|
8
8
|
`;r+=`${o} ]`}else g(c)?r+=F(c,t+1):O(c)?r+=b(c):r+=c;r+=`,
|
|
9
|
-
`}return r+=`${o}}`,r},
|
|
9
|
+
`}return r+=`${o}}`,r},se=[/^\(\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]*\}$/],fe=/^["[{]/,le=/^(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("("))||le.test(t)||!se.some(i=>i.test(t)))return!1;const r=t.charCodeAt(0);return!(r===123&&!n||r===91||fe.test(t)&&!n)},v=e=>(0,eval)(e),ue=(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)}},M=1,D=2,E=new WeakMap,
|
|
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;e=oe(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=ue(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,ae=/^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,pe=/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/,ye=/^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/,de=/^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,he=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,ge=(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)},_e=e=>{let t=e,n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;n&&(t=t.slice(n));let o=ae.exec(t);if(o){if(o[2]||Y(t)!==125)return null;const r=o[3]||"";return r&&ge(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=pe.exec(t)||ye.exec(t),o?{src:e,name:"",kind:D,async:!!o[1],fn:void 0}:(o=de.exec(t),o&&!he.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},we=(e,t,n)=>Reflect.construct(e,t,n);function Oe(){const e=E.get(this);return e?e.src.trim():Function.prototype.toString.call(this)}const Se={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:Oe,writable:!0,configurable:!0}},Ee=Object.getPrototypeOf(async function(){}),xe=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?we(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,Se),e.async&&Object.setPrototypeOf(t,Ee),t},G=(e,t,n,o)=>{const r=_e(e);return r?(r.key=t,r.index=n,r.opts=o,xe(r)):T(e,n===-1?`"${t}"`:`array index ${n} (prop "${t}")`,o)},Ge=e=>typeof e=="function"&&E.has(e),He=e=>{const t=E.get(e);return t?t.src.trim():Function.prototype.toString.call(e)},Ke=e=>{const t=typeof e=="function"?E.get(e):void 0;return t?(t.fn===void 0?R(t):t.fn)===null:!1},Ae=new Set(["components","pages","functions","methods","snippets","app","globalScope"]),$e={window:{eval:v}},Be=(e,t={},n=$e)=>{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?Ae.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 ke(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")},Ue=J,X=Symbol.for("smbls.revived"),ke=e=>{if(e&&typeof e=="object")try{e[X]=!0}catch{}return e},qe=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},Ve=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
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
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},
|
|
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},Je=(e,t={verbose:!0})=>{try{return e?A.eval("("+e+")"):{}}catch(n){t.verbose&&console.warn(n)}},Xe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),Pe=e=>{for(const t in e)return!1;return!0},Qe=e=>x(e)&&Pe(e),je=()=>Object.create(null),et=(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},tt=(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},Te=(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]=Te(s,p,n,o):p!==void 0&&(e[l]=p)}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},Ne=new Set(["node","__ref"]),nt=(e,t,n=Ne)=>{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)},rt=(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},De=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]=De(e[n]));return t},ot=(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},it=(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]},ct=(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},st=(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},ft=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(m==="test"||m==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",n),!0},lt=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)},ut=(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,Ye as clone,ot as createNestedObject,De as createObjectWithoutPrototype,Ze as deepClone,nt as deepContains,Be as deepDestringifyFunctions,We as deepMerge,z as deepStringifyFunctions,Ve as destringifyGlobalScope,ft as detectInfiniteLoop,ut as excludeKeysFromObject,I as exec,He as getFunctionSource,st as getInObjectByPath,N as hasFunction,Xe as hasOwnProperty,lt as isCyclic,Pe as isEmpty,Qe as isEmptyObject,Re as isEqualDeep,Ke as isFailedRevival,Ge as isLazyFunction,qe as isRevived,Ue as isStringTag,je as makeObjectWithoutPrototype,ve as map,ke as markRevived,Me as merge,F as objectToString,et as overwrite,Te as overwriteDeep,tt as overwriteShallow,rt as removeFromObject,it as removeNestedKeyByPath,ct as setInObjectByPath,Je as stringToObject};
|
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from './cache.js'
|
|
|
25
25
|
export * from './update.js'
|
|
26
26
|
export * from './triggerEvent.js'
|
|
27
27
|
export * from './projectKeys.js'
|
|
28
|
+
export * from './legacyScopePreamble.js'
|
|
28
29
|
|
|
29
30
|
// ── Merged from the former @symbo.ls/smbls-utils package (4.x) ────────────
|
|
30
31
|
export * from './browser.js'
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// LEGACY ARROW SCOPE PREAMBLE — FW-STASHED-CALLBACK-WARNING-FALSE-POSITIVES-1
|
|
4
|
+
// (item D).
|
|
5
|
+
//
|
|
6
|
+
// frank prefixes an emitted component / page function with a `__scope`
|
|
7
|
+
// preamble that finds the element's scope through a RECEIVER (`ref`). Before
|
|
8
|
+
// 3.14.827 (frank c068598ba) the receiver was chosen by an exact `'el'` name
|
|
9
|
+
// test, so a parameter esbuild had renamed to `el2` fell through to `this`:
|
|
10
|
+
//
|
|
11
|
+
// (el2, s4) => { const __scope = (() => { const r = this; … })(); … }
|
|
12
|
+
//
|
|
13
|
+
// In an ARROW function `this` is lexical — the revival site's, never the
|
|
14
|
+
// element — and DOMQL calls factory props without a receiver anyway, so
|
|
15
|
+
// `__scope` was `{}` and every peer read threw (`__scope.isViewNavRoute is
|
|
16
|
+
// not a function` on docs.symbols.app: 297 such arrows in system/shared 1.4.4).
|
|
17
|
+
// Current frank emits `const r = el2`. Payloads pushed before it stay broken
|
|
18
|
+
// until re-pushed; this repair makes the runtime read them the way current
|
|
19
|
+
// frank would have written them.
|
|
20
|
+
//
|
|
21
|
+
// Narrow by construction:
|
|
22
|
+
// • an ARROW source only (a `function` source's `this` is the receiver its
|
|
23
|
+
// caller binds — right as it is);
|
|
24
|
+
// • the preamble must be the FIRST statement of the arrow's block body,
|
|
25
|
+
// spelled EXACTLY as one of frank's historic receiver templates with
|
|
26
|
+
// `this` as the receiver (below, from frank's git history), optionally
|
|
27
|
+
// inside the shared-library scope wrapper (@symbo.ls/utils
|
|
28
|
+
// sharedLibraries.js scopeLibraryText) — user code that merely mentions
|
|
29
|
+
// `this` never matches;
|
|
30
|
+
// • the receiver becomes the parameter current frank's getElementRef picks
|
|
31
|
+
// for a component / page function (`el\d*` first or second,
|
|
32
|
+
// `element\d*` / `node\d*` first, any `element\d*`); no such parameter
|
|
33
|
+
// (a helper like `(s4) => …`, a destructured list) → left untouched.
|
|
34
|
+
|
|
35
|
+
const TEMPLATES = [
|
|
36
|
+
// frank's receiver forms, oldest first. `$R` is the receiver.
|
|
37
|
+
'$R?.scope ?? $R?.context?.globalScope ?? {}',
|
|
38
|
+
'(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()',
|
|
39
|
+
'(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()',
|
|
40
|
+
'(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()',
|
|
41
|
+
'(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()',
|
|
42
|
+
"(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"
|
|
43
|
+
]
|
|
44
|
+
const withReceiver = (tpl, ref) => tpl.split('$R').join(ref)
|
|
45
|
+
const THIS_FORMS = TEMPLATES.map((tpl) => [withReceiver(tpl, 'this'), tpl])
|
|
46
|
+
|
|
47
|
+
const DECL = 'const __scope = '
|
|
48
|
+
// sharedLibraries.js scopeLibraryText's wrapper around a preamble's value
|
|
49
|
+
const LIBRARY_WRAPPER_RE = /^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /
|
|
50
|
+
// An arrow head with a flat parameter list (no nested parens, strings,
|
|
51
|
+
// destructuring) and a block body.
|
|
52
|
+
const ARROW_HEAD_RE = /^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/
|
|
53
|
+
const IDENT_RE = /^[A-Za-z_$][\w$]*$/
|
|
54
|
+
|
|
55
|
+
const named = (p, base) => typeof p === 'string' && new RegExp('^' + base + '\\d*$').test(p)
|
|
56
|
+
|
|
57
|
+
// Mirror of frank scopeRewriter getElementRef for component / page paths.
|
|
58
|
+
const elementParam = (params) => {
|
|
59
|
+
if (params.length >= 2 && named(params[0], 'el')) return params[0]
|
|
60
|
+
if (params.length >= 2 && named(params[1], 'el')) return params[1]
|
|
61
|
+
if (params.length >= 1 && named(params[0], 'el')) return params[0]
|
|
62
|
+
if (named(params[0], 'element') || named(params[0], 'node')) return params[0]
|
|
63
|
+
return params.find((p) => named(p, 'element')) || null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Rewrite an old frank `this`-receiver scope preamble at the start of an
|
|
68
|
+
* ARROW function source to read the element parameter. Returns the source
|
|
69
|
+
* unchanged when it is not exactly that shape.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} src - a stored function source
|
|
72
|
+
* @returns {string}
|
|
73
|
+
*/
|
|
74
|
+
export const repairLegacyArrowScopePreamble = (src) => {
|
|
75
|
+
if (typeof src !== 'string' || src.indexOf(DECL) === -1 || src.indexOf('this') === -1) return src
|
|
76
|
+
const head = ARROW_HEAD_RE.exec(src)
|
|
77
|
+
if (!head) return src
|
|
78
|
+
let at = head[0].length
|
|
79
|
+
if (!src.startsWith(DECL, at)) return src
|
|
80
|
+
at += DECL.length
|
|
81
|
+
const wrapper = LIBRARY_WRAPPER_RE.exec(src.slice(at, at + 400))
|
|
82
|
+
if (wrapper) at += wrapper[0].length
|
|
83
|
+
const form = THIS_FORMS.find(([text]) => src.startsWith(text, at))
|
|
84
|
+
if (!form) return src
|
|
85
|
+
const end = at + form[0].length
|
|
86
|
+
if (src[end] !== (wrapper ? ')' : ';')) return src
|
|
87
|
+
const raw = head[1] !== undefined ? head[1] : head[2]
|
|
88
|
+
const params = raw.split(',').map((p) => p.split('=')[0].trim()).filter(Boolean)
|
|
89
|
+
if (params.some((p) => !IDENT_RE.test(p))) return src
|
|
90
|
+
const ref = elementParam(params)
|
|
91
|
+
if (!ref) return src
|
|
92
|
+
return src.slice(0, at) + withReceiver(form[1], ref) + src.slice(end)
|
|
93
|
+
}
|
package/object.js
CHANGED
|
@@ -13,6 +13,7 @@ import { unstackArrayOfObjects } from './array.js'
|
|
|
13
13
|
import { stringIncludesAny } from './string.js'
|
|
14
14
|
import { isDOMNode } from './node.js'
|
|
15
15
|
import { METHODS_EXL } from './keys.js'
|
|
16
|
+
import { repairLegacyArrowScopePreamble } from './legacyScopePreamble.js'
|
|
16
17
|
|
|
17
18
|
const ENV = process.env.NODE_ENV
|
|
18
19
|
|
|
@@ -549,6 +550,11 @@ const _destringifyFnString = (str, label, opts, lazy) => {
|
|
|
549
550
|
// on every project fetch (2026-06-06).
|
|
550
551
|
const head = String(str).trimStart()
|
|
551
552
|
if (/^(export|import)\s/.test(head)) return str
|
|
553
|
+
// An arrow emitted by frank < 3.14.827 whose `__scope` preamble reads the
|
|
554
|
+
// lexical `this` instead of its element parameter compiles as current frank
|
|
555
|
+
// would have written it (legacyScopePreamble.js) — every revival, eager or
|
|
556
|
+
// lazy, compiles through here.
|
|
557
|
+
str = repairLegacyArrowScopePreamble(str)
|
|
552
558
|
try {
|
|
553
559
|
return opts.window.eval(`(${str})`)
|
|
554
560
|
} catch (e) {
|