Skip to content

Commit 2b0df2c

Browse files
committed
docs(desktop): document DesktopTray and ElectronTray services
- Add JSDoc comments to exported classes, interfaces, and helper functions in DesktopTray and ElectronTray
1 parent 60f154c commit 2b0df2c

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎apps/desktop/src/app/DesktopTray.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import * as DesktopEnvironment from "./DesktopEnvironment.ts";
1212
import { makeComponentLogger } from "./DesktopObservability.ts";
1313
import * as DesktopWindow from "../window/DesktopWindow.ts";
1414

15+
/**
16+
* Error raised when configuring the high-level desktop system tray fails.
17+
*/
1518
export class DesktopTrayConfigureError extends Schema.TaggedErrorClass<DesktopTrayConfigureError>()(
1619
"DesktopTrayConfigureError",
1720
{
@@ -23,6 +26,9 @@ export class DesktopTrayConfigureError extends Schema.TaggedErrorClass<DesktopTr
2326
}
2427
}
2528

29+
/**
30+
* High-level service managing tray lifecycle, platform check, and availability status.
31+
*/
2632
export class DesktopTray extends Context.Service<
2733
DesktopTray,
2834
{
@@ -38,6 +44,9 @@ const {
3844
logWarning: logTrayWarning,
3945
} = makeComponentLogger("desktop-tray");
4046

47+
/**
48+
* Effect constructor creating the DesktopTray service.
49+
*/
4150
export const make = Effect.gen(function* () {
4251
const environment = yield* DesktopEnvironment.DesktopEnvironment;
4352
const desktopAssets = yield* DesktopAssets.DesktopAssets;
@@ -122,4 +131,7 @@ export const make = Effect.gen(function* () {
122131
});
123132
});
124133

134+
/**
135+
* Default live layer for DesktopTray.
136+
*/
125137
export const layer = Layer.effect(DesktopTray, make);

‎apps/desktop/src/electron/ElectronTray.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import * as Schema from "effect/Schema";
88

99
import * as Electron from "electron";
1010

11+
/**
12+
* Error raised when creating the Electron system tray instance fails.
13+
*/
1114
export class ElectronTrayCreateError extends Schema.TaggedErrorClass<ElectronTrayCreateError>()(
1215
"ElectronTrayCreateError",
1316
{
@@ -20,6 +23,9 @@ export class ElectronTrayCreateError extends Schema.TaggedErrorClass<ElectronTra
2023
}
2124
}
2225

26+
/**
27+
* Error raised when performing an operation on the system tray fails.
28+
*/
2329
export class ElectronTrayOperationError extends Schema.TaggedErrorClass<ElectronTrayOperationError>()(
2430
"ElectronTrayOperationError",
2531
{
@@ -33,6 +39,9 @@ export class ElectronTrayOperationError extends Schema.TaggedErrorClass<Electron
3339
}
3440
}
3541

42+
/**
43+
* Menu item configuration for constructing the tray context menu.
44+
*/
3645
export interface ElectronTrayMenuItem {
3746
readonly label?: string;
3847
readonly type?: "normal" | "separator" | "submenu" | "checkbox" | "radio";
@@ -41,6 +50,9 @@ export interface ElectronTrayMenuItem {
4150
readonly submenu?: readonly ElectronTrayMenuItem[];
4251
}
4352

53+
/**
54+
* Options for creating an Electron system tray.
55+
*/
4456
export interface ElectronTrayCreateOptions {
4557
readonly iconPath: string;
4658
readonly tooltip?: string;
@@ -49,6 +61,9 @@ export interface ElectronTrayCreateOptions {
4961
readonly onDoubleClick?: () => void;
5062
}
5163

64+
/**
65+
* Low-level service managing Electron's native system tray instance.
66+
*/
5267
export class ElectronTray extends Context.Service<
5368
ElectronTray,
5469
{
@@ -59,6 +74,9 @@ export class ElectronTray extends Context.Service<
5974
}
6075
>()("@t3tools/desktop/electron/ElectronTray") {}
6176

77+
/**
78+
* Recursively maps typed menu item descriptors to Electron MenuItemConstructorOptions.
79+
*/
6280
const mapMenuItems = (
6381
items: readonly ElectronTrayMenuItem[],
6482
): Electron.MenuItemConstructorOptions[] =>
@@ -72,6 +90,9 @@ const mapMenuItems = (
7290
return menuItem;
7391
});
7492

93+
/**
94+
* Effect constructor creating the ElectronTray service.
95+
*/
7596
export const make = Effect.gen(function* () {
7697
const platform = yield* HostProcessPlatform;
7798
const currentTrayRef = yield* Ref.make<Option.Option<Electron.Tray>>(Option.none());
@@ -149,4 +170,7 @@ export const make = Effect.gen(function* () {
149170
});
150171
});
151172

173+
/**
174+
* Default live layer for ElectronTray.
175+
*/
152176
export const layer = Layer.effect(ElectronTray, make);

0 commit comments

Comments
 (0)