esp32tool 1.6.6 → 1.6.7

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.
@@ -86,8 +86,6 @@ export class ColoredConsole {
86
86
  const lineSpan = document.createElement("span");
87
87
  lineSpan.classList.add("line");
88
88
  const addSpan = (content) => {
89
- if (content === "")
90
- return;
91
89
  const span = document.createElement("span");
92
90
  if (this.state.bold)
93
91
  span.classList.add("log-bold");
@@ -175,7 +173,8 @@ export class ColoredConsole {
175
173
  }
176
174
  if (invalidSgr)
177
175
  continue;
178
- for (let ci = 0; ci < codes.length; ci++) {
176
+ let ci = 0;
177
+ while (ci < codes.length) {
179
178
  const code = codes[ci];
180
179
  switch (code) {
181
180
  case 0:
@@ -454,6 +453,7 @@ export class ColoredConsole {
454
453
  this.state.bgRgb = ANSI_256[15];
455
454
  break;
456
455
  }
456
+ ci++;
457
457
  }
458
458
  }
459
459
  addSpan(line.substring(i));
@@ -7,6 +7,10 @@
7
7
  // [HH:MM:SS.mmm] wall-clock bracket with millis
8
8
  // HH:MM:SS.mmm plain wall-clock
9
9
  const DEVICE_TIMESTAMP_RE = /^\s*(?:\[\d{2}:\d{2}:\d{2}(?:\.\d+)?\]|(?:\d{2}:){2}\d{2}\.\d)/;
10
+ // Matches leading ANSI SGR (color/style) codes at the start of a string
11
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences
12
+ // eslint-disable-next-line no-control-regex
13
+ const LEADING_ANSI_RE = /^(\x1b\[(?:\d+;)*\d*m)+/;
10
14
  export class TimestampTransformer {
11
15
  constructor() {
12
16
  this.deviceHasTimestamps = false;
@@ -25,11 +29,30 @@ export class TimestampTransformer {
25
29
  controller.enqueue(chunk);
26
30
  return;
27
31
  }
32
+ // Extract leading ANSI codes to preserve them across line splits
33
+ const ansiMatch = chunk.match(LEADING_ANSI_RE);
34
+ const leadingAnsi = ansiMatch ? ansiMatch[0] : "";
35
+ const contentWithoutAnsi = leadingAnsi
36
+ ? chunk.slice(leadingAnsi.length)
37
+ : chunk;
28
38
  const date = new Date();
29
39
  const h = date.getHours().toString().padStart(2, "0");
30
40
  const m = date.getMinutes().toString().padStart(2, "0");
31
41
  const s = date.getSeconds().toString().padStart(2, "0");
32
- controller.enqueue(`[${h}:${m}:${s}] ${chunk}`);
42
+ const timestamp = `[${h}:${m}:${s}]`;
43
+ // For multi-line chunks, we need to preserve ANSI codes on each line
44
+ // Split on newlines, but keep the newline characters
45
+ const lines = contentWithoutAnsi.split(/(\r?\n)/);
46
+ let result = "";
47
+ for (const part of lines) {
48
+ if (part === "\n" || part === "\r\n") {
49
+ result += part;
50
+ }
51
+ else if (part !== "") {
52
+ result += leadingAnsi + timestamp + " " + part;
53
+ }
54
+ }
55
+ controller.enqueue(result);
33
56
  }
34
57
  reset() {
35
58
  this.deviceHasTimestamps = false;