@niyamulahsan/create-deskapp 1.2.2 → 1.2.4

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 (48) hide show
  1. package/package.json +1 -1
  2. package/template/.env +1 -1
  3. package/template/package.json +1 -2
  4. package/template/src/config/winsetup.ts +1 -1
  5. package/template/src/core/api/generate.manifest.ts +4 -10
  6. package/template/src/core/api/registry.ts +1 -1
  7. package/template/src/core/config.ts +2 -2
  8. package/template/src/core/database/aggregate.ts +1 -1
  9. package/template/src/core/database/connection.ts +11 -11
  10. package/template/src/core/database/migrate-hooks.ts +1 -1
  11. package/template/src/core/database/paginate.ts +9 -9
  12. package/template/src/core/database/reset.ts +2 -2
  13. package/template/src/core/database/seed.ts +3 -5
  14. package/template/src/core/database/status.ts +4 -1
  15. package/template/src/core/env.ts +1 -1
  16. package/template/src/core/maker/db/fresh.ts +2 -2
  17. package/template/src/core/maker/db/generate.ts +1 -1
  18. package/template/src/core/maker/db/migrate.ts +3 -4
  19. package/template/src/core/maker/db/mod.ts +47 -19
  20. package/template/src/core/maker/db/module-migrate.ts +7 -6
  21. package/template/src/core/maker/db/push.ts +1 -1
  22. package/template/src/core/maker/db/reset.ts +1 -1
  23. package/template/src/core/maker/db/seed.ts +1 -1
  24. package/template/src/core/maker/db/status.ts +1 -1
  25. package/template/src/core/maker/help.ts +6 -15
  26. package/template/src/core/maker/make/controller.ts +5 -10
  27. package/template/src/core/maker/make/helpers.ts +6 -8
  28. package/template/src/core/maker/make/mod.ts +13 -14
  29. package/template/src/core/maker/make/model.ts +1 -1
  30. package/template/src/core/maker/make/module.ts +6 -29
  31. package/template/src/core/maker/make/seeder.ts +2 -2
  32. package/template/src/core/maker/make/test.ts +3 -3
  33. package/template/src/core/maker/mod.ts +4 -4
  34. package/template/src/core/maker/run/mod.ts +34 -14
  35. package/template/src/core/utils/playwright.ts +25 -25
  36. package/template/src/core/utils/queue.ts +17 -10
  37. package/template/src/core/utils/scheduler.ts +7 -17
  38. package/template/src/core/utils/storage.ts +1 -1
  39. package/template/src/core/utils/validation.ts +3 -3
  40. package/template/src/database/migrations/sqlite/meta/_journal.json +5 -1
  41. package/template/src/main.ts +1 -3
  42. package/template/src/preload.ts +1 -1
  43. package/template/src/window/app-menu.ts +6 -0
  44. package/template/src/window/context-menu.ts +7 -0
  45. package/template/src/window/manager.ts +31 -3
  46. package/template/src/window/native.ts +8 -3
  47. package/template/src/window/tray.ts +64 -13
  48. package/template/src/ui/src/plugins/gum.ts.bak +0 -683
@@ -1,7 +1,7 @@
1
1
  import type { ChromeParts } from "@config/winsetup";
2
2
  import { resolveChrome } from "@config/winsetup";
3
- import { defaultMenuItems, installAppMenu } from "./app-menu";
4
- import { installContextMenu } from "./context-menu";
3
+ import { defaultMenuItems, installAppMenu, removeAppMenu } from "./app-menu";
4
+ import { disableContextMenu, installContextMenu } from "./context-menu";
5
5
  import { alertDialog, confirmDialog } from "./dialogs";
6
6
  import type { DesktopWindow } from "./manager";
7
7
  import { createAppTray, createHeadlessTray, createTray, hideDock, isTrayAvailable } from "./tray";
@@ -14,9 +14,14 @@ export type { ChromeParts };
14
14
  * Install desktop chrome for a window. Pass `parts` for granular control;
15
15
  * defaults to all enabled (backward compatible).
16
16
  */
17
- function setupDesktopChrome(win: DesktopWindow, parts: Required<ChromeParts> = { appMenu: true, contextMenu: true, tray: true }): void {
17
+ function setupDesktopChrome(
18
+ win: DesktopWindow,
19
+ parts: Required<ChromeParts> = { appMenu: true, contextMenu: true, tray: true },
20
+ ): void {
18
21
  if (parts.appMenu) installAppMenu(win);
22
+ else removeAppMenu(win);
19
23
  if (parts.contextMenu) installContextMenu(win);
24
+ else disableContextMenu(win);
20
25
  if (parts.tray) createAppTray();
21
26
  }
22
27
 
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import path from "node:path";
2
3
  import { app, Menu, nativeImage, Tray } from "electron";
3
4
  import { config } from "@/core/config";
@@ -7,18 +8,68 @@ export interface DesktopTray extends Tray {}
7
8
 
8
9
  let tray: Tray | null = null;
9
10
 
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");
11
+ // 16x16 red dot (known-good data URL) as guaranteed fallback so tray can still appear.
12
+ const FALLBACK_TRAY_ICON =
13
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABYSURBVHgB7ZMxDoAgDEXfQI7gERzFQw5u5BWMg4maNB8WBgeTPqHJb9qfAjgQCLZYkGIgnSWmmOMcRZ6LzF1k65s6UKMo15W1X9mHe3vK+3xM4QcM0wUogx/2yq6l8gAAAABJRU5ErkJggg==";
14
+
15
+ function getTrayIconCandidates(): string[] {
16
+ // In dev, main bundle runs from out/main so app.getAppPath() can resolve to out/main;
17
+ // project assets live at the project root (../../ from out/main). In packaged builds,
18
+ // app.getAppPath() points to the app root (or asar root) where src/icons is packaged.
19
+ const bases = app.isPackaged
20
+ ? [app.getAppPath()]
21
+ : [path.resolve(app.getAppPath(), "..", ".."), app.getAppPath(), process.cwd()];
22
+
23
+ const candidates: string[] = [];
24
+ for (const root of Array.from(new Set(bases))) {
25
+ const base = path.join(root, "src", "icons");
26
+ candidates.push(
27
+ path.join(base, "tray.png"),
28
+ path.join(base, "favicon-96x96.png"),
29
+ path.join(base, "favicon.ico"),
30
+ path.join(base, "web-app-manifest-192x192.png"),
31
+ path.join(base, "web-app-manifest-512x512.png"),
32
+ );
33
+ }
34
+ // Last resort: executable icon (Electron icon in dev, app icon when packaged).
35
+ candidates.push(process.execPath);
36
+ return candidates;
13
37
  }
14
38
 
15
39
  export function createTray(): Tray | undefined {
40
+ if (tray && !(tray as any).isDestroyed?.()) return tray;
16
41
  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;
42
+ for (const iconPath of getTrayIconCandidates()) {
43
+ try {
44
+ // Prefer passing a file path string directly (supported by Electron Tray).
45
+ if (fs.existsSync(iconPath)) {
46
+ try {
47
+ tray = new Tray(iconPath);
48
+ return tray;
49
+ } catch {}
50
+ }
51
+ const icon = nativeImage.createFromPath(iconPath);
52
+ if (!icon.isEmpty()) {
53
+ const size = icon.getSize();
54
+ const trayIcon = size.width > 32 ? icon.resize({ width: 16, height: 16 }) : icon;
55
+ tray = new Tray(trayIcon);
56
+ return tray;
57
+ }
58
+ } catch {
59
+ // try next candidate
60
+ }
61
+ }
62
+
63
+ // Guaranteed fallback so tray still appears even if files/exe icon can't be loaded.
64
+ try {
65
+ const fallback = nativeImage.createFromDataURL(FALLBACK_TRAY_ICON);
66
+ if (!fallback.isEmpty()) {
67
+ tray = new Tray(fallback);
68
+ return tray;
69
+ }
70
+ } catch {}
71
+
72
+ return undefined;
22
73
  } catch {
23
74
  return undefined;
24
75
  }
@@ -40,16 +91,16 @@ export function createAppTray(): Tray | undefined {
40
91
  click: () => {
41
92
  winApi.getWindow()?.show();
42
93
  winApi.getWindow()?.focus();
43
- }
94
+ },
44
95
  },
45
96
  {
46
97
  label: "Open Settings",
47
98
  click: () => {
48
99
  void winApi.openWindow({ title: "Settings", width: 420, height: 320 });
49
- }
100
+ },
50
101
  },
51
102
  { type: "separator" },
52
- { label: "Quit", click: () => app.quit() }
103
+ { label: "Quit", click: () => app.quit() },
53
104
  ]);
54
105
 
55
106
  t.setContextMenu(contextMenu);
@@ -65,8 +116,8 @@ export function createHeadlessTray(): Tray | undefined {
65
116
  Menu.buildFromTemplate([
66
117
  { label: `${config.appName} is running - no UI`, enabled: false },
67
118
  { type: "separator" },
68
- { label: "Quit", click: () => app.quit() }
69
- ])
119
+ { label: "Quit", click: () => app.quit() },
120
+ ]),
70
121
  );
71
122
 
72
123
  return t;