@prozilla-os/shared 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/chunks/index-PU_xBoDn.js +857 -0
- package/dist/chunks/index-PU_xBoDn.js.map +1 -0
- package/dist/chunks/object.utils-xiWGUq8N.js +15 -0
- package/dist/chunks/object.utils-xiWGUq8N.js.map +1 -0
- package/dist/logging.d.ts +711 -0
- package/dist/logging.js +17 -0
- package/dist/logging.js.map +1 -0
- package/dist/main.d.ts +785 -43
- package/dist/main.js +300 -674
- package/dist/main.js.map +1 -1
- package/dist/utils.d.ts +265 -0
- package/dist/utils.js +245 -0
- package/dist/utils.js.map +1 -0
- package/package.json +24 -9
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides utility functions for wrapping text in ANSI escape codes.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link ANSI}
|
|
5
|
+
* @hideconstructor
|
|
6
|
+
*/
|
|
7
|
+
export declare class Ansi {
|
|
8
|
+
/**
|
|
9
|
+
* Makes text black using {@link ANSI.fg.black}.
|
|
10
|
+
*/
|
|
11
|
+
static black(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Makes text red using {@link ANSI.fg.red}.
|
|
14
|
+
*/
|
|
15
|
+
static red(text: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Makes text green using {@link ANSI.fg.green}.
|
|
18
|
+
*/
|
|
19
|
+
static green(text: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Makes text yellow using {@link ANSI.fg.yellow}.
|
|
22
|
+
*/
|
|
23
|
+
static yellow(text: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Makes text blue using {@link ANSI.fg.blue}.
|
|
26
|
+
*/
|
|
27
|
+
static blue(text: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Makes text magenta using {@link ANSI.fg.magenta}.
|
|
30
|
+
*/
|
|
31
|
+
static magenta(text: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Makes text cyan using {@link ANSI.fg.cyan}.
|
|
34
|
+
*/
|
|
35
|
+
static cyan(text: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Makes text white using {@link ANSI.fg.white}.
|
|
38
|
+
*/
|
|
39
|
+
static white(text: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Sets background to black using {@link ANSI.bg.black}.
|
|
42
|
+
*/
|
|
43
|
+
static blackBackground(text: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Sets background to red using {@link ANSI.bg.red}.
|
|
46
|
+
*/
|
|
47
|
+
static redBackground(text: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Sets background to green using {@link ANSI.bg.green}.
|
|
50
|
+
*/
|
|
51
|
+
static greenBackground(text: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Sets background to yellow using {@link ANSI.bg.yellow}.
|
|
54
|
+
*/
|
|
55
|
+
static yellowBackground(text: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Sets background to blue using {@link ANSI.bg.blue}.
|
|
58
|
+
*/
|
|
59
|
+
static blueBackground(text: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Sets background to magenta using {@link ANSI.bg.magenta}.
|
|
62
|
+
*/
|
|
63
|
+
static magentaBackground(text: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Sets background to cyan using {@link ANSI.bg.cyan}.
|
|
66
|
+
*/
|
|
67
|
+
static cyanBackground(text: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Sets background to white using {@link ANSI.bg.white}.
|
|
70
|
+
*/
|
|
71
|
+
static whiteBackground(text: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Makes text bold using {@link ANSI.decoration.bold}.
|
|
74
|
+
*/
|
|
75
|
+
static bold(text: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Makes text dim using {@link ANSI.decoration.dim}.
|
|
78
|
+
*/
|
|
79
|
+
static dim(text: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Makes text italic using {@link ANSI.decoration.italic}.
|
|
82
|
+
*/
|
|
83
|
+
static italic(text: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Underlines text using {@link ANSI.decoration.underline}.
|
|
86
|
+
*/
|
|
87
|
+
static underline(text: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* Inverts foreground and background colors using {@link ANSI.decoration.invert}.
|
|
90
|
+
*/
|
|
91
|
+
static invert(text: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Makes text strike through using {@link ANSI.decoration.strike}.
|
|
94
|
+
*/
|
|
95
|
+
static strike(text: string): string;
|
|
96
|
+
static apply(text: string, code: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Removes all ANSI escape sequences.
|
|
99
|
+
*/
|
|
100
|
+
static strip(text: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Removes ANSI escape sequences for colors and background colors (SGR).
|
|
103
|
+
*/
|
|
104
|
+
static stripColors(text: string): string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Applies a format to a string.
|
|
109
|
+
* @param text - The text to format.
|
|
110
|
+
* @returns The formatted text.
|
|
111
|
+
*/
|
|
112
|
+
export declare type Formatter = (text: string) => string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Generates a human-readable string representation of a value.
|
|
116
|
+
*
|
|
117
|
+
* This is intended for debugging purposes.
|
|
118
|
+
* It is an alternative to {@link https://nodejs.org/api/util.html#utilinspectobject-options util.inspect}, that supports more customization of the output.
|
|
119
|
+
*
|
|
120
|
+
* @param value - The value to inspect.
|
|
121
|
+
* @param options - Optional inspection options.
|
|
122
|
+
* @returns The resulting string.
|
|
123
|
+
* @example
|
|
124
|
+
* **Note:** The following examples omit the `options` parameter for simplicity. In reality, the return values will contain ANSI escape codes unless you explicitly set `colors` to `false`.
|
|
125
|
+
* ```tsx
|
|
126
|
+
* // Supports primitive values.
|
|
127
|
+
* inspect(null) === "null"
|
|
128
|
+
* inspect("example") === "\"example\""
|
|
129
|
+
*
|
|
130
|
+
* // Supports objects and arrays (and other containers).
|
|
131
|
+
* inspect({ size: 2, values: [true, false] }) === "{ size: 2, values: [true, false] }"
|
|
132
|
+
*
|
|
133
|
+
* // Even supports React nodes.
|
|
134
|
+
* inspect(<h1>Example</h1>) === "<h1>Example</h1>"
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function inspect(value: unknown, options?: InspectionOptions): string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns a string representation of an array.
|
|
141
|
+
* @param array - The array to inspect.
|
|
142
|
+
* @param options - Optional inspection options.
|
|
143
|
+
* @returns The resulting string.
|
|
144
|
+
* @example
|
|
145
|
+
* **Note:** The following examples omit or shorten the `options` parameter for simplicity. In reality, the return values will contain ANSI escape codes unless you explicitly set `colors` to `false`.
|
|
146
|
+
* ```ts
|
|
147
|
+
* inspect([1, 2, 3]) === "[1, 2, 3]"
|
|
148
|
+
* inspect([1, 2, 3], { spaceAfterComma: false }) === "[1,2,3]"
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function inspectArray(array: unknown[], options?: InspectionOptions): string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns a string representation of an error.
|
|
155
|
+
* @param error - The error to inspect.
|
|
156
|
+
* @param options - Optional inspection options.
|
|
157
|
+
* @returns The resulting string.
|
|
158
|
+
*/
|
|
159
|
+
export declare function inspectError(error: Error, options?: InspectionOptions): string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Returns a string representation of a function.
|
|
163
|
+
* @param func - The function to inspect.
|
|
164
|
+
* @param options - Optional inspection options.
|
|
165
|
+
* @returns The resulting string.
|
|
166
|
+
*/
|
|
167
|
+
export declare function inspectFunction(func: Function, options?: InspectionOptions): string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Returns a string representation of a function call, its arguments and its return value.
|
|
171
|
+
* @param func - The function to inspect.
|
|
172
|
+
* @param args - The arguments of the function call.
|
|
173
|
+
* @param returnValue - The return value of the function call.
|
|
174
|
+
* @param options - Optional inspection options.
|
|
175
|
+
* @returns The resulting string.
|
|
176
|
+
*/
|
|
177
|
+
export declare function inspectFunctionCall<A extends unknown[] = [], R = undefined>(func: (...args: A) => R, args: A, returnValue: R, options?: InspectionOptions): string;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Configuration options for the inspection utilities.
|
|
181
|
+
* @see {@link inspect}
|
|
182
|
+
*/
|
|
183
|
+
export declare interface InspectionOptions {
|
|
184
|
+
/**
|
|
185
|
+
* The maximum depth for representations of container values (e.g., objects, arrays).
|
|
186
|
+
* @default 2
|
|
187
|
+
*/
|
|
188
|
+
depth?: number;
|
|
189
|
+
/**
|
|
190
|
+
* The maximum number of array elements to represent before truncating.
|
|
191
|
+
* @default 100
|
|
192
|
+
*/
|
|
193
|
+
maxArrayLength?: number;
|
|
194
|
+
/**
|
|
195
|
+
* The maximum amount of characters of a string to represent, before replacing the remainder with an ellipsis.
|
|
196
|
+
* @default 80
|
|
197
|
+
*/
|
|
198
|
+
maxStringLength?: number;
|
|
199
|
+
/**
|
|
200
|
+
* The maximum line length before wrapping to a new line.
|
|
201
|
+
*
|
|
202
|
+
* This option is ignored when {@link compact} is set to `true`.
|
|
203
|
+
* @default 60
|
|
204
|
+
*/
|
|
205
|
+
breakLength?: number;
|
|
206
|
+
/**
|
|
207
|
+
* `true` keeps container values on a single line when possible.
|
|
208
|
+
* @default true
|
|
209
|
+
*/
|
|
210
|
+
compact?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* `true` enables the sorting of keys in object representations.
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
sortKeys?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* `true` uses single quotes instead of double quotes.
|
|
218
|
+
* @default false
|
|
219
|
+
*/
|
|
220
|
+
singleQuotes?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* `true` places a space after every comma.
|
|
223
|
+
* @default true
|
|
224
|
+
*/
|
|
225
|
+
spaceAfterComma?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Plugins to extend, override or configure the inspection process.
|
|
228
|
+
*/
|
|
229
|
+
plugins?: InspectionPlugin[];
|
|
230
|
+
/**
|
|
231
|
+
* The {@link ANSI} color codes for different symbols.
|
|
232
|
+
*
|
|
233
|
+
* Set to `false` to disable ANSI colors.
|
|
234
|
+
*/
|
|
235
|
+
colors?: false | {
|
|
236
|
+
/**
|
|
237
|
+
* The color to apply to strings.
|
|
238
|
+
* @default ANSI.fg.green
|
|
239
|
+
*/
|
|
240
|
+
string?: string | null;
|
|
241
|
+
/**
|
|
242
|
+
* The color to apply to numbers.
|
|
243
|
+
* @default ANSI.fg.yellow
|
|
244
|
+
*/
|
|
245
|
+
number?: string | null;
|
|
246
|
+
/**
|
|
247
|
+
* The color to apply to booleans.
|
|
248
|
+
* @default ANSI.fg.yellow
|
|
249
|
+
*/
|
|
250
|
+
boolean?: string | null;
|
|
251
|
+
/**
|
|
252
|
+
* The color to apply to `null` keywords.
|
|
253
|
+
* @default ANSI.decoration.dim + ANSI.fg.yellow
|
|
254
|
+
*/
|
|
255
|
+
null?: string | null;
|
|
256
|
+
/**
|
|
257
|
+
* The color to apply to `undefined` keywords.
|
|
258
|
+
* @default ANSI.decoration.dim + ANSI.fg.yellow
|
|
259
|
+
*/
|
|
260
|
+
undefined?: string | null;
|
|
261
|
+
/**
|
|
262
|
+
* The color to apply to bigints.
|
|
263
|
+
* @default ANSI.fg.yellow
|
|
264
|
+
*/
|
|
265
|
+
bigint?: string | null;
|
|
266
|
+
/**
|
|
267
|
+
* The color to apply to symbols.
|
|
268
|
+
* @default ANSI.fg.green
|
|
269
|
+
*/
|
|
270
|
+
symbol?: string | null;
|
|
271
|
+
/**
|
|
272
|
+
* The color to apply to functions.
|
|
273
|
+
* @default ANSI.fg.blue
|
|
274
|
+
*/
|
|
275
|
+
function?: string | null;
|
|
276
|
+
/**
|
|
277
|
+
* The color to apply to keys.
|
|
278
|
+
* @default ANSI.fg.white
|
|
279
|
+
*/
|
|
280
|
+
key?: string | null;
|
|
281
|
+
/**
|
|
282
|
+
* The color to apply to dates.
|
|
283
|
+
* @default ANSI.fg.magenta
|
|
284
|
+
*/
|
|
285
|
+
date?: string | null;
|
|
286
|
+
/**
|
|
287
|
+
* The color to apply to {@link RegExp}s.
|
|
288
|
+
* @default ANSI.fg.cyan
|
|
289
|
+
*/
|
|
290
|
+
regExp?: string | null;
|
|
291
|
+
/**
|
|
292
|
+
* The color to apply to errors.
|
|
293
|
+
* @default ANSI.fg.red
|
|
294
|
+
*/
|
|
295
|
+
error?: string | null;
|
|
296
|
+
/**
|
|
297
|
+
* The color to apply to HTML tags.
|
|
298
|
+
* @default ANSI.fg.red
|
|
299
|
+
*/
|
|
300
|
+
htmlTag?: string | null;
|
|
301
|
+
/**
|
|
302
|
+
* The color to apply to React components.
|
|
303
|
+
* @default ANSI.fg.yellow
|
|
304
|
+
*/
|
|
305
|
+
reactComponent?: string | null;
|
|
306
|
+
/**
|
|
307
|
+
* The color to apply to delimiters.
|
|
308
|
+
* @default ANSI.fg.cyan
|
|
309
|
+
*/
|
|
310
|
+
delimiter?: string | null;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* A plugin for the inspection utilities.
|
|
316
|
+
*
|
|
317
|
+
* Can be used to extend, override or configure the inspection process.
|
|
318
|
+
* Hook methods are called at different stages of the process and can seamlessly interact with it.
|
|
319
|
+
*
|
|
320
|
+
* This is heavily inspired by [Vite's plugin API](https://vite.dev/guide/api-plugin) and follows a similar pattern.
|
|
321
|
+
*
|
|
322
|
+
* @see {@link inspect}
|
|
323
|
+
*/
|
|
324
|
+
export declare interface InspectionPlugin {
|
|
325
|
+
/** The name of this plugin. */
|
|
326
|
+
name: string;
|
|
327
|
+
/**
|
|
328
|
+
* A hook that configures the inspection options before any values are inspected.
|
|
329
|
+
* @param options - The current inspection options.
|
|
330
|
+
*/
|
|
331
|
+
config?: (options: ResolvedInspectionOptions) => void;
|
|
332
|
+
/**
|
|
333
|
+
* A hook that is called before a value is inspected.
|
|
334
|
+
* @param input - The input value.
|
|
335
|
+
* @param context - The inspection context.
|
|
336
|
+
*/
|
|
337
|
+
first?: (input: unknown, context: ResolvedInspectionOptions) => string | undefined;
|
|
338
|
+
/**
|
|
339
|
+
* A hook that is called if a value could not be inspected.
|
|
340
|
+
* @param input - The input value.
|
|
341
|
+
* @param context - The inspection context.
|
|
342
|
+
*/
|
|
343
|
+
fallback?: (input: unknown, context: ResolvedInspectionOptions) => string | undefined;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Returns a string representation of a map.
|
|
348
|
+
* @param map - The map to inspect.
|
|
349
|
+
* @param options - Optional inspection options.
|
|
350
|
+
* @returns The resulting string.
|
|
351
|
+
*/
|
|
352
|
+
export declare function inspectMap(map: Map<unknown, unknown>, options?: InspectionOptions): string;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Returns a string representation of an object.
|
|
356
|
+
* @param object - The object to inspect.
|
|
357
|
+
* @param options - Optional inspection options.
|
|
358
|
+
* @returns The resulting string.
|
|
359
|
+
* @example
|
|
360
|
+
* **Note:** The following example omits the `options` parameter for simplicity. In reality, the return values will contain ANSI escape codes unless you explicitly set `colors` to `false`.
|
|
361
|
+
* ```ts
|
|
362
|
+
* inspect({ first: true, second: false }) === "{ first: true, second: false }"
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
export declare function inspectObject(object: Record<PropertyKey, unknown>, options?: InspectionOptions): string;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Returns a string representation of a React element.
|
|
369
|
+
* @param element - The React element to inspect.
|
|
370
|
+
* @param options - Optional inspection options.
|
|
371
|
+
* @returns The resulting string.
|
|
372
|
+
* @example
|
|
373
|
+
* **Note:** The following example omits the `options` parameter for simplicity. In reality, the return values will contain ANSI escape codes unless you explicitly set `colors` to `false`.
|
|
374
|
+
* ```tsx
|
|
375
|
+
* inspect(<h1>Example</h1>) === "<h1>Example</h1>"
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
export declare function inspectReactElement(element: ReactElementLike, options?: InspectionOptions): string;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Returns a string representation of a set.
|
|
382
|
+
* @param set - The set to inspect.
|
|
383
|
+
* @param options - Optional inspection options.
|
|
384
|
+
* @returns The resulting string.
|
|
385
|
+
*/
|
|
386
|
+
export declare function inspectSet(set: Set<unknown>, options?: InspectionOptions): string;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Generates a literal string representation of a string.
|
|
390
|
+
* @param string - The string to inspect.
|
|
391
|
+
* @param options - Optional inspection options.
|
|
392
|
+
* @returns The resulting string.
|
|
393
|
+
* @example
|
|
394
|
+
* **Note:** The following examples omit or shorten the `options` parameter for simplicity. In reality, the return values will contain ANSI escape codes unless you explicitly set `colors` to `false`.
|
|
395
|
+
* ```ts
|
|
396
|
+
* inspect("Example") === "\"Example\""
|
|
397
|
+
* inspect("Example", { singleQuotes: true }) === "'Example'"
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
export declare function inspectString(string: string, options?: InspectionOptions): string;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* A simple wrapper for {@link console} that logs formatted text and supports log levels.
|
|
404
|
+
*/
|
|
405
|
+
export declare class Logger {
|
|
406
|
+
#private;
|
|
407
|
+
/**
|
|
408
|
+
* The minimum log level or an array of log levels to enable.
|
|
409
|
+
*
|
|
410
|
+
* `undefined` enables all log levels. An array enables all log levels in that array. A single level enables that log level and the ones above.
|
|
411
|
+
* @default LogLevel.Debug
|
|
412
|
+
*/
|
|
413
|
+
level?: LogLevel | LogLevel[];
|
|
414
|
+
/**
|
|
415
|
+
* The current level of indentation.
|
|
416
|
+
* @default 0
|
|
417
|
+
*/
|
|
418
|
+
indent: number;
|
|
419
|
+
/**
|
|
420
|
+
* The string to use for indentation.
|
|
421
|
+
* @default "\t"
|
|
422
|
+
*/
|
|
423
|
+
indentString?: string;
|
|
424
|
+
/**
|
|
425
|
+
* The function to use when highlighting text.
|
|
426
|
+
* @default Ansi.cyan
|
|
427
|
+
* @see {@link Ansi.cyan}
|
|
428
|
+
*/
|
|
429
|
+
highlight: Formatter;
|
|
430
|
+
/**
|
|
431
|
+
* The function to use when emphasizing text.
|
|
432
|
+
* @default Ansi.bold
|
|
433
|
+
* @see {@link Ansi.bold}
|
|
434
|
+
*/
|
|
435
|
+
emphasize: Formatter;
|
|
436
|
+
/**
|
|
437
|
+
* The prefixes to prepend to logs.
|
|
438
|
+
* @default {
|
|
439
|
+
[LogLevel.Info]: Ansi.cyan("[info]"),
|
|
440
|
+
[LogLevel.Success]: Ansi.green("[success]"),
|
|
441
|
+
[LogLevel.Warning]: Ansi.yellow("[warning]"),
|
|
442
|
+
[LogLevel.Error]: Ansi.red("[error]"),
|
|
443
|
+
}
|
|
444
|
+
*/
|
|
445
|
+
prefix: {
|
|
446
|
+
[key in LogLevel | "global"]?: string;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* The function to use to turn values into strings.
|
|
450
|
+
* @see {@link createStringifier}
|
|
451
|
+
* @default Logger.createStringifier("pretty")
|
|
452
|
+
*/
|
|
453
|
+
stringify: (value: unknown) => string;
|
|
454
|
+
get errorCount(): number;
|
|
455
|
+
set errorCount(value: number);
|
|
456
|
+
get warningCount(): number;
|
|
457
|
+
set warningCount(value: number);
|
|
458
|
+
constructor(options?: {
|
|
459
|
+
/** {@inheritDoc Logger.level}. */
|
|
460
|
+
level?: Logger["level"];
|
|
461
|
+
/**
|
|
462
|
+
* The prefix(es) to prepend to logs.
|
|
463
|
+
*
|
|
464
|
+
* Does not override default prefixes unless specified.
|
|
465
|
+
*/
|
|
466
|
+
prefix?: Logger["prefix"] | string;
|
|
467
|
+
});
|
|
468
|
+
/**
|
|
469
|
+
* @param level - The minimum log level.
|
|
470
|
+
*/
|
|
471
|
+
constructor(level: LogLevel);
|
|
472
|
+
/**
|
|
473
|
+
* @param levels - The log levels to enable.
|
|
474
|
+
*/
|
|
475
|
+
constructor(levels: LogLevel[]);
|
|
476
|
+
/**
|
|
477
|
+
* Resets all properties to their default values.
|
|
478
|
+
*/
|
|
479
|
+
reset(): this;
|
|
480
|
+
/**
|
|
481
|
+
* Calls a function while the level of indentation is increased.
|
|
482
|
+
*
|
|
483
|
+
* Increases the level of indentation, then calls the function and finally restores the indentation.
|
|
484
|
+
* @param callback - The function to call.
|
|
485
|
+
* @param indentation - The amount of indentation to use.
|
|
486
|
+
*/
|
|
487
|
+
indented(callback: (this: undefined) => void, indentation?: number): this;
|
|
488
|
+
/**
|
|
489
|
+
* Logs every line while the level of indentation is increased.
|
|
490
|
+
*
|
|
491
|
+
* Increases the level of indentation, then logs every line and finally restores the indentation.
|
|
492
|
+
* @param lines - The lines to log.
|
|
493
|
+
* @param indentation - The amount of indentation to use.
|
|
494
|
+
* @param level - The log level.
|
|
495
|
+
*/
|
|
496
|
+
indented(lines: unknown[], indentation?: number, level?: LogLevel): this;
|
|
497
|
+
/**
|
|
498
|
+
* Logs a message while the level of indentation is increased.
|
|
499
|
+
*
|
|
500
|
+
* Increases the level of indentation, then logs the message and finally restores the indentation.
|
|
501
|
+
* @param message - The message to log.
|
|
502
|
+
* @param indentation - The amount of indentation to use.
|
|
503
|
+
* @param level - The log level.
|
|
504
|
+
*/
|
|
505
|
+
indented(message: unknown, indentation?: number, level?: LogLevel): this;
|
|
506
|
+
/**
|
|
507
|
+
* Increases the level of indentation.
|
|
508
|
+
* @param amount - The amount to increase the level of indentation with.
|
|
509
|
+
*/
|
|
510
|
+
tab(amount?: number): this;
|
|
511
|
+
/**
|
|
512
|
+
* Decreases the level of indentation.
|
|
513
|
+
* @param amount - The amount to decrease the level of indentation with.
|
|
514
|
+
*/
|
|
515
|
+
shiftTab(amount?: number): this;
|
|
516
|
+
/**
|
|
517
|
+
* Sets the prefix to prepend to all logs.
|
|
518
|
+
* @param prefix - The prefix to use.
|
|
519
|
+
*/
|
|
520
|
+
setPrefix(prefix: string): this;
|
|
521
|
+
/**
|
|
522
|
+
* Sets the prefixes to prepend to logs.
|
|
523
|
+
*
|
|
524
|
+
* Will override any existing prefixes.
|
|
525
|
+
* @param prefixes - The prefixes to use.
|
|
526
|
+
*/
|
|
527
|
+
setPrefix(prefixes: Logger["prefix"]): this;
|
|
528
|
+
/**
|
|
529
|
+
* Sets the prefix to prepend to logs at a given log level.
|
|
530
|
+
* @param level - The log level.
|
|
531
|
+
* @param prefix - The prefix to use.
|
|
532
|
+
*/
|
|
533
|
+
setPrefix(level: LogLevel, prefix: string): this;
|
|
534
|
+
/**
|
|
535
|
+
* Logs an info message about a URL being fetched.
|
|
536
|
+
* @param url - The URL being fetched.
|
|
537
|
+
*/
|
|
538
|
+
fetching(url: string): this;
|
|
539
|
+
/**
|
|
540
|
+
* Logs an info message that implies a pending state.
|
|
541
|
+
* @param message - The status message.
|
|
542
|
+
*/
|
|
543
|
+
pending(message: string): this;
|
|
544
|
+
/**
|
|
545
|
+
* Logs an error message.
|
|
546
|
+
* @param message - The error message or reason.
|
|
547
|
+
* @param details - The details of the error message.
|
|
548
|
+
*/
|
|
549
|
+
error(message: unknown, ...details: unknown[]): this;
|
|
550
|
+
/**
|
|
551
|
+
* Logs a warning message.
|
|
552
|
+
* @param message - The warning message.
|
|
553
|
+
* @param details - The details of the warning message.
|
|
554
|
+
*/
|
|
555
|
+
warn(message: string, ...details: unknown[]): this;
|
|
556
|
+
/**
|
|
557
|
+
* Logs a success message.
|
|
558
|
+
* @param message - The success message.
|
|
559
|
+
* @param details - The details of the success message.
|
|
560
|
+
*/
|
|
561
|
+
success(message: string, ...details: unknown[]): this;
|
|
562
|
+
/**
|
|
563
|
+
* Logs an info message.
|
|
564
|
+
* @param message - The info message.
|
|
565
|
+
* @param details - The details of the info message.
|
|
566
|
+
*/
|
|
567
|
+
info(message: string, ...details: unknown[]): this;
|
|
568
|
+
/**
|
|
569
|
+
* Logs a status message.
|
|
570
|
+
* @param message - The status message.
|
|
571
|
+
* @param details - The details of the status message.
|
|
572
|
+
* @param level - The log level.
|
|
573
|
+
*/
|
|
574
|
+
statusMessage(message: string, details: unknown[], level?: LogLevel): this;
|
|
575
|
+
/**
|
|
576
|
+
* Logs the amount of errors and warnings that have been logged since the previous call to this function or the creation of this logger.
|
|
577
|
+
*/
|
|
578
|
+
summary(): this;
|
|
579
|
+
/**
|
|
580
|
+
* Logs a labeled parameter.
|
|
581
|
+
*
|
|
582
|
+
* The value is emphasized using {@link emphasize}.
|
|
583
|
+
* @param label - The label of the parameter.
|
|
584
|
+
* @param value - The value of the parameter.
|
|
585
|
+
* @param level - The log level.
|
|
586
|
+
*/
|
|
587
|
+
parameter(label: string, value: unknown, level?: LogLevel): this;
|
|
588
|
+
/**
|
|
589
|
+
* Logs properties as a list of key-value pairs.
|
|
590
|
+
* @param properties - The properties to log.
|
|
591
|
+
* @param level - The log level.
|
|
592
|
+
* @see {@link value()}
|
|
593
|
+
*/
|
|
594
|
+
properties(properties: Record<string, unknown>, level?: LogLevel): this;
|
|
595
|
+
/**
|
|
596
|
+
* Logs a labeled value.
|
|
597
|
+
*
|
|
598
|
+
* The value is highlighted using {@link highlight}.
|
|
599
|
+
* @param label - The label of the value.
|
|
600
|
+
* @param value - The value.
|
|
601
|
+
* @param level - The log level.
|
|
602
|
+
*/
|
|
603
|
+
value(label: string, value: unknown, level?: LogLevel): this;
|
|
604
|
+
/**
|
|
605
|
+
* Logs emphasized text.
|
|
606
|
+
* @param text - The text to log.
|
|
607
|
+
* @param level - The log level.
|
|
608
|
+
*/
|
|
609
|
+
emphasized(text: string, level?: LogLevel): this;
|
|
610
|
+
/**
|
|
611
|
+
* Logs highlighted text.
|
|
612
|
+
* @param text - The text to log.
|
|
613
|
+
* @param level - The log level.
|
|
614
|
+
*/
|
|
615
|
+
highlighted(text: string, level?: LogLevel): this;
|
|
616
|
+
/**
|
|
617
|
+
* Logs each item on a new line.
|
|
618
|
+
* @param lines - The items to log.
|
|
619
|
+
* @param level - The log level.
|
|
620
|
+
*/
|
|
621
|
+
lines(lines: unknown[], level?: LogLevel): this;
|
|
622
|
+
/**
|
|
623
|
+
* Logs a message.
|
|
624
|
+
* @param message - The message to log.
|
|
625
|
+
* @param level - The log level.
|
|
626
|
+
*/
|
|
627
|
+
log(message: unknown, level?: LogLevel): this;
|
|
628
|
+
/**
|
|
629
|
+
* Logs text using this logger's format.
|
|
630
|
+
* @param text - The text to log.
|
|
631
|
+
* @param level - The log level.
|
|
632
|
+
*/
|
|
633
|
+
text(text: string, level?: LogLevel): this;
|
|
634
|
+
/**
|
|
635
|
+
* Logs an newline character.
|
|
636
|
+
*/
|
|
637
|
+
newLine(): this;
|
|
638
|
+
/**
|
|
639
|
+
* Checks if the given log level is enabled.
|
|
640
|
+
* @param level - The log level to check.
|
|
641
|
+
*/
|
|
642
|
+
isLevelEnabled(level: LogLevel): boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Formats text using this logger's formatting properties.
|
|
645
|
+
* @param text - The text to format.
|
|
646
|
+
*/
|
|
647
|
+
format(text: string): string;
|
|
648
|
+
/**
|
|
649
|
+
* Prepends a prefix to text.
|
|
650
|
+
* @param text - The text to apply the prefix to.
|
|
651
|
+
* @param level - The log level.
|
|
652
|
+
*/
|
|
653
|
+
applyPrefix(text: string, level?: LogLevel): string;
|
|
654
|
+
/**
|
|
655
|
+
* Creates a stringify function that uses the {@link String} constructor.
|
|
656
|
+
* @param type - The type of stringify function to use.
|
|
657
|
+
*/
|
|
658
|
+
static createStringifier(type?: "basic"): Logger["stringify"];
|
|
659
|
+
/**
|
|
660
|
+
* Creates a stringify function that uses {@link inspect} for any non-string value.
|
|
661
|
+
* @param type - The type of stringify function to use.
|
|
662
|
+
* @param options - The options for {@link inspect}.
|
|
663
|
+
*/
|
|
664
|
+
static createStringifier(type: "pretty", options?: InspectionOptions): Logger["stringify"];
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export declare enum LogLevel {
|
|
668
|
+
Debug = 0,
|
|
669
|
+
Info = 1,
|
|
670
|
+
Success = 2,
|
|
671
|
+
Warning = 3,
|
|
672
|
+
Error = 4
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export declare interface ReactElementLike {
|
|
676
|
+
type: unknown;
|
|
677
|
+
props?: unknown;
|
|
678
|
+
key?: string | null;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* The resolved inspection options combined with some utility functions for generating string representations.
|
|
683
|
+
*
|
|
684
|
+
* Used internally by the inspection utilities and {@link InspectionPlugin}s.
|
|
685
|
+
* @see {@link inspect}
|
|
686
|
+
*/
|
|
687
|
+
export declare interface ResolvedInspectionOptions extends Required<InspectionOptions> {
|
|
688
|
+
/**
|
|
689
|
+
* Returns a formatted delimiter string.
|
|
690
|
+
* @param delimiter - The raw delimiter.
|
|
691
|
+
*/
|
|
692
|
+
delimiter: (delimiter: string) => string;
|
|
693
|
+
/** Returns a formatted separator string. */
|
|
694
|
+
separator: () => string;
|
|
695
|
+
/**
|
|
696
|
+
* Applies color to the given string, if {@link ResolvedInspectionOptions.colors} is `true`.
|
|
697
|
+
* @param text - The raw text.
|
|
698
|
+
* @param colorCode - The ANSI color code to apply.
|
|
699
|
+
*/
|
|
700
|
+
color: (text: string, colorCode: string | undefined | null) => string;
|
|
701
|
+
/**
|
|
702
|
+
* Applies the appropriate formatting to the given token.
|
|
703
|
+
* @param token - The raw token.
|
|
704
|
+
* @param type - The type of token.
|
|
705
|
+
*/
|
|
706
|
+
token: (token: string, type?: keyof Exclude<InspectionOptions["colors"], false | undefined>) => string;
|
|
707
|
+
/** Creates a new inspection context and increments the current depth. */
|
|
708
|
+
fork: () => ResolvedInspectionOptions;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export { }
|