@symbo.ls/scratch 3.14.771 → 3.14.774
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 R=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var _=(a,e)=>{for(var i in e)R(a,i,{get:e[i],enumerable:!0})},ee=(a,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Y(e))!Z.call(a,r)&&r!==i&&R(a,r,{get:()=>e[r],enumerable:!(c=X(e,r))||c.enumerable});return a};var te=a=>ee(R({},"__esModule",{value:!0}),a);var re={};_(re,{getSafeInk:()=>F,getSafeInkInfo:()=>oe});module.exports=te(re);var D=require("@symbo.ls/utils"),j=require("../factory.js"),o=require("../utils/index.js"),u=require("./color.js");const F=(a,e,i={},c)=>{const r=c||(0,j.getActiveConfig)(),{min:G=4.5,large:K=!1,scheme:N,meta:V=!1,maxIterations:w=15}=i,v=K?3:G,g=N||(r.globalTheme&&r.globalTheme!=="auto"?r.globalTheme:"light"),O=(0,D.isString)(e)?e:String(e),b=(0,o.parseColorToken)(a),k=b&&!b.passthrough&&!b.cssVar?b.name:null,h=(t,n)=>V?{value:t,...n}:t;if(k){const t=r.color[`${k}Safe`];if(t){const n=`${O}@${g}`,s=t[n]!==void 0?t[n]:t[O];if(s!==void 0){const I=s&&s.rgb!==void 0?r.useVariable&&s.var?`var(${s.var})`:s.value:(0,u.getColor)(s,null,r);return h(I,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const x=(0,u.getColor)(a,g?`@${g}`:null,r),l=(0,u.resolveColorRgb)(a,r,g),p=(0,u.resolveColorRgb)(e,r,g);if(!l||!p)return r.verbose&&console.warn("getSafeInk: could not resolve",a,e,"\u2014 returning hue unchanged"),h(x,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const m=(0,o.compositeOverBackdrop)(p.rgb,p.alpha),B=(0,o.compositeOverBackdrop)(l.rgb,l.alpha,m),S=(0,o.contrastRatio)(B,m);if(S>=v-.02)return h(x,{ratio:S,deviation:0,derived:!1,overridden:!1});const[d,E,H]=(0,o.srgbToOklab)(l.rgb),[,P,q]=(0,o.oklabToOklch)([d,E,H]),M=(0,o.relativeLuminance)(m)>.5,z=M?d:1-d,y=t=>{const n=M?d-t:d+t,s=Math.max(0,Math.min(1,n));return{rgb:(0,o.oklchToGamutSafeSrgb)(s,P,q),L:s}},C=t=>{const{rgb:n}=y(t),s=(0,o.compositeOverBackdrop)(n.map(I=>Math.round(I)),l.alpha,m);return(0,o.contrastRatio)(s,m)};let L=0,f=z;const A=C(f)>=v;if(A)for(let t=0;t<w;t++){const n=(L+f)/2;C(n)>=v?f=n:L=n}else L=f;const{rgb:J,L:Q}=y(f),$=J.map(t=>Math.round(t)),T=C(f),U=l.alpha<1?`rgba(${$.join(", ")}, ${l.alpha})`:`rgb(${$.join(", ")})`,W=Math.abs(Q-d)*100;return h(U,{rgb:$,ratio:T,startRatio:S,deviation:W,derived:!0,overridden:!1,reachable:A})},oe=(a,e,i={},c)=>F(a,e,{...i,meta:!0},c);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var E=(t,n)=>{for(var r in n)x(t,r,{get:n[r],enumerable:!0})},F=(t,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of L(n))!k.call(t,e)&&e!==r&&x(t,e,{get:()=>n[e],enumerable:!(s=_(n,e))||s.enumerable});return t};var A=t=>F(x({},"__esModule",{value:!0}),t);var B={};E(B,{CSS_NATIVE_COLOR_REGEX:()=>R,changeLightness:()=>V,colorStringToRgbaArray:()=>m,compositeOverBackdrop:()=>W,contrastRatio:()=>K,getColorShade:()=>w,getRgbTone:()=>Y,hexToRgb:()=>H,hexToRgbArray:()=>b,hexToRgba:()=>j,hslToRgb:()=>T,isCSSVar:()=>S,isResolvedColor:()=>q,linearChannelToSrgb:()=>$,mixTwoColors:()=>G,mixTwoRgb:()=>P,mixTwoRgba:()=>C,oklabToLinearSrgb:()=>I,oklabToOklch:()=>Q,oklchToGamutSafeSrgb:()=>U,oklchToOklab:()=>O,opacify:()=>z,parseColorToken:()=>Z,relativeLuminance:()=>g,rgbArrayToHex:()=>d,rgbToHSL:()=>M,rgbToHex:()=>N,splitTopLevelCommas:()=>D,srgbChannelToLinear:()=>y,srgbToOklab:()=>J,toLinearChannel:()=>f});module.exports=A(B);var i=require("@symbo.ls/utils");const m=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i.document&&i.window){const n=i.document.body.appendChild(i.document.createElement("fictum")),r="rgb(1, 2, 3)";if(n.style.color=r,n.style.color!==r){i.document.body.removeChild(n);return}if(n.style.color=t,n.style.color===r||n.style.color==="")return i.document.body.removeChild(n),[0,0,0,0];t=i.window.getComputedStyle(n).color,i.document.body.removeChild(n)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(n=>+n)):[0,0,0,0]},G=(t,n,r=.5)=>(t=m(t),n=m(n),C(t,n,r)),H=(t,n=1)=>{const[r,s,e]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${r},${s},${e})`},b=(t,n=1)=>{const[r,s,e]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[r,s,e]},N=(t,n,r)=>"#"+(1<<24|t<<16|n<<8|r).toString(16).slice(1),d=([t,n,r])=>((1<<24)+(t<<16)+(n<<8)+r).toString(16).slice(1),j=(t,n=1)=>{const[r,s,e]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${r},${s},${e},${n})`},P=(t,n,r=.5)=>{const s=[];for(let e=0;e<3;e++)s[e]=~~(t[e]+(n[e]-t[e])*r);return`rgb(${s})`},V=(t,n)=>{const[r,s,e]=n,o=Math.max(0,Math.min(100,e+parseFloat(t)));return[r,s,o]},M=(t,n,r)=>{const s=Math.max(t,n,r),e=s-Math.min(t,n,r),o=1-Math.abs(s+s-e-1),a=e&&(s==t?(n-r)/e:s==n?2+(r-t)/e:4+(t-n)/e);return[60*(a<0?a+6:a),o?e/o:0,(s+s-e)/2]},T=(t,n,r,s=n*Math.min(r,1-r),e=(o,a=(o+t/30)%12)=>r-s*Math.max(Math.min(a-3,9-a,1),-1))=>[e(0),e(8),e(4)],w=(t,n)=>{const r=parseInt(t,16);let s=(r>>16)+n;s>255?s=255:s<0&&(s=0);let e=(r>>8&255)+n;e>255?e=255:e<0&&(e=0);let o=(r&255)+n;return o>255?o=255:o<0&&(o=0),((o|e<<8|s<<16)+16777216).toString(16).slice(1)},C=(t,n,r=.5)=>{const s=[];for(let e=0;e<4;e++){const o=e===3?a=>a:Math.round;s[e]=o(t[e]+(n[e]-t[e])*r)}return`rgba(${s})`},z=(t,n)=>{const r=m(t);if(!r){(0,i.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=n,`rgba(${r})`},S=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,R=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,X=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,Z=t=>{if(!(0,i.isString)(t))return null;if(R.test(t))return{passthrough:t};if(S(t))return{cssVar:t};const n=t.match(X);if(!n)return null;const[,r,s,e]=n,o=s!==void 0?`0.${s}`:void 0,a=e&&e[0]==="="?e.slice(1):e;return{name:r,alpha:o,tone:a}},q=t=>(0,i.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),D=t=>{const n=[];let r="",s=0;for(const e of t){if(e==="("?s+=1:e===")"&&s>0&&(s-=1),e===","&&s===0){n.push(r),r="";continue}r+=e}return(r.length||!n.length)&&n.push(r),n},f=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),g=t=>.2126*f(t[0])+.7152*f(t[1])+.0722*f(t[2]),K=(t,n)=>{const r=g(t)+.05,s=g(n)+.05;return r>s?r/s:s/r},y=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),$=t=>(t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055)*255,J=([t,n,r])=>{const[s,e,o]=[t,n,r].map(y),a=.4122214708*s+.5363325363*e+.0514459929*o,c=.2119034982*s+.6806995451*e+.1073969566*o,h=.0883024619*s+.2817188376*e+.6299787005*o,p=Math.cbrt(a),u=Math.cbrt(c),l=Math.cbrt(h);return[.2104542553*p+.793617785*u-.0040720468*l,1.9779984951*p-2.428592205*u+.4505937099*l,.0259040371*p+.7827717662*u-.808675766*l]},I=([t,n,r])=>{const s=t+.3963377774*n+.2158037573*r,e=t-.1055613458*n-.0638541728*r,o=t-.0894841775*n-1.291485548*r,a=s**3,c=e**3,h=o**3;return[4.0767416621*a-3.3077115913*c+.2309699292*h,-1.2684380046*a+2.6097574011*c-.3413193965*h,-.0041960863*a-.7034186147*c+1.707614701*h]},Q=([t,n,r])=>{let s=Math.atan2(r,n)*180/Math.PI;return s<0&&(s+=360),[t,Math.sqrt(n*n+r*r),s]},O=([t,n,r])=>{const s=r*Math.PI/180;return[t,n*Math.cos(s),n*Math.sin(s)]},U=(t,n,r,s=24)=>{const e=c=>I(O([t,c,r])),o=c=>c.every(h=>h>=-1e-4&&h<=1.0001);let a=e(n);if(!o(a)){let c=0,h=n;for(let p=0;p<s;p++){const u=(c+h)/2;o(e(u))?c=u:h=u}a=e(c)}return a.map(c=>$(Math.max(0,Math.min(1,c))))},W=(t,n=1,r=[255,255,255])=>n>=1?t:t.map((s,e)=>s*n+r[e]*(1-n)),Y=(t,n)=>{(0,i.isString)(t)&&t.includes("rgb")&&(t=m(t).join(", ")),(0,i.isString)(t)&&(t=t.split(",").map(e=>parseFloat(e.trim()))),(0,i.isNumber)(n)&&(n+="");const r=d(t),s=n.slice(0,1);if(s==="-"||s==="+"){const e=w(r,parseFloat(n));return b(e).join(", ")}else{const[e,o,a]=t,[c,h]=M(e/255,o/255,a/255),p=Math.max(0,Math.min(100,parseFloat(n)))/100;return T(c,h,p).map(l=>Math.round(Math.max(0,Math.min(1,l))*255)).join(", ")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isString as
|
|
1
|
+
import{isString as U}from"@symbo.ls/utils";import{getActiveConfig as W}from"../factory.js";import{parseColorToken as X,srgbToOklab as Y,oklabToOklch as Z,oklchToGamutSafeSrgb as _,relativeLuminance as ee,contrastRatio as y,compositeOverBackdrop as $}from"../utils/index.js";import{getColor as A,resolveColorRgb as D}from"./color.js";const te=(s,a,g={},m)=>{const r=m||W(),{min:j=4.5,large:F=!1,scheme:G,meta:K=!1,maxIterations:N=15}=g,b=F?3:j,c=G||(r.globalTheme&&r.globalTheme!=="auto"?r.globalTheme:"light"),I=U(a)?a:String(a),f=X(s),R=f&&!f.passthrough&&!f.cssVar?f.name:null,u=(e,t)=>K?{value:e,...t}:e;if(R){const e=r.color[`${R}Safe`];if(e){const t=`${I}@${c}`,o=e[t]!==void 0?e[t]:e[I];if(o!==void 0){const L=o&&o.rgb!==void 0?r.useVariable&&o.var?`var(${o.var})`:o.value:A(o,null,r);return u(L,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const O=A(s,c?`@${c}`:null,r),n=D(s,r,c),h=D(a,r,c);if(!n||!h)return r.verbose&&console.warn("getSafeInk: could not resolve",s,a,"\u2014 returning hue unchanged"),u(O,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const d=$(h.rgb,h.alpha),V=$(n.rgb,n.alpha,d),v=y(V,d);if(v>=b-.02)return u(O,{ratio:v,deviation:0,derived:!1,overridden:!1});const[i,w,B]=Y(n.rgb),[,E,H]=Z([i,w,B]),k=ee(d)>.5,P=k?i:1-i,x=e=>{const t=k?i-e:i+e,o=Math.max(0,Math.min(1,t));return{rgb:_(o,E,H),L:o}},p=e=>{const{rgb:t}=x(e),o=$(t.map(L=>Math.round(L)),n.alpha,d);return y(o,d)};let S=0,l=P;const M=p(l)>=b;if(M)for(let e=0;e<N;e++){const t=(S+l)/2;p(t)>=b?l=t:S=t}else S=l;const{rgb:q,L:z}=x(l),C=q.map(e=>Math.round(e)),J=p(l),Q=n.alpha<1?`rgba(${C.join(", ")}, ${n.alpha})`:`rgb(${C.join(", ")})`,T=Math.abs(z-i)*100;return u(Q,{rgb:C,ratio:J,startRatio:v,deviation:T,derived:!0,overridden:!1,reachable:M})},se=(s,a,g={},m)=>te(s,a,{...g,meta:!0},m);export{te as getSafeInk,se as getSafeInkInfo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{document as
|
|
1
|
+
import{document as u,window as g,isString as m,isNumber as d,isNotProduction as M}from"@symbo.ls/utils";const f=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&u&&g){const n=u.body.appendChild(u.createElement("fictum")),e="rgb(1, 2, 3)";if(n.style.color=e,n.style.color!==e){u.body.removeChild(n);return}if(n.style.color=t,n.style.color===e||n.style.color==="")return u.body.removeChild(n),[0,0,0,0];t=g.getComputedStyle(n).color,u.body.removeChild(n)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(n=>+n)):[0,0,0,0]},A=(t,n,e=.5)=>(t=f(t),n=f(n),y(t,n,e)),G=(t,n=1)=>{const[e,s,r]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${e},${s},${r})`},T=(t,n=1)=>{const[e,s,r]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[e,s,r]},H=(t,n,e)=>"#"+(1<<24|t<<16|n<<8|e).toString(16).slice(1),w=([t,n,e])=>((1<<24)+(t<<16)+(n<<8)+e).toString(16).slice(1),N=(t,n=1)=>{const[e,s,r]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${e},${s},${r},${n})`},j=(t,n,e=.5)=>{const s=[];for(let r=0;r<3;r++)s[r]=~~(t[r]+(n[r]-t[r])*e);return`rgb(${s})`},P=(t,n)=>{const[e,s,r]=n,o=Math.max(0,Math.min(100,r+parseFloat(t)));return[e,s,o]},C=(t,n,e)=>{const s=Math.max(t,n,e),r=s-Math.min(t,n,e),o=1-Math.abs(s+s-r-1),a=r&&(s==t?(n-e)/r:s==n?2+(e-t)/r:4+(t-n)/r);return[60*(a<0?a+6:a),o?r/o:0,(s+s-r)/2]},S=(t,n,e,s=n*Math.min(e,1-e),r=(o,a=(o+t/30)%12)=>e-s*Math.max(Math.min(a-3,9-a,1),-1))=>[r(0),r(8),r(4)],R=(t,n)=>{const e=parseInt(t,16);let s=(e>>16)+n;s>255?s=255:s<0&&(s=0);let r=(e>>8&255)+n;r>255?r=255:r<0&&(r=0);let o=(e&255)+n;return o>255?o=255:o<0&&(o=0),((o|r<<8|s<<16)+16777216).toString(16).slice(1)},y=(t,n,e=.5)=>{const s=[];for(let r=0;r<4;r++){const o=r===3?a=>a:Math.round;s[r]=o(t[r]+(n[r]-t[r])*e)}return`rgba(${s})`},V=(t,n)=>{const e=f(t);if(!e){M()&&console.warn(t+" color is not rgba");return}return e[3]=n,`rgba(${e})`},$=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,I=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,O=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,z=t=>{if(!m(t))return null;if(I.test(t))return{passthrough:t};if($(t))return{cssVar:t};const n=t.match(O);if(!n)return null;const[,e,s,r]=n,o=s!==void 0?`0.${s}`:void 0,a=r&&r[0]==="="?r.slice(1):r;return{name:e,alpha:o,tone:a}},X=t=>m(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),Z=t=>{const n=[];let e="",s=0;for(const r of t){if(r==="("?s+=1:r===")"&&s>0&&(s-=1),r===","&&s===0){n.push(e),e="";continue}e+=r}return(e.length||!n.length)&&n.push(e),n},x=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),b=t=>.2126*x(t[0])+.7152*x(t[1])+.0722*x(t[2]),q=(t,n)=>{const e=b(t)+.05,s=b(n)+.05;return e>s?e/s:s/e},_=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),L=t=>(t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055)*255,D=([t,n,e])=>{const[s,r,o]=[t,n,e].map(_),a=.4122214708*s+.5363325363*r+.0514459929*o,i=.2119034982*s+.6806995451*r+.1073969566*o,c=.0883024619*s+.2817188376*r+.6299787005*o,h=Math.cbrt(a),p=Math.cbrt(i),l=Math.cbrt(c);return[.2104542553*h+.793617785*p-.0040720468*l,1.9779984951*h-2.428592205*p+.4505937099*l,.0259040371*h+.7827717662*p-.808675766*l]},k=([t,n,e])=>{const s=t+.3963377774*n+.2158037573*e,r=t-.1055613458*n-.0638541728*e,o=t-.0894841775*n-1.291485548*e,a=s**3,i=r**3,c=o**3;return[4.0767416621*a-3.3077115913*i+.2309699292*c,-1.2684380046*a+2.6097574011*i-.3413193965*c,-.0041960863*a-.7034186147*i+1.707614701*c]},K=([t,n,e])=>{let s=Math.atan2(e,n)*180/Math.PI;return s<0&&(s+=360),[t,Math.sqrt(n*n+e*e),s]},E=([t,n,e])=>{const s=e*Math.PI/180;return[t,n*Math.cos(s),n*Math.sin(s)]},J=(t,n,e,s=24)=>{const r=i=>k(E([t,i,e])),o=i=>i.every(c=>c>=-1e-4&&c<=1.0001);let a=r(n);if(!o(a)){let i=0,c=n;for(let h=0;h<s;h++){const p=(i+c)/2;o(r(p))?i=p:c=p}a=r(i)}return a.map(i=>L(Math.max(0,Math.min(1,i))))},Q=(t,n=1,e=[255,255,255])=>n>=1?t:t.map((s,r)=>s*n+e[r]*(1-n)),U=(t,n)=>{m(t)&&t.includes("rgb")&&(t=f(t).join(", ")),m(t)&&(t=t.split(",").map(r=>parseFloat(r.trim()))),d(n)&&(n+="");const e=w(t),s=n.slice(0,1);if(s==="-"||s==="+"){const r=R(e,parseFloat(n));return T(r).join(", ")}else{const[r,o,a]=t,[i,c]=C(r/255,o/255,a/255),h=Math.max(0,Math.min(100,parseFloat(n)))/100;return S(i,c,h).map(l=>Math.round(Math.max(0,Math.min(1,l))*255)).join(", ")}};export{I as CSS_NATIVE_COLOR_REGEX,P as changeLightness,f as colorStringToRgbaArray,Q as compositeOverBackdrop,q as contrastRatio,R as getColorShade,U as getRgbTone,G as hexToRgb,T as hexToRgbArray,N as hexToRgba,S as hslToRgb,$ as isCSSVar,X as isResolvedColor,L as linearChannelToSrgb,A as mixTwoColors,j as mixTwoRgb,y as mixTwoRgba,k as oklabToLinearSrgb,K as oklabToOklch,J as oklchToGamutSafeSrgb,E as oklchToOklab,V as opacify,z as parseColorToken,b as relativeLuminance,w as rgbArrayToHex,C as rgbToHSL,H as rgbToHex,Z as splitTopLevelCommas,_ as srgbChannelToLinear,D as srgbToOklab,x as toLinearChannel};
|