@loglayer/transport-simple-pretty-terminal 2.2.7 → 2.2.8

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/dist/index.cjs CHANGED
@@ -1,676 +1,721 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/SimplePrettyTerminalTransport.ts
2
- var _transport = require('@loglayer/transport');
3
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk); _createStarExport(_chalk);
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
4
22
 
5
- // src/themes.ts
23
+ //#endregion
24
+ let __loglayer_transport = require("@loglayer/transport");
25
+ __loglayer_transport = __toESM(__loglayer_transport);
26
+ let chalk = require("chalk");
27
+ chalk = __toESM(chalk);
28
+ let date_fns = require("date-fns");
29
+ date_fns = __toESM(date_fns);
6
30
 
7
- var moonlight = {
8
- colors: {
9
- trace: _chalk2.default.rgb(114, 135, 153),
10
- // Muted blue-grey for less important info
11
- debug: _chalk2.default.rgb(130, 170, 255),
12
- // Soft blue that pops but doesn't strain
13
- info: _chalk2.default.rgb(195, 232, 141),
14
- // Sage green for good readability
15
- warn: _chalk2.default.rgb(255, 203, 107),
16
- // Warm yellow, less harsh than pure yellow
17
- error: _chalk2.default.rgb(247, 118, 142),
18
- // Soft red that stands out without being aggressive
19
- fatal: _chalk2.default.bgRgb(247, 118, 142).white
20
- // Inverted soft red for maximum visibility
21
- },
22
- logIdColor: _chalk2.default.rgb(84, 98, 117),
23
- // Darker blue-grey for secondary information
24
- dataValueColor: _chalk2.default.rgb(209, 219, 231),
25
- // Light grey-blue for primary content
26
- dataKeyColor: _chalk2.default.rgb(130, 170, 255)
27
- // Matching debug blue for consistency
31
+ //#region src/themes.ts
32
+ /**
33
+ * Moonlight - A dark theme with cool blue tones
34
+ * Inspired by moonlit nights and modern IDEs
35
+ *
36
+ * Color Palette:
37
+ * - Primary: Cool blues and soft greens
38
+ * - Accents: Warm yellows and soft reds
39
+ * - Background: Assumes dark terminal (black or very dark grey)
40
+ *
41
+ * Best used with:
42
+ * - Dark terminal themes
43
+ * - Night-time coding sessions
44
+ * - Environments where eye strain is a concern
45
+ */
46
+ const moonlight = {
47
+ colors: {
48
+ trace: chalk.default.rgb(114, 135, 153),
49
+ debug: chalk.default.rgb(130, 170, 255),
50
+ info: chalk.default.rgb(195, 232, 141),
51
+ warn: chalk.default.rgb(255, 203, 107),
52
+ error: chalk.default.rgb(247, 118, 142),
53
+ fatal: chalk.default.bgRgb(247, 118, 142).white
54
+ },
55
+ logIdColor: chalk.default.rgb(84, 98, 117),
56
+ dataValueColor: chalk.default.rgb(209, 219, 231),
57
+ dataKeyColor: chalk.default.rgb(130, 170, 255)
28
58
  };
29
- var sunlight = {
30
- colors: {
31
- trace: _chalk2.default.rgb(110, 110, 110),
32
- // Dark grey for subtle information
33
- debug: _chalk2.default.rgb(32, 96, 159),
34
- // Deep blue for strong contrast on white
35
- info: _chalk2.default.rgb(35, 134, 54),
36
- // Forest green, easier on the eyes than bright green
37
- warn: _chalk2.default.rgb(176, 95, 0),
38
- // Brown-orange for natural warning color
39
- error: _chalk2.default.rgb(191, 0, 0),
40
- // Deep red for clear visibility on light backgrounds
41
- fatal: _chalk2.default.bgRgb(191, 0, 0).white
42
- // White on deep red for critical issues
43
- },
44
- logIdColor: _chalk2.default.rgb(110, 110, 110),
45
- dataValueColor: _chalk2.default.rgb(0, 0, 0),
46
- dataKeyColor: _chalk2.default.rgb(32, 96, 159)
59
+ /**
60
+ * Sunlight - A light theme with warm tones
61
+ * Inspired by daylight reading and paper documentation
62
+ *
63
+ * Color Palette:
64
+ * - Primary: Deep, rich colors that contrast well with white
65
+ * - Accents: Earth tones and deep jewel tones
66
+ * - Background: Assumes light terminal (white or very light grey)
67
+ *
68
+ * Best used with:
69
+ * - Light terminal themes
70
+ * - Daytime coding sessions
71
+ * - High-glare environments
72
+ * - Printed documentation
73
+ */
74
+ const sunlight = {
75
+ colors: {
76
+ trace: chalk.default.rgb(110, 110, 110),
77
+ debug: chalk.default.rgb(32, 96, 159),
78
+ info: chalk.default.rgb(35, 134, 54),
79
+ warn: chalk.default.rgb(176, 95, 0),
80
+ error: chalk.default.rgb(191, 0, 0),
81
+ fatal: chalk.default.bgRgb(191, 0, 0).white
82
+ },
83
+ logIdColor: chalk.default.rgb(110, 110, 110),
84
+ dataValueColor: chalk.default.rgb(0, 0, 0),
85
+ dataKeyColor: chalk.default.rgb(32, 96, 159)
47
86
  };
48
- var neon = {
49
- colors: {
50
- trace: _chalk2.default.rgb(108, 108, 255),
51
- // Electric blue
52
- debug: _chalk2.default.rgb(255, 82, 246),
53
- // Hot pink
54
- info: _chalk2.default.rgb(0, 255, 163),
55
- // Cyber green
56
- warn: _chalk2.default.rgb(255, 231, 46),
57
- // Electric yellow
58
- error: _chalk2.default.rgb(255, 53, 91),
59
- // Neon red
60
- fatal: _chalk2.default.bgRgb(255, 53, 91).rgb(0, 255, 163)
61
- // Neon red bg with cyber green text
62
- },
63
- logIdColor: _chalk2.default.rgb(187, 134, 252),
64
- // Bright purple
65
- dataValueColor: _chalk2.default.rgb(255, 255, 255),
66
- // Pure white
67
- dataKeyColor: _chalk2.default.rgb(0, 255, 240)
68
- // Cyan
87
+ /**
88
+ * Neon - A dark theme with vibrant cyberpunk colors
89
+ * Inspired by neon-lit cityscapes and retro-futuristic aesthetics
90
+ *
91
+ * Color Palette:
92
+ * - Primary: Electric blues and hot pinks
93
+ * - Accents: Bright purples and cyber greens
94
+ * - Background: Assumes dark terminal (black or very dark grey)
95
+ *
96
+ * Best used with:
97
+ * - Dark terminal themes
98
+ * - High-contrast preferences
99
+ * - Modern, tech-focused applications
100
+ */
101
+ const neon = {
102
+ colors: {
103
+ trace: chalk.default.rgb(108, 108, 255),
104
+ debug: chalk.default.rgb(255, 82, 246),
105
+ info: chalk.default.rgb(0, 255, 163),
106
+ warn: chalk.default.rgb(255, 231, 46),
107
+ error: chalk.default.rgb(255, 53, 91),
108
+ fatal: chalk.default.bgRgb(255, 53, 91).rgb(0, 255, 163)
109
+ },
110
+ logIdColor: chalk.default.rgb(187, 134, 252),
111
+ dataValueColor: chalk.default.rgb(255, 255, 255),
112
+ dataKeyColor: chalk.default.rgb(0, 255, 240)
69
113
  };
70
- var nature = {
71
- colors: {
72
- trace: _chalk2.default.rgb(101, 115, 126),
73
- // Slate grey
74
- debug: _chalk2.default.rgb(34, 139, 34),
75
- // Forest green
76
- info: _chalk2.default.rgb(46, 139, 87),
77
- // Sea green
78
- warn: _chalk2.default.rgb(218, 165, 32),
79
- // Golden rod
80
- error: _chalk2.default.rgb(139, 69, 19),
81
- // Saddle brown
82
- fatal: _chalk2.default.bgRgb(139, 69, 19).white
83
- // Brown background with white text
84
- },
85
- logIdColor: _chalk2.default.rgb(101, 115, 126),
86
- dataValueColor: _chalk2.default.rgb(0, 0, 0),
87
- dataKeyColor: _chalk2.default.rgb(34, 139, 34)
114
+ /**
115
+ * Nature - A light theme with organic, earthy colors
116
+ * Inspired by forest landscapes and natural elements
117
+ *
118
+ * Color Palette:
119
+ * - Primary: Deep forest greens and rich browns
120
+ * - Accents: Autumn reds and golden yellows
121
+ * - Background: Assumes light terminal (white or very light grey)
122
+ *
123
+ * Best used with:
124
+ * - Light terminal themes
125
+ * - Nature-inspired interfaces
126
+ * - Applications focusing on readability
127
+ */
128
+ const nature = {
129
+ colors: {
130
+ trace: chalk.default.rgb(101, 115, 126),
131
+ debug: chalk.default.rgb(34, 139, 34),
132
+ info: chalk.default.rgb(46, 139, 87),
133
+ warn: chalk.default.rgb(218, 165, 32),
134
+ error: chalk.default.rgb(139, 69, 19),
135
+ fatal: chalk.default.bgRgb(139, 69, 19).white
136
+ },
137
+ logIdColor: chalk.default.rgb(101, 115, 126),
138
+ dataValueColor: chalk.default.rgb(0, 0, 0),
139
+ dataKeyColor: chalk.default.rgb(34, 139, 34)
88
140
  };
89
- var pastel = {
90
- colors: {
91
- trace: _chalk2.default.rgb(200, 200, 200),
92
- // Light grey
93
- debug: _chalk2.default.rgb(173, 216, 230),
94
- // Light blue
95
- info: _chalk2.default.rgb(144, 238, 144),
96
- // Light green
97
- warn: _chalk2.default.rgb(255, 218, 185),
98
- // Peach
99
- error: _chalk2.default.rgb(255, 182, 193),
100
- // Light pink
101
- fatal: _chalk2.default.bgRgb(255, 182, 193).rgb(105, 105, 105)
102
- // Light pink bg with dim grey text
103
- },
104
- logIdColor: _chalk2.default.rgb(200, 200, 200),
105
- dataValueColor: _chalk2.default.rgb(105, 105, 105),
106
- dataKeyColor: _chalk2.default.rgb(173, 216, 230)
141
+ /**
142
+ * Pastel - A soft, calming theme with gentle colors
143
+ * Inspired by watercolor paintings and soft aesthetics
144
+ *
145
+ * Color Palette:
146
+ * - Primary: Soft pastels and muted tones
147
+ * - Accents: Gentle pinks and light blues
148
+ * - Background: Assumes light terminal (white or very light grey)
149
+ *
150
+ * Best used with:
151
+ * - Light terminal themes
152
+ * - Long coding sessions
153
+ * - Reduced visual stress
154
+ */
155
+ const pastel = {
156
+ colors: {
157
+ trace: chalk.default.rgb(200, 200, 200),
158
+ debug: chalk.default.rgb(173, 216, 230),
159
+ info: chalk.default.rgb(144, 238, 144),
160
+ warn: chalk.default.rgb(255, 218, 185),
161
+ error: chalk.default.rgb(255, 182, 193),
162
+ fatal: chalk.default.bgRgb(255, 182, 193).rgb(105, 105, 105)
163
+ },
164
+ logIdColor: chalk.default.rgb(200, 200, 200),
165
+ dataValueColor: chalk.default.rgb(105, 105, 105),
166
+ dataKeyColor: chalk.default.rgb(173, 216, 230)
107
167
  };
108
168
 
109
- // src/vendor/prettyjson.js
110
-
111
-
112
- // src/vendor/utils.js
169
+ //#endregion
170
+ //#region src/vendor/utils.js
171
+ /**
172
+ * Creates a string with the same length as `numSpaces` parameter
173
+ **/
113
174
  function indent(numSpaces) {
114
- return new Array(numSpaces + 1).join(" ");
175
+ return new Array(numSpaces + 1).join(" ");
115
176
  }
177
+ /**
178
+ * Gets the string length of the longer index in a hash
179
+ **/
116
180
  function getMaxIndexLength(input) {
117
- var maxWidth = 0;
118
- Object.getOwnPropertyNames(input).forEach((key) => {
119
- if (input[key] === void 0) {
120
- return;
121
- }
122
- maxWidth = Math.max(maxWidth, key.length);
123
- });
124
- return maxWidth;
181
+ var maxWidth = 0;
182
+ Object.getOwnPropertyNames(input).forEach((key) => {
183
+ if (input[key] === void 0) return;
184
+ maxWidth = Math.max(maxWidth, key.length);
185
+ });
186
+ return maxWidth;
125
187
  }
126
188
  function isIsoStringDate(isoString) {
127
- if (typeof isoString !== "string") {
128
- return false;
129
- }
130
- if (!/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/.test(isoString)) {
131
- return false;
132
- }
133
- const testDate = new Date(isoString);
134
- return !Number.isNaN(testDate.getTime());
189
+ if (typeof isoString !== "string") return false;
190
+ if (!/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/.test(isoString)) return false;
191
+ const testDate = new Date(isoString);
192
+ return !Number.isNaN(testDate.getTime());
135
193
  }
136
194
 
137
- // src/vendor/prettyjson.js
138
- var conflictChars = /[^\w\s\n\r\v\t.,]/i;
139
- var isPrintable = (input, options) => input !== void 0 || options.renderUndefined;
140
- var isSerializable = (input, onlyPrimitives, options) => {
141
- if (typeof input === "boolean" || typeof input === "number" || typeof input === "function" || input === null || input === void 0 || input instanceof Date) {
142
- return true;
143
- }
144
- if (typeof input === "string" && input.indexOf("\n") === -1) {
145
- return true;
146
- }
147
- if (options.inlineArrays && !onlyPrimitives) {
148
- if (Array.isArray(input) && isSerializable(input[0], true, options)) {
149
- return true;
150
- }
151
- }
152
- return false;
195
+ //#endregion
196
+ //#region src/vendor/prettyjson.js
197
+ const conflictChars = /[^\w\s\n\r\v\t.,]/i;
198
+ const isPrintable = (input, options) => input !== void 0 || options.renderUndefined;
199
+ const isSerializable = (input, onlyPrimitives, options) => {
200
+ if (typeof input === "boolean" || typeof input === "number" || typeof input === "function" || input === null || input === void 0 || input instanceof Date) return true;
201
+ if (typeof input === "string" && input.indexOf("\n") === -1) return true;
202
+ if (options.inlineArrays && !onlyPrimitives) {
203
+ if (Array.isArray(input) && isSerializable(input[0], true, options)) return true;
204
+ }
205
+ return false;
153
206
  };
154
- var getColorRenderer = (colorFn, options) => {
155
- if (options.noColor) {
156
- return (text) => text;
157
- }
158
- if (typeof colorFn !== "function") {
159
- return (text) => text;
160
- }
161
- return colorFn;
207
+ /**
208
+ * @param {Function} colorFn
209
+ * @param {PrettyJSONOptions} options
210
+ */
211
+ const getColorRenderer = (colorFn, options) => {
212
+ if (options.noColor) return (text) => text;
213
+ if (typeof colorFn !== "function") return (text) => text;
214
+ return colorFn;
162
215
  };
163
- var addColorToData = (input, options) => {
164
- if (options.noColor) {
165
- return input;
166
- }
167
- if (input instanceof Date) {
168
- return getColorRenderer(options.dateColor, options)(input.toISOString());
169
- }
170
- if (typeof input === "string") {
171
- if (isIsoStringDate(input)) {
172
- return getColorRenderer(options.dateColor, options)(input);
173
- }
174
- return getColorRenderer(options.stringColor, options)(input);
175
- }
176
- const sInput = `${input}`;
177
- if (typeof input === "boolean") {
178
- return getColorRenderer(options.booleanColor, options)(sInput);
179
- }
180
- if (input === null || input === void 0) {
181
- return getColorRenderer(options.nullUndefinedColor, options)(sInput);
182
- }
183
- if (typeof input === "number") {
184
- if (input >= 0) {
185
- return getColorRenderer(options.positiveNumberColor, options)(sInput);
186
- }
187
- return getColorRenderer(options.negativeNumberColor, options)(sInput);
188
- }
189
- if (typeof input === "function") {
190
- return "function() {}";
191
- }
192
- if (Array.isArray(input)) {
193
- return input.join(", ");
194
- }
195
- return sInput;
216
+ const addColorToData = (input, options) => {
217
+ if (options.noColor) return input;
218
+ if (input instanceof Date) return getColorRenderer(options.dateColor, options)(input.toISOString());
219
+ if (typeof input === "string") {
220
+ if (isIsoStringDate(input)) return getColorRenderer(options.dateColor, options)(input);
221
+ return getColorRenderer(options.stringColor, options)(input);
222
+ }
223
+ const sInput = `${input}`;
224
+ if (typeof input === "boolean") return getColorRenderer(options.booleanColor, options)(sInput);
225
+ if (input === null || input === void 0) return getColorRenderer(options.nullUndefinedColor, options)(sInput);
226
+ if (typeof input === "number") {
227
+ if (input >= 0) return getColorRenderer(options.positiveNumberColor, options)(sInput);
228
+ return getColorRenderer(options.negativeNumberColor, options)(sInput);
229
+ }
230
+ if (typeof input === "function") return "function() {}";
231
+ if (Array.isArray(input)) return input.join(", ");
232
+ return sInput;
196
233
  };
197
- var colorMultilineString = (options, line) => getColorRenderer(options.multilineStringColor, options)(line);
198
- var indentLines = (string, spaces, options) => {
199
- let lines = string.split("\n");
200
- lines = lines.map((line) => indent(spaces) + colorMultilineString(options, line));
201
- return lines.join("\n");
234
+ const colorMultilineString = (options, line) => getColorRenderer(options.multilineStringColor, options)(line);
235
+ const indentLines = (string, spaces, options) => {
236
+ let lines = string.split("\n");
237
+ lines = lines.map((line) => indent(spaces) + colorMultilineString(options, line));
238
+ return lines.join("\n");
202
239
  };
203
- var renderToArray = (data, options, indentation) => {
204
- if (typeof data === "string" && data.match(conflictChars) && options.escape) {
205
- data = JSON.stringify(data);
206
- }
207
- if (!isPrintable(data, options)) {
208
- return [];
209
- }
210
- if (isSerializable(data, false, options)) {
211
- return [indent(indentation) + addColorToData(data, options)];
212
- }
213
- if (typeof data === "string") {
214
- return [
215
- indent(indentation) + colorMultilineString(options, '"""'),
216
- indentLines(data, indentation + options.defaultIndentation, options),
217
- indent(indentation) + colorMultilineString(options, '"""')
218
- ];
219
- }
220
- if (Array.isArray(data)) {
221
- if (data.length === 0) {
222
- return [indent(indentation) + options.emptyArrayMsg];
223
- }
224
- if (options.collapseArrays && data.length > 0) {
225
- return [`${indent(indentation)}[... ${data.length} items]`];
226
- }
227
- const outputArray = [];
228
- data.forEach((element) => {
229
- if (!isPrintable(element, options)) {
230
- return;
231
- }
232
- let line = "- ";
233
- line = getColorRenderer(options.dashColor, options)(line);
234
- line = indent(indentation) + line;
235
- if (isSerializable(element, false, options)) {
236
- line += renderToArray(element, options, 0)[0];
237
- outputArray.push(line);
238
- } else {
239
- outputArray.push(line);
240
- outputArray.push.apply(outputArray, renderToArray(element, options, indentation + options.defaultIndentation));
241
- }
242
- });
243
- return outputArray;
244
- }
245
- if (data instanceof Error) {
246
- return renderToArray(
247
- {
248
- message: data.message,
249
- stack: data.stack.split("\n")
250
- },
251
- options,
252
- indentation
253
- );
254
- }
255
- const maxIndexLength = options.noAlign ? 0 : getMaxIndexLength(data);
256
- let key;
257
- const output = [];
258
- Object.getOwnPropertyNames(data).forEach((i) => {
259
- if (!isPrintable(data[i], options)) {
260
- return;
261
- }
262
- key = `${i}: `;
263
- key = getColorRenderer(options.keysColor, options)(key);
264
- key = indent(indentation) + key;
265
- if (isSerializable(data[i], false, options)) {
266
- const nextIndentation = options.noAlign ? 0 : maxIndexLength - i.length;
267
- key += renderToArray(data[i], options, nextIndentation)[0];
268
- output.push(key);
269
- } else {
270
- output.push(key);
271
- output.push.apply(output, renderToArray(data[i], options, indentation + options.defaultIndentation));
272
- }
273
- });
274
- return output;
240
+ const renderToArray = (data, options, indentation) => {
241
+ if (typeof data === "string" && data.match(conflictChars) && options.escape) data = JSON.stringify(data);
242
+ if (!isPrintable(data, options)) return [];
243
+ if (isSerializable(data, false, options)) return [indent(indentation) + addColorToData(data, options)];
244
+ if (typeof data === "string") return [
245
+ indent(indentation) + colorMultilineString(options, "\"\"\""),
246
+ indentLines(data, indentation + options.defaultIndentation, options),
247
+ indent(indentation) + colorMultilineString(options, "\"\"\"")
248
+ ];
249
+ if (Array.isArray(data)) {
250
+ if (data.length === 0) return [indent(indentation) + options.emptyArrayMsg];
251
+ if (options.collapseArrays && data.length > 0) return [`${indent(indentation)}[... ${data.length} items]`];
252
+ const outputArray = [];
253
+ data.forEach((element) => {
254
+ if (!isPrintable(element, options)) return;
255
+ let line = "- ";
256
+ line = getColorRenderer(options.dashColor, options)(line);
257
+ line = indent(indentation) + line;
258
+ if (isSerializable(element, false, options)) {
259
+ line += renderToArray(element, options, 0)[0];
260
+ outputArray.push(line);
261
+ } else {
262
+ outputArray.push(line);
263
+ outputArray.push.apply(outputArray, renderToArray(element, options, indentation + options.defaultIndentation));
264
+ }
265
+ });
266
+ return outputArray;
267
+ }
268
+ if (data instanceof Error) return renderToArray({
269
+ message: data.message,
270
+ stack: data.stack.split("\n")
271
+ }, options, indentation);
272
+ const maxIndexLength = options.noAlign ? 0 : getMaxIndexLength(data);
273
+ let key;
274
+ const output = [];
275
+ Object.getOwnPropertyNames(data).forEach((i) => {
276
+ if (!isPrintable(data[i], options)) return;
277
+ key = `${i}: `;
278
+ key = getColorRenderer(options.keysColor, options)(key);
279
+ key = indent(indentation) + key;
280
+ if (isSerializable(data[i], false, options)) {
281
+ const nextIndentation = options.noAlign ? 0 : maxIndexLength - i.length;
282
+ key += renderToArray(data[i], options, nextIndentation)[0];
283
+ output.push(key);
284
+ } else {
285
+ output.push(key);
286
+ output.push.apply(output, renderToArray(data[i], options, indentation + options.defaultIndentation));
287
+ }
288
+ });
289
+ return output;
275
290
  };
276
- var validateOptionsAndSetDefaults = (options) => {
277
- options = options || {};
278
- options.emptyArrayMsg = options.emptyArrayMsg || "(empty array)";
279
- options.keysColor = options.keysColor || _chalk2.default.green;
280
- options.dashColor = options.dashColor || _chalk2.default.green;
281
- options.booleanColor = options.booleanColor || _chalk2.default.cyan;
282
- options.nullUndefinedColor = options.nullUndefinedColor || _chalk2.default.grey;
283
- options.numberColor = options.numberColor || _chalk2.default.blue;
284
- options.positiveNumberColor = options.positiveNumberColor || options.numberColor;
285
- options.negativeNumberColor = options.negativeNumberColor || options.numberColor;
286
- options.dateColor = options.dateColor || _chalk2.default.magenta;
287
- options.defaultIndentation = options.defaultIndentation || 2;
288
- options.noColor = !!options.noColor;
289
- options.noAlign = !!options.noAlign;
290
- options.escape = !!options.escape;
291
- options.renderUndefined = !!options.renderUndefined;
292
- options.collapseArrays = !!options.collapseArrays;
293
- options.stringColor = options.stringColor || null;
294
- options.multilineStringColor = options.multilineStringColor || options.stringColor || null;
295
- return options;
291
+ /**
292
+ * @typedef {Object} PrettyJSONOptions
293
+ * @property {Function} [stringColor=null] Chalk color function for strings
294
+ * @property {Function} [multilineStringColor=null] Chalk color function for multiline strings
295
+ * @property {Function} [keysColor=chalk.green] Chalk color function for keys in hashes
296
+ * @property {Function} [dashColor=chalk.green] Chalk color function for dashes in arrays
297
+ * @property {Function} [numberColor=chalk.blue] Default Chalk color function for numbers
298
+ * @property {Function} [positiveNumberColor=numberColor] Chalk color function for positive numbers
299
+ * @property {Function} [negativeNumberColor=numberColor] Chalk color function for negative numbers
300
+ * @property {Function} [booleanColor=chalk.cyan] Chalk color function for boolean values
301
+ * @property {Function} [nullUndefinedColor=chalk.grey] Chalk color function for null || undefined
302
+ * @property {Function} [dateColor=chalk.magenta] Chalk color function for Date objects
303
+ * @property {number} [defaultIndentation=2] Indentation spaces per object level
304
+ * @property {string} [emptyArrayMsg="(empty array)"] Replace empty strings with
305
+ * @property {boolean} [noColor] Flag to disable colors
306
+ * @property {boolean} [noAlign] Flag to disable alignment
307
+ * @property {boolean} [escape] Flag to escape printed content
308
+ * @property {boolean} [collapseArrays] Flag to collapse arrays
309
+ */
310
+ /**
311
+ * Mutating function that ensures we have a valid options object
312
+ * @param {PrettyJSONOptions} options
313
+ * @returns PrettyJSONOptions
314
+ */
315
+ const validateOptionsAndSetDefaults = (options) => {
316
+ options = options || {};
317
+ options.emptyArrayMsg = options.emptyArrayMsg || "(empty array)";
318
+ options.keysColor = options.keysColor || chalk.default.green;
319
+ options.dashColor = options.dashColor || chalk.default.green;
320
+ options.booleanColor = options.booleanColor || chalk.default.cyan;
321
+ options.nullUndefinedColor = options.nullUndefinedColor || chalk.default.grey;
322
+ options.numberColor = options.numberColor || chalk.default.blue;
323
+ options.positiveNumberColor = options.positiveNumberColor || options.numberColor;
324
+ options.negativeNumberColor = options.negativeNumberColor || options.numberColor;
325
+ options.dateColor = options.dateColor || chalk.default.magenta;
326
+ options.defaultIndentation = options.defaultIndentation || 2;
327
+ options.noColor = !!options.noColor;
328
+ options.noAlign = !!options.noAlign;
329
+ options.escape = !!options.escape;
330
+ options.renderUndefined = !!options.renderUndefined;
331
+ options.collapseArrays = !!options.collapseArrays;
332
+ options.stringColor = options.stringColor || null;
333
+ options.multilineStringColor = options.multilineStringColor || options.stringColor || null;
334
+ return options;
296
335
  };
336
+ /**
337
+ * ### Render function
338
+ * *Parameters:*
339
+ *
340
+ * @param {*} data: Data to render
341
+ * @param {PrettyJSONOptions} options: Hash of different options
342
+ * @param {*} indentation **`indentation`**: Base indentation of the output
343
+ *
344
+ * *Example of options hash:*
345
+ *
346
+ * {
347
+ * emptyArrayMsg: '(empty)', // Rendered message on empty strings
348
+ * keysColor: 'blue', // Color for keys in hashes
349
+ * dashColor: 'red', // Color for the dashes in arrays
350
+ * stringColor: 'grey', // Color for strings
351
+ * multilineStringColor: 'cyan' // Color for multiline strings
352
+ * defaultIndentation: 2 // Indentation on nested objects
353
+ * }
354
+ * @returns string with the rendered data
355
+ */
297
356
  function render(data, options, indentation) {
298
- indentation = indentation || 0;
299
- options = validateOptionsAndSetDefaults(options);
300
- return renderToArray(data, options, indentation).join("\n");
357
+ indentation = indentation || 0;
358
+ options = validateOptionsAndSetDefaults(options);
359
+ return renderToArray(data, options, indentation).join("\n");
301
360
  }
302
361
 
303
- // src/views/utils.ts
304
-
305
- var _datefns = require('date-fns');
362
+ //#endregion
363
+ //#region src/views/utils.ts
364
+ /**
365
+ * Formats a timestamp into a readable string.
366
+ *
367
+ * @param timestamp - Unix timestamp in milliseconds
368
+ * @param colorFn - Chalk function to color the timestamp
369
+ * @param timestampFormat - Custom format string (date-fns) or function. Defaults to "HH:mm:ss.SSS"
370
+ * @returns Formatted timestamp string
371
+ */
306
372
  function formatTimestamp(timestamp, colorFn, timestampFormat = "HH:mm:ss.SSS") {
307
- let formattedTime;
308
- if (typeof timestampFormat === "function") {
309
- formattedTime = timestampFormat(timestamp);
310
- } else {
311
- const date = new Date(timestamp);
312
- formattedTime = _datefns.format.call(void 0, date, timestampFormat);
313
- }
314
- return colorFn(`[${formattedTime}]`);
373
+ let formattedTime;
374
+ if (typeof timestampFormat === "function") formattedTime = timestampFormat(timestamp);
375
+ else formattedTime = (0, date_fns.format)(new Date(timestamp), timestampFormat);
376
+ return colorFn(`[${formattedTime}]`);
315
377
  }
378
+ /**
379
+ * Gets the appropriate color function for a log level.
380
+ *
381
+ * @param level - Log level string
382
+ * @param colors - Color configuration object
383
+ * @returns Chalk function for the log level
384
+ */
316
385
  function getLevelColor(level, colors) {
317
- const levelLower = level.toLowerCase();
318
- switch (levelLower) {
319
- case "trace":
320
- return colors.trace || _chalk2.default.white;
321
- case "debug":
322
- return colors.debug || _chalk2.default.white;
323
- case "info":
324
- return colors.info || _chalk2.default.white;
325
- case "warn":
326
- return colors.warn || _chalk2.default.white;
327
- case "error":
328
- return colors.error || _chalk2.default.white;
329
- case "fatal":
330
- return colors.fatal || _chalk2.default.white;
331
- default:
332
- return colors.info || _chalk2.default.white;
333
- }
386
+ switch (level.toLowerCase()) {
387
+ case "trace": return colors.trace || chalk.default.white;
388
+ case "debug": return colors.debug || chalk.default.white;
389
+ case "info": return colors.info || chalk.default.white;
390
+ case "warn": return colors.warn || chalk.default.white;
391
+ case "error": return colors.error || chalk.default.white;
392
+ case "fatal": return colors.fatal || chalk.default.white;
393
+ default: return colors.info || chalk.default.white;
394
+ }
334
395
  }
396
+ /**
397
+ * Formats a value for display.
398
+ */
335
399
  function formatValue(value, expanded = false, collapseArrays = true) {
336
- if (typeof value === "string") return value;
337
- if (typeof value === "number" || typeof value === "boolean") return value.toString();
338
- if (value === null) return "null";
339
- if (value === void 0) return "undefined";
340
- if (Array.isArray(value)) return expanded ? JSON.stringify(value) : collapseArrays ? "[...]" : value.toString();
341
- if (typeof value === "object") return expanded ? JSON.stringify(value) : "{...}";
342
- return value.toString();
400
+ if (typeof value === "string") return value;
401
+ if (typeof value === "number" || typeof value === "boolean") return value.toString();
402
+ if (value === null) return "null";
403
+ if (value === void 0) return "undefined";
404
+ if (Array.isArray(value)) return expanded ? JSON.stringify(value) : collapseArrays ? "[...]" : value.toString();
405
+ if (typeof value === "object") return expanded ? JSON.stringify(value) : "{...}";
406
+ return value.toString();
343
407
  }
408
+ /**
409
+ * Formats structured data for inline display with depth limiting.
410
+ *
411
+ * @param data - The data to format
412
+ * @param config - View configuration for colors
413
+ * @param maxDepth - Maximum depth for nested objects
414
+ * @param expanded - Whether to show full depth (for inline view mode)
415
+ * @param collapseArrays - Whether to collapse arrays to summary format
416
+ * @returns Formatted data string
417
+ */
344
418
  function formatInlineData(data, config, maxDepth, expanded = false, collapseArrays = true) {
345
- if (!data) return "";
346
- const pairs = [];
347
- const traverse = (obj, prefix = "", depth = 0) => {
348
- if (!expanded && depth >= maxDepth) return;
349
- for (const [key, value] of Object.entries(obj)) {
350
- const fullKey = prefix ? `${prefix}.${key}` : key;
351
- if (value && typeof value === "object" && !Array.isArray(value)) {
352
- if (expanded) {
353
- pairs.push(`${config.dataKeyColor(fullKey)}=${config.dataValueColor(JSON.stringify(value))}`);
354
- } else {
355
- traverse(value, fullKey, depth + 1);
356
- }
357
- } else {
358
- pairs.push(
359
- `${config.dataKeyColor(fullKey)}=${config.dataValueColor(formatValue(value, expanded, collapseArrays))}`
360
- );
361
- }
362
- }
363
- };
364
- traverse(data);
365
- const result = pairs.join(" ");
366
- return result;
419
+ if (!data) return "";
420
+ const pairs = [];
421
+ const traverse = (obj, prefix = "", depth = 0) => {
422
+ if (!expanded && depth >= maxDepth) return;
423
+ for (const [key, value] of Object.entries(obj)) {
424
+ const fullKey = prefix ? `${prefix}.${key}` : key;
425
+ if (value && typeof value === "object" && !Array.isArray(value)) if (expanded) pairs.push(`${config.dataKeyColor(fullKey)}=${config.dataValueColor(JSON.stringify(value))}`);
426
+ else traverse(value, fullKey, depth + 1);
427
+ else pairs.push(`${config.dataKeyColor(fullKey)}=${config.dataValueColor(formatValue(value, expanded, collapseArrays))}`);
428
+ }
429
+ };
430
+ traverse(data);
431
+ return pairs.join(" ");
367
432
  }
368
433
 
369
- // src/views/SimpleView.ts
434
+ //#endregion
435
+ //#region src/views/SimpleView.ts
436
+ /**
437
+ * Handles rendering of the simple view mode.
438
+ * Supports three display modes:
439
+ * - Message-only: Shows timestamp, level and message
440
+ * - Inline: Shows all details with complete data inline
441
+ * - Expanded: Shows timestamp, level, and message on first line, with data on indented separate lines
442
+ */
370
443
  var SimpleView = class {
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
- constructor(config) {
381
- this.config = config;
382
- this.viewMode = config.viewMode;
383
- this.maxInlineDepth = config.maxInlineDepth;
384
- this.showLogId = config.showLogId;
385
- this.timestampFormat = config.timestampFormat;
386
- this.collapseArrays = config.collapseArrays !== false;
387
- this.flattenNestedObjects = config.flattenNestedObjects !== false;
388
- this.runtime = config.runtime;
389
- this.includeDataInBrowserConsole = config.includeDataInBrowserConsole || false;
390
- }
391
- getConfig() {
392
- return this.config;
393
- }
394
- getViewMode() {
395
- return this.viewMode;
396
- }
397
- /**
398
- * Writes a message to the appropriate output based on runtime
399
- */
400
- writeMessage(message, level, data) {
401
- if (this.runtime === "node") {
402
- _optionalChain([process, 'optionalAccess', _ => _.stdout, 'optionalAccess', _2 => _2.write, 'optionalCall', _3 => _3(`${message}
403
- `)]);
404
- } else {
405
- const shouldIncludeData = this.includeDataInBrowserConsole && data !== void 0;
406
- switch (level) {
407
- case "trace":
408
- if (shouldIncludeData) {
409
- console.debug(message, data);
410
- } else {
411
- console.debug(message);
412
- }
413
- break;
414
- case "debug":
415
- if (shouldIncludeData) {
416
- console.debug(message, data);
417
- } else {
418
- console.debug(message);
419
- }
420
- break;
421
- case "info":
422
- if (shouldIncludeData) {
423
- console.info(message, data);
424
- } else {
425
- console.info(message);
426
- }
427
- break;
428
- case "warn":
429
- if (shouldIncludeData) {
430
- console.warn(message, data);
431
- } else {
432
- console.warn(message);
433
- }
434
- break;
435
- case "error":
436
- case "fatal":
437
- if (shouldIncludeData) {
438
- console.error(message, data);
439
- } else {
440
- console.error(message);
441
- }
442
- break;
443
- default:
444
- if (shouldIncludeData) {
445
- console.log(message, data);
446
- } else {
447
- console.log(message);
448
- }
449
- break;
450
- }
451
- }
452
- }
453
- /**
454
- * Renders a single log entry based on the current view mode
455
- */
456
- renderLogLine(entry) {
457
- const levelColor = getLevelColor(entry.level, this.config.config.colors);
458
- const chevron = levelColor(`\u25B6 ${entry.level.toUpperCase()} `);
459
- const message = entry.message || "(no message)";
460
- const timestamp = formatTimestamp(entry.timestamp, this.config.config.logIdColor, this.timestampFormat);
461
- const parsedData = entry.data ? JSON.parse(entry.data) : void 0;
462
- switch (this.viewMode) {
463
- case "message-only": {
464
- const condensedLine = `${timestamp} ${chevron}${message}`;
465
- this.writeMessage(condensedLine, entry.level, parsedData);
466
- break;
467
- }
468
- case "inline": {
469
- const logId = this.showLogId ? this.config.config.logIdColor(`[${entry.id}]`) : "";
470
- const fullData = entry.data ? formatInlineData(
471
- JSON.parse(entry.data),
472
- this.config.config,
473
- this.maxInlineDepth,
474
- !this.flattenNestedObjects,
475
- this.collapseArrays
476
- ) : "";
477
- const expandedLine = `${timestamp} ${chevron}${logId ? `${logId} ` : ""}${message}${fullData ? ` ${fullData}` : ""}`;
478
- this.writeMessage(expandedLine, entry.level, parsedData);
479
- break;
480
- }
481
- case "expanded": {
482
- const logId = this.showLogId ? this.config.config.logIdColor(`[${entry.id}]`) : "";
483
- const firstLine = `${timestamp} ${chevron}${logId ? `${logId} ` : ""}${message}`;
484
- this.writeMessage(firstLine, entry.level, parsedData);
485
- if (entry.data) {
486
- const jsonLines = render(JSON.parse(entry.data), {
487
- defaultIndentation: 2,
488
- keysColor: this.config.config.dataKeyColor,
489
- dashColor: this.config.config.dataKeyColor,
490
- numberColor: this.config.config.dataValueColor,
491
- stringColor: this.config.config.dataValueColor,
492
- multilineStringColor: this.config.config.dataValueColor,
493
- positiveNumberColor: this.config.config.dataValueColor,
494
- negativeNumberColor: this.config.config.dataValueColor,
495
- booleanColor: this.config.config.dataValueColor,
496
- nullUndefinedColor: this.config.config.dataValueColor,
497
- dateColor: this.config.config.dataValueColor,
498
- collapseArrays: this.collapseArrays
499
- }).split("\n");
500
- for (const line of jsonLines) {
501
- if (line.trim() !== "") {
502
- this.writeMessage(` ${line}`, entry.level);
503
- }
504
- }
505
- }
506
- break;
507
- }
508
- default: {
509
- const logId = this.showLogId ? this.config.config.logIdColor(`[${entry.id}]`) : "";
510
- const fullData = entry.data ? formatInlineData(JSON.parse(entry.data), this.config.config, this.maxInlineDepth, true, this.collapseArrays) : "";
511
- const expandedLine = `${timestamp} ${chevron}${logId ? `${logId} ` : ""}${message}${fullData ? ` ${fullData}` : ""}`;
512
- this.writeMessage(expandedLine, entry.level, parsedData);
513
- break;
514
- }
515
- }
516
- }
444
+ config;
445
+ viewMode;
446
+ maxInlineDepth;
447
+ showLogId;
448
+ timestampFormat;
449
+ collapseArrays;
450
+ flattenNestedObjects;
451
+ runtime;
452
+ includeDataInBrowserConsole;
453
+ constructor(config) {
454
+ this.config = config;
455
+ this.viewMode = config.viewMode;
456
+ this.maxInlineDepth = config.maxInlineDepth;
457
+ this.showLogId = config.showLogId;
458
+ this.timestampFormat = config.timestampFormat;
459
+ this.collapseArrays = config.collapseArrays !== false;
460
+ this.flattenNestedObjects = config.flattenNestedObjects !== false;
461
+ this.runtime = config.runtime;
462
+ this.includeDataInBrowserConsole = config.includeDataInBrowserConsole || false;
463
+ }
464
+ getConfig() {
465
+ return this.config;
466
+ }
467
+ getViewMode() {
468
+ return this.viewMode;
469
+ }
470
+ /**
471
+ * Writes a message to the appropriate output based on runtime
472
+ */
473
+ writeMessage(message, level, data) {
474
+ if (this.runtime === "node") process?.stdout?.write?.(`${message}\n`);
475
+ else {
476
+ const shouldIncludeData = this.includeDataInBrowserConsole && data !== void 0;
477
+ switch (level) {
478
+ case "trace":
479
+ if (shouldIncludeData) console.debug(message, data);
480
+ else console.debug(message);
481
+ break;
482
+ case "debug":
483
+ if (shouldIncludeData) console.debug(message, data);
484
+ else console.debug(message);
485
+ break;
486
+ case "info":
487
+ if (shouldIncludeData) console.info(message, data);
488
+ else console.info(message);
489
+ break;
490
+ case "warn":
491
+ if (shouldIncludeData) console.warn(message, data);
492
+ else console.warn(message);
493
+ break;
494
+ case "error":
495
+ case "fatal":
496
+ if (shouldIncludeData) console.error(message, data);
497
+ else console.error(message);
498
+ break;
499
+ default:
500
+ if (shouldIncludeData) console.log(message, data);
501
+ else console.log(message);
502
+ break;
503
+ }
504
+ }
505
+ }
506
+ /**
507
+ * Renders a single log entry based on the current view mode
508
+ */
509
+ renderLogLine(entry) {
510
+ const chevron = getLevelColor(entry.level, this.config.config.colors)(`▶ ${entry.level.toUpperCase()} `);
511
+ const message = entry.message || "(no message)";
512
+ const timestamp = formatTimestamp(entry.timestamp, this.config.config.logIdColor, this.timestampFormat);
513
+ const parsedData = entry.data ? JSON.parse(entry.data) : void 0;
514
+ switch (this.viewMode) {
515
+ case "message-only": {
516
+ const condensedLine = `${timestamp} ${chevron}${message}`;
517
+ this.writeMessage(condensedLine, entry.level, parsedData);
518
+ break;
519
+ }
520
+ case "inline": {
521
+ const logId = this.showLogId ? this.config.config.logIdColor(`[${entry.id}]`) : "";
522
+ const fullData = entry.data ? formatInlineData(JSON.parse(entry.data), this.config.config, this.maxInlineDepth, !this.flattenNestedObjects, this.collapseArrays) : "";
523
+ const expandedLine = `${timestamp} ${chevron}${logId ? `${logId} ` : ""}${message}${fullData ? ` ${fullData}` : ""}`;
524
+ this.writeMessage(expandedLine, entry.level, parsedData);
525
+ break;
526
+ }
527
+ case "expanded": {
528
+ const logId = this.showLogId ? this.config.config.logIdColor(`[${entry.id}]`) : "";
529
+ const firstLine = `${timestamp} ${chevron}${logId ? `${logId} ` : ""}${message}`;
530
+ this.writeMessage(firstLine, entry.level, parsedData);
531
+ if (entry.data) {
532
+ const jsonLines = render(JSON.parse(entry.data), {
533
+ defaultIndentation: 2,
534
+ keysColor: this.config.config.dataKeyColor,
535
+ dashColor: this.config.config.dataKeyColor,
536
+ numberColor: this.config.config.dataValueColor,
537
+ stringColor: this.config.config.dataValueColor,
538
+ multilineStringColor: this.config.config.dataValueColor,
539
+ positiveNumberColor: this.config.config.dataValueColor,
540
+ negativeNumberColor: this.config.config.dataValueColor,
541
+ booleanColor: this.config.config.dataValueColor,
542
+ nullUndefinedColor: this.config.config.dataValueColor,
543
+ dateColor: this.config.config.dataValueColor,
544
+ collapseArrays: this.collapseArrays
545
+ }).split("\n");
546
+ for (const line of jsonLines) if (line.trim() !== "") this.writeMessage(` ${line}`, entry.level);
547
+ }
548
+ break;
549
+ }
550
+ default: {
551
+ const logId = this.showLogId ? this.config.config.logIdColor(`[${entry.id}]`) : "";
552
+ const fullData = entry.data ? formatInlineData(JSON.parse(entry.data), this.config.config, this.maxInlineDepth, true, this.collapseArrays) : "";
553
+ const expandedLine = `${timestamp} ${chevron}${logId ? `${logId} ` : ""}${message}${fullData ? ` ${fullData}` : ""}`;
554
+ this.writeMessage(expandedLine, entry.level, parsedData);
555
+ break;
556
+ }
557
+ }
558
+ }
517
559
  };
518
560
 
519
- // src/SimplePrettyTerminalTransport.ts
520
- var SimplePrettyTerminalTransport = class extends _transport.LoggerlessTransport {
521
- /** Handles rendering and formatting of logs */
522
-
523
- /** Configuration options */
524
-
525
- /**
526
- * Creates a new SimplePrettyTerminalTransport instance.
527
- *
528
- * @param config - Configuration options for the transport
529
- */
530
- constructor(config) {
531
- super(config);
532
- this.config = config;
533
- if (config.enabled === false) {
534
- return;
535
- }
536
- const maxInlineDepth = config.maxInlineDepth || 4;
537
- const theme = config.theme || moonlight;
538
- const viewMode = config.viewMode || "inline";
539
- const showLogId = config.showLogId || false;
540
- const timestampFormat = config.timestampFormat || "HH:mm:ss.SSS";
541
- const collapseArrays = config.collapseArrays !== false;
542
- const flattenNestedObjects = config.flattenNestedObjects !== false;
543
- const runtime = config.runtime;
544
- const includeDataInBrowserConsole = config.includeDataInBrowserConsole || false;
545
- const viewConfig = {
546
- colors: {
547
- trace: _chalk2.default.gray,
548
- // Lowest level, used for verbose output
549
- debug: _chalk2.default.blue,
550
- // Debug information
551
- info: _chalk2.default.green,
552
- // Normal operation
553
- warn: _chalk2.default.yellow,
554
- // Warning conditions
555
- error: _chalk2.default.red,
556
- // Error conditions
557
- fatal: _chalk2.default.bgRed.white,
558
- // Critical errors
559
- ...theme.colors
560
- },
561
- logIdColor: theme.logIdColor || _chalk2.default.dim,
562
- dataValueColor: theme.dataValueColor || _chalk2.default.white,
563
- dataKeyColor: theme.dataKeyColor || _chalk2.default.dim
564
- };
565
- this.renderer = new SimpleView({
566
- viewMode,
567
- maxInlineDepth,
568
- showLogId,
569
- timestampFormat,
570
- collapseArrays,
571
- flattenNestedObjects,
572
- runtime,
573
- includeDataInBrowserConsole,
574
- config: viewConfig
575
- });
576
- }
577
- /**
578
- * Generates a random ID for each log entry.
579
- * Uses base36 encoding for compact, readable IDs.
580
- *
581
- * @returns A 6-character string ID
582
- * @example
583
- * "a1b2c3" // Example generated ID
584
- */
585
- generateId() {
586
- return Math.random().toString(36).substring(2, 8);
587
- }
588
- /**
589
- * Main transport method that receives logs from LogLayer.
590
- * This method is called for each log event and handles:
591
- * - Generating a unique ID for the log
592
- * - Converting the log data to a storable format
593
- * - Rendering the log using the SimpleView renderer
594
- *
595
- * @param logLevel - The severity level of the log
596
- * @param messages - Array of message strings to be joined
597
- * @param data - Additional structured data to be logged
598
- * @param hasData - Whether the log includes additional data
599
- * @returns The original messages array
600
- */
601
- shipToLogger({ logLevel, messages, data, hasData }) {
602
- if (this.config.enabled === false) {
603
- return messages;
604
- }
605
- const entry = {
606
- id: this.generateId(),
607
- timestamp: Date.now(),
608
- level: logLevel,
609
- message: messages.join(" "),
610
- data: hasData ? JSON.stringify(data) : null
611
- };
612
- this.renderer.renderLogLine(entry);
613
- return messages;
614
- }
615
- /**
616
- * Changes the view mode for log display.
617
- *
618
- * @param viewMode - The new view mode to use
619
- */
620
- setViewMode(viewMode) {
621
- if (this.config.enabled === false) {
622
- return;
623
- }
624
- const theme = this.config.theme || moonlight;
625
- const runtime = this.config.runtime;
626
- const viewConfig = {
627
- colors: {
628
- trace: _chalk2.default.gray,
629
- debug: _chalk2.default.blue,
630
- info: _chalk2.default.green,
631
- warn: _chalk2.default.yellow,
632
- error: _chalk2.default.red,
633
- fatal: _chalk2.default.bgRed.white,
634
- ...theme.colors
635
- },
636
- logIdColor: theme.logIdColor || _chalk2.default.dim,
637
- dataValueColor: theme.dataValueColor || _chalk2.default.white,
638
- dataKeyColor: theme.dataKeyColor || _chalk2.default.dim
639
- };
640
- this.renderer = new SimpleView({
641
- viewMode,
642
- maxInlineDepth: this.config.maxInlineDepth || 4,
643
- showLogId: this.config.showLogId || false,
644
- timestampFormat: this.config.timestampFormat || "HH:mm:ss.SSS",
645
- collapseArrays: this.config.collapseArrays !== false,
646
- flattenNestedObjects: this.config.flattenNestedObjects !== false,
647
- runtime,
648
- includeDataInBrowserConsole: this.config.includeDataInBrowserConsole || false,
649
- config: viewConfig
650
- });
651
- }
652
- /**
653
- * Gets the current view mode.
654
- *
655
- * @returns The current view mode
656
- */
657
- getViewMode() {
658
- return this.renderer.getViewMode();
659
- }
561
+ //#endregion
562
+ //#region src/SimplePrettyTerminalTransport.ts
563
+ /**
564
+ * Main transport class that handles simple pretty terminal output.
565
+ * This class provides the display functionality of PrettyTerminal without interactive features.
566
+ *
567
+ * The transport supports three view modes:
568
+ * 1. Inline: Shows all information with complete data structures inline (no truncation)
569
+ * 2. Message-only: Shows only the timestamp, log level and message for a cleaner output (no data shown)
570
+ * 3. Expanded: Shows timestamp, level, and message on first line, with data on indented separate lines
571
+ */
572
+ var SimplePrettyTerminalTransport = class extends __loglayer_transport.LoggerlessTransport {
573
+ /** Handles rendering and formatting of logs */
574
+ renderer;
575
+ /** Configuration options */
576
+ config;
577
+ /**
578
+ * Creates a new SimplePrettyTerminalTransport instance.
579
+ *
580
+ * @param config - Configuration options for the transport
581
+ */
582
+ constructor(config) {
583
+ super(config);
584
+ this.config = config;
585
+ if (config.enabled === false) return;
586
+ const maxInlineDepth = config.maxInlineDepth || 4;
587
+ const theme = config.theme || moonlight;
588
+ const viewMode = config.viewMode || "inline";
589
+ const showLogId = config.showLogId || false;
590
+ const timestampFormat = config.timestampFormat || "HH:mm:ss.SSS";
591
+ const collapseArrays = config.collapseArrays !== false;
592
+ const flattenNestedObjects = config.flattenNestedObjects !== false;
593
+ const runtime = config.runtime;
594
+ this.renderer = new SimpleView({
595
+ viewMode,
596
+ maxInlineDepth,
597
+ showLogId,
598
+ timestampFormat,
599
+ collapseArrays,
600
+ flattenNestedObjects,
601
+ runtime,
602
+ includeDataInBrowserConsole: config.includeDataInBrowserConsole || false,
603
+ config: {
604
+ colors: {
605
+ trace: chalk.default.gray,
606
+ debug: chalk.default.blue,
607
+ info: chalk.default.green,
608
+ warn: chalk.default.yellow,
609
+ error: chalk.default.red,
610
+ fatal: chalk.default.bgRed.white,
611
+ ...theme.colors
612
+ },
613
+ logIdColor: theme.logIdColor || chalk.default.dim,
614
+ dataValueColor: theme.dataValueColor || chalk.default.white,
615
+ dataKeyColor: theme.dataKeyColor || chalk.default.dim
616
+ }
617
+ });
618
+ }
619
+ /**
620
+ * Generates a random ID for each log entry.
621
+ * Uses base36 encoding for compact, readable IDs.
622
+ *
623
+ * @returns A 6-character string ID
624
+ * @example
625
+ * "a1b2c3" // Example generated ID
626
+ */
627
+ generateId() {
628
+ return Math.random().toString(36).substring(2, 8);
629
+ }
630
+ /**
631
+ * Main transport method that receives logs from LogLayer.
632
+ * This method is called for each log event and handles:
633
+ * - Generating a unique ID for the log
634
+ * - Converting the log data to a storable format
635
+ * - Rendering the log using the SimpleView renderer
636
+ *
637
+ * @param logLevel - The severity level of the log
638
+ * @param messages - Array of message strings to be joined
639
+ * @param data - Additional structured data to be logged
640
+ * @param hasData - Whether the log includes additional data
641
+ * @returns The original messages array
642
+ */
643
+ shipToLogger({ logLevel, messages, data, hasData }) {
644
+ if (this.config.enabled === false) return messages;
645
+ const entry = {
646
+ id: this.generateId(),
647
+ timestamp: Date.now(),
648
+ level: logLevel,
649
+ message: messages.join(" "),
650
+ data: hasData ? JSON.stringify(data) : null
651
+ };
652
+ this.renderer.renderLogLine(entry);
653
+ return messages;
654
+ }
655
+ /**
656
+ * Changes the view mode for log display.
657
+ *
658
+ * @param viewMode - The new view mode to use
659
+ */
660
+ setViewMode(viewMode) {
661
+ if (this.config.enabled === false) return;
662
+ const theme = this.config.theme || moonlight;
663
+ const runtime = this.config.runtime;
664
+ const viewConfig = {
665
+ colors: {
666
+ trace: chalk.default.gray,
667
+ debug: chalk.default.blue,
668
+ info: chalk.default.green,
669
+ warn: chalk.default.yellow,
670
+ error: chalk.default.red,
671
+ fatal: chalk.default.bgRed.white,
672
+ ...theme.colors
673
+ },
674
+ logIdColor: theme.logIdColor || chalk.default.dim,
675
+ dataValueColor: theme.dataValueColor || chalk.default.white,
676
+ dataKeyColor: theme.dataKeyColor || chalk.default.dim
677
+ };
678
+ this.renderer = new SimpleView({
679
+ viewMode,
680
+ maxInlineDepth: this.config.maxInlineDepth || 4,
681
+ showLogId: this.config.showLogId || false,
682
+ timestampFormat: this.config.timestampFormat || "HH:mm:ss.SSS",
683
+ collapseArrays: this.config.collapseArrays !== false,
684
+ flattenNestedObjects: this.config.flattenNestedObjects !== false,
685
+ runtime,
686
+ includeDataInBrowserConsole: this.config.includeDataInBrowserConsole || false,
687
+ config: viewConfig
688
+ });
689
+ }
690
+ /**
691
+ * Gets the current view mode.
692
+ *
693
+ * @returns The current view mode
694
+ */
695
+ getViewMode() {
696
+ return this.renderer.getViewMode();
697
+ }
660
698
  };
661
699
 
662
- // src/index.ts
663
-
700
+ //#endregion
701
+ //#region src/index.ts
664
702
  function getSimplePrettyTerminal(config) {
665
- return new SimplePrettyTerminalTransport(config);
703
+ return new SimplePrettyTerminalTransport(config);
666
704
  }
667
705
 
706
+ //#endregion
707
+ exports.SimplePrettyTerminalTransport = SimplePrettyTerminalTransport;
708
+ exports.getSimplePrettyTerminal = getSimplePrettyTerminal;
709
+ exports.moonlight = moonlight;
710
+ exports.nature = nature;
711
+ exports.neon = neon;
712
+ exports.pastel = pastel;
713
+ exports.sunlight = sunlight;
714
+ Object.keys(chalk).forEach(function (k) {
715
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
716
+ enumerable: true,
717
+ get: function () { return chalk[k]; }
718
+ });
719
+ });
668
720
 
669
-
670
-
671
-
672
-
673
-
674
-
675
- exports.SimplePrettyTerminalTransport = SimplePrettyTerminalTransport; exports.getSimplePrettyTerminal = getSimplePrettyTerminal; exports.moonlight = moonlight; exports.nature = nature; exports.neon = neon; exports.pastel = pastel; exports.sunlight = sunlight;
676
721
  //# sourceMappingURL=index.cjs.map