@visulima/fmt 2.0.0-alpha.7 → 2.0.0-alpha.8
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 +13 -0
- package/dist/index.cjs +20 -20
- package/dist/index.mjs +20 -20
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## @visulima/fmt [2.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/fmt@2.0.0-alpha.7...@visulima/fmt@2.0.0-alpha.8) (2026-04-08)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **fmt:** resolve eslint errors ([45181b2](https://github.com/visulima/visulima/commit/45181b24520bcb2ee766497e677f7fcd6f8182d8))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* **fmt:** add tsconfig.eslint.json for type-aware linting ([d47f7c0](https://github.com/visulima/visulima/commit/d47f7c0068c69d0f9de86c2d6653ba5d3b55ab48))
|
|
10
|
+
* **fmt:** apply prettier formatting ([1e9c241](https://github.com/visulima/visulima/commit/1e9c241d498a92740cb9d6b5ff040d200738669a))
|
|
11
|
+
* **fmt:** migrate .prettierrc.cjs to prettier.config.js ([c699d91](https://github.com/visulima/visulima/commit/c699d916dd5c9a00bcec10f2ae073774d932cb3d))
|
|
12
|
+
* **terminal:** remove empty dependency objects from package.json ([562c704](https://github.com/visulima/visulima/commit/562c704e5d90aa2d13eae942ebbdcfeb787c2b46))
|
|
13
|
+
|
|
1
14
|
## @visulima/fmt [2.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/fmt@2.0.0-alpha.6...@visulima/fmt@2.0.0-alpha.7) (2026-03-26)
|
|
2
15
|
|
|
3
16
|
### Features
|
package/dist/index.cjs
CHANGED
|
@@ -167,7 +167,7 @@ const getDefaultCss = () => {
|
|
|
167
167
|
textDecorationLine: []
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
|
-
const SPACE_PATTERN = /\s
|
|
170
|
+
const SPACE_PATTERN = /\s+/;
|
|
171
171
|
const parseCssColor = (colorString) => {
|
|
172
172
|
if (colorKeywords.has(colorString)) {
|
|
173
173
|
colorString = colorKeywords.get(colorString);
|
|
@@ -233,10 +233,10 @@ const parseCss = (cssString) => {
|
|
|
233
233
|
let currentPart = "";
|
|
234
234
|
for (const c of cssString) {
|
|
235
235
|
if (c === "(") {
|
|
236
|
-
parenthesesDepth
|
|
236
|
+
parenthesesDepth += 1;
|
|
237
237
|
} else if (parenthesesDepth > 0) {
|
|
238
238
|
if (c === ")") {
|
|
239
|
-
parenthesesDepth
|
|
239
|
+
parenthesesDepth -= 1;
|
|
240
240
|
}
|
|
241
241
|
} else if (inValue) {
|
|
242
242
|
if (c === ";") {
|
|
@@ -369,14 +369,14 @@ const cssToAnsi = (css, previousCss = null) => {
|
|
|
369
369
|
default: {
|
|
370
370
|
if (Array.isArray(css.backgroundColor)) {
|
|
371
371
|
const { 0: r, 1: g, 2: b } = css.backgroundColor;
|
|
372
|
-
ansi += `\x1B[48;2;${r};${g};${b}m`;
|
|
372
|
+
ansi += `\x1B[48;2;${String(r)};${String(g)};${String(b)}m`;
|
|
373
373
|
} else {
|
|
374
374
|
const parsed = parseCssColor(css.backgroundColor);
|
|
375
375
|
if (parsed === null) {
|
|
376
376
|
ansi += "\x1B[49m";
|
|
377
377
|
} else {
|
|
378
378
|
const { 0: r, 1: g, 2: b } = parsed;
|
|
379
|
-
ansi += `\x1B[48;2;${r};${g};${b}m`;
|
|
379
|
+
ansi += `\x1B[48;2;${String(r)};${String(g)};${String(b)}m`;
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
}
|
|
@@ -423,14 +423,14 @@ const cssToAnsi = (css, previousCss = null) => {
|
|
|
423
423
|
default: {
|
|
424
424
|
if (Array.isArray(css.color)) {
|
|
425
425
|
const { 0: r, 1: g, 2: b } = css.color;
|
|
426
|
-
ansi += `\x1B[38;2;${r};${g};${b}m`;
|
|
426
|
+
ansi += `\x1B[38;2;${String(r)};${String(g)};${String(b)}m`;
|
|
427
427
|
} else {
|
|
428
428
|
const parsed = parseCssColor(css.color);
|
|
429
429
|
if (parsed === null) {
|
|
430
430
|
ansi += "\x1B[39m";
|
|
431
431
|
} else {
|
|
432
432
|
const { 0: r, 1: g, 2: b } = parsed;
|
|
433
|
-
ansi += `\x1B[38;2;${r};${g};${b}m`;
|
|
433
|
+
ansi += `\x1B[38;2;${String(r)};${String(g)};${String(b)}m`;
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
}
|
|
@@ -448,7 +448,7 @@ const cssToAnsi = (css, previousCss = null) => {
|
|
|
448
448
|
ansi += "\x1B[59m";
|
|
449
449
|
} else {
|
|
450
450
|
const { 0: r, 1: g, 2: b } = css.textDecorationColor;
|
|
451
|
-
ansi += `\x1B[58;2;${r};${g};${b}m`;
|
|
451
|
+
ansi += `\x1B[58;2;${String(r)};${String(g)};${String(b)}m`;
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
if (css.textDecorationLine.includes("line-through") !== previousCss.textDecorationLine.includes("line-through")) {
|
|
@@ -492,7 +492,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
492
492
|
}
|
|
493
493
|
const objects = Array.from({ length: argumentsLength });
|
|
494
494
|
objects[0] = stringify(fmt);
|
|
495
|
-
for (let index = 1; index < argumentsLength; index
|
|
495
|
+
for (let index = 1; index < argumentsLength; index += 1) {
|
|
496
496
|
objects[index] = stringify(arguments_[index - offset]);
|
|
497
497
|
}
|
|
498
498
|
return objects.join(" ");
|
|
@@ -510,7 +510,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
510
510
|
lastPosition = lastPosition > -1 ? lastPosition : 0;
|
|
511
511
|
const c = fmt.codePointAt(index + 1);
|
|
512
512
|
if (c === void 0) {
|
|
513
|
-
|
|
513
|
+
a += 1;
|
|
514
514
|
break;
|
|
515
515
|
}
|
|
516
516
|
switch (c) {
|
|
@@ -527,7 +527,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
lastPosition = index + 2;
|
|
530
|
-
index
|
|
530
|
+
index += 1;
|
|
531
531
|
break;
|
|
532
532
|
}
|
|
533
533
|
case CHAR_d:
|
|
@@ -540,7 +540,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
540
540
|
}
|
|
541
541
|
result += Number(arguments_[a]).toString();
|
|
542
542
|
lastPosition = index + 2;
|
|
543
|
-
index
|
|
543
|
+
index += 1;
|
|
544
544
|
break;
|
|
545
545
|
}
|
|
546
546
|
case CHAR_i: {
|
|
@@ -552,7 +552,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
552
552
|
}
|
|
553
553
|
result += Math.floor(Number(arguments_[a])).toString();
|
|
554
554
|
lastPosition = index + 2;
|
|
555
|
-
index
|
|
555
|
+
index += 1;
|
|
556
556
|
break;
|
|
557
557
|
}
|
|
558
558
|
case CHAR_j:
|
|
@@ -578,7 +578,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
578
578
|
}
|
|
579
579
|
result += stringify(temporaryArgument);
|
|
580
580
|
lastPosition = index + 2;
|
|
581
|
-
index
|
|
581
|
+
index += 1;
|
|
582
582
|
break;
|
|
583
583
|
}
|
|
584
584
|
case CHAR_PERCENT: {
|
|
@@ -587,8 +587,8 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
587
587
|
}
|
|
588
588
|
result += "%";
|
|
589
589
|
lastPosition = index + 2;
|
|
590
|
-
index
|
|
591
|
-
a
|
|
590
|
+
index += 1;
|
|
591
|
+
a -= 1;
|
|
592
592
|
break;
|
|
593
593
|
}
|
|
594
594
|
case CHAR_s: {
|
|
@@ -600,7 +600,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
600
600
|
}
|
|
601
601
|
result += typeof arguments_[a] === "object" ? stringify(arguments_[a]) : String(arguments_[a]);
|
|
602
602
|
lastPosition = index + 2;
|
|
603
|
-
index
|
|
603
|
+
index += 1;
|
|
604
604
|
break;
|
|
605
605
|
}
|
|
606
606
|
default: {
|
|
@@ -610,13 +610,13 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
610
610
|
}
|
|
611
611
|
result += options.formatters[c](arguments_[a]);
|
|
612
612
|
lastPosition = index + 2;
|
|
613
|
-
index
|
|
613
|
+
index += 1;
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
|
|
617
|
+
a += 1;
|
|
618
618
|
}
|
|
619
|
-
|
|
619
|
+
index += 1;
|
|
620
620
|
}
|
|
621
621
|
if (lastPosition === -1) {
|
|
622
622
|
return fmt;
|
package/dist/index.mjs
CHANGED
|
@@ -163,7 +163,7 @@ const getDefaultCss = () => {
|
|
|
163
163
|
textDecorationLine: []
|
|
164
164
|
};
|
|
165
165
|
};
|
|
166
|
-
const SPACE_PATTERN = /\s
|
|
166
|
+
const SPACE_PATTERN = /\s+/;
|
|
167
167
|
const parseCssColor = (colorString) => {
|
|
168
168
|
if (colorKeywords.has(colorString)) {
|
|
169
169
|
colorString = colorKeywords.get(colorString);
|
|
@@ -229,10 +229,10 @@ const parseCss = (cssString) => {
|
|
|
229
229
|
let currentPart = "";
|
|
230
230
|
for (const c of cssString) {
|
|
231
231
|
if (c === "(") {
|
|
232
|
-
parenthesesDepth
|
|
232
|
+
parenthesesDepth += 1;
|
|
233
233
|
} else if (parenthesesDepth > 0) {
|
|
234
234
|
if (c === ")") {
|
|
235
|
-
parenthesesDepth
|
|
235
|
+
parenthesesDepth -= 1;
|
|
236
236
|
}
|
|
237
237
|
} else if (inValue) {
|
|
238
238
|
if (c === ";") {
|
|
@@ -365,14 +365,14 @@ const cssToAnsi = (css, previousCss = null) => {
|
|
|
365
365
|
default: {
|
|
366
366
|
if (Array.isArray(css.backgroundColor)) {
|
|
367
367
|
const { 0: r, 1: g, 2: b } = css.backgroundColor;
|
|
368
|
-
ansi += `\x1B[48;2;${r};${g};${b}m`;
|
|
368
|
+
ansi += `\x1B[48;2;${String(r)};${String(g)};${String(b)}m`;
|
|
369
369
|
} else {
|
|
370
370
|
const parsed = parseCssColor(css.backgroundColor);
|
|
371
371
|
if (parsed === null) {
|
|
372
372
|
ansi += "\x1B[49m";
|
|
373
373
|
} else {
|
|
374
374
|
const { 0: r, 1: g, 2: b } = parsed;
|
|
375
|
-
ansi += `\x1B[48;2;${r};${g};${b}m`;
|
|
375
|
+
ansi += `\x1B[48;2;${String(r)};${String(g)};${String(b)}m`;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
}
|
|
@@ -419,14 +419,14 @@ const cssToAnsi = (css, previousCss = null) => {
|
|
|
419
419
|
default: {
|
|
420
420
|
if (Array.isArray(css.color)) {
|
|
421
421
|
const { 0: r, 1: g, 2: b } = css.color;
|
|
422
|
-
ansi += `\x1B[38;2;${r};${g};${b}m`;
|
|
422
|
+
ansi += `\x1B[38;2;${String(r)};${String(g)};${String(b)}m`;
|
|
423
423
|
} else {
|
|
424
424
|
const parsed = parseCssColor(css.color);
|
|
425
425
|
if (parsed === null) {
|
|
426
426
|
ansi += "\x1B[39m";
|
|
427
427
|
} else {
|
|
428
428
|
const { 0: r, 1: g, 2: b } = parsed;
|
|
429
|
-
ansi += `\x1B[38;2;${r};${g};${b}m`;
|
|
429
|
+
ansi += `\x1B[38;2;${String(r)};${String(g)};${String(b)}m`;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
}
|
|
@@ -444,7 +444,7 @@ const cssToAnsi = (css, previousCss = null) => {
|
|
|
444
444
|
ansi += "\x1B[59m";
|
|
445
445
|
} else {
|
|
446
446
|
const { 0: r, 1: g, 2: b } = css.textDecorationColor;
|
|
447
|
-
ansi += `\x1B[58;2;${r};${g};${b}m`;
|
|
447
|
+
ansi += `\x1B[58;2;${String(r)};${String(g)};${String(b)}m`;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
if (css.textDecorationLine.includes("line-through") !== previousCss.textDecorationLine.includes("line-through")) {
|
|
@@ -488,7 +488,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
488
488
|
}
|
|
489
489
|
const objects = Array.from({ length: argumentsLength });
|
|
490
490
|
objects[0] = stringify(fmt);
|
|
491
|
-
for (let index = 1; index < argumentsLength; index
|
|
491
|
+
for (let index = 1; index < argumentsLength; index += 1) {
|
|
492
492
|
objects[index] = stringify(arguments_[index - offset]);
|
|
493
493
|
}
|
|
494
494
|
return objects.join(" ");
|
|
@@ -506,7 +506,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
506
506
|
lastPosition = lastPosition > -1 ? lastPosition : 0;
|
|
507
507
|
const c = fmt.codePointAt(index + 1);
|
|
508
508
|
if (c === void 0) {
|
|
509
|
-
|
|
509
|
+
a += 1;
|
|
510
510
|
break;
|
|
511
511
|
}
|
|
512
512
|
switch (c) {
|
|
@@ -523,7 +523,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
lastPosition = index + 2;
|
|
526
|
-
index
|
|
526
|
+
index += 1;
|
|
527
527
|
break;
|
|
528
528
|
}
|
|
529
529
|
case CHAR_d:
|
|
@@ -536,7 +536,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
536
536
|
}
|
|
537
537
|
result += Number(arguments_[a]).toString();
|
|
538
538
|
lastPosition = index + 2;
|
|
539
|
-
index
|
|
539
|
+
index += 1;
|
|
540
540
|
break;
|
|
541
541
|
}
|
|
542
542
|
case CHAR_i: {
|
|
@@ -548,7 +548,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
548
548
|
}
|
|
549
549
|
result += Math.floor(Number(arguments_[a])).toString();
|
|
550
550
|
lastPosition = index + 2;
|
|
551
|
-
index
|
|
551
|
+
index += 1;
|
|
552
552
|
break;
|
|
553
553
|
}
|
|
554
554
|
case CHAR_j:
|
|
@@ -574,7 +574,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
574
574
|
}
|
|
575
575
|
result += stringify(temporaryArgument);
|
|
576
576
|
lastPosition = index + 2;
|
|
577
|
-
index
|
|
577
|
+
index += 1;
|
|
578
578
|
break;
|
|
579
579
|
}
|
|
580
580
|
case CHAR_PERCENT: {
|
|
@@ -583,8 +583,8 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
583
583
|
}
|
|
584
584
|
result += "%";
|
|
585
585
|
lastPosition = index + 2;
|
|
586
|
-
index
|
|
587
|
-
a
|
|
586
|
+
index += 1;
|
|
587
|
+
a -= 1;
|
|
588
588
|
break;
|
|
589
589
|
}
|
|
590
590
|
case CHAR_s: {
|
|
@@ -596,7 +596,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
596
596
|
}
|
|
597
597
|
result += typeof arguments_[a] === "object" ? stringify(arguments_[a]) : String(arguments_[a]);
|
|
598
598
|
lastPosition = index + 2;
|
|
599
|
-
index
|
|
599
|
+
index += 1;
|
|
600
600
|
break;
|
|
601
601
|
}
|
|
602
602
|
default: {
|
|
@@ -606,13 +606,13 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
606
606
|
}
|
|
607
607
|
result += options.formatters[c](arguments_[a]);
|
|
608
608
|
lastPosition = index + 2;
|
|
609
|
-
index
|
|
609
|
+
index += 1;
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
|
-
|
|
613
|
+
a += 1;
|
|
614
614
|
}
|
|
615
|
-
|
|
615
|
+
index += 1;
|
|
616
616
|
}
|
|
617
617
|
if (lastPosition === -1) {
|
|
618
618
|
return fmt;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/fmt",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.8",
|
|
4
4
|
"description": "Util.format-like string formatting utility.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -70,9 +70,6 @@
|
|
|
70
70
|
"CHANGELOG.md",
|
|
71
71
|
"LICENSE.md"
|
|
72
72
|
],
|
|
73
|
-
"dependencies": {},
|
|
74
|
-
"peerDependencies": {},
|
|
75
|
-
"optionalDependencies": {},
|
|
76
73
|
"engines": {
|
|
77
74
|
"node": ">=22.13 <=25.x"
|
|
78
75
|
},
|