@visulima/pail 4.0.0-alpha.10 → 4.0.0-alpha.12
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 +57 -0
- package/LICENSE.md +143 -931
- package/dist/error.d.ts +95 -96
- package/dist/index.browser.d.ts +557 -47
- package/dist/index.browser.js +2 -2
- package/dist/index.server.d.ts +722 -65
- package/dist/index.server.js +27 -410
- package/dist/middleware/elysia.d.ts +65 -63
- package/dist/middleware/elysia.js +2 -2
- package/dist/middleware/express.d.ts +73 -71
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +69 -67
- package/dist/middleware/fastify.js +2 -2
- package/dist/middleware/hono.d.ts +74 -72
- package/dist/middleware/next/handler.d.ts +101 -34
- package/dist/middleware/sveltekit.d.ts +100 -98
- package/dist/object-tree.d.ts +67 -70
- 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-C2dCzIaf.js → PrettyReporter-CIbrmjUV.js} +2 -4
- package/dist/packem_shared/{PrettyReporter-gMqa7j_m.js → PrettyReporter-CNJEO9g7.js} +1250 -15
- package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-szQO-IgK.js → abstract-pretty-reporter-CkqCt5hg.js} +2300 -2298
- package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
- package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
- package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
- package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
- package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
- package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
- package/dist/packem_shared/{write-stream-BuFtjATz.js → write-stream-MDqyXmc_.js} +1 -1
- package/dist/processor/caller/caller-processor.d.ts +49 -47
- package/dist/processor/caller/caller-processor.js +1 -1
- package/dist/processor/environment-processor.d.ts +113 -113
- package/dist/processor/message-formatter-processor.d.ts +51 -49
- package/dist/processor/message-formatter-processor.js +2 -2
- package/dist/processor/opentelemetry-processor.d.ts +69 -66
- package/dist/processor/redact-processor.d.ts +60 -41
- package/dist/processor/sampling-processor.d.ts +102 -101
- package/dist/reporter/file/json-file-reporter.d.ts +91 -42
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
- package/dist/reporter/http/abstract-http-reporter.js +1 -1
- package/dist/reporter/http/http-reporter.d.ts +40 -36
- package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
- package/dist/reporter/http/http-reporter.edge-light.js +1 -5
- package/dist/reporter/json/index.browser.d.ts +99 -3
- package/dist/reporter/json/index.browser.js +2 -2
- package/dist/reporter/json/index.d.ts +51 -3
- package/dist/reporter/json/index.js +2 -2
- package/dist/reporter/pretty/index.browser.d.ts +106 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +219 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
- package/dist/reporter/simple/simple-reporter.server.js +3 -2
- package/dist/wide-event.d.ts +5 -300
- package/dist/wide-event.js +3 -2
- package/package.json +9 -21
- package/dist/constants.d.ts +0 -37
- 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/middleware/next/middleware.d.ts +0 -59
- package/dist/middleware/next/storage.d.ts +0 -14
- package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
- package/dist/middleware/shared/headers.d.ts +0 -14
- package/dist/middleware/shared/routes.d.ts +0 -30
- package/dist/middleware/shared/storage.d.ts +0 -29
- 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/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -233
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- package/dist/progress-bar.d.ts +0 -145
- package/dist/progress-bar.js +0 -459
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
- package/dist/reporter/http/utils/compression.d.ts +0 -7
- package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
- package/dist/reporter/http/utils/retry.d.ts +0 -27
- package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
- package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
- package/dist/reporter/json/json-reporter.server.d.ts +0 -50
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
- package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
- package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
- package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
- package/dist/reporter/utils/format-label.d.ts +0 -3
- package/dist/spinner.d.ts +0 -220
- package/dist/spinner.js +0 -2183
- package/dist/types.d.ts +0 -241
- package/dist/utils/ansi-escapes.d.ts +0 -4
- package/dist/utils/arrayify.d.ts +0 -2
- package/dist/utils/get-longest-badge.d.ts +0 -4
- package/dist/utils/get-longest-label.d.ts +0 -4
- package/dist/utils/merge-types.d.ts +0 -4
- package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
- package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
- package/dist/utils/write-stream.d.ts +0 -2
package/dist/index.server.js
CHANGED
|
@@ -4,325 +4,36 @@ const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
|
4
4
|
|
|
5
5
|
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
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
7
|
const {
|
|
21
8
|
stdout,
|
|
22
9
|
stderr,
|
|
23
10
|
env
|
|
24
11
|
} = __cjs_getProcess;
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} = __cjs_getBuiltinModule("node:string_decoder");
|
|
29
|
-
import { ProgressBar, applyStyleToOptions, MultiProgressBar } from './packem_shared/getBarChar-D7JfmdTr.js';
|
|
30
|
-
export { getBarChar } from './packem_shared/getBarChar-D7JfmdTr.js';
|
|
31
|
-
import { Spinner, MultiSpinner } from './packem_shared/Spinner-Cokext9b.js';
|
|
32
|
-
import colorize, { red, greenBright, cyan, green, grey, bgGrey, underline, white } from '@visulima/colorize';
|
|
12
|
+
import { InteractiveManager, InteractiveStreamHook } from '@visulima/interactive-manager';
|
|
13
|
+
import { g as getLongestLabel, E as EXTENDED_RFC_5424_LOG_LEVELS, a as EMPTY_SYMBOL, L as LOG_TYPES, i as inspect, w as writeStream, A as AbstractPrettyReporter, d as defaultInspectorConfig, t as terminalSize, b as getLongestBadge, c as getStringWidth, f as formatLabel, e as wordWrap, r as renderError, W as WrapMode } from './packem_shared/abstract-pretty-reporter-CkqCt5hg.js';
|
|
14
|
+
import colorize from '@visulima/colorize';
|
|
33
15
|
export { PailError, createPailError } from './packem_shared/createPailError-B_sgL0nF.js';
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#isActive = false;
|
|
38
|
-
#isSuspended = false;
|
|
39
|
-
#lastLength = 0;
|
|
40
|
-
#outside = 0;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new InteractiveManager with the given stream hooks.
|
|
43
|
-
* @param stdout Hook for stdout stream
|
|
44
|
-
* @param stderr Hook for stderr stream
|
|
45
|
-
*/
|
|
46
|
-
constructor(stdout, stderr) {
|
|
47
|
-
this.#stream = {
|
|
48
|
-
stderr,
|
|
49
|
-
stdout
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Last printed rows count.
|
|
54
|
-
*
|
|
55
|
-
* Tracks the number of rows that were last written to the terminal.
|
|
56
|
-
* Used internally for managing cursor positioning and output updates.
|
|
57
|
-
*/
|
|
58
|
-
get lastLength() {
|
|
59
|
-
return this.#lastLength;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Rows count outside editable area.
|
|
63
|
-
*
|
|
64
|
-
* Tracks the number of rows that extend beyond the current terminal height.
|
|
65
|
-
* Used for managing scrolling and ensuring all output remains visible.
|
|
66
|
-
*/
|
|
67
|
-
get outside() {
|
|
68
|
-
return this.#outside;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Hook activity status.
|
|
72
|
-
*
|
|
73
|
-
* Indicates whether the interactive hooks are currently active.
|
|
74
|
-
* When true, streams are being intercepted for interactive output.
|
|
75
|
-
*/
|
|
76
|
-
get isHooked() {
|
|
77
|
-
return this.#isActive;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Suspend status for active hooks.
|
|
81
|
-
*
|
|
82
|
-
* Indicates whether interactive mode is temporarily suspended.
|
|
83
|
-
* When suspended, external output can be written without interference.
|
|
84
|
-
*/
|
|
85
|
-
get isSuspended() {
|
|
86
|
-
return this.#isSuspended;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Removes lines from the terminal output.
|
|
90
|
-
*
|
|
91
|
-
* Erases the specified number of lines from the bottom of the output,
|
|
92
|
-
* moving the cursor up and clearing the lines. Useful for removing
|
|
93
|
-
* previous interactive output before displaying new content.
|
|
94
|
-
* @param stream The stream to erase lines from ("stdout" or "stderr")
|
|
95
|
-
* @param count Number of lines to remove (defaults to lastLength)
|
|
96
|
-
* @throws {TypeError} If the specified stream is not available
|
|
97
|
-
*/
|
|
98
|
-
erase(stream, count = this.#lastLength) {
|
|
99
|
-
this.#stream[stream].erase(count);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Hook stdout and stderr streams.
|
|
103
|
-
* @returns Success status
|
|
104
|
-
*/
|
|
105
|
-
hook() {
|
|
106
|
-
if (!this.#isActive) {
|
|
107
|
-
const hooks = Object.values(this.#stream);
|
|
108
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
109
|
-
hooks[i].active();
|
|
110
|
-
}
|
|
111
|
-
this.#clear(true);
|
|
112
|
-
}
|
|
113
|
-
return this.#isActive;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Resume suspend hooks.
|
|
117
|
-
* @param stream Stream to resume
|
|
118
|
-
* @param eraseRowCount erase output rows count
|
|
119
|
-
*/
|
|
120
|
-
resume(stream, eraseRowCount) {
|
|
121
|
-
if (this.#isSuspended) {
|
|
122
|
-
this.#isSuspended = false;
|
|
123
|
-
if (eraseRowCount) {
|
|
124
|
-
this.erase(stream, eraseRowCount);
|
|
125
|
-
}
|
|
126
|
-
this.#lastLength = 0;
|
|
127
|
-
const hooks = Object.values(this.#stream);
|
|
128
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
129
|
-
hooks[i].active();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Suspend active hooks for external output.
|
|
135
|
-
* @param stream Stream to suspend
|
|
136
|
-
* @param erase erase output
|
|
137
|
-
*/
|
|
138
|
-
suspend(stream, erase = true) {
|
|
139
|
-
if (!this.#isSuspended) {
|
|
140
|
-
this.#isSuspended = true;
|
|
141
|
-
if (erase) {
|
|
142
|
-
this.erase(stream);
|
|
143
|
-
}
|
|
144
|
-
const hooks = Object.values(this.#stream);
|
|
145
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
146
|
-
hooks[i].renew();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Unhooks both stdout and stderr streams and print their story of logs.
|
|
152
|
-
* @param separateHistory If `true`, will add an empty line to the history output for individual recorded lines and console logs
|
|
153
|
-
* @returns Success status
|
|
154
|
-
*/
|
|
155
|
-
unhook(separateHistory = true) {
|
|
156
|
-
if (this.#isActive) {
|
|
157
|
-
const hooks = Object.values(this.#stream);
|
|
158
|
-
for (let i = 0; i < hooks.length; i += 1) {
|
|
159
|
-
hooks[i].inactive(separateHistory);
|
|
160
|
-
}
|
|
161
|
-
this.#clear();
|
|
162
|
-
}
|
|
163
|
-
return !this.#isActive;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Update output.
|
|
167
|
-
* @param stream Stream to write to
|
|
168
|
-
* @param rows Text lines to write to standard output
|
|
169
|
-
* @param from Index of the line starting from which the contents of the terminal are being overwritten
|
|
170
|
-
*/
|
|
171
|
-
update(stream, rows, from = 0) {
|
|
172
|
-
if (rows.length > 0) {
|
|
173
|
-
const hook = this.#stream[stream];
|
|
174
|
-
const { columns: width, rows: height } = terminalSize();
|
|
175
|
-
const position = from > height ? height - 1 : Math.max(0, Math.min(height - 1, from));
|
|
176
|
-
const actualLength = this.lastLength - position;
|
|
177
|
-
const outside = Math.max(actualLength - height, this.outside);
|
|
178
|
-
let output = rows.reduce(
|
|
179
|
-
(accumulator, row) => [
|
|
180
|
-
...accumulator,
|
|
181
|
-
wordWrap(row, {
|
|
182
|
-
trim: false,
|
|
183
|
-
width,
|
|
184
|
-
wrapMode: WrapMode.STRICT_WIDTH
|
|
185
|
-
})
|
|
186
|
-
],
|
|
187
|
-
[]
|
|
188
|
-
);
|
|
189
|
-
if (height <= actualLength) {
|
|
190
|
-
hook.erase(height);
|
|
191
|
-
if (position < outside) {
|
|
192
|
-
output = output.slice(outside - position + 1);
|
|
193
|
-
}
|
|
194
|
-
} else if (actualLength) {
|
|
195
|
-
hook.erase(actualLength);
|
|
196
|
-
}
|
|
197
|
-
hook.write(`${output.join("\n")}
|
|
198
|
-
`);
|
|
199
|
-
this.#lastLength = outside ? outside + output.length + 1 : output.length;
|
|
200
|
-
this.#outside = Math.max(this.lastLength - height, this.outside);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
#clear(status = false) {
|
|
204
|
-
this.#isActive = status;
|
|
205
|
-
this.#lastLength = 0;
|
|
206
|
-
this.#outside = 0;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
17
|
+
const ESC = "\x1B";
|
|
18
|
+
const CSI = `${ESC}[`;
|
|
209
19
|
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
)
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const eraseLines = (count) => {
|
|
225
|
-
let clear = "";
|
|
226
|
-
for (let index = 0; index < count; index++) {
|
|
227
|
-
clear += eraseLine + (index < count - 1 ? cursorUp() : "");
|
|
228
|
-
}
|
|
229
|
-
if (count) {
|
|
230
|
-
clear += cursorLeft;
|
|
231
|
-
}
|
|
232
|
-
return clear;
|
|
20
|
+
const isBrowser = typeof globalThis !== "undefined" && typeof globalThis.window === "object" && globalThis.window.document !== void 0;
|
|
21
|
+
const OSTYPE_REGEX = /^(?:msys|cygwin)$/;
|
|
22
|
+
const isWindows = !isBrowser && (process.platform === "win32" || OSTYPE_REGEX.test(process.env.OSTYPE));
|
|
23
|
+
|
|
24
|
+
var EraseDisplayMode = /* @__PURE__ */ ((EraseDisplayMode2) => {
|
|
25
|
+
EraseDisplayMode2[EraseDisplayMode2["ToEnd"] = 0] = "ToEnd";
|
|
26
|
+
EraseDisplayMode2[EraseDisplayMode2["ToBeginning"] = 1] = "ToBeginning";
|
|
27
|
+
EraseDisplayMode2[EraseDisplayMode2["EntireScreen"] = 2] = "EntireScreen";
|
|
28
|
+
EraseDisplayMode2[EraseDisplayMode2["EntireScreenAndScrollback"] = 3] = "EntireScreenAndScrollback";
|
|
29
|
+
return EraseDisplayMode2;
|
|
30
|
+
})(EraseDisplayMode || {});
|
|
31
|
+
const eraseDisplay = (mode) => {
|
|
32
|
+
const validMode = mode >= 0 && mode <= 3 ? mode : 0;
|
|
33
|
+
return `${CSI}${validMode === 0 ? "" : String(validMode)}J`;
|
|
233
34
|
};
|
|
234
35
|
|
|
235
|
-
|
|
236
|
-
/** Constant indicating the stream write operation was successful */
|
|
237
|
-
static DRAIN = true;
|
|
238
|
-
#decoder = new StringDecoder();
|
|
239
|
-
#history = [];
|
|
240
|
-
#method;
|
|
241
|
-
#stream;
|
|
242
|
-
/**
|
|
243
|
-
* Creates a new InteractiveStreamHook for the given stream.
|
|
244
|
-
* @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
|
|
245
|
-
*/
|
|
246
|
-
constructor(stream) {
|
|
247
|
-
this.#method = stream.write.bind(stream);
|
|
248
|
-
this.#stream = stream;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Activates the stream hook.
|
|
252
|
-
*
|
|
253
|
-
* When active, all writes to the stream are captured in history instead of
|
|
254
|
-
* being written immediately. This allows for interactive features like
|
|
255
|
-
* progress bars that can update dynamically.
|
|
256
|
-
*/
|
|
257
|
-
active() {
|
|
258
|
-
this.write(cursorHide);
|
|
259
|
-
this.#stream.write = (data, ...arguments_) => {
|
|
260
|
-
const callback = arguments_.at(-1);
|
|
261
|
-
this.#history.push(
|
|
262
|
-
// prettier-ignore
|
|
263
|
-
this.#decoder.write(
|
|
264
|
-
typeof data === "string" ? Buffer.from(data, typeof arguments_[0] === "string" ? arguments_[0] : void 0) : Buffer.from(data)
|
|
265
|
-
)
|
|
266
|
-
);
|
|
267
|
-
if (typeof callback === "function") {
|
|
268
|
-
callback();
|
|
269
|
-
}
|
|
270
|
-
return InteractiveStreamHook.DRAIN;
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Erases the specified number of lines from the terminal.
|
|
275
|
-
*
|
|
276
|
-
* Uses ANSI escape sequences to remove lines from the current cursor position
|
|
277
|
-
* upwards, which is useful for clearing previous output in interactive applications.
|
|
278
|
-
* @param count Number of lines to erase (including the current line)
|
|
279
|
-
*/
|
|
280
|
-
erase(count) {
|
|
281
|
-
if (count > 0) {
|
|
282
|
-
this.write(eraseLines(count + 1));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Deactivates the stream hook and replays captured output.
|
|
287
|
-
*
|
|
288
|
-
* Restores normal stream operation and outputs all captured history.
|
|
289
|
-
* Optionally adds a newline separator before replaying the history.
|
|
290
|
-
* @param separateHistory Whether to add a newline before replaying history
|
|
291
|
-
*/
|
|
292
|
-
inactive(separateHistory = false) {
|
|
293
|
-
if (this.#history.length > 0) {
|
|
294
|
-
if (separateHistory) {
|
|
295
|
-
this.write("\n");
|
|
296
|
-
}
|
|
297
|
-
this.#history.forEach((element) => {
|
|
298
|
-
this.write(element);
|
|
299
|
-
});
|
|
300
|
-
this.#history = [];
|
|
301
|
-
}
|
|
302
|
-
this.renew();
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Renews the stream hook state.
|
|
306
|
-
*
|
|
307
|
-
* Restores the original stream write method and shows the cursor.
|
|
308
|
-
* This is typically called when temporarily suspending interactive mode.
|
|
309
|
-
*/
|
|
310
|
-
renew() {
|
|
311
|
-
this.#stream.write = this.#method;
|
|
312
|
-
this.write(cursorShow);
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Writes a message directly to the underlying stream.
|
|
316
|
-
*
|
|
317
|
-
* Bypasses the hook mechanism and writes directly using the original
|
|
318
|
-
* stream write method. Useful for writing control sequences or
|
|
319
|
-
* messages that should not be captured in history.
|
|
320
|
-
* @param message The message to write to the stream
|
|
321
|
-
*/
|
|
322
|
-
write(message) {
|
|
323
|
-
this.#method.apply(this.#stream, [message]);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
36
|
+
const resetTerminal = isWindows ? `${eraseDisplay(EraseDisplayMode.EntireScreen)}${CSI}0f` : `${eraseDisplay(EraseDisplayMode.EntireScreen)}${eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)}${CSI}H${ESC}c`;
|
|
326
37
|
|
|
327
38
|
function getDefaultExportFromCjs(x) {
|
|
328
39
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -2086,99 +1797,6 @@ class PailServerImpl extends PailBrowserImpl {
|
|
|
2086
1797
|
this.restoreConsole();
|
|
2087
1798
|
this.restoreStd();
|
|
2088
1799
|
}
|
|
2089
|
-
/**
|
|
2090
|
-
* Creates a single progress bar.
|
|
2091
|
-
* @param options Configuration options for the progress bar
|
|
2092
|
-
* @returns A new ProgressBar instance
|
|
2093
|
-
* @example
|
|
2094
|
-
* ```typescript
|
|
2095
|
-
* const logger = createPail({ interactive: true });
|
|
2096
|
-
* const bar = logger.createProgressBar({
|
|
2097
|
-
* total: 100,
|
|
2098
|
-
* format: 'Downloading [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}'
|
|
2099
|
-
* });
|
|
2100
|
-
*
|
|
2101
|
-
* bar.start();
|
|
2102
|
-
* // ... do work and update progress
|
|
2103
|
-
* bar.update(50);
|
|
2104
|
-
* bar.stop();
|
|
2105
|
-
* ```
|
|
2106
|
-
*/
|
|
2107
|
-
createProgressBar(options) {
|
|
2108
|
-
if (!this.interactiveManager) {
|
|
2109
|
-
throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use progress bars.");
|
|
2110
|
-
}
|
|
2111
|
-
const styledOptions = applyStyleToOptions(options);
|
|
2112
|
-
return new ProgressBar(styledOptions, this.interactiveManager);
|
|
2113
|
-
}
|
|
2114
|
-
/**
|
|
2115
|
-
* Creates a multi-bar progress manager for displaying multiple progress bars.
|
|
2116
|
-
* @param options Configuration options for the multi-bar manager
|
|
2117
|
-
* @returns A new MultiProgressBar instance
|
|
2118
|
-
* @example
|
|
2119
|
-
* ```typescript
|
|
2120
|
-
* const logger = createPail({ interactive: true });
|
|
2121
|
-
* const multiBar = logger.createMultiProgressBar();
|
|
2122
|
-
*
|
|
2123
|
-
* const bar1 = multiBar.create(100);
|
|
2124
|
-
* const bar2 = multiBar.create(200);
|
|
2125
|
-
*
|
|
2126
|
-
* bar1.start();
|
|
2127
|
-
* bar2.start();
|
|
2128
|
-
* // ... update bars as needed
|
|
2129
|
-
* multiBar.stop();
|
|
2130
|
-
* ```
|
|
2131
|
-
*/
|
|
2132
|
-
createMultiProgressBar(options = {}) {
|
|
2133
|
-
if (!this.interactiveManager) {
|
|
2134
|
-
throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use progress bars.");
|
|
2135
|
-
}
|
|
2136
|
-
const styledOptions = applyStyleToOptions(options);
|
|
2137
|
-
return new MultiProgressBar(styledOptions, this.interactiveManager);
|
|
2138
|
-
}
|
|
2139
|
-
/**
|
|
2140
|
-
* Creates a single spinner.
|
|
2141
|
-
* @param options Configuration options for the spinner
|
|
2142
|
-
* @returns A new Spinner instance
|
|
2143
|
-
* @example
|
|
2144
|
-
* ```typescript
|
|
2145
|
-
* const logger = createPail({ interactive: true });
|
|
2146
|
-
* const spinner = logger.createSpinner({ name: 'dots' });
|
|
2147
|
-
* spinner.start('Loading...');
|
|
2148
|
-
* // ... do work
|
|
2149
|
-
* spinner.succeed('Done');
|
|
2150
|
-
* ```
|
|
2151
|
-
*/
|
|
2152
|
-
createSpinner(options = {}) {
|
|
2153
|
-
if (!this.interactiveManager) {
|
|
2154
|
-
throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use spinners.");
|
|
2155
|
-
}
|
|
2156
|
-
return new Spinner(options, this.interactiveManager);
|
|
2157
|
-
}
|
|
2158
|
-
/**
|
|
2159
|
-
* Creates a multi-spinner manager for displaying multiple spinners.
|
|
2160
|
-
* @param options Configuration options for the multi-spinner manager
|
|
2161
|
-
* @returns A new MultiSpinner instance
|
|
2162
|
-
* @example
|
|
2163
|
-
* ```typescript
|
|
2164
|
-
* const logger = createPail({ interactive: true });
|
|
2165
|
-
* const multiSpinner = logger.createMultiSpinner();
|
|
2166
|
-
*
|
|
2167
|
-
* const spinner1 = multiSpinner.create('Loading 1');
|
|
2168
|
-
* const spinner2 = multiSpinner.create('Loading 2');
|
|
2169
|
-
*
|
|
2170
|
-
* spinner1.start();
|
|
2171
|
-
* spinner2.start();
|
|
2172
|
-
* // ... update spinners as needed
|
|
2173
|
-
* multiSpinner.stop();
|
|
2174
|
-
* ```
|
|
2175
|
-
*/
|
|
2176
|
-
createMultiSpinner(options = {}) {
|
|
2177
|
-
if (!this.interactiveManager) {
|
|
2178
|
-
throw new Error("Interactive mode is not enabled. Create Pail with { interactive: true } to use spinners.");
|
|
2179
|
-
}
|
|
2180
|
-
return new MultiSpinner(options, this.interactiveManager);
|
|
2181
|
-
}
|
|
2182
1800
|
/**
|
|
2183
1801
|
* Clears the terminal screen.
|
|
2184
1802
|
*
|
|
@@ -2193,8 +1811,8 @@ class PailServerImpl extends PailBrowserImpl {
|
|
|
2193
1811
|
* ```
|
|
2194
1812
|
*/
|
|
2195
1813
|
clear() {
|
|
2196
|
-
this.stdout.write(
|
|
2197
|
-
this.stderr.write(
|
|
1814
|
+
this.stdout.write(resetTerminal);
|
|
1815
|
+
this.stderr.write(resetTerminal);
|
|
2198
1816
|
}
|
|
2199
1817
|
extendReporter(reporter) {
|
|
2200
1818
|
if (typeof reporter.setStdout === "function") {
|
|
@@ -2565,7 +2183,7 @@ const parseCss = (cssString) => {
|
|
|
2565
2183
|
}
|
|
2566
2184
|
return css;
|
|
2567
2185
|
};
|
|
2568
|
-
const cssToAnsi = (css, previousCss
|
|
2186
|
+
const cssToAnsi = (css, previousCss) => {
|
|
2569
2187
|
previousCss = previousCss ?? getDefaultCss();
|
|
2570
2188
|
let ansi = "";
|
|
2571
2189
|
if (!colorEquals(css.backgroundColor, previousCss.backgroundColor)) {
|
|
@@ -2742,7 +2360,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
|
|
|
2742
2360
|
let a = 1 - offset;
|
|
2743
2361
|
let lastPosition = -1;
|
|
2744
2362
|
let usedStyle = false;
|
|
2745
|
-
let previousCss
|
|
2363
|
+
let previousCss;
|
|
2746
2364
|
for (let index = 0; index < fmt.length; ) {
|
|
2747
2365
|
if (fmt.codePointAt(index) === CHAR_PERCENT && index + 1 < fmt.length) {
|
|
2748
2366
|
lastPosition = lastPosition > -1 ? lastPosition : 0;
|
|
@@ -2955,6 +2573,7 @@ class MessageFormatterProcessor {
|
|
|
2955
2573
|
}
|
|
2956
2574
|
}
|
|
2957
2575
|
|
|
2576
|
+
const { bgGrey, cyan, green, greenBright, grey, red, underline, white } = colorize;
|
|
2958
2577
|
const PAIL_DIST_REGEX = /[\\/]pail[\\/]dist/;
|
|
2959
2578
|
const pailFileFilter = (line) => !PAIL_DIST_REGEX.test(line);
|
|
2960
2579
|
class PrettyReporter extends AbstractPrettyReporter {
|
|
@@ -3064,9 +2683,7 @@ class PrettyReporter extends AbstractPrettyReporter {
|
|
|
3064
2683
|
items.push(` ${grey(`[${scope.join(" > ")}]`)} `);
|
|
3065
2684
|
}
|
|
3066
2685
|
if (prefix) {
|
|
3067
|
-
items.push(
|
|
3068
|
-
`${grey(`${Array.isArray(scope) && scope.length > 0 ? ". " : " "}[${this.styles.underline.prefix ? underline(prefix) : prefix}]`)} `
|
|
3069
|
-
);
|
|
2686
|
+
items.push(`${grey(`${Array.isArray(scope) && scope.length > 0 ? ". " : " "}[${this.styles.underline.prefix ? underline(prefix) : prefix}]`)} `);
|
|
3070
2687
|
}
|
|
3071
2688
|
const titleSize = getStringWidth(items.join(" "));
|
|
3072
2689
|
if (file) {
|
|
@@ -3184,4 +2801,4 @@ const createPail = (options) => {
|
|
|
3184
2801
|
};
|
|
3185
2802
|
const pail = createPail();
|
|
3186
2803
|
|
|
3187
|
-
export {
|
|
2804
|
+
export { createPail, pail };
|
|
@@ -1,71 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { W as WideEvent } from "../packem_shared/wide-event.d-B-t8ZnhI.js";
|
|
2
|
+
import { P as PailMiddlewareOptions } from "../packem_shared/create-middleware-logger.d-DheMh8q4.js";
|
|
3
|
+
import 'safe-stable-stringify';
|
|
4
|
+
import "../packem_shared/types.d-BeLumqgD.js";
|
|
5
|
+
import '@visulima/colorize';
|
|
6
|
+
import '@visulima/interactive-manager';
|
|
3
7
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
* An Elysia-like instance that supports the derive/hook registration API.
|
|
9
|
+
* Compatible with Elysia v1+.
|
|
10
|
+
*/
|
|
7
11
|
interface PailElysiaInstance {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
derive: (options: {
|
|
13
|
+
as: string;
|
|
14
|
+
}, handler: (context: {
|
|
15
|
+
request: Request;
|
|
16
|
+
}) => Record<string, unknown>) => PailElysiaInstance;
|
|
17
|
+
onAfterHandle: (options: {
|
|
18
|
+
as: string;
|
|
19
|
+
}, handler: (context: {
|
|
20
|
+
request: Request;
|
|
21
|
+
set: {
|
|
22
|
+
status?: number;
|
|
23
|
+
};
|
|
24
|
+
}) => Promise<void>) => PailElysiaInstance;
|
|
25
|
+
onError: (options: {
|
|
26
|
+
as: string;
|
|
27
|
+
}, handler: (context: {
|
|
28
|
+
error: Error;
|
|
29
|
+
request: Request;
|
|
30
|
+
}) => Promise<void>) => PailElysiaInstance;
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
* Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
|
|
34
|
+
* Must be called within a request handler where pail middleware is active.
|
|
35
|
+
* @returns The request-scoped WideEvent logger
|
|
36
|
+
* @throws Error if called outside of the middleware context
|
|
37
|
+
*/
|
|
34
38
|
declare const useLogger: () => WideEvent;
|
|
35
39
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
* Configuration options for the Elysia pail plugin.
|
|
41
|
+
* @template T - Custom logger type names from the pail instance
|
|
42
|
+
*/
|
|
39
43
|
type ElysiaPluginOptions<T extends string = string> = PailMiddlewareOptions<T>;
|
|
40
44
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export { useLogger };
|
|
70
|
-
export type { ElysiaPluginOptions, PailElysiaInstance };
|
|
71
|
-
export type { WideEvent } from "../wide-event.d.ts";
|
|
45
|
+
* Register pail wide event logging as an Elysia plugin.
|
|
46
|
+
*
|
|
47
|
+
* Injects a `log` property into handler context via `derive`, accessible via:
|
|
48
|
+
* - `context.log` in route handlers (auto-injected)
|
|
49
|
+
* - `useLogger()` from anywhere in the async call stack
|
|
50
|
+
*
|
|
51
|
+
* The wide event is automatically emitted on response or error.
|
|
52
|
+
* @param app The Elysia instance
|
|
53
|
+
* @param options Plugin configuration
|
|
54
|
+
* @returns The Elysia instance (for chaining)
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { Elysia } from "elysia";
|
|
58
|
+
* import { createPail } from "@visulima/pail";
|
|
59
|
+
* import { pailPlugin, useLogger } from "@visulima/pail/middleware/elysia";
|
|
60
|
+
*
|
|
61
|
+
* const logger = createPail();
|
|
62
|
+
* const app = new Elysia();
|
|
63
|
+
*
|
|
64
|
+
* pailPlugin(app, { pail: logger });
|
|
65
|
+
*
|
|
66
|
+
* app.get("/api/users", ({ log }) => {
|
|
67
|
+
* log.set({ user: { id: 1 } });
|
|
68
|
+
* return { ok: true };
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare const pailPlugin: <T extends string = string>(app: PailElysiaInstance, options: ElysiaPluginOptions<T>) => PailElysiaInstance;
|
|
73
|
+
export { type ElysiaPluginOptions, type PailElysiaInstance, type WideEvent, pailPlugin, useLogger };
|
|
@@ -50,14 +50,14 @@ const pailPlugin = (app, options) => {
|
|
|
50
50
|
storage.enterWith(result.logger);
|
|
51
51
|
}
|
|
52
52
|
return { log: result.logger };
|
|
53
|
-
}).onAfterHandle({ as: "global" }, ({ request, set }) => {
|
|
53
|
+
}).onAfterHandle({ as: "global" }, async ({ request, set }) => {
|
|
54
54
|
const state = requestState.get(request);
|
|
55
55
|
if (!state?.skipped && state && !emitted.has(request)) {
|
|
56
56
|
emitted.add(request);
|
|
57
57
|
state.finish({ status: set.status ?? 200 });
|
|
58
58
|
activeLoggers.delete(state.logger);
|
|
59
59
|
}
|
|
60
|
-
}).onError({ as: "global" }, ({ error, request }) => {
|
|
60
|
+
}).onError({ as: "global" }, async ({ error, request }) => {
|
|
61
61
|
const state = requestState.get(request);
|
|
62
62
|
if (!state?.skipped && state && !emitted.has(request)) {
|
|
63
63
|
emitted.add(request);
|