tasmota-webserial-esptool 7.3.4 → 9.1.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.
- package/css/dark.css +74 -0
- package/css/light.css +74 -0
- package/css/style.css +663 -35
- package/dist/esp_loader.d.ts +102 -14
- package/dist/esp_loader.js +1012 -188
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -3
- package/dist/stubs/index.d.ts +1 -2
- package/dist/stubs/index.js +4 -0
- package/dist/web/index.js +1 -1
- package/js/modules/esptool.js +1 -1
- package/js/script.js +215 -85
- package/js/webusb-serial.js +1028 -0
- package/package.json +2 -2
- package/src/esp_loader.ts +1187 -220
- package/src/index.ts +42 -3
- package/src/stubs/index.ts +4 -1
package/src/index.ts
CHANGED
|
@@ -24,10 +24,49 @@ export {
|
|
|
24
24
|
} from "./const";
|
|
25
25
|
|
|
26
26
|
export const connect = async (logger: Logger) => {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
let port: SerialPort;
|
|
28
|
+
|
|
29
|
+
// Check if a custom requestSerialPort function is available (e.g., from WebUSB wrapper)
|
|
30
|
+
const customRequestPort = (
|
|
31
|
+
globalThis as { requestSerialPort?: () => Promise<SerialPort> }
|
|
32
|
+
).requestSerialPort;
|
|
33
|
+
|
|
34
|
+
if (typeof customRequestPort === "function") {
|
|
35
|
+
// Use custom port request function (handles Android/WebUSB automatically)
|
|
36
|
+
logger.log("Using custom port request function");
|
|
37
|
+
port = await customRequestPort();
|
|
38
|
+
} else {
|
|
39
|
+
// Fallback to standard Web Serial API
|
|
40
|
+
if (!navigator.serial) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"Web Serial API is not supported in this browser. " +
|
|
43
|
+
"Please use Chrome 89+, Edge 89+, or Opera on desktop, or Chrome 61+ on Android with USB OTG. " +
|
|
44
|
+
"Note: The page must be served over HTTPS or localhost."
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
port = await navigator.serial.requestPort();
|
|
48
|
+
}
|
|
29
49
|
|
|
30
|
-
|
|
50
|
+
// Only open if not already open (WebUSB may return an opened port)
|
|
51
|
+
if (!port.readable || !port.writable) {
|
|
52
|
+
await port.open({ baudRate: ESP_ROM_BAUD });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
logger.log("Connected successfully.");
|
|
56
|
+
|
|
57
|
+
return new ESPLoader(port, logger);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const connectWithPort = async (port: SerialPort, logger: Logger) => {
|
|
61
|
+
// Connect using an already opened port (useful for WebUSB wrapper)
|
|
62
|
+
if (!port) {
|
|
63
|
+
throw new Error("Port is required");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Only open if not already open
|
|
67
|
+
if (!port.readable || !port.writable) {
|
|
68
|
+
await port.open({ baudRate: ESP_ROM_BAUD });
|
|
69
|
+
}
|
|
31
70
|
|
|
32
71
|
logger.log("Connected successfully.");
|
|
33
72
|
|
package/src/stubs/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface LoadedStub {
|
|
|
25
25
|
data_start: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
interface Stub {
|
|
28
|
+
export interface Stub {
|
|
29
29
|
text: number[];
|
|
30
30
|
data: number[];
|
|
31
31
|
text_start: number;
|
|
@@ -75,6 +75,9 @@ export const getStubCode = async (
|
|
|
75
75
|
} else {
|
|
76
76
|
stubcode = await import("./esp32p4.json");
|
|
77
77
|
}
|
|
78
|
+
} else {
|
|
79
|
+
// Unknown chip family - no stub available
|
|
80
|
+
return null;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
// Base64 decode the text and data
|