Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

DesktopIpcHandlers.ts

170 lines5.7 KB

1import * as Effect from "effect/Effect";
2​
3import { receiveProviderAuthCallback, cancelProviderAuthCallback } from "./methods/providerAuth.ts";
4import * as DesktopIpc from "./DesktopIpc.ts";
5import { installNotificationBadge } from "./methods/notificationBadge.ts";
6import { getClientSettings, setClientSettings } from "./methods/clientSettings.ts";
7import { getConnectionCatalog, setConnectionCatalog } from "./methods/connectionCatalog.ts";
8import {
9 getLocalEnvironmentEnabled,
10 setLocalEnvironmentEnabled,
11} from "./methods/localEnvironment.ts";
12import {
13 getAdvertisedEndpoints,
14 getServerExposureState,
15 setServerExposureMode,
16 setTailscaleServeEnabled,
17} from "./methods/serverExposure.ts";
18import {
19 bootstrapSshBearerSession,
20 disconnectSshEnvironment,
21 discoverSshHosts,
22 ensureSshEnvironment,
23 fetchSshEnvironmentDescriptor,
24 fetchSshSessionState,
25 resolveSshHost,
26 resolveSshPasswordPrompt,
27} from "./methods/sshEnvironment.ts";
28import {
29 checkForUpdate,
30 downloadUpdate,
31 getUpdateState,
32 installUpdate,
33 setUpdateChannel,
34} from "./methods/updates.ts";
35import {
36 getAppBranding,
37 getLocalEnvironmentBootstraps,
38 getLocalEnvironmentBearerToken,
39 installRelayTelemetryEnabled,
40 getSystemLocale,
41 getWindowFullscreenState,
42 openExternal,
43 readMedia,
44 openSystemSettings,
45 checkSystemPermission,
46 pasteAsText,
47 probeRemoteEditors,
48 revealWindow,
49 pickFolder,
50 pickProjectFavicon,
51 pickThemeFiles,
52 setTheme,
53 showContextMenu,
54} from "./methods/window.ts";
55import {
56 acknowledgeSnapShot,
57 checkSnapShotShortcut,
58 dismissSnapShotAnimation,
59 getSnapShotState,
60 setupSnapShot,
61 previewSnapShotConfig,
62 applySnapShotConfig,
63 listPendingSnapShots,
64 readSnapShot,
65 requestSnapShotPermissions,
66 setSnapShotAnimationDestination,
67 setSnapShotShortcutSuppressed,
68} from "./methods/snapShot.ts";
69import * as PreviewIpc from "./methods/preview.ts";
70import * as AppActivationIpc from "./methods/appActivation.ts";
71import * as WebLinksIpc from "./methods/webLinks.ts";
72import {
73 completeLegacyLocalStorage,
74 takeLegacyLocalStorage,
75} from "./methods/legacyLocalStorage.ts";
76import { getWslState, setWslBackendEnabled, setWslDistro, setWslOnly } from "./methods/wsl.ts";
77import {
78 getCliCommandState,
79 installCliCommand,
80 uninstallCliCommand,
81} from "./methods/cliCommand.ts";
82​
83export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers")(function* () {
84 const ipc = yield* DesktopIpc.DesktopIpc;
85 yield* installNotificationBadge();
86 yield* PreviewIpc.installPreviewEventForwarding();
87​
88 yield* ipc.handle(AppActivationIpc.setReady);
89 yield* ipc.handle(AppActivationIpc.complete);
90 yield* ipc.handle(WebLinksIpc.setReady);
91​
92 yield* ipc.handleSync(takeLegacyLocalStorage);
93 yield* ipc.handle(completeLegacyLocalStorage);
94 yield* ipc.handleSync(getAppBranding);
95 yield* installRelayTelemetryEnabled();
96 yield* ipc.handleSync(getSystemLocale);
97 yield* ipc.handleSync(getWindowFullscreenState);
98 yield* ipc.handleSync(getLocalEnvironmentBootstraps);
99 yield* ipc.handleSync(getLocalEnvironmentEnabled);
100 yield* ipc.handle(setLocalEnvironmentEnabled);
101 yield* ipc.handle(getLocalEnvironmentBearerToken);
102​
103 yield* ipc.handle(getClientSettings);
104 yield* ipc.handle(setClientSettings);
105 yield* ipc.handle(getConnectionCatalog);
106 yield* ipc.handle(getSnapShotState);
107 yield* ipc.handle(setupSnapShot);
108 yield* ipc.handle(previewSnapShotConfig);
109 yield* ipc.handle(applySnapShotConfig);
110 yield* ipc.handle(requestSnapShotPermissions);
111 yield* ipc.handle(checkSnapShotShortcut);
112 yield* ipc.handle(setSnapShotShortcutSuppressed);
113 yield* ipc.handle(listPendingSnapShots);
114 yield* ipc.handle(readSnapShot);
115 yield* ipc.handle(setSnapShotAnimationDestination);
116 yield* ipc.handle(dismissSnapShotAnimation);
117 yield* ipc.handle(acknowledgeSnapShot);
118 yield* ipc.handle(setConnectionCatalog);
119​
120 yield* ipc.handle(discoverSshHosts);
121 yield* ipc.handle(resolveSshHost);
122 yield* ipc.handle(ensureSshEnvironment);
123 yield* ipc.handle(disconnectSshEnvironment);
124 yield* ipc.handle(fetchSshEnvironmentDescriptor);
125 yield* ipc.handle(bootstrapSshBearerSession);
126 yield* ipc.handle(fetchSshSessionState);
127 yield* ipc.handle(resolveSshPasswordPrompt);
128​
129 yield* ipc.handle(getServerExposureState);
130 yield* ipc.handle(setServerExposureMode);
131 yield* ipc.handle(setTailscaleServeEnabled);
132 yield* ipc.handle(getAdvertisedEndpoints);
133​
134 yield* ipc.handle(getWslState);
135 yield* ipc.handle(setWslBackendEnabled);
136 yield* ipc.handle(setWslDistro);
137 yield* ipc.handle(setWslOnly);
138​
139 yield* ipc.handle(pickFolder);
140 yield* ipc.handle(pickProjectFavicon);
141 yield* ipc.handle(pickThemeFiles);
142 yield* ipc.handle(setTheme);
143 yield* ipc.handle(showContextMenu);
144 yield* ipc.handle(openExternal);
145 yield* ipc.handle(readMedia);
146 yield* ipc.handle(receiveProviderAuthCallback);
147 yield* ipc.handle(cancelProviderAuthCallback);
148 yield* ipc.handle(openSystemSettings);
149 yield* ipc.handle(checkSystemPermission);
150 yield* ipc.handle(pasteAsText);
151 yield* ipc.handle(revealWindow);
152 yield* ipc.handle(probeRemoteEditors);
153 yield* ipc.handle(getUpdateState);
154 yield* ipc.handle(setUpdateChannel);
155 yield* ipc.handle(downloadUpdate);
156 yield* ipc.handle(installUpdate);
157 yield* ipc.handle(checkForUpdate);
158 yield* ipc.handle(getCliCommandState);
159 yield* ipc.handle(installCliCommand);
160 yield* ipc.handle(uninstallCliCommand);
161 for (const previewMethod of PreviewIpc.methods) {
162 // Explicit types preserve the error/service union of these heterogeneous preview methods.
163 yield* ipc.handle<
164 Effect.Error<ReturnType<(typeof PreviewIpc.methods)[number]["handler"]>>,
165 Effect.Services<ReturnType<(typeof PreviewIpc.methods)[number]["handler"]>>
166 >(previewMethod);
167 }
168 yield* ipc.handle(PreviewIpc.listBrowserImportSources);
169 yield* ipc.handle(PreviewIpc.importBrowserCookies);
170});