@niyamulahsan/create-deskapp 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +6 -0
  2. package/bin/create.js +1 -1
  3. package/package.json +1 -1
  4. package/template/.env +1 -1
  5. package/template/src/config/winsetup.ts +91 -0
  6. package/template/src/core/api/generate.manifest.ts +4 -10
  7. package/template/src/core/api/registry.ts +1 -1
  8. package/template/src/core/config.ts +2 -2
  9. package/template/src/core/database/aggregate.ts +1 -1
  10. package/template/src/core/database/connection.ts +11 -11
  11. package/template/src/core/database/migrate-hooks.ts +1 -1
  12. package/template/src/core/database/paginate.ts +9 -9
  13. package/template/src/core/database/reset.ts +2 -2
  14. package/template/src/core/database/seed.ts +3 -5
  15. package/template/src/core/database/status.ts +4 -1
  16. package/template/src/core/env.ts +1 -1
  17. package/template/src/core/facade.ts +3 -1
  18. package/template/src/core/maker/db/fresh.ts +2 -2
  19. package/template/src/core/maker/db/generate.ts +1 -1
  20. package/template/src/core/maker/db/migrate.ts +3 -4
  21. package/template/src/core/maker/db/mod.ts +47 -19
  22. package/template/src/core/maker/db/module-migrate.ts +7 -6
  23. package/template/src/core/maker/db/push.ts +1 -1
  24. package/template/src/core/maker/db/reset.ts +1 -1
  25. package/template/src/core/maker/db/seed.ts +1 -1
  26. package/template/src/core/maker/db/status.ts +1 -1
  27. package/template/src/core/maker/help.ts +6 -15
  28. package/template/src/core/maker/make/controller.ts +5 -10
  29. package/template/src/core/maker/make/helpers.ts +6 -8
  30. package/template/src/core/maker/make/mod.ts +13 -14
  31. package/template/src/core/maker/make/model.ts +1 -1
  32. package/template/src/core/maker/make/module.ts +6 -29
  33. package/template/src/core/maker/make/seeder.ts +2 -2
  34. package/template/src/core/maker/make/test.ts +3 -3
  35. package/template/src/core/maker/mod.ts +4 -4
  36. package/template/src/core/maker/run/mod.ts +34 -14
  37. package/template/src/core/utils/playwright.ts +25 -25
  38. package/template/src/core/utils/queue.ts +17 -10
  39. package/template/src/core/utils/scheduler.ts +7 -17
  40. package/template/src/core/utils/storage.ts +1 -1
  41. package/template/src/core/utils/validation.ts +3 -3
  42. package/template/src/database/migrations/sqlite/meta/_journal.json +5 -1
  43. package/template/src/main.ts +10 -6
  44. package/template/src/preload.ts +1 -1
  45. package/template/src/window/app-menu.ts +81 -0
  46. package/template/src/window/config.ts +10 -69
  47. package/template/src/window/context-menu.ts +14 -0
  48. package/template/src/window/dialogs.ts +23 -0
  49. package/template/src/window/manager.ts +5 -5
  50. package/template/src/window/native.ts +40 -215
  51. package/template/src/window/tray.ts +79 -0
  52. package/template/src/ui/src/plugins/gum.ts.bak +0 -683
@@ -26,10 +26,10 @@ export const validate = {
26
26
  throw {
27
27
  status: 422,
28
28
  message: "Validation failed",
29
- errors: result.error.flatten(),
29
+ errors: result.error.flatten()
30
30
  };
31
31
  }
32
32
 
33
33
  return result.data;
34
- },
35
- };
34
+ }
35
+ };
@@ -1 +1,5 @@
1
- {"version":"7","dialect":"sqlite","entries":[]}
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": []
5
+ }
@@ -1,12 +1,12 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { windowDev, windows } from "@config/winsetup";
3
4
  import { app, BrowserWindow, dialog } from "electron";
4
5
  import { bindAll } from "@/core/api/registry";
5
6
  import { config } from "@/core/config";
6
7
  import { loadEnv } from "@/core/env";
7
8
  import { chrome, cron, db, win } from "@/core/facade";
8
9
  import { storage } from "@/core/utils/storage";
9
- import { windows } from "@/window/config";
10
10
 
11
11
  function logFatal(err: unknown): void {
12
12
  const msg = err instanceof Error ? `${err.stack || err.message}` : String(err);
@@ -74,20 +74,24 @@ if (!gotLock) {
74
74
  if (!created.isDestroyed()) created.show();
75
75
  });
76
76
 
77
- if (isMain && preset.chrome !== false) {
78
- chrome.setupDesktopChrome(created);
77
+ if (isMain) {
78
+ const chromeParts = chrome.resolveChrome(preset.chrome);
79
+ if (chromeParts.appMenu || chromeParts.contextMenu || chromeParts.tray) {
80
+ chrome.setupDesktopChrome(created, chromeParts);
81
+ }
79
82
  }
80
83
  isMain = false;
81
84
 
82
85
  if (devUrl) {
83
86
  const route = preset.route || "/";
84
87
  await created.loadURL(`${devUrl}${route}`);
85
- if (isDev) {
86
- created.webContents.openDevTools({ mode: "bottom" });
87
- }
88
88
  } else {
89
89
  await created.loadFile(getRendererIndexPath());
90
90
  }
91
+
92
+ if (isDev && windowDev.devTools !== "none") {
93
+ created.webContents.openDevTools({ mode: windowDev.devTools });
94
+ }
91
95
  }
92
96
  } else {
93
97
  // Headless mode: No windows, just a tray icon.
@@ -32,4 +32,4 @@ try {
32
32
  console.log(`[preload] module bridge ready (${names.length} handlers) as \`md\`/\`bindings\``);
33
33
  } catch (err) {
34
34
  console.error("[preload] failed to expose bindings", err);
35
- }
35
+ }
@@ -0,0 +1,81 @@
1
+ import { Menu } from "electron";
2
+ import { type DesktopWindow, win as winApi } from "@/window/manager";
3
+
4
+ export interface MenuRole {
5
+ role: string;
6
+ }
7
+ export interface MenuActionItem {
8
+ item: { label: string; id?: string; accelerator?: string; enabled?: boolean };
9
+ }
10
+ export interface MenuSubmenu {
11
+ submenu: { label: string; items: MenuItem[] };
12
+ }
13
+ export type MenuItem = MenuActionItem | MenuSubmenu | "separator" | { role: MenuRole };
14
+
15
+ // Map our custom MenuItem types to Electron's MenuItemConstructorOptions
16
+ export function toElectronMenu(items: MenuItem[]): Electron.MenuItemConstructorOptions[] {
17
+ return items.map((item) => {
18
+ if (item === "separator") return { type: "separator" };
19
+ if ("role" in item) return { role: item.role.role as any };
20
+ if ("item" in item) {
21
+ return {
22
+ label: item.item.label,
23
+ id: item.item.id,
24
+ accelerator: item.item.accelerator,
25
+ enabled: item.item.enabled,
26
+ click: () => {
27
+ // Forward clicks to the window's custom event if needed,
28
+ // or handle globally
29
+ const mainWin = winApi.getWindow();
30
+ if (mainWin && item.item.id) {
31
+ // Emulate Deno's event by executing custom JS or sending IPC
32
+ mainWin.webContents.send("menu-click", item.item.id);
33
+ }
34
+ }
35
+ };
36
+ }
37
+ if ("submenu" in item) {
38
+ return {
39
+ label: item.submenu.label,
40
+ submenu: toElectronMenu(item.submenu.items)
41
+ };
42
+ }
43
+ return {};
44
+ });
45
+ }
46
+
47
+ export function defaultMenuItems(): MenuItem[] {
48
+ return [
49
+ {
50
+ submenu: {
51
+ label: "File",
52
+ items: [
53
+ { item: { label: "New", id: "new", accelerator: "CmdOrCtrl+N", enabled: true } },
54
+ { item: { label: "Open Settings", id: "openSettings", accelerator: "CmdOrCtrl+,", enabled: true } },
55
+ "separator",
56
+ { role: { role: "quit" } }
57
+ ]
58
+ }
59
+ },
60
+ {
61
+ submenu: {
62
+ label: "Edit",
63
+ items: [
64
+ { role: { role: "undo" } },
65
+ { role: { role: "redo" } },
66
+ "separator",
67
+ { role: { role: "cut" } },
68
+ { role: { role: "copy" } },
69
+ { role: { role: "paste" } }
70
+ ]
71
+ }
72
+ }
73
+ ];
74
+ }
75
+
76
+ export function installAppMenu(win: DesktopWindow): void {
77
+ // Set menu for the main window (also sets application menu on Windows/Linux).
78
+ const menu = Menu.buildFromTemplate(toElectronMenu(defaultMenuItems()));
79
+ win.setMenu(menu);
80
+ Menu.setApplicationMenu(menu);
81
+ }
@@ -1,71 +1,12 @@
1
1
  /**
2
- * window/config.ts - native window configuration (Electron).
3
- *
4
- * Tune windows here instead of touching src/main.ts. Each entry in `windows`
5
- * becomes a native BrowserWindow. The first entry is the main window.
6
- *
7
- * `route` is the in-app path each window loads on startup (frontend router).
8
- * Omit it to stay on "/".
2
+ * Backward-compat re-export. Window base setup lives in src/config/winsetup.ts.
9
3
  */
10
-
11
- import { config } from "@/core/config";
12
-
13
- export interface WindowPreset {
14
- /** Window title. Falls back to the app name if unset. */
15
- title: string;
16
- /** Initial width in logical pixels. */
17
- width: number;
18
- /** Initial height in logical pixels. */
19
- height: number;
20
- /** Initial horizontal position; centered if omitted. */
21
- x?: number;
22
- /** Initial vertical position; centered if omitted. */
23
- y?: number;
24
- /** Whether the user can resize the window. */
25
- resizable?: boolean;
26
- /** Keep the window above others. */
27
- alwaysOnTop?: boolean;
28
- /** Remove the title bar and window chrome (creation-only). */
29
- frameless?: boolean;
30
- /** Floating, non-activating panel that doesn't steal focus (creation-only). */
31
- noActivate?: boolean;
32
- /** Blend the title bar into the content (creation-only). */
33
- transparentTitlebar?: boolean;
34
- /** In-app path the window loads on startup (frontend route). */
35
- route?: string;
36
- /**
37
- * Install the default desktop chrome (app menu, context menu, tray) at
38
- * startup. Only honoured for the FIRST (main) window — openWindow() windows
39
- * never get it. Omit (or set `true`) to keep it, `false` to disable.
40
- */
41
- chrome?: boolean;
42
- }
43
-
44
- /**
45
- * Named window presets. Only these open at boot. The "main" entry is always
46
- * created first (it adopts the shutdown window); every extra entry also opens
47
- * as a fresh window at startup.
48
- *
49
- * Windows for runtime use (opened on a button click, a menu item, etc.) are
50
- * NOT declared here — pass a `WindowPreset` straight to `win.openWindow()`:
51
- *
52
- * import { win } from "@/core/facade.ts";
53
- * await win.openWindow({ title: "Help", width: 760, height: 600, route: "/help" });
54
- *
55
- * Every such window is individual: its own close (×) button closes only that
56
- * window. The app exits when the last window is closed.
57
- */
58
- export const windows: Record<string, WindowPreset> = {
59
- main: {
60
- title: config.appName,
61
- width: 900,
62
- height: 600,
63
- resizable: true,
64
- alwaysOnTop: false,
65
- route: "/",
66
- chrome: true
67
- }
68
- };
69
-
70
- /** The main (first-created) window preset. */
71
- export const windowConfig: WindowPreset = windows.main;
4
+ export {
5
+ type ChromeParts,
6
+ type DevToolsMode,
7
+ resolveChrome,
8
+ type WindowPreset,
9
+ windowConfig,
10
+ windowDev,
11
+ windows
12
+ } from "@config/winsetup";
@@ -0,0 +1,14 @@
1
+ import { Menu } from "electron";
2
+ import type { DesktopWindow } from "@/window/manager";
3
+
4
+ export function installContextMenu(win: DesktopWindow): void {
5
+ win.webContents.on("context-menu", (_event, _params) => {
6
+ const menu = Menu.buildFromTemplate([
7
+ { role: "copy" },
8
+ { role: "paste" },
9
+ { type: "separator" },
10
+ { label: "Reload", click: () => win.reload() }
11
+ ]);
12
+ menu.popup({ window: win });
13
+ });
14
+ }
@@ -1,5 +1,28 @@
1
1
  import { BrowserWindow, dialog } from "electron";
2
2
 
3
+ // ---------------------------------------------------------------------------
4
+ // Message dialogs (confirm / alert / prompt)
5
+ // ---------------------------------------------------------------------------
6
+
7
+ export async function confirmDialog(message: string): Promise<boolean> {
8
+ const result = await dialog.showMessageBox({
9
+ type: "question",
10
+ buttons: ["Cancel", "OK"],
11
+ title: "Confirm",
12
+ message: message
13
+ });
14
+
15
+ return result.response === 1;
16
+ }
17
+
18
+ export async function alertDialog(message: string): Promise<void> {
19
+ await dialog.showMessageBox({
20
+ type: "info",
21
+ title: "Alert",
22
+ message: message
23
+ });
24
+ }
25
+
3
26
  export interface PickOpenOptions {
4
27
  title?: string;
5
28
  filter?: string; // Electron uses extensions array, but we can parse your string
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { app, BrowserWindow } from "electron";
3
- import { type WindowPreset, windowConfig, windows as windowPresets } from "@/window/config";
4
3
  import { closeDatabase } from "@/core/database/connection";
4
+ import { type WindowPreset, windowConfig, windows as windowPresets } from "@/window/config";
5
5
 
6
6
  // We map your custom options to Electron's expected options
7
7
  export interface BrowserWindowOptions extends WindowPreset {}
@@ -52,8 +52,8 @@ function createWindow(options?: BrowserWindowOptions, name?: string, preloadPath
52
52
  preload: resolvedPreload,
53
53
  contextIsolation: true,
54
54
  nodeIntegration: false,
55
- sandbox: false,
56
- },
55
+ sandbox: false
56
+ }
57
57
  });
58
58
 
59
59
  const winId = win.id;
@@ -135,5 +135,5 @@ export const win = {
135
135
  getWindow,
136
136
  getWindowCount,
137
137
  openWindow,
138
- watchFrontend,
139
- };
138
+ watchFrontend
139
+ };
@@ -1,215 +1,40 @@
1
- import path from "node:path";
2
- import { app, dialog, Menu, nativeImage, Tray } from "electron";
3
- import { config } from "@/core/config";
4
- import { type DesktopWindow, win as winApi } from "@/window/manager";
5
-
6
- export interface DesktopTray extends Tray {}
7
- export interface MenuRole {
8
- role: string;
9
- }
10
- export interface MenuActionItem {
11
- item: { label: string; id?: string; accelerator?: string; enabled?: boolean };
12
- }
13
- export interface MenuSubmenu {
14
- submenu: { label: string; items: MenuItem[] };
15
- }
16
- export type MenuItem = MenuActionItem | MenuSubmenu | "separator" | { role: MenuRole };
17
-
18
- // Map our custom MenuItem types to Electron's MenuItemConstructorOptions
19
- function toElectronMenu(items: MenuItem[]): Electron.MenuItemConstructorOptions[] {
20
- return items.map((item) => {
21
- if (item === "separator") return { type: "separator" };
22
- if ("role" in item) return { role: item.role.role as any };
23
- if ("item" in item) {
24
- return {
25
- label: item.item.label,
26
- id: item.item.id,
27
- accelerator: item.item.accelerator,
28
- enabled: item.item.enabled,
29
- click: () => {
30
- // Forward clicks to the window's custom event if needed,
31
- // or handle globally
32
- const mainWin = winApi.getWindow();
33
- if (mainWin && item.item.id) {
34
- // Emulate Deno's event by executing custom JS or sending IPC
35
- mainWin.webContents.send("menu-click", item.item.id);
36
- }
37
- }
38
- };
39
- }
40
- if ("submenu" in item) {
41
- return {
42
- label: item.submenu.label,
43
- submenu: toElectronMenu(item.submenu.items)
44
- };
45
- }
46
- return {};
47
- });
48
- }
49
-
50
- let tray: Tray | null = null;
51
-
52
- function getTrayIconPath(): string {
53
- // Bundle-safe: resolve from the app root (works in dev and packaged builds).
54
- return path.join(app.getAppPath(), "src", "icons", "tray.png");
55
- }
56
-
57
- function createTray(): Tray | undefined {
58
- try {
59
- const iconPath = getTrayIconPath();
60
- const icon = nativeImage.createFromPath(iconPath);
61
- if (icon.isEmpty()) return undefined;
62
- tray = new Tray(icon);
63
- return tray;
64
- } catch {
65
- return undefined;
66
- }
67
- }
68
-
69
- function isTrayAvailable(): boolean {
70
- return true;
71
- }
72
-
73
- async function confirmDialog(message: string): Promise<boolean> {
74
- const result = await dialog.showMessageBox({
75
- type: "question",
76
- buttons: ["Cancel", "OK"],
77
- title: "Confirm",
78
- message: message
79
- });
80
- return result.response === 1;
81
- }
82
-
83
- async function alertDialog(message: string): Promise<void> {
84
- await dialog.showMessageBox({
85
- type: "info",
86
- title: "Alert",
87
- message: message
88
- });
89
- }
90
-
91
- async function promptDialog(message: string, defaultValue?: string): Promise<string | null> {
92
- // Electron doesn't have a native prompt dialog, so we'd need a custom HTML modal.
93
- // For now, we fallback to confirm as a stub.
94
- console.warn("promptDialog not natively supported in Electron");
95
- return null;
96
- }
97
-
98
- function defaultMenuItems(): MenuItem[] {
99
- return [
100
- {
101
- submenu: {
102
- label: "File",
103
- items: [
104
- { item: { label: "New", id: "new", accelerator: "CmdOrCtrl+N", enabled: true } },
105
- { item: { label: "Open Settings", id: "openSettings", accelerator: "CmdOrCtrl+,", enabled: true } },
106
- "separator",
107
- { role: { role: "quit" } }
108
- ]
109
- }
110
- },
111
- {
112
- submenu: {
113
- label: "Edit",
114
- items: [
115
- { role: { role: "undo" } },
116
- { role: { role: "redo" } },
117
- "separator",
118
- { role: { role: "cut" } },
119
- { role: { role: "copy" } },
120
- { role: { role: "paste" } }
121
- ]
122
- }
123
- }
124
- ];
125
- }
126
-
127
- function installAppMenu(win: DesktopWindow): void {
128
- // Set menu for the main window (also sets application menu on Windows/Linux).
129
- const menu = Menu.buildFromTemplate(toElectronMenu(defaultMenuItems()));
130
- win.setMenu(menu);
131
- Menu.setApplicationMenu(menu);
132
- }
133
-
134
- function createAppTray(): Tray | undefined {
135
- const t = createTray();
136
- if (!t) return undefined;
137
-
138
- t.setToolTip(config.appName);
139
-
140
- const contextMenu = Menu.buildFromTemplate([
141
- {
142
- label: "Show window",
143
- click: () => {
144
- winApi.getWindow()?.show();
145
- winApi.getWindow()?.focus();
146
- }
147
- },
148
- {
149
- label: "Open Settings",
150
- click: () => {
151
- void winApi.openWindow({ title: "Settings", width: 420, height: 320 });
152
- }
153
- },
154
- { type: "separator" },
155
- { label: "Quit", click: () => app.quit() }
156
- ]);
157
-
158
- t.setContextMenu(contextMenu);
159
- return t;
160
- }
161
-
162
- function installContextMenu(win: DesktopWindow): void {
163
- win.webContents.on("context-menu", (event, params) => {
164
- const menu = Menu.buildFromTemplate([
165
- { role: "copy" },
166
- { role: "paste" },
167
- { type: "separator" },
168
- { label: "Reload", click: () => win.reload() }
169
- ]);
170
- menu.popup({ window: win });
171
- });
172
- }
173
-
174
- function setupDesktopChrome(win: DesktopWindow): void {
175
- installAppMenu(win);
176
- installContextMenu(win);
177
- createAppTray();
178
- }
179
-
180
- function createHeadlessTray(): Tray | undefined {
181
- const t = createTray();
182
- if (!t) return undefined;
183
-
184
- t.setToolTip(`${config.appName} (headless)`);
185
- t.setContextMenu(
186
- Menu.buildFromTemplate([
187
- { label: `${config.appName} is running - no UI`, enabled: false },
188
- { type: "separator" },
189
- { label: "Quit", click: () => app.quit() }
190
- ])
191
- );
192
-
193
- return t;
194
- }
195
-
196
- function hideDock(): void {
197
- if (process.platform === "darwin" && app.dock) {
198
- app.dock.hide();
199
- }
200
- }
201
-
202
- export const chrome = {
203
- createTray,
204
- isTrayAvailable,
205
- confirmDialog,
206
- alertDialog,
207
- promptDialog,
208
- defaultMenuItems,
209
- installAppMenu,
210
- createAppTray,
211
- installContextMenu,
212
- setupDesktopChrome,
213
- createHeadlessTray,
214
- hideDock
215
- };
1
+ import type { ChromeParts } from "@config/winsetup";
2
+ import { resolveChrome } from "@config/winsetup";
3
+ import { defaultMenuItems, installAppMenu } from "./app-menu";
4
+ import { installContextMenu } from "./context-menu";
5
+ import { alertDialog, confirmDialog } from "./dialogs";
6
+ import type { DesktopWindow } from "./manager";
7
+ import { createAppTray, createHeadlessTray, createTray, hideDock, isTrayAvailable } from "./tray";
8
+
9
+ export type { MenuActionItem, MenuItem, MenuRole, MenuSubmenu } from "@/window/app-menu";
10
+ export type { DesktopTray } from "@/window/tray";
11
+ export type { ChromeParts };
12
+
13
+ /**
14
+ * Install desktop chrome for a window. Pass `parts` for granular control;
15
+ * defaults to all enabled (backward compatible).
16
+ */
17
+ function setupDesktopChrome(win: DesktopWindow, parts: Required<ChromeParts> = { appMenu: true, contextMenu: true, tray: true }): void {
18
+ if (parts.appMenu) installAppMenu(win);
19
+ if (parts.contextMenu) installContextMenu(win);
20
+ if (parts.tray) createAppTray();
21
+ }
22
+
23
+ export const chrome = {
24
+ // Tray
25
+ createTray,
26
+ isTrayAvailable,
27
+ createAppTray,
28
+ createHeadlessTray,
29
+ hideDock,
30
+ // Dialogs
31
+ confirmDialog,
32
+ alertDialog,
33
+ // Menu
34
+ defaultMenuItems,
35
+ installAppMenu,
36
+ installContextMenu,
37
+ // Orchestration
38
+ setupDesktopChrome,
39
+ resolveChrome
40
+ };
@@ -0,0 +1,79 @@
1
+ import path from "node:path";
2
+ import { app, Menu, nativeImage, Tray } from "electron";
3
+ import { config } from "@/core/config";
4
+ import { win as winApi } from "@/window/manager";
5
+
6
+ export interface DesktopTray extends Tray {}
7
+
8
+ let tray: Tray | null = null;
9
+
10
+ function getTrayIconPath(): string {
11
+ // Bundle-safe: resolve from the app root (works in dev and packaged builds).
12
+ return path.join(app.getAppPath(), "src", "icons", "tray.png");
13
+ }
14
+
15
+ export function createTray(): Tray | undefined {
16
+ try {
17
+ const iconPath = getTrayIconPath();
18
+ const icon = nativeImage.createFromPath(iconPath);
19
+ if (icon.isEmpty()) return undefined;
20
+ tray = new Tray(icon);
21
+ return tray;
22
+ } catch {
23
+ return undefined;
24
+ }
25
+ }
26
+
27
+ export function isTrayAvailable(): boolean {
28
+ return true;
29
+ }
30
+
31
+ export function createAppTray(): Tray | undefined {
32
+ const t = createTray();
33
+ if (!t) return undefined;
34
+
35
+ t.setToolTip(config.appName);
36
+
37
+ const contextMenu = Menu.buildFromTemplate([
38
+ {
39
+ label: "Show window",
40
+ click: () => {
41
+ winApi.getWindow()?.show();
42
+ winApi.getWindow()?.focus();
43
+ }
44
+ },
45
+ {
46
+ label: "Open Settings",
47
+ click: () => {
48
+ void winApi.openWindow({ title: "Settings", width: 420, height: 320 });
49
+ }
50
+ },
51
+ { type: "separator" },
52
+ { label: "Quit", click: () => app.quit() }
53
+ ]);
54
+
55
+ t.setContextMenu(contextMenu);
56
+ return t;
57
+ }
58
+
59
+ export function createHeadlessTray(): Tray | undefined {
60
+ const t = createTray();
61
+ if (!t) return undefined;
62
+
63
+ t.setToolTip(`${config.appName} (headless)`);
64
+ t.setContextMenu(
65
+ Menu.buildFromTemplate([
66
+ { label: `${config.appName} is running - no UI`, enabled: false },
67
+ { type: "separator" },
68
+ { label: "Quit", click: () => app.quit() }
69
+ ])
70
+ );
71
+
72
+ return t;
73
+ }
74
+
75
+ export function hideDock(): void {
76
+ if (process.platform === "darwin" && app.dock) {
77
+ app.dock.hide();
78
+ }
79
+ }