@visulima/pail 4.0.0-alpha.9 → 4.0.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +511 -0
  2. package/LICENSE.md +270 -166
  3. package/README.md +53 -24
  4. package/dist/error.d.ts +95 -96
  5. package/dist/error.js +5 -76
  6. package/dist/index.browser.d.ts +568 -47
  7. package/dist/index.browser.js +19 -1499
  8. package/dist/index.server.d.ts +749 -65
  9. package/dist/index.server.js +32 -3179
  10. package/dist/middleware/elysia.d.ts +66 -63
  11. package/dist/middleware/elysia.js +1 -70
  12. package/dist/middleware/express.d.ts +74 -71
  13. package/dist/middleware/express.js +1 -29
  14. package/dist/middleware/fastify.d.ts +70 -67
  15. package/dist/middleware/fastify.js +1 -46
  16. package/dist/middleware/hono.d.ts +75 -72
  17. package/dist/middleware/hono.js +1 -33
  18. package/dist/middleware/next/handler.d.ts +102 -34
  19. package/dist/middleware/next/handler.js +1 -53
  20. package/dist/middleware/sveltekit.d.ts +101 -98
  21. package/dist/middleware/sveltekit.js +1 -43
  22. package/dist/object-tree.d.ts +67 -70
  23. package/dist/object-tree.js +2 -89
  24. package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
  25. package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +1 -0
  26. package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +2 -0
  27. package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
  28. package/dist/packem_shared/PailError-CbU1Ogfa.js +5 -0
  29. package/dist/packem_shared/PrettyReporter-CcDdPQSt.js +44 -0
  30. package/dist/packem_shared/PrettyReporter-DsHfKOU7.js +5 -0
  31. package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +62 -0
  32. package/dist/packem_shared/abstract-pretty-reporter-DrLBJ6ds.js +57 -0
  33. package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +25 -0
  34. package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
  35. package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
  36. package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +47 -0
  37. package/dist/packem_shared/headers-DH0H2s8W.js +1 -0
  38. package/dist/packem_shared/index-Q1764hvO.js +1 -0
  39. package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
  40. package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +1 -0
  41. package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
  42. package/dist/packem_shared/storage-DaXAlpiO.js +1 -0
  43. package/dist/packem_shared/types.d-Cz9S7jZh.d.ts +201 -0
  44. package/dist/packem_shared/types.d-bWnqHJKL.d.ts +211 -0
  45. package/dist/packem_shared/types.d-xxE3FOD3.d.ts +229 -0
  46. package/dist/packem_shared/useLogger-DB34CuU5.js +1 -0
  47. package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +717 -0
  48. package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
  49. package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
  50. package/dist/processor/caller/caller-processor.d.ts +50 -47
  51. package/dist/processor/caller/caller-processor.js +1 -59
  52. package/dist/processor/environment-processor.d.ts +114 -113
  53. package/dist/processor/environment-processor.js +1 -78
  54. package/dist/processor/message-formatter-processor.d.ts +59 -49
  55. package/dist/processor/message-formatter-processor.js +1 -713
  56. package/dist/processor/opentelemetry-processor.d.ts +70 -66
  57. package/dist/processor/opentelemetry-processor.js +1 -52
  58. package/dist/processor/redact-processor.d.ts +99 -41
  59. package/dist/processor/redact-processor.js +1 -30
  60. package/dist/processor/sampling-processor.d.ts +103 -101
  61. package/dist/processor/sampling-processor.js +1 -59
  62. package/dist/reporter/file/json-file-reporter.d.ts +109 -42
  63. package/dist/reporter/file/json-file-reporter.js +2 -136
  64. package/dist/reporter/http/abstract-http-reporter.d.ts +256 -211
  65. package/dist/reporter/http/abstract-http-reporter.js +2 -435
  66. package/dist/reporter/http/http-reporter.d.ts +41 -36
  67. package/dist/reporter/http/http-reporter.edge-light.d.ts +487 -39
  68. package/dist/reporter/http/http-reporter.edge-light.js +2 -733
  69. package/dist/reporter/http/http-reporter.js +1 -13
  70. package/dist/reporter/json/index.browser.d.ts +98 -3
  71. package/dist/reporter/json/index.browser.js +1 -2
  72. package/dist/reporter/json/index.d.ts +53 -3
  73. package/dist/reporter/json/index.js +1 -2
  74. package/dist/reporter/pretty/index.browser.d.ts +105 -2
  75. package/dist/reporter/pretty/index.browser.js +1 -1
  76. package/dist/reporter/pretty/index.d.ts +270 -2
  77. package/dist/reporter/pretty/index.js +1 -1
  78. package/dist/reporter/simple/simple-reporter.server.d.ts +215 -18
  79. package/dist/reporter/simple/simple-reporter.server.js +8 -182
  80. package/dist/wide-event.d.ts +6 -300
  81. package/dist/wide-event.js +1 -281
  82. package/package.json +22 -37
  83. package/dist/constants.d.ts +0 -37
  84. package/dist/interactive/index.d.ts +0 -2
  85. package/dist/interactive/index.js +0 -2
  86. package/dist/interactive/interactive-manager.d.ts +0 -108
  87. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  88. package/dist/middleware/next/middleware.d.ts +0 -59
  89. package/dist/middleware/next/storage.d.ts +0 -14
  90. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  91. package/dist/middleware/shared/headers.d.ts +0 -14
  92. package/dist/middleware/shared/routes.d.ts +0 -30
  93. package/dist/middleware/shared/storage.d.ts +0 -29
  94. package/dist/packem_shared/AbstractJsonReporter-CGKHS8_M.js +0 -286
  95. package/dist/packem_shared/AbstractJsonReporter-DDjDkciI.js +0 -286
  96. package/dist/packem_shared/InteractiveManager-Cd6A14ZK.js +0 -172
  97. package/dist/packem_shared/InteractiveStreamHook-ePIURL_U.js +0 -133
  98. package/dist/packem_shared/JsonReporter-B3XX8GHN.js +0 -58
  99. package/dist/packem_shared/JsonReporter-p_BXg6Sj.js +0 -28
  100. package/dist/packem_shared/PrettyReporter-BYL3NrdA.js +0 -214
  101. package/dist/packem_shared/PrettyReporter-CvBn-hxP.js +0 -1459
  102. package/dist/packem_shared/Spinner-DIdVcfWq.js +0 -2183
  103. package/dist/packem_shared/abstract-pretty-reporter-jU8WL_6c.js +0 -2602
  104. package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
  105. package/dist/packem_shared/constants-omsTHUWB.js +0 -119
  106. package/dist/packem_shared/createPailError-B11aRfrT.js +0 -76
  107. package/dist/packem_shared/getBarChar-BWj1UrH3.js +0 -404
  108. package/dist/packem_shared/headers-Cp4uLtr4.js +0 -123
  109. package/dist/packem_shared/index-DnkF86LQ.js +0 -658
  110. package/dist/packem_shared/index-frijFf5m.js +0 -1252
  111. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
  112. package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
  113. package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
  114. package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +0 -14
  115. package/dist/packem_shared/write-stream-BG8fhcs3.js +0 -6
  116. package/dist/pail.browser.d.ts +0 -412
  117. package/dist/pail.server.d.ts +0 -233
  118. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  119. package/dist/progress-bar.d.ts +0 -136
  120. package/dist/progress-bar.js +0 -404
  121. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  122. package/dist/reporter/http/utils/compression.d.ts +0 -7
  123. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  124. package/dist/reporter/http/utils/retry.d.ts +0 -27
  125. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  126. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  127. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  128. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  129. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  130. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  131. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  132. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  133. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  134. package/dist/reporter/utils/format-label.d.ts +0 -3
  135. package/dist/spinner.d.ts +0 -220
  136. package/dist/spinner.js +0 -2183
  137. package/dist/types.d.ts +0 -241
  138. package/dist/utils/ansi-escapes.d.ts +0 -4
  139. package/dist/utils/arrayify.d.ts +0 -2
  140. package/dist/utils/get-longest-badge.d.ts +0 -4
  141. package/dist/utils/get-longest-label.d.ts +0 -4
  142. package/dist/utils/merge-types.d.ts +0 -4
  143. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  144. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  145. package/dist/utils/write-stream.d.ts +0 -2
@@ -1,713 +1 @@
1
- const colorKeywords = /* @__PURE__ */ new Map([
2
- ["aliceblue", "#f0f8ff"],
3
- ["antiquewhite", "#faebd7"],
4
- ["aqua", "#00ffff"],
5
- ["aquamarine", "#7fffd4"],
6
- ["azure", "#f0ffff"],
7
- ["beige", "#f5f5dc"],
8
- ["bisque", "#ffe4c4"],
9
- ["black", "#000000"],
10
- ["blanchedalmond", "#ffebcd"],
11
- ["blue", "#0000ff"],
12
- ["blueviolet", "#8a2be2"],
13
- ["brown", "#a52a2a"],
14
- ["burlywood", "#deb887"],
15
- ["cadetblue", "#5f9ea0"],
16
- ["chartreuse", "#7fff00"],
17
- ["chocolate", "#d2691e"],
18
- ["coral", "#ff7f50"],
19
- ["cornflowerblue", "#6495ed"],
20
- ["cornsilk", "#fff8dc"],
21
- ["crimson", "#dc143c"],
22
- ["cyan", "#00ffff"],
23
- ["darkblue", "#00008b"],
24
- ["darkcyan", "#008b8b"],
25
- ["darkgoldenrod", "#b8860b"],
26
- ["darkgray", "#a9a9a9"],
27
- ["darkgreen", "#006400"],
28
- ["darkgrey", "#a9a9a9"],
29
- ["darkkhaki", "#bdb76b"],
30
- ["darkmagenta", "#8b008b"],
31
- ["darkolivegreen", "#556b2f"],
32
- ["darkorange", "#ff8c00"],
33
- ["darkorchid", "#9932cc"],
34
- ["darkred", "#8b0000"],
35
- ["darksalmon", "#e9967a"],
36
- ["darkseagreen", "#8fbc8f"],
37
- ["darkslateblue", "#483d8b"],
38
- ["darkslategray", "#2f4f4f"],
39
- ["darkslategrey", "#2f4f4f"],
40
- ["darkturquoise", "#00ced1"],
41
- ["darkviolet", "#9400d3"],
42
- ["deeppink", "#ff1493"],
43
- ["deepskyblue", "#00bfff"],
44
- ["dimgray", "#696969"],
45
- ["dimgrey", "#696969"],
46
- ["dodgerblue", "#1e90ff"],
47
- ["firebrick", "#b22222"],
48
- ["floralwhite", "#fffaf0"],
49
- ["forestgreen", "#228b22"],
50
- ["fuchsia", "#ff00ff"],
51
- ["gainsboro", "#dcdcdc"],
52
- ["ghostwhite", "#f8f8ff"],
53
- ["gold", "#ffd700"],
54
- ["goldenrod", "#daa520"],
55
- ["gray", "#808080"],
56
- ["green", "#008000"],
57
- ["greenyellow", "#adff2f"],
58
- ["grey", "#808080"],
59
- ["honeydew", "#f0fff0"],
60
- ["hotpink", "#ff69b4"],
61
- ["indianred", "#cd5c5c"],
62
- ["indigo", "#4b0082"],
63
- ["ivory", "#fffff0"],
64
- ["khaki", "#f0e68c"],
65
- ["lavender", "#e6e6fa"],
66
- ["lavenderblush", "#fff0f5"],
67
- ["lawngreen", "#7cfc00"],
68
- ["lemonchiffon", "#fffacd"],
69
- ["lightblue", "#add8e6"],
70
- ["lightcoral", "#f08080"],
71
- ["lightcyan", "#e0ffff"],
72
- ["lightgoldenrodyellow", "#fafad2"],
73
- ["lightgray", "#d3d3d3"],
74
- ["lightgreen", "#90ee90"],
75
- ["lightgrey", "#d3d3d3"],
76
- ["lightpink", "#ffb6c1"],
77
- ["lightsalmon", "#ffa07a"],
78
- ["lightseagreen", "#20b2aa"],
79
- ["lightskyblue", "#87cefa"],
80
- ["lightslategray", "#778899"],
81
- ["lightslategrey", "#778899"],
82
- ["lightsteelblue", "#b0c4de"],
83
- ["lightyellow", "#ffffe0"],
84
- ["lime", "#00ff00"],
85
- ["limegreen", "#32cd32"],
86
- ["linen", "#faf0e6"],
87
- ["magenta", "#ff00ff"],
88
- ["maroon", "#800000"],
89
- ["mediumaquamarine", "#66cdaa"],
90
- ["mediumblue", "#0000cd"],
91
- ["mediumorchid", "#ba55d3"],
92
- ["mediumpurple", "#9370db"],
93
- ["mediumseagreen", "#3cb371"],
94
- ["mediumslateblue", "#7b68ee"],
95
- ["mediumspringgreen", "#00fa9a"],
96
- ["mediumturquoise", "#48d1cc"],
97
- ["mediumvioletred", "#c71585"],
98
- ["midnightblue", "#191970"],
99
- ["mintcream", "#f5fffa"],
100
- ["mistyrose", "#ffe4e1"],
101
- ["moccasin", "#ffe4b5"],
102
- ["navajowhite", "#ffdead"],
103
- ["navy", "#000080"],
104
- ["oldlace", "#fdf5e6"],
105
- ["olive", "#808000"],
106
- ["olivedrab", "#6b8e23"],
107
- ["orange", "#ffa500"],
108
- ["orangered", "#ff4500"],
109
- ["orchid", "#da70d6"],
110
- ["palegoldenrod", "#eee8aa"],
111
- ["palegreen", "#98fb98"],
112
- ["paleturquoise", "#afeeee"],
113
- ["palevioletred", "#db7093"],
114
- ["papayawhip", "#ffefd5"],
115
- ["peachpuff", "#ffdab9"],
116
- ["peru", "#cd853f"],
117
- ["pink", "#ffc0cb"],
118
- ["plum", "#dda0dd"],
119
- ["powderblue", "#b0e0e6"],
120
- ["purple", "#800080"],
121
- ["rebeccapurple", "#663399"],
122
- ["red", "#ff0000"],
123
- ["rosybrown", "#bc8f8f"],
124
- ["royalblue", "#4169e1"],
125
- ["saddlebrown", "#8b4513"],
126
- ["salmon", "#fa8072"],
127
- ["sandybrown", "#f4a460"],
128
- ["seagreen", "#2e8b57"],
129
- ["seashell", "#fff5ee"],
130
- ["sienna", "#a0522d"],
131
- ["silver", "#c0c0c0"],
132
- ["skyblue", "#87ceeb"],
133
- ["slateblue", "#6a5acd"],
134
- ["slategray", "#708090"],
135
- ["slategrey", "#708090"],
136
- ["snow", "#fffafa"],
137
- ["springgreen", "#00ff7f"],
138
- ["steelblue", "#4682b4"],
139
- ["tan", "#d2b48c"],
140
- ["teal", "#008080"],
141
- ["thistle", "#d8bfd8"],
142
- ["tomato", "#ff6347"],
143
- ["turquoise", "#40e0d0"],
144
- ["violet", "#ee82ee"],
145
- ["wheat", "#f5deb3"],
146
- ["white", "#ffffff"],
147
- ["whitesmoke", "#f5f5f5"],
148
- ["yellow", "#ffff00"],
149
- ["yellowgreen", "#9acd32"]
150
- ]);
151
- const HASH_PATTERN = /^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i;
152
- const SMALL_HASH_PATTERN = /^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i;
153
- const RGB_PATTERN = /^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/;
154
- const HSL_PATTERN = /^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/;
155
- const getDefaultCss = () => {
156
- return {
157
- __proto__: null,
158
- backgroundColor: null,
159
- color: null,
160
- fontStyle: null,
161
- fontWeight: null,
162
- textDecorationColor: null,
163
- textDecorationLine: []
164
- };
165
- };
166
- const SPACE_PATTERN = /\s+/g;
167
- const parseCssColor = (colorString) => {
168
- if (colorKeywords.has(colorString)) {
169
- colorString = colorKeywords.get(colorString);
170
- }
171
- const hashMatch = HASH_PATTERN.exec(colorString);
172
- if (hashMatch) {
173
- return [Number.parseInt(hashMatch[1], 16), Number.parseInt(hashMatch[2], 16), Number.parseInt(hashMatch[3], 16)];
174
- }
175
- const smallHashMatch = SMALL_HASH_PATTERN.exec(colorString);
176
- if (smallHashMatch) {
177
- return [
178
- Number.parseInt(`${smallHashMatch[1]}${smallHashMatch[1]}`, 16),
179
- Number.parseInt(`${smallHashMatch[2]}${smallHashMatch[2]}`, 16),
180
- Number.parseInt(`${smallHashMatch[3]}${smallHashMatch[3]}`, 16)
181
- ];
182
- }
183
- const rgbMatch = RGB_PATTERN.exec(colorString);
184
- if (rgbMatch) {
185
- return [
186
- Math.round(Math.max(0, Math.min(255, Number(rgbMatch[1])))),
187
- Math.round(Math.max(0, Math.min(255, Number(rgbMatch[2])))),
188
- Math.round(Math.max(0, Math.min(255, Number(rgbMatch[3]))))
189
- ];
190
- }
191
- const hslMatch = HSL_PATTERN.exec(colorString);
192
- if (hslMatch) {
193
- let h = Number(hslMatch[1]) % 360;
194
- if (h < 0) {
195
- h += 360;
196
- }
197
- const s = Math.max(0, Math.min(100, Number(hslMatch[2]))) / 100;
198
- const l = Math.max(0, Math.min(100, Number(hslMatch[3]))) / 100;
199
- const c = (1 - Math.abs(2 * l - 1)) * s;
200
- const x = c * (1 - Math.abs(h / 60 % 2 - 1));
201
- const m = l - c / 2;
202
- let r_;
203
- let g_;
204
- let b_;
205
- if (h < 60) {
206
- ({ 0: r_, 1: g_, 2: b_ } = [c, x, 0]);
207
- } else if (h < 120) {
208
- ({ 0: r_, 1: g_, 2: b_ } = [x, c, 0]);
209
- } else if (h < 180) {
210
- ({ 0: r_, 1: g_, 2: b_ } = [0, c, x]);
211
- } else if (h < 240) {
212
- ({ 0: r_, 1: g_, 2: b_ } = [0, x, c]);
213
- } else if (h < 300) {
214
- ({ 0: r_, 1: g_, 2: b_ } = [x, 0, c]);
215
- } else {
216
- ({ 0: r_, 1: g_, 2: b_ } = [c, 0, x]);
217
- }
218
- return [Math.round((r_ + m) * 255), Math.round((g_ + m) * 255), Math.round((b_ + m) * 255)];
219
- }
220
- return null;
221
- };
222
- const colorEquals = (color1, color2) => color1?.[0] === color2?.[0] && color1?.[1] === color2?.[1] && color1?.[2] === color2?.[2];
223
- const parseCss = (cssString) => {
224
- const css = getDefaultCss();
225
- const rawEntries = [];
226
- let inValue = false;
227
- let currentKey = null;
228
- let parenthesesDepth = 0;
229
- let currentPart = "";
230
- for (const c of cssString) {
231
- if (c === "(") {
232
- parenthesesDepth++;
233
- } else if (parenthesesDepth > 0) {
234
- if (c === ")") {
235
- parenthesesDepth--;
236
- }
237
- } else if (inValue) {
238
- if (c === ";") {
239
- const value = currentPart.trim();
240
- if (value !== "") {
241
- rawEntries.push([currentKey, value]);
242
- }
243
- currentKey = null;
244
- currentPart = "";
245
- inValue = false;
246
- continue;
247
- }
248
- } else if (c === ":") {
249
- currentKey = currentPart.trim();
250
- currentPart = "";
251
- inValue = true;
252
- continue;
253
- }
254
- currentPart += c;
255
- }
256
- if (inValue && parenthesesDepth === 0) {
257
- const value = currentPart.trim();
258
- if (value !== "") {
259
- rawEntries.push([currentKey, value]);
260
- }
261
- currentKey = null;
262
- currentPart = "";
263
- }
264
- for (const { 0: key, 1: value } of rawEntries) {
265
- switch (key) {
266
- case "background-color": {
267
- if (value != void 0) {
268
- css.backgroundColor = value;
269
- }
270
- break;
271
- }
272
- case "color": {
273
- if (value != void 0) {
274
- css.color = value;
275
- }
276
- break;
277
- }
278
- case "font-style": {
279
- if (["italic", "oblique", "oblique 14deg"].includes(value)) {
280
- css.fontStyle = "italic";
281
- }
282
- break;
283
- }
284
- case "font-weight": {
285
- if (value === "bold") {
286
- css.fontWeight = value;
287
- }
288
- break;
289
- }
290
- case "text-decoration": {
291
- css.textDecorationColor = null;
292
- css.textDecorationLine = [];
293
- const arguments_ = value.split(SPACE_PATTERN);
294
- for (const argument of arguments_) {
295
- const maybeColor = parseCssColor(argument);
296
- if (maybeColor != void 0) {
297
- css.textDecorationColor = maybeColor;
298
- } else if (["line-through", "overline", "underline"].includes(argument)) {
299
- css.textDecorationLine.push(argument);
300
- }
301
- }
302
- break;
303
- }
304
- case "text-decoration-color": {
305
- const color = parseCssColor(value);
306
- if (color != void 0) {
307
- css.textDecorationColor = color;
308
- }
309
- break;
310
- }
311
- case "text-decoration-line": {
312
- css.textDecorationLine = [];
313
- const lineTypes = value.split(SPACE_PATTERN);
314
- for (const lineType of lineTypes) {
315
- if (["line-through", "overline", "underline"].includes(lineType)) {
316
- css.textDecorationLine.push(lineType);
317
- }
318
- }
319
- break;
320
- }
321
- }
322
- }
323
- return css;
324
- };
325
- const cssToAnsi = (css, previousCss = null) => {
326
- previousCss = previousCss ?? getDefaultCss();
327
- let ansi = "";
328
- if (!colorEquals(css.backgroundColor, previousCss.backgroundColor)) {
329
- if (css.backgroundColor == void 0) {
330
- ansi += "\x1B[49m";
331
- } else {
332
- switch (css.backgroundColor) {
333
- case "black": {
334
- ansi += "\x1B[40m";
335
- break;
336
- }
337
- case "blue": {
338
- ansi += "\x1B[44m";
339
- break;
340
- }
341
- case "cyan": {
342
- ansi += "\x1B[46m";
343
- break;
344
- }
345
- case "green": {
346
- ansi += "\x1B[42m";
347
- break;
348
- }
349
- case "magenta": {
350
- ansi += "\x1B[45m";
351
- break;
352
- }
353
- case "red": {
354
- ansi += "\x1B[41m";
355
- break;
356
- }
357
- case "white": {
358
- ansi += "\x1B[47m";
359
- break;
360
- }
361
- case "yellow": {
362
- ansi += "\x1B[43m";
363
- break;
364
- }
365
- default: {
366
- if (Array.isArray(css.backgroundColor)) {
367
- const { 0: r, 1: g, 2: b } = css.backgroundColor;
368
- ansi += `\x1B[48;2;${r};${g};${b}m`;
369
- } else {
370
- const parsed = parseCssColor(css.backgroundColor);
371
- if (parsed === null) {
372
- ansi += "\x1B[49m";
373
- } else {
374
- const { 0: r, 1: g, 2: b } = parsed;
375
- ansi += `\x1B[48;2;${r};${g};${b}m`;
376
- }
377
- }
378
- }
379
- }
380
- }
381
- }
382
- if (!colorEquals(css.color, previousCss.color)) {
383
- if (css.color == void 0) {
384
- ansi += "\x1B[39m";
385
- } else {
386
- switch (css.color) {
387
- case "black": {
388
- ansi += "\x1B[30m";
389
- break;
390
- }
391
- case "blue": {
392
- ansi += "\x1B[34m";
393
- break;
394
- }
395
- case "cyan": {
396
- ansi += "\x1B[36m";
397
- break;
398
- }
399
- case "green": {
400
- ansi += "\x1B[32m";
401
- break;
402
- }
403
- case "magenta": {
404
- ansi += "\x1B[35m";
405
- break;
406
- }
407
- case "red": {
408
- ansi += "\x1B[31m";
409
- break;
410
- }
411
- case "white": {
412
- ansi += "\x1B[37m";
413
- break;
414
- }
415
- case "yellow": {
416
- ansi += "\x1B[33m";
417
- break;
418
- }
419
- default: {
420
- if (Array.isArray(css.color)) {
421
- const { 0: r, 1: g, 2: b } = css.color;
422
- ansi += `\x1B[38;2;${r};${g};${b}m`;
423
- } else {
424
- const parsed = parseCssColor(css.color);
425
- if (parsed === null) {
426
- ansi += "\x1B[39m";
427
- } else {
428
- const { 0: r, 1: g, 2: b } = parsed;
429
- ansi += `\x1B[38;2;${r};${g};${b}m`;
430
- }
431
- }
432
- }
433
- }
434
- }
435
- }
436
- if (css.fontWeight !== previousCss.fontWeight) {
437
- ansi += css.fontWeight === "bold" ? "\x1B[1m" : "\x1B[22m";
438
- }
439
- if (css.fontStyle !== previousCss.fontStyle) {
440
- ansi += css.fontStyle === "italic" ? "\x1B[3m" : "\x1B[23m";
441
- }
442
- if (!colorEquals(css.textDecorationColor, previousCss.textDecorationColor)) {
443
- if (css.textDecorationColor == void 0) {
444
- ansi += "\x1B[59m";
445
- } else {
446
- const { 0: r, 1: g, 2: b } = css.textDecorationColor;
447
- ansi += `\x1B[58;2;${r};${g};${b}m`;
448
- }
449
- }
450
- if (css.textDecorationLine.includes("line-through") !== previousCss.textDecorationLine.includes("line-through")) {
451
- ansi += css.textDecorationLine.includes("line-through") ? "\x1B[9m" : "\x1B[29m";
452
- }
453
- if (css.textDecorationLine.includes("overline") !== previousCss.textDecorationLine.includes("overline")) {
454
- ansi += css.textDecorationLine.includes("overline") ? "\x1B[53m" : "\x1B[55m";
455
- }
456
- if (css.textDecorationLine.includes("underline") !== previousCss.textDecorationLine.includes("underline")) {
457
- ansi += css.textDecorationLine.includes("underline") ? "\x1B[4m" : "\x1B[24m";
458
- }
459
- return ansi;
460
- };
461
- const tryStringify = (o) => {
462
- try {
463
- return JSON.stringify(o);
464
- } catch {
465
- return '"[Circular]"';
466
- }
467
- };
468
- const CHAR_PERCENT = "%".codePointAt(0);
469
- const CHAR_s = "s".codePointAt(0);
470
- const CHAR_d = "d".codePointAt(0);
471
- const CHAR_f = "f".codePointAt(0);
472
- const CHAR_i = "i".codePointAt(0);
473
- const CHAR_O = "O".codePointAt(0);
474
- const CHAR_o = "o".codePointAt(0);
475
- const CHAR_j = "j".codePointAt(0);
476
- const CHAR_c = "c".codePointAt(0);
477
- const format = (fmt, arguments_ = [], options = {}) => {
478
- if (typeof fmt !== "string" && typeof fmt !== "object" || fmt === null) {
479
- throw new TypeError(`fmt must be a string or object, got ${fmt === null ? "null" : typeof fmt}`);
480
- }
481
- const stringify = options.stringify ?? tryStringify;
482
- const offset = 1;
483
- if (typeof fmt === "object") {
484
- const argumentsLength = arguments_.length + offset;
485
- if (argumentsLength === 1) {
486
- return "{}";
487
- }
488
- const objects = Array.from({ length: argumentsLength });
489
- objects[0] = stringify(fmt);
490
- for (let index = 1; index < argumentsLength; index++) {
491
- objects[index] = stringify(arguments_[index - offset]);
492
- }
493
- return objects.join(" ");
494
- }
495
- if (arguments_.length === 0) {
496
- return fmt;
497
- }
498
- let result = "";
499
- let a = 1 - offset;
500
- let lastPosition = -1;
501
- let usedStyle = false;
502
- let previousCss = null;
503
- for (let index = 0; index < fmt.length; ) {
504
- if (fmt.codePointAt(index) === CHAR_PERCENT && index + 1 < fmt.length) {
505
- lastPosition = lastPosition > -1 ? lastPosition : 0;
506
- const c = fmt.codePointAt(index + 1);
507
- if (c === void 0) {
508
- ++a;
509
- break;
510
- }
511
- switch (c) {
512
- case CHAR_c: {
513
- if (globalThis.window === void 0) {
514
- const css = parseCss(arguments_[a]);
515
- if (lastPosition < index) {
516
- result += fmt.slice(lastPosition, index);
517
- }
518
- result += cssToAnsi(css, previousCss);
519
- if (result !== "") {
520
- usedStyle = true;
521
- previousCss = css;
522
- }
523
- }
524
- lastPosition = index + 2;
525
- index++;
526
- break;
527
- }
528
- case CHAR_d:
529
- case CHAR_f: {
530
- if (a >= arguments_.length || arguments_[a] == void 0) {
531
- break;
532
- }
533
- if (lastPosition < index) {
534
- result += fmt.slice(lastPosition, index);
535
- }
536
- result += Number(arguments_[a]).toString();
537
- lastPosition = index + 2;
538
- index++;
539
- break;
540
- }
541
- case CHAR_i: {
542
- if (a >= arguments_.length || arguments_[a] == void 0) {
543
- break;
544
- }
545
- if (lastPosition < index) {
546
- result += fmt.slice(lastPosition, index);
547
- }
548
- result += Math.floor(Number(arguments_[a])).toString();
549
- lastPosition = index + 2;
550
- index++;
551
- break;
552
- }
553
- case CHAR_j:
554
- case CHAR_O:
555
- case CHAR_o: {
556
- if (a >= arguments_.length || arguments_[a] === void 0) {
557
- break;
558
- }
559
- if (lastPosition < index) {
560
- result += fmt.slice(lastPosition, index);
561
- }
562
- const temporaryArgument = arguments_[a];
563
- const type = typeof temporaryArgument;
564
- if (type === "string") {
565
- result += `'${temporaryArgument}'`;
566
- lastPosition = index + 2;
567
- break;
568
- }
569
- if (type === "function") {
570
- result += temporaryArgument.name ? `[Function: ${temporaryArgument.name}]` : "[Function: <anonymous>]";
571
- lastPosition = index + 2;
572
- break;
573
- }
574
- result += stringify(temporaryArgument);
575
- lastPosition = index + 2;
576
- index++;
577
- break;
578
- }
579
- case CHAR_PERCENT: {
580
- if (lastPosition < index) {
581
- result += fmt.slice(lastPosition, index);
582
- }
583
- result += "%";
584
- lastPosition = index + 2;
585
- index++;
586
- a--;
587
- break;
588
- }
589
- case CHAR_s: {
590
- if (a >= arguments_.length) {
591
- break;
592
- }
593
- if (lastPosition < index) {
594
- result += fmt.slice(lastPosition, index);
595
- }
596
- result += typeof arguments_[a] === "object" ? stringify(arguments_[a]) : String(arguments_[a]);
597
- lastPosition = index + 2;
598
- index++;
599
- break;
600
- }
601
- default: {
602
- if (typeof options.formatters?.[c] === "function") {
603
- if (lastPosition < index) {
604
- result += fmt.slice(lastPosition, index);
605
- }
606
- result += options.formatters[c](arguments_[a]);
607
- lastPosition = index + 2;
608
- index++;
609
- }
610
- }
611
- }
612
- ++a;
613
- }
614
- ++index;
615
- }
616
- if (lastPosition === -1) {
617
- return fmt;
618
- }
619
- if (lastPosition < fmt.length) {
620
- result += fmt.slice(lastPosition);
621
- }
622
- if (usedStyle) {
623
- result += "\x1B[0m";
624
- }
625
- return result;
626
- };
627
- const build = (options = {}) => {
628
- const formatters = {};
629
- if (typeof options.formatters === "object") {
630
- Object.entries(options.formatters).forEach(([key, formatterFunction]) => {
631
- if (key.length === 0) {
632
- throw new Error(`Formatter %${key} has no characters`);
633
- }
634
- if (key.length > 1) {
635
- throw new Error(`Formatter %${key} has more than one character`);
636
- }
637
- if (typeof formatterFunction !== "function") {
638
- throw new TypeError(`Formatter for %${key} is not a function`);
639
- }
640
- const c = key.codePointAt(0);
641
- if (c === void 0) {
642
- throw new Error(`${key}.codePointAt(0) failed to return a value, please report this issue`);
643
- }
644
- formatters[c] = formatterFunction;
645
- });
646
- }
647
- return (f, arguments_ = [], formatOptions = {}) => format(f, arguments_, { ...formatOptions, formatters });
648
- };
649
-
650
- class MessageFormatterProcessor {
651
- /** Custom stringify function for object serialization */
652
- #stringify;
653
- /** Custom formatters for message interpolation */
654
- #formatters;
655
- /**
656
- * Creates a new MessageFormatterProcessor instance.
657
- * @param options Configuration options
658
- * @param options.formatters Custom formatters for message interpolation
659
- */
660
- constructor(options = {}) {
661
- this.#formatters = options.formatters;
662
- }
663
- /**
664
- * Sets the stringify function for object serialization.
665
- * @param function_ The stringify function to use for serializing objects
666
- */
667
- setStringify(function_) {
668
- this.#stringify = function_;
669
- }
670
- /**
671
- * Processes log metadata to format messages.
672
- *
673
- * Applies string interpolation and custom formatters to the message
674
- * and contextual data in the log metadata.
675
- * @param meta The log metadata to process
676
- * @returns The processed metadata with formatted messages
677
- */
678
- process(meta) {
679
- const formatter = build({
680
- formatters: this.#formatters});
681
- if (meta.message !== void 0) {
682
- meta.message = this.#format(formatter, meta.message, meta.context ?? []);
683
- }
684
- return meta;
685
- }
686
- /**
687
- * Recursively formats data using the formatter.
688
- *
689
- * Applies string interpolation and formatting to strings, arrays, and objects.
690
- * @param formatter The formatter function to use
691
- * @param data The data to format (string, array, or object)
692
- * @param arguments_ Additional arguments for formatting
693
- * @returns The formatted data
694
- * @private
695
- */
696
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
697
- #format(formatter, data, arguments_ = []) {
698
- if (typeof data === "string") {
699
- return formatter(data, arguments_);
700
- }
701
- if (typeof data === "object" && data !== null) {
702
- for (const index in data) {
703
- const value = data[index];
704
- if (typeof value === "string" || Array.isArray(value) || typeof value === "object") {
705
- data[index] = this.#format(formatter, value, arguments_);
706
- }
707
- }
708
- }
709
- return data;
710
- }
711
- }
712
-
713
- export { MessageFormatterProcessor as default };
1
+ let h;const B=()=>(h!==void 0||(h=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),h),$=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,A=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,v=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,S=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,y=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),x=/\s+/,m=e=>{const t=B();t.has(e)&&(e=t.get(e));const o=$.exec(e);if(o)return[Number.parseInt(o[1],16),Number.parseInt(o[2],16),Number.parseInt(o[3],16)];const i=A.exec(e);if(i)return[Number.parseInt(`${i[1]}${i[1]}`,16),Number.parseInt(`${i[2]}${i[2]}`,16),Number.parseInt(`${i[3]}${i[3]}`,16)];const f=v.exec(e);if(f)return[Math.round(Math.max(0,Math.min(255,Number(f[1])))),Math.round(Math.max(0,Math.min(255,Number(f[2])))),Math.round(Math.max(0,Math.min(255,Number(f[3]))))];const n=S.exec(e);if(n){let l=Number(n[1])%360;l<0&&(l+=360);const a=Math.max(0,Math.min(100,Number(n[2])))/100,s=Math.max(0,Math.min(100,Number(n[3])))/100,u=(1-Math.abs(2*s-1))*a,b=u*(1-Math.abs(l/60%2-1)),r=s-u/2;let d,c,g;return l<60?{0:d,1:c,2:g}=[u,b,0]:l<120?{0:d,1:c,2:g}=[b,u,0]:l<180?{0:d,1:c,2:g}=[0,u,b]:l<240?{0:d,1:c,2:g}=[0,b,u]:l<300?{0:d,1:c,2:g}=[b,0,u]:{0:d,1:c,2:g}=[u,0,b],[Math.round((d+r)*255),Math.round((c+r)*255),Math.round((g+r)*255)]}return null},k=(e,t)=>e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],D=e=>{if(typeof e!="string")return y();const t=y(),o=[];let i=!1,f=null,n=0,l="";for(const a of e){if(a==="(")n+=1;else if(n>0)a===")"&&(n-=1);else if(i){if(a===";"){const s=l.trim();s!==""&&o.push([f,s]),f=null,l="",i=!1;continue}}else if(a===":"){f=l.trim(),l="",i=!0;continue}l+=a}if(i&&n===0){const a=l.trim();a!==""&&o.push([f,a]),f=null,l=""}for(const{0:a,1:s}of o)switch(a){case"background-color":{s!=null&&(t.backgroundColor=s);break}case"color":{s!=null&&(t.color=s);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(s)&&(t.fontStyle="italic");break}case"font-weight":{s==="bold"&&(t.fontWeight=s);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=s.split(x);for(const b of u){const r=m(b);r!=null?t.textDecorationColor=r:["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b)}break}case"text-decoration-color":{const u=m(s);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=s.split(x);for(const b of u)["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b);break}}return t},M=(e,t)=>{t=t??y();let o="";if(!k(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)o+="\x1B[49m";else switch(e.backgroundColor){case"black":{o+="\x1B[40m";break}case"blue":{o+="\x1B[44m";break}case"cyan":{o+="\x1B[46m";break}case"green":{o+="\x1B[42m";break}case"magenta":{o+="\x1B[45m";break}case"red":{o+="\x1B[41m";break}case"white":{o+="\x1B[47m";break}case"yellow":{o+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:i,1:f,2:n}=e.backgroundColor;o+=`\x1B[48;2;${String(i)};${String(f)};${String(n)}m`}else{const i=m(e.backgroundColor);if(i===null)o+="\x1B[49m";else{const{0:f,1:n,2:l}=i;o+=`\x1B[48;2;${String(f)};${String(n)};${String(l)}m`}}}if(!k(e.color,t.color))if(e.color==null)o+="\x1B[39m";else switch(e.color){case"black":{o+="\x1B[30m";break}case"blue":{o+="\x1B[34m";break}case"cyan":{o+="\x1B[36m";break}case"green":{o+="\x1B[32m";break}case"magenta":{o+="\x1B[35m";break}case"red":{o+="\x1B[31m";break}case"white":{o+="\x1B[37m";break}case"yellow":{o+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:i,1:f,2:n}=e.color;o+=`\x1B[38;2;${String(i)};${String(f)};${String(n)}m`}else{const i=m(e.color);if(i===null)o+="\x1B[39m";else{const{0:f,1:n,2:l}=i;o+=`\x1B[38;2;${String(f)};${String(n)};${String(l)}m`}}}if(e.fontWeight!==t.fontWeight&&(o+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(o+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!k(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)o+="\x1B[59m";else{const{0:i,1:f,2:n}=e.textDecorationColor;o+=`\x1B[58;2;${String(i)};${String(f)};${String(n)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(o+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(o+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(o+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),o},N=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},p="%".codePointAt(0),C="s".codePointAt(0),j="d".codePointAt(0),L="f".codePointAt(0),F="i".codePointAt(0),P="O".codePointAt(0),q="o".codePointAt(0),E="j".codePointAt(0),I="c".codePointAt(0),w=(e,t=[],o={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const i=o.stringify??N,f=1;if(typeof e=="object"){const r=t.length+f;if(r===1)return"{}";const d=Array.from({length:r});d[0]=i(e);for(let c=1;c<r;c+=1)d[c]=i(t[c-f]);return d.join(" ")}if(t.length===0)return e;let n="",l=1-f,a=-1,s=!1,u;const b=o.colors??globalThis.window===void 0;for(let r=0;r<e.length;){if(e.codePointAt(r)===p&&r+1<e.length){a=a>-1?a:0;const d=e.codePointAt(r+1);switch(d){case I:{if(b){const c=D(t[l]);a<r&&(n+=e.slice(a,r));const g=M(c,u);n+=g,g!==""&&(s=!0,u=c)}a=r+2,r+=1;break}case j:case L:{const c=t[l];if(l>=t.length||c==null)break;a<r&&(n+=e.slice(a,r)),n+=(typeof c=="symbol"?Number.NaN:Number(c)).toString(),a=r+2,r+=1;break}case F:{const c=t[l];if(l>=t.length||c==null)break;a<r&&(n+=e.slice(a,r)),n+=Math.floor(typeof c=="symbol"?Number.NaN:Number(c)).toString(),a=r+2,r+=1;break}case E:case P:case q:{if(l>=t.length||t[l]===void 0)break;a<r&&(n+=e.slice(a,r));const c=t[l],g=typeof c;if(g==="string"){n+=`'${c}'`,a=r+2,r+=1;break}if(g==="function"){n+=c.name?`[Function: ${c.name}]`:"[Function: <anonymous>]",a=r+2,r+=1;break}n+=i(c),a=r+2,r+=1;break}case p:{a<r&&(n+=e.slice(a,r)),n+="%",a=r+2,r+=1,l-=1;break}case C:{if(l>=t.length)break;a<r&&(n+=e.slice(a,r));const c=t[l];n+=typeof c=="object"&&c!==null?i(c):String(c),a=r+2,r+=1;break}default:typeof o.formatters?.[d]=="function"?(a<r&&(n+=e.slice(a,r)),n+=o.formatters[d](t[l]),a=r+2,r+=1):l-=1}l+=1}r+=1}if(a===-1&&!(o.appendExtraArguments&&l<t.length))return e;if(a===-1?n=e:a<e.length&&(n+=e.slice(a)),a!==-1&&s&&(n+="\x1B[0m"),o.appendExtraArguments&&l<t.length)for(let r=Math.max(l,0);r<t.length;r+=1){const d=t[r];n+=` ${typeof d=="object"&&d!==null?i(d):String(d)}`}return n},O=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([i,f])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof f!="function")throw new TypeError(`Formatter for %${i} is not a function`);const n=i.codePointAt(0);if(n===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);t[n]=f});const o=Object.freeze({formatters:t});return(i,f=[],n)=>n===void 0?w(i,f,o):w(i,f,{...n,formatters:t})};class W{#r;#t;#e;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#r=t}process(t){this.#e===void 0&&(this.#e=O({formatters:this.#t}));const o=this.#e;return t.message!==void 0&&(t.message=this.#o(o,t.message,t.context??[])),t}#o(t,o,i=[]){if(typeof o=="string")return t(o,i);if(typeof o=="object"&&o!==null){const f=o,n=Object.keys(f);for(let l=0;l<n.length;l+=1){const a=n[l],s=f[a];(typeof s=="string"||Array.isArray(s)||typeof s=="object")&&(f[a]=this.#o(t,s,i))}}return o}}export{W as default};