authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-07 15:00:37-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-07 15:00:37-07:00
log5a853a4b4513467fd1be3d62fe7dc974cea07c3c
treefe244771ea4b966a0877c70836942f2cf9ba1dab
parent5b8a69c7b90b751507d0ab762dd77aaa2048408b
signature Signed by PGP key B5690EEEBB952194

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


10 files changed, 14 insertions(+), 5 deletions(-)

apps/desktop/src/electron/ElectronApp.ts+1
......@@ -98,6 +98,7 @@ const addScopedAppListener = <Args extends ReadonlyArray<unknown>>(
9898 }),
9999 ).pipe(Effect.asVoid);
100100
101/** @public Service construction is part of the canonical Effect module API. */
101102export const make = ElectronApp.of({
102103 metadata: Effect.gen(function* () {
103104 const appVersion = yield* Effect.try({
apps/desktop/src/electron/ElectronDialog.ts+1
......@@ -102,6 +102,7 @@ export class ElectronDialog extends Context.Service<
102102 }
103103>()("@t3tools/desktop/electron/ElectronDialog") {}
104104
105/** @public Service construction is part of the canonical Effect module API. */
105106export const make = ElectronDialog.of({
106107 pickFolder: Effect.fn("desktop.electron.dialog.pickFolder")(function* (input) {
107108 const ownerWindowId = Option.match(input.owner, {
apps/desktop/src/electron/ElectronMenu.ts+1
......@@ -110,6 +110,7 @@ const normalizePosition = (
110110 Option.map(({ x, y }) => ({ x: Math.floor(x * zoomFactor), y: Math.floor(y * zoomFactor) })),
111111 );
112112
113/** @public Service construction is part of the canonical Effect module API. */
113114export const make = Effect.gen(function* () {
114115 const platform = yield* HostProcessPlatform;
115116 let destructiveMenuIconCache: Option.Option<Electron.NativeImage> | undefined;
apps/desktop/src/electron/ElectronPowerMonitor.ts+1
......@@ -75,6 +75,7 @@ const onSpeedLimitChange: ElectronPowerMonitor["Service"]["onSpeedLimitChange"]
7575 ).pipe(Effect.asVoid);
7676};
7777
78/** @public Service construction is part of the canonical Effect module API. */
7879export const make = ElectronPowerMonitor.of({
7980 isOnBatteryPower: Effect.sync(() => Electron.powerMonitor.isOnBatteryPower()),
8081 getSystemIdleTime: Effect.sync(() => Electron.powerMonitor.getSystemIdleTime()),
apps/desktop/src/electron/ElectronProtocol.ts+5-4
......@@ -9,14 +9,14 @@ import * as Scope from "effect/Scope";
99import * as Electron from "electron";
1010
1111export const DESKTOP_HOST = "app";
12export const DESKTOP_PRODUCTION_SCHEME = "t3code";
13export const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";
12const DESKTOP_PRODUCTION_SCHEME = "t3code";
13const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";
1414
1515export function getDesktopScheme(isDevelopment: boolean): string {
1616 return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;
1717}
1818
19export function getDesktopOrigin(isDevelopment: boolean): string {
19function getDesktopOrigin(isDevelopment: boolean): string {
2020 return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`;
2121}
2222
......@@ -109,7 +109,7 @@ function withContentSecurityPolicy(response: Response, policy: string): Response
109109/**
110110 * Must run synchronously during process bootstrap, before Electron emits `ready`.
111111 */
112export function registerDesktopSchemePrivilegesSync(): void {
112function registerDesktopSchemePrivilegesSync(): void {
113113 Electron.protocol.registerSchemesAsPrivileged([
114114 {
115115 scheme: DESKTOP_PRODUCTION_SCHEME,
......@@ -205,6 +205,7 @@ async function fetchWithTransientRetry(url: string, init: RequestInit): Promise<
205205 throw lastError;
206206}
207207
208/** @public Service construction is part of the canonical Effect module API. */
208209export const make = Effect.gen(function* () {
209210 const registered = yield* Ref.make(false);
210211
apps/desktop/src/electron/ElectronSafeStorage.ts+1-1
......@@ -50,7 +50,6 @@ export const ElectronSafeStorageError = Schema.Union([
5050 ElectronSafeStorageDecryptError,
5151]);
5252export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type;
53export const isElectronSafeStorageError = Schema.is(ElectronSafeStorageError);
5453
5554export class ElectronSafeStorage extends Context.Service<
5655 ElectronSafeStorage,
......@@ -66,6 +65,7 @@ export class ElectronSafeStorage extends Context.Service<
6665 }
6766>()("@t3tools/desktop/electron/ElectronSafeStorage") {}
6867
68/** @public Service construction is part of the canonical Effect module API. */
6969export const make = Effect.gen(function* () {
7070 const platform = yield* HostProcessPlatform;
7171
apps/desktop/src/electron/ElectronShell.ts+1
......@@ -67,6 +67,7 @@ export class ElectronShell extends Context.Service<
6767 }
6868>()("@t3tools/desktop/electron/ElectronShell") {}
6969
70/** @public Service construction is part of the canonical Effect module API. */
7071export const make = ElectronShell.of({
7172 openExternal: (rawUrl) =>
7273 Option.match(parseSafeExternalUrl(rawUrl), {
apps/desktop/src/electron/ElectronTheme.ts+1
......@@ -28,6 +28,7 @@ export class ElectronTheme extends Context.Service<
2828 }
2929>()("@t3tools/desktop/electron/ElectronTheme") {}
3030
31/** @public Service construction is part of the canonical Effect module API. */
3132export const make = ElectronTheme.of({
3233 shouldUseDarkColors: Effect.sync(() => Electron.nativeTheme.shouldUseDarkColors),
3334 setSource: (theme) =>
apps/desktop/src/electron/ElectronUpdater.ts+1
......@@ -80,6 +80,7 @@ export class ElectronUpdater extends Context.Service<
8080 }
8181>()("@t3tools/desktop/electron/ElectronUpdater") {}
8282
83/** @public Service construction is part of the canonical Effect module API. */
8384export const make = ElectronUpdater.of({
8485 setFeedURL: (options) =>
8586 Effect.suspend(() => {
apps/desktop/src/electron/ElectronWindow.ts+1
......@@ -95,6 +95,7 @@ export class ElectronWindow extends Context.Service<
9595 }
9696>()("@t3tools/desktop/electron/ElectronWindow") {}
9797
98/** @public Service construction is part of the canonical Effect module API. */
9899export const make = Effect.gen(function* () {
99100 const platform = yield* HostProcessPlatform;
100101 const mainWindowRef = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());