Files
Ivan Fontosh d1f180ee0a Initial TTRPG character meta-builder with visual sheet editor.
Offline Electron app seeds 10 system presets, supports create-from-scratch designer with palette/drag/resize/bricks, and exports .ttrpg-system.json for the player.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 14:49:31 +08:00

33 lines
1.7 KiB
TypeScript

import { contextBridge, ipcRenderer } from 'electron';
import type { CharacterSheet, SystemDefinition } from '../shared/types.ts';
const api = {
listSystems: () => ipcRenderer.invoke('systems:list') as Promise<
Array<{ id: string; name: string; revision: number; schemaVersion: number }>
>,
getSystem: (id: string) => ipcRenderer.invoke('systems:get', id) as Promise<SystemDefinition | null>,
upsertSystem: (system: SystemDefinition) =>
ipcRenderer.invoke('systems:upsert', system) as Promise<SystemDefinition>,
deleteSystem: (id: string) => ipcRenderer.invoke('systems:delete', id) as Promise<boolean>,
exportSystem: (id: string) => ipcRenderer.invoke('systems:export', id) as Promise<string | null>,
importSystem: () => ipcRenderer.invoke('systems:import') as Promise<SystemDefinition | null>,
listPresets: () => ipcRenderer.invoke('presets:list') as Promise<string[]>,
loadPreset: (filePath: string) =>
ipcRenderer.invoke('presets:load', filePath) as Promise<SystemDefinition>,
seedPresets: () => ipcRenderer.invoke('presets:seed') as Promise<number>,
listCharacters: (systemId?: string) =>
ipcRenderer.invoke('characters:list', systemId) as Promise<
Array<{ id: string; name: string; systemId: string }>
>,
getCharacter: (id: string) =>
ipcRenderer.invoke('characters:get', id) as Promise<CharacterSheet | null>,
upsertCharacter: (character: CharacterSheet) =>
ipcRenderer.invoke('characters:upsert', character) as Promise<CharacterSheet>,
deleteCharacter: (id: string) => ipcRenderer.invoke('characters:delete', id) as Promise<boolean>,
};
contextBridge.exposeInMainWorld('ttrpgBuilder', api);
export type TtrpgBuilderApi = typeof api;