@visulima/pail 4.0.0-alpha.1 → 4.0.0-alpha.10
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 +164 -0
- package/LICENSE.md +434 -6
- package/README.md +323 -0
- package/dist/error.d.ts +104 -0
- package/dist/error.js +76 -0
- package/dist/index.browser.d.ts +3 -1
- package/dist/index.browser.js +1490 -3
- package/dist/index.server.d.ts +3 -1
- package/dist/index.server.js +2668 -14
- package/dist/interactive/index.js +2 -2
- package/dist/middleware/elysia.d.ts +71 -0
- package/dist/middleware/elysia.js +70 -0
- package/dist/middleware/express.d.ts +86 -0
- package/dist/middleware/express.js +29 -0
- package/dist/middleware/fastify.d.ts +81 -0
- package/dist/middleware/fastify.js +46 -0
- package/dist/middleware/hono.d.ts +85 -0
- package/dist/middleware/hono.js +33 -0
- package/dist/middleware/next/handler.d.ts +36 -0
- package/dist/middleware/next/handler.js +53 -0
- package/dist/middleware/next/middleware.d.ts +59 -0
- package/dist/middleware/next/storage.d.ts +14 -0
- package/dist/middleware/shared/create-middleware-logger.d.ts +82 -0
- package/dist/middleware/shared/headers.d.ts +14 -0
- package/dist/middleware/shared/routes.d.ts +30 -0
- package/dist/middleware/shared/storage.d.ts +29 -0
- package/dist/middleware/sveltekit.d.ts +123 -0
- package/dist/middleware/sveltekit.js +43 -0
- package/dist/object-tree.d.ts +2 -2
- package/dist/object-tree.js +7 -7
- package/dist/packem_shared/AbstractJsonReporter-CjtVgHbU.js +288 -0
- package/dist/packem_shared/{AbstractJsonReporter-BaZ33PlE.js → AbstractJsonReporter-DlugSJpY.js} +111 -27
- package/dist/packem_shared/{InteractiveManager-CZ85hGNW.js → InteractiveManager-CowYA3Hx.js} +17 -11
- package/dist/packem_shared/{interactive-stream-hook-DG4BtN12.js → InteractiveStreamHook-BypRlYTX.js} +3 -11
- package/dist/packem_shared/{JsonReporter-VzgyLEYz.js → JsonReporter-BgPvIyC2.js} +2 -2
- package/dist/packem_shared/{JsonReporter-BRw4skd5.js → JsonReporter-Dbw82ewj.js} +2 -2
- package/dist/packem_shared/{PrettyReporter-DySIXBjQ.js → PrettyReporter-C2dCzIaf.js} +54 -8
- package/dist/packem_shared/{format-label-De49vNPd.js → PrettyReporter-gMqa7j_m.js} +370 -75
- package/dist/packem_shared/Spinner-Cokext9b.js +2183 -0
- package/dist/packem_shared/abstract-pretty-reporter-szQO-IgK.js +2635 -0
- package/dist/packem_shared/constants-B1RjD_ps.js +99 -0
- package/dist/packem_shared/createPailError-B_sgL0nF.js +76 -0
- package/dist/packem_shared/getBarChar-D7JfmdTr.js +459 -0
- package/dist/packem_shared/headers-BxHWM6KI.js +127 -0
- package/dist/packem_shared/{index-DqKWykfa.js → index-BEfVUy9P.js} +174 -64
- package/dist/packem_shared/{index-BomQ3E6J.js → index-Bx3-C0j9.js} +29 -21
- package/dist/packem_shared/pailMiddleware-Ci88geIF.js +24 -0
- package/dist/packem_shared/storage-D0vqz8OX.js +36 -0
- package/dist/packem_shared/{InteractiveStreamHook-DiSubbJ1.js → useLogger-D0rU3lcX.js} +13 -1
- package/dist/packem_shared/{write-console-log-based-on-level-DBmRYXpj.js → write-console-log-based-on-level-ree2lDPw.js} +5 -4
- package/dist/packem_shared/{write-stream-BG8fhcs3.js → write-stream-BuFtjATz.js} +1 -1
- package/dist/pail.browser.d.ts +1 -1
- package/dist/processor/environment-processor.d.ts +124 -0
- package/dist/processor/environment-processor.js +82 -0
- package/dist/processor/message-formatter-processor.d.ts +2 -3
- package/dist/processor/message-formatter-processor.js +654 -5
- package/dist/processor/opentelemetry-processor.js +4 -4
- package/dist/processor/redact-processor.d.ts +1 -1
- package/dist/processor/redact-processor.js +2 -1
- package/dist/processor/sampling-processor.d.ts +111 -0
- package/dist/processor/sampling-processor.js +59 -0
- package/dist/progress-bar.d.ts +10 -1
- package/dist/progress-bar.js +75 -20
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.js +23 -26
- package/dist/reporter/http/http-reporter.edge-light.js +133 -52
- package/dist/reporter/json/abstract-json-reporter.d.ts +1 -1
- 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/simple/simple-reporter.server.js +8 -12
- package/dist/spinner.js +37 -4
- package/dist/types.d.ts +3 -3
- package/dist/wide-event.d.ts +300 -0
- package/dist/wide-event.js +283 -0
- package/package.json +71 -7
- package/dist/packem_shared/PrettyReporter-DgZB2eBG.js +0 -222
- package/dist/packem_shared/abstract-pretty-reporter-Di_sdm2r.js +0 -50
- package/dist/packem_shared/get-longest-label-C9PWeyKq.js +0 -9
- package/dist/packem_shared/pail.browser-u2CSR_af.js +0 -1427
package/dist/packem_shared/{AbstractJsonReporter-BaZ33PlE.js → AbstractJsonReporter-DlugSJpY.js}
RENAMED
|
@@ -12,7 +12,7 @@ const ErrorProto = Object.create(
|
|
|
12
12
|
{},
|
|
13
13
|
{
|
|
14
14
|
cause: {
|
|
15
|
-
enumerable:
|
|
15
|
+
enumerable: false,
|
|
16
16
|
value: void 0,
|
|
17
17
|
writable: true
|
|
18
18
|
},
|
|
@@ -22,62 +22,89 @@ const ErrorProto = Object.create(
|
|
|
22
22
|
writable: true
|
|
23
23
|
},
|
|
24
24
|
errors: {
|
|
25
|
-
enumerable:
|
|
25
|
+
enumerable: false,
|
|
26
26
|
value: void 0,
|
|
27
27
|
writable: true
|
|
28
28
|
},
|
|
29
29
|
message: {
|
|
30
|
-
enumerable:
|
|
30
|
+
enumerable: false,
|
|
31
31
|
value: void 0,
|
|
32
32
|
writable: true
|
|
33
33
|
},
|
|
34
34
|
name: {
|
|
35
|
-
enumerable:
|
|
35
|
+
enumerable: false,
|
|
36
36
|
value: void 0,
|
|
37
37
|
writable: true
|
|
38
38
|
},
|
|
39
39
|
stack: {
|
|
40
|
-
enumerable:
|
|
40
|
+
enumerable: false,
|
|
41
41
|
value: void 0,
|
|
42
42
|
writable: true
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
const toJsonWasCalled = /* @__PURE__ */ new WeakSet();
|
|
47
|
+
const makePropertiesEnumerable = (object) => {
|
|
48
|
+
const props = Object.getOwnPropertyNames(object);
|
|
49
|
+
for (const prop of props) {
|
|
50
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, prop);
|
|
51
|
+
if (descriptor) {
|
|
52
|
+
if (!descriptor.enumerable) {
|
|
53
|
+
Object.defineProperty(object, prop, {
|
|
54
|
+
...descriptor,
|
|
55
|
+
enumerable: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (descriptor.value && typeof descriptor.value === "object" && !Array.isArray(descriptor.value) && (Object.getPrototypeOf(descriptor.value) === Object.prototype || Object.getPrototypeOf(descriptor.value) === null)) {
|
|
59
|
+
makePropertiesEnumerable(descriptor.value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
47
64
|
const toJSON = (from) => {
|
|
48
65
|
toJsonWasCalled.add(from);
|
|
49
66
|
const json = from.toJSON();
|
|
50
67
|
toJsonWasCalled.delete(from);
|
|
68
|
+
if (
|
|
69
|
+
// Only make properties enumerable if the object is extensible
|
|
70
|
+
// Non-extensible objects (like when toJSON returns 'this') should preserve original enumerability
|
|
71
|
+
Object.isExtensible(json)
|
|
72
|
+
) {
|
|
73
|
+
makePropertiesEnumerable(json);
|
|
74
|
+
}
|
|
51
75
|
return json;
|
|
52
76
|
};
|
|
53
77
|
const serializeValue = (value, seen, depth, options) => {
|
|
54
78
|
if (value && value instanceof Uint8Array && value.constructor.name === "Buffer") {
|
|
55
79
|
return "[object Buffer]";
|
|
56
80
|
}
|
|
57
|
-
if (value !== null && typeof value === "object" && typeof value.pipe === "function") {
|
|
81
|
+
if (value !== null && typeof value === "object" && "pipe" in value && typeof value.pipe === "function") {
|
|
58
82
|
return "[object Stream]";
|
|
59
83
|
}
|
|
60
84
|
if (value instanceof Error) {
|
|
61
|
-
if (seen.
|
|
85
|
+
if (seen.has(value)) {
|
|
62
86
|
return "[Circular]";
|
|
63
87
|
}
|
|
64
88
|
depth += 1;
|
|
65
89
|
return _serialize(value, options, seen, depth);
|
|
66
90
|
}
|
|
67
|
-
if (options.useToJSON && typeof value.toJSON === "function") {
|
|
91
|
+
if (options.useToJSON && value !== null && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
|
|
68
92
|
return value.toJSON();
|
|
69
93
|
}
|
|
70
|
-
if (
|
|
94
|
+
if (value instanceof Date) {
|
|
71
95
|
return value.toISOString();
|
|
72
96
|
}
|
|
73
97
|
if (typeof value === "function") {
|
|
74
98
|
return `[Function: ${value.name || "anonymous"}]`;
|
|
75
99
|
}
|
|
100
|
+
if (typeof value === "bigint") {
|
|
101
|
+
return `${String(value)}n`;
|
|
102
|
+
}
|
|
76
103
|
if (isPlainObject(value)) {
|
|
77
|
-
depth
|
|
78
|
-
if (options.maxDepth && depth >= options.maxDepth) {
|
|
104
|
+
if (options.maxDepth !== void 0 && options.maxDepth !== Number.POSITIVE_INFINITY && depth + 1 >= options.maxDepth) {
|
|
79
105
|
return {};
|
|
80
106
|
}
|
|
107
|
+
depth += 1;
|
|
81
108
|
const plainObject = {};
|
|
82
109
|
for (const key in value) {
|
|
83
110
|
plainObject[key] = serializeValue(value[key], seen, depth, options);
|
|
@@ -91,7 +118,7 @@ const serializeValue = (value, seen, depth, options) => {
|
|
|
91
118
|
}
|
|
92
119
|
};
|
|
93
120
|
const _serialize = (error, options, seen, depth) => {
|
|
94
|
-
seen.
|
|
121
|
+
seen.add(error);
|
|
95
122
|
if (options.maxDepth === 0) {
|
|
96
123
|
return {};
|
|
97
124
|
}
|
|
@@ -99,31 +126,88 @@ const _serialize = (error, options, seen, depth) => {
|
|
|
99
126
|
return toJSON(error);
|
|
100
127
|
}
|
|
101
128
|
const protoError = Object.create(ErrorProto);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
129
|
+
Object.defineProperty(protoError, "name", {
|
|
130
|
+
configurable: true,
|
|
131
|
+
enumerable: true,
|
|
132
|
+
value: Object.prototype.toString.call(error.constructor) === "[object Function]" ? error.constructor.name : error.name,
|
|
133
|
+
writable: true
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(protoError, "message", {
|
|
136
|
+
configurable: true,
|
|
137
|
+
enumerable: true,
|
|
138
|
+
value: error.message,
|
|
139
|
+
writable: true
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(protoError, "stack", {
|
|
142
|
+
configurable: true,
|
|
143
|
+
enumerable: true,
|
|
144
|
+
value: error.stack,
|
|
145
|
+
writable: true
|
|
146
|
+
});
|
|
105
147
|
if (Array.isArray(error.errors)) {
|
|
106
148
|
const aggregateErrors = [];
|
|
107
149
|
for (const aggregateError of error.errors) {
|
|
108
150
|
if (!(aggregateError instanceof Error)) {
|
|
109
151
|
throw new TypeError("All errors in the 'errors' property must be instances of Error");
|
|
110
152
|
}
|
|
111
|
-
if (seen.
|
|
112
|
-
protoError
|
|
153
|
+
if (seen.has(aggregateError)) {
|
|
154
|
+
Object.defineProperty(protoError, "errors", {
|
|
155
|
+
configurable: true,
|
|
156
|
+
enumerable: true,
|
|
157
|
+
value: [],
|
|
158
|
+
writable: true
|
|
159
|
+
});
|
|
113
160
|
return protoError;
|
|
114
161
|
}
|
|
115
162
|
aggregateErrors.push(_serialize(aggregateError, options, seen, depth));
|
|
116
163
|
}
|
|
117
|
-
protoError
|
|
164
|
+
Object.defineProperty(protoError, "errors", {
|
|
165
|
+
configurable: true,
|
|
166
|
+
enumerable: true,
|
|
167
|
+
value: aggregateErrors,
|
|
168
|
+
writable: true
|
|
169
|
+
});
|
|
118
170
|
}
|
|
119
|
-
|
|
120
|
-
|
|
171
|
+
const causeValue = error.cause;
|
|
172
|
+
if (causeValue !== void 0 && causeValue !== null) {
|
|
173
|
+
if (causeValue instanceof Error) {
|
|
174
|
+
if (seen.has(causeValue)) {
|
|
175
|
+
Object.defineProperty(protoError, "cause", {
|
|
176
|
+
configurable: true,
|
|
177
|
+
enumerable: true,
|
|
178
|
+
value: "[Circular]",
|
|
179
|
+
writable: true
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
Object.defineProperty(protoError, "cause", {
|
|
183
|
+
configurable: true,
|
|
184
|
+
enumerable: true,
|
|
185
|
+
value: _serialize(causeValue, options, seen, depth),
|
|
186
|
+
writable: true
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
const serializedCause = serializeValue(causeValue, seen, depth, options);
|
|
191
|
+
Object.defineProperty(protoError, "cause", {
|
|
192
|
+
configurable: true,
|
|
193
|
+
enumerable: true,
|
|
194
|
+
value: serializedCause,
|
|
195
|
+
writable: true
|
|
196
|
+
});
|
|
197
|
+
}
|
|
121
198
|
}
|
|
122
199
|
for (const key in error) {
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
protoError[key] = serializeValue(value, seen, depth, options);
|
|
200
|
+
if (key === "name" || key === "message" || key === "stack" || key === "cause" || key === "errors") {
|
|
201
|
+
continue;
|
|
126
202
|
}
|
|
203
|
+
const value = error[key];
|
|
204
|
+
const serializedValue = serializeValue(value, seen, depth, options);
|
|
205
|
+
Object.defineProperty(protoError, key, {
|
|
206
|
+
configurable: true,
|
|
207
|
+
enumerable: true,
|
|
208
|
+
value: serializedValue,
|
|
209
|
+
writable: true
|
|
210
|
+
});
|
|
127
211
|
}
|
|
128
212
|
if (Array.isArray(options.exclude) && options.exclude.length > 0) {
|
|
129
213
|
for (const key of options.exclude) {
|
|
@@ -142,7 +226,7 @@ const serialize = (error, options = {}) => _serialize(
|
|
|
142
226
|
maxDepth: options.maxDepth ?? Number.POSITIVE_INFINITY,
|
|
143
227
|
useToJSON: options.useToJSON ?? false
|
|
144
228
|
},
|
|
145
|
-
|
|
229
|
+
/* @__PURE__ */ new Set(),
|
|
146
230
|
0
|
|
147
231
|
);
|
|
148
232
|
|
|
@@ -162,7 +246,6 @@ class AbstractJsonReporter {
|
|
|
162
246
|
* Sets a custom stringify function for object serialization.
|
|
163
247
|
* @param function_ The stringify function to use for serialization
|
|
164
248
|
*/
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
166
249
|
setStringify(function_) {
|
|
167
250
|
this.stringify = function_;
|
|
168
251
|
}
|
|
@@ -173,7 +256,7 @@ class AbstractJsonReporter {
|
|
|
173
256
|
rest.label = rest.label.trim();
|
|
174
257
|
}
|
|
175
258
|
if (file) {
|
|
176
|
-
rest.file = `${file.name}:${file.line}${file.column ? `:${file.column}` : ""}`;
|
|
259
|
+
rest.file = `${file.name ?? ""}:${String(file.line)}${file.column ? `:${String(file.column)}` : ""}`;
|
|
177
260
|
}
|
|
178
261
|
if (message === EMPTY_SYMBOL) {
|
|
179
262
|
rest.message = void 0;
|
|
@@ -185,7 +268,8 @@ class AbstractJsonReporter {
|
|
|
185
268
|
}
|
|
186
269
|
if (context) {
|
|
187
270
|
const newContext = [];
|
|
188
|
-
for (
|
|
271
|
+
for (let i = 0; i < context.length; i += 1) {
|
|
272
|
+
const item = context[i];
|
|
189
273
|
if (item === EMPTY_SYMBOL) {
|
|
190
274
|
continue;
|
|
191
275
|
}
|
package/dist/packem_shared/{InteractiveManager-CZ85hGNW.js → InteractiveManager-CowYA3Hx.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as terminalSize, w as wordWrap, W as WrapMode } from './index-
|
|
1
|
+
import { t as terminalSize, w as wordWrap, W as WrapMode } from './index-BEfVUy9P.js';
|
|
2
2
|
|
|
3
3
|
class InteractiveManager {
|
|
4
4
|
#stream;
|
|
@@ -64,9 +64,6 @@ class InteractiveManager {
|
|
|
64
64
|
* @throws {TypeError} If the specified stream is not available
|
|
65
65
|
*/
|
|
66
66
|
erase(stream, count = this.#lastLength) {
|
|
67
|
-
if (this.#stream[stream] === void 0) {
|
|
68
|
-
throw new TypeError(`Stream "${stream}" is not available`);
|
|
69
|
-
}
|
|
70
67
|
this.#stream[stream].erase(count);
|
|
71
68
|
}
|
|
72
69
|
/**
|
|
@@ -75,7 +72,10 @@ class InteractiveManager {
|
|
|
75
72
|
*/
|
|
76
73
|
hook() {
|
|
77
74
|
if (!this.#isActive) {
|
|
78
|
-
Object.values(this.#stream)
|
|
75
|
+
const hooks = Object.values(this.#stream);
|
|
76
|
+
for (let i = 0; i < hooks.length; i += 1) {
|
|
77
|
+
hooks[i].active();
|
|
78
|
+
}
|
|
79
79
|
this.#clear(true);
|
|
80
80
|
}
|
|
81
81
|
return this.#isActive;
|
|
@@ -92,7 +92,10 @@ class InteractiveManager {
|
|
|
92
92
|
this.erase(stream, eraseRowCount);
|
|
93
93
|
}
|
|
94
94
|
this.#lastLength = 0;
|
|
95
|
-
Object.values(this.#stream)
|
|
95
|
+
const hooks = Object.values(this.#stream);
|
|
96
|
+
for (let i = 0; i < hooks.length; i += 1) {
|
|
97
|
+
hooks[i].active();
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
@@ -106,7 +109,10 @@ class InteractiveManager {
|
|
|
106
109
|
if (erase) {
|
|
107
110
|
this.erase(stream);
|
|
108
111
|
}
|
|
109
|
-
Object.values(this.#stream)
|
|
112
|
+
const hooks = Object.values(this.#stream);
|
|
113
|
+
for (let i = 0; i < hooks.length; i += 1) {
|
|
114
|
+
hooks[i].renew();
|
|
115
|
+
}
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
118
|
/**
|
|
@@ -116,7 +122,10 @@ class InteractiveManager {
|
|
|
116
122
|
*/
|
|
117
123
|
unhook(separateHistory = true) {
|
|
118
124
|
if (this.#isActive) {
|
|
119
|
-
Object.values(this.#stream)
|
|
125
|
+
const hooks = Object.values(this.#stream);
|
|
126
|
+
for (let i = 0; i < hooks.length; i += 1) {
|
|
127
|
+
hooks[i].inactive(separateHistory);
|
|
128
|
+
}
|
|
120
129
|
this.#clear();
|
|
121
130
|
}
|
|
122
131
|
return !this.#isActive;
|
|
@@ -129,9 +138,6 @@ class InteractiveManager {
|
|
|
129
138
|
*/
|
|
130
139
|
update(stream, rows, from = 0) {
|
|
131
140
|
if (rows.length > 0) {
|
|
132
|
-
if (this.#stream[stream] === void 0) {
|
|
133
|
-
throw new TypeError(`Stream "${stream}" is not available`);
|
|
134
|
-
}
|
|
135
141
|
const hook = this.#stream[stream];
|
|
136
142
|
const { columns: width, rows: height } = terminalSize();
|
|
137
143
|
const position = from > height ? height - 1 : Math.max(0, Math.min(height - 1, from));
|
package/dist/packem_shared/{interactive-stream-hook-DG4BtN12.js → InteractiveStreamHook-BypRlYTX.js}
RENAMED
|
@@ -22,17 +22,9 @@ const {
|
|
|
22
22
|
} = __cjs_getBuiltinModule("node:string_decoder");
|
|
23
23
|
|
|
24
24
|
const ESC = "\x1B[";
|
|
25
|
-
const eraseScreen = `${ESC}2J`;
|
|
26
25
|
const eraseLine = `${ESC}2K`;
|
|
27
26
|
const cursorLeft = `${ESC}G`;
|
|
28
|
-
const cursorUp = (count = 1) => `${ESC
|
|
29
|
-
const clearTerminal = process.platform === "win32" ? `${eraseScreen}${ESC}0f` : (
|
|
30
|
-
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
31
|
-
// 2. Erases the whole screen including scrollback buffer
|
|
32
|
-
// 3. Moves cursor to the top-left position
|
|
33
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
34
|
-
`${eraseScreen}${ESC}3J${ESC}H`
|
|
35
|
-
);
|
|
27
|
+
const cursorUp = (count = 1) => `${ESC}${String(count)}A`;
|
|
36
28
|
const cursorHide = `${ESC}?25l`;
|
|
37
29
|
const cursorShow = `${ESC}?25h`;
|
|
38
30
|
const eraseLines = (count) => {
|
|
@@ -58,7 +50,7 @@ class InteractiveStreamHook {
|
|
|
58
50
|
* @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
|
|
59
51
|
*/
|
|
60
52
|
constructor(stream) {
|
|
61
|
-
this.#method = stream.write;
|
|
53
|
+
this.#method = stream.write.bind(stream);
|
|
62
54
|
this.#stream = stream;
|
|
63
55
|
}
|
|
64
56
|
/**
|
|
@@ -138,4 +130,4 @@ class InteractiveStreamHook {
|
|
|
138
130
|
}
|
|
139
131
|
}
|
|
140
132
|
|
|
141
|
-
export { InteractiveStreamHook as
|
|
133
|
+
export { InteractiveStreamHook as default };
|
|
@@ -8,8 +8,8 @@ const {
|
|
|
8
8
|
stdout,
|
|
9
9
|
stderr
|
|
10
10
|
} = __cjs_getProcess;
|
|
11
|
-
import { w as writeStream } from './write-stream-
|
|
12
|
-
import { AbstractJsonReporter } from './AbstractJsonReporter-
|
|
11
|
+
import { w as writeStream } from './write-stream-BuFtjATz.js';
|
|
12
|
+
import { AbstractJsonReporter } from './AbstractJsonReporter-CjtVgHbU.js';
|
|
13
13
|
|
|
14
14
|
class JsonReporter extends AbstractJsonReporter {
|
|
15
15
|
/** Standard output stream */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractJsonReporter } from './AbstractJsonReporter-
|
|
2
|
-
import { w as writeConsoleLogBasedOnLevel } from './write-console-log-based-on-level-
|
|
1
|
+
import { AbstractJsonReporter } from './AbstractJsonReporter-DlugSJpY.js';
|
|
2
|
+
import { w as writeConsoleLogBasedOnLevel } from './write-console-log-based-on-level-ree2lDPw.js';
|
|
3
3
|
|
|
4
4
|
class JsonReporter extends AbstractJsonReporter {
|
|
5
5
|
/**
|
|
@@ -1,9 +1,54 @@
|
|
|
1
1
|
import colorize, { grey, white, underline, bold } from '@visulima/colorize/browser';
|
|
2
|
-
import { f as format } from './index-
|
|
3
|
-
import { E as EMPTY_SYMBOL } from './constants-omsTHUWB.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { f as format, g as getLongestLabel } from './index-Bx3-C0j9.js';
|
|
3
|
+
import { L as LOG_TYPES, E as EMPTY_SYMBOL } from './constants-omsTHUWB.js';
|
|
4
|
+
import { w as writeConsoleLogBasedOnLevel } from './write-console-log-based-on-level-ree2lDPw.js';
|
|
5
|
+
|
|
6
|
+
const getLongestBadge = (types) => {
|
|
7
|
+
const badges = Object.keys(types).map((x) => types[x].badge ?? "");
|
|
8
|
+
if (badges.length === 0) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
return badges.reduce((x, y) => x.length > y.length ? x : y, "");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const dateFormatter = (date) => [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
|
|
15
|
+
class AbstractPrettyReporter {
|
|
16
|
+
/** Styling options for pretty formatting */
|
|
17
|
+
styles;
|
|
18
|
+
/** Logger type configurations for styling */
|
|
19
|
+
loggerTypes;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
22
|
+
* @param options Styling options for pretty formatting
|
|
23
|
+
* @protected
|
|
24
|
+
*/
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.styles = {
|
|
27
|
+
bold: {
|
|
28
|
+
label: false
|
|
29
|
+
},
|
|
30
|
+
dateFormatter,
|
|
31
|
+
underline: {
|
|
32
|
+
label: false,
|
|
33
|
+
message: false,
|
|
34
|
+
prefix: false,
|
|
35
|
+
suffix: false
|
|
36
|
+
},
|
|
37
|
+
uppercase: {
|
|
38
|
+
label: false
|
|
39
|
+
},
|
|
40
|
+
...options
|
|
41
|
+
};
|
|
42
|
+
this.loggerTypes = LOG_TYPES;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Sets the logger types configuration for styling.
|
|
46
|
+
* @param types Logger type configurations with colors and labels
|
|
47
|
+
*/
|
|
48
|
+
setLoggerTypes(types) {
|
|
49
|
+
this.loggerTypes = types;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
7
52
|
|
|
8
53
|
class PrettyReporter extends AbstractPrettyReporter {
|
|
9
54
|
/**
|
|
@@ -19,7 +64,7 @@ class PrettyReporter extends AbstractPrettyReporter {
|
|
|
19
64
|
...options
|
|
20
65
|
});
|
|
21
66
|
}
|
|
22
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
67
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- browser colorize returns arrays where spread is intentional
|
|
23
68
|
log(meta) {
|
|
24
69
|
const isNotBrowser = typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
|
|
25
70
|
const consoleLogFunction = writeConsoleLogBasedOnLevel(meta.type.level);
|
|
@@ -139,9 +184,10 @@ ${cSuffix[0]}`, ...cSuffix.slice(1)]);
|
|
|
139
184
|
let logMessage = "";
|
|
140
185
|
const css = [];
|
|
141
186
|
const arguments_ = [];
|
|
142
|
-
for (
|
|
187
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
188
|
+
const value = items[i];
|
|
143
189
|
if (Array.isArray(value) && value.length > 1 && value[0].includes("%c")) {
|
|
144
|
-
logMessage += value[0];
|
|
190
|
+
logMessage += String(value[0]);
|
|
145
191
|
css.push(...value.slice(1));
|
|
146
192
|
} else {
|
|
147
193
|
arguments_.push(value);
|