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

window.ts

553 lines21.1 KB

1import {
2 ContextMenuItemSchema,
3 DesktopAppBrandingSchema,
4 DesktopEnvironmentBootstrapSchema,
5 DesktopMediaReadSchema,
6 DesktopThemeSchema,
7 EDITORS,
8 EditorId,
9 PickedThemeFileSchema,
10 PickFolderOptionsSchema,
11 PRIMARY_LOCAL_ENVIRONMENT_ID,
12 REMOTE_CAPABLE_EDITOR_IDS,
13 SystemSettingsPaneSchema,
14 type DesktopEnvironmentBootstrap,
15 type PickedThemeFile,
16} from "@t3tools/contracts";
17import { PROJECT_FAVICON_EXTENSIONS } from "@t3tools/shared/projectFavicon";
18import { resolveEditorCommand } from "@t3tools/shared/editor";
19import * as HostProcess from "@t3tools/shared/HostProcess";
20import { isRelayTracingEnabled } from "@t3tools/shared/otelEnvironment";
21import * as FileSystem from "effect/FileSystem";
22import * as Path from "effect/Path";
23import * as Effect from "effect/Effect";
24import * as Option from "effect/Option";
25import * as Schema from "effect/Schema";
26​
27import * as DesktopBackendConfiguration from "../../backend/DesktopBackendConfiguration.ts";
28import * as DesktopBackendPool from "../../backend/DesktopBackendPool.ts";
29import * as DesktopLocalEnvironmentAuth from "../../backend/DesktopLocalEnvironmentAuth.ts";
30import * as DesktopEnvironment from "../../app/DesktopEnvironment.ts";
31import * as DesktopManagedPolicy from "../../app/DesktopManagedPolicy.ts";
32import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
33import * as DesktopWslBackend from "../../wsl/DesktopWslBackend.ts";
34import * as DesktopWslEnvironment from "../../wsl/DesktopWslEnvironment.ts";
35import * as ElectronApp from "../../electron/ElectronApp.ts";
36import * as ElectronDialog from "../../electron/ElectronDialog.ts";
37import * as ElectronMenu from "../../electron/ElectronMenu.ts";
38import * as ElectronShell from "../../electron/ElectronShell.ts";
39import * as ElectronTheme from "../../electron/ElectronTheme.ts";
40import * as ElectronWindow from "../../electron/ElectronWindow.ts";
41import * as Electron from "electron";
42import * as MacPermissions from "../../permissions/MacPermissions.ts";
43import { safariPermissionCheck } from "../../preview/BrowserImport/SafariPermission.ts";
44import * as IpcChannels from "../channels.ts";
45import * as DesktopIpc from "../DesktopIpc.ts";
46import {
47 extractDistroFromUncPath,
48 resolveWslPickFolderDefaultPath,
49 wslUncPathToLinuxPath,
50} from "../../wsl/wslPathParsing.ts";
51​
52const ContextMenuPosition = Schema.Struct({
53 x: Schema.Number,
54 y: Schema.Number,
55});
56​
57const ContextMenuInput = Schema.Struct({
58 items: Schema.Array(ContextMenuItemSchema),
59 position: Schema.optionalKey(ContextMenuPosition),
60});
61​
62function toWebSocketBaseUrl(httpBaseUrl: URL): string {
63 const url = new URL(httpBaseUrl.href);
64 url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
65 return url.href;
67​
68export const getAppBranding = DesktopIpc.makeSyncIpcMethod({
69 channel: IpcChannels.GET_APP_BRANDING_CHANNEL,
70 result: Schema.NullOr(DesktopAppBrandingSchema),
71 handler: Effect.fn("desktop.ipc.window.getAppBranding")(function* () {
72 const environment = yield* DesktopEnvironment.DesktopEnvironment;
73 return environment.branding;
74 }),
75});
76​
77/**
78 * Relay traces leave the machine, so a policy with `telemetry: false`, or one that cannot be read,
79 * stops them. Read once here: a sync IPC handler cannot wait on the filesystem.
80 */
81export const installRelayTelemetryEnabled = Effect.fn("desktop.ipc.window.installRelayTelemetry")(
82 function* () {
83 const ipc = yield* DesktopIpc.DesktopIpc;
84 const enabled =
85 isRelayTracingEnabled(yield* HostProcess.Environment) &&
86 (yield* (yield* DesktopManagedPolicy.DesktopManagedPolicy).read.pipe(
87 Effect.map((found) => found?.document.limits?.telemetry !== false),
88 Effect.orElseSucceed(() => false),
89 ));
90 yield* ipc.handleSync(
91 DesktopIpc.makeSyncIpcMethod({
92 channel: IpcChannels.GET_RELAY_TELEMETRY_ENABLED_CHANNEL,
93 result: Schema.Boolean,
94 handler: () => Effect.succeed(enabled),
95 }),
96 );
97 },
98);
99​
100export const getSystemLocale = DesktopIpc.makeSyncIpcMethod({
101 channel: IpcChannels.GET_SYSTEM_LOCALE_CHANNEL,
102 result: Schema.String,
103 handler: Effect.fn("desktop.ipc.window.getSystemLocale")(function* () {
104 const electronApp = yield* ElectronApp.ElectronApp;
105 return yield* electronApp.systemLocale;
106 }),
107});
108​
109export const getPreferredSystemLanguages = DesktopIpc.makeSyncIpcMethod({
110 channel: IpcChannels.GET_PREFERRED_SYSTEM_LANGUAGES_CHANNEL,
111 result: Schema.Array(Schema.String),
112 handler: Effect.fn("desktop.ipc.window.getPreferredSystemLanguages")(function* () {
113 const electronApp = yield* ElectronApp.ElectronApp;
114 return yield* electronApp.preferredSystemLanguages;
115 }),
116});
117​
118export const getWindowFullscreenState = DesktopIpc.makeSyncIpcMethod({
119 channel: IpcChannels.GET_WINDOW_FULLSCREEN_STATE_CHANNEL,
120 result: Schema.Boolean,
121 handler: Effect.fn("desktop.ipc.window.getWindowFullscreenState")(function* () {
122 const electronWindow = yield* ElectronWindow.ElectronWindow;
123 const window = yield* electronWindow.currentMainOrFirst;
124 return Option.isSome(window) && window.value.isFullScreen();
125 }),
126});
127​
128export const getLocalEnvironmentBootstraps = DesktopIpc.makeSyncIpcMethod({
129 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL,
130 result: Schema.Array(DesktopEnvironmentBootstrapSchema),
131 handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBootstraps")(function* () {
132 const pool = yield* DesktopBackendPool.DesktopBackendPool;
133 const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
134 const instances = yield* pool.list;
135 const bootstraps: DesktopEnvironmentBootstrap[] = [];
136 for (const instance of instances) {
137 const isPrimary = instance.id === PRIMARY_LOCAL_ENVIRONMENT_ID;
138 const config = yield* instance.currentConfig;
139 const snapshot = yield* instance.snapshot;
140 if (Option.isNone(config) || Option.isSome(config.value.preflightFailure)) {
141 const fatalPreflight =
142 Option.isSome(config) &&
143 Option.isSome(config.value.preflightFailure) &&
144 config.value.preflightFailure.value.fatal;
145 const stoppedPreflight =
146 Option.isSome(config) &&
147 Option.isSome(config.value.preflightFailure) &&
148 (!snapshot.desiredRunning || !snapshot.restartScheduled);
149 if (isPrimary || fatalPreflight || stoppedPreflight) continue;
150 bootstraps.push({
151 id: instance.id,
152 label: yield* instance.label,
153 runningDistro: null,
154 httpBaseUrl: null,
155 wsBaseUrl: null,
156 });
157 continue;
158 }
159 const { bootstrap, httpBaseUrl } = config.value;
160 const runningDistro = config.value.runningDistro ?? null;
161 bootstraps.push({
162 id: instance.id,
163 label: runningDistro === null ? yield* instance.label : `WSL (${runningDistro})`,
164 runningDistro,
165 httpBaseUrl: httpBaseUrl.href,
166 wsBaseUrl: toWebSocketBaseUrl(httpBaseUrl),
167 // Use the current window's derived token; the launch config's token may be stale.
168 ...(bootstrap.desktopBootstrapSecret
169 ? { bootstrapToken: yield* configuration.currentBootstrapToken }
170 : bootstrap.desktopBootstrapToken
171 ? { bootstrapToken: bootstrap.desktopBootstrapToken }
172 : {}),
173 });
174 }
175 return bootstraps;
176 }),
177});
178​
179function extractWslDistroFromEnvironmentId(envId: string): string | null {
180 if (!envId.startsWith(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX)) {
181 return null;
182 }
183 const suffix = envId.slice(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX.length);
184 return suffix === "default" || suffix.length === 0 ? null : suffix;
186​
187export const getLocalEnvironmentBearerToken = DesktopIpc.makeIpcMethod({
188 channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL,
189 payload: Schema.Void,
190 result: Schema.String,
191 handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBearerToken")(function* () {
192 const localAuth = yield* DesktopLocalEnvironmentAuth.DesktopLocalEnvironmentAuth;
193 return yield* localAuth.getBearerToken;
194 }),
195});
196​
197export const pickFolder = DesktopIpc.makeIpcMethod({
198 channel: IpcChannels.PICK_FOLDER_CHANNEL,
199 payload: Schema.UndefinedOr(PickFolderOptionsSchema),
200 result: Schema.NullOr(Schema.String),
201 handler: Effect.fn("desktop.ipc.window.pickFolder")(function* (options) {
202 const dialog = yield* ElectronDialog.ElectronDialog;
203 const electronWindow = yield* ElectronWindow.ElectronWindow;
204 const environment = yield* DesktopEnvironment.DesktopEnvironment;
205 const appSettings = yield* DesktopAppSettings.DesktopAppSettings;
206 const wslEnvironment = yield* DesktopWslEnvironment.DesktopWslEnvironment;
207 const settings = yield* appSettings.get;
208 // A picked path only means something to a backend on this machine.
209 if (!settings.localEnvironmentEnabled) {
210 return null;
211 }
212 const targetId = options?.targetEnvironmentId;
213 const wslDistroFromTarget =
214 targetId !== undefined && targetId.startsWith(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX)
215 ? extractWslDistroFromEnvironmentId(targetId)
216 : null;
217 const useWsl =
218 targetId !== undefined &&
219 targetId !== PRIMARY_LOCAL_ENVIRONMENT_ID &&
220 targetId.startsWith(DesktopWslBackend.WSL_INSTANCE_ID_PREFIX);
221 // Match the orchestrator's persisted distro fallback for wsl:default.
222 const wslDistro = useWsl ? (wslDistroFromTarget ?? settings.wslDistro) : null;
223 const defaultPath = useWsl
224 ? Option.fromNullishOr(
225 resolveWslPickFolderDefaultPath(
226 options,
227 { distro: wslDistro },
228 yield* wslEnvironment.listDistros,
229 Option.getOrNull(yield* wslEnvironment.getUserHome(wslDistro)),
230 ),
231 )
232 : environment.resolvePickFolderDefaultPath(options);
233 const selectedPath = yield* dialog.pickFolder({
234 owner: yield* electronWindow.focusedMainOrFirst,
235 defaultPath,
236 });
237 if (Option.isNone(selectedPath)) {
238 return null;
239 }
240 if (!useWsl) {
241 return selectedPath.value;
242 }
243​
244 const linuxUncPath = wslUncPathToLinuxPath(selectedPath.value);
245 if (linuxUncPath !== null) {
246 return linuxUncPath;
247 }
248​
249 const converted = yield* wslEnvironment.windowsToWslPath(
250 extractDistroFromUncPath(selectedPath.value) ?? wslDistro,
251 selectedPath.value,
252 );
253 return Option.getOrElse(converted, () => selectedPath.value);
254 }),
255});
256​
257export const pickProjectFavicon = DesktopIpc.makeIpcMethod({
258 channel: IpcChannels.PICK_PROJECT_FAVICON_CHANNEL,
259 payload: Schema.UndefinedOr(Schema.String),
260 result: Schema.NullOr(Schema.String),
261 handler: Effect.fn("desktop.ipc.window.pickProjectFavicon")(function* (initialPath) {
262 const dialog = yield* ElectronDialog.ElectronDialog;
263 const electronWindow = yield* ElectronWindow.ElectronWindow;
264 const appSettings = yield* DesktopAppSettings.DesktopAppSettings;
265 if (!(yield* appSettings.get).localEnvironmentEnabled) {
266 return null;
267 }
268 const paths = yield* dialog.pickFiles({
269 owner: yield* electronWindow.focusedMainOrFirst,
270 defaultPath: Option.fromNullishOr(initialPath),
271 multiple: false,
272 filters: [
273 {
274 name: "Images",
275 extensions: PROJECT_FAVICON_EXTENSIONS.map((extension) => extension.slice(1)),
276 },
277 ],
278 });
279 return paths[0] ?? null;
280 }),
281});
282​
283export const setTheme = DesktopIpc.makeIpcMethod({
284 channel: IpcChannels.SET_THEME_CHANNEL,
285 payload: DesktopThemeSchema,
286 result: Schema.Void,
287 handler: Effect.fn("desktop.ipc.window.setTheme")(function* (theme) {
288 const electronTheme = yield* ElectronTheme.ElectronTheme;
289 yield* electronTheme.setSource(theme);
290 }),
291});
292​
293export const showContextMenu = DesktopIpc.makeIpcMethod({
294 channel: IpcChannels.CONTEXT_MENU_CHANNEL,
295 payload: ContextMenuInput,
296 result: Schema.NullOr(Schema.String),
297 handler: Effect.fn("desktop.ipc.window.showContextMenu")(function* (input) {
298 const electronMenu = yield* ElectronMenu.ElectronMenu;
299 const electronWindow = yield* ElectronWindow.ElectronWindow;
300 const window = yield* electronWindow.focusedMainOrFirst;
301 if (Option.isNone(window)) {
302 return null;
303 }
304​
305 const selectedItemId = yield* electronMenu.showContextMenu({
306 window: window.value,
307 items: input.items,
308 position: Option.fromNullishOr(input.position),
309 });
310 return Option.getOrNull(selectedItemId);
311 }),
312});
313​
314export const openExternal = DesktopIpc.makeIpcMethod({
315 channel: IpcChannels.OPEN_EXTERNAL_CHANNEL,
316 payload: Schema.String,
317 result: Schema.Boolean,
318 handler: Effect.fn("desktop.ipc.window.openExternal")(function* (url) {
319 const shell = yield* ElectronShell.ElectronShell;
320 return yield* shell.openExternal(url);
321 }),
322});
323​
324const READ_MEDIA_MAX_BYTES = 256 * 1024 * 1024;
325​
326// No URL field: media URLs can carry signed query tokens.
327class MediaReadError extends Schema.TaggedError<MediaReadError>()("MediaReadError", {
328 message: Schema.String,
329 cause: Schema.Defect(),
330}) {}
331​
332// The renderer can display media it cannot fetch(); reading here keeps Save and Copy working for it.
333export const readMedia = DesktopIpc.makeIpcMethod({
334 channel: IpcChannels.READ_MEDIA_CHANNEL,
335 payload: Schema.String,
336 result: Schema.NullOr(DesktopMediaReadSchema),
337 handler: Effect.fn("desktop.ipc.window.readMedia")(function* (url, event) {
338 const window = yield* (yield* ElectronWindow.ElectronWindow).main;
339 if (
340 event === undefined ||
341 Option.isNone(window) ||
342 window.value.webContents.id !== event.sender.id ||
343 !/^https?:$/.test(URL.parse(url)?.protocol ?? "")
344 ) {
345 return null;
346 }
347 const session = window.value.webContents.session;
348 return yield* Effect.tryPromise({
349 try: async () => {
350 // Like an <img>, send the session's cookies.
351 const response = await session.fetch(url, { credentials: "include" });
352 const mimeType = response.headers.get("content-type") ?? "";
353 if (!response.ok || !response.body) {
354 await response.body?.cancel();
355 return { status: response.status, mimeType, data: new Uint8Array() };
356 }
357 // The whole body crosses IPC, so stop before a huge file can exhaust main-process memory.
358 const chunks: Uint8Array[] = [];
359 let size = 0;
360 for await (const chunk of response.body) {
361 size += chunk.byteLength;
362 if (size > READ_MEDIA_MAX_BYTES) {
363 return { status: 413, mimeType, data: new Uint8Array() };
364 }
365 chunks.push(chunk);
366 }
367 return { status: response.status, mimeType, data: Buffer.concat(chunks) };
368 },
369 catch: (cause) => new MediaReadError({ message: "Could not read media.", cause }),
370 }).pipe(Effect.orElseSucceed(() => null));
371 }),
372});
373​
374export const openSystemSettings = DesktopIpc.makeIpcMethod({
375 channel: IpcChannels.OPEN_SYSTEM_SETTINGS_CHANNEL,
376 payload: SystemSettingsPaneSchema,
377 result: Schema.Boolean,
378 handler: Effect.fn("desktop.ipc.window.openSystemSettings")(function* (pane) {
379 const shell = yield* ElectronShell.ElectronShell;
380 const environment = yield* DesktopEnvironment.DesktopEnvironment;
381 if (environment.platform !== "darwin") return false;
382 const owner = Electron.BrowserWindow.getFocusedWindow();
383 const opened = yield* shell.openSystemSettings(pane);
384 if (opened && environment.isPackaged) {
385 const permissions = yield* MacPermissions.MacPermissions;
386 const isGranted = yield* safariPermissionCheck;
387 yield* permissions.showHelper(pane, owner, isGranted);
388 }
389 return opened;
390 }),
391});
392​
393export const probeRemoteEditors = DesktopIpc.makeIpcMethod({
394 channel: IpcChannels.PROBE_REMOTE_EDITORS_CHANNEL,
395 payload: Schema.Undefined,
396 result: Schema.Array(EditorId),
397 handler: Effect.fn("desktop.ipc.window.probeRemoteEditors")(function* () {
398 const available: Array<EditorId> = [];
399 const env = yield* HostProcess.Environment;
400 for (const editorId of REMOTE_CAPABLE_EDITOR_IDS) {
401 const editor = EDITORS.find((editor) => editor.id === editorId);
402 if (editor && Option.isSome(yield* resolveEditorCommand(editor, env))) {
403 available.push(editorId);
404 }
405 }
406 return available;
407 }),
408});
409​
410export const pasteAsText = DesktopIpc.makeIpcMethod({
411 channel: IpcChannels.PASTE_AS_TEXT_CHANNEL,
412 payload: Schema.Undefined,
413 result: Schema.Void,
414 handler: Effect.fn("desktop.ipc.window.pasteAsText")(function* (_input, event) {
415 const electronWindow = yield* ElectronWindow.ElectronWindow;
416 const window = yield* electronWindow.main;
417 if (
418 event === undefined ||
419 Option.isNone(window) ||
420 window.value.isDestroyed() ||
421 window.value.webContents.id !== event.sender.id
422 ) {
423 return;
424 }
425 const focused = Electron.webContents.getFocusedWebContents();
426 if (
427 focused &&
428 !focused.isDestroyed() &&
429 Electron.BrowserWindow.fromWebContents(focused) === window.value
430 ) {
431 focused.paste();
432 }
433 }),
434});
435​
436export const revealWindow = DesktopIpc.makeIpcMethod({
437 channel: IpcChannels.REVEAL_WINDOW_CHANNEL,
438 payload: Schema.Undefined,
439 result: Schema.Void,
440 handler: Effect.fn("desktop.ipc.window.revealWindow")(function* (_input, event) {
441 const electronWindow = yield* ElectronWindow.ElectronWindow;
442 const window = yield* electronWindow.main;
443 if (
444 event === undefined ||
445 Option.isNone(window) ||
446 window.value.webContents.id !== event.sender.id
447 ) {
448 return;
449 }
450 yield* electronWindow.reveal(window.value);
451 }),
452});
453​
454const htmlFullscreenStates = new WeakMap<
455 Electron.BrowserWindow,
456 { owned: boolean; leaving: boolean }
457>();
458​
459const htmlFullscreenState = (window: Electron.BrowserWindow) => {
460 const existing = htmlFullscreenStates.get(window);
461 if (existing !== undefined) return existing;
462 const state = { owned: false, leaving: false };
463 window.on("leave-full-screen", () => {
464 // Leaving OS fullscreen any other way, such as F11, hands the window back to the user.
465 if (!state.leaving) state.owned = false;
466 state.leaving = false;
467 });
468 htmlFullscreenStates.set(window, state);
469 return state;
470};
471​
472// The main window keeps HTML fullscreen inside itself so preview guests stay in their webview,
473// so the app's own fullscreen elements, such as chat videos, take the screen here.
474export const syncHtmlFullscreen = DesktopIpc.makeIpcMethod({
475 channel: IpcChannels.SYNC_HTML_FULLSCREEN_CHANNEL,
476 payload: Schema.Boolean,
477 result: Schema.Void,
478 handler: Effect.fn("desktop.ipc.window.syncHtmlFullscreen")(function* (fullscreen, event) {
479 const electronWindow = yield* ElectronWindow.ElectronWindow;
480 const main = yield* electronWindow.main;
481 if (
482 event === undefined ||
483 Option.isNone(main) ||
484 main.value.isDestroyed() ||
485 main.value.webContents.id !== event.sender.id
486 ) {
487 return;
488 }
489 const window = main.value;
490 const state = htmlFullscreenState(window);
491 if (fullscreen) {
492 // macOS reports fullscreen until its exit animation ends, and Electron queues the re-entry.
493 if (state.owned || (window.isFullScreen() && !state.leaving)) return;
494 state.owned = true;
495 window.setFullScreen(true);
496 } else if (state.owned) {
497 state.owned = false;
498 state.leaving = window.isFullScreen();
499 window.setFullScreen(false);
500 }
501 }),
502});
503​
504const PICKED_THEME_FILE_MAX_BYTES = 256 * 1024;
505​
506export const pickThemeFiles = DesktopIpc.makeIpcMethod({
507 channel: IpcChannels.PICK_THEME_FILES_CHANNEL,
508 payload: Schema.Undefined,
509 result: Schema.NullOr(Schema.Array(PickedThemeFileSchema)),
510 handler: Effect.fn("desktop.ipc.window.pickThemeFiles")(function* () {
511 const dialog = yield* ElectronDialog.ElectronDialog;
512 const electronWindow = yield* ElectronWindow.ElectronWindow;
513 const fileSystem = yield* FileSystem.FileSystem;
514 const path = yield* Path.Path;
515 const extensionsDir = path.join(yield* HostProcess.HomeDirectory, ".vscode", "extensions");
516 const defaultPath = yield* fileSystem
517 .exists(extensionsDir)
518 .pipe(Effect.orElseSucceed(() => false));
519 const paths = yield* dialog.pickFiles({
520 owner: yield* electronWindow.focusedMainOrFirst,
521 defaultPath: defaultPath ? Option.some(extensionsDir) : Option.none(),
522 filters: [{ name: "JSON", extensions: ["json"] }],
523 multiple: true,
524 });
525 if (paths.length === 0) {
526 return null;
527 }
528 return yield* Effect.forEach(paths, (filePath) => {
529 const name = path.basename(filePath);
530 return Effect.gen(function* () {
531 const info = yield* fileSystem.stat(filePath);
532 const size = Number(info.size);
533 if (size > PICKED_THEME_FILE_MAX_BYTES) {
534 return { name, size, text: "" } satisfies PickedThemeFile;
535 }
536 const text = yield* fileSystem.readFileString(filePath);
537 return { name, size, text } satisfies PickedThemeFile;
538 }).pipe(Effect.orElseSucceed((): PickedThemeFile => ({ name, size: 0, text: "" })));
539 });
540 }),
541});
542​
543export const checkSystemPermission = DesktopIpc.makeIpcMethod({
544 channel: IpcChannels.CHECK_SYSTEM_PERMISSION_CHANNEL,
545 payload: SystemSettingsPaneSchema,
546 result: Schema.Boolean,
547 handler: Effect.fn("desktop.ipc.window.checkSystemPermission")(function* () {
548 const environment = yield* DesktopEnvironment.DesktopEnvironment;
549 if (environment.platform !== "darwin") return false;
550 const check = yield* safariPermissionCheck;
551 return yield* Effect.promise(check);
552 }),
553});