@visulima/pail 2.1.31 → 3.0.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 +39 -0
- package/LICENSE.md +909 -208
- package/README.md +216 -8
- package/dist/index.browser.d.ts +4 -4
- package/dist/index.browser.js +1 -0
- package/dist/index.server.d.ts +74 -8
- package/dist/index.server.js +5 -0
- package/dist/packem_shared/AbstractJsonReporter-UftN6CIL.js +1 -0
- package/dist/packem_shared/JsonReporter-Bb6YuCj2.js +2 -0
- package/dist/packem_shared/JsonReporter-Dl4m0xZe.js +1 -0
- package/dist/packem_shared/PrettyReporter-CGKSTI7X.js +5 -0
- package/dist/packem_shared/PrettyReporter-CREln5bH.js +12 -0
- package/dist/packem_shared/abstract-json-reporter-wUti0B3k.d.ts +22 -0
- package/dist/packem_shared/abstract-pretty-reporter-CUtSm20r.js +1 -0
- package/dist/packem_shared/abstract-pretty-reporter-MOYolfGR.d.ts +28 -0
- package/dist/packem_shared/{constants-BMS51p6Y.mjs → constants-DKfCaSUR.js} +1 -1
- package/dist/packem_shared/format-label-DqvZRRR6.js +33 -0
- package/dist/packem_shared/getBarChar-mKDZW32R.js +1 -0
- package/dist/packem_shared/index-D9hWq9ka.js +1 -0
- package/dist/packem_shared/index.d-BR1GjZri.d.ts +53 -0
- package/dist/packem_shared/index.d-oxZvg_y7.d.ts +20 -0
- package/dist/packem_shared/pail.browser-BmHoDvEA.js +19 -0
- package/dist/packem_shared/{pail.browser-CaPhlNua.d.ts → pail.browser-Bs2ng_Qj.d.ts} +12 -8
- package/dist/packem_shared/{types-CMdBdNgA.d.cts → types-RidvA4RN.d.ts} +2 -3
- package/dist/{processor.server.d.ts → processor/caller/caller-processor.d.ts} +2 -5
- package/dist/processor/caller/caller-processor.js +1 -0
- package/dist/processor/message-formatter-processor.d.ts +16 -0
- package/dist/processor/message-formatter-processor.js +1 -0
- package/dist/processor/redact-processor.d.ts +12 -0
- package/dist/processor/redact-processor.js +1 -0
- package/dist/reporter/file/json-file-reporter.d.ts +26 -0
- package/dist/{packem_shared/JsonFileReporter-raQZY3Ci.mjs → reporter/file/json-file-reporter.js} +1 -1
- package/dist/reporter/json/index.browser.d.ts +12 -0
- package/dist/reporter/json/index.browser.js +1 -0
- package/dist/reporter/json/index.d.ts +15 -0
- package/dist/reporter/json/index.js +1 -0
- package/dist/reporter/pretty/index.browser.d.ts +12 -0
- package/dist/reporter/pretty/index.browser.js +1 -0
- package/dist/reporter/pretty/index.d.ts +24 -0
- package/dist/reporter/pretty/index.js +1 -0
- package/dist/reporter/simple/simple-reporter.server.d.ts +23 -0
- package/dist/reporter/simple/simple-reporter.server.js +11 -0
- package/package.json +34 -122
- package/dist/index.browser.cjs +0 -1
- package/dist/index.browser.d.cts +0 -11
- package/dist/index.browser.d.mts +0 -11
- package/dist/index.browser.mjs +0 -1
- package/dist/index.server.cjs +0 -5
- package/dist/index.server.d.cts +0 -32
- package/dist/index.server.d.mts +0 -32
- package/dist/index.server.mjs +0 -5
- package/dist/packem_shared/CallerProcessor-DJnmMPMj.cjs +0 -1
- package/dist/packem_shared/CallerProcessor-mNkBei3j.mjs +0 -1
- package/dist/packem_shared/JsonFileReporter-B7cJWaL5.cjs +0 -2
- package/dist/packem_shared/JsonReporter-0IxBO0rl.mjs +0 -2
- package/dist/packem_shared/JsonReporter-CRzHu5q7.mjs +0 -1
- package/dist/packem_shared/JsonReporter-DZvKFDz6.cjs +0 -2
- package/dist/packem_shared/JsonReporter-U9kk2_gT.cjs +0 -1
- package/dist/packem_shared/MessageFormatterProcessor-D_s8r8ot.cjs +0 -1
- package/dist/packem_shared/MessageFormatterProcessor-rkvAy05-.mjs +0 -1
- package/dist/packem_shared/PrettyReporter-1aoZvU3r.mjs +0 -5
- package/dist/packem_shared/PrettyReporter-BSm1ACaz.cjs +0 -13
- package/dist/packem_shared/PrettyReporter-C0Qa7g8i.mjs +0 -13
- package/dist/packem_shared/PrettyReporter-CklpEjI1.cjs +0 -5
- package/dist/packem_shared/RedactProcessor-BBJysXaX.cjs +0 -1
- package/dist/packem_shared/RedactProcessor-CxKTN42V.mjs +0 -3
- package/dist/packem_shared/SimpleReporter-BajPeBDy.mjs +0 -11
- package/dist/packem_shared/SimpleReporter-DiFOEIps.cjs +0 -11
- package/dist/packem_shared/abstract-json-reporter-B_QC6gt7.mjs +0 -1
- package/dist/packem_shared/abstract-json-reporter-C1jqd5bO.cjs +0 -1
- package/dist/packem_shared/abstract-pretty-reporter-C2vDqWAQ.cjs +0 -1
- package/dist/packem_shared/abstract-pretty-reporter-C5UVAUaP.d.cts +0 -45
- package/dist/packem_shared/abstract-pretty-reporter-CDuO-IFk.d.ts +0 -45
- package/dist/packem_shared/abstract-pretty-reporter-CRcf4WZd.mjs +0 -1
- package/dist/packem_shared/abstract-pretty-reporter-Ckmv6CnU.d.mts +0 -45
- package/dist/packem_shared/constants-BFrKdBPm.cjs +0 -1
- package/dist/packem_shared/format-label-B496HVjo.mjs +0 -8
- package/dist/packem_shared/format-label-BkRisUmO.cjs +0 -8
- package/dist/packem_shared/get-longest-label-7LkwzzHo.cjs +0 -1
- package/dist/packem_shared/pail.browser-2KlA4DJS.d.cts +0 -60
- package/dist/packem_shared/pail.browser-B9eJPHAe.d.mts +0 -60
- package/dist/packem_shared/pail.browser-Di9_5Zcq.mjs +0 -1
- package/dist/packem_shared/pail.browser-vVxBu_Xl.cjs +0 -1
- package/dist/packem_shared/types-CMdBdNgA.d.mts +0 -123
- package/dist/packem_shared/types-CMdBdNgA.d.ts +0 -123
- package/dist/packem_shared/write-console-log-3G15muTS.cjs +0 -1
- package/dist/packem_shared/write-stream-Dl-usQqh.cjs +0 -1
- package/dist/processor.browser.cjs +0 -1
- package/dist/processor.browser.d.cts +0 -23
- package/dist/processor.browser.d.mts +0 -23
- package/dist/processor.browser.d.ts +0 -23
- package/dist/processor.browser.mjs +0 -1
- package/dist/processor.server.cjs +0 -1
- package/dist/processor.server.d.cts +0 -23
- package/dist/processor.server.d.mts +0 -23
- package/dist/processor.server.mjs +0 -1
- package/dist/reporter.browser.cjs +0 -1
- package/dist/reporter.browser.d.cts +0 -18
- package/dist/reporter.browser.d.mts +0 -18
- package/dist/reporter.browser.d.ts +0 -18
- package/dist/reporter.browser.mjs +0 -1
- package/dist/reporter.server.cjs +0 -1
- package/dist/reporter.server.d.cts +0 -69
- package/dist/reporter.server.d.mts +0 -69
- package/dist/reporter.server.d.ts +0 -69
- package/dist/reporter.server.mjs +0 -1
- /package/dist/packem_shared/{get-longest-label-B0NrI-o2.mjs → get-longest-label-B0NrI-o2.js} +0 -0
- /package/dist/packem_shared/{write-console-log-BP95fgQZ.mjs → write-console-log-based-on-level-BP95fgQZ.js} +0 -0
- /package/dist/packem_shared/{write-stream-CD8XFv1L.mjs → write-stream-CD8XFv1L.js} +0 -0
package/README.md
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
[@visulima/fmt][fmt],
|
|
7
7
|
[@visulima/colorize](https://github.com/visulima/visulima/tree/main/packages/colorize),
|
|
8
|
+
[@visulima/string](https://github.com/visulima/visulima/tree/main/packages/string),
|
|
8
9
|
[ansi-escapes](https://www.npmjs.com/package/ansi-escapes),
|
|
9
|
-
[safe-stable-stringify](https://www.npmjs.com/package/safe-stable-stringify),
|
|
10
|
-
[
|
|
11
|
-
[terminal-size](https://www.npmjs.com/package/terminal-size) and
|
|
12
|
-
[wrap-ansi](https://www.npmjs.com/package/wrap-ansi)
|
|
10
|
+
[safe-stable-stringify](https://www.npmjs.com/package/safe-stable-stringify), and
|
|
11
|
+
[terminal-size](https://www.npmjs.com/package/terminal-size)
|
|
13
12
|
|
|
14
13
|
</p>
|
|
15
14
|
</div>
|
|
@@ -34,6 +33,12 @@
|
|
|
34
33
|
|
|
35
34
|
---
|
|
36
35
|
|
|
36
|
+
## 📋 Migration Guide
|
|
37
|
+
|
|
38
|
+
If you're upgrading from an earlier version of pail, check out our [Migration Guide](MIGRATION-GUIDE.md) for breaking changes and upgrade instructions.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
37
42
|
## Why Pail?
|
|
38
43
|
|
|
39
44
|
- Easy to use
|
|
@@ -54,7 +59,7 @@
|
|
|
54
59
|
- [Browser](./__assets__/header-browser.png) and [Server](./__assets__/header-server.png) support
|
|
55
60
|
- Redirect console and stdout/stderr to pail and easily restore redirect.
|
|
56
61
|
- `Pretty` or `JSON` output
|
|
57
|
-
-
|
|
62
|
+
- ESM‑only with tree‑shaking support (Node.js ≥ 20.19)
|
|
58
63
|
- Supports circular structures
|
|
59
64
|
- Fast and powerful, see the [benchmarks](__bench__/README.md)
|
|
60
65
|
|
|
@@ -308,8 +313,8 @@ const id = setInterval(() => {
|
|
|
308
313
|
if (--ticks < 0) {
|
|
309
314
|
clearInterval(id);
|
|
310
315
|
|
|
311
|
-
interactiveManager.update(["✔ Success", "", "Messages:", "this line will be deleted!!!"]);
|
|
312
|
-
interactiveManager.erase(1);
|
|
316
|
+
interactiveManager.update("stdout", ["✔ Success", "", "Messages:", "this line will be deleted!!!"]);
|
|
317
|
+
interactiveManager.erase("stdout", 1);
|
|
313
318
|
interactiveManager.unhook(false);
|
|
314
319
|
} else {
|
|
315
320
|
const frame = frames[(i = ++i % frames.length)];
|
|
@@ -317,7 +322,7 @@ const id = setInterval(() => {
|
|
|
317
322
|
const message = messages[index];
|
|
318
323
|
|
|
319
324
|
if (message) {
|
|
320
|
-
interactiveManager.update([`${frame} Some process...`, message]);
|
|
325
|
+
interactiveManager.update("stdout", [`${frame} Some process...`, message]);
|
|
321
326
|
}
|
|
322
327
|
}
|
|
323
328
|
}, TIMEOUT);
|
|
@@ -360,6 +365,184 @@ pail.time("test");
|
|
|
360
365
|
pail.timeEnd("test");
|
|
361
366
|
```
|
|
362
367
|
|
|
368
|
+
## Progress Bars (Server Only)
|
|
369
|
+
|
|
370
|
+
Pail includes a comprehensive progress bar system inspired by cli-progress, with support for single and multi-bar modes, various styles, and interactive terminal output.
|
|
371
|
+
|
|
372
|
+
### Single Progress Bar
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
import { createPail } from "@visulima/pail";
|
|
376
|
+
|
|
377
|
+
const logger = createPail({ interactive: true });
|
|
378
|
+
const bar = logger.createProgressBar({
|
|
379
|
+
total: 100,
|
|
380
|
+
format: "Downloading [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
bar.start();
|
|
384
|
+
bar.update(50);
|
|
385
|
+
bar.increment(10);
|
|
386
|
+
bar.stop();
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Styled Progress Bars
|
|
390
|
+
|
|
391
|
+
Pail supports various built-in progress bar styles:
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
import { createPail } from "@visulima/pail";
|
|
395
|
+
|
|
396
|
+
const logger = createPail({ interactive: true });
|
|
397
|
+
|
|
398
|
+
// Shades classic (default)
|
|
399
|
+
const bar1 = logger.createProgressBar({
|
|
400
|
+
total: 100,
|
|
401
|
+
style: "shades_classic",
|
|
402
|
+
format: "Progress [{bar}] {percentage}%",
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Shades grey
|
|
406
|
+
const bar2 = logger.createProgressBar({
|
|
407
|
+
total: 100,
|
|
408
|
+
style: "shades_grey",
|
|
409
|
+
format: "Progress [{bar}] {percentage}%",
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// Rect style
|
|
413
|
+
const bar3 = logger.createProgressBar({
|
|
414
|
+
total: 100,
|
|
415
|
+
style: "rect",
|
|
416
|
+
format: "Progress [{bar}] {percentage}%",
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// ASCII style
|
|
420
|
+
const bar4 = logger.createProgressBar({
|
|
421
|
+
total: 100,
|
|
422
|
+
style: "ascii",
|
|
423
|
+
format: "Progress [{bar}] {percentage}%",
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// You can still override individual style settings
|
|
427
|
+
const bar5 = logger.createProgressBar({
|
|
428
|
+
total: 100,
|
|
429
|
+
style: "shades_classic",
|
|
430
|
+
barCompleteChar: "🚀", // Override the complete character
|
|
431
|
+
format: "Progress [{bar}] {percentage}%",
|
|
432
|
+
});
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Available styles: `shades_classic`, `shades_grey`, `rect`, `filled`, `solid`, `ascii`, `custom`
|
|
436
|
+
|
|
437
|
+
### Multi Progress Bars
|
|
438
|
+
|
|
439
|
+
Display multiple progress bars simultaneously:
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
import { createPail } from "@visulima/pail";
|
|
443
|
+
|
|
444
|
+
const logger = createPail({ interactive: true });
|
|
445
|
+
const multiBar = logger.createMultiProgressBar({
|
|
446
|
+
style: "shades_classic", // Apply style to all bars
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
const bar1 = multiBar.create(100);
|
|
450
|
+
const bar2 = multiBar.create(200);
|
|
451
|
+
const bar3 = multiBar.create(150);
|
|
452
|
+
|
|
453
|
+
// Update bars as needed
|
|
454
|
+
bar1.update(50);
|
|
455
|
+
bar2.update(75);
|
|
456
|
+
bar3.update(25);
|
|
457
|
+
|
|
458
|
+
// Clean up when done
|
|
459
|
+
multiBar.stop();
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### Custom Progress Bar
|
|
463
|
+
|
|
464
|
+
Create fully customized progress bars with your own characters and formatting:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
import { createPail } from "@visulima/pail";
|
|
468
|
+
|
|
469
|
+
const logger = createPail({ interactive: true });
|
|
470
|
+
const bar = logger.createProgressBar({
|
|
471
|
+
total: 100,
|
|
472
|
+
format: "🚀 Downloading {filename}: [{bar}] {percentage}% | Speed: {speed} MB/s | ETA: {eta}s",
|
|
473
|
+
barCompleteChar: "🚀",
|
|
474
|
+
barIncompleteChar: "⚪",
|
|
475
|
+
width: 20,
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
bar.start(0, 0, {
|
|
479
|
+
filename: "large-file.zip",
|
|
480
|
+
speed: "0.0",
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
// Update with payload data
|
|
484
|
+
bar.update(50, { speed: "2.5" });
|
|
485
|
+
bar.stop();
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
## Integrations
|
|
489
|
+
|
|
490
|
+
### Use with @visulima/boxen
|
|
491
|
+
|
|
492
|
+
Create nicely framed messages with `@visulima/boxen` and log them with Pail:
|
|
493
|
+
|
|
494
|
+
```typescript
|
|
495
|
+
import { pail } from "@visulima/pail";
|
|
496
|
+
import { boxen } from "@visulima/boxen";
|
|
497
|
+
|
|
498
|
+
const output = boxen("Build completed successfully", {
|
|
499
|
+
headerText: "Success",
|
|
500
|
+
padding: 1,
|
|
501
|
+
borderStyle: "round",
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
pail.success(output);
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
You can also include multi‑line content; Pail preserves newlines:
|
|
508
|
+
|
|
509
|
+
```typescript
|
|
510
|
+
import { pail } from "@visulima/pail";
|
|
511
|
+
import { boxen } from "@visulima/boxen";
|
|
512
|
+
|
|
513
|
+
const details = ["Service: api", "Env: production", "Commit: a1b2c3"].join("\n");
|
|
514
|
+
|
|
515
|
+
pail.info(
|
|
516
|
+
boxen(details, {
|
|
517
|
+
headerText: "Deploy Info",
|
|
518
|
+
padding: { top: 0, right: 2, bottom: 0, left: 2 },
|
|
519
|
+
borderStyle: "classic",
|
|
520
|
+
}),
|
|
521
|
+
);
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Use with @visulima/tabular
|
|
525
|
+
|
|
526
|
+
Render tables with `@visulima/tabular` and send them through Pail:
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
import { pail } from "@visulima/pail";
|
|
530
|
+
import { createTable } from "@visulima/tabular";
|
|
531
|
+
|
|
532
|
+
const table = createTable({
|
|
533
|
+
showHeader: true,
|
|
534
|
+
style: {
|
|
535
|
+
// optional: customize colors/border via @visulima/colorize
|
|
536
|
+
},
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
table.setHeaders(["Task", "Status", "Duration"]).addRow(["build", "ok", "1.2s"]).addRow(["test", "ok", "3.4s"]).addRow(["lint", "warn", "0.8s"]);
|
|
540
|
+
|
|
541
|
+
pail.info("\n" + table.toString());
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
For dynamic dashboards, combine `tabular` with Pail's interactive mode and update the rendered table as your process runs.
|
|
545
|
+
|
|
363
546
|
## Disable and Enable Loggers
|
|
364
547
|
|
|
365
548
|
To disable a logger, use the `disable()` function, which will prevent any log messages from being written to the console or a file.
|
|
@@ -382,6 +565,31 @@ pail.enable();
|
|
|
382
565
|
pail.success("This message will be logged");
|
|
383
566
|
```
|
|
384
567
|
|
|
568
|
+
## Pause and Resume Loggers
|
|
569
|
+
|
|
570
|
+
The `pause()` and `resume()` functions allow you to temporarily queue log messages and then flush them all at once. This is similar to how consola works and is useful when you need to buffer output during critical operations.
|
|
571
|
+
|
|
572
|
+
When paused, all log calls will be queued instead of being output immediately. When you call `resume()`, all queued messages will be processed in the order they were called.
|
|
573
|
+
|
|
574
|
+
```typescript
|
|
575
|
+
import { pail } from "@visulima/pail";
|
|
576
|
+
|
|
577
|
+
pail.pause();
|
|
578
|
+
|
|
579
|
+
// These messages will be queued
|
|
580
|
+
pail.info("First message");
|
|
581
|
+
pail.warn("Second message");
|
|
582
|
+
pail.success("Third message");
|
|
583
|
+
|
|
584
|
+
// Resume logging - all queued messages are now output in order
|
|
585
|
+
pail.resume();
|
|
586
|
+
|
|
587
|
+
// This message is output immediately
|
|
588
|
+
pail.info("Fourth message");
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
**Note:** Unlike `disable()`, which discards log messages, `pause()` queues them for later output. This makes it ideal for scenarios where you want to control when messages appear without losing them.
|
|
592
|
+
|
|
385
593
|
## Api
|
|
386
594
|
|
|
387
595
|
## Supported Node.js Versions
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
4
|
-
import '
|
|
1
|
+
import { P as PailBrowserType } from './packem_shared/pail.browser-Bs2ng_Qj.js';
|
|
2
|
+
import { C as ConstructorOptions } from './packem_shared/types-RidvA4RN.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-RidvA4RN.js';
|
|
4
|
+
import './packem_shared/index.d-oxZvg_y7.js';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
import '@visulima/colorize';
|
|
7
7
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{P as t}from"./packem_shared/pail.browser-BmHoDvEA.js";import p from"./processor/message-formatter-processor.js";import i from"./packem_shared/JsonReporter-Dl4m0xZe.js";var m=Object.defineProperty,n=o((r,e)=>m(r,"name",{value:e,configurable:!0}),"e");const s=n(r=>new t({processors:[new p],reporters:[new i],...r}),"createPail"),w=s();export{s as createPail,w as pail};
|
package/dist/index.server.d.ts
CHANGED
|
@@ -1,11 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
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-
|
|
3
|
-
import { a as PailBrowserImpl } from './packem_shared/pail.browser-
|
|
1
|
+
import { I as InteractiveManager, e as ServerConstructorOptions, R as Reporter, a as DefaultLogTypes, b as LoggerFunction, C as ConstructorOptions } from './packem_shared/types-RidvA4RN.js';
|
|
2
|
+
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-RidvA4RN.js';
|
|
3
|
+
import { a as PailBrowserImpl } from './packem_shared/pail.browser-Bs2ng_Qj.js';
|
|
4
4
|
import '@visulima/colorize';
|
|
5
5
|
import 'type-fest';
|
|
6
|
-
import '
|
|
6
|
+
import './packem_shared/index.d-oxZvg_y7.js';
|
|
7
|
+
|
|
8
|
+
type ProgressBarStyle = "shades_classic" | "shades_grey" | "rect" | "filled" | "solid" | "ascii" | "custom";
|
|
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
|
+
}
|
|
7
72
|
|
|
8
73
|
declare class PailServerImpl<T extends string = string, L extends string = string> extends PailBrowserImpl<T, L> {
|
|
74
|
+
#private;
|
|
9
75
|
readonly options: ServerConstructorOptions<T, L>;
|
|
10
76
|
protected readonly stdout: NodeJS.WriteStream;
|
|
11
77
|
protected readonly stderr: NodeJS.WriteStream;
|
|
@@ -18,15 +84,15 @@ declare class PailServerImpl<T extends string = string, L extends string = strin
|
|
|
18
84
|
restoreStd(): void;
|
|
19
85
|
wrapAll(): void;
|
|
20
86
|
restoreAll(): void;
|
|
87
|
+
createProgressBar(options: SingleBarOptions): ProgressBar;
|
|
88
|
+
createMultiProgressBar(options?: MultiBarOptions): MultiProgressBar;
|
|
21
89
|
clear(): void;
|
|
22
90
|
protected extendReporter(reporter: Reporter<L>): Reporter<L>;
|
|
23
|
-
private _wrapStream;
|
|
24
|
-
private _restoreStream;
|
|
25
91
|
}
|
|
26
92
|
type PailServerType<T extends string = string, L extends string = string> = (new <TC extends string = string, LC extends string = string>(options?: ServerConstructorOptions<TC, LC>) => PailServerType<TC, LC>) & PailServerImpl<T, L> & Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
|
|
27
93
|
|
|
28
94
|
declare const createPail: <T extends string = string, L extends string = string>(options?: ConstructorOptions<T, L>) => PailServerType<T, L>;
|
|
29
95
|
declare const pail: PailServerType<string, string>;
|
|
30
96
|
|
|
31
|
-
export { ConstructorOptions, DefaultLogTypes, LoggerFunction, Reporter, createPail, pail };
|
|
32
|
-
export type { PailServerType as Pail };
|
|
97
|
+
export { ConstructorOptions, DefaultLogTypes, LoggerFunction, MultiProgressBar, ProgressBar, Reporter, createPail, getBarChar, pail };
|
|
98
|
+
export type { MultiBarOptions, PailServerType as Pail, ProgressBarOptions, ProgressBarPayload, ProgressBarStyle, SingleBarOptions };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var j=Object.defineProperty;var o=(r,t)=>j(r,"name",{value:t,configurable:!0});import{createRequire as I}from"node:module";import{O as x,i as $,B as O,a as f}from"./packem_shared/format-label-DqvZRRR6.js";import{a as R}from"./packem_shared/pail.browser-BmHoDvEA.js";import{applyStyleToOptions as g,ProgressBar as A,MultiProgressBar as N}from"./packem_shared/getBarChar-mKDZW32R.js";import{getBarChar as bt}from"./packem_shared/getBarChar-mKDZW32R.js";import{E as D}from"./packem_shared/constants-DKfCaSUR.js";import{n as H}from"./packem_shared/write-stream-CD8XFv1L.js";import k from"./processor/message-formatter-processor.js";import{PrettyReporter as C}from"./packem_shared/PrettyReporter-CREln5bH.js";const P=I(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=o(r=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[t,e]=l.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return l.getBuiltinModule(r)}return P(r)},"__cjs_getBuiltinModule"),{stdout:y,stderr:_,env:d}=l,{StringDecoder:T}=E("node:string_decoder");var G=Object.defineProperty,V=o((r,t)=>G(r,"name",{value:t,configurable:!0}),"l");class q{static{o(this,"g")}static{V(this,"InteractiveManager")}#t;#e=!1;#r=!1;#s=0;#i=0;constructor(t,e){this.#t={stderr:e,stdout:t}}get lastLength(){return this.#s}get outside(){return this.#i}get isHooked(){return this.#e}get isSuspended(){return this.#r}erase(t,e=this.#s){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.#o(!0)),this.#e}resume(t,e){this.#r&&(this.#r=!1,e&&this.erase(t,e),this.#s=0,Object.values(this.#t).forEach(s=>s.active()))}suspend(t,e=!0){this.#r||(this.#r=!0,e&&this.erase(t),Object.values(this.#t).forEach(s=>s.renew()))}unhook(t=!0){return this.#e&&(Object.values(this.#t).forEach(e=>e.inactive(t)),this.#o()),!this.#e}update(t,e,s=0){if(e.length>0){if(this.#t[t]===void 0)throw new TypeError(`Stream "${t}" is not available`);const a=this.#t[t],{columns:p,rows:i}=x(),h=s>i?i-1:Math.max(0,Math.min(i-1,s)),c=this.lastLength-h,u=Math.max(c-i,this.outside);let n=e.reduce((L,M)=>[...L,$(M,{trim:!1,width:p,wrapMode:O.STRICT_WIDTH})],[]);i<=c?(a.erase(i),h<u&&(n=n.slice(u-h+1))):c&&a.erase(c),a.write(`${n.join(`
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var c=(e,t)=>h(e,"name",{value:t,configurable:!0});import{E as y}from"./constants-DKfCaSUR.js";var S=Object.defineProperty,O=c((e,t)=>S(e,"name",{value:t,configurable:!0}),"r"),j=Object.defineProperty,d=O((e,t)=>j(e,"name",{value:t,configurable:!0}),"o"),x=Object.defineProperty,N=d((e,t)=>x(e,"name",{value:t,configurable:!0}),"e");function f(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}c(f,"o");O(f,"i");d(f,"r");N(f,"isPlainObject");var P=Object.defineProperty,J=c((e,t)=>P(e,"name",{value:t,configurable:!0}),"l"),w=Object.defineProperty,A=J((e,t)=>w(e,"name",{value:t,configurable:!0}),"f");const E=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var T=Object.defineProperty,b=A((e,t)=>T(e,"name",{value:t,configurable:!0}),"c");const m=new WeakSet,D=b(e=>{m.add(e);const t=e.toJSON();return m.delete(e),t},"toJSON"),g=b((e,t,o,a)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(o+=1,l(e,a,t,o));if(a.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(f(e)){if(o+=1,a.maxDepth&&o>=a.maxDepth)return{};const r={};for(const n in e)r[n]=g(e[n],t,o,a);return r}try{return e}catch{return"[Not Available]"}},"serializeValue"),l=b((e,t,o,a)=>{if(o.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!m.has(e))return D(e);const r=Object.create(E);if(r.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,r.message=e.message,r.stack=e.stack,Array.isArray(e.errors)){const n=[];for(const u of e.errors){if(!(u instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(o.includes(u))return r.errors=[],r;n.push(l(u,t,o,a))}r.errors=n}e.cause instanceof Error&&!o.includes(e.cause)&&(r.cause=l(e.cause,t,o,a));for(const n in e)if(r[n]===void 0){const u=e[n];r[n]=g(u,o,a,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete r[n]}catch{}return r},"_serialize"),v=b((e,t={})=>l(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var I=Object.defineProperty,$=c((e,t)=>I(e,"name",{value:t,configurable:!0}),"p");class z{static{c(this,"AbstractJsonReporter")}static{$(this,"AbstractJsonReporter")}stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:o,error:a,file:r,message:n,type:u,...i}=t;if(i.label&&(i.label=i.label.trim()),r&&(i.file=`${r.name}:${r.line}${r.column?`:${r.column}`:""}`),n===y?i.message=void 0:i.message=n,a&&(i.error=v(a,this.errorOptions)),o){const p=[];for(const s of o)s!==y&&(s instanceof Error?p.push(v(s,this.errorOptions)):p.push(s));i.context=p}this._log(this.stringify(i),u.level)}}export{z as AbstractJsonReporter};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(t,e)=>i(t,"name",{value:e,configurable:!0});import{createRequire as n}from"node:module";import{n as d}from"./write-stream-CD8XFv1L.js";import{AbstractJsonReporter as l}from"./AbstractJsonReporter-UftN6CIL.js";const h=n(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{stdout:u,stderr:a}=c;var p=Object.defineProperty,f=r((t,e)=>p(t,"name",{value:e,configurable:!0}),"e");class j extends l{static{r(this,"d")}static{f(this,"JsonReporter")}#e;#t;constructor(e={}){super(e),this.#e=u,this.#t=a}setStdout(e){this.#e=e}setStderr(e){this.#t=e}_log(e,s){const o=["error","warn"].includes(s)?this.#t:this.#e;d(`${e}
|
|
2
|
+
`,o)}}export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var t=(e,r)=>s(e,"name",{value:r,configurable:!0});import{AbstractJsonReporter as a}from"./AbstractJsonReporter-UftN6CIL.js";import{t as p}from"./write-console-log-based-on-level-BP95fgQZ.js";var c=Object.defineProperty,n=t((e,r)=>c(e,"name",{value:r,configurable:!0}),"e");class l extends a{static{t(this,"p")}static{n(this,"JsonReporter")}constructor(r={}){super(r)}_log(r,o){p(o)(r)}}export{l as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var Y=Object.defineProperty;var d=(h,i)=>Y(h,"name",{value:i,configurable:!0});import E,{grey as o,white as R,underline as b,bold as L}from"@visulima/colorize/browser";import{v as r}from"./index-D9hWq9ka.js";import{E as O}from"./constants-DKfCaSUR.js";import{A as k,s as B}from"./abstract-pretty-reporter-CUtSm20r.js";import{s as C}from"./get-longest-label-B0NrI-o2.js";import{t as D}from"./write-console-log-based-on-level-BP95fgQZ.js";var F=Object.defineProperty,U=d((h,i)=>F(h,"name",{value:i,configurable:!0}),"A");class K extends k{static{d(this,"Y")}static{U(this,"PrettyReporter")}constructor(i={}){super({uppercase:{label:!0,...i.uppercase},...i})}log(i){const t=typeof globalThis.window<"u"&&typeof globalThis.document<"u",x=D(i.type.level),{badge:A,context:T,date:u,error:v,groups:f,label:g,message:w,prefix:y,repeated:a,scope:n,suffix:m,type:S}=i,{color:P}=this.loggerTypes[S.name],j=P?E[P]:R,e=[];if(t&&f.length>0){const s=f.map(()=>" ").join(""),l=o(`[${f.at(-1)}]`);e.push(r(s+l[0],l.slice(1)))}if(u){const s=o(this.styles.dateFormatter(typeof u=="string"?new Date(u):u));t?e.push(r(s[0],s.slice(1))):e.push([`${s[0]} `,...s.slice(1)])}if(A){const s=j(A);t?e.push(r(s[0],s.slice(1))):e.push([`${s[0]} `,...s.slice(1)])}else{const s=B(this.loggerTypes);if(s.length>0){const l=o(".".repeat(s.length));t?e.push(r(`${l[0]} `,l.slice(1))):e.push([`${l[0]} `,...l.slice(1)])}}const M=C(this.loggerTypes);let $;if(a){const s=R(`[${a}x]`);$=t?r(s[0],s.slice(1)):[s[0],...s.slice(1)]}if(g){const s=j(this.#s(g));t?e.push(r(s[0],s.slice(1))):e.push([s[0],...s.slice(1)]),$&&e.push($);let l=M.length-g.length;if(a?l-=String(a).length+3:l+=1,l>0){const p=o(".".repeat(l));t?e.push(r(p[0],p.slice(1))):e.push([` ${p[0]}`,...p.slice(1)])}}else{const s=o(".".repeat(M.length+1));t?e.push(r(s[0],s.slice(1))):e.push([s[0],...s.slice(1)])}if(Array.isArray(n)&&n.length>0){const s=o(`[${n.join(" > ")}]`);t?e.push(r(s[0],s.slice(1))):e.push([s[0],...s.slice(1)])}if(y){const s=o(`${Array.isArray(n)&&n.length>0?". ":" "}[${this.styles.underline.prefix?b(y):y}] `);t?e.push(r(s[0],s.slice(1))):e.push([s[0],...s.slice(1)])}if(w!==O&&e.push(w),T&&e.push(...T),v&&e.push(v,`
|
|
2
|
+
|
|
3
|
+
`),m){const s=o(this.styles.underline.suffix?b(m):m);t?e.push(r(`
|
|
4
|
+
${s[0]}`,s.slice(1))):e.push([`
|
|
5
|
+
${s[0]}`,...s.slice(1)])}if(t)x(...e);else{let s="";const l=[],p=[];for(const c of e)Array.isArray(c)&&c.length>1&&c[0].includes("%c")?(s+=c[0],l.push(...c.slice(1))):p.push(c);x(`${s}%c`,...l,"",...p)}}#s(i){let t=this.styles.uppercase.label?i.toUpperCase():i;return t=this.styles.underline.label?b(t):t,this.styles.bold.label&&(t=L(t)),t}}export{K as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var k=Object.defineProperty;var M=(a,e)=>k(a,"name",{value:e,configurable:!0});import{createRequire as O}from"node:module";import Y,{red as b,greenBright as D,cyan as G,green as H,grey as r,white as N,bgGrey as W,underline as C}from"@visulima/colorize";import{u as z,O as J,o as g,n as K,a as I,i as Q,B as U,G as T}from"./format-label-DqvZRRR6.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 se}from"./write-stream-CD8XFv1L.js";const ne=O(import.meta.url),q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{stdout:F,stderr:V}=q;var re=Object.defineProperty,B=M((a,e)=>re(a,"name",{value:e,configurable:!0}),"x");const j=B(a=>!/[\\/]pail[\\/]dist/.test(a),"pailFileFilter");class fe extends Z{static{M(this,"PrettyReporter")}static{B(this,"PrettyReporter")}#t;#s;#r;#o=!1;#i;#e;constructor(e={}){const{error:h,inspect:i,...n}=e;super({uppercase:{label:!0,...n.uppercase},...n}),this.#i={...z,...i},this.#e={...h,color:{fileLine:H,hint:G,marker:b,message:b,method:D,title:b}},this.#t=F,this.#s=V}setStdout(e){this.#t=e}setStderr(e){this.#s=e}setInteractiveManager(e){this.#r=e}setIsInteractive(e){this.#o=e}log(e){this._log(this._formatMessage(e),e.type.level)}_formatMessage(e){const{columns:h}=J();let i=h;typeof this.styles.messageLength=="number"&&(i=this.styles.messageLength);const{badge:n,context:v,date:u,error:w,file:c,groups:d,label:m,message:f,prefix:y,repeated:E,scope:l,suffix:$,traceError:S,type:L}=e,{color:A}=this.loggerTypes[L.name],P=A?Y[A]:N,p=d.map(()=>" ").join(""),t=[];if(d.length>0&&t.push(`${p+r(`[${d.at(-1)}]`)} `),u&&t.push(`${r(this.styles.dateFormatter(typeof u=="string"?new Date(u):u))} `),n)t.push(P(n));else{const s=ee(this.loggerTypes);s.length>0&&t.push(`${r(".".repeat(s.length))} `)}const R=te(this.loggerTypes);if(m){const s=g(R),o=g(m);t.push(`${P(K(m,this.styles))} `,r(".".repeat(Math.max(0,s-o))))}else t.push(r(".".repeat(R.length+2)));E&&t.push(`${W.white(`[${E}x]`)} `),Array.isArray(l)&&l.length>0&&t.push(` ${r(`[${l.join(" > ")}]`)} `),y&&t.push(`${r(`${Array.isArray(l)&&l.length>0?". ":" "}[${this.styles.underline.prefix?C(y):y}]`)} `);const _=g(t.join(" "));if(c){const s=c.name+(c.line?`:${c.line}`:""),o=g(s);if(o+_+2>i)t.push(r(` ${s}`));else{const x=Math.max(0,i-_-o-2);t.push(r(`${".".repeat(x)} ${s}`))}}else t.push(r(".".repeat(Math.max(0,i-_-1))));if(t.length>0&&t.push(`
|
|
2
|
+
|
|
3
|
+
`),f!==X){const s=typeof f=="string"?f:I(f,this.#i);t.push(p+Q(s,{trim:!1,width:i-3,wrapMode:U.STRICT_WIDTH}))}if(v){let s=!1;t.push(...v.map(o=>{if(o instanceof Error)return s=!0,`
|
|
4
|
+
|
|
5
|
+
${T(o,{...this.#e,filterStacktrace:j,prefix:p})}`;if(typeof o=="object")return` ${I(o,this.#i)}`;const x=(s?`
|
|
6
|
+
|
|
7
|
+
`:" ")+o;return s=!1,x}))}return w&&t.push(T(w,{...this.#e,filterStacktrace:j,prefix:p})),S&&t.push(`
|
|
8
|
+
|
|
9
|
+
${T(S,{...this.#e,filterStacktrace:j,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:p})}`),$&&t.push(`
|
|
10
|
+
`,p+r(this.styles.underline.suffix?C($):$)),t.join("")}_log(e,h){const i=["error","trace","warn"].includes(h)?"stderr":"stdout",n=i==="stderr"?this.#s:this.#t;this.#o&&this.#r!==void 0&&n.isTTY?this.#r.update(i,e.split(`
|
|
11
|
+
`),0):se(`${e}
|
|
12
|
+
`,n)}}export{fe as PrettyReporter};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { s as stringify } from './index.d-oxZvg_y7.js';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { g as StringifyAwareReporter, h as ReadonlyMeta, E as ExtendedRfc5424LogLevels } from './types-RidvA4RN.js';
|
|
4
|
+
|
|
5
|
+
type AbstractJsonReporterOptions = {
|
|
6
|
+
error: Partial<{
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
maxDepth?: number;
|
|
9
|
+
useToJSON?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
|
|
13
|
+
protected stringify: typeof stringify | undefined;
|
|
14
|
+
protected errorOptions: AbstractJsonReporterOptions["error"];
|
|
15
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
16
|
+
setStringify(function_: any): void;
|
|
17
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
18
|
+
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { AbstractJsonReporter as a };
|
|
22
|
+
export type { AbstractJsonReporterOptions as A };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=Object.defineProperty;var s=(t,e)=>o(t,"name",{value:e,configurable:!0});import{L as g}from"./constants-DKfCaSUR.js";var n=Object.defineProperty,c=s((t,e)=>n(t,"name",{value:e,configurable:!0}),"r$1");const b=c(t=>{const e=Object.keys(t).map(r=>t[r].badge??"");return e.length===0?"":e.reduce((r,a)=>r.length>a.length?r:a)},"getLongestBadge");var i=Object.defineProperty,l=s((t,e)=>i(t,"name",{value:e,configurable:!0}),"o");const p=l(t=>[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>String(e).padStart(2,"0")).join(":"),"dateFormatter");class d{static{s(this,"AbstractPrettyReporter")}static{l(this,"AbstractPrettyReporter")}styles;loggerTypes;constructor(e){this.styles={bold:{label:!1},dateFormatter:p,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...e},this.loggerTypes=g}setLoggerTypes(e){this.loggerTypes=e}}export{d as A,b as s};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes, h as ReadonlyMeta } from './types-RidvA4RN.js';
|
|
3
|
+
|
|
4
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
5
|
+
protected readonly styles: PrettyStyleOptions;
|
|
6
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
7
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
8
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
9
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
10
|
+
}
|
|
11
|
+
type PrettyStyleOptions = {
|
|
12
|
+
bold: {
|
|
13
|
+
label: boolean;
|
|
14
|
+
};
|
|
15
|
+
dateFormatter: (date: Date) => string;
|
|
16
|
+
messageLength: number | undefined;
|
|
17
|
+
underline: {
|
|
18
|
+
label: boolean;
|
|
19
|
+
prefix: boolean;
|
|
20
|
+
suffix: boolean;
|
|
21
|
+
};
|
|
22
|
+
uppercase: {
|
|
23
|
+
label: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { AbstractPrettyReporter as A };
|
|
28
|
+
export type { PrettyStyleOptions as P };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const l={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},e={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},o=Symbol("EMPTY");export{o as E,e as L,l as a};
|
|
1
|
+
const l={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},e={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},warning:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},o=Symbol("EMPTY");export{o as E,e as L,l as a};
|