esp32tool 1.0.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 (115) hide show
  1. package/README.md +31 -0
  2. package/css/dark.css +156 -0
  3. package/css/light.css +156 -0
  4. package/css/style.css +870 -0
  5. package/dist/const.d.ts +277 -0
  6. package/dist/const.js +511 -0
  7. package/dist/esp_loader.d.ts +222 -0
  8. package/dist/esp_loader.js +1466 -0
  9. package/dist/index.d.ts +10 -0
  10. package/dist/index.js +15 -0
  11. package/dist/lib/spiffs/index.d.ts +15 -0
  12. package/dist/lib/spiffs/index.js +16 -0
  13. package/dist/lib/spiffs/spiffs.d.ts +26 -0
  14. package/dist/lib/spiffs/spiffs.js +132 -0
  15. package/dist/lib/spiffs/spiffsBlock.d.ts +36 -0
  16. package/dist/lib/spiffs/spiffsBlock.js +140 -0
  17. package/dist/lib/spiffs/spiffsConfig.d.ts +63 -0
  18. package/dist/lib/spiffs/spiffsConfig.js +79 -0
  19. package/dist/lib/spiffs/spiffsPage.d.ts +45 -0
  20. package/dist/lib/spiffs/spiffsPage.js +260 -0
  21. package/dist/lib/spiffs/spiffsReader.d.ts +19 -0
  22. package/dist/lib/spiffs/spiffsReader.js +192 -0
  23. package/dist/partition.d.ts +26 -0
  24. package/dist/partition.js +129 -0
  25. package/dist/struct.d.ts +2 -0
  26. package/dist/struct.js +91 -0
  27. package/dist/stubs/esp32.json +8 -0
  28. package/dist/stubs/esp32c2.json +8 -0
  29. package/dist/stubs/esp32c3.json +8 -0
  30. package/dist/stubs/esp32c5.json +8 -0
  31. package/dist/stubs/esp32c6.json +8 -0
  32. package/dist/stubs/esp32c61.json +8 -0
  33. package/dist/stubs/esp32h2.json +8 -0
  34. package/dist/stubs/esp32p4.json +8 -0
  35. package/dist/stubs/esp32p4r3.json +8 -0
  36. package/dist/stubs/esp32s2.json +8 -0
  37. package/dist/stubs/esp32s3.json +8 -0
  38. package/dist/stubs/esp8266.json +8 -0
  39. package/dist/stubs/index.d.ts +10 -0
  40. package/dist/stubs/index.js +56 -0
  41. package/dist/util.d.ts +14 -0
  42. package/dist/util.js +46 -0
  43. package/dist/wasm/filesystems.d.ts +33 -0
  44. package/dist/wasm/filesystems.js +114 -0
  45. package/dist/web/esp32-D955RjN9.js +16 -0
  46. package/dist/web/esp32c2-CJkxHDQi.js +16 -0
  47. package/dist/web/esp32c3-BhUHzH0o.js +16 -0
  48. package/dist/web/esp32c5-Chs0HtmA.js +16 -0
  49. package/dist/web/esp32c6-D6mPN6ut.js +16 -0
  50. package/dist/web/esp32c61-CQiYCWAs.js +16 -0
  51. package/dist/web/esp32h2-LsKJE9AS.js +16 -0
  52. package/dist/web/esp32p4-7nWC-HiD.js +16 -0
  53. package/dist/web/esp32p4r3-CwiPecZW.js +16 -0
  54. package/dist/web/esp32s2-CtqVheSJ.js +16 -0
  55. package/dist/web/esp32s3-CRbtB0QR.js +16 -0
  56. package/dist/web/esp8266-nEkNAo8K.js +16 -0
  57. package/dist/web/index.js +7265 -0
  58. package/electron/main.js +333 -0
  59. package/electron/preload.js +37 -0
  60. package/eslint.config.js +22 -0
  61. package/index.html +408 -0
  62. package/js/modules/esp32-D955RjN9.js +16 -0
  63. package/js/modules/esp32c2-CJkxHDQi.js +16 -0
  64. package/js/modules/esp32c3-BhUHzH0o.js +16 -0
  65. package/js/modules/esp32c5-Chs0HtmA.js +16 -0
  66. package/js/modules/esp32c6-D6mPN6ut.js +16 -0
  67. package/js/modules/esp32c61-CQiYCWAs.js +16 -0
  68. package/js/modules/esp32h2-LsKJE9AS.js +16 -0
  69. package/js/modules/esp32p4-7nWC-HiD.js +16 -0
  70. package/js/modules/esp32p4r3-CwiPecZW.js +16 -0
  71. package/js/modules/esp32s2-CtqVheSJ.js +16 -0
  72. package/js/modules/esp32s3-CRbtB0QR.js +16 -0
  73. package/js/modules/esp8266-nEkNAo8K.js +16 -0
  74. package/js/modules/esptool.js +7265 -0
  75. package/js/script.js +2237 -0
  76. package/js/utilities.js +182 -0
  77. package/license.md +11 -0
  78. package/package.json +61 -0
  79. package/script/build +12 -0
  80. package/script/develop +17 -0
  81. package/src/const.ts +599 -0
  82. package/src/esp_loader.ts +1907 -0
  83. package/src/index.ts +63 -0
  84. package/src/lib/spiffs/index.ts +22 -0
  85. package/src/lib/spiffs/spiffs.ts +175 -0
  86. package/src/lib/spiffs/spiffsBlock.ts +204 -0
  87. package/src/lib/spiffs/spiffsConfig.ts +140 -0
  88. package/src/lib/spiffs/spiffsPage.ts +357 -0
  89. package/src/lib/spiffs/spiffsReader.ts +280 -0
  90. package/src/partition.ts +155 -0
  91. package/src/struct.ts +108 -0
  92. package/src/stubs/README.md +3 -0
  93. package/src/stubs/esp32.json +8 -0
  94. package/src/stubs/esp32c2.json +8 -0
  95. package/src/stubs/esp32c3.json +8 -0
  96. package/src/stubs/esp32c5.json +8 -0
  97. package/src/stubs/esp32c6.json +8 -0
  98. package/src/stubs/esp32c61.json +8 -0
  99. package/src/stubs/esp32h2.json +8 -0
  100. package/src/stubs/esp32p4.json +8 -0
  101. package/src/stubs/esp32p4r3.json +8 -0
  102. package/src/stubs/esp32s2.json +8 -0
  103. package/src/stubs/esp32s3.json +8 -0
  104. package/src/stubs/esp8266.json +8 -0
  105. package/src/stubs/index.ts +86 -0
  106. package/src/util.ts +49 -0
  107. package/src/wasm/fatfs/fatfs.wasm +0 -0
  108. package/src/wasm/fatfs/index.d.ts +26 -0
  109. package/src/wasm/fatfs/index.js +343 -0
  110. package/src/wasm/filesystems.ts +156 -0
  111. package/src/wasm/littlefs/index.d.ts +83 -0
  112. package/src/wasm/littlefs/index.js +529 -0
  113. package/src/wasm/littlefs/littlefs.js +2 -0
  114. package/src/wasm/littlefs/littlefs.wasm +0 -0
  115. package/src/wasm/shared/types.ts +13 -0
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @name toByteArray
3
+ * Convert a string to a byte array
4
+ */
5
+ function toByteArray(str) {
6
+ let byteArray = [];
7
+ for (let i = 0; i < str.length; i++) {
8
+ let charcode = str.charCodeAt(i);
9
+ if (charcode <= 0xff) {
10
+ byteArray.push(charcode);
11
+ }
12
+ }
13
+ return byteArray;
14
+ }
15
+
16
+ function fromByteArray(byteArray) {
17
+ return String.fromCharCode.apply(String, byteArray);
18
+ }
19
+
20
+ function crc32(data, value = 0) {
21
+ if (data instanceof Array) {
22
+ data = fromByteArray(data);
23
+ }
24
+ let table = [];
25
+ for (let entry, c = 0; c < 256; c++) {
26
+ entry = c;
27
+ for (let k = 0; k < 8; k++) {
28
+ entry = 1 & entry ? 3988292384 ^ (entry >>> 1) : entry >>> 1;
29
+ }
30
+ table[c] = entry;
31
+ }
32
+ let n = -1 - value;
33
+ for (let t = 0; t < data.length; t++) {
34
+ n = (n >>> 8) ^ table[255 & (n ^ data.charCodeAt(t))];
35
+ }
36
+ return (-1 ^ n) >>> 0;
37
+ }
38
+
39
+ function zipLongest() {
40
+ var args = [].slice.call(arguments);
41
+ var longest = args.reduce(function (a, b) {
42
+ return a.length > b.length ? a : b;
43
+ }, []);
44
+
45
+ return longest.map(function (_, i) {
46
+ return args.map(function (array) {
47
+ return array[i];
48
+ });
49
+ });
50
+ }
51
+
52
+ class struct {
53
+ static lut = {
54
+ b: {
55
+ u: DataView.prototype.getInt8,
56
+ p: DataView.prototype.setInt8,
57
+ bytes: 1,
58
+ },
59
+ B: {
60
+ u: DataView.prototype.getUint8,
61
+ p: DataView.prototype.setUint8,
62
+ bytes: 1,
63
+ },
64
+ h: {
65
+ u: DataView.prototype.getInt16,
66
+ p: DataView.prototype.setInt16,
67
+ bytes: 2,
68
+ },
69
+ H: {
70
+ u: DataView.prototype.getUint16,
71
+ p: DataView.prototype.setUint16,
72
+ bytes: 2,
73
+ },
74
+ i: {
75
+ u: DataView.prototype.getInt32,
76
+ p: DataView.prototype.setInt32,
77
+ bytes: 4,
78
+ },
79
+ I: {
80
+ u: DataView.prototype.getUint32,
81
+ p: DataView.prototype.setUint32,
82
+ bytes: 4,
83
+ },
84
+ q: {
85
+ u: DataView.prototype.getInt64,
86
+ p: DataView.prototype.setInt64,
87
+ bytes: 8,
88
+ },
89
+ Q: {
90
+ u: DataView.prototype.getUint64,
91
+ p: DataView.prototype.setUint64,
92
+ bytes: 8,
93
+ },
94
+ };
95
+
96
+ static pack(...args) {
97
+ let format = args[0];
98
+ let pointer = 0;
99
+ let data = args.slice(1);
100
+ if (format.replace(/[<>]/, "").length != data.length) {
101
+ throw "Pack format to Argument count mismatch";
102
+ return;
103
+ }
104
+ let bytes = [];
105
+ let littleEndian = true;
106
+ for (let i = 0; i < format.length; i++) {
107
+ if (format[i] == "<") {
108
+ littleEndian = true;
109
+ } else if (format[i] == ">") {
110
+ littleEndian = false;
111
+ } else {
112
+ pushBytes(format[i], data[pointer]);
113
+ pointer++;
114
+ }
115
+ }
116
+
117
+ function pushBytes(formatChar, value) {
118
+ if (!(formatChar in struct.lut)) {
119
+ throw "Unhandled character '" + formatChar + "' in pack format";
120
+ }
121
+ let dataSize = struct.lut[formatChar].bytes;
122
+ let view = new DataView(new ArrayBuffer(dataSize));
123
+ let dataViewFn = struct.lut[formatChar].p.bind(view);
124
+ dataViewFn(0, value, littleEndian);
125
+ for (let i = 0; i < dataSize; i++) {
126
+ bytes.push(view.getUint8(i));
127
+ }
128
+ }
129
+
130
+ return bytes;
131
+ }
132
+
133
+ static unpack(format, bytes) {
134
+ let pointer = 0;
135
+ let data = [];
136
+ let littleEndian = true;
137
+
138
+ for (let c of format) {
139
+ if (c == "<") {
140
+ littleEndian = true;
141
+ } else if (c == ">") {
142
+ littleEndian = false;
143
+ } else {
144
+ pushData(c);
145
+ }
146
+ }
147
+
148
+ function pushData(formatChar) {
149
+ if (!(formatChar in struct.lut)) {
150
+ throw "Unhandled character '" + formatChar + "' in unpack format";
151
+ }
152
+ let dataSize = struct.lut[formatChar].bytes;
153
+ let view = new DataView(new ArrayBuffer(dataSize));
154
+ for (let i = 0; i < dataSize; i++) {
155
+ view.setUint8(i, bytes[pointer + i] & 0xff);
156
+ }
157
+ let dataViewFn = struct.lut[formatChar].u.bind(view);
158
+ data.push(dataViewFn(0, littleEndian));
159
+ pointer += dataSize;
160
+ }
161
+
162
+ return data;
163
+ }
164
+
165
+ static calcsize(format) {
166
+ let size = 0;
167
+ for (let i = 0; i < format.length; i++) {
168
+ if (format[i] != "<" && format[i] != ">") {
169
+ size += struct.lut[format[i]].bytes;
170
+ }
171
+ }
172
+
173
+ return size;
174
+ }
175
+ }
176
+
177
+ function* makeFileIterator(content) {
178
+ for (let line of content.split(/\r?\n/)) {
179
+ yield line.trim();
180
+ }
181
+ return "";
182
+ }
package/license.md ADDED
@@ -0,0 +1,11 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Johann Obermeier
4
+ Copyright (c) 2021 Nabu Casa
5
+ Copyright (c) 2020 Melissa LeBlanc-Williams for Adafruit Industries
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "esp32tool",
3
+ "version": "1.0.0",
4
+ "description": "Flash & Read ESP devices using WebSerial",
5
+ "main": "electron/main.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git://github.com/Jason2866/esp32tool.git"
9
+ },
10
+ "publishConfig": {
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "author": "Johann Obermeier",
14
+ "license": "MIT",
15
+ "scripts": {
16
+ "prebuild": "node -e \"const fs=require('fs'); fs.rmSync('dist',{recursive:true,force:true}); fs.rmSync('js/modules',{recursive:true,force:true}); fs.mkdirSync('js/modules',{recursive:true});\"",
17
+ "build": "npm run prebuild && tsc && rollup -c && node -e \"const fs=require('fs'); fs.readdirSync('dist/web').filter(f=>f.endsWith('.js')).forEach(f=>fs.copyFileSync('dist/web/'+f,'js/modules/'+f)); fs.renameSync('js/modules/index.js','js/modules/esptool.js');\"",
18
+ "prepublishOnly": "npm run build",
19
+ "format": "npm exec -- prettier --write src",
20
+ "develop": "script/develop",
21
+ "lint": "eslint src/",
22
+ "lintAndFix": "eslint src/ --fix",
23
+ "start": "electron-forge start",
24
+ "package": "electron-forge package",
25
+ "make": "electron-forge make",
26
+ "publish": "electron-forge publish"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^25.0.2",
30
+ "eslint": "^9.39.2",
31
+ "@eslint/js": "^9.39.2",
32
+ "electron": "^39.2.5",
33
+ "electron-squirrel-startup": "^1.0.1",
34
+ "@electron-forge/cli": "^7.6.0",
35
+ "@electron-forge/maker-deb": "^7.6.0",
36
+ "@electron-forge/maker-dmg": "^7.6.0",
37
+ "@electron-forge/maker-rpm": "^7.6.0",
38
+ "@electron-forge/maker-squirrel": "^7.6.0",
39
+ "@electron-forge/maker-zip": "^7.6.0",
40
+ "@electron-forge/plugin-auto-unpack-natives": "^7.6.0",
41
+ "@electron-forge/plugin-fuses": "^7.6.0",
42
+ "@electron/fuses": "^1.8.0",
43
+ "@rollup/plugin-json": "^6.1.0",
44
+ "@rollup/plugin-node-resolve": "^16.0.0",
45
+ "@rollup/plugin-terser": "^0.4.4",
46
+ "@rollup/plugin-typescript": "^12.3.0",
47
+ "@types/pako": "^2.0.4",
48
+ "@types/w3c-web-serial": "^1.0.7",
49
+ "eslint-config-prettier": "^10.1.8",
50
+ "eslint-plugin-prettier": "^5.5.4",
51
+ "prettier": "^3.7.3",
52
+ "rollup": "^4.53.5",
53
+ "serve": "^14.2.4",
54
+ "typescript": "^5.7.3",
55
+ "typescript-eslint": "^8.50.1"
56
+ },
57
+ "dependencies": {
58
+ "pako": "^2.1.0",
59
+ "tslib": "^2.8.1"
60
+ }
61
+ }
package/script/build ADDED
@@ -0,0 +1,12 @@
1
+ # Stop on errors
2
+ set -e
3
+
4
+ cd "$(dirname "$0")/.."
5
+
6
+ rm -rf dist
7
+ rm -rf js/modules
8
+ mkdir js/modules
9
+ NODE_ENV=production npm exec -- tsc
10
+ NODE_ENV=production npm exec -- rollup -c
11
+ cp dist/web/*.js js/modules/
12
+ mv js/modules/index.js js/modules/esptool.js
package/script/develop ADDED
@@ -0,0 +1,17 @@
1
+ # Stop on errors
2
+ set -e
3
+
4
+ cd "$(dirname "$0")/.."
5
+
6
+ rm -rf dist
7
+
8
+ # Quit all background tasks when script exits
9
+ trap "kill 0" EXIT
10
+
11
+ # Run tsc once as rollup expects those files
12
+ npm exec -- tsc || true
13
+
14
+ npm exec -- serve -p 5004 &
15
+ npm exec -- tsc --watch &
16
+ npm exec -- rollup -c --watch &
17
+ wait