@visulima/pail 3.0.2 → 3.1.0
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 +31 -1
- package/LICENSE.md +34 -0
- package/README.md +280 -0
- package/dist/index.browser.d.ts +4 -3
- package/dist/index.server.d.ts +14 -72
- package/dist/index.server.js +2 -5
- package/dist/interactive/index.d.ts +28 -0
- package/dist/interactive/index.js +1 -0
- package/dist/object-tree.d.ts +17 -0
- package/dist/object-tree.js +2 -0
- package/dist/packem_shared/InteractiveManager-CgmJyW9x.js +3 -0
- package/dist/packem_shared/InteractiveStreamHook-NtJu71aN.js +1 -0
- package/dist/packem_shared/JsonReporter-DTBtHNaD.js +2 -0
- package/dist/packem_shared/PrettyReporter-Bns0ZWLy.js +12 -0
- package/dist/packem_shared/{abstract-json-reporter-wUti0B3k.d.ts → abstract-json-reporter-CPsNkpz8.d.ts} +3 -3
- package/dist/packem_shared/{abstract-pretty-reporter-MOYolfGR.d.ts → abstract-pretty-reporter-DB2G-qlI.d.ts} +1 -1
- package/dist/packem_shared/format-label-CpyyTBom.js +26 -0
- package/dist/packem_shared/index-CysYvHXs.js +8 -0
- package/dist/packem_shared/interactive-stream-hook-CeVo4Kth.js +2 -0
- package/dist/packem_shared/{pail.browser-Bs2ng_Qj.d.ts → pail.browser-CmWcqnn9.d.ts} +1 -1
- package/dist/packem_shared/{types-RidvA4RN.d.ts → types-DVzG8TWL.d.ts} +2 -29
- package/dist/processor/caller/caller-processor.d.ts +2 -1
- package/dist/processor/message-formatter-processor.d.ts +2 -1
- package/dist/processor/redact-processor.d.ts +2 -1
- package/dist/progress-bar.d.ts +76 -0
- package/dist/progress-bar.js +1 -0
- package/dist/reporter/file/json-file-reporter.d.ts +3 -2
- package/dist/reporter/json/index.browser.d.ts +3 -2
- package/dist/reporter/json/index.d.ts +3 -2
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/pretty/index.browser.d.ts +3 -2
- package/dist/reporter/pretty/index.d.ts +3 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +3 -2
- package/dist/reporter/simple/simple-reporter.server.js +6 -6
- package/dist/spinner.d.ts +154 -0
- package/dist/spinner.js +1 -0
- package/package.json +20 -4
- package/dist/packem_shared/JsonReporter-Bb6YuCj2.js +0 -2
- package/dist/packem_shared/PrettyReporter-CREln5bH.js +0 -12
- package/dist/packem_shared/format-label-DqvZRRR6.js +0 -33
- package/dist/packem_shared/getBarChar-mKDZW32R.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## @visulima/pail [3.1.0](https://github.com/visulima/visulima/compare/@visulima/pail@3.0.3...@visulima/pail@3.1.0) (2025-11-05)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* add comprehensive documentation for Pail logging library ([6b552ad](https://github.com/visulima/visulima/commit/6b552adc5763aa13b9ac03f457db686c09a73e1c))
|
|
6
|
+
* add interactive module and update package.json ([bb9328c](https://github.com/visulima/visulima/commit/bb9328c98701108e601c07c5f1fff4f554c682cf))
|
|
7
|
+
* **pail:** add comprehensive documentation, object tree, spinner, and enhanced progress bar ([f69738b](https://github.com/visulima/visulima/commit/f69738b708fa73b6755d66b0c5ef5283e85fd55b))
|
|
8
|
+
|
|
9
|
+
### Miscellaneous Chores
|
|
10
|
+
|
|
11
|
+
* update dependencies in package.json for cerebro and pail ([4ff6e98](https://github.com/visulima/visulima/commit/4ff6e984e4e2707095bbdff76c1362fa7d30c8ec))
|
|
12
|
+
* update documentation and improve formatting across multiple files ([449b4fb](https://github.com/visulima/visulima/commit/449b4fbd1a57711e2daf5c8ded6a95c9cca87a03))
|
|
13
|
+
|
|
14
|
+
## @visulima/pail [3.0.3](https://github.com/visulima/visulima/compare/@visulima/pail@3.0.2...@visulima/pail@3.0.3) (2025-11-05)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* update dependencies across multiple packages ([36a47f2](https://github.com/visulima/visulima/commit/36a47f26d65d25a7b4d8371186710e7d0ab61a2b))
|
|
19
|
+
* Upgraded `type-fest` to version `5.2.0` ([bd6cd53](https://github.com/visulima/visulima/commit/bd6cd5367ff102a7487372dc1ca7742a41c69ea9))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Dependencies
|
|
23
|
+
|
|
24
|
+
* **@visulima/colorize:** upgraded to 1.4.26
|
|
25
|
+
* **@visulima/error:** upgraded to 5.0.3
|
|
26
|
+
* **@visulima/fmt:** upgraded to 1.1.18
|
|
27
|
+
* **@visulima/inspector:** upgraded to 1.0.27
|
|
28
|
+
* **@visulima/redact:** upgraded to 2.0.2
|
|
29
|
+
* **@visulima/string:** upgraded to 2.0.3
|
|
30
|
+
|
|
1
31
|
## @visulima/pail [3.0.2](https://github.com/visulima/visulima/compare/@visulima/pail@3.0.1...@visulima/pail@3.0.2) (2025-10-22)
|
|
2
32
|
|
|
3
33
|
### Miscellaneous Chores
|
|
@@ -86,7 +116,7 @@
|
|
|
86
116
|
### Bug Fixes
|
|
87
117
|
|
|
88
118
|
* consolidate ESLint configuration and remove obsolete files for improved maintainability ([5b3e825](https://github.com/visulima/visulima/commit/5b3e825f3f2f428c9fb0950c300de10b42b657f9))
|
|
89
|
-
* update @visulima/packem to 2.0.0-alpha.
|
|
119
|
+
* update @visulima/packem to 2.0.0-alpha.32 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
|
|
90
120
|
|
|
91
121
|
### Miscellaneous Chores
|
|
92
122
|
|
package/LICENSE.md
CHANGED
|
@@ -557,6 +557,23 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
557
557
|
|
|
558
558
|
---------------------------------------
|
|
559
559
|
|
|
560
|
+
## cli-spinners
|
|
561
|
+
License: MIT
|
|
562
|
+
By: Sindre Sorhus
|
|
563
|
+
Repository: sindresorhus/cli-spinners
|
|
564
|
+
|
|
565
|
+
> MIT License
|
|
566
|
+
>
|
|
567
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
568
|
+
>
|
|
569
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
570
|
+
>
|
|
571
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
572
|
+
>
|
|
573
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
574
|
+
|
|
575
|
+
---------------------------------------
|
|
576
|
+
|
|
560
577
|
## safe-stable-stringify
|
|
561
578
|
License: MIT
|
|
562
579
|
By: Ruben Bridgewater
|
|
@@ -1000,6 +1017,23 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
1000
1017
|
|
|
1001
1018
|
---------------------------------------
|
|
1002
1019
|
|
|
1020
|
+
## cli-spinners
|
|
1021
|
+
License: MIT
|
|
1022
|
+
By: Sindre Sorhus
|
|
1023
|
+
Repository: sindresorhus/cli-spinners
|
|
1024
|
+
|
|
1025
|
+
> MIT License
|
|
1026
|
+
>
|
|
1027
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
1028
|
+
>
|
|
1029
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1030
|
+
>
|
|
1031
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1032
|
+
>
|
|
1033
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1034
|
+
|
|
1035
|
+
---------------------------------------
|
|
1036
|
+
|
|
1003
1037
|
## safe-stable-stringify
|
|
1004
1038
|
License: MIT
|
|
1005
1039
|
By: Ruben Bridgewater
|
package/README.md
CHANGED
|
@@ -485,6 +485,286 @@ bar.update(50, { speed: "2.5" });
|
|
|
485
485
|
bar.stop();
|
|
486
486
|
```
|
|
487
487
|
|
|
488
|
+
### Gradient Character Arrays
|
|
489
|
+
|
|
490
|
+
Create smooth gradient animations by providing arrays of characters that progressively fill:
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
import { createPail } from "@visulima/pail";
|
|
494
|
+
|
|
495
|
+
const logger = createPail({ interactive: true });
|
|
496
|
+
|
|
497
|
+
// Shade gradient (light to dark)
|
|
498
|
+
const bar = logger.createProgressBar({
|
|
499
|
+
total: 100,
|
|
500
|
+
barCompleteChar: ["░", "▒", "▓", "█"], // Gradient array
|
|
501
|
+
barIncompleteChar: " ",
|
|
502
|
+
format: "Downloading [{bar}] {percentage}%",
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
bar.start();
|
|
506
|
+
for (let i = 0; i <= 100; i++) {
|
|
507
|
+
bar.update(i);
|
|
508
|
+
}
|
|
509
|
+
bar.stop();
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
Supported gradients:
|
|
513
|
+
|
|
514
|
+
- **Shades**: `["░", "▒", "▓", "█"]` (light to dark)
|
|
515
|
+
- **Blocks**: `["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]` (small to large)
|
|
516
|
+
- **Temperature**: `["🔵", "🟢", "🟡", "🟠", "🔴"]` (cold to hot)
|
|
517
|
+
- **Custom**: Any array of characters for your own gradient effect
|
|
518
|
+
|
|
519
|
+
### Composite Progress Bars
|
|
520
|
+
|
|
521
|
+
Track multiple related progress bars simultaneously with automatic color layering based on progress percentage. This is perfect for operations with multiple parallel sources or stages:
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
import { createPail } from "@visulima/pail";
|
|
525
|
+
import colorize from "@visulima/colorize";
|
|
526
|
+
|
|
527
|
+
const logger = createPail({ interactive: true });
|
|
528
|
+
|
|
529
|
+
// Create a composite multi-bar that displays all bars as a single layered composite
|
|
530
|
+
const multiBar = logger.createMultiProgressBar({
|
|
531
|
+
composite: true, // Enable composite mode
|
|
532
|
+
format: "[{bar}] ① {r}% ② {y}% ③ {b}%",
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
const source1 = multiBar.create(100, 0, { r: "0", y: "0", b: "0" });
|
|
536
|
+
const source2 = multiBar.create(100, 0, { r: "0", y: "0", b: "0" });
|
|
537
|
+
const source3 = multiBar.create(100, 0, { r: "0", y: "0", b: "0" });
|
|
538
|
+
|
|
539
|
+
// Apply colors to each source
|
|
540
|
+
multiBar.setBarColor(source1, colorize.red);
|
|
541
|
+
multiBar.setBarColor(source2, colorize.yellow);
|
|
542
|
+
multiBar.setBarColor(source3, colorize.blue);
|
|
543
|
+
|
|
544
|
+
// Update sources with different speeds
|
|
545
|
+
for (let i = 0; i <= 100; i++) {
|
|
546
|
+
source1.update(i); // Red: 100% progress
|
|
547
|
+
source2.update(Math.floor(i * 0.7)); // Yellow: 70% progress
|
|
548
|
+
source3.update(Math.floor(i * 0.4)); // Blue: 40% progress
|
|
549
|
+
await new Promise((r) => setTimeout(r, 40));
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
multiBar.stop();
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
**Output example:**
|
|
556
|
+
|
|
557
|
+
```txt
|
|
558
|
+
[▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓██████████████████████] ① 100% ② 70% ③ 40%
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
#### Color Layering & Character Shading
|
|
562
|
+
|
|
563
|
+
The composite bar uses character shading to represent overlapping progress bars:
|
|
564
|
+
|
|
565
|
+
| Character | Meaning | Example |
|
|
566
|
+
| ---------------- | ------------------ | ------------------- |
|
|
567
|
+
| **█** (solid) | One bar visible | Red at 100% |
|
|
568
|
+
| **▓** (medium) | Two bars overlap | Red + Yellow |
|
|
569
|
+
| **▒** (light) | Three bars overlap | Red + Yellow + Blue |
|
|
570
|
+
| **░** (lightest) | Four+ bars overlap | All bars present |
|
|
571
|
+
|
|
572
|
+
#### How It Works
|
|
573
|
+
|
|
574
|
+
The composite bar renders based on **progress percentage at each position**:
|
|
575
|
+
|
|
576
|
+
1. **At position 0-40%**: Only Red (①) is filled → shows **█** with red color
|
|
577
|
+
2. **At position 40-70%**: Red + Yellow (①+②) filled → shows **▓** with yellow color (highest index shown)
|
|
578
|
+
3. **At position 70-100%**: All three (①+②+③) filled → shows **▒** with blue color (highest index)
|
|
579
|
+
|
|
580
|
+
The **highest-indexed bar's color** is used at each position, creating a natural progression.
|
|
581
|
+
|
|
582
|
+
**Dynamic Visibility Based on Progress:**
|
|
583
|
+
|
|
584
|
+
The bar with the **smallest progress percentage** is shown on top for maximum visibility:
|
|
585
|
+
|
|
586
|
+
- Red at 30%, Yellow at 60% → Red is visible first (30% < 60%)
|
|
587
|
+
- When Red reaches 30% and Yellow is only at 20% → Yellow becomes visible (20% < 30%)
|
|
588
|
+
- This ensures slower-progressing operations are always visible and not hidden beneath faster ones
|
|
589
|
+
|
|
590
|
+
#### Use Cases
|
|
591
|
+
|
|
592
|
+
1. **Multi-source Download**: Show progress from multiple download sources
|
|
593
|
+
2. **Parallel Tasks**: Monitor concurrent operations (build, test, lint)
|
|
594
|
+
3. **Pipeline Stages**: Upload → Process → Finalize with different completion times
|
|
595
|
+
4. **Batch Operations**: Parse → Validate → Compile at different speeds
|
|
596
|
+
5. **Resource Tracking**: CPU, Memory, Disk usage in parallel
|
|
597
|
+
|
|
598
|
+
Each progress bar:
|
|
599
|
+
|
|
600
|
+
- Updates independently at its own speed
|
|
601
|
+
- Can have different total values and progress rates
|
|
602
|
+
- Uses color to distinguish sources
|
|
603
|
+
- Shows through character shading when overlapping
|
|
604
|
+
|
|
605
|
+
## Spinners (Server Only)
|
|
606
|
+
|
|
607
|
+
Pail includes a comprehensive spinner system inspired by cli-progress, with support for single and multi-spinner modes, various styles, and interactive terminal output.
|
|
608
|
+
|
|
609
|
+
### Single Spinner
|
|
610
|
+
|
|
611
|
+
```typescript
|
|
612
|
+
import { createPail } from "@visulima/pail";
|
|
613
|
+
|
|
614
|
+
const logger = createPail({ interactive: true });
|
|
615
|
+
const spinner = logger.createSpinner({
|
|
616
|
+
text: "Loading...",
|
|
617
|
+
color: "blue",
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
spinner.start();
|
|
621
|
+
spinner.succeed("Loaded!");
|
|
622
|
+
spinner.fail("Failed!");
|
|
623
|
+
spinner.stop();
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Multi Spinner
|
|
627
|
+
|
|
628
|
+
```typescript
|
|
629
|
+
import { createPail } from "@visulima/pail";
|
|
630
|
+
|
|
631
|
+
const logger = createPail({ interactive: true });
|
|
632
|
+
const multiSpinner = logger.createMultiSpinner({
|
|
633
|
+
style: "dots", // Apply style to all spinners
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
const spinner1 = multiSpinner.create("Loading A");
|
|
637
|
+
const spinner2 = multiSpinner.create("Loading B");
|
|
638
|
+
const spinner3 = multiSpinner.create("Loading C");
|
|
639
|
+
|
|
640
|
+
// Update spinners as needed
|
|
641
|
+
spinner1.succeed("Loaded A!");
|
|
642
|
+
spinner2.succeed("Loaded B!");
|
|
643
|
+
spinner3.succeed("Loaded C!");
|
|
644
|
+
|
|
645
|
+
// Clean up when done
|
|
646
|
+
multiSpinner.stop();
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
### Custom Spinner
|
|
650
|
+
|
|
651
|
+
Create fully customized spinners with your own characters and formatting:
|
|
652
|
+
|
|
653
|
+
```typescript
|
|
654
|
+
import { createPail } from "@visulima/pail";
|
|
655
|
+
|
|
656
|
+
const logger = createPail({ interactive: true });
|
|
657
|
+
const spinner = logger.createSpinner({
|
|
658
|
+
text: "🚀 Downloading {filename}: [{bar}] {percentage}% | Speed: {speed} MB/s | ETA: {eta}s",
|
|
659
|
+
barCompleteChar: "🚀",
|
|
660
|
+
barIncompleteChar: "⚪",
|
|
661
|
+
width: 20,
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
spinner.start(0, 0, {
|
|
665
|
+
filename: "large-file.zip",
|
|
666
|
+
speed: "0.0",
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
// Update with payload data
|
|
670
|
+
spinner.update(50, { speed: "2.5" });
|
|
671
|
+
spinner.succeed();
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
## Object Tree
|
|
675
|
+
|
|
676
|
+
Render objects and data structures as formatted ASCII trees for better terminal visualization and debugging:
|
|
677
|
+
|
|
678
|
+
```typescript
|
|
679
|
+
import { renderObjectTree } from "@visulima/pail/object-tree";
|
|
680
|
+
|
|
681
|
+
const data = {
|
|
682
|
+
user: {
|
|
683
|
+
name: "John Doe",
|
|
684
|
+
email: "john@example.com",
|
|
685
|
+
profile: {
|
|
686
|
+
age: 30,
|
|
687
|
+
location: "New York",
|
|
688
|
+
skills: ["JavaScript", "TypeScript", "Node.js"],
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
settings: {
|
|
692
|
+
theme: "dark",
|
|
693
|
+
notifications: true,
|
|
694
|
+
},
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
console.log(renderObjectTree(data));
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
**Output:**
|
|
701
|
+
|
|
702
|
+
```txt
|
|
703
|
+
├─ user:
|
|
704
|
+
│ ├─ name: John Doe
|
|
705
|
+
│ ├─ email: john@example.com
|
|
706
|
+
│ └─ profile:
|
|
707
|
+
│ ├─ age: 30
|
|
708
|
+
│ ├─ location: New York
|
|
709
|
+
│ └─ skills:
|
|
710
|
+
├─ settings:
|
|
711
|
+
│ ├─ theme: dark
|
|
712
|
+
│ └─ notifications: true
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
> **Note:** `renderObjectTree` is exported as a separate module (`@visulima/pail/object-tree`) to reduce main bundle size. It works in both **Node.js** and **Browser** environments and is a pure utility function with no platform-specific dependencies.
|
|
716
|
+
|
|
717
|
+
### Custom Rendering
|
|
718
|
+
|
|
719
|
+
Customize how object trees are rendered:
|
|
720
|
+
|
|
721
|
+
```typescript
|
|
722
|
+
import { renderObjectTree } from "@visulima/pail/object-tree";
|
|
723
|
+
|
|
724
|
+
const obj = {
|
|
725
|
+
name: "John",
|
|
726
|
+
age: 30,
|
|
727
|
+
address: {
|
|
728
|
+
street: "Main St",
|
|
729
|
+
city: "New York",
|
|
730
|
+
},
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// Custom rendering with sorting and formatting
|
|
734
|
+
const tree = renderObjectTree(obj, {
|
|
735
|
+
sortFn: (a, b) => a.localeCompare(b), // Sort keys alphabetically
|
|
736
|
+
renderFn: (node) => {
|
|
737
|
+
if (typeof node === "string") return node.toUpperCase();
|
|
738
|
+
return ["boolean", "string", "number"].includes(typeof node) ? String(node) : undefined;
|
|
739
|
+
},
|
|
740
|
+
joined: true, // Return as single string (false for array of lines)
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
console.log(tree);
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### Configuration Options
|
|
747
|
+
|
|
748
|
+
| Option | Description | Default |
|
|
749
|
+
| ------------------- | ----------------------------------------------------- | -------------------- |
|
|
750
|
+
| `joined` | Return as single string or array of lines | `true` |
|
|
751
|
+
| `sortFn` | Function to sort object keys (null for natural order) | `null` |
|
|
752
|
+
| `renderFn` | Function to render node values | Renders primitives |
|
|
753
|
+
| `separator` | Separator between key and value | `": "` |
|
|
754
|
+
| `keyNeighbour` | Connector for keys with siblings | `"├─ "` |
|
|
755
|
+
| `keyNoNeighbour` | Connector for last keys | `"└─ "` |
|
|
756
|
+
| `spacerNeighbour` | Spacer for branches with siblings | `"│ "` |
|
|
757
|
+
| `spacerNoNeighbour` | Spacer for branches without siblings | `" "` |
|
|
758
|
+
| `breakCircularWith` | Text for circular references | `" (circular ref.)"` |
|
|
759
|
+
|
|
760
|
+
### Use Cases
|
|
761
|
+
|
|
762
|
+
1. **Debugging**: Visualize complex object structures during development
|
|
763
|
+
2. **Logging**: Pretty-print objects for better readability in logs
|
|
764
|
+
3. **API Responses**: Display JSON API responses in tree format
|
|
765
|
+
4. **Configuration Display**: Show configuration trees in terminal applications
|
|
766
|
+
5. **Data Inspection**: Inspect deeply nested data structures
|
|
767
|
+
|
|
488
768
|
## Integrations
|
|
489
769
|
|
|
490
770
|
### Use with @visulima/boxen
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { P as PailBrowserType } from './packem_shared/pail.browser-
|
|
2
|
-
import { C as ConstructorOptions } from './packem_shared/types-
|
|
3
|
-
export { a as DefaultLogTypes, D as DefaultLoggerTypes, E as ExtendedRfc5424LogLevels, L as LoggerConfiguration, b as LoggerFunction, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, P as Processor, R as Reporter, S as StreamAwareReporter } from './packem_shared/types-
|
|
1
|
+
import { P as PailBrowserType } from './packem_shared/pail.browser-CmWcqnn9.js';
|
|
2
|
+
import { C as ConstructorOptions } from './packem_shared/types-DVzG8TWL.js';
|
|
3
|
+
export { a as DefaultLogTypes, D as DefaultLoggerTypes, E as ExtendedRfc5424LogLevels, L as LoggerConfiguration, b as LoggerFunction, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, P as Processor, R as Reporter, S as StreamAwareReporter } from './packem_shared/types-DVzG8TWL.js';
|
|
4
4
|
import './packem_shared/index.d-oxZvg_y7.js';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
import '@visulima/colorize';
|
|
7
|
+
import './interactive/index.js';
|
|
7
8
|
|
|
8
9
|
declare const createPail: <T extends string = string, L extends string = string>(options?: ConstructorOptions<T, L>) => PailBrowserType<T, L>;
|
|
9
10
|
declare const pail: PailBrowserType<string, string>;
|
package/dist/index.server.d.ts
CHANGED
|
@@ -1,74 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import '
|
|
1
|
+
import { InteractiveManager } from './interactive/index.js';
|
|
2
|
+
import { a as PailBrowserImpl } from './packem_shared/pail.browser-CmWcqnn9.js';
|
|
3
|
+
import { SingleBarOptions, ProgressBar, MultiBarOptions, MultiProgressBar } from './progress-bar.js';
|
|
4
|
+
export { ProgressBarOptions, ProgressBarPayload, ProgressBarStyle, getBarChar } from './progress-bar.js';
|
|
5
|
+
import { SpinnerOptions, Spinner, MultiSpinner } from './spinner.js';
|
|
6
|
+
export { SpinnerIcons, SpinnerStartOptions, SpinnerStyle } from './spinner.js';
|
|
7
|
+
import { g as ServerConstructorOptions, R as Reporter, a as DefaultLogTypes, b as LoggerFunction, C as ConstructorOptions } from './packem_shared/types-DVzG8TWL.js';
|
|
8
|
+
export { D as DefaultLoggerTypes, E as ExtendedRfc5424LogLevels, L as LoggerConfiguration, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, P as Processor, S as StreamAwareReporter } from './packem_shared/types-DVzG8TWL.js';
|
|
6
9
|
import './packem_shared/index.d-oxZvg_y7.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
interface ProgressBarOptions {
|
|
10
|
-
barCompleteChar?: string;
|
|
11
|
-
barGlue?: string;
|
|
12
|
-
barIncompleteChar?: string;
|
|
13
|
-
barsize?: number;
|
|
14
|
-
clear?: boolean;
|
|
15
|
-
current?: number;
|
|
16
|
-
etaBuffer?: number;
|
|
17
|
-
format?: string;
|
|
18
|
-
fps?: number;
|
|
19
|
-
hideCursor?: boolean;
|
|
20
|
-
lineWrap?: boolean;
|
|
21
|
-
position?: "left" | "right" | "center";
|
|
22
|
-
stream?: NodeJS.WriteStream;
|
|
23
|
-
style?: ProgressBarStyle;
|
|
24
|
-
total: number;
|
|
25
|
-
width?: number;
|
|
26
|
-
}
|
|
27
|
-
interface SingleBarOptions extends ProgressBarOptions {
|
|
28
|
-
format?: string;
|
|
29
|
-
}
|
|
30
|
-
interface MultiBarOptions {
|
|
31
|
-
barCompleteChar?: string;
|
|
32
|
-
barGlue?: string;
|
|
33
|
-
barIncompleteChar?: string;
|
|
34
|
-
clearOnComplete?: boolean;
|
|
35
|
-
format?: string;
|
|
36
|
-
fps?: number;
|
|
37
|
-
hideCursor?: boolean;
|
|
38
|
-
stream?: NodeJS.WriteStream;
|
|
39
|
-
style?: ProgressBarStyle;
|
|
40
|
-
}
|
|
41
|
-
interface ProgressBarPayload {
|
|
42
|
-
[key: string]: string | number | boolean;
|
|
43
|
-
}
|
|
44
|
-
declare const getBarChar: (char: string | undefined, style: ProgressBarStyle, complete?: boolean) => string;
|
|
45
|
-
declare class ProgressBar {
|
|
46
|
-
private options;
|
|
47
|
-
private current;
|
|
48
|
-
private startTime;
|
|
49
|
-
private interactiveManager?;
|
|
50
|
-
private isActive;
|
|
51
|
-
private payload?;
|
|
52
|
-
constructor(options: ProgressBarOptions, interactiveManager?: InteractiveManager, payload?: ProgressBarPayload);
|
|
53
|
-
update(current: number, payload?: ProgressBarPayload): void;
|
|
54
|
-
increment(step?: number, payload?: ProgressBarPayload): void;
|
|
55
|
-
render(): string;
|
|
56
|
-
start(total?: number, startValue?: number, payload?: ProgressBarPayload): void;
|
|
57
|
-
stop(): void;
|
|
58
|
-
private calculateETA;
|
|
59
|
-
}
|
|
60
|
-
declare class MultiProgressBar {
|
|
61
|
-
private bars;
|
|
62
|
-
private options;
|
|
63
|
-
private interactiveManager?;
|
|
64
|
-
private isActive;
|
|
65
|
-
private nextBarId;
|
|
66
|
-
constructor(options?: MultiBarOptions, interactiveManager?: InteractiveManager);
|
|
67
|
-
create(total: number, startValue?: number, payload?: ProgressBarPayload): ProgressBar;
|
|
68
|
-
remove(bar: ProgressBar): boolean;
|
|
69
|
-
renderAll(): void;
|
|
70
|
-
stop(): void;
|
|
71
|
-
}
|
|
10
|
+
import 'type-fest';
|
|
11
|
+
import '@visulima/colorize';
|
|
72
12
|
|
|
73
13
|
declare class PailServerImpl<T extends string = string, L extends string = string> extends PailBrowserImpl<T, L> {
|
|
74
14
|
#private;
|
|
@@ -86,6 +26,8 @@ declare class PailServerImpl<T extends string = string, L extends string = strin
|
|
|
86
26
|
restoreAll(): void;
|
|
87
27
|
createProgressBar(options: SingleBarOptions): ProgressBar;
|
|
88
28
|
createMultiProgressBar(options?: MultiBarOptions): MultiProgressBar;
|
|
29
|
+
createSpinner(options?: SpinnerOptions): Spinner;
|
|
30
|
+
createMultiSpinner(options?: SpinnerOptions): MultiSpinner;
|
|
89
31
|
clear(): void;
|
|
90
32
|
protected extendReporter(reporter: Reporter<L>): Reporter<L>;
|
|
91
33
|
}
|
|
@@ -94,5 +36,5 @@ type PailServerType<T extends string = string, L extends string = string> = (new
|
|
|
94
36
|
declare const createPail: <T extends string = string, L extends string = string>(options?: ConstructorOptions<T, L>) => PailServerType<T, L>;
|
|
95
37
|
declare const pail: PailServerType<string, string>;
|
|
96
38
|
|
|
97
|
-
export { ConstructorOptions, DefaultLogTypes, LoggerFunction, MultiProgressBar, ProgressBar, Reporter,
|
|
98
|
-
export type {
|
|
39
|
+
export { ConstructorOptions, DefaultLogTypes, LoggerFunction, MultiBarOptions, MultiProgressBar, MultiSpinner, ProgressBar, Reporter, SingleBarOptions, Spinner, SpinnerOptions, createPail, pail };
|
|
40
|
+
export type { PailServerType as Pail };
|
package/dist/index.server.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}
|
|
3
|
-
`),this.#s=u?u+n.length+1:n.length,this.#i=Math.max(this.lastLength-i,this.outside)}}#o(t=!1){this.#e=t,this.#s=0,this.#i=0}}var Y=Object.defineProperty,b=o((r,t)=>Y(r,"name",{value:t,configurable:!0}),"t$2");const v="\x1B[2J",J="\x1B[2K",U=b((r=1)=>`${"\x1B["+r}A`,"cursorUp"),w=process.platform==="win32"?`${v}\x1B[0f`:`${v}\x1B[3J\x1B[H`,K="\x1B[?25l",W="\x1B[?25h",z=b(r=>{let t="";for(let e=0;e<r;e++)t+=J+(e<r-1?U():"");return r&&(t+="\x1B[G"),t},"eraseLines");var F=Object.defineProperty,Q=o((r,t)=>F(r,"name",{value:t,configurable:!0}),"o$1");let m=class S{static{o(this,"t")}static{Q(this,"InteractiveStreamHook")}static DRAIN=!0;#t=new T;#e=[];#r;#s;constructor(t){this.#r=t.write,this.#s=t}active(){this.write(K),this.#s.write=(t,...e)=>{const s=e.at(-1);return this.#e.push(this.#t.write(typeof t=="string"?Buffer.from(t,typeof e[0]=="string"?e[0]:void 0):Buffer.from(t))),typeof s=="function"&&s(),S.DRAIN}}erase(t){t>0&&this.write(z(t+1))}inactive(t=!1){this.#e.length>0&&(t&&this.write(`
|
|
4
|
-
`),this.#e.forEach(e=>{this.write(e)}),this.#e=[]),this.renew()}renew(){this.#s.write=this.#r,this.write(W)}write(t){this.#r.apply(this.#s,[t])}};var X=Object.defineProperty,Z=o((r,t)=>X(r,"name",{value:t,configurable:!0}),"c");class tt{static{o(this,"v")}static{Z(this,"RawReporter")}#t;#e;#r;#s=!1;#i;constructor(t={}){this.#t=y,this.#e=_,this.#i=t}setStdout(t){this.#t=t}setStderr(t){this.#e=t}setInteractiveManager(t){this.#r=t}setIsInteractive(t){this.#s=t}log(t){const{context:e,groups:s,message:a,type:p}=t,i=[];if(a!==D){const n=typeof a=="string"?a:f(a,this.#i);i.push(n)}e&&i.push(...e.map(n=>typeof n=="object"?` ${f(n,this.#i)}`:` ${n}`));const h=["error","trace","warn"].includes(p.level)?"stderr":"stdout",c=h==="stderr"?this.#e:this.#t,u=s.map(()=>" ").join("");this.#s&&this.#r!==void 0&&c.isTTY?this.#r.update(h,(u+i.join("")).split(`
|
|
5
|
-
`),0):H(u+i.join(""),c)}}var et=Object.defineProperty,rt=o((r,t)=>et(r,"name",{value:t,configurable:!0}),"o");let st=class extends R{static{o(this,"L")}constructor(t){const{interactive:e,rawReporter:s,reporters:a,stderr:p,stdout:i,...h}=t;super(h),this.options=t,this.interactive=e??!1,this.stdout=i,this.stderr=p,this.interactive&&(this.interactiveManager=new q(new m(this.stdout),new m(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(t.rawReporter??new tt)}static{rt(this,"PailServerImpl")}stdout;stderr;interactiveManager;interactive;scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.scopeName=t.flat(),this}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#t(this.stdout,"log"),this.#t(this.stderr,"log")}restoreStd(){this.#e(this.stdout),this.#e(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}createProgressBar(t){const e=g(t);return new A(e,this.interactiveManager)}createMultiProgressBar(t={}){const e=g(t);return new N(e,this.interactiveManager)}clear(){this.stdout.write(w),this.stderr.write(w)}extendReporter(t){return typeof t.setStdout=="function"&&t.setStdout(this.stdout),typeof t.setStderr=="function"&&t.setStderr(this.stderr),typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),typeof t.setIsInteractive=="function"&&t.setIsInteractive(this.interactive),this.interactive&&typeof t.setInteractiveManager=="function"&&t.setInteractiveManager(this.interactiveManager),t}#t(t,e){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[e](String(s).trim())})}#e(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}};const it=st;var ot=Object.defineProperty,B=o((r,t)=>ot(r,"name",{value:t,configurable:!0}),"t");const at=B(()=>d.NODE_ENV==="debug"||d.DEBUG!==void 0?"debug":d.NODE_ENV==="test"?"warning":"informational","getDefaultLogLevel"),nt=B(r=>{let t=at();return d.PAIL_LOG_LEVEL!==void 0&&(t=d.PAIL_LOG_LEVEL),new it({logLevel:t,processors:[new k],reporters:[new C],stderr:_,stdout:y,...r})},"createPail"),mt=nt();export{N as MultiProgressBar,A as ProgressBar,nt as createPail,bt as getBarChar,mt as pail};
|
|
1
|
+
var y=Object.defineProperty;var n=(e,t)=>y(e,"name",{value:t,configurable:!0});import{createRequire as M}from"node:module";import S from"./packem_shared/InteractiveManager-CgmJyW9x.js";import{t as d,c as g}from"./packem_shared/interactive-stream-hook-CeVo4Kth.js";import{a as b}from"./packem_shared/pail.browser-BmHoDvEA.js";import{applyStyleToOptions as v,ProgressBar as I,MultiProgressBar as E}from"./progress-bar.js";import{getBarChar as nt}from"./progress-bar.js";import{a as f}from"./packem_shared/format-label-CpyyTBom.js";import{E as L}from"./packem_shared/constants-DKfCaSUR.js";import{n as R}from"./packem_shared/write-stream-CD8XFv1L.js";import{Spinner as j,MultiSpinner as T}from"./spinner.js";import O from"./processor/message-formatter-processor.js";import{PrettyReporter as B}from"./packem_shared/PrettyReporter-Bns0ZWLy.js";const z=M(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:w,stderr:m,env:o}=P;var C=Object.defineProperty,x=n((e,t)=>C(e,"name",{value:t,configurable:!0}),"c");class A{static{n(this,"v")}static{x(this,"RawReporter")}#t;#e;#r;#s=!1;#i;constructor(t={}){this.#t=w,this.#e=m,this.#i=t}setStdout(t){this.#t=t}setStderr(t){this.#e=t}setInteractiveManager(t){this.#r=t}setIsInteractive(t){this.#s=t}log(t){const{context:r,groups:c,message:i,type:h}=t,s=[];if(i!==L){const a=typeof i=="string"?i:f(i,this.#i);s.push(a)}r&&s.push(...r.map(a=>typeof a=="object"?` ${f(a,this.#i)}`:` ${a}`));const p=["error","trace","warn"].includes(h.level)?"stderr":"stdout",u=p==="stderr"?this.#e:this.#t,l=c.map(()=>" ").join("");this.#s&&this.#r!==void 0&&u.isTTY?this.#r.update(p,(l+s.join("")).split(`
|
|
2
|
+
`),0):R(l+s.join(""),u)}}var N=Object.defineProperty,$=n((e,t)=>N(e,"name",{value:t,configurable:!0}),"a");class D extends b{static{n(this,"m")}constructor(t){const{interactive:r,rawReporter:c,reporters:i,stderr:h,stdout:s,...p}=t;super(p),this.options=t,this.interactive=r??!1,this.stdout=s,this.stderr=h,this.interactive&&(this.interactiveManager=new S(new d(this.stdout),new d(this.stderr))),Array.isArray(i)&&this.registerReporters(i),this.rawReporter=this.extendReporter(t.rawReporter??new A)}static{$(this,"PailServerImpl")}stdout;stderr;interactiveManager;interactive;scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.scopeName=t.flat(),this}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#t(this.stdout,"log"),this.#t(this.stderr,"log")}restoreStd(){this.#e(this.stdout),this.#e(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}createProgressBar(t){if(!this.interactiveManager)throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use progress bars.");const r=v(t);return new I(r,this.interactiveManager)}createMultiProgressBar(t={}){if(!this.interactiveManager)throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use progress bars.");const r=v(t);return new E(r,this.interactiveManager)}createSpinner(t={}){if(!this.interactiveManager)throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use spinners.");return new j(t,this.interactiveManager)}createMultiSpinner(t={}){if(!this.interactiveManager)throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use spinners.");return new T(t,this.interactiveManager)}clear(){this.stdout.write(g),this.stderr.write(g)}extendReporter(t){return typeof t.setStdout=="function"&&t.setStdout(this.stdout),typeof t.setStderr=="function"&&t.setStderr(this.stderr),typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),typeof t.setIsInteractive=="function"&&t.setIsInteractive(this.interactive),this.interactive&&typeof t.setInteractiveManager=="function"&&t.setInteractiveManager(this.interactiveManager),t}#t(t,r){t&&(t.__write||(t.__write=t.write),t.write=c=>{this[r](String(c).trim())})}#e(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}}const V=D;var q=Object.defineProperty,_=n((e,t)=>q(e,"name",{value:t,configurable:!0}),"o");const G=_(()=>o.NODE_ENV==="debug"||o.DEBUG!==void 0?"debug":o.NODE_ENV==="test"?"warning":"informational","getDefaultLogLevel"),Y=_(e=>{let t=G();return o.PAIL_LOG_LEVEL!==void 0&&(t=o.PAIL_LOG_LEVEL),new V({logLevel:t,processors:[new O],reporters:[new B],stderr:m,stdout:w,...e})},"createPail"),rt=Y();export{E as MultiProgressBar,T as MultiSpinner,I as ProgressBar,j as Spinner,Y as createPail,nt as getBarChar,rt as pail};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare class InteractiveStreamHook {
|
|
2
|
+
#private;
|
|
3
|
+
static readonly DRAIN = true;
|
|
4
|
+
constructor(stream: NodeJS.WriteStream);
|
|
5
|
+
active(): void;
|
|
6
|
+
erase(count: number): void;
|
|
7
|
+
inactive(separateHistory?: boolean): void;
|
|
8
|
+
renew(): void;
|
|
9
|
+
write(message: string): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type StreamType = "stderr" | "stdout";
|
|
13
|
+
declare class InteractiveManager {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(stdout: InteractiveStreamHook, stderr: InteractiveStreamHook);
|
|
16
|
+
get lastLength(): number;
|
|
17
|
+
get outside(): number;
|
|
18
|
+
get isHooked(): boolean;
|
|
19
|
+
get isSuspended(): boolean;
|
|
20
|
+
erase(stream: StreamType, count?: number): void;
|
|
21
|
+
hook(): boolean;
|
|
22
|
+
resume(stream: StreamType, eraseRowCount?: number): void;
|
|
23
|
+
suspend(stream: StreamType, erase?: boolean): void;
|
|
24
|
+
unhook(separateHistory?: boolean): boolean;
|
|
25
|
+
update(stream: StreamType, rows: string[], from?: number): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { InteractiveManager, InteractiveStreamHook };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as a}from"../packem_shared/InteractiveManager-CgmJyW9x.js";import{t as o}from"../packem_shared/interactive-stream-hook-CeVo4Kth.js";export{a as InteractiveManager,o as InteractiveStreamHook};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type TreeRenderFunction = (node: unknown) => string | undefined;
|
|
2
|
+
type TreeSortFunction = (a: string, b: string) => number;
|
|
3
|
+
interface ObjectTreeOptions {
|
|
4
|
+
breakCircularWith?: string | null | undefined;
|
|
5
|
+
joined?: boolean;
|
|
6
|
+
keyNeighbour?: string;
|
|
7
|
+
keyNoNeighbour?: string;
|
|
8
|
+
renderFn?: TreeRenderFunction;
|
|
9
|
+
separator?: string;
|
|
10
|
+
sortFn?: TreeSortFunction | undefined;
|
|
11
|
+
spacerNeighbour?: string;
|
|
12
|
+
spacerNoNeighbour?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const renderObjectTree: (tree: Record<string, unknown> | unknown[], options?: ObjectTreeOptions) => string | string[];
|
|
15
|
+
|
|
16
|
+
export { renderObjectTree as default, renderObjectTree };
|
|
17
|
+
export type { ObjectTreeOptions, TreeRenderFunction, TreeSortFunction };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var O=Object.defineProperty;var y=(o,r)=>O(o,"name",{value:r,configurable:!0});var m=Object.defineProperty,a=y((o,r)=>m(o,"name",{value:r,configurable:!0}),"s");const j=a(o=>{const r={breakCircularWith:" (circular ref.)",joined:!0,keyNeighbour:"├─ ",keyNoNeighbour:"└─ ",renderFn:a(t=>{if(["boolean","number","string"].includes(typeof t))return String(t)},"renderFn"),separator:": ",sortFn:void 0,spacerNeighbour:"│ ",spacerNoNeighbour:" ",...o};if(typeof r.joined!="boolean")throw new TypeError('Option "joined" must be a boolean');if(typeof r.spacerNoNeighbour!="string")throw new TypeError('Option "spacerNoNeighbour" must be a string');if(typeof r.spacerNeighbour!="string")throw new TypeError('Option "spacerNeighbour" must be a string');if(typeof r.keyNoNeighbour!="string")throw new TypeError('Option "keyNoNeighbour" must be a string');if(typeof r.keyNeighbour!="string")throw new TypeError('Option "keyNeighbour" must be a string');if(typeof r.separator!="string")throw new TypeError('Option "separator" must be a string');if(typeof r.renderFn!="function")throw new TypeError('Option "renderFn" must be a function');if(r.sortFn!==void 0&&typeof r.sortFn!="function")throw new TypeError('Option "sortFn" must be a function or undefined');if(r.breakCircularWith!==null&&typeof r.breakCircularWith!="string")throw new TypeError('Option "breakCircularWith" must be a string or null');return r},"buildContext"),T=a((o,r)=>{const t=j(r),s=[],b=t.renderFn(o);b!==void 0&&s.push(String(b));const l=a(e=>t.sortFn===void 0?e:e.toSorted((n,u)=>t?.sortFn?.(u,n)??0),"sort"),p=[],i=l(Object.keys(o)).map(e=>[e]),h=[o];for(;i.length>0;){const e=i.pop()??[],n=h[e.length-1][e[e.length-1]??""],u=t.breakCircularWith!==null&&h.slice(0,e.length).includes(n);p[e.length-1]=i.length>0&&(i[i.length-1]?.length??0)===e.length;const f=p.slice(0,e.length-1).map(g=>g?t.spacerNeighbour:t.spacerNoNeighbour).join(""),d=p[e.length-1]?t.keyNeighbour:t.keyNoNeighbour,N=e[e.length-1],c=t.renderFn(n),w=c===void 0?"":`${t.separator}${c}`,k=u?t.breakCircularWith:"";s.push(`${f}${d}${N}${w}${k}`),n!==null&&typeof n=="object"&&!Array.isArray(n)&&!u&&(i.push(...l(Object.keys(n)).map(g=>[...e,g])),h[e.length]=n)}return t.joined===!0?s.join(`
|
|
2
|
+
`):s},"renderObjectTree");export{T as default,T as renderObjectTree};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var v=Object.defineProperty;var l=(a,t)=>v(a,"name",{value:t,configurable:!0});import{O as g,i as m,B as p}from"./index-CysYvHXs.js";var w=Object.defineProperty,b=l((a,t)=>w(a,"name",{value:t,configurable:!0}),"l");class M{static{l(this,"g")}static{b(this,"InteractiveManager")}#t;#e=!1;#s=!1;#i=0;#r=0;constructor(t,e){this.#t={stderr:e,stdout:t}}get lastLength(){return this.#i}get outside(){return this.#r}get isHooked(){return this.#e}get isSuspended(){return this.#s}erase(t,e=this.#i){if(this.#t[t]===void 0)throw new TypeError(`Stream "${t}" is not available`);this.#t[t].erase(e)}hook(){return this.#e||(Object.values(this.#t).forEach(t=>t.active()),this.#a(!0)),this.#e}resume(t,e){this.#s&&(this.#s=!1,e&&this.erase(t,e),this.#i=0,Object.values(this.#t).forEach(i=>i.active()))}suspend(t,e=!0){this.#s||(this.#s=!0,e&&this.erase(t),Object.values(this.#t).forEach(i=>i.renew()))}unhook(t=!0){return this.#e&&(Object.values(this.#t).forEach(e=>e.inactive(t)),this.#a()),!this.#e}update(t,e,i=0){if(e.length>0){if(this.#t[t]===void 0)throw new TypeError(`Stream "${t}" is not available`);const n=this.#t[t],{columns:c,rows:s}=g(),u=i>s?s-1:Math.max(0,Math.min(s-1,i)),h=this.lastLength-u,o=Math.max(h-s,this.outside);let r=e.reduce((d,f)=>[...d,m(f,{trim:!1,width:c,wrapMode:p.STRICT_WIDTH})],[]);s<=h?(n.erase(s),u<o&&(r=r.slice(o-u+1))):h&&n.erase(h),n.write(`${r.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`),this.#i=o?o+r.length+1:r.length,this.#r=Math.max(this.lastLength-s,this.outside)}}#a(t=!1){this.#e=t,this.#i=0,this.#r=0}}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{t as u}from"./interactive-stream-hook-CeVo4Kth.js";const t=e(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;export{u as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(t,e)=>i(t,"name",{value:e,configurable:!0});import{createRequire as c}from"node:module";import{n as p}from"./write-stream-CD8XFv1L.js";import{AbstractJsonReporter as d}from"./AbstractJsonReporter-UftN6CIL.js";const m=c(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:n,stderr:u}=a;var l=Object.defineProperty,f=r((t,e)=>l(t,"name",{value:e,configurable:!0}),"e");class j extends d{static{r(this,"d")}static{f(this,"JsonReporter")}#e;#t;constructor(e={}){super(e),this.#e=n,this.#t=u}setStdout(e){this.#e=e}setStderr(e){this.#t=e}_log(e,s){const o=["error","warn"].includes(s)?this.#t:this.#e;p(`${e}
|
|
2
|
+
`,o)}}export{j as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var O=Object.defineProperty;var T=(n,e)=>O(n,"name",{value:e,configurable:!0});import{createRequire as q}from"node:module";import Y,{red as b,greenBright as D,cyan as G,green as H,grey as s,white as W,bgGrey as z,underline as C}from"@visulima/colorize";import{u as J,n as K,a as I,G as M}from"./format-label-CpyyTBom.js";import{O as N,o as g,i as Q,B as U}from"./index-CysYvHXs.js";import{E as X}from"./constants-DKfCaSUR.js";import{A as Z,s as ee}from"./abstract-pretty-reporter-CUtSm20r.js";import{s as te}from"./get-longest-label-B0NrI-o2.js";import{n as re}from"./write-stream-CD8XFv1L.js";const ae=q(import.meta.url),B=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:F,stderr:V}=B;var se=Object.defineProperty,L=T((n,e)=>se(n,"name",{value:e,configurable:!0}),"x");const w=L(n=>!/[\\/]pail[\\/]dist/.test(n),"pailFileFilter");class ge extends Z{static{T(this,"PrettyReporter")}static{L(this,"PrettyReporter")}#t;#r;#s;#o=!1;#i;#e;constructor(e={}){const{error:p,inspect:i,...a}=e;super({uppercase:{label:!0,...a.uppercase},...a}),this.#i={...J,...i},this.#e={...p,color:{fileLine:H,hint:G,marker:b,message:b,method:D,title:b}},this.#t=F,this.#r=V}setStdout(e){this.#t=e}setStderr(e){this.#r=e}setInteractiveManager(e){this.#s=e}setIsInteractive(e){this.#o=e}log(e){this._log(this._formatMessage(e),e.type.level)}_formatMessage(e){const{columns:p}=N();let i=p;typeof this.styles.messageLength=="number"&&(i=this.styles.messageLength);const{badge:a,context:j,date:u,error:E,file:c,groups:m,label:d,message:f,prefix:y,repeated:v,scope:l,suffix:$,traceError:S,type:k}=e,{color:P}=this.loggerTypes[k.name],R=P?Y[P]:W,h=m.map(()=>" ").join(""),t=[];if(m.length>0&&t.push(`${h+s(`[${m.at(-1)}]`)} `),u&&t.push(`${s(this.styles.dateFormatter(typeof u=="string"?new Date(u):u))} `),a)t.push(R(a));else{const r=ee(this.loggerTypes);r.length>0&&t.push(`${s(".".repeat(r.length))} `)}const A=te(this.loggerTypes);if(d){const r=g(A),o=g(d);t.push(`${R(K(d,this.styles))} `,s(".".repeat(Math.max(0,r-o))))}else t.push(s(".".repeat(A.length+2)));v&&t.push(`${z.white(`[${v}x]`)} `),Array.isArray(l)&&l.length>0&&t.push(` ${s(`[${l.join(" > ")}]`)} `),y&&t.push(`${s(`${Array.isArray(l)&&l.length>0?". ":" "}[${this.styles.underline.prefix?C(y):y}]`)} `);const _=g(t.join(" "));if(c){const r=c.name+(c.line?`:${c.line}`:""),o=g(r);if(o+_+2>i)t.push(s(` ${r}`));else{const x=Math.max(0,i-_-o-2);t.push(s(`${".".repeat(x)} ${r}`))}}else t.push(s(".".repeat(Math.max(0,i-_-1))));if(t.length>0&&t.push(`
|
|
2
|
+
|
|
3
|
+
`),f!==X){const r=typeof f=="string"?f:I(f,this.#i);t.push(h+Q(r,{trim:!1,width:i-3,wrapMode:U.STRICT_WIDTH}))}if(j){let r=!1;t.push(...j.map(o=>{if(o instanceof Error)return r=!0,`
|
|
4
|
+
|
|
5
|
+
${M(o,{...this.#e,filterStacktrace:w,prefix:h})}`;if(typeof o=="object")return` ${I(o,this.#i)}`;const x=(r?`
|
|
6
|
+
|
|
7
|
+
`:" ")+o;return r=!1,x}))}return E&&t.push(M(E,{...this.#e,filterStacktrace:w,prefix:h})),S&&t.push(`
|
|
8
|
+
|
|
9
|
+
${M(S,{...this.#e,filterStacktrace:w,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:h})}`),$&&t.push(`
|
|
10
|
+
`,h+s(this.styles.underline.suffix?C($):$)),t.join("")}_log(e,p){const i=["error","trace","warn"].includes(p)?"stderr":"stdout",a=i==="stderr"?this.#r:this.#t;this.#o&&this.#s!==void 0&&a.isTTY?this.#s.update(i,e.split(`
|
|
11
|
+
`),0):re(`${e}
|
|
12
|
+
`,a)}}export{ge as PrettyReporter};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as stringify } from './index.d-oxZvg_y7.js';
|
|
2
2
|
import { LiteralUnion } from 'type-fest';
|
|
3
|
-
import {
|
|
3
|
+
import { e as StringifyAwareReporter, f as ReadonlyMeta, E as ExtendedRfc5424LogLevels } from './types-DVzG8TWL.js';
|
|
4
4
|
|
|
5
5
|
type AbstractJsonReporterOptions = {
|
|
6
6
|
error: Partial<{
|
|
@@ -18,5 +18,5 @@ declare abstract class AbstractJsonReporter<L extends string = string> implement
|
|
|
18
18
|
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export { AbstractJsonReporter as
|
|
22
|
-
export type { AbstractJsonReporterOptions as
|
|
21
|
+
export { AbstractJsonReporter as A };
|
|
22
|
+
export type { AbstractJsonReporterOptions as a };
|