@symbo.ls/scratch 3.14.773 → 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 +6 -0
- package/dist/cjs/src/system/ink.js +1 -1
- package/dist/esm/src/system/ink.js +1 -1
- package/package.json +1 -1
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
|
-
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
|
|
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};
|