@soybeanjs/colord 0.0.2 → 0.0.4

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.
@@ -1,8 +1,8 @@
1
- import { _ as ALPHA_PRECISION, c as round } from "./utils-BgIyY6bK.js";
2
- import { a as parseRgbString, c as roundRgb, i as parseRgb, s as rgbToRgbString } from "./rgb-CfVJB1Bj.js";
3
- import { i as roundHsv, n as parseHsv, r as rgbToHsv } from "./hsv-UWMaaOSN.js";
4
- import { a as saturate, c as rgbToHsl, l as rgbToHslString, n as invert, o as parseHsl, r as lighten, s as parseHslString, t as changeAlpha, u as roundHsl } from "./manipulate-CeAgrUd6.js";
5
- import { t as getBrightness } from "./get-BFaklfVd.js";
1
+ import { l as round, v as ALPHA_PRECISION } from "./utils-DajWVr6Z.js";
2
+ import { a as parseRgbString, c as roundRgb, i as parseRgb, s as rgbToRgbString } from "./rgb-DNYno5F7.js";
3
+ import { i as roundHsv, n as parseHsv, r as rgbToHsv } from "./hsv-BKcGyyrD.js";
4
+ import { a as saturate, c as rgbToHsl, l as rgbToHslString, n as invert, o as parseHsl, r as lighten, s as parseHslString, t as changeAlpha, u as roundHsl } from "./manipulate-C3CvrU4m.js";
5
+ import { t as getBrightness } from "./get-D0jfz1WU.js";
6
6
 
7
7
  //#region src/models/hex.ts
8
8
  const hexMatcher = /^#([0-9a-f]{3,8})$/i;
package/dist/colord.js CHANGED
@@ -1,10 +1,10 @@
1
- import "./utils-BgIyY6bK.js";
2
- import "./rgb-CfVJB1Bj.js";
3
- import { n as colord, t as Colord } from "./colord-BV1k1-gC.js";
4
- import "./hsv-UWMaaOSN.js";
5
- import "./manipulate-CeAgrUd6.js";
6
- import "./xyz-MII3ndWO.js";
7
- import "./lab-CJHLdqfe.js";
8
- import "./get-BFaklfVd.js";
1
+ import "./utils-DajWVr6Z.js";
2
+ import "./rgb-DNYno5F7.js";
3
+ import { n as colord, t as Colord } from "./colord-C3iU53g-.js";
4
+ import "./hsv-BKcGyyrD.js";
5
+ import "./manipulate-C3CvrU4m.js";
6
+ import "./xyz-CXEZJhV8.js";
7
+ import "./lab-B5wAd4fu.js";
8
+ import "./get-D0jfz1WU.js";
9
9
 
10
10
  export { Colord, colord };
@@ -1,4 +1,4 @@
1
- import { o as rgbToLinearRgb } from "./rgb-CfVJB1Bj.js";
1
+ import { o as rgbToLinearRgb } from "./rgb-DNYno5F7.js";
2
2
 
3
3
  //#region src/shared/get.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { _ as ALPHA_PRECISION, c as round, i as isPresent, n as clampHue, t as clamp } from "./utils-BgIyY6bK.js";
1
+ import { i as isPresent, l as round, n as clampHue, t as clamp, v as ALPHA_PRECISION } from "./utils-DajWVr6Z.js";
2
2
 
3
3
  //#region src/models/hsv.ts
4
4
  const clampHsv = (hsv) => ({
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import "./utils-BgIyY6bK.js";
2
- import "./rgb-CfVJB1Bj.js";
3
- import { a as parsers, i as getFormat, n as colord, r as random, t as Colord } from "./colord-BV1k1-gC.js";
4
- import "./hsv-UWMaaOSN.js";
5
- import "./manipulate-CeAgrUd6.js";
6
- import "./xyz-MII3ndWO.js";
7
- import "./lab-CJHLdqfe.js";
8
- import "./get-BFaklfVd.js";
1
+ import "./utils-DajWVr6Z.js";
2
+ import "./rgb-DNYno5F7.js";
3
+ import { a as parsers, i as getFormat, n as colord, r as random, t as Colord } from "./colord-C3iU53g-.js";
4
+ import "./hsv-BKcGyyrD.js";
5
+ import "./manipulate-C3CvrU4m.js";
6
+ import "./xyz-CXEZJhV8.js";
7
+ import "./lab-B5wAd4fu.js";
8
+ import "./get-D0jfz1WU.js";
9
9
 
10
10
  //#region src/extend.ts
11
11
  const activePlugins = [];
@@ -1,5 +1,5 @@
1
- import { _ as ALPHA_PRECISION, a as mul3x3, c as round, i as isPresent, l as M_D50_TO_D65, o as parseAlpha, t as clamp, u as M_D65_TO_D50, v as D50 } from "./utils-BgIyY6bK.js";
2
- import { i as xyzToRgb, n as rgbToXyz } from "./xyz-MII3ndWO.js";
1
+ import { a as mul3x3, d as M_D65_TO_D50, i as isPresent, l as round, o as parseAlpha, t as clamp, u as M_D50_TO_D65, v as ALPHA_PRECISION, y as D50 } from "./utils-DajWVr6Z.js";
2
+ import { i as xyzToRgb, n as rgbToXyz } from "./xyz-CXEZJhV8.js";
3
3
 
4
4
  //#region src/models/lab.ts
5
5
  const EPSILON = 216 / 24389;
@@ -1,6 +1,6 @@
1
- import { _ as ALPHA_PRECISION, c as round, i as isPresent, n as clampHue, o as parseAlpha, s as parseHue, t as clamp } from "./utils-BgIyY6bK.js";
2
- import { r as rgbToHsv, t as hsvToRgb } from "./hsv-UWMaaOSN.js";
3
- import { a as rgbToLab, n as labToRgb, t as clampLab } from "./lab-CJHLdqfe.js";
1
+ import { i as isPresent, l as round, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "./utils-DajWVr6Z.js";
2
+ import { r as rgbToHsv, t as hsvToRgb } from "./hsv-BKcGyyrD.js";
3
+ import { a as rgbToLab, n as labToRgb, t as clampLab } from "./lab-B5wAd4fu.js";
4
4
 
5
5
  //#region src/models/hsl.ts
6
6
  const clampHsl = (hsl) => {
@@ -1,6 +1,6 @@
1
- import { c as round, r as floor } from "../utils-BgIyY6bK.js";
2
- import "../rgb-CfVJB1Bj.js";
3
- import { i as getLuminance, n as getContrast } from "../get-BFaklfVd.js";
1
+ import { l as round, r as floor } from "../utils-DajWVr6Z.js";
2
+ import "../rgb-DNYno5F7.js";
3
+ import { i as getLuminance, n as getContrast } from "../get-D0jfz1WU.js";
4
4
 
5
5
  //#region src/plugins/a11y.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { _ as ALPHA_PRECISION, c as round, i as isPresent, o as parseAlpha, t as clamp } from "../utils-BgIyY6bK.js";
1
+ import { i as isPresent, l as round, o as parseAlpha, t as clamp, v as ALPHA_PRECISION } from "../utils-DajWVr6Z.js";
2
2
 
3
3
  //#region src/models/cmyk.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { _ as ALPHA_PRECISION, c as round, i as isPresent, n as clampHue, o as parseAlpha, s as parseHue, t as clamp } from "../utils-BgIyY6bK.js";
2
- import { r as rgbToHsv, t as hsvToRgb } from "../hsv-UWMaaOSN.js";
1
+ import { i as isPresent, l as round, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "../utils-DajWVr6Z.js";
2
+ import { r as rgbToHsv, t as hsvToRgb } from "../hsv-BKcGyyrD.js";
3
3
 
4
4
  //#region src/models/hwb.ts
5
5
  const clampHwb = (hwb) => {
@@ -1,8 +1,8 @@
1
- import { c as round, t as clamp } from "../utils-BgIyY6bK.js";
2
- import "../rgb-CfVJB1Bj.js";
3
- import "../xyz-MII3ndWO.js";
4
- import { a as rgbToLab, i as parseLabString, o as roundLab, r as parseLab } from "../lab-CJHLdqfe.js";
5
- import { r as getDeltaE2000 } from "../get-BFaklfVd.js";
1
+ import { l as round, t as clamp } from "../utils-DajWVr6Z.js";
2
+ import "../rgb-DNYno5F7.js";
3
+ import "../xyz-CXEZJhV8.js";
4
+ import { a as rgbToLab, i as parseLabString, o as roundLab, r as parseLab } from "../lab-B5wAd4fu.js";
5
+ import { r as getDeltaE2000 } from "../get-D0jfz1WU.js";
6
6
 
7
7
  //#region src/plugins/lab.ts
8
8
  /**
@@ -1,7 +1,7 @@
1
- import { _ as ALPHA_PRECISION, c as round, i as isPresent, n as clampHue, o as parseAlpha, s as parseHue, t as clamp } from "../utils-BgIyY6bK.js";
2
- import "../rgb-CfVJB1Bj.js";
3
- import "../xyz-MII3ndWO.js";
4
- import { a as rgbToLab, n as labToRgb } from "../lab-CJHLdqfe.js";
1
+ import { i as isPresent, l as round, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "../utils-DajWVr6Z.js";
2
+ import "../rgb-DNYno5F7.js";
3
+ import "../xyz-CXEZJhV8.js";
4
+ import { a as rgbToLab, n as labToRgb } from "../lab-B5wAd4fu.js";
5
5
 
6
6
  //#region src/models/lch.ts
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { c as round } from "../utils-BgIyY6bK.js";
1
+ import { l as round } from "../utils-DajWVr6Z.js";
2
2
 
3
3
  //#region src/plugins/minify.ts
4
4
  /**
@@ -1,9 +1,9 @@
1
- import "../utils-BgIyY6bK.js";
2
- import "../rgb-CfVJB1Bj.js";
3
- import "../hsv-UWMaaOSN.js";
4
- import { i as mix } from "../manipulate-CeAgrUd6.js";
5
- import "../xyz-MII3ndWO.js";
6
- import "../lab-CJHLdqfe.js";
1
+ import "../utils-DajWVr6Z.js";
2
+ import "../rgb-DNYno5F7.js";
3
+ import "../hsv-BKcGyyrD.js";
4
+ import { i as mix } from "../manipulate-C3CvrU4m.js";
5
+ import "../xyz-CXEZJhV8.js";
6
+ import "../lab-B5wAd4fu.js";
7
7
 
8
8
  //#region src/plugins/mix.ts
9
9
  /**
@@ -1,5 +1,5 @@
1
- import { _ as ALPHA_PRECISION, a as mul3x3, c as round, g as OKLAB_M2_INV, h as OKLAB_M2, i as isPresent, m as OKLAB_M1_INV, o as parseAlpha, p as OKLAB_M1, t as clamp } from "../utils-BgIyY6bK.js";
2
- import { n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb, t as clampLinearRgb } from "../rgb-CfVJB1Bj.js";
1
+ import { _ as OKLAB_M2_INV, a as mul3x3, c as parseValueToDecimal, g as OKLAB_M2, h as OKLAB_M1_INV, i as isPresent, l as round, m as OKLAB_M1, o as parseAlpha, t as clamp, v as ALPHA_PRECISION } from "../utils-DajWVr6Z.js";
2
+ import { n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb, t as clampLinearRgb } from "../rgb-DNYno5F7.js";
3
3
 
4
4
  //#region src/models/oklab.ts
5
5
  const clampOklab = (oklab) => {
@@ -73,11 +73,9 @@ const oklabMatcher = /^oklab\(\s*([+-]?[\d.]+)%?\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)
73
73
  const parseOklabString = (input) => {
74
74
  const match = oklabMatcher.exec(input);
75
75
  if (!match) return null;
76
- const [_, L, a, b, alpha] = match;
77
- let l = Number.parseFloat(L);
78
- if (L.endsWith("%")) l /= 100;
76
+ const [_, l, a, b, alpha] = match;
79
77
  return oklabToRgb(clampOklab({
80
- l,
78
+ l: parseValueToDecimal(l),
81
79
  a: Number.parseFloat(a),
82
80
  b: Number.parseFloat(b),
83
81
  alpha: parseAlpha(alpha)
@@ -1,5 +1,5 @@
1
- import { _ as ALPHA_PRECISION, a as mul3x3, c as round, g as OKLAB_M2_INV, h as OKLAB_M2, i as isPresent, m as OKLAB_M1_INV, n as clampHue, o as parseAlpha, p as OKLAB_M1, s as parseHue, t as clamp } from "../utils-BgIyY6bK.js";
2
- import { n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb, t as clampLinearRgb } from "../rgb-CfVJB1Bj.js";
1
+ import { _ as OKLAB_M2_INV, a as mul3x3, c as parseValueToDecimal, g as OKLAB_M2, h as OKLAB_M1_INV, i as isPresent, l as round, m as OKLAB_M1, n as clampHue, o as parseAlpha, s as parseHue, t as clamp, v as ALPHA_PRECISION } from "../utils-DajWVr6Z.js";
2
+ import { n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb, t as clampLinearRgb } from "../rgb-DNYno5F7.js";
3
3
 
4
4
  //#region src/models/oklch.ts
5
5
  const clampOklch = (oklch) => {
@@ -82,11 +82,9 @@ const oklchMatcher = /^oklch\(\s*([+-]?[\d.]+)%?\s+([+-]?[\d.]+)\s+([+-]?[\d.]+)
82
82
  const parseOklchString = (input) => {
83
83
  const match = oklchMatcher.exec(input);
84
84
  if (!match) return null;
85
- const [_, L, c, h, unit, alpha] = match;
86
- let l = Number.parseFloat(L);
87
- if (L.endsWith("%")) l /= 100;
85
+ const [_, l, c, h, unit, alpha] = match;
88
86
  return oklchToRgb(clampOklch({
89
- l,
87
+ l: parseValueToDecimal(l),
90
88
  c: Number.parseFloat(c),
91
89
  h: parseHue(h, unit),
92
90
  alpha: parseAlpha(alpha)
@@ -94,7 +92,7 @@ const parseOklchString = (input) => {
94
92
  };
95
93
  const rgbToOklchString = (rgb) => {
96
94
  const { l, c, h, alpha } = roundOklch(rgbToOklch(rgb));
97
- return alpha < 1 ? `oklch(${l}% ${c} ${h} / ${alpha})` : `oklch(${l}% ${c} ${h})`;
95
+ return alpha < 1 ? `oklch(${l} ${c} ${h} / ${alpha})` : `oklch(${l} ${c} ${h})`;
98
96
  };
99
97
 
100
98
  //#endregion
@@ -1,6 +1,6 @@
1
- import "../utils-BgIyY6bK.js";
2
- import "../rgb-CfVJB1Bj.js";
3
- import { n as rgbToXyz, r as roundXyz, t as parseXyz } from "../xyz-MII3ndWO.js";
1
+ import "../utils-DajWVr6Z.js";
2
+ import "../rgb-DNYno5F7.js";
3
+ import { n as rgbToXyz, r as roundXyz, t as parseXyz } from "../xyz-CXEZJhV8.js";
4
4
 
5
5
  //#region src/plugins/xyz.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { _ as ALPHA_PRECISION, c as round, i as isPresent, o as parseAlpha, t as clamp } from "./utils-BgIyY6bK.js";
1
+ import { i as isPresent, l as round, o as parseAlpha, t as clamp, v as ALPHA_PRECISION } from "./utils-DajWVr6Z.js";
2
2
 
3
3
  //#region src/models/rgb.ts
4
4
  const clampRgb = (rgb) => {
@@ -224,6 +224,16 @@ function parseAlpha(alpha) {
224
224
  if (alpha.endsWith("%")) value /= 100;
225
225
  return value;
226
226
  }
227
+ /**
228
+ * parse value to decimal
229
+ * @param value
230
+ * @returns the decimal value in [0, 1]
231
+ */
232
+ function parseValueToDecimal(value) {
233
+ const num = Number.parseFloat(value);
234
+ if (value.endsWith("%") || num > 1) return clamp(num / 100);
235
+ return clamp(num);
236
+ }
227
237
 
228
238
  //#endregion
229
- export { ALPHA_PRECISION as _, mul3x3 as a, round as c, M_SRGB_TO_XYZ_D65 as d, M_XYZ_D65_TO_SRGB as f, OKLAB_M2_INV as g, OKLAB_M2 as h, isPresent as i, M_D50_TO_D65 as l, OKLAB_M1_INV as m, clampHue as n, parseAlpha as o, OKLAB_M1 as p, floor as r, parseHue as s, clamp as t, M_D65_TO_D50 as u, D50 as v };
239
+ export { OKLAB_M2_INV as _, mul3x3 as a, parseValueToDecimal as c, M_D65_TO_D50 as d, M_SRGB_TO_XYZ_D65 as f, OKLAB_M2 as g, OKLAB_M1_INV as h, isPresent as i, round as l, OKLAB_M1 as m, clampHue as n, parseAlpha as o, M_XYZ_D65_TO_SRGB as p, floor as r, parseHue as s, clamp as t, M_D50_TO_D65 as u, ALPHA_PRECISION as v, D50 as y };
@@ -1,5 +1,5 @@
1
- import { _ as ALPHA_PRECISION, a as mul3x3, c as round, d as M_SRGB_TO_XYZ_D65, f as M_XYZ_D65_TO_SRGB, i as isPresent, t as clamp, v as D50 } from "./utils-BgIyY6bK.js";
2
- import { n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb } from "./rgb-CfVJB1Bj.js";
1
+ import { a as mul3x3, f as M_SRGB_TO_XYZ_D65, i as isPresent, l as round, p as M_XYZ_D65_TO_SRGB, t as clamp, v as ALPHA_PRECISION, y as D50 } from "./utils-DajWVr6Z.js";
2
+ import { n as clampRgb, o as rgbToLinearRgb, r as linearRgbToRgb } from "./rgb-DNYno5F7.js";
3
3
 
4
4
  //#region src/models/xyz.ts
5
5
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soybeanjs/colord",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "description": "A tiny yet powerful tool for high-performance color manipulations and conversions",
6
6
  "author": {
7
7
  "name": "Soybean",