@symbo.ls/utils 3.14.768 → 3.14.769

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/cdn.js CHANGED
@@ -91,6 +91,25 @@ export const getCDNUrl = (
91
91
  return cdnConfig.formatUrl(packageName, stripVersionRangePrefix(version))
92
92
  }
93
93
 
94
+ // The package DIRECTORY on the CDN — `<cdn>/<pkg>@<version>/` — i.e. the
95
+ // exact-entry URL without its module-entry suffix (`/+esm`, `?module`) and
96
+ // WITH a trailing slash. This is the address an importmap prefix entry
97
+ // (`"pkg/": "<dir>/"`) needs so `import('pkg/<subpath>')` resolves to
98
+ // `<dir>/<subpath>` — a raw file path every provider here serves
99
+ // (pkg.symbo.ls is a raw passthrough; esm.sh / jsDelivr / unpkg / skypack
100
+ // all accept `/<pkg>@<v>/<file>`). Kept separate from `formatUrl` on purpose:
101
+ // the exact entry MUST keep its suffix (the IIFE-vs-ESM lesson above), the
102
+ // prefix entry MUST NOT have one.
103
+ export const getCDNDirUrl = (
104
+ packageName,
105
+ version = 'latest',
106
+ provider = 'esmsh'
107
+ ) => {
108
+ const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.esmsh
109
+ const v = stripVersionRangePrefix(version)
110
+ return `${cdnConfig.url}/${packageName}${v !== 'latest' ? `@${v}` : ''}/`
111
+ }
112
+
94
113
  // SMBLS-IMPORTMAP-SKIP — shared with packages/smbls/src/prepare.js's own
95
114
  // client-side loader (fc660da57, tickets/opus.md "runtime importmap loader
96
115
  // burns ~25-40s retrying unresolvable specifiers"). That fix only covers
@@ -150,6 +169,21 @@ export const isMalformedDependency = (name) =>
150
169
  * *.at.symbo.ls pages shipped `"smbls": "latest"` against an inlined IIFE from
151
170
  * a months-old pin, and the client half moved 683 → 704 in a single evening
152
171
  * under already-published sites (tickets/smbls.md).
172
+ *
173
+ * SUBPATH TWIN (tickets/fable.md IMPORTMAP-SUBPATH-1). Browser importmap
174
+ * semantics do NOT satisfy a subpath import from a bare entry:
175
+ * `"typesense-docsearch.js": "…@3.4.1/+esm"` resolves `import('typesense-
176
+ * docsearch.js')` and NOTHING else — `import('typesense-docsearch.js/dist/
177
+ * umd/index.js')` rejects with `TypeError: Failed to resolve module
178
+ * specifier` BEFORE any network request (measured live on docs.symbols.app,
179
+ * silent unless the caller awaits). A prefix entry — a key ending in `/`
180
+ * mapped to an address ending in `/` — is how importmaps express "and every
181
+ * subpath under it". So every dependency gets a TWIN:
182
+ * "pkg": "<cdn>/pkg@X/+esm" (exact — the importable module entry)
183
+ * "pkg/": "<cdn>/pkg@X/" (prefix — `pkg/<file>` → `<cdn>/pkg@X/<file>`)
184
+ * Same pinned version on both. A key that already ends with `/` gets no twin
185
+ * (it IS one). The address MUST end with `/` — the browser silently drops a
186
+ * prefix entry whose address does not.
153
187
  */
154
188
  export const getImportMapScript = (
155
189
  data,
@@ -172,6 +206,10 @@ export const getImportMapScript = (
172
206
  if (isUnresolvableDependency(pkgName) || isMalformedDependency(pkgName)) continue
173
207
  const version = pin[pkgName] || dependencies[pkgName] || 'latest'
174
208
  imports[pkgName] = getCDNUrl(pkgName, version, defaultProvider)
209
+ // See SUBPATH TWIN above.
210
+ if (!pkgName.endsWith('/')) {
211
+ imports[pkgName + '/'] = getCDNDirUrl(pkgName, version, defaultProvider)
212
+ }
175
213
  }
176
214
  if (!Object.keys(imports).length) return ''
177
215
 
package/dist/cjs/cdn.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var l=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var x=(t,s)=>{for(var e in s)l(t,e,{get:s[e],enumerable:!0})},D=(t,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of b(s))!E.call(t,r)&&r!==e&&l(t,r,{get:()=>s[r],enumerable:!(o=h(s,r))||o.enumerable});return t};var U=t=>D(l({},"__esModule",{value:!0}),t);var N={};x(N,{CDN_PROVIDERS:()=>n,PACKAGE_MANAGER_TO_CDN:()=>m,getCDNUrl:()=>i,getCdnProviderFromConfig:()=>C,getImportMapScript:()=>j,isMalformedDependency:()=>g,isUnresolvableDependency:()=>u,stripVersionRangePrefix:()=>a});module.exports=U(N);const n={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${n.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${n.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${n.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${n.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${n.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},m={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},C=(t={})=>{const{packageManager:s}=t;return m[s]||null},a=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},i=(t,s="latest",e="esmsh")=>(n[e]||n.esmsh).formatUrl(t,a(s)),R=/^node:|^@symbo-ls\//,u=t=>typeof t=="string"&&R.test(t),_=/[<>…]/,g=t=>typeof t=="string"&&_.test(t),j=(t,s="skypack",e={})=>{const o=t.dependencies||{},r=Object.keys(o);if(!r.length)return"";const $=e.pin||{},c={};for(const p of r){if(u(p)||g(p))continue;const f=$[p]||o[p]||"latest";c[p]=i(p,f,s)}if(!Object.keys(c).length)return"";const k='<script type="importmap">',d="<\/script>",y=`{
2
- "imports": ${JSON.stringify(c,null,2)}
3
- }`;return`${k}${y}${d}`};
1
+ "use strict";var l=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var C=(t,s)=>{for(var r in s)l(t,r,{get:s[r],enumerable:!0})},E=(t,s,r,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of b(s))!x.call(t,e)&&e!==r&&l(t,e,{get:()=>s[e],enumerable:!(c=D(s,e))||c.enumerable});return t};var U=t=>E(l({},"__esModule",{value:!0}),t);var O={};C(O,{CDN_PROVIDERS:()=>n,PACKAGE_MANAGER_TO_CDN:()=>a,getCDNDirUrl:()=>u,getCDNUrl:()=>$,getCdnProviderFromConfig:()=>N,getImportMapScript:()=>j,isMalformedDependency:()=>k,isUnresolvableDependency:()=>g,stripVersionRangePrefix:()=>m});module.exports=U(O);const n={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${n.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${n.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${n.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${n.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${n.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},a={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},N=(t={})=>{const{packageManager:s}=t;return a[s]||null},m=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},$=(t,s="latest",r="esmsh")=>(n[r]||n.esmsh).formatUrl(t,m(s)),u=(t,s="latest",r="esmsh")=>{const c=n[r]||n.esmsh,e=m(s);return`${c.url}/${t}${e!=="latest"?`@${e}`:""}/`},R=/^node:|^@symbo-ls\//,g=t=>typeof t=="string"&&R.test(t),_=/[<>…]/,k=t=>typeof t=="string"&&_.test(t),j=(t,s="skypack",r={})=>{const c=t.dependencies||{},e=Object.keys(c);if(!e.length)return"";const d=r.pin||{},p={};for(const o of e){if(g(o)||k(o))continue;const i=d[o]||c[o]||"latest";p[o]=$(o,i,s),o.endsWith("/")||(p[o+"/"]=u(o,i,s))}if(!Object.keys(p).length)return"";const y='<script type="importmap">',f="<\/script>",h=`{
2
+ "imports": ${JSON.stringify(p,null,2)}
3
+ }`;return`${y}${h}${f}`};
@@ -1,17 +1,18 @@
1
- "use strict";var x=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b(t))!F.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(s=W(t,n))||s.enumerable});return e};var B=e=>q(x({},"__esModule",{value:!0}),e);var Se={};J(Se,{clone:()=>z,createNestedObject:()=>ye,createObjectWithoutPrototype:()=>R,deepClone:()=>U,deepContains:()=>ae,deepDestringifyFunctions:()=>j,deepMerge:()=>m,deepStringifyFunctions:()=>$,destringifyGlobalScope:()=>re,detectInfiniteLoop:()=>ge,excludeKeysFromObject:()=>_e,exec:()=>P,getInObjectByPath:()=>we,hasFunction:()=>S,hasOwnProperty:()=>se,isCyclic:()=>Oe,isEmpty:()=>C,isEmptyObject:()=>ie,isEqualDeep:()=>M,makeObjectWithoutPrototype:()=>ce,map:()=>G,merge:()=>H,objectToString:()=>k,overwrite:()=>fe,overwriteDeep:()=>I,overwriteShallow:()=>le,removeFromObject:()=>pe,removeNestedKeyByPath:()=>he,setInObjectByPath:()=>de,stringToObject:()=>oe});module.exports=B(Se);var _=require("./globals.js"),l=require("./types.js"),T=require("./array.js"),N=require("./string.js"),g=require("./node.js"),D=require("./keys.js");const E="production",O=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,P=(e,t,r,s)=>{if((0,l.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,l.isArray)(e)||(0,l.isObject)(e)&&!(0,g.isDOMNode)(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return P(i,t,r,s)}}return e},G=(e,t,r)=>{for(const s in t)e[s]=P(t[s],r)},H=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(O(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},m=(e,t,r=D.METHODS_EXL)=>v(e,t,r,null),v=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||O(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],c=t[o];if((0,l.isObjectLike)(i)&&(0,l.isObjectLike)(c)){const u=s||[];u.push(e,t),v(i,c,r,u),u.length-=2}else i===void 0&&(e[o]=c)}return e},z=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(O(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},U=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!(0,l.isObjectLike)(e)||(0,g.isDOMNode)(e))return e;if(o.has(e))return o.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,u=y=>c?c.has(y):r.includes(y),f=(0,l.isArray)(e)?[]:{};o.set(e,f);const p=[[e,f]];for(;p.length;){const[y,d]=p.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||O(h)||h==="__proto__"||u(h))continue;const a=y[h];if(!(s&&a===void 0)&&!(n&&a===null)){if((0,g.isDOMNode)(a)){d[h]=a;continue}if(i&&h==="extends"&&(0,l.isArray)(a)){d[h]=(0,T.unstackArrayOfObjects)(a,r);continue}if((0,l.isFunction)(a)){d[h]=a;continue}if((0,l.isObjectLike)(a))if(o.has(a))d[h]=o.get(a);else{const w=(0,l.isArray)(a)?[]:{};o.set(a,w),d[h]=w,p.push([a,w])}else d[h]=a}}}return f},$=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const r in e){const s=e[r];if((0,l.isFunction)(s))t[r]=s.toString();else if((0,l.isObject)(s))t[r]={},$(s,t[r]);else if((0,l.isArray)(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];(0,l.isObject)(i)?(n[o]={},$(i,n[o])):(0,l.isFunction)(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},V=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),k=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
2
- `;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let c=!1;for(let f=0;f<o.length;f++)if(V.has(o[f])){c=!0;break}const u=c?`'${o}'`:o;if(n+=`${s} ${u}: `,(0,l.isArray)(i)){n+=`[
3
- `;for(const f of i)(0,l.isObjectLike)(f)&&f!==null?n+=`${s} ${k(f,t+2)},
4
- `:(0,l.isString)(f)?n+=`${s} '${f}',
5
- `:n+=`${s} ${f},
6
- `;n+=`${s} ]`}else(0,l.isObjectLike)(i)?n+=k(i,t+1):(0,l.isString)(i)?n+=(0,N.stringIncludesAny)(i,[`
1
+ "use strict";var x=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},B=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!q.call(e,n)&&n!==r&&x(e,n,{get:()=>t[n],enumerable:!(s=G(t,n))||s.enumerable});return e};var H=e=>B(x({},"__esModule",{value:!0}),e);var $e={};z($e,{clone:()=>V,createNestedObject:()=>de,createObjectWithoutPrototype:()=>W,deepClone:()=>X,deepContains:()=>ye,deepDestringifyFunctions:()=>ne,deepMerge:()=>m,deepStringifyFunctions:()=>E,destringifyGlobalScope:()=>se,detectInfiniteLoop:()=>Oe,excludeKeysFromObject:()=>xe,exec:()=>$,getInObjectByPath:()=>_e,hasFunction:()=>S,hasOwnProperty:()=>ce,isCyclic:()=>Se,isEmpty:()=>M,isEmptyObject:()=>fe,isEqualDeep:()=>L,makeObjectWithoutPrototype:()=>le,map:()=>U,merge:()=>Z,objectToString:()=>P,overwrite:()=>ue,overwriteDeep:()=>b,overwriteShallow:()=>ae,removeFromObject:()=>he,removeNestedKeyByPath:()=>ge,setInObjectByPath:()=>we,stringToObject:()=>ie});module.exports=H($e);var O=require("./globals.js"),l=require("./types.js"),D=require("./array.js"),C=require("./string.js"),w=require("./node.js"),I=require("./keys.js");const k="production",_=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,$=(e,t,r,s)=>{if((0,l.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,l.isArray)(e)||(0,l.isObject)(e)&&!(0,w.isDOMNode)(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return $(i,t,r,s)}}return e},U=(e,t,r)=>{for(const s in t)e[s]=$(t[s],r)},Z=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(_(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},m=(e,t,r=I.METHODS_EXL)=>A(e,t,r,null),A=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||_(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],f=t[o];if((0,l.isObjectLike)(i)&&(0,l.isObjectLike)(f)){const u=s||[];u.push(e,t),A(i,f,r,u),u.length-=2}else i===void 0&&(e[o]=f)}return e},V=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},X=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!(0,l.isObjectLike)(e)||(0,w.isDOMNode)(e))return e;if(o.has(e))return o.get(e);const f=r instanceof Set?r:r.length>3?new Set(r):null,u=y=>f?f.has(y):r.includes(y),c=(0,l.isArray)(e)?[]:{};o.set(e,c);const a=[[e,c]];for(;a.length;){const[y,d]=a.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||_(h)||h==="__proto__"||u(h))continue;const p=y[h];if(!(s&&p===void 0)&&!(n&&p===null)){if((0,w.isDOMNode)(p)){d[h]=p;continue}if(i&&h==="extends"&&(0,l.isArray)(p)){d[h]=(0,D.unstackArrayOfObjects)(p,r);continue}if((0,l.isFunction)(p)){d[h]=p;continue}if((0,l.isObjectLike)(p))if(o.has(p))d[h]=o.get(p);else{const g=(0,l.isArray)(p)?[]:{};o.set(p,g),d[h]=g,a.push([p,g])}else d[h]=p}}}return c},E=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const r in e){const s=e[r];if((0,l.isFunction)(s))t[r]=s.toString();else if((0,l.isObject)(s))t[r]={},E(s,t[r]);else if((0,l.isArray)(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];(0,l.isObject)(i)?(n[o]={},E(i,n[o])):(0,l.isFunction)(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},Y=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),P=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
2
+ `;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let f=!1;for(let c=0;c<o.length;c++)if(Y.has(o[c])){f=!0;break}const u=f?`'${o}'`:o;if(n+=`${s} ${u}: `,i instanceof RegExp)n+=String(i);else if((0,l.isArray)(i)){n+=`[
3
+ `;for(const c of i)c instanceof RegExp?n+=`${s} ${String(c)},
4
+ `:(0,l.isObjectLike)(c)&&c!==null?n+=`${s} ${P(c,t+2)},
5
+ `:(0,l.isString)(c)?n+=`${s} '${c}',
6
+ `:n+=`${s} ${c},
7
+ `;n+=`${s} ]`}else(0,l.isObjectLike)(i)?n+=P(i,t+1):(0,l.isString)(i)?n+=(0,C.stringIncludesAny)(i,[`
7
8
  `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
- `}return n+=`${s}}`,n},Z=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],K=/^["[{]/,X=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||X.test(t)||!Z.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||K.test(t)&&!n)},Y=e=>(0,eval)(e),Q=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,c=null;const u=e.length,f=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<u&&i>0;){const y=e[o];if(y==="/"&&e[o+1]==="/"){const d=e.indexOf(`
9
- `,o);o=d===-1?u:d;continue}if(y==="/"&&e[o+1]==="*"){const d=e.indexOf("*/",o+2);o=d===-1?u:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(o++;o<u;){if(e[o]==="\\"){o+=2;continue}if(e[o]===d){o++;break}if(d==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let h=1;for(;o<u&&h>0;)e[o]==="{"?h++:e[o]==="}"&&h--,o++;continue}o++}continue}if(y==="{"){i++,o++;continue}if(y==="}"){i--,o++;continue}if(i===1&&f.test(e.slice(o))){const d=o;let h=0,a=o;for(;a<u;){const w=e[a];if(w==='"'||w==="'"||w==="`"){const L=w;for(a++;a<u;){if(e[a]==="\\"){a+=2;continue}if(e[a]===L){a++;break}a++}continue}if(w==="("||w==="["||w==="{"){h++,a++;continue}if(w===")"||w==="]"||w==="}"){if(h===0)break;h--,a++;continue}if(h===0&&(w===";"||w===`
10
- `)){a++;break}a++}n.push([d,a]),o=a;continue}o++}if(!n.length)return null;let p=e;for(let y=n.length-1;y>=0;y--)p=p.slice(0,n[y][0])+p.slice(n[y][1]);return p},A=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),c=/Identifier '([^']+)' has already been declared/.exec(o);let u=null;if(i){const f=String(e).trim();if(/^function[\s(]/.test(f))try{u=r.window.eval("(async "+f+")")}catch{}}else if(c){let f=String(e),p=c[1];for(let y=0;y<5;y++){const d=Q(f,p);if(!d||d===f)break;f=d;try{u=r.window.eval("("+f+")");break}catch(h){const a=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!a||a[1]!==p)break}}}return u||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
11
- First 200 chars of source: `+String(e).slice(0,200)),e)}},j=(e,t={},r={window:{eval:Y}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if((0,l.isString)(c))S(c)?o[i]=A(c,`"${i}"`,r):o[i]=c;else if((0,l.isArray)(c)){const u=o[i]=[];for(let f=0;f<c.length;f++){const p=c[f];if((0,l.isString)(p))u.push(S(p)?A(p,`array index ${f} (prop "${i}")`,r):p);else if((0,l.isObject)(p)){const y={};u.push(y),s.push([p,y])}else u.push(p)}}else if((0,l.isObject)(c)){const u=o[i]&&typeof o[i]=="object"&&!(0,l.isArray)(o[i])?o[i]:o[i]={};s.push([c,u])}else o[i]=c}}return t},ee="Set",te="Map",ne=e=>!e||typeof e!="object"?e:e.__type===ee&&Array.isArray(e.values)?new Set(e.values):e.__type===te&&Array.isArray(e.entries)?new Map(e.entries):e,re=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const c=e[i];(0,l.isString)(c)&&S(c)?r.push([i,c]):t[i]=ne(c)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
12
- `);try{const i=n.map(([f,p])=>`var ${f} = (${p});`).join(`
13
- `),c="{ "+n.map(([f])=>`${JSON.stringify(f)}: ${f}`).join(", ")+" }",u=_.window.eval(`(function(__gs__) { ${o}
9
+ `}return n+=`${s}}`,n},K=[/^\(\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]*\}$/],Q=/^["[{]/,j=/^(export|import)\s/,S=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||j.test(t)||!K.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||Q.test(t)&&!n)},ee=e=>(0,eval)(e),te=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,f=null;const u=e.length,c=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<u&&i>0;){const y=e[o];if(y==="/"&&e[o+1]==="/"){const d=e.indexOf(`
10
+ `,o);o=d===-1?u:d;continue}if(y==="/"&&e[o+1]==="*"){const d=e.indexOf("*/",o+2);o=d===-1?u:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(o++;o<u;){if(e[o]==="\\"){o+=2;continue}if(e[o]===d){o++;break}if(d==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let h=1;for(;o<u&&h>0;)e[o]==="{"?h++:e[o]==="}"&&h--,o++;continue}o++}continue}if(y==="{"){i++,o++;continue}if(y==="}"){i--,o++;continue}if(i===1&&c.test(e.slice(o))){const d=o;let h=0,p=o;for(;p<u;){const g=e[p];if(g==='"'||g==="'"||g==="`"){const F=g;for(p++;p<u;){if(e[p]==="\\"){p+=2;continue}if(e[p]===F){p++;break}p++}continue}if(g==="("||g==="["||g==="{"){h++,p++;continue}if(g===")"||g==="]"||g==="}"){if(h===0)break;h--,p++;continue}if(h===0&&(g===";"||g===`
11
+ `)){p++;break}p++}n.push([d,p]),o=p;continue}o++}if(!n.length)return null;let a=e;for(let y=n.length-1;y>=0;y--)a=a.slice(0,n[y][0])+a.slice(n[y][1]);return a},v=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),f=/Identifier '([^']+)' has already been declared/.exec(o);let u=null;if(i){const c=String(e).trim();if(/^function[\s(]/.test(c))try{u=r.window.eval("(async "+c+")")}catch{}}else if(f){let c=String(e),a=f[1];for(let y=0;y<5;y++){const d=te(c,a);if(!d||d===c)break;c=d;try{u=r.window.eval("("+c+")");break}catch(h){const p=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!p||p[1]!==a)break}}}if(!u&&/Unexpected (token '\{'|identifier)/.test(o))try{const c=r.window.eval("({"+e+"})");if(c&&typeof c=="object"){const a=Object.keys(c);a.length===1&&typeof c[a[0]]=="function"&&(u=c[a[0]])}}catch{}return u||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
12
+ First 200 chars of source: `+String(e).slice(0,200)),e)}},ne=(e,t={},r={window:{eval:ee}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=n[i];if((0,l.isString)(f))S(f)?o[i]=v(f,`"${i}"`,r):o[i]=f;else if((0,l.isArray)(f)){const u=o[i]=[];for(let c=0;c<f.length;c++){const a=f[c];if((0,l.isString)(a))u.push(S(a)?v(a,`array index ${c} (prop "${i}")`,r):a);else if((0,l.isObject)(a)){const y=N(a);if(y)u.push(y);else{const d={};u.push(d),s.push([a,d])}}else u.push(a)}}else if((0,l.isObject)(f)){const u=N(f);if(u){o[i]=u;continue}const c=o[i]&&typeof o[i]=="object"&&!(0,l.isArray)(o[i])?o[i]:o[i]={};s.push([f,c])}else o[i]=f}}return t},re="Set",oe="Map",R="RegExp",T=e=>{if(!e||typeof e!="object")return e;if(e.__type===re&&Array.isArray(e.values))return new Set(e.values);if(e.__type===oe&&Array.isArray(e.entries))return new Map(e.entries);if(e.__type===R&&(0,l.isString)(e.source))try{return new RegExp(e.source,(0,l.isString)(e.flags)?e.flags:"")}catch{return e}return e},N=e=>{if(!e||typeof e!="object"||e.__type!==R)return null;const t=T(e);return t instanceof RegExp?t:null},se=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const f=e[i];(0,l.isString)(f)&&S(f)?r.push([i,f]):t[i]=T(f)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
13
+ `);try{const i=n.map(([c,a])=>`var ${c} = (${a});`).join(`
14
+ `),f="{ "+n.map(([c])=>`${JSON.stringify(c)}: ${c}`).join(", ")+" }",u=O.window.eval(`(function(__gs__) { ${o}
14
15
  ${i}
15
- return ${c}; })`)(t);Object.assign(t,u)}catch{for(const[c,u]of n)try{const f=Object.keys(t).filter(s).map(p=>`var ${p} = __gs__[${JSON.stringify(p)}];`).join(`
16
- `);t[c]=_.window.eval(`(function(__gs__) { ${f}
17
- return (${u}); })`)(t)}catch{try{t[c]=_.window.eval(`(${u})`)}catch{t[c]=u}}}for(const[i,c]of r)if(!s(i))try{t[i]=_.window.eval(`(${c})`)}catch{t[i]=c}return t},oe=(e,t={verbose:!0})=>{try{return e?_.window.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},se=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),C=e=>{for(const t in e)return!1;return!0},ie=e=>(0,l.isObject)(e)&&C(e),ce=()=>Object.create(null),fe=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&O(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},le=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)O(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},I=(e,t,r={},s=new WeakMap)=>{if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||o&&o.has(c)||i&&O(c)||c==="constructor"||c==="prototype")continue;const u=e[c],f=t[c];(0,g.isDOMNode)(f)?e[c]=f:(0,l.isObjectLike)(u)&&(0,l.isObjectLike)(f)?e[c]=I(u,f,r,s):f!==void 0&&(e[c]=f)}return e},M=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!M(e[i],t[i],r))return!1}return!0},ue=new Set(["node","__ref"]),ae=(e,t,r=ue)=>{if(e===t)return!0;if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,g.isDOMNode)(e)||(0,g.isDOMNode)(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,c){if(n.has(c))return!0;n.add(c);for(const u in c){if(!Object.prototype.hasOwnProperty.call(c,u)||s.has(u))continue;if(!Object.prototype.hasOwnProperty.call(i,u))return!1;const f=c[u],p=i[u];if((0,g.isDOMNode)(f)||(0,g.isDOMNode)(p)){if(f!==p)return!1}else if((0,l.isObjectLike)(f)&&(0,l.isObjectLike)(p)){if(!o(p,f))return!1}else if(f!==p)return!1}return!0}return o(e,t)},pe=(e,t)=>{if(t==null)return e;if((0,l.is)(t)("string","number"))delete e[t];else if((0,l.isArray)(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},R=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=R(e[r]));return t},ye=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[e[n]]);return r},he=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},de=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[t[t.length-1]]=r,e},we=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},ge=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(E==="test"||E==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Oe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},_e=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};
16
+ return ${f}; })`)(t);Object.assign(t,u)}catch{for(const[f,u]of n)try{const c=Object.keys(t).filter(s).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
17
+ `);t[f]=O.window.eval(`(function(__gs__) { ${c}
18
+ return (${u}); })`)(t)}catch{try{t[f]=O.window.eval(`(${u})`)}catch{t[f]=u}}}for(const[i,f]of r)if(!s(i))try{t[i]=O.window.eval(`(${f})`)}catch{t[i]=f}return t},ie=(e,t={verbose:!0})=>{try{return e?O.window.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},ce=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),M=e=>{for(const t in e)return!1;return!0},fe=e=>(0,l.isObject)(e)&&M(e),le=()=>Object.create(null),ue=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&_(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},ae=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)_(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},b=(e,t,r={},s=new WeakMap)=>{if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,w.isDOMNode)(e)||(0,w.isDOMNode)(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||o&&o.has(f)||i&&_(f)||f==="constructor"||f==="prototype")continue;const u=e[f],c=t[f];(0,w.isDOMNode)(c)?e[f]=c:(0,l.isObjectLike)(u)&&(0,l.isObjectLike)(c)?e[f]=b(u,c,r,s):c!==void 0&&(e[f]=c)}return e},L=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!L(e[i],t[i],r))return!1}return!0},pe=new Set(["node","__ref"]),ye=(e,t,r=pe)=>{if(e===t)return!0;if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,w.isDOMNode)(e)||(0,w.isDOMNode)(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,f){if(n.has(f))return!0;n.add(f);for(const u in f){if(!Object.prototype.hasOwnProperty.call(f,u)||s.has(u))continue;if(!Object.prototype.hasOwnProperty.call(i,u))return!1;const c=f[u],a=i[u];if((0,w.isDOMNode)(c)||(0,w.isDOMNode)(a)){if(c!==a)return!1}else if((0,l.isObjectLike)(c)&&(0,l.isObjectLike)(a)){if(!o(a,c))return!1}else if(c!==a)return!1}return!0}return o(e,t)},he=(e,t)=>{if(t==null)return e;if((0,l.is)(t)("string","number"))delete e[t];else if((0,l.isArray)(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},W=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=W(e[r]));return t},de=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[e[n]]);return r},ge=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},we=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[t[t.length-1]]=r,e},_e=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},Oe=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(k==="test"||k==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Se=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},xe=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var e in t)u(n,e,{get:t[e],enumerable:!0})},E=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!U.call(n,o)&&o!==e&&u(n,o,{get:()=>t[o],enumerable:!(r=j(t,o))||r.enumerable});return n};var O=n=>E(u({},"__esModule",{value:!0}),n);var N={};S(N,{deepDefaults:()=>d,fetchLibraryData:()=>k,isWrappedLibrary:()=>y,mergeSharedLibraries:()=>F,normalizeIgnoreList:()=>p,normalizeLibraryKey:()=>l,resolveSharedLibraries:()=>K,sharedLibrary:()=>C});module.exports=O(N);var a=require("./types.js");const b="system",_="https://smbls-kv.nika-980.workers.dev",P="https://api.symbols.app";function l(n){const t=String(n||"").trim();if(!t)return{owner:b,key:"",full:""};let e=null,r=t;if(t.includes("/")){const s=t.indexOf("/");e=t.slice(0,s),r=t.slice(s+1)}r=r.replace(/\.symbo\.ls$/iu,""),e||(e=b);const o=r?`${e}/${r}`:"";return{owner:e,key:r,full:o}}const d=(n,t,e,r)=>{for(const o in t){const s=r?`${r}/${o}`:o;e&&e.has(s)||(o in n?(0,a.isObject)(n[o])&&(0,a.isObject)(t[o])&&d(n[o],t[o],e,s):n[o]=t[o])}},w=(n,t,e)=>{if(!(0,a.isObject)(n)||!t.size)return n;const r=`${e}/`;let o=!1;for(const i of t)if(i.startsWith(r)){o=!0;break}if(!o)return n;const s={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=`${e}/${i}`;t.has(f)||(s[i]=w(n[i],t,f))}return s},B=new Set,x=n=>n.replace(/\.js$/iu,""),p=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const e of n){if(!(0,a.isString)(e))continue;const r=e.split("/").map(o=>x(o.trim())).filter(Boolean).join("/");r&&t.add(r)}return t},C=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),y=n=>(0,a.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),T=n=>n.library!==void 0?n.library:n.key??n.name,z=(n,t,e)=>{const r=p(t.sharedLibIgnore);t.sharePages===!1&&r.add("pages");const o=r.size?new Set([...e,...r]):e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&!(s==="sharePages"||s==="sharedLibIgnore")&&!o.has(s))if((0,a.isObject)(t[s])&&(0,a.isObject)(n[s]))if(s==="designSystem")d(n[s],t[s],o,s);else for(const i in t[s])o.has(`${s}/${i}`)||i in n[s]||(n[s][i]=t[s][i]);else s in n||(n[s]=w(t[s],o,s))},F=(n,t)=>{if(!(!t||!t.length))for(let e=0;e<t.length;e++){let r=t[e],o=B;y(r)&&(o=p(r.ignoreList),r=r.library),(0,a.isObject)(r)&&z(n,r,o)}};async function k(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const r=await G(n,t);return r||$(n,t)}async function G(n,t={}){const e=t.kvBaseUrl||_,r=t.env||"production",o=`${e}/kv/${encodeURIComponent(n)}?env=${r}`;try{const s=await fetch(o,{method:"GET"});return s.ok&&(await s.json())?.value||null}catch{return null}}async function $(n,t={}){const e=t.apiBaseUrl||P,{key:r}=l(n);try{const o=`${e}/core/projects/libraries/available?search=${encodeURIComponent(r)}&limit=10`,s=await fetch(o,{method:"GET"});if(!s.ok)return null;const i=await s.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(v=>{const{key:I}=l(v?.key);return I.toLowerCase()===r.toLowerCase()});if(!c?.id&&!c?._id)return null;const L=c.id||c._id,A=`${e}/core/projects/${encodeURIComponent(L)}/data?branch=main`,h=await fetch(A,{method:"GET"});if(!h.ok)return null;const m=await h.json();return m?.data||m||null}catch{return null}}async function g(n,t={}){if((0,a.isObject)(n))return n;if((0,a.isString)(n)){const{full:e}=l(n);if(!e)return null;try{const r=await k(e,t);return r||console.warn(`[smbls] Shared library "${e}" not found`),r}catch(r){return console.warn(`[smbls] Failed to fetch shared library "${e}":`,r.message),null}}return null}async function K(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async r=>{if(y(r)){const o=await g(T(r),t);return o?{library:o,ignoreList:r.ignoreList}:null}return g(r,t)}))).filter(Boolean)}
1
+ "use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var E=(n,t)=>{for(var o in t)u(n,o,{get:t[o],enumerable:!0})},O=(n,t,o,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of R(t))!U.call(n,s)&&s!==o&&u(n,s,{get:()=>t[s],enumerable:!(e=j(t,s))||e.enumerable});return n};var _=n=>O(u({},"__esModule",{value:!0}),n);var x={};E(x,{deepDefaults:()=>p,fetchLibraryData:()=>L,isWrappedLibrary:()=>d,mergeSharedLibraries:()=>K,normalizeIgnoreList:()=>y,normalizeLibraryKey:()=>l,resolveSharedLibraries:()=>W,sharedLibrary:()=>z});module.exports=_(x);var a=require("./types.js");const b="system",B="https://smbls-kv.nika-980.workers.dev",P="https://api.symbols.app";function l(n){const t=String(n||"").trim();if(!t)return{owner:b,key:"",full:""};let o=null,e=t;if(t.includes("/")){const r=t.indexOf("/");o=t.slice(0,r),e=t.slice(r+1)}e=e.replace(/\.symbo\.ls$/iu,""),o||(o=b);const s=e?`${o}/${e}`:"";return{owner:o,key:e,full:s}}const p=(n,t,o,e)=>{for(const s in t){const r=e?`${e}/${s}`:s;o&&o.has(r)||(s in n?(0,a.isObject)(n[s])&&(0,a.isObject)(t[s])&&p(n[s],t[s],o,r):n[s]=t[s])}},w=(n,t,o)=>{if(!(0,a.isObject)(n)||!t.size)return n;const e=`${o}/`;let s=!1;for(const i of t)if(i.startsWith(e)){s=!0;break}if(!s)return n;const r={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=`${o}/${i}`;t.has(f)||(r[i]=w(n[i],t,f))}return r},C=new Set,T=new Set(["components","pages","functions","snippets","methods"]),g=(n,t)=>t===""&&T.has(n),G=n=>n.replace(/\.js$/iu,""),y=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const o of n){if(!(0,a.isString)(o))continue;const e=o.split("/").map(s=>G(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},z=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),d=n=>(0,a.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),F=n=>n.library!==void 0?n.library:n.key??n.name,J=(n,t,o)=>{const e=y(t.sharedLibIgnore);t.sharePages===!1&&e.add("pages");const s=e.size?new Set([...o,...e]):o;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!(r==="sharePages"||r==="sharedLibIgnore")&&!s.has(r))if((0,a.isObject)(t[r])&&(0,a.isObject)(n[r]))if(r==="designSystem")p(n[r],t[r],s,r);else for(const i in t[r])s.has(`${r}/${i}`)||(i in n[r]?g(r,n[r][i])&&!g(r,t[r][i])&&(n[r][i]=t[r][i]):n[r][i]=t[r][i]);else r in n||(n[r]=w(t[r],s,r))},K=(n,t)=>{if(!(!t||!t.length))for(let o=0;o<t.length;o++){let e=t[o],s=C;d(e)&&(s=y(e.ignoreList),e=e.library),(0,a.isObject)(e)&&J(n,e,s)}};async function L(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const e=await N(n,t);return e||$(n,t)}async function N(n,t={}){const o=t.kvBaseUrl||B,e=t.env||"production",s=`${o}/kv/${encodeURIComponent(n)}?env=${e}`;try{const r=await fetch(s,{method:"GET"});return r.ok&&(await r.json())?.value||null}catch{return null}}async function $(n,t={}){const o=t.apiBaseUrl||P,{key:e}=l(n);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,r=await fetch(s,{method:"GET"});if(!r.ok)return null;const i=await r.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(v=>{const{key:I}=l(v?.key);return I.toLowerCase()===e.toLowerCase()});if(!c?.id&&!c?._id)return null;const A=c.id||c._id,S=`${o}/core/projects/${encodeURIComponent(A)}/data?branch=main`,h=await fetch(S,{method:"GET"});if(!h.ok)return null;const m=await h.json();return m?.data||m||null}catch{return null}}async function k(n,t={}){if((0,a.isObject)(n))return n;if((0,a.isString)(n)){const{full:o}=l(n);if(!o)return null;try{const e=await L(o,t);return e||console.warn(`[smbls] Shared library "${o}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,e.message),null}}return null}async function W(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(d(e)){const s=await k(F(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return k(e,t)}))).filter(Boolean)}
package/dist/esm/cdn.js CHANGED
@@ -1,3 +1,3 @@
1
- const e={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${e.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${e.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${e.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${e.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${e.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},g={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},b=(t={})=>{const{packageManager:s}=t;return g[s]||null},$=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},k=(t,s="latest",n="esmsh")=>(e[n]||e.esmsh).formatUrl(t,$(s)),d=/^node:|^@symbo-ls\//,y=t=>typeof t=="string"&&d.test(t),f=/[<>…]/,h=t=>typeof t=="string"&&f.test(t),E=(t,s="skypack",n={})=>{const o=t.dependencies||{},c=Object.keys(o);if(!c.length)return"";const l=n.pin||{},p={};for(const r of c){if(y(r)||h(r))continue;const u=l[r]||o[r]||"latest";p[r]=k(r,u,s)}if(!Object.keys(p).length)return"";const m='<script type="importmap">',a="<\/script>",i=`{
1
+ const r={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${r.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${r.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${r.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${r.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${r.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},g={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},b=(t={})=>{const{packageManager:s}=t;return g[s]||null},m=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},k=(t,s="latest",n="esmsh")=>(r[n]||r.esmsh).formatUrl(t,m(s)),d=(t,s="latest",n="esmsh")=>{const o=r[n]||r.esmsh,c=m(s);return`${o.url}/${t}${c!=="latest"?`@${c}`:""}/`},y=/^node:|^@symbo-ls\//,f=t=>typeof t=="string"&&y.test(t),h=/[<>…]/,D=t=>typeof t=="string"&&h.test(t),x=(t,s="skypack",n={})=>{const o=t.dependencies||{},c=Object.keys(o);if(!c.length)return"";const i=n.pin||{},p={};for(const e of c){if(f(e)||D(e))continue;const l=i[e]||o[e]||"latest";p[e]=k(e,l,s),e.endsWith("/")||(p[e+"/"]=d(e,l,s))}if(!Object.keys(p).length)return"";const a='<script type="importmap">',$="<\/script>",u=`{
2
2
  "imports": ${JSON.stringify(p,null,2)}
3
- }`;return`${m}${i}${a}`};export{e as CDN_PROVIDERS,g as PACKAGE_MANAGER_TO_CDN,k as getCDNUrl,b as getCdnProviderFromConfig,E as getImportMapScript,h as isMalformedDependency,y as isUnresolvableDependency,$ as stripVersionRangePrefix};
3
+ }`;return`${a}${u}${$}`};export{r as CDN_PROVIDERS,g as PACKAGE_MANAGER_TO_CDN,d as getCDNDirUrl,k as getCDNUrl,b as getCdnProviderFromConfig,x as getImportMapScript,D as isMalformedDependency,f as isUnresolvableDependency,m as stripVersionRangePrefix};
@@ -1,17 +1,18 @@
1
- import{window as x}from"./globals.js";import{isFunction as $,isObjectLike as w,isObject as S,isArray as O,isString as P,is as I}from"./types.js";import{unstackArrayOfObjects as M}from"./array.js";import{stringIncludesAny as R}from"./string.js";import{isDOMNode as g}from"./node.js";import{METHODS_EXL as L}from"./keys.js";const E="production",_=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,v=(e,t,r,s)=>{if($(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&(O(e)||S(e)&&!g(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return v(i,t,r,s)}}return e},ne=(e,t,r)=>{for(const s in t)e[s]=v(t[s],r)},re=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(_(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},oe=(e,t,r=L)=>A(e,t,r,null),A=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||_(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],c=t[o];if(w(i)&&w(c)){const l=s||[];l.push(e,t),A(i,c,r,l),l.length-=2}else i===void 0&&(e[o]=c)}return e},se=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},ie=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!w(e)||g(e))return e;if(o.has(e))return o.get(e);const c=r instanceof Set?r:r.length>3?new Set(r):null,l=p=>c?c.has(p):r.includes(p),f=O(e)?[]:{};o.set(e,f);const a=[[e,f]];for(;a.length;){const[p,h]=a.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||_(y)||y==="__proto__"||l(y))continue;const u=p[y];if(!(s&&u===void 0)&&!(n&&u===null)){if(g(u)){h[y]=u;continue}if(i&&y==="extends"&&O(u)){h[y]=M(u,r);continue}if($(u)){h[y]=u;continue}if(w(u))if(o.has(u))h[y]=o.get(u);else{const d=O(u)?[]:{};o.set(u,d),h[y]=d,a.push([u,d])}else h[y]=u}}}return f},T=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const r in e){const s=e[r];if($(s))t[r]=s.toString();else if(S(s))t[r]={},T(s,t[r]);else if(O(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];S(i)?(n[o]={},T(i,n[o])):$(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},W=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),N=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
2
- `;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let c=!1;for(let f=0;f<o.length;f++)if(W.has(o[f])){c=!0;break}const l=c?`'${o}'`:o;if(n+=`${s} ${l}: `,O(i)){n+=`[
3
- `;for(const f of i)w(f)&&f!==null?n+=`${s} ${N(f,t+2)},
4
- `:P(f)?n+=`${s} '${f}',
5
- `:n+=`${s} ${f},
6
- `;n+=`${s} ]`}else w(i)?n+=N(i,t+1):P(i)?n+=R(i,[`
1
+ import{window as $}from"./globals.js";import{isFunction as E,isObjectLike as g,isObject as x,isArray as _,isString as O,is as b}from"./types.js";import{unstackArrayOfObjects as L}from"./array.js";import{stringIncludesAny as W}from"./string.js";import{isDOMNode as w}from"./node.js";import{METHODS_EXL as F}from"./keys.js";const k="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,A=(e,t,r,s)=>{if(E(e))return t?typeof e.call!="function"?e:e.call(t,t,r||t.state,s||t.context):void 0;if(e!=null&&t?.context?.plugins&&(_(e)||x(e)&&!w(e))){const n=t.context.plugins;for(const o of n)if(o.resolveHandler){const i=o.resolveHandler(e,t);if(typeof i=="function")return A(i,t,r,s)}}return e},oe=(e,t,r)=>{for(const s in t)e[s]=A(t[s],r)},se=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(S(n)||(s?r.has(n):r.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},ie=(e,t,r=F)=>v(e,t,r,null),v=(e,t,r,s)=>{if(e===t)return e;if(s){for(let o=0;o<s.length;o+=2)if(s[o]===e&&s[o+1]===t)return e}const n=r instanceof Set;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||S(o)||o==="constructor"||o==="prototype"||(n?r.has(o):r.includes(o)))continue;const i=e[o],f=t[o];if(g(i)&&g(f)){const l=s||[];l.push(e,t),v(i,f,r,l),l.length-=2}else i===void 0&&(e[o]=f)}return e},ce=(e,t=[])=>{const r=t instanceof Set,s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(S(n)||(r?t.has(n):t.includes(n))||(s[n]=e[n]));return s},fe=(e,t={})=>{const{exclude:r=[],cleanUndefined:s=!1,cleanNull:n=!1,visited:o=new WeakMap,handleExtends:i=!1}=t;if(!g(e)||w(e))return e;if(o.has(e))return o.get(e);const f=r instanceof Set?r:r.length>3?new Set(r):null,l=p=>f?f.has(p):r.includes(p),c=_(e)?[]:{};o.set(e,c);const u=[[e,c]];for(;u.length;){const[p,h]=u.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||S(y)||y==="__proto__"||l(y))continue;const a=p[y];if(!(s&&a===void 0)&&!(n&&a===null)){if(w(a)){h[y]=a;continue}if(i&&y==="extends"&&_(a)){h[y]=L(a,r);continue}if(E(a)){h[y]=a;continue}if(g(a))if(o.has(a))h[y]=o.get(a);else{const d=_(a)?[]:{};o.set(a,d),h[y]=d,u.push([a,d])}else h[y]=a}}}return c},R=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const r in e){const s=e[r];if(E(s))t[r]=s.toString();else if(x(s))t[r]={},R(s,t[r]);else if(_(s)){const n=t[r]=[];for(let o=0;o<s.length;o++){const i=s[o];x(i)?(n[o]={},R(i,n[o])):E(i)?n[o]=i.toString():n[o]=i}}else t[r]=s}return t},G=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),T=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let r=!1;for(const o in e){r=!0;break}if(!r)return"{}";const s=" ".repeat(t);let n=`{
2
+ `;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let f=!1;for(let c=0;c<o.length;c++)if(G.has(o[c])){f=!0;break}const l=f?`'${o}'`:o;if(n+=`${s} ${l}: `,i instanceof RegExp)n+=String(i);else if(_(i)){n+=`[
3
+ `;for(const c of i)c instanceof RegExp?n+=`${s} ${String(c)},
4
+ `:g(c)&&c!==null?n+=`${s} ${T(c,t+2)},
5
+ `:O(c)?n+=`${s} '${c}',
6
+ `:n+=`${s} ${c},
7
+ `;n+=`${s} ]`}else g(i)?n+=T(i,t+1):O(i)?n+=W(i,[`
7
8
  `,"'"])?`\`${i}\``:`'${i}'`:n+=i;n+=`,
8
- `}return n+=`${s}}`,n},b=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],F=/^["[{]/,J=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||J.test(t)||!b.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||F.test(t)&&!n)},q=e=>(0,eval)(e),B=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,c=null;const l=e.length,f=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<l&&i>0;){const p=e[o];if(p==="/"&&e[o+1]==="/"){const h=e.indexOf(`
9
- `,o);o=h===-1?l:h;continue}if(p==="/"&&e[o+1]==="*"){const h=e.indexOf("*/",o+2);o=h===-1?l:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(o++;o<l;){if(e[o]==="\\"){o+=2;continue}if(e[o]===h){o++;break}if(h==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let y=1;for(;o<l&&y>0;)e[o]==="{"?y++:e[o]==="}"&&y--,o++;continue}o++}continue}if(p==="{"){i++,o++;continue}if(p==="}"){i--,o++;continue}if(i===1&&f.test(e.slice(o))){const h=o;let y=0,u=o;for(;u<l;){const d=e[u];if(d==='"'||d==="'"||d==="`"){const C=d;for(u++;u<l;){if(e[u]==="\\"){u+=2;continue}if(e[u]===C){u++;break}u++}continue}if(d==="("||d==="["||d==="{"){y++,u++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,u++;continue}if(y===0&&(d===";"||d===`
10
- `)){u++;break}u++}n.push([h,u]),o=u;continue}o++}if(!n.length)return null;let a=e;for(let p=n.length-1;p>=0;p--)a=a.slice(0,n[p][0])+a.slice(n[p][1]);return a},D=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),c=/Identifier '([^']+)' has already been declared/.exec(o);let l=null;if(i){const f=String(e).trim();if(/^function[\s(]/.test(f))try{l=r.window.eval("(async "+f+")")}catch{}}else if(c){let f=String(e),a=c[1];for(let p=0;p<5;p++){const h=B(f,a);if(!h||h===f)break;f=h;try{l=r.window.eval("("+f+")");break}catch(y){const u=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!u||u[1]!==a)break}}}return l||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
11
- First 200 chars of source: `+String(e).slice(0,200)),e)}},ce=(e,t={},r={window:{eval:q}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const c=n[i];if(P(c))k(c)?o[i]=D(c,`"${i}"`,r):o[i]=c;else if(O(c)){const l=o[i]=[];for(let f=0;f<c.length;f++){const a=c[f];if(P(a))l.push(k(a)?D(a,`array index ${f} (prop "${i}")`,r):a);else if(S(a)){const p={};l.push(p),s.push([a,p])}else l.push(a)}}else if(S(c)){const l=o[i]&&typeof o[i]=="object"&&!O(o[i])?o[i]:o[i]={};s.push([c,l])}else o[i]=c}}return t},G="Set",H="Map",m=e=>!e||typeof e!="object"?e:e.__type===G&&Array.isArray(e.values)?new Set(e.values):e.__type===H&&Array.isArray(e.entries)?new Map(e.entries):e,fe=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const c=e[i];P(c)&&k(c)?r.push([i,c]):t[i]=m(c)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
12
- `);try{const i=n.map(([f,a])=>`var ${f} = (${a});`).join(`
13
- `),c="{ "+n.map(([f])=>`${JSON.stringify(f)}: ${f}`).join(", ")+" }",l=x.eval(`(function(__gs__) { ${o}
9
+ `}return n+=`${s}}`,n},J=[/^\(\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]*\}$/],q=/^["[{]/,z=/^(export|import)\s/,P=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||z.test(t)||!J.some(o=>o.test(t)))return!1;const s=t.charCodeAt(0),n=t.includes("=>");return!(s===123&&!n||s===91||q.test(t)&&!n)},B=e=>(0,eval)(e),H=(e,t)=>{const r=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!r)return null;const s=r[0].length,n=[];let o=s,i=1,f=null;const l=e.length,c=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;o<l&&i>0;){const p=e[o];if(p==="/"&&e[o+1]==="/"){const h=e.indexOf(`
10
+ `,o);o=h===-1?l:h;continue}if(p==="/"&&e[o+1]==="*"){const h=e.indexOf("*/",o+2);o=h===-1?l:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(o++;o<l;){if(e[o]==="\\"){o+=2;continue}if(e[o]===h){o++;break}if(h==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let y=1;for(;o<l&&y>0;)e[o]==="{"?y++:e[o]==="}"&&y--,o++;continue}o++}continue}if(p==="{"){i++,o++;continue}if(p==="}"){i--,o++;continue}if(i===1&&c.test(e.slice(o))){const h=o;let y=0,a=o;for(;a<l;){const d=e[a];if(d==='"'||d==="'"||d==="`"){const M=d;for(a++;a<l;){if(e[a]==="\\"){a+=2;continue}if(e[a]===M){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++}n.push([h,a]),o=a;continue}o++}if(!n.length)return null;let u=e;for(let p=n.length-1;p>=0;p--)u=u.slice(0,n[p][0])+u.slice(n[p][1]);return u},N=(e,t,r)=>{const s=String(e).trimStart();if(/^(export|import)\s/.test(s))return e;try{return r.window.eval(`(${e})`)}catch(n){const o=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(o),f=/Identifier '([^']+)' has already been declared/.exec(o);let l=null;if(i){const c=String(e).trim();if(/^function[\s(]/.test(c))try{l=r.window.eval("(async "+c+")")}catch{}}else if(f){let c=String(e),u=f[1];for(let p=0;p<5;p++){const h=H(c,u);if(!h||h===c)break;c=h;try{l=r.window.eval("("+c+")");break}catch(y){const a=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!a||a[1]!==u)break}}}if(!l&&/Unexpected (token '\{'|identifier)/.test(o))try{const c=r.window.eval("({"+e+"})");if(c&&typeof c=="object"){const u=Object.keys(c);u.length===1&&typeof c[u[0]]=="function"&&(l=c[u[0]])}}catch{}return l||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+o+`.
12
+ First 200 chars of source: `+String(e).slice(0,200)),e)}},le=(e,t={},r={window:{eval:B}})=>{if(!e||typeof e!="object")return t;const s=[[e,t]];for(;s.length;){const[n,o]=s.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const f=n[i];if(O(f))P(f)?o[i]=N(f,`"${i}"`,r):o[i]=f;else if(_(f)){const l=o[i]=[];for(let c=0;c<f.length;c++){const u=f[c];if(O(u))l.push(P(u)?N(u,`array index ${c} (prop "${i}")`,r):u);else if(x(u)){const p=I(u);if(p)l.push(p);else{const h={};l.push(h),s.push([u,h])}}else l.push(u)}}else if(x(f)){const l=I(f);if(l){o[i]=l;continue}const c=o[i]&&typeof o[i]=="object"&&!_(o[i])?o[i]:o[i]={};s.push([f,c])}else o[i]=f}}return t},U="Set",Z="Map",D="RegExp",C=e=>{if(!e||typeof e!="object")return e;if(e.__type===U&&Array.isArray(e.values))return new Set(e.values);if(e.__type===Z&&Array.isArray(e.entries))return new Map(e.entries);if(e.__type===D&&O(e.source))try{return new RegExp(e.source,O(e.flags)?e.flags:"")}catch{return e}return e},I=e=>{if(!e||typeof e!="object"||e.__type!==D)return null;const t=C(e);return t instanceof RegExp?t:null},ue=e=>{if(!e||typeof e!="object")return e;const t={},r=[];for(const i of Object.keys(e)){const f=e[i];O(f)&&P(f)?r.push([i,f]):t[i]=C(f)}if(r.length===0)return t;const s=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=r.filter(([i])=>s(i)),o=Object.keys(t).filter(s).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
13
+ `);try{const i=n.map(([c,u])=>`var ${c} = (${u});`).join(`
14
+ `),f="{ "+n.map(([c])=>`${JSON.stringify(c)}: ${c}`).join(", ")+" }",l=$.eval(`(function(__gs__) { ${o}
14
15
  ${i}
15
- return ${c}; })`)(t);Object.assign(t,l)}catch{for(const[c,l]of n)try{const f=Object.keys(t).filter(s).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
16
- `);t[c]=x.eval(`(function(__gs__) { ${f}
17
- return (${l}); })`)(t)}catch{try{t[c]=x.eval(`(${l})`)}catch{t[c]=l}}}for(const[i,c]of r)if(!s(i))try{t[i]=x.eval(`(${c})`)}catch{t[i]=c}return t},le=(e,t={verbose:!0})=>{try{return e?x.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},ue=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),z=e=>{for(const t in e)return!1;return!0},ae=e=>S(e)&&z(e),pe=()=>Object.create(null),ye=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&_(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},he=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)_(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},U=(e,t,r={},s=new WeakMap)=>{if(!w(e)||!w(t)||g(e)||g(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||o&&o.has(c)||i&&_(c)||c==="constructor"||c==="prototype")continue;const l=e[c],f=t[c];g(f)?e[c]=f:w(l)&&w(f)?e[c]=U(l,f,r,s):f!==void 0&&(e[c]=f)}return e},V=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!V(e[i],t[i],r))return!1}return!0},Z=new Set(["node","__ref"]),de=(e,t,r=Z)=>{if(e===t)return!0;if(!w(e)||!w(t)||g(e)||g(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,c){if(n.has(c))return!0;n.add(c);for(const l in c){if(!Object.prototype.hasOwnProperty.call(c,l)||s.has(l))continue;if(!Object.prototype.hasOwnProperty.call(i,l))return!1;const f=c[l],a=i[l];if(g(f)||g(a)){if(f!==a)return!1}else if(w(f)&&w(a)){if(!o(a,f))return!1}else if(f!==a)return!1}return!0}return o(e,t)},we=(e,t)=>{if(t==null)return e;if(I(t)("string","number"))delete e[t];else if(O(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},K=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=K(e[r]));return t},ge=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[e[n]]);return r},Oe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},_e=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[t[t.length-1]]=r,e},Se=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},xe=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(E==="test"||E==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Pe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},$e=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};export{se as clone,ge as createNestedObject,K as createObjectWithoutPrototype,ie as deepClone,de as deepContains,ce as deepDestringifyFunctions,oe as deepMerge,T as deepStringifyFunctions,fe as destringifyGlobalScope,xe as detectInfiniteLoop,$e as excludeKeysFromObject,v as exec,Se as getInObjectByPath,k as hasFunction,ue as hasOwnProperty,Pe as isCyclic,z as isEmpty,ae as isEmptyObject,V as isEqualDeep,pe as makeObjectWithoutPrototype,ne as map,re as merge,N as objectToString,ye as overwrite,U as overwriteDeep,he as overwriteShallow,we as removeFromObject,Oe as removeNestedKeyByPath,_e as setInObjectByPath,le as stringToObject};
16
+ return ${f}; })`)(t);Object.assign(t,l)}catch{for(const[f,l]of n)try{const c=Object.keys(t).filter(s).map(u=>`var ${u} = __gs__[${JSON.stringify(u)}];`).join(`
17
+ `);t[f]=$.eval(`(function(__gs__) { ${c}
18
+ return (${l}); })`)(t)}catch{try{t[f]=$.eval(`(${l})`)}catch{t[f]=l}}}for(const[i,f]of r)if(!s(i))try{t[i]=$.eval(`(${f})`)}catch{t[i]=f}return t},ae=(e,t={verbose:!0})=>{try{return e?$.eval("("+e+")"):{}}catch(r){t.verbose&&console.warn(r)}},pe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),m=e=>{for(const t in e)return!1;return!0},ye=e=>x(e)&&m(e),he=()=>Object.create(null),de=(e,t,r={})=>{const s=r.exclude||[],n=r.preventUnderscore;for(const o in t)s.includes(o)||!n&&S(o)||o==="constructor"||o==="prototype"||t[o]!==void 0&&(e[o]=t[o]);return e},ge=(e,t,r=[])=>{const s=r instanceof Set;for(const n in t)S(n)||n==="constructor"||n==="prototype"||(s?r.has(n):r.includes(n))||(e[n]=t[n]);return e},V=(e,t,r={},s=new WeakMap)=>{if(!g(e)||!g(t)||w(e)||w(t))return t;if(s.has(e))return s.get(e);s.set(e,e);const n=r.exclude,o=n?n instanceof Set?n:new Set(n):null,i=!r.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||o&&o.has(f)||i&&S(f)||f==="constructor"||f==="prototype")continue;const l=e[f],c=t[f];w(c)?e[f]=c:g(l)&&g(c)?e[f]=V(l,c,r,s):c!==void 0&&(e[f]=c)}return e},X=(e,t,r=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);const s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){const i=s[o];if(!Object.prototype.hasOwnProperty.call(t,i)||!X(e[i],t[i],r))return!1}return!0},Y=new Set(["node","__ref"]),we=(e,t,r=Y)=>{if(e===t)return!0;if(!g(e)||!g(t)||w(e)||w(t))return e===t;const s=r instanceof Set?r:new Set(r),n=new WeakSet;function o(i,f){if(n.has(f))return!0;n.add(f);for(const l in f){if(!Object.prototype.hasOwnProperty.call(f,l)||s.has(l))continue;if(!Object.prototype.hasOwnProperty.call(i,l))return!1;const c=f[l],u=i[l];if(w(c)||w(u)){if(c!==u)return!1}else if(g(c)&&g(u)){if(!o(u,c))return!1}else if(c!==u)return!1}return!0}return o(e,t)},_e=(e,t)=>{if(t==null)return e;if(b(t)("string","number"))delete e[t];else if(_(t))for(let r=0;r<t.length;r++)delete e[t[r]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},K=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=K(e[r]));return t},Oe=(e,t)=>{if(e.length===0)return t;const r={};let s=r;for(let n=0;n<e.length;n++)n===e.length-1&&t?s[e[n]]=t:(s[e[n]]={},s=s[e[n]]);return r},Se=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++){if(r[t[n]]===void 0)return;r=r[t[n]]}const s=t[t.length-1];r&&Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]},xe=(e,t,r)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let s=e;for(let n=0;n<t.length-1;n++)(!s[t[n]]||typeof s[t[n]]!="object")&&(s[t[n]]={}),s=s[t[n]];return s[t[t.length-1]]=r,e},$e=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let s=0;s<t.length;s++){if(r==null)return;r=r[t[s]]}return r},Ee=e=>{let r=[],s=0;for(let n=0;n<e.length;n++)if(r.length<2)r.push(e[n]);else if(e[n]===r[n%2]?s++:(r=[e[n-1],e[n]],s=1),s>=20)return(k==="test"||k==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",r),!0},Pe=e=>{const t=new WeakSet;function r(s){if(s&&typeof s=="object"){if(t.has(s))return!0;t.add(s);for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)&&r(s[n]))return console.log(s,"cycle at "+n),!0}return!1}return r(e)},ke=(e,t)=>{const r=t instanceof Set?t:new Set(t),s={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!r.has(n)&&(s[n]=e[n]);return s};export{ce as clone,Oe as createNestedObject,K as createObjectWithoutPrototype,fe as deepClone,we as deepContains,le as deepDestringifyFunctions,ie as deepMerge,R as deepStringifyFunctions,ue as destringifyGlobalScope,Ee as detectInfiniteLoop,ke as excludeKeysFromObject,A as exec,$e as getInObjectByPath,P as hasFunction,pe as hasOwnProperty,Pe as isCyclic,m as isEmpty,ye as isEmptyObject,X as isEqualDeep,he as makeObjectWithoutPrototype,oe as map,se as merge,T as objectToString,de as overwrite,V as overwriteDeep,ge as overwriteShallow,_e as removeFromObject,Se as removeNestedKeyByPath,xe as setInObjectByPath,ae as stringToObject};
@@ -1 +1 @@
1
- import{isObject as a,isString as p}from"./types.js";const y="system",I="https://smbls-kv.nika-980.workers.dev",j="https://api.symbols.app";function f(n){const t=String(n||"").trim();if(!t)return{owner:y,key:"",full:""};let e=null,r=t;if(t.includes("/")){const o=t.indexOf("/");e=t.slice(0,o),r=t.slice(o+1)}r=r.replace(/\.symbo\.ls$/iu,""),e||(e=y);const s=r?`${e}/${r}`:"";return{owner:e,key:r,full:s}}const h=(n,t,e,r)=>{for(const s in t){const o=r?`${r}/${s}`:s;e&&e.has(o)||(s in n?a(n[s])&&a(t[s])&&h(n[s],t[s],e,o):n[s]=t[s])}},m=(n,t,e)=>{if(!a(n)||!t.size)return n;const r=`${e}/`;let s=!1;for(const i of t)if(i.startsWith(r)){s=!0;break}if(!s)return n;const o={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const l=`${e}/${i}`;t.has(l)||(o[i]=m(n[i],t,l))}return o},R=new Set,U=n=>n.replace(/\.js$/iu,""),b=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const e of n){if(!p(e))continue;const r=e.split("/").map(s=>U(s.trim())).filter(Boolean).join("/");r&&t.add(r)}return t},B=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),w=n=>a(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),S=n=>n.library!==void 0?n.library:n.key??n.name,E=(n,t,e)=>{const r=b(t.sharedLibIgnore);t.sharePages===!1&&r.add("pages");const s=r.size?new Set([...e,...r]):e;for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&!(o==="sharePages"||o==="sharedLibIgnore")&&!s.has(o))if(a(t[o])&&a(n[o]))if(o==="designSystem")h(n[o],t[o],s,o);else for(const i in t[o])s.has(`${o}/${i}`)||i in n[o]||(n[o][i]=t[o][i]);else o in n||(n[o]=m(t[o],s,o))},x=(n,t)=>{if(!(!t||!t.length))for(let e=0;e<t.length;e++){let r=t[e],s=R;w(r)&&(s=b(r.ignoreList),r=r.library),a(r)&&E(n,r,s)}};async function O(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const r=await _(n,t);return r||$(n,t)}async function _(n,t={}){const e=t.kvBaseUrl||I,r=t.env||"production",s=`${e}/kv/${encodeURIComponent(n)}?env=${r}`;try{const o=await fetch(s,{method:"GET"});return o.ok&&(await o.json())?.value||null}catch{return null}}async function $(n,t={}){const e=t.apiBaseUrl||j,{key:r}=f(n);try{const s=`${e}/core/projects/libraries/available?search=${encodeURIComponent(r)}&limit=10`,o=await fetch(s,{method:"GET"});if(!o.ok)return null;const i=await o.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(A=>{const{key:v}=f(A?.key);return v.toLowerCase()===r.toLowerCase()});if(!c?.id&&!c?._id)return null;const k=c.id||c._id,L=`${e}/core/projects/${encodeURIComponent(k)}/data?branch=main`,u=await fetch(L,{method:"GET"});if(!u.ok)return null;const d=await u.json();return d?.data||d||null}catch{return null}}async function g(n,t={}){if(a(n))return n;if(p(n)){const{full:e}=f(n);if(!e)return null;try{const r=await O(e,t);return r||console.warn(`[smbls] Shared library "${e}" not found`),r}catch(r){return console.warn(`[smbls] Failed to fetch shared library "${e}":`,r.message),null}}return null}async function C(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async r=>{if(w(r)){const s=await g(S(r),t);return s?{library:s,ignoreList:r.ignoreList}:null}return g(r,t)}))).filter(Boolean)}export{h as deepDefaults,O as fetchLibraryData,w as isWrappedLibrary,x as mergeSharedLibraries,b as normalizeIgnoreList,f as normalizeLibraryKey,C as resolveSharedLibraries,B as sharedLibrary};
1
+ import{isObject as a,isString as y}from"./types.js";const d="system",I="https://smbls-kv.nika-980.workers.dev",j="https://api.symbols.app";function f(n){const t=String(n||"").trim();if(!t)return{owner:d,key:"",full:""};let o=null,e=t;if(t.includes("/")){const r=t.indexOf("/");o=t.slice(0,r),e=t.slice(r+1)}e=e.replace(/\.symbo\.ls$/iu,""),o||(o=d);const s=e?`${o}/${e}`:"";return{owner:o,key:e,full:s}}const h=(n,t,o,e)=>{for(const s in t){const r=e?`${e}/${s}`:s;o&&o.has(r)||(s in n?a(n[s])&&a(t[s])&&h(n[s],t[s],o,r):n[s]=t[s])}},m=(n,t,o)=>{if(!a(n)||!t.size)return n;const e=`${o}/`;let s=!1;for(const i of t)if(i.startsWith(e)){s=!0;break}if(!s)return n;const r={};for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const l=`${o}/${i}`;t.has(l)||(r[i]=m(n[i],t,l))}return r},R=new Set,U=new Set(["components","pages","functions","snippets","methods"]),b=(n,t)=>t===""&&U.has(n),E=n=>n.replace(/\.js$/iu,""),w=n=>{const t=new Set;if(!Array.isArray(n))return t;for(const o of n){if(!y(o))continue;const e=o.split("/").map(s=>E(s.trim())).filter(Boolean).join("/");e&&t.add(e)}return t},T=(n,t={})=>({library:n,ignoreList:Array.isArray(t.ignoreList)?t.ignoreList:[]}),g=n=>a(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),O=n=>n.library!==void 0?n.library:n.key??n.name,_=(n,t,o)=>{const e=w(t.sharedLibIgnore);t.sharePages===!1&&e.add("pages");const s=e.size?new Set([...o,...e]):o;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!(r==="sharePages"||r==="sharedLibIgnore")&&!s.has(r))if(a(t[r])&&a(n[r]))if(r==="designSystem")h(n[r],t[r],s,r);else for(const i in t[r])s.has(`${r}/${i}`)||(i in n[r]?b(r,n[r][i])&&!b(r,t[r][i])&&(n[r][i]=t[r][i]):n[r][i]=t[r][i]);else r in n||(n[r]=m(t[r],s,r))},G=(n,t)=>{if(!(!t||!t.length))for(let o=0;o<t.length;o++){let e=t[o],s=R;g(e)&&(s=w(e.ignoreList),e=e.library),a(e)&&_(n,e,s)}};async function B(n,t={}){if((t.provider||"kv")==="api")return $(n,t);const e=await P(n,t);return e||$(n,t)}async function P(n,t={}){const o=t.kvBaseUrl||I,e=t.env||"production",s=`${o}/kv/${encodeURIComponent(n)}?env=${e}`;try{const r=await fetch(s,{method:"GET"});return r.ok&&(await r.json())?.value||null}catch{return null}}async function $(n,t={}){const o=t.apiBaseUrl||j,{key:e}=f(n);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(e)}&limit=10`,r=await fetch(s,{method:"GET"});if(!r.ok)return null;const i=await r.json(),c=(i?.items||i?.data||(Array.isArray(i)?i:[])).find(S=>{const{key:v}=f(S?.key);return v.toLowerCase()===e.toLowerCase()});if(!c?.id&&!c?._id)return null;const L=c.id||c._id,A=`${o}/core/projects/${encodeURIComponent(L)}/data?branch=main`,u=await fetch(A,{method:"GET"});if(!u.ok)return null;const p=await u.json();return p?.data||p||null}catch{return null}}async function k(n,t={}){if(a(n))return n;if(y(n)){const{full:o}=f(n);if(!o)return null;try{const e=await B(o,t);return e||console.warn(`[smbls] Shared library "${o}" not found`),e}catch(e){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,e.message),null}}return null}async function z(n,t={}){return!n||!n.length?[]:(await Promise.all(n.map(async e=>{if(g(e)){const s=await k(O(e),t);return s?{library:s,ignoreList:e.ignoreList}:null}return k(e,t)}))).filter(Boolean)}export{h as deepDefaults,B as fetchLibraryData,g as isWrappedLibrary,G as mergeSharedLibraries,w as normalizeIgnoreList,f as normalizeLibraryKey,z as resolveSharedLibraries,T as sharedLibrary};
package/object.js CHANGED
@@ -289,6 +289,12 @@ export const objectToString = (obj = {}, indent = 0) => {
289
289
  return String(obj)
290
290
  }
291
291
 
292
+ // A RegExp has no own enumerable keys, so the generic walk below would
293
+ // print `{}`. `String(/foo/g)` is the valid source literal `/foo/g` —
294
+ // exactly what a written-back .js file needs
295
+ // (FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1).
296
+ if (obj instanceof RegExp) return String(obj)
297
+
292
298
  // Handle empty object case - avoid Object.keys allocation
293
299
  let hasKeys = false
294
300
  for (const _k in obj) {
@@ -313,10 +319,14 @@ export const objectToString = (obj = {}, indent = 0) => {
313
319
  const stringedKey = keyNeedsQuotes ? `'${key}'` : key
314
320
  str += `${spaces} ${stringedKey}: `
315
321
 
316
- if (isArray(value)) {
322
+ if (value instanceof RegExp) {
323
+ str += String(value)
324
+ } else if (isArray(value)) {
317
325
  str += '[\n'
318
326
  for (const element of value) {
319
- if (isObjectLike(element) && element !== null) {
327
+ if (element instanceof RegExp) {
328
+ str += `${spaces} ${String(element)},\n`
329
+ } else if (isObjectLike(element) && element !== null) {
320
330
  str += `${spaces} ${objectToString(element, indent + 2)},\n`
321
331
  } else if (isString(element)) {
322
332
  str += `${spaces} '${element}',\n`
@@ -348,7 +358,16 @@ const FN_PATTERNS = [
348
358
  /^function[\s(]/,
349
359
  /^async\s+/,
350
360
  /^\(\s*function/,
351
- /^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/
361
+ /^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,
362
+ // OBJECT-METHOD-SHORTHAND toString: `stopTracks(v4) { … }`, `*walk() { … }`.
363
+ // frank emissions predating plugins/frank/fnString.js normalization stored
364
+ // these verbatim; without this pattern the PLAIN (non-async) shape was
365
+ // never even recognized as a function string, so the shorthand recovery in
366
+ // _destringifyFnString could not run and the value stayed a string
367
+ // (silent dead handler). Anchored to a `{…}`-terminated body so ordinary
368
+ // prose containing `word(…)` never matches; params allow one nesting level
369
+ // for parenthesized defaults.
370
+ /^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/
352
371
  ]
353
372
  const RE_JSON_LIKE = /^["[{]/
354
373
  // Module-source prefixes. A string starting with `export ` or `import ` is a
@@ -542,6 +561,25 @@ const _destringifyFnString = (str, label, opts) => {
542
561
  }
543
562
  }
544
563
  }
564
+ // OBJECT-METHOD-SHORTHAND recovery: `refresh() {…}` / `async mic() {…}`
565
+ // (a Function.prototype.toString of a shorthand method, stored by frank
566
+ // emissions predating plugins/frank/fnString.js normalization) is not a
567
+ // standalone expression — `('(' + str + ')')` throws
568
+ // "Unexpected token '{'" (plain) or "Unexpected identifier" (async) —
569
+ // but it IS valid inside an object literal. Wrap, eval, pluck the single
570
+ // method. This also faithfully revives `super`-using and quoted-name
571
+ // methods, which no standalone rewrite can.
572
+ if (!recovered && /Unexpected (token '\{'|identifier)/.test(msg)) {
573
+ try {
574
+ const wrapped = opts.window.eval('({' + str + '})')
575
+ if (wrapped && typeof wrapped === 'object') {
576
+ const wkeys = Object.keys(wrapped)
577
+ if (wkeys.length === 1 && typeof wrapped[wkeys[0]] === 'function') {
578
+ recovered = wrapped[wkeys[0]]
579
+ }
580
+ }
581
+ } catch (_) { /* fall through to the warning below */ }
582
+ }
545
583
  if (recovered) return recovered
546
584
  // FR-1 (FRANK-RUNNER.md): make the silent fallback loud so consumers
547
585
  // notice when a handler ends up stored as a string instead of a
@@ -591,14 +629,28 @@ export const deepDestringifyFunctions = (
591
629
  ? _destringifyFnString(arrProp, `array index ${i} (prop "${prop}")`, opts)
592
630
  : arrProp)
593
631
  } else if (isObject(arrProp)) {
594
- const child = {}
595
- arr.push(child)
596
- stack.push([arrProp, child])
632
+ const taggedRe = _rehydrateTaggedRegExp(arrProp)
633
+ if (taggedRe) {
634
+ arr.push(taggedRe)
635
+ } else {
636
+ const child = {}
637
+ arr.push(child)
638
+ stack.push([arrProp, child])
639
+ }
597
640
  } else {
598
641
  arr.push(arrProp)
599
642
  }
600
643
  }
601
644
  } else if (isObject(objProp)) {
645
+ // `{__type:'RegExp', source, flags}` (frank's stringifyFunctions
646
+ // tagged form) revives to a real RegExp instead of being walked —
647
+ // the walk would clone it to a dead plain object
648
+ // (FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1).
649
+ const taggedRe = _rehydrateTaggedRegExp(objProp)
650
+ if (taggedRe) {
651
+ dest[prop] = taggedRe
652
+ continue
653
+ }
602
654
  // Preserve any pre-existing container the caller passed in for this
603
655
  // key (matches the legacy `destringified[prop]` argument); otherwise
604
656
  // allocate one.
@@ -619,20 +671,37 @@ export const deepDestringifyFunctions = (
619
671
  // destringifyGlobalScope-set-map.test.js.
620
672
  const TYPE_TAG_SET = 'Set'
621
673
  const TYPE_TAG_MAP = 'Map'
674
+ const TYPE_TAG_REGEXP = 'RegExp'
622
675
 
623
676
  /**
624
- * Rehydrate Set / Map tagged forms back into real Set / Map instances.
677
+ * Rehydrate Set / Map / RegExp tagged forms back into real instances.
625
678
  * Pass-through for any other value (including user objects that
626
- * happen to carry an unrelated `__type` field — only `'Set'` / `'Map'`
627
- * rehydrate).
679
+ * happen to carry an unrelated `__type` field — only `'Set'` / `'Map'` /
680
+ * `'RegExp'` rehydrate).
628
681
  */
629
682
  const _rehydrateTaggedValue = (val) => {
630
683
  if (!val || typeof val !== 'object') return val
631
684
  if (val.__type === TYPE_TAG_SET && Array.isArray(val.values)) return new Set(val.values)
632
685
  if (val.__type === TYPE_TAG_MAP && Array.isArray(val.entries)) return new Map(val.entries)
686
+ if (val.__type === TYPE_TAG_REGEXP && isString(val.source)) {
687
+ // Guard: a corrupt flags string must not take down the whole
688
+ // destringify pass — leave the tagged object as-is instead.
689
+ try { return new RegExp(val.source, isString(val.flags) ? val.flags : '') } catch (e) { return val }
690
+ }
633
691
  return val
634
692
  }
635
693
 
694
+ // deepDestringifyFunctions rehydrates ONLY the RegExp tag (the form
695
+ // plugins/frank/toJSON.js stringifyFunctions emits for element-scope
696
+ // RegExp values — FRANK-EMIT-REGEXP-SCOPE-VALUE-DIES-TO-EMPTY-OBJECT-1).
697
+ // Set/Map tagged forms exist only on the globalScope channel, which
698
+ // destringifyGlobalScope owns.
699
+ const _rehydrateTaggedRegExp = (val) => {
700
+ if (!val || typeof val !== 'object' || val.__type !== TYPE_TAG_REGEXP) return null
701
+ const revived = _rehydrateTaggedValue(val)
702
+ return revived instanceof RegExp ? revived : null
703
+ }
704
+
636
705
  /**
637
706
  * Destringify a globalScope object so that function strings become real functions.
638
707
  * All globalScope values are made available as local variables when eval'ing each
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.768",
3
+ "version": "3.14.769",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -105,6 +105,37 @@ const copyWithNestedIgnores = (value, skip, prefix) => {
105
105
 
106
106
  const EMPTY_IGNORE = new Set()
107
107
 
108
+ /**
109
+ * The section bags whose values are always objects or functions, never text.
110
+ * Same list frank's stub-phantom sweep walks (`plugins/frank/toJSON.js`), for
111
+ * the same reason: these are the bags a stubbed external import can land in.
112
+ */
113
+ const OBJECT_BAGS = new Set(['components', 'pages', 'functions', 'snippets', 'methods'])
114
+
115
+ /**
116
+ * Is the value sitting at `bag[key]` a STUB PHANTOM rather than a real value?
117
+ *
118
+ * When frank bundles a project, `stubExternalsPlugin` replaces an import it
119
+ * cannot resolve with a no-op proxy; `stringifyFunctions` then reduces that
120
+ * proxy to the empty string, so the published payload carries `""` where a
121
+ * component/page/function should be. In `OBJECT_BAGS` an empty string is never
122
+ * a value a library can legitimately mean — it is only ever that signature.
123
+ *
124
+ * This matters because the merge below is FIRST-WINS, which is correct for
125
+ * real values (an earlier declaration outranks a later one, and the consumer
126
+ * outranks every library) but wrong for a phantom: an earlier library's `""`
127
+ * would permanently shadow the real object a LATER declared library carries
128
+ * under the same name, and the consumer that declared the good library would
129
+ * still get `""`. Measured live 2026-08-21 on the published `workspace-ui`
130
+ * payload: 25 names held a real object in a later library and every one was
131
+ * thrown away (FRANK-STUB-PHANTOM-SHADOWS-REAL-LIB-VALUE-1).
132
+ *
133
+ * So a phantom does not occupy its slot. Precedence is untouched everywhere
134
+ * else — `designSystem`, `state` and every other key keep empty strings,
135
+ * because there `''` is a legal value.
136
+ */
137
+ const isStubPhantom = (bag, value) => value === '' && OBJECT_BAGS.has(bag)
138
+
108
139
  const stripJsExt = (segment) => segment.replace(/\.js$/iu, '')
109
140
 
110
141
  /**
@@ -190,7 +221,14 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
190
221
  } else {
191
222
  for (const k in sharedLib[key]) {
192
223
  if (skip.has(`${key}/${k}`)) continue // nested skip: 'components/Header'
193
- if (!(k in context[key])) context[key][k] = sharedLib[key][k]
224
+ if (!(k in context[key])) {
225
+ context[key][k] = sharedLib[key][k]
226
+ } else if (isStubPhantom(key, context[key][k]) && !isStubPhantom(key, sharedLib[key][k])) {
227
+ // The slot holds a stub phantom, not a value — a real value fills it.
228
+ // Order-independent: a real value already in the slot is never a
229
+ // phantom, so a later library's `''` can never overwrite it.
230
+ context[key][k] = sharedLib[key][k]
231
+ }
194
232
  }
195
233
  }
196
234
  } else if (!(key in context)) {
@@ -202,7 +240,9 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
202
240
  /**
203
241
  * Merge an array of shared library objects into a context.
204
242
  * - designSystem: deep defaults (non-destructive recursive)
205
- * - other object keys (components, pages, etc.): shallow add missing
243
+ * - other object keys (components, pages, etc.): shallow add missing. A slot
244
+ * holding a STUB PHANTOM counts as missing in the object bags — see
245
+ * `isStubPhantom`.
206
246
  * - new top-level keys: copy from library
207
247
  *
208
248
  * Entries may be a bare library context, or a wrapped `{ library, ignoreList }`