@visulima/colorize 2.0.0-alpha.10 → 2.0.0-alpha.12
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 +36 -0
- package/dist/gradient.cjs +3 -62
- package/dist/gradient.d.cts +21 -12
- package/dist/gradient.d.mts +21 -12
- package/dist/gradient.d.ts +21 -12
- package/dist/gradient.mjs +3 -56
- package/dist/index.browser.d.mts +203 -60
- package/dist/index.browser.d.ts +204 -0
- package/dist/index.browser.mjs +1 -61
- package/dist/index.server.cjs +2 -255
- package/dist/index.server.d.cts +12 -6
- package/dist/index.server.d.mts +203 -60
- package/dist/index.server.d.ts +12 -6
- package/dist/index.server.mjs +1 -61
- package/dist/packem_shared/Colorize-BUAQi0t0.js +2 -0
- package/dist/packem_shared/Colorize-i0NybjSp.js +1 -0
- package/dist/packem_shared/GradientBuilder-CudosKb8.cjs +1 -0
- package/dist/packem_shared/GradientBuilder-Du8WSL23.mjs +1 -0
- package/dist/packem_shared/colorize.server-BkQZGeaS.mjs +2 -0
- package/dist/packem_shared/colorize.server-Dn-gV0MN.cjs +2 -0
- package/dist/packem_shared/convertHexToRgb-CJNE3k_E.mjs +1 -0
- package/dist/packem_shared/convertHexToRgb-Dvalc5FD.cjs +1 -0
- package/dist/packem_shared/rgbToAnsi256--f09kvlF.cjs +1 -0
- package/dist/packem_shared/rgbToAnsi256-YETEPW8R.mjs +1 -0
- package/dist/packem_shared/types.d-bhP-2hCu.d.cts +154 -0
- package/dist/packem_shared/types.d-bhP-2hCu.d.mts +154 -0
- package/dist/packem_shared/types.d-bhP-2hCu.d.ts +154 -0
- package/dist/template.cjs +2 -152
- package/dist/template.d.cts +10 -4
- package/dist/template.d.mts +4 -4
- package/dist/template.d.ts +10 -4
- package/dist/template.mjs +2 -146
- package/dist/utils.cjs +1 -13
- package/dist/utils.d.cts +13 -2
- package/dist/utils.d.mts +13 -2
- package/dist/utils.d.ts +13 -2
- package/dist/utils.mjs +1 -2
- package/package.json +13 -13
- package/dist/ansi-codes.d.cts +0 -18
- package/dist/ansi-codes.d.mts +0 -18
- package/dist/ansi-codes.d.ts +0 -18
- package/dist/colorize.browser.d.mts +0 -3
- package/dist/colorize.server.d.cts +0 -10
- package/dist/colorize.server.d.mts +0 -10
- package/dist/colorize.server.d.ts +0 -10
- package/dist/css-code.d.mts +0 -11
- package/dist/gradient/gradient-builder.d.cts +0 -10
- package/dist/gradient/gradient-builder.d.mts +0 -10
- package/dist/gradient/gradient-builder.d.ts +0 -10
- package/dist/gradient/util/color-names.d.cts +0 -2
- package/dist/gradient/util/color-names.d.mts +0 -2
- package/dist/gradient/util/color-names.d.ts +0 -2
- package/dist/gradient/util/compute.d.cts +0 -2
- package/dist/gradient/util/compute.d.mts +0 -2
- package/dist/gradient/util/compute.d.ts +0 -2
- package/dist/gradient/util/hsv-to-rgb.d.cts +0 -5
- package/dist/gradient/util/hsv-to-rgb.d.mts +0 -5
- package/dist/gradient/util/hsv-to-rgb.d.ts +0 -5
- package/dist/gradient/util/interpolate.d.cts +0 -3
- package/dist/gradient/util/interpolate.d.mts +0 -3
- package/dist/gradient/util/interpolate.d.ts +0 -3
- package/dist/gradient/util/rgb-to-hsv.d.cts +0 -9
- package/dist/gradient/util/rgb-to-hsv.d.mts +0 -9
- package/dist/gradient/util/rgb-to-hsv.d.ts +0 -9
- package/dist/packem_shared/Colorize-BQ-Wlgs0.js +0 -409
- package/dist/packem_shared/Colorize-rJUN0RFg.js +0 -250
- package/dist/packem_shared/GradientBuilder-CkX4Imo9.mjs +0 -483
- package/dist/packem_shared/GradientBuilder-DRrwebdU.cjs +0 -487
- package/dist/packem_shared/colorize.server-CwTmhs0e.cjs +0 -198
- package/dist/packem_shared/colorize.server-YxoHIDUp.mjs +0 -196
- package/dist/packem_shared/convertHexToRgb-51-edHxE.cjs +0 -21
- package/dist/packem_shared/convertHexToRgb-BZwJEiMZ.mjs +0 -17
- package/dist/packem_shared/rgbToAnsi256-BdS0fomP.mjs +0 -41
- package/dist/packem_shared/rgbToAnsi256-DL8eajTz.cjs +0 -47
- package/dist/template/make-colorize-template.d.cts +0 -9
- package/dist/template/make-colorize-template.d.mts +0 -9
- package/dist/template/make-colorize-template.d.ts +0 -9
- package/dist/template/make-template.d.cts +0 -10
- package/dist/template/make-template.d.mts +0 -10
- package/dist/template/make-template.d.ts +0 -10
- package/dist/types.d.cts +0 -174
- package/dist/types.d.mts +0 -174
- package/dist/types.d.ts +0 -174
- package/dist/util/ansi-code-hex-map.d.mts +0 -8
- package/dist/util/clamp.d.cts +0 -12
- package/dist/util/clamp.d.mts +0 -12
- package/dist/util/clamp.d.ts +0 -12
- package/dist/util/convert-hex-to-rgb.d.cts +0 -8
- package/dist/util/convert-hex-to-rgb.d.mts +0 -8
- package/dist/util/convert-hex-to-rgb.d.ts +0 -8
- package/dist/util/convert-rgb-to-ansi.d.cts +0 -18
- package/dist/util/convert-rgb-to-ansi.d.mts +0 -18
- package/dist/util/convert-rgb-to-ansi.d.ts +0 -18
- package/dist/util/string-replace-all.d.cts +0 -12
- package/dist/util/string-replace-all.d.mts +0 -12
- package/dist/util/string-replace-all.d.ts +0 -12
- package/dist/util/unescape.d.cts +0 -9
- package/dist/util/unescape.d.mts +0 -9
- package/dist/util/unescape.d.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## @visulima/colorize [2.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.11...@visulima/colorize@2.0.0-alpha.12) (2026-05-27)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **storage-client:** percent-encode user fields in defaultFingerprint ([7c78a0f](https://github.com/visulima/visulima/commit/7c78a0f9512e2a673b941d80839e9f1e86b7b5d0))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* **ci-stability:** green CI across vis, native, lint, tests, attw ([#651](https://github.com/visulima/visulima/issues/651)) ([d4eb684](https://github.com/visulima/visulima/commit/d4eb684b5f75c818c9251048c605a0ed54a268e3))
|
|
10
|
+
* **repo:** sort package.json keys across all packages ([e1fd9ab](https://github.com/visulima/visulima/commit/e1fd9ab467ef96a98c777da1572ff6a50fcf7e71))
|
|
11
|
+
* sorted package.json ([b47c545](https://github.com/visulima/visulima/commit/b47c545591600fdab17d5cd3a3fbc68b61e199da))
|
|
12
|
+
|
|
13
|
+
### Tests
|
|
14
|
+
|
|
15
|
+
* **repo:** add dist runtime + types integration tests ([32ee300](https://github.com/visulima/visulima/commit/32ee300b7184117a0ddf9f9d390f75f8932d5ed9))
|
|
16
|
+
|
|
17
|
+
## @visulima/colorize [2.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.10...@visulima/colorize@2.0.0-alpha.11) (2026-05-14)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **colorize:** rewrite ternary as if/else to satisfy operator-linebreak ([999c115](https://github.com/visulima/visulima/commit/999c115ee078a601167c972404c6e625813fea1b))
|
|
22
|
+
|
|
23
|
+
### Miscellaneous Chores
|
|
24
|
+
|
|
25
|
+
* **colorize:** fix lint conflict between eslint and prettier ([b0a316d](https://github.com/visulima/visulima/commit/b0a316d0ba7f6b7969fe14ce0fee9aae55206453))
|
|
26
|
+
* **colorize:** fix lint errors ([7aac22d](https://github.com/visulima/visulima/commit/7aac22d80dffe22a75881bc89460493381cda317))
|
|
27
|
+
* **colorize:** housekeeping cleanup ([69a01ec](https://github.com/visulima/visulima/commit/69a01ec038aa738b1f4a2504c85ea56f5786edc5))
|
|
28
|
+
* **colorize:** upgrade packem to 2.0.0-alpha.76 ([d912a81](https://github.com/visulima/visulima/commit/d912a81321bdb96047b483deea693375030e63a3))
|
|
29
|
+
* re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
|
|
30
|
+
* simplify pnpm-workspace packages list ([7cab221](https://github.com/visulima/visulima/commit/7cab221163632d9b7aa044a6f88c49083103a869))
|
|
31
|
+
|
|
32
|
+
### Tests
|
|
33
|
+
|
|
34
|
+
* **colorize:** use packages.colors key in bench ([e87c2db](https://github.com/visulima/visulima/commit/e87c2db66eec4883cb22201982d0820461babd6f))
|
|
35
|
+
* repair cerebro, fs, colorize bench CI runs ([03b530e](https://github.com/visulima/visulima/commit/03b530edc678ca6f5c2869ae283f0f3ca6e86c5e))
|
|
36
|
+
|
|
1
37
|
## @visulima/colorize [2.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.9...@visulima/colorize@2.0.0-alpha.10) (2026-04-22)
|
|
2
38
|
|
|
3
39
|
### Bug Fixes
|
package/dist/gradient.cjs
CHANGED
|
@@ -1,62 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const colorize_server = require('./packem_shared/colorize.server-CwTmhs0e.cjs');
|
|
6
|
-
const GradientBuilder = require('./packem_shared/GradientBuilder-DRrwebdU.cjs');
|
|
7
|
-
|
|
8
|
-
const colorize = new colorize_server.Colorize();
|
|
9
|
-
const WHITESPACE_GLOBAL = /\s/g;
|
|
10
|
-
const WHITESPACE_TEST = /\s/;
|
|
11
|
-
const gradient = (stops, options) => {
|
|
12
|
-
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
13
|
-
let builder = new GradientBuilder.GradientBuilder(colorize, stops);
|
|
14
|
-
if (options?.loop) {
|
|
15
|
-
builder = builder.loop();
|
|
16
|
-
} else if (options?.reverse) {
|
|
17
|
-
builder = builder.reverse();
|
|
18
|
-
}
|
|
19
|
-
return (string_) => {
|
|
20
|
-
const stripped = string_.replaceAll(WHITESPACE_GLOBAL, "");
|
|
21
|
-
const colorsCount = Math.max(stripped.length, builder.stops.length);
|
|
22
|
-
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
23
|
-
let result = "";
|
|
24
|
-
for (const s of string_) {
|
|
25
|
-
if (WHITESPACE_TEST.test(s)) {
|
|
26
|
-
result += s;
|
|
27
|
-
} else {
|
|
28
|
-
const color = colors.shift();
|
|
29
|
-
result += color(s);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
const multilineGradient = (stops, options) => {
|
|
36
|
-
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
37
|
-
let builder = new GradientBuilder.GradientBuilder(colorize, stops);
|
|
38
|
-
if (options?.loop) {
|
|
39
|
-
builder = builder.loop();
|
|
40
|
-
} else if (options?.reverse) {
|
|
41
|
-
builder = builder.reverse();
|
|
42
|
-
}
|
|
43
|
-
return (string_) => {
|
|
44
|
-
const lines = string_.split("\n");
|
|
45
|
-
const colorsCount = Reflect.apply(Math.max, void 0, [...lines.map((l) => l.length), builder.stops.length]);
|
|
46
|
-
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
47
|
-
const results = [];
|
|
48
|
-
for (const line of lines) {
|
|
49
|
-
const lineColors = [...colors];
|
|
50
|
-
let lineResult = "";
|
|
51
|
-
for (const l of line) {
|
|
52
|
-
lineResult += WHITESPACE_TEST.test(l) ? l : lineColors.shift()(l);
|
|
53
|
-
}
|
|
54
|
-
results.push(lineResult);
|
|
55
|
-
}
|
|
56
|
-
return results.join("\n");
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.GradientBuilder = GradientBuilder.GradientBuilder;
|
|
61
|
-
exports.gradient = gradient;
|
|
62
|
-
exports.multilineGradient = multilineGradient;
|
|
1
|
+
"use strict";var G=Object.defineProperty;var v=(r,t)=>G(r,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const B=require("./packem_shared/colorize.server-Dn-gV0MN.cjs"),g=require("./packem_shared/GradientBuilder-CudosKb8.cjs");var S=Object.defineProperty,f=v((r,t)=>S(r,"name",{value:t,configurable:!0}),"h");const b=new B.A,M=/\s/g,m=/\s/,j=f((r,t)=>{const{hsvSpin:a="short",interpolation:u="rgb"}=t??{};let e=new g.GradientBuilder(b,r);return t?.loop?e=e.loop():t?.reverse&&(e=e.reverse()),s=>{const l=s.replaceAll(M,""),i=Math.max(l.length,e.stops.length),c=u==="rgb"?e.rgb(i):e.hsv(i,a);let o="";for(const n of s)if(m.test(n))o+=n;else{const d=c.shift();o+=d(n)}return o}},"gradient"),w=f((r,t)=>{const{hsvSpin:a="short",interpolation:u="rgb"}=t??{};let e=new g.GradientBuilder(b,r);return t?.loop?e=e.loop():t?.reverse&&(e=e.reverse()),s=>{const l=s.split(`
|
|
2
|
+
`),i=Reflect.apply(Math.max,void 0,[...l.map(n=>n.length),e.stops.length]),c=u==="rgb"?e.rgb(i):e.hsv(i,a),o=[];for(const n of l){const d=[...c];let h="";for(const p of n)h+=m.test(p)?p:d.shift()(p);o.push(h)}return o.join(`
|
|
3
|
+
`)}},"multilineGradient");exports.GradientBuilder=g.GradientBuilder;exports.gradient=j;exports.multilineGradient=w;
|
package/dist/gradient.d.cts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { S as StopOutput, C as ColorizeType, a as ColorValueHex, b as CssColorName, R as RGB, c as StopInput } from "./packem_shared/types.d-bhP-2hCu.cjs";
|
|
2
|
+
declare class GradientBuilder {
|
|
3
|
+
#private;
|
|
4
|
+
readonly stops: StopOutput[];
|
|
5
|
+
constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
|
|
6
|
+
reverse(): GradientBuilder;
|
|
7
|
+
loop(): GradientBuilder;
|
|
8
|
+
rgb(steps: number): ColorizeType[];
|
|
9
|
+
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
10
|
+
}
|
|
11
|
+
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
12
|
+
hsvSpin?: "long" | "short";
|
|
13
|
+
interpolation?: "hsv" | "rgb";
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
reverse?: boolean;
|
|
7
16
|
}) => (string_: string) => string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
18
|
+
hsvSpin?: "long" | "short";
|
|
19
|
+
interpolation?: "hsv" | "rgb";
|
|
20
|
+
loop?: boolean;
|
|
21
|
+
reverse?: boolean;
|
|
13
22
|
}) => (string_: string) => string;
|
|
14
|
-
export { GradientBuilder
|
|
23
|
+
export { GradientBuilder, gradient, multilineGradient };
|
package/dist/gradient.d.mts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { S as StopOutput, C as ColorizeType, a as ColorValueHex, b as CssColorName, R as RGB, c as StopInput } from "./packem_shared/types.d-bhP-2hCu.mjs";
|
|
2
|
+
declare class GradientBuilder {
|
|
3
|
+
#private;
|
|
4
|
+
readonly stops: StopOutput[];
|
|
5
|
+
constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
|
|
6
|
+
reverse(): GradientBuilder;
|
|
7
|
+
loop(): GradientBuilder;
|
|
8
|
+
rgb(steps: number): ColorizeType[];
|
|
9
|
+
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
10
|
+
}
|
|
11
|
+
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
12
|
+
hsvSpin?: "long" | "short";
|
|
13
|
+
interpolation?: "hsv" | "rgb";
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
reverse?: boolean;
|
|
7
16
|
}) => (string_: string) => string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
18
|
+
hsvSpin?: "long" | "short";
|
|
19
|
+
interpolation?: "hsv" | "rgb";
|
|
20
|
+
loop?: boolean;
|
|
21
|
+
reverse?: boolean;
|
|
13
22
|
}) => (string_: string) => string;
|
|
14
|
-
export { GradientBuilder
|
|
23
|
+
export { GradientBuilder, gradient, multilineGradient };
|
package/dist/gradient.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { S as StopOutput, C as ColorizeType, a as ColorValueHex, b as CssColorName, R as RGB, c as StopInput } from "./packem_shared/types.d-bhP-2hCu.js";
|
|
2
|
+
declare class GradientBuilder {
|
|
3
|
+
#private;
|
|
4
|
+
readonly stops: StopOutput[];
|
|
5
|
+
constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
|
|
6
|
+
reverse(): GradientBuilder;
|
|
7
|
+
loop(): GradientBuilder;
|
|
8
|
+
rgb(steps: number): ColorizeType[];
|
|
9
|
+
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
10
|
+
}
|
|
11
|
+
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
12
|
+
hsvSpin?: "long" | "short";
|
|
13
|
+
interpolation?: "hsv" | "rgb";
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
reverse?: boolean;
|
|
7
16
|
}) => (string_: string) => string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
18
|
+
hsvSpin?: "long" | "short";
|
|
19
|
+
interpolation?: "hsv" | "rgb";
|
|
20
|
+
loop?: boolean;
|
|
21
|
+
reverse?: boolean;
|
|
13
22
|
}) => (string_: string) => string;
|
|
14
|
-
export { GradientBuilder
|
|
23
|
+
export { GradientBuilder, gradient, multilineGradient };
|
package/dist/gradient.mjs
CHANGED
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const colorize = new Colorize();
|
|
5
|
-
const WHITESPACE_GLOBAL = /\s/g;
|
|
6
|
-
const WHITESPACE_TEST = /\s/;
|
|
7
|
-
const gradient = (stops, options) => {
|
|
8
|
-
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
9
|
-
let builder = new GradientBuilder(colorize, stops);
|
|
10
|
-
if (options?.loop) {
|
|
11
|
-
builder = builder.loop();
|
|
12
|
-
} else if (options?.reverse) {
|
|
13
|
-
builder = builder.reverse();
|
|
14
|
-
}
|
|
15
|
-
return (string_) => {
|
|
16
|
-
const stripped = string_.replaceAll(WHITESPACE_GLOBAL, "");
|
|
17
|
-
const colorsCount = Math.max(stripped.length, builder.stops.length);
|
|
18
|
-
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
19
|
-
let result = "";
|
|
20
|
-
for (const s of string_) {
|
|
21
|
-
if (WHITESPACE_TEST.test(s)) {
|
|
22
|
-
result += s;
|
|
23
|
-
} else {
|
|
24
|
-
const color = colors.shift();
|
|
25
|
-
result += color(s);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const multilineGradient = (stops, options) => {
|
|
32
|
-
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
33
|
-
let builder = new GradientBuilder(colorize, stops);
|
|
34
|
-
if (options?.loop) {
|
|
35
|
-
builder = builder.loop();
|
|
36
|
-
} else if (options?.reverse) {
|
|
37
|
-
builder = builder.reverse();
|
|
38
|
-
}
|
|
39
|
-
return (string_) => {
|
|
40
|
-
const lines = string_.split("\n");
|
|
41
|
-
const colorsCount = Reflect.apply(Math.max, void 0, [...lines.map((l) => l.length), builder.stops.length]);
|
|
42
|
-
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
43
|
-
const results = [];
|
|
44
|
-
for (const line of lines) {
|
|
45
|
-
const lineColors = [...colors];
|
|
46
|
-
let lineResult = "";
|
|
47
|
-
for (const l of line) {
|
|
48
|
-
lineResult += WHITESPACE_TEST.test(l) ? l : lineColors.shift()(l);
|
|
49
|
-
}
|
|
50
|
-
results.push(lineResult);
|
|
51
|
-
}
|
|
52
|
-
return results.join("\n");
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export { GradientBuilder, gradient, multilineGradient };
|
|
1
|
+
var w=Object.defineProperty;var u=(r,e)=>w(r,"name",{value:e,configurable:!0});import{A as x}from"./packem_shared/colorize.server-BkQZGeaS.mjs";import{GradientBuilder as v}from"./packem_shared/GradientBuilder-Du8WSL23.mjs";var G=Object.defineProperty,m=u((r,e)=>G(r,"name",{value:e,configurable:!0}),"h");const b=new x,S=/\s/g,d=/\s/,M=m((r,e)=>{const{hsvSpin:p="short",interpolation:a="rgb"}=e??{};let t=new v(b,r);return e?.loop?t=t.loop():e?.reverse&&(t=t.reverse()),i=>{const l=i.replaceAll(S,""),s=Math.max(l.length,t.stops.length),c=a==="rgb"?t.rgb(s):t.hsv(s,p);let n="";for(const o of i)if(d.test(o))n+=o;else{const h=c.shift();n+=h(o)}return n}},"gradient"),B=m((r,e)=>{const{hsvSpin:p="short",interpolation:a="rgb"}=e??{};let t=new v(b,r);return e?.loop?t=t.loop():e?.reverse&&(t=t.reverse()),i=>{const l=i.split(`
|
|
2
|
+
`),s=Reflect.apply(Math.max,void 0,[...l.map(o=>o.length),t.stops.length]),c=a==="rgb"?t.rgb(s):t.hsv(s,p),n=[];for(const o of l){const h=[...c];let g="";for(const f of o)g+=d.test(f)?f:h.shift()(f);n.push(g)}return n.join(`
|
|
3
|
+
`)}},"multilineGradient");export{v as GradientBuilder,M as gradient,B as multilineGradient};
|
package/dist/index.browser.d.mts
CHANGED
|
@@ -1,61 +1,204 @@
|
|
|
1
|
-
|
|
1
|
+
type ColorValueHex = `#${string}`;
|
|
2
|
+
interface ColorizeType {
|
|
3
|
+
/**
|
|
4
|
+
* Return styled string.
|
|
5
|
+
* @param {string | TemplateStringsArray} string
|
|
6
|
+
*/
|
|
7
|
+
(string: number | string): string;
|
|
8
|
+
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for foreground color.
|
|
11
|
+
*
|
|
12
|
+
* Code ranges:
|
|
13
|
+
* ```
|
|
14
|
+
* 0 - 7: standard colors
|
|
15
|
+
* 8 - 15: high intensity colors
|
|
16
|
+
* 16 - 231: 6 × 6 × 6 cube (216 colors)
|
|
17
|
+
* 232 - 255: grayscale from black to white in 24 steps
|
|
18
|
+
* ```
|
|
19
|
+
* @param {number} code in range [0, 255].
|
|
20
|
+
*/
|
|
21
|
+
ansi256: (code: number) => this;
|
|
22
|
+
/**
|
|
23
|
+
* Alias for bgAnsi256.
|
|
24
|
+
* @param {number} code in range [0, 255].
|
|
25
|
+
*/
|
|
26
|
+
bg: (code: number) => this;
|
|
27
|
+
/**
|
|
28
|
+
* Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for background color.
|
|
29
|
+
*
|
|
30
|
+
* Code ranges:
|
|
31
|
+
* ```
|
|
32
|
+
* 0 - 7: standard colors
|
|
33
|
+
* 8 - 15: high intensity colors
|
|
34
|
+
* 16 - 231: 6 × 6 × 6 cube (216 colors)
|
|
35
|
+
* 232 - 255: grayscale from black to white in 24 steps
|
|
36
|
+
* ```
|
|
37
|
+
* @param {number} code in range [0, 255].
|
|
38
|
+
*/
|
|
39
|
+
bgAnsi256: (code: number) => this;
|
|
40
|
+
readonly bgBlack: this;
|
|
41
|
+
readonly bgBlackBright: this;
|
|
42
|
+
readonly bgBlue: this;
|
|
43
|
+
readonly bgBlueBright: this;
|
|
44
|
+
readonly bgCyan: this;
|
|
45
|
+
readonly bgCyanBright: this;
|
|
46
|
+
readonly bgGray: this;
|
|
47
|
+
readonly bgGreen: this;
|
|
48
|
+
readonly bgGreenBright: this;
|
|
49
|
+
readonly bgGrey: this;
|
|
50
|
+
/**
|
|
51
|
+
* Set HEX value for background color.
|
|
52
|
+
* @param {string} color
|
|
53
|
+
*/
|
|
54
|
+
bgHex: (color: ColorValueHex) => this;
|
|
55
|
+
readonly bgMagenta: this;
|
|
56
|
+
readonly bgMagentaBright: this;
|
|
57
|
+
readonly bgRed: this;
|
|
58
|
+
readonly bgRedBright: this;
|
|
59
|
+
/**
|
|
60
|
+
* Set RGB values for background color.
|
|
61
|
+
* @param {number} red The red value, in range [0, 255].
|
|
62
|
+
* @param {number} green The green value, in range [0, 255].
|
|
63
|
+
* @param {number} blue The blue value, in range [0, 255].
|
|
64
|
+
*/
|
|
65
|
+
bgRgb: (red: number, green: number, blue: number) => this;
|
|
66
|
+
readonly bgWhite: this;
|
|
67
|
+
readonly bgWhiteBright: this;
|
|
68
|
+
readonly bgYellow: this;
|
|
69
|
+
readonly bgYellowBright: this;
|
|
70
|
+
readonly black: this;
|
|
71
|
+
readonly blackBright: this;
|
|
72
|
+
readonly blue: this;
|
|
73
|
+
readonly blueBright: this;
|
|
74
|
+
/** <b>Bold</b> style (high intensity). */
|
|
75
|
+
readonly bold: this;
|
|
76
|
+
/** The ANSI escape sequences for ending the current style. */
|
|
77
|
+
readonly close: string;
|
|
78
|
+
readonly cyan: this;
|
|
79
|
+
readonly cyanBright: this;
|
|
80
|
+
/** Faint style (low intensity or dim). */
|
|
81
|
+
readonly dim: this;
|
|
82
|
+
/**
|
|
83
|
+
* Alias for ansi256.
|
|
84
|
+
* @param {number} code in range [0, 255].
|
|
85
|
+
*/
|
|
86
|
+
fg: (code: number) => this;
|
|
87
|
+
readonly gray: this;
|
|
88
|
+
readonly green: this;
|
|
89
|
+
readonly greenBright: this;
|
|
90
|
+
readonly grey: this;
|
|
91
|
+
/**
|
|
92
|
+
* Set HEX value for foreground color.
|
|
93
|
+
* @param {string} color
|
|
94
|
+
*/
|
|
95
|
+
hex: (color: ColorValueHex) => this;
|
|
96
|
+
/** Print the invisible text. */
|
|
97
|
+
readonly hidden: this;
|
|
98
|
+
/** Invert background and foreground colors. */
|
|
99
|
+
readonly inverse: this;
|
|
100
|
+
/** <i>Italic</i> style. (Not widely supported) */
|
|
101
|
+
readonly italic: this;
|
|
102
|
+
readonly magenta: this;
|
|
103
|
+
readonly magentaBright: this;
|
|
104
|
+
/** The ANSI escape sequences for starting the current style. */
|
|
105
|
+
readonly open: string;
|
|
106
|
+
/** O̅v̅e̅r̅l̅i̅n̅e̅ style. (Not widely supported) */
|
|
107
|
+
readonly overline: this;
|
|
108
|
+
readonly red: this;
|
|
109
|
+
readonly redBright: this;
|
|
110
|
+
/** Reset the current style. */
|
|
111
|
+
readonly reset: this;
|
|
112
|
+
/**
|
|
113
|
+
* Set RGB values for foreground color.
|
|
114
|
+
* @param {number} red The red value, in range [0, 255].
|
|
115
|
+
* @param {number} green The green value, in range [0, 255].
|
|
116
|
+
* @param {number} blue The blue value, in range [0, 255].
|
|
117
|
+
*/
|
|
118
|
+
rgb: (red: number, green: number, blue: number) => this;
|
|
119
|
+
/** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) The alias for `strikethrough`. */
|
|
120
|
+
readonly strike: this;
|
|
121
|
+
/** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) */
|
|
122
|
+
readonly strikethrough: this;
|
|
123
|
+
/**
|
|
124
|
+
* Remove ANSI styling codes.
|
|
125
|
+
* @param {string} string
|
|
126
|
+
* @returns {string}
|
|
127
|
+
*/
|
|
128
|
+
strip: (string: string) => string;
|
|
129
|
+
/** U̲n̲d̲e̲r̲l̲i̲n̲e̲ style. (Not widely supported) */
|
|
130
|
+
readonly underline: this;
|
|
131
|
+
/** Print visible text without ANSI styling. */
|
|
132
|
+
readonly visible: this;
|
|
133
|
+
readonly white: this;
|
|
134
|
+
readonly whiteBright: this;
|
|
135
|
+
readonly yellow: this;
|
|
136
|
+
readonly yellowBright: this;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Base ANSI Styles
|
|
140
|
+
*/
|
|
141
|
+
type AnsiStyles = "bold" | "dim" | "hidden" | "inverse" | "italic" | "overline" | "reset" | "strike" | "strikethrough" | "underline" | "visible";
|
|
142
|
+
/**
|
|
143
|
+
* Base ANSI Colors
|
|
144
|
+
*/
|
|
145
|
+
type AnsiColors = "bgBlack" | "bgBlackBright" | "bgBlue" | "bgBlueBright" | "bgCyan" | "bgCyanBright" | "bgGray" | "bgGreen" | "bgGreenBright" | "bgGrey" | "bgMagenta" | "bgMagentaBright" | "bgRed" | "bgRedBright" | "bgWhite" | "bgWhiteBright" | "bgYellow" | "bgYellowBright" | "black" | "blackBright" | "blue" | "blueBright" | "cyan" | "cyanBright" | "gray" | "green" | "greenBright" | "grey" | "magenta" | "magentaBright" | "red" | "redBright" | "white" | "whiteBright" | "yellow" | "yellowBright";
|
|
146
|
+
declare const WebColorize: new () => ColorizeType;
|
|
2
147
|
declare const colorize: ColorizeType;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export
|
|
60
|
-
export { default as Colorize } from "./colorize.d.ts";
|
|
61
|
-
export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.ts";
|
|
148
|
+
declare const ansi256: (code: number) => ColorizeType;
|
|
149
|
+
declare const bg: (code: number) => ColorizeType;
|
|
150
|
+
declare const bgAnsi256: (code: number) => ColorizeType;
|
|
151
|
+
declare const bgHex: (color: ColorValueHex) => ColorizeType;
|
|
152
|
+
declare const bgRgb: (red: number, green: number, blue: number) => ColorizeType;
|
|
153
|
+
declare const fg: (code: number) => ColorizeType;
|
|
154
|
+
declare const hex: (color: ColorValueHex) => ColorizeType;
|
|
155
|
+
declare const rgb: (red: number, green: number, blue: number) => ColorizeType;
|
|
156
|
+
declare const strip: (string: string) => string;
|
|
157
|
+
declare const bgBlack: ColorizeType;
|
|
158
|
+
declare const bgBlackBright: ColorizeType;
|
|
159
|
+
declare const bgBlue: ColorizeType;
|
|
160
|
+
declare const bgBlueBright: ColorizeType;
|
|
161
|
+
declare const bgCyan: ColorizeType;
|
|
162
|
+
declare const bgCyanBright: ColorizeType;
|
|
163
|
+
declare const bgGray: ColorizeType;
|
|
164
|
+
declare const bgGreen: ColorizeType;
|
|
165
|
+
declare const bgGreenBright: ColorizeType;
|
|
166
|
+
declare const bgGrey: ColorizeType;
|
|
167
|
+
declare const bgMagenta: ColorizeType;
|
|
168
|
+
declare const bgMagentaBright: ColorizeType;
|
|
169
|
+
declare const bgRed: ColorizeType;
|
|
170
|
+
declare const bgRedBright: ColorizeType;
|
|
171
|
+
declare const bgWhite: ColorizeType;
|
|
172
|
+
declare const bgWhiteBright: ColorizeType;
|
|
173
|
+
declare const bgYellow: ColorizeType;
|
|
174
|
+
declare const bgYellowBright: ColorizeType;
|
|
175
|
+
declare const black: ColorizeType;
|
|
176
|
+
declare const blackBright: ColorizeType;
|
|
177
|
+
declare const blue: ColorizeType;
|
|
178
|
+
declare const blueBright: ColorizeType;
|
|
179
|
+
declare const bold: ColorizeType;
|
|
180
|
+
declare const cyan: ColorizeType;
|
|
181
|
+
declare const cyanBright: ColorizeType;
|
|
182
|
+
declare const dim: ColorizeType;
|
|
183
|
+
declare const gray: ColorizeType;
|
|
184
|
+
declare const green: ColorizeType;
|
|
185
|
+
declare const greenBright: ColorizeType;
|
|
186
|
+
declare const grey: ColorizeType;
|
|
187
|
+
declare const hidden: ColorizeType;
|
|
188
|
+
declare const inverse: ColorizeType;
|
|
189
|
+
declare const italic: ColorizeType;
|
|
190
|
+
declare const magenta: ColorizeType;
|
|
191
|
+
declare const magentaBright: ColorizeType;
|
|
192
|
+
declare const overline: ColorizeType;
|
|
193
|
+
declare const red: ColorizeType;
|
|
194
|
+
declare const redBright: ColorizeType;
|
|
195
|
+
declare const reset: ColorizeType;
|
|
196
|
+
declare const strike: ColorizeType;
|
|
197
|
+
declare const strikethrough: ColorizeType;
|
|
198
|
+
declare const underline: ColorizeType;
|
|
199
|
+
declare const visible: ColorizeType;
|
|
200
|
+
declare const white: ColorizeType;
|
|
201
|
+
declare const whiteBright: ColorizeType;
|
|
202
|
+
declare const yellow: ColorizeType;
|
|
203
|
+
declare const yellowBright: ColorizeType;
|
|
204
|
+
export { type AnsiColors, type AnsiStyles, WebColorize as Colorize, type ColorizeType, ansi256, bg, bgAnsi256, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgHex, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgRgb, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, colorize as default, dim, fg, gray, green, greenBright, grey, hex, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, rgb, strike, strikethrough, strip, underline, visible, white, whiteBright, yellow, yellowBright };
|