Spaces:
Build error
Build error
Download frontend/src/lib/processEditHandoff.ts from shiva0013/YT-AI-Automation: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/spaces/shiva0013/YT-AI-Automation/resolve/main/frontend/src/lib/processEditHandoff.ts
- Command line
-
hf download hf://spaces/shiva0013/YT-AI-Automation/frontend/src/lib/processEditHandoff.ts
-
curl -L -o processEditHandoff.ts https://huggingface.co/spaces/shiva0013/YT-AI-Automation/resolve/main/frontend/src/lib/processEditHandoff.ts
1.66 kB
| import type { GenerateSettings } from '../api/types' | |
| import type { RunTool } from '../store/runs' | |
| export const PROCESS_EDIT_HANDOFF_KEY = 'textbro:process-edit-handoff:v1' | |
| export interface ReplacementTargets { | |
| runId?: string | |
| htmlFilename?: string | |
| screenshotFiles?: string[] | |
| presentationFile?: string | |
| videoFile?: string | |
| } | |
| export interface ProcessEditHandoff { | |
| tool: Exclude<RunTool, 'image-to-video' | 'screenshots-to-video' | 'youtube-screenshots'> | |
| text: string | |
| settings: GenerateSettings | |
| replaceTargets: ReplacementTargets | |
| } | |
| export function readProcessEditHandoff(): ProcessEditHandoff | null { | |
| if (typeof window === 'undefined') return null | |
| try { | |
| const raw = window.sessionStorage.getItem(PROCESS_EDIT_HANDOFF_KEY) | |
| if (!raw) return null | |
| const parsed = JSON.parse(raw) as unknown | |
| if (!parsed || typeof parsed !== 'object') return null | |
| const draft = parsed as Partial<ProcessEditHandoff> | |
| if ( | |
| draft.tool !== 'text-to-video' && | |
| draft.tool !== 'html-to-video' && | |
| draft.tool !== 'youtube-to-video' | |
| ) return null | |
| if (typeof draft.text !== 'string') return null | |
| return { | |
| tool: draft.tool, | |
| text: draft.text, | |
| settings: draft.settings ?? {}, | |
| replaceTargets: draft.replaceTargets ?? {}, | |
| } | |
| } catch { | |
| return null | |
| } | |
| } | |
| export function consumeProcessEditHandoff(tool: ProcessEditHandoff['tool']): ProcessEditHandoff | null { | |
| const draft = readProcessEditHandoff() | |
| if (!draft || draft.tool !== tool) return null | |
| try { | |
| window.sessionStorage.removeItem(PROCESS_EDIT_HANDOFF_KEY) | |
| } catch { | |
| /* ignore storage failures */ | |
| } | |
| return draft | |
| } | |