diff --git a/apps/desktop/src/effectRpcIpcPoc/example/browser-client.ts b/apps/desktop/src/effectRpcIpcPoc/example/browser-client.ts index 55fc503e40..ac85b7bc32 100644 --- a/apps/desktop/src/effectRpcIpcPoc/example/browser-client.ts +++ b/apps/desktop/src/effectRpcIpcPoc/example/browser-client.ts @@ -1,5 +1,4 @@ -import { AsyncResult, Atom } from "effect/unstable/reactivity"; -import { Cause, Effect, Option, Scope, Stream } from "effect"; +import { Effect, Scope, Stream } from "effect"; import { RpcClient } from "effect/unstable/rpc"; import type { RpcClientError } from "effect/unstable/rpc/RpcClientError"; @@ -19,67 +18,12 @@ import { type DesktopIpcPocTick, } from "./protocol.ts"; -// ----------------------------------------------------------------------------- -// example/preload.ts -// ----------------------------------------------------------------------------- -// The real preload file is intentionally tiny: -// -// import { contextBridge, ipcRenderer } from "electron"; -// import { exposeEffectElectronIpcPreloadBridge } from "effect-electron-ipc/preload"; -// -// exposeEffectElectronIpcPreloadBridge({ contextBridge, ipcRenderer }); -// -// That installs `window.effectElectronIpc`, which this browser module reads below. - -// ----------------------------------------------------------------------------- -// example/browser-react-runtime.ts -// ----------------------------------------------------------------------------- -// These declarations stand in for the actual React and @effect/atom-react imports -// a renderer bundle would use. The transport and Effect RPC client code below is -// real; only the UI runtime host is declared to keep this proof of concept small. - -type ReactElement = unknown; -type ReactNode = unknown; -type ReactComponent

> = (props: P) => ReactElement; -type ReactElementType

> = string | ReactComponent

; - -declare const React: { - readonly createElement:

( - type: ReactElementType

, - props?: P | null, - ...children: ReactNode[] - ) => ReactElement; -}; - -declare const createRoot: (container: Element) => { - readonly render: (element: ReactElement) => void; -}; - -declare const useAtomRefresh: (atom: Atom.Atom) => () => void; -declare const useAtomValue: (atom: Atom.Atom) => A; - -// ----------------------------------------------------------------------------- -// example/protocol.ts -// ----------------------------------------------------------------------------- -// The shared RPC contract lives in protocol.ts. Both the Electron main process -// and browser renderer import this contract, so the renderer gets a typed client -// without depending on Electron-specific implementation code. - export interface DesktopIpcPocSnapshot { readonly runtimeInfo: DesktopIpcPocRuntimeInfo; readonly echo: DesktopIpcPocEchoResult; readonly ticks: ReadonlyArray; } -// ----------------------------------------------------------------------------- -// example/browser-client.ts -// ----------------------------------------------------------------------------- -// This is the important browser-side transport step: -// -// preload bridge -> Effect Electron IPC renderer port -// -> Effect RPC RpcClient.Protocol -// -> typed DesktopIpcPocClient - export interface DesktopIpcPocBrowserClientOptions { readonly bridge?: EffectElectronIpcRendererBridge; readonly globalObject?: EffectElectronIpcBrowserGlobal; @@ -129,142 +73,3 @@ export const loadDesktopIpcPocSnapshot = ( export const loadDesktopIpcPocSnapshotFromBrowser = ( options: Omit = {}, ) => Effect.runPromise(Effect.scoped(loadDesktopIpcPocSnapshot(options))); - -// ----------------------------------------------------------------------------- -// example/browser-atoms.ts -// ----------------------------------------------------------------------------- -// These are the Effect Atom values the React layer consumes. The labels and SWR -// annotations are the important bit for app ergonomics: the RPC client and RPC -// query have stable, inspectable identities and refresh behavior. - -const DESKTOP_IPC_POC_SNAPSHOT_STALE_TIME_MS = 5_000; -const DESKTOP_IPC_POC_SNAPSHOT_IDLE_TTL_MS = 60_000; - -export const desktopIpcPocClientAtom = Atom.make(makeDesktopIpcPocBrowserClient()).pipe( - Atom.keepAlive, - Atom.withLabel("desktop-ipc-poc:effect-rpc-client"), -); - -export const desktopIpcPocSnapshotAtom = Atom.make( - loadDesktopIpcPocSnapshot({ - echoText: "hello from an Effect Atom", - ticks: 5, - }), -).pipe( - Atom.swr({ - staleTime: DESKTOP_IPC_POC_SNAPSHOT_STALE_TIME_MS, - revalidateOnMount: true, - }), - Atom.setIdleTTL(DESKTOP_IPC_POC_SNAPSHOT_IDLE_TTL_MS), - Atom.withLabel("desktop-ipc-poc:snapshot"), -); - -export const desktopIpcPocManualEchoAtom = Atom.make( - Effect.gen(function* () { - const client = yield* makeDesktopIpcPocBrowserClient(); - return yield* client[DESKTOP_IPC_POC_METHODS.echo]({ - text: "manual echo from an Atom-backed action", - }); - }), -).pipe(Atom.withLabel("desktop-ipc-poc:manual-echo")); - -// ----------------------------------------------------------------------------- -// example/components/DesktopIpcPocPanel.tsx -// ----------------------------------------------------------------------------- -// The React layer does not know about Electron IPC or RpcClient.Protocol. It only -// reads Atom values, renders AsyncResult states, and calls Atom refresh handlers. - -function formatAsyncResultError(result: AsyncResult.AsyncResult): string | null { - if (result._tag !== "Failure") { - return null; - } - const error = Cause.squash(result.cause); - return error instanceof Error ? error.message : String(error); -} - -function DesktopIpcPocClientStatus(): ReactElement { - const clientResult = useAtomValue(desktopIpcPocClientAtom); - const isReady = clientResult._tag === "Success"; - const label = isReady - ? "Effect RPC client ready" - : clientResult.waiting - ? "Connecting RPC client" - : "RPC client failed"; - - return React.createElement( - "span", - { - "data-state": isReady ? "ready" : clientResult._tag.toLowerCase(), - }, - label, - ); -} - -function RuntimeInfoView(props: { readonly runtimeInfo: DesktopIpcPocRuntimeInfo }): ReactElement { - return React.createElement( - "dl", - { "aria-label": "Runtime info" }, - React.createElement("dt", null, "App version"), - React.createElement("dd", null, props.runtimeInfo.appVersion), - React.createElement("dt", null, "Platform"), - React.createElement("dd", null, props.runtimeInfo.platform), - React.createElement("dt", null, "Transport"), - React.createElement("dd", null, props.runtimeInfo.ipcTransport), - ); -} - -function EchoView(props: { readonly echo: DesktopIpcPocEchoResult }): ReactElement { - return React.createElement("p", null, `Echoed "${props.echo.text}" at ${props.echo.echoedAt}`); -} - -function TickList(props: { readonly ticks: ReadonlyArray }): ReactElement { - return React.createElement( - "ol", - { "aria-label": "Streamed ticks" }, - ...props.ticks.map((tick) => - React.createElement("li", { key: tick.sequence }, `${tick.sequence}: ${tick.label}`), - ), - ); -} - -export function DesktopIpcPocPanel(): ReactElement { - const snapshotResult = useAtomValue(desktopIpcPocSnapshotAtom); - const refreshSnapshot = useAtomRefresh(desktopIpcPocSnapshotAtom); - const snapshot = Option.getOrNull(AsyncResult.value(snapshotResult)); - const error = formatAsyncResultError(snapshotResult); - - return React.createElement( - "section", - { "aria-label": "Effect Electron IPC proof of concept" }, - React.createElement("header", null, React.createElement(DesktopIpcPocClientStatus, null)), - React.createElement( - "button", - { - disabled: snapshotResult.waiting, - onClick: refreshSnapshot, - type: "button", - }, - snapshotResult.waiting ? "Refreshing" : "Refresh", - ), - error ? React.createElement("p", { role: "alert" }, error) : null, - snapshot - ? React.createElement( - "div", - null, - React.createElement(RuntimeInfoView, { runtimeInfo: snapshot.runtimeInfo }), - React.createElement(EchoView, { echo: snapshot.echo }), - React.createElement(TickList, { ticks: snapshot.ticks }), - ) - : React.createElement("p", null, "Loading desktop RPC data"), - ); -} - -// ----------------------------------------------------------------------------- -// example/renderer.tsx -// ----------------------------------------------------------------------------- -// The renderer entrypoint just mounts the React tree. The preload has already -// installed the bridge, and the Atom graph lazily creates the Effect RPC client. - -export function mountDesktopIpcPocReactExample(container: Element): void { - createRoot(container).render(React.createElement(DesktopIpcPocPanel, null)); -} diff --git a/apps/desktop/src/effectRpcIpcPoc/example/protocol.ts b/apps/desktop/src/effectRpcIpcPoc/example/protocol.ts index 35dd35aff1..3a5136bfe7 100644 --- a/apps/desktop/src/effectRpcIpcPoc/example/protocol.ts +++ b/apps/desktop/src/effectRpcIpcPoc/example/protocol.ts @@ -1,66 +1,12 @@ -import { Effect, Schema } from "effect"; +import { DesktopIpcPocRpcGroup } from "@t3tools/contracts/effectElectronIpcPoc"; +import { Effect } from "effect"; import { RpcClient } from "effect/unstable/rpc"; -import * as Rpc from "effect/unstable/rpc/Rpc"; -import * as RpcGroup from "effect/unstable/rpc/RpcGroup"; -export const DESKTOP_IPC_POC_METHODS = { - getRuntimeInfo: "desktop.poc.getRuntimeInfo", - echo: "desktop.poc.echo", - subscribeTicks: "desktop.poc.subscribeTicks", -} as const; - -export const DesktopIpcPocRuntimeInfo = Schema.Struct({ - appVersion: Schema.String, - platform: Schema.String, - ipcTransport: Schema.Literal("electron-ipc"), -}); -export type DesktopIpcPocRuntimeInfo = typeof DesktopIpcPocRuntimeInfo.Type; - -export const DesktopIpcPocEchoInput = Schema.Struct({ - text: Schema.String, -}); -export type DesktopIpcPocEchoInput = typeof DesktopIpcPocEchoInput.Type; - -export const DesktopIpcPocEchoResult = Schema.Struct({ - text: Schema.String, - echoedAt: Schema.String, -}); -export type DesktopIpcPocEchoResult = typeof DesktopIpcPocEchoResult.Type; - -export const DesktopIpcPocSubscribeTicksInput = Schema.Struct({ - take: Schema.Number, -}); -export type DesktopIpcPocSubscribeTicksInput = typeof DesktopIpcPocSubscribeTicksInput.Type; - -export const DesktopIpcPocTick = Schema.Struct({ - sequence: Schema.Number, - label: Schema.String, -}); -export type DesktopIpcPocTick = typeof DesktopIpcPocTick.Type; - -export const DesktopIpcPocGetRuntimeInfoRpc = Rpc.make(DESKTOP_IPC_POC_METHODS.getRuntimeInfo, { - payload: Schema.Struct({}), - success: DesktopIpcPocRuntimeInfo, -}); - -export const DesktopIpcPocEchoRpc = Rpc.make(DESKTOP_IPC_POC_METHODS.echo, { - payload: DesktopIpcPocEchoInput, - success: DesktopIpcPocEchoResult, -}); - -export const DesktopIpcPocSubscribeTicksRpc = Rpc.make(DESKTOP_IPC_POC_METHODS.subscribeTicks, { - payload: DesktopIpcPocSubscribeTicksInput, - success: DesktopIpcPocTick, - stream: true, -}); - -export const DesktopIpcPocRpcGroup = RpcGroup.make( - DesktopIpcPocGetRuntimeInfoRpc, - DesktopIpcPocEchoRpc, - DesktopIpcPocSubscribeTicksRpc, -); +export * from "@t3tools/contracts/effectElectronIpcPoc"; export const makeDesktopIpcPocClient = RpcClient.make(DesktopIpcPocRpcGroup); type DesktopIpcPocClientFactory = typeof makeDesktopIpcPocClient; export type DesktopIpcPocClient = - DesktopIpcPocClientFactory extends Effect.Effect ? Client : never; + DesktopIpcPocClientFactory extends Effect.Effect + ? Client + : never; diff --git a/apps/web/package.json b/apps/web/package.json index 7fa8818109..7adb7838dd 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -33,6 +33,7 @@ "@xterm/xterm": "^6.0.0", "class-variance-authority": "^0.7.1", "effect": "catalog:", + "effect-electron-ipc": "workspace:*", "lexical": "^0.41.0", "lucide-react": "^0.564.0", "react": "^19.0.0", diff --git a/apps/web/src/examples/effectElectronIpcPoc.tsx b/apps/web/src/examples/effectElectronIpcPoc.tsx new file mode 100644 index 0000000000..6d58be64c7 --- /dev/null +++ b/apps/web/src/examples/effectElectronIpcPoc.tsx @@ -0,0 +1,265 @@ +import { useAtomRefresh, useAtomValue } from "@effect/atom-react"; +import { + DESKTOP_IPC_POC_METHODS, + DesktopIpcPocRpcGroup, + type DesktopIpcPocEchoResult, + type DesktopIpcPocRuntimeInfo, + type DesktopIpcPocTick, +} from "@t3tools/contracts/effectElectronIpcPoc"; +import { Cause, Effect, Option, Scope, Stream } from "effect"; +import { AsyncResult, Atom } from "effect/unstable/reactivity"; +import { RpcClient } from "effect/unstable/rpc"; +import type { RpcClientError } from "effect/unstable/rpc/RpcClientError"; +import { + getEffectElectronIpcRendererBridge, + makeEffectElectronIpcRendererPort, + makeEffectElectronIpcRendererProtocol, + type EffectElectronIpcBrowserGlobal, +} from "effect-electron-ipc/client"; +import type { EffectElectronIpcRendererBridge } from "effect-electron-ipc/ipc"; +import { createRoot } from "react-dom/client"; +import type { ReactElement } from "react"; + +import { AppAtomRegistryProvider } from "../rpc/atomRegistry"; + +// ----------------------------------------------------------------------------- +// example/preload.ts +// ----------------------------------------------------------------------------- +// import { contextBridge, ipcRenderer } from "electron"; +// import { exposeEffectElectronIpcPreloadBridge } from "effect-electron-ipc/preload"; +// +// exposeEffectElectronIpcPreloadBridge({ contextBridge, ipcRenderer }); + +// ----------------------------------------------------------------------------- +// packages/contracts/src/effectElectronIpcPoc.ts +// ----------------------------------------------------------------------------- +// The shared contract owns only app-level RPC method names and schemas: +// +// DESKTOP_IPC_POC_METHODS +// DesktopIpcPocRuntimeInfo +// DesktopIpcPocEchoInput +// DesktopIpcPocEchoResult +// DesktopIpcPocSubscribeTicksInput +// DesktopIpcPocTick +// DesktopIpcPocRpcGroup +// +// The generic Electron transport package does not import these contracts. + +// ----------------------------------------------------------------------------- +// example/browser-client.ts +// ----------------------------------------------------------------------------- +// preload bridge -> Effect Electron IPC renderer port +// -> Effect RPC RpcClient.Protocol +// -> generated typed DesktopIpcPoc client + +const makeDesktopIpcPocClient = RpcClient.make(DesktopIpcPocRpcGroup); +type DesktopIpcPocClient = + typeof makeDesktopIpcPocClient extends Effect.Effect + ? Client + : never; + +export interface DesktopIpcPocSnapshot { + readonly runtimeInfo: DesktopIpcPocRuntimeInfo; + readonly echo: DesktopIpcPocEchoResult; + readonly ticks: ReadonlyArray; +} + +export interface DesktopIpcPocBrowserClientOptions { + readonly bridge?: EffectElectronIpcRendererBridge; + readonly globalObject?: EffectElectronIpcBrowserGlobal; +} + +export interface DesktopIpcPocSnapshotOptions extends DesktopIpcPocBrowserClientOptions { + readonly echoText?: string; + readonly ticks?: number; +} + +export const makeDesktopIpcPocBrowserClient = ( + options: DesktopIpcPocBrowserClientOptions = {}, +): Effect.Effect => + Effect.gen(function* () { + const bridge = options.bridge ?? getEffectElectronIpcRendererBridge(options.globalObject); + const rendererPort = makeEffectElectronIpcRendererPort(bridge); + const rendererProtocol = yield* makeEffectElectronIpcRendererProtocol(rendererPort); + + return yield* makeDesktopIpcPocClient.pipe( + Effect.provideService(RpcClient.Protocol, rendererProtocol), + ); + }); + +export const loadDesktopIpcPocSnapshot = ( + options: DesktopIpcPocSnapshotOptions = {}, +): Effect.Effect => + Effect.gen(function* () { + const client = yield* makeDesktopIpcPocBrowserClient(options); + const runtimeInfo = yield* client[DESKTOP_IPC_POC_METHODS.getRuntimeInfo]({}); + const echo = yield* client[DESKTOP_IPC_POC_METHODS.echo]({ + text: options.echoText ?? "hello from the renderer", + }); + const ticks = yield* client[DESKTOP_IPC_POC_METHODS.subscribeTicks]({ + take: options.ticks ?? 3, + }).pipe( + Stream.runCollect, + Effect.map((chunk) => Array.from(chunk)), + ); + + return { + runtimeInfo, + echo, + ticks, + }; + }); + +export const loadDesktopIpcPocSnapshotFromBrowser = ( + options: Omit = {}, +) => Effect.runPromise(Effect.scoped(loadDesktopIpcPocSnapshot(options))); + +// ----------------------------------------------------------------------------- +// example/browser-atoms.ts +// ----------------------------------------------------------------------------- + +const DESKTOP_IPC_POC_SNAPSHOT_STALE_TIME_MS = 5_000; +const DESKTOP_IPC_POC_SNAPSHOT_IDLE_TTL_MS = 60_000; + +export const desktopIpcPocClientAtom = Atom.make(makeDesktopIpcPocBrowserClient()).pipe( + Atom.keepAlive, + Atom.withLabel("desktop-ipc-poc:effect-rpc-client"), +); + +export const desktopIpcPocSnapshotAtom = Atom.make( + loadDesktopIpcPocSnapshot({ + echoText: "hello from an Effect Atom", + ticks: 5, + }), +).pipe( + Atom.swr({ + staleTime: DESKTOP_IPC_POC_SNAPSHOT_STALE_TIME_MS, + revalidateOnMount: true, + }), + Atom.setIdleTTL(DESKTOP_IPC_POC_SNAPSHOT_IDLE_TTL_MS), + Atom.withLabel("desktop-ipc-poc:snapshot"), +); + +export const desktopIpcPocManualEchoAtom = Atom.make( + Effect.gen(function* () { + const client = yield* makeDesktopIpcPocBrowserClient(); + return yield* client[DESKTOP_IPC_POC_METHODS.echo]({ + text: "manual echo from an Atom-backed action", + }); + }), +).pipe(Atom.withLabel("desktop-ipc-poc:manual-echo")); + +// ----------------------------------------------------------------------------- +// example/components/DesktopIpcPocPanel.tsx +// ----------------------------------------------------------------------------- + +function formatAsyncResultError(result: AsyncResult.AsyncResult): string | null { + if (result._tag !== "Failure") { + return null; + } + const error = Cause.squash(result.cause); + return error instanceof Error ? error.message : String(error); +} + +function DesktopIpcPocClientStatus(): ReactElement { + const clientResult = useAtomValue(desktopIpcPocClientAtom); + const isReady = clientResult._tag === "Success"; + const label = isReady + ? "Effect RPC client ready" + : clientResult.waiting + ? "Connecting RPC client" + : "RPC client failed"; + + return {label}; +} + +function RuntimeInfoView(props: { readonly runtimeInfo: DesktopIpcPocRuntimeInfo }): ReactElement { + return ( +

+
App version
+
{props.runtimeInfo.appVersion}
+
Platform
+
{props.runtimeInfo.platform}
+
Transport
+
{props.runtimeInfo.ipcTransport}
+
+ ); +} + +function EchoView(props: { readonly echo: DesktopIpcPocEchoResult }): ReactElement { + return ( +

+ Echoed "{props.echo.text}" at {props.echo.echoedAt} +

+ ); +} + +function TickList(props: { readonly ticks: ReadonlyArray }): ReactElement { + return ( +
    + {props.ticks.map((tick) => ( +
  1. + {tick.sequence}: {tick.label} +
  2. + ))} +
+ ); +} + +function ManualEchoButton(): ReactElement { + const echoResult = useAtomValue(desktopIpcPocManualEchoAtom); + const runEcho = useAtomRefresh(desktopIpcPocManualEchoAtom); + const echo = Option.getOrNull(AsyncResult.value(echoResult)); + const error = formatAsyncResultError(echoResult); + + return ( +
+ + {echo ? : null} + {error ?

{error}

: null} +
+ ); +} + +export function DesktopIpcPocPanel(): ReactElement { + const snapshotResult = useAtomValue(desktopIpcPocSnapshotAtom); + const refreshSnapshot = useAtomRefresh(desktopIpcPocSnapshotAtom); + const snapshot = Option.getOrNull(AsyncResult.value(snapshotResult)); + const error = formatAsyncResultError(snapshotResult); + + return ( +
+
+ +
+ + {error ?

{error}

: null} + {snapshot ? ( +
+ + + + +
+ ) : ( +

Loading desktop RPC data

+ )} +
+ ); +} + +// ----------------------------------------------------------------------------- +// example/renderer.tsx +// ----------------------------------------------------------------------------- + +export function mountDesktopIpcPocReactExample(container: Element): void { + createRoot(container).render( + + + , + ); +} diff --git a/bun.lock b/bun.lock index 77decb032d..31ec01bf6c 100644 --- a/bun.lock +++ b/bun.lock @@ -105,6 +105,7 @@ "@xterm/xterm": "^6.0.0", "class-variance-authority": "^0.7.1", "effect": "catalog:", + "effect-electron-ipc": "workspace:*", "lexical": "^0.41.0", "lucide-react": "^0.564.0", "react": "^19.0.0", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 41ce0dcd7b..aa2c8c2e5e 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -10,6 +10,11 @@ "module": "./dist/index.mjs", "types": "./src/index.ts", "exports": { + "./effectElectronIpcPoc": { + "types": "./src/effectElectronIpcPoc.ts", + "import": "./src/effectElectronIpcPoc.ts", + "require": "./src/effectElectronIpcPoc.ts" + }, "./settings": { "types": "./src/settings.ts", "import": "./src/settings.ts", diff --git a/packages/contracts/src/effectElectronIpcPoc.ts b/packages/contracts/src/effectElectronIpcPoc.ts new file mode 100644 index 0000000000..cda3b474b4 --- /dev/null +++ b/packages/contracts/src/effectElectronIpcPoc.ts @@ -0,0 +1,60 @@ +import { Schema } from "effect"; +import * as Rpc from "effect/unstable/rpc/Rpc"; +import * as RpcGroup from "effect/unstable/rpc/RpcGroup"; + +export const DESKTOP_IPC_POC_METHODS = { + getRuntimeInfo: "desktop.poc.getRuntimeInfo", + echo: "desktop.poc.echo", + subscribeTicks: "desktop.poc.subscribeTicks", +} as const; + +export const DesktopIpcPocRuntimeInfo = Schema.Struct({ + appVersion: Schema.String, + platform: Schema.String, + ipcTransport: Schema.Literal("electron-ipc"), +}); +export type DesktopIpcPocRuntimeInfo = typeof DesktopIpcPocRuntimeInfo.Type; + +export const DesktopIpcPocEchoInput = Schema.Struct({ + text: Schema.String, +}); +export type DesktopIpcPocEchoInput = typeof DesktopIpcPocEchoInput.Type; + +export const DesktopIpcPocEchoResult = Schema.Struct({ + text: Schema.String, + echoedAt: Schema.String, +}); +export type DesktopIpcPocEchoResult = typeof DesktopIpcPocEchoResult.Type; + +export const DesktopIpcPocSubscribeTicksInput = Schema.Struct({ + take: Schema.Number, +}); +export type DesktopIpcPocSubscribeTicksInput = typeof DesktopIpcPocSubscribeTicksInput.Type; + +export const DesktopIpcPocTick = Schema.Struct({ + sequence: Schema.Number, + label: Schema.String, +}); +export type DesktopIpcPocTick = typeof DesktopIpcPocTick.Type; + +export const DesktopIpcPocGetRuntimeInfoRpc = Rpc.make(DESKTOP_IPC_POC_METHODS.getRuntimeInfo, { + payload: Schema.Struct({}), + success: DesktopIpcPocRuntimeInfo, +}); + +export const DesktopIpcPocEchoRpc = Rpc.make(DESKTOP_IPC_POC_METHODS.echo, { + payload: DesktopIpcPocEchoInput, + success: DesktopIpcPocEchoResult, +}); + +export const DesktopIpcPocSubscribeTicksRpc = Rpc.make(DESKTOP_IPC_POC_METHODS.subscribeTicks, { + payload: DesktopIpcPocSubscribeTicksInput, + success: DesktopIpcPocTick, + stream: true, +}); + +export const DesktopIpcPocRpcGroup = RpcGroup.make( + DesktopIpcPocGetRuntimeInfoRpc, + DesktopIpcPocEchoRpc, + DesktopIpcPocSubscribeTicksRpc, +); diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts index 1a3647eb31..a1ae659d4c 100644 --- a/packages/contracts/src/index.ts +++ b/packages/contracts/src/index.ts @@ -19,3 +19,4 @@ export * from "./editor.ts"; export * from "./project.ts"; export * from "./filesystem.ts"; export * from "./rpc.ts"; +export * from "./effectElectronIpcPoc.ts";