@@ -8,6 +8,9 @@ import * as Schema from "effect/Schema";
88
99import * as Electron from "electron" ;
1010
11+ /**
12+ * Error raised when creating the Electron system tray instance fails.
13+ */
1114export 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+ */
2329export 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+ */
3645export 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+ */
4456export 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+ */
5267export 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+ */
6280const 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+ */
7596export 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+ */
152176export const layer = Layer . effect ( ElectronTray , make ) ;
0 commit comments