@buoy-gg/console 7.0.41 → 7.0.42

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 (108) hide show
  1. package/README.md +11 -69
  2. package/lib/commonjs/components/ConsoleIcon.js +1 -19
  3. package/lib/commonjs/components/ConsoleLogList.js +1 -152
  4. package/lib/commonjs/components/ConsoleModal.js +1 -48
  5. package/lib/commonjs/components/ConsoleRoot.js +1 -37
  6. package/lib/commonjs/devtools/ConsoleBody.js +1 -234
  7. package/lib/commonjs/devtools/ConsoleHeader.js +1 -114
  8. package/lib/commonjs/devtools/ConsoleMessageRow.js +1 -356
  9. package/lib/commonjs/devtools/ConsoleValue.js +1 -254
  10. package/lib/commonjs/devtools/ConsoleView.js +1 -54
  11. package/lib/commonjs/devtools/consoleFilter.js +1 -125
  12. package/lib/commonjs/devtools/consoleFormat.js +1 -313
  13. package/lib/commonjs/devtools/origin.js +1 -191
  14. package/lib/commonjs/devtools/theme.js +1 -152
  15. package/lib/commonjs/devtools/useConsoleController.js +1 -82
  16. package/lib/commonjs/devtools/useConsoleMessages.js +1 -241
  17. package/lib/commonjs/hooks/useConsoleLogs.js +1 -23
  18. package/lib/commonjs/index.js +1 -181
  19. package/lib/commonjs/preset.js +1 -63
  20. package/lib/commonjs/store/consoleLogStore.js +6 -589
  21. package/lib/commonjs/store/sanitize.js +1 -83
  22. package/lib/commonjs/sync/consoleSyncAdapter.js +1 -86
  23. package/lib/module/components/ConsoleIcon.js +1 -12
  24. package/lib/module/components/ConsoleLogList.js +1 -147
  25. package/lib/module/components/ConsoleModal.js +1 -44
  26. package/lib/module/components/ConsoleRoot.js +1 -33
  27. package/lib/module/devtools/ConsoleBody.js +1 -229
  28. package/lib/module/devtools/ConsoleHeader.js +1 -109
  29. package/lib/module/devtools/ConsoleMessageRow.js +1 -352
  30. package/lib/module/devtools/ConsoleValue.js +1 -249
  31. package/lib/module/devtools/ConsoleView.js +1 -49
  32. package/lib/module/devtools/consoleFilter.js +1 -119
  33. package/lib/module/devtools/consoleFormat.js +1 -309
  34. package/lib/module/devtools/origin.js +1 -183
  35. package/lib/module/devtools/theme.js +1 -143
  36. package/lib/module/devtools/useConsoleController.js +1 -79
  37. package/lib/module/devtools/useConsoleMessages.js +1 -238
  38. package/lib/module/hooks/useConsoleLogs.js +1 -19
  39. package/lib/module/index.js +1 -52
  40. package/lib/module/preset.js +1 -61
  41. package/lib/module/store/consoleLogStore.js +6 -575
  42. package/lib/module/store/sanitize.js +1 -77
  43. package/lib/module/sync/consoleSyncAdapter.js +1 -82
  44. package/lib/web/index.mjs +11 -12
  45. package/package.json +2 -2
  46. package/lib/commonjs/components/ConsoleIcon.js.map +0 -1
  47. package/lib/commonjs/components/ConsoleLogList.js.map +0 -1
  48. package/lib/commonjs/components/ConsoleModal.js.map +0 -1
  49. package/lib/commonjs/components/ConsoleRoot.js.map +0 -1
  50. package/lib/commonjs/devtools/ConsoleBody.js.map +0 -1
  51. package/lib/commonjs/devtools/ConsoleHeader.js.map +0 -1
  52. package/lib/commonjs/devtools/ConsoleMessageRow.js.map +0 -1
  53. package/lib/commonjs/devtools/ConsoleValue.js.map +0 -1
  54. package/lib/commonjs/devtools/ConsoleView.js.map +0 -1
  55. package/lib/commonjs/devtools/consoleFilter.js.map +0 -1
  56. package/lib/commonjs/devtools/consoleFormat.js.map +0 -1
  57. package/lib/commonjs/devtools/origin.js.map +0 -1
  58. package/lib/commonjs/devtools/theme.js.map +0 -1
  59. package/lib/commonjs/devtools/useConsoleController.js.map +0 -1
  60. package/lib/commonjs/devtools/useConsoleMessages.js.map +0 -1
  61. package/lib/commonjs/hooks/useConsoleLogs.js.map +0 -1
  62. package/lib/commonjs/index.js.map +0 -1
  63. package/lib/commonjs/preset.js.map +0 -1
  64. package/lib/commonjs/store/consoleLogStore.js.map +0 -1
  65. package/lib/commonjs/store/sanitize.js.map +0 -1
  66. package/lib/commonjs/sync/consoleSyncAdapter.js.map +0 -1
  67. package/lib/module/components/ConsoleIcon.js.map +0 -1
  68. package/lib/module/components/ConsoleLogList.js.map +0 -1
  69. package/lib/module/components/ConsoleModal.js.map +0 -1
  70. package/lib/module/components/ConsoleRoot.js.map +0 -1
  71. package/lib/module/devtools/ConsoleBody.js.map +0 -1
  72. package/lib/module/devtools/ConsoleHeader.js.map +0 -1
  73. package/lib/module/devtools/ConsoleMessageRow.js.map +0 -1
  74. package/lib/module/devtools/ConsoleValue.js.map +0 -1
  75. package/lib/module/devtools/ConsoleView.js.map +0 -1
  76. package/lib/module/devtools/consoleFilter.js.map +0 -1
  77. package/lib/module/devtools/consoleFormat.js.map +0 -1
  78. package/lib/module/devtools/origin.js.map +0 -1
  79. package/lib/module/devtools/theme.js.map +0 -1
  80. package/lib/module/devtools/useConsoleController.js.map +0 -1
  81. package/lib/module/devtools/useConsoleMessages.js.map +0 -1
  82. package/lib/module/hooks/useConsoleLogs.js.map +0 -1
  83. package/lib/module/index.js.map +0 -1
  84. package/lib/module/preset.js.map +0 -1
  85. package/lib/module/store/consoleLogStore.js.map +0 -1
  86. package/lib/module/store/sanitize.js.map +0 -1
  87. package/lib/module/sync/consoleSyncAdapter.js.map +0 -1
  88. package/lib/typescript/components/ConsoleIcon.d.ts.map +0 -1
  89. package/lib/typescript/components/ConsoleLogList.d.ts.map +0 -1
  90. package/lib/typescript/components/ConsoleModal.d.ts.map +0 -1
  91. package/lib/typescript/components/ConsoleRoot.d.ts.map +0 -1
  92. package/lib/typescript/devtools/ConsoleBody.d.ts.map +0 -1
  93. package/lib/typescript/devtools/ConsoleHeader.d.ts.map +0 -1
  94. package/lib/typescript/devtools/ConsoleMessageRow.d.ts.map +0 -1
  95. package/lib/typescript/devtools/ConsoleValue.d.ts.map +0 -1
  96. package/lib/typescript/devtools/ConsoleView.d.ts.map +0 -1
  97. package/lib/typescript/devtools/consoleFilter.d.ts.map +0 -1
  98. package/lib/typescript/devtools/consoleFormat.d.ts.map +0 -1
  99. package/lib/typescript/devtools/origin.d.ts.map +0 -1
  100. package/lib/typescript/devtools/theme.d.ts.map +0 -1
  101. package/lib/typescript/devtools/useConsoleController.d.ts.map +0 -1
  102. package/lib/typescript/devtools/useConsoleMessages.d.ts.map +0 -1
  103. package/lib/typescript/hooks/useConsoleLogs.d.ts.map +0 -1
  104. package/lib/typescript/index.d.ts.map +0 -1
  105. package/lib/typescript/preset.d.ts.map +0 -1
  106. package/lib/typescript/store/consoleLogStore.d.ts.map +0 -1
  107. package/lib/typescript/store/sanitize.d.ts.map +0 -1
  108. package/lib/typescript/sync/consoleSyncAdapter.d.ts.map +0 -1
@@ -1,313 +1 @@
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
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatConsoleMessage=formatConsoleMessage;var _theme=require("./theme");const ANSI_COLORS=["black","red","green","yellow","blue","magenta","cyan","gray"];const ANSI_BRIGHT_COLORS=["darkgray","lightred","lightgreen","lightyellow","lightblue","lightmagenta","lightcyan","white"];function description(t){if(typeof t==="string")return t;if(t===void 0)return"undefined";if(t===null)return"null";if(typeof t==="number"||typeof t==="boolean"||typeof t==="bigint"){return String(t)}if(t instanceof Error)return t.stack??`${t.name}: ${t.message}`;if(typeof t==="function")return`\u0192 ${t.name||"(anonymous)"}`;try{return JSON.stringify(t)}catch{return String(t)}}const FORMAT_RE=/%([%_Oocsdfi])|\x1B\[([\d;]*)m/;function hasFormatting(t){return FORMAT_RE.test(t)}function cssToTextStyle(t){const e={};let s=false;for(const i of t.split(";")){const o=i.indexOf(":");if(o===-1)continue;const r=i.slice(0,o).trim().toLowerCase();let n=i.slice(o+1).trim();if(!n)continue;const l=n.match(/var\(--console-color-([a-z]+)\)/);if(l)n=_theme.ansiColors[l[1]]??n;switch(r){case"color":e.color=n;s=true;break;case"background-color":case"background":e.backgroundColor=n;s=true;break;case"font-weight":e.fontWeight=n==="lighter"?"300":n;s=true;break;case"font-style":if(n==="italic"){e.fontStyle="italic";s=true}break;case"font-size":{const c=parseFloat(n);if(!Number.isNaN(c)){e.fontSize=c;s=true}break}case"text-decoration":case"text-decoration-line":if(n.includes("underline")&&n.includes("line-through")){e.textDecorationLine="underline line-through"}else if(n.includes("underline")){e.textDecorationLine="underline"}else if(n.includes("line-through")){e.textDecorationLine="line-through"}s=true;break;default:break}}return s?e:void 0}function applyAnsi(t,e){const s=o=>{const r=e.get("text-decoration")??"";if(!r.includes(o))e.set("text-decoration",`${r} ${o}`)};const i=o=>{const r=e.get("text-decoration")?.replace(` ${o}`,"");if(r)e.set("text-decoration",r);else e.delete("text-decoration")};while(t.length){const o=t.shift();switch(o){case 0:e.clear();break;case 1:e.set("font-weight","bold");break;case 2:e.set("font-weight","lighter");break;case 3:e.set("font-style","italic");break;case 4:s("underline");break;case 9:s("line-through");break;case 22:e.delete("font-weight");break;case 23:e.delete("font-style");break;case 24:i("underline");break;case 29:i("line-through");break;case 38:case 48:if(t.shift()===2){const r=t.shift()??0;const n=t.shift()??0;const l=t.shift()??0;e.set(o===38?"color":"background-color",`rgb(${r},${n},${l})`)}break;case 39:case 49:e.delete(o===39?"color":"background-color");break;default:{const r=ANSI_COLORS[o-30]??ANSI_BRIGHT_COLORS[o-90];if(r!==void 0){e.set("color",`var(--console-color-${r})`)}else{const n=ANSI_COLORS[o-40]??ANSI_BRIGHT_COLORS[o-100];if(n!==void 0)e.set("background-color",`var(--console-color-${n})`)}break}}}}function formatWithSubstitutions(t,e){let s=t;const i=[];const o=new Map;let r;const n=c=>{if(!c)return;const a=i[i.length-1];if(a&&a.type==="string"&&styleEq(a.style,r)){a.value+=c;return}i.push({type:"string",value:c,style:r})};let l=0;for(let c=FORMAT_RE.exec(s);c!==null;c=FORMAT_RE.exec(s)){n(c.input.substring(0,c.index));let a;const h=c[1];switch(h){case"%":n("%");a="";break;case"s":if(l<e.length)a=description(e[l++]);break;case"c":if(l<e.length){r=cssToTextStyle(description(e[l++]));a=""}break;case"o":case"O":if(l<e.length){i.push({type:"value",value:e[l++],mode:h==="O"?"generic":"optimal"});a=""}break;case"_":if(l<e.length){l++;a=""}break;case"d":case"f":case"i":{if(l<e.length){const u=e[l++];let f=typeof u!=="number"?NaN:u;if(h!=="f")f=Math.floor(f);a=f}break}case void 0:{const u=(c[2]||"0").split(";").map(d=>d?parseInt(d,10):0);applyAnsi(u,o);const f=[...o.entries()].map(([d,b])=>`${d}:${b.trimStart()}`).join(";");r=cssToTextStyle(f);a="";break}}if(a===void 0){n(c[0]);a=""}s=a+c.input.substring(c.index+c[0].length)}n(s);return{tokens:i,rest:e.slice(l)}}function styleEq(t,e){if(t===e)return true;if(!t||!e)return false;return JSON.stringify(t)===JSON.stringify(e)}function formatConsoleMessage(t){if(t.length===0)return[];let e=[];let s=t;if(typeof t[0]==="string"&&hasFormatting(t[0])){const i=formatWithSubstitutions(t[0],t.slice(1));e=i.tokens;s=i.rest}for(const i of s){if(e.length>0)e.push({type:"string",value:" "});if(typeof i==="string"){e.push({type:"string",value:i})}else{e.push({type:"value",value:i,mode:"optimal"})}}return e}
@@ -1,191 +1 @@
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
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.bracketGlyph=bracketGlyph;exports.colorForKey=colorForKey;exports.parseOrigin=parseOrigin;exports.sourceKey=sourceKey;exports.sourceLabel=sourceLabel;const INTERNAL_FUNC=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/;const INTERNAL_FILE=/consoleLogStore/;function isInternalFrame(n){if(n.func&&INTERNAL_FUNC.test(n.func.replace(/^Object\./,""))){return true}return Boolean(n.file&&INTERNAL_FILE.test(n.file))}function parseFrames(n){const e=[];for(const u of n.split("\n")){const r=u.trim();if(!r||r==="Error")continue;let t=r.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(t){e.push({func:t[1],file:t[2],line:Number(t[3])});continue}t=r.match(/^at\s+(.+?):(\d+):(\d+)$/);if(t){e.push({file:t[1],line:Number(t[2])});continue}t=r.match(/^(.*?)@(.+?):(\d+):(\d+)$/);if(t){e.push({func:t[1]||void 0,file:t[2],line:Number(t[3])});continue}}return e}function basename(n){if(!n)return void 0;const e=n.split("?")[0];return e.split("/").pop()||e}function cleanFunctionName(n){if(!n)return void 0;const e=n.replace(/^Object\./,"").trim();if(!e||e==="<anonymous>"||e==="anonymous")return void 0;return e}function firstComponent(n){if(!n)return void 0;for(const e of n.split("\n")){const u=e.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(u)return u[1]}return void 0}function parseOrigin(n,e){const u=firstComponent(e);let r;if(n){const a=parseFrames(n);r=a.find(s=>!isInternalFrame(s))}const t=cleanFunctionName(r?.func);const o=basename(r?.file);const c=r?.line;const f=o&&c!=null?`${o}:${c}`:void 0;if(!u&&!t&&!f)return void 0;return{component:u,functionName:t,callSite:f,file:o,line:c}}function sourceKey(n,e){if(e==="off"||!n)return e==="off"?null:"\u2014unknown\u2014";if(e==="component"){return n.component??n.functionName??n.callSite??"\u2014unknown\u2014"}if(e==="function"){return n.functionName??n.callSite??n.component??"\u2014anonymous\u2014"}return n.callSite??n.functionName??"\u2014unknown\u2014"}function sourceLabel(n,e){if(!n)return"(unknown)";if(e==="component"){if(n.component)return n.component;if(n.functionName)return`\u0192 ${n.functionName}`;return n.callSite??"(unknown)"}if(e==="function"){if(n.functionName)return n.functionName;return n.callSite??"(anonymous)"}if(e==="callsite"){if(n.functionName&&n.callSite)return`${n.functionName} \xB7 ${n.callSite}`;return n.callSite??(n.functionName?`\u0192 ${n.functionName}`:"(unknown)")}return""}function hashString(n){let e=0;for(let u=0;u<n.length;u++)e=e*31+n.charCodeAt(u)|0;return Math.abs(e)}function colorForKey(n){const e=hashString(n)%360;return`hsl(${e}, 70%, 66%)`}function bracketGlyph(n){switch(n){case"top":return"\u250C";case"bottom":return"\u2514";case"single":return"\u2500";default:return"\u2502"}}
@@ -1,152 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.lightTheme = exports.levelStyles = exports.darkTheme = exports.consoleTheme = exports.ansiColors = void 0;
7
- Object.defineProperty(exports, "monoFont", {
8
- enumerable: true,
9
- get: function () {
10
- return _sharedUi.monoFont;
11
- }
12
- });
13
- var _sharedUi = require("@buoy-gg/shared-ui");
14
- /**
15
- * Console palette — a dark theme whose CHROME entries (surfaces, dividers,
16
- * default/secondary text) come from Buoy's `night` tokens so the console reads
17
- * as part of the night suite, while the Chrome-DevTools DATA colours (level
18
- * rows, value types, links, ANSI) stay classic — they tell the user something
19
- * about the logged data.
20
- * `lightTheme` below holds the exact DevTools light tokens and `consoleTheme`
21
- * picks between the two from the host app's surface. Every shipped theme is
22
- * dark today, so the light branch is currently unreachable — it is kept because
23
- * the probe is what makes this correct if a light surface ever returns.
24
- *
25
- * Not themed: `ansiColors` below is the dark-theme ANSI palette, so ANSI
26
- * escape sequences in captured output keep their dark-console colours.
27
- */
28
-
29
- /**
30
- * Monospace font — re-exported from shared-ui so the console keeps its import
31
- * site. The per-platform choice (Menlo on iOS, the curated stack on web) lives
32
- * in `packages/shared/src/ui/fonts.ts`.
33
- */
34
-
35
- /** Resolved DevTools light-theme tokens. Unreachable today — see the header. */
36
- const lightTheme = exports.lightTheme = {
37
- baseContainer: "#ffffff",
38
- // --sys-color-cdt-base-container (neutral99 ≈ white)
39
- surfaceError: "#fceaea",
40
- // --sys-color-surface-error rgb(252 235 235)
41
- surfaceYellow: "#fef6d5",
42
- // --sys-color-surface-yellow rgb(254 246 213)
43
- divider: "#e8eaed",
44
- // --sys-color-divider (primary90, lightened for contrast)
45
- inputBackground: "#f1f3f4",
46
- menuBackground: "#ffffff",
47
- onSurface: "#1f1f1f",
48
- // neutral10
49
- onSurfaceYellow: "#3e2f00",
50
- // yellow20
51
- onErrorContainer: "#410e0b",
52
- // error10
53
- tokenSubtle: "#757575",
54
- // neutral50
55
- primary: "#0b57d0",
56
- // primary40 (links)
57
- valueNumber: "#0842a0",
58
- // token-attribute-value (blue30)
59
- valueString: "#c5221f",
60
- // token-property-special (error50, slightly deepened)
61
- valueBigint: "#146c2e",
62
- // token-comment (green40)
63
- valueNode: "#1f1f1f",
64
- // token-variable (= on-surface)
65
- valueNullish: "rgba(31,31,31,0.5)",
66
- // state-disabled
67
- valuePreview: "rgba(31,31,31,0.62)"
68
- };
69
-
70
- /** Dark theme (active) — night chrome, classic DevTools data colours. */
71
- const darkTheme = exports.darkTheme = {
72
- baseContainer: "#0A0A0C",
73
- // desktop inline shell base (modal path is transparent)
74
- surfaceError: "rgba(255,69,58,0.15)",
75
- // semantic.errorBackground
76
- surfaceYellow: "rgba(255,235,59,0.13)",
77
- // semantic.warningBackground
78
- divider: _sharedUi.night.color.fillTertiary,
79
- // row hairlines + nesting guides (strong enough to stay visible)
80
- inputBackground: _sharedUi.night.color.surfaceElevated,
81
- menuBackground: _sharedUi.night.color.surface,
82
- onSurface: _sharedUi.night.color.text,
83
- onSurfaceYellow: "#FFE9A3",
84
- // light warm yellow on dark warning row
85
- onErrorContainer: "#FFB4AB",
86
- // light red on dark error row
87
- tokenSubtle: _sharedUi.night.color.textSecondary,
88
- // timestamps, previews
89
- primary: "#40CCFF",
90
- // semantic.infoLight (links, ~9:1)
91
- valueNumber: "#FF9F1C",
92
- // orange (number + boolean)
93
- valueString: "#7EE787",
94
- // green (string/regexp/symbol)
95
- valueBigint: "#A1A1A6",
96
- // muted (bigint)
97
- valueNode: "#F5F5F7",
98
- // default text (DOM node / variable)
99
- valueNullish: "#8E8E93",
100
- // text.muted (null/undefined)
101
- valuePreview: "#A1A1A6" // object preview (italic)
102
- };
103
-
104
- /**
105
- * The active console palette.
106
- *
107
- * `darkTheme`, always. `macOSColors` is the dark palette on every surface Buoy
108
- * renders on, so there is nothing to pick between — this used to probe the host
109
- * surface's luminance for a light dashboard theme that no longer exists.
110
- * `lightTheme` above is kept because it is the real Chrome DevTools light token
111
- * set and predates that experiment; swap it in here if a light surface returns.
112
- */
113
- const consoleTheme = exports.consoleTheme = darkTheme;
114
-
115
- /** ANSI 16-color palette (dark theme), from consoleView.css `--console-color-*`. */
116
- const ansiColors = exports.ansiColors = {
117
- black: "#000",
118
- red: "rgb(237 78 76)",
119
- green: "rgb(1 200 1)",
120
- yellow: "rgb(210 192 87)",
121
- blue: "rgb(39 116 240)",
122
- magenta: "rgb(161 66 244)",
123
- cyan: "rgb(18 181 203)",
124
- gray: "rgb(207 208 208)",
125
- darkgray: "rgb(137 137 137)",
126
- lightred: "rgb(242 139 130)",
127
- lightgreen: "rgb(161 247 181)",
128
- lightyellow: "rgb(221 251 85)",
129
- lightblue: "rgb(102 157 246)",
130
- lightmagenta: "rgb(214 112 214)",
131
- lightcyan: "rgb(132 240 255)",
132
- white: "#fff"
133
- };
134
- const levelStyles = exports.levelStyles = {
135
- verbose: {
136
- text: consoleTheme.tokenSubtle
137
- },
138
- info: {
139
- text: consoleTheme.onSurface
140
- },
141
- warning: {
142
- background: consoleTheme.surfaceYellow,
143
- text: consoleTheme.onSurfaceYellow,
144
- icon: "warning"
145
- },
146
- error: {
147
- background: consoleTheme.surfaceError,
148
- text: consoleTheme.onErrorContainer,
149
- icon: "error"
150
- }
151
- };
152
- //# sourceMappingURL=theme.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.lightTheme=exports.levelStyles=exports.darkTheme=exports.consoleTheme=exports.ansiColors=void 0;Object.defineProperty(exports,"monoFont",{enumerable:true,get:function(){return _sharedUi.monoFont}});var _sharedUi=require("@buoy-gg/shared-ui");const lightTheme=exports.lightTheme={baseContainer:"#ffffff",surfaceError:"#fceaea",surfaceYellow:"#fef6d5",divider:"#e8eaed",inputBackground:"#f1f3f4",menuBackground:"#ffffff",onSurface:"#1f1f1f",onSurfaceYellow:"#3e2f00",onErrorContainer:"#410e0b",tokenSubtle:"#757575",primary:"#0b57d0",valueNumber:"#0842a0",valueString:"#c5221f",valueBigint:"#146c2e",valueNode:"#1f1f1f",valueNullish:"rgba(31,31,31,0.5)",valuePreview:"rgba(31,31,31,0.62)"};const darkTheme=exports.darkTheme={baseContainer:"#0A0A0C",surfaceError:"rgba(255,69,58,0.15)",surfaceYellow:"rgba(255,235,59,0.13)",divider:_sharedUi.night.color.fillTertiary,inputBackground:_sharedUi.night.color.surfaceElevated,menuBackground:_sharedUi.night.color.surface,onSurface:_sharedUi.night.color.text,onSurfaceYellow:"#FFE9A3",onErrorContainer:"#FFB4AB",tokenSubtle:_sharedUi.night.color.textSecondary,primary:"#40CCFF",valueNumber:"#FF9F1C",valueString:"#7EE787",valueBigint:"#A1A1A6",valueNode:"#F5F5F7",valueNullish:"#8E8E93",valuePreview:"#A1A1A6"};const consoleTheme=exports.consoleTheme=darkTheme;const ansiColors=exports.ansiColors={black:"#000",red:"rgb(237 78 76)",green:"rgb(1 200 1)",yellow:"rgb(210 192 87)",blue:"rgb(39 116 240)",magenta:"rgb(161 66 244)",cyan:"rgb(18 181 203)",gray:"rgb(207 208 208)",darkgray:"rgb(137 137 137)",lightred:"rgb(242 139 130)",lightgreen:"rgb(161 247 181)",lightyellow:"rgb(221 251 85)",lightblue:"rgb(102 157 246)",lightmagenta:"rgb(214 112 214)",lightcyan:"rgb(132 240 255)",white:"#fff"};const levelStyles=exports.levelStyles={verbose:{text:consoleTheme.tokenSubtle},info:{text:consoleTheme.onSurface},warning:{background:consoleTheme.surfaceYellow,text:consoleTheme.onSurfaceYellow,icon:"warning"},error:{background:consoleTheme.surfaceError,text:consoleTheme.onErrorContainer,icon:"error"}};