esp32tool 1.1.9 → 1.3.0

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 (64) hide show
  1. package/.nojekyll +0 -0
  2. package/README.md +100 -6
  3. package/apple-touch-icon.png +0 -0
  4. package/build-electron-cli.cjs +177 -0
  5. package/build-single-binary.cjs +295 -0
  6. package/css/light.css +11 -0
  7. package/css/style.css +261 -41
  8. package/dist/cli.d.ts +17 -0
  9. package/dist/cli.js +458 -0
  10. package/dist/console.d.ts +15 -0
  11. package/dist/console.js +237 -0
  12. package/dist/const.d.ts +99 -0
  13. package/dist/const.js +129 -8
  14. package/dist/esp_loader.d.ts +244 -22
  15. package/dist/esp_loader.js +1960 -251
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.js +37 -4
  18. package/dist/node-usb-adapter.d.ts +47 -0
  19. package/dist/node-usb-adapter.js +725 -0
  20. package/dist/stubs/index.d.ts +1 -2
  21. package/dist/stubs/index.js +4 -0
  22. package/dist/util/console-color.d.ts +19 -0
  23. package/dist/util/console-color.js +272 -0
  24. package/dist/util/line-break-transformer.d.ts +5 -0
  25. package/dist/util/line-break-transformer.js +17 -0
  26. package/dist/web/index.js +1 -1
  27. package/electron/cli-main.cjs +74 -0
  28. package/electron/main.cjs +338 -0
  29. package/electron/main.js +7 -2
  30. package/favicon.ico +0 -0
  31. package/fix-cli-imports.cjs +127 -0
  32. package/generate-icons.sh +89 -0
  33. package/icons/icon-128.png +0 -0
  34. package/icons/icon-144.png +0 -0
  35. package/icons/icon-152.png +0 -0
  36. package/icons/icon-192.png +0 -0
  37. package/icons/icon-384.png +0 -0
  38. package/icons/icon-512.png +0 -0
  39. package/icons/icon-72.png +0 -0
  40. package/icons/icon-96.png +0 -0
  41. package/index.html +143 -73
  42. package/install-android.html +411 -0
  43. package/js/console.js +269 -0
  44. package/js/modules/esptool.js +1 -1
  45. package/js/script.js +750 -175
  46. package/js/util/console-color.js +282 -0
  47. package/js/util/line-break-transformer.js +19 -0
  48. package/js/webusb-serial.js +1017 -0
  49. package/license.md +1 -1
  50. package/manifest.json +89 -0
  51. package/package.cli.json +29 -0
  52. package/package.json +35 -24
  53. package/screenshots/desktop.png +0 -0
  54. package/screenshots/mobile.png +0 -0
  55. package/src/cli.ts +618 -0
  56. package/src/console.ts +278 -0
  57. package/src/const.ts +165 -8
  58. package/src/esp_loader.ts +2354 -302
  59. package/src/index.ts +69 -3
  60. package/src/node-usb-adapter.ts +924 -0
  61. package/src/stubs/index.ts +4 -1
  62. package/src/util/console-color.ts +290 -0
  63. package/src/util/line-break-transformer.ts +20 -0
  64. package/sw.js +155 -0
@@ -0,0 +1,282 @@
1
+ export class ColoredConsole {
2
+ constructor(targetElement) {
3
+ this.targetElement = targetElement;
4
+ this.state = {
5
+ bold: false,
6
+ italic: false,
7
+ underline: false,
8
+ strikethrough: false,
9
+ foregroundColor: null,
10
+ backgroundColor: null,
11
+ carriageReturn: false,
12
+ secret: false,
13
+ };
14
+ }
15
+
16
+ logs() {
17
+ return this.targetElement.innerText;
18
+ }
19
+
20
+ addLine(line) {
21
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences
22
+ const re = /(?:\x1B|\\x1B)(?:\[(.*?)[@-~]|\].*?(?:\x07|\x1B\\))/g;
23
+ let i = 0;
24
+
25
+ if (this.state.carriageReturn) {
26
+ if (line !== "\n") {
27
+ // don't remove if \r\n
28
+ if (this.targetElement.lastChild) {
29
+ this.targetElement.removeChild(this.targetElement.lastChild);
30
+ }
31
+ }
32
+ this.state.carriageReturn = false;
33
+ }
34
+
35
+ if (line.includes("\r")) {
36
+ this.state.carriageReturn = true;
37
+ }
38
+
39
+ const lineSpan = document.createElement("span");
40
+ lineSpan.classList.add("line");
41
+ this.targetElement.appendChild(lineSpan);
42
+
43
+ const addSpan = (content) => {
44
+ if (content === "") return;
45
+
46
+ const span = document.createElement("span");
47
+ if (this.state.bold) span.classList.add("log-bold");
48
+ if (this.state.italic) span.classList.add("log-italic");
49
+ if (this.state.underline) span.classList.add("log-underline");
50
+ if (this.state.strikethrough) span.classList.add("log-strikethrough");
51
+ if (this.state.secret) span.classList.add("log-secret");
52
+ if (this.state.foregroundColor !== null)
53
+ span.classList.add(`log-fg-${this.state.foregroundColor}`);
54
+ if (this.state.backgroundColor !== null)
55
+ span.classList.add(`log-bg-${this.state.backgroundColor}`);
56
+ span.appendChild(document.createTextNode(content));
57
+ lineSpan.appendChild(span);
58
+
59
+ if (this.state.secret) {
60
+ const redacted = document.createElement("span");
61
+ redacted.classList.add("log-secret-redacted");
62
+ redacted.appendChild(document.createTextNode("[redacted]"));
63
+ lineSpan.appendChild(redacted);
64
+ }
65
+ };
66
+
67
+ while (true) {
68
+ const match = re.exec(line);
69
+ if (match === null) break;
70
+
71
+ const j = match.index;
72
+ addSpan(line.substring(i, j));
73
+ i = j + match[0].length;
74
+
75
+ if (match[1] === undefined) continue;
76
+
77
+ for (const colorCode of match[1].split(";")) {
78
+ switch (parseInt(colorCode)) {
79
+ case 0:
80
+ // reset
81
+ this.state.bold = false;
82
+ this.state.italic = false;
83
+ this.state.underline = false;
84
+ this.state.strikethrough = false;
85
+ this.state.foregroundColor = null;
86
+ this.state.backgroundColor = null;
87
+ this.state.secret = false;
88
+ break;
89
+ case 1:
90
+ this.state.bold = true;
91
+ break;
92
+ case 3:
93
+ this.state.italic = true;
94
+ break;
95
+ case 4:
96
+ this.state.underline = true;
97
+ break;
98
+ case 5:
99
+ this.state.secret = true;
100
+ break;
101
+ case 6:
102
+ this.state.secret = false;
103
+ break;
104
+ case 9:
105
+ this.state.strikethrough = true;
106
+ break;
107
+ case 22:
108
+ this.state.bold = false;
109
+ break;
110
+ case 23:
111
+ this.state.italic = false;
112
+ break;
113
+ case 24:
114
+ this.state.underline = false;
115
+ break;
116
+ case 29:
117
+ this.state.strikethrough = false;
118
+ break;
119
+ case 30:
120
+ this.state.foregroundColor = "black";
121
+ break;
122
+ case 31:
123
+ this.state.foregroundColor = "red";
124
+ break;
125
+ case 32:
126
+ this.state.foregroundColor = "green";
127
+ break;
128
+ case 33:
129
+ this.state.foregroundColor = "yellow";
130
+ break;
131
+ case 34:
132
+ this.state.foregroundColor = "blue";
133
+ break;
134
+ case 35:
135
+ this.state.foregroundColor = "magenta";
136
+ break;
137
+ case 36:
138
+ this.state.foregroundColor = "cyan";
139
+ break;
140
+ case 37:
141
+ this.state.foregroundColor = "white";
142
+ break;
143
+ case 39:
144
+ this.state.foregroundColor = null;
145
+ break;
146
+ case 41:
147
+ this.state.backgroundColor = "red";
148
+ break;
149
+ case 42:
150
+ this.state.backgroundColor = "green";
151
+ break;
152
+ case 43:
153
+ this.state.backgroundColor = "yellow";
154
+ break;
155
+ case 44:
156
+ this.state.backgroundColor = "blue";
157
+ break;
158
+ case 45:
159
+ this.state.backgroundColor = "magenta";
160
+ break;
161
+ case 46:
162
+ this.state.backgroundColor = "cyan";
163
+ break;
164
+ case 47:
165
+ this.state.backgroundColor = "white";
166
+ break;
167
+ case 40:
168
+ this.state.backgroundColor = "black";
169
+ break;
170
+ case 49:
171
+ this.state.backgroundColor = null;
172
+ break;
173
+ }
174
+ }
175
+ }
176
+
177
+ // Use percentage-based threshold (5% of viewport height) for better UX across screen sizes
178
+ const scrollThreshold = this.targetElement.offsetHeight * 0.05;
179
+ const atBottom =
180
+ this.targetElement.scrollTop >
181
+ this.targetElement.scrollHeight - this.targetElement.offsetHeight - scrollThreshold;
182
+
183
+ addSpan(line.substring(i));
184
+
185
+ // Keep scroll at bottom
186
+ if (atBottom) {
187
+ this.targetElement.scrollTop = this.targetElement.scrollHeight;
188
+ }
189
+ }
190
+ }
191
+
192
+ export const coloredConsoleStyles = `
193
+ .log {
194
+ flex: 1;
195
+ background-color: #1c1c1c;
196
+ font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier,
197
+ monospace;
198
+ font-size: 12px;
199
+ padding: 16px;
200
+ overflow: auto;
201
+ line-height: 1.45;
202
+ border-radius: 3px;
203
+ white-space: pre-wrap;
204
+ overflow-wrap: break-word;
205
+ color: #ddd;
206
+ }
207
+
208
+ .log-bold {
209
+ font-weight: bold;
210
+ }
211
+ .log-italic {
212
+ font-style: italic;
213
+ }
214
+ .log-underline {
215
+ text-decoration: underline;
216
+ }
217
+ .log-strikethrough {
218
+ text-decoration: line-through;
219
+ }
220
+ .log-underline.log-strikethrough {
221
+ text-decoration: underline line-through;
222
+ }
223
+ .log-secret {
224
+ -webkit-user-select: none;
225
+ -moz-user-select: none;
226
+ -ms-user-select: none;
227
+ user-select: none;
228
+ }
229
+ .log-secret-redacted {
230
+ opacity: 0;
231
+ width: 1px;
232
+ font-size: 1px;
233
+ }
234
+ .log-fg-black {
235
+ color: rgb(128, 128, 128);
236
+ }
237
+ .log-fg-red {
238
+ color: rgb(255, 0, 0);
239
+ }
240
+ .log-fg-green {
241
+ color: rgb(0, 255, 0);
242
+ }
243
+ .log-fg-yellow {
244
+ color: rgb(255, 255, 0);
245
+ }
246
+ .log-fg-blue {
247
+ color: rgb(0, 0, 255);
248
+ }
249
+ .log-fg-magenta {
250
+ color: rgb(255, 0, 255);
251
+ }
252
+ .log-fg-cyan {
253
+ color: rgb(0, 255, 255);
254
+ }
255
+ .log-fg-white {
256
+ color: rgb(187, 187, 187);
257
+ }
258
+ .log-bg-black {
259
+ background-color: rgb(0, 0, 0);
260
+ }
261
+ .log-bg-red {
262
+ background-color: rgb(255, 0, 0);
263
+ }
264
+ .log-bg-green {
265
+ background-color: rgb(0, 255, 0);
266
+ }
267
+ .log-bg-yellow {
268
+ background-color: rgb(255, 255, 0);
269
+ }
270
+ .log-bg-blue {
271
+ background-color: rgb(0, 0, 255);
272
+ }
273
+ .log-bg-magenta {
274
+ background-color: rgb(255, 0, 255);
275
+ }
276
+ .log-bg-cyan {
277
+ background-color: rgb(0, 255, 255);
278
+ }
279
+ .log-bg-white {
280
+ background-color: rgb(255, 255, 255);
281
+ }
282
+ `;
@@ -0,0 +1,19 @@
1
+ export class LineBreakTransformer {
2
+ constructor() {
3
+ this.chunks = "";
4
+ }
5
+
6
+ transform(chunk, controller) {
7
+ // Append new chunks to existing chunks.
8
+ this.chunks += chunk;
9
+ // For each line breaks in chunks, send the parsed lines out.
10
+ const lines = this.chunks.split("\r\n");
11
+ this.chunks = lines.pop();
12
+ lines.forEach((line) => controller.enqueue(line + "\r\n"));
13
+ }
14
+
15
+ flush(controller) {
16
+ // When the stream is closed, flush any remaining chunks out.
17
+ controller.enqueue(this.chunks);
18
+ }
19
+ }