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>>(...@@ -98,6 +98,7 @@ const addScopedAppListener = <Args extends ReadonlyArray<unknown>>(
98 }),98 }),
99 ).pipe(Effect.asVoid);99 ).pipe(Effect.asVoid);
100100
101/** @public Service construction is part of the canonical Effect module API. */
101export const make = ElectronApp.of({102export const make = ElectronApp.of({
102 metadata: Effect.gen(function* () {103 metadata: Effect.gen(function* () {
103 const appVersion = yield* Effect.try({104 const appVersion = yield* Effect.try({
apps/desktop/src/electron/ElectronDialog.ts+1
...@@ -102,6 +102,7 @@ export class ElectronDialog extends Context.Service<...@@ -102,6 +102,7 @@ export class ElectronDialog extends Context.Service<
102 }102 }
103>()("@t3tools/desktop/electron/ElectronDialog") {}103>()("@t3tools/desktop/electron/ElectronDialog") {}
104104
105/** @public Service construction is part of the canonical Effect module API. */
105export const make = ElectronDialog.of({106export const make = ElectronDialog.of({
106 pickFolder: Effect.fn("desktop.electron.dialog.pickFolder")(function* (input) {107 pickFolder: Effect.fn("desktop.electron.dialog.pickFolder")(function* (input) {
107 const ownerWindowId = Option.match(input.owner, {108 const ownerWindowId = Option.match(input.owner, {
apps/desktop/src/electron/ElectronMenu.ts+1
...@@ -110,6 +110,7 @@ const normalizePosition = (...@@ -110,6 +110,7 @@ const normalizePosition = (
110 Option.map(({ x, y }) => ({ x: Math.floor(x * zoomFactor), y: Math.floor(y * zoomFactor) })),110 Option.map(({ x, y }) => ({ x: Math.floor(x * zoomFactor), y: Math.floor(y * zoomFactor) })),
111 );111 );
112112
113/** @public Service construction is part of the canonical Effect module API. */
113export const make = Effect.gen(function* () {114export const make = Effect.gen(function* () {
114 const platform = yield* HostProcessPlatform;115 const platform = yield* HostProcessPlatform;
115 let destructiveMenuIconCache: Option.Option<Electron.NativeImage> | undefined;116 let destructiveMenuIconCache: Option.Option<Electron.NativeImage> | undefined;
apps/desktop/src/electron/ElectronPowerMonitor.ts+1
...@@ -75,6 +75,7 @@ const onSpeedLimitChange: ElectronPowerMonitor["Service"]["onSpeedLimitChange"]...@@ -75,6 +75,7 @@ const onSpeedLimitChange: ElectronPowerMonitor["Service"]["onSpeedLimitChange"]
75 ).pipe(Effect.asVoid);75 ).pipe(Effect.asVoid);
76};76};
7777
78/** @public Service construction is part of the canonical Effect module API. */
78export const make = ElectronPowerMonitor.of({79export const make = ElectronPowerMonitor.of({
79 isOnBatteryPower: Effect.sync(() => Electron.powerMonitor.isOnBatteryPower()),80 isOnBatteryPower: Effect.sync(() => Electron.powerMonitor.isOnBatteryPower()),
80 getSystemIdleTime: Effect.sync(() => Electron.powerMonitor.getSystemIdleTime()),81 getSystemIdleTime: Effect.sync(() => Electron.powerMonitor.getSystemIdleTime()),
apps/desktop/src/electron/ElectronProtocol.ts+5-4
...@@ -9,14 +9,14 @@ import * as Scope from "effect/Scope";...@@ -9,14 +9,14 @@ import * as Scope from "effect/Scope";
9import * as Electron from "electron";9import * as Electron from "electron";
1010
11export const DESKTOP_HOST = "app";11export const DESKTOP_HOST = "app";
12export const DESKTOP_PRODUCTION_SCHEME = "t3code";12const DESKTOP_PRODUCTION_SCHEME = "t3code";
13export const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";13const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";
1414
15export function getDesktopScheme(isDevelopment: boolean): string {15export function getDesktopScheme(isDevelopment: boolean): string {
16 return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;16 return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;
17}17}
1818
19export function getDesktopOrigin(isDevelopment: boolean): string {19function getDesktopOrigin(isDevelopment: boolean): string {
20 return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`;20 return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`;
21}21}
2222
...@@ -109,7 +109,7 @@ function withContentSecurityPolicy(response: Response, policy: string): Response...@@ -109,7 +109,7 @@ function withContentSecurityPolicy(response: Response, policy: string): Response
109/**109/**
110 * Must run synchronously during process bootstrap, before Electron emits `ready`.110 * Must run synchronously during process bootstrap, before Electron emits `ready`.
111 */111 */
112export function registerDesktopSchemePrivilegesSync(): void {112function registerDesktopSchemePrivilegesSync(): void {
113 Electron.protocol.registerSchemesAsPrivileged([113 Electron.protocol.registerSchemesAsPrivileged([
114 {114 {
115 scheme: DESKTOP_PRODUCTION_SCHEME,115 scheme: DESKTOP_PRODUCTION_SCHEME,
...@@ -205,6 +205,7 @@ async function fetchWithTransientRetry(url: string, init: RequestInit): Promise<...@@ -205,6 +205,7 @@ async function fetchWithTransientRetry(url: string, init: RequestInit): Promise<
205 throw lastError;205 throw lastError;
206}206}
207207
208/** @public Service construction is part of the canonical Effect module API. */
208export const make = Effect.gen(function* () {209export const make = Effect.gen(function* () {
209 const registered = yield* Ref.make(false);210 const registered = yield* Ref.make(false);
210211
apps/desktop/src/electron/ElectronSafeStorage.ts+1-1
...@@ -50,7 +50,6 @@ export const ElectronSafeStorageError = Schema.Union([...@@ -50,7 +50,6 @@ export const ElectronSafeStorageError = Schema.Union([
50 ElectronSafeStorageDecryptError,50 ElectronSafeStorageDecryptError,
51]);51]);
52export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type;52export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type;
53export const isElectronSafeStorageError = Schema.is(ElectronSafeStorageError);
5453
55export class ElectronSafeStorage extends Context.Service<54export class ElectronSafeStorage extends Context.Service<
56 ElectronSafeStorage,55 ElectronSafeStorage,
...@@ -66,6 +65,7 @@ export class ElectronSafeStorage extends Context.Service<...@@ -66,6 +65,7 @@ export class ElectronSafeStorage extends Context.Service<
66 }65 }
67>()("@t3tools/desktop/electron/ElectronSafeStorage") {}66>()("@t3tools/desktop/electron/ElectronSafeStorage") {}
6867
68/** @public Service construction is part of the canonical Effect module API. */
69export const make = Effect.gen(function* () {69export const make = Effect.gen(function* () {
70 const platform = yield* HostProcessPlatform;70 const platform = yield* HostProcessPlatform;
7171
apps/desktop/src/electron/ElectronShell.ts+1
...@@ -67,6 +67,7 @@ export class ElectronShell extends Context.Service<...@@ -67,6 +67,7 @@ export class ElectronShell extends Context.Service<
67 }67 }
68>()("@t3tools/desktop/electron/ElectronShell") {}68>()("@t3tools/desktop/electron/ElectronShell") {}
6969
70/** @public Service construction is part of the canonical Effect module API. */
70export const make = ElectronShell.of({71export const make = ElectronShell.of({
71 openExternal: (rawUrl) =>72 openExternal: (rawUrl) =>
72 Option.match(parseSafeExternalUrl(rawUrl), {73 Option.match(parseSafeExternalUrl(rawUrl), {
apps/desktop/src/electron/ElectronTheme.ts+1
...@@ -28,6 +28,7 @@ export class ElectronTheme extends Context.Service<...@@ -28,6 +28,7 @@ export class ElectronTheme extends Context.Service<
28 }28 }
29>()("@t3tools/desktop/electron/ElectronTheme") {}29>()("@t3tools/desktop/electron/ElectronTheme") {}
3030
31/** @public Service construction is part of the canonical Effect module API. */
31export const make = ElectronTheme.of({32export const make = ElectronTheme.of({
32 shouldUseDarkColors: Effect.sync(() => Electron.nativeTheme.shouldUseDarkColors),33 shouldUseDarkColors: Effect.sync(() => Electron.nativeTheme.shouldUseDarkColors),
33 setSource: (theme) =>34 setSource: (theme) =>
apps/desktop/src/electron/ElectronUpdater.ts+1
...@@ -80,6 +80,7 @@ export class ElectronUpdater extends Context.Service<...@@ -80,6 +80,7 @@ export class ElectronUpdater extends Context.Service<
80 }80 }
81>()("@t3tools/desktop/electron/ElectronUpdater") {}81>()("@t3tools/desktop/electron/ElectronUpdater") {}
8282
83/** @public Service construction is part of the canonical Effect module API. */
83export const make = ElectronUpdater.of({84export const make = ElectronUpdater.of({
84 setFeedURL: (options) =>85 setFeedURL: (options) =>
85 Effect.suspend(() => {86 Effect.suspend(() => {
apps/desktop/src/electron/ElectronWindow.ts+1
...@@ -95,6 +95,7 @@ export class ElectronWindow extends Context.Service<...@@ -95,6 +95,7 @@ export class ElectronWindow extends Context.Service<
95 }95 }
96>()("@t3tools/desktop/electron/ElectronWindow") {}96>()("@t3tools/desktop/electron/ElectronWindow") {}
9797
98/** @public Service construction is part of the canonical Effect module API. */
98export const make = Effect.gen(function* () {99export const make = Effect.gen(function* () {
99 const platform = yield* HostProcessPlatform;100 const platform = yield* HostProcessPlatform;
100 const mainWindowRef = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());101 const mainWindowRef = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());