From 6df46af71f84c644d0d79204c9836dd24d2cd72c Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Wed, 29 Jan 2025 15:50:46 -0500 Subject: [PATCH 01/16] Update index.js --- test/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/index.js b/test/index.js index f4b77c7..4ed8d95 100644 --- a/test/index.js +++ b/test/index.js @@ -3,7 +3,6 @@ import assert from 'assert'; import almost from 'almost-equal'; import {suite} from 'uvu' - assert.almost = function (x, y, precision=1e-1) { if (!almost(x, y, precision)) assert.fail(x + ' ≈ ' + y); return true; @@ -793,4 +792,3 @@ let yesTest = suite('yes') assert.deepEqualAlmost(s.yes.rgb(s.rgb.yes([10,20,30])), [10,20,30]); }); yesTest.run() - From 7a9eb23663f1a4e61f8f2467233aed5966f4dcd3 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 19:43:17 -0500 Subject: [PATCH 02/16] Cleanup core files --- dist/color-space.d.ts | 2766 ------------------------------------- dist/color-space.d.ts.map | 1 - package.json | 4 +- tsconfig.json | 17 - 4 files changed, 1 insertion(+), 2787 deletions(-) delete mode 100644 dist/color-space.d.ts delete mode 100644 dist/color-space.d.ts.map delete mode 100644 tsconfig.json diff --git a/dist/color-space.d.ts b/dist/color-space.d.ts deleted file mode 100644 index 149e593..0000000 --- a/dist/color-space.d.ts +++ /dev/null @@ -1,2766 +0,0 @@ -// Generated by dts-bundle v0.7.3 -// Dependencies for this module: -// dist/color-space.d.ts -// mri -// uvu/parse - -export * from 'color-space/build/cmy'; -export * from 'color-space/build/cmyk'; -export * from 'color-space/build/coloroid'; -export * from 'color-space/build/cubehelix'; -export * from 'color-space/build/hcg'; -export * from 'color-space/build/hcy'; -export * from 'color-space/build/hpluv'; -export * from 'color-space/build/hsi'; -export * from 'color-space/build/hsl'; -export * from 'color-space/build/hsluv'; -export * from 'color-space/build/hsp'; -export * from 'color-space/build/hsv'; -export * from 'color-space/build/hwb'; -export * from 'color-space/build/index'; -export * from 'color-space/build/jpeg'; -export * from 'color-space/build/lab'; -export * from 'color-space/build/labh'; -export * from 'color-space/build/lchab'; -export * from 'color-space/build/lchuv'; -export * from 'color-space/build/lms'; -export * from 'color-space/build/luv'; -export * from 'color-space/build/osaucs'; -export * from 'color-space/build/rgb'; -export * from 'color-space/build/tsl'; -export * from 'color-space/build/ucs'; -export * from 'color-space/build/uvw'; -export * from 'color-space/build/xvycc'; -export * from 'color-space/build/xyy'; -export * from 'color-space/build/xyz'; -export * from 'color-space/build/ycbcr'; -export * from 'color-space/build/yccbccrc'; -export * from 'color-space/build/ycgco'; -export * from 'color-space/build/ydbdr'; -export * from 'color-space/build/yes'; -export * from 'color-space/build/yiq'; -export * from 'color-space/build/ypbpr'; -export * from 'color-space/build/yuv'; -export * from 'color-space/dist/color-space'; -export * from 'color-space/node_modules/dequal/index'; -export * from 'color-space/node_modules/dequal/lite/index'; -export * from 'color-space/node_modules/esbuild/lib/main'; -export * from 'color-space/node_modules/kleur/colors'; -export * from 'color-space/node_modules/kleur/index'; -export * from 'color-space/node_modules/mri/index'; -export * from 'color-space/node_modules/sade/index'; -export * from 'color-space/node_modules/uvu/assert/index'; -export * from 'color-space/node_modules/uvu/diff/index'; -export * from 'color-space/node_modules/uvu/index'; -export * from 'color-space/node_modules/uvu/parse/index'; -export * from 'color-space/node_modules/uvu/run/index'; - -declare module 'color-space/build/cmy' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/cmyk' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/coloroid' { - const _default: import("./index.js").ColorSpace & ColoroidSpecific; - export default _default; - export type ColoroidSpecific = { - table: Array>; - }; -} - -declare module 'color-space/build/cubehelix' { - const _default: import("./index.js").ColorSpace & CubeHelixSpecific; - export default _default; - export type CubeHelixSpecific = { - defaults: { - start: number; - rotation: number; - hue: number; - gamma: number; - }; - }; -} - -declare module 'color-space/build/hcg' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hcy' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hpluv' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hsi' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hsl' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hsluv' { - export namespace _hsluv { - export { Q as hsluvToRgb }; - export { H as hsluvToLch }; - export { R as rgbToHsluv }; - export { T as rgbToHpluv }; - export { u as rgbToXyz }; - export { P as rgbToLch }; - export { S as hpluvToRgb }; - export { J as hpluvToLch }; - export { K as lchToHpluv }; - export { I as lchToHsluv }; - export { G as lchToLuv }; - export { O as lchToRgb }; - export { F as luvToLch }; - export { E as luvToXyz }; - export { A as xyzToLuv }; - export { t as xyzToRgb }; - } - const _default: import("./index.js").ColorSpace & HSLuvSpecific; - export default _default; - export type HSLuvSpecific = { - _hsluv: { - [x: string]: import("./index.js").Transform; - }; - }; - function Q(a: any): number[]; - function H(a: any): any[]; - function R(a: any): any[]; - function T(a: any): any[]; - function u(a: any): number[]; - function P(a: any): any[]; - function S(a: any): number[]; - function J(a: any): any[]; - function K(a: any): any[]; - function I(a: any): any[]; - function G(a: any): any[]; - function O(a: any): number[]; - function F(a: any): any[]; - function E(a: any): any[]; - function A(a: any): any[]; - function t(a: any): number[]; -} - -declare module 'color-space/build/hsp' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hsv' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/hwb' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/index' { - /** - * @param {ColorSpace} newSpace - */ - export function register(newSpace: ColorSpace): void; - export default spaces; - export type SpaceId = "rgb" | "xyz" | "hsl" | "hsv" | "hsi" | "hwb" | "cmyk" | "cmy" | "xyy" | "yiq" | "yuv" | "ydbdr" | "ycgco" | "ypbpr" | "ycbcr" | "xvycc" | "yccbccrc" | "ucs" | "uvw" | "jpeg" | "lab" | "labh" | "lms" | "lchab" | "luv" | "lchuv" | "hsluv" | "hpluv" | "cubehelix" | "coloroid" | "hcg" | "hcy" | "tsl" | "yes" | "osaucs" | "hsp"; - export type Transform = (color: Array, ...rest: Array) => Array; - export type ColorSpaceTransforms = { [key in SpaceId]: Transform; }; - export type ColorSpaceBase = { - name: SpaceId; - min: Array; - max: Array; - channel: Array; - alias?: string[] | undefined; - }; - export type ColorSpace = ColorSpaceBase & ColorSpaceTransforms; - /** @typedef {ColorSpaceBase & ColorSpaceTransforms} ColorSpace */ - const spaces: { [key in SpaceId]: ColorSpace; }; -} - -declare module 'color-space/build/jpeg' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/lab' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/labh' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/lchab' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/lchuv' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/lms' { - const _default: import("./index.js").ColorSpace & LMSSpecific; - export default _default; - export type LMSSpecific = { - matrix: { - [x: string]: Array; - }; - }; -} - -declare module 'color-space/build/luv' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/osaucs' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/rgb' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/tsl' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/ucs' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/uvw' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/xvycc' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/xyy' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/xyz' { - const _default: import("./index.js").ColorSpace & XYZSpecific; - export default _default; - export type XYZSpecific = { - whitepoint: { - [x: number]: { - [x: string]: Array; - }; - }; - }; -} - -declare module 'color-space/build/ycbcr' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/yccbccrc' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/ycgco' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/ydbdr' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/yes' { - const _default: import("./index.js").ColorSpace; - export default _default; -} - -declare module 'color-space/build/yiq' { - export default yiq; - var yiq: import("./index.js").ColorSpace; -} - -declare module 'color-space/build/ypbpr' { - export default ypbpr; - var ypbpr: import("./index.js").ColorSpace; -} - -declare module 'color-space/build/yuv' { - export default yuv; - var yuv: import("./index.js").ColorSpace; -} - -declare module 'color-space/dist/color-space' { - - export * from 'color-space/build/cmy'; - export * from 'color-space/build/cmyk'; - export * from 'color-space/build/coloroid'; - export * from 'color-space/build/cubehelix'; - export * from 'color-space/build/hcg'; - export * from 'color-space/build/hcy'; - export * from 'color-space/build/hpluv'; - export * from 'color-space/build/hsi'; - export * from 'color-space/build/hsl'; - export * from 'color-space/build/hsluv'; - export * from 'color-space/build/hsp'; - export * from 'color-space/build/hsv'; - export * from 'color-space/build/hwb'; - export * from 'color-space/build/index'; - export * from 'color-space/build/jpeg'; - export * from 'color-space/build/lab'; - export * from 'color-space/build/labh'; - export * from 'color-space/build/lchab'; - export * from 'color-space/build/lchuv'; - export * from 'color-space/build/lms'; - export * from 'color-space/build/luv'; - export * from 'color-space/build/osaucs'; - export * from 'color-space/build/rgb'; - export * from 'color-space/build/tsl'; - export * from 'color-space/build/ucs'; - export * from 'color-space/build/uvw'; - export * from 'color-space/build/xvycc'; - export * from 'color-space/build/xyy'; - export * from 'color-space/build/xyz'; - export * from 'color-space/build/ycbcr'; - export * from 'color-space/build/yccbccrc'; - export * from 'color-space/build/ycgco'; - export * from 'color-space/build/ydbdr'; - export * from 'color-space/build/yes'; - export * from 'color-space/build/yiq'; - export * from 'color-space/build/ypbpr'; - export * from 'color-space/build/yuv'; - export * from 'color-space/dist/color-space'; - export * from 'color-space/node_modules/dequal/index'; - export * from 'color-space/node_modules/dequal/lite/index'; - export * from 'color-space/node_modules/esbuild/lib/main'; - export * from 'color-space/node_modules/kleur/colors'; - export * from 'color-space/node_modules/kleur/index'; - export * from 'color-space/node_modules/mri/index'; - export * from 'color-space/node_modules/sade/index'; - export * from 'color-space/node_modules/uvu/assert/index'; - export * from 'color-space/node_modules/uvu/diff/index'; - export * from 'color-space/node_modules/uvu/index'; - export * from 'color-space/node_modules/uvu/parse/index'; - export * from 'color-space/node_modules/uvu/run/index'; - - declare module 'color-space/build/cmy' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/cmyk' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/coloroid' { - const _default: import("./index.js").ColorSpace & ColoroidSpecific; - export default _default; - export type ColoroidSpecific = { - table: Array>; - }; - } - - declare module 'color-space/build/cubehelix' { - const _default: import("./index.js").ColorSpace & CubeHelixSpecific; - export default _default; - export type CubeHelixSpecific = { - defaults: { - start: number; - rotation: number; - hue: number; - gamma: number; - }; - }; - } - - declare module 'color-space/build/hcg' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hcy' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hpluv' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hsi' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hsl' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hsluv' { - export namespace _hsluv { - export { Q as hsluvToRgb }; - export { H as hsluvToLch }; - export { R as rgbToHsluv }; - export { T as rgbToHpluv }; - export { u as rgbToXyz }; - export { P as rgbToLch }; - export { S as hpluvToRgb }; - export { J as hpluvToLch }; - export { K as lchToHpluv }; - export { I as lchToHsluv }; - export { G as lchToLuv }; - export { O as lchToRgb }; - export { F as luvToLch }; - export { E as luvToXyz }; - export { A as xyzToLuv }; - export { t as xyzToRgb }; - } - const _default: import("./index.js").ColorSpace & HSLuvSpecific; - export default _default; - export type HSLuvSpecific = { - _hsluv: { - [x: string]: import("./index.js").Transform; - }; - }; - function Q(a: any): number[]; - function H(a: any): any[]; - function R(a: any): any[]; - function T(a: any): any[]; - function u(a: any): number[]; - function P(a: any): any[]; - function S(a: any): number[]; - function J(a: any): any[]; - function K(a: any): any[]; - function I(a: any): any[]; - function G(a: any): any[]; - function O(a: any): number[]; - function F(a: any): any[]; - function E(a: any): any[]; - function A(a: any): any[]; - function t(a: any): number[]; - } - - declare module 'color-space/build/hsp' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hsv' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/hwb' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/index' { - /** - * @param {ColorSpace} newSpace - */ - export function register(newSpace: ColorSpace): void; - export default spaces; - export type SpaceId = "rgb" | "xyz" | "hsl" | "hsv" | "hsi" | "hwb" | "cmyk" | "cmy" | "xyy" | "yiq" | "yuv" | "ydbdr" | "ycgco" | "ypbpr" | "ycbcr" | "xvycc" | "yccbccrc" | "ucs" | "uvw" | "jpeg" | "lab" | "labh" | "lms" | "lchab" | "luv" | "lchuv" | "hsluv" | "hpluv" | "cubehelix" | "coloroid" | "hcg" | "hcy" | "tsl" | "yes" | "osaucs" | "hsp"; - export type Transform = (color: Array, ...rest: Array) => Array; - export type ColorSpaceTransforms = { [key in SpaceId]: Transform; }; - export type ColorSpaceBase = { - name: SpaceId; - min: Array; - max: Array; - channel: Array; - alias?: string[] | undefined; - }; - export type ColorSpace = ColorSpaceBase & ColorSpaceTransforms; - /** @typedef {ColorSpaceBase & ColorSpaceTransforms} ColorSpace */ - const spaces: { [key in SpaceId]: ColorSpace; }; - } - - declare module 'color-space/build/jpeg' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/lab' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/labh' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/lchab' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/lchuv' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/lms' { - const _default: import("./index.js").ColorSpace & LMSSpecific; - export default _default; - export type LMSSpecific = { - matrix: { - [x: string]: Array; - }; - }; - } - - declare module 'color-space/build/luv' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/osaucs' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/rgb' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/tsl' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/ucs' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/uvw' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/xvycc' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/xyy' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/xyz' { - const _default: import("./index.js").ColorSpace & XYZSpecific; - export default _default; - export type XYZSpecific = { - whitepoint: { - [x: number]: { - [x: string]: Array; - }; - }; - }; - } - - declare module 'color-space/build/ycbcr' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/yccbccrc' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/ycgco' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/ydbdr' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/yes' { - const _default: import("./index.js").ColorSpace; - export default _default; - } - - declare module 'color-space/build/yiq' { - export default yiq; - var yiq: import("./index.js").ColorSpace; - } - - declare module 'color-space/build/ypbpr' { - export default ypbpr; - var ypbpr: import("./index.js").ColorSpace; - } - - declare module 'color-space/build/yuv' { - export default yuv; - var yuv: import("./index.js").ColorSpace; - } - - declare module 'color-space/dist/color-space' { - declare module "color-space/dts-bundle.tmp.color-space//rgb" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hsl" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hsv" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hsi" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hwb" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//cmyk" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//cmy" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//xyz" { - const _default: import("index").ColorSpace & XYZSpecific; - export default _default; - export type XYZSpecific = { - whitepoint: { - [x: number]: { - [x: string]: Array; - }; - }; - }; - } - declare module "color-space/dts-bundle.tmp.color-space//xyy" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//yiq" { - export default yiq; - var yiq: import("index").ColorSpace; - } - declare module "color-space/dts-bundle.tmp.color-space//yuv" { - export default yuv; - var yuv: import("index").ColorSpace; - } - declare module "color-space/dts-bundle.tmp.color-space//ydbdr" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//ycgco" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//ypbpr" { - export default ypbpr; - var ypbpr: import("index").ColorSpace; - } - declare module "color-space/dts-bundle.tmp.color-space//ycbcr" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//xvycc" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//yccbccrc" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//ucs" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//uvw" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//jpeg" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//lab" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//labh" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//lms" { - const _default: import("index").ColorSpace & LMSSpecific; - export default _default; - export type LMSSpecific = { - matrix: { - [x: string]: Array; - }; - }; - } - declare module "color-space/dts-bundle.tmp.color-space//lchab" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//luv" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//lchuv" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hsluv" { - export namespace _hsluv { - export { Q as hsluvToRgb }; - export { H as hsluvToLch }; - export { R as rgbToHsluv }; - export { T as rgbToHpluv }; - export { u as rgbToXyz }; - export { P as rgbToLch }; - export { S as hpluvToRgb }; - export { J as hpluvToLch }; - export { K as lchToHpluv }; - export { I as lchToHsluv }; - export { G as lchToLuv }; - export { O as lchToRgb }; - export { F as luvToLch }; - export { E as luvToXyz }; - export { A as xyzToLuv }; - export { t as xyzToRgb }; - } - const _default: import("index").ColorSpace & HSLuvSpecific; - export default _default; - export type HSLuvSpecific = { - _hsluv: { - [x: string]: import("index").Transform; - }; - }; - function Q(a: any): number[]; - function H(a: any): any[]; - function R(a: any): any[]; - function T(a: any): any[]; - function u(a: any): number[]; - function P(a: any): any[]; - function S(a: any): number[]; - function J(a: any): any[]; - function K(a: any): any[]; - function I(a: any): any[]; - function G(a: any): any[]; - function O(a: any): number[]; - function F(a: any): any[]; - function E(a: any): any[]; - function A(a: any): any[]; - function t(a: any): number[]; - } - declare module "color-space/dts-bundle.tmp.color-space//hpluv" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//cubehelix" { - const _default: import("index").ColorSpace & CubeHelixSpecific; - export default _default; - export type CubeHelixSpecific = { - defaults: { - start: number; - rotation: number; - hue: number; - gamma: number; - }; - }; - } - declare module "color-space/dts-bundle.tmp.color-space//coloroid" { - const _default: import("index").ColorSpace & ColoroidSpecific; - export default _default; - export type ColoroidSpecific = { - table: Array>; - }; - } - declare module "color-space/dts-bundle.tmp.color-space//hcg" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hcy" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//tsl" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//yes" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//osaucs" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//hsp" { - const _default: import("index").ColorSpace; - export default _default; - } - declare module "color-space/dts-bundle.tmp.color-space//index" { - /** - * @param {ColorSpace} newSpace - */ - export function register(newSpace: ColorSpace): void; - export default spaces; - export type SpaceId = "rgb" | "xyz" | "hsl" | "hsv" | "hsi" | "hwb" | "cmyk" | "cmy" | "xyy" | "yiq" | "yuv" | "ydbdr" | "ycgco" | "ypbpr" | "ycbcr" | "xvycc" | "yccbccrc" | "ucs" | "uvw" | "jpeg" | "lab" | "labh" | "lms" | "lchab" | "luv" | "lchuv" | "hsluv" | "hpluv" | "cubehelix" | "coloroid" | "hcg" | "hcy" | "tsl" | "yes" | "osaucs" | "hsp"; - export type Transform = (color: Array, ...rest: Array) => Array; - export type ColorSpaceTransforms = { [key in SpaceId]: Transform; }; - export type ColorSpaceBase = { - name: SpaceId; - min: Array; - max: Array; - channel: Array; - alias?: string[] | undefined; - }; - export type ColorSpace = ColorSpaceBase & ColorSpaceTransforms; - /** @typedef {ColorSpaceBase & ColorSpaceTransforms} ColorSpace */ - const spaces: { [key in SpaceId]: ColorSpace; }; - } - } - - declare module 'color-space/node_modules/dequal/index' { - export function dequal(foo: any, bar: any): boolean; - } - - declare module 'color-space/node_modules/dequal/lite/index' { - export function dequal(foo: any, bar: any): boolean; - } - - declare module 'color-space/node_modules/esbuild/lib/main' { - export type Platform = 'browser' | 'node' | 'neutral' - export type Format = 'iife' | 'cjs' | 'esm' - export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx' - export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent' - export type Charset = 'ascii' | 'utf8' - export type Drop = 'console' | 'debugger' - - interface CommonOptions { - /** Documentation: https://esbuild.github.io/api/#sourcemap */ - sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both' - /** Documentation: https://esbuild.github.io/api/#legal-comments */ - legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external' - /** Documentation: https://esbuild.github.io/api/#source-root */ - sourceRoot?: string - /** Documentation: https://esbuild.github.io/api/#sources-content */ - sourcesContent?: boolean - - /** Documentation: https://esbuild.github.io/api/#format */ - format?: Format - /** Documentation: https://esbuild.github.io/api/#global-name */ - globalName?: string - /** Documentation: https://esbuild.github.io/api/#target */ - target?: string | string[] - /** Documentation: https://esbuild.github.io/api/#supported */ - supported?: Record - /** Documentation: https://esbuild.github.io/api/#platform */ - platform?: Platform - - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - mangleProps?: RegExp - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - reserveProps?: RegExp - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - mangleQuoted?: boolean - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - mangleCache?: Record - /** Documentation: https://esbuild.github.io/api/#drop */ - drop?: Drop[] - /** Documentation: https://esbuild.github.io/api/#drop-labels */ - dropLabels?: string[] - /** Documentation: https://esbuild.github.io/api/#minify */ - minify?: boolean - /** Documentation: https://esbuild.github.io/api/#minify */ - minifyWhitespace?: boolean - /** Documentation: https://esbuild.github.io/api/#minify */ - minifyIdentifiers?: boolean - /** Documentation: https://esbuild.github.io/api/#minify */ - minifySyntax?: boolean - /** Documentation: https://esbuild.github.io/api/#line-limit */ - lineLimit?: number - /** Documentation: https://esbuild.github.io/api/#charset */ - charset?: Charset - /** Documentation: https://esbuild.github.io/api/#tree-shaking */ - treeShaking?: boolean - /** Documentation: https://esbuild.github.io/api/#ignore-annotations */ - ignoreAnnotations?: boolean - - /** Documentation: https://esbuild.github.io/api/#jsx */ - jsx?: 'transform' | 'preserve' | 'automatic' - /** Documentation: https://esbuild.github.io/api/#jsx-factory */ - jsxFactory?: string - /** Documentation: https://esbuild.github.io/api/#jsx-fragment */ - jsxFragment?: string - /** Documentation: https://esbuild.github.io/api/#jsx-import-source */ - jsxImportSource?: string - /** Documentation: https://esbuild.github.io/api/#jsx-development */ - jsxDev?: boolean - /** Documentation: https://esbuild.github.io/api/#jsx-side-effects */ - jsxSideEffects?: boolean - - /** Documentation: https://esbuild.github.io/api/#define */ - define?: { [key: string]: string } - /** Documentation: https://esbuild.github.io/api/#pure */ - pure?: string[] - /** Documentation: https://esbuild.github.io/api/#keep-names */ - keepNames?: boolean - - /** Documentation: https://esbuild.github.io/api/#color */ - color?: boolean - /** Documentation: https://esbuild.github.io/api/#log-level */ - logLevel?: LogLevel - /** Documentation: https://esbuild.github.io/api/#log-limit */ - logLimit?: number - /** Documentation: https://esbuild.github.io/api/#log-override */ - logOverride?: Record - - /** Documentation: https://esbuild.github.io/api/#tsconfig-raw */ - tsconfigRaw?: string | TsconfigRaw - } - - export interface TsconfigRaw { - compilerOptions?: { - alwaysStrict?: boolean - baseUrl?: string - experimentalDecorators?: boolean - importsNotUsedAsValues?: 'remove' | 'preserve' | 'error' - jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev' - jsxFactory?: string - jsxFragmentFactory?: string - jsxImportSource?: string - paths?: Record - preserveValueImports?: boolean - strict?: boolean - target?: string - useDefineForClassFields?: boolean - verbatimModuleSyntax?: boolean - } - } - - export interface BuildOptions extends CommonOptions { - /** Documentation: https://esbuild.github.io/api/#bundle */ - bundle?: boolean - /** Documentation: https://esbuild.github.io/api/#splitting */ - splitting?: boolean - /** Documentation: https://esbuild.github.io/api/#preserve-symlinks */ - preserveSymlinks?: boolean - /** Documentation: https://esbuild.github.io/api/#outfile */ - outfile?: string - /** Documentation: https://esbuild.github.io/api/#metafile */ - metafile?: boolean - /** Documentation: https://esbuild.github.io/api/#outdir */ - outdir?: string - /** Documentation: https://esbuild.github.io/api/#outbase */ - outbase?: string - /** Documentation: https://esbuild.github.io/api/#external */ - external?: string[] - /** Documentation: https://esbuild.github.io/api/#packages */ - packages?: 'bundle' | 'external' - /** Documentation: https://esbuild.github.io/api/#alias */ - alias?: Record - /** Documentation: https://esbuild.github.io/api/#loader */ - loader?: { [ext: string]: Loader } - /** Documentation: https://esbuild.github.io/api/#resolve-extensions */ - resolveExtensions?: string[] - /** Documentation: https://esbuild.github.io/api/#main-fields */ - mainFields?: string[] - /** Documentation: https://esbuild.github.io/api/#conditions */ - conditions?: string[] - /** Documentation: https://esbuild.github.io/api/#write */ - write?: boolean - /** Documentation: https://esbuild.github.io/api/#allow-overwrite */ - allowOverwrite?: boolean - /** Documentation: https://esbuild.github.io/api/#tsconfig */ - tsconfig?: string - /** Documentation: https://esbuild.github.io/api/#out-extension */ - outExtension?: { [ext: string]: string } - /** Documentation: https://esbuild.github.io/api/#public-path */ - publicPath?: string - /** Documentation: https://esbuild.github.io/api/#entry-names */ - entryNames?: string - /** Documentation: https://esbuild.github.io/api/#chunk-names */ - chunkNames?: string - /** Documentation: https://esbuild.github.io/api/#asset-names */ - assetNames?: string - /** Documentation: https://esbuild.github.io/api/#inject */ - inject?: string[] - /** Documentation: https://esbuild.github.io/api/#banner */ - banner?: { [type: string]: string } - /** Documentation: https://esbuild.github.io/api/#footer */ - footer?: { [type: string]: string } - /** Documentation: https://esbuild.github.io/api/#entry-points */ - entryPoints?: string[] | Record | { in: string, out: string }[] - /** Documentation: https://esbuild.github.io/api/#stdin */ - stdin?: StdinOptions - /** Documentation: https://esbuild.github.io/plugins/ */ - plugins?: Plugin[] - /** Documentation: https://esbuild.github.io/api/#working-directory */ - absWorkingDir?: string - /** Documentation: https://esbuild.github.io/api/#node-paths */ - nodePaths?: string[]; // The "NODE_PATH" variable from Node.js - } - - export interface StdinOptions { - contents: string | Uint8Array - resolveDir?: string - sourcefile?: string - loader?: Loader - } - - export interface Message { - id: string - pluginName: string - text: string - location: Location | null - notes: Note[] - - /** - * Optional user-specified data that is passed through unmodified. You can - * use this to stash the original error, for example. - */ - detail: any - } - - export interface Note { - text: string - location: Location | null - } - - export interface Location { - file: string - namespace: string - /** 1-based */ - line: number - /** 0-based, in bytes */ - column: number - /** in bytes */ - length: number - lineText: string - suggestion: string - } - - export interface OutputFile { - path: string - contents: Uint8Array - hash: string - /** "contents" as text (changes automatically with "contents") */ - readonly text: string - } - - export interface BuildResult { - errors: Message[] - warnings: Message[] - /** Only when "write: false" */ - outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined) - /** Only when "metafile: true" */ - metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined) - /** Only when "mangleCache" is present */ - mangleCache: Record | (ProvidedOptions['mangleCache'] extends Object ? never : undefined) - } - - export interface BuildFailure extends Error { - errors: Message[] - warnings: Message[] - } - - /** Documentation: https://esbuild.github.io/api/#serve-arguments */ - export interface ServeOptions { - port?: number - host?: string - servedir?: string - keyfile?: string - certfile?: string - fallback?: string - onRequest?: (args: ServeOnRequestArgs) => void - } - - export interface ServeOnRequestArgs { - remoteAddress: string - method: string - path: string - status: number - /** The time to generate the response, not to send it */ - timeInMS: number - } - - /** Documentation: https://esbuild.github.io/api/#serve-return-values */ - export interface ServeResult { - port: number - host: string - } - - export interface TransformOptions extends CommonOptions { - /** Documentation: https://esbuild.github.io/api/#sourcefile */ - sourcefile?: string - /** Documentation: https://esbuild.github.io/api/#loader */ - loader?: Loader - /** Documentation: https://esbuild.github.io/api/#banner */ - banner?: string - /** Documentation: https://esbuild.github.io/api/#footer */ - footer?: string - } - - export interface TransformResult { - code: string - map: string - warnings: Message[] - /** Only when "mangleCache" is present */ - mangleCache: Record | (ProvidedOptions['mangleCache'] extends Object ? never : undefined) - /** Only when "legalComments" is "external" */ - legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined) - } - - export interface TransformFailure extends Error { - errors: Message[] - warnings: Message[] - } - - export interface Plugin { - name: string - setup: (build: PluginBuild) => (void | Promise) - } - - export interface PluginBuild { - /** Documentation: https://esbuild.github.io/plugins/#build-options */ - initialOptions: BuildOptions - - /** Documentation: https://esbuild.github.io/plugins/#resolve */ - resolve(path: string, options?: ResolveOptions): Promise - - /** Documentation: https://esbuild.github.io/plugins/#on-start */ - onStart(callback: () => - (OnStartResult | null | void | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-end */ - onEnd(callback: (result: BuildResult) => - (OnEndResult | null | void | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve */ - onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) => - (OnResolveResult | null | undefined | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-load */ - onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) => - (OnLoadResult | null | undefined | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-dispose */ - onDispose(callback: () => void): void - - // This is a full copy of the esbuild library in case you need it - esbuild: { - context: typeof context, - build: typeof build, - buildSync: typeof buildSync, - transform: typeof transform, - transformSync: typeof transformSync, - formatMessages: typeof formatMessages, - formatMessagesSync: typeof formatMessagesSync, - analyzeMetafile: typeof analyzeMetafile, - analyzeMetafileSync: typeof analyzeMetafileSync, - initialize: typeof initialize, - version: typeof version, - } - } - - /** Documentation: https://esbuild.github.io/plugins/#resolve-options */ - export interface ResolveOptions { - pluginName?: string - importer?: string - namespace?: string - resolveDir?: string - kind?: ImportKind - pluginData?: any - with?: Record - } - - /** Documentation: https://esbuild.github.io/plugins/#resolve-results */ - export interface ResolveResult { - errors: Message[] - warnings: Message[] - - path: string - external: boolean - sideEffects: boolean - namespace: string - suffix: string - pluginData: any - } - - export interface OnStartResult { - errors?: PartialMessage[] - warnings?: PartialMessage[] - } - - export interface OnEndResult { - errors?: PartialMessage[] - warnings?: PartialMessage[] - } - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */ - export interface OnResolveOptions { - filter: RegExp - namespace?: string - } - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */ - export interface OnResolveArgs { - path: string - importer: string - namespace: string - resolveDir: string - kind: ImportKind - pluginData: any - with: Record - } - - export type ImportKind = - | 'entry-point' - - // JS - | 'import-statement' - | 'require-call' - | 'dynamic-import' - | 'require-resolve' - - // CSS - | 'import-rule' - | 'composes-from' - | 'url-token' - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */ - export interface OnResolveResult { - pluginName?: string - - errors?: PartialMessage[] - warnings?: PartialMessage[] - - path?: string - external?: boolean - sideEffects?: boolean - namespace?: string - suffix?: string - pluginData?: any - - watchFiles?: string[] - watchDirs?: string[] - } - - /** Documentation: https://esbuild.github.io/plugins/#on-load-options */ - export interface OnLoadOptions { - filter: RegExp - namespace?: string - } - - /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */ - export interface OnLoadArgs { - path: string - namespace: string - suffix: string - pluginData: any - with: Record - } - - /** Documentation: https://esbuild.github.io/plugins/#on-load-results */ - export interface OnLoadResult { - pluginName?: string - - errors?: PartialMessage[] - warnings?: PartialMessage[] - - contents?: string | Uint8Array - resolveDir?: string - loader?: Loader - pluginData?: any - - watchFiles?: string[] - watchDirs?: string[] - } - - export interface PartialMessage { - id?: string - pluginName?: string - text?: string - location?: Partial | null - notes?: PartialNote[] - detail?: any - } - - export interface PartialNote { - text?: string - location?: Partial | null - } - - /** Documentation: https://esbuild.github.io/api/#metafile */ - export interface Metafile { - inputs: { - [path: string]: { - bytes: number - imports: { - path: string - kind: ImportKind - external?: boolean - original?: string - with?: Record - }[] - format?: 'cjs' | 'esm' - with?: Record - } - } - outputs: { - [path: string]: { - bytes: number - inputs: { - [path: string]: { - bytesInOutput: number - } - } - imports: { - path: string - kind: ImportKind | 'file-loader' - external?: boolean - }[] - exports: string[] - entryPoint?: string - cssBundle?: string - } - } - } - - export interface FormatMessagesOptions { - kind: 'error' | 'warning' - color?: boolean - terminalWidth?: number - } - - export interface AnalyzeMetafileOptions { - color?: boolean - verbose?: boolean - } - - export interface WatchOptions { - } - - export interface BuildContext { - /** Documentation: https://esbuild.github.io/api/#rebuild */ - rebuild(): Promise> - - /** Documentation: https://esbuild.github.io/api/#watch */ - watch(options?: WatchOptions): Promise - - /** Documentation: https://esbuild.github.io/api/#serve */ - serve(options?: ServeOptions): Promise - - cancel(): Promise - dispose(): Promise - } - - type SameShape = In & { [Key in Exclude]: never } - - /** - * This function invokes the "esbuild" command-line tool for you. It returns a - * promise that either resolves with a "BuildResult" object or rejects with a - * "BuildFailure" object. - * - * - Works in node: yes - * - Works in browser: yes - * - * Documentation: https://esbuild.github.io/api/#build - */ - export function build(options: SameShape): Promise> - - /** - * This is the advanced long-running form of "build" that supports additional - * features such as watch mode and a local development server. - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#build - */ - export function context(options: SameShape): Promise> - - /** - * This function transforms a single JavaScript file. It can be used to minify - * JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript - * to older JavaScript. It returns a promise that is either resolved with a - * "TransformResult" object or rejected with a "TransformFailure" object. - * - * - Works in node: yes - * - Works in browser: yes - * - * Documentation: https://esbuild.github.io/api/#transform - */ - export function transform(input: string | Uint8Array, options?: SameShape): Promise> - - /** - * Converts log messages to formatted message strings suitable for printing in - * the terminal. This allows you to reuse the built-in behavior of esbuild's - * log message formatter. This is a batch-oriented API for efficiency. - * - * - Works in node: yes - * - Works in browser: yes - */ - export function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise - - /** - * Pretty-prints an analysis of the metafile JSON to a string. This is just for - * convenience to be able to match esbuild's pretty-printing exactly. If you want - * to customize it, you can just inspect the data in the metafile yourself. - * - * - Works in node: yes - * - Works in browser: yes - * - * Documentation: https://esbuild.github.io/api/#analyze - */ - export function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise - - /** - * A synchronous version of "build". - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#build - */ - export function buildSync(options: SameShape): BuildResult - - /** - * A synchronous version of "transform". - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#transform - */ - export function transformSync(input: string | Uint8Array, options?: SameShape): TransformResult - - /** - * A synchronous version of "formatMessages". - * - * - Works in node: yes - * - Works in browser: no - */ - export function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[] - - /** - * A synchronous version of "analyzeMetafile". - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#analyze - */ - export function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string - - /** - * This configures the browser-based version of esbuild. It is necessary to - * call this first and wait for the returned promise to be resolved before - * making other API calls when using esbuild in the browser. - * - * - Works in node: yes - * - Works in browser: yes ("options" is required) - * - * Documentation: https://esbuild.github.io/api/#browser - */ - export function initialize(options: InitializeOptions): Promise - - export interface InitializeOptions { - /** - * The URL of the "esbuild.wasm" file. This must be provided when running - * esbuild in the browser. - */ - wasmURL?: string | URL - - /** - * The result of calling "new WebAssembly.Module(buffer)" where "buffer" - * is a typed array or ArrayBuffer containing the binary code of the - * "esbuild.wasm" file. - * - * You can use this as an alternative to "wasmURL" for environments where it's - * not possible to download the WebAssembly module. - */ - wasmModule?: WebAssembly.Module - - /** - * By default esbuild runs the WebAssembly-based browser API in a web worker - * to avoid blocking the UI thread. This can be disabled by setting "worker" - * to false. - */ - worker?: boolean - } - - export let version: string - - export function stop(): Promise - - global { - namespace WebAssembly { - interface Module { - } - } - interface URL { - } - } - } - - declare module 'color-space/node_modules/kleur/colors' { - function print(input: string | boolean | number): string; - function print(input: undefined | void): undefined; - function print(input: null): null; - type Colorize = typeof print; - - export const $: { enabled: boolean }; - - export const black: Colorize; - export const red: Colorize; - export const green: Colorize; - export const yellow: Colorize; - export const blue: Colorize; - export const magenta: Colorize; - export const cyan: Colorize; - export const white: Colorize; - export const gray: Colorize; - export const grey: Colorize; - - export const bgBlack: Colorize; - export const bgRed: Colorize; - export const bgGreen: Colorize; - export const bgYellow: Colorize; - export const bgBlue: Colorize; - export const bgMagenta: Colorize; - export const bgCyan: Colorize; - export const bgWhite: Colorize; - - export const reset: Colorize; - export const bold: Colorize; - export const dim: Colorize; - export const italic: Colorize; - export const underline: Colorize; - export const inverse: Colorize; - export const hidden: Colorize; - export const strikethrough: Colorize; - } - - declare module 'color-space/node_modules/kleur/index' { - namespace kleur { - interface Color { - (x: string | number): string; - (): Kleur; - } - - interface Kleur { - // Colors - black: Color; - red: Color; - green: Color; - yellow: Color; - blue: Color; - magenta: Color; - cyan: Color; - white: Color; - gray: Color; - grey: Color; - - // Backgrounds - bgBlack: Color; - bgRed: Color; - bgGreen: Color; - bgYellow: Color; - bgBlue: Color; - bgMagenta: Color; - bgCyan: Color; - bgWhite: Color; - - // Modifiers - reset: Color; - bold: Color; - dim: Color; - italic: Color; - underline: Color; - inverse: Color; - hidden: Color; - strikethrough: Color; - } - } - - let kleur: kleur.Kleur & { enabled: boolean }; - export = kleur; - } - - declare module 'color-space/node_modules/mri/index' { - type Dict = Record; - type Arrayable = T | T[]; - type Default = Dict; - - function mri(args?: string[], options?: mri.Options): mri.Argv; - - namespace mri { - export interface Options { - boolean?: Arrayable; - string?: Arrayable; - alias?: Dict>; - default?: Dict; - unknown?(flag: string): void; - } - - export type Argv = T & { - _: string[]; - } - } - - export = mri; - } - - declare module 'color-space/node_modules/sade/index' { - import type * as mri from 'mri'; - - type Arrayable = T | T[]; - - function sade(usage: string, isSingle?: boolean): sade.Sade; - - namespace sade { - export type Handler = (...args: any[]) => any; - export type Value = number | string | boolean | null; - - export interface LazyOutput { - name: string; - handler: Handler; - args: string[]; - } - - export interface Sade { - command(usage: string, description?: string, options?: { - alias?: Arrayable; - default?: boolean; - }): Sade; - - option(flag: string, description?: string, value?: Value): Sade; - action(handler: Handler): Sade; - describe(text: Arrayable): Sade; - alias(...names: string[]): Sade; - example(usage: string): Sade; - - parse(arr: string[], opts: { lazy: true } & mri.Options): LazyOutput; - parse(arr: string[], opts?: { lazy?: boolean } & mri.Options): void; - - version(value: string): Sade; - help(cmd?: string): void; - } - } - - export = sade; - } - - declare module 'color-space/node_modules/uvu/assert/index' { - type Types = 'string' | 'number' | 'boolean' | 'object' | 'undefined' | 'function'; - - export type Message = string | Error; - export function ok(actual: any, msg?: Message): asserts actual; - export function is(actual: any, expects: any, msg?: Message): void; - export function equal(actual: any, expects: any, msg?: Message): void; - export function type(actual: any, expects: Types, msg?: Message): void; - export function instance(actual: any, expects: any, msg?: Message): void; - export function snapshot(actual: string, expects: string, msg?: Message): void; - export function fixture(actual: string, expects: string, msg?: Message): void; - export function match(actual: string, expects: string | RegExp, msg?: Message): void; - export function throws(fn: Function, expects?: Message | RegExp | Function, msg?: Message): void; - export function not(actual: any, msg?: Message): void; - export function unreachable(msg?: Message): void; - - export namespace is { - function not(actual: any, expects: any, msg?: Message): void; - } - - export namespace not { - function ok(actual: any, msg?: Message): void; - function equal(actual: any, expects: any, msg?: Message): void; - function type(actual: any, expects: Types, msg?: Message): void; - function instance(actual: any, expects: any, msg?: Message): void; - function snapshot(actual: string, expects: string, msg?: Message): void; - function fixture(actual: string, expects: string, msg?: Message): void; - function match(actual: string, expects: string | RegExp, msg?: Message): void; - function throws(fn: Function, expects?: Message | RegExp | Function, msg?: Message): void; - } - - export class Assertion extends Error { - name: 'Assertion'; - code: 'ERR_ASSERTION'; - details: false | string; - generated: boolean; - operator: string; - expects: any; - actual: any; - constructor(options?: { - message: string; - details?: string; - generated?: boolean; - operator: string; - expects: any; - actual: any; - }); - } - } - - declare module 'color-space/node_modules/uvu/diff/index' { - export function chars(input: any, expects: any): string; - export function lines(input: any, expects: any, linenum?: number): string; - export function direct(input: any, expects: any, lenA?: number, lenB?: number): string; - export function compare(input: any, expects: any): string; - export function arrays(input: any, expects: any): string; - } - - declare module 'color-space/node_modules/uvu/index' { - namespace uvu { - type Crumbs = { __suite__: string; __test__: string }; - type Callback = (context: T & Crumbs) => Promise | void; - - interface Hook { - (hook: Callback): void; - each(hook: Callback): void; - } - - interface Test { - (name: string, test: Callback): void; - only(name: string, test: Callback): void; - skip(name?: string, test?: Callback): void; - before: Hook; - after: Hook - run(): () => void; - } - } - - type Context = Record; - - export type Test = uvu.Test; - export type Callback = uvu.Callback; - - export const test: uvu.Test; - export function suite(title?: string, context?: T): uvu.Test; - export function exec(bail?: boolean): Promise; - } - - declare module 'color-space/node_modules/uvu/parse/index' { - type Arrayable = T[] | T; - - export interface Suite { - /** The relative file path */ - name: string; - /** The absolute file path */ - file: string; - } - - export interface Options { - cwd: string; - require: Arrayable; - ignore: Arrayable; - } - - export interface Argv { - dir: string; - suites: Suite[]; - requires: boolean; - } - - export function parse(dir?: string, pattern?: string|RegExp, opts?: Partial): Promise; - } - - declare module 'color-space/node_modules/uvu/run/index' { - import type { Suite } from 'uvu/parse'; - export function run(suites: Suite[], options?: { bail: boolean }): Promise; - } -} - -declare module 'color-space/node_modules/dequal/index' { - export function dequal(foo: any, bar: any): boolean; -} - -declare module 'color-space/node_modules/dequal/lite/index' { - export function dequal(foo: any, bar: any): boolean; -} - -declare module 'color-space/node_modules/esbuild/lib/main' { - export type Platform = 'browser' | 'node' | 'neutral' - export type Format = 'iife' | 'cjs' | 'esm' - export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx' - export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent' - export type Charset = 'ascii' | 'utf8' - export type Drop = 'console' | 'debugger' - - interface CommonOptions { - /** Documentation: https://esbuild.github.io/api/#sourcemap */ - sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both' - /** Documentation: https://esbuild.github.io/api/#legal-comments */ - legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external' - /** Documentation: https://esbuild.github.io/api/#source-root */ - sourceRoot?: string - /** Documentation: https://esbuild.github.io/api/#sources-content */ - sourcesContent?: boolean - - /** Documentation: https://esbuild.github.io/api/#format */ - format?: Format - /** Documentation: https://esbuild.github.io/api/#global-name */ - globalName?: string - /** Documentation: https://esbuild.github.io/api/#target */ - target?: string | string[] - /** Documentation: https://esbuild.github.io/api/#supported */ - supported?: Record - /** Documentation: https://esbuild.github.io/api/#platform */ - platform?: Platform - - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - mangleProps?: RegExp - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - reserveProps?: RegExp - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - mangleQuoted?: boolean - /** Documentation: https://esbuild.github.io/api/#mangle-props */ - mangleCache?: Record - /** Documentation: https://esbuild.github.io/api/#drop */ - drop?: Drop[] - /** Documentation: https://esbuild.github.io/api/#drop-labels */ - dropLabels?: string[] - /** Documentation: https://esbuild.github.io/api/#minify */ - minify?: boolean - /** Documentation: https://esbuild.github.io/api/#minify */ - minifyWhitespace?: boolean - /** Documentation: https://esbuild.github.io/api/#minify */ - minifyIdentifiers?: boolean - /** Documentation: https://esbuild.github.io/api/#minify */ - minifySyntax?: boolean - /** Documentation: https://esbuild.github.io/api/#line-limit */ - lineLimit?: number - /** Documentation: https://esbuild.github.io/api/#charset */ - charset?: Charset - /** Documentation: https://esbuild.github.io/api/#tree-shaking */ - treeShaking?: boolean - /** Documentation: https://esbuild.github.io/api/#ignore-annotations */ - ignoreAnnotations?: boolean - - /** Documentation: https://esbuild.github.io/api/#jsx */ - jsx?: 'transform' | 'preserve' | 'automatic' - /** Documentation: https://esbuild.github.io/api/#jsx-factory */ - jsxFactory?: string - /** Documentation: https://esbuild.github.io/api/#jsx-fragment */ - jsxFragment?: string - /** Documentation: https://esbuild.github.io/api/#jsx-import-source */ - jsxImportSource?: string - /** Documentation: https://esbuild.github.io/api/#jsx-development */ - jsxDev?: boolean - /** Documentation: https://esbuild.github.io/api/#jsx-side-effects */ - jsxSideEffects?: boolean - - /** Documentation: https://esbuild.github.io/api/#define */ - define?: { [key: string]: string } - /** Documentation: https://esbuild.github.io/api/#pure */ - pure?: string[] - /** Documentation: https://esbuild.github.io/api/#keep-names */ - keepNames?: boolean - - /** Documentation: https://esbuild.github.io/api/#color */ - color?: boolean - /** Documentation: https://esbuild.github.io/api/#log-level */ - logLevel?: LogLevel - /** Documentation: https://esbuild.github.io/api/#log-limit */ - logLimit?: number - /** Documentation: https://esbuild.github.io/api/#log-override */ - logOverride?: Record - - /** Documentation: https://esbuild.github.io/api/#tsconfig-raw */ - tsconfigRaw?: string | TsconfigRaw - } - - export interface TsconfigRaw { - compilerOptions?: { - alwaysStrict?: boolean - baseUrl?: string - experimentalDecorators?: boolean - importsNotUsedAsValues?: 'remove' | 'preserve' | 'error' - jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev' - jsxFactory?: string - jsxFragmentFactory?: string - jsxImportSource?: string - paths?: Record - preserveValueImports?: boolean - strict?: boolean - target?: string - useDefineForClassFields?: boolean - verbatimModuleSyntax?: boolean - } - } - - export interface BuildOptions extends CommonOptions { - /** Documentation: https://esbuild.github.io/api/#bundle */ - bundle?: boolean - /** Documentation: https://esbuild.github.io/api/#splitting */ - splitting?: boolean - /** Documentation: https://esbuild.github.io/api/#preserve-symlinks */ - preserveSymlinks?: boolean - /** Documentation: https://esbuild.github.io/api/#outfile */ - outfile?: string - /** Documentation: https://esbuild.github.io/api/#metafile */ - metafile?: boolean - /** Documentation: https://esbuild.github.io/api/#outdir */ - outdir?: string - /** Documentation: https://esbuild.github.io/api/#outbase */ - outbase?: string - /** Documentation: https://esbuild.github.io/api/#external */ - external?: string[] - /** Documentation: https://esbuild.github.io/api/#packages */ - packages?: 'bundle' | 'external' - /** Documentation: https://esbuild.github.io/api/#alias */ - alias?: Record - /** Documentation: https://esbuild.github.io/api/#loader */ - loader?: { [ext: string]: Loader } - /** Documentation: https://esbuild.github.io/api/#resolve-extensions */ - resolveExtensions?: string[] - /** Documentation: https://esbuild.github.io/api/#main-fields */ - mainFields?: string[] - /** Documentation: https://esbuild.github.io/api/#conditions */ - conditions?: string[] - /** Documentation: https://esbuild.github.io/api/#write */ - write?: boolean - /** Documentation: https://esbuild.github.io/api/#allow-overwrite */ - allowOverwrite?: boolean - /** Documentation: https://esbuild.github.io/api/#tsconfig */ - tsconfig?: string - /** Documentation: https://esbuild.github.io/api/#out-extension */ - outExtension?: { [ext: string]: string } - /** Documentation: https://esbuild.github.io/api/#public-path */ - publicPath?: string - /** Documentation: https://esbuild.github.io/api/#entry-names */ - entryNames?: string - /** Documentation: https://esbuild.github.io/api/#chunk-names */ - chunkNames?: string - /** Documentation: https://esbuild.github.io/api/#asset-names */ - assetNames?: string - /** Documentation: https://esbuild.github.io/api/#inject */ - inject?: string[] - /** Documentation: https://esbuild.github.io/api/#banner */ - banner?: { [type: string]: string } - /** Documentation: https://esbuild.github.io/api/#footer */ - footer?: { [type: string]: string } - /** Documentation: https://esbuild.github.io/api/#entry-points */ - entryPoints?: string[] | Record | { in: string, out: string }[] - /** Documentation: https://esbuild.github.io/api/#stdin */ - stdin?: StdinOptions - /** Documentation: https://esbuild.github.io/plugins/ */ - plugins?: Plugin[] - /** Documentation: https://esbuild.github.io/api/#working-directory */ - absWorkingDir?: string - /** Documentation: https://esbuild.github.io/api/#node-paths */ - nodePaths?: string[]; // The "NODE_PATH" variable from Node.js - } - - export interface StdinOptions { - contents: string | Uint8Array - resolveDir?: string - sourcefile?: string - loader?: Loader - } - - export interface Message { - id: string - pluginName: string - text: string - location: Location | null - notes: Note[] - - /** - * Optional user-specified data that is passed through unmodified. You can - * use this to stash the original error, for example. - */ - detail: any - } - - export interface Note { - text: string - location: Location | null - } - - export interface Location { - file: string - namespace: string - /** 1-based */ - line: number - /** 0-based, in bytes */ - column: number - /** in bytes */ - length: number - lineText: string - suggestion: string - } - - export interface OutputFile { - path: string - contents: Uint8Array - hash: string - /** "contents" as text (changes automatically with "contents") */ - readonly text: string - } - - export interface BuildResult { - errors: Message[] - warnings: Message[] - /** Only when "write: false" */ - outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined) - /** Only when "metafile: true" */ - metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined) - /** Only when "mangleCache" is present */ - mangleCache: Record | (ProvidedOptions['mangleCache'] extends Object ? never : undefined) - } - - export interface BuildFailure extends Error { - errors: Message[] - warnings: Message[] - } - - /** Documentation: https://esbuild.github.io/api/#serve-arguments */ - export interface ServeOptions { - port?: number - host?: string - servedir?: string - keyfile?: string - certfile?: string - fallback?: string - onRequest?: (args: ServeOnRequestArgs) => void - } - - export interface ServeOnRequestArgs { - remoteAddress: string - method: string - path: string - status: number - /** The time to generate the response, not to send it */ - timeInMS: number - } - - /** Documentation: https://esbuild.github.io/api/#serve-return-values */ - export interface ServeResult { - port: number - host: string - } - - export interface TransformOptions extends CommonOptions { - /** Documentation: https://esbuild.github.io/api/#sourcefile */ - sourcefile?: string - /** Documentation: https://esbuild.github.io/api/#loader */ - loader?: Loader - /** Documentation: https://esbuild.github.io/api/#banner */ - banner?: string - /** Documentation: https://esbuild.github.io/api/#footer */ - footer?: string - } - - export interface TransformResult { - code: string - map: string - warnings: Message[] - /** Only when "mangleCache" is present */ - mangleCache: Record | (ProvidedOptions['mangleCache'] extends Object ? never : undefined) - /** Only when "legalComments" is "external" */ - legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined) - } - - export interface TransformFailure extends Error { - errors: Message[] - warnings: Message[] - } - - export interface Plugin { - name: string - setup: (build: PluginBuild) => (void | Promise) - } - - export interface PluginBuild { - /** Documentation: https://esbuild.github.io/plugins/#build-options */ - initialOptions: BuildOptions - - /** Documentation: https://esbuild.github.io/plugins/#resolve */ - resolve(path: string, options?: ResolveOptions): Promise - - /** Documentation: https://esbuild.github.io/plugins/#on-start */ - onStart(callback: () => - (OnStartResult | null | void | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-end */ - onEnd(callback: (result: BuildResult) => - (OnEndResult | null | void | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve */ - onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) => - (OnResolveResult | null | undefined | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-load */ - onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) => - (OnLoadResult | null | undefined | Promise)): void - - /** Documentation: https://esbuild.github.io/plugins/#on-dispose */ - onDispose(callback: () => void): void - - // This is a full copy of the esbuild library in case you need it - esbuild: { - context: typeof context, - build: typeof build, - buildSync: typeof buildSync, - transform: typeof transform, - transformSync: typeof transformSync, - formatMessages: typeof formatMessages, - formatMessagesSync: typeof formatMessagesSync, - analyzeMetafile: typeof analyzeMetafile, - analyzeMetafileSync: typeof analyzeMetafileSync, - initialize: typeof initialize, - version: typeof version, - } - } - - /** Documentation: https://esbuild.github.io/plugins/#resolve-options */ - export interface ResolveOptions { - pluginName?: string - importer?: string - namespace?: string - resolveDir?: string - kind?: ImportKind - pluginData?: any - with?: Record - } - - /** Documentation: https://esbuild.github.io/plugins/#resolve-results */ - export interface ResolveResult { - errors: Message[] - warnings: Message[] - - path: string - external: boolean - sideEffects: boolean - namespace: string - suffix: string - pluginData: any - } - - export interface OnStartResult { - errors?: PartialMessage[] - warnings?: PartialMessage[] - } - - export interface OnEndResult { - errors?: PartialMessage[] - warnings?: PartialMessage[] - } - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */ - export interface OnResolveOptions { - filter: RegExp - namespace?: string - } - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */ - export interface OnResolveArgs { - path: string - importer: string - namespace: string - resolveDir: string - kind: ImportKind - pluginData: any - with: Record - } - - export type ImportKind = - | 'entry-point' - - // JS - | 'import-statement' - | 'require-call' - | 'dynamic-import' - | 'require-resolve' - - // CSS - | 'import-rule' - | 'composes-from' - | 'url-token' - - /** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */ - export interface OnResolveResult { - pluginName?: string - - errors?: PartialMessage[] - warnings?: PartialMessage[] - - path?: string - external?: boolean - sideEffects?: boolean - namespace?: string - suffix?: string - pluginData?: any - - watchFiles?: string[] - watchDirs?: string[] - } - - /** Documentation: https://esbuild.github.io/plugins/#on-load-options */ - export interface OnLoadOptions { - filter: RegExp - namespace?: string - } - - /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */ - export interface OnLoadArgs { - path: string - namespace: string - suffix: string - pluginData: any - with: Record - } - - /** Documentation: https://esbuild.github.io/plugins/#on-load-results */ - export interface OnLoadResult { - pluginName?: string - - errors?: PartialMessage[] - warnings?: PartialMessage[] - - contents?: string | Uint8Array - resolveDir?: string - loader?: Loader - pluginData?: any - - watchFiles?: string[] - watchDirs?: string[] - } - - export interface PartialMessage { - id?: string - pluginName?: string - text?: string - location?: Partial | null - notes?: PartialNote[] - detail?: any - } - - export interface PartialNote { - text?: string - location?: Partial | null - } - - /** Documentation: https://esbuild.github.io/api/#metafile */ - export interface Metafile { - inputs: { - [path: string]: { - bytes: number - imports: { - path: string - kind: ImportKind - external?: boolean - original?: string - with?: Record - }[] - format?: 'cjs' | 'esm' - with?: Record - } - } - outputs: { - [path: string]: { - bytes: number - inputs: { - [path: string]: { - bytesInOutput: number - } - } - imports: { - path: string - kind: ImportKind | 'file-loader' - external?: boolean - }[] - exports: string[] - entryPoint?: string - cssBundle?: string - } - } - } - - export interface FormatMessagesOptions { - kind: 'error' | 'warning' - color?: boolean - terminalWidth?: number - } - - export interface AnalyzeMetafileOptions { - color?: boolean - verbose?: boolean - } - - export interface WatchOptions { - } - - export interface BuildContext { - /** Documentation: https://esbuild.github.io/api/#rebuild */ - rebuild(): Promise> - - /** Documentation: https://esbuild.github.io/api/#watch */ - watch(options?: WatchOptions): Promise - - /** Documentation: https://esbuild.github.io/api/#serve */ - serve(options?: ServeOptions): Promise - - cancel(): Promise - dispose(): Promise - } - - type SameShape = In & { [Key in Exclude]: never } - - /** - * This function invokes the "esbuild" command-line tool for you. It returns a - * promise that either resolves with a "BuildResult" object or rejects with a - * "BuildFailure" object. - * - * - Works in node: yes - * - Works in browser: yes - * - * Documentation: https://esbuild.github.io/api/#build - */ - export function build(options: SameShape): Promise> - - /** - * This is the advanced long-running form of "build" that supports additional - * features such as watch mode and a local development server. - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#build - */ - export function context(options: SameShape): Promise> - - /** - * This function transforms a single JavaScript file. It can be used to minify - * JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript - * to older JavaScript. It returns a promise that is either resolved with a - * "TransformResult" object or rejected with a "TransformFailure" object. - * - * - Works in node: yes - * - Works in browser: yes - * - * Documentation: https://esbuild.github.io/api/#transform - */ - export function transform(input: string | Uint8Array, options?: SameShape): Promise> - - /** - * Converts log messages to formatted message strings suitable for printing in - * the terminal. This allows you to reuse the built-in behavior of esbuild's - * log message formatter. This is a batch-oriented API for efficiency. - * - * - Works in node: yes - * - Works in browser: yes - */ - export function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise - - /** - * Pretty-prints an analysis of the metafile JSON to a string. This is just for - * convenience to be able to match esbuild's pretty-printing exactly. If you want - * to customize it, you can just inspect the data in the metafile yourself. - * - * - Works in node: yes - * - Works in browser: yes - * - * Documentation: https://esbuild.github.io/api/#analyze - */ - export function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise - - /** - * A synchronous version of "build". - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#build - */ - export function buildSync(options: SameShape): BuildResult - - /** - * A synchronous version of "transform". - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#transform - */ - export function transformSync(input: string | Uint8Array, options?: SameShape): TransformResult - - /** - * A synchronous version of "formatMessages". - * - * - Works in node: yes - * - Works in browser: no - */ - export function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[] - - /** - * A synchronous version of "analyzeMetafile". - * - * - Works in node: yes - * - Works in browser: no - * - * Documentation: https://esbuild.github.io/api/#analyze - */ - export function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string - - /** - * This configures the browser-based version of esbuild. It is necessary to - * call this first and wait for the returned promise to be resolved before - * making other API calls when using esbuild in the browser. - * - * - Works in node: yes - * - Works in browser: yes ("options" is required) - * - * Documentation: https://esbuild.github.io/api/#browser - */ - export function initialize(options: InitializeOptions): Promise - - export interface InitializeOptions { - /** - * The URL of the "esbuild.wasm" file. This must be provided when running - * esbuild in the browser. - */ - wasmURL?: string | URL - - /** - * The result of calling "new WebAssembly.Module(buffer)" where "buffer" - * is a typed array or ArrayBuffer containing the binary code of the - * "esbuild.wasm" file. - * - * You can use this as an alternative to "wasmURL" for environments where it's - * not possible to download the WebAssembly module. - */ - wasmModule?: WebAssembly.Module - - /** - * By default esbuild runs the WebAssembly-based browser API in a web worker - * to avoid blocking the UI thread. This can be disabled by setting "worker" - * to false. - */ - worker?: boolean - } - - export let version: string - - export function stop(): Promise - - global { - namespace WebAssembly { - interface Module { - } - } - interface URL { - } - } -} - -declare module 'color-space/node_modules/kleur/colors' { - function print(input: string | boolean | number): string; - function print(input: undefined | void): undefined; - function print(input: null): null; - type Colorize = typeof print; - - export const $: { enabled: boolean }; - - export const black: Colorize; - export const red: Colorize; - export const green: Colorize; - export const yellow: Colorize; - export const blue: Colorize; - export const magenta: Colorize; - export const cyan: Colorize; - export const white: Colorize; - export const gray: Colorize; - export const grey: Colorize; - - export const bgBlack: Colorize; - export const bgRed: Colorize; - export const bgGreen: Colorize; - export const bgYellow: Colorize; - export const bgBlue: Colorize; - export const bgMagenta: Colorize; - export const bgCyan: Colorize; - export const bgWhite: Colorize; - - export const reset: Colorize; - export const bold: Colorize; - export const dim: Colorize; - export const italic: Colorize; - export const underline: Colorize; - export const inverse: Colorize; - export const hidden: Colorize; - export const strikethrough: Colorize; -} - -declare module 'color-space/node_modules/kleur/index' { - namespace kleur { - interface Color { - (x: string | number): string; - (): Kleur; - } - - interface Kleur { - // Colors - black: Color; - red: Color; - green: Color; - yellow: Color; - blue: Color; - magenta: Color; - cyan: Color; - white: Color; - gray: Color; - grey: Color; - - // Backgrounds - bgBlack: Color; - bgRed: Color; - bgGreen: Color; - bgYellow: Color; - bgBlue: Color; - bgMagenta: Color; - bgCyan: Color; - bgWhite: Color; - - // Modifiers - reset: Color; - bold: Color; - dim: Color; - italic: Color; - underline: Color; - inverse: Color; - hidden: Color; - strikethrough: Color; - } - } - - let kleur: kleur.Kleur & { enabled: boolean }; - export = kleur; -} - -declare module 'color-space/node_modules/mri/index' { - type Dict = Record; - type Arrayable = T | T[]; - type Default = Dict; - - function mri(args?: string[], options?: mri.Options): mri.Argv; - - namespace mri { - export interface Options { - boolean?: Arrayable; - string?: Arrayable; - alias?: Dict>; - default?: Dict; - unknown?(flag: string): void; - } - - export type Argv = T & { - _: string[]; - } - } - - export = mri; -} - -declare module 'color-space/node_modules/sade/index' { - import type * as mri from 'mri'; - - type Arrayable = T | T[]; - - function sade(usage: string, isSingle?: boolean): sade.Sade; - - namespace sade { - export type Handler = (...args: any[]) => any; - export type Value = number | string | boolean | null; - - export interface LazyOutput { - name: string; - handler: Handler; - args: string[]; - } - - export interface Sade { - command(usage: string, description?: string, options?: { - alias?: Arrayable; - default?: boolean; - }): Sade; - - option(flag: string, description?: string, value?: Value): Sade; - action(handler: Handler): Sade; - describe(text: Arrayable): Sade; - alias(...names: string[]): Sade; - example(usage: string): Sade; - - parse(arr: string[], opts: { lazy: true } & mri.Options): LazyOutput; - parse(arr: string[], opts?: { lazy?: boolean } & mri.Options): void; - - version(value: string): Sade; - help(cmd?: string): void; - } - } - - export = sade; -} - -declare module 'color-space/node_modules/uvu/assert/index' { - type Types = 'string' | 'number' | 'boolean' | 'object' | 'undefined' | 'function'; - - export type Message = string | Error; - export function ok(actual: any, msg?: Message): asserts actual; - export function is(actual: any, expects: any, msg?: Message): void; - export function equal(actual: any, expects: any, msg?: Message): void; - export function type(actual: any, expects: Types, msg?: Message): void; - export function instance(actual: any, expects: any, msg?: Message): void; - export function snapshot(actual: string, expects: string, msg?: Message): void; - export function fixture(actual: string, expects: string, msg?: Message): void; - export function match(actual: string, expects: string | RegExp, msg?: Message): void; - export function throws(fn: Function, expects?: Message | RegExp | Function, msg?: Message): void; - export function not(actual: any, msg?: Message): void; - export function unreachable(msg?: Message): void; - - export namespace is { - function not(actual: any, expects: any, msg?: Message): void; - } - - export namespace not { - function ok(actual: any, msg?: Message): void; - function equal(actual: any, expects: any, msg?: Message): void; - function type(actual: any, expects: Types, msg?: Message): void; - function instance(actual: any, expects: any, msg?: Message): void; - function snapshot(actual: string, expects: string, msg?: Message): void; - function fixture(actual: string, expects: string, msg?: Message): void; - function match(actual: string, expects: string | RegExp, msg?: Message): void; - function throws(fn: Function, expects?: Message | RegExp | Function, msg?: Message): void; - } - - export class Assertion extends Error { - name: 'Assertion'; - code: 'ERR_ASSERTION'; - details: false | string; - generated: boolean; - operator: string; - expects: any; - actual: any; - constructor(options?: { - message: string; - details?: string; - generated?: boolean; - operator: string; - expects: any; - actual: any; - }); - } -} - -declare module 'color-space/node_modules/uvu/diff/index' { - export function chars(input: any, expects: any): string; - export function lines(input: any, expects: any, linenum?: number): string; - export function direct(input: any, expects: any, lenA?: number, lenB?: number): string; - export function compare(input: any, expects: any): string; - export function arrays(input: any, expects: any): string; -} - -declare module 'color-space/node_modules/uvu/index' { - namespace uvu { - type Crumbs = { __suite__: string; __test__: string }; - type Callback = (context: T & Crumbs) => Promise | void; - - interface Hook { - (hook: Callback): void; - each(hook: Callback): void; - } - - interface Test { - (name: string, test: Callback): void; - only(name: string, test: Callback): void; - skip(name?: string, test?: Callback): void; - before: Hook; - after: Hook - run(): () => void; - } - } - - type Context = Record; - - export type Test = uvu.Test; - export type Callback = uvu.Callback; - - export const test: uvu.Test; - export function suite(title?: string, context?: T): uvu.Test; - export function exec(bail?: boolean): Promise; -} - -declare module 'color-space/node_modules/uvu/parse/index' { - type Arrayable = T[] | T; - - export interface Suite { - /** The relative file path */ - name: string; - /** The absolute file path */ - file: string; - } - - export interface Options { - cwd: string; - require: Arrayable; - ignore: Arrayable; - } - - export interface Argv { - dir: string; - suites: Suite[]; - requires: boolean; - } - - export function parse(dir?: string, pattern?: string|RegExp, opts?: Partial): Promise; -} - -declare module 'color-space/node_modules/uvu/run/index' { - import type { Suite } from 'uvu/parse'; - export function run(suites: Suite[], options?: { bail: boolean }): Promise; -} - diff --git a/dist/color-space.d.ts.map b/dist/color-space.d.ts.map deleted file mode 100644 index 3d061f8..0000000 --- a/dist/color-space.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"color-space.d.ts","sourceRoot":"","sources":["../rgb.js","../hsl.js","../hsv.js","../hsi.js","../hwb.js","../cmyk.js","../cmy.js","../xyz.js","../xyy.js","../yiq.js","../yuv.js","../ydbdr.js","../ycgco.js","../ypbpr.js","../ycbcr.js","../xvycc.js","../yccbccrc.js","../ucs.js","../uvw.js","../jpeg.js","../lab.js","../labh.js","../lms.js","../lchab.js","../luv.js","../lchuv.js","../hsluv.js","../hpluv.js","../cubehelix.js","../coloroid.js","../hcg.js","../hcy.js","../tsl.js","../yes.js","../osaucs.js","../hsp.js","../index.js"],"names":[],"mappings":";oBAgB0B,OAAO,OAAY,EAAE,UAAU;;;;oBCoB/B,OAAO,OAAY,EAAE,UAAU;;;;oBCsB/B,OAAO,OAAY,EAAE,UAAU;;;;oBCzC/B,OAAO,OAAY,EAAE,UAAU;;;;oBCiE/B,OAAO,OAAY,EAAE,UAAU;;;;oBCxC/B,OAAO,OAAY,EAAE,UAAU;;;;oBCY/B,OAAO,OAAY,EAAE,UAAU;;;;oBCwF/B,OAAO,OAAY,EAAE,UAAU,GAAG,WAAW;;8BAvIzD;QAAC,UAAU,EAAE;gBAAO,MAAM,GAAE;oBAAO,MAAM,GAAE,KAAK,CAAC,MAAM,CAAC;aAAC;SAAC,CAAA;KAAC;;;oBC8B/C,OAAO,OAAY,EAAE,UAAU;;;;;IC9BzD,SAAqB,OAAO,OAAY,EAAE,UAAU,CAMjD;;;;ICNH,SAAqB,OAAO,OAAY,EAAE,UAAU,CAMjD;;;oBC4DuB,OAAO,OAAY,EAAE,UAAU;;;;oBChB/B,OAAO,OAAY,EAAE,UAAU;;;;;IC7CzD,WAAuB,OAAO,OAAY,EAAE,UAAU,CAMnD;;;oBC6DuB,OAAO,OAAY,EAAE,UAAU;;;;oBCrC/B,OAAO,OAAY,EAAE,UAAU;;;;oBCA/B,OAAO,OAAY,EAAE,UAAU;;;;oBCxB/B,OAAO,OAAY,EAAE,UAAU;;;;oBCC/B,OAAO,OAAY,EAAE,UAAU;;;;oBCD/B,OAAO,OAAY,EAAE,UAAU;;;;oBCwB/B,OAAO,OAAY,EAAE,UAAU;;;;oBCP/B,OAAO,OAAY,EAAE,UAAU;;;;oBCkB/B,OAAO,OAAY,EAAE,UAAU,GAAG,WAAW;;8BAvCzD;QAAC,MAAM,EAAE;gBAAO,MAAM,GAAE,KAAK,CAAC,MAAM,CAAC;SAAC,CAAA;KAAC;;;oBC2C3B,OAAO,OAAY,EAAE,UAAU;;;;oBCI/B,OAAO,OAAY,EAAE,UAAU;;;;oBC3B/B,OAAO,OAAY,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;oBCsC/B,OAAO,OAAY,EAAE,UAAU,GAAG,aAAa;;gCAzB3D;QAAC,MAAM,EAAE;gBAAO,MAAM,GAAE,OAAO,OAAY,EAAE,SAAS;SAAC,CAAA;KAAC;IAvB2I,6BAA6B;IAJnB,0BAA4H;IAIzG,0BAA6B;IAA6B,0BAA6B;IANrU,6BAAgF;IAMiG,0BAAgC;IAA0D,6BAA6B;IAFxS,0BAA0H;IAAA,0BAA8H;IAF+F,0BAAgI;IAAnV,0BAAuF;IAI1E,6BAAgC;IAJjL,0BAAoI;IAF6H,0BAAoL;IAArW,0BAAiL;IAFoI,6BAA6D;;;oBCWxa,OAAO,OAAY,EAAE,UAAU;;;;oBCsD/B,OAAO,OAAY,EAAE,UAAU,GAAG,iBAAiB;;oCA3E/D;QAAC,QAAQ,EAAE;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAC,CAAA;KAAC;;;oBCuQ7D,OAAO,OAAY,EAAE,UAAU,GAAG,gBAAgB;;mCAlQ9D;QAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;KAAC;;;oBC4EjB,OAAO,OAAY,EAAE,UAAU;;;;oBCtE/B,OAAO,OAAY,EAAE,UAAU;;;;oBCE/B,OAAO,OAAY,EAAE,UAAU;;;;oBCgC/B,OAAO,OAAY,EAAE,UAAU;;;;oBCwB/B,OAAO,OAAY,EAAE,UAAU;;;;oBC2B/B,OAAO,OAAY,EAAE,UAAU;;;;ICtCzD;;OAEG;IACH,mCAFW,UAAU,QAapB;;0BAnCa,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK;4BAErU,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,GAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC;uCAE1D,GAAE,GAAG,IAAI,OAAO,GAAG,SAAS,GAAC;;cAI7B,OAAO;aACP,KAAK,CAAC,MAAM,CAAC;aACb,KAAK,CAAC,MAAM,CAAC;iBACb,KAAK,CAAC,MAAM,CAAC;;;6BAIb,cAAc,GAAG,oBAAoB;IAfnD,+VAA+V;IAE/V,sFAAsF;IAEtF,oEAAoE;IAEpE;;;;;;;OAOG;IAEH,kEAAkE;IAGlE,cAA0B,GAAE,GAAG,IAAI,OAAO,GAAG,UAAU,GAAC,CAAU"} \ No newline at end of file diff --git a/package.json b/package.json index c07c062..355637e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ ], "license": "MIT", "main": "./index.js", - "types": "./dist/color-space.d.ts", "devDependencies": { "almost-equal": "^1.1.0", "esbuild": "^0.24.2", @@ -48,7 +47,6 @@ "test": "uvu test", "build": "esbuild ./index.js --bundle --format=esm --outfile=dist/color-space.js", "min": "esbuild ./dist/color-space.js --minify --outfile=dist/color-space.min.js", - "types": "npx -y --package=typescript@latest -c 'tsc' && npx --package dts-bundle@latest -c 'dts-bundle --name color-space --main build/**/*.d.ts --baseDir . --out dist/color-space.d.ts'", - "prepublishOnly": "npm run build && npm run min && npm run types" + "prepublishOnly": "npm run build && npm run min" } } diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 2de53e3..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "allowJs": true, - "checkJs": true, - "target": "es6", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "declaration": true, - "declarationMap": true, - "outDir": "./build", - }, - "include": [ - "index.js", - ] -} \ No newline at end of file From 89645072e781e1d8af3c2216674d35d3535e37e2 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 20:19:58 -0500 Subject: [PATCH 03/16] Begin cleanup --- cmy.js | 40 +++++++++++++--------------------------- cmyk.js | 19 +++++++++---------- coloroid.js | 52 +++++++++++++++++++--------------------------------- cubehelix.js | 25 ++++++++----------------- rgb.js | 11 ++++------- 5 files changed, 53 insertions(+), 94 deletions(-) diff --git a/cmy.js b/cmy.js index f947c48..aa75c70 100644 --- a/cmy.js +++ b/cmy.js @@ -3,8 +3,7 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ -var cmy = { +const cmy = { name: 'cmy', min: [0,0,0], max: [100,100,100], @@ -12,26 +11,18 @@ var cmy = { alias: ['CMY'] }; - /** * CMY to RGB * - * @param {Array} cmy Channels + * @param {Array} CMY channels * * @return {Array} RGB channels */ -cmy.rgb = function(cmy) { - var c = cmy[0] / 100, - m = cmy[1] / 100, - y = cmy[2] / 100; - - return [ - (1 - c) * 255, - (1 - m) * 255, - (1 - y) * 255 - ]; -}; - +cmy.rgb = ([c, m, y]) => [ + (1 - c/100) * 255, + (1 - m/100) * 255, + (1 - y/100) * 255 +]; /** * RGB to CMY @@ -40,16 +31,11 @@ cmy.rgb = function(cmy) { * * @return {Array} CMY channels */ -rgb.cmy = function(rgb) { - var r = rgb[0] / 255, - g = rgb[1] / 255, - b = rgb[2] / 255; +rgb.cmy = ([r, g, b]) => [ + (1-r/255) * 100 || 0, + (1-g/255) * 100 || 0, + (1-b/255) * 100 || 0 +]; - return [ - (1-r) * 100 || 0, - (1-g) * 100 || 0, - (1-b) * 100 || 0 - ]; -} -export default /** @type {import('./index.js').ColorSpace} */ (cmy); +export default cmy; diff --git a/cmyk.js b/cmyk.js index 6bcb092..e16325c 100644 --- a/cmyk.js +++ b/cmyk.js @@ -3,7 +3,6 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ const cmyk = { name: 'cmyk', min: [0,0,0,0], @@ -11,24 +10,23 @@ const cmyk = { channel: ['cyan', 'magenta', 'yellow', 'black'], alias: ['CMYK'], - rgb: function(cmyk) { - var c = cmyk[0] / 100, + rgb: (cmyk) => { + let c = cmyk[0] / 100, m = cmyk[1] / 100, y = cmyk[2] / 100, k = cmyk[3] / 100, r, g, b; - r = 1 - Math.min(1, c * (1 - k) + k); - g = 1 - Math.min(1, m * (1 - k) + k); + r = 1 - Math.min(1, c * (1 - k) + k), + g = 1 - Math.min(1, m * (1 - k) + k), b = 1 - Math.min(1, y * (1 - k) + k); + return [r * 255, g * 255, b * 255]; } }; - -//extend rgb -rgb.cmyk = function(rgb) { - var r = rgb[0] / 255, +rgb.cmyk = (rgb) => { + let r = rgb[0] / 255, g = rgb[1] / 255, b = rgb[2] / 255, c, m, y, k; @@ -37,7 +35,8 @@ rgb.cmyk = function(rgb) { c = (1 - r - k) / (1 - k) || 0; m = (1 - g - k) / (1 - k) || 0; y = (1 - b - k) / (1 - k) || 0; + return [c * 100, m * 100, y * 100, k * 100]; }; -export default /** @type {import('./index.js').ColorSpace} */ (cmyk); +export default cmyk; diff --git a/coloroid.js b/coloroid.js index 71d0876..6e78141 100644 --- a/coloroid.js +++ b/coloroid.js @@ -9,31 +9,23 @@ import xyy from './xyy.js'; import xyz from './xyz.js'; -/** @typedef {{table: Array>}} ColoroidSpecific */ - -/** - * Main color space object - * @type {Partial & {xyy: import('./index.js').Transform} & ColoroidSpecific} -*/ var coloroid = { name: 'coloroid', alias: ['ATV'], - //hue, saturation, luminosity - //note that hue values are ids, not the numbers - not every value is possible - //e.g. 38 will be rounded to 36 + // hue, saturation, luminosity + // note that hue values are ids, not the numbers - not every value is possible + // e.g. 38 will be rounded to 36 channel: ['A', 'T', 'V'], min: [10, 0, 0], max: [76, 100, 100], - /** - * Coloroid table - * Regression of values is almost impossible, as hues don’t correlate - * Even angle values are picked very inconsistently, based on aesthetical evaluation. - * - * - tgф, ctgф are removed, ф is searched instead - * - eλ = xλ + yλ + zλ - * - λ is removed as not used - */ + + // Coloroid table + // Regression of values is almost impossible, as hues don’t correlate + // Even angle values are picked very inconsistently, based on aesthetical evaluation. + // - tgф, ctgф are removed, ф is searched instead + // - eλ = xλ + yλ + zλ + // - λ is removed as not used table: [ //A angle eλ xλ yλ [10, 59.0, 1.724349, 0.44987, 0.53641], @@ -85,6 +77,7 @@ var coloroid = { [75, 66.9, 1.681080, 0.42141, 0.56222], [76, 62.8, 1.704979, 0.43647, 0.54895] ], + /** * Backwise - from coloroid to xyY * @@ -92,9 +85,7 @@ var coloroid = { * * @return {Array} xyY values */ - xyy: function (arg) { - var A = arg[0], T = arg[1], V = arg[2]; - + xyy: function ([A, T, V]) { //find the closest row in the table var row; for (var i = 0; i < table.length; i++) { @@ -105,7 +96,6 @@ var coloroid = { } //FIXME row is possibly undefined - //@ts-ignore var yl = row[4], el = row[2], xl = row[3]; var Y = V * V / 100; @@ -190,17 +180,13 @@ A λ ф tg ф ctg ф xλ yλ zλ xλ yλ */ - - -/** Create angle-sorted table */ +// Create angle-sorted table var table = coloroid.table; var angleTable = table.slice(-13).concat(table.slice(0, -13)); -/** - * Some precalculations - * 2° D65 whitepoint is used - */ +// Some precalculations +// 2° D65 whitepoint is used var i = 'D65'; var o = 2; @@ -212,8 +198,6 @@ var y0 = Xn / (Xn + Yn + Zn); var x0 = Yn / (Xn + Yn + Zn); var ew = (Xn + Yn + Zn) / 100; - - /** * From xyY to coloroid * @@ -257,7 +241,9 @@ xyy.coloroid = function (arg) { return [A, T, V]; }; -/** Proper transformation to a XYZ (via xyY) */ +/** + * Proper transformation to a XYZ (via xyY) + **/ xyz.coloroid = function (arg) { return xyy.coloroid(xyz.xyy(arg)); }; @@ -267,4 +253,4 @@ coloroid.xyz = function (arg) { -export default /** @type {import('./index.js').ColorSpace & ColoroidSpecific} */ (coloroid); +export default coloroid; diff --git a/cubehelix.js b/cubehelix.js index 4c6f503..ff15a15 100644 --- a/cubehelix.js +++ b/cubehelix.js @@ -3,44 +3,36 @@ * * @module color-space/cubehelix */ - -/** @typedef {{defaults: {start: number, rotation: number, hue: number, gamma: number}}} CubeHelixSpecific */ - import rgb from './rgb.js'; -/** Default options for space */ var defaults = { - //0..3 + // 0..3 start: 0, - //-10..10 + // -10..10 rotation: 0.5, - //0..1+ + // 0..1+ hue: 1, - //0..2 + // 0..2 gamma: 1 }; -/** @type {Partial & CubeHelixSpecific} */ var cubehelix = { name: 'cubehelix', channel: ['fraction'], min: [0], max: [1], - defaults: defaults + defaults }; /** * Transform cubehelix level to RGB * - * @param {Number|Array} fraction 0..1 cubehelix level + * @param {number|Array} fraction 0..1 cubehelix level * @param {Object} options Mapping options, overrides defaults - * * @return {Array} rgb tuple */ -cubehelix.rgb = function(fraction, options) { - options = options || {}; - +cubehelix.rgb = function(fraction, options={}) { if (Array.isArray(fraction)) fraction = fraction[0]; var start = options.start !== undefined ? options.start : defaults.start; @@ -70,7 +62,6 @@ cubehelix.rgb = function(fraction, options) { * RGB to cubehelix * * @param {Array} rgb RGB values - * * @return {Array} cubehelix fraction(s) */ rgb.cubehelix = function(rgb) { @@ -79,4 +70,4 @@ rgb.cubehelix = function(rgb) { }; -export default /** @type {import('./index.js').ColorSpace & CubeHelixSpecific} */ (cubehelix); +export default cubehelix; diff --git a/rgb.js b/rgb.js index c9dd963..bbd55ca 100644 --- a/rgb.js +++ b/rgb.js @@ -3,15 +3,12 @@ * * @module color-space/rgb */ - - -/** @type {Partial} */ -var rgb = { +const rgb = { name: 'rgb', - min: [0,0,0], - max: [255,255,255], + min: [0, 0, 0], + max: [255, 255, 255], channel: ['red', 'green', 'blue'], alias: ['RGB'] }; -export default /** @type {import('./index.js').ColorSpace} */ (rgb); +export default rgb; From b6f2f3999879ad09341c19e700e134ee90e1ab4a Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 20:20:52 -0500 Subject: [PATCH 04/16] Cleanup xyz --- xyz.js | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/xyz.js b/xyz.js index 771e184..9a96602 100644 --- a/xyz.js +++ b/xyz.js @@ -5,24 +5,19 @@ */ import rgb from './rgb.js'; -/** @typedef {{whitepoint: Object>>}} XYZSpecific */ - -/** @type {Partial & XYZSpecific} */ -var xyz = { +const xyz = { name: 'xyz', - min: [0,0,0], - channel: ['X','Y','Z'], + min: [0, 0, 0], + channel: ['X', 'Y', 'Z'], alias: ['XYZ', 'ciexyz', 'cie1931'], - /** - * Whitepoint reference values with observer/illuminant - * - * http://en.wikipedia.org/wiki/Standard_illuminant - */ + + // Whitepoint reference values with observer/illuminant + // http://en.wikipedia.org/wiki/Standard_illuminant whitepoint: { //1931 2° 2: { //incadescent - A:[109.85, 100, 35.585], + A: [109.85, 100, 35.585], // B:[], C: [98.074, 100, 118.232], D50: [96.422, 100, 82.521], @@ -43,13 +38,13 @@ var xyz = { // F10: [], F11: [100.966, 100, 64.370], // F12: [], - E: [100,100,100] + E: [100, 100, 100] }, //1964 10° 10: { //incadescent - A:[111.144, 100, 35.200], + A: [111.144, 100, 35.200], C: [97.285, 100, 116.145], D50: [96.720, 100, 81.427], D55: [95.799, 100, 90.926], @@ -60,7 +55,7 @@ var xyz = { F2: [103.280, 100, 69.026], F7: [95.792, 100, 107.687], F11: [103.866, 100, 65.627], - E: [100,100,100] + E: [100, 100, 100] } } }; @@ -80,7 +75,7 @@ xyz.max = xyz.whitepoint[2].D65; * @return {Array} RGB values */ xyz.rgb = function (_xyz, white) { - //FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then + // FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then white = white || xyz.whitepoint[2].E; var x = _xyz[0] / white[0], @@ -121,8 +116,8 @@ xyz.rgb = function (_xyz, white) { */ rgb.xyz = function(rgb, white) { var r = rgb[0] / 255, - g = rgb[1] / 255, - b = rgb[2] / 255; + g = rgb[1] / 255, + b = rgb[2] / 255; // assume sRGB r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); @@ -140,4 +135,4 @@ rgb.xyz = function(rgb, white) { -export default /** @type {import('./index.js').ColorSpace & XYZSpecific} */ (xyz); +export default xyz; From 532ec00a6cf7c4541bfa0a8a453c385c846050a0 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 20:20:59 -0500 Subject: [PATCH 05/16] Begin separate declarations --- types/cmy.d.ts | 17 +++++++++++++++++ types/cmyk.d.ts | 17 +++++++++++++++++ types/coloroid.d.ts | 24 ++++++++++++++++++++++++ types/index.d.ts | 0 types/package.json | 5 +++++ types/rgb.d.ts | 10 ++++++++++ 6 files changed, 73 insertions(+) create mode 100644 types/cmy.d.ts create mode 100644 types/cmyk.d.ts create mode 100644 types/coloroid.d.ts create mode 100644 types/index.d.ts create mode 100644 types/package.json create mode 100644 types/rgb.d.ts diff --git a/types/cmy.d.ts b/types/cmy.d.ts new file mode 100644 index 0000000..231560a --- /dev/null +++ b/types/cmy.d.ts @@ -0,0 +1,17 @@ +export interface CmySpace { + name: 'cmy'; + min: [0,0,0]; + max: [100,100,100]; + channel: ['cyan', 'magenta', 'yellow']; + alias: ['CMY']; + rgb: (cmy: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + cmy: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const cmy: CmySpace; +export default cmy; diff --git a/types/cmyk.d.ts b/types/cmyk.d.ts new file mode 100644 index 0000000..836c87b --- /dev/null +++ b/types/cmyk.d.ts @@ -0,0 +1,17 @@ +export interface CmykSpace { + name: 'cmyk', + min: [0,0,0,0], + max: [100,100,100,100], + channel: ['cyan', 'magenta', 'yellow', 'black'], + alias: ['CMYK'], + rgb: (cmyk: [number, number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + cmyk: (rgb: [number, number, number]) => [number, number, number, number] + } +} + +declare const cmyk: CmykSpace; +export default cmyk; diff --git a/types/coloroid.d.ts b/types/coloroid.d.ts new file mode 100644 index 0000000..be9689f --- /dev/null +++ b/types/coloroid.d.ts @@ -0,0 +1,24 @@ +export interface ColoroidSpace { + name: 'coloroid', + alias: ['ATV'], + channel: ['A', 'T', 'V'], + min: [10, 0, 0], + max: [76, 100, 100], + table: number[][], + xyy: (atv: [number, number, number]) => [number, number, number] + xyz: (atv: [number, number, number]) => [number, number, number] +} + +declare module "./xyy" { + interface XyySpace { + coloroid: (xyy: [number, number, number]) => [number, number, number] + } +} +declare module "./xyz" { + interface XyzSpace { + coloroid: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const coloroid: ColoroidSpace; +export default coloroid; diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/types/package.json b/types/package.json new file mode 100644 index 0000000..bb20d63 --- /dev/null +++ b/types/package.json @@ -0,0 +1,5 @@ +{ + "name": "@types/color-space", + "version": "1.0.0", + "types": "index.d.ts" +} diff --git a/types/rgb.d.ts b/types/rgb.d.ts new file mode 100644 index 0000000..a49d510 --- /dev/null +++ b/types/rgb.d.ts @@ -0,0 +1,10 @@ +export interface RgbSpace { + name: 'rgb', + min: [0, 0, 0], + max: [255, 255, 255], + channel: ['red', 'green', 'blue'], + alias: ['RGB'] +} + +declare const rgb: RgbSpace; +export default rgb; From 540940d684efd78f363b065082fd21075f25f6a6 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 20:51:46 -0500 Subject: [PATCH 06/16] Add index.d.ts --- package.json | 1 + types/index.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/package.json b/package.json index 355637e..4815398 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ ], "license": "MIT", "main": "./index.js", + "types": "./types/index.d.ts", "devDependencies": { "almost-equal": "^1.1.0", "esbuild": "^0.24.2", diff --git a/types/index.d.ts b/types/index.d.ts index e69de29..b9a26a7 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -0,0 +1,38 @@ +// export * from './ciecam'; +export * from './cmy'; +export * from './cmyk'; +export * from './coloroid'; +export * from './cubehelix'; +export * from './hcg'; +export * from './hcy'; +export * from './hpluv'; +export * from './hsi'; +export * from './hsl'; +export * from './hsluv'; +export * from './hsp'; +export * from './hsv'; +export * from './hwb'; +export * from './jpeg'; +export * from './lab'; +export * from './labh'; +export * from './lchab'; +export * from './lchuv'; +export * from './lms'; +export * from './luv'; +// export * from './munsell'; +export * from './osaucs'; +export * from './rgb'; +export * from './tsl'; +export * from './ucs'; +export * from './uvw'; +export * from './xvycc'; +export * from './xyz'; +export * from './xyy'; +export * from './ycbcr'; +export * from './yccbccrc'; +export * from './ycgco'; +export * from './ydbdr'; +export * from './yes'; +export * from './yiq'; +export * from './ypbpr'; +export * from './yuv'; From c98376665d35fbbe511da4e20776395b1ed461e7 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 21:06:35 -0500 Subject: [PATCH 07/16] Create readme.md --- types/readme.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 types/readme.md diff --git a/types/readme.md b/types/readme.md new file mode 100644 index 0000000..b920bb3 --- /dev/null +++ b/types/readme.md @@ -0,0 +1,15 @@ +# @types/color-space + +* `index.d.ts` exports full space with all conversions. +* `*.d.ts` exports individual color spaces. + +Types are kept as meaningfully minimal as possible. +Eg. there's no sense for generic _ColorSpace_ since all subtypes include static members. +There's no sense for _Tuple_ data types like _RgbData_ or even _Vec3_/_Vec4_ since they introduce non-existent layer: simple in-place `[number, number, number]` is enough. + +## Why not generating from jsdoc? + +* Proper jsdoc declarations introduce hacks to js files and still don't reach correct results. +* JSdoc doesn't provide matching features, eg. merging interfaces, which we need. +* Generated types look wrong: they miss important parts and include jsdocs. +* Current JSDoc serve literally formalized description purpose. From 5be0f29aa63905e8a504b1e452bd96681ffdf3bc Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 21:33:46 -0500 Subject: [PATCH 08/16] Clean up xyy, xyz --- index.js | 3 +-- types/cmy.d.ts | 9 +++---- types/cmyk.d.ts | 9 +++---- types/coloroid.d.ts | 10 +++----- types/index.d.ts | 60 ++++++++++++++++++++++----------------------- types/rgb.d.ts | 10 +++----- types/types.d.ts | 9 +++++++ types/xyy.d.ts | 14 +++++++++++ types/xyz.d.ts | 14 +++++++++++ xyy.js | 3 +-- 10 files changed, 82 insertions(+), 59 deletions(-) create mode 100644 types/types.d.ts create mode 100644 types/xyy.d.ts create mode 100644 types/xyz.d.ts diff --git a/index.js b/index.js index 2f8485d..c402a76 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,6 @@ import yes from './yes.js' import osaucs from './osaucs.js' import hsp from './hsp.js' -/** @typedef {'rgb' | 'xyz' | 'hsl' | 'hsv' | 'hsi' | 'hwb' | 'cmyk' | 'cmy' | 'xyy' | 'yiq' | 'yuv' | 'ydbdr' | 'ycgco' | 'ypbpr' | 'ycbcr' | 'xvycc' | 'yccbccrc' | 'ucs' | 'uvw' | 'jpeg' | 'lab' | 'labh' | 'lms' | 'lchab' | 'luv' | 'lchuv' | 'hsluv' | 'hpluv' | 'cubehelix' | 'coloroid' | 'hcg' | 'hcy' | 'tsl' | 'yes' | 'osaucs' | 'hsp'} SpaceId */ /** @typedef {(color: Array, ...rest: Array<*>) => Array} Transform */ @@ -63,7 +62,7 @@ const spaces = /** @type {{[key in SpaceId]: ColorSpace}} */ ({}); export default spaces; /** - * @param {ColorSpace} newSpace + * @param {ColorSpace} newSpace */ export function register (newSpace) { const newSpaceName = newSpace.name; diff --git a/types/cmy.d.ts b/types/cmy.d.ts index 231560a..931e3c6 100644 --- a/types/cmy.d.ts +++ b/types/cmy.d.ts @@ -1,9 +1,6 @@ -export interface CmySpace { - name: 'cmy'; - min: [0,0,0]; - max: [100,100,100]; - channel: ['cyan', 'magenta', 'yellow']; - alias: ['CMY']; +import { ColorSpace } from "./types"; + +export interface CmySpace extends ColorSpace { rgb: (cmy: [number, number, number]) => [number, number, number]; } diff --git a/types/cmyk.d.ts b/types/cmyk.d.ts index 836c87b..a135b06 100644 --- a/types/cmyk.d.ts +++ b/types/cmyk.d.ts @@ -1,9 +1,6 @@ -export interface CmykSpace { - name: 'cmyk', - min: [0,0,0,0], - max: [100,100,100,100], - channel: ['cyan', 'magenta', 'yellow', 'black'], - alias: ['CMYK'], +import { ColorSpace } from "./types"; + +export interface CmykSpace extends ColorSpace { rgb: (cmyk: [number, number, number, number]) => [number, number, number]; } diff --git a/types/coloroid.d.ts b/types/coloroid.d.ts index be9689f..5a0bdbc 100644 --- a/types/coloroid.d.ts +++ b/types/coloroid.d.ts @@ -1,10 +1,6 @@ -export interface ColoroidSpace { - name: 'coloroid', - alias: ['ATV'], - channel: ['A', 'T', 'V'], - min: [10, 0, 0], - max: [76, 100, 100], - table: number[][], +import { ColorSpace } from "./types"; + +export interface ColoroidSpace extends ColorSpace { xyy: (atv: [number, number, number]) => [number, number, number] xyz: (atv: [number, number, number]) => [number, number, number] } diff --git a/types/index.d.ts b/types/index.d.ts index b9a26a7..4d54622 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,37 +2,37 @@ export * from './cmy'; export * from './cmyk'; export * from './coloroid'; -export * from './cubehelix'; -export * from './hcg'; -export * from './hcy'; -export * from './hpluv'; -export * from './hsi'; -export * from './hsl'; -export * from './hsluv'; -export * from './hsp'; -export * from './hsv'; -export * from './hwb'; -export * from './jpeg'; -export * from './lab'; -export * from './labh'; -export * from './lchab'; -export * from './lchuv'; -export * from './lms'; -export * from './luv'; +// export * from './cubehelix'; +// export * from './hcg'; +// export * from './hcy'; +// export * from './hpluv'; +// export * from './hsi'; +// export * from './hsl'; +// export * from './hsluv'; +// export * from './hsp'; +// export * from './hsv'; +// export * from './hwb'; +// export * from './jpeg'; +// export * from './lab'; +// export * from './labh'; +// export * from './lchab'; +// export * from './lchuv'; +// export * from './lms'; +// export * from './luv'; // export * from './munsell'; -export * from './osaucs'; +// export * from './osaucs'; export * from './rgb'; -export * from './tsl'; -export * from './ucs'; -export * from './uvw'; -export * from './xvycc'; +// export * from './tsl'; +// export * from './ucs'; +// export * from './uvw'; +// export * from './xvycc'; export * from './xyz'; export * from './xyy'; -export * from './ycbcr'; -export * from './yccbccrc'; -export * from './ycgco'; -export * from './ydbdr'; -export * from './yes'; -export * from './yiq'; -export * from './ypbpr'; -export * from './yuv'; +// export * from './ycbcr'; +// export * from './yccbccrc'; +// export * from './ycgco'; +// export * from './ydbdr'; +// export * from './yes'; +// export * from './yiq'; +// export * from './ypbpr'; +// export * from './yuv'; diff --git a/types/rgb.d.ts b/types/rgb.d.ts index a49d510..11932ec 100644 --- a/types/rgb.d.ts +++ b/types/rgb.d.ts @@ -1,9 +1,7 @@ -export interface RgbSpace { - name: 'rgb', - min: [0, 0, 0], - max: [255, 255, 255], - channel: ['red', 'green', 'blue'], - alias: ['RGB'] +import { ColorSpace } from './types' + +export interface RgbSpace extends ColorSpace { + } declare const rgb: RgbSpace; diff --git a/types/types.d.ts b/types/types.d.ts new file mode 100644 index 0000000..acb0cae --- /dev/null +++ b/types/types.d.ts @@ -0,0 +1,9 @@ +export type SpaceId = 'rgb' | 'xyz' | 'hsl' | 'hsv' | 'hsi' | 'hwb' | 'cmyk' | 'cmy' | 'xyy' | 'yiq' | 'yuv' | 'ydbdr' | 'ycgco' | 'ypbpr' | 'ycbcr' | 'xvycc' | 'yccbccrc' | 'ucs' | 'uvw' | 'jpeg' | 'lab' | 'labh' | 'lms' | 'lchab' | 'luv' | 'lchuv' | 'hsluv' | 'hpluv' | 'cubehelix' | 'coloroid' | 'hcg' | 'hcy' | 'tsl' | 'yes' | 'osaucs' | 'hsp' + +export interface ColorSpace { + name: SpaceId; + min: number[]; + max: number[]; + channel: string[]; + alias?: string[]; +} diff --git a/types/xyy.d.ts b/types/xyy.d.ts new file mode 100644 index 0000000..6778221 --- /dev/null +++ b/types/xyy.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from './types' + +export interface XyySpace extends ColorSpace { + xyz: (xyy: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + xyy: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const xyy: XyySpace; +export default xyy; diff --git a/types/xyz.d.ts b/types/xyz.d.ts new file mode 100644 index 0000000..142e3cd --- /dev/null +++ b/types/xyz.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from './types' + +export interface XyzSpace extends ColorSpace { + rgb: (xyz: [number, number, number]) => [number, number, number] +} + +declare module "./rgb" { + interface RgbSpace { + xyz: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const xyz: XyzSpace; +export default xyz; diff --git a/xyy.js b/xyy.js index be0e49d..330c89c 100644 --- a/xyy.js +++ b/xyy.js @@ -5,7 +5,6 @@ */ import xyz from './xyz.js'; -/** @type {Partial} */ var xyy = { name: 'xyy', min: [0,0,0], @@ -35,4 +34,4 @@ xyz.xyy = function(arg) { return [X / sum, Y / sum, Y]; }; -export default /** @type {import('./index.js').ColorSpace} */ (xyy); +export default (xyy); From ff3472cb1e648284e65676935b91bd0d8c9610bb Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 30 Jan 2025 21:42:39 -0500 Subject: [PATCH 09/16] Update readme.md --- types/readme.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/types/readme.md b/types/readme.md index b920bb3..c60da8f 100644 --- a/types/readme.md +++ b/types/readme.md @@ -4,12 +4,10 @@ * `*.d.ts` exports individual color spaces. Types are kept as meaningfully minimal as possible. -Eg. there's no sense for generic _ColorSpace_ since all subtypes include static members. -There's no sense for _Tuple_ data types like _RgbData_ or even _Vec3_/_Vec4_ since they introduce non-existent layer: simple in-place `[number, number, number]` is enough. ## Why not generating from jsdoc? -* Proper jsdoc declarations introduce hacks to js files and still don't reach correct results. -* JSdoc doesn't provide matching features, eg. merging interfaces, which we need. -* Generated types look wrong: they miss important parts and include jsdocs. +* Proper jsdoc declarations introduce hacks to js files and still don't attain correct results. +* JSdoc doesn't provide merging interfaces, which we need. It lacks capabilities of TS. +* Generated types look wrong: they miss important parts and somehow retain jsdocs. * Current JSDoc serve literally formalized description purpose. From bcb721c30ce07f45fc57f4ba4859a02748fb5797 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 04:04:56 -0500 Subject: [PATCH 10/16] Append all h* spaces --- hcg.js | 3 +-- hcy.js | 3 +-- hpluv.js | 5 ++--- hsi.js | 3 +-- hsluv.js | 15 +++------------ hsp.js | 7 ++----- hwb.js | 44 +++++++++++++++++++++----------------------- types/coloroid.d.ts | 1 + types/cubehelix.ts | 22 ++++++++++++++++++++++ types/hcg.d.ts | 32 ++++++++++++++++++++++++++++++++ types/hcy.d.ts | 14 ++++++++++++++ types/hpluv.d.ts | 21 +++++++++++++++++++++ types/hsi.d.ts | 14 ++++++++++++++ types/hsl.d.ts | 13 +++++++++++++ types/hsluv.d.ts | 26 ++++++++++++++++++++++++++ types/hsp.d.ts | 14 ++++++++++++++ types/hsv.d.ts | 20 ++++++++++++++++++++ types/hwb.d.ts | 26 ++++++++++++++++++++++++++ 18 files changed, 234 insertions(+), 49 deletions(-) create mode 100644 types/cubehelix.ts create mode 100644 types/hcg.d.ts create mode 100644 types/hcy.d.ts create mode 100644 types/hpluv.d.ts create mode 100644 types/hsi.d.ts create mode 100644 types/hsl.d.ts create mode 100644 types/hsluv.d.ts create mode 100644 types/hsp.d.ts create mode 100644 types/hsv.d.ts create mode 100644 types/hwb.d.ts diff --git a/hcg.js b/hcg.js index ae1b947..dd15cd3 100644 --- a/hcg.js +++ b/hcg.js @@ -6,7 +6,6 @@ import hsl from './hsl.js'; import hsv from './hsv.js'; import hwb from './hwb.js'; -/** @type {Partial} */ var hcg = { name: 'hcg', min: [0,0,0], @@ -85,7 +84,7 @@ var hcg = { } }; -export default /** @type {import('./index.js').ColorSpace} */ (hcg); +export default (hcg); //append rgb diff --git a/hcy.js b/hcy.js index 10f9b5c..406ab9d 100644 --- a/hcy.js +++ b/hcy.js @@ -6,7 +6,6 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ var hcy = { name: 'hcy', min: [0,0,0], @@ -15,7 +14,7 @@ var hcy = { alias: ['HCY'] }; -export default /** @type {import('./index.js').ColorSpace} */ (hcy); +export default (hcy); /** diff --git a/hpluv.js b/hpluv.js index e5173b0..d397093 100644 --- a/hpluv.js +++ b/hpluv.js @@ -6,9 +6,8 @@ */ import xyz from './xyz.js'; import lchuv from './lchuv.js'; -import hsluv, {_hsluv} from './hsluv.js'; +import {_hsluv} from './hsluv.js'; -/** @type {Partial} */ var hpluv = { name: 'hpluv', min: [0,0,0], @@ -25,7 +24,7 @@ var hpluv = { } }; -export default /** @type {import('./index.js').ColorSpace} */ (hpluv); +export default hpluv; //extend lchuv, xyz lchuv.hpluv = _hsluv.lchToHpluv; diff --git a/hsi.js b/hsi.js index f5b2067..3e10fff 100644 --- a/hsi.js +++ b/hsi.js @@ -6,7 +6,6 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ var hsi = { name: 'hsi', min: [0,0,0], @@ -15,7 +14,7 @@ var hsi = { alias: ['HSI'] }; -export default /** @type {import('./index.js').ColorSpace} */ (hsi) +export default hsi /** diff --git a/hsluv.js b/hsluv.js index ac2637f..4a256c6 100644 --- a/hsluv.js +++ b/hsluv.js @@ -1,6 +1,6 @@ /** * A uniform wrapper for hsluv. - * // http://www.hsluv.org/ + * http://www.hsluv.org/ * * @module color-space/hsluv */ @@ -11,19 +11,13 @@ import rgb from './rgb.js'; // unwrapped https://github.com/hsluv/hsluv/blob/master/javascript/dist/hsluv-0.1.0.min.js // FIXME: it has redundant functions like rgbToXyz - can be reused from color-space itself -//@ts-ignore +// FIXME: update to the latest function f(a){var c=[],b=Math.pow(a+16,3)/1560896;b=b>g?b:a/k;for(var d=0;3>d;){var e=d++,h=l[e][0],w=l[e][1];e=l[e][2];for(var x=0;2>x;){var y=x++,z=(632260*e-126452*w)*b+126452*y;c.push({b:(284517*h-94839*e)*b/z,a:((838422*e+769860*w+731718*h)*a*b-769860*y*a)/z})}}return c}function m(a){a=f(a);for(var c=Infinity,b=0;b=a?12.92*a:1.055*Math.pow(a,.4166666666666667)-.055}function r(a){return.04045=c?B*c/k:B*Math.pow((c+16)/116,3);b=0-9*c*b/((b-4)*a-b*a);return[b,c,(9*c-15*a*c-a*b)/(3*a)]} -//@ts-ignore function F(a){var c=a[0],b=a[1],d=a[2];a=Math.sqrt(b*b+d*d);1E-8>a?b=0:(b=180*Math.atan2(d,b)/Math.PI,0>b&&(b=360+b));return[c,a,b]}function G(a){var c=a[1],b=a[2]/360*2*Math.PI;return[a[0],Math.cos(b)*c,Math.sin(b)*c]}function H(a){var c=a[0],b=a[1];a=a[2];if(99.9999999a)return[0,0,c];b=n(a,c)/100*b;return[a,b,c]}function I(a){var c=a[0],b=a[1];a=a[2];if(99.9999999c)return[a,0,0];var d=n(c,a);return[a,b/d*100,c]} -//@ts-ignore function J(a){var c=a[0],b=a[1];a=a[2];if(99.9999999a)return[0,0,c];b=m(a)/100*b;return[a,b,c]}function K(a){var c=a[0],b=a[1];a=a[2];if(99.9999999c)return[a,0,0];var d=m(c);return[a,b/d*100,c]}function L(a){for(var c="#",b=0;3>b;){var d=b++;d=Math.round(255*a[d]);var e=d%16;c+=M.charAt((d-e)/16|0)+M.charAt(e)}return c} -//@ts-ignore function N(a){a=a.toLowerCase();for(var c=[],b=0;3>b;){var d=b++;c.push((16*M.indexOf(a.charAt(2*d+1))+M.indexOf(a.charAt(2*d+2)))/255)}return c}function O(a){return t(E(G(a)))}function P(a){return F(A(u(a)))}function Q(a){return O(H(a))}function R(a){return I(P(a))}function S(a){return O(J(a))}function T(a){return K(P(a))} -//@ts-ignore var l=[[3.240969941904521,-1.537383177570093,-.498610760293],[-.96924363628087,1.87596750150772,.041555057407175],[.055630079696993,-.20397695888897,1.056971514242878]],v=[[.41239079926595,.35758433938387,.18048078840183],[.21263900587151,.71516867876775,.072192315360733],[.019330818715591,.11919477979462,.95053215224966]],B=1,C=.19783000664283,D=.46831999493879,k=903.2962962,g=.0088564516,M="0123456789abcdef"; export const _hsluv = { @@ -45,9 +39,6 @@ export const _hsluv = { xyzToRgb: t, }; -/** @typedef {{_hsluv: Object}} HSLuvSpecific */ - -/** @type {Partial & HSLuvSpecific} */ var hsluv = { name: 'hsluv', min: [0,0,0], @@ -70,7 +61,7 @@ var hsluv = { _hsluv }; -export default /** @type {import('./index.js').ColorSpace & HSLuvSpecific} */ (hsluv); +export default hsluv; //extend lchuv, xyz lchuv.hsluv = _hsluv.lchToHsluv; diff --git a/hsp.js b/hsp.js index 82c6494..183f990 100644 --- a/hsp.js +++ b/hsp.js @@ -7,7 +7,6 @@ const Pr = 0.299, Pg = 0.587, Pb = 0.114; -/** @type {Partial} */ var hsp = { name: 'hsp', min: [0, 0, 0], @@ -96,11 +95,9 @@ var hsp = { return [Math.round(r), Math.round(g), Math.round(b)]; } - - }; -export default /** @type {import('./index.js').ColorSpace} */ (hsp); +export default hsp; //append rgb @@ -117,7 +114,7 @@ rgb.hsp = function (rgb) { if (r === g && r === b) { h = 0.0; s = 0.0; - } else { + } else { // R is largest if (r >= g && r >= b) { if (b >= g) { diff --git a/hwb.js b/hwb.js index 9301e01..63c9760 100644 --- a/hwb.js +++ b/hwb.js @@ -5,16 +5,15 @@ import rgb from './rgb.js'; import hsv from './hsv.js'; import hsl from './hsl.js'; -/** @type {Partial & {hsv: import('./index.js').Transform}} */ var hwb = { name: 'hwb', - min: [0,0,0], - max: [360,100,100], + min: [0, 0, 0], + max: [360, 100, 100], channel: ['hue', 'whiteness', 'blackness'], alias: ['HWB'], // http://dev.w3.org/csswg/css-color/#hwb-to-rgb - rgb: function(hwb) { + rgb: function (hwb) { var h = hwb[0] / 360, wh = hwb[1] / 100, bl = hwb[2] / 100, @@ -56,56 +55,55 @@ var hwb = { // http://alvyray.com/Papers/CG/HWB_JGTv208.pdf - hsv: function(arg){ + hsv: function (arg) { var h = arg[0], w = arg[1], b = arg[2], s, v; //if w+b > 100% - take proportion (how many times ) - if (w + b >= 100){ + if (w + b >= 100) { s = 0; - v = 100 * w/(w+b); + v = 100 * w / (w + b); } //by default - take wiki formula else { - s = 100-(w/(1-b/100)); - v = 100-b; + s = 100 - (w / (1 - b / 100)); + v = 100 - b; } return [h, s, v]; }, - hsl: function(arg){ + hsl: function (arg) { return hsv.hsl(hwb.hsv(arg)); } }; -export default /** @type {import('./index.js').ColorSpace} */ (hwb); +export default (hwb); -//extend rgb -rgb.hwb = function(val) { +// extend rgb +rgb.hwb = function (val) { var r = val[0], - g = val[1], - b = val[2], - h = rgb.hsl(val)[0], - w = 1/255 * Math.min(r, Math.min(g, b)); + g = val[1], + b = val[2], + h = rgb.hsl(val)[0], + w = 1 / 255 * Math.min(r, Math.min(g, b)); - b = 1 - 1/255 * Math.max(r, Math.max(g, b)); + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); return [h, w * 100, b * 100]; }; - -//keep proper hue on 0 values (conversion to rgb loses hue on zero-lightness) -hsv.hwb = function(arg){ +// keep proper hue on 0 values (conversion to rgb loses hue on zero-lightness) +hsv.hwb = function (arg) { var h = arg[0], s = arg[1], v = arg[2]; - return [h, v === 0 ? 0 : (v * (1-s/100)), 100 - v]; + return [h, v === 0 ? 0 : (v * (1 - s / 100)), 100 - v]; }; //extend hsl with proper conversions -hsl.hwb = function(arg){ +hsl.hwb = function (arg) { return hsv.hwb(hsl.hsv(arg)); }; diff --git a/types/coloroid.d.ts b/types/coloroid.d.ts index 5a0bdbc..d245004 100644 --- a/types/coloroid.d.ts +++ b/types/coloroid.d.ts @@ -1,6 +1,7 @@ import { ColorSpace } from "./types"; export interface ColoroidSpace extends ColorSpace { + table: number[][] xyy: (atv: [number, number, number]) => [number, number, number] xyz: (atv: [number, number, number]) => [number, number, number] } diff --git a/types/cubehelix.ts b/types/cubehelix.ts new file mode 100644 index 0000000..c24655c --- /dev/null +++ b/types/cubehelix.ts @@ -0,0 +1,22 @@ +import { ColorSpace } from "./types"; + +export type CubehelixOptions = { + start: number, + rotation: number, + hue: number, + gamma: number +} + +export interface CubehelixSpace extends ColorSpace { + rgb: (rgb: [number, number, number]) => [number] + defaults: CubehelixOptions +} + +declare module "./rgb" { + interface RgbSpace { + cubehelix: (fraction: number | [number], options: CubehelixOptions) => [number, number, number] + } +} + +declare const coloroid: CubehelixSpace; +export default coloroid; diff --git a/types/hcg.d.ts b/types/hcg.d.ts new file mode 100644 index 0000000..797afa2 --- /dev/null +++ b/types/hcg.d.ts @@ -0,0 +1,32 @@ +import { ColorSpace } from "./types"; + +export interface HcgSpace extends ColorSpace { + rgb: (hcg: [number, number, number]) => [number, number, number]; + hsl: (hcg: [number, number, number]) => [number, number, number]; + hsv: (hcg: [number, number, number]) => [number, number, number]; + hwb: (hcg: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hcg: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./hsl" { + interface HslSpace { + hcg: (hsl: [number, number, number]) => [number, number, number] + } +} +declare module "./hsv" { + interface HsvSpace { + hcg: (hsv: [number, number, number]) => [number, number, number] + } +} +declare module "./hwb" { + interface HwbSpace { + hcg: (hwb: [number, number, number]) => [number, number, number] + } +} + +declare const hcg: HcgSpace; +export default hcg; diff --git a/types/hcy.d.ts b/types/hcy.d.ts new file mode 100644 index 0000000..1d706cb --- /dev/null +++ b/types/hcy.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface HcySpace extends ColorSpace { + rgb: (hcy: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hcy: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const hcy: HcySpace; +export default hcy; diff --git a/types/hpluv.d.ts b/types/hpluv.d.ts new file mode 100644 index 0000000..6ef7327 --- /dev/null +++ b/types/hpluv.d.ts @@ -0,0 +1,21 @@ +import { ColorSpace } from "./types"; + +export interface HpluvSpace extends ColorSpace { + lchuv: (hpl: [number, number, number]) => [number, number, number] + xyz: (hpl: [number, number, number]) => [number, number, number] + hsluv: (hpl: [number, number, number]) => [number, number, number] +} + +declare module "./lchuv" { + interface LchuvSpace { + hpluv: (lch: [number, number, number]) => [number, number, number] + } +} +declare module "./xyz" { + interface XyzSpace { + hpluv: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const hcy: HpluvSpace; +export default hcy; diff --git a/types/hsi.d.ts b/types/hsi.d.ts new file mode 100644 index 0000000..8260ca7 --- /dev/null +++ b/types/hsi.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface HsiSpace extends ColorSpace { + rgb: (hsi: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hsi: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const hsi: HsiSpace; +export default hsi; diff --git a/types/hsl.d.ts b/types/hsl.d.ts new file mode 100644 index 0000000..240e323 --- /dev/null +++ b/types/hsl.d.ts @@ -0,0 +1,13 @@ +import { ColorSpace } from "./types"; + +export interface HslSpace extends ColorSpace { + rgb: (hsl: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hsl: (rgb: [number, number, number]) => [number, number, number] + } +} +declare const hsl: HslSpace; +export default hsl; diff --git a/types/hsluv.d.ts b/types/hsluv.d.ts new file mode 100644 index 0000000..1cc64b5 --- /dev/null +++ b/types/hsluv.d.ts @@ -0,0 +1,26 @@ +import { ColorSpace } from "./types"; + +export interface HsluvSpace extends ColorSpace { + lchuv: (hsluv: [number, number, number]) => [number, number, number]; + xyz: (hsluv: [number, number, number]) => [number, number, number]; + hpluv: (hsluv: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hsluv: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./lchuv" { + interface HsvSpace { + hsluv: (lchuv: [number, number, number]) => [number, number, number] + } +} +declare module "./xyz" { + interface HwbSpace { + hsluv: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const hsluv: HsluvSpace; +export default hsluv; diff --git a/types/hsp.d.ts b/types/hsp.d.ts new file mode 100644 index 0000000..6f8fdf2 --- /dev/null +++ b/types/hsp.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface HspSpace extends ColorSpace { + rgb: (hsp: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hsp: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const hsp: HspSpace; +export default hsp; diff --git a/types/hsv.d.ts b/types/hsv.d.ts new file mode 100644 index 0000000..55ca556 --- /dev/null +++ b/types/hsv.d.ts @@ -0,0 +1,20 @@ +import { ColorSpace } from "./types"; + +export interface HsvSpace extends ColorSpace { + rgb: (hsv: [number, number, number]) => [number, number, number]; + hsl: (hsv: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hsv: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./hsl" { + interface HslSpace { + hsv: (hsl: [number, number, number]) => [number, number, number] + } +} + +declare const hsv: HsvSpace; +export default hsv; diff --git a/types/hwb.d.ts b/types/hwb.d.ts new file mode 100644 index 0000000..943822d --- /dev/null +++ b/types/hwb.d.ts @@ -0,0 +1,26 @@ +import { ColorSpace } from "./types"; + +export interface HwbSpace extends ColorSpace { + rgb: (hwb: [number, number, number]) => [number, number, number]; + hsl: (hwb: [number, number, number]) => [number, number, number]; + hsv: (hwb: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + hwb: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./hsl" { + interface HslSpace { + hwb: (hsl: [number, number, number]) => [number, number, number] + } +} +declare module "./hsv" { + interface HsvSpace { + hwb: (hsv: [number, number, number]) => [number, number, number] + } +} + +declare const hwb: HwbSpace; +export default hwb; From e851500fb57f16699b9f27e81117f02b3b6fcf32 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 04:13:47 -0500 Subject: [PATCH 11/16] Add x, y spaces --- types/xvycc.ts | 20 ++++++++++++++++++++ types/yes.d.ts | 14 ++++++++++++++ types/yiq.d.ts | 14 ++++++++++++++ types/ypbpr.d.ts | 14 ++++++++++++++ types/yuv.d.ts | 14 ++++++++++++++ ucs.js | 3 +-- uvw.js | 4 +--- xvycc.js | 30 ++++++++++++++---------------- yes.js | 4 +--- yiq.js | 3 +-- yuv.js | 3 +-- 11 files changed, 95 insertions(+), 28 deletions(-) create mode 100644 types/xvycc.ts create mode 100644 types/yes.d.ts create mode 100644 types/yiq.d.ts create mode 100644 types/ypbpr.d.ts create mode 100644 types/yuv.d.ts diff --git a/types/xvycc.ts b/types/xvycc.ts new file mode 100644 index 0000000..14b57e6 --- /dev/null +++ b/types/xvycc.ts @@ -0,0 +1,20 @@ +import { ColorSpace } from "./types"; + +export interface XvyccSpace extends ColorSpace { + rgb: (xvycc: [number, number, number]) => [number, number, number]; + ypbpr: (xvycc: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + xvycc: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./ypbpr" { + interface HslSpace { + xvycc: (ypbpr: [number, number, number]) => [number, number, number] + } +} + +declare const xvycc: XvyccSpace; +export default xvycc; diff --git a/types/yes.d.ts b/types/yes.d.ts new file mode 100644 index 0000000..dabfa15 --- /dev/null +++ b/types/yes.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface YesSpace extends ColorSpace { + rgb: (yes: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + yes: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const yes: YesSpace; +export default yes; diff --git a/types/yiq.d.ts b/types/yiq.d.ts new file mode 100644 index 0000000..bdf58e1 --- /dev/null +++ b/types/yiq.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface YiqSpace extends ColorSpace { + rgb: (yiq: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + yiq: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const yiq: YiqSpace; +export default yiq; diff --git a/types/ypbpr.d.ts b/types/ypbpr.d.ts new file mode 100644 index 0000000..e192768 --- /dev/null +++ b/types/ypbpr.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface YpbprSpace extends ColorSpace { + rgb: (ypbpr: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + ypbpr: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const ypbpr: YpbprSpace; +export default ypbpr; diff --git a/types/yuv.d.ts b/types/yuv.d.ts new file mode 100644 index 0000000..5b0b93c --- /dev/null +++ b/types/yuv.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface YuvSpace extends ColorSpace { + rgb: (yuv: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + yuv: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const yuv: YuvSpace; +export default yuv; diff --git a/ucs.js b/ucs.js index b1168fd..937f41c 100644 --- a/ucs.js +++ b/ucs.js @@ -7,7 +7,6 @@ */ import xyz from './xyz.js'; -/** @type {Partial} */ var ucs = { name: 'ucs', min: [0,0,0], @@ -16,7 +15,7 @@ var ucs = { alias: ['UCS', 'cie1960'] }; -export default /** @type {import('./index.js').ColorSpace} */ (ucs); +export default (ucs); /** * UCS to XYZ diff --git a/uvw.js b/uvw.js index adb8e1e..a1063fc 100644 --- a/uvw.js +++ b/uvw.js @@ -8,7 +8,6 @@ import ucs from './ucs.js'; import xyz from './xyz.js'; -/** @type {Partial} */ var uvw = { name: 'uvw', min: [-134, -140, 0], @@ -17,12 +16,11 @@ var uvw = { alias: ['UVW', 'cieuvw', 'cie1964'] }; -export default /** @type {import('./index.js').ColorSpace} */ (uvw); +export default (uvw); /** * UVW to XYZ */ -/** @type {import('./index.js').Transform} */ uvw.xyz = function (arg, i, o) { var _u, _v, w, u, v, x, y, z, xn, yn, zn, un, vn; u = arg[0], v = arg[1], w = arg[2]; diff --git a/xvycc.js b/xvycc.js index cc978c0..35e085b 100644 --- a/xvycc.js +++ b/xvycc.js @@ -18,7 +18,6 @@ import rgb from './rgb.js'; import ypbpr from './ypbpr.js'; -/** @type {Partial & {ypbpr: import('./index.js').Transform}} */ var xvycc = { name: 'xvycc', min: [0, 0, 0], @@ -37,10 +36,23 @@ var xvycc = { (cb - 128) / 224, (cr - 128) / 224 ]; + }, + + /** + * xvYCC to RGB + * transform through analog form + * + * @param {Array} arr RGB values + * @param {number} kb + * @param {number} kr + * @return {Array} xvYCC values + */ + rgb: function (arr, kb, kr) { + return ypbpr.rgb(xvycc.ypbpr(arr), kb, kr); } }; -export default /** @type {import('./index.js').ColorSpace} */ (xvycc); +export default (xvycc); /** * From analog to digital form. @@ -59,20 +71,6 @@ ypbpr.xvycc = function (ypbpr) { } -/** - * xvYCC to RGB - * transform through analog form - * - * @param {Array} arr RGB values - * @param {number} kb - * @param {number} kr - * @return {Array} xvYCC values - */ -xvycc.rgb = function (arr, kb, kr) { - return ypbpr.rgb(xvycc.ypbpr(arr), kb, kr); -}; - - /** * RGB to xvYCC * transform through analog form diff --git a/yes.js b/yes.js index dcb3b77..a917fcb 100644 --- a/yes.js +++ b/yes.js @@ -7,7 +7,6 @@ import rgb from './rgb.js'; -/** @type {Partial} */ var yes = { name: 'yes', min: [0,0,0], @@ -15,7 +14,6 @@ var yes = { channel: ['luminance', 'e-factor', 's-factor'] }; -/** @type {import('./index.js').Transform} */ yes.rgb = function(arg){ var y = arg[0], e = arg[1], s = arg[2]; @@ -49,4 +47,4 @@ rgb.yes = function(arg) { }; -export default /** @type {import('./index.js').ColorSpace} */ (yes); +export default yes; diff --git a/yiq.js b/yiq.js index 6fe4b30..9e7c457 100644 --- a/yiq.js +++ b/yiq.js @@ -5,7 +5,7 @@ */ import rgb from './rgb.js'; -var yiq = /** @type {import('./index.js').ColorSpace} */ ({ +var yiq = ({ name: 'yiq', min: [0,-0.5957,-0.5226], max: [1, 0.5957, 0.5226], @@ -13,7 +13,6 @@ var yiq = /** @type {import('./index.js').ColorSpace} */ ({ alias: ['YIQ'] }); -/** @type {import('./index.js').Transform} */ yiq.rgb = function(yiq) { var y = yiq[0], i = yiq[1], diff --git a/yuv.js b/yuv.js index d427eca..9e27a21 100644 --- a/yuv.js +++ b/yuv.js @@ -5,7 +5,7 @@ */ import rgb from './rgb.js'; -var yuv = /** @type {import('./index.js').ColorSpace} */ ({ +var yuv = ({ name: 'yuv', min: [0,-0.5,-0.5], max: [1, 0.5, 0.5], @@ -13,7 +13,6 @@ var yuv = /** @type {import('./index.js').ColorSpace} */ ({ alias: ['YUV', 'EBU'], }); -/** @type {import('./index.js').Transform} */ yuv.rgb = function(yuv) { var y = yuv[0], u = yuv[1], From 34999f22eb7ffadadace5dba7ec99c0d0ecc8c5e Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 04:25:52 -0500 Subject: [PATCH 12/16] Add l spaces --- jpeg.js | 4 ++-- lab.js | 31 +++++++++++++++---------------- labh.js | 21 ++++++++++----------- lchab.js | 3 +-- lchuv.js | 31 +++++++++++++++---------------- lms.js | 5 +---- luv.js | 19 +++++++++---------- types/hsluv.d.ts | 4 ++-- types/index.d.ts | 46 +++++++++++++++++++++++----------------------- types/jpeg.d.ts | 14 ++++++++++++++ types/lab.d.ts | 14 ++++++++++++++ types/labh.d.ts | 14 ++++++++++++++ types/lchab.d.ts | 21 +++++++++++++++++++++ types/lchuv.d.ts | 21 +++++++++++++++++++++ types/lms.d.ts | 14 ++++++++++++++ types/luv.d.ts | 14 ++++++++++++++ types/xvycc.ts | 2 +- 17 files changed, 191 insertions(+), 87 deletions(-) create mode 100644 types/jpeg.d.ts create mode 100644 types/lab.d.ts create mode 100644 types/labh.d.ts create mode 100644 types/lchab.d.ts create mode 100644 types/lchuv.d.ts create mode 100644 types/lms.d.ts create mode 100644 types/luv.d.ts diff --git a/jpeg.js b/jpeg.js index b927b64..38ba3da 100644 --- a/jpeg.js +++ b/jpeg.js @@ -7,7 +7,7 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ + var jpeg = { name: 'jpeg', min: [0, 0, 0], @@ -16,7 +16,7 @@ var jpeg = { alias: ['JPEG'] }; -export default /** @type {import('./index.js').ColorSpace} */ (jpeg); +export default (jpeg); /** diff --git a/lab.js b/lab.js index 32285b3..f3543b2 100644 --- a/lab.js +++ b/lab.js @@ -6,26 +6,25 @@ import xyz from './xyz.js'; -/** @type {Partial} */ var lab = { name: 'lab', - min: [0,-100,-100], - max: [100,100,100], + min: [0, -100, -100], + max: [100, 100, 100], channel: ['lightness', 'a', 'b'], alias: ['LAB', 'cielab'], - xyz: function(lab) { + xyz: function (lab) { var l = lab[0], - a = lab[1], - b = lab[2], - x, y, z, y2; + a = lab[1], + b = lab[2], + x, y, z, y2; if (l <= 8) { y = (l * 100) / 903.3; y2 = (7.787 * (y / 100)) + (16 / 116); } else { y = 100 * Math.pow((l + 16) / 116, 3); - y2 = Math.pow(y / 100, 1/3); + y2 = Math.pow(y / 100, 1 / 3); } //FIXME x is undefined! @@ -40,23 +39,23 @@ var lab = { } }; -export default /** @type {import('./index.js').ColorSpace} */ (lab); +export default (lab); //extend xyz -xyz.lab = function(xyz){ +xyz.lab = function (xyz) { var x = xyz[0], - y = xyz[1], - z = xyz[2], - l, a, b; + y = xyz[1], + z = xyz[2], + l, a, b; x /= 95.047; y /= 100; z /= 108.883; - x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116); + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); l = (116 * y) - 16; a = 500 * (x - y); diff --git a/labh.js b/labh.js index 2f15de0..e666dd4 100644 --- a/labh.js +++ b/labh.js @@ -6,19 +6,18 @@ import xyz from './xyz.js'; -/** @type {Partial} */ var labh = { name: 'labh', //mins/maxes are taken from colormine //FIXME: check whether mins/maxes correct - min: [0,-128,-128], - max: [100,128,128], + min: [0, -128, -128], + max: [100, 128, 128], channel: ['lightness', 'a', 'b'], alias: ['LABh', 'hunter-lab', 'hlab'], //maths are taken from EasyRGB - xyz: function(lab) { + xyz: function (lab) { var l = lab[0], a = lab[1], b = lab[2]; var _y = l / 10; @@ -26,22 +25,22 @@ var labh = { var _z = b / 7 * l / 10; var y = _y * _y; - var x = ( _x + y ) / 1.02; - var z = -( _z - y ) / 0.847; + var x = (_x + y) / 1.02; + var z = -(_z - y) / 0.847; - return [x,y,z]; + return [x, y, z]; } }; -export default /** @type {import('./index.js').ColorSpace} */ (labh); +export default (labh); //extend xyz -xyz.labh = function(xyz){ +xyz.labh = function (xyz) { var x = xyz[0], y = xyz[1], z = xyz[2]; var _y12 = Math.sqrt(y); var l = 10 * _y12; - var a = y === 0 ? 0 : 17.5 * ((( 1.02 * x ) - y ) / _y12 ); - var b = y === 0 ? 0 : 7 * ( ( y - ( 0.847 * z ) ) / _y12 ); + var a = y === 0 ? 0 : 17.5 * (((1.02 * x) - y) / _y12); + var b = y === 0 ? 0 : 7 * ((y - (0.847 * z)) / _y12); return [l, a, b]; }; diff --git a/lchab.js b/lchab.js index 6e21398..0131635 100644 --- a/lchab.js +++ b/lchab.js @@ -8,7 +8,6 @@ import lab from './lab.js'; //cylindrical lab -/** @type {Partial & {lab: import('./index.js').Transform}} */ var lchab = { name: 'lchab', min: [0,0,0], @@ -55,4 +54,4 @@ xyz.lchab = function(arg){ }; -export default /** @type {import('./index.js').ColorSpace} */ (lchab); +export default (lchab); diff --git a/lchuv.js b/lchuv.js index d9e3d45..4c240ec 100644 --- a/lchuv.js +++ b/lchuv.js @@ -6,20 +6,19 @@ import luv from './luv.js'; import xyz from './xyz.js'; -//cylindrical luv -/** @type {Partial & {luv: import('./index.js').Transform}} */ +// cylindrical luv var lchuv = { name: 'lchuv', channel: ['lightness', 'chroma', 'hue'], alias: ['LCHuv', 'cielchuv'], - min: [0,0,0], - max: [100,100,360], + min: [0, 0, 0], + max: [100, 100, 360], - luv: function(luv){ + luv: function (luv) { var l = luv[0], - c = luv[1], - h = luv[2], - u, v, hr; + c = luv[1], + h = luv[2], + u, v, hr; hr = h / 360 * 2 * Math.PI; u = c * Math.cos(hr); @@ -27,26 +26,26 @@ var lchuv = { return [l, u, v]; }, - xyz: function(arg) { + xyz: function (arg) { return luv.xyz(lchuv.luv(arg)); } }; -export default /** @type {import('./index.js').ColorSpace} */ (lchuv); +export default (lchuv); -luv.lchuv = function(luv){ +luv.lchuv = function (luv) { var l = luv[0], u = luv[1], v = luv[2]; - var c = Math.sqrt(u*u + v*v); - var hr = Math.atan2(v,u); + var c = Math.sqrt(u * u + v * v); + var hr = Math.atan2(v, u); var h = hr * 360 / 2 / Math.PI; if (h < 0) { h += 360; } - return [l,c,h] + return [l, c, h] }; -xyz.lchuv = function(arg){ - return luv.lchuv(xyz.luv(arg)); +xyz.lchuv = function (arg) { + return luv.lchuv(xyz.luv(arg)); }; diff --git a/lms.js b/lms.js index c1a8355..467365d 100644 --- a/lms.js +++ b/lms.js @@ -12,9 +12,6 @@ */ import xyz from './xyz.js'; -/** @typedef {{matrix: Object>}} LMSSpecific */ - -/** @type {Partial & LMSSpecific} */ var lms = { name: 'lms', min: [0,0,0], @@ -51,7 +48,7 @@ var lms = { } }; -export default /** @type {import('./index.js').ColorSpace & LMSSpecific} */ (lms); +export default lms; lms.xyz = function(arg, matrix){ var l = arg[0], m = arg[1], s = arg[2]; diff --git a/luv.js b/luv.js index c47b687..fd80ff7 100644 --- a/luv.js +++ b/luv.js @@ -5,23 +5,22 @@ */ import xyz from './xyz.js'; -/** @type {Partial} */ var luv = { name: 'luv', //NOTE: luv has no rigidly defined limits //easyrgb fails to get proper coords //boronine states no rigid limits //colorMine refers this ones: - min: [0,-134,-140], - max: [100,224,122], + min: [0, -134, -140], + max: [100, 224, 122], channel: ['lightness', 'u', 'v'], alias: ['LUV', 'cieluv', 'cie1976'], - xyz: function(arg, i, o){ + xyz: function (arg, i, o) { var _u, _v, l, u, v, x, y, z, xn, yn, zn, un, vn; l = arg[0], u = arg[1], v = arg[2]; - if (l === 0) return [0,0,0]; + if (l === 0) return [0, 0, 0]; //get constants //var e = 0.008856451679035631; //(6/29)^3 @@ -44,7 +43,7 @@ var luv = { _u = u / (13 * l) + un || 0; _v = v / (13 * l) + vn || 0; - y = l > 8 ? yn * Math.pow( (l + 16) / 116 , 3) : yn * l * k; + y = l > 8 ? yn * Math.pow((l + 16) / 116, 3) : yn * l * k; //wikipedia method x = y * 9 * _u / (4 * _v) || 0; @@ -59,13 +58,13 @@ var luv = { } }; -export default /** @type {import('./index.js').ColorSpace} */ (luv); +export default (luv); // http://www.brucelindbloom.com/index.html?Equations.html // https://github.com/boronine/husl/blob/master/husl.coffee //i - illuminant //o - observer -xyz.luv = function(arg, i, o) { +xyz.luv = function (arg, i, o) { var _u, _v, l, u, v, x, y, z, xn, yn, zn, un, vn; //get constants @@ -90,9 +89,9 @@ xyz.luv = function(arg, i, o) { _u = (4 * x) / (x + (15 * y) + (3 * z)) || 0; _v = (9 * y) / (x + (15 * y) + (3 * z)) || 0; - var yr = y/yn; + var yr = y / yn; - l = yr <= e ? k * yr : 116 * Math.pow(yr, 1/3) - 16; + l = yr <= e ? k * yr : 116 * Math.pow(yr, 1 / 3) - 16; u = 13 * l * (_u - un); v = 13 * l * (_v - vn); diff --git a/types/hsluv.d.ts b/types/hsluv.d.ts index 1cc64b5..c36b75f 100644 --- a/types/hsluv.d.ts +++ b/types/hsluv.d.ts @@ -12,12 +12,12 @@ declare module "./rgb" { } } declare module "./lchuv" { - interface HsvSpace { + interface LchuvSpace { hsluv: (lchuv: [number, number, number]) => [number, number, number] } } declare module "./xyz" { - interface HwbSpace { + interface XyzSpace { hsluv: (xyz: [number, number, number]) => [number, number, number] } } diff --git a/types/index.d.ts b/types/index.d.ts index 4d54622..fa8d26d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,20 +2,20 @@ export * from './cmy'; export * from './cmyk'; export * from './coloroid'; -// export * from './cubehelix'; -// export * from './hcg'; -// export * from './hcy'; -// export * from './hpluv'; -// export * from './hsi'; -// export * from './hsl'; -// export * from './hsluv'; -// export * from './hsp'; -// export * from './hsv'; -// export * from './hwb'; -// export * from './jpeg'; -// export * from './lab'; -// export * from './labh'; -// export * from './lchab'; +export * from './cubehelix'; +export * from './hcg'; +export * from './hcy'; +export * from './hpluv'; +export * from './hsi'; +export * from './hsl'; +export * from './hsluv'; +export * from './hsp'; +export * from './hsv'; +export * from './hwb'; +export * from './jpeg'; +export * from './lab'; +export * from './labh'; +export * from './lchab'; // export * from './lchuv'; // export * from './lms'; // export * from './luv'; @@ -25,14 +25,14 @@ export * from './rgb'; // export * from './tsl'; // export * from './ucs'; // export * from './uvw'; -// export * from './xvycc'; +export * from './xvycc'; export * from './xyz'; export * from './xyy'; -// export * from './ycbcr'; -// export * from './yccbccrc'; -// export * from './ycgco'; -// export * from './ydbdr'; -// export * from './yes'; -// export * from './yiq'; -// export * from './ypbpr'; -// export * from './yuv'; +export * from './ycbcr'; +export * from './yccbccrc'; +export * from './ycgco'; +export * from './ydbdr'; +export * from './yes'; +export * from './yiq'; +export * from './ypbpr'; +export * from './yuv'; diff --git a/types/jpeg.d.ts b/types/jpeg.d.ts new file mode 100644 index 0000000..27303bf --- /dev/null +++ b/types/jpeg.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface JpegSpace extends ColorSpace { + rgb: (jpeg: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + jpeg: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const jpeg: JpegSpace; +export default jpeg; diff --git a/types/lab.d.ts b/types/lab.d.ts new file mode 100644 index 0000000..9558b24 --- /dev/null +++ b/types/lab.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface LabSpace extends ColorSpace { + xyz: (lab: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + lab: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const lab: LabSpace; +export default lab; diff --git a/types/labh.d.ts b/types/labh.d.ts new file mode 100644 index 0000000..5cbba45 --- /dev/null +++ b/types/labh.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface LabhSpace extends ColorSpace { + xyz: (labh: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + labh: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const labh: LabhSpace; +export default labh; diff --git a/types/lchab.d.ts b/types/lchab.d.ts new file mode 100644 index 0000000..ddec8c2 --- /dev/null +++ b/types/lchab.d.ts @@ -0,0 +1,21 @@ +import { ColorSpace } from "./types"; + +export interface LchabSpace extends ColorSpace { + xyz: (lchab: [number, number, number]) => [number, number, number]; + lab: (lchab: [number, number, number]) => [number, number, number]; +} + +declare module "./lab" { + interface LabSpace { + lchab: (lab: [number, number, number]) => [number, number, number] + } +} + +declare module "./xyz" { + interface XyzSpace { + lchab: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const lchab: LchabSpace; +export default lchab; diff --git a/types/lchuv.d.ts b/types/lchuv.d.ts new file mode 100644 index 0000000..de947c9 --- /dev/null +++ b/types/lchuv.d.ts @@ -0,0 +1,21 @@ +import { ColorSpace } from "./types"; + +export interface LchuvSpace extends ColorSpace { + xyz: (lchuv: [number, number, number]) => [number, number, number]; + luv: (lchuv: [number, number, number]) => [number, number, number]; +} + +declare module "./luv" { + interface LabSpace { + lchuv: (luv: [number, number, number]) => [number, number, number] + } +} + +declare module "./xyz" { + interface XyzSpace { + lchuv: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const lchuv: LchuvSpace; +export default lchuv; diff --git a/types/lms.d.ts b/types/lms.d.ts new file mode 100644 index 0000000..6037d48 --- /dev/null +++ b/types/lms.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface LmsSpace extends ColorSpace { + xyz: (lms: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + lms: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const lms: LmsSpace; +export default lms; diff --git a/types/luv.d.ts b/types/luv.d.ts new file mode 100644 index 0000000..cacade0 --- /dev/null +++ b/types/luv.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface LuvSpace extends ColorSpace { + xyz: (luv: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + luv: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const luv: LuvSpace; +export default luv; diff --git a/types/xvycc.ts b/types/xvycc.ts index 14b57e6..5928ef3 100644 --- a/types/xvycc.ts +++ b/types/xvycc.ts @@ -11,7 +11,7 @@ declare module "./rgb" { } } declare module "./ypbpr" { - interface HslSpace { + interface YpbprSpace { xvycc: (ypbpr: [number, number, number]) => [number, number, number] } } From 6d88a8b023f19e03e4cd558f41b4d448a47a2f5c Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 04:38:09 -0500 Subject: [PATCH 13/16] Finish up all spaces types --- hsl.js | 3 +-- hsp.js | 6 +++--- hsv.js | 6 +++--- munsell.js | 2 +- osaucs.js | 4 ++-- tsl.js | 3 +-- types/index.d.ts | 16 ++++++++-------- types/munsell.d.ts | 8 ++++++++ types/osaucs.d.ts | 14 ++++++++++++++ types/tsl.d.ts | 14 ++++++++++++++ types/ucs.d.ts | 14 ++++++++++++++ types/uvw.d.ts | 21 +++++++++++++++++++++ types/ycbcr.d.ts | 20 ++++++++++++++++++++ types/yccbccrc.ts | 14 ++++++++++++++ types/ycgco.d.ts | 14 ++++++++++++++ types/ydbdr.d.ts | 20 ++++++++++++++++++++ ycbcr.js | 3 +-- yccbccrc.js | 3 +-- ycgco.js | 4 ++-- ydbdr.js | 4 ++-- ypbpr.js | 2 +- 21 files changed, 165 insertions(+), 30 deletions(-) create mode 100644 types/munsell.d.ts create mode 100644 types/osaucs.d.ts create mode 100644 types/tsl.d.ts create mode 100644 types/ucs.d.ts create mode 100644 types/uvw.d.ts create mode 100644 types/ycbcr.d.ts create mode 100644 types/yccbccrc.ts create mode 100644 types/ycgco.d.ts create mode 100644 types/ydbdr.d.ts diff --git a/hsl.js b/hsl.js index 98acedb..fdf4cc0 100644 --- a/hsl.js +++ b/hsl.js @@ -3,7 +3,6 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ var hsl = { name: 'hsl', min: [0,0,0], @@ -34,7 +33,7 @@ var hsl = { } }; -export default /** @type {import('./index.js').ColorSpace} */ (hsl); +export default (hsl); //extend rgb diff --git a/hsp.js b/hsp.js index 183f990..0194f14 100644 --- a/hsp.js +++ b/hsp.js @@ -102,9 +102,9 @@ export default hsp; //append rgb rgb.hsp = function (rgb) { - var r = parseInt(/** @type {?} */ (rgb[0]), 10), - g = parseInt(/** @type {?} */ (rgb[1]), 10), - b = parseInt(/** @type {?} */ (rgb[2]), 10), + var r = parseInt((rgb[0]), 10), + g = parseInt((rgb[1]), 10), + b = parseInt((rgb[2]), 10), h, s, p; // Calculate the Perceived brightness diff --git a/hsv.js b/hsv.js index 70f8712..198b472 100644 --- a/hsv.js +++ b/hsv.js @@ -4,7 +4,7 @@ import rgb from './rgb.js'; import hsl from './hsl.js'; -/** @type {Partial} */ + var hsv = { name: 'hsv', min: [0,0,0], @@ -16,7 +16,7 @@ var hsv = { var h = hsv[0] / 60, s = hsv[1] / 100, v = hsv[2] / 100, - hi = /** @type {0 | 1 | 2 | 3 | 4 | 5} */ (Math.floor(h) % 6); + hi = (Math.floor(h) % 6); var f = h - Math.floor(h), p = 255 * v * (1 - s), @@ -56,7 +56,7 @@ var hsv = { } }; -export default /** @type {import('./index.js').ColorSpace} */ (hsv); +export default (hsv); //append rgb diff --git a/munsell.js b/munsell.js index ed9cc85..cbadbdb 100644 --- a/munsell.js +++ b/munsell.js @@ -6,7 +6,6 @@ var munsell = { alias: [], min: [], max: [], - //hue, value, chroma channel: ['H', 'V', 'C'] } @@ -14,6 +13,7 @@ var munsell = { /** * http://www.pp.bme.hu/ar/article/view/2395/1500 */ +// FIXME: obviously unfinished munsell.coloroid = function (cv) { var c = arg[0], vm = arg[1]; diff --git a/osaucs.js b/osaucs.js index 6d53d9c..598858d 100644 --- a/osaucs.js +++ b/osaucs.js @@ -6,7 +6,7 @@ import xyz from './xyz.js'; -/** @type {Partial} */ + var osaucs = { name: 'osaucs', alias: ['OSA-UCS'], @@ -73,4 +73,4 @@ xyz.osaucs = function (arg) { }; -export default /** @type {import('./index.js').ColorSpace} */ (osaucs); +export default (osaucs); diff --git a/tsl.js b/tsl.js index 4517fec..d24d6b4 100644 --- a/tsl.js +++ b/tsl.js @@ -8,7 +8,6 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ var tsl = { name: 'tsl', min: [0,0,0], @@ -17,7 +16,7 @@ var tsl = { alias: ['TSL'], }; -export default /** @type {import('./index.js').ColorSpace} */ (tsl); +export default (tsl); /** * TSL to RGB diff --git a/types/index.d.ts b/types/index.d.ts index fa8d26d..bc1ef52 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -16,15 +16,15 @@ export * from './jpeg'; export * from './lab'; export * from './labh'; export * from './lchab'; -// export * from './lchuv'; -// export * from './lms'; -// export * from './luv'; -// export * from './munsell'; -// export * from './osaucs'; +export * from './lchuv'; +export * from './lms'; +export * from './luv'; +export * from './munsell'; +export * from './osaucs'; export * from './rgb'; -// export * from './tsl'; -// export * from './ucs'; -// export * from './uvw'; +export * from './tsl'; +export * from './ucs'; +export * from './uvw'; export * from './xvycc'; export * from './xyz'; export * from './xyy'; diff --git a/types/munsell.d.ts b/types/munsell.d.ts new file mode 100644 index 0000000..104e612 --- /dev/null +++ b/types/munsell.d.ts @@ -0,0 +1,8 @@ +import { ColorSpace } from "./types"; + +export interface MunsellSpace extends ColorSpace { + coloroid: (munsell: [number, number, number]) => [number, number, number]; +} + +declare const munsell: MunsellSpace; +export default munsell; diff --git a/types/osaucs.d.ts b/types/osaucs.d.ts new file mode 100644 index 0000000..50954a7 --- /dev/null +++ b/types/osaucs.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface OsaucsSpace extends ColorSpace { + xyz: (osaucs: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + osaucs: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const osaucs: OsaucsSpace; +export default osaucs; diff --git a/types/tsl.d.ts b/types/tsl.d.ts new file mode 100644 index 0000000..e3f6df2 --- /dev/null +++ b/types/tsl.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface TslSpace extends ColorSpace { + rgb: (tsl: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + tsl: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const tsl: TslSpace; +export default tsl; diff --git a/types/ucs.d.ts b/types/ucs.d.ts new file mode 100644 index 0000000..1f95c64 --- /dev/null +++ b/types/ucs.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface UcsSpace extends ColorSpace { + xyz: (ucs: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + ucs: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare const ucs: UcsSpace; +export default ucs; diff --git a/types/uvw.d.ts b/types/uvw.d.ts new file mode 100644 index 0000000..8383612 --- /dev/null +++ b/types/uvw.d.ts @@ -0,0 +1,21 @@ +import { ColorSpace } from "./types"; + +export interface UvwSpace extends ColorSpace { + xyz: (uvw: [number, number, number]) => [number, number, number]; + ucs: (uvw: [number, number, number]) => [number, number, number]; +} + +declare module "./xyz" { + interface XyzSpace { + uvw: (xyz: [number, number, number]) => [number, number, number] + } +} + +declare module "./ucs" { + interface UcsSpace { + uvw: (ucs: [number, number, number]) => [number, number, number] + } +} + +declare const uvw: UvwSpace; +export default uvw; diff --git a/types/ycbcr.d.ts b/types/ycbcr.d.ts new file mode 100644 index 0000000..b8e6717 --- /dev/null +++ b/types/ycbcr.d.ts @@ -0,0 +1,20 @@ +import { ColorSpace } from "./types"; + +export interface YcbcrSpace extends ColorSpace { + rgb: (ycbcr: [number, number, number]) => [number, number, number]; + ypbpr: (ycbcr: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + ycbcr: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./ypbpr" { + interface YpbprSpace { + ycbcr: (ypbpr: [number, number, number]) => [number, number, number] + } +} + +declare const ycbcr: YcbcrSpace; +export default ycbcr; diff --git a/types/yccbccrc.ts b/types/yccbccrc.ts new file mode 100644 index 0000000..83e59d5 --- /dev/null +++ b/types/yccbccrc.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface YccbccrcSpace extends ColorSpace { + rgb: (yccbccrc: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + yccbccrc: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const yccbccrc: YccbccrcSpace; +export default yccbccrc; diff --git a/types/ycgco.d.ts b/types/ycgco.d.ts new file mode 100644 index 0000000..445ea23 --- /dev/null +++ b/types/ycgco.d.ts @@ -0,0 +1,14 @@ +import { ColorSpace } from "./types"; + +export interface YcgcoSpace extends ColorSpace { + rgb: (ycgco: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + ycgco: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const ycgco: YcgcoSpace; +export default ycgco; diff --git a/types/ydbdr.d.ts b/types/ydbdr.d.ts new file mode 100644 index 0000000..7d1462c --- /dev/null +++ b/types/ydbdr.d.ts @@ -0,0 +1,20 @@ +import { ColorSpace } from "./types"; + +export interface YdbdrSpace extends ColorSpace { + rgb: (ydbdr: [number, number, number]) => [number, number, number]; + yuv: (ydbdr: [number, number, number]) => [number, number, number]; +} + +declare module "./rgb" { + interface RgbSpace { + ydbdr: (rgb: [number, number, number]) => [number, number, number] + } +} +declare module "./yuv" { + interface YuvSpace { + ydbdr: (yuv: [number, number, number]) => [number, number, number] + } +} + +declare const ydbdr: YdbdrSpace; +export default ydbdr; diff --git a/ycbcr.js b/ycbcr.js index 93ddda2..25b39d5 100644 --- a/ycbcr.js +++ b/ycbcr.js @@ -9,7 +9,6 @@ import rgb from './rgb.js' import ypbpr from './ypbpr.js' -/** @type {Partial & {ypbpr: import('./index.js').Transform}} */ var ycbcr = { name: 'ycbcr', min: [16, 16, 16], @@ -77,4 +76,4 @@ rgb.ycbcr = function(arr, kb, kr) { }; -export default /** @type {import('./index.js').ColorSpace} */ (ycbcr); +export default (ycbcr); diff --git a/yccbccrc.js b/yccbccrc.js index 6a2201d..70c873c 100644 --- a/yccbccrc.js +++ b/yccbccrc.js @@ -6,7 +6,6 @@ import rgb from './rgb.js'; import ypbpr from './ypbpr.js'; -/** @type {Partial} */ var yccbccrc = { name: 'yccbccrc', min: [0, -0.5, -0.5], @@ -40,4 +39,4 @@ rgb.yccbccrc = function(arr) { }; -export default /** @type {import('./index.js').ColorSpace} */ (yccbccrc); +export default (yccbccrc); diff --git a/ycgco.js b/ycgco.js index be0297b..7ce50bb 100644 --- a/ycgco.js +++ b/ycgco.js @@ -5,7 +5,7 @@ */ import rgb from './rgb.js'; -/** @type {Partial} */ + var ycgco = { name: 'ycgco', min: [0, -0.5, -0.5], @@ -55,4 +55,4 @@ rgb.ycgco = function(arr) { }; -export default /** @type {import('./index.js').ColorSpace} */ (ycgco); +export default (ycgco); diff --git a/ydbdr.js b/ydbdr.js index 582b34a..7cf4df5 100644 --- a/ydbdr.js +++ b/ydbdr.js @@ -7,7 +7,7 @@ import rgb from './rgb.js'; import yuv from './yuv.js'; -/** @type {Partial} */ + var ydbdr = { name: 'ydbdr', min: [0,-1.333,-1.333], @@ -71,4 +71,4 @@ ydbdr.yuv = function (ydbdr) { }; -export default /** @type {import('./index.js').ColorSpace} */ (ydbdr); +export default (ydbdr); diff --git a/ypbpr.js b/ypbpr.js index e43d848..9f69fe8 100644 --- a/ypbpr.js +++ b/ypbpr.js @@ -10,7 +10,7 @@ */ import rgb from './rgb.js'; -var ypbpr = /** @type {import('./index.js').ColorSpace} */ ({ +var ypbpr = ({ name: 'ypbpr', min: [0,-0.5,-0.5], max: [1, 0.5, 0.5], From 2c96063356a426db7009d4efa41bc94ef0d5fe84 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 04:46:35 -0500 Subject: [PATCH 14/16] Update index --- index.js | 25 +++++++++---------------- types/index.d.ts | 7 +++++++ types/types.d.ts | 4 ++++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index c402a76..a052ad4 100644 --- a/index.js +++ b/index.js @@ -42,31 +42,22 @@ import osaucs from './osaucs.js' import hsp from './hsp.js' -/** @typedef {(color: Array, ...rest: Array<*>) => Array} Transform */ - -/** @typedef {{[key in SpaceId]: Transform}} ColorSpaceTransforms */ - /** - * @typedef {Object} ColorSpaceBase - * @property {SpaceId} name - * @property {Array} min - * @property {Array} max - * @property {Array} channel - * @property {Array} [alias] + * Dict with all color spaces + * + * @type {{[key in SpaceId]: ColorSpace}} */ - -/** @typedef {ColorSpaceBase & ColorSpaceTransforms} ColorSpace */ - - -const spaces = /** @type {{[key in SpaceId]: ColorSpace}} */ ({}); +const spaces = {}; export default spaces; + /** + * Register new color space and conversions with all existing spaces + * * @param {ColorSpace} newSpace */ export function register (newSpace) { const newSpaceName = newSpace.name; - /** @type {SpaceId} */ var existingSpaceName; for (existingSpaceName in spaces) { if (!newSpace[existingSpaceName]) newSpace[existingSpaceName] = createConverter(newSpace, existingSpaceName); @@ -78,6 +69,8 @@ export function register (newSpace) { } /** + * Creates a color space converter function. + * * @param {ColorSpace} fromSpace * @param {SpaceId} toSpaceName * @returns {Transform} diff --git a/types/index.d.ts b/types/index.d.ts index bc1ef52..262278f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,10 @@ +import { SpaceId, ColorSpace } from './types'; + +declare const spaces: Record; +export default spaces; + +export * from './types'; + // export * from './ciecam'; export * from './cmy'; export * from './cmyk'; diff --git a/types/types.d.ts b/types/types.d.ts index acb0cae..a669f96 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -7,3 +7,7 @@ export interface ColorSpace { channel: string[]; alias?: string[]; } + +export type Transform = (color: number[], ...rest: any[]) => number[]; + +export type ColorSpaceTransforms = { [key in SpaceId]?: Transform }; From 7f51c86e4d85d6deb44c4b1bed404782a56a9211 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 04:55:14 -0500 Subject: [PATCH 15/16] Fix index.d --- types/index.d.ts | 5 ++++- types/lchuv.d.ts | 2 +- types/types.d.ts | 4 ---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 262278f..bce1b15 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,6 +1,9 @@ import { SpaceId, ColorSpace } from './types'; -declare const spaces: Record; +export type Transform = (color: number[], ...rest: any[]) => number[]; +export type ColorSpaceTransforms = { [key in SpaceId]?: Transform }; + +declare const spaces: { [key in SpaceId]: ColorSpace & ColorSpaceTransforms }; export default spaces; export * from './types'; diff --git a/types/lchuv.d.ts b/types/lchuv.d.ts index de947c9..276d151 100644 --- a/types/lchuv.d.ts +++ b/types/lchuv.d.ts @@ -6,7 +6,7 @@ export interface LchuvSpace extends ColorSpace { } declare module "./luv" { - interface LabSpace { + interface LuvSpace { lchuv: (luv: [number, number, number]) => [number, number, number] } } diff --git a/types/types.d.ts b/types/types.d.ts index a669f96..acb0cae 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -7,7 +7,3 @@ export interface ColorSpace { channel: string[]; alias?: string[]; } - -export type Transform = (color: number[], ...rest: any[]) => number[]; - -export type ColorSpaceTransforms = { [key in SpaceId]?: Transform }; From ba6a217256397b6271ab1d35f1b4e458fec00cc3 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 31 Jan 2025 15:51:25 -0500 Subject: [PATCH 16/16] Finish up types --- index.js | 3 +- types/cmy.d.ts | 5 +- types/cmyk.d.ts | 7 +- types/color-space.d.ts | 7 ++ types/coloroid.d.ts | 3 +- types/cubehelix.d.ts | 23 ++++++ types/cubehelix.ts | 22 ------ types/hcg.d.ts | 3 +- types/hcy.d.ts | 3 +- types/hpluv.d.ts | 3 +- types/hsi.d.ts | 3 +- types/hsl.d.ts | 3 +- types/hsluv.d.ts | 3 +- types/hsp.d.ts | 3 +- types/hsv.d.ts | 3 +- types/hwb.d.ts | 3 +- types/index.d.ts | 173 ++++++++++++++++++++++++++++++----------- types/jpeg.d.ts | 3 +- types/lab.d.ts | 3 +- types/labh.d.ts | 3 +- types/lchab.d.ts | 3 +- types/lchuv.d.ts | 3 +- types/lms.d.ts | 3 +- types/luv.d.ts | 3 +- types/munsell.d.ts | 3 +- types/osaucs.d.ts | 3 +- types/rgb.d.ts | 4 +- types/tsl.d.ts | 3 +- types/types.d.ts | 9 --- types/ucs.d.ts | 3 +- types/uvw.d.ts | 3 +- types/xvycc.ts | 3 +- types/xyy.d.ts | 3 +- types/xyz.d.ts | 3 +- types/ycbcr.d.ts | 3 +- types/yccbccrc.ts | 3 +- types/ycgco.d.ts | 3 +- types/ydbdr.d.ts | 3 +- types/yes.d.ts | 3 +- types/yiq.d.ts | 3 +- types/ypbpr.d.ts | 3 +- types/yuv.d.ts | 3 +- 42 files changed, 235 insertions(+), 117 deletions(-) create mode 100644 types/color-space.d.ts create mode 100644 types/cubehelix.d.ts delete mode 100644 types/cubehelix.ts delete mode 100644 types/types.d.ts diff --git a/index.js b/index.js index a052ad4..a7f27da 100644 --- a/index.js +++ b/index.js @@ -58,8 +58,7 @@ export default spaces; */ export function register (newSpace) { const newSpaceName = newSpace.name; - var existingSpaceName; - for (existingSpaceName in spaces) { + for (const existingSpaceName in spaces) { if (!newSpace[existingSpaceName]) newSpace[existingSpaceName] = createConverter(newSpace, existingSpaceName); const existingSpace = spaces[existingSpaceName] diff --git a/types/cmy.d.ts b/types/cmy.d.ts index 931e3c6..6ed9d8a 100644 --- a/types/cmy.d.ts +++ b/types/cmy.d.ts @@ -1,7 +1,8 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface CmySpace extends ColorSpace { - rgb: (cmy: [number, number, number]) => [number, number, number]; + name: 'cmy' + rgb: (cmy: [number, number, number]) => [number, number, number] } declare module "./rgb" { diff --git a/types/cmyk.d.ts b/types/cmyk.d.ts index a135b06..a9a023c 100644 --- a/types/cmyk.d.ts +++ b/types/cmyk.d.ts @@ -1,7 +1,8 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; -export interface CmykSpace extends ColorSpace { - rgb: (cmyk: [number, number, number, number]) => [number, number, number]; +export interface CmykSpace extends ColorSpace<[number, number, number, number]> { + name: 'cmyk' + rgb: (cmyk: [number, number, number, number]) => [number, number, number] } declare module "./rgb" { diff --git a/types/color-space.d.ts b/types/color-space.d.ts new file mode 100644 index 0000000..657ef4d --- /dev/null +++ b/types/color-space.d.ts @@ -0,0 +1,7 @@ +export interface ColorSpace { + name: string; + min: T; + max: T; + channel: { [K in keyof T]: string }; + alias?: string[]; +} diff --git a/types/coloroid.d.ts b/types/coloroid.d.ts index d245004..75097dc 100644 --- a/types/coloroid.d.ts +++ b/types/coloroid.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface ColoroidSpace extends ColorSpace { + name: 'coloroid' table: number[][] xyy: (atv: [number, number, number]) => [number, number, number] xyz: (atv: [number, number, number]) => [number, number, number] diff --git a/types/cubehelix.d.ts b/types/cubehelix.d.ts new file mode 100644 index 0000000..d86a2e6 --- /dev/null +++ b/types/cubehelix.d.ts @@ -0,0 +1,23 @@ +import { ColorSpace } from "./color-space"; + +export type CubehelixOptions = { + start: number, + rotation: number, + hue: number, + gamma: number +} + +export interface CubehelixSpace extends ColorSpace<[number]> { + name: 'cubehelix' + rgb: (fraction: [number], options?: CubehelixOptions) => [number] + defaults: CubehelixOptions +} + +declare module "./rgb" { + interface RgbSpace { + cubehelix: (rgb: [number, number, number]) => [number, number, number] + } +} + +declare const coloroid: CubehelixSpace; +export default coloroid; diff --git a/types/cubehelix.ts b/types/cubehelix.ts deleted file mode 100644 index c24655c..0000000 --- a/types/cubehelix.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ColorSpace } from "./types"; - -export type CubehelixOptions = { - start: number, - rotation: number, - hue: number, - gamma: number -} - -export interface CubehelixSpace extends ColorSpace { - rgb: (rgb: [number, number, number]) => [number] - defaults: CubehelixOptions -} - -declare module "./rgb" { - interface RgbSpace { - cubehelix: (fraction: number | [number], options: CubehelixOptions) => [number, number, number] - } -} - -declare const coloroid: CubehelixSpace; -export default coloroid; diff --git a/types/hcg.d.ts b/types/hcg.d.ts index 797afa2..6969c80 100644 --- a/types/hcg.d.ts +++ b/types/hcg.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HcgSpace extends ColorSpace { + name: 'hcg' rgb: (hcg: [number, number, number]) => [number, number, number]; hsl: (hcg: [number, number, number]) => [number, number, number]; hsv: (hcg: [number, number, number]) => [number, number, number]; diff --git a/types/hcy.d.ts b/types/hcy.d.ts index 1d706cb..532cb41 100644 --- a/types/hcy.d.ts +++ b/types/hcy.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HcySpace extends ColorSpace { + name: 'hcy' rgb: (hcy: [number, number, number]) => [number, number, number]; } diff --git a/types/hpluv.d.ts b/types/hpluv.d.ts index 6ef7327..b172e9e 100644 --- a/types/hpluv.d.ts +++ b/types/hpluv.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HpluvSpace extends ColorSpace { + name: 'hpluv' lchuv: (hpl: [number, number, number]) => [number, number, number] xyz: (hpl: [number, number, number]) => [number, number, number] hsluv: (hpl: [number, number, number]) => [number, number, number] diff --git a/types/hsi.d.ts b/types/hsi.d.ts index 8260ca7..038cc95 100644 --- a/types/hsi.d.ts +++ b/types/hsi.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HsiSpace extends ColorSpace { + name: 'hsi' rgb: (hsi: [number, number, number]) => [number, number, number]; } diff --git a/types/hsl.d.ts b/types/hsl.d.ts index 240e323..d0643c7 100644 --- a/types/hsl.d.ts +++ b/types/hsl.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HslSpace extends ColorSpace { + name: 'hsl' rgb: (hsl: [number, number, number]) => [number, number, number]; } diff --git a/types/hsluv.d.ts b/types/hsluv.d.ts index c36b75f..704923a 100644 --- a/types/hsluv.d.ts +++ b/types/hsluv.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HsluvSpace extends ColorSpace { + name: 'hsluv' lchuv: (hsluv: [number, number, number]) => [number, number, number]; xyz: (hsluv: [number, number, number]) => [number, number, number]; hpluv: (hsluv: [number, number, number]) => [number, number, number]; diff --git a/types/hsp.d.ts b/types/hsp.d.ts index 6f8fdf2..8d42df1 100644 --- a/types/hsp.d.ts +++ b/types/hsp.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HspSpace extends ColorSpace { + name: 'hsp' rgb: (hsp: [number, number, number]) => [number, number, number]; } diff --git a/types/hsv.d.ts b/types/hsv.d.ts index 55ca556..d00933a 100644 --- a/types/hsv.d.ts +++ b/types/hsv.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HsvSpace extends ColorSpace { + name: 'hsv' rgb: (hsv: [number, number, number]) => [number, number, number]; hsl: (hsv: [number, number, number]) => [number, number, number]; } diff --git a/types/hwb.d.ts b/types/hwb.d.ts index 943822d..32a2253 100644 --- a/types/hwb.d.ts +++ b/types/hwb.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface HwbSpace extends ColorSpace { + name: 'hwb' rgb: (hwb: [number, number, number]) => [number, number, number]; hsl: (hwb: [number, number, number]) => [number, number, number]; hsv: (hwb: [number, number, number]) => [number, number, number]; diff --git a/types/index.d.ts b/types/index.d.ts index bce1b15..1a3a8ef 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,48 +1,133 @@ -import { SpaceId, ColorSpace } from './types'; +// Import type definitions for all color space modules +import cmy from './cmy'; +import cmyk from './cmyk'; +import coloroid from './coloroid'; +import cubehelix from './cubehelix'; +import hcg from './hcg'; +import hcy from './hcy'; +import hpluv from './hpluv'; +import hsi from './hsi'; +import hsl from './hsl'; +import hsluv from './hsluv'; +import hsp from './hsp'; +import hsv from './hsv'; +import hwb from './hwb'; +import jpeg from './jpeg'; +import lab from './lab'; +import labh from './labh'; +import lchab from './lchab'; +import lchuv from './lchuv'; +import lms from './lms'; +import luv from './luv'; +import munsell from './munsell'; +import osaucs from './osaucs'; +import rgb from './rgb'; +import tsl from './tsl'; +import ucs from './ucs'; +import uvw from './uvw'; +import xvycc from './xvycc'; +import xyz from './xyz'; +import xyy from './xyy'; +import ycbcr from './ycbcr'; +import yccbccrc from './yccbccrc'; +import ycgco from './ycgco'; +import ydbdr from './ydbdr'; +import yes from './yes'; +import yiq from './yiq'; +import ypbpr from './ypbpr'; +import yuv from './yuv'; -export type Transform = (color: number[], ...rest: any[]) => number[]; -export type ColorSpaceTransforms = { [key in SpaceId]?: Transform }; +// Declare the space object with the defined type +declare const space: { + cmy: typeof cmy; + cmyk: typeof cmyk; + coloroid: typeof coloroid; + cubehelix: typeof cubehelix; + hcg: typeof hcg; + hcy: typeof hcy; + hpluv: typeof hpluv; + hsi: typeof hsi; + hsl: typeof hsl; + hsluv: typeof hsluv; + hsp: typeof hsp; + hsv: typeof hsv; + hwb: typeof hwb; + jpeg: typeof jpeg; + lab: typeof lab; + labh: typeof labh; + lchab: typeof lchab; + lchuv: typeof lchuv; + lms: typeof lms; + luv: typeof luv; + munsell: typeof munsell; + osaucs: typeof osaucs; + rgb: typeof rgb; + tsl: typeof tsl; + ucs: typeof ucs; + uvw: typeof uvw; + xvycc: typeof xvycc; + xyz: typeof xyz; + xyy: typeof xyy; + ycbcr: typeof ycbcr; + yccbccrc: typeof yccbccrc; + ycgco: typeof ycgco; + ydbdr: typeof ydbdr; + yes: typeof yes; + yiq: typeof yiq; + ypbpr: typeof ypbpr; + yuv: typeof yuv; +}; -declare const spaces: { [key in SpaceId]: ColorSpace & ColorSpaceTransforms }; -export default spaces; +type SpaceId = keyof typeof space; -export * from './types'; +export default space; -// export * from './ciecam'; -export * from './cmy'; -export * from './cmyk'; -export * from './coloroid'; -export * from './cubehelix'; -export * from './hcg'; -export * from './hcy'; -export * from './hpluv'; -export * from './hsi'; -export * from './hsl'; -export * from './hsluv'; -export * from './hsp'; -export * from './hsv'; -export * from './hwb'; -export * from './jpeg'; -export * from './lab'; -export * from './labh'; -export * from './lchab'; -export * from './lchuv'; -export * from './lms'; -export * from './luv'; -export * from './munsell'; -export * from './osaucs'; -export * from './rgb'; -export * from './tsl'; -export * from './ucs'; -export * from './uvw'; -export * from './xvycc'; -export * from './xyz'; -export * from './xyy'; -export * from './ycbcr'; -export * from './yccbccrc'; -export * from './ycgco'; -export * from './ydbdr'; -export * from './yes'; -export * from './yiq'; -export * from './ypbpr'; -export * from './yuv'; +// NOTE: to exclude self-transform this can be modified to Transforms> +export type Transforms = { + /** + * Convert value from current color space to target color space. + * @param channels - Channel values in the current color space. + * @returns target color space channel values. + */ + [key in SpaceId]?: (channels: Channels) => number[]; +}; + +// augment all color spaces with conversions to every other space, except itself +// FIXME: something with type inference can be done here, but for now good enough +declare module './cmy' { interface CmySpace extends Transforms {}} +declare module './cmyk' { interface CmykSpace extends Transforms<[number, number, number, number]> {}} +declare module './coloroid' { interface ColoroidSpace extends Transforms {}} +declare module './cubehelix' { interface CubehelixSpace extends Transforms<[number]> {}} +declare module './hcg' { interface HcgSpace extends Transforms {}} +declare module './hcy' { interface HcySpace extends Transforms {}} +declare module './hpluv' { interface HpluvSpace extends Transforms {}} +declare module './hsi' { interface HsiSpace extends Transforms {}} +declare module './hsl' { interface HslSpace extends Transforms {}} +declare module './hsluv' { interface HsluvSpace extends Transforms {}} +declare module './hsp' { interface HspSpace extends Transforms {}} +declare module './hsv' { interface HsvSpace extends Transforms {}} +declare module './hwb' { interface HwbSpace extends Transforms {}} +declare module './jpeg' { interface JpegSpace extends Transforms {}} +declare module './lab' { interface LabSpace extends Transforms {}} +declare module './labh' { interface LabhSpace extends Transforms {}} +declare module './lchab' { interface LchabSpace extends Transforms {}} +declare module './lchuv' { interface LchuvSpace extends Transforms {}} +declare module './lms' { interface LmsSpace extends Transforms {}} +declare module './luv' { interface LuvSpace extends Transforms {}} +declare module './munsell' { interface MunsellSpace extends Transforms {}} +declare module './osaucs' { interface OsaucsSpace extends Transforms {}} +declare module './rgb' { interface RgbSpace extends Transforms {}} +declare module './tsl' { interface TslSpace extends Transforms {}} +declare module './ucs' { interface UcsSpace extends Transforms {}} +declare module './uvw' { interface UvwSpace extends Transforms {}} +declare module './xvycc' { interface XvyccSpace extends Transforms {}} +declare module './xyz' { interface XyzSpace extends Transforms {}} +declare module './xyy' { interface XyySpace extends Transforms {}} +declare module './ycbcr' { interface YcbcrSpace extends Transforms {}} +declare module './yccbccrc' { interface YccbccrcSpace extends Transforms {}} +declare module './ycgco' { interface YcgcoSpace extends Transforms {}} +declare module './ydbdr' { interface YdbdrSpace extends Transforms {}} +declare module './yes' { interface YesSpace extends Transforms {}} +declare module './yiq' { interface YiqSpace extends Transforms {}} +declare module './ypbpr' { interface YpbprSpace extends Transforms {}} +declare module './yuv' { interface YuvSpace extends Transforms {}} diff --git a/types/jpeg.d.ts b/types/jpeg.d.ts index 27303bf..35a8943 100644 --- a/types/jpeg.d.ts +++ b/types/jpeg.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface JpegSpace extends ColorSpace { + name: 'jpeg' rgb: (jpeg: [number, number, number]) => [number, number, number]; } diff --git a/types/lab.d.ts b/types/lab.d.ts index 9558b24..5d9919d 100644 --- a/types/lab.d.ts +++ b/types/lab.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface LabSpace extends ColorSpace { + name: 'lab' xyz: (lab: [number, number, number]) => [number, number, number]; } diff --git a/types/labh.d.ts b/types/labh.d.ts index 5cbba45..7701c02 100644 --- a/types/labh.d.ts +++ b/types/labh.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface LabhSpace extends ColorSpace { + name: 'labh' xyz: (labh: [number, number, number]) => [number, number, number]; } diff --git a/types/lchab.d.ts b/types/lchab.d.ts index ddec8c2..ed87523 100644 --- a/types/lchab.d.ts +++ b/types/lchab.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface LchabSpace extends ColorSpace { + name: 'lchab' xyz: (lchab: [number, number, number]) => [number, number, number]; lab: (lchab: [number, number, number]) => [number, number, number]; } diff --git a/types/lchuv.d.ts b/types/lchuv.d.ts index 276d151..9481188 100644 --- a/types/lchuv.d.ts +++ b/types/lchuv.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface LchuvSpace extends ColorSpace { + name: 'lchuv' xyz: (lchuv: [number, number, number]) => [number, number, number]; luv: (lchuv: [number, number, number]) => [number, number, number]; } diff --git a/types/lms.d.ts b/types/lms.d.ts index 6037d48..f5dcd99 100644 --- a/types/lms.d.ts +++ b/types/lms.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface LmsSpace extends ColorSpace { + name: 'lms' xyz: (lms: [number, number, number]) => [number, number, number]; } diff --git a/types/luv.d.ts b/types/luv.d.ts index cacade0..b12ef6a 100644 --- a/types/luv.d.ts +++ b/types/luv.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface LuvSpace extends ColorSpace { + name: 'luv' xyz: (luv: [number, number, number]) => [number, number, number]; } diff --git a/types/munsell.d.ts b/types/munsell.d.ts index 104e612..8444c5b 100644 --- a/types/munsell.d.ts +++ b/types/munsell.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface MunsellSpace extends ColorSpace { + name: 'munsell' coloroid: (munsell: [number, number, number]) => [number, number, number]; } diff --git a/types/osaucs.d.ts b/types/osaucs.d.ts index 50954a7..c06c5b9 100644 --- a/types/osaucs.d.ts +++ b/types/osaucs.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface OsaucsSpace extends ColorSpace { + name: 'osaucs' xyz: (osaucs: [number, number, number]) => [number, number, number]; } diff --git a/types/rgb.d.ts b/types/rgb.d.ts index 11932ec..39b7fd6 100644 --- a/types/rgb.d.ts +++ b/types/rgb.d.ts @@ -1,7 +1,7 @@ -import { ColorSpace } from './types' +import { ColorSpace } from './color-space' export interface RgbSpace extends ColorSpace { - + name: 'rgb' } declare const rgb: RgbSpace; diff --git a/types/tsl.d.ts b/types/tsl.d.ts index e3f6df2..12618d1 100644 --- a/types/tsl.d.ts +++ b/types/tsl.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface TslSpace extends ColorSpace { + name: 'tsl' rgb: (tsl: [number, number, number]) => [number, number, number]; } diff --git a/types/types.d.ts b/types/types.d.ts deleted file mode 100644 index acb0cae..0000000 --- a/types/types.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type SpaceId = 'rgb' | 'xyz' | 'hsl' | 'hsv' | 'hsi' | 'hwb' | 'cmyk' | 'cmy' | 'xyy' | 'yiq' | 'yuv' | 'ydbdr' | 'ycgco' | 'ypbpr' | 'ycbcr' | 'xvycc' | 'yccbccrc' | 'ucs' | 'uvw' | 'jpeg' | 'lab' | 'labh' | 'lms' | 'lchab' | 'luv' | 'lchuv' | 'hsluv' | 'hpluv' | 'cubehelix' | 'coloroid' | 'hcg' | 'hcy' | 'tsl' | 'yes' | 'osaucs' | 'hsp' - -export interface ColorSpace { - name: SpaceId; - min: number[]; - max: number[]; - channel: string[]; - alias?: string[]; -} diff --git a/types/ucs.d.ts b/types/ucs.d.ts index 1f95c64..775087d 100644 --- a/types/ucs.d.ts +++ b/types/ucs.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface UcsSpace extends ColorSpace { + name: 'ucs' xyz: (ucs: [number, number, number]) => [number, number, number]; } diff --git a/types/uvw.d.ts b/types/uvw.d.ts index 8383612..b5d3cda 100644 --- a/types/uvw.d.ts +++ b/types/uvw.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface UvwSpace extends ColorSpace { + name: 'uvw' xyz: (uvw: [number, number, number]) => [number, number, number]; ucs: (uvw: [number, number, number]) => [number, number, number]; } diff --git a/types/xvycc.ts b/types/xvycc.ts index 5928ef3..4db1a1a 100644 --- a/types/xvycc.ts +++ b/types/xvycc.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface XvyccSpace extends ColorSpace { + name: 'xvycc' rgb: (xvycc: [number, number, number]) => [number, number, number]; ypbpr: (xvycc: [number, number, number]) => [number, number, number]; } diff --git a/types/xyy.d.ts b/types/xyy.d.ts index 6778221..81a4f61 100644 --- a/types/xyy.d.ts +++ b/types/xyy.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from './types' +import { ColorSpace } from './color-space' export interface XyySpace extends ColorSpace { + name: 'xyy' xyz: (xyy: [number, number, number]) => [number, number, number]; } diff --git a/types/xyz.d.ts b/types/xyz.d.ts index 142e3cd..93494eb 100644 --- a/types/xyz.d.ts +++ b/types/xyz.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from './types' +import { ColorSpace } from './color-space' export interface XyzSpace extends ColorSpace { + name: 'xyz' rgb: (xyz: [number, number, number]) => [number, number, number] } diff --git a/types/ycbcr.d.ts b/types/ycbcr.d.ts index b8e6717..4b591cd 100644 --- a/types/ycbcr.d.ts +++ b/types/ycbcr.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YcbcrSpace extends ColorSpace { + name: 'ycbcr' rgb: (ycbcr: [number, number, number]) => [number, number, number]; ypbpr: (ycbcr: [number, number, number]) => [number, number, number]; } diff --git a/types/yccbccrc.ts b/types/yccbccrc.ts index 83e59d5..cbd574b 100644 --- a/types/yccbccrc.ts +++ b/types/yccbccrc.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YccbccrcSpace extends ColorSpace { + name: 'yccbccrc' rgb: (yccbccrc: [number, number, number]) => [number, number, number]; } diff --git a/types/ycgco.d.ts b/types/ycgco.d.ts index 445ea23..058c6d2 100644 --- a/types/ycgco.d.ts +++ b/types/ycgco.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YcgcoSpace extends ColorSpace { + name: 'ycgco' rgb: (ycgco: [number, number, number]) => [number, number, number]; } diff --git a/types/ydbdr.d.ts b/types/ydbdr.d.ts index 7d1462c..0862561 100644 --- a/types/ydbdr.d.ts +++ b/types/ydbdr.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YdbdrSpace extends ColorSpace { + name: 'ydbdr' rgb: (ydbdr: [number, number, number]) => [number, number, number]; yuv: (ydbdr: [number, number, number]) => [number, number, number]; } diff --git a/types/yes.d.ts b/types/yes.d.ts index dabfa15..c8005f9 100644 --- a/types/yes.d.ts +++ b/types/yes.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YesSpace extends ColorSpace { + name: 'yes' rgb: (yes: [number, number, number]) => [number, number, number]; } diff --git a/types/yiq.d.ts b/types/yiq.d.ts index bdf58e1..df81c7a 100644 --- a/types/yiq.d.ts +++ b/types/yiq.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YiqSpace extends ColorSpace { + name: 'yiq' rgb: (yiq: [number, number, number]) => [number, number, number]; } diff --git a/types/ypbpr.d.ts b/types/ypbpr.d.ts index e192768..f0ef744 100644 --- a/types/ypbpr.d.ts +++ b/types/ypbpr.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YpbprSpace extends ColorSpace { + name: 'ypbpr' rgb: (ypbpr: [number, number, number]) => [number, number, number]; } diff --git a/types/yuv.d.ts b/types/yuv.d.ts index 5b0b93c..a2500e5 100644 --- a/types/yuv.d.ts +++ b/types/yuv.d.ts @@ -1,6 +1,7 @@ -import { ColorSpace } from "./types"; +import { ColorSpace } from "./color-space"; export interface YuvSpace extends ColorSpace { + name: 'yuv' rgb: (yuv: [number, number, number]) => [number, number, number]; }