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

DesktopIpcHandlers.ts

186 lines6.3 KB

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