| 1 | import { DesktopCliCommandStateSchema } from "@t3tools/contracts"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Schema from "effect/Schema"; |
| 4 | |
| 5 | import * as DesktopCliCommand from "../../app/DesktopCliCommand.ts"; |
| 6 | import * as IpcChannels from "../channels.ts"; |
| 7 | import { makeIpcMethod } from "../DesktopIpc.ts"; |
| 8 | |
| 9 | export const getCliCommandState = makeIpcMethod({ |
| 10 | channel: IpcChannels.CLI_COMMAND_GET_STATE_CHANNEL, |
| 11 | payload: Schema.Void, |
| 12 | result: DesktopCliCommandStateSchema, |
| 13 | handler: Effect.fn("desktop.ipc.cliCommand.getState")(function* () { |
| 14 | return yield* (yield* DesktopCliCommand.DesktopCliCommand).state; |
| 15 | }), |
| 16 | }); |
| 17 | |
| 18 | export const installCliCommand = makeIpcMethod({ |
| 19 | channel: IpcChannels.CLI_COMMAND_INSTALL_CHANNEL, |
| 20 | payload: Schema.Void, |
| 21 | result: DesktopCliCommandStateSchema, |
| 22 | handler: Effect.fn("desktop.ipc.cliCommand.install")(function* () { |
| 23 | return yield* (yield* DesktopCliCommand.DesktopCliCommand).install; |
| 24 | }), |
| 25 | }); |
| 26 | |
| 27 | export const uninstallCliCommand = makeIpcMethod({ |
| 28 | channel: IpcChannels.CLI_COMMAND_UNINSTALL_CHANNEL, |
| 29 | payload: Schema.Void, |
| 30 | result: DesktopCliCommandStateSchema, |
| 31 | handler: Effect.fn("desktop.ipc.cliCommand.uninstall")(function* () { |
| 32 | return yield* (yield* DesktopCliCommand.DesktopCliCommand).uninstall; |
| 33 | }), |
| 34 | }); |