@oh-my-pi/pi-utils 18.8.7 → 18.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/types/color.d.ts +2 -0
- package/package.json +2 -2
- package/src/color.ts +6 -0
- package/src/format.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [18.8.9] - 2026-10-10
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added `hueDistance`, the angular distance between two OKLCH hues
|
|
10
|
+
|
|
11
|
+
## [18.8.8] - 2026-10-10
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Fixed `formatDuration` printing `60.0s` for durations just under a minute; they now read `1m` ([#15121](https://github.com/can1357/oh-my-pi/pull/15121) by [@H4vC](https://github.com/H4vC))
|
|
16
|
+
|
|
5
17
|
## [18.8.7] - 2026-10-09
|
|
6
18
|
|
|
7
19
|
### Added
|
package/dist/types/color.d.ts
CHANGED
|
@@ -111,6 +111,8 @@ export declare function oklchCusp(h: number): {
|
|
|
111
111
|
l: number;
|
|
112
112
|
c: number;
|
|
113
113
|
};
|
|
114
|
+
/** Angular distance between two hues in degrees (0–180), wrapping at 360. */
|
|
115
|
+
export declare function hueDistance(a: number, b: number): number;
|
|
114
116
|
/**
|
|
115
117
|
* Convert OKLCH to a CSS hex string, gamut-mapping by chroma reduction.
|
|
116
118
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-utils",
|
|
3
|
-
"version": "18.8.
|
|
3
|
+
"version": "18.8.9",
|
|
4
4
|
"description": "Shared utilities for pi packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@oh-my-pi/pi-natives": "18.8.
|
|
60
|
+
"@oh-my-pi/pi-natives": "18.8.9"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/bun": "^1.3.14"
|
package/src/color.ts
CHANGED
|
@@ -399,6 +399,12 @@ export function oklchCusp(h: number): { l: number; c: number } {
|
|
|
399
399
|
return { l: lCusp, c: lCusp * sCusp };
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
/** Angular distance between two hues in degrees (0–180), wrapping at 360. */
|
|
403
|
+
export function hueDistance(a: number, b: number): number {
|
|
404
|
+
const d = Math.abs(a - b) % 360;
|
|
405
|
+
return Math.min(d, 360 - d);
|
|
406
|
+
}
|
|
407
|
+
|
|
402
408
|
/** Slack allowed on linear channels before a color counts as out of sRGB gamut. */
|
|
403
409
|
const GAMUT_EPSILON = 1e-4;
|
|
404
410
|
|
package/src/format.ts
CHANGED
|
@@ -10,7 +10,11 @@ const DAY = 24 * HOUR;
|
|
|
10
10
|
export function formatDuration(ms: number): string {
|
|
11
11
|
if (!Number.isFinite(ms) || ms <= 0) return "0ms";
|
|
12
12
|
if (ms < SEC) return `${Math.floor(ms)}ms`;
|
|
13
|
-
if (ms < MIN)
|
|
13
|
+
if (ms < MIN) {
|
|
14
|
+
// Round to tenths first: `toFixed(1)` alone turns 59.95s+ into an impossible `60.0s`.
|
|
15
|
+
const tenths = Math.round(ms / 100);
|
|
16
|
+
return tenths < 600 ? `${(tenths / 10).toFixed(1)}s` : "1m";
|
|
17
|
+
}
|
|
14
18
|
if (ms < HOUR) {
|
|
15
19
|
const mins = Math.floor(ms / MIN);
|
|
16
20
|
const secs = Math.floor((ms % MIN) / SEC);
|