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

DesktopIpcHandlers.ts

198 lines6.7 KB

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