mirror of
https://github.com/esphome/esp-web-tools.git
synced 2025-07-28 22:26:37 +00:00
Code split smarter to get port picking done first (#310)
This commit is contained in:
parent
2d0af6c9d5
commit
47f9543831
@ -1,7 +1,7 @@
|
|||||||
import type { InstallButton } from "./install-button.js";
|
import type { InstallButton } from "./install-button.js";
|
||||||
import "./install-dialog.js";
|
|
||||||
|
|
||||||
export const connect = async (button: InstallButton) => {
|
export const connect = async (button: InstallButton) => {
|
||||||
|
import("./install-dialog.js");
|
||||||
let port: SerialPort | undefined;
|
let port: SerialPort | undefined;
|
||||||
try {
|
try {
|
||||||
port = await navigator.serial.requestPort();
|
port = await navigator.serial.requestPort();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type { FlashState } from "./const";
|
import type { FlashState } from "./const";
|
||||||
import type { EwtInstallDialog } from "./install-dialog";
|
import type { EwtInstallDialog } from "./install-dialog";
|
||||||
|
import { connect } from "./connect";
|
||||||
|
|
||||||
export class InstallButton extends HTMLElement {
|
export class InstallButton extends HTMLElement {
|
||||||
public static isSupported = "serial" in navigator;
|
public static isSupported = "serial" in navigator;
|
||||||
@ -74,10 +75,6 @@ export class InstallButton extends HTMLElement {
|
|||||||
|
|
||||||
public overrides: EwtInstallDialog["overrides"];
|
public overrides: EwtInstallDialog["overrides"];
|
||||||
|
|
||||||
public static preload() {
|
|
||||||
import("./connect");
|
|
||||||
}
|
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
if (this.renderRoot) {
|
if (this.renderRoot) {
|
||||||
return;
|
return;
|
||||||
@ -95,14 +92,11 @@ export class InstallButton extends HTMLElement {
|
|||||||
|
|
||||||
this.toggleAttribute("install-supported", true);
|
this.toggleAttribute("install-supported", true);
|
||||||
|
|
||||||
this.addEventListener("mouseover", InstallButton.preload);
|
|
||||||
|
|
||||||
const slot = document.createElement("slot");
|
const slot = document.createElement("slot");
|
||||||
|
|
||||||
slot.addEventListener("click", async (ev) => {
|
slot.addEventListener("click", async (ev) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
const mod = await import("./connect");
|
connect(this);
|
||||||
mod.connect(this);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
slot.name = "activate";
|
slot.name = "activate";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user