@visulima/pail 2.1.27 → 2.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/index.browser.cjs +1 -19
  3. package/dist/index.browser.mjs +1 -14
  4. package/dist/index.server.cjs +5 -442
  5. package/dist/index.server.mjs +5 -437
  6. package/dist/packem_shared/CallerProcessor-DJnmMPMj.cjs +1 -0
  7. package/dist/packem_shared/CallerProcessor-mNkBei3j.mjs +1 -0
  8. package/dist/packem_shared/JsonFileReporter-BnxuhH4o.cjs +2 -0
  9. package/dist/packem_shared/JsonFileReporter-Og8hyKfg.mjs +4 -0
  10. package/dist/packem_shared/JsonReporter-BdExg5gk.mjs +1 -0
  11. package/dist/packem_shared/JsonReporter-CjvkrXUp.cjs +1 -0
  12. package/dist/packem_shared/JsonReporter-DRGJgjAO.mjs +2 -0
  13. package/dist/packem_shared/JsonReporter-DuF0Ho5i.cjs +2 -0
  14. package/dist/packem_shared/MessageFormatterProcessor-BjBZzL2D.mjs +1 -0
  15. package/dist/packem_shared/MessageFormatterProcessor-CCRIUIdT.cjs +1 -0
  16. package/dist/packem_shared/PrettyReporter-BRFlkORc.mjs +5 -0
  17. package/dist/packem_shared/PrettyReporter-BuKPqA5T.cjs +5 -0
  18. package/dist/packem_shared/PrettyReporter-DDsX0vlT.mjs +13 -0
  19. package/dist/packem_shared/PrettyReporter-Dx1OfdGj.cjs +13 -0
  20. package/dist/packem_shared/RedactProcessor-BBJysXaX.cjs +1 -0
  21. package/dist/packem_shared/RedactProcessor-CxKTN42V.mjs +3 -0
  22. package/dist/packem_shared/SimpleReporter-BV0taliz.mjs +11 -0
  23. package/dist/packem_shared/SimpleReporter-YuzZZabX.cjs +11 -0
  24. package/dist/packem_shared/abstract-json-reporter-Z6bVrpPK.cjs +1 -0
  25. package/dist/packem_shared/abstract-json-reporter-tFmKAzRZ.mjs +1 -0
  26. package/dist/packem_shared/abstract-pretty-reporter-C2vDqWAQ.cjs +1 -0
  27. package/dist/packem_shared/abstract-pretty-reporter-CRcf4WZd.mjs +1 -0
  28. package/dist/packem_shared/constants-BFrKdBPm.cjs +1 -0
  29. package/dist/packem_shared/constants-BMS51p6Y.mjs +1 -0
  30. package/dist/packem_shared/format-label-CKRxcWAQ.cjs +8 -0
  31. package/dist/packem_shared/format-label-D2xt_3df.mjs +8 -0
  32. package/dist/packem_shared/get-longest-label-7LkwzzHo.cjs +1 -0
  33. package/dist/packem_shared/get-longest-label-B0NrI-o2.mjs +1 -0
  34. package/dist/packem_shared/pail.browser-DC6QwLTj.cjs +1 -0
  35. package/dist/packem_shared/pail.browser-DkNIDzgk.mjs +1 -0
  36. package/dist/packem_shared/write-console-log-3G15muTS.cjs +1 -0
  37. package/dist/packem_shared/write-console-log-BP95fgQZ.mjs +1 -0
  38. package/dist/packem_shared/write-stream-CD8XFv1L.mjs +1 -0
  39. package/dist/packem_shared/write-stream-Dl-usQqh.cjs +1 -0
  40. package/dist/processor.browser.cjs +1 -11
  41. package/dist/processor.browser.mjs +1 -2
  42. package/dist/processor.server.cjs +1 -13
  43. package/dist/processor.server.mjs +1 -3
  44. package/dist/reporter.browser.cjs +1 -11
  45. package/dist/reporter.browser.mjs +1 -2
  46. package/dist/reporter.server.cjs +1 -15
  47. package/dist/reporter.server.mjs +1 -4
  48. package/package.json +2 -2
  49. package/dist/packem_shared/CallerProcessor-CNhuyGAa.mjs +0 -58
  50. package/dist/packem_shared/CallerProcessor-DJ5euiUK.cjs +0 -60
  51. package/dist/packem_shared/JsonFileReporter-BazAMbEI.mjs +0 -133
  52. package/dist/packem_shared/JsonFileReporter-PNmBNTr1.cjs +0 -135
  53. package/dist/packem_shared/JsonReporter-CKWF4Ibl.mjs +0 -20
  54. package/dist/packem_shared/JsonReporter-CcOVaf3A.cjs +0 -34
  55. package/dist/packem_shared/JsonReporter-Cg5R1FXn.cjs +0 -22
  56. package/dist/packem_shared/JsonReporter-DFFyVZyh.mjs +0 -32
  57. package/dist/packem_shared/MessageFormatterProcessor-Cd4HntPG.mjs +0 -53
  58. package/dist/packem_shared/MessageFormatterProcessor-t4t6CpzV.cjs +0 -55
  59. package/dist/packem_shared/PrettyReporter-3oMWkX6j.cjs +0 -200
  60. package/dist/packem_shared/PrettyReporter-Bx3QLZrW.mjs +0 -162
  61. package/dist/packem_shared/PrettyReporter-C2hjNe-y.mjs +0 -192
  62. package/dist/packem_shared/PrettyReporter-mFCjMb0i.cjs +0 -168
  63. package/dist/packem_shared/RedactProcessor-CfNkF2lC.mjs +0 -26
  64. package/dist/packem_shared/RedactProcessor-DWE5iqAQ.cjs +0 -26
  65. package/dist/packem_shared/SimpleReporter-CXXqr1h3.cjs +0 -186
  66. package/dist/packem_shared/SimpleReporter-TOcMSqJb.mjs +0 -178
  67. package/dist/packem_shared/abstract-json-reporter-okwLqT9k.cjs +0 -57
  68. package/dist/packem_shared/abstract-json-reporter-sxnmNIlg.mjs +0 -55
  69. package/dist/packem_shared/abstract-pretty-reporter-BR_6_JVa.cjs +0 -49
  70. package/dist/packem_shared/abstract-pretty-reporter-izJgxoMv.mjs +0 -46
  71. package/dist/packem_shared/constants-BYYZ5WNW.mjs +0 -114
  72. package/dist/packem_shared/constants-DHfYGxxG.cjs +0 -118
  73. package/dist/packem_shared/format-label-DYEhjrTZ.cjs +0 -621
  74. package/dist/packem_shared/format-label-Uj-cxY3j.mjs +0 -609
  75. package/dist/packem_shared/get-longest-label-CM8kLFWH.mjs +0 -11
  76. package/dist/packem_shared/get-longest-label-CQ7lRhgD.cjs +0 -13
  77. package/dist/packem_shared/pail.browser-Bp1fz428.mjs +0 -384
  78. package/dist/packem_shared/pail.browser-O53Q_cus.cjs +0 -387
  79. package/dist/packem_shared/write-console-log-Cu0-IDN-.cjs +0 -18
  80. package/dist/packem_shared/write-console-log-Tptfzg9D.mjs +0 -16
  81. package/dist/packem_shared/write-stream-BBAF33Zm.mjs +0 -8
  82. package/dist/packem_shared/write-stream-CkNf2Ju8.cjs +0 -10
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## @visulima/pail [2.1.28](https://github.com/visulima/visulima/compare/@visulima/pail@2.1.27...@visulima/pail@2.1.28) (2025-09-19)
2
+
3
+ ### Miscellaneous Chores
4
+
5
+ * **deps:** update build scripts and remove cross-env dependency ([7510e82](https://github.com/visulima/visulima/commit/7510e826b9235a0013fe61c82a7eb333bc4cbb78))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/error:** upgraded to 4.6.1
11
+
1
12
  ## @visulima/pail [2.1.27](https://github.com/visulima/visulima/compare/@visulima/pail@2.1.26...@visulima/pail@2.1.27) (2025-09-12)
2
13
 
3
14
  ### Miscellaneous Chores
@@ -1,19 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const pail_browser = require('./packem_shared/pail.browser-O53Q_cus.cjs');
6
- const MessageFormatterProcessor = require('./packem_shared/MessageFormatterProcessor-t4t6CpzV.cjs');
7
- const JsonReporter = require('./packem_shared/JsonReporter-Cg5R1FXn.cjs');
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- const createPail = /* @__PURE__ */ __name((options) => new pail_browser.PailBrowser({
12
- processors: [new MessageFormatterProcessor()],
13
- reporters: [new JsonReporter()],
14
- ...options
15
- }), "createPail");
16
- const pail = createPail();
17
-
18
- exports.createPail = createPail;
19
- exports.pail = pail;
1
+ "use strict";var o=Object.defineProperty;var t=(e,r)=>o(e,"name",{value:r,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./packem_shared/pail.browser-DC6QwLTj.cjs"),i=require("./packem_shared/MessageFormatterProcessor-CCRIUIdT.cjs"),l=require("./packem_shared/JsonReporter-CjvkrXUp.cjs");var u=Object.defineProperty,c=t((e,r)=>u(e,"name",{value:r,configurable:!0}),"e");const a=c(e=>new s.P({processors:[new i],reporters:[new l],...e}),"createPail"),n=a();exports.createPail=a;exports.pail=n;
@@ -1,14 +1 @@
1
- import { P as PailBrowser } from './packem_shared/pail.browser-Bp1fz428.mjs';
2
- import MessageFormatterProcessor from './packem_shared/MessageFormatterProcessor-Cd4HntPG.mjs';
3
- import JsonReporter from './packem_shared/JsonReporter-CKWF4Ibl.mjs';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const createPail = /* @__PURE__ */ __name((options) => new PailBrowser({
8
- processors: [new MessageFormatterProcessor()],
9
- reporters: [new JsonReporter()],
10
- ...options
11
- }), "createPail");
12
- const pail = createPail();
13
-
14
- export { createPail, pail };
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-DkNIDzgk.mjs";import p from"./packem_shared/MessageFormatterProcessor-BjBZzL2D.mjs";import i from"./packem_shared/JsonReporter-BdExg5gk.mjs";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};
@@ -1,442 +1,5 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const process$1 = require('node:process');
6
- const formatLabel = require('./packem_shared/format-label-DYEhjrTZ.cjs');
7
- const node_string_decoder = require('node:string_decoder');
8
- const pail_browser = require('./packem_shared/pail.browser-O53Q_cus.cjs');
9
- const inspector = require('@visulima/inspector');
10
- const constants = require('./packem_shared/constants-DHfYGxxG.cjs');
11
- const writeStream = require('./packem_shared/write-stream-CkNf2Ju8.cjs');
12
- const MessageFormatterProcessor = require('./packem_shared/MessageFormatterProcessor-t4t6CpzV.cjs');
13
- const PrettyReporter = require('./packem_shared/PrettyReporter-3oMWkX6j.cjs');
14
-
15
- var __defProp$5 = Object.defineProperty;
16
- var __name$5 = (target, value) => __defProp$5(target, "name", { value, configurable: true });
17
- class InteractiveManager {
18
- static {
19
- __name$5(this, "InteractiveManager");
20
- }
21
- #stream;
22
- #isActive = false;
23
- #isSuspended = false;
24
- #lastLength = 0;
25
- #outside = 0;
26
- constructor(stdout, stderr) {
27
- this.#stream = {
28
- stderr,
29
- stdout
30
- };
31
- }
32
- /**
33
- * Last printed rows count
34
- */
35
- get lastLength() {
36
- return this.#lastLength;
37
- }
38
- /**
39
- * Rows count outside editable area
40
- */
41
- get outside() {
42
- return this.#outside;
43
- }
44
- /**
45
- * Hook activity status
46
- */
47
- get isHooked() {
48
- return this.#isActive;
49
- }
50
- /**
51
- * Suspend status for active hooks
52
- */
53
- get isSuspended() {
54
- return this.#isSuspended;
55
- }
56
- /**
57
- * Removes from the bottom of output up the specified count of lines
58
- *
59
- * @param stream - Stream to remove lines from
60
- * @param count - lines count to remove
61
- */
62
- erase(stream, count = this.#lastLength) {
63
- if (this.#stream[stream] === void 0) {
64
- throw new TypeError(`Stream "${stream}" is not available`);
65
- }
66
- this.#stream[stream].erase(count);
67
- }
68
- /**
69
- * Hook stdout and stderr streams
70
- * @returns Success status
71
- */
72
- hook() {
73
- if (!this.#isActive) {
74
- Object.values(this.#stream).forEach((hook) => hook.active());
75
- this._clear(true);
76
- }
77
- return this.#isActive;
78
- }
79
- /**
80
- * Resume suspend hooks
81
- *
82
- * @param stream - Stream to resume
83
- * @param eraseRowCount - erase output rows count
84
- */
85
- resume(stream, eraseRowCount) {
86
- if (this.#isSuspended) {
87
- this.#isSuspended = false;
88
- if (eraseRowCount) {
89
- this.erase(stream, eraseRowCount);
90
- }
91
- this.#lastLength = 0;
92
- Object.values(this.#stream).forEach((hook) => hook.active());
93
- }
94
- }
95
- /**
96
- * Suspend active hooks for external output
97
- *
98
- * @param stream - Stream to suspend
99
- * @param erase - erase output
100
- */
101
- suspend(stream, erase = true) {
102
- if (!this.#isSuspended) {
103
- this.#isSuspended = true;
104
- if (erase) {
105
- this.erase(stream);
106
- }
107
- Object.values(this.#stream).forEach((hook) => hook.renew());
108
- }
109
- }
110
- /**
111
- * Unhooks both stdout and stderr streams and print their story of logs
112
- *
113
- * @param separateHistory - If `true`, will add an empty line to the history output for individual recorded lines and console logs
114
- *
115
- * @returns Success status
116
- */
117
- unhook(separateHistory = true) {
118
- if (this.#isActive) {
119
- Object.values(this.#stream).forEach((hook) => hook.inactive(separateHistory));
120
- this._clear();
121
- }
122
- return !this.#isActive;
123
- }
124
- /**
125
- * Update output
126
- *
127
- * @param stream - Stream to write to
128
- * @param rows - Text lines to write to standard output
129
- * @param from - Index of the line starting from which the contents of the terminal are being overwritten
130
- */
131
- update(stream, rows, from = 0) {
132
- if (rows.length > 0) {
133
- if (this.#stream[stream] === void 0) {
134
- throw new TypeError(`Stream "${stream}" is not available`);
135
- }
136
- const hook = this.#stream[stream];
137
- const { columns: width, rows: height } = formatLabel.terminalSize();
138
- const position = from > height ? height - 1 : Math.max(0, Math.min(height - 1, from));
139
- const actualLength = this.lastLength - position;
140
- const outside = Math.max(actualLength - height, this.outside);
141
- let output = rows.reduce(
142
- (accumulator, row) => [
143
- ...accumulator,
144
- formatLabel.wrapAnsi(row, width, {
145
- hard: true,
146
- trim: false,
147
- wordWrap: true
148
- })
149
- ],
150
- []
151
- );
152
- if (height <= actualLength) {
153
- hook.erase(height);
154
- if (position < outside) {
155
- output = output.slice(outside - position + 1);
156
- }
157
- } else if (actualLength) {
158
- hook.erase(actualLength);
159
- }
160
- hook.write(output.join("\n") + "\n");
161
- this.#lastLength = outside ? outside + output.length + 1 : output.length;
162
- this.#outside = Math.max(this.lastLength - height, this.outside);
163
- }
164
- }
165
- _clear(status = false) {
166
- this.#isActive = status;
167
- this.#lastLength = 0;
168
- this.#outside = 0;
169
- }
170
- }
171
-
172
- var __defProp$4 = Object.defineProperty;
173
- var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
174
- const ESC = "\x1B[";
175
- const eraseScreen = ESC + "2J";
176
- const eraseLine = ESC + "2K";
177
- const cursorLeft = ESC + "G";
178
- const cursorUp = /* @__PURE__ */ __name$4((count = 1) => ESC + count + "A", "cursorUp");
179
- const clearTerminal = process.platform === "win32" ? `${eraseScreen}${ESC}0f` : (
180
- // 1. Erases the screen (Only done in case `2` is not supported)
181
- // 2. Erases the whole screen including scrollback buffer
182
- // 3. Moves cursor to the top-left position
183
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
184
- `${eraseScreen}${ESC}3J${ESC}H`
185
- );
186
- const cursorHide = ESC + "?25l";
187
- const cursorShow = ESC + "?25h";
188
- const eraseLines = /* @__PURE__ */ __name$4((count) => {
189
- let clear = "";
190
- for (let index = 0; index < count; index++) {
191
- clear += eraseLine + (index < count - 1 ? cursorUp() : "");
192
- }
193
- if (count) {
194
- clear += cursorLeft;
195
- }
196
- return clear;
197
- }, "eraseLines");
198
-
199
- var __defProp$3 = Object.defineProperty;
200
- var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
201
- class InteractiveStreamHook {
202
- static {
203
- __name$3(this, "InteractiveStreamHook");
204
- }
205
- static DRAIN = true;
206
- #decoder = new node_string_decoder.StringDecoder();
207
- #history = [];
208
- #method;
209
- #stream;
210
- constructor(stream) {
211
- this.#method = stream.write;
212
- this.#stream = stream;
213
- }
214
- active() {
215
- this.write(cursorHide);
216
- this.#stream.write = (data, ...arguments_) => {
217
- const callback = arguments_.at(-1);
218
- this.#history.push(
219
- this.#decoder.write(
220
- typeof data === "string" ? Buffer.from(data, typeof arguments_[0] === "string" ? arguments_[0] : void 0) : Buffer.from(data)
221
- )
222
- );
223
- if (typeof callback === "function") {
224
- callback();
225
- }
226
- return InteractiveStreamHook.DRAIN;
227
- };
228
- }
229
- erase(count) {
230
- if (count > 0) {
231
- this.write(eraseLines(count + 1));
232
- }
233
- }
234
- inactive(separateHistory = false) {
235
- if (this.#history.length > 0) {
236
- if (separateHistory) {
237
- this.write("\n");
238
- }
239
- this.#history.forEach((element) => {
240
- this.write(element);
241
- });
242
- this.#history = [];
243
- }
244
- this.renew();
245
- }
246
- renew() {
247
- this.#stream.write = this.#method;
248
- this.write(cursorShow);
249
- }
250
- write(message) {
251
- this.#method.apply(this.#stream, [message]);
252
- }
253
- }
254
-
255
- var __defProp$2 = Object.defineProperty;
256
- var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
257
- class RawReporter {
258
- static {
259
- __name$2(this, "RawReporter");
260
- }
261
- #stdout;
262
- #stderr;
263
- #interactiveManager;
264
- #interactive = false;
265
- #inspectOptions;
266
- constructor(inspectOptions = {}) {
267
- this.#stdout = process$1.stdout;
268
- this.#stderr = process$1.stderr;
269
- this.#inspectOptions = inspectOptions;
270
- }
271
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
272
- setStdout(stdout_) {
273
- this.#stdout = stdout_;
274
- }
275
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
276
- setStderr(stderr_) {
277
- this.#stderr = stderr_;
278
- }
279
- setInteractiveManager(manager) {
280
- this.#interactiveManager = manager;
281
- }
282
- setIsInteractive(interactive) {
283
- this.#interactive = interactive;
284
- }
285
- log(meta) {
286
- const { context, groups, message, type } = meta;
287
- const items = [];
288
- if (message !== constants.EMPTY_SYMBOL) {
289
- const formattedMessage = typeof message === "string" ? message : inspector.inspect(message, this.#inspectOptions);
290
- items.push(formattedMessage);
291
- }
292
- if (context) {
293
- items.push(
294
- ...context.map((value) => {
295
- if (typeof value === "object") {
296
- return " " + inspector.inspect(value, this.#inspectOptions);
297
- }
298
- return " " + value;
299
- })
300
- );
301
- }
302
- const streamType = ["error", "trace", "warn"].includes(type.level) ? "stderr" : "stdout";
303
- const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
304
- const groupSpaces = groups.map(() => " ").join("");
305
- if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
306
- this.#interactiveManager.update(streamType, (groupSpaces + items.join("")).split("\n"), 0);
307
- } else {
308
- writeStream.writeStream(groupSpaces + items.join(""), stream);
309
- }
310
- }
311
- }
312
-
313
- var __defProp$1 = Object.defineProperty;
314
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
315
- class PailServerImpl extends pail_browser.PailBrowserImpl {
316
- constructor(options) {
317
- const { interactive, rawReporter, reporters, stderr, stdout, ...rest } = options;
318
- super(rest);
319
- this.options = options;
320
- this.interactive = interactive ?? false;
321
- this.stdout = stdout;
322
- this.stderr = stderr;
323
- if (this.interactive) {
324
- this.interactiveManager = new InteractiveManager(new InteractiveStreamHook(this.stdout), new InteractiveStreamHook(this.stderr));
325
- }
326
- if (Array.isArray(reporters)) {
327
- this.registerReporters(reporters);
328
- }
329
- this.rawReporter = this.extendReporter(options.rawReporter ?? new RawReporter());
330
- }
331
- static {
332
- __name$1(this, "PailServerImpl");
333
- }
334
- stdout;
335
- stderr;
336
- interactiveManager;
337
- interactive;
338
- // @ts-expect-error - this returns a different type
339
- scope(...name) {
340
- if (name.length === 0) {
341
- throw new Error("No scope name was defined.");
342
- }
343
- this.scopeName = name.flat();
344
- return this;
345
- }
346
- getInteractiveManager() {
347
- return this.interactiveManager;
348
- }
349
- wrapStd() {
350
- this._wrapStream(this.stdout, "log");
351
- this._wrapStream(this.stderr, "log");
352
- }
353
- restoreStd() {
354
- this._restoreStream(this.stdout);
355
- this._restoreStream(this.stderr);
356
- }
357
- wrapAll() {
358
- this.wrapConsole();
359
- this.wrapStd();
360
- }
361
- restoreAll() {
362
- this.restoreConsole();
363
- this.restoreStd();
364
- }
365
- clear() {
366
- this.stdout.write(clearTerminal);
367
- this.stderr.write(clearTerminal);
368
- }
369
- extendReporter(reporter) {
370
- if (typeof reporter.setStdout === "function") {
371
- reporter.setStdout(this.stdout);
372
- }
373
- if (typeof reporter.setStderr === "function") {
374
- reporter.setStderr(this.stderr);
375
- }
376
- if (typeof reporter.setLoggerTypes === "function") {
377
- reporter.setLoggerTypes(this.types);
378
- }
379
- if (typeof reporter.setStringify === "function") {
380
- reporter.setStringify(this.stringify);
381
- }
382
- if (typeof reporter.setIsInteractive === "function") {
383
- reporter.setIsInteractive(this.interactive);
384
- }
385
- if (this.interactive && typeof reporter.setInteractiveManager === "function") {
386
- reporter.setInteractiveManager(this.interactiveManager);
387
- }
388
- return reporter;
389
- }
390
- _wrapStream(stream, type) {
391
- if (!stream) {
392
- return;
393
- }
394
- if (!stream.__write) {
395
- stream.__write = stream.write;
396
- }
397
- stream.write = (data) => {
398
- this[type](String(data).trim());
399
- };
400
- }
401
- // eslint-disable-next-line class-methods-use-this
402
- _restoreStream(stream) {
403
- if (!stream) {
404
- return;
405
- }
406
- if (stream.__write) {
407
- stream.write = stream.__write;
408
- delete stream.__write;
409
- }
410
- }
411
- }
412
- const PailServer = PailServerImpl;
413
-
414
- var __defProp = Object.defineProperty;
415
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
416
- const _getDefaultLogLevel = /* @__PURE__ */ __name(() => {
417
- if (process$1.env.NODE_ENV === "debug" || process$1.env.DEBUG !== void 0) {
418
- return "debug";
419
- }
420
- if (process$1.env.NODE_ENV === "test") {
421
- return "warning";
422
- }
423
- return "informational";
424
- }, "_getDefaultLogLevel");
425
- const createPail = /* @__PURE__ */ __name((options) => {
426
- let logLevel = _getDefaultLogLevel();
427
- if (process$1.env.PAIL_LOG_LEVEL !== void 0) {
428
- logLevel = process$1.env.PAIL_LOG_LEVEL;
429
- }
430
- return new PailServer({
431
- logLevel,
432
- processors: [new MessageFormatterProcessor()],
433
- reporters: [new PrettyReporter.PrettyReporter()],
434
- stderr: process$1.stderr,
435
- stdout: process$1.stdout,
436
- ...options
437
- });
438
- }, "createPail");
439
- const pail = createPail();
440
-
441
- exports.createPail = createPail;
442
- exports.pail = pail;
1
+ "use strict";var E=Object.defineProperty;var n=(r,t)=>E(r,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("node:process"),f=require("./packem_shared/format-label-CKRxcWAQ.cjs"),$=require("node:string_decoder"),I=require("./packem_shared/pail.browser-DC6QwLTj.cjs"),w=require("@visulima/inspector"),P=require("./packem_shared/constants-BFrKdBPm.cjs"),j=require("./packem_shared/write-stream-Dl-usQqh.cjs"),M=require("./packem_shared/MessageFormatterProcessor-CCRIUIdT.cjs"),O=require("./packem_shared/PrettyReporter-Dx1OfdGj.cjs");var R=Object.defineProperty,q=n((r,t)=>R(r,"name",{value:t,configurable:!0}),"l$1");let A=class{static{n(this,"v")}static{q(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._clear(!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._clear()),!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}=f.O(),u=s>i?i-1:Math.max(0,Math.min(i-1,s)),l=this.lastLength-u,d=Math.max(l-i,this.outside);let o=e.reduce((b,L)=>[...b,f.T(L,p,{hard:!0,trim:!1,wordWrap:!0})],[]);i<=l?(a.erase(i),u<d&&(o=o.slice(d-u+1))):l&&a.erase(l),a.write(o.join(`
2
+ `)+`
3
+ `),this.#s=d?d+o.length+1:o.length,this.#i=Math.max(this.lastLength-i,this.outside)}}_clear(t=!1){this.#e=t,this.#s=0,this.#i=0}};var T=Object.defineProperty,y=n((r,t)=>T(r,"name",{value:t,configurable:!0}),"n$1");const c="\x1B[",g=c+"2J",x=c+"2K",N=c+"G",D=y((r=1)=>c+r+"A","cursorUp"),m=process.platform==="win32"?`${g}${c}0f`:`${g}${c}3J${c}H`,k=c+"?25l",B=c+"?25h",G=y(r=>{let t="";for(let e=0;e<r;e++)t+=x+(e<r-1?D():"");return r&&(t+=N),t},"eraseLines");var H=Object.defineProperty,V=n((r,t)=>H(r,"name",{value:t,configurable:!0}),"s$1");class v{static{n(this,"t")}static{V(this,"InteractiveStreamHook")}static DRAIN=!0;#t=new $.StringDecoder;#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(),v.DRAIN}}erase(t){t>0&&this.write(G(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(B)}write(t){this.#r.apply(this.#s,[t])}}var C=Object.defineProperty,J=n((r,t)=>C(r,"name",{value:t,configurable:!0}),"c");let U=class{static{n(this,"v")}static{J(this,"RawReporter")}#t;#e;#r;#s=!1;#i;constructor(t={}){this.#t=h.stdout,this.#e=h.stderr,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!==P.E){const o=typeof a=="string"?a:w.inspect(a,this.#i);i.push(o)}e&&i.push(...e.map(o=>typeof o=="object"?" "+w.inspect(o,this.#i):" "+o));const u=["error","trace","warn"].includes(p.level)?"stderr":"stdout",l=u==="stderr"?this.#e:this.#t,d=s.map(()=>" ").join("");this.#s&&this.#r!==void 0&&l.isTTY?this.#r.update(u,(d+i.join("")).split(`
5
+ `),0):j.n(d+i.join(""),l)}};var F=Object.defineProperty,K=n((r,t)=>F(r,"name",{value:t,configurable:!0}),"a$1");class W extends I.a{static{n(this,"v")}constructor(t){const{interactive:e,rawReporter:s,reporters:a,stderr:p,stdout:i,...u}=t;super(u),this.options=t,this.interactive=e??!1,this.stdout=i,this.stderr=p,this.interactive&&(this.interactiveManager=new A(new v(this.stdout),new v(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(t.rawReporter??new U)}static{K(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._wrapStream(this.stdout,"log"),this._wrapStream(this.stderr,"log")}restoreStd(){this._restoreStream(this.stdout),this._restoreStream(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout.write(m),this.stderr.write(m)}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}_wrapStream(t,e){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[e](String(s).trim())})}_restoreStream(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}}const Y=W;var z=Object.defineProperty,S=n((r,t)=>z(r,"name",{value:t,configurable:!0}),"o");const Q=S(()=>h.env.NODE_ENV==="debug"||h.env.DEBUG!==void 0?"debug":h.env.NODE_ENV==="test"?"warning":"informational","_getDefaultLogLevel"),_=S(r=>{let t=Q();return h.env.PAIL_LOG_LEVEL!==void 0&&(t=h.env.PAIL_LOG_LEVEL),new Y({logLevel:t,processors:[new M],reporters:[new O.PrettyReporter],stderr:h.stderr,stdout:h.stdout,...r})},"createPail"),X=_();exports.createPail=_;exports.pail=X;