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

DesktopIpcHandlers.ts

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