diff --git a/frontend/src/routes/lesson/[slug]/DeployTab.svelte b/frontend/src/routes/lesson/[slug]/DeployTab.svelte index 31226a4..6876215 100644 --- a/frontend/src/routes/lesson/[slug]/DeployTab.svelte +++ b/frontend/src/routes/lesson/[slug]/DeployTab.svelte @@ -51,9 +51,18 @@ } }); + $effect(() => { + if (typeof window === 'undefined') return; + const mq = window.matchMedia('(min-width: 1024px)'); + isDesktop = mq.matches; + const handler = (e: MediaQueryListEvent) => { isDesktop = e.matches; }; + mq.addEventListener('change', handler); + return () => mq.removeEventListener('change', handler); + }); + function detectMode() { usbSupported = typeof navigator !== 'undefined' && 'serial' in navigator; - isDesktop = window.matchMedia('(min-width: 1024px)').matches; + isDesktop = typeof window !== 'undefined' && window.matchMedia('(min-width: 1024px)').matches; if (usbSupported && isDesktop) { deployMode = 'usb'; } else { @@ -189,8 +198,8 @@ completedChunks = p.completedChunks; }; - if (deployMode === 'usb' && res.binary_content) { - await deployer.deployBinary!(res.binary_content, onProgress); + if (deployMode === 'usb' && res.binary_content && typeof deployer.deployBinary === 'function') { + await deployer.deployBinary(res.binary_content, onProgress); } else { await deployer.deployHex(res.hex_content, onProgress); } @@ -288,18 +297,22 @@ {deployMode === 'usb' ? 'USB Deployer' : 'BLE Deployer'} {#if usbSupported && isDesktop} -