init
This commit is contained in:
commit
42ef2f9674
468 files changed
+645161
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>ClipForge</title>
|
||||
<link rel="stylesheet" href="./styles.css" />
|
||||
<script type="module" src="./src/main.ts"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
+672
@@ -0,0 +1,672 @@
|
||||
type RecordingState =
|
||||
| "WaitingForGame"
|
||||
| "Buffering"
|
||||
| "RecordingSession"
|
||||
| "Clipping"
|
||||
| "Processing"
|
||||
| "StorageLow";
|
||||
|
||||
type ClipSource = "Auto Event" | "Manual Hotkey" | "Bookmark" | "Imported";
|
||||
type UploadState = "Local only" | "Uploaded" | "Failed" | "Queued";
|
||||
|
||||
type Clip = {
|
||||
id: string;
|
||||
title: string;
|
||||
game: string;
|
||||
event: string;
|
||||
source: ClipSource;
|
||||
duration: string;
|
||||
createdAt: string;
|
||||
uploadState: UploadState;
|
||||
path: string;
|
||||
tags: string[];
|
||||
colorClass: string;
|
||||
};
|
||||
|
||||
type AutoEvent = {
|
||||
id: string;
|
||||
game: string;
|
||||
event: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
type DesktopStatus = {
|
||||
recording_state: RecordingState;
|
||||
detected_game: string | null;
|
||||
replay_buffer_seconds: number;
|
||||
mic_enabled: boolean;
|
||||
upload_enabled: boolean;
|
||||
session_recording: boolean;
|
||||
capture_active: boolean;
|
||||
capture_path: string | null;
|
||||
clip_count: number;
|
||||
library_root: string;
|
||||
ffmpeg_available: boolean;
|
||||
ffmpeg_path: string | null;
|
||||
};
|
||||
|
||||
type ClipDto = {
|
||||
id: string;
|
||||
title: string;
|
||||
game: string;
|
||||
event: string;
|
||||
source: ClipSource;
|
||||
duration: string;
|
||||
created_at: string;
|
||||
upload_state: UploadState;
|
||||
path: string;
|
||||
tags: string[];
|
||||
color_class: string;
|
||||
};
|
||||
|
||||
type AppState = {
|
||||
activeView: "Library" | "Recording" | "Auto Clip" | "Uploads" | "Settings";
|
||||
recordingState: RecordingState;
|
||||
detectedGame: string;
|
||||
replayBufferSeconds: number;
|
||||
sessionRecording: boolean;
|
||||
captureActive: boolean;
|
||||
capturePath: string | null;
|
||||
ffmpegAvailable: boolean;
|
||||
ffmpegPath: string | null;
|
||||
micEnabled: boolean;
|
||||
autoUpload: boolean;
|
||||
selectedClipId: string;
|
||||
clips: Clip[];
|
||||
autoEvents: AutoEvent[];
|
||||
};
|
||||
|
||||
type TauriGlobal = {
|
||||
core?: {
|
||||
invoke?: <T>(command: string, args?: Record<string, unknown>) => Promise<T>;
|
||||
};
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI__?: TauriGlobal;
|
||||
__TAURI_INTERNALS__?: unknown;
|
||||
}
|
||||
}
|
||||
|
||||
let tauriInvoke: (<T>(command: string, args?: Record<string, unknown>) => Promise<T>) | null = null;
|
||||
|
||||
const state: AppState = {
|
||||
activeView: "Library",
|
||||
recordingState: "Buffering",
|
||||
detectedGame: "Counter-Strike 2",
|
||||
replayBufferSeconds: 60,
|
||||
sessionRecording: false,
|
||||
captureActive: false,
|
||||
capturePath: null,
|
||||
ffmpegAvailable: false,
|
||||
ffmpegPath: null,
|
||||
micEnabled: false,
|
||||
autoUpload: false,
|
||||
selectedClipId: "clip-1",
|
||||
clips: [
|
||||
{
|
||||
id: "clip-1",
|
||||
title: "Dust II clutch",
|
||||
game: "Counter-Strike 2",
|
||||
event: "Kill",
|
||||
source: "Auto Event",
|
||||
duration: "0:18",
|
||||
createdAt: "Today 12:08",
|
||||
uploadState: "Local only",
|
||||
path: "",
|
||||
tags: ["clutch", "kill"],
|
||||
colorClass: "kill",
|
||||
},
|
||||
{
|
||||
id: "clip-2",
|
||||
title: "Baron steal",
|
||||
game: "League of Legends",
|
||||
event: "Objective",
|
||||
source: "Auto Event",
|
||||
duration: "0:22",
|
||||
createdAt: "Today 11:44",
|
||||
uploadState: "Queued",
|
||||
path: "",
|
||||
tags: ["objective"],
|
||||
colorClass: "objective",
|
||||
},
|
||||
{
|
||||
id: "clip-3",
|
||||
title: "Manual save",
|
||||
game: "Dota 2",
|
||||
event: "Manual",
|
||||
source: "Manual Hotkey",
|
||||
duration: "1:00",
|
||||
createdAt: "Yesterday 22:15",
|
||||
uploadState: "Uploaded",
|
||||
path: "",
|
||||
tags: ["teamfight"],
|
||||
colorClass: "manual",
|
||||
},
|
||||
],
|
||||
autoEvents: [
|
||||
{ id: "cs2-kill", game: "Counter-Strike 2", event: "Kill", enabled: true },
|
||||
{ id: "cs2-round", game: "Counter-Strike 2", event: "Round win", enabled: true },
|
||||
{ id: "lol-kill", game: "League of Legends", event: "Champion kill", enabled: true },
|
||||
{ id: "lol-objective", game: "League of Legends", event: "Objective", enabled: true },
|
||||
{ id: "dota-objective", game: "Dota 2", event: "Roshan/objective", enabled: false },
|
||||
],
|
||||
};
|
||||
|
||||
const root = document.querySelector<HTMLDivElement>("#app");
|
||||
|
||||
if (!root) {
|
||||
throw new Error("Missing #app root");
|
||||
}
|
||||
|
||||
const appRoot = root;
|
||||
|
||||
function render() {
|
||||
const selectedClip = state.clips.find((clip) => clip.id === state.selectedClipId) ?? state.clips[0];
|
||||
appRoot.innerHTML = `
|
||||
<main class="app-shell">
|
||||
<aside class="sidebar" aria-label="Primary">
|
||||
<div class="brand">
|
||||
<span class="brand-mark">CF</span>
|
||||
<span>ClipForge</span>
|
||||
</div>
|
||||
<nav>${["Library", "Recording", "Auto Clip", "Uploads", "Settings"]
|
||||
.map(
|
||||
(view) => `
|
||||
<button class="nav-item ${state.activeView === view ? "active" : ""}" data-view="${view}">
|
||||
${view}
|
||||
</button>
|
||||
`,
|
||||
)
|
||||
.join("")}</nav>
|
||||
</aside>
|
||||
|
||||
<section class="workspace">
|
||||
${renderRecordingBar()}
|
||||
${renderActiveView(selectedClip)}
|
||||
</section>
|
||||
</main>
|
||||
`;
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
function renderRecordingBar() {
|
||||
const statusText = state.captureActive
|
||||
? "Recording to disk"
|
||||
: state.sessionRecording
|
||||
? "Recording session"
|
||||
: `${state.recordingState} ${state.replayBufferSeconds}s`;
|
||||
return `
|
||||
<header class="recording-bar">
|
||||
<div>
|
||||
<p class="eyebrow">Detected game</p>
|
||||
<h1>${state.detectedGame}</h1>
|
||||
</div>
|
||||
<div class="meter-group" aria-label="Audio levels">
|
||||
<span class="meter"><i style="width: 72%"></i></span>
|
||||
<span class="meter"><i style="width: ${state.micEnabled ? 34 : 0}%"></i></span>
|
||||
</div>
|
||||
<div class="status-pill">${statusText}</div>
|
||||
<button class="icon-button" data-action="clip">Clip</button>
|
||||
<button class="record-button" data-action="toggle-record">${state.captureActive || state.sessionRecording ? "Stop" : "Record"}</button>
|
||||
</header>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderActiveView(selectedClip: Clip) {
|
||||
switch (state.activeView) {
|
||||
case "Recording":
|
||||
return renderRecordingView();
|
||||
case "Auto Clip":
|
||||
return renderAutoClipView();
|
||||
case "Uploads":
|
||||
return renderUploadsView();
|
||||
case "Settings":
|
||||
return renderSettingsView();
|
||||
case "Library":
|
||||
default:
|
||||
return renderLibraryView(selectedClip);
|
||||
}
|
||||
}
|
||||
|
||||
function renderLibraryView(selectedClip: Clip | undefined) {
|
||||
return `
|
||||
<section class="content-grid">
|
||||
<section class="library-panel">
|
||||
<div class="section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Local library</p>
|
||||
<h2>Recent Clips</h2>
|
||||
</div>
|
||||
<div class="segmented">
|
||||
<button class="selected">Grid</button>
|
||||
<button>List</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filters">
|
||||
<button class="selected">All</button>
|
||||
<button>Kills</button>
|
||||
<button>Wins</button>
|
||||
<button>Uploaded</button>
|
||||
</div>
|
||||
<div class="clip-grid">
|
||||
${state.clips.length > 0 ? state.clips.map(renderClipCard).join("") : `<div class="empty-state">No clips saved yet</div>`}
|
||||
</div>
|
||||
</section>
|
||||
${renderClipDetails(selectedClip)}
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
function clipFromDto(dto: ClipDto): Clip {
|
||||
return {
|
||||
id: dto.id,
|
||||
title: dto.title,
|
||||
game: dto.game,
|
||||
event: dto.event,
|
||||
source: dto.source,
|
||||
duration: dto.duration,
|
||||
createdAt: dto.created_at,
|
||||
uploadState: dto.upload_state,
|
||||
path: dto.path,
|
||||
tags: dto.tags,
|
||||
colorClass: dto.color_class,
|
||||
};
|
||||
}
|
||||
|
||||
function renderClipCard(clip: Clip) {
|
||||
return `
|
||||
<article class="clip-card ${state.selectedClipId === clip.id ? "selected" : ""}" data-clip-id="${clip.id}">
|
||||
<div class="thumb ${clip.colorClass}">${clip.event}</div>
|
||||
<h3>${clip.title}</h3>
|
||||
<p>${clip.game} · ${clip.source} · ${clip.duration}</p>
|
||||
</article>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderClipDetails(clip: Clip | undefined) {
|
||||
if (!clip) {
|
||||
return `
|
||||
<aside class="detail-panel">
|
||||
<div class="preview"><span>Preview</span></div>
|
||||
<h2>No clip selected</h2>
|
||||
<p class="muted">Start recording or press Clip to create the first local clip.</p>
|
||||
</aside>
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
<aside class="detail-panel">
|
||||
<div class="preview"><span>Preview</span></div>
|
||||
<h2>${clip.title}</h2>
|
||||
<p class="muted">${clip.game} · ${clip.event} · ${clip.createdAt} · ${clip.uploadState}</p>
|
||||
<div class="tag-row">${clip.tags.map((tag) => `<span>${tag}</span>`).join("")}</div>
|
||||
<p class="muted file-path">${clip.path || "Demo clip; no local file yet"}</p>
|
||||
<div class="trim-row">
|
||||
<label>Start <input value="00:00" data-action="trim-start" /></label>
|
||||
<label>End <input value="${clip.duration}" data-action="trim-end" /></label>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button data-action="process">Trim</button>
|
||||
<button data-action="reveal">Reveal</button>
|
||||
<button data-action="upload">Upload</button>
|
||||
<button data-action="delete">Delete</button>
|
||||
</div>
|
||||
<section class="auto-box">
|
||||
<h3>Auto clip policy</h3>
|
||||
<p>10s pre-roll · 8s post-roll · 12s merge window</p>
|
||||
</section>
|
||||
</aside>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderRecordingView() {
|
||||
return `
|
||||
<section class="settings-grid">
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Replay buffer</p>
|
||||
<h2>${state.replayBufferSeconds} seconds</h2>
|
||||
<input type="range" min="15" max="600" step="15" value="${state.replayBufferSeconds}" data-action="buffer-length" />
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Capture</p>
|
||||
<h2>720p30 Performance</h2>
|
||||
<p class="muted">Lightweight desktop capture uses bundled FFmpeg when system FFmpeg is missing.</p>
|
||||
<p class="muted">${state.ffmpegAvailable ? "FFmpeg ready" : "FFmpeg missing"}${state.ffmpegPath ? ` · ${state.ffmpegPath}` : ""}</p>
|
||||
<p class="muted">${state.capturePath ? `Writing ${state.capturePath}` : "No active capture file"}</p>
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Audio</p>
|
||||
<h2>System audio on</h2>
|
||||
<label class="toggle"><input type="checkbox" ${state.micEnabled ? "checked" : ""} data-action="toggle-mic" /> Mic capture</label>
|
||||
</article>
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderAutoClipView() {
|
||||
return `
|
||||
<section class="table-panel">
|
||||
<div class="section-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Game events</p>
|
||||
<h2>Auto Clip Rules</h2>
|
||||
</div>
|
||||
<div class="status-pill">Local APIs only</div>
|
||||
</div>
|
||||
<div class="event-list">
|
||||
${state.autoEvents
|
||||
.map(
|
||||
(event) => `
|
||||
<label class="event-row">
|
||||
<span><strong>${event.game}</strong><small>${event.event}</small></span>
|
||||
<input type="checkbox" ${event.enabled ? "checked" : ""} data-event-id="${event.id}" />
|
||||
</label>
|
||||
`,
|
||||
)
|
||||
.join("")}
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderUploadsView() {
|
||||
return `
|
||||
<section class="settings-grid">
|
||||
${["Catbox", "Litterbox", "Custom HTTP", "Lustful"].map((provider) => `
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Provider</p>
|
||||
<h2>${provider}</h2>
|
||||
<p class="muted">${provider === "Lustful" ? "Stubbed until API details are confirmed." : "Optional; local clips remain available if upload fails."}</p>
|
||||
<button>${provider === "Custom HTTP" ? "Configure" : "Enable"}</button>
|
||||
</article>
|
||||
`).join("")}
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderSettingsView() {
|
||||
return `
|
||||
<section class="settings-grid">
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Privacy</p>
|
||||
<h2>Local-first</h2>
|
||||
<label class="toggle"><input type="checkbox" ${state.autoUpload ? "checked" : ""} data-action="toggle-auto-upload" /> Auto-upload after clipping</label>
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Storage</p>
|
||||
<h2>50 GB cap</h2>
|
||||
<p class="muted">Old temporary buffer segments are removed automatically; saved clips are kept.</p>
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Hotkeys</p>
|
||||
<h2>F8 saves last 60s</h2>
|
||||
<p class="muted">Shift+F8 saves 30s · Alt+F7 toggles session recording.</p>
|
||||
</article>
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
function bindEvents() {
|
||||
appRoot.querySelectorAll<HTMLButtonElement>("[data-view]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
state.activeView = button.dataset.view as AppState["activeView"];
|
||||
render();
|
||||
});
|
||||
});
|
||||
|
||||
appRoot.querySelectorAll<HTMLElement>("[data-clip-id]").forEach((card) => {
|
||||
card.addEventListener("click", () => {
|
||||
state.selectedClipId = card.dataset.clipId ?? state.selectedClipId;
|
||||
render();
|
||||
});
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='clip']")?.addEventListener("click", () => {
|
||||
void saveClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='toggle-record']")?.addEventListener("click", () => {
|
||||
void toggleRecording();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='process']")?.addEventListener("click", () => {
|
||||
void trimSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='reveal']")?.addEventListener("click", () => {
|
||||
void revealSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='upload']")?.addEventListener("click", () => {
|
||||
void uploadSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='delete']")?.addEventListener("click", () => {
|
||||
void deleteSelectedClip();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='buffer-length']")?.addEventListener("input", (event) => {
|
||||
state.replayBufferSeconds = Number((event.target as HTMLInputElement).value);
|
||||
render();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='toggle-mic']")?.addEventListener("change", (event) => {
|
||||
state.micEnabled = (event.target as HTMLInputElement).checked;
|
||||
render();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLInputElement>("[data-action='toggle-auto-upload']")?.addEventListener("change", (event) => {
|
||||
state.autoUpload = (event.target as HTMLInputElement).checked;
|
||||
render();
|
||||
});
|
||||
|
||||
appRoot.querySelectorAll<HTMLInputElement>("[data-event-id]").forEach((input) => {
|
||||
input.addEventListener("change", () => {
|
||||
const eventRule = state.autoEvents.find((event) => event.id === input.dataset.eventId);
|
||||
if (eventRule) {
|
||||
eventRule.enabled = input.checked;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function saveClip() {
|
||||
state.recordingState = "Clipping";
|
||||
render();
|
||||
|
||||
if (tauriInvoke) {
|
||||
try {
|
||||
const dto = await tauriInvoke<ClipDto>("save_manual_clip", { seconds: state.replayBufferSeconds });
|
||||
const clip = clipFromDto(dto);
|
||||
state.clips.unshift(clip);
|
||||
state.selectedClipId = clip.id;
|
||||
state.activeView = "Library";
|
||||
state.recordingState = "Processing";
|
||||
await refreshClips();
|
||||
render();
|
||||
return;
|
||||
} catch (error) {
|
||||
console.error("Could not save desktop clip", error);
|
||||
}
|
||||
}
|
||||
|
||||
state.clips.unshift({
|
||||
id: `manual-${Date.now()}`,
|
||||
title: "Manual clip",
|
||||
game: state.detectedGame,
|
||||
event: "Manual",
|
||||
source: "Manual Hotkey",
|
||||
duration: "1:00",
|
||||
createdAt: "Just now",
|
||||
uploadState: "Local only",
|
||||
path: "",
|
||||
tags: ["manual"],
|
||||
colorClass: "manual",
|
||||
});
|
||||
state.selectedClipId = state.clips[0].id;
|
||||
state.activeView = "Library";
|
||||
render();
|
||||
}
|
||||
|
||||
async function toggleRecording() {
|
||||
if (tauriInvoke) {
|
||||
try {
|
||||
const status = await tauriInvoke<DesktopStatus>(state.captureActive ? "stop_capture" : "start_capture");
|
||||
applyDesktopStatus(status);
|
||||
await refreshClips();
|
||||
render();
|
||||
return;
|
||||
} catch (error) {
|
||||
console.error("Could not toggle desktop recording", error);
|
||||
}
|
||||
}
|
||||
|
||||
state.sessionRecording = !state.sessionRecording;
|
||||
state.recordingState = state.sessionRecording ? "RecordingSession" : "Buffering";
|
||||
render();
|
||||
}
|
||||
|
||||
function applyDesktopStatus(status: DesktopStatus) {
|
||||
state.recordingState = status.recording_state;
|
||||
state.detectedGame = status.detected_game ?? "Waiting for game";
|
||||
state.replayBufferSeconds = status.replay_buffer_seconds;
|
||||
state.micEnabled = status.mic_enabled;
|
||||
state.autoUpload = status.upload_enabled;
|
||||
state.sessionRecording = status.session_recording;
|
||||
state.captureActive = status.capture_active;
|
||||
state.capturePath = status.capture_path;
|
||||
state.ffmpegAvailable = status.ffmpeg_available;
|
||||
state.ffmpegPath = status.ffmpeg_path;
|
||||
}
|
||||
|
||||
async function trimSelectedClip() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clip = state.clips.find((candidate) => candidate.id === state.selectedClipId);
|
||||
if (!clip) {
|
||||
return;
|
||||
}
|
||||
|
||||
const startInput = appRoot.querySelector<HTMLInputElement>("[data-action='trim-start']");
|
||||
const endInput = appRoot.querySelector<HTMLInputElement>("[data-action='trim-end']");
|
||||
const startSeconds = parseTimestamp(startInput?.value ?? "0");
|
||||
const endSeconds = parseTimestamp(endInput?.value ?? clip.duration);
|
||||
|
||||
try {
|
||||
const dto = await tauriInvoke<ClipDto>("trim_clip", {
|
||||
clipId: clip.id,
|
||||
startSeconds,
|
||||
endSeconds,
|
||||
});
|
||||
const trimmed = clipFromDto(dto);
|
||||
state.clips.unshift(trimmed);
|
||||
state.selectedClipId = trimmed.id;
|
||||
await refreshClips();
|
||||
render();
|
||||
} catch (error) {
|
||||
console.error("Could not trim clip", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function revealSelectedClip() {
|
||||
if (!tauriInvoke || !state.selectedClipId) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await tauriInvoke("reveal_clip", { clipId: state.selectedClipId });
|
||||
} catch (error) {
|
||||
console.error("Could not reveal clip", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadSelectedClip() {
|
||||
if (!tauriInvoke || !state.selectedClipId) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const dto = await tauriInvoke<ClipDto>("upload_clip", { clipId: state.selectedClipId });
|
||||
const updated = clipFromDto(dto);
|
||||
state.clips = state.clips.map((clip) => (clip.id === updated.id ? updated : clip));
|
||||
render();
|
||||
} catch (error) {
|
||||
console.error("Could not queue upload", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSelectedClip() {
|
||||
if (!tauriInvoke || !state.selectedClipId) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const clips = await tauriInvoke<ClipDto[]>("delete_clip", { clipId: state.selectedClipId });
|
||||
state.clips = clips.map(clipFromDto);
|
||||
state.selectedClipId = state.clips[0]?.id ?? "";
|
||||
render();
|
||||
} catch (error) {
|
||||
console.error("Could not delete clip", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshClips() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clips = await tauriInvoke<ClipDto[]>("list_clips");
|
||||
state.clips = clips.map(clipFromDto);
|
||||
if (!state.clips.some((clip) => clip.id === state.selectedClipId)) {
|
||||
state.selectedClipId = state.clips[0]?.id ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
function parseTimestamp(value: string) {
|
||||
const parts = value.trim().split(":").map(Number);
|
||||
if (parts.some((part) => Number.isNaN(part))) {
|
||||
return 0;
|
||||
}
|
||||
if (parts.length === 1) {
|
||||
return parts[0];
|
||||
}
|
||||
if (parts.length === 2) {
|
||||
return parts[0] * 60 + parts[1];
|
||||
}
|
||||
return parts[0] * 3600 + parts[1] * 60 + parts[2];
|
||||
}
|
||||
|
||||
async function loadDesktopBridge() {
|
||||
const hasTauri = "__TAURI_INTERNALS__" in window;
|
||||
if (!hasTauri) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
tauriInvoke = window.__TAURI__?.core?.invoke ?? null;
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
const invoke = tauriInvoke;
|
||||
const status = await invoke<DesktopStatus>("get_status");
|
||||
applyDesktopStatus(status);
|
||||
const clips = await invoke<ClipDto[]>("list_clips");
|
||||
state.clips = clips.map(clipFromDto);
|
||||
state.selectedClipId = state.clips[0]?.id ?? "";
|
||||
render();
|
||||
} catch (error) {
|
||||
console.warn("Tauri bridge unavailable", error);
|
||||
}
|
||||
}
|
||||
|
||||
render();
|
||||
void loadDesktopBridge();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+442
@@ -0,0 +1,442 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
background: #101114;
|
||||
color: #f5f7fb;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: #101114;
|
||||
}
|
||||
|
||||
button,
|
||||
input {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.app-shell {
|
||||
display: grid;
|
||||
grid-template-columns: 220px minmax(0, 1fr);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
padding: 20px 14px;
|
||||
background: #17191f;
|
||||
border-right: 1px solid #2a2e38;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 28px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 8px;
|
||||
background: #6ee7b7;
|
||||
color: #111827;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.nav-item,
|
||||
.filters button,
|
||||
.segmented button,
|
||||
.actions button,
|
||||
.icon-button,
|
||||
.record-button {
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
color: #f5f7fb;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
width: 100%;
|
||||
padding: 11px 12px;
|
||||
text-align: left;
|
||||
color: #b8c0cc;
|
||||
}
|
||||
|
||||
.nav-item.active,
|
||||
.nav-item:hover {
|
||||
background: #232833;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.workspace {
|
||||
min-width: 0;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.recording-bar {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(220px, 1fr) 150px auto auto auto;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 8px;
|
||||
background: #191c24;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 4px;
|
||||
color: #8d99aa;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 0;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 6px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.meter-group {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.meter {
|
||||
display: block;
|
||||
height: 7px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: #29303c;
|
||||
}
|
||||
|
||||
.meter i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: #60a5fa;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
padding: 8px 11px;
|
||||
border-radius: 999px;
|
||||
background: #263142;
|
||||
color: #bcd7ff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.icon-button,
|
||||
.record-button,
|
||||
.actions button {
|
||||
padding: 10px 14px;
|
||||
background: #242a36;
|
||||
}
|
||||
|
||||
.record-button {
|
||||
background: #ef4444;
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 360px;
|
||||
gap: 18px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.library-panel,
|
||||
.detail-panel {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.section-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.segmented {
|
||||
display: flex;
|
||||
padding: 3px;
|
||||
border-radius: 8px;
|
||||
background: #1b2029;
|
||||
}
|
||||
|
||||
.segmented button {
|
||||
padding: 7px 10px;
|
||||
color: #aeb8c6;
|
||||
}
|
||||
|
||||
.segmented .selected,
|
||||
.filters .selected {
|
||||
background: #334155;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.filters button {
|
||||
padding: 8px 11px;
|
||||
background: #1b2029;
|
||||
color: #b7c1d0;
|
||||
}
|
||||
|
||||
.clip-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.clip-card {
|
||||
overflow: hidden;
|
||||
border: 1px solid #2b3140;
|
||||
border-radius: 8px;
|
||||
background: #191c24;
|
||||
}
|
||||
|
||||
.clip-card.selected {
|
||||
border-color: #6ee7b7;
|
||||
}
|
||||
|
||||
.clip-card h3,
|
||||
.clip-card p {
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.clip-card p,
|
||||
.muted {
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
.file-path {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
min-height: 160px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border: 1px dashed rgba(231, 237, 251, 0.2);
|
||||
border-radius: 8px;
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
.tag-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin: 14px 0 2px;
|
||||
}
|
||||
|
||||
.tag-row span {
|
||||
padding: 5px 8px;
|
||||
border-radius: 999px;
|
||||
background: #263142;
|
||||
color: #cfe0f7;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.thumb {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
height: 132px;
|
||||
margin-bottom: 12px;
|
||||
background: #243244;
|
||||
color: #e5e7eb;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.thumb.kill {
|
||||
background: linear-gradient(135deg, #1f2937, #7f1d1d);
|
||||
}
|
||||
|
||||
.thumb.objective {
|
||||
background: linear-gradient(135deg, #172554, #064e3b);
|
||||
}
|
||||
|
||||
.thumb.manual {
|
||||
background: linear-gradient(135deg, #312e81, #3f3f46);
|
||||
}
|
||||
|
||||
.detail-panel {
|
||||
padding: 14px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 8px;
|
||||
background: #191c24;
|
||||
}
|
||||
|
||||
.preview {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
aspect-ratio: 16 / 9;
|
||||
margin-bottom: 14px;
|
||||
border-radius: 8px;
|
||||
background: #0c0f14;
|
||||
color: #718096;
|
||||
}
|
||||
|
||||
.trim-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
color: #c7d0dd;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 9px 10px;
|
||||
border: 1px solid #313847;
|
||||
border-radius: 8px;
|
||||
background: #10141b;
|
||||
color: #f5f7fb;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.auto-box {
|
||||
margin-top: 18px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #2d3443;
|
||||
}
|
||||
|
||||
.auto-box p {
|
||||
margin-bottom: 0;
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
.settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 14px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.settings-panel,
|
||||
.table-panel {
|
||||
padding: 16px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 8px;
|
||||
background: #191c24;
|
||||
}
|
||||
|
||||
.settings-panel button {
|
||||
margin-top: 12px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid #374151;
|
||||
border-radius: 8px;
|
||||
background: #242a36;
|
||||
color: #f5f7fb;
|
||||
}
|
||||
|
||||
.toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
grid-auto-flow: column;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 8px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.toggle input,
|
||||
.event-row input {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.table-panel {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.event-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.event-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px;
|
||||
border: 1px solid #2c3140;
|
||||
border-radius: 8px;
|
||||
background: #12161d;
|
||||
}
|
||||
|
||||
.event-row span {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.event-row small {
|
||||
color: #9ba7b8;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.app-shell,
|
||||
.content-grid,
|
||||
.recording-bar {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #2a2e38;
|
||||
}
|
||||
|
||||
nav {
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user