@symbo.ls/utils 3.14.756 → 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/CHANGELOG.md +6 -0
- package/cdn.js +38 -0
- package/dist/cjs/cdn.js +3 -3
- package/dist/cjs/object.js +16 -15
- package/dist/cjs/sharedLibraries.js +1 -1
- package/dist/esm/cdn.js +2 -2
- package/dist/esm/object.js +16 -15
- package/dist/esm/sharedLibraries.js +1 -1
- package/methods.js +19 -0
- package/object.js +78 -9
- package/package.json +1 -1
- package/sharedLibraries.js +42 -2
package/CHANGELOG.md
CHANGED
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
|
|
2
|
-
"imports": ${JSON.stringify(
|
|
3
|
-
}`;return`${
|
|
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}`};
|
package/dist/cjs/object.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var
|
|
2
|
-
`;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let
|
|
3
|
-
`;for(const
|
|
4
|
-
`:(0,l.
|
|
5
|
-
`:n+=`${s} ${
|
|
6
|
-
|
|
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},
|
|
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&&
|
|
10
|
-
`)){
|
|
11
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},
|
|
12
|
-
`);try{const i=n.map(([
|
|
13
|
-
`),
|
|
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 ${
|
|
16
|
-
`);t[
|
|
17
|
-
return (${u}); })`)(t)}catch{try{t[
|
|
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
|
|
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
|
|
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`${
|
|
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};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import{window as
|
|
2
|
-
`;for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];let
|
|
3
|
-
`;for(const
|
|
4
|
-
`:
|
|
5
|
-
`:n+=`${s} ${
|
|
6
|
-
|
|
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},
|
|
9
|
-
`,o);o=h===-1?l:h;continue}if(p==="/"&&e[o+1]==="*"){const h=e.indexOf("*/",o+2);o=h===-1?l:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(o++;o<l;){if(e[o]==="\\"){o+=2;continue}if(e[o]===h){o++;break}if(h==="`"&&e[o]==="$"&&e[o+1]==="{"){o+=2;let y=1;for(;o<l&&y>0;)e[o]==="{"?y++:e[o]==="}"&&y--,o++;continue}o++}continue}if(p==="{"){i++,o++;continue}if(p==="}"){i--,o++;continue}if(i===1&&
|
|
10
|
-
`)){
|
|
11
|
-
First 200 chars of source: `+String(e).slice(0,200)),e)}},
|
|
12
|
-
`);try{const i=n.map(([
|
|
13
|
-
`),
|
|
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 ${
|
|
16
|
-
`);t[
|
|
17
|
-
return (${l}); })`)(t)}catch{try{t[
|
|
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
|
|
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/methods.js
CHANGED
|
@@ -31,6 +31,25 @@ export function spotByPath (path) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// TODO: update these files
|
|
34
|
+
//
|
|
35
|
+
// ⚠️ DEPRECATED / NOT the `el.lookup` you get on a DOMQL element.
|
|
36
|
+
//
|
|
37
|
+
// The LIVE implementation is `@symbo.ls/element` `src/methods.js` — it is
|
|
38
|
+
// bound onto every element by `addMethods`, and it calls its predicate with
|
|
39
|
+
// exactly ONE argument (the candidate element). This twin calls
|
|
40
|
+
// `param(parent, parent.state, parent.context)` — THREE arguments — and is
|
|
41
|
+
// additionally gated on `parent.state` existing.
|
|
42
|
+
//
|
|
43
|
+
// `element/src/methods.js` deliberately does NOT import this function, and
|
|
44
|
+
// nothing in the monorepo imports it either (verified 2026-08-11); it stays
|
|
45
|
+
// exported only because `index.js` re-exports this file wholesale and
|
|
46
|
+
// removing a public export is a release-gated breaking change.
|
|
47
|
+
//
|
|
48
|
+
// It is, however, actively harmful as documentation: its 3-arg shape is why
|
|
49
|
+
// authors keep writing `el.lookup((el, s) => …)`, which throws against the
|
|
50
|
+
// real 1-arg implementation. Four such sites were live in `workspace` until
|
|
51
|
+
// 2026-08-10 (workspace `34884e6a`). If you are reading this to learn the
|
|
52
|
+
// signature, read `element/src/methods.js` instead.
|
|
34
53
|
export function lookup (param) {
|
|
35
54
|
const el = this
|
|
36
55
|
let { parent } = el
|
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 (
|
|
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 (
|
|
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
|
|
595
|
-
|
|
596
|
-
|
|
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
|
|
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
package/sharedLibraries.js
CHANGED
|
@@ -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]))
|
|
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 }`
|