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

DesktopIpcHandlers.ts

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