From 3aa9ce1b5985397d7f568887ec6f881df13c1034 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 11 Feb 2026 17:09:39 -0800 Subject: fix ts errors --- .../(app)/[username]/(profile)/+layout.svelte | 2 +- src/routes/(app)/[username]/receive/+page.svelte | 7 +-- src/routes/(app)/account/[id]/+page.svelte | 6 +- src/routes/(app)/account/ark/+page.svelte | 12 ++-- src/routes/(app)/account/pass/+page.svelte | 16 +++--- src/routes/(app)/dm/+page.svelte | 58 +++++++++---------- src/routes/(app)/firehose/+page.svelte | 4 +- src/routes/(app)/fund/[id]/+page.svelte | 4 +- src/routes/(app)/fund/[id]/access/+page.svelte | 2 +- src/routes/(app)/invoice/[id]/+page.svelte | 5 +- src/routes/(app)/invoice/[id]/tip/+page.svelte | 28 ++++----- src/routes/(app)/messages/+page.svelte | 18 +++--- src/routes/(app)/messages/[recipient]/+page.svelte | 28 ++++----- src/routes/(app)/payment/[id]/+page.svelte | 2 +- src/routes/(app)/pos/+page.svelte | 30 +++++----- src/routes/(app)/send/[...text]/+page.svelte | 4 +- .../[address]/[amount]/[...feeRate]/+page.svelte | 2 +- .../[address]/[amount]/[...feeRate]/+page.svelte | 28 ++++----- src/routes/(app)/send/invoice/[id]/+page.svelte | 12 ++-- .../lightning/[payreq]/[...memo]/+page.server.ts | 2 +- .../send/lightning/[payreq]/[...memo]/+page.svelte | 16 +++--- .../(app)/send/zap/[id]/[...amount]/+page.svelte | 30 +++++----- src/routes/(app)/settings/+layout.svelte | 40 ++++++------- src/routes/(app)/settings/account/+page.svelte | 15 ++--- src/routes/(app)/settings/nostr/+page.svelte | 18 +++--- src/routes/(app)/settings/profile/+page.svelte | 19 +++---- src/routes/(app)/settings/security/+page.svelte | 34 +++++------ src/routes/(static)/bounties/+page.svelte | 2 +- src/routes/(static)/login/+page.svelte | 32 +++++------ src/routes/(static)/register/+page.svelte | 66 +++++++++++----------- src/routes/(static)/support/+page.svelte | 5 +- 31 files changed, 275 insertions(+), 272 deletions(-) (limited to 'src/routes') diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index 5734c71f..8331c98e 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -29,7 +29,7 @@ try { await post(`/reset`, { username: n, password }); success("Password reset"); - } catch (e) { + } catch (e: any) { fail(e.message); } }; diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte index 009422a5..6921d443 100644 --- a/src/routes/(app)/[username]/receive/+page.svelte +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -26,7 +26,7 @@ import { goto, invalidate } from "$app/navigation"; import { page } from "$app/stores"; - let { data } = $props(); + let { data }: any = $props(); let showOptions; @@ -40,7 +40,7 @@ let qr; let aid = $derived(subject.id); - let invoice = $derived({ + let invoice: any = $derived({ aid, type: types.lightning, items: [], @@ -65,7 +65,7 @@ else url += "?options=true"; goto(url, { invalidateAll: true, noScroll: true }); - } catch (e) { + } catch (e: any) { fail(e.message); } }; @@ -158,7 +158,6 @@ {invoice} {copy} {link} - {type} {showQr} {txt} t={$t} diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index ad977e7a..4a23a211 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -40,7 +40,7 @@ mnemonic = entropyToMnemonic(entropy, wordlist); password = cached; return true; - } catch (e) { + } catch (e: any) { forgetWalletPassword(); return false; } @@ -57,7 +57,7 @@ const { decrypt } = await import("nostr-tools/nip49"); let entropy = await decrypt(seed, password); mnemonic = entropyToMnemonic(entropy, wordlist); - } catch (e) { + } catch (e: any) { fail("Invalid password, try again"); passwordPrompt = true; } @@ -67,7 +67,7 @@ try { await post("/api/account/delete", { id }); goto(`/${user.username}`); - } catch (e) { + } catch (e: any) { fail(e.message); } }; diff --git a/src/routes/(app)/account/ark/+page.svelte b/src/routes/(app)/account/ark/+page.svelte index 32dbfe13..0c4d8783 100644 --- a/src/routes/(app)/account/ark/+page.svelte +++ b/src/routes/(app)/account/ark/+page.svelte @@ -66,12 +66,12 @@ let seed = await mnemonicToSeed(mnemonic, pw); let master = HDKey.fromMasterSeed(seed, versions); let arkChild = master.derive("m/86'/0'/0'/0/0"); - let arkHex = bytesToHex(arkChild.privateKey); + let arkHex = bytesToHex(arkChild.privateKey!); const identity = SingleKey.fromHex(arkHex); const wallet = await Wallet.create({ identity, arkServerUrl }); arkAddress = await wallet.getAddress(); confirmed = true; - } catch (e) { + } catch (e: any) { console.log("master seed derivation failed", e); fail("Invalid password"); } @@ -117,7 +117,7 @@ forgetWalletPassword(); } goto(`/${user.username}`); - } catch (e) { + } catch (e: any) { console.log(e); fail(e.message); } @@ -150,7 +150,7 @@ forgetWalletPassword(); } goto(`/${user.username}`); - } catch (e) { + } catch (e: any) { console.log(e); fail(e.message); } @@ -220,7 +220,7 @@ id="rememberFor" class="w-full" value={rememberForMs} - onchange={(e) => (rememberForMs = Number(e.target.value))} + onchange={(e) => (rememberForMs = Number((e.target as HTMLSelectElement).value))} > {#each rememberForOptions as option} @@ -371,7 +371,7 @@ id="rememberFor" class="w-full" value={rememberForMs} - onchange={(e) => (rememberForMs = Number(e.target.value))} + onchange={(e) => (rememberForMs = Number((e.target as HTMLSelectElement).value))} > {#each rememberForOptions as option} diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte index a64d95ee..4e9573d4 100644 --- a/src/routes/(app)/account/pass/+page.svelte +++ b/src/routes/(app)/account/pass/+page.svelte @@ -21,13 +21,13 @@ forgetWalletPassword, } from "$lib/passwordCache"; - let { data } = $props(); + let { data }: any = $props(); let { user } = data; - let submitting = $state(); + let submitting = $state(false); - let confirm = $state(), - password = $state(), + let confirm: string = $state(""), + password: string = $state(""), revealPassword = $state(), revealConfirm = $state(); let rememberForMs = $state(defaultRememberForMs); @@ -47,7 +47,7 @@ try { const { encrypt } = await import("nostr-tools/nip49"); let seed = await encrypt( - mnemonicToEntropy($mnemonic, wordlist), + mnemonicToEntropy($mnemonic as string, wordlist), password, ); @@ -55,7 +55,7 @@ await post("/post/user", { seed }); let master = HDKey.fromMasterSeed( - await mnemonicToSeed($mnemonic, password), + await mnemonicToSeed($mnemonic as string, password), versions, ); @@ -78,7 +78,7 @@ } $mnemonic = ""; goto(`/${user.username}`); - } catch (e) { + } catch (e: any) { console.log(e); fail(e.message); } @@ -188,7 +188,7 @@ id="rememberFor" class="w-full" value={rememberForMs} - onchange={(e) => (rememberForMs = Number(e.target.value))} + onchange={(e) => (rememberForMs = Number((e.target as HTMLSelectElement).value))} > {#each rememberForOptions as option} diff --git a/src/routes/(app)/dm/+page.svelte b/src/routes/(app)/dm/+page.svelte index 7b864f89..95cb208e 100644 --- a/src/routes/(app)/dm/+page.svelte +++ b/src/routes/(app)/dm/+page.svelte @@ -23,7 +23,7 @@ } /// chat selection - const usernameFromPubkey = async (pubkey: string): string => { + const usernameFromPubkey = async (pubkey: string): Promise => { const response = await fetch(`/api/users/${pubkey}`); if (response.ok) { const userInfo = await response.json(); @@ -35,7 +35,7 @@ const userInfo = async (pubkey: string) => { if (pubkey.slice(0, 4) === "npub") { - return userInfo(decode(pubkey).data); + return userInfo(decode(pubkey).data as string); } const nostrUserInfo = await getNostrUserInfo(pubkey) || {}; @@ -48,11 +48,11 @@ nip05Valid: valid, pubkey }; } - const name = (userInfo: object): string => { + const name = (userInfo: any): string => { return userInfo.coinosUsername || userInfo.nostrName || $t("dm.anonymous"); } - const id = (userInfo: object): string => { + const id = (userInfo: any): string => { if (userInfo.nip05 && userInfo.nip05.slice(0, 2) == "_@") { return userInfo.nip05.slice(2); } @@ -60,11 +60,11 @@ return userInfo.nip05 || (npubEncode(userInfo.pubkey).slice(0, 16) + "..."); } - const idValid = (userInfo: object): string => { + const idValid = (userInfo: any): boolean => { return !userInfo.nip05 || userInfo.nip05Valid; } - const rumourInvolves = (rumour: object, pubkey: string) => { + const rumourInvolves = (rumour: any, pubkey: string) => { if (rumour.pubkey === pubkey) { return true; } else { @@ -77,7 +77,7 @@ } } - const mostRecentCommunication = (rumours: object[], pubkey: string) => { + const mostRecentCommunication = (rumours: any[], pubkey: string) => { let mostRecentTime = null; for (const rumour of rumours.filter((r) => rumourInvolves(r, pubkey))) { if (!mostRecentTime || rumour.created_at > mostRecentTime) { @@ -87,9 +87,9 @@ return mostRecentTime; } - const updateSendersRecipients = async (rumours: object[]) => { - const senders = new Set(); - const recipients = new Set(); + const updateSendersRecipients = async (rumours: any[]) => { + const senders = new Set(); + const recipients = new Set(); for (const rumour of rumours) { if (rumour.pubkey !== user.pubkey) { senders.add(await userInfo(rumour.pubkey)); @@ -102,7 +102,7 @@ messageSenders = Array.from(senders); messageRecipients = Array.from(recipients); - const chatMap = new Map(); + const chatMap = new Map(); for (const sender of senders) { chatMap.set(sender.pubkey, sender); } @@ -110,31 +110,31 @@ chatMap.set(recipient.pubkey, recipient); } chats = Array.from(chatMap.values()); - chats.sort((a, b) => mostRecentCommunication(rumours, b.pubkey) - mostRecentCommunication(rumours, a.pubkey)); + chats.sort((a, b) => (mostRecentCommunication(rumours, b.pubkey) ?? 0) - (mostRecentCommunication(rumours, a.pubkey) ?? 0)); }; - let messageSenders = $state([]); - let messageRecipients = $state([]); - let chats = $state([]); + let messageSenders: any[] = $state([]); + let messageRecipients: any[] = $state([]); + let chats: any[] = $state([]); getMessageRumours(user).then(updateSendersRecipients); - let selectedChat = $state(null); + let selectedChat: any = $state(null); let creatingNewChat = $state(false); let searchQuery = $state(""); /// individual chat let text = $state(""); - let allRumours = $state([]); - let messageRumours = $state([]); - let dates = $state([]); + let allRumours: any[] = $state([]); + let messageRumours: any = $state([]); + let dates: any[] = $state([]); let relayWarningShown = $state(false); let expiryEnabled = $state(false); let expiryDays = $state(7); let canSend = $state(false); let canSendExpiring = $state(false); - let nostrUserInfo = $state({}); + let nostrUserInfo: any = $state({}); - const includesPubkey = (chats: object[], pubkey: string) => { + const includesPubkey = (chats: any[], pubkey: string) => { for (const c of chats) { if (c.pubkey === pubkey) { return true; @@ -143,7 +143,7 @@ return false; } - const selectChat = (c: object) => { + const selectChat = (c: any) => { selectedChat = c; if (!includesPubkey(chats, c.pubkey)) { chats.unshift(c); @@ -184,23 +184,23 @@ onMount(() => { const urlParams = new URLSearchParams(window.location.search); if (urlParams.get('username')) { - selectChatUsername(urlParams.get('username')); + selectChatUsername(urlParams.get('username')!); } else if (urlParams.get('nip05')) { - selectChatNip05(urlParams.get('nip05')); + selectChatNip05(urlParams.get('nip05')!); } else if (urlParams.get('pubkey')) { - selectChatPubkey(urlParams.get('pubkey')); + selectChatPubkey(urlParams.get('pubkey')!); } }); - const appendMultimap = (map: Map, key: string, value: object) => { + const appendMultimap = (map: Map, key: any, value: any) => { if (map.has(key)) { - map.get(key).push(value); + map.get(key)!.push(value); } else { map.set(key, [value]); } } - const dateMap = (events: object[]): Map => { + const dateMap = (events: any[]): Map => { let eventsMap = new Map(); for (const event of events) { const created = Math.floor(event.created_at / 86400); @@ -249,7 +249,7 @@ } const sendMessage = async (message: string) => { - const expiry = expiryEnabled ? expiryDays : null; + const expiry = expiryEnabled ? expiryDays : undefined; await libnip17.send(message, user, selectedChat, expiry); updateEvents(); } diff --git a/src/routes/(app)/firehose/+page.svelte b/src/routes/(app)/firehose/+page.svelte index 6b2338c2..2fdaa4d0 100644 --- a/src/routes/(app)/firehose/+page.svelte +++ b/src/routes/(app)/firehose/+page.svelte @@ -4,7 +4,7 @@ import { onMount } from "svelte"; import { ignore } from "$lib/store"; - let events = $state([]); + let events: any[] = $state([]); let paused = $state(); let pause = (e) => { e.preventDefault(); @@ -21,7 +21,7 @@ const { Relay } = await import("nostr-tools/relay"); const relay = await Relay.connect("wss://relay.primal.net"); const subscription = relay.subscribe([{ kinds: [1], limit: 20 }], { - async onevent(event) { + async onevent(event: any) { if (paused) return; const { parts, names } = await post("/post/parseEvent", { event }); event.author = await get(`/api/users/${event.pubkey}`); diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index 5f8d848f..c3fa7ce1 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -12,7 +12,7 @@ import { bech32 } from "@scure/base"; const encoder = new TextEncoder(); - let { data } = $props(); + let { data }: any = $props(); let { amount, payments, managers, rate, user } = data; let { id } = $page.params; @@ -21,7 +21,7 @@ let currency = user ? user.currency : "CAD"; let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2))); - $effect(() => ($loginRedirect = $page.url.pathname)); + $effect(() => { $loginRedirect = $page.url.pathname; }); let show = $state(); let toggle = () => (show = !show); diff --git a/src/routes/(app)/fund/[id]/access/+page.svelte b/src/routes/(app)/fund/[id]/access/+page.svelte index 9a7a85cb..24ded54e 100644 --- a/src/routes/(app)/fund/[id]/access/+page.svelte +++ b/src/routes/(app)/fund/[id]/access/+page.svelte @@ -15,7 +15,7 @@ m = await post(`/post/fund/${id}/managers/delete`, { id: user.id, }); - } catch (e) { + } catch (e: any) { fail(e.message); } }; diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte index beffa264..bf62a062 100644 --- a/src/routes/(app)/invoice/[id]/+page.svelte +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -28,7 +28,7 @@ import { t } from "$lib/translations"; import { goto, invalidate } from "$app/navigation"; - let { data } = $props(); + let { data }: any = $props(); let showOptions; @@ -91,7 +91,7 @@ else url += "?options=true"; goto(url, { invalidateAll: true, noScroll: true }); - } catch (e) { + } catch (e: any) { fail(e.message); } }; @@ -185,7 +185,6 @@ {invoice} {copy} {link} - {type} {txt} t={$t} bind:showQr={$showQr} diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte index c9f38837..4d3af188 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.svelte +++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte @@ -10,10 +10,10 @@ const tipAmounts = ["No", "10%", "15%", "20%"]; let showCustomAmount = $state(); - let customInput = $state(); - let customTipAmount = $state(); + let customInput: HTMLInputElement = $state() as any; + let customTipAmount: number = $state(0); - let apply = async (e) => { + let apply = async (e: Event) => { e.preventDefault(); if (customTipAmount > 0) { @@ -25,24 +25,24 @@ let active = (amount) => !customTipAmount && Math.round(tipPercent) === parseInt(amount.slice(0, 2)); - const handleCustomTipAmount = (e) => { - customTipAmount = e.target.value; + const handleCustomTipAmount = (e: Event) => { + customTipAmount = Number((e.target as HTMLInputElement).value); tipPercent = (customTipAmount / amountFiat) * 100; tip = Math.round((amount / 100) * tipPercent); }; let timeout; - const handleSlide = (e) => { - customTipAmount = ""; + const handleSlide = (e: Event) => { + customTipAmount = 0; if (customInput) { customInput.value = ""; } - tipPercent = e.target.value; + tipPercent = Number((e.target as HTMLInputElement).value); tip = Math.round((amount / 100) * tipPercent); }; let submitting = $state(); - const handleTipButtonClick = async (v) => { + const handleTipButtonClick = async (v: string) => { submitting = true; if (v === "No") { tipPercent = 0; @@ -56,9 +56,9 @@ submit.click(); }; - let submit = $state(); + let submit: HTMLButtonElement = $state() as any; - let { data } = $props(); + let { data }: any = $props(); let { invoice, id, user } = $state(data); let { aid, @@ -87,7 +87,7 @@ }); let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2))); - let tipAmount = $derived(((tip * rate) / sats).toFixed(2)); + let tipAmount = $derived(parseFloat(((tip * rate) / sats).toFixed(2))); let invoiceAmountFiatFormatted = $derived(f(amountFiat, currency)); @@ -147,14 +147,14 @@ use:focus type="button" class="btn" - class:active={active(amount, tipPercent)} + class:active={active(amount)} onclick={() => handleTipButtonClick(amount)}>{amount} {:else} {/if} diff --git a/src/routes/(app)/messages/+page.svelte b/src/routes/(app)/messages/+page.svelte index 606af893..2de56e0b 100644 --- a/src/routes/(app)/messages/+page.svelte +++ b/src/routes/(app)/messages/+page.svelte @@ -9,24 +9,24 @@ let { data } = $props(); - let { messages, notes, invoices, sent, received, subject, user } = + let { messages, notes, invoices, sent, received, subject, user }: any = $state(data); - let refresh = (d) => + let refresh = (d: any) => ({ messages, notes, invoices, sent, received, subject, user } = d); let keys = new Set(); - let latest = $state([]); - let ready; + let latest: any[] = $state([]); + let ready: any; - e.subscribe(async (event) => { + e.subscribe(async (event: any) => { if (!(browser && event && ready)) return; if ( event.recipient?.id === user.id && - !~latest.findIndex((m) => m.id === event.id) + !~latest.findIndex((m: any) => m.id === event.id) ) { event.content = await decrypt({ event, user }); - let i = latest.findIndex((m) => m.pubkey === event.pubkey); + let i = latest.findIndex((m: any) => m.pubkey === event.pubkey); let popped; if (~i) popped = latest.splice(i, 1); else popped = latest.pop(); @@ -36,7 +36,7 @@ } }); - let initialize = async (p) => { + let initialize = async (p: any) => { let i = 0; ready = false; if (!(browser && user)) return; @@ -80,7 +80,7 @@
- +
{u.username}
diff --git a/src/routes/(app)/messages/[recipient]/+page.svelte b/src/routes/(app)/messages/[recipient]/+page.svelte index c8d522f0..f399ab25 100644 --- a/src/routes/(app)/messages/[recipient]/+page.svelte +++ b/src/routes/(app)/messages/[recipient]/+page.svelte @@ -15,12 +15,12 @@ let { data } = $props(); function fadeScale( - node, - { delay = 0, duration = 200, easing = (x) => x, baseScale = 0 }, + node: any, + { delay = 0, duration = 200, easing = (x: number) => x, baseScale = 0 }, ) { const o = +getComputedStyle(node).opacity; const m = getComputedStyle(node).transform.match(/scale\(([0-9.]+)\)/); - const s = m ? m[1] : 1; + const s: any = m ? m[1] : 1; const is = 1 - baseScale; return { @@ -35,10 +35,10 @@ }; } - let { messages, recipient, user } = $state(data); - let input, pane = $state(); + let { messages, recipient, user }: any = $state(data); + let input: any, pane: any = $state(); - let initialize = async (p) => { + let initialize = async (p: any) => { await Promise.all( messages.map( async (event) => (event.message = await decrypt({ event, user })), @@ -49,8 +49,8 @@ tick().then(() => pane && (pane.scrollTop = pane.scrollHeight)); }; - e.subscribe(async (event) => { - let found = ~messages.findIndex((m) => m.id === event?.id); + e.subscribe(async (event: any) => { + let found = ~messages.findIndex((m: any) => m.id === event?.id); if (event?.recipient.id === user.id && !found) { event.message = await decrypt({ event, user }); messages.push(event); @@ -59,11 +59,11 @@ } }); - let sent, submitting, message = $state(); + let sent: any, submitting: any, message: any = $state(); let submit = async () => { submitting = true; - let event = { + let event: any = { pubkey: user.pubkey, created_at: Math.floor(Date.now() / 1000), kind: 4, @@ -93,8 +93,8 @@ await send(event); sent = true; - } catch (e) { - console.log(e); + } catch (err: any) { + console.log(err); fail("Failed to send message"); } @@ -102,7 +102,7 @@ submitting = false; }; - let keydown = (e) => { + let keydown = (e: any) => { if (e.key === "Enter") { e.preventDefault(); submit(); @@ -149,7 +149,7 @@ {message}
- +
diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index e368f2ad..436a7ab6 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -66,7 +66,7 @@ let bump = async () => { try { await post(`/payment/${id}/bump`, { id }); - } catch (e) { + } catch (e: any) { fail(e.message); } }; diff --git a/src/routes/(app)/pos/+page.svelte b/src/routes/(app)/pos/+page.svelte index 967ddd09..6806fec3 100644 --- a/src/routes/(app)/pos/+page.svelte +++ b/src/routes/(app)/pos/+page.svelte @@ -3,7 +3,7 @@ import { hex } from "@scure/base"; // Convert Uint8Array → JS "binary string" in safe chunks - function bs(uint8Array) { + function bs(uint8Array: Uint8Array) { let binaryString = ""; const chunkSize = 0x8000; for (let i = 0; i < uint8Array.length; i += chunkSize) { @@ -13,7 +13,7 @@ return binaryString; } - let { data, form } = $props(); + let { data, form }: any = $props(); let { token } = $state(data); // --- Defaults --- @@ -23,12 +23,12 @@ const WORK_BAUD = 921600; // fast flashing // --- Shared state --- - let esploader = $state(); - let chip, transport; + let esploader: any = $state(); + let chip: any, transport: any; let connected = $state(false); let portInfo = $state(""); - let ESPLoader; - let Transport; + let ESPLoader: any; + let Transport: any; // --- Existing config path (generated server-side to hex in form.bytes) --- let bytes = $derived(form ? hex.decode(form.bytes) : undefined); @@ -37,8 +37,8 @@ let configDone = $state(false); // --- New firmware flashing path --- - let fwFile = $state(null); - let fwBytes = $state(); // Uint8Array + let fwFile: any = $state(null); + let fwBytes: Uint8Array | undefined = $state(); // Uint8Array let fwAddress = $state(FW_ADDRESS_DEFAULT); let fwEraseAll = $state(false); let fwProgress = $state(0); @@ -53,7 +53,7 @@ if (!ESPLoader || !Transport) { ({ ESPLoader, Transport } = await import("esptool-js")); } - const device = await navigator.serial.requestPort({}); + const device = await (navigator as any).serial.requestPort({}); transport = new Transport(device, true); esploader = new ESPLoader({ transport, @@ -90,10 +90,10 @@ configDone = true; }; - function onPickFw(e) { + function onPickFw(e: Event) { fwError = ""; fwDone = false; - const f = e.target.files?.[0]; + const f = (e.target as HTMLInputElement).files?.[0]; fwFile = f || null; if (!fwFile) { fwBytes = undefined; @@ -101,7 +101,7 @@ } const reader = new FileReader(); reader.onload = () => { - const buf = new Uint8Array(reader.result); + const buf = new Uint8Array(reader.result as ArrayBuffer); fwBytes = buf; }; reader.onerror = () => { @@ -138,7 +138,7 @@ }); fwDone = true; - } catch (e) { + } catch (e: any) { console.error(e); fwError = e?.message || "Flash failed."; } @@ -178,7 +178,7 @@ id="littlefs-address" class="input" bind:value={littlefsAddress} - onchange={(e) => (littlefsAddress = Number(e.target.value))} + onchange={(e) => (littlefsAddress = Number((e.target as HTMLInputElement).value))} />
@@ -214,7 +214,7 @@ id="firmware-address" class="input" bind:value={fwAddress} - onchange={(e) => (fwAddress = Number(e.target.value))} + onchange={(e) => (fwAddress = Number((e.target as HTMLInputElement).value))} />
{#if passwordPrompt} - + {/if}