Skip to content

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

1.2 KB
Raw Blame
export interface InstalledBrowser {
  id: string;
  name: string;
}
export interface SiteBrowserState {
  url: string;
  title: string;
  loading: boolean;
  canGoBack: boolean;
  canGoForward: boolean;
  error: boolean;
}
export interface SiteBrowserBridge {
  open(url: string): Promise<void>;
  close(): Promise<void>;
  state(): Promise<SiteBrowserState | null>;
  navigate(url: string): Promise<void>;
  command(action: 'back' | 'forward' | 'reload' | 'stop'): Promise<void>;
  bounds(rect: SiteBrowserBounds): Promise<void>;
  installed(): Promise<InstalledBrowser[]>;
  openExternal(id: string): Promise<void>;
  onState(callback: (state: SiteBrowserState | null) => void): () => void;
}

export interface SiteBrowserBounds {
  x: number;
  y: number;
  width: number;
  height: number;
}

export function browserUrl(input: unknown): string {
  if (typeof input !== 'string' || !input.trim() || input.length > 8192)
    throw new Error('Invalid URL');
  const value = input.trim();
  const url = new URL(/^[a-z][a-z\d+.-]*:/i.test(value) ? value : `https://${value}`);
  if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
    throw new Error('Only HTTP and HTTPS websites are supported');
  return url.href;
}