@visulima/pail 4.0.0-alpha.10 → 4.0.0-alpha.11
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 +40 -0
- package/LICENSE.md +0 -46
- package/dist/index.browser.js +1 -1
- package/dist/index.server.d.ts +0 -4
- package/dist/index.server.js +23 -407
- package/dist/middleware/elysia.js +2 -2
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.js +2 -2
- package/dist/middleware/next/handler.d.ts +1 -1
- package/dist/middleware/next/middleware.d.ts +1 -1
- package/dist/packem_shared/{AbstractJsonReporter-DlugSJpY.js → AbstractJsonReporter-BO8Calb4.js} +1 -5
- package/dist/packem_shared/{AbstractJsonReporter-CjtVgHbU.js → AbstractJsonReporter-nOj0Ft1F.js} +1 -5
- package/dist/packem_shared/{JsonReporter-Dbw82ewj.js → JsonReporter-CCmj7oYL.js} +1 -1
- package/dist/packem_shared/{JsonReporter-BgPvIyC2.js → JsonReporter-Ck2PIAEw.js} +2 -2
- package/dist/packem_shared/{PrettyReporter-gMqa7j_m.js → PrettyReporter-BCvyNzXO.js} +1239 -7
- package/dist/packem_shared/{PrettyReporter-C2dCzIaf.js → PrettyReporter-BtTr13Ha.js} +1 -3
- package/dist/packem_shared/{abstract-pretty-reporter-szQO-IgK.js → abstract-pretty-reporter-CXAKYCb8.js} +2296 -2296
- package/dist/packem_shared/{write-stream-BuFtjATz.js → write-stream-MDqyXmc_.js} +1 -1
- package/dist/pail.server.d.ts +1 -76
- package/dist/processor/caller/caller-processor.js +1 -1
- package/dist/processor/environment-processor.js +10 -3
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.js +1 -1
- package/dist/reporter/http/http-reporter.edge-light.js +1 -5
- package/dist/reporter/json/index.browser.js +2 -2
- package/dist/reporter/json/index.js +2 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +1 -1
- package/dist/reporter/raw/raw-reporter.server.d.ts +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +1 -1
- package/dist/reporter/simple/simple-reporter.server.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/write-console-log-based-on-level.d.ts +1 -1
- package/dist/wide-event.d.ts +1 -1
- package/dist/wide-event.js +3 -2
- package/package.json +6 -17
- package/dist/interactive/index.d.ts +0 -2
- package/dist/interactive/index.js +0 -2
- package/dist/interactive/interactive-manager.d.ts +0 -108
- package/dist/interactive/interactive-stream-hook.d.ts +0 -68
- package/dist/packem_shared/InteractiveManager-CowYA3Hx.js +0 -178
- package/dist/packem_shared/InteractiveStreamHook-BypRlYTX.js +0 -133
- package/dist/packem_shared/Spinner-Cokext9b.js +0 -2183
- package/dist/packem_shared/getBarChar-D7JfmdTr.js +0 -459
- package/dist/packem_shared/index-BEfVUy9P.js +0 -1256
- package/dist/progress-bar.d.ts +0 -145
- package/dist/progress-bar.js +0 -459
- package/dist/spinner.d.ts +0 -220
- package/dist/spinner.js +0 -2183
- package/dist/utils/ansi-escapes.d.ts +0 -4
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { t as terminalSize, w as wordWrap, W as WrapMode } from './index-BEfVUy9P.js';
|
|
2
|
-
|
|
3
|
-
class InteractiveManager {
|
|
4
|
-
#stream;
|
|
5
|
-
#isActive = false;
|
|
6
|
-
#isSuspended = false;
|
|
7
|
-
#lastLength = 0;
|
|
8
|
-
#outside = 0;
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new InteractiveManager with the given stream hooks.
|
|
11
|
-
* @param stdout Hook for stdout stream
|
|
12
|
-
* @param stderr Hook for stderr stream
|
|
13
|
-
*/
|
|
14
|
-
constructor(stdout, stderr) {
|
|
15
|
-
this.#stream = {
|
|
16
|
-
stderr,
|
|
17
|
-
stdout
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Last printed rows count.
|
|
22
|
-
*
|
|
23
|
-
* Tracks the number of rows that were last written to the terminal.
|
|
24
|
-
* Used internally for managing cursor positioning and output updates.
|
|
25
|
-
*/
|
|
26
|
-
get lastLength() {
|
|
27
|
-
return this.#lastLength;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Rows count outside editable area.
|
|
31
|
-
*
|
|
32
|
-
* Tracks the number of rows that extend beyond the current terminal height.
|
|
33
|
-
* Used for managing scrolling and ensuring all output remains visible.
|
|
34
|
-
*/
|
|
35
|
-
get outside() {
|
|
36
|
-
return this.#outside;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Hook activity status.
|
|
40
|
-
*
|
|
41
|
-
* Indicates whether the interactive hooks are currently active.
|
|
42
|
-
* When true, streams are being intercepted for interactive output.
|
|
43
|
-
*/
|
|
44
|
-
get isHooked() {
|
|
45
|
-
return this.#isActive;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Suspend status for active hooks.
|
|
49
|
-
*
|
|
50
|
-
* Indicates whether interactive mode is temporarily suspended.
|
|
51
|
-
* When suspended, external output can be written without interference.
|
|
52
|
-
*/
|
|
53
|
-
get isSuspended() {
|
|
54
|
-
return this.#isSuspended;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Removes lines from the terminal output.
|
|
58
|
-
*
|
|
59
|
-
* Erases the specified number of lines from the bottom of the output,
|
|
60
|
-
* moving the cursor up and clearing the lines. Useful for removing
|
|
61
|
-
* previous interactive output before displaying new content.
|
|
62
|
-
* @param stream The stream to erase lines from ("stdout" or "stderr")
|
|
63
|
-
* @param count Number of lines to remove (defaults to lastLength)
|
|
64
|
-
* @throws {TypeError} If the specified stream is not available
|
|
65
|
-
*/
|
|
66
|
-
erase(stream, count = this.#lastLength) {
|
|
67
|
-
this.#stream[stream].erase(count);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Hook stdout and stderr streams.
|
|
71
|
-
* @returns Success status
|
|
72
|
-
*/
|
|
73
|
-
hook() {
|
|
74
|
-
if (!this.#isActive) {
|
|
75
|
-
const hooks = Object.values(this.#stream);
|
|
76
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
77
|
-
hooks[i].active();
|
|
78
|
-
}
|
|
79
|
-
this.#clear(true);
|
|
80
|
-
}
|
|
81
|
-
return this.#isActive;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Resume suspend hooks.
|
|
85
|
-
* @param stream Stream to resume
|
|
86
|
-
* @param eraseRowCount erase output rows count
|
|
87
|
-
*/
|
|
88
|
-
resume(stream, eraseRowCount) {
|
|
89
|
-
if (this.#isSuspended) {
|
|
90
|
-
this.#isSuspended = false;
|
|
91
|
-
if (eraseRowCount) {
|
|
92
|
-
this.erase(stream, eraseRowCount);
|
|
93
|
-
}
|
|
94
|
-
this.#lastLength = 0;
|
|
95
|
-
const hooks = Object.values(this.#stream);
|
|
96
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
97
|
-
hooks[i].active();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Suspend active hooks for external output.
|
|
103
|
-
* @param stream Stream to suspend
|
|
104
|
-
* @param erase erase output
|
|
105
|
-
*/
|
|
106
|
-
suspend(stream, erase = true) {
|
|
107
|
-
if (!this.#isSuspended) {
|
|
108
|
-
this.#isSuspended = true;
|
|
109
|
-
if (erase) {
|
|
110
|
-
this.erase(stream);
|
|
111
|
-
}
|
|
112
|
-
const hooks = Object.values(this.#stream);
|
|
113
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
114
|
-
hooks[i].renew();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Unhooks both stdout and stderr streams and print their story of logs.
|
|
120
|
-
* @param separateHistory If `true`, will add an empty line to the history output for individual recorded lines and console logs
|
|
121
|
-
* @returns Success status
|
|
122
|
-
*/
|
|
123
|
-
unhook(separateHistory = true) {
|
|
124
|
-
if (this.#isActive) {
|
|
125
|
-
const hooks = Object.values(this.#stream);
|
|
126
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
127
|
-
hooks[i].inactive(separateHistory);
|
|
128
|
-
}
|
|
129
|
-
this.#clear();
|
|
130
|
-
}
|
|
131
|
-
return !this.#isActive;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Update output.
|
|
135
|
-
* @param stream Stream to write to
|
|
136
|
-
* @param rows Text lines to write to standard output
|
|
137
|
-
* @param from Index of the line starting from which the contents of the terminal are being overwritten
|
|
138
|
-
*/
|
|
139
|
-
update(stream, rows, from = 0) {
|
|
140
|
-
if (rows.length > 0) {
|
|
141
|
-
const hook = this.#stream[stream];
|
|
142
|
-
const { columns: width, rows: height } = terminalSize();
|
|
143
|
-
const position = from > height ? height - 1 : Math.max(0, Math.min(height - 1, from));
|
|
144
|
-
const actualLength = this.lastLength - position;
|
|
145
|
-
const outside = Math.max(actualLength - height, this.outside);
|
|
146
|
-
let output = rows.reduce(
|
|
147
|
-
(accumulator, row) => [
|
|
148
|
-
...accumulator,
|
|
149
|
-
wordWrap(row, {
|
|
150
|
-
trim: false,
|
|
151
|
-
width,
|
|
152
|
-
wrapMode: WrapMode.STRICT_WIDTH
|
|
153
|
-
})
|
|
154
|
-
],
|
|
155
|
-
[]
|
|
156
|
-
);
|
|
157
|
-
if (height <= actualLength) {
|
|
158
|
-
hook.erase(height);
|
|
159
|
-
if (position < outside) {
|
|
160
|
-
output = output.slice(outside - position + 1);
|
|
161
|
-
}
|
|
162
|
-
} else if (actualLength) {
|
|
163
|
-
hook.erase(actualLength);
|
|
164
|
-
}
|
|
165
|
-
hook.write(`${output.join("\n")}
|
|
166
|
-
`);
|
|
167
|
-
this.#lastLength = outside ? outside + output.length + 1 : output.length;
|
|
168
|
-
this.#outside = Math.max(this.lastLength - height, this.outside);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
#clear(status = false) {
|
|
172
|
-
this.#isActive = status;
|
|
173
|
-
this.#lastLength = 0;
|
|
174
|
-
this.#outside = 0;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export { InteractiveManager as default };
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
StringDecoder
|
|
22
|
-
} = __cjs_getBuiltinModule("node:string_decoder");
|
|
23
|
-
|
|
24
|
-
const ESC = "\x1B[";
|
|
25
|
-
const eraseLine = `${ESC}2K`;
|
|
26
|
-
const cursorLeft = `${ESC}G`;
|
|
27
|
-
const cursorUp = (count = 1) => `${ESC}${String(count)}A`;
|
|
28
|
-
const cursorHide = `${ESC}?25l`;
|
|
29
|
-
const cursorShow = `${ESC}?25h`;
|
|
30
|
-
const eraseLines = (count) => {
|
|
31
|
-
let clear = "";
|
|
32
|
-
for (let index = 0; index < count; index++) {
|
|
33
|
-
clear += eraseLine + (index < count - 1 ? cursorUp() : "");
|
|
34
|
-
}
|
|
35
|
-
if (count) {
|
|
36
|
-
clear += cursorLeft;
|
|
37
|
-
}
|
|
38
|
-
return clear;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
class InteractiveStreamHook {
|
|
42
|
-
/** Constant indicating the stream write operation was successful */
|
|
43
|
-
static DRAIN = true;
|
|
44
|
-
#decoder = new StringDecoder();
|
|
45
|
-
#history = [];
|
|
46
|
-
#method;
|
|
47
|
-
#stream;
|
|
48
|
-
/**
|
|
49
|
-
* Creates a new InteractiveStreamHook for the given stream.
|
|
50
|
-
* @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
|
|
51
|
-
*/
|
|
52
|
-
constructor(stream) {
|
|
53
|
-
this.#method = stream.write.bind(stream);
|
|
54
|
-
this.#stream = stream;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Activates the stream hook.
|
|
58
|
-
*
|
|
59
|
-
* When active, all writes to the stream are captured in history instead of
|
|
60
|
-
* being written immediately. This allows for interactive features like
|
|
61
|
-
* progress bars that can update dynamically.
|
|
62
|
-
*/
|
|
63
|
-
active() {
|
|
64
|
-
this.write(cursorHide);
|
|
65
|
-
this.#stream.write = (data, ...arguments_) => {
|
|
66
|
-
const callback = arguments_.at(-1);
|
|
67
|
-
this.#history.push(
|
|
68
|
-
// prettier-ignore
|
|
69
|
-
this.#decoder.write(
|
|
70
|
-
typeof data === "string" ? Buffer.from(data, typeof arguments_[0] === "string" ? arguments_[0] : void 0) : Buffer.from(data)
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
if (typeof callback === "function") {
|
|
74
|
-
callback();
|
|
75
|
-
}
|
|
76
|
-
return InteractiveStreamHook.DRAIN;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Erases the specified number of lines from the terminal.
|
|
81
|
-
*
|
|
82
|
-
* Uses ANSI escape sequences to remove lines from the current cursor position
|
|
83
|
-
* upwards, which is useful for clearing previous output in interactive applications.
|
|
84
|
-
* @param count Number of lines to erase (including the current line)
|
|
85
|
-
*/
|
|
86
|
-
erase(count) {
|
|
87
|
-
if (count > 0) {
|
|
88
|
-
this.write(eraseLines(count + 1));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Deactivates the stream hook and replays captured output.
|
|
93
|
-
*
|
|
94
|
-
* Restores normal stream operation and outputs all captured history.
|
|
95
|
-
* Optionally adds a newline separator before replaying the history.
|
|
96
|
-
* @param separateHistory Whether to add a newline before replaying history
|
|
97
|
-
*/
|
|
98
|
-
inactive(separateHistory = false) {
|
|
99
|
-
if (this.#history.length > 0) {
|
|
100
|
-
if (separateHistory) {
|
|
101
|
-
this.write("\n");
|
|
102
|
-
}
|
|
103
|
-
this.#history.forEach((element) => {
|
|
104
|
-
this.write(element);
|
|
105
|
-
});
|
|
106
|
-
this.#history = [];
|
|
107
|
-
}
|
|
108
|
-
this.renew();
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Renews the stream hook state.
|
|
112
|
-
*
|
|
113
|
-
* Restores the original stream write method and shows the cursor.
|
|
114
|
-
* This is typically called when temporarily suspending interactive mode.
|
|
115
|
-
*/
|
|
116
|
-
renew() {
|
|
117
|
-
this.#stream.write = this.#method;
|
|
118
|
-
this.write(cursorShow);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Writes a message directly to the underlying stream.
|
|
122
|
-
*
|
|
123
|
-
* Bypasses the hook mechanism and writes directly using the original
|
|
124
|
-
* stream write method. Useful for writing control sequences or
|
|
125
|
-
* messages that should not be captured in history.
|
|
126
|
-
* @param message The message to write to the stream
|
|
127
|
-
*/
|
|
128
|
-
write(message) {
|
|
129
|
-
this.#method.apply(this.#stream, [message]);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { InteractiveStreamHook as default };
|