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.
- package/apple-touch-icon.png +0 -0
- package/dist/console.d.ts +4 -0
- package/dist/console.js +54 -2
- package/dist/util/console-color.d.ts +10 -1
- package/dist/util/console-color.js +369 -30
- package/dist/util/line-break-transformer.js +18 -4
- package/dist/util/timestamp-transformer.d.ts +5 -0
- package/dist/util/timestamp-transformer.js +37 -0
- package/icons/icon-128.png +0 -0
- package/icons/icon-144.png +0 -0
- package/icons/icon-152.png +0 -0
- package/icons/icon-192.png +0 -0
- package/icons/icon-384.png +0 -0
- package/icons/icon-512.png +0 -0
- package/icons/icon-72.png +0 -0
- package/icons/icon-96.png +0 -0
- package/js/console.js +52 -3
- package/js/util/console-color.js +513 -211
- package/js/util/line-break-transformer.js +29 -17
- package/js/util/timestamp-transformer.js +37 -0
- package/package.cli.json +1 -1
- package/package.json +13 -12
- package/screenshots/desktop.png +0 -0
- package/screenshots/mobile.png +0 -0
- package/src/console.ts +57 -2
- package/src/util/console-color.ts +373 -32
- package/src/util/line-break-transformer.ts +18 -4
- package/src/util/timestamp-transformer.ts +45 -0
- package/sw.js +1 -1
- package/tsconfig.util.json +9 -0
package/js/console.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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
|
import { ImprovDialog } from "./improv.js";
|
|
4
5
|
|
|
5
6
|
export class ESP32ToolConsole {
|
|
@@ -16,6 +17,11 @@ export class ESP32ToolConsole {
|
|
|
16
17
|
this.allowInput = allowInput;
|
|
17
18
|
this.console = null;
|
|
18
19
|
this.cancelConnection = null;
|
|
20
|
+
// Command history buffer — keep in sync with src/console.ts
|
|
21
|
+
// (history logic is duplicated there; update both files together)
|
|
22
|
+
this.commandHistory = [];
|
|
23
|
+
this.historyIndex = -1;
|
|
24
|
+
this.currentInput = "";
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
logs() {
|
|
@@ -180,6 +186,16 @@ export class ESP32ToolConsole {
|
|
|
180
186
|
ev.preventDefault();
|
|
181
187
|
ev.stopPropagation();
|
|
182
188
|
this._sendCommand();
|
|
189
|
+
} else if (ev.key === "ArrowUp") {
|
|
190
|
+
ev.preventDefault();
|
|
191
|
+
this._navigateHistory(1, input);
|
|
192
|
+
} else if (ev.key === "ArrowDown") {
|
|
193
|
+
ev.preventDefault();
|
|
194
|
+
this._navigateHistory(-1, input);
|
|
195
|
+
} else {
|
|
196
|
+
if (this.historyIndex !== -1) {
|
|
197
|
+
this.historyIndex = -1;
|
|
198
|
+
}
|
|
183
199
|
}
|
|
184
200
|
});
|
|
185
201
|
}
|
|
@@ -220,16 +236,16 @@ export class ESP32ToolConsole {
|
|
|
220
236
|
signal: abortSignal,
|
|
221
237
|
})
|
|
222
238
|
.pipeThrough(new TransformStream(new LineBreakTransformer()))
|
|
239
|
+
.pipeThrough(new TransformStream(new TimestampTransformer()))
|
|
223
240
|
.pipeTo(
|
|
224
241
|
new WritableStream({
|
|
225
242
|
write: (chunk) => {
|
|
226
|
-
|
|
227
|
-
this.console.addLine(cleaned);
|
|
243
|
+
this.console.addLine(chunk);
|
|
228
244
|
|
|
229
245
|
if (!bootloaderDetected && lineCount < 30) {
|
|
230
246
|
lineCount++;
|
|
231
247
|
for (const pat of BOOTLOADER_PATTERNS) {
|
|
232
|
-
if (pat.test(
|
|
248
|
+
if (pat.test(chunk)) {
|
|
233
249
|
bootloaderDetected = true;
|
|
234
250
|
this.containerElement.dispatchEvent(
|
|
235
251
|
new CustomEvent("console-bootloader", { bubbles: true })
|
|
@@ -259,9 +275,42 @@ export class ESP32ToolConsole {
|
|
|
259
275
|
}
|
|
260
276
|
}
|
|
261
277
|
|
|
278
|
+
_navigateHistory(direction, input) {
|
|
279
|
+
if (this.commandHistory.length === 0) return;
|
|
280
|
+
|
|
281
|
+
if (this.historyIndex === -1) {
|
|
282
|
+
this.currentInput = input.value;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const nextIndex = this.historyIndex + direction;
|
|
286
|
+
|
|
287
|
+
if (nextIndex < 0) {
|
|
288
|
+
this.historyIndex = -1;
|
|
289
|
+
input.value = this.currentInput;
|
|
290
|
+
} else if (nextIndex < this.commandHistory.length) {
|
|
291
|
+
this.historyIndex = nextIndex;
|
|
292
|
+
input.value = this.commandHistory[this.historyIndex];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const len = input.value.length;
|
|
296
|
+
input.setSelectionRange(len, len);
|
|
297
|
+
}
|
|
298
|
+
|
|
262
299
|
async _sendCommand() {
|
|
263
300
|
const input = this.containerElement.querySelector(".esp32tool-console-input");
|
|
264
301
|
const command = input.value;
|
|
302
|
+
|
|
303
|
+
if (command.trim() !== "") {
|
|
304
|
+
if (this.commandHistory[0] !== command) {
|
|
305
|
+
this.commandHistory.unshift(command);
|
|
306
|
+
if (this.commandHistory.length > 100) {
|
|
307
|
+
this.commandHistory.pop();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
this.historyIndex = -1;
|
|
312
|
+
this.currentInput = "";
|
|
313
|
+
|
|
265
314
|
if (!this.port.writable) {
|
|
266
315
|
this.console.addLine("Terminal disconnected: port not writable");
|
|
267
316
|
return;
|