@flighthq/host-electron 0.1.0

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 (94) hide show
  1. package/dist/electronApp.d.ts +4 -0
  2. package/dist/electronApp.d.ts.map +1 -0
  3. package/dist/electronApp.js +184 -0
  4. package/dist/electronApp.js.map +1 -0
  5. package/dist/electronClipboard.d.ts +4 -0
  6. package/dist/electronClipboard.d.ts.map +1 -0
  7. package/dist/electronClipboard.js +211 -0
  8. package/dist/electronClipboard.js.map +1 -0
  9. package/dist/electronDialog.d.ts +4 -0
  10. package/dist/electronDialog.d.ts.map +1 -0
  11. package/dist/electronDialog.js +85 -0
  12. package/dist/electronDialog.js.map +1 -0
  13. package/dist/electronIpc.d.ts +4 -0
  14. package/dist/electronIpc.d.ts.map +1 -0
  15. package/dist/electronIpc.js +21 -0
  16. package/dist/electronIpc.js.map +1 -0
  17. package/dist/electronMenu.d.ts +4 -0
  18. package/dist/electronMenu.d.ts.map +1 -0
  19. package/dist/electronMenu.js +59 -0
  20. package/dist/electronMenu.js.map +1 -0
  21. package/dist/electronModule.d.ts +368 -0
  22. package/dist/electronModule.d.ts.map +1 -0
  23. package/dist/electronModule.js +12 -0
  24. package/dist/electronModule.js.map +1 -0
  25. package/dist/electronNotification.d.ts +4 -0
  26. package/dist/electronNotification.d.ts.map +1 -0
  27. package/dist/electronNotification.js +134 -0
  28. package/dist/electronNotification.js.map +1 -0
  29. package/dist/electronPlatform.d.ts +4 -0
  30. package/dist/electronPlatform.d.ts.map +1 -0
  31. package/dist/electronPlatform.js +30 -0
  32. package/dist/electronPlatform.js.map +1 -0
  33. package/dist/electronPower.d.ts +4 -0
  34. package/dist/electronPower.d.ts.map +1 -0
  35. package/dist/electronPower.js +92 -0
  36. package/dist/electronPower.js.map +1 -0
  37. package/dist/electronProtocol.d.ts +4 -0
  38. package/dist/electronProtocol.d.ts.map +1 -0
  39. package/dist/electronProtocol.js +55 -0
  40. package/dist/electronProtocol.js.map +1 -0
  41. package/dist/electronRegister.d.ts +6 -0
  42. package/dist/electronRegister.d.ts.map +1 -0
  43. package/dist/electronRegister.js +62 -0
  44. package/dist/electronRegister.js.map +1 -0
  45. package/dist/electronScreen.d.ts +4 -0
  46. package/dist/electronScreen.d.ts.map +1 -0
  47. package/dist/electronScreen.js +68 -0
  48. package/dist/electronScreen.js.map +1 -0
  49. package/dist/electronShell.d.ts +4 -0
  50. package/dist/electronShell.d.ts.map +1 -0
  51. package/dist/electronShell.js +105 -0
  52. package/dist/electronShell.js.map +1 -0
  53. package/dist/electronShortcut.d.ts +4 -0
  54. package/dist/electronShortcut.d.ts.map +1 -0
  55. package/dist/electronShortcut.js +40 -0
  56. package/dist/electronShortcut.js.map +1 -0
  57. package/dist/electronStorage.d.ts +4 -0
  58. package/dist/electronStorage.d.ts.map +1 -0
  59. package/dist/electronStorage.js +75 -0
  60. package/dist/electronStorage.js.map +1 -0
  61. package/dist/electronTray.d.ts +4 -0
  62. package/dist/electronTray.d.ts.map +1 -0
  63. package/dist/electronTray.js +164 -0
  64. package/dist/electronTray.js.map +1 -0
  65. package/dist/electronUpdater.d.ts +4 -0
  66. package/dist/electronUpdater.d.ts.map +1 -0
  67. package/dist/electronUpdater.js +113 -0
  68. package/dist/electronUpdater.js.map +1 -0
  69. package/dist/electronWindow.d.ts +7 -0
  70. package/dist/electronWindow.d.ts.map +1 -0
  71. package/dist/electronWindow.js +417 -0
  72. package/dist/electronWindow.js.map +1 -0
  73. package/dist/index.d.ts +19 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +19 -0
  76. package/dist/index.js.map +1 -0
  77. package/package.json +54 -0
  78. package/src/electronApp.test.ts +141 -0
  79. package/src/electronClipboard.test.ts +86 -0
  80. package/src/electronDialog.test.ts +95 -0
  81. package/src/electronIpc.test.ts +47 -0
  82. package/src/electronMenu.test.ts +85 -0
  83. package/src/electronNotification.test.ts +97 -0
  84. package/src/electronPlatform.test.ts +28 -0
  85. package/src/electronPower.test.ts +110 -0
  86. package/src/electronProtocol.test.ts +63 -0
  87. package/src/electronRegister.test.ts +57 -0
  88. package/src/electronScreen.test.ts +92 -0
  89. package/src/electronShell.test.ts +67 -0
  90. package/src/electronShortcut.test.ts +56 -0
  91. package/src/electronStorage.test.ts +70 -0
  92. package/src/electronTray.test.ts +107 -0
  93. package/src/electronUpdater.test.ts +117 -0
  94. package/src/electronWindow.test.ts +217 -0
@@ -0,0 +1,92 @@
1
+ // Maps Flight's PowerBackend onto Electron's powerMonitor and powerSaveBlocker. The main process has
2
+ // no battery-level reading, so getStatus reports batteryLevel -1 and infers charging from the AC/
3
+ // battery flag. setKeepAwake holds a single display-sleep blocker id across calls.
4
+ export function createElectronPowerBackend(electron) {
5
+ const powerMonitor = electron.powerMonitor;
6
+ const powerSaveBlocker = electron.powerSaveBlocker;
7
+ let blockerId = -1;
8
+ return {
9
+ getStatus(out) {
10
+ const onBattery = powerMonitor.onBatteryPower === true;
11
+ out.batteryLevel = -1;
12
+ out.chargingTime = -1;
13
+ out.dischargingTime = -1;
14
+ out.isBatteryLow = false;
15
+ out.isCharging = !onBattery;
16
+ out.isLowPower = false;
17
+ out.isOnBattery = onBattery;
18
+ out.thermalState = 'Unknown';
19
+ return out;
20
+ },
21
+ getBatteryHealth() {
22
+ // Electron's main process exposes no battery-health detail; report none.
23
+ return null;
24
+ },
25
+ getSystemIdleState(thresholdSeconds) {
26
+ return toIdleState(powerMonitor.getSystemIdleState(thresholdSeconds));
27
+ },
28
+ getSystemIdleTime() {
29
+ return powerMonitor.getSystemIdleTime();
30
+ },
31
+ isKeepAwakeActive() {
32
+ return blockerId >= 0;
33
+ },
34
+ subscribe(listener) {
35
+ powerMonitor.on('on-battery', listener);
36
+ powerMonitor.on('on-ac', listener);
37
+ return () => {
38
+ powerMonitor.removeListener('on-battery', listener);
39
+ powerMonitor.removeListener('on-ac', listener);
40
+ };
41
+ },
42
+ subscribeLockScreen(listener) {
43
+ powerMonitor.on('lock-screen', listener);
44
+ return () => powerMonitor.removeListener('lock-screen', listener);
45
+ },
46
+ subscribeLowPowerModeChange() {
47
+ // Electron's powerMonitor has no low-power-mode event; inert unsubscribe.
48
+ return () => { };
49
+ },
50
+ subscribeResume(listener) {
51
+ powerMonitor.on('resume', listener);
52
+ return () => powerMonitor.removeListener('resume', listener);
53
+ },
54
+ subscribeSuspend(listener) {
55
+ powerMonitor.on('suspend', listener);
56
+ return () => powerMonitor.removeListener('suspend', listener);
57
+ },
58
+ subscribeThermalStateChange(listener) {
59
+ powerMonitor.on('thermal-state-change', listener);
60
+ return () => powerMonitor.removeListener('thermal-state-change', listener);
61
+ },
62
+ subscribeUnlockScreen(listener) {
63
+ powerMonitor.on('unlock-screen', listener);
64
+ return () => powerMonitor.removeListener('unlock-screen', listener);
65
+ },
66
+ setKeepAwake(enabled) {
67
+ try {
68
+ if (enabled && blockerId < 0) {
69
+ blockerId = powerSaveBlocker.start('prevent-display-sleep');
70
+ return true;
71
+ }
72
+ if (!enabled && blockerId >= 0) {
73
+ powerSaveBlocker.stop(blockerId);
74
+ blockerId = -1;
75
+ return true;
76
+ }
77
+ return enabled;
78
+ }
79
+ catch {
80
+ return false;
81
+ }
82
+ },
83
+ };
84
+ }
85
+ function toIdleState(state) {
86
+ if (state === 'active')
87
+ return 'Active';
88
+ if (state === 'idle' || state === 'locked')
89
+ return 'Idle';
90
+ return 'Unknown';
91
+ }
92
+ //# sourceMappingURL=electronPower.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronPower.js","sourceRoot":"","sources":["../src/electronPower.ts"],"names":[],"mappings":"AAIA,qGAAqG;AACrG,kGAAkG;AAClG,mFAAmF;AACnF,MAAM,UAAU,0BAA0B,CAAC,QAAqB;IAC9D,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC3C,MAAM,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;IACnD,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;IACnB,OAAO;QACL,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AAC,CAAC,CAAC;oBACf,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,KAA+C;IAClE,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACxC,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC1D,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ProtocolBackend } from '@flighthq/types';
2
+ import type { ElectronApi } from './electronModule';
3
+ export declare function createElectronProtocolBackend(electron: ElectronApi): ProtocolBackend;
4
+ //# sourceMappingURL=electronProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronProtocol.d.ts","sourceRoot":"","sources":["../src/electronProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKpD,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,WAAW,GAAG,eAAe,CAgDpF"}
@@ -0,0 +1,55 @@
1
+ // Maps Flight's ProtocolBackend onto Electron's `app` protocol-client methods. Deep links arrive via
2
+ // the 'open-url' event (macOs); the subscribe wrapper adapts Electron's (event, url) argument shape to
3
+ // Flight's (url) listener and returns an unsubscribe that removes that exact handler.
4
+ export function createElectronProtocolBackend(electron) {
5
+ const app = electron.app;
6
+ // Electron exposes no scheme enumeration, so the seam tracks what it has registered.
7
+ const registered = new Set();
8
+ return {
9
+ register(scheme) {
10
+ const ok = app.setAsDefaultProtocolClient(scheme);
11
+ if (ok)
12
+ registered.add(scheme);
13
+ return ok;
14
+ },
15
+ unregister(scheme) {
16
+ const ok = app.removeAsDefaultProtocolClient(scheme);
17
+ registered.delete(scheme);
18
+ return ok;
19
+ },
20
+ isRegistered(scheme) {
21
+ return app.isDefaultProtocolClient(scheme);
22
+ },
23
+ getRegisteredSchemes() {
24
+ return [...registered];
25
+ },
26
+ setAsDefault(scheme) {
27
+ const ok = app.setAsDefaultProtocolClient(scheme);
28
+ if (ok)
29
+ registered.add(scheme);
30
+ return ok;
31
+ },
32
+ isDefault(scheme) {
33
+ return app.isDefaultProtocolClient(scheme);
34
+ },
35
+ removeAsDefault(scheme) {
36
+ return app.removeAsDefaultProtocolClient(scheme);
37
+ },
38
+ getLaunchUrl() {
39
+ // Electron delivers the cold-start deep link via the 'open-url'/'second-instance' events rather
40
+ // than a queryable launch URL; report none.
41
+ return null;
42
+ },
43
+ drainPendingUrls() {
44
+ // No pre-attach buffer in this seam — deep links arrive live via the 'open-url' event.
45
+ return [];
46
+ },
47
+ subscribe(listener) {
48
+ // Electron passes (event, url); Flight wants just the url.
49
+ const handler = (...args) => listener(String(args[1] ?? ''));
50
+ app.on('open-url', handler);
51
+ return () => app.removeListener('open-url', handler);
52
+ },
53
+ };
54
+ }
55
+ //# sourceMappingURL=electronProtocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronProtocol.js","sourceRoot":"","sources":["../src/electronProtocol.ts"],"names":[],"mappings":"AAIA,qGAAqG;AACrG,uGAAuG;AACvG,sFAAsF;AACtF,MAAM,UAAU,6BAA6B,CAAC,QAAqB;IACjE,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IACzB,qFAAqF;IACrF,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,OAAO;QACL,QAAQ,CAAC,MAAM;YACb,MAAM,EAAE,GAAG,GAAG,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;YAClD,IAAI,EAAE;gBAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,UA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 import type { ElectronApi } from './electronModule';
2
+ export interface ElectronBackendOptions {
3
+ storageFileName?: string;
4
+ }
5
+ export declare function registerElectronBackends(electron: ElectronApi, options?: Readonly<ElectronBackendOptions>): void;
6
+ //# sourceMappingURL=electronRegister.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronRegister.d.ts","sourceRoot":"","sources":["../src/electronRegister.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAapD,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAaD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAE,QAAQ,CAAC,sBAAsB,CAAM,GAAG,IAAI,CAiBpH"}
@@ -0,0 +1,62 @@
1
+ import { setAppBackend } from '@flighthq/app';
2
+ import { setWindowBackend } from '@flighthq/application';
3
+ import { setClipboardBackend } from '@flighthq/clipboard';
4
+ import { setDialogBackend } from '@flighthq/dialog';
5
+ import { setIpcBackend } from '@flighthq/ipc';
6
+ import { setMenuBackend } from '@flighthq/menu';
7
+ import { setNotificationBackend } from '@flighthq/notification';
8
+ import { setPlatformBackend } from '@flighthq/platform';
9
+ import { setPowerBackend } from '@flighthq/power';
10
+ import { setProtocolBackend } from '@flighthq/protocol';
11
+ import { setScreenBackend } from '@flighthq/screen';
12
+ import { setShellBackend } from '@flighthq/shell';
13
+ import { setShortcutBackend } from '@flighthq/shortcut';
14
+ import { setStorageBackend } from '@flighthq/storage';
15
+ import { setTrayBackend } from '@flighthq/tray';
16
+ import { setUpdaterBackend } from '@flighthq/updater';
17
+ import { createElectronAppBackend } from './electronApp';
18
+ import { createElectronClipboardBackend } from './electronClipboard';
19
+ import { createElectronDialogBackend } from './electronDialog';
20
+ import { createElectronIpcBackend } from './electronIpc';
21
+ import { createElectronMenuBackend } from './electronMenu';
22
+ import { createElectronNotificationBackend } from './electronNotification';
23
+ import { createElectronPlatformBackend } from './electronPlatform';
24
+ import { createElectronPowerBackend } from './electronPower';
25
+ import { createElectronProtocolBackend } from './electronProtocol';
26
+ import { createElectronScreenBackend } from './electronScreen';
27
+ import { createElectronShellBackend } from './electronShell';
28
+ import { createElectronShortcutBackend } from './electronShortcut';
29
+ import { createElectronStorageBackend } from './electronStorage';
30
+ import { createElectronTrayBackend } from './electronTray';
31
+ import { createElectronUpdaterBackend } from './electronUpdater';
32
+ import { createElectronWindowBackend } from './electronWindow';
33
+ // Installs every Electron host backend into its capability package in one call. Run this once in the
34
+ // Electron main process, passing the `electron` module plus the real node:fs module (needed for the
35
+ // storage backend):
36
+ //
37
+ // import * as electron from 'electron';
38
+ // import * as fs from 'node:fs';
39
+ // registerElectronBackends({ ...electron, fs });
40
+ //
41
+ // After this, the platform/app/window seams resolve to their Electron implementations instead of the
42
+ // web defaults. Each set*Backend(null) (per package) reverts to the web default; there is no bulk
43
+ // unregister because backends are independent — clear the ones you replaced.
44
+ export function registerElectronBackends(electron, options = {}) {
45
+ setPlatformBackend(createElectronPlatformBackend(electron));
46
+ setAppBackend(createElectronAppBackend(electron));
47
+ setWindowBackend(createElectronWindowBackend(electron));
48
+ setDialogBackend(createElectronDialogBackend(electron));
49
+ setClipboardBackend(createElectronClipboardBackend(electron));
50
+ setMenuBackend(createElectronMenuBackend(electron));
51
+ setTrayBackend(createElectronTrayBackend(electron));
52
+ setShortcutBackend(createElectronShortcutBackend(electron));
53
+ setScreenBackend(createElectronScreenBackend(electron));
54
+ setPowerBackend(createElectronPowerBackend(electron));
55
+ setNotificationBackend(createElectronNotificationBackend(electron));
56
+ setShellBackend(createElectronShellBackend(electron));
57
+ setStorageBackend(createElectronStorageBackend(electron, options.storageFileName));
58
+ setProtocolBackend(createElectronProtocolBackend(electron));
59
+ setUpdaterBackend(createElectronUpdaterBackend(electron));
60
+ setIpcBackend(createElectronIpcBackend(electron));
61
+ }
62
+ //# sourceMappingURL=electronRegister.js.map
@@ -0,0 +1 @@
1
+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BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,eAAe,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,sBAAsB,CAAC,iCAAiC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpE,eAAe,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,iBAAiB,CAAC,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IACnF,kBAAkB,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5D,iBAAiB,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1D,aAAa,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ScreenBackend } from '@flighthq/types';
2
+ import type { ElectronApi } from './electronModule';
3
+ export declare function createElectronScreenBackend(electron: ElectronApi): ScreenBackend;
4
+ //# sourceMappingURL=electronScreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronScreen.d.ts","sourceRoot":"","sources":["../src/electronScreen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAmD,MAAM,iBAAiB,CAAC;AAEtG,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AAKrE,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,WAAW,GAAG,aAAa,CAsDhF"}
@@ -0,0 +1,68 @@
1
+ // Maps Flight's ScreenBackend onto Electron's `screen` module. Enumeration writes into caller-owned
2
+ // `out` values so hot paths allocate nothing. subscribe wires all three of Electron's display change
3
+ // events to one listener and returns an unsubscribe that removes all three.
4
+ export function createElectronScreenBackend(electron) {
5
+ const screen = electron.screen;
6
+ return {
7
+ getScreens(out) {
8
+ const displays = screen.getAllDisplays();
9
+ const primaryId = screen.getPrimaryDisplay().id;
10
+ out.length = displays.length;
11
+ for (let i = 0; i < displays.length; i++) {
12
+ const display = displays[i];
13
+ out[i] = fillScreenInfo({}, display, display.id === primaryId);
14
+ }
15
+ return out;
16
+ },
17
+ getPrimaryScreen(out) {
18
+ return fillScreenInfo(out, screen.getPrimaryDisplay(), true);
19
+ },
20
+ getCursorPosition(out) {
21
+ const point = screen.getCursorScreenPoint();
22
+ out.x = point.x;
23
+ out.y = point.y;
24
+ return out;
25
+ },
26
+ subscribe(listener) {
27
+ const primaryId = () => screen.getPrimaryDisplay().id;
28
+ // Electron passes (event, display) for each display change; adapt that into a ScreenChangeEvent.
29
+ const makeHandler = (kind) => (...args) => {
30
+ const display = args[1];
31
+ const event = {
32
+ kind,
33
+ screen: display
34
+ ? fillScreenInfo({}, display, display.id === primaryId())
35
+ : {},
36
+ changedMetrics: kind === 'ScreenMetricsChanged'
37
+ ? { bounds: true, workArea: true, scaleFactor: true, orientation: true }
38
+ : null,
39
+ };
40
+ listener(event);
41
+ };
42
+ const onAdded = makeHandler('ScreenAdded');
43
+ const onRemoved = makeHandler('ScreenRemoved');
44
+ const onMetrics = makeHandler('ScreenMetricsChanged');
45
+ screen.on('display-added', onAdded);
46
+ screen.on('display-removed', onRemoved);
47
+ screen.on('display-metrics-changed', onMetrics);
48
+ return () => {
49
+ screen.removeListener('display-added', onAdded);
50
+ screen.removeListener('display-removed', onRemoved);
51
+ screen.removeListener('display-metrics-changed', onMetrics);
52
+ };
53
+ },
54
+ };
55
+ }
56
+ function fillScreenInfo(out, display, isPrimary) {
57
+ out.id = display.id;
58
+ out.x = display.bounds.x;
59
+ out.y = display.bounds.y;
60
+ out.width = display.bounds.width;
61
+ out.height = display.bounds.height;
62
+ out.workWidth = display.workArea.width;
63
+ out.workHeight = display.workArea.height;
64
+ out.scaleFactor = display.scaleFactor;
65
+ out.isPrimary = isPrimary;
66
+ return out;
67
+ }
68
+ //# sourceMappingURL=electronScreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronScreen.js","sourceRoot":"","sources":["../src/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AE,GAAG,OAAO,CAAC,EAAE,CAAC;IACpB,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACzB,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACzB,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IACjC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;IACnC,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IACvC,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACzC,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACtC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ShellBackend } from '@flighthq/types';
2
+ import type { ElectronApi } from './electronModule';
3
+ export declare function createElectronShellBackend(electron: ElectronApi): ShellBackend;
4
+ //# sourceMappingURL=electronShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronShell.d.ts","sourceRoot":"","sources":["../src/electronShell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAC;AAK7E,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,CA8F9E"}
@@ -0,0 +1,105 @@
1
+ // Maps Flight's ShellBackend onto Electron's main-process shell module. Async operations resolve to
2
+ // false on failure rather than throwing — these are expected-failure surfaces, not programmer
3
+ // errors. openPath is special: Electron returns '' on success and an error string otherwise.
4
+ export function createElectronShellBackend(electron) {
5
+ const shell = electron.shell;
6
+ return {
7
+ async openExternal(url) {
8
+ try {
9
+ await shell.openExternal(url);
10
+ return true;
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ },
16
+ async openPath(path) {
17
+ try {
18
+ const err = await shell.openPath(path);
19
+ return err === '';
20
+ }
21
+ catch {
22
+ return false;
23
+ }
24
+ },
25
+ async openPathResult(path) {
26
+ // Electron's openPath returns '' on success and an OS error string on failure — Flight's contract.
27
+ try {
28
+ return await shell.openPath(path);
29
+ }
30
+ catch {
31
+ return '';
32
+ }
33
+ },
34
+ async showItemInFolder(path) {
35
+ try {
36
+ shell.showItemInFolder(path);
37
+ return true;
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ },
43
+ async moveToTrash(path) {
44
+ try {
45
+ await shell.trashItem(path);
46
+ return true;
47
+ }
48
+ catch {
49
+ return false;
50
+ }
51
+ },
52
+ async moveItemsToTrash(paths) {
53
+ // Electron trashes one path at a time; trash each and report per-path success.
54
+ return Promise.all(paths.map(async (path) => {
55
+ try {
56
+ await shell.trashItem(path);
57
+ return true;
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }));
63
+ },
64
+ async readShortcutLink(shortcutPath) {
65
+ // Windows .lnk only; throws on other platforms or a missing link — report null.
66
+ try {
67
+ const details = shell.readShortcutLink(shortcutPath);
68
+ const link = {
69
+ target: details.target,
70
+ appUserModelId: details.appUserModelId,
71
+ args: details.args,
72
+ description: details.description,
73
+ icon: details.icon,
74
+ iconIndex: details.iconIndex,
75
+ workingDirectory: details.cwd,
76
+ };
77
+ return link;
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ },
83
+ async writeShortcutLink(shortcutPath, link, operation = 'create') {
84
+ try {
85
+ const details = {
86
+ target: link.target,
87
+ appUserModelId: link.appUserModelId,
88
+ args: link.args,
89
+ description: link.description,
90
+ icon: link.icon,
91
+ iconIndex: link.iconIndex,
92
+ cwd: link.workingDirectory,
93
+ };
94
+ return shell.writeShortcutLink(shortcutPath, operation, details);
95
+ }
96
+ catch {
97
+ return false;
98
+ }
99
+ },
100
+ beep() {
101
+ shell.beep();
102
+ },
103
+ };
104
+ }
105
+ //# sourceMappingURL=electronShell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronShell.js","sourceRoot":"","sources":["../src/electronShell.ts"],"names":[],"mappings":"AAIA,oGAAoG;AACpG,8FAA8F;AAC9F,6FAA6F;AAC7F,MAAM,UAAU,0BAA0B,CAAC,QAAqB;IAC9D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7B,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,GAAG;YACpB,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;gBAC9B,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI;YACjB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACvC,OAAO,GAAG,KAAK,EAAE,CAAC;YACpB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,KAAK,CAAC,cAAc,CAAC,IAAI;YACvB,mGAAmG;YACnG,IAAI,CAAC;gBACH,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QACD,KAAK,CAAC,gBAAgB,CAAC,IAAI;YACzB,IAAI,CAAC;gBACH,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,IAAI;YACpB,IAAI,CAAC;gBACH,MAAM,KAAK,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,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,WAAW,EAAE,IAAI,CAAC,WAAW;oBAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,GAAG,EAAE,IAAI,CAAC,gBAAgB;iBAC3B,CAAC;gBACF,OAAO,KAAK,CAAC,iBAAiB,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACnE,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,IAAI;YACF,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ShortcutBackend } from '@flighthq/types';
2
+ import type { ElectronApi } from './electronModule';
3
+ export declare function createElectronShortcutBackend(electron: ElectronApi): ShortcutBackend;
4
+ //# sourceMappingURL=electronShortcut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronShortcut.d.ts","sourceRoot":"","sources":["../src/electronShortcut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAMpD,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,WAAW,GAAG,eAAe,CAiCpF"}
@@ -0,0 +1,40 @@
1
+ // Maps Flight's ShortcutBackend onto Electron's `globalShortcut` module. Electron's unregister returns
2
+ // void, so it is treated as always succeeding (true) to satisfy Flight's boolean contract. Electron's
3
+ // callback is bare; the seam synthesizes the ShortcutEvent (carrying the accelerator) Flight delivers.
4
+ // The set of registered accelerators is tracked here since Electron exposes no enumeration.
5
+ export function createElectronShortcutBackend(electron) {
6
+ const globalShortcut = electron.globalShortcut;
7
+ const registered = new Set();
8
+ return {
9
+ getRegistered() {
10
+ return [...registered];
11
+ },
12
+ register(accelerator, listener) {
13
+ const ok = globalShortcut.register(accelerator, () => listener({ accelerator }));
14
+ if (ok)
15
+ registered.add(accelerator);
16
+ return ok;
17
+ },
18
+ setAllEnabled(_enabled) {
19
+ // Electron's globalShortcut has no enable/disable toggle; a caller must unregister/re-register.
20
+ // Reported as a no-op rather than silently re-registering.
21
+ },
22
+ setEnabled(_accelerator, _enabled) {
23
+ // Electron has no per-accelerator enable toggle; report unsupported via false.
24
+ return false;
25
+ },
26
+ unregister(accelerator) {
27
+ globalShortcut.unregister(accelerator);
28
+ registered.delete(accelerator);
29
+ return true;
30
+ },
31
+ unregisterAll() {
32
+ globalShortcut.unregisterAll();
33
+ registered.clear();
34
+ },
35
+ isRegistered(accelerator) {
36
+ return globalShortcut.isRegistered(accelerator);
37
+ },
38
+ };
39
+ }
40
+ //# sourceMappingURL=electronShortcut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronShortcut.js","sourceRoot":"","sources":["../src/electronShortcut.ts"],"names":[],"mappings":"AAIA,uGAAuG;AACvG,sGAAsG;AACtG,uGAAuG;AACvG,4FAA4F;AAC5F,MAAM,UAAU,6BAA6B,CAAC,QAAqB;IACjE,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;IAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,OAAO;QACL,aAAa;YACX,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QACzB,CAAC;QACD,QAAQ,CAAC,WAAW,EAAE,QAAQ;YAC5B,MAAM,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YACjF,IAAI,EAAE;gBAAE,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACpC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,aAAa,CAAC,QAAQ;YACpB,gGAAgG;YAChG,2DAA2D;QAC7D,CAAC;QACD,UAAU,CAAC,YAAY,EAAE,QAAQ;YAC/B,+EAA+E;YAC/E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,UAAU,CAAC,WAAW;YACpB,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YACvC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,aAAa;YACX,cAAc,CAAC,aAAa,EAAE,CAAC;YAC/B,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QACD,YAAY,CAAC,WAAW;YACtB,OAAO,cAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { StorageBackend } from '@flighthq/types';
2
+ import type { ElectronApi } from './electronModule';
3
+ export declare function createElectronStorageBackend(electron: ElectronApi, fileName?: string): StorageBackend;
4
+ //# sourceMappingURL=electronStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronStorage.d.ts","sourceRoot":"","sources":["../src/electronStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgBpD,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,SAAiB,GAAG,cAAc,CA0D7G"}
@@ -0,0 +1,75 @@
1
+ // Maps Flight's StorageBackend onto a JSON file in the Electron userData directory. The file is
2
+ // read and written synchronously to match the StorageBackend contract (localStorage is sync). All
3
+ // reads/writes are guarded with try/catch; failures return the documented sentinels (null/false/[])
4
+ // rather than throwing — storage is an expected-failure surface (permissions, disk full, etc.).
5
+ //
6
+ // The userData path comes from electron.app.getPath('userData'), and file I/O is performed via
7
+ // electron.fs — a minimal { readFileSync, writeFileSync, existsSync } slice injected on ElectronApi
8
+ // to keep this package node:fs-dependency-free (matching the electron-free design principle). In
9
+ // most Electron apps this is satisfied by the real node:fs module passed to registerElectronBackends.
10
+ //
11
+ // Design note: `node:fs` is documented in the codebase map as "out of scope here — a future
12
+ // node-fs injection covers those" for the @flighthq/filesystem seam. This storage implementation
13
+ // threads the fs surface through ElectronApi.fs instead, keeping host-electron node:fs-free while
14
+ // still providing the main-process storage backend the seam requires.
15
+ export function createElectronStorageBackend(electron, fileName = 'storage.json') {
16
+ const fs = electron.fs;
17
+ let store = null;
18
+ function load() {
19
+ if (store !== null)
20
+ return store;
21
+ try {
22
+ const dir = electron.app.getPath('userData');
23
+ const path = `${dir}/${fileName}`;
24
+ if (fs.existsSync(path)) {
25
+ const raw = fs.readFileSync(path, 'utf-8');
26
+ const parsed = JSON.parse(raw);
27
+ if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
28
+ store = parsed;
29
+ return store;
30
+ }
31
+ }
32
+ }
33
+ catch {
34
+ /* unreadable or corrupt file — start fresh */
35
+ }
36
+ store = {};
37
+ return store;
38
+ }
39
+ function save() {
40
+ try {
41
+ const dir = electron.app.getPath('userData');
42
+ const path = `${dir}/${fileName}`;
43
+ fs.writeFileSync(path, JSON.stringify(load()));
44
+ return true;
45
+ }
46
+ catch {
47
+ return false;
48
+ }
49
+ }
50
+ return {
51
+ clear() {
52
+ store = {};
53
+ return save();
54
+ },
55
+ getItem(key) {
56
+ const s = load();
57
+ return Object.prototype.hasOwnProperty.call(s, key) ? s[key] : null;
58
+ },
59
+ keys() {
60
+ return Object.keys(load());
61
+ },
62
+ removeItem(key) {
63
+ const s = load();
64
+ if (!Object.prototype.hasOwnProperty.call(s, key))
65
+ return false;
66
+ delete s[key];
67
+ return save();
68
+ },
69
+ setItem(key, value) {
70
+ load()[key] = value;
71
+ return save();
72
+ },
73
+ };
74
+ }
75
+ //# sourceMappingURL=electronStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronStorage.js","sourceRoot":"","sources":["../src/electronStorage.ts"],"names":[],"mappings":"A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AM,IAAI,GAAG,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC;YAClC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK;YACH,KAAK,GAAG,EAAE,CAAC;YACX,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QACD,OAAO,CAAC,GAAG;YACT,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;YACjB,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtE,CAAC;QACD,IAAI;YACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;YAChE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,KAAK;YAChB,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TrayBackend } from '@flighthq/types';
2
+ import type { ElectronApi } from './electronModule';
3
+ export declare function createElectronTrayBackend(electron: ElectronApi): TrayBackend;
4
+ //# sourceMappingURL=electronTray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronTray.d.ts","sourceRoot":"","sources":["../src/electronTray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,WAAW,EAAgC,MAAM,iBAAiB,CAAC;AAEnG,OAAO,KAAK,EAAE,WAAW,EAAuD,MAAM,kBAAkB,CAAC;AAOzG,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,WAAW,GAAG,WAAW,CA4H5E"}