i think i got step one working

This commit is contained in:
2026-03-25 01:22:30 -06:00
parent 4230ae6cb9
commit b4bcb8f3f2
14 changed files with 5932 additions and 32 deletions

View File

@ -0,0 +1,71 @@
/**
* tauri-bridge.ts
*
* Polyfills window.electronAPI with Tauri equivalents so all existing
* call-sites in App.tsx, hooks, and stores continue to work unchanged.
*
* Imported once at the top of main.tsx.
*/
import { invoke } from '@tauri-apps/api/core';
import { open, save } from '@tauri-apps/plugin-dialog';
import { readTextFile, writeTextFile } from '@tauri-apps/plugin-fs';
const VIDEO_FILTERS = [
{ name: 'Video Files', extensions: ['mp4', 'avi', 'mov', 'mkv', 'webm'] },
{ name: 'Audio Files', extensions: ['m4a', 'wav', 'mp3', 'flac'] },
{ name: 'All Files', extensions: ['*'] },
];
const PROJECT_FILTERS = [
{ name: 'TalkEdit Project', extensions: ['aive'] },
];
const EXPORT_FILTERS = [
{ name: 'Video Files', extensions: ['mp4', 'mov', 'webm'] },
{ name: 'Project Files', extensions: ['aive'] },
];
window.electronAPI = {
openFile: async (_options?: Record<string, unknown>): Promise<string | null> => {
const result = await open({
multiple: false,
filters: VIDEO_FILTERS,
});
return typeof result === 'string' ? result : null;
},
saveFile: async (_options?: Record<string, unknown>): Promise<string | null> => {
const result = await save({ filters: EXPORT_FILTERS });
return result ?? null;
},
openProject: async (): Promise<string | null> => {
const result = await open({
multiple: false,
filters: PROJECT_FILTERS,
});
return typeof result === 'string' ? result : null;
},
getBackendUrl: (): Promise<string> => {
return invoke<string>('get_backend_url');
},
encryptString: (data: string): Promise<string> => {
return invoke<string>('encrypt_string', { data });
},
decryptString: (encrypted: string): Promise<string> => {
return invoke<string>('decrypt_string', { encrypted });
},
readFile: (path: string): Promise<string> => {
return readTextFile(path);
},
writeFile: async (path: string, content: string): Promise<boolean> => {
await writeTextFile(path, content);
return true;
},
};

View File

@ -1,5 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
// Must be imported before App so window.electronAPI is patched before any component runs.
import './lib/tauri-bridge';
import App from './App';
import './index.css';