@symbo.ls/utils 3.14.784 → 3.14.786
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 +25 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/legacyScopePreamble.js +1 -0
- package/dist/cjs/metadata.js +2 -2
- package/dist/cjs/object.js +9 -9
- package/dist/cjs/polyglotLang.js +1 -0
- package/dist/cjs/sharedLibraries.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/legacyScopePreamble.js +1 -0
- package/dist/esm/metadata.js +2 -2
- package/dist/esm/object.js +7 -7
- package/dist/esm/polyglotLang.js +1 -0
- package/dist/esm/sharedLibraries.js +2 -2
- package/index.js +2 -0
- package/legacyScopePreamble.js +122 -0
- package/metadata.js +30 -11
- package/object.js +6 -0
- package/package.json +2 -2
- package/polyglotLang.js +22 -0
- package/sharedLibraries.js +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @symbo.ls/utils
|
|
2
2
|
|
|
3
|
+
## 3.14.786
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Performance pass on the 3.14.827–3.14.832 batch, and opt-in View Transitions.
|
|
8
|
+
|
|
9
|
+
- Element create is faster than 3.14.826 again (kekela-like 4,068-element tree: create CPU min 1,265–1,355 ms vs 1,361–1,532 ms on 3.14.826). Per-definition caching of the extends merge layers (46,330 → 13,600 entries), no per-element source-text reads, one attribute writer.
|
|
10
|
+
- `css()` 3x faster (21 → 7 µs per call), byte-identical CSS output.
|
|
11
|
+
- Helmet renders a head layer only when its values change (20 `root.update({})` → 0 head renders, was 40). One runtime head writer: `applyElementMetadata`.
|
|
12
|
+
- brender/mermaid: registry script is escaped on the ISR and non-adopt paths; head/SSR output byte-identical otherwise.
|
|
13
|
+
- View Transitions for page switches (opt-in), `viewTransitionName` / `viewTransitionClass` flat props, `designSystem.viewTransition` animations.
|
|
14
|
+
- utils exports shared helpers used by helmet, frank, fetch and polyglot (escapeHtml, jsonForScript, alternateLinkKey, faviconLinkKey, bareLibraryKey, librarySpecsFor, polyglotLangStorageKey, ...).
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @symbo.ls/fetch@3.14.664
|
|
18
|
+
|
|
19
|
+
## 3.14.785
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Fixes:
|
|
24
|
+
- 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.
|
|
25
|
+
- 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.
|
|
26
|
+
- 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.
|
|
27
|
+
|
|
3
28
|
## 3.14.784
|
|
4
29
|
|
|
5
30
|
### 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("./polyglotLang.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 b=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var o in e)g(t,o,{get:e[o],enumerable:!0})},$=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of u(e))!R.call(t,n)&&n!==o&&g(t,n,{get:()=>e[n],enumerable:!(s=b(e,n))||s.enumerable});return t};var P=t=>$(g({},"__esModule",{value:!0}),t);var w={};h(w,{repairLegacyArrowScopePreamble:()=>E,scopeElementParam:()=>O,scopeReceiverExpression:()=>j});module.exports=P(w);const i=["$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 : {}); })()"],f=(t,e)=>t.split("$R").join(e),x=i.map(t=>[f(t,"this"),t]),j=t=>f(i[i.length-1],t),l="const __scope = ",d=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,S=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,a=/^[A-Za-z_$][\w$]*$/,c=(t,e)=>typeof t=="string"&&new RegExp("^"+e+"\\d*$").test(t),O=(t,e)=>{if(t.length>=2&&c(t[0],"el"))return t[0];if(t.length>=2&&c(t[1],"el"))return t[1];if(t.length>=1&&c(t[0],"el")||c(t[0],"element")||c(t[0],"node"))return t[0];if(typeof e=="function"){const o=e();if(o&&t.includes(o))return o}return t.find(o=>c(o,"element"))||null},E=t=>{if(typeof t!="string"||t.indexOf(l)===-1||t.indexOf("this")===-1)return t;const e=S.exec(t);if(!e)return t;let o=e[0].length;if(!t.startsWith(l,o))return t;o+=l.length;const s=d.exec(t.slice(o,o+400));s&&(o+=s[0].length);const n=x.find(([r])=>t.startsWith(r,o));if(!n)return t;const _=o+n[0].length;if(t[_]!==(s?")":";"))return t;const p=(e[1]!==void 0?e[1]:e[2]).split(",").map(r=>r.split("=")[0].trim()).filter(Boolean);if(p.some(r=>!a.test(r)))return t;const y=O(p);return y?t.slice(0,o)+f(n[1],y)+t.slice(_):t};
|
package/dist/cjs/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var A=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
`)},
|
|
1
|
+
"use strict";var A=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var P=(t,n)=>{for(var e in n)A(t,e,{get:n[e],enumerable:!0})},R=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of U(n))!D.call(t,i)&&i!==e&&A(t,i,{get:()=>n[i],enumerable:!(r=T(n,i))||r.enumerable});return t};var _=t=>R(A({},"__esModule",{value:!0}),t);var Q={};P(Q,{alternateLinkKey:()=>E,escapeHtml:()=>l,faviconLinkKey:()=>K,fileEntryUrl:()=>W,generateHeadArrayTags:()=>x,generateMetaTags:()=>Y,getPageMetadata:()=>I,hashContent:()=>j,jsonForScript:()=>q,resolveFileReferences:()=>F});module.exports=_(Q);var b=require("./types.js"),M=require("./function.js");const l=t=>{if(t==null)return"";const n={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.toString().replace(/[&<>"']/g,e=>n[e])},q=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),N=t=>Object.entries(t||{}).filter(([n,e])=>e!==void 0).map(([n,e])=>`${n}="${l(e)}"`).join(" "),j=t=>{let n=5381;const e=String(t);for(let r=0;r<e.length;r++)n=(n*33^e.charCodeAt(r))>>>0;return n.toString(36)},C=new Set(["jsonLd","styles","scripts"]),x=t=>{const n=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const r=typeof e=="string"?e:JSON.stringify(e),i=String(r).replace(/<\/script/gi,"<\\/script");n.push(`<script type="application/ld+json" data-smbls-jsonld="${j(r)}">${i}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const r=String(e).replace(/<\/style/gi,"<\\/style");n.push(`<style data-smbls-style="${j(r)}">${r}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const r=typeof e=="string",i=r?e:e.src;if(!i&&!e.body)continue;const o=[];i&&o.push(`src="${l(i)}"`),r||(e.type&&o.push(`type="${l(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${l(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${l(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${l(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const p=` data-smbls-script="${l(i||j(e.body||""))}"`;if(!r&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");n.push(`<script ${o.join(" ")}${p}>${d}<\/script>`)}else n.push(`<script ${o.join(" ")}${p}><\/script>`)}return n},E=t=>`${t.hreflang||""}|${t.href||""}`,K=t=>(0,b.isObject)(t)?j(JSON.stringify(t)):String(t),H=(t,n,e)=>t==="favicons"?Array.isArray(n)&&(typeof e=="string"||(0,b.isObject)(e))?` data-smbls-favicon="${l(K(e))}"`:"":(t==="icon"||t==="favicon")&&typeof n=="string"?` data-smbls-single-icon="${l(n)}"`:"",J=t=>(0,b.isObject)(t)?` data-smbls-alternate="${l(E(t))}"`:"",Y=(t,n)=>{n||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((r,[i,o])=>{if(!o&&o!==0&&o!==!1||C.has(i))return r;if(i==="title")return r.push(`<title>${l(o)}</title>`),r;if(i==="canonical")return r.push(`<link rel="canonical" href="${l(o)}">`),r;if(i==="manifest")return r.push(`<link rel="manifest" href="${l(o)}">`),r;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=H(i,o,c);if(typeof c=="string")r.push(`<link rel="icon" href="${l(c)}"${u}>`);else if(typeof c=="object"){const s=N(c);/rel=/.test(s)?r.push(`<link ${s}${u}>`):r.push(`<link rel="icon" ${s}${u}>`)}}),r;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([s,g])=>g!==void 0).map(([s,g])=>`${s}="${l(g)}"`).join(" ");r.push(`<link rel="alternate" ${u}${J(c)}>`)}}),r;const p=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")r.push(`<meta ${u}="${l(f)}" content="${l(c)}">`);else if(Array.isArray(c))c.forEach(s=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")r.push(`<meta ${u}="${l(f)}" content="${l(s)}">`);else if(typeof s=="object"){const g=Object.entries(s).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${l($)}"`).join(" ");r.push(`<meta ${g}>`)}});else if(typeof c=="object"){const s=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${l(y)}"`).join(" ");r.push(`<meta ${s}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return p(f,o,"http-equiv"),r}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return p(f,o,"itemprop"),r}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(h){const f=i.replace(h,"");return p(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),r}if(i.startsWith("apple:")||i.startsWith("msapplication:")){const f=i.startsWith("apple:")?"apple-":"msapplication-",c=i.replace(/^apple:|^msapplication:/,"");return p(`${f}${c}`,o,"name"),r}return p(i,o),r},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...x(t)),e.join(`
|
|
2
|
+
`)},B=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),S=t=>typeof t=="string"&&t.length>0,W=t=>{if(!t||typeof t!="object")return null;if(S(t.src))return t.src;const n=t.content;return!n||typeof n!="object"?null:S(n.src)?n.src:S(n.storageUrl)?n.storageUrl:null};function F(t,n){if(!n||typeof n!="object")return t;const e=i=>!B(i)||!Object.prototype.hasOwnProperty.call(n,i)?i:W(n[i])||i,r={...t};for(const[i,o]of Object.entries(r))typeof o=="string"?r[i]=e(o):Array.isArray(o)&&(r[i]=o.map(p=>typeof p=="string"?e(p):p));return r}function w(t,n){if(!t||!n)return;const e=n.split(".");let r=t;for(const i of e){if(r==null||typeof r!="object")return;r=r[i]}return r}function z(t,n){const e=w(t,n);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!(0,M.isStringFunction)(e))return e}function G(t,n,e){const i=(n.config||n.settings||{}).polyglot||n.polyglot,o=e?.lang||i?.defaultLang||"en",d=(i?.translations||{})[o]||{},h=[e?.state,n.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const s of h){const g=z(s,u);if(g!==void 0)return g}},c={...t};for(const[u,s]of Object.entries(c))typeof s!="string"||!s.includes("{{")||(c[u]=s.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??w(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const m=f(a);return m!==void 0?m:d[a]??w(d,a)??g}));return c}function L(t){if(!(0,b.isObject)(t))return{};const n={...t};for(const[e,r]of Object.entries(n))if(typeof r=="function"){const i=r.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){n[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const p=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(p){n[e]=`{{ ${p[1]} | polyglot }}`;continue}const d=i.match(/s\.(\w+(?:\.\w+)+)/);if(d){n[e]=`{{ ${d[1]} }}`;continue}delete n[e]}else if(typeof r=="string"){const i=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){n[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){n[e]=`{{ ${o[1]} | polyglot }}`;continue}if(r.includes("=>")&&r.includes("s.")){const p=r.match(/s\.(\w+(?:\.\w+)+)/);if(p){n[e]=`{{ ${p[1]} }}`;continue}}(0,M.isStringFunction)(r)&&delete n[e]}return n}function I(t,n,e,{isProduction:r=!1,channel:i="production"}={}){const o=t.pages?.[n],p=(0,b.isObject)(o?.state)&&o?.state,d=o?.metadata||o?.helmet||p||{},h=L(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=L(c);let s={};if(t.integrations?.seo?s={...t.integrations.seo,...u,...h}:Object.keys(u).length?s={...u,...h}:s={...h},!s.title){const a=t.name||t.key;a?r?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=G(s,t,e),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 g=f.has("og:url")?s["og:url"]:f.has("url")?s.url:void 0,y=e?.actualPathname||n;if(g)s["og:url"]=g;else if(s["og:url"]||s.url){const a=(s["og:url"]||s.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const m=y.startsWith("/")?y:"/"+y;s["og:url"]=a+m}}s=F(s,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,m]of Object.entries(s))if(typeof m=="string"&&m.includes("{{")){const O=m.replace(/\{\{[^}]*\}\}/g,"").trim();O?s[a]=O:a==="title"?s[a]=$:delete s[a]}return s}
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(t,a)=>{for(var n in a)o(t,n,{get:a[n],enumerable:!0})},_=(t,a,n,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of r(a))!c.call(t,e)&&e!==n&&o(t,e,{get:()=>a[e],enumerable:!(s=L(a,e))||s.enumerable});return t};var p=t=>_(o({},"__esModule",{value:!0}),t);var K={};l(K,{POLYGLOT_LANG_STORAGE_KEY:()=>g,polyglotFallbackLang:()=>G,polyglotLangStorageKey:()=>x});module.exports=p(K);const g="smbls_lang",x=t=>t&&t.storageLangKey||g,G=(t,a)=>t||a&&a.defaultLang||"en";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var $=Object.defineProperty;var
|
|
1
|
+
"use strict";var $=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var de=(e,n)=>{for(var o in n)$(e,o,{get:n[o],enumerable:!0})},he=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ye(n))!be.call(e,s)&&s!==o&&$(e,s,{get:()=>n[s],enumerable:!(t=pe(n,s))||t.enumerable});return e};var me=e=>he($({},"__esModule",{value:!0}),e);var ot={};de(ot,{LIBRARY_PACKAGES:()=>fe,LIBRARY_SCOPES_KEY:()=>k,__resetBuiltinMethodWarnings:()=>Le,bareLibraryKey:()=>C,bindLibraryGlobalScopes:()=>Ye,deepDefaults:()=>A,exposeBagGlobalScopes:()=>Je,fetchLibraryData:()=>ue,isWrappedLibrary:()=>_,libraryPackageSpecs:()=>ae,librarySpecsFor:()=>ce,mergeSharedLibraries:()=>ve,mergeSharedLibraryDesignSystems:()=>et,normalizeIgnoreList:()=>B,normalizeLibraryKey:()=>S,resolveSharedLibraries:()=>nt,sharedLibrary:()=>Oe,warnLibraryAliasCollision:()=>le});module.exports=me(ot);var f=require("./types.js"),L=require("./keys.js"),ie=require("./env.js"),b=require("./object.js");const R="system",ge="https://smbls-kv.nika-980.workers.dev",Se="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:R,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=R);const s=t?`${o}/${t}`:"";return{owner:o,key:t,full:s}}const A=(e,n,o,t)=>{for(const s in n){const i=t?`${t}/${s}`:s;o&&o.has(i)||(s in e?(0,f.isObject)(e[s])&&(0,f.isObject)(n[s])&&A(e[s],n[s],o,i):e[s]=n[s])}},F=(e,n,o)=>{if(!(0,f.isObject)(e)||!n.size)return e;const t=`${o}/`;let s=!1;for(const c of n)if(c.startsWith(t)){s=!0;break}if(!s)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const r=`${o}/${c}`;n.has(r)||(i[c]=F(e[c],n,r))}return i},_e=new Set,ke=new Set(["components","pages","functions","snippets","methods"]),V=(e,n)=>n===""&&ke.has(e),D=["fontFamily","fontfamily","font_family","FONT_FAMILY"],G=e=>{const n=new Map;if(!(0,f.isObject)(e))return n;for(const o of D){const t=e[o];if((0,f.isObject)(t))for(const s in t)!(0,f.isObject)(t[s])||!t[s].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(s))}return n},U=(e,n)=>{for(const o of D){const t=e[o];if(!(0,f.isObject)(t))continue;const s=n.get(o);let i=null;for(const c in t){const r=t[c];if(!(0,f.isObject)(r)||!r.isDefault||s&&s.has(c))continue;const l={...r};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},we=e=>e.replace(/\.js$/iu,""),B=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!(0,f.isString)(o))continue;const t=o.split("/").map(s=>we(s.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},Oe=(e,n={})=>({library:e,ignoreList:Array.isArray(n.ignoreList)?n.ignoreList:[]}),_=e=>(0,f.isObject)(e)&&Array.isArray(e.ignoreList)&&("library"in e||"key"in e||"name"in e),Y=e=>e.library!==void 0?e.library:e.key??e.name,j=new Set,Le=()=>{j.clear()},Ae=(e,n)=>{const o=n.filter(t=>!j.has(t));if(o.length){for(const t of o)j.add(t);(0,ie.isLoudDevRuntime)()&&console.warn(`[smbls] shared library "${e}" ships ${o.map(t=>`methods.${t}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},$e=(e,n,o)=>{let t=null;for(const s in e)if((0,L.isProtectedElementMethod)(s)&&(n.has(`methods/${s}`)||o.push(s),!t)){t={};for(const i in e)(0,L.isProtectedElementMethod)(i)||(t[i]=e[i])}return t||e},W=(e,n)=>{const o=B(e.sharedLibIgnore);return e.sharePages===!1&&o.add("pages"),o.size?new Set([...n,...o]):n},E=["functions","methods","snippets"],K=["components","pages"],z=Symbol.for("smbls.libraryScope"),k="__libraryScopes",I=new Map,Re=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),h=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),je=/const __scope = |const __peers_* = |const _s = el\?\.scope|\?\.context\?\.globalScope\?\./,J=e=>{try{return(0,b.getFunctionSource)(e)}catch{return null}},H=e=>{if(typeof e!="function")return null;const n=J(e);return(0,f.isString)(n)&&je.test(n)&&(0,b.hasFunction)(n)?n:null},q=e=>(0,f.isString)(e)&&(0,b.hasFunction)(e)||H(e)!==null,Ee=e=>{const n=e.globalScope;return(0,f.isObject)(n)&&Object.keys(n).some(o=>q(n[o]))?!0:E.some(o=>{const t=e[o];return!!t&&typeof t=="object"&&Object.keys(t).some(s=>q(t[s]))})},Ie=(e,n,o)=>{const t=e.globalScope,s=n.globalScope;if(o.has("globalScope")||!(0,f.isObject)(t)||!(0,f.isObject)(s)||!Ee(n))return 0;let i=0;for(const c of Object.keys(s))o.has(`globalScope/${c}`)||h(t,c)&&i++;return i},Pe=[[/const __scope = (\(\(\) => \{ const r = [\s\S]*?\}\)\(\));/g,"const __scope = $RESOLVE($1);"],[/const __scope = this \?\? \{\};/g,"const __scope = $RESOLVE(this ?? {});"],[/const (__peers_*) = (this && this !== globalThis && this\.context && this\.context\.globalScope \? this\.scope \?\? this\.context\.globalScope : this);/g,"const $1 = $RESOLVE($2);"],[/const _s = (el\?\.scope \?\? el\?\.context\?\.globalScope \?\? \{\});/g,"const _s = $RESOLVE($1);"],[/(?<![\w$.])(this|[A-Za-z_$][\w$]*)\?\.context\?\.globalScope\?\./g,"$RESOLVE($1?.context?.globalScope)?."]],Te=e=>{const n=e.split(""),o=[];let t=0,s=0;const i=(r,l)=>{for(let p=r;p<l;p++)n[p]!==`
|
|
2
2
|
`&&(n[p]="~")},c=()=>{const r=t;for(;t<e.length;){const l=e[t];if(l==="\\"){t+=2;continue}if(l==="`"){i(r,t),t++;return}if(l==="$"&&e[t+1]==="{"){i(r,t),t+=2,o.push(s),s++;return}t++}i(r,t)};for(;t<e.length;){const r=e[t];if(r==="/"&&e[t+1]==="/"){const l=e.indexOf(`
|
|
3
3
|
`,t),p=l===-1?e.length:l;i(t,p),t=p;continue}if(r==="/"&&e[t+1]==="*"){const l=e.indexOf("*/",t+2),p=l===-1?e.length:l+2;i(t,p),t=p;continue}if(r==='"'||r==="'"){const l=r,p=++t;for(;t<e.length&&e[t]!==l&&e[t]!==`
|
|
4
|
-
`;)e[t]==="\\"&&t++,t++;i(p,t),t++;continue}if(r==="`"){t++,c();continue}if(r==="{"){s++,t++;continue}if(r==="}"){if(s--,o.length&&s===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},
|
|
4
|
+
`;)e[t]==="\\"&&t++,t++;i(p,t),t++;continue}if(r==="`"){t++,c();continue}if(r==="{"){s++,t++;continue}if(r==="}"){if(s--,o.length&&s===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},Z=(e,n)=>{if(!(0,f.isString)(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!(0,b.hasFunction)(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[s,i]of Pe){const c=Te(t);t=t.replace(s,(...r)=>{const l=r[r.length-2];return c[l]==="~"||c[l]!==t[l]?r[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(p,a)=>r[Number(a)])})}return t},w=(e,n)=>{if((0,f.isString)(e))return Z(e,n);const o=H(e);return o===null?e:Z(o,n)},Be={lazy:!0,window:globalThis},Q=(e,n)=>{const o=w(e,n);if(o===e||!(0,f.isString)(o))return o;try{const t=(0,b.deepDestringifyFunctions)({v:o},{},Be).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},X=(e,n,o=new WeakMap)=>{if((0,f.isString)(e)||typeof e=="function")return Q(e,n);if((0,b.isStringTag)(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const s of Object.keys(e))t[s]=X(e[s],n,o);return t},Ce=(e,n)=>{const o={...e},t={};for(const s of Object.keys(e.globalScope))t[s]=w(e.globalScope[s],n);o.globalScope=t;for(const s of E){const i=e[s];if(!P(i))continue;const c={};for(const r of Object.keys(i))c[r]=Q(i[r],n);o[s]=c}for(const s of K)P(e[s])&&(o[s]=X(e[s],n));return o},x=new WeakMap,Me=(e,n,o)=>{let t=x.get(e);t||x.set(e,t=new Map);let s=t.get(n);if(s)return s;const i=(c,r)=>h(o,c)&&o[c]===r;return s=new Proxy(e,{get(c,r){if(typeof r=="symbol"||h(c,r))return Reflect.get(c,r);const l=Reflect.get(c,r);return h(n,r)&&(l===void 0||i(r,l))||l===void 0?n[r]:l},set(c,r,l){return typeof r!="symbol"&&!h(c,r)&&h(n,r)?(n[r]=l,!0):Reflect.set(c,r,l)},has:(c,r)=>Reflect.has(c,r)||r in n}),t.set(n,s),s},Ne=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",Fe=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Ne(n)?Me(n,o.libGs,o.consumerGs):n:n},Ve=()=>{typeof globalThis[z]!="function"&&Object.defineProperty(globalThis,z,{value:Fe,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,De=(e,n,o)=>{const t=O(e);return!!t&&t.some(s=>s&&s.index===n&&(!s.key||s.key===o.key)&&(0,f.isString)(s.id)&&Ge(e,s.id))},Ge=(e,n)=>{const o=JSON.stringify(n),t=new Set,s=i=>{if((0,f.isString)(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(s(i[c]))return!0;return!1};for(const i of["globalScope",...E,...K])if(s(e[i]))return!0;return!1},Ue=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},v=new WeakMap,Ye=(e,n=null)=>{const o=e&&O(e);if(!o||!o.length)return 0;const t=e.globalScope;if(!(0,f.isObject)(t))return 0;const s=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];let i=v.get(t);i||v.set(t,i=new Set),Ve();let c=0;for(const r of o){if(!r||!(0,f.isString)(r.id)||i.has(r.id))continue;const l=T(s[r.index]);if(!l||!(0,f.isObject)(l.globalScope)||r.key&&l.key!==r.key)continue;const p=y=>typeof y=="function"?J(y):y,a=(y,m)=>{if(y===m)return!0;const M=p(y),N=p(m);return(0,f.isString)(M)||(0,f.isString)(N)?M===N:JSON.stringify(y)===JSON.stringify(m)},u=(0,f.isObject)(n)?(Array.isArray(r.landed)?r.landed:[]).filter(y=>(0,f.isString)(y)&&h(l.globalScope,y)&&h(n,y)&&a(n[y],w(l.globalScope[y],r.id))):[],d=(0,b.destringifyGlobalScope)(Ue(l.globalScope,r.id));Object.setPrototypeOf(d,t),I.set(r.id,{libGs:d,consumerGs:t});for(const y of u)t[y]=d[y];i.add(r.id),c++}return c},We=/^@symbo[-.]ls\//,C=e=>e.includes("/")?e.slice(e.indexOf("/")+1):e,ce=e=>[`@symbo-ls/${e}`,`@symbo.ls/${e}`],ae=(e,n)=>{const o=[];if(!Array.isArray(e))return o;const t=new Map,s=(c,r,l)=>{for(const p of ce(c)){const a=t.get(p);if(a===void 0){t.set(p,r),o.push([p,r]);continue}a!==r&&l&&typeof n=="function"&&n({spec:p,kept:a,refused:r})}},i=[];for(const c of e){const r=T(c);if(!r||typeof r!="object"||r.__isStub)continue;const l=r.key||r.name||r.__libraryKey,p=[];for(const a of[r.key,r.name,r.__libraryKey,r.__libraryName]){if(typeof a!="string"||!a||a!==l&&!We.test(a))continue;const u=C(a);u&&!p.includes(u)&&p.push(u)}p.forEach((a,u)=>{u===0&&l&&C(l)===a?s(a,r,!1):i.push([a,r])})}for(const[c,r]of i)s(c,r,!0);return o},le=({spec:e,kept:n,refused:o})=>{typeof console>"u"||console.warn(`[smbls] shared library "${o&&o.key}" also claims ${e}, which "${n&&n.key}" already owns; ${e} stays with "${n&&n.key}".`)},ee=["functions","methods","snippets"],fe=Symbol.for("smbls.libraryPackages"),g=new WeakMap,Ke=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ze=e=>({get globalScope(){return e()}}),te=(e,n,o)=>{const t={};for(const s of Object.keys(e))t[s]=e[s];return Object.defineProperty(t,"context",{configurable:!0,enumerable:!1,writable:!0,value:ze(n)}),g.set(t,o),t},ne=e=>!Ke(e)||!g.has(e)&&Object.prototype.hasOwnProperty.call(e,"context"),Je=e=>{if(!e||typeof e!="object")return;const n=()=>e.globalScope;for(const t of ee){const s=e[t];ne(s)||g.get(s)===e||(e[t]=te(s,n,e))}if(Array.isArray(e.sharedLibraries)){const t=O(e)||[];e.sharedLibraries=e.sharedLibraries.map((s,i)=>{const c=_(s)&&s&&"library"in s,r=T(s);if(!r||typeof r!="object"||r.__isStub||g.get(r)===e)return s;const l=t.find(u=>u&&u.index===i&&(!u.key||u.key===r.key)),p=()=>{const u=l&&I.get(l.id);return u&&u.consumerGs===e.globalScope?u.libGs:e.globalScope},a={...r};for(const u of ee)ne(r[u])||(a[u]=te(r[u],p,e));return g.set(a,e),c?{...s,library:a}:a})}const o=e.globalScope;if(o&&typeof o=="object"){const t={};for(const[s,i]of ae(e.sharedLibraries,le))t[s]=i;try{Object.defineProperty(o,fe,{configurable:!0,enumerable:!1,writable:!0,value:t})}catch{}}},He=(e,n,o,t="library",s=-1)=>{const i=W(n,o),c=!De(e,s,n)&&Ie(e,n,i)>0?`${t}#${Re()}`:null,r=c?Ce(n,c):n,l=c?new Set(Object.keys(e.globalScope)):null,p=[];for(const a in r)if(Object.prototype.hasOwnProperty.call(r,a)&&!(a==="sharePages"||a==="sharedLibIgnore")&&a!==k&&!a.startsWith("__")&&a!=="app"&&!i.has(a)){if((0,f.isObject)(r[a])&&(0,f.isObject)(e[a])){if(a==="designSystem")A(e[a],r[a],i,a);else for(const u in r[a])if(!i.has(`${a}/${u}`)){if(a==="methods"&&(0,L.isProtectedElementMethod)(u)){u in e[a]||p.push(u);continue}u in e[a]?V(a,e[a][u])&&!V(a,r[a][u])&&(e[a][u]=r[a][u]):e[a][u]=r[a][u]}}else if(!(a in e)){const u=r[a],d=a==="methods"&&u&&typeof u=="object"?$e(u,i,p):u;e[a]=F(d,i,a)}}c&&(O(e)||(e[k]=[]),e[k].push({id:c,index:s,key:(0,f.isString)(n.key)?n.key:null,landed:Object.keys(r.globalScope).filter(a=>!l.has(a))})),p.length&&Ae(t,p)},qe=(e,n,o)=>{if(e!==n){const t=Y(e);if((0,f.isString)(t)&&t)return t;if(e.key||e.name)return e.key||e.name}return n&&(n.key||n.name)||`sharedLibraries[${o}]`},Ze=`${R}/default`,Qe=e=>(0,f.isString)(e)&&e!==""&&S(e).full===Ze,Xe=(e,n)=>{if((0,f.isString)(n.key)&&n.key)return n.key;if(e!==n){if((0,f.isString)(e.key)&&e.key)return e.key;if((0,f.isString)(e.name)&&e.name)return e.name}return null},xe=e=>{const n=[],o=[];for(let t=0;t<e.length;t++){const s=e[t];let i=s,c=_e;if(_(i)&&(c=B(i.ignoreList),i=i.library),!(0,f.isObject)(i))continue;const r={entry:s,lib:i,ignore:c,index:t};Qe(Xe(s,i))?o.push(r):n.push(r)}return{linked:n,bases:o}},oe=(e,n,o)=>{const t=G(n()),{linked:s,bases:i}=xe(e);for(const r of s)o(r);const c=!t.size&&i.length?G(n()):null;for(const r of i)o(r);return t.size?t:c&&c.size?c:null},ve=(e,n)=>{if(!n||!n.length)return;const o=e.designSystem,t=oe(n,()=>e.designSystem,({entry:s,lib:i,ignore:c,index:r})=>He(e,i,c,qe(s,i,r),r));t&&(e.designSystem!==o&&(e.designSystem={...e.designSystem}),U(e.designSystem,t))},et=(e,n,o=A)=>{if(!(0,f.isObject)(e)||!Array.isArray(n)||!n.length)return e;const t=oe(n,()=>e,({lib:s,ignore:i})=>{const c=s.designSystem;if(!c||typeof c!="object")return;const r=W(s,i);r.has("designSystem")||o(e,c,r,"designSystem")});return t&&U(e,t),e};async function ue(e,n={}){if((n.provider||"kv")==="api")return se(e,n);const t=await tt(e,n);return t||se(e,n)}async function tt(e,n={}){const o=n.kvBaseUrl||ge,t=n.env||"production",s=`${o}/kv/${encodeURIComponent(e)}?env=${t}`;try{const i=await fetch(s,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function se(e,n={}){const o=n.apiBaseUrl||Se,{key:t}=S(e);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(t)}&limit=10`,i=await fetch(s,{method:"GET"});if(!i.ok)return null;const c=await i.json(),l=(c?.items||c?.data||(Array.isArray(c)?c:[])).find(y=>{const{key:m}=S(y?.key);return m.toLowerCase()===t.toLowerCase()});if(!l?.id&&!l?._id)return null;const p=l.id||l._id,a=`${o}/core/projects/${encodeURIComponent(p)}/data?branch=main`,u=await fetch(a,{method:"GET"});if(!u.ok)return null;const d=await u.json();return d?.data||d||null}catch{return null}}async function re(e,n={}){if((0,f.isObject)(e))return e;if((0,f.isString)(e)){const{full:o}=S(e);if(!o)return null;try{const t=await ue(o,n);return t||console.warn(`[smbls] Shared library "${o}" not found`),t}catch(t){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,t.message),null}}return null}async function nt(e,n={}){return!e||!e.length?[]:(await Promise.all(e.map(async t=>{if(_(t)){const s=await re(Y(t),n);return s?{library:s,ignoreList:t.ignoreList}:null}return re(t,n)}))).filter(Boolean)}
|
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"./polyglotLang.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 g=["$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 : {}); })()"],i=(t,o)=>t.split("$R").join(o),y=g.map(t=>[i(t,"this"),t]),$=t=>i(g[g.length-1],t),f="const __scope = ",O=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,b=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,u=/^[A-Za-z_$][\w$]*$/,n=(t,o)=>typeof t=="string"&&new RegExp("^"+o+"\\d*$").test(t),R=(t,o)=>{if(t.length>=2&&n(t[0],"el"))return t[0];if(t.length>=2&&n(t[1],"el"))return t[1];if(t.length>=1&&n(t[0],"el")||n(t[0],"element")||n(t[0],"node"))return t[0];if(typeof o=="function"){const e=o();if(e&&t.includes(e))return e}return t.find(e=>n(e,"element"))||null},P=t=>{if(typeof t!="string"||t.indexOf(f)===-1||t.indexOf("this")===-1)return t;const o=b.exec(t);if(!o)return t;let e=o[0].length;if(!t.startsWith(f,e))return t;e+=f.length;const c=O.exec(t.slice(e,e+400));c&&(e+=c[0].length);const r=y.find(([s])=>t.startsWith(s,e));if(!r)return t;const l=e+r[0].length;if(t[l]!==(c?")":";"))return t;const _=(o[1]!==void 0?o[1]:o[2]).split(",").map(s=>s.split("=")[0].trim()).filter(Boolean);if(_.some(s=>!u.test(s)))return t;const p=R(_);return p?t.slice(0,e)+i(r[1],p)+t.slice(l):t};export{P as repairLegacyArrowScopePreamble,R as scopeElementParam,$ as scopeReceiverExpression};
|
package/dist/esm/metadata.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isObject as b}from"./types.js";import{isStringFunction as M}from"./function.js";const p=
|
|
2
|
-
`)},
|
|
1
|
+
import{isObject as b}from"./types.js";import{isStringFunction as M}from"./function.js";const p=t=>{if(t==null)return"";const s={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.toString().replace(/[&<>"']/g,e=>s[e])},C=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),L=t=>Object.entries(t||{}).filter(([s,e])=>e!==void 0).map(([s,e])=>`${s}="${p(e)}"`).join(" "),j=t=>{let s=5381;const e=String(t);for(let r=0;r<e.length;r++)s=(s*33^e.charCodeAt(r))>>>0;return s.toString(36)},x=new Set(["jsonLd","styles","scripts"]),E=t=>{const s=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const r=typeof e=="string"?e:JSON.stringify(e),i=String(r).replace(/<\/script/gi,"<\\/script");s.push(`<script type="application/ld+json" data-smbls-jsonld="${j(r)}">${i}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const r=String(e).replace(/<\/style/gi,"<\\/style");s.push(`<style data-smbls-style="${j(r)}">${r}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const r=typeof e=="string",i=r?e:e.src;if(!i&&!e.body)continue;const o=[];i&&o.push(`src="${p(i)}"`),r||(e.type&&o.push(`type="${p(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${p(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${p(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${p(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(i||j(e.body||""))}"`;if(!r&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");s.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else s.push(`<script ${o.join(" ")}${l}><\/script>`)}return s},K=t=>`${t.hreflang||""}|${t.href||""}`,W=t=>b(t)?j(JSON.stringify(t)):String(t),F=(t,s,e)=>t==="favicons"?Array.isArray(s)&&(typeof e=="string"||b(e))?` data-smbls-favicon="${p(W(e))}"`:"":(t==="icon"||t==="favicon")&&typeof s=="string"?` data-smbls-single-icon="${p(s)}"`:"",T=t=>b(t)?` data-smbls-alternate="${p(K(t))}"`:"",H=(t,s)=>{s||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((r,[i,o])=>{if(!o&&o!==0&&o!==!1||x.has(i))return r;if(i==="title")return r.push(`<title>${p(o)}</title>`),r;if(i==="canonical")return r.push(`<link rel="canonical" href="${p(o)}">`),r;if(i==="manifest")return r.push(`<link rel="manifest" href="${p(o)}">`),r;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=F(i,o,c);if(typeof c=="string")r.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const n=L(c);/rel=/.test(n)?r.push(`<link ${n}${u}>`):r.push(`<link rel="icon" ${n}${u}>`)}}),r;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([n,g])=>g!==void 0).map(([n,g])=>`${n}="${p(g)}"`).join(" ");r.push(`<link rel="alternate" ${u}${T(c)}>`)}}),r;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(n)}">`);else if(typeof n=="object"){const g=Object.entries(n).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");r.push(`<meta ${g}>`)}});else if(typeof c=="object"){const n=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");r.push(`<meta ${n}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return l(f,o,"http-equiv"),r}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return l(f,o,"itemprop"),r}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(h){const f=i.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),r}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"),r}return l(i,o),r},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...E(t)),e.join(`
|
|
2
|
+
`)},U=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),A=t=>typeof t=="string"&&t.length>0,D=t=>{if(!t||typeof t!="object")return null;if(A(t.src))return t.src;const s=t.content;return!s||typeof s!="object"?null:A(s.src)?s.src:A(s.storageUrl)?s.storageUrl:null};function P(t,s){if(!s||typeof s!="object")return t;const e=i=>!U(i)||!Object.prototype.hasOwnProperty.call(s,i)?i:D(s[i])||i,r={...t};for(const[i,o]of Object.entries(r))typeof o=="string"?r[i]=e(o):Array.isArray(o)&&(r[i]=o.map(l=>typeof l=="string"?e(l):l));return r}function S(t,s){if(!t||!s)return;const e=s.split(".");let r=t;for(const i of e){if(r==null||typeof r!="object")return;r=r[i]}return r}function R(t,s){const e=S(t,s);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!M(e))return e}function _(t,s,e){const i=(s.config||s.settings||{}).polyglot||s.polyglot,o=e?.lang||i?.defaultLang||"en",d=(i?.translations||{})[o]||{},h=[e?.state,s.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const n of h){const g=R(n,u);if(g!==void 0)return g}},c={...t};for(const[u,n]of Object.entries(c))typeof n!="string"||!n.includes("{{")||(c[u]=n.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??S(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const m=f(a);return m!==void 0?m:d[a]??S(d,a)??g}));return c}function O(t){if(!b(t))return{};const s={...t};for(const[e,r]of Object.entries(s))if(typeof r=="function"){const i=r.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){s[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){s[e]=`{{ ${l[1]} | polyglot }}`;continue}const d=i.match(/s\.(\w+(?:\.\w+)+)/);if(d){s[e]=`{{ ${d[1]} }}`;continue}delete s[e]}else if(typeof r=="string"){const i=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){s[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){s[e]=`{{ ${o[1]} | polyglot }}`;continue}if(r.includes("=>")&&r.includes("s.")){const l=r.match(/s\.(\w+(?:\.\w+)+)/);if(l){s[e]=`{{ ${l[1]} }}`;continue}}M(r)&&delete s[e]}return s}function J(t,s,e,{isProduction:r=!1,channel:i="production"}={}){const o=t.pages?.[s],l=b(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=O(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=O(c);let n={};if(t.integrations?.seo?n={...t.integrations.seo,...u,...h}:Object.keys(u).length?n={...u,...h}:n={...h},!n.title){const a=t.name||t.key;a?r?n.title=a:i==="development"?n.title=`${a} / dev:symbo.ls`:i==="staging"?n.title=`${a} / staging:symbo.ls`:n.title=`${a} / symbo.ls`:n.title="Symbols demo"}n=_(n,t,e),n.title&&(f.has("title")||!n["og:title"])&&(f.has("og:title")||(n["og:title"]=n.title)),n.description&&(f.has("description")||!n["og:description"])&&(f.has("og:description")||(n["og:description"]=n.description)),n.title&&!n["twitter:title"]&&(n["twitter:title"]=n.title),n.description&&!n["twitter:description"]&&(n["twitter:description"]=n.description);const g=f.has("og:url")?n["og:url"]:f.has("url")?n.url:void 0,y=e?.actualPathname||s;if(g)n["og:url"]=g;else if(n["og:url"]||n.url){const a=(n["og:url"]||n.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const m=y.startsWith("/")?y:"/"+y;n["og:url"]=a+m}}n=P(n,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,m]of Object.entries(n))if(typeof m=="string"&&m.includes("{{")){const w=m.replace(/\{\{[^}]*\}\}/g,"").trim();w?n[a]=w:a==="title"?n[a]=$:delete n[a]}return n}export{K as alternateLinkKey,p as escapeHtml,W as faviconLinkKey,D as fileEntryUrl,E as generateHeadArrayTags,H as generateMetaTags,J as getPageMetadata,j as hashContent,C as jsonForScript,P as resolveFileReferences};
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="smbls_lang",n=t=>t&&t.storageLangKey||e,o=(t,a)=>t||a&&a.defaultLang||"en";export{e as POLYGLOT_LANG_STORAGE_KEY,o as polyglotFallbackLang,n as polyglotLangStorageKey};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{isObject as p,isString as y}from"./types.js";import{isProtectedElementMethod as L}from"./keys.js";import{isLoudDevRuntime as ie}from"./env.js";import{destringifyGlobalScope as ce,hasFunction as A,getFunctionSource as ae,deepDestringifyFunctions as le,isStringTag as fe}from"./object.js";const $="system",ue="https://smbls-kv.nika-980.workers.dev",pe="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:$,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=$);const r=t?`${o}/${t}`:"";return{owner:o,key:t,full:r}}const R=(e,n,o,t)=>{for(const r in n){const i=t?`${t}/${r}`:r;o&&o.has(i)||(r in e?p(e[r])&&p(n[r])&&R(e[r],n[r],o,i):e[r]=n[r])}},M=(e,n,o)=>{if(!p(e)||!n.size)return e;const t=`${o}/`;let r=!1;for(const c of n)if(c.startsWith(t)){r=!0;break}if(!r)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const s=`${o}/${c}`;n.has(s)||(i[c]=M(e[c],n,s))}return i},ye=new Set,be=new Set(["components","pages","functions","snippets","methods"]),N=(e,n)=>n===""&&be.has(e),F=["fontFamily","fontfamily","font_family","FONT_FAMILY"],V=e=>{const n=new Map;if(!p(e))return n;for(const o of F){const t=e[o];if(p(t))for(const r in t)!p(t[r])||!t[r].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(r))}return n},D=(e,n)=>{for(const o of F){const t=e[o];if(!p(t))continue;const r=n.get(o);let i=null;for(const c in t){const s=t[c];if(!p(s)||!s.isDefault||r&&r.has(c))continue;const l={...s};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},de=e=>e.replace(/\.js$/iu,""),G=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!y(o))continue;const t=o.split("/").map(r=>de(r.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},
|
|
1
|
+
import{isObject as p,isString as y}from"./types.js";import{isProtectedElementMethod as L}from"./keys.js";import{isLoudDevRuntime as ie}from"./env.js";import{destringifyGlobalScope as ce,hasFunction as A,getFunctionSource as ae,deepDestringifyFunctions as le,isStringTag as fe}from"./object.js";const $="system",ue="https://smbls-kv.nika-980.workers.dev",pe="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:$,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=$);const r=t?`${o}/${t}`:"";return{owner:o,key:t,full:r}}const R=(e,n,o,t)=>{for(const r in n){const i=t?`${t}/${r}`:r;o&&o.has(i)||(r in e?p(e[r])&&p(n[r])&&R(e[r],n[r],o,i):e[r]=n[r])}},M=(e,n,o)=>{if(!p(e)||!n.size)return e;const t=`${o}/`;let r=!1;for(const c of n)if(c.startsWith(t)){r=!0;break}if(!r)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const s=`${o}/${c}`;n.has(s)||(i[c]=M(e[c],n,s))}return i},ye=new Set,be=new Set(["components","pages","functions","snippets","methods"]),N=(e,n)=>n===""&&be.has(e),F=["fontFamily","fontfamily","font_family","FONT_FAMILY"],V=e=>{const n=new Map;if(!p(e))return n;for(const o of F){const t=e[o];if(p(t))for(const r in t)!p(t[r])||!t[r].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(r))}return n},D=(e,n)=>{for(const o of F){const t=e[o];if(!p(t))continue;const r=n.get(o);let i=null;for(const c in t){const s=t[c];if(!p(s)||!s.isDefault||r&&r.has(c))continue;const l={...s};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},de=e=>e.replace(/\.js$/iu,""),G=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!y(o))continue;const t=o.split("/").map(r=>de(r.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},xe=(e,n={})=>({library:e,ignoreList:Array.isArray(n.ignoreList)?n.ignoreList:[]}),_=e=>p(e)&&Array.isArray(e.ignoreList)&&("library"in e||"key"in e||"name"in e),U=e=>e.library!==void 0?e.library:e.key??e.name,j=new Set,ve=()=>{j.clear()},he=(e,n)=>{const o=n.filter(t=>!j.has(t));if(o.length){for(const t of o)j.add(t);ie()&&console.warn(`[smbls] shared library "${e}" ships ${o.map(t=>`methods.${t}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},me=(e,n,o)=>{let t=null;for(const r in e)if(L(r)&&(n.has(`methods/${r}`)||o.push(r),!t)){t={};for(const i in e)L(i)||(t[i]=e[i])}return t||e},Y=(e,n)=>{const o=G(e.sharedLibIgnore);return e.sharePages===!1&&o.add("pages"),o.size?new Set([...n,...o]):n},E=["functions","methods","snippets"],W=["components","pages"],K=Symbol.for("smbls.libraryScope"),k="__libraryScopes",I=new Map,ge=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),h=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),Se=/const __scope = |const __peers_* = |const _s = el\?\.scope|\?\.context\?\.globalScope\?\./,z=e=>{try{return ae(e)}catch{return null}},J=e=>{if(typeof e!="function")return null;const n=z(e);return y(n)&&Se.test(n)&&A(n)?n:null},H=e=>y(e)&&A(e)||J(e)!==null,_e=e=>{const n=e.globalScope;return p(n)&&Object.keys(n).some(o=>H(n[o]))?!0:E.some(o=>{const t=e[o];return!!t&&typeof t=="object"&&Object.keys(t).some(r=>H(t[r]))})},ke=(e,n,o)=>{const t=e.globalScope,r=n.globalScope;if(o.has("globalScope")||!p(t)||!p(r)||!_e(n))return 0;let i=0;for(const c of Object.keys(r))o.has(`globalScope/${c}`)||h(t,c)&&i++;return i},we=[[/const __scope = (\(\(\) => \{ const r = [\s\S]*?\}\)\(\));/g,"const __scope = $RESOLVE($1);"],[/const __scope = this \?\? \{\};/g,"const __scope = $RESOLVE(this ?? {});"],[/const (__peers_*) = (this && this !== globalThis && this\.context && this\.context\.globalScope \? this\.scope \?\? this\.context\.globalScope : this);/g,"const $1 = $RESOLVE($2);"],[/const _s = (el\?\.scope \?\? el\?\.context\?\.globalScope \?\? \{\});/g,"const _s = $RESOLVE($1);"],[/(?<![\w$.])(this|[A-Za-z_$][\w$]*)\?\.context\?\.globalScope\?\./g,"$RESOLVE($1?.context?.globalScope)?."]],Oe=e=>{const n=e.split(""),o=[];let t=0,r=0;const i=(s,l)=>{for(let u=s;u<l;u++)n[u]!==`
|
|
2
2
|
`&&(n[u]="~")},c=()=>{const s=t;for(;t<e.length;){const l=e[t];if(l==="\\"){t+=2;continue}if(l==="`"){i(s,t),t++;return}if(l==="$"&&e[t+1]==="{"){i(s,t),t+=2,o.push(r),r++;return}t++}i(s,t)};for(;t<e.length;){const s=e[t];if(s==="/"&&e[t+1]==="/"){const l=e.indexOf(`
|
|
3
3
|
`,t),u=l===-1?e.length:l;i(t,u),t=u;continue}if(s==="/"&&e[t+1]==="*"){const l=e.indexOf("*/",t+2),u=l===-1?e.length:l+2;i(t,u),t=u;continue}if(s==='"'||s==="'"){const l=s,u=++t;for(;t<e.length&&e[t]!==l&&e[t]!==`
|
|
4
|
-
`;)e[t]==="\\"&&t++,t++;i(u,t),t++;continue}if(s==="`"){t++,c();continue}if(s==="{"){r++,t++;continue}if(s==="}"){if(r--,o.length&&r===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},q=(e,n)=>{if(!y(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!A(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[r,i]of we){const c=Oe(t);t=t.replace(r,(...s)=>{const l=s[s.length-2];return c[l]==="~"||c[l]!==t[l]?s[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(u,a)=>s[Number(a)])})}return t},w=(e,n)=>{if(y(e))return q(e,n);const o=J(e);return o===null?e:q(o,n)},Le={lazy:!0,window:globalThis},Z=(e,n)=>{const o=w(e,n);if(o===e||!y(o))return o;try{const t=le({v:o},{},Le).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},Q=(e,n,o=new WeakMap)=>{if(y(e)||typeof e=="function")return Z(e,n);if(fe(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const r of Object.keys(e))t[r]=Q(e[r],n,o);return t},Ae=(e,n)=>{const o={...e},t={};for(const r of Object.keys(e.globalScope))t[r]=w(e.globalScope[r],n);o.globalScope=t;for(const r of E){const i=e[r];if(!P(i))continue;const c={};for(const s of Object.keys(i))c[s]=Z(i[s],n);o[r]=c}for(const r of W)P(e[r])&&(o[r]=Q(e[r],n));return o},X=new WeakMap,$e=(e,n,o)=>{let t=X.get(e);t||X.set(e,t=new Map);let r=t.get(n);if(r)return r;const i=(c,s)=>h(o,c)&&o[c]===s;return r=new Proxy(e,{get(c,s){if(typeof s=="symbol"||h(c,s))return Reflect.get(c,s);const l=Reflect.get(c,s);return h(n,s)&&(l===void 0||i(s,l))||l===void 0?n[s]:l},set(c,s,l){return typeof s!="symbol"&&!h(c,s)&&h(n,s)?(n[s]=l,!0):Reflect.set(c,s,l)},has:(c,s)=>Reflect.has(c,s)||s in n}),t.set(n,r),r},Re=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",je=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Re(n)?$e(n,o.libGs,o.consumerGs):n:n},Ee=()=>{typeof globalThis[K]!="function"&&Object.defineProperty(globalThis,K,{value:je,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,Ie=(e,n,o)=>{const t=O(e);return!!t&&t.some(r=>r&&r.index===n&&(!r.key||r.key===o.key)&&y(r.id)&&Pe(e,r.id))},Pe=(e,n)=>{const o=JSON.stringify(n),t=new Set,r=i=>{if(y(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(r(i[c]))return!0;return!1};for(const i of["globalScope",...E,...W])if(r(e[i]))return!0;return!1},Te=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},
|
|
4
|
+
`;)e[t]==="\\"&&t++,t++;i(u,t),t++;continue}if(s==="`"){t++,c();continue}if(s==="{"){r++,t++;continue}if(s==="}"){if(r--,o.length&&r===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},q=(e,n)=>{if(!y(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!A(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[r,i]of we){const c=Oe(t);t=t.replace(r,(...s)=>{const l=s[s.length-2];return c[l]==="~"||c[l]!==t[l]?s[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(u,a)=>s[Number(a)])})}return t},w=(e,n)=>{if(y(e))return q(e,n);const o=J(e);return o===null?e:q(o,n)},Le={lazy:!0,window:globalThis},Z=(e,n)=>{const o=w(e,n);if(o===e||!y(o))return o;try{const t=le({v:o},{},Le).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},Q=(e,n,o=new WeakMap)=>{if(y(e)||typeof e=="function")return Z(e,n);if(fe(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const r of Object.keys(e))t[r]=Q(e[r],n,o);return t},Ae=(e,n)=>{const o={...e},t={};for(const r of Object.keys(e.globalScope))t[r]=w(e.globalScope[r],n);o.globalScope=t;for(const r of E){const i=e[r];if(!P(i))continue;const c={};for(const s of Object.keys(i))c[s]=Z(i[s],n);o[r]=c}for(const r of W)P(e[r])&&(o[r]=Q(e[r],n));return o},X=new WeakMap,$e=(e,n,o)=>{let t=X.get(e);t||X.set(e,t=new Map);let r=t.get(n);if(r)return r;const i=(c,s)=>h(o,c)&&o[c]===s;return r=new Proxy(e,{get(c,s){if(typeof s=="symbol"||h(c,s))return Reflect.get(c,s);const l=Reflect.get(c,s);return h(n,s)&&(l===void 0||i(s,l))||l===void 0?n[s]:l},set(c,s,l){return typeof s!="symbol"&&!h(c,s)&&h(n,s)?(n[s]=l,!0):Reflect.set(c,s,l)},has:(c,s)=>Reflect.has(c,s)||s in n}),t.set(n,r),r},Re=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",je=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Re(n)?$e(n,o.libGs,o.consumerGs):n:n},Ee=()=>{typeof globalThis[K]!="function"&&Object.defineProperty(globalThis,K,{value:je,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,Ie=(e,n,o)=>{const t=O(e);return!!t&&t.some(r=>r&&r.index===n&&(!r.key||r.key===o.key)&&y(r.id)&&Pe(e,r.id))},Pe=(e,n)=>{const o=JSON.stringify(n),t=new Set,r=i=>{if(y(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(r(i[c]))return!0;return!1};for(const i of["globalScope",...E,...W])if(r(e[i]))return!0;return!1},Te=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},x=new WeakMap,et=(e,n=null)=>{const o=e&&O(e);if(!o||!o.length)return 0;const t=e.globalScope;if(!p(t))return 0;const r=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];let i=x.get(t);i||x.set(t,i=new Set),Ee();let c=0;for(const s of o){if(!s||!y(s.id)||i.has(s.id))continue;const l=T(r[s.index]);if(!l||!p(l.globalScope)||s.key&&l.key!==s.key)continue;const u=b=>typeof b=="function"?z(b):b,a=(b,m)=>{if(b===m)return!0;const B=u(b),C=u(m);return y(B)||y(C)?B===C:JSON.stringify(b)===JSON.stringify(m)},f=p(n)?(Array.isArray(s.landed)?s.landed:[]).filter(b=>y(b)&&h(l.globalScope,b)&&h(n,b)&&a(n[b],w(l.globalScope[b],s.id))):[],d=ce(Te(l.globalScope,s.id));Object.setPrototypeOf(d,t),I.set(s.id,{libGs:d,consumerGs:t});for(const b of f)t[b]=d[b];i.add(s.id),c++}return c},Be=/^@symbo[-.]ls\//,v=e=>e.includes("/")?e.slice(e.indexOf("/")+1):e,Ce=e=>[`@symbo-ls/${e}`,`@symbo.ls/${e}`],Me=(e,n)=>{const o=[];if(!Array.isArray(e))return o;const t=new Map,r=(c,s,l)=>{for(const u of Ce(c)){const a=t.get(u);if(a===void 0){t.set(u,s),o.push([u,s]);continue}a!==s&&l&&typeof n=="function"&&n({spec:u,kept:a,refused:s})}},i=[];for(const c of e){const s=T(c);if(!s||typeof s!="object"||s.__isStub)continue;const l=s.key||s.name||s.__libraryKey,u=[];for(const a of[s.key,s.name,s.__libraryKey,s.__libraryName]){if(typeof a!="string"||!a||a!==l&&!Be.test(a))continue;const f=v(a);f&&!u.includes(f)&&u.push(f)}u.forEach((a,f)=>{f===0&&l&&v(l)===a?r(a,s,!1):i.push([a,s])})}for(const[c,s]of i)r(c,s,!0);return o},Ne=({spec:e,kept:n,refused:o})=>{typeof console>"u"||console.warn(`[smbls] shared library "${o&&o.key}" also claims ${e}, which "${n&&n.key}" already owns; ${e} stays with "${n&&n.key}".`)},ee=["functions","methods","snippets"],Fe=Symbol.for("smbls.libraryPackages"),g=new WeakMap,Ve=e=>!!e&&typeof e=="object"&&!Array.isArray(e),De=e=>({get globalScope(){return e()}}),te=(e,n,o)=>{const t={};for(const r of Object.keys(e))t[r]=e[r];return Object.defineProperty(t,"context",{configurable:!0,enumerable:!1,writable:!0,value:De(n)}),g.set(t,o),t},ne=e=>!Ve(e)||!g.has(e)&&Object.prototype.hasOwnProperty.call(e,"context"),tt=e=>{if(!e||typeof e!="object")return;const n=()=>e.globalScope;for(const t of ee){const r=e[t];ne(r)||g.get(r)===e||(e[t]=te(r,n,e))}if(Array.isArray(e.sharedLibraries)){const t=O(e)||[];e.sharedLibraries=e.sharedLibraries.map((r,i)=>{const c=_(r)&&r&&"library"in r,s=T(r);if(!s||typeof s!="object"||s.__isStub||g.get(s)===e)return r;const l=t.find(f=>f&&f.index===i&&(!f.key||f.key===s.key)),u=()=>{const f=l&&I.get(l.id);return f&&f.consumerGs===e.globalScope?f.libGs:e.globalScope},a={...s};for(const f of ee)ne(s[f])||(a[f]=te(s[f],u,e));return g.set(a,e),c?{...r,library:a}:a})}const o=e.globalScope;if(o&&typeof o=="object"){const t={};for(const[r,i]of Me(e.sharedLibraries,Ne))t[r]=i;try{Object.defineProperty(o,Fe,{configurable:!0,enumerable:!1,writable:!0,value:t})}catch{}}},Ge=(e,n,o,t="library",r=-1)=>{const i=Y(n,o),c=!Ie(e,r,n)&&ke(e,n,i)>0?`${t}#${ge()}`:null,s=c?Ae(n,c):n,l=c?new Set(Object.keys(e.globalScope)):null,u=[];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)&&!(a==="sharePages"||a==="sharedLibIgnore")&&a!==k&&!a.startsWith("__")&&a!=="app"&&!i.has(a)){if(p(s[a])&&p(e[a])){if(a==="designSystem")R(e[a],s[a],i,a);else for(const f in s[a])if(!i.has(`${a}/${f}`)){if(a==="methods"&&L(f)){f in e[a]||u.push(f);continue}f in e[a]?N(a,e[a][f])&&!N(a,s[a][f])&&(e[a][f]=s[a][f]):e[a][f]=s[a][f]}}else if(!(a in e)){const f=s[a],d=a==="methods"&&f&&typeof f=="object"?me(f,i,u):f;e[a]=M(d,i,a)}}c&&(O(e)||(e[k]=[]),e[k].push({id:c,index:r,key:y(n.key)?n.key:null,landed:Object.keys(s.globalScope).filter(a=>!l.has(a))})),u.length&&he(t,u)},Ue=(e,n,o)=>{if(e!==n){const t=U(e);if(y(t)&&t)return t;if(e.key||e.name)return e.key||e.name}return n&&(n.key||n.name)||`sharedLibraries[${o}]`},Ye=`${$}/default`,We=e=>y(e)&&e!==""&&S(e).full===Ye,Ke=(e,n)=>{if(y(n.key)&&n.key)return n.key;if(e!==n){if(y(e.key)&&e.key)return e.key;if(y(e.name)&&e.name)return e.name}return null},ze=e=>{const n=[],o=[];for(let t=0;t<e.length;t++){const r=e[t];let i=r,c=ye;if(_(i)&&(c=G(i.ignoreList),i=i.library),!p(i))continue;const s={entry:r,lib:i,ignore:c,index:t};We(Ke(r,i))?o.push(s):n.push(s)}return{linked:n,bases:o}},oe=(e,n,o)=>{const t=V(n()),{linked:r,bases:i}=ze(e);for(const s of r)o(s);const c=!t.size&&i.length?V(n()):null;for(const s of i)o(s);return t.size?t:c&&c.size?c:null},nt=(e,n)=>{if(!n||!n.length)return;const o=e.designSystem,t=oe(n,()=>e.designSystem,({entry:r,lib:i,ignore:c,index:s})=>Ge(e,i,c,Ue(r,i,s),s));t&&(e.designSystem!==o&&(e.designSystem={...e.designSystem}),D(e.designSystem,t))},ot=(e,n,o=R)=>{if(!p(e)||!Array.isArray(n)||!n.length)return e;const t=oe(n,()=>e,({lib:r,ignore:i})=>{const c=r.designSystem;if(!c||typeof c!="object")return;const s=Y(r,i);s.has("designSystem")||o(e,c,s,"designSystem")});return t&&D(e,t),e};async function Je(e,n={}){if((n.provider||"kv")==="api")return se(e,n);const t=await He(e,n);return t||se(e,n)}async function He(e,n={}){const o=n.kvBaseUrl||ue,t=n.env||"production",r=`${o}/kv/${encodeURIComponent(e)}?env=${t}`;try{const i=await fetch(r,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function se(e,n={}){const o=n.apiBaseUrl||pe,{key:t}=S(e);try{const r=`${o}/core/projects/libraries/available?search=${encodeURIComponent(t)}&limit=10`,i=await fetch(r,{method:"GET"});if(!i.ok)return null;const c=await i.json(),l=(c?.items||c?.data||(Array.isArray(c)?c:[])).find(b=>{const{key:m}=S(b?.key);return m.toLowerCase()===t.toLowerCase()});if(!l?.id&&!l?._id)return null;const u=l.id||l._id,a=`${o}/core/projects/${encodeURIComponent(u)}/data?branch=main`,f=await fetch(a,{method:"GET"});if(!f.ok)return null;const d=await f.json();return d?.data||d||null}catch{return null}}async function re(e,n={}){if(p(e))return e;if(y(e)){const{full:o}=S(e);if(!o)return null;try{const t=await Je(o,n);return t||console.warn(`[smbls] Shared library "${o}" not found`),t}catch(t){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,t.message),null}}return null}async function st(e,n={}){return!e||!e.length?[]:(await Promise.all(e.map(async t=>{if(_(t)){const r=await re(U(t),n);return r?{library:r,ignoreList:t.ignoreList}:null}return re(t,n)}))).filter(Boolean)}export{Fe as LIBRARY_PACKAGES,k as LIBRARY_SCOPES_KEY,ve as __resetBuiltinMethodWarnings,v as bareLibraryKey,et as bindLibraryGlobalScopes,R as deepDefaults,tt as exposeBagGlobalScopes,Je as fetchLibraryData,_ as isWrappedLibrary,Me as libraryPackageSpecs,Ce as librarySpecsFor,nt as mergeSharedLibraries,ot as mergeSharedLibraryDesignSystems,G as normalizeIgnoreList,S as normalizeLibraryKey,st as resolveSharedLibraries,xe as sharedLibrary,Ne as warnLibraryAliasCollision};
|
package/index.js
CHANGED
|
@@ -25,6 +25,8 @@ 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'
|
|
29
|
+
export * from './polyglotLang.js'
|
|
28
30
|
|
|
29
31
|
// ── Merged from the former @symbo.ls/smbls-utils package (4.x) ────────────
|
|
30
32
|
export * from './browser.js'
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
/**
|
|
48
|
+
* The scope expression CURRENT frank emits for a receiver `ref` — the newest
|
|
49
|
+
* template above. frank scopeRewriter buildScopeDecl reads it from here, so
|
|
50
|
+
* the preamble frank writes and the forms this repair recognises cannot
|
|
51
|
+
* drift: a new preamble shape is a new last entry of TEMPLATES (never an edit
|
|
52
|
+
* of one — payloads pushed with it stay in the wild).
|
|
53
|
+
*
|
|
54
|
+
* @param {string} ref - the receiver expression (a parameter name, `this`)
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
export const scopeReceiverExpression = (ref) => withReceiver(TEMPLATES[TEMPLATES.length - 1], ref)
|
|
58
|
+
|
|
59
|
+
const DECL = 'const __scope = '
|
|
60
|
+
// sharedLibraries.js scopeLibraryText's wrapper around a preamble's value
|
|
61
|
+
const LIBRARY_WRAPPER_RE = /^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /
|
|
62
|
+
// An arrow head with a flat parameter list (no nested parens, strings,
|
|
63
|
+
// destructuring) and a block body.
|
|
64
|
+
const ARROW_HEAD_RE = /^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/
|
|
65
|
+
const IDENT_RE = /^[A-Za-z_$][\w$]*$/
|
|
66
|
+
|
|
67
|
+
const named = (p, base) => typeof p === 'string' && new RegExp('^' + base + '\\d*$').test(p)
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The parameter of a component / page function that receives the element —
|
|
71
|
+
* the receiver of its scope preamble. frank scopeRewriter getElementRef uses
|
|
72
|
+
* it (one rule for the preamble frank writes and the one this repair writes):
|
|
73
|
+
* `el\d*` first or second (esbuild renames `el` to `el2`), `element\d*` /
|
|
74
|
+
* `node\d*` first, then `boundElement` — the parameter a destructuring
|
|
75
|
+
* pattern binds to the `element` key (frank reads it from the function text;
|
|
76
|
+
* a thunk, called only when the rules before it found none) — then any
|
|
77
|
+
* `element\d*`. null when none.
|
|
78
|
+
*
|
|
79
|
+
* @param {string[]} params - the parameter names, in order
|
|
80
|
+
* @param {() => (string|null)} [boundElement]
|
|
81
|
+
* @returns {string|null}
|
|
82
|
+
*/
|
|
83
|
+
export const scopeElementParam = (params, boundElement) => {
|
|
84
|
+
if (params.length >= 2 && named(params[0], 'el')) return params[0]
|
|
85
|
+
if (params.length >= 2 && named(params[1], 'el')) return params[1]
|
|
86
|
+
if (params.length >= 1 && named(params[0], 'el')) return params[0]
|
|
87
|
+
if (named(params[0], 'element') || named(params[0], 'node')) return params[0]
|
|
88
|
+
if (typeof boundElement === 'function') {
|
|
89
|
+
const bound = boundElement()
|
|
90
|
+
if (bound && params.includes(bound)) return bound
|
|
91
|
+
}
|
|
92
|
+
return params.find((p) => named(p, 'element')) || null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Rewrite an old frank `this`-receiver scope preamble at the start of an
|
|
97
|
+
* ARROW function source to read the element parameter. Returns the source
|
|
98
|
+
* unchanged when it is not exactly that shape.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} src - a stored function source
|
|
101
|
+
* @returns {string}
|
|
102
|
+
*/
|
|
103
|
+
export const repairLegacyArrowScopePreamble = (src) => {
|
|
104
|
+
if (typeof src !== 'string' || src.indexOf(DECL) === -1 || src.indexOf('this') === -1) return src
|
|
105
|
+
const head = ARROW_HEAD_RE.exec(src)
|
|
106
|
+
if (!head) return src
|
|
107
|
+
let at = head[0].length
|
|
108
|
+
if (!src.startsWith(DECL, at)) return src
|
|
109
|
+
at += DECL.length
|
|
110
|
+
const wrapper = LIBRARY_WRAPPER_RE.exec(src.slice(at, at + 400))
|
|
111
|
+
if (wrapper) at += wrapper[0].length
|
|
112
|
+
const form = THIS_FORMS.find(([text]) => src.startsWith(text, at))
|
|
113
|
+
if (!form) return src
|
|
114
|
+
const end = at + form[0].length
|
|
115
|
+
if (src[end] !== (wrapper ? ')' : ';')) return src
|
|
116
|
+
const raw = head[1] !== undefined ? head[1] : head[2]
|
|
117
|
+
const params = raw.split(',').map((p) => p.split('=')[0].trim()).filter(Boolean)
|
|
118
|
+
if (params.some((p) => !IDENT_RE.test(p))) return src
|
|
119
|
+
const ref = scopeElementParam(params)
|
|
120
|
+
if (!ref) return src
|
|
121
|
+
return src.slice(0, at) + withReceiver(form[1], ref) + src.slice(end)
|
|
122
|
+
}
|
package/metadata.js
CHANGED
|
@@ -3,12 +3,27 @@
|
|
|
3
3
|
import { isObject } from './types.js'
|
|
4
4
|
import { isStringFunction } from './function.js'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// HTML text / attribute-value escape shared by every server head builder —
|
|
7
|
+
// this file's generateMetaTags and helmet's generateHeadHtml (SSR) — so the
|
|
8
|
+
// two emit the same bytes for the same value.
|
|
9
|
+
export const escapeHtml = (text) => {
|
|
7
10
|
if (text === null || text === undefined) return ''
|
|
8
11
|
const map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }
|
|
9
12
|
return text.toString().replace(/[&<>"']/g, (m) => map[m])
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
/**
|
|
16
|
+
* `value` as JSON that is safe INSIDE an inline <script>: `<` is escaped (no
|
|
17
|
+
* `</script>` can end the tag early), and so are U+2028 / U+2029 (line
|
|
18
|
+
* terminators to a pre-ES2019 parser). Still valid JSON and the same value.
|
|
19
|
+
* The server pages' boot scripts use it — brender's element-path registry,
|
|
20
|
+
* @symbo.ls/fetch's seed of recorded answers.
|
|
21
|
+
*/
|
|
22
|
+
export const jsonForScript = (value) => JSON.stringify(value)
|
|
23
|
+
.replace(/</g, '\\u003c')
|
|
24
|
+
.replace(/\u2028/g, '\\u2028')
|
|
25
|
+
.replace(/\u2029/g, '\\u2029')
|
|
26
|
+
|
|
12
27
|
const buildAttrs = (obj) =>
|
|
13
28
|
Object.entries(obj || {})
|
|
14
29
|
.filter(([_, v]) => v !== undefined)
|
|
@@ -26,9 +41,7 @@ const buildAttrs = (obj) =>
|
|
|
26
41
|
* Lives here because `utils` is the lowest package in the graph:
|
|
27
42
|
* `@symbo.ls/helmet` already depends on `@symbo.ls/utils`, never the
|
|
28
43
|
* reverse, so this is the only place the three pipelines can share one
|
|
29
|
-
* implementation without a cycle.
|
|
30
|
-
* byte-identical private `_hashContent` (`plugins/helmet/index.js`); it can
|
|
31
|
-
* drop it in favour of this export whenever that package is next touched.
|
|
44
|
+
* implementation without a cycle.
|
|
32
45
|
*/
|
|
33
46
|
export const hashContent = (s) => {
|
|
34
47
|
let h = 5381
|
|
@@ -50,10 +63,11 @@ const HEAD_ARRAY_KEYS = new Set(['jsonLd', 'styles', 'scripts'])
|
|
|
50
63
|
/**
|
|
51
64
|
* Render the `jsonLd` / `styles` / `scripts` head extensions.
|
|
52
65
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
66
|
+
* The one emitter of these tags for both server heads — helmet's SSR
|
|
67
|
+
* `generateHeadHtml` (`plugins/helmet/index.js`) calls it too — so a
|
|
68
|
+
* published page and an SSR'd page carry the same `data-smbls-*` keys, the
|
|
69
|
+
* same escaping and the same hash inputs, and the client runtime reconciles
|
|
70
|
+
* both without re-emitting.
|
|
57
71
|
*
|
|
58
72
|
* metadata.jsonLd: [{ '@context': 'https://schema.org', '@type': 'Organization', … }]
|
|
59
73
|
* metadata.styles: ['@media (prefers-color-scheme: dark) { :root { --c: #111 } }']
|
|
@@ -125,12 +139,17 @@ export const generateHeadArrayTags = (metadata) => {
|
|
|
125
139
|
* stayed on every page after it. helmet's SSR builder (`generateHeadHtml`)
|
|
126
140
|
* emits the same keys. A shape the client never renders (`icons`, an icon
|
|
127
141
|
* array, a lone `favicons` value) stays unkeyed, so the client never owns it.
|
|
142
|
+
*
|
|
143
|
+
* The two keys below are the ONE definition all three use (unescaped — each
|
|
144
|
+
* server builder escapes it into its attribute; the client sets it as is).
|
|
128
145
|
*/
|
|
146
|
+
export const alternateLinkKey = (alt) => `${alt.hreflang || ''}|${alt.href || ''}`
|
|
147
|
+
export const faviconLinkKey = (fav) => isObject(fav) ? hashContent(JSON.stringify(fav)) : String(fav)
|
|
148
|
+
|
|
129
149
|
const iconKeyAttr = (key, value, item) => {
|
|
130
150
|
if (key === 'favicons') {
|
|
131
151
|
if (!Array.isArray(value)) return ''
|
|
132
|
-
if (typeof item === 'string') return ` data-smbls-favicon="${escapeHtml(item)}"`
|
|
133
|
-
if (isObject(item)) return ` data-smbls-favicon="${hashContent(JSON.stringify(item))}"`
|
|
152
|
+
if (typeof item === 'string' || isObject(item)) return ` data-smbls-favicon="${escapeHtml(faviconLinkKey(item))}"`
|
|
134
153
|
return ''
|
|
135
154
|
}
|
|
136
155
|
if ((key === 'icon' || key === 'favicon') && typeof value === 'string') {
|
|
@@ -140,7 +159,7 @@ const iconKeyAttr = (key, value, item) => {
|
|
|
140
159
|
}
|
|
141
160
|
|
|
142
161
|
const alternateKeyAttr = (alt) =>
|
|
143
|
-
isObject(alt) ? ` data-smbls-alternate="${escapeHtml(
|
|
162
|
+
isObject(alt) ? ` data-smbls-alternate="${escapeHtml(alternateLinkKey(alt))}"` : ''
|
|
144
163
|
|
|
145
164
|
/**
|
|
146
165
|
* Generates HTML meta tags from a flat metadata object.
|
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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/utils",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.786",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@symbo.ls/fetch": "^3.14.
|
|
50
|
+
"@symbo.ls/fetch": "^3.14.664"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"@symbo.ls/fetch": {
|
package/polyglotLang.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// The language a polyglot app starts in — shared by @symbo.ls/polyglot (the
|
|
4
|
+
// runtime: initPolyglot, setLang, getActiveLang) and @symbo.ls/fetch's
|
|
5
|
+
// pre-boot script build (earlyScript.js languageRule), which must ask in the
|
|
6
|
+
// language the app will boot in. They kept one copy each of the storage key
|
|
7
|
+
// and the fallback order; a change to one would have sent the early requests
|
|
8
|
+
// in another language than the app's, and nothing would have failed.
|
|
9
|
+
|
|
10
|
+
/** Where polyglot keeps a visitor's chosen language, unless `storageLangKey` says otherwise. */
|
|
11
|
+
export const POLYGLOT_LANG_STORAGE_KEY = 'smbls_lang'
|
|
12
|
+
|
|
13
|
+
/** The storage key of the chosen language for a `polyglot` config. */
|
|
14
|
+
export const polyglotLangStorageKey = (polyglot) =>
|
|
15
|
+
(polyglot && polyglot.storageLangKey) || POLYGLOT_LANG_STORAGE_KEY
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The language when no choice is stored: the language the state already
|
|
19
|
+
* resolved (`stateLang`), else the config's `defaultLang`, else 'en'.
|
|
20
|
+
*/
|
|
21
|
+
export const polyglotFallbackLang = (stateLang, polyglot) =>
|
|
22
|
+
stateLang || (polyglot && polyglot.defaultLang) || 'en'
|
package/sharedLibraries.js
CHANGED
|
@@ -753,7 +753,16 @@ export const bindLibraryGlobalScopes = (context, mergedGlobalScope = null) => {
|
|
|
753
753
|
// alias, so a library cannot take a slot another library owns by record key;
|
|
754
754
|
// an alias two libraries claim stays with the first and is reported.
|
|
755
755
|
const NPM_SCOPED_LIBRARY_ID_RE = /^@symbo[-.]ls\//
|
|
756
|
-
|
|
756
|
+
|
|
757
|
+
/** A library identifier without its owner / npm scope: `owner/key` → `key`. */
|
|
758
|
+
export const bareLibraryKey = (raw) => (raw.includes('/') ? raw.slice(raw.indexOf('/') + 1) : raw)
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* The package names a library key is imported under — both npm scopes. frank
|
|
762
|
+
* (scopeRewriter buildDeclaredLibraryPackageSet) and the registry below take
|
|
763
|
+
* them from here, so the specifiers frank rewrites are the ones registered.
|
|
764
|
+
*/
|
|
765
|
+
export const librarySpecsFor = (key) => [`@symbo-ls/${key}`, `@symbo.ls/${key}`]
|
|
757
766
|
|
|
758
767
|
/**
|
|
759
768
|
* Ordered [spec, library] pairs for `libraries` (entries or wrappers), stubs
|
|
@@ -765,7 +774,7 @@ export const libraryPackageSpecs = (libraries, onCollision) => {
|
|
|
765
774
|
if (!Array.isArray(libraries)) return out
|
|
766
775
|
const owner = new Map()
|
|
767
776
|
const take = (key, lib, isAlias) => {
|
|
768
|
-
for (const spec of
|
|
777
|
+
for (const spec of librarySpecsFor(key)) {
|
|
769
778
|
const have = owner.get(spec)
|
|
770
779
|
if (have === undefined) { owner.set(spec, lib); out.push([spec, lib]); continue }
|
|
771
780
|
if (have !== lib && isAlias && typeof onCollision === 'function') onCollision({ spec, kept: have, refused: lib })
|