| author | |
| committer | |
| log | 5a853a4b4513467fd1be3d62fe7dc974cea07c3c |
| tree | fe244771ea4b966a0877c70836942f2cf9ba1dab |
| parent | 5b8a69c7b90b751507d0ab762dd77aaa2048408b |
| signature | Signed by PGP key B5690EEEBB952194 |
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); |
| 100 | 100 | ||
| 101 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 101 | export const make = ElectronApp.of({ | 102 | export 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") {} |
| 104 | 104 | ||
| 105 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 105 | export const make = ElectronDialog.of({ | 106 | export 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 | ); |
| 112 | 112 | ||
| 113 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 113 | export const make = Effect.gen(function* () { | 114 | export 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 | }; |
| 77 | 77 | ||
| 78 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 78 | export const make = ElectronPowerMonitor.of({ | 79 | export 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"; |
| 9 | import * as Electron from "electron"; | 9 | import * as Electron from "electron"; |
| 10 | 10 | ||
| 11 | export const DESKTOP_HOST = "app"; | 11 | export const DESKTOP_HOST = "app"; |
| 12 | export const DESKTOP_PRODUCTION_SCHEME = "t3code"; | 12 | const DESKTOP_PRODUCTION_SCHEME = "t3code"; |
| 13 | export const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev"; | 13 | const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev"; |
| 14 | 14 | ||
| 15 | export function getDesktopScheme(isDevelopment: boolean): string { | 15 | export 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 | } |
| 18 | 18 | ||
| 19 | export function getDesktopOrigin(isDevelopment: boolean): string { | 19 | function getDesktopOrigin(isDevelopment: boolean): string { |
| 20 | return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`; | 20 | return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| ... | @@ -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 | */ |
| 112 | export function registerDesktopSchemePrivilegesSync(): void { | 112 | function 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 | } |
| 207 | 207 | ||
| 208 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 208 | export const make = Effect.gen(function* () { | 209 | export const make = Effect.gen(function* () { |
| 209 | const registered = yield* Ref.make(false); | 210 | const registered = yield* Ref.make(false); |
| 210 | 211 |
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 | ]); |
| 52 | export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type; | 52 | export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type; |
| 53 | export const isElectronSafeStorageError = Schema.is(ElectronSafeStorageError); | ||
| 54 | 53 | ||
| 55 | export class ElectronSafeStorage extends Context.Service< | 54 | export 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") {} |
| 68 | 67 | ||
| 68 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 69 | export const make = Effect.gen(function* () { | 69 | export const make = Effect.gen(function* () { |
| 70 | const platform = yield* HostProcessPlatform; | 70 | const platform = yield* HostProcessPlatform; |
| 71 | 71 |
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") {} |
| 69 | 69 | ||
| 70 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 70 | export const make = ElectronShell.of({ | 71 | export 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") {} |
| 30 | 30 | ||
| 31 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 31 | export const make = ElectronTheme.of({ | 32 | export 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") {} |
| 82 | 82 | ||
| 83 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 83 | export const make = ElectronUpdater.of({ | 84 | export 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") {} |
| 97 | 97 | ||
| 98 | /** @public Service construction is part of the canonical Effect module API. */ | ||
| 98 | export const make = Effect.gen(function* () { | 99 | export 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()); |