From 11f2e4f064a084404f59b3625d8a091fcdb31482 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 27 Jan 2023 19:08:55 -0500 Subject: [PATCH] Updates dependencies --- package.json | 4 ++-- src/annotations/annotations.ts | 9 ++------- src/system/color.ts | 27 ++++++++++----------------- yarn.lock | 16 ++++++++-------- 4 files changed, 22 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 5c3cd65..05d17cc 100644 --- a/package.json +++ b/package.json @@ -12762,8 +12762,8 @@ "@vscode/codicons": "0.0.32", "@vscode/webview-ui-toolkit": "1.2.1", "ansi-regex": "6.0.1", - "billboard.js": "3.7.2", - "colorjs.io": "0.4.2", + "billboard.js": "3.7.3", + "colorjs.io": "0.4.3", "https-proxy-agent": "5.0.1", "iconv-lite": "0.6.3", "lit": "2.3.1", diff --git a/src/annotations/annotations.ts b/src/annotations/annotations.ts index fc0bcf4..8f4658f 100644 --- a/src/annotations/annotations.ts +++ b/src/annotations/annotations.ts @@ -14,7 +14,7 @@ import { Colors, GlyphChars } from '../constants'; import type { CommitFormatOptions } from '../git/formatters/commitFormatter'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { GitCommit } from '../git/models/commit'; -import { steps, toRgba } from '../system/color'; +import { interpolate as interpolateColors, toRgba } from '../system/color'; import { getWidth, interpolate, pad } from '../system/string'; export interface ComputedHeatmap { @@ -66,12 +66,7 @@ export function getHeatmapColors() { if (coldColor === defaultHeatmapColdColor && hotColor === defaultHeatmapHotColor) { colors = defaultHeatmapColors; } else { - colors = steps(hotColor, coldColor, { - space: 'xyz', - outputSpace: 'srgb', - steps: 20, - maxSteps: 20, - }).map(c => c.toString({ format: 'hex' })); + colors = interpolateColors(hotColor, coldColor, 20); } heatmapColors = { hot: colors.slice(0, 10), diff --git a/src/system/color.ts b/src/system/color.ts index b999958..7992524 100644 --- a/src/system/color.ts +++ b/src/system/color.ts @@ -1,8 +1,4 @@ -import type Color from 'colorjs.io'; -import { steps as _steps } from 'colorjs.io/fn'; -import type { ColorTypes } from 'colorjs.io/types/src/color'; -import type { Methods } from 'colorjs.io/types/src/index-fn'; -import type { RangeOptions } from 'colorjs.io/types/src/interpolation'; +import { steps as interpolateSteps } from 'colorjs.io/fn'; const cssColorRegex = /^(?:(#?)([0-9a-f]{3}|[0-9a-f]{6})|((?:rgb|hsl)a?)\((-?\d+%?)[,\s]+(-?\d+%?)[,\s]+(-?\d+%?)[,\s]*(-?[\d.]+%?)?\))$/i; @@ -18,6 +14,15 @@ export function darken(color: string, percentage: number) { return lighten(color, -percentage); } +export function interpolate(color1: string, color2: string, steps: number): string[] { + return interpolateSteps(color1, color2, { + space: 'xyz', + outputSpace: 'srgb', + steps: steps, + maxSteps: steps, + }).map(c => c.toString({ format: 'hex' })); +} + export function lighten(color: string, percentage: number) { const rgba = toRgba(color); if (rgba == null) return color; @@ -52,18 +57,6 @@ const mixChannel = (channel1: number, channel2: number, percentage: number) => { return channel1 + ((channel2 - channel1) * percentage) / 100; }; -interface StepsOptions extends RangeOptions { - maxDeltaE?: number | undefined; - deltaEMethod?: Methods | undefined; - steps?: number | undefined; - maxSteps?: number | undefined; -} - -export function steps(color1: ColorTypes, color2: ColorTypes, options?: StepsOptions): Color[] { - type Steps = (color1: ColorTypes, color2: ColorTypes, options?: StepsOptions) => Color[]; - return (_steps as Steps)(color1, color2, options); -} - export function toRgba(color: string) { color = color.trim(); diff --git a/yarn.lock b/yarn.lock index 6709306..3ddd689 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1489,10 +1489,10 @@ big.js@^5.2.2: resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== -billboard.js@3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/billboard.js/-/billboard.js-3.7.2.tgz#a5ecff1aad3bf0f3bc3064e1c342b9e8cd359915" - integrity sha512-Ud81dKw7SgaOVCkRqGmEYXn0SBY7Q0CFk5UPftkBa+62DzOF0ti7loHslkLMQkPv5RydSJuB6zl0IXkWWKuIJw== +billboard.js@3.7.3: + version "3.7.3" + resolved "https://registry.yarnpkg.com/billboard.js/-/billboard.js-3.7.3.tgz#fc1b7a8e9b046eb9d41aefbb098384ccd2cc3f7d" + integrity sha512-zic7Nts43/IyaoIbtij0eIJzq9wSRsyh8jpQx16hSbFnMDB82dePoA3zjY3dFOsU54BuOT5X1NtQISWhFjp8rA== dependencies: "@types/d3-selection" "^3.0.4" "@types/d3-transition" "^3.0.3" @@ -1980,10 +1980,10 @@ colorette@^2.0.14: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.19.tgz#cdf044f47ad41a0f4b56b3a0d5b4e6e1a2d5a798" integrity sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ== -colorjs.io@0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/colorjs.io/-/colorjs.io-0.4.2.tgz#5338fc185a8be3b46674420cd2be88389a18145b" - integrity sha512-vtpiH+BTzZtzs4Yno0GyoC05Z20fTeLwNJ7lQzjxi8GJJb1SZO2o5yUBAUXzgvrO2JNuyIqur4gb1Z6HBjpd9A== +colorjs.io@0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/colorjs.io/-/colorjs.io-0.4.3.tgz#0f12aca97508d7db8f53ed304d28f079b3b3fff5" + integrity sha512-Jr6NiWFZCuSECl23Bhe4jvDldQsE0ErnWrdl3xIUFy+Bkp0l8r5qt/iZlNH47/xxGP5izcyC8InjoUoI4Po+Pg== commander@7, commander@^7.2.0: version "7.2.0"