@buoy-gg/console 4.0.2
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/LICENSE +58 -0
- package/README.md +55 -0
- package/lib/commonjs/components/ConsoleIcon.js +47 -0
- package/lib/commonjs/components/ConsoleIcon.js.map +1 -0
- package/lib/commonjs/components/ConsoleLogList.js +145 -0
- package/lib/commonjs/components/ConsoleLogList.js.map +1 -0
- package/lib/commonjs/components/ConsoleModal.js +48 -0
- package/lib/commonjs/components/ConsoleModal.js.map +1 -0
- package/lib/commonjs/components/ConsoleRoot.js +28 -0
- package/lib/commonjs/components/ConsoleRoot.js.map +1 -0
- package/lib/commonjs/devtools/ConsoleBody.js +235 -0
- package/lib/commonjs/devtools/ConsoleBody.js.map +1 -0
- package/lib/commonjs/devtools/ConsoleHeader.js +146 -0
- package/lib/commonjs/devtools/ConsoleHeader.js.map +1 -0
- package/lib/commonjs/devtools/ConsoleMessageRow.js +338 -0
- package/lib/commonjs/devtools/ConsoleMessageRow.js.map +1 -0
- package/lib/commonjs/devtools/ConsoleValue.js +254 -0
- package/lib/commonjs/devtools/ConsoleValue.js.map +1 -0
- package/lib/commonjs/devtools/ConsoleView.js +51 -0
- package/lib/commonjs/devtools/ConsoleView.js.map +1 -0
- package/lib/commonjs/devtools/consoleFilter.js +125 -0
- package/lib/commonjs/devtools/consoleFilter.js.map +1 -0
- package/lib/commonjs/devtools/consoleFormat.js +313 -0
- package/lib/commonjs/devtools/consoleFormat.js.map +1 -0
- package/lib/commonjs/devtools/origin.js +191 -0
- package/lib/commonjs/devtools/origin.js.map +1 -0
- package/lib/commonjs/devtools/theme.js +143 -0
- package/lib/commonjs/devtools/theme.js.map +1 -0
- package/lib/commonjs/devtools/useConsoleController.js +82 -0
- package/lib/commonjs/devtools/useConsoleController.js.map +1 -0
- package/lib/commonjs/devtools/useConsoleMessages.js +241 -0
- package/lib/commonjs/devtools/useConsoleMessages.js.map +1 -0
- package/lib/commonjs/hooks/useConsoleLogs.js +23 -0
- package/lib/commonjs/hooks/useConsoleLogs.js.map +1 -0
- package/lib/commonjs/index.js +175 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/preset.js +45 -0
- package/lib/commonjs/preset.js.map +1 -0
- package/lib/commonjs/store/consoleLogStore.js +298 -0
- package/lib/commonjs/store/consoleLogStore.js.map +1 -0
- package/lib/commonjs/store/sanitize.js +64 -0
- package/lib/commonjs/store/sanitize.js.map +1 -0
- package/lib/commonjs/sync/consoleSyncAdapter.js +47 -0
- package/lib/commonjs/sync/consoleSyncAdapter.js.map +1 -0
- package/lib/module/components/ConsoleIcon.js +42 -0
- package/lib/module/components/ConsoleIcon.js.map +1 -0
- package/lib/module/components/ConsoleLogList.js +140 -0
- package/lib/module/components/ConsoleLogList.js.map +1 -0
- package/lib/module/components/ConsoleModal.js +44 -0
- package/lib/module/components/ConsoleModal.js.map +1 -0
- package/lib/module/components/ConsoleRoot.js +25 -0
- package/lib/module/components/ConsoleRoot.js.map +1 -0
- package/lib/module/devtools/ConsoleBody.js +230 -0
- package/lib/module/devtools/ConsoleBody.js.map +1 -0
- package/lib/module/devtools/ConsoleHeader.js +141 -0
- package/lib/module/devtools/ConsoleHeader.js.map +1 -0
- package/lib/module/devtools/ConsoleMessageRow.js +333 -0
- package/lib/module/devtools/ConsoleMessageRow.js.map +1 -0
- package/lib/module/devtools/ConsoleValue.js +249 -0
- package/lib/module/devtools/ConsoleValue.js.map +1 -0
- package/lib/module/devtools/ConsoleView.js +46 -0
- package/lib/module/devtools/ConsoleView.js.map +1 -0
- package/lib/module/devtools/consoleFilter.js +119 -0
- package/lib/module/devtools/consoleFilter.js.map +1 -0
- package/lib/module/devtools/consoleFormat.js +309 -0
- package/lib/module/devtools/consoleFormat.js.map +1 -0
- package/lib/module/devtools/origin.js +183 -0
- package/lib/module/devtools/origin.js.map +1 -0
- package/lib/module/devtools/theme.js +140 -0
- package/lib/module/devtools/theme.js.map +1 -0
- package/lib/module/devtools/useConsoleController.js +79 -0
- package/lib/module/devtools/useConsoleController.js.map +1 -0
- package/lib/module/devtools/useConsoleMessages.js +238 -0
- package/lib/module/devtools/useConsoleMessages.js.map +1 -0
- package/lib/module/hooks/useConsoleLogs.js +19 -0
- package/lib/module/hooks/useConsoleLogs.js.map +1 -0
- package/lib/module/index.js +52 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/preset.js +40 -0
- package/lib/module/preset.js.map +1 -0
- package/lib/module/store/consoleLogStore.js +284 -0
- package/lib/module/store/consoleLogStore.js.map +1 -0
- package/lib/module/store/sanitize.js +60 -0
- package/lib/module/store/sanitize.js.map +1 -0
- package/lib/module/sync/consoleSyncAdapter.js +43 -0
- package/lib/module/sync/consoleSyncAdapter.js.map +1 -0
- package/lib/typescript/components/ConsoleIcon.d.ts +14 -0
- package/lib/typescript/components/ConsoleIcon.d.ts.map +1 -0
- package/lib/typescript/components/ConsoleLogList.d.ts +8 -0
- package/lib/typescript/components/ConsoleLogList.d.ts.map +1 -0
- package/lib/typescript/components/ConsoleModal.d.ts +18 -0
- package/lib/typescript/components/ConsoleModal.d.ts.map +1 -0
- package/lib/typescript/components/ConsoleRoot.d.ts +14 -0
- package/lib/typescript/components/ConsoleRoot.d.ts.map +1 -0
- package/lib/typescript/devtools/ConsoleBody.d.ts +11 -0
- package/lib/typescript/devtools/ConsoleBody.d.ts.map +1 -0
- package/lib/typescript/devtools/ConsoleHeader.d.ts +17 -0
- package/lib/typescript/devtools/ConsoleHeader.d.ts.map +1 -0
- package/lib/typescript/devtools/ConsoleMessageRow.d.ts +20 -0
- package/lib/typescript/devtools/ConsoleMessageRow.d.ts.map +1 -0
- package/lib/typescript/devtools/ConsoleValue.d.ts +21 -0
- package/lib/typescript/devtools/ConsoleValue.d.ts.map +1 -0
- package/lib/typescript/devtools/ConsoleView.d.ts +10 -0
- package/lib/typescript/devtools/ConsoleView.d.ts.map +1 -0
- package/lib/typescript/devtools/consoleFilter.d.ts +31 -0
- package/lib/typescript/devtools/consoleFilter.d.ts.map +1 -0
- package/lib/typescript/devtools/consoleFormat.d.ts +29 -0
- package/lib/typescript/devtools/consoleFormat.d.ts.map +1 -0
- package/lib/typescript/devtools/origin.d.ts +39 -0
- package/lib/typescript/devtools/origin.d.ts.map +1 -0
- package/lib/typescript/devtools/theme.d.ts +57 -0
- package/lib/typescript/devtools/theme.d.ts.map +1 -0
- package/lib/typescript/devtools/useConsoleController.d.ts +35 -0
- package/lib/typescript/devtools/useConsoleController.d.ts.map +1 -0
- package/lib/typescript/devtools/useConsoleMessages.d.ts +74 -0
- package/lib/typescript/devtools/useConsoleMessages.d.ts.map +1 -0
- package/lib/typescript/hooks/useConsoleLogs.d.ts +11 -0
- package/lib/typescript/hooks/useConsoleLogs.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +26 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts +38 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/store/consoleLogStore.d.ts +71 -0
- package/lib/typescript/store/consoleLogStore.d.ts.map +1 -0
- package/lib/typescript/store/sanitize.d.ts +11 -0
- package/lib/typescript/store/sanitize.d.ts.map +1 -0
- package/lib/typescript/sync/consoleSyncAdapter.d.ts +30 -0
- package/lib/typescript/sync/consoleSyncAdapter.d.ts.map +1 -0
- package/package.json +56 -0
- package/src/components/ConsoleIcon.tsx +49 -0
- package/src/components/ConsoleLogList.tsx +133 -0
- package/src/components/ConsoleModal.tsx +48 -0
- package/src/components/ConsoleRoot.tsx +25 -0
- package/src/devtools/ConsoleBody.tsx +225 -0
- package/src/devtools/ConsoleHeader.tsx +149 -0
- package/src/devtools/ConsoleMessageRow.tsx +345 -0
- package/src/devtools/ConsoleValue.tsx +265 -0
- package/src/devtools/ConsoleView.tsx +41 -0
- package/src/devtools/consoleFilter.ts +123 -0
- package/src/devtools/consoleFormat.ts +314 -0
- package/src/devtools/origin.ts +190 -0
- package/src/devtools/theme.ts +137 -0
- package/src/devtools/useConsoleController.ts +104 -0
- package/src/devtools/useConsoleMessages.ts +337 -0
- package/src/hooks/useConsoleLogs.ts +26 -0
- package/src/index.tsx +69 -0
- package/src/preset.tsx +35 -0
- package/src/store/consoleLogStore.ts +346 -0
- package/src/store/sanitize.ts +58 -0
- package/src/sync/consoleSyncAdapter.ts +49 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatConsoleMessage = formatConsoleMessage;
|
|
7
|
+
var _theme = require("./theme");
|
|
8
|
+
/**
|
|
9
|
+
* consoleFormat — port of DevTools `panels/console/ConsoleFormat.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Implements the WHATWG console Formatter: %s/%d/%i/%f/%o/%O/%c/%_ substitutions
|
|
12
|
+
* plus ANSI SGR (\x1B[…m) styling. Where DevTools works over V8 RemoteObjects we
|
|
13
|
+
* work over raw JS values; the substitution/ANSI logic is otherwise 1:1.
|
|
14
|
+
*
|
|
15
|
+
* Output is a flat list of tokens the row renderer consumes:
|
|
16
|
+
* - { type: 'string', value, style? } — text, optionally styled by %c / ANSI
|
|
17
|
+
* - { type: 'value', value, mode } — an object/array substitution (%o/%O)
|
|
18
|
+
* or a trailing non-string argument
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// VGA color palette (matches DevTools ANSI_COLORS / ANSI_BRIGHT_COLORS).
|
|
22
|
+
const ANSI_COLORS = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "gray"];
|
|
23
|
+
const ANSI_BRIGHT_COLORS = ["darkgray", "lightred", "lightgreen", "lightyellow", "lightblue", "lightmagenta", "lightcyan", "white"];
|
|
24
|
+
|
|
25
|
+
/** A console arg's `description` (string form) — DevTools uses RemoteObject.description. */
|
|
26
|
+
function description(arg) {
|
|
27
|
+
if (typeof arg === "string") return arg;
|
|
28
|
+
if (arg === undefined) return "undefined";
|
|
29
|
+
if (arg === null) return "null";
|
|
30
|
+
if (typeof arg === "number" || typeof arg === "boolean" || typeof arg === "bigint") {
|
|
31
|
+
return String(arg);
|
|
32
|
+
}
|
|
33
|
+
if (arg instanceof Error) return arg.stack ?? `${arg.name}: ${arg.message}`;
|
|
34
|
+
if (typeof arg === "function") return `ƒ ${arg.name || "(anonymous)"}`;
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(arg);
|
|
37
|
+
} catch {
|
|
38
|
+
return String(arg);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// \x1B is the ANSI escape (ESC) — intentional, for parsing color codes.
|
|
43
|
+
// eslint-disable-next-line no-control-regex
|
|
44
|
+
const FORMAT_RE = /%([%_Oocsdfi])|\x1B\[([\d;]*)m/;
|
|
45
|
+
|
|
46
|
+
/** Does the first arg actually need the substitution engine? */
|
|
47
|
+
function hasFormatting(fmt) {
|
|
48
|
+
return FORMAT_RE.test(fmt);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Convert a CSS declaration string (from %c or ANSI) into an RN TextStyle. */
|
|
52
|
+
function cssToTextStyle(css) {
|
|
53
|
+
const style = {};
|
|
54
|
+
let any = false;
|
|
55
|
+
for (const decl of css.split(";")) {
|
|
56
|
+
const idx = decl.indexOf(":");
|
|
57
|
+
if (idx === -1) continue;
|
|
58
|
+
const prop = decl.slice(0, idx).trim().toLowerCase();
|
|
59
|
+
let value = decl.slice(idx + 1).trim();
|
|
60
|
+
if (!value) continue;
|
|
61
|
+
// Resolve DevTools ANSI color vars to concrete hex.
|
|
62
|
+
const varMatch = value.match(/var\(--console-color-([a-z]+)\)/);
|
|
63
|
+
if (varMatch) value = _theme.ansiColors[varMatch[1]] ?? value;
|
|
64
|
+
switch (prop) {
|
|
65
|
+
case "color":
|
|
66
|
+
style.color = value;
|
|
67
|
+
any = true;
|
|
68
|
+
break;
|
|
69
|
+
case "background-color":
|
|
70
|
+
case "background":
|
|
71
|
+
style.backgroundColor = value;
|
|
72
|
+
any = true;
|
|
73
|
+
break;
|
|
74
|
+
case "font-weight":
|
|
75
|
+
style.fontWeight = value === "lighter" ? "300" : value;
|
|
76
|
+
any = true;
|
|
77
|
+
break;
|
|
78
|
+
case "font-style":
|
|
79
|
+
if (value === "italic") {
|
|
80
|
+
style.fontStyle = "italic";
|
|
81
|
+
any = true;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "font-size":
|
|
85
|
+
{
|
|
86
|
+
const n = parseFloat(value);
|
|
87
|
+
if (!Number.isNaN(n)) {
|
|
88
|
+
style.fontSize = n;
|
|
89
|
+
any = true;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "text-decoration":
|
|
94
|
+
case "text-decoration-line":
|
|
95
|
+
if (value.includes("underline") && value.includes("line-through")) {
|
|
96
|
+
style.textDecorationLine = "underline line-through";
|
|
97
|
+
} else if (value.includes("underline")) {
|
|
98
|
+
style.textDecorationLine = "underline";
|
|
99
|
+
} else if (value.includes("line-through")) {
|
|
100
|
+
style.textDecorationLine = "line-through";
|
|
101
|
+
}
|
|
102
|
+
any = true;
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return any ? style : undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Apply one ANSI SGR sequence to the running style map (DevTools algorithm). */
|
|
112
|
+
function applyAnsi(codes, currentStyle) {
|
|
113
|
+
const addTextDecoration = value => {
|
|
114
|
+
const td = currentStyle.get("text-decoration") ?? "";
|
|
115
|
+
if (!td.includes(value)) currentStyle.set("text-decoration", `${td} ${value}`);
|
|
116
|
+
};
|
|
117
|
+
const removeTextDecoration = value => {
|
|
118
|
+
const td = currentStyle.get("text-decoration")?.replace(` ${value}`, "");
|
|
119
|
+
if (td) currentStyle.set("text-decoration", td);else currentStyle.delete("text-decoration");
|
|
120
|
+
};
|
|
121
|
+
while (codes.length) {
|
|
122
|
+
const code = codes.shift();
|
|
123
|
+
switch (code) {
|
|
124
|
+
case 0:
|
|
125
|
+
currentStyle.clear();
|
|
126
|
+
break;
|
|
127
|
+
case 1:
|
|
128
|
+
currentStyle.set("font-weight", "bold");
|
|
129
|
+
break;
|
|
130
|
+
case 2:
|
|
131
|
+
currentStyle.set("font-weight", "lighter");
|
|
132
|
+
break;
|
|
133
|
+
case 3:
|
|
134
|
+
currentStyle.set("font-style", "italic");
|
|
135
|
+
break;
|
|
136
|
+
case 4:
|
|
137
|
+
addTextDecoration("underline");
|
|
138
|
+
break;
|
|
139
|
+
case 9:
|
|
140
|
+
addTextDecoration("line-through");
|
|
141
|
+
break;
|
|
142
|
+
case 22:
|
|
143
|
+
currentStyle.delete("font-weight");
|
|
144
|
+
break;
|
|
145
|
+
case 23:
|
|
146
|
+
currentStyle.delete("font-style");
|
|
147
|
+
break;
|
|
148
|
+
case 24:
|
|
149
|
+
removeTextDecoration("underline");
|
|
150
|
+
break;
|
|
151
|
+
case 29:
|
|
152
|
+
removeTextDecoration("line-through");
|
|
153
|
+
break;
|
|
154
|
+
case 38:
|
|
155
|
+
case 48:
|
|
156
|
+
if (codes.shift() === 2) {
|
|
157
|
+
const r = codes.shift() ?? 0;
|
|
158
|
+
const g = codes.shift() ?? 0;
|
|
159
|
+
const b = codes.shift() ?? 0;
|
|
160
|
+
currentStyle.set(code === 38 ? "color" : "background-color", `rgb(${r},${g},${b})`);
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case 39:
|
|
164
|
+
case 49:
|
|
165
|
+
currentStyle.delete(code === 39 ? "color" : "background-color");
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
{
|
|
169
|
+
const color = ANSI_COLORS[code - 30] ?? ANSI_BRIGHT_COLORS[code - 90];
|
|
170
|
+
if (color !== undefined) {
|
|
171
|
+
currentStyle.set("color", `var(--console-color-${color})`);
|
|
172
|
+
} else {
|
|
173
|
+
const bg = ANSI_COLORS[code - 40] ?? ANSI_BRIGHT_COLORS[code - 100];
|
|
174
|
+
if (bg !== undefined) currentStyle.set("background-color", `var(--console-color-${bg})`);
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Run the substitution engine over a format string + its args. */
|
|
183
|
+
function formatWithSubstitutions(fmtIn, args) {
|
|
184
|
+
let fmt = fmtIn;
|
|
185
|
+
const tokens = [];
|
|
186
|
+
const currentStyle = new Map();
|
|
187
|
+
let cssStyle;
|
|
188
|
+
const pushString = value => {
|
|
189
|
+
if (!value) return;
|
|
190
|
+
const last = tokens[tokens.length - 1];
|
|
191
|
+
if (last && last.type === "string" && styleEq(last.style, cssStyle)) {
|
|
192
|
+
last.value += value;
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
tokens.push({
|
|
196
|
+
type: "string",
|
|
197
|
+
value,
|
|
198
|
+
style: cssStyle
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
let argIndex = 0;
|
|
202
|
+
for (let match = FORMAT_RE.exec(fmt); match !== null; match = FORMAT_RE.exec(fmt)) {
|
|
203
|
+
pushString(match.input.substring(0, match.index));
|
|
204
|
+
let substitution;
|
|
205
|
+
const specifier = match[1];
|
|
206
|
+
switch (specifier) {
|
|
207
|
+
case "%":
|
|
208
|
+
pushString("%");
|
|
209
|
+
substitution = "";
|
|
210
|
+
break;
|
|
211
|
+
case "s":
|
|
212
|
+
if (argIndex < args.length) substitution = description(args[argIndex++]);
|
|
213
|
+
break;
|
|
214
|
+
case "c":
|
|
215
|
+
if (argIndex < args.length) {
|
|
216
|
+
cssStyle = cssToTextStyle(description(args[argIndex++]));
|
|
217
|
+
substitution = "";
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case "o":
|
|
221
|
+
case "O":
|
|
222
|
+
if (argIndex < args.length) {
|
|
223
|
+
tokens.push({
|
|
224
|
+
type: "value",
|
|
225
|
+
value: args[argIndex++],
|
|
226
|
+
mode: specifier === "O" ? "generic" : "optimal"
|
|
227
|
+
});
|
|
228
|
+
substitution = "";
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
case "_":
|
|
232
|
+
if (argIndex < args.length) {
|
|
233
|
+
argIndex++;
|
|
234
|
+
substitution = "";
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
case "d":
|
|
238
|
+
case "f":
|
|
239
|
+
case "i":
|
|
240
|
+
{
|
|
241
|
+
if (argIndex < args.length) {
|
|
242
|
+
const v = args[argIndex++];
|
|
243
|
+
let n = typeof v !== "number" ? NaN : v;
|
|
244
|
+
if (specifier !== "f") n = Math.floor(n);
|
|
245
|
+
substitution = n;
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case undefined:
|
|
250
|
+
{
|
|
251
|
+
const codes = (match[2] || "0").split(";").map(c => c ? parseInt(c, 10) : 0);
|
|
252
|
+
applyAnsi(codes, currentStyle);
|
|
253
|
+
const css = [...currentStyle.entries()].map(([k, val]) => `${k}:${val.trimStart()}`).join(";");
|
|
254
|
+
cssStyle = cssToTextStyle(css);
|
|
255
|
+
substitution = "";
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (substitution === undefined) {
|
|
260
|
+
pushString(match[0]);
|
|
261
|
+
substitution = "";
|
|
262
|
+
}
|
|
263
|
+
fmt = substitution + match.input.substring(match.index + match[0].length);
|
|
264
|
+
}
|
|
265
|
+
pushString(fmt);
|
|
266
|
+
return {
|
|
267
|
+
tokens,
|
|
268
|
+
rest: args.slice(argIndex)
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function styleEq(a, b) {
|
|
272
|
+
if (a === b) return true;
|
|
273
|
+
if (!a || !b) return false;
|
|
274
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Format a console call's arguments into renderable tokens, mirroring how the
|
|
279
|
+
* DevTools console renders a message: if the first arg is a format string it
|
|
280
|
+
* drives substitution, then any leftover args are appended (space-separated).
|
|
281
|
+
*/
|
|
282
|
+
function formatConsoleMessage(args) {
|
|
283
|
+
if (args.length === 0) return [];
|
|
284
|
+
let tokens = [];
|
|
285
|
+
let rest = args;
|
|
286
|
+
if (typeof args[0] === "string" && hasFormatting(args[0])) {
|
|
287
|
+
const result = formatWithSubstitutions(args[0], args.slice(1));
|
|
288
|
+
tokens = result.tokens;
|
|
289
|
+
rest = result.rest;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Append remaining args (the common case: console.log("x", obj, 1)).
|
|
293
|
+
for (const arg of rest) {
|
|
294
|
+
if (tokens.length > 0) tokens.push({
|
|
295
|
+
type: "string",
|
|
296
|
+
value: " "
|
|
297
|
+
});
|
|
298
|
+
if (typeof arg === "string") {
|
|
299
|
+
tokens.push({
|
|
300
|
+
type: "string",
|
|
301
|
+
value: arg
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
tokens.push({
|
|
305
|
+
type: "value",
|
|
306
|
+
value: arg,
|
|
307
|
+
mode: "optimal"
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return tokens;
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=consoleFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_theme","require","ANSI_COLORS","ANSI_BRIGHT_COLORS","description","arg","undefined","String","Error","stack","name","message","JSON","stringify","FORMAT_RE","hasFormatting","fmt","test","cssToTextStyle","css","style","any","decl","split","idx","indexOf","prop","slice","trim","toLowerCase","value","varMatch","match","ansiColors","color","backgroundColor","fontWeight","fontStyle","n","parseFloat","Number","isNaN","fontSize","includes","textDecorationLine","applyAnsi","codes","currentStyle","addTextDecoration","td","get","set","removeTextDecoration","replace","delete","length","code","shift","clear","r","g","b","bg","formatWithSubstitutions","fmtIn","args","tokens","Map","cssStyle","pushString","last","type","styleEq","push","argIndex","exec","input","substring","index","substitution","specifier","mode","v","NaN","Math","floor","map","c","parseInt","entries","k","val","trimStart","join","rest","a","formatConsoleMessage","result"],"sourceRoot":"../../../src","sources":["devtools/consoleFormat.ts"],"mappings":";;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA,MAAMC,WAAW,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;AAC1F,MAAMC,kBAAkB,GAAG,CACzB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,WAAW,EACX,OAAO,CACR;;AAED;AACA,SAASC,WAAWA,CAACC,GAAY,EAAU;EACzC,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE,OAAOA,GAAG;EACvC,IAAIA,GAAG,KAAKC,SAAS,EAAE,OAAO,WAAW;EACzC,IAAID,GAAG,KAAK,IAAI,EAAE,OAAO,MAAM;EAC/B,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAI,OAAOA,GAAG,KAAK,SAAS,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IAClF,OAAOE,MAAM,CAACF,GAAG,CAAC;EACpB;EACA,IAAIA,GAAG,YAAYG,KAAK,EAAE,OAAOH,GAAG,CAACI,KAAK,IAAI,GAAGJ,GAAG,CAACK,IAAI,KAAKL,GAAG,CAACM,OAAO,EAAE;EAC3E,IAAI,OAAON,GAAG,KAAK,UAAU,EAAE,OAAO,KAAKA,GAAG,CAACK,IAAI,IAAI,aAAa,EAAE;EACtE,IAAI;IACF,OAAOE,IAAI,CAACC,SAAS,CAACR,GAAG,CAAC;EAC5B,CAAC,CAAC,MAAM;IACN,OAAO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AAM;IACtB4B,IAAI,GAAGG,MAAM,CAACH,IAAI;EACpB;;EAEA;EACA,KAAK,MAAMzF,GAAG,IAAIyF,IAAI,EAAE;IACtB,IAAI5B,MAAM,CAACX,MAAM,GAAG,CAAC,EAAEW,MAAM,CAACO,IAAI,CAAC;MAAEF,IAAI,EAAE,QAAQ;MAAEzC,KAAK,EAAE;IAAI,CAAC,CAAC;IAClE,IAAI,OAAOzB,GAAG,KAAK,QAAQ,EAAE;MAC3B6D,MAAM,CAACO,IAAI,CAAC;QAAEF,IAAI,EAAE,QAAQ;QAAEzC,KAAK,EAAEzB;MAAI,CAAC,CAAC;IAC7C,CAAC,MAAM;MACL6D,MAAM,CAACO,IAAI,CAAC;QAAEF,IAAI,EAAE,OAAO;QAAEzC,KAAK,EAAEzB,GAAG;QAAE4E,IAAI,EAAE;MAAU,CAAC,CAAC;IAC7D;EACF;EAEA,OAAOf,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bracketGlyph = bracketGlyph;
|
|
7
|
+
exports.colorForKey = colorForKey;
|
|
8
|
+
exports.parseOrigin = parseOrigin;
|
|
9
|
+
exports.sourceKey = sourceKey;
|
|
10
|
+
exports.sourceLabel = sourceLabel;
|
|
11
|
+
/**
|
|
12
|
+
* origin — attributes a console call to *where it came from*, and provides the
|
|
13
|
+
* lnav-style colored connecting bracket helpers.
|
|
14
|
+
*
|
|
15
|
+
* Three independent signals (captured in the store at log time):
|
|
16
|
+
* - **component** — nearest owning React component (React.captureOwnerStack,
|
|
17
|
+
* dev only; null outside render / in async callbacks)
|
|
18
|
+
* - **function** — the enclosing function of the call site (JS stack)
|
|
19
|
+
* - **callSite** — the exact `file:line` of the call site (JS stack)
|
|
20
|
+
*
|
|
21
|
+
* The view groups consecutive same-source rows and draws a colored bracket
|
|
22
|
+
* gutter (┌ │ └ ─) exactly like lnav's per-file gutter.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Our own capture frames, matched by FUNCTION NAME. This is the primary filter:
|
|
27
|
+
* in a Metro/Hermes bundle every frame shares one bundle URL, so filename
|
|
28
|
+
* filtering can't distinguish them — and that URL often contains `node_modules`
|
|
29
|
+
* (e.g. expo-router/entry.bundle), which would wrongly reject *every* frame.
|
|
30
|
+
* The first frame after these is the real caller (framework internals sit
|
|
31
|
+
* deeper in the stack, after the app frame).
|
|
32
|
+
*/
|
|
33
|
+
const INTERNAL_FUNC = /^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/;
|
|
34
|
+
|
|
35
|
+
/** Narrow filename guard — only our own module (used when stacks carry real
|
|
36
|
+
* file paths, e.g. on web/V8 rather than a single Hermes bundle). */
|
|
37
|
+
const INTERNAL_FILE = /consoleLogStore/;
|
|
38
|
+
function isInternalFrame(frame) {
|
|
39
|
+
if (frame.func && INTERNAL_FUNC.test(frame.func.replace(/^Object\./, ""))) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return Boolean(frame.file && INTERNAL_FILE.test(frame.file));
|
|
43
|
+
}
|
|
44
|
+
/** Parse a V8 or Hermes stack string into frames. */
|
|
45
|
+
function parseFrames(stack) {
|
|
46
|
+
const frames = [];
|
|
47
|
+
for (const raw of stack.split("\n")) {
|
|
48
|
+
const line = raw.trim();
|
|
49
|
+
if (!line || line === "Error") continue;
|
|
50
|
+
// V8: "at func (file:line:col)"
|
|
51
|
+
let m = line.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);
|
|
52
|
+
if (m) {
|
|
53
|
+
frames.push({
|
|
54
|
+
func: m[1],
|
|
55
|
+
file: m[2],
|
|
56
|
+
line: Number(m[3])
|
|
57
|
+
});
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
// V8: "at file:line:col"
|
|
61
|
+
m = line.match(/^at\s+(.+?):(\d+):(\d+)$/);
|
|
62
|
+
if (m) {
|
|
63
|
+
frames.push({
|
|
64
|
+
file: m[1],
|
|
65
|
+
line: Number(m[2])
|
|
66
|
+
});
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Hermes: "func@file:line:col"
|
|
70
|
+
m = line.match(/^(.*?)@(.+?):(\d+):(\d+)$/);
|
|
71
|
+
if (m) {
|
|
72
|
+
frames.push({
|
|
73
|
+
func: m[1] || undefined,
|
|
74
|
+
file: m[2],
|
|
75
|
+
line: Number(m[3])
|
|
76
|
+
});
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return frames;
|
|
81
|
+
}
|
|
82
|
+
function basename(file) {
|
|
83
|
+
if (!file) return undefined;
|
|
84
|
+
const noQuery = file.split("?")[0];
|
|
85
|
+
return noQuery.split("/").pop() || noQuery;
|
|
86
|
+
}
|
|
87
|
+
function cleanFunctionName(func) {
|
|
88
|
+
if (!func) return undefined;
|
|
89
|
+
const f = func.replace(/^Object\./, "").trim();
|
|
90
|
+
if (!f || f === "<anonymous>" || f === "anonymous") return undefined;
|
|
91
|
+
return f;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** First component name from a React owner stack (nearest owner). */
|
|
95
|
+
function firstComponent(ownerStack) {
|
|
96
|
+
if (!ownerStack) return undefined;
|
|
97
|
+
for (const raw of ownerStack.split("\n")) {
|
|
98
|
+
const m = raw.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);
|
|
99
|
+
if (m) return m[1];
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Derive the origin of a log from its captured JS stack + React owner stack. */
|
|
105
|
+
function parseOrigin(stack, ownerStack) {
|
|
106
|
+
const component = firstComponent(ownerStack);
|
|
107
|
+
let appFrame;
|
|
108
|
+
if (stack) {
|
|
109
|
+
const frames = parseFrames(stack);
|
|
110
|
+
appFrame = frames.find(f => !isInternalFrame(f));
|
|
111
|
+
}
|
|
112
|
+
const functionName = cleanFunctionName(appFrame?.func);
|
|
113
|
+
const file = basename(appFrame?.file);
|
|
114
|
+
const line = appFrame?.line;
|
|
115
|
+
const callSite = file && line != null ? `${file}:${line}` : undefined;
|
|
116
|
+
if (!component && !functionName && !callSite) return undefined;
|
|
117
|
+
return {
|
|
118
|
+
component,
|
|
119
|
+
functionName,
|
|
120
|
+
callSite,
|
|
121
|
+
file,
|
|
122
|
+
line
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ─── Grouping by dimension ───────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Stable key used to group consecutive rows (null = ungrouped).
|
|
130
|
+
*
|
|
131
|
+
* Each dimension falls back to the next-best signal so a row is never lumped
|
|
132
|
+
* into a single catch-all bucket: a handler-fired log (no React owner) still
|
|
133
|
+
* differentiates by its function / call site under "Component".
|
|
134
|
+
*/
|
|
135
|
+
function sourceKey(origin, dim) {
|
|
136
|
+
if (dim === "off" || !origin) return dim === "off" ? null : "—unknown—";
|
|
137
|
+
if (dim === "component") {
|
|
138
|
+
return origin.component ?? origin.functionName ?? origin.callSite ?? "—unknown—";
|
|
139
|
+
}
|
|
140
|
+
if (dim === "function") {
|
|
141
|
+
return origin.functionName ?? origin.callSite ?? origin.component ?? "—anonymous—";
|
|
142
|
+
}
|
|
143
|
+
return origin.callSite ?? origin.functionName ?? "—unknown—";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Human label shown next to the row. */
|
|
147
|
+
function sourceLabel(origin, dim) {
|
|
148
|
+
if (!origin) return "(unknown)";
|
|
149
|
+
if (dim === "component") {
|
|
150
|
+
if (origin.component) return origin.component;
|
|
151
|
+
if (origin.functionName) return `ƒ ${origin.functionName}`;
|
|
152
|
+
return origin.callSite ?? "(unknown)";
|
|
153
|
+
}
|
|
154
|
+
if (dim === "function") {
|
|
155
|
+
if (origin.functionName) return origin.functionName;
|
|
156
|
+
return origin.callSite ?? "(anonymous)";
|
|
157
|
+
}
|
|
158
|
+
if (dim === "callsite") {
|
|
159
|
+
if (origin.functionName && origin.callSite) return `${origin.functionName} · ${origin.callSite}`;
|
|
160
|
+
return origin.callSite ?? (origin.functionName ? `ƒ ${origin.functionName}` : "(unknown)");
|
|
161
|
+
}
|
|
162
|
+
return "";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ─── Color + bracket ─────────────────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
function hashString(s) {
|
|
168
|
+
let h = 0;
|
|
169
|
+
for (let i = 0; i < s.length; i++) h = h * 31 + s.charCodeAt(i) | 0;
|
|
170
|
+
return Math.abs(h);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Stable, readable color for a source key (bright enough for a dark surface). */
|
|
174
|
+
function colorForKey(key) {
|
|
175
|
+
const hue = hashString(key) % 360;
|
|
176
|
+
return `hsl(${hue}, 70%, 66%)`;
|
|
177
|
+
}
|
|
178
|
+
/** lnav gutter glyph: ┌ run-start · │ run-middle · └ run-end · ─ single. */
|
|
179
|
+
function bracketGlyph(bracket) {
|
|
180
|
+
switch (bracket) {
|
|
181
|
+
case "top":
|
|
182
|
+
return "┌";
|
|
183
|
+
case "bottom":
|
|
184
|
+
return "└";
|
|
185
|
+
case "single":
|
|
186
|
+
return "─";
|
|
187
|
+
default:
|
|
188
|
+
return "│";
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=origin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["INTERNAL_FUNC","INTERNAL_FILE","isInternalFrame","frame","func","test","replace","Boolean","file","parseFrames","stack","frames","raw","split","line","trim","m","match","push","Number","undefined","basename","noQuery","pop","cleanFunctionName","f","firstComponent","ownerStack","parseOrigin","component","appFrame","find","functionName","callSite","sourceKey","origin","dim","sourceLabel","hashString","s","h","i","length","charCodeAt","Math","abs","colorForKey","key","hue","bracketGlyph","bracket"],"sourceRoot":"../../../src","sources":["devtools/origin.ts"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,aAAa,GACjB,+EAA+E;;AAEjF;AACA;AACA,MAAMC,aAAa,GAAG,iBAAiB;AAEvC,SAASC,eAAeA,CAACC,KAAe,EAAW;EACjD,IAAIA,KAAK,CAACC,IAAI,IAAIJ,aAAa,CAACK,IAAI,CAACF,KAAK,CAACC,IAAI,CAACE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,EAAE;IACzE,OAAO,IAAI;EACb;EACA,OAAOC,OAAO,CAACJ,KAAK,CAACK,IAAI,IAAIP,aAAa,CAACI,IAAI,CAACF,KAAK,CAACK,IAAI,CAAC,CAAC;AAC9D;AAQA;AACA,SAASC,WAAWA,CAACC,KAAa,EAAc;EAC9C,MAAMC,MAAkB,GAAG,EAAE;EAC7B,KAAK,MAAMC,GAAG,IAAIF,KAAK,CAACG,KAAK,CAAC,IAAI,CAAC,EAAE;IACnC,MAAMC,IAAI,GAAGF,GAAG,CAACG,IAAI,CAAC,CAAC;IACvB,IAAI,CAACD,IAAI,IAAIA,IAAI,KAAK,OAAO,EAAE;IAC/B;IACA,IAAIE,CAAC,GAAGF,IAAI,CAACG,KAAK,CAAC,sCAAsC,CAAC;IAC1D,IAAID,CAAC,EAAE;MACLL,MAAM,CAACO,IAAI,CAAC;QAAEd,IAAI,EAAEY,CAAC,CAAC,CAAC,CAAC;QAAER,IAAI,EAAEQ,CAAC,CAAC,CAAC,CAAC;QAAEF,IAAI,EAAEK,MAAM,CAACH,CAAC,CAAC,CAAC,CAAC;MAAE,CAAC,CAAC;MAC3D;IACF;IACA;IACAA,CAAC,GAAGF,IAAI,CAACG,KAAK,CAAC,0BAA0B,CAAC;IAC1C,IAAID,CAAC,EAAE;MACLL,M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AC,GAAIA,CAAC,GAAG,EAAE,GAAGD,CAAC,CAACI,UAAU,CAACF,CAAC,CAAC,GAAI,CAAC;EACrE,OAAOG,IAAI,CAACC,GAAG,CAACL,CAAC,CAAC;AACpB;;AAEA;AACO,SAASM,WAAWA,CAACC,GAAW,EAAU;EAC/C,MAAMC,GAAG,GAAGV,UAAU,CAACS,GAAG,CAAC,GAAG,GAAG;EACjC,OAAO,OAAOC,GAAG,aAAa;AAChC;AAIA;AACO,SAASC,YAAYA,CAACC,OAAgB,EAAU;EACrD,QAAQA,OAAO;IACb,KAAK,KAAK;MACR,OAAO,GAAG;IACZ,KAAK,QAAQ;MACX,OAAO,GAAG;IACZ,KAAK,QAAQ;MACX,OAAO,GAAG;IACZ;MACE,OAAO,GAAG;EACd;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.monoFont = exports.lightTheme = exports.levelStyles = exports.darkTheme = exports.consoleTheme = exports.ansiColors = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* Console palette — a dark theme matched to Buoy's shared design tokens
|
|
10
|
+
* (`macOSColors` in @buoy-gg/shared-ui) so the console reads as part of the
|
|
11
|
+
* tool suite, tuned for contrast per WCAG AA:
|
|
12
|
+
* - body text #F5F5F7 on #0A0A0C ≈ 17:1
|
|
13
|
+
* - secondary #A1A1A6 on #0A0A0C ≈ 7:1
|
|
14
|
+
* - links #40CCFF on #0A0A0C ≈ 9:1
|
|
15
|
+
* - dividers / nesting guides lightened to ~#3A3A40 so lines are clearly
|
|
16
|
+
* visible against the near-black surface.
|
|
17
|
+
* The light values (the exact DevTools light tokens) are kept for a future
|
|
18
|
+
* toggle.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Monospace font. On the desktop dashboard (react-native-web) the generic
|
|
23
|
+
* `"monospace"` resolves to a thin, poorly-hinted browser default that's hard
|
|
24
|
+
* to read at small sizes — so we use a curated mono stack there. Native (mobile)
|
|
25
|
+
* keeps its system monospace, which already renders well.
|
|
26
|
+
*/
|
|
27
|
+
const monoFont = exports.monoFont = _reactNative.Platform.select({
|
|
28
|
+
web: 'ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Liberation Mono", monospace',
|
|
29
|
+
default: "monospace"
|
|
30
|
+
}) ?? "monospace";
|
|
31
|
+
/** Light theme (active) — resolved DevTools light-theme tokens. */
|
|
32
|
+
const lightTheme = exports.lightTheme = {
|
|
33
|
+
baseContainer: "#ffffff",
|
|
34
|
+
// --sys-color-cdt-base-container (neutral99 ≈ white)
|
|
35
|
+
surfaceError: "#fceaea",
|
|
36
|
+
// --sys-color-surface-error rgb(252 235 235)
|
|
37
|
+
surfaceYellow: "#fef6d5",
|
|
38
|
+
// --sys-color-surface-yellow rgb(254 246 213)
|
|
39
|
+
divider: "#e8eaed",
|
|
40
|
+
// --sys-color-divider (primary90, lightened for contrast)
|
|
41
|
+
inputBackground: "#f1f3f4",
|
|
42
|
+
menuBackground: "#ffffff",
|
|
43
|
+
onSurface: "#1f1f1f",
|
|
44
|
+
// neutral10
|
|
45
|
+
onSurfaceYellow: "#3e2f00",
|
|
46
|
+
// yellow20
|
|
47
|
+
onErrorContainer: "#410e0b",
|
|
48
|
+
// error10
|
|
49
|
+
tokenSubtle: "#757575",
|
|
50
|
+
// neutral50
|
|
51
|
+
primary: "#0b57d0",
|
|
52
|
+
// primary40 (links)
|
|
53
|
+
valueNumber: "#0842a0",
|
|
54
|
+
// token-attribute-value (blue30)
|
|
55
|
+
valueString: "#c5221f",
|
|
56
|
+
// token-property-special (error50, slightly deepened)
|
|
57
|
+
valueBigint: "#146c2e",
|
|
58
|
+
// token-comment (green40)
|
|
59
|
+
valueNode: "#1f1f1f",
|
|
60
|
+
// token-variable (= on-surface)
|
|
61
|
+
valueNullish: "rgba(31,31,31,0.5)",
|
|
62
|
+
// state-disabled
|
|
63
|
+
valuePreview: "rgba(31,31,31,0.62)"
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Dark theme (active) — matched to Buoy macOSColors, contrast-tuned. */
|
|
67
|
+
const darkTheme = exports.darkTheme = {
|
|
68
|
+
baseContainer: "#0A0A0C",
|
|
69
|
+
// macOSColors.background.base
|
|
70
|
+
surfaceError: "rgba(255,69,58,0.15)",
|
|
71
|
+
// semantic.errorBackground
|
|
72
|
+
surfaceYellow: "rgba(255,235,59,0.13)",
|
|
73
|
+
// semantic.warningBackground
|
|
74
|
+
divider: "#3A3A40",
|
|
75
|
+
// lightened from border.default (#2D2D2F) for visible lines
|
|
76
|
+
inputBackground: "#26262A",
|
|
77
|
+
// background.input
|
|
78
|
+
menuBackground: "#1A1A1C",
|
|
79
|
+
// background.card
|
|
80
|
+
onSurface: "#F5F5F7",
|
|
81
|
+
// text.primary (~17:1)
|
|
82
|
+
onSurfaceYellow: "#FFE9A3",
|
|
83
|
+
// light warm yellow on dark warning row
|
|
84
|
+
onErrorContainer: "#FFB4AB",
|
|
85
|
+
// light red on dark error row
|
|
86
|
+
tokenSubtle: "#A1A1A6",
|
|
87
|
+
// text.secondary (~7:1 — timestamps, previews)
|
|
88
|
+
primary: "#40CCFF",
|
|
89
|
+
// semantic.infoLight (links, ~9:1)
|
|
90
|
+
valueNumber: "#FF9F1C",
|
|
91
|
+
// orange (number + boolean)
|
|
92
|
+
valueString: "#7EE787",
|
|
93
|
+
// green (string/regexp/symbol)
|
|
94
|
+
valueBigint: "#A1A1A6",
|
|
95
|
+
// muted (bigint)
|
|
96
|
+
valueNode: "#F5F5F7",
|
|
97
|
+
// default text (DOM node / variable)
|
|
98
|
+
valueNullish: "#8E8E93",
|
|
99
|
+
// text.muted (null/undefined)
|
|
100
|
+
valuePreview: "#A1A1A6" // object preview (italic)
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** The active console palette. */
|
|
104
|
+
const consoleTheme = exports.consoleTheme = darkTheme;
|
|
105
|
+
|
|
106
|
+
/** ANSI 16-color palette (dark theme), from consoleView.css `--console-color-*`. */
|
|
107
|
+
const ansiColors = exports.ansiColors = {
|
|
108
|
+
black: "#000",
|
|
109
|
+
red: "rgb(237 78 76)",
|
|
110
|
+
green: "rgb(1 200 1)",
|
|
111
|
+
yellow: "rgb(210 192 87)",
|
|
112
|
+
blue: "rgb(39 116 240)",
|
|
113
|
+
magenta: "rgb(161 66 244)",
|
|
114
|
+
cyan: "rgb(18 181 203)",
|
|
115
|
+
gray: "rgb(207 208 208)",
|
|
116
|
+
darkgray: "rgb(137 137 137)",
|
|
117
|
+
lightred: "rgb(242 139 130)",
|
|
118
|
+
lightgreen: "rgb(161 247 181)",
|
|
119
|
+
lightyellow: "rgb(221 251 85)",
|
|
120
|
+
lightblue: "rgb(102 157 246)",
|
|
121
|
+
lightmagenta: "rgb(214 112 214)",
|
|
122
|
+
lightcyan: "rgb(132 240 255)",
|
|
123
|
+
white: "#fff"
|
|
124
|
+
};
|
|
125
|
+
const levelStyles = exports.levelStyles = {
|
|
126
|
+
verbose: {
|
|
127
|
+
text: consoleTheme.tokenSubtle
|
|
128
|
+
},
|
|
129
|
+
info: {
|
|
130
|
+
text: consoleTheme.onSurface
|
|
131
|
+
},
|
|
132
|
+
warning: {
|
|
133
|
+
background: consoleTheme.surfaceYellow,
|
|
134
|
+
text: consoleTheme.onSurfaceYellow,
|
|
135
|
+
icon: "warning"
|
|
136
|
+
},
|
|
137
|
+
error: {
|
|
138
|
+
background: consoleTheme.surfaceError,
|
|
139
|
+
text: consoleTheme.onErrorContainer,
|
|
140
|
+
icon: "error"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=theme.js.map
|