瀏覽代碼

Bump esp-web-flasher to 2.0 + hide improv button when done provision is done (#14)

Bram Kragten 4 年之前
父節點
當前提交
7f03060e86
共有 4 個文件被更改,包括 24 次插入12 次删除
  1. 9 9
      package-lock.json
  2. 1 1
      package.json
  3. 1 1
      src/flash.ts
  4. 13 1
      src/start-flash.ts

+ 9 - 9
package-lock.json

@@ -1,16 +1,16 @@
 {
   "name": "esp-web-tools",
-  "version": "2.0.2",
+  "version": "3.1.0",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
-      "version": "2.0.2",
+      "version": "3.1.0",
       "license": "Apache-2.0",
       "dependencies": {
         "@material/mwc-base": "^0.21.0",
         "@material/mwc-linear-progress": "^0.21.0",
-        "esp-web-flasher": "^1.0.4",
+        "esp-web-flasher": "^2.0.0",
         "lit": "^2.0.0-rc.2",
         "tslib": "^2.2.0"
       },
@@ -556,9 +556,9 @@
       }
     },
     "node_modules/esp-web-flasher": {
-      "version": "1.0.4",
-      "resolved": "https://registry.npmjs.org/esp-web-flasher/-/esp-web-flasher-1.0.4.tgz",
-      "integrity": "sha512-n1LrBV6M5fu4k06zh7IW5FbpBnLTrPxTRO2YrpRu5ahqG0FO2dsxLkASdlOhVzSHtKNo29ZG4IS6nPtxlLiL5A==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/esp-web-flasher/-/esp-web-flasher-2.0.0.tgz",
+      "integrity": "sha512-vLAVJbWYL/wNIv5AQ8XwqO61ORnbtmbbAMFJJ1C0fMSUnu4J/rogWZYHZLNLZbtjp0XL5nbu8RWjXCE6DeSTjw==",
       "dependencies": {
         "tslib": "^2.2.0"
       }
@@ -1925,9 +1925,9 @@
       "dev": true
     },
     "esp-web-flasher": {
-      "version": "1.0.4",
-      "resolved": "https://registry.npmjs.org/esp-web-flasher/-/esp-web-flasher-1.0.4.tgz",
-      "integrity": "sha512-n1LrBV6M5fu4k06zh7IW5FbpBnLTrPxTRO2YrpRu5ahqG0FO2dsxLkASdlOhVzSHtKNo29ZG4IS6nPtxlLiL5A==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/esp-web-flasher/-/esp-web-flasher-2.0.0.tgz",
+      "integrity": "sha512-vLAVJbWYL/wNIv5AQ8XwqO61ORnbtmbbAMFJJ1C0fMSUnu4J/rogWZYHZLNLZbtjp0XL5nbu8RWjXCE6DeSTjw==",
       "requires": {
         "tslib": "^2.2.0"
       }

+ 1 - 1
package.json

@@ -23,7 +23,7 @@
   "dependencies": {
     "@material/mwc-base": "^0.21.0",
     "@material/mwc-linear-progress": "^0.21.0",
-    "esp-web-flasher": "^1.0.4",
+    "esp-web-flasher": "^2.0.0",
     "lit": "^2.0.0-rc.2",
     "tslib": "^2.2.0"
   }

+ 1 - 1
src/flash.ts

@@ -224,7 +224,7 @@ export const flash = async (
   });
 
   await sleep(100);
-  await esploader.softReset();
+  await esploader.hardReset();
   await esploader.disconnect();
 
   fireStateEvent({

+ 13 - 1
src/start-flash.ts

@@ -110,12 +110,24 @@ const startImprov = async (button: InstallButton) => {
   // @ts-ignore
   await import("https://www.improv-wifi.com/sdk-js/launch-button.js");
 
-  if (!customElements.get("improv-wifi-launch-button").isSupported) {
+  const improvButtonConstructor = customElements.get(
+    "improv-wifi-launch-button"
+  );
+
+  if (
+    !improvButtonConstructor.isSupported ||
+    !improvButtonConstructor.isAllowed
+  ) {
     return;
   }
 
   if (!improvEl) {
     improvEl = document.createElement("improv-wifi-launch-button");
+    improvEl.addEventListener("state-changed", (ev: any) => {
+      if (ev.detail.state === "PROVISIONED") {
+        improvEl!.classList.toggle("hidden", true);
+      }
+    });
     const improvButton = document.createElement("button");
     improvButton.slot = "activate";
     improvButton.textContent = "CLICK HERE TO FINISH SETTING UP YOUR DEVICE";