69 lines · 2.7 KB · TypeScript
RawDownload
import {  AdvertisedEndpoint,  DesktopServerExposureModeSchema,  DesktopServerExposureStateSchema,} from "@t3tools/contracts";import * as Effect from "effect/Effect";import * as Schema from "effect/Schema"; import * as DesktopLifecycle from "../../app/DesktopLifecycle.ts";import * as DesktopServerExposure from "../../backend/DesktopServerExposure.ts";import * as IpcChannels from "../channels.ts";import * as DesktopIpc from "../DesktopIpc.ts"; const SetTailscaleServeEnabledInput = Schema.Struct({  enabled: Schema.Boolean,  port: Schema.optionalKey(Schema.Number),}); export const getServerExposureState = DesktopIpc.makeIpcMethod({  channel: IpcChannels.GET_SERVER_EXPOSURE_STATE_CHANNEL,  payload: Schema.Void,  result: DesktopServerExposureStateSchema,  handler: Effect.fn("desktop.ipc.serverExposure.getState")(function* () {    const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;    return yield* serverExposure.getState;  }),}); export const setServerExposureMode = DesktopIpc.makeIpcMethod({  channel: IpcChannels.SET_SERVER_EXPOSURE_MODE_CHANNEL,  payload: DesktopServerExposureModeSchema,  result: DesktopServerExposureStateSchema,  handler: Effect.fn("desktop.ipc.serverExposure.setMode")(function* (mode) {    const lifecycle = yield* DesktopLifecycle.DesktopLifecycle;    const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;    const change = yield* serverExposure.setMode(mode);    if (change.requiresRelaunch) {      yield* lifecycle.relaunch(`serverExposureMode=${mode}`);    }    return change.state;  }),}); export const setTailscaleServeEnabled = DesktopIpc.makeIpcMethod({  channel: IpcChannels.SET_TAILSCALE_SERVE_ENABLED_CHANNEL,  payload: SetTailscaleServeEnabledInput,  result: DesktopServerExposureStateSchema,  handler: Effect.fn("desktop.ipc.serverExposure.setTailscaleServeEnabled")(function* (input) {    const lifecycle = yield* DesktopLifecycle.DesktopLifecycle;    const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;    const change = yield* serverExposure.setTailscaleServeEnabled(input);    if (change.requiresRelaunch) {      yield* lifecycle.relaunch(        change.state.tailscaleServeEnabled ? "tailscale-serve-enabled" : "tailscale-serve-disabled",      );    }    return change.state;  }),}); export const getAdvertisedEndpoints = DesktopIpc.makeIpcMethod({  channel: IpcChannels.GET_ADVERTISED_ENDPOINTS_CHANNEL,  payload: Schema.Void,  result: Schema.Array(AdvertisedEndpoint),  handler: Effect.fn("desktop.ipc.serverExposure.getAdvertisedEndpoints")(function* () {    const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;    return yield* serverExposure.getAdvertisedEndpoints;  }),});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t