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

DesktopIpcHandlers.ts

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