eb53de2ea5
Ship a smaller installer that no longer carries ffmpeg.exe/ffprobe.exe (the bulk of its size). On first run they are downloaded from a pinned upstream archive (gyan 8.1.2), verified against a pinned SHA-256, and unpacked with the OS tar.exe into the managed userData/bin dir -- the same place as the self-updating yt-dlp, so they survive app updates and portable re-extraction. A hard onboarding gate blocks the app until they are present, with a "locate existing ffmpeg" folder-picker fallback for offline machines and a Repair action in Settings > About. The updater's streaming/checksum/redirect/idle-timeout download loop is extracted to lib/verifiedDownload.streamVerifiedFile and shared by both the app-installer download and the ffmpeg fetch; the updater's public behaviour and error strings are unchanged (its boundary tests still pass). No new npm dependency: extraction uses the System32 bsdtar resolved by absolute path (audit F3). Note: this commit also carries pre-existing, in-progress aria2c/network and updater-token work that was already uncommitted in the working tree and is entangled with the above in shared files (updater.ts, ipc.ts, preload/index.ts, mockApi.ts, shared/ipc.ts, plus the settings/network files and aria2c.exe). It was not cleanly separable by path, so it is included here rather than split out. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { useEffect, useState } from 'react'
|
|
import { logError } from '../../reportError'
|
|
|
|
export interface NetworkCardController {
|
|
mintingPot: boolean
|
|
potHint: string | null
|
|
clearPotHint: () => void
|
|
mintPoToken: () => Promise<void>
|
|
/** whether aria2c.exe shipped with this build; null while the check is in flight */
|
|
aria2cAvailable: boolean | null
|
|
}
|
|
|
|
/**
|
|
* View-model for the Network card's PO-token minting (L93/CC13): owns the fetch
|
|
* state and hint copy so the card stays presentational. Also probes whether the
|
|
* optional aria2c downloader is bundled, so the card can disable its toggle rather
|
|
* than leave a setting that silently does nothing.
|
|
*/
|
|
export function useNetworkCard(): NetworkCardController {
|
|
const [mintingPot, setMintingPot] = useState(false)
|
|
const [potHint, setPotHint] = useState<string | null>(null)
|
|
const [aria2cAvailable, setAria2cAvailable] = useState<boolean | null>(null)
|
|
|
|
useEffect(() => {
|
|
// Detect whether the optional aria2c downloader is bundled so the toggle can
|
|
// disable itself instead of silently doing nothing. A failed probe leaves the
|
|
// state null (unknown), which keeps the toggle enabled rather than wrongly
|
|
// disabling a working feature.
|
|
window.api.aria2cAvailable().then(setAria2cAvailable).catch(logError('aria2cAvailable'))
|
|
}, [])
|
|
|
|
async function mintPoToken(): Promise<void> {
|
|
setMintingPot(true)
|
|
setPotHint(null)
|
|
try {
|
|
const token = await window.api.mintPoToken()
|
|
if (token) {
|
|
setPotHint('Token saved.')
|
|
} else {
|
|
setPotHint('Token not found -- try signing into YouTube first via Cookies above.')
|
|
}
|
|
} catch {
|
|
setPotHint('Failed to open YouTube window.')
|
|
} finally {
|
|
setMintingPot(false)
|
|
}
|
|
}
|
|
|
|
return { mintingPot, potHint, clearPotHint: () => setPotHint(null), mintPoToken, aria2cAvailable }
|
|
}
|