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