narraleaf
Version:
Create your visual novel with Electron and React
116 lines (115 loc) • 3.79 kB
TypeScript
import { AppConfig } from "../../../main/electron/app/config";
import { EventEmitter } from "events";
import { AppWindow, WindowConfig } from "../../../main/electron/app/appWindow";
import { PlatformInfo } from "../../../utils/pure/os";
import { Client } from "../../../utils/nodejs/websocket";
import { DevServerEvents } from "../../../core/dev/devServer";
import { SavedGame, SavedGameMetadata, SaveType } from "../../../core/game/save";
import { StoreProvider } from "../../../main/electron/app/save/storeProvider";
type AppEvents = {
"ready": [];
};
export type CrashReport = {
isCritical: true;
timestamp?: never;
reason?: never;
recoveryDisabled?: never;
} | {
isCritical: false;
timestamp: number;
reason: string;
recoveryDisabled: boolean;
};
export type AppEventToken = {
cancel(): void;
};
export type AppMeta = {
publicDir: string;
rootDir: string;
};
export declare enum AppDataNamespace {
save = "msg_storage",
flags = "app_flags"
}
export declare class App {
static Constants: {
readonly AppLifeCycleViolationTimeout: 5000;
};
static Events: {
readonly Ready: "ready";
};
readonly electronApp: Electron.App;
readonly events: EventEmitter<AppEvents>;
readonly platform: PlatformInfo;
devState: {
wsClient: Client<DevServerEvents> | null;
};
mainWindow: AppWindow | null;
saveStorage: StoreProvider;
config: AppConfig;
t: (key: string) => string;
private hooks;
private assets;
private metadata;
private schedules;
private flags;
private crashReport;
constructor(config: AppConfig);
onReady(fn: (...args: AppEvents["ready"]) => void): AppEventToken;
createWindow(config: Partial<WindowConfig>): AppWindow;
getConfig(): import("../../../main/electron/app/config").BaseAppConfig & (import("../../../main/electron/app/config").IWindowsConfig | import("../../../main/electron/app/config").ILinuxConfig | import("../../../main/electron/app/config").IMacConfig);
getCrashReport(): CrashReport | null;
getPreloadScript(): string;
getEntryFile(): string;
getPublicDir(): string;
/**
* Returns the build directory of the app
*
* For example, under development mode, it returns the directory of the `.narraleaf` folder which contains `app-dev`
* Under production mode, it returns the directory of the app.asar file which contains `app-build` and `package.json`
*
* The structure of the build directory
*/
getAppPath(): string;
getRendererBuildDir(): string;
/**
* Quit the app without any error
*/
quit(): void;
/**
* Quit the app and create a crash report
*
* If the reason is not provided, the crash will be considered critical
*/
crash(reason?: string, { disableRecovery }?: {
disableRecovery?: boolean;
}): void;
launchApp(config?: Partial<WindowConfig>): Promise<AppWindow>;
isPackaged(): boolean;
getUserDataDir(): string;
saveGameData(data: SavedGame, type: SaveType, id: string, preview?: string): Promise<void>;
readGameData(id: string): Promise<SavedGame>;
listGameData(): Promise<SavedGameMetadata[]>;
deleteGameData(id: string): Promise<void>;
private crashReason;
private getFsFlags;
private consumeCrashReport;
private prepareCrashHelper;
private getSavedGameMetadata;
private prepareMainWindow;
private prepare;
private prepareDevMode;
private prepareMenu;
private prepareWebAssets;
private hook;
private onceHook;
private unhook;
private emitHook;
private fetchMetadata;
private readFile;
private getMetadata;
private emit;
private schedule;
private timeout;
}
export {};