1 | export interface Logger {
|
2 | log(msg: string, ...args: any[]): void;
|
3 | error(msg: string, ...args: any[]): void;
|
4 | debug(msg: string, ...args: any[]): void;
|
5 | }
|
6 | export interface Build {
|
7 | chipFamily: "ESP32" | "ESP32-C2" | "ESP32-C3" | "ESP32-C6" | "ESP32-H2" | "ESP32-S2" | "ESP32-S3" | "ESP8266";
|
8 | parts: {
|
9 | path: string;
|
10 | offset: number;
|
11 | }[];
|
12 | }
|
13 | export interface Manifest {
|
14 | name: string;
|
15 | version: string;
|
16 | home_assistant_domain?: string;
|
17 | funding_url?: string;
|
18 |
|
19 | new_install_skip_erase?: boolean;
|
20 | new_install_prompt_erase?: boolean;
|
21 | new_install_improv_wait_time?: number;
|
22 | builds: Build[];
|
23 | }
|
24 | export interface BaseFlashState {
|
25 | state: FlashStateType;
|
26 | message: string;
|
27 | manifest?: Manifest;
|
28 | build?: Build;
|
29 | chipFamily?: Build["chipFamily"] | "Unknown Chip";
|
30 | }
|
31 | export interface InitializingState extends BaseFlashState {
|
32 | state: FlashStateType.INITIALIZING;
|
33 | details: {
|
34 | done: boolean;
|
35 | };
|
36 | }
|
37 | export interface PreparingState extends BaseFlashState {
|
38 | state: FlashStateType.PREPARING;
|
39 | details: {
|
40 | done: boolean;
|
41 | };
|
42 | }
|
43 | export interface ErasingState extends BaseFlashState {
|
44 | state: FlashStateType.ERASING;
|
45 | details: {
|
46 | done: boolean;
|
47 | };
|
48 | }
|
49 | export interface WritingState extends BaseFlashState {
|
50 | state: FlashStateType.WRITING;
|
51 | details: {
|
52 | bytesTotal: number;
|
53 | bytesWritten: number;
|
54 | percentage: number;
|
55 | };
|
56 | }
|
57 | export interface FinishedState extends BaseFlashState {
|
58 | state: FlashStateType.FINISHED;
|
59 | }
|
60 | export interface ErrorState extends BaseFlashState {
|
61 | state: FlashStateType.ERROR;
|
62 | details: {
|
63 | error: FlashError;
|
64 | details: string | Error;
|
65 | };
|
66 | }
|
67 | export type FlashState = InitializingState | PreparingState | ErasingState | WritingState | FinishedState | ErrorState;
|
68 | export declare const enum FlashStateType {
|
69 | INITIALIZING = "initializing",
|
70 | PREPARING = "preparing",
|
71 | ERASING = "erasing",
|
72 | WRITING = "writing",
|
73 | FINISHED = "finished",
|
74 | ERROR = "error"
|
75 | }
|
76 | export declare const enum FlashError {
|
77 | FAILED_INITIALIZING = "failed_initialize",
|
78 | FAILED_MANIFEST_FETCH = "fetch_manifest_failed",
|
79 | NOT_SUPPORTED = "not_supported",
|
80 | FAILED_FIRMWARE_DOWNLOAD = "failed_firmware_download",
|
81 | WRITE_FAILED = "write_failed"
|
82 | }
|
83 | declare global {
|
84 | interface HTMLElementEventMap {
|
85 | "state-changed": CustomEvent<FlashState>;
|
86 | }
|
87 | }
|