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

DesktopIpcHandlers.ts

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