@visulima/colorize 1.4.29 → 2.0.0-alpha.10

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +32 -30
  4. package/dist/ansi-codes.d.mts +1 -1
  5. package/dist/colorize.browser.d.mts +1 -1
  6. package/dist/colorize.server.d.mts +1 -1
  7. package/dist/css-code.d.mts +1 -1
  8. package/dist/gradient.cjs +9 -7
  9. package/dist/gradient.mjs +9 -7
  10. package/dist/index.browser.d.mts +5 -5
  11. package/dist/index.browser.mjs +1 -1
  12. package/dist/index.server.cjs +24 -15
  13. package/dist/index.server.d.cts +2 -2
  14. package/dist/index.server.d.mts +5 -5
  15. package/dist/index.server.d.ts +2 -2
  16. package/dist/index.server.mjs +1 -1
  17. package/dist/packem_shared/{Colorize-Ca9CXTcj.mjs → Colorize-BQ-Wlgs0.js} +9 -13
  18. package/dist/packem_shared/{Colorize-BenP3bFn.mjs → Colorize-rJUN0RFg.js} +24 -15
  19. package/dist/packem_shared/{GradientBuilder-Ba4Teq6P.mjs → GradientBuilder-CkX4Imo9.mjs} +36 -40
  20. package/dist/packem_shared/{GradientBuilder-DjJK22kP.cjs → GradientBuilder-DRrwebdU.cjs} +36 -40
  21. package/dist/packem_shared/{colorize.server-BA3gZZXz.cjs → colorize.server-CwTmhs0e.cjs} +14 -9
  22. package/dist/packem_shared/{colorize.server-ry9FZNfG.mjs → colorize.server-YxoHIDUp.mjs} +14 -9
  23. package/dist/packem_shared/convertHexToRgb-51-edHxE.cjs +21 -0
  24. package/dist/packem_shared/convertHexToRgb-BZwJEiMZ.mjs +17 -0
  25. package/dist/template.cjs +15 -7
  26. package/dist/template.mjs +15 -7
  27. package/dist/types.d.cts +3 -3
  28. package/dist/types.d.mts +3 -3
  29. package/dist/types.d.ts +3 -3
  30. package/dist/util/clamp.d.cts +1 -1
  31. package/dist/util/clamp.d.mts +1 -1
  32. package/dist/util/clamp.d.ts +1 -1
  33. package/dist/util/convert-hex-to-rgb.d.cts +1 -15
  34. package/dist/util/convert-hex-to-rgb.d.mts +1 -15
  35. package/dist/util/convert-hex-to-rgb.d.ts +1 -15
  36. package/dist/utils.cjs +1 -1
  37. package/dist/utils.mjs +1 -1
  38. package/package.json +5 -5
  39. package/dist/packem_shared/convertHexToRgb-CWdAm2kE.mjs +0 -13
  40. package/dist/packem_shared/convertHexToRgb-DvkHBM3-.cjs +0 -17
package/CHANGELOG.md CHANGED
@@ -1,3 +1,172 @@
1
+ ## @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
+
3
+ ### Bug Fixes
4
+
5
+ * Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
10
+ * **colorize:** apply pending changes ([2ef0ef0](https://github.com/visulima/visulima/commit/2ef0ef0f05183a62a442f2390947b955da33a23a))
11
+ * **colorize:** enforce curly braces and apply lint fixes ([aaa9abb](https://github.com/visulima/visulima/commit/aaa9abbf7216ecc6526a40104ad9088235978142))
12
+ * fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
13
+
14
+
15
+ ### Dependencies
16
+
17
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.10
18
+
19
+ ## @visulima/colorize [2.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.8...@visulima/colorize@2.0.0-alpha.9) (2026-04-15)
20
+
21
+ ### Bug Fixes
22
+
23
+ * **colorize:** resolve eslint and formatting issues ([edc292a](https://github.com/visulima/visulima/commit/edc292a567fb3a97e6428e6fee86b47137e00952))
24
+ * **terminal:** resolve eslint and formatting issues ([8f30389](https://github.com/visulima/visulima/commit/8f30389deb9ff81e7afce0aa064ef11fcb179f23))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.9
30
+
31
+ ## @visulima/colorize [2.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.7...@visulima/colorize@2.0.0-alpha.8) (2026-04-08)
32
+
33
+ ### Bug Fixes
34
+
35
+ * **colorize:** properly fix eslint errors in code ([c9941a4](https://github.com/visulima/visulima/commit/c9941a42e04570c7a4f39e4f65424b507a58352d))
36
+ * resolve failing tests across multiple packages ([2b4b6f0](https://github.com/visulima/visulima/commit/2b4b6f04169b60fdc4cf77b293015436a272c0fb))
37
+
38
+ ### Miscellaneous Chores
39
+
40
+ * apply linting and formatting fixes across packages ([5d150a5](https://github.com/visulima/visulima/commit/5d150a578f9ce861c791843c683deeb849b774a9))
41
+ * **colorize:** add tsconfig.eslint.json for type-aware linting ([0a2b596](https://github.com/visulima/visulima/commit/0a2b596b74df932cf492400029ecdaf572b8f474))
42
+ * **colorize:** apply prettier formatting ([f572dc4](https://github.com/visulima/visulima/commit/f572dc47f1398070adc5d4879d9f99870fe71760))
43
+ * **colorize:** migrate .prettierrc.cjs to prettier.config.js ([6d84ecc](https://github.com/visulima/visulima/commit/6d84eccbfba7ff59fd7463ef973b80d50d85f464))
44
+ * **terminal:** remove empty dependency objects from package.json ([562c704](https://github.com/visulima/visulima/commit/562c704e5d90aa2d13eae942ebbdcfeb787c2b46))
45
+
46
+
47
+ ### Dependencies
48
+
49
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.8
50
+
51
+ ## @visulima/colorize [2.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.6...@visulima/colorize@2.0.0-alpha.7) (2026-03-26)
52
+
53
+ ### Features
54
+
55
+ * **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
56
+
57
+ ### Miscellaneous Chores
58
+
59
+ * update homepage URLs to visulima.com/packages/ format ([be42968](https://github.com/visulima/visulima/commit/be42968129df85fb074224435e33135ff44cab91))
60
+
61
+
62
+ ### Dependencies
63
+
64
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.7
65
+
66
+ ## @visulima/colorize [2.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.5...@visulima/colorize@2.0.0-alpha.6) (2026-03-26)
67
+
68
+ ### Bug Fixes
69
+
70
+ * **colorize:** use workspace:* for internal [@visulima](https://github.com/visulima) deps ([65da9d0](https://github.com/visulima/visulima/commit/65da9d038280a836a925fc264186506841b89add))
71
+ * **web:** improve build setup with incremental stats caching and prod install ([fe33e75](https://github.com/visulima/visulima/commit/fe33e75827586779b4b3a0c6d57b39f889ee6207))
72
+
73
+ ### Miscellaneous Chores
74
+
75
+ * **colorize:** migrate deps to pnpm catalogs ([72117a7](https://github.com/visulima/visulima/commit/72117a7e915e99b81517a67a61bce44bf58bc23e))
76
+ * **colorize:** update dependencies ([ec10901](https://github.com/visulima/visulima/commit/ec109011e995724aaff2276344c18619c4c96ad9))
77
+ * visulima website ([#591](https://github.com/visulima/visulima/issues/591)) ([59ab2e2](https://github.com/visulima/visulima/commit/59ab2e2befb03e51cd2088956f83d9b87de6d033))
78
+
79
+
80
+ ### Dependencies
81
+
82
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.6
83
+
84
+ ## @visulima/colorize [2.0.0-alpha.5](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.4...@visulima/colorize@2.0.0-alpha.5) (2026-03-06)
85
+
86
+ ### Bug Fixes
87
+
88
+ * **colorize:** update packem to 2.0.0-alpha.54 ([61e248b](https://github.com/visulima/visulima/commit/61e248be63d5e3ad069aae06d5f0a76e5ca58600))
89
+
90
+ ### Documentation
91
+
92
+ * **object,redact,colorize,path,fs:** add comprehensive Fumadocs documentation ([19c3840](https://github.com/visulima/visulima/commit/19c384041db855e1c2de41ce2067458b39737565))
93
+
94
+ ### Miscellaneous Chores
95
+
96
+ * **colorize:** update dependencies ([9da1353](https://github.com/visulima/visulima/commit/9da1353fc7c6c61b511ceb2988f5ae2a6a598d45))
97
+ * **colorize:** update dependencies ([1d995c9](https://github.com/visulima/visulima/commit/1d995c97607a5c95ac208758e957a62180e27072))
98
+ * move top-level examples into their respective packages ([3bf7105](https://github.com/visulima/visulima/commit/3bf7105a56db6383ae65d5e28dea9a2c18af791a))
99
+ * moved examples ([bb07290](https://github.com/visulima/visulima/commit/bb07290fba65a83aaad8f0ef62d1c244d1610002))
100
+ * **terminal:** update dependencies ([a5bb91a](https://github.com/visulima/visulima/commit/a5bb91a66f2be2ade485d586156a54c347a23cc9))
101
+ * update lock file maintenance ([d83e716](https://github.com/visulima/visulima/commit/d83e71697b75d24704185b66bb521a934d2db02d))
102
+ * year update ([47f4105](https://github.com/visulima/visulima/commit/47f410596ce7190cfea36a073db32e0cec50bbcd))
103
+
104
+
105
+ ### Dependencies
106
+
107
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.5
108
+
109
+ ## @visulima/colorize [2.0.0-alpha.4](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.3...@visulima/colorize@2.0.0-alpha.4) (2025-12-27)
110
+
111
+ ### Bug Fixes
112
+
113
+ * **colorize:** update package files ([84c87a3](https://github.com/visulima/visulima/commit/84c87a3383cf370c94280319ac79ac106aaca3ec))
114
+
115
+ ### Miscellaneous Chores
116
+
117
+ * fixed project.json names and schema path ([964722f](https://github.com/visulima/visulima/commit/964722f691db205c7edb9aa6db29e849a647500b))
118
+
119
+
120
+ ### Dependencies
121
+
122
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.4
123
+
124
+ ## @visulima/colorize [2.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.2...@visulima/colorize@2.0.0-alpha.3) (2025-12-11)
125
+
126
+ ### Bug Fixes
127
+
128
+ * update package OG images across multiple packages ([f08e4dd](https://github.com/visulima/visulima/commit/f08e4dd2b105ccb29c8412020a9c2be36d6c1e9e))
129
+
130
+
131
+ ### Dependencies
132
+
133
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.3
134
+
135
+ ## @visulima/colorize [2.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.1...@visulima/colorize@2.0.0-alpha.2) (2025-12-06)
136
+
137
+ ### Bug Fixes
138
+
139
+ * add new package image, fixed readme rendering on npm, fixed building of packages ([b790ba2](https://github.com/visulima/visulima/commit/b790ba253ea07fef83528fd822a678facf021b5f))
140
+
141
+ ### Miscellaneous Chores
142
+
143
+ * update @anolilab/semantic-release-pnpm and @anolilab/semantic-release-preset to versions 3.2.2 and 12.1.2 across multiple package.json files for improved compatibility ([3921626](https://github.com/visulima/visulima/commit/3921626141fe5da398749bf0ba675f1596f18afb))
144
+
145
+
146
+ ### Dependencies
147
+
148
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.2
149
+
150
+ ## @visulima/colorize [2.0.0-alpha.1](https://github.com/visulima/visulima/compare/@visulima/colorize@1.4.29...@visulima/colorize@2.0.0-alpha.1) (2025-12-05)
151
+
152
+ ### ⚠ BREAKING CHANGES
153
+
154
+ * change min node version to 22.13
155
+
156
+ ### Bug Fixes
157
+
158
+ * update Node.js engine version requirement to >=22.13 in multiple package.json files for improved compatibility ([b828e9a](https://github.com/visulima/visulima/commit/b828e9aeaebfc798eecddccd90e6ec7560c6d36a))
159
+
160
+ ### Styles
161
+
162
+ * cs fix ([3ec237b](https://github.com/visulima/visulima/commit/3ec237b85eb4f83801d2c3f73a19e7107778dd5d))
163
+
164
+ ### Miscellaneous Chores
165
+
166
+ * moved all packages into groups ([0615e9d](https://github.com/visulima/visulima/commit/0615e9d14a8a886e11da529ce150cf31ca973c10))
167
+ * update dependencies across multiple packages to improve compatibility and performance, including upgrading `@anolilab/semantic-release-pnpm` and `@anolilab/semantic-release-preset` to versions 3.2.0 and 12.1.0 respectively, and updating `react`, `react-dom`, and `next` versions to 19.2.1 and 16.0.7 in various package.json files ([aee8fcd](https://github.com/visulima/visulima/commit/aee8fcd796ae9b8d055903260e7150996ea9f53d))
168
+ * upgrade `vitest` version to 4.0.15 in multiple package.json files and update lockfile for improved compatibility; adjust test cases for ESM package support in tooling tests ([0fba407](https://github.com/visulima/visulima/commit/0fba407e08283ba8c1c9488f99ca1f9ff676c4cf))
169
+
1
170
  ## @visulima/colorize [1.4.29](https://github.com/visulima/visulima/compare/@visulima/colorize@1.4.28...@visulima/colorize@1.4.29) (2025-11-13)
2
171
 
3
172
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 visulima
3
+ Copyright (c) 2026 visulima
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,20 +1,24 @@
1
- <div align="center">
2
- <h3>Visulima Colorize</h3>
3
- <p>
4
- Terminal and Console string styling done right, powered by <a href="https://github.com/visulima/visulima/packages/is-ansi-color-supported">@visulima/is-ansi-color-supported</a>.
1
+ <!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
5
2
 
6
- Colorize stands as a sleek, lightning-fast alternative to [Chalk][chalk], boasting a plethora of additional, valuable features.<br>
7
- Elevate your terminal experience by effortlessly adding vibrant colors to your output with its clean and straightforward syntax.<br>
8
- For instance, you can use `green` to make `` green`Hello World!` `` pop, `` red`Error!` `` to signify Errors, or `` black.bgYellow`Warning!` `` to highlight warnings.
3
+ <a href="https://www.anolilab.com/open-source" align="center">
9
4
 
10
- </p>
11
- </div>
5
+ <img src="__assets__/package-og.svg" alt="colorize" />
6
+
7
+ </a>
8
+
9
+ <h3 align="center">Terminal and Console string styling done right.</h3>
10
+
11
+ <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
12
12
 
13
13
  <br />
14
14
 
15
15
  <div align="center">
16
16
 
17
- [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
17
+ [![typescript-image][typescript-badge]][typescript-url]
18
+ [![mit licence][license-badge]][license]
19
+ [![npm downloads][npm-downloads-badge]][npm-downloads]
20
+ [![Chat][chat-badge]][chat]
21
+ [![PRs Welcome][prs-welcome-badge]][prs-welcome]
18
22
 
19
23
  </div>
20
24
 
@@ -919,25 +923,23 @@ Gradient:
919
923
  - [tinygradient](https://github.com/mistic100/tinygradient) - Easily generate color gradients with an unlimited number of color stops and steps.
920
924
  - [gradient-string](https://github.com/bokub/gradient-string) - Beautiful color gradients in terminal output
921
925
 
926
+ ## Made with ❤️ at Anolilab
927
+
928
+ This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
929
+
922
930
  ## License
923
931
 
924
- The visulima colorize is open-sourced software licensed under the [MIT][license-url]
925
-
926
- [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
927
-
928
- [typescript-url]: https://www.typescriptlang.org/ "TypeScript" "typescript"
929
- [license-image]: https://img.shields.io/npm/l/@visulima/colorize?color=blueviolet&style=for-the-badge
930
- [license-url]: LICENSE.md "license"
931
- [npm-image]: https://img.shields.io/npm/v/@visulima/colorize/latest.svg?style=for-the-badge&logo=npm
932
- [npm-url]: https://www.npmjs.com/package/@visulima/colorize/v/latest "npm"
933
- [colors.js]: https://github.com/Marak/colors.js
934
- [colorette]: https://github.com/jorgebucaran/colorette
935
- [picocolors]: https://github.com/alexeyraspopov/picocolors
936
- [cli-color]: https://github.com/medikoo/cli-color
937
- [colors-cli]: https://github.com/jaywcjlove/colors-cli
938
- [ansi-colors]: https://github.com/doowb/ansi-colors
939
- [kleur]: https://github.com/lukeed/kleur
940
- [chalk]: https://github.com/chalk/chalk
941
- [chalk-template]: https://github.com/chalk/chalk-template
942
- [ansis]: https://github.com/webdiscus/ansis
943
- [styleText]: https://nodejs.org/api/util.html#utilstyletextformat-text-options
932
+ The visulima colorize is open-sourced software licensed under the [MIT][license]
933
+
934
+ <!-- badges -->
935
+
936
+ [license-badge]: https://img.shields.io/npm/l/@visulima/colorize?style=for-the-badge
937
+ [license]: https://github.com/visulima/visulima/blob/main/LICENSE
938
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/colorize?style=for-the-badge
939
+ [npm-downloads]: https://www.npmjs.com/package/@visulima/colorize
940
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
941
+ [prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
942
+ [chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
943
+ [chat]: https://discord.gg/TtFJY8xkFK
944
+ [typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
945
+ [typescript-url]: https://www.typescriptlang.org/
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Copyright (c) 2023, webdiscus
7
7
  */
8
- import type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from "./types.d.mts";
8
+ import type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from "./types.d.ts";
9
9
  export declare const baseStyles: Required<Record<AnsiStyles, ColorData>>;
10
10
  export declare const baseColors: Required<Record<AnsiColors, ColorData>>;
11
11
  export declare const styleMethods: {
@@ -1,3 +1,3 @@
1
- import type { ColorizeType } from "./types.d.mts";
1
+ import type { ColorizeType } from "./types.d.ts";
2
2
  declare const WebColorize: new () => ColorizeType;
3
3
  export default WebColorize;
@@ -5,6 +5,6 @@
5
5
  *
6
6
  * Copyright (c) 2023, webdiscus
7
7
  */
8
- import type { ColorizeType } from "./types.d.mts";
8
+ import type { ColorizeType } from "./types.d.ts";
9
9
  declare const Colorize: new () => ColorizeType;
10
10
  export default Colorize;
@@ -1,4 +1,4 @@
1
- import type { AnsiColors, AnsiStyles } from "./types.d.mts";
1
+ import type { AnsiColors, AnsiStyles } from "./types.d.ts";
2
2
  export declare const baseStyles: Required<Record<AnsiStyles, string>>;
3
3
  export declare const baseColors: Required<Record<AnsiColors, string>>;
4
4
  export declare const styleMethods: {
package/dist/gradient.cjs CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const colorize_server = require('./packem_shared/colorize.server-BA3gZZXz.cjs');
6
- const GradientBuilder = require('./packem_shared/GradientBuilder-DjJK22kP.cjs');
5
+ const colorize_server = require('./packem_shared/colorize.server-CwTmhs0e.cjs');
6
+ const GradientBuilder = require('./packem_shared/GradientBuilder-DRrwebdU.cjs');
7
7
 
8
8
  const colorize = new colorize_server.Colorize();
9
- const forbiddenChars = /\s/g;
9
+ const WHITESPACE_GLOBAL = /\s/g;
10
+ const WHITESPACE_TEST = /\s/;
10
11
  const gradient = (stops, options) => {
11
12
  const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
12
13
  let builder = new GradientBuilder.GradientBuilder(colorize, stops);
@@ -16,11 +17,12 @@ const gradient = (stops, options) => {
16
17
  builder = builder.reverse();
17
18
  }
18
19
  return (string_) => {
19
- const colorsCount = Math.max(string_.replaceAll(forbiddenChars, "").length, builder.stops.length);
20
+ const stripped = string_.replaceAll(WHITESPACE_GLOBAL, "");
21
+ const colorsCount = Math.max(stripped.length, builder.stops.length);
20
22
  const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
21
23
  let result = "";
22
24
  for (const s of string_) {
23
- if (forbiddenChars.test(s)) {
25
+ if (WHITESPACE_TEST.test(s)) {
24
26
  result += s;
25
27
  } else {
26
28
  const color = colors.shift();
@@ -40,14 +42,14 @@ const multilineGradient = (stops, options) => {
40
42
  }
41
43
  return (string_) => {
42
44
  const lines = string_.split("\n");
43
- const colorsCount = Reflect.apply(Math.max, null, [...lines.map((l) => l.length), builder.stops.length]);
45
+ const colorsCount = Reflect.apply(Math.max, void 0, [...lines.map((l) => l.length), builder.stops.length]);
44
46
  const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
45
47
  const results = [];
46
48
  for (const line of lines) {
47
49
  const lineColors = [...colors];
48
50
  let lineResult = "";
49
51
  for (const l of line) {
50
- lineResult += forbiddenChars.test(l) ? l : lineColors.shift()(l);
52
+ lineResult += WHITESPACE_TEST.test(l) ? l : lineColors.shift()(l);
51
53
  }
52
54
  results.push(lineResult);
53
55
  }
package/dist/gradient.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import { C as Colorize } from './packem_shared/colorize.server-ry9FZNfG.mjs';
2
- import { GradientBuilder } from './packem_shared/GradientBuilder-Ba4Teq6P.mjs';
1
+ import { C as Colorize } from './packem_shared/colorize.server-YxoHIDUp.mjs';
2
+ import { GradientBuilder } from './packem_shared/GradientBuilder-CkX4Imo9.mjs';
3
3
 
4
4
  const colorize = new Colorize();
5
- const forbiddenChars = /\s/g;
5
+ const WHITESPACE_GLOBAL = /\s/g;
6
+ const WHITESPACE_TEST = /\s/;
6
7
  const gradient = (stops, options) => {
7
8
  const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
8
9
  let builder = new GradientBuilder(colorize, stops);
@@ -12,11 +13,12 @@ const gradient = (stops, options) => {
12
13
  builder = builder.reverse();
13
14
  }
14
15
  return (string_) => {
15
- const colorsCount = Math.max(string_.replaceAll(forbiddenChars, "").length, builder.stops.length);
16
+ const stripped = string_.replaceAll(WHITESPACE_GLOBAL, "");
17
+ const colorsCount = Math.max(stripped.length, builder.stops.length);
16
18
  const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
17
19
  let result = "";
18
20
  for (const s of string_) {
19
- if (forbiddenChars.test(s)) {
21
+ if (WHITESPACE_TEST.test(s)) {
20
22
  result += s;
21
23
  } else {
22
24
  const color = colors.shift();
@@ -36,14 +38,14 @@ const multilineGradient = (stops, options) => {
36
38
  }
37
39
  return (string_) => {
38
40
  const lines = string_.split("\n");
39
- const colorsCount = Reflect.apply(Math.max, null, [...lines.map((l) => l.length), builder.stops.length]);
41
+ const colorsCount = Reflect.apply(Math.max, void 0, [...lines.map((l) => l.length), builder.stops.length]);
40
42
  const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
41
43
  const results = [];
42
44
  for (const line of lines) {
43
45
  const lineColors = [...colors];
44
46
  let lineResult = "";
45
47
  for (const l of line) {
46
- lineResult += forbiddenChars.test(l) ? l : lineColors.shift()(l);
48
+ lineResult += WHITESPACE_TEST.test(l) ? l : lineColors.shift()(l);
47
49
  }
48
50
  results.push(lineResult);
49
51
  }
@@ -1,6 +1,6 @@
1
- import type { ColorizeType, ColorValueHex } from "./types.d.mts";
2
- declare const _default: ColorizeType;
3
- export default _default;
1
+ import type { ColorizeType, ColorValueHex } from "./types.d.ts";
2
+ declare const colorize: ColorizeType;
3
+ export default colorize;
4
4
  export declare const ansi256: (code: number) => ColorizeType;
5
5
  export declare const bg: (code: number) => ColorizeType;
6
6
  export declare const bgAnsi256: (code: number) => ColorizeType;
@@ -57,5 +57,5 @@ export declare const white: ColorizeType;
57
57
  export declare const whiteBright: ColorizeType;
58
58
  export declare const yellow: ColorizeType;
59
59
  export declare const yellowBright: ColorizeType;
60
- export { default as Colorize } from "./colorize.d.mts";
61
- export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.mts";
60
+ export { default as Colorize } from "./colorize.d.ts";
61
+ export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.ts";
@@ -1,4 +1,4 @@
1
- import WebColorize from './packem_shared/Colorize-Ca9CXTcj.mjs';
1
+ import WebColorize from './packem_shared/Colorize-BQ-Wlgs0.js';
2
2
 
3
3
  const colorize = new WebColorize();
4
4
  const ansi256 = colorize.ansi256;
@@ -10,18 +10,27 @@ function ansiRegex({ onlyFirst = false } = {}) {
10
10
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
11
11
  }
12
12
 
13
- const clamp = (number_, min, max) => min > number_ ? min : Math.min(number_, max);
13
+ const clamp = (number_, min, max) => {
14
+ if (min > number_) {
15
+ return min;
16
+ }
17
+ return Math.min(number_, max);
18
+ };
14
19
 
20
+ const HEX_COLOR_REGEX = /([a-f\d]{3,6})/i;
15
21
  const convertHexToRgb = (hex) => {
16
- let [, color] = /([a-f\d]{3,6})/i.exec(hex) ?? [];
17
- const length_ = color ? color.length : 0;
18
- if (length_ === 3) {
19
- color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];
20
- } else if (length_ !== 6) {
22
+ let [, color] = HEX_COLOR_REGEX.exec(hex) ?? [];
23
+ const colorLength = color ? color.length : 0;
24
+ if (colorLength === 3) {
25
+ const c0 = color.charAt(0);
26
+ const c1 = color.charAt(1);
27
+ const c2 = color.charAt(2);
28
+ color = c0 + c0 + c1 + c1 + c2 + c2;
29
+ } else if (colorLength !== 6) {
21
30
  return [0, 0, 0];
22
31
  }
23
- const number_ = Number.parseInt(color, 16);
24
- return [number_ >> 16 & 255, number_ >> 8 & 255, number_ & 255];
32
+ const colorNumber = Number.parseInt(color, 16);
33
+ return [colorNumber >> 16 & 255, colorNumber >> 8 & 255, colorNumber & 255];
25
34
  };
26
35
 
27
36
  const rgbToAnsi256 = (r, g, b) => {
@@ -70,17 +79,17 @@ const bgOffset = 10;
70
79
  const supportedColor = isAnsiColorSupported.isStdoutColorSupported();
71
80
  const mono = { close: "", open: "" };
72
81
  const esc = supportedColor > 0 ? (open, close) => {
73
- return { close: `\x1B[${close}m`, open: `\x1B[${open}m` };
82
+ return { close: `\x1B[${String(close)}m`, open: `\x1B[${String(open)}m` };
74
83
  } : () => mono;
75
84
  const createRgbFunction = (function_) => (r, g, b) => function_(rgbToAnsi256(Number(r), Number(g), Number(b)));
76
85
  const createHexFunction = (function_) => (hex) => {
77
86
  const [r, g, b] = convertHexToRgb(hex);
78
87
  return function_(r, g, b);
79
88
  };
80
- let createAnsi256 = (code) => esc(`38;5;${code}`, closeCode);
81
- let createBgAnsi256 = (code) => esc(`48;5;${code}`, bgCloseCode);
82
- let createRgb = (r, g, b) => esc(`38;2;${r};${g};${b}`, closeCode);
83
- let createBgRgb = (r, g, b) => esc(`48;2;${r};${g};${b}`, bgCloseCode);
89
+ let createAnsi256 = (code) => esc(`38;5;${String(code)}`, closeCode);
90
+ let createBgAnsi256 = (code) => esc(`48;5;${String(code)}`, bgCloseCode);
91
+ let createRgb = (r, g, b) => esc(`38;2;${String(r)};${String(g)};${String(b)}`, closeCode);
92
+ let createBgRgb = (r, g, b) => esc(`48;2;${String(r)};${String(g)};${String(b)}`, bgCloseCode);
84
93
  if (supportedColor === 1) {
85
94
  createAnsi256 = (code) => esc(ansi256To16(Number(code)), closeCode);
86
95
  createBgAnsi256 = (code) => esc(ansi256To16(Number(code)) + bgOffset, bgCloseCode);
@@ -181,7 +190,7 @@ const wrapText = (strings, values, properties) => {
181
190
  if (!strings) {
182
191
  return "";
183
192
  }
184
- let string = strings.raw == void 0 ? `${strings}` : String.raw(strings, ...values);
193
+ let string = strings.raw === void 0 ? String(strings) : String.raw(strings, ...values);
185
194
  if (string.includes("\x1B")) {
186
195
  for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {
187
196
  string = stringReplaceAll(string, currentProperties.close, currentProperties.open);
@@ -203,7 +212,7 @@ const createStyle = ({ props }, { close, open }) => {
203
212
  return style;
204
213
  };
205
214
  const Colorize = function() {
206
- const self = (string_) => `${string_}`;
215
+ const self = (string_) => String(string_);
207
216
  self.strip = (value) => value.replaceAll(ansiRegex(), "");
208
217
  for (const name in baseColors) {
209
218
  styles[name] = {
@@ -3,6 +3,6 @@ import type { ColorizeType } from "./types.d.cts";
3
3
  type ColorizeTypeWithColorize = ColorizeType & {
4
4
  Colorize: typeof ColorizeImpl;
5
5
  };
6
- declare const _default: ColorizeTypeWithColorize;
7
- export = _default;
6
+ declare const colorize: ColorizeTypeWithColorize;
7
+ export = colorize;
8
8
  export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.cts";
@@ -1,6 +1,6 @@
1
- import type { ColorizeType, ColorValueHex } from "./types.d.mts";
2
- declare const _default: ColorizeType;
3
- export default _default;
1
+ import type { ColorizeType, ColorValueHex } from "./types.d.ts";
2
+ declare const colorize: ColorizeType;
3
+ export default colorize;
4
4
  export declare const ansi256: (code: number) => ColorizeType;
5
5
  export declare const bg: (code: number) => ColorizeType;
6
6
  export declare const bgAnsi256: (code: number) => ColorizeType;
@@ -57,5 +57,5 @@ export declare const white: ColorizeType;
57
57
  export declare const whiteBright: ColorizeType;
58
58
  export declare const yellow: ColorizeType;
59
59
  export declare const yellowBright: ColorizeType;
60
- export { default as Colorize } from "./colorize.d.mts";
61
- export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.mts";
60
+ export { default as Colorize } from "./colorize.d.ts";
61
+ export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.ts";
@@ -3,6 +3,6 @@ import type { ColorizeType } from "./types.d.ts";
3
3
  type ColorizeTypeWithColorize = ColorizeType & {
4
4
  Colorize: typeof ColorizeImpl;
5
5
  };
6
- declare const _default: ColorizeTypeWithColorize;
7
- export = _default;
6
+ declare const colorize: ColorizeTypeWithColorize;
7
+ export = colorize;
8
8
  export type { AnsiColors, AnsiStyles, ColorizeType } from "./types.d.ts";
@@ -1,4 +1,4 @@
1
- import Colorize from './packem_shared/Colorize-BenP3bFn.mjs';
1
+ import Colorize from './packem_shared/Colorize-rJUN0RFg.js';
2
2
 
3
3
  const colorize = new Colorize();
4
4
  const ansi256 = colorize.ansi256;
@@ -313,14 +313,12 @@ const baseColors = {
313
313
  yellowBright: "color: #ff5;"
314
314
  };
315
315
  const styleMethods = {
316
- // eslint-disable-next-line security/detect-object-injection
317
- bg: (code) => `background-color: ${ansiCodeHexMap[code]};`,
316
+ bg: (code) => `background-color: ${ansiCodeHexMap[code] ?? ""};`,
318
317
  bgHex: (hex) => `background-color: ${hex};`,
319
- bgRgb: (r, g, b) => `background-color: rgb(${r},${g},${b});`,
320
- // eslint-disable-next-line security/detect-object-injection
321
- fg: (code) => `color: ${ansiCodeHexMap[code]};`,
318
+ bgRgb: (r, g, b) => `background-color: rgb(${String(r)},${String(g)},${String(b)});`,
319
+ fg: (code) => `color: ${ansiCodeHexMap[code] ?? ""};`,
322
320
  hex: (hex) => `color:${hex};`,
323
- rgb: (r, g, b) => `color: rgb(${r},${g},${b});`
321
+ rgb: (r, g, b) => `color: rgb(${String(r)},${String(g)},${String(b)});`
324
322
  };
325
323
 
326
324
  const styles = {};
@@ -339,9 +337,7 @@ const createStyle = ({ props }, css) => {
339
337
  const cssObject = cssStringToObject(css);
340
338
  const propertiesCssObject = cssStringToObject(props.cssStack);
341
339
  for (const key in propertiesCssObject) {
342
- if (cssObject[key] === void 0) {
343
- cssObject[key] = propertiesCssObject[key];
344
- }
340
+ cssObject[key] ??= propertiesCssObject[key];
345
341
  }
346
342
  cssStack = `${JSON.stringify(cssObject).replace(/["{}]/g, "").replace(/,/g, ";")};`;
347
343
  }
@@ -355,9 +351,9 @@ const createStyle = ({ props }, css) => {
355
351
  return [`%c${inputWithoutStyles}`, style.css, ...collectedStyles ?? []];
356
352
  }
357
353
  if (typeof input === "number" || typeof input === "string") {
358
- return [`%c${input}`, style.css];
354
+ return [`%c${String(input)}`, style.css];
359
355
  }
360
- if (input.raw !== null && Array.isArray(values) && values.length > 0) {
356
+ if (input.raw !== void 0 && Array.isArray(values) && values.length > 0) {
361
357
  const rawString = String.raw(input, ...values);
362
358
  const collectedStyles = rawString.match(/(?<=,).*;/g);
363
359
  const inputWithoutStyles = rawString.replace(/,.*;/g, "");
@@ -365,7 +361,7 @@ const createStyle = ({ props }, css) => {
365
361
  }
366
362
  const [first, ...rest] = input;
367
363
  rest.unshift(style.css);
368
- return [`${`${first}`.includes("%c") ? "" : "%c"}${first}`, rest.join("")];
364
+ return [`${String(first).includes("%c") ? "" : "%c"}${String(first)}`, rest.join("")];
369
365
  };
370
366
  Object.setPrototypeOf(style, stylePrototype);
371
367
  style.props = { css, cssStack, props };
@@ -373,7 +369,7 @@ const createStyle = ({ props }, css) => {
373
369
  return style;
374
370
  };
375
371
  const WebColorize = function() {
376
- const self = (string_) => `${string_}`;
372
+ const self = (string_) => String(string_);
377
373
  self.strip = (value) => value;
378
374
  for (const name in baseColors) {
379
375
  styles[name] = {