esp32tool 1.6.4 → 1.6.6

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.
Binary file
package/dist/console.d.ts CHANGED
@@ -4,10 +4,14 @@ export declare class ESP32ToolConsole {
4
4
  private cancelConnection?;
5
5
  private containerElement;
6
6
  private allowInput;
7
+ private commandHistory;
8
+ private historyIndex;
9
+ private currentInput;
7
10
  constructor(port: SerialPort, containerElement: HTMLElement, allowInput?: boolean);
8
11
  logs(): string;
9
12
  init(): Promise<void>;
10
13
  private _connect;
14
+ private _navigateHistory;
11
15
  private _sendCommand;
12
16
  clear(): void;
13
17
  reset(): Promise<void>;
package/dist/console.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import { ColoredConsole, coloredConsoleStyles } from "./util/console-color.js";
2
2
  import { LineBreakTransformer } from "./util/line-break-transformer.js";
3
+ import { TimestampTransformer } from "./util/timestamp-transformer.js";
3
4
  export class ESP32ToolConsole {
4
5
  constructor(port, containerElement, allowInput = true) {
6
+ // Command history buffer
7
+ this.commandHistory = [];
8
+ this.historyIndex = -1;
9
+ this.currentInput = "";
5
10
  this.port = port;
6
11
  this.containerElement = containerElement;
7
12
  this.allowInput = allowInput;
@@ -137,6 +142,20 @@ export class ESP32ToolConsole {
137
142
  ev.stopPropagation();
138
143
  this._sendCommand();
139
144
  }
145
+ else if (ev.key === "ArrowUp") {
146
+ ev.preventDefault();
147
+ this._navigateHistory(1, input);
148
+ }
149
+ else if (ev.key === "ArrowDown") {
150
+ ev.preventDefault();
151
+ this._navigateHistory(-1, input);
152
+ }
153
+ else {
154
+ // User is editing — reset history navigation to live input
155
+ if (this.historyIndex !== -1) {
156
+ this.historyIndex = -1;
157
+ }
158
+ }
140
159
  });
141
160
  }
142
161
  // Start connection
@@ -174,10 +193,10 @@ export class ESP32ToolConsole {
174
193
  signal: abortSignal,
175
194
  })
176
195
  .pipeThrough(new TransformStream(new LineBreakTransformer()))
196
+ .pipeThrough(new TransformStream(new TimestampTransformer()))
177
197
  .pipeTo(new WritableStream({
178
198
  write: (chunk) => {
179
- const cleaned = chunk.replace(/\r\n$/, "\n");
180
- this.console.addLine(cleaned);
199
+ this.console.addLine(chunk);
181
200
  },
182
201
  }));
183
202
  if (!abortSignal.aborted) {
@@ -196,9 +215,42 @@ export class ESP32ToolConsole {
196
215
  console.log("Finished console read loop");
197
216
  }
198
217
  }
218
+ _navigateHistory(direction, input) {
219
+ if (this.commandHistory.length === 0)
220
+ return;
221
+ // Save current unsent input before navigating away
222
+ if (this.historyIndex === -1) {
223
+ this.currentInput = input.value;
224
+ }
225
+ const nextIndex = this.historyIndex + direction;
226
+ if (nextIndex < 0) {
227
+ // Back to unsent draft
228
+ this.historyIndex = -1;
229
+ input.value = this.currentInput;
230
+ }
231
+ else if (nextIndex < this.commandHistory.length) {
232
+ this.historyIndex = nextIndex;
233
+ input.value = this.commandHistory[this.historyIndex];
234
+ }
235
+ // Move cursor to end
236
+ const len = input.value.length;
237
+ input.setSelectionRange(len, len);
238
+ }
199
239
  async _sendCommand() {
200
240
  const input = this.containerElement.querySelector(".esp32tool-console-input");
201
241
  const command = input.value;
242
+ if (command.trim() !== "") {
243
+ // Avoid consecutive duplicates, cap at 100
244
+ if (this.commandHistory[0] !== command) {
245
+ this.commandHistory.unshift(command);
246
+ if (this.commandHistory.length > 100) {
247
+ this.commandHistory.pop();
248
+ }
249
+ }
250
+ }
251
+ // Reset history navigation state
252
+ this.historyIndex = -1;
253
+ this.currentInput = "";
202
254
  if (!this.port.writable) {
203
255
  this.console.addLine("Terminal disconnected: port not writable");
204
256
  return;
@@ -5,15 +5,24 @@ interface ConsoleState {
5
5
  strikethrough: boolean;
6
6
  foregroundColor: string | null;
7
7
  backgroundColor: string | null;
8
+ fgRgb: string | null;
9
+ bgRgb: string | null;
10
+ dim: boolean;
11
+ reverse: boolean;
8
12
  carriageReturn: boolean;
13
+ lines: string[];
9
14
  secret: boolean;
15
+ blink: boolean;
16
+ rapidBlink: boolean;
10
17
  }
11
18
  export declare class ColoredConsole {
12
19
  targetElement: HTMLElement;
13
20
  state: ConsoleState;
14
21
  constructor(targetElement: HTMLElement);
15
22
  logs(): string;
23
+ processLine(line: string): Element;
24
+ processLines(): void;
16
25
  addLine(line: string): void;
17
26
  }
18
- export declare const coloredConsoleStyles = "\n .log {\n flex: 1;\n background-color: #1c1c1c;\n font-family: \"SFMono-Regular\", Consolas, \"Liberation Mono\", Menlo, Courier,\n monospace;\n font-size: 12px;\n padding: 16px;\n overflow: auto;\n line-height: 1.45;\n border-radius: 3px;\n white-space: pre-wrap;\n overflow-wrap: break-word;\n color: #ddd;\n }\n\n .log-bold {\n font-weight: bold;\n }\n .log-italic {\n font-style: italic;\n }\n .log-underline {\n text-decoration: underline;\n }\n .log-strikethrough {\n text-decoration: line-through;\n }\n .log-underline.log-strikethrough {\n text-decoration: underline line-through;\n }\n .log-secret {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n .log-secret-redacted {\n opacity: 0;\n width: 1px;\n font-size: 1px;\n }\n .log-fg-black {\n color: rgb(128, 128, 128);\n }\n .log-fg-red {\n color: rgb(255, 0, 0);\n }\n .log-fg-green {\n color: rgb(0, 255, 0);\n }\n .log-fg-yellow {\n color: rgb(255, 255, 0);\n }\n .log-fg-blue {\n color: rgb(0, 0, 255);\n }\n .log-fg-magenta {\n color: rgb(255, 0, 255);\n }\n .log-fg-cyan {\n color: rgb(0, 255, 255);\n }\n .log-fg-white {\n color: rgb(187, 187, 187);\n }\n .log-bg-black {\n background-color: rgb(0, 0, 0);\n }\n .log-bg-red {\n background-color: rgb(255, 0, 0);\n }\n .log-bg-green {\n background-color: rgb(0, 255, 0);\n }\n .log-bg-yellow {\n background-color: rgb(255, 255, 0);\n }\n .log-bg-blue {\n background-color: rgb(0, 0, 255);\n }\n .log-bg-magenta {\n background-color: rgb(255, 0, 255);\n }\n .log-bg-cyan {\n background-color: rgb(0, 255, 255);\n }\n .log-bg-white {\n background-color: rgb(255, 255, 255);\n }\n";
27
+ export declare const coloredConsoleStyles = "\n .log {\n flex: 1;\n background-color: #1c1c1c;\n font-family: \"SFMono-Regular\", Consolas, \"Liberation Mono\", Menlo, Courier,\n monospace;\n font-size: 12px;\n padding: 16px;\n overflow: auto;\n line-height: 1.45;\n border-radius: 3px;\n white-space: pre-wrap;\n overflow-wrap: break-word;\n color: #ddd;\n }\n\n .log-bold {\n font-weight: bold;\n }\n .log-dim {\n opacity: 0.5;\n }\n .log-italic {\n font-style: italic;\n }\n .log-underline {\n text-decoration: underline;\n }\n .log-strikethrough {\n text-decoration: line-through;\n }\n .log-underline.log-strikethrough {\n text-decoration: underline line-through;\n }\n .log-blink {\n animation: blink 1s step-end infinite;\n }\n .log-rapid-blink {\n animation: blink 0.4s step-end infinite;\n }\n @keyframes blink {\n 50% {\n opacity: 0;\n }\n }\n .log-secret {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n .log-secret-redacted {\n opacity: 0;\n width: 1px;\n font-size: 1px;\n }\n .log-reverse {\n background: #ddd;\n color: #1c1c1c;\n }\n .log-fg-black {\n color: rgb(128, 128, 128);\n }\n .log-fg-red {\n color: rgb(255, 0, 0);\n }\n .log-fg-green {\n color: rgb(0, 255, 0);\n }\n .log-fg-yellow {\n color: rgb(255, 255, 0);\n }\n .log-fg-blue {\n color: rgb(0, 0, 255);\n }\n .log-fg-magenta {\n color: rgb(255, 0, 255);\n }\n .log-fg-cyan {\n color: rgb(0, 255, 255);\n }\n .log-fg-white {\n color: rgb(187, 187, 187);\n }\n .log-bg-black {\n background-color: rgb(0, 0, 0);\n }\n .log-bg-red {\n background-color: rgb(255, 0, 0);\n }\n .log-bg-green {\n background-color: rgb(0, 255, 0);\n }\n .log-bg-yellow {\n background-color: rgb(255, 255, 0);\n }\n .log-bg-blue {\n background-color: rgb(0, 0, 255);\n }\n .log-bg-magenta {\n background-color: rgb(255, 0, 255);\n }\n .log-bg-cyan {\n background-color: rgb(0, 255, 255);\n }\n .log-bg-white {\n background-color: rgb(255, 255, 255);\n }\n";
19
28
  export {};