@symbo.ls/utils 3.14.707 → 3.14.736

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.736
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
3
9
  ## 3.14.707
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var j=(n,e)=>{for(var t in e)u(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of R(e))!U.call(n,i)&&i!==t&&u(n,i,{get:()=>e[i],enumerable:!(r=A(e,i))||r.enumerable});return n};var S=n=>I(u({},"__esModule",{value:!0}),n);var K={};j(K,{deepDefaults:()=>f,fetchLibraryData:()=>k,isWrappedLibrary:()=>p,mergeSharedLibraries:()=>T,normalizeIgnoreList:()=>d,normalizeLibraryKey:()=>c,resolveSharedLibraries:()=>G,sharedLibrary:()=>P});module.exports=S(K);var s=require("./types.js");const h="system",E="https://smbls-kv.nika-980.workers.dev",_="https://api.symbols.app";function c(n){const e=String(n||"").trim();if(!e)return{owner:h,key:"",full:""};let t=null,r=e;if(e.includes("/")){const o=e.indexOf("/");t=e.slice(0,o),r=e.slice(o+1)}r=r.replace(/\.symbo\.ls$/iu,""),t||(t=h);const i=r?`${t}/${r}`:"";return{owner:t,key:r,full:i}}const f=(n,e,t,r)=>{for(const i in e){const o=r?`${r}/${i}`:i;t&&t.has(o)||(i in n?(0,s.isObject)(n[i])&&(0,s.isObject)(e[i])&&f(n[i],e[i],t,o):n[i]=e[i])}},O=new Set,B=n=>n.replace(/\.js$/iu,""),d=n=>{const e=new Set;if(!Array.isArray(n))return e;for(const t of n){if(!(0,s.isString)(t))continue;const r=t.split("/").map(i=>B(i.trim())).filter(Boolean).join("/");r&&e.add(r)}return e},P=(n,e={})=>({library:n,ignoreList:Array.isArray(e.ignoreList)?e.ignoreList:[]}),p=n=>(0,s.isObject)(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),x=n=>n.library!==void 0?n.library:n.key??n.name,C=(n,e,t)=>{const r=d(e.sharedLibIgnore);e.sharePages===!1&&r.add("pages");const i=r.size?new Set([...t,...r]):t;for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&!(o==="sharePages"||o==="sharedLibIgnore")&&!i.has(o))if((0,s.isObject)(e[o])&&(0,s.isObject)(n[o]))if(o==="designSystem")f(n[o],e[o],i,o);else for(const a in e[o])i.has(`${o}/${a}`)||a in n[o]||(n[o][a]=e[o][a]);else o in n||(n[o]=e[o])},T=(n,e)=>{if(!(!e||!e.length))for(let t=0;t<e.length;t++){let r=e[t],i=O;p(r)&&(i=d(r.ignoreList),r=r.library),(0,s.isObject)(r)&&C(n,r,i)}};async function k(n,e={}){if((e.provider||"kv")==="api")return b(n,e);const r=await F(n,e);return r||b(n,e)}async function F(n,e={}){const t=e.kvBaseUrl||E,r=e.env||"production",i=`${t}/kv/${encodeURIComponent(n)}?env=${r}`;try{const o=await fetch(i,{method:"GET"});return o.ok&&(await o.json())?.value||null}catch{return null}}async function b(n,e={}){const t=e.apiBaseUrl||_,{key:r}=c(n);try{const i=`${t}/core/projects/libraries/available?search=${encodeURIComponent(r)}&limit=10`,o=await fetch(i,{method:"GET"});if(!o.ok)return null;const a=await o.json(),l=(a?.items||a?.data||(Array.isArray(a)?a:[])).find(g=>{const{key:$}=c(g?.key);return $.toLowerCase()===r.toLowerCase()});if(!l?.id&&!l?._id)return null;const L=l.id||l._id,v=`${t}/core/projects/${encodeURIComponent(L)}/data?branch=main`,y=await fetch(v,{method:"GET"});if(!y.ok)return null;const m=await y.json();return m?.data||m||null}catch{return null}}async function w(n,e={}){if((0,s.isObject)(n))return n;if((0,s.isString)(n)){const{full:t}=c(n);if(!t)return null;try{const r=await k(t,e);return r||console.warn(`[smbls] Shared library "${t}" not found`),r}catch(r){return console.warn(`[smbls] Failed to fetch shared library "${t}":`,r.message),null}}return null}async function G(n,e={}){return!n||!n.length?[]:(await Promise.all(n.map(async r=>{if(p(r)){const i=await w(x(r),e);return i?{library:i,ignoreList:r.ignoreList}:null}return w(r,e)}))).filter(Boolean)}
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 +1 @@
1
- import{isObject as a,isString as d}from"./types.js";const p="system",$="https://smbls-kv.nika-980.workers.dev",A="https://api.symbols.app";function c(n){const e=String(n||"").trim();if(!e)return{owner:p,key:"",full:""};let t=null,r=e;if(e.includes("/")){const i=e.indexOf("/");t=e.slice(0,i),r=e.slice(i+1)}r=r.replace(/\.symbo\.ls$/iu,""),t||(t=p);const o=r?`${t}/${r}`:"";return{owner:t,key:r,full:o}}const y=(n,e,t,r)=>{for(const o in e){const i=r?`${r}/${o}`:o;t&&t.has(i)||(o in n?a(n[o])&&a(e[o])&&y(n[o],e[o],t,i):n[o]=e[o])}},R=new Set,U=n=>n.replace(/\.js$/iu,""),m=n=>{const e=new Set;if(!Array.isArray(n))return e;for(const t of n){if(!d(t))continue;const r=t.split("/").map(o=>U(o.trim())).filter(Boolean).join("/");r&&e.add(r)}return e},B=(n,e={})=>({library:n,ignoreList:Array.isArray(e.ignoreList)?e.ignoreList:[]}),h=n=>a(n)&&Array.isArray(n.ignoreList)&&("library"in n||"key"in n||"name"in n),j=n=>n.library!==void 0?n.library:n.key??n.name,I=(n,e,t)=>{const r=m(e.sharedLibIgnore);e.sharePages===!1&&r.add("pages");const o=r.size?new Set([...t,...r]):t;for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&!(i==="sharePages"||i==="sharedLibIgnore")&&!o.has(i))if(a(e[i])&&a(n[i]))if(i==="designSystem")y(n[i],e[i],o,i);else for(const s in e[i])o.has(`${i}/${s}`)||s in n[i]||(n[i][s]=e[i][s]);else i in n||(n[i]=e[i])},P=(n,e)=>{if(!(!e||!e.length))for(let t=0;t<e.length;t++){let r=e[t],o=R;h(r)&&(o=m(r.ignoreList),r=r.library),a(r)&&I(n,r,o)}};async function S(n,e={}){if((e.provider||"kv")==="api")return b(n,e);const r=await E(n,e);return r||b(n,e)}async function E(n,e={}){const t=e.kvBaseUrl||$,r=e.env||"production",o=`${t}/kv/${encodeURIComponent(n)}?env=${r}`;try{const i=await fetch(o,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function b(n,e={}){const t=e.apiBaseUrl||A,{key:r}=c(n);try{const o=`${t}/core/projects/libraries/available?search=${encodeURIComponent(r)}&limit=10`,i=await fetch(o,{method:"GET"});if(!i.ok)return null;const s=await i.json(),l=(s?.items||s?.data||(Array.isArray(s)?s:[])).find(v=>{const{key:g}=c(v?.key);return g.toLowerCase()===r.toLowerCase()});if(!l?.id&&!l?._id)return null;const k=l.id||l._id,L=`${t}/core/projects/${encodeURIComponent(k)}/data?branch=main`,u=await fetch(L,{method:"GET"});if(!u.ok)return null;const f=await u.json();return f?.data||f||null}catch{return null}}async function w(n,e={}){if(a(n))return n;if(d(n)){const{full:t}=c(n);if(!t)return null;try{const r=await S(t,e);return r||console.warn(`[smbls] Shared library "${t}" not found`),r}catch(r){return console.warn(`[smbls] Failed to fetch shared library "${t}":`,r.message),null}}return null}async function x(n,e={}){return!n||!n.length?[]:(await Promise.all(n.map(async r=>{if(h(r)){const o=await w(j(r),e);return o?{library:o,ignoreList:r.ignoreList}:null}return w(r,e)}))).filter(Boolean)}export{y as deepDefaults,S as fetchLibraryData,h as isWrappedLibrary,P as mergeSharedLibraries,m as normalizeIgnoreList,c as normalizeLibraryKey,x as resolveSharedLibraries,B as sharedLibrary};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.707",
3
+ "version": "3.14.736",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -60,6 +60,49 @@ export const deepDefaults = (target, source, ignore, prefix) => {
60
60
  }
61
61
  }
62
62
 
63
+ /**
64
+ * Recursively drop any subtree of `value` whose '/'-joined path (relative to
65
+ * `prefix`) is in `skip`. Used by `mergeOneLibrary`'s wholesale-copy branch:
66
+ * when the consumer has NO object at all at a top-level key, the whole
67
+ * section is copied in one shot — a nested `sharedLibIgnore` path declared
68
+ * under that key (e.g. 'functions/router') must be honored there too, not
69
+ * only in the per-key defaults-fill branch below. Recurses to whatever depth
70
+ * the ignore path names — `normalizeIgnoreList` has no depth cap, so a
71
+ * library author's declaration stays private regardless of which merge
72
+ * branch a given consumer happens to hit.
73
+ *
74
+ * Returns `value` unchanged (same reference) whenever nothing under `prefix`
75
+ * is ignored — the common case — so this never allocates when there is
76
+ * nothing to filter.
77
+ *
78
+ * @param {*} value - the subtree being wholesale-copied
79
+ * @param {Set<string>} skip - normalized '/'-joined ignore paths (whole-key
80
+ * entries already short-circuited by the caller before this runs)
81
+ * @param {string} prefix - the top-level key this subtree lives under
82
+ */
83
+ const copyWithNestedIgnores = (value, skip, prefix) => {
84
+ if (!isObject(value) || !skip.size) return value
85
+
86
+ const branchPrefix = `${prefix}/`
87
+ let hasNestedIgnore = false
88
+ for (const path of skip) {
89
+ if (path.startsWith(branchPrefix)) {
90
+ hasNestedIgnore = true
91
+ break
92
+ }
93
+ }
94
+ if (!hasNestedIgnore) return value
95
+
96
+ const copy = {}
97
+ for (const k in value) {
98
+ if (!Object.prototype.hasOwnProperty.call(value, k)) continue
99
+ const path = `${prefix}/${k}`
100
+ if (skip.has(path)) continue
101
+ copy[k] = copyWithNestedIgnores(value[k], skip, path)
102
+ }
103
+ return copy
104
+ }
105
+
63
106
  const EMPTY_IGNORE = new Set()
64
107
 
65
108
  const stripJsExt = (segment) => segment.replace(/\.js$/iu, '')
@@ -151,7 +194,7 @@ const mergeOneLibrary = (context, sharedLib, ignore) => {
151
194
  }
152
195
  }
153
196
  } else if (!(key in context)) {
154
- context[key] = sharedLib[key]
197
+ context[key] = copyWithNestedIgnores(sharedLib[key], skip, key)
155
198
  }
156
199
  }
157
200
  }