fix extraction leak, dead deps, logging, and frontend races
This commit is contained in:
+47
-35
@@ -115,9 +115,29 @@
|
||||
let unlistenOverlayClosed: (() => void) | null = null
|
||||
|
||||
void (async () => {
|
||||
unlistenOverlayClosed = await listen("overlay-closed", () => {
|
||||
useFrame = false
|
||||
})
|
||||
const [overlayClosed, hotkey, progress, audio] = await Promise.all([
|
||||
listen("overlay-closed", () => { useFrame = false }),
|
||||
api.onHotkey((kind) => {
|
||||
if (kind === "start" && phase === "idle") void startRec()
|
||||
else if (kind === "pause") {
|
||||
if (phase === "recording") void pauseRec()
|
||||
else if (phase === "paused") void resumeRec()
|
||||
} else if (kind === "stop") {
|
||||
if (phase === "recording" || phase === "paused") void stopRec()
|
||||
}
|
||||
}),
|
||||
api.onEncodeProgress((p) => {
|
||||
encodeProgress = { pass: p.pass, total: p.total_passes, pct: p.percent }
|
||||
}),
|
||||
api.onAudioFailed((msg) => {
|
||||
audioWarning = msg || "audio capture failed - audio will not be recorded"
|
||||
}),
|
||||
])
|
||||
unlistenOverlayClosed = overlayClosed
|
||||
unlistenHotkey = hotkey
|
||||
unlistenProgress = progress
|
||||
unlistenAudio = audio
|
||||
|
||||
try {
|
||||
config = await api.getConfig()
|
||||
format = config.export.default_format
|
||||
@@ -127,22 +147,6 @@
|
||||
} catch (e) {
|
||||
console.warn("failed to load config:", e)
|
||||
}
|
||||
|
||||
unlistenHotkey = await api.onHotkey((kind) => {
|
||||
if (kind === "start" && phase === "idle") void startRec()
|
||||
else if (kind === "pause") {
|
||||
if (phase === "recording") void pauseRec()
|
||||
else if (phase === "paused") void resumeRec()
|
||||
} else if (kind === "stop") {
|
||||
if (phase === "recording" || phase === "paused") void stopRec()
|
||||
}
|
||||
})
|
||||
unlistenProgress = await api.onEncodeProgress((p) => {
|
||||
encodeProgress = { pass: p.pass, total: p.total_passes, pct: p.percent }
|
||||
})
|
||||
unlistenAudio = await api.onAudioFailed((msg) => {
|
||||
audioWarning = msg || "audio capture failed - audio will not be recorded"
|
||||
})
|
||||
})()
|
||||
return () => {
|
||||
unlistenHotkey?.()
|
||||
@@ -208,9 +212,12 @@
|
||||
}
|
||||
|
||||
async function resumeRec() {
|
||||
try { await api.resumeCapture(); phase = "recording"; tick() }
|
||||
catch (e) { errMsg = String(e) }
|
||||
void emit("recording-state", { phase: "recording", fps })
|
||||
try {
|
||||
await api.resumeCapture()
|
||||
phase = "recording"
|
||||
tick()
|
||||
void emit("recording-state", { phase: "recording", fps })
|
||||
} catch (e) { errMsg = String(e) }
|
||||
}
|
||||
|
||||
async function browseOutput() {
|
||||
@@ -398,9 +405,9 @@
|
||||
})
|
||||
|
||||
$effect(() => {
|
||||
if (phase === "editing" && !pathOverridden && format) {
|
||||
void api.defaultOutputPath(format).then(p => { if (!pathOverridden) outputPath = p })
|
||||
}
|
||||
const f = format
|
||||
if (phase !== "editing" || pathOverridden || !f) return
|
||||
void api.defaultOutputPath(f).then(p => { if (!pathOverridden) outputPath = p })
|
||||
})
|
||||
|
||||
// Auto-dismiss error toast
|
||||
@@ -421,12 +428,13 @@
|
||||
phase === "done" ? "DONE" : ""
|
||||
)
|
||||
|
||||
let phaseColor = $derived(
|
||||
phase === "recording" ? "var(--recording)" :
|
||||
phase === "paused" ? "var(--warn)" :
|
||||
phase === "done" ? "var(--accent)" :
|
||||
"var(--text-3)"
|
||||
)
|
||||
let phaseColor: string = $derived.by(() => {
|
||||
const p: string = phase
|
||||
return p === "recording" ? "var(--recording)" :
|
||||
p === "paused" ? "var(--warn)" :
|
||||
p === "done" ? "var(--accent)" :
|
||||
"var(--text-3)"
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="app">
|
||||
@@ -572,11 +580,15 @@
|
||||
</div>
|
||||
|
||||
<!-- Preview -->
|
||||
{#if (dragging && trimPreviewPath ? trimPreviewPath : previewPath)}
|
||||
{#if dragging && trimPreviewPath}
|
||||
<div class="preview-box">
|
||||
<img src={convertFileSrc(dragging && trimPreviewPath ? trimPreviewPath : previewPath) + "?t=" + (dragging && trimPreviewPath ? trimPreviewBust : previewCacheBust)} alt="preview frame" class="preview-img"/>
|
||||
{#if previewLoading && !dragging}<div class="preview-loading">rendering</div>{/if}
|
||||
{#if dragging}<div class="preview-loading">original</div>{/if}
|
||||
<img src={convertFileSrc(trimPreviewPath) + "?t=" + trimPreviewBust} alt="preview frame" class="preview-img"/>
|
||||
<div class="preview-loading">original</div>
|
||||
</div>
|
||||
{:else if previewPath}
|
||||
<div class="preview-box">
|
||||
<img src={convertFileSrc(previewPath) + "?t=" + previewCacheBust} alt="preview frame" class="preview-img"/>
|
||||
{#if previewLoading}<div class="preview-loading">rendering</div>{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="preview-box empty">
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
.overlay {
|
||||
box-sizing: border-box;
|
||||
height: 100vh; width: 100vw;
|
||||
border: 2px solid #14B8A6;
|
||||
border: 2px solid var(--accent);
|
||||
display: flex; flex-direction: column;
|
||||
background: transparent;
|
||||
border-radius: var(--r-sm);
|
||||
@@ -192,14 +192,14 @@
|
||||
border-color: rgba(20, 184, 166, 0.25);
|
||||
color: rgba(20, 184, 166, 0.7);
|
||||
}
|
||||
.pick-btn:hover { background: rgba(20, 184, 166, 0.18); border-color: rgba(20, 184, 166, 0.5); color: #14B8A6; }
|
||||
.pick-btn:hover { background: rgba(20, 184, 166, 0.18); border-color: rgba(20, 184, 166, 0.5); color: var(--accent); }
|
||||
|
||||
.close-btn {
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
border-color: rgba(239, 68, 68, 0.25);
|
||||
color: rgba(239, 68, 68, 0.7);
|
||||
}
|
||||
.close-btn:hover { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.5); color: #EF4444; }
|
||||
.close-btn:hover { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.5); color: var(--stop); }
|
||||
|
||||
.status {
|
||||
margin-left: 4px;
|
||||
@@ -214,7 +214,7 @@
|
||||
}
|
||||
.status.recording {
|
||||
background: rgba(34, 197, 94, 0.15);
|
||||
color: #22C55E;
|
||||
color: var(--recording);
|
||||
}
|
||||
.sep { opacity: 0.3; }
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte"
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
|
||||
import { listen } from "@tauri-apps/api/event"
|
||||
import { listen, emit } from "@tauri-apps/api/event"
|
||||
|
||||
type Rect = { x: number; y: number; width: number; height: number }
|
||||
|
||||
@@ -87,13 +87,13 @@
|
||||
.frame {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
border: 2px solid #14B8A6;
|
||||
border: 2px solid var(--accent);
|
||||
background: transparent;
|
||||
background-image:
|
||||
repeating-linear-gradient(90deg, #14B8A6 0px, #14B8A6 8px, transparent 8px, transparent 12px),
|
||||
repeating-linear-gradient(0deg, #14B8A6 0px, #14B8A6 8px, transparent 8px, transparent 12px),
|
||||
repeating-linear-gradient(90deg, #14B8A6 0px, #14B8A6 8px, transparent 8px, transparent 12px),
|
||||
repeating-linear-gradient(0deg, #14B8A6 0px, #14B8A6 8px, transparent 8px, transparent 12px);
|
||||
repeating-linear-gradient(90deg, var(--accent) 0px, var(--accent) 8px, transparent 8px, transparent 12px),
|
||||
repeating-linear-gradient(0deg, var(--accent) 0px, var(--accent) 8px, transparent 8px, transparent 12px),
|
||||
repeating-linear-gradient(90deg, var(--accent) 0px, var(--accent) 8px, transparent 8px, transparent 12px),
|
||||
repeating-linear-gradient(0deg, var(--accent) 0px, var(--accent) 8px, transparent 8px, transparent 12px);
|
||||
background-position: 0 0, 0 0, 0 100%, 100% 0;
|
||||
background-size: 12px 2px, 2px 12px, 12px 2px, 2px 12px;
|
||||
background-repeat: repeat-x, repeat-y, repeat-x, repeat-y;
|
||||
@@ -109,7 +109,7 @@
|
||||
position: absolute;
|
||||
top: -20px; left: 0;
|
||||
padding: 2px 6px;
|
||||
background: #14B8A6;
|
||||
background: var(--accent);
|
||||
color: #020617;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
@@ -142,6 +142,6 @@
|
||||
border-radius: 2px;
|
||||
font-family: var(--mono, 'JetBrains Mono', monospace);
|
||||
font-size: 10px;
|
||||
color: #14B8A6;
|
||||
color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
|
||||
onMount(async () => { cfg = await api.getConfig(); initialCfg = structuredClone(cfg) })
|
||||
|
||||
$effect(() => {
|
||||
if (cfg) document.documentElement.setAttribute("data-theme", cfg.theme)
|
||||
})
|
||||
|
||||
async function save() {
|
||||
if (!cfg) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user