@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,5 +1,17 @@
1
1
  # @symbo.ls/scratch
2
2
 
3
+ ## 3.14.774
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
9
+ ## 3.14.773
10
+
11
+ ### Patch Changes
12
+
13
+ - Auto-generated cross-repo patch release.
14
+
3
15
  ## 3.14.771
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var T=(a,e)=>{for(var l in e)C(a,l,{get:e[l],enumerable:!0})},ee=(a,e,l,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _(e))!k.call(a,o)&&o!==l&&C(a,o,{get:()=>e[o],enumerable:!(c=Z(e,o))||c.enumerable});return a};var te=a=>ee(C({},"__esModule",{value:!0}),a);var re={};T(re,{getSafeInk:()=>K,getSafeInkInfo:()=>oe});module.exports=te(re);var j=require("@symbo.ls/utils"),F=require("../factory.js"),r=require("../utils/index.js"),g=require("./color.js");const K=(a,e,l={},c)=>{const o=c||(0,F.getActiveConfig)(),{min:N=4.5,large:O=!1,scheme:V,meta:B=!1,maxIterations:E=15}=l,v=O?3:N,m=V||(o.globalTheme&&o.globalTheme!=="auto"?o.globalTheme:"light"),I=(0,j.isString)(e)?e:String(e),h=(0,r.parseColorToken)(a),x=h&&!h.passthrough&&!h.cssVar?h.name:null,b=(t,n)=>B?{value:t,...n}:t;if(x){const t=o.color[`${x}Safe`];if(t){const n=`${I}@${m}`,s=t[n]!==void 0?t[n]:t[I];if(s!==void 0){const D=s&&s.rgb!==void 0?o.useVariable&&s.var?`var(${s.var})`:s.value:(0,g.getColor)(s,null,o);return b(D,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const M=(0,g.getColor)(a,m?`@${m}`:null,o),i=(0,g.resolveColorRgb)(a,o,m),p=(0,g.resolveColorRgb)(e,o,m);if(!i||!p)return o.verbose&&console.warn("getSafeInk: could not resolve",a,e,"\u2014 returning hue unchanged"),b(M,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const f=(0,r.compositeOverBackdrop)(p.rgb,p.alpha),G=(0,r.compositeOverBackdrop)(i.rgb,i.alpha,f),L=(0,r.contrastRatio)(G,f);if(L>=v-.02)return b(M,{ratio:L,deviation:0,derived:!1,overridden:!1});const[H,P,q]=(0,r.rgbToHSL)(i.rgb[0]/255,i.rgb[1]/255,i.rgb[2]/255),u=q*100,y=(0,r.relativeLuminance)(f)>.5,z=y?u:100-u,w=t=>{const n=y?u-t:u+t,s=Math.max(0,Math.min(100,n));return{rgb:(0,r.hslToRgb)(H,P,s/100).map(Y=>Math.max(0,Math.min(1,Y))*255),L:s}},R=t=>{const{rgb:n}=w(t),s=(0,r.compositeOverBackdrop)(n,i.alpha,f);return(0,r.contrastRatio)(s,f)};let S=0,d=z;const A=R(d)>=v;if(A)for(let t=0;t<E;t++){const n=(S+d)/2;R(n)>=v?d=n:S=n}else S=d;const{rgb:J,L:Q}=w(d),$=J.map(t=>Math.round(t)),U=R(d),W=i.alpha<1?`rgba(${$.join(", ")}, ${i.alpha})`:`rgb(${$.join(", ")})`,X=Math.abs(Q-u);return b(W,{rgb:$,ratio:U,startRatio:L,deviation:X,derived:!0,overridden:!1,reachable:A})},oe=(a,e,l={},c)=>K(a,e,{...l,meta:!0},c);
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 u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)u(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of S(e))!$.call(t,n)&&n!==r&&u(t,n,{get:()=>e[n],enumerable:!(s=y(e,n))||s.enumerable});return t};var O=t=>L(u({},"__esModule",{value:!0}),t);var K={};I(K,{CSS_NATIVE_COLOR_REGEX:()=>w,changeLightness:()=>N,colorStringToRgbaArray:()=>c,compositeOverBackdrop:()=>k,contrastRatio:()=>Z,getColorShade:()=>d,getRgbTone:()=>D,hexToRgb:()=>A,hexToRgbArray:()=>f,hexToRgba:()=>_,hslToRgb:()=>g,isCSSVar:()=>b,isResolvedColor:()=>G,mixTwoColors:()=>E,mixTwoRgb:()=>H,mixTwoRgba:()=>l,opacify:()=>j,parseColorToken:()=>z,relativeLuminance:()=>h,rgbArrayToHex:()=>x,rgbToHSL:()=>m,rgbToHex:()=>F,splitTopLevelCommas:()=>X,toLinearChannel:()=>p});module.exports=O(K);var a=require("@symbo.ls/utils");const c=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&&a.document&&a.window){const e=a.document.body.appendChild(a.document.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){a.document.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return a.document.body.removeChild(e),[0,0,0,0];t=a.window.getComputedStyle(e).color,a.document.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},E=(t,e,r=.5)=>(t=c(t),e=c(e),l(t,e,r)),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${r},${s},${n})`},f=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[r,s,n]},F=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),x=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),_=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${r},${s},${n},${e})`},H=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},N=(t,e)=>{const[r,s,n]=e,o=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,o]},m=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),o=1-Math.abs(s+s-n-1),i=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(i<0?i+6:i),o?n/o:0,(s+s-n)/2]},g=(t,e,r,s=e*Math.min(r,1-r),n=(o,i=(o+t/30)%12)=>r-s*Math.max(Math.min(i-3,9-i,1),-1))=>[n(0),n(8),n(4)],d=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let o=(r&255)+e;return o>255?o=255:o<0&&(o=0),((o|n<<8|s<<16)+16777216).toString(16).slice(1)},l=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const o=n===3?i=>i:Math.round;s[n]=o(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},j=(t,e)=>{const r=c(t);if(!r){(0,a.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},b=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,w=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,V=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,z=t=>{if(!(0,a.isString)(t))return null;if(w.test(t))return{passthrough:t};if(b(t))return{cssVar:t};const e=t.match(V);if(!e)return null;const[,r,s,n]=e,o=s!==void 0?`0.${s}`:void 0,i=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:o,tone:i}},G=t=>(0,a.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),X=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},p=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),h=t=>.2126*p(t[0])+.7152*p(t[1])+.0722*p(t[2]),Z=(t,e)=>{const r=h(t)+.05,s=h(e)+.05;return r>s?r/s:s/r},k=(t,e=1,r=[255,255,255])=>e>=1?t:t.map((s,n)=>s*e+r[n]*(1-e)),D=(t,e)=>{(0,a.isString)(t)&&t.includes("rgb")&&(t=c(t).join(", ")),(0,a.isString)(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),(0,a.isNumber)(e)&&(e+="");const r=x(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=d(r,parseFloat(e));return f(n).join(", ")}else{const[n,o,i]=t,[C,T]=m(n/255,o/255,i/255),R=Math.max(0,Math.min(100,parseFloat(e)))/100;return g(C,T,R).map(M=>Math.round(Math.max(0,Math.min(1,M))*255)).join(", ")}};
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 X}from"@symbo.ls/utils";import{getActiveConfig as Y}from"../factory.js";import{parseColorToken as Z,rgbToHSL as _,hslToRgb as k,relativeLuminance as T,contrastRatio as A,compositeOverBackdrop as S}from"../utils/index.js";import{getColor as D,resolveColorRgb as j}from"./color.js";const ee=(s,n,f={},u)=>{const r=u||Y(),{min:F=4.5,large:K=!1,scheme:N,meta:O=!1,maxIterations:V=15}=f,h=K?3:F,l=N||(r.globalTheme&&r.globalTheme!=="auto"?r.globalTheme:"light"),$=X(n)?n:String(n),g=Z(s),C=g&&!g.passthrough&&!g.cssVar?g.name:null,m=(e,t)=>O?{value:e,...t}:e;if(C){const e=r.color[`${C}Safe`];if(e){const t=`${$}@${l}`,o=e[t]!==void 0?e[t]:e[$];if(o!==void 0){const w=o&&o.rgb!==void 0?r.useVariable&&o.var?`var(${o.var})`:o.value:D(o,null,r);return m(w,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const I=D(s,l?`@${l}`:null,r),a=j(s,r,l),b=j(n,r,l);if(!a||!b)return r.verbose&&console.warn("getSafeInk: could not resolve",s,n,"\u2014 returning hue unchanged"),m(I,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const c=S(b.rgb,b.alpha),B=S(a.rgb,a.alpha,c),v=A(B,c);if(v>=h-.02)return m(I,{ratio:v,deviation:0,derived:!1,overridden:!1});const[E,G,H]=_(a.rgb[0]/255,a.rgb[1]/255,a.rgb[2]/255),d=H*100,x=T(c)>.5,P=x?d:100-d,M=e=>{const t=x?d-e:d+e,o=Math.max(0,Math.min(100,t));return{rgb:k(E,G,o/100).map(W=>Math.max(0,Math.min(1,W))*255),L:o}},p=e=>{const{rgb:t}=M(e),o=S(t,a.alpha,c);return A(o,c)};let L=0,i=P;const y=p(i)>=h;if(y)for(let e=0;e<V;e++){const t=(L+i)/2;p(t)>=h?i=t:L=t}else L=i;const{rgb:q,L:z}=M(i),R=q.map(e=>Math.round(e)),J=p(i),Q=a.alpha<1?`rgba(${R.join(", ")}, ${a.alpha})`:`rgb(${R.join(", ")})`,U=Math.abs(z-d);return m(Q,{rgb:R,ratio:J,startRatio:v,deviation:U,derived:!0,overridden:!1,reachable:y})},ne=(s,n,f={},u)=>ee(s,n,{...f,meta:!0},u);export{ee as getSafeInk,ne as getSafeInkInfo};
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 i,window as h,isString as c,isNumber as l,isNotProduction as b}from"@symbo.ls/utils";const p=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&&h){const e=i.body.appendChild(i.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){i.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return i.body.removeChild(e),[0,0,0,0];t=h.getComputedStyle(e).color,i.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},E=(t,e,r=.5)=>(t=p(t),e=p(e),y(t,e,r)),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${r},${s},${n})`},w=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[r,s,n]},F=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),C=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),_=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${r},${s},${n},${e})`},H=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},N=(t,e)=>{const[r,s,n]=e,o=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,o]},T=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),o=1-Math.abs(s+s-n-1),a=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(a<0?a+6:a),o?n/o:0,(s+s-n)/2]},R=(t,e,r,s=e*Math.min(r,1-r),n=(o,a=(o+t/30)%12)=>r-s*Math.max(Math.min(a-3,9-a,1),-1))=>[n(0),n(8),n(4)],M=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let o=(r&255)+e;return o>255?o=255:o<0&&(o=0),((o|n<<8|s<<16)+16777216).toString(16).slice(1)},y=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const o=n===3?a=>a:Math.round;s[n]=o(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},j=(t,e)=>{const r=p(t);if(!r){b()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},S=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,$=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,I=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,V=t=>{if(!c(t))return null;if($.test(t))return{passthrough:t};if(S(t))return{cssVar:t};const e=t.match(I);if(!e)return null;const[,r,s,n]=e,o=s!==void 0?`0.${s}`:void 0,a=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:o,tone:a}},z=t=>c(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),G=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},u=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),f=t=>.2126*u(t[0])+.7152*u(t[1])+.0722*u(t[2]),X=(t,e)=>{const r=f(t)+.05,s=f(e)+.05;return r>s?r/s:s/r},Z=(t,e=1,r=[255,255,255])=>e>=1?t:t.map((s,n)=>s*e+r[n]*(1-e)),k=(t,e)=>{c(t)&&t.includes("rgb")&&(t=p(t).join(", ")),c(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),l(e)&&(e+="");const r=C(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=M(r,parseFloat(e));return w(n).join(", ")}else{const[n,o,a]=t,[x,m]=T(n/255,o/255,a/255),g=Math.max(0,Math.min(100,parseFloat(e)))/100;return R(x,m,g).map(d=>Math.round(Math.max(0,Math.min(1,d))*255)).join(", ")}};export{$ as CSS_NATIVE_COLOR_REGEX,N as changeLightness,p as colorStringToRgbaArray,Z as compositeOverBackdrop,X as contrastRatio,M as getColorShade,k as getRgbTone,A as hexToRgb,w as hexToRgbArray,_ as hexToRgba,R as hslToRgb,S as isCSSVar,z as isResolvedColor,E as mixTwoColors,H as mixTwoRgb,y as mixTwoRgba,j as opacify,V as parseColorToken,f as relativeLuminance,C as rgbArrayToHex,T as rgbToHSL,F as rgbToHex,G as splitTopLevelCommas,u as toLinearChannel};
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};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.14.771",
5
+ "version": "3.14.774",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",