refactor(desktop): classify electron exports (#10266)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-07 15:00:37 -07:00
1 parent 5b8a69c7b9
commit 5a853a4b45
10 files changed
+14 -5

No files matched your search

+1
View File
@@ -98,6 +98,7 @@ const addScopedAppListener = <Args extends ReadonlyArray<unknown>>(
}),
).pipe(Effect.asVoid);
/** @public Service construction is part of the canonical Effect module API. */
export const make = ElectronApp.of({
metadata: Effect.gen(function* () {
const appVersion = yield* Effect.try({
@@ -102,6 +102,7 @@ export class ElectronDialog extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronDialog") {}
/** @public Service construction is part of the canonical Effect module API. */
export const make = ElectronDialog.of({
pickFolder: Effect.fn("desktop.electron.dialog.pickFolder")(function* (input) {
const ownerWindowId = Option.match(input.owner, {
@@ -110,6 +110,7 @@ const normalizePosition = (
Option.map(({ x, y }) => ({ x: Math.floor(x * zoomFactor), y: Math.floor(y * zoomFactor) })),
);
/** @public Service construction is part of the canonical Effect module API. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
let destructiveMenuIconCache: Option.Option<Electron.NativeImage> | undefined;
@@ -75,6 +75,7 @@ const onSpeedLimitChange: ElectronPowerMonitor["Service"]["onSpeedLimitChange"]
).pipe(Effect.asVoid);
};
/** @public Service construction is part of the canonical Effect module API. */
export const make = ElectronPowerMonitor.of({
isOnBatteryPower: Effect.sync(() => Electron.powerMonitor.isOnBatteryPower()),
getSystemIdleTime: Effect.sync(() => Electron.powerMonitor.getSystemIdleTime()),
@@ -9,14 +9,14 @@ import * as Scope from "effect/Scope";
import * as Electron from "electron";
export const DESKTOP_HOST = "app";
export const DESKTOP_PRODUCTION_SCHEME = "t3code";
export const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";
const DESKTOP_PRODUCTION_SCHEME = "t3code";
const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";
export function getDesktopScheme(isDevelopment: boolean): string {
return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;
}
export function getDesktopOrigin(isDevelopment: boolean): string {
function getDesktopOrigin(isDevelopment: boolean): string {
return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`;
}
@@ -109,7 +109,7 @@ function withContentSecurityPolicy(response: Response, policy: string): Response
/**
* Must run synchronously during process bootstrap, before Electron emits `ready`.
*/
export function registerDesktopSchemePrivilegesSync(): void {
function registerDesktopSchemePrivilegesSync(): void {
Electron.protocol.registerSchemesAsPrivileged([
{
scheme: DESKTOP_PRODUCTION_SCHEME,
@@ -205,6 +205,7 @@ async function fetchWithTransientRetry(url: string, init: RequestInit): Promise<
throw lastError;
}
/** @public Service construction is part of the canonical Effect module API. */
export const make = Effect.gen(function* () {
const registered = yield* Ref.make(false);
@@ -50,7 +50,6 @@ export const ElectronSafeStorageError = Schema.Union([
ElectronSafeStorageDecryptError,
]);
export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type;
export const isElectronSafeStorageError = Schema.is(ElectronSafeStorageError);
export class ElectronSafeStorage extends Context.Service<
ElectronSafeStorage,
@@ -66,6 +65,7 @@ export class ElectronSafeStorage extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronSafeStorage") {}
/** @public Service construction is part of the canonical Effect module API. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
@@ -67,6 +67,7 @@ export class ElectronShell extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronShell") {}
/** @public Service construction is part of the canonical Effect module API. */
export const make = ElectronShell.of({
openExternal: (rawUrl) =>
Option.match(parseSafeExternalUrl(rawUrl), {
@@ -28,6 +28,7 @@ export class ElectronTheme extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronTheme") {}
/** @public Service construction is part of the canonical Effect module API. */
export const make = ElectronTheme.of({
shouldUseDarkColors: Effect.sync(() => Electron.nativeTheme.shouldUseDarkColors),
setSource: (theme) =>
@@ -80,6 +80,7 @@ export class ElectronUpdater extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronUpdater") {}
/** @public Service construction is part of the canonical Effect module API. */
export const make = ElectronUpdater.of({
setFeedURL: (options) =>
Effect.suspend(() => {
@@ -95,6 +95,7 @@ export class ElectronWindow extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronWindow") {}
/** @public Service construction is part of the canonical Effect module API. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
const mainWindowRef = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());