2022-02-25 00:24:49 +08:00
|
|
|
import { CommandDef } from "./plugins/types";
|
|
|
|
|
2022-02-26 20:26:31 +08:00
|
|
|
export type PageMeta = {
|
2022-02-21 20:25:41 +08:00
|
|
|
name: string;
|
2022-02-25 22:34:00 +08:00
|
|
|
lastModified: Date;
|
|
|
|
created?: boolean;
|
2022-02-21 20:25:41 +08:00
|
|
|
};
|
|
|
|
|
2022-02-22 21:18:37 +08:00
|
|
|
export type AppCommand = {
|
2022-02-25 00:24:49 +08:00
|
|
|
command: CommandDef;
|
2022-02-26 20:26:31 +08:00
|
|
|
run: (arg: any) => Promise<any>;
|
2022-02-23 21:09:26 +08:00
|
|
|
};
|
2022-02-22 21:18:37 +08:00
|
|
|
|
2022-02-21 20:25:41 +08:00
|
|
|
export type AppViewState = {
|
2022-02-26 20:26:31 +08:00
|
|
|
currentPage?: PageMeta;
|
2022-02-21 20:25:41 +08:00
|
|
|
isSaved: boolean;
|
2022-02-26 20:26:31 +08:00
|
|
|
showPageNavigator: boolean;
|
2022-02-22 21:18:37 +08:00
|
|
|
showCommandPalette: boolean;
|
2022-02-26 20:26:31 +08:00
|
|
|
allPages: PageMeta[];
|
2022-02-25 00:24:49 +08:00
|
|
|
commands: Map<string, AppCommand>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const initialViewState: AppViewState = {
|
|
|
|
isSaved: false,
|
2022-02-26 20:26:31 +08:00
|
|
|
showPageNavigator: false,
|
2022-02-25 00:24:49 +08:00
|
|
|
showCommandPalette: false,
|
2022-02-26 20:26:31 +08:00
|
|
|
allPages: [],
|
2022-02-25 00:24:49 +08:00
|
|
|
commands: new Map(),
|
2022-02-21 20:25:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export type Action =
|
2022-02-26 20:26:31 +08:00
|
|
|
| { type: "page-loaded"; meta: PageMeta }
|
|
|
|
| { type: "page-saved"; meta: PageMeta }
|
|
|
|
| { type: "page-updated" }
|
|
|
|
| { type: "pages-listed"; pages: PageMeta[] }
|
2022-02-21 20:25:41 +08:00
|
|
|
| { type: "start-navigate" }
|
|
|
|
| { type: "stop-navigate" }
|
2022-02-25 00:24:49 +08:00
|
|
|
| { type: "update-commands"; commands: Map<string, AppCommand> }
|
2022-02-22 21:18:37 +08:00
|
|
|
| { type: "show-palette" }
|
2022-02-23 21:09:26 +08:00
|
|
|
| { type: "hide-palette" };
|