|
1 | 1 | import {App, Format} from './base';
|
2 |
| -import {ConversionStatus} from './conversion-options'; |
| 2 | +import {ExportStatus} from './conversion-options'; |
| 3 | + |
| 4 | +// eslint-disable-next-line @typescript-eslint/ban-types |
| 5 | +export type RemoteState<State = any, Actions extends Record<string, (...args: any[]) => any> = {}> = { |
| 6 | + actions: Actions; |
| 7 | + state: State; |
| 8 | +}; |
| 9 | + |
| 10 | +export type RemoteStateHook<Base extends RemoteState> = Base extends RemoteState<infer State, infer Actions> ? ( |
| 11 | + Actions & { |
| 12 | + state: State; |
| 13 | + isLoading: boolean; |
| 14 | + refreshState: () => void; |
| 15 | + } |
| 16 | +) : never; |
| 17 | + |
| 18 | +export type RemoteStateHandler<Base extends RemoteState> = Base extends RemoteState<infer State, infer Actions> ? (sendUpdate: (state: State, id?: string) => void) => { |
| 19 | + actions: { |
| 20 | + [Key in keyof Actions]: Actions[Key] extends (...args: any[]) => any ? (id: string, ...args: Parameters<Actions[Key]>) => void : never |
| 21 | + }; |
| 22 | + getState: (id: string) => State | undefined; |
| 23 | +} : never; |
3 | 24 |
|
4 | 25 | export interface ExportOptionsPlugin {
|
5 | 26 | title: string;
|
@@ -29,34 +50,40 @@ export type ExportOptions = {
|
29 | 50 | fpsHistory: {[key in Format]: number};
|
30 | 51 | };
|
31 | 52 |
|
32 |
| -export type EditorOptionsRemoteState = (sendUpdate: (state: ExportOptions) => void) => { |
33 |
| - actions: { |
34 |
| - updatePluginUsage: ({format, plugin}: { |
35 |
| - format: Format; |
36 |
| - plugin: string; |
37 |
| - }) => void; |
38 |
| - updateFpsUsage: ({format, fps}: { |
39 |
| - format: Format; |
40 |
| - fps: number; |
41 |
| - }) => void; |
42 |
| - }; |
43 |
| - getState: () => ExportOptions; |
44 |
| -}; |
| 53 | +export type EditorOptionsRemoteState = RemoteState<ExportOptions, { |
| 54 | + updatePluginUsage: ({format, plugin}: { |
| 55 | + format: Format; |
| 56 | + plugin: string; |
| 57 | + }) => void; |
| 58 | + updateFpsUsage: ({format, fps}: { |
| 59 | + format: Format; |
| 60 | + fps: number; |
| 61 | + }) => void; |
| 62 | +}>; |
45 | 63 |
|
46 |
| -export interface ConversionState { |
| 64 | +export interface ExportState { |
| 65 | + id: string; |
47 | 66 | title: string;
|
48 | 67 | description: string;
|
49 | 68 | message: string;
|
50 | 69 | progress?: number;
|
51 |
| - size?: string; |
52 |
| - status: ConversionStatus; |
| 70 | + image?: string; |
| 71 | + filePath?: string; |
| 72 | + error?: Error; |
| 73 | + fileSize?: string; |
| 74 | + status: ExportStatus; |
53 | 75 | canCopy: boolean;
|
| 76 | + disableOutputActions: boolean; |
| 77 | + canPreviewExport: boolean; |
| 78 | + titleWithFormat: string; |
54 | 79 | }
|
55 | 80 |
|
56 |
| -export type ConversionRemoteState = (sendUpdate: (state: ConversionState, id: string) => void) => { |
57 |
| - actions: { |
58 |
| - copy: (_?: undefined, conversionId?: string) => void; |
59 |
| - cancel: (_?: undefined, conversionId?: string) => void; |
60 |
| - }; |
61 |
| - getState: (conversionId: string) => ConversionState | undefined; |
62 |
| -}; |
| 81 | +export type ExportsRemoteState = RemoteState<ExportState, { |
| 82 | + copy: () => void; |
| 83 | + cancel: () => void; |
| 84 | + retry: () => void; |
| 85 | + openInEditor: () => void; |
| 86 | + showInFolder: () => void; |
| 87 | +}>; |
| 88 | + |
| 89 | +export type ExportsListRemoteState = RemoteState<string[]>; |
0 commit comments