@nutteen/conductor-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ const electron = require("electron");
3
+ const CHANNELS = {
4
+ getFlows: "conductor:get-flows",
5
+ getWorkflow: "conductor:get-workflow",
6
+ getTickets: "conductor:get-tickets",
7
+ getTicket: "conductor:get-ticket",
8
+ getReport: "conductor:get-report",
9
+ getInitialView: "conductor:get-initial-view",
10
+ setTheme: "conductor:set-theme",
11
+ openWorkflowFile: "conductor:open-workflow-file",
12
+ revealPath: "conductor:reveal-path",
13
+ subscribe: "conductor:subscribe",
14
+ pushTickets: "conductor:push-tickets",
15
+ pushEvents: "conductor:push-events",
16
+ pushWorkflow: "conductor:push-workflow",
17
+ // Lifecycle and config. Each one is five mechanical edits — this list, a
18
+ // request/response type, a `ConductorBridge` method, a preload line and an
19
+ // `ipcMain.handle` — and because `App.test.tsx` builds a fully typed bridge, a
20
+ // missing stub is a compile error there rather than an empty panel at runtime.
21
+ preflight: "conductor:preflight",
22
+ startFlow: "conductor:start-flow",
23
+ stopFlow: "conductor:stop-flow",
24
+ restartFlow: "conductor:restart-flow",
25
+ getDaemonConfig: "conductor:get-daemon-config",
26
+ chooseDaemonConfig: "conductor:choose-daemon-config",
27
+ readFlowsConfig: "conductor:read-flows-config",
28
+ previewFlowsEdit: "conductor:preview-flows-edit",
29
+ commitFlowsEdit: "conductor:commit-flows-edit",
30
+ pushFlows: "conductor:push-flows",
31
+ pushDaemon: "conductor:push-daemon"
32
+ };
33
+ function storedTheme() {
34
+ const flag = process.argv.find((argument) => argument.startsWith("--conductor-theme="));
35
+ const value = flag?.slice("--conductor-theme=".length);
36
+ return value === "dark" || value === "light" ? value : null;
37
+ }
38
+ function subscribe(channel, handler) {
39
+ const listener = (_event, payload) => handler(payload);
40
+ electron.ipcRenderer.on(channel, listener);
41
+ return () => electron.ipcRenderer.removeListener(channel, listener);
42
+ }
43
+ const bridge = {
44
+ getFlows: () => electron.ipcRenderer.invoke(CHANNELS.getFlows),
45
+ getWorkflow: (input) => electron.ipcRenderer.invoke(CHANNELS.getWorkflow, input),
46
+ getTickets: (input) => electron.ipcRenderer.invoke(CHANNELS.getTickets, input),
47
+ getTicket: (input) => electron.ipcRenderer.invoke(CHANNELS.getTicket, input),
48
+ getReport: (input) => electron.ipcRenderer.invoke(CHANNELS.getReport, input),
49
+ getInitialView: () => electron.ipcRenderer.invoke(CHANNELS.getInitialView),
50
+ storedTheme: storedTheme(),
51
+ setTheme: (theme) => electron.ipcRenderer.invoke(CHANNELS.setTheme, theme),
52
+ openWorkflowFile: () => electron.ipcRenderer.invoke(CHANNELS.openWorkflowFile),
53
+ revealPath: (path) => electron.ipcRenderer.invoke(CHANNELS.revealPath, path),
54
+ subscribe: (input) => electron.ipcRenderer.invoke(CHANNELS.subscribe, input),
55
+ onTickets: (handler) => subscribe(CHANNELS.pushTickets, handler),
56
+ onEvents: (handler) => subscribe(CHANNELS.pushEvents, handler),
57
+ onWorkflow: (handler) => subscribe(CHANNELS.pushWorkflow, handler),
58
+ preflight: (input) => electron.ipcRenderer.invoke(CHANNELS.preflight, input),
59
+ startFlow: (input) => electron.ipcRenderer.invoke(CHANNELS.startFlow, input),
60
+ stopFlow: (input) => electron.ipcRenderer.invoke(CHANNELS.stopFlow, input),
61
+ restartFlow: (input) => electron.ipcRenderer.invoke(CHANNELS.restartFlow, input),
62
+ getDaemonConfig: () => electron.ipcRenderer.invoke(CHANNELS.getDaemonConfig),
63
+ chooseDaemonConfig: () => electron.ipcRenderer.invoke(CHANNELS.chooseDaemonConfig),
64
+ readFlowsConfig: () => electron.ipcRenderer.invoke(CHANNELS.readFlowsConfig),
65
+ previewFlowsEdit: (input) => electron.ipcRenderer.invoke(CHANNELS.previewFlowsEdit, input),
66
+ commitFlowsEdit: (input) => electron.ipcRenderer.invoke(CHANNELS.commitFlowsEdit, input),
67
+ onFlows: (handler) => subscribe(CHANNELS.pushFlows, handler),
68
+ onDaemon: (handler) => subscribe(CHANNELS.pushDaemon, handler)
69
+ };
70
+ electron.contextBridge.exposeInMainWorld("conductor", bridge);