@symbo.ls/utils 3.14.770 → 3.14.771
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.
|
@@ -1 +1 @@
|
|
|
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)}
|
|
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")&&r!=="app"&&!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)}
|
|
@@ -1 +1 @@
|
|
|
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};
|
|
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")&&r!=="app"&&!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/package.json
CHANGED
package/sharedLibraries.js
CHANGED
|
@@ -214,7 +214,18 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
|
|
|
214
214
|
if (!Object.prototype.hasOwnProperty.call(sharedLib, key)) continue
|
|
215
215
|
// merge directives, not library content
|
|
216
216
|
if (key === 'sharePages' || key === 'sharedLibIgnore') continue
|
|
217
|
-
|
|
217
|
+
// A library's `app` is its own standalone deployment root — chrome, boot
|
|
218
|
+
// hooks, watchers — never consumer content, so it is excluded
|
|
219
|
+
// UNCONDITIONALLY, on both merge branches, declaration or not. Six of the
|
|
220
|
+
// seven app-carrying workspace libraries already declared
|
|
221
|
+
// `sharedLibIgnore: ['app']` by hand; the one that forgot
|
|
222
|
+
// (workspace-design-system) leaked `app.metadata` into every consumer's
|
|
223
|
+
// root, and the incident that surfaced the class was a full library root
|
|
224
|
+
// tree mounting as consumer root children
|
|
225
|
+
// (FW-SHAREDLIB-APP-MOUNTS-DESPITE-CLEAN-MERGE-1). A consumer that wants
|
|
226
|
+
// a library's root spreads it explicitly in its own app.js.
|
|
227
|
+
if (key === 'app') continue
|
|
228
|
+
if (skip.has(key)) continue // top-level skip: 'designSystem', 'state', …
|
|
218
229
|
if (isObject(sharedLib[key]) && isObject(context[key])) {
|
|
219
230
|
if (key === 'designSystem') {
|
|
220
231
|
deepDefaults(context[key], sharedLib[key], skip, key)
|
|
@@ -244,6 +255,8 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
|
|
|
244
255
|
* holding a STUB PHANTOM counts as missing in the object bags — see
|
|
245
256
|
* `isStubPhantom`.
|
|
246
257
|
* - new top-level keys: copy from library
|
|
258
|
+
* - `app` NEVER merges — a library's root definition is not consumer
|
|
259
|
+
* content (see the unconditional exclusion in `mergeOneLibrary`)
|
|
247
260
|
*
|
|
248
261
|
* Entries may be a bare library context, or a wrapped `{ library, ignoreList }`
|
|
249
262
|
* (see `sharedLibrary`). `ignoreList` names paths to skip while merging that
|