@symbo.ls/scratch 3.14.707 → 3.14.749
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 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var w=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var q=(r,s)=>{for(var a in s)w(r,a,{get:s[a],enumerable:!0})},O=(r,s,a,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of j(s))!L.call(r,u)&&u!==a&&w(r,u,{get:()=>s[u],enumerable:!(e=T(s,u))||e.enumerable});return r};var _=r=>O(w({},"__esModule",{value:!0}),r);var Q={};q(Q,{STANDARD_SCHEME_QUERIES:()=>P,getColor:()=>C,getMediaColor:()=>H,setAdaptiveSchemeVar:()=>E,setColor:()=>M,setGradient:()=>D});module.exports=_(Q);var c=require("@symbo.ls/utils"),S=require("../factory.js"),g=require("../utils/index.js");const P={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},C=(r,s,a)=>{const e=a||(0,S.getActiveConfig)();if(!(0,c.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,g.isCSSVar)(r))return`var(${r})`;s&&r[s]&&(r=r[s]);let u,f,o;if((0,c.isArray)(r))[u,f,o]=r;else{const n=(0,g.parseColorToken)(r);if(!n){const{color:V,gradient:A}=e;let $=A[r]||V[r];return $?(s&&$[s]&&($=$[s]),e.useVariable?`var(${$.var})`:$.value):r}if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;u=n.name,f=n.alpha,o=n.tone}const{color:p,gradient:h}=e;let t=p[u]||h[u];if(!t)return e.verbose&&console.warn("Can't find color ",u),r;if(s)if(t[s]!==void 0)t=t[s];else if((0,c.isArray)(t)){const n=s.charCodeAt(0)===64?s.slice(1):s;n==="dark"?t=t[1]!==void 0?t[1]:t[0]:(n!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",s),t=t[0])}else e.verbose&&console.warn(r," - does not have ",s);if((0,c.isString)(t))return C(t,null,a);let d=t.rgb;if(!d){const n=e.useVariable?`var(${t.var})`:t.value;if(f&&n){const V=Math.round(parseFloat(f)*100);return`color-mix(in srgb, ${n} ${V}%, transparent)`}return n}return o&&!t[o]&&(d=(0,g.getRgbTone)(d,o),t[o]={rgb:d,var:`${t.var}-${o}`}),t[o]&&(d=t[o].rgb),f?`rgba(${d}, ${f})`:o?`rgba(${d}, 1)`:e.useVariable?`var(${t.var})`:`rgb(${d})`},H=(r,s,a)=>{const e=a||(0,S.getActiveConfig)();if(s||(s=e.globalTheme==="auto"?null:e.globalTheme),!(0,c.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,g.isCSSVar)(r))return`var(${r})`;let u,f,o;if((0,c.isArray)(r))u=r[0];else{const n=(0,g.parseColorToken)(r);if(n){if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;u=n.name,f=n.alpha,o=n.tone}else u=r}const{color:p,gradient:h}=e,t=p[u]||h[u],d=(0,c.isObject)(t);if(d&&t.value)return C(r,`@${s}`,a);if(d){if(e.useVariable&&t.var)return f||o?C(r,null,a):`var(${t.var})`;if(s)return C(r,`@${s}`,a);{const n={};for(const V in t){if(V.charCodeAt(0)!==64)continue;const A=V.slice(1),$=e.media&&e.media[A]||P[A];if(!$)continue;const l="@media "+($==="print"?`${$}`:`screen and ${$}`);n[l]=C(r,V,a)}return n}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,s,a,e)=>{const f=`--${e.varPrefix?e.varPrefix+"-":""}${s}-${a}`;let o;const p={};for(const h in r){if(h.charCodeAt(0)!==64)continue;const t=h.slice(1),d=r[h],n=d&&(d.value||d);!n||typeof n!="string"||(p[t]=n,(t==="light"||o===void 0)&&(o=n))}if(o!==void 0){e.cssVars[f]=o,e.cssMediaVars||(e.cssMediaVars={});for(const h in p){const t=`[data-theme="${h}"]`;if(e.cssMediaVars[t]||(e.cssMediaVars[t]={}),e.cssMediaVars[t][f]=p[h],h==="light"||h==="dark"){const d=`@media (prefers-color-scheme: ${h})`;e.cssMediaVars[d]||(e.cssMediaVars[d]={}),e.cssMediaVars[d][f]=p[h]}}return r.var=f,f}},M=(r,s,a)=>{const e=(0,S.getActiveConfig)();if((0,c.isObject)(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return r;if((0,c.isString)(r)&&(0,g.isCSSVar)(r)){const l=r.slice(2);if(r=C(l),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=l.split(" ");let b=e.color[i[0]];if(b&&!b.value&&!b.rgb&&((0,c.isString)(b)||(0,c.isArray)(b)||(0,c.isObject)(b))&&(e.color[i[0]]=M(b,i[0]),b=e.color[i[0]]),b&&b.value){let m=b.rgb;const x=i[1]!==void 0?i[1]:"1",R=i[2];R&&(m=(0,g.getRgbTone)(m,R)),r=`rgba(${m}, ${x})`}else{const m=i[2],x=i[1]!==void 0?i[1]:"1";if(m)try{const R=(0,g.colorStringToRgbaArray)(i[0]);R&&R.length>=3?r=`rgba(${(0,g.getRgbTone)(R.slice(0,3).join(", "),m)}, ${x})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if((0,c.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,c.isObject)(r)){const l={};for(const i in r)i!=="var"&&(l[i]=M(r[i],s,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&E(l,"color",s,e),l}const f=`--${e.varPrefix?e.varPrefix+"-":""}color-${s}`+(a?`-${a}`:"");let o=r.value||r;if((0,c.isString)(o)&&!o.includes("(")&&!o.startsWith("#")){const l=(0,g.parseColorToken)(o);if(l&&l.name&&!l.passthrough&&!l.cssVar){const i=e.color[l.name];i&&!i.value&&!i.rgb&&((0,c.isString)(i)||(0,c.isArray)(i)||(0,c.isObject)(i))&&(e.color[l.name]=M(i,l.name));const b=e.color[l.name];if(b&&b.rgb){let m=b.rgb;l.tone&&(m=(0,g.getRgbTone)(m,l.tone));const x=l.alpha?parseFloat(l.alpha):1;o=`rgba(${m}, ${x})`}}}const p=(0,g.colorStringToRgbaArray)(o),[h,t,d,n=1]=p,V=parseFloat(n.toFixed(2)),A=`${h}, ${t}, ${d}`,$=`rgba(${A}, ${V})`;return e.useVariable&&(e.cssVars[f]=$),{var:f,rgb:A,alpha:V,value:$}},D=(r,s,a)=>{const e=(0,S.getActiveConfig)();if((0,c.isObject)(r)&&r.value!==void 0&&r.var!==void 0)return r;if((0,c.isString)(r)&&(0,g.isCSSVar)(r)&&(r=C(r.slice(2))),(0,c.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,c.isObject)(r)){const o={};for(const p in r)p!=="var"&&(o[p]=D(r[p],s,p.slice(0,1)==="@"?p.slice(1):p));return e.useVariable&&E(o,"gradient",s,e),o}const f=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${s}`+(a?`-${a}`:"");return e.useVariable&&(e.cssVars[f]=r.value||r),{var:f,value:r.value||r}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},x=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!v.call(t,n)&&n!==r&&p(t,n,{get:()=>e[n],enumerable:!(s=d(e,n))||s.enumerable});return t};var S=t=>x(p({},"__esModule",{value:!0}),t);var y={};m(y,{convertSvgToSymbol:()=>R,generateSprite:()=>b});module.exports=S(y);var l=require("@symbo.ls/utils"),w=require("../factory.js");const f=(0,l.isNotProduction)(),b=t=>{const e=(0,w.getActiveConfig)();let r="";for(const s in t)e.__svgCache[s]||(e.__svgCache[s]=!0,r+=t[s]);return r},_=t=>{const e=t&&(t.default||t);if(!(0,l.isString)(e))return f&&console.warn("parseRootAttributes:",e,"is not a string"),{};const r=e.match(/<svg\s+(.*?)>/);if(!r||!r[1])return{};const n=r[1].match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);return n?n.reduce((o,c)=>{const[a,g]=c.split("=");return o[a]=g.replace(/['"]/g,""),o},{}):{}},C=(t,e)=>{const r=[];if(t.replace(/id="([^"]*)"/g,(n,o)=>(r.push(o),n)),!r.length)return t;let s=t;for(const n of r){const o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=`${e}-${n}`;s=s.replace(new RegExp(`id="${o}"`,"g"),`id="${c}"`).replace(new RegExp(`url\\(#${o}\\)`,"g"),`url(#${c})`).replace(new RegExp(`xlink:href="#${o}"`,"g"),`xlink:href="#${c}"`).replace(new RegExp(`href="#${o}"`,"g"),`href="#${c}"`)}return s},$=new Set,R=(t,e)=>{const r=e&&e.default?e.default:e;if(!(0,l.isString)(r))return f&&!$.has(t)&&($.add(t),console.warn("convertSvgToSymbol:",t,"is not a string")),"";e=r;const s=e.match(/^<symbol\b[^>]*\bid="([^"]*)"/);if(s){const u=s[1];return u===t?e:e.replace(`id="${u}"`,`id="${t}"`)}const n=_(e),{width:o,height:c}=n,a=n.viewBox||`0 0 ${o||24} ${c||24}`;let i=C(e,t).replace("<svg",`<symbol id="${t}" xmlns="http://www.w3.org/2000/svg" viewBox="${a}"`);return i=i.replace(/width="[^"]*"/,""),i=i.replace(/height="[^"]*"/,""),i=i.replace("</svg","</symbol"),i=I(i),i},A="line|circle|ellipse|rect|polyline|polygon|path|stop|use|image",E=new RegExp(`<(${A})\\b([^>]*?)\\s*/>`,"g"),I=t=>t.replace(E,"<$1$2></$1>");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as A,isArray as R,isString as V}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{colorStringToRgbaArray as T,getRgbTone as w,isCSSVar as E,parseColorToken as P}from"../utils/index.js";const L={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},x=(r,n,l)=>{const e=l||M();if(!V(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(E(r))return`var(${r})`;n&&r[n]&&(r=r[n]);let g,c,o;if(R(r))[g,c,o]=r;else{const t=P(r);if(!t){const{color:b,gradient:m}=e;let h=m[r]||b[r];return h?(n&&h[n]&&(h=h[n]),e.useVariable?`var(${h.var})`:h.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;g=t.name,c=t.alpha,o=t.tone}const{color:d,gradient:u}=e;let s=d[g]||u[g];if(!s)return e.verbose&&console.warn("Can't find color ",g),r;if(n)if(s[n]!==void 0)s=s[n];else if(R(s)){const t=n.charCodeAt(0)===64?n.slice(1):n;t==="dark"?s=s[1]!==void 0?s[1]:s[0]:(t!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",n),s=s[0])}else e.verbose&&console.warn(r," - does not have ",n);if(V(s))return x(s,null,l);let a=s.rgb;if(!a){const t=e.useVariable?`var(${s.var})`:s.value;if(c&&t){const b=Math.round(parseFloat(c)*100);return`color-mix(in srgb, ${t} ${b}%, transparent)`}return t}return o&&!s[o]&&(a=w(a,o),s[o]={rgb:a,var:`${s.var}-${o}`}),s[o]&&(a=s[o].rgb),c?`rgba(${a}, ${c})`:o?`rgba(${a}, 1)`:e.useVariable?`var(${s.var})`:`rgb(${a})`},U=(r,n,l)=>{const e=l||M();if(n||(n=e.globalTheme==="auto"?null:e.globalTheme),!V(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(E(r))return`var(${r})`;let g,c,o;if(R(r))g=r[0];else{const t=P(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;g=t.name,c=t.alpha,o=t.tone}else g=r}const{color:d,gradient:u}=e,s=d[g]||u[g],a=A(s);if(a&&s.value)return x(r,`@${n}`,l);if(a){if(e.useVariable&&s.var)return c||o?x(r,null,l):`var(${s.var})`;if(n)return x(r,`@${n}`,l);{const t={};for(const b in s){if(b.charCodeAt(0)!==64)continue;const m=b.slice(1),h=e.media&&e.media[m]||L[m];if(!h)continue;const f="@media "+(h==="print"?`${h}`:`screen and ${h}`);t[f]=x(r,b,l)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},j=(r,n,l,e)=>{const c=`--${e.varPrefix?e.varPrefix+"-":""}${n}-${l}`;let o;const d={};for(const u in r){if(u.charCodeAt(0)!==64)continue;const s=u.slice(1),a=r[u],t=a&&(a.value||a);!t||typeof t!="string"||(d[s]=t,(s==="light"||o===void 0)&&(o=t))}if(o!==void 0){e.cssVars[c]=o,e.cssMediaVars||(e.cssMediaVars={});for(const u in d){const s=`[data-theme="${u}"]`;if(e.cssMediaVars[s]||(e.cssMediaVars[s]={}),e.cssMediaVars[s][c]=d[u],u==="light"||u==="dark"){const a=`@media (prefers-color-scheme: ${u})`;e.cssMediaVars[a]||(e.cssMediaVars[a]={}),e.cssMediaVars[a][c]=d[u]}}return r.var=c,c}},D=(r,n,l)=>{const e=M();if(A(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return r;if(V(r)&&E(r)){const f=r.slice(2);if(r=x(f),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=f.split(" ");let p=e.color[i[0]];if(p&&!p.value&&!p.rgb&&(V(p)||R(p)||A(p))&&(e.color[i[0]]=D(p,i[0]),p=e.color[i[0]]),p&&p.value){let $=p.rgb;const S=i[1]!==void 0?i[1]:"1",C=i[2];C&&($=w($,C)),r=`rgba(${$}, ${S})`}else{const $=i[2],S=i[1]!==void 0?i[1]:"1";if($)try{const C=T(i[0]);C&&C.length>=3?r=`rgba(${w(C.slice(0,3).join(", "),$)}, ${S})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if(R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),A(r)){const f={};for(const i in r)i!=="var"&&(f[i]=D(r[i],n,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&j(f,"color",n,e),f}const c=`--${e.varPrefix?e.varPrefix+"-":""}color-${n}`+(l?`-${l}`:"");let o=r.value||r;if(V(o)&&!o.includes("(")&&!o.startsWith("#")){const f=P(o);if(f&&f.name&&!f.passthrough&&!f.cssVar){const i=e.color[f.name];i&&!i.value&&!i.rgb&&(V(i)||R(i)||A(i))&&(e.color[f.name]=D(i,f.name));const p=e.color[f.name];if(p&&p.rgb){let $=p.rgb;f.tone&&($=w($,f.tone));const S=f.alpha?parseFloat(f.alpha):1;o=`rgba(${$}, ${S})`}}}const d=T(o),[u,s,a,t=1]=d,b=parseFloat(t.toFixed(2)),m=`${u}, ${s}, ${a}`,h=`rgba(${m}, ${b})`;return e.useVariable&&(e.cssVars[c]=h),{var:c,rgb:m,alpha:b,value:h}},q=(r,n,l)=>{const e=M();if(A(r)&&r.value!==void 0&&r.var!==void 0)return r;if(V(r)&&E(r)&&(r=x(r.slice(2))),R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),A(r)){const o={};for(const d in r)d!=="var"&&(o[d]=q(r[d],n,d.slice(0,1)==="@"?d.slice(1):d));return e.useVariable&&j(o,"gradient",n,e),o}const c=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${n}`+(l?`-${l}`:"");return e.useVariable&&(e.cssVars[c]=r.value||r),{var:c,value:r.value||r}};export{L as STANDARD_SCHEME_QUERIES,x as getColor,U as getMediaColor,j as setAdaptiveSchemeVar,D as setColor,q as setGradient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNotProduction as
|
|
1
|
+
import{isNotProduction as $,isString as g}from"@symbo.ls/utils";import{getActiveConfig as w}from"../factory.js";const u=$(),R=e=>{const t=w();let r="";for(const n in e)t.__svgCache[n]||(t.__svgCache[n]=!0,r+=e[n]);return r},d=e=>{const t=e&&(e.default||e);if(!g(t))return u&&console.warn("parseRootAttributes:",t,"is not a string"),{};const r=t.match(/<svg\s+(.*?)>/);if(!r||!r[1])return{};const o=r[1].match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm);return o?o.reduce((s,c)=>{const[l,a]=c.split("=");return s[l]=a.replace(/['"]/g,""),s},{}):{}},h=(e,t)=>{const r=[];if(e.replace(/id="([^"]*)"/g,(o,s)=>(r.push(s),o)),!r.length)return e;let n=e;for(const o of r){const s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=`${t}-${o}`;n=n.replace(new RegExp(`id="${s}"`,"g"),`id="${c}"`).replace(new RegExp(`url\\(#${s}\\)`,"g"),`url(#${c})`).replace(new RegExp(`xlink:href="#${s}"`,"g"),`xlink:href="#${c}"`).replace(new RegExp(`href="#${s}"`,"g"),`href="#${c}"`)}return n},f=new Set,A=(e,t)=>{const r=t&&t.default?t.default:t;if(!g(r))return u&&!f.has(e)&&(f.add(e),console.warn("convertSvgToSymbol:",e,"is not a string")),"";t=r;const n=t.match(/^<symbol\b[^>]*\bid="([^"]*)"/);if(n){const p=n[1];return p===e?t:t.replace(`id="${p}"`,`id="${e}"`)}const o=d(t),{width:s,height:c}=o,l=o.viewBox||`0 0 ${s||24} ${c||24}`;let i=h(t,e).replace("<svg",`<symbol id="${e}" xmlns="http://www.w3.org/2000/svg" viewBox="${l}"`);return i=i.replace(/width="[^"]*"/,""),i=i.replace(/height="[^"]*"/,""),i=i.replace("</svg","</symbol"),i=x(i),i},v="line|circle|ellipse|rect|polyline|polygon|path|stop|use|image",m=new RegExp(`<(${v})\\b([^>]*?)\\s*/>`,"g"),x=e=>e.replace(m,"<$1$2></$1>");export{A as convertSvgToSymbol,R as generateSprite};
|