Files
cydweb/components/esp-web-install.tsx
DESKTOP-PUHFO60\dsx2016 ae63378fdb Add CYD browser flasher with Next.js, i18n, and Web Serial install.
Replace the starter app with a public/local flasher that discovers sibling firmwares, supports en/zh, and documents HTTPS deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-19 19:38:53 +08:00

49 lines
978 B
TypeScript

"use client";
import { createElement, useEffect } from "react";
/**
* Loads esp-web-tools once; hosts the install button via slot.
*/
export function EspWebInstall({
manifest,
label,
disabled,
}: {
manifest: string | null;
label: string;
disabled?: boolean;
}) {
useEffect(() => {
if (document.querySelector('script[data-esp-web-tools="1"]')) return;
const script = document.createElement("script");
script.type = "module";
script.src =
"https://unpkg.com/esp-web-tools@10.1.0/dist/web/install-button.js?module";
script.dataset.espWebTools = "1";
document.head.appendChild(script);
}, []);
const activate = createElement(
"button",
{
slot: "activate",
type: "button",
className: "cta-btn",
disabled: Boolean(disabled || !manifest),
},
label
);
if (!manifest) {
return activate;
}
return createElement(
"esp-web-install-button",
{ manifest },
activate
);
}