@flighthq/host-electron 0.5.1-next.920.da8f530 → 0.6.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 (137) hide show
  1. package/README.md +2 -2
  2. package/dist/contract.d.ts +19 -24
  3. package/dist/contract.d.ts.map +1 -1
  4. package/dist/contract.js +18 -24
  5. package/dist/contract.js.map +1 -1
  6. package/dist/electronApp.d.ts +62 -34
  7. package/dist/electronApp.d.ts.map +1 -1
  8. package/dist/electronApp.js +175 -234
  9. package/dist/electronApp.js.map +1 -1
  10. package/dist/electronClipboard.d.ts +7 -5
  11. package/dist/electronClipboard.d.ts.map +1 -1
  12. package/dist/electronClipboard.js +91 -66
  13. package/dist/electronClipboard.js.map +1 -1
  14. package/dist/electronDefaultHostGroups.d.ts +59 -0
  15. package/dist/electronDefaultHostGroups.d.ts.map +1 -0
  16. package/dist/electronDefaultHostGroups.js +109 -0
  17. package/dist/electronDefaultHostGroups.js.map +1 -0
  18. package/dist/electronDialog.d.ts +12 -9
  19. package/dist/electronDialog.d.ts.map +1 -1
  20. package/dist/electronDialog.js +28 -21
  21. package/dist/electronDialog.js.map +1 -1
  22. package/dist/electronIpc.d.ts +13 -11
  23. package/dist/electronIpc.d.ts.map +1 -1
  24. package/dist/electronIpc.js +32 -26
  25. package/dist/electronIpc.js.map +1 -1
  26. package/dist/electronMenu.d.ts +12 -6
  27. package/dist/electronMenu.d.ts.map +1 -1
  28. package/dist/electronMenu.js +41 -30
  29. package/dist/electronMenu.js.map +1 -1
  30. package/dist/electronMenuTemplate.d.ts +2 -1
  31. package/dist/electronMenuTemplate.d.ts.map +1 -1
  32. package/dist/electronMenuTemplate.js.map +1 -1
  33. package/dist/electronNotification.d.ts +25 -7
  34. package/dist/electronNotification.d.ts.map +1 -1
  35. package/dist/electronNotification.js +39 -16
  36. package/dist/electronNotification.js.map +1 -1
  37. package/dist/electronPlatform.d.ts +5 -3
  38. package/dist/electronPlatform.d.ts.map +1 -1
  39. package/dist/electronPlatform.js +9 -7
  40. package/dist/electronPlatform.js.map +1 -1
  41. package/dist/electronPower.d.ts +22 -11
  42. package/dist/electronPower.d.ts.map +1 -1
  43. package/dist/electronPower.js +48 -59
  44. package/dist/electronPower.js.map +1 -1
  45. package/dist/electronProtocol.d.ts +16 -8
  46. package/dist/electronProtocol.d.ts.map +1 -1
  47. package/dist/electronProtocol.js +45 -28
  48. package/dist/electronProtocol.js.map +1 -1
  49. package/dist/electronRegister.d.ts +5 -7
  50. package/dist/electronRegister.d.ts.map +1 -1
  51. package/dist/electronRegister.js +72 -99
  52. package/dist/electronRegister.js.map +1 -1
  53. package/dist/electronScreen.d.ts +7 -6
  54. package/dist/electronScreen.d.ts.map +1 -1
  55. package/dist/electronScreen.js +17 -14
  56. package/dist/electronScreen.js.map +1 -1
  57. package/dist/electronShell.d.ts +16 -8
  58. package/dist/electronShell.d.ts.map +1 -1
  59. package/dist/electronShell.js +50 -43
  60. package/dist/electronShell.js.map +1 -1
  61. package/dist/electronShortcut.d.ts +6 -4
  62. package/dist/electronShortcut.d.ts.map +1 -1
  63. package/dist/electronShortcut.js +16 -10
  64. package/dist/electronShortcut.js.map +1 -1
  65. package/dist/electronStorage.d.ts +5 -3
  66. package/dist/electronStorage.d.ts.map +1 -1
  67. package/dist/electronStorage.js +9 -7
  68. package/dist/electronStorage.js.map +1 -1
  69. package/dist/electronTray.d.ts +38 -21
  70. package/dist/electronTray.d.ts.map +1 -1
  71. package/dist/electronTray.js +110 -76
  72. package/dist/electronTray.js.map +1 -1
  73. package/dist/electronUpdater.d.ts +6 -3
  74. package/dist/electronUpdater.d.ts.map +1 -1
  75. package/dist/electronUpdater.js +10 -7
  76. package/dist/electronUpdater.js.map +1 -1
  77. package/dist/electronWindow.d.ts +23 -7
  78. package/dist/electronWindow.d.ts.map +1 -1
  79. package/dist/electronWindow.js +234 -152
  80. package/dist/electronWindow.js.map +1 -1
  81. package/dist/index.d.ts +19 -1
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +18 -1
  84. package/dist/index.js.map +1 -1
  85. package/dist/types/ElectronApi.d.ts +393 -0
  86. package/dist/types/ElectronApi.d.ts.map +1 -0
  87. package/dist/types/ElectronApi.js +20 -0
  88. package/dist/types/ElectronApi.js.map +1 -0
  89. package/dist/types/ElectronAppCapabilitiesFor.d.ts +8 -0
  90. package/dist/types/ElectronAppCapabilitiesFor.d.ts.map +1 -0
  91. package/dist/types/ElectronAppCapabilitiesFor.js +2 -0
  92. package/dist/types/ElectronAppCapabilitiesFor.js.map +1 -0
  93. package/dist/types/ElectronHost.d.ts +43 -0
  94. package/dist/types/ElectronHost.d.ts.map +1 -0
  95. package/dist/types/ElectronHost.js +2 -0
  96. package/dist/types/ElectronHost.js.map +1 -0
  97. package/dist/types/ElectronHostGroups.d.ts +85 -0
  98. package/dist/types/ElectronHostGroups.d.ts.map +1 -0
  99. package/dist/types/ElectronHostGroups.js +2 -0
  100. package/dist/types/ElectronHostGroups.js.map +1 -0
  101. package/dist/types/ElectronHostOptions.d.ts +7 -0
  102. package/dist/types/ElectronHostOptions.d.ts.map +1 -0
  103. package/dist/types/ElectronHostOptions.js +2 -0
  104. package/dist/types/ElectronHostOptions.js.map +1 -0
  105. package/dist/types/ElectronProtocolCapabilities.d.ts +3 -0
  106. package/dist/types/ElectronProtocolCapabilities.d.ts.map +1 -0
  107. package/dist/types/ElectronProtocolCapabilities.js +2 -0
  108. package/dist/types/ElectronProtocolCapabilities.js.map +1 -0
  109. package/dist/types/ElectronTrayCapabilitiesFor.d.ts +7 -0
  110. package/dist/types/ElectronTrayCapabilitiesFor.d.ts.map +1 -0
  111. package/dist/types/ElectronTrayCapabilitiesFor.js +2 -0
  112. package/dist/types/ElectronTrayCapabilitiesFor.js.map +1 -0
  113. package/dist/types/index.d.ts +7 -0
  114. package/dist/types/index.d.ts.map +1 -0
  115. package/dist/types/index.js +7 -0
  116. package/dist/types/index.js.map +1 -0
  117. package/package.json +42 -21
  118. package/src/electronApp.test.ts +158 -131
  119. package/src/electronClipboard.test.ts +40 -13
  120. package/src/electronDefaultHostGroups.test.ts +148 -0
  121. package/src/electronDialog.test.ts +55 -53
  122. package/src/electronHostTreeShaking.test.ts +51 -0
  123. package/src/electronIpc.test.ts +47 -66
  124. package/src/electronMenu.test.ts +61 -47
  125. package/src/electronMenuTemplate.test.ts +1 -1
  126. package/src/electronNotification.test.ts +71 -21
  127. package/src/electronPlatform.test.ts +17 -12
  128. package/src/electronPower.test.ts +112 -88
  129. package/src/electronProtocol.test.ts +68 -35
  130. package/src/electronRegister.test.ts +280 -26
  131. package/src/electronScreen.test.ts +34 -25
  132. package/src/electronShell.test.ts +99 -59
  133. package/src/electronShortcut.test.ts +22 -19
  134. package/src/electronStorage.test.ts +26 -24
  135. package/src/electronTray.test.ts +225 -109
  136. package/src/electronUpdater.test.ts +26 -19
  137. package/src/electronWindow.test.ts +229 -101
@@ -1,38 +1,36 @@
1
- import type { ElectronApi, ElectronMenu, ElectronMenuItemOptions } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
3
1
  import { describe, expect, it, vi } from 'vitest';
4
2
 
5
3
  import {
6
- createElectronAppCapabilities,
7
- initializeAppActivateBackend,
8
- initializeAppActivationPolicyBackend,
9
- initializeAppAllWindowsClosedBackend,
10
- initializeAppBadgeBackend,
11
- initializeAppDockBackend,
12
- initializeAppFocusBackend,
13
- initializeAppHideBackend,
14
- initializeAppLocaleBackend,
15
- initializeAppLoginItemBackend,
16
- initializeAppNameBackend,
17
- initializeAppNameWriteBackend,
18
- initializeAppOpenFileBackend,
19
- initializeAppPathBackend,
20
- initializeAppQuitBackend,
21
- initializeAppQuitRequestBackend,
22
- initializeAppReadyBackend,
23
- initializeAppRecentDocumentsBackend,
24
- initializeAppRelaunchBackend,
25
- initializeAppSecondInstanceBackend,
26
- initializeAppShowBackend,
27
- initializeAppSingleInstanceBackend,
28
- initializeAppUserModelIdBackend,
29
- initializeAppVersionBackend,
30
- initializeAppVisibilityQueryBackend,
31
- initializeElectronCommonAppCapabilities,
32
- initializeElectronLinuxAppCapabilities,
33
- initializeElectronMacosAppCapabilities,
34
- initializeElectronWindowsAppCapabilities,
35
- } from './electronApp';
4
+ electronHostApp,
5
+ populateElectronHostAppActivate,
6
+ populateElectronHostAppActivationPolicy,
7
+ populateElectronHostAppAllWindowsClosed,
8
+ populateElectronHostAppBadge,
9
+ populateElectronHostAppDock,
10
+ populateElectronHostAppFocus,
11
+ populateElectronHostAppHide,
12
+ populateElectronHostAppLocale,
13
+ populateElectronHostAppLoginItem,
14
+ populateElectronHostAppName,
15
+ populateElectronHostAppNameWrite,
16
+ populateElectronHostAppOpenFile,
17
+ populateElectronHostAppPath,
18
+ populateElectronHostAppQuit,
19
+ populateElectronHostAppQuitRequest,
20
+ populateElectronHostAppReady,
21
+ populateElectronHostAppRecentDocuments,
22
+ populateElectronHostAppRelaunch,
23
+ populateElectronHostAppSecondInstance,
24
+ populateElectronHostAppShow,
25
+ populateElectronHostAppSingleInstance,
26
+ populateElectronHostAppUserModelId,
27
+ populateElectronHostAppVersion,
28
+ populateElectronHostAppCommon,
29
+ populateElectronHostAppLinux,
30
+ populateElectronHostAppMacos,
31
+ populateElectronHostAppWindows,
32
+ } from './electronApp.ts';
33
+ import type { ElectronApi, ElectronMenu, ElectronMenuItemOptions } from './types/index.ts';
36
34
 
37
35
  function fakeElectron() {
38
36
  const calls: string[] = [];
@@ -99,12 +97,19 @@ function fakeElectron() {
99
97
  };
100
98
  }
101
99
 
102
- describe('createElectronAppCapabilities', () => {
100
+ function appLeaf(profile: 'linux' | 'macos' | 'windows', slot: string): () => void {
101
+ return () => {
102
+ it('constructs an Entity-backed provider in the application group', () => {
103
+ const app = electronHostApp(fakeElectron().electron, profile) as unknown as Record<string, object>;
104
+ });
105
+ };
106
+ }
107
+
108
+ describe('electronHostApp', () => {
103
109
  it('publishes common application identity, control, and event slots on every profile', async () => {
104
110
  const fake = fakeElectron();
105
- const app = createElectronAppCapabilities(fake.electron, 'linux');
106
- expect(EntityRuntimeKey in app).toBe(true);
107
- expect(Object.keys(app).sort()).toEqual([
111
+ const app = electronHostApp(fake.electron, 'linux');
112
+ const common = [
108
113
  'allWindowsClosed',
109
114
  'badge',
110
115
  'focus',
@@ -119,20 +124,24 @@ describe('createElectronAppCapabilities', () => {
119
124
  'secondInstance',
120
125
  'singleInstance',
121
126
  'version',
122
- ]);
127
+ ];
128
+ const profileOnly = [
129
+ ...Object.keys(electronHostApp(fakeElectron().electron, 'macos')),
130
+ ...Object.keys(electronHostApp(fakeElectron().electron, 'windows')),
131
+ ].filter((slot) => !common.includes(slot));
132
+ expect(Object.keys(app)).toEqual(expect.arrayContaining(common));
133
+ expect(Object.keys(app).filter((slot) => profileOnly.includes(slot))).toEqual([]);
123
134
  expect(app.name.getName()).toBe('Flight');
124
135
  expect(app.version.getVersion()).toBe('1.2.3');
125
136
  expect(app.locale.getPreferredSystemLanguages()).toEqual(['en-US', 'fr']);
126
137
  expect(app.path.getAppDirectoryPath('logs')).toBe('/path/logs');
127
138
  expect(app.singleInstance.requestSingleInstanceLock()).toBe(true);
128
139
  await expect(app.badge.setBadgeCount(2)).resolves.toBe(true);
129
- for (const provider of Object.values(app)) expect(EntityRuntimeKey in provider).toBe(true);
130
140
  });
131
141
 
132
- it('publishes macOS-only dock, visibility, login, open-file, and activation slots', () => {
142
+ it('publishes macOS-only dock, login, open-file, and activation slots', () => {
133
143
  const fake = fakeElectron();
134
- const app = createElectronAppCapabilities(fake.electron, 'macos');
135
- expect(app.hiddenQuery.isAppHidden()).toBe(true);
144
+ const app = electronHostApp(fake.electron, 'macos');
136
145
  app.dock.setDockMenu([{ id: 'a', label: 'A', submenu: [{ id: 'b', label: 'B' }] }]);
137
146
  expect(fake.dockMenuTemplate?.[0]?.submenu).toHaveLength(1);
138
147
  expect(app.dock.requestAttention(true)).toBe(7);
@@ -146,7 +155,7 @@ describe('createElectronAppCapabilities', () => {
146
155
 
147
156
  it('publishes Windows login, recent-document, and app-user-model slots', () => {
148
157
  const fake = fakeElectron();
149
- const app = createElectronAppCapabilities(fake.electron, 'windows');
158
+ const app = electronHostApp(fake.electron, 'windows');
150
159
  app.recentDocuments.addRecentDocument('/tmp/a');
151
160
  app.userModelId.setUserModelId('flight.app');
152
161
  expect(fake.calls).toEqual(['recent:/tmp/a', 'userModel:flight.app']);
@@ -155,7 +164,7 @@ describe('createElectronAppCapabilities', () => {
155
164
 
156
165
  it('adapts quit-veto and second-instance event arguments', () => {
157
166
  const fake = fakeElectron();
158
- const app = createElectronAppCapabilities(fake.electron, 'linux');
167
+ const app = electronHostApp(fake.electron, 'linux');
159
168
  const preventDefault = vi.fn();
160
169
  const cancel = vi.fn((cancelHost: () => void) => cancelHost());
161
170
  let argv: readonly string[] = [];
@@ -171,173 +180,191 @@ describe('createElectronAppCapabilities', () => {
171
180
  it('rejects a macOS facade whose dock API is absent', () => {
172
181
  const electron = fakeElectron().electron;
173
182
  Object.assign(electron.app, { dock: undefined });
174
- expect(() => createElectronAppCapabilities(electron, 'macos')).toThrow('require app.dock');
183
+ expect(() => electronHostApp(electron, 'macos')).toThrow('require app.dock');
175
184
  });
176
185
  });
177
- describe('initializeAppActivateBackend', () => {
178
- it('is the construction initializer of createAppActivateBackend', () => {
179
- expect(typeof initializeAppActivateBackend).toBe('function');
180
- });
181
- });
182
-
183
- describe('initializeAppActivationPolicyBackend', () => {
184
- it('is the construction initializer of createAppActivationPolicyBackend', () => {
185
- expect(typeof initializeAppActivationPolicyBackend).toBe('function');
186
+ describe('electronHostAppActivate', appLeaf('macos', 'activate'));
187
+ describe('electronHostAppActivationPolicy', appLeaf('macos', 'activationPolicy'));
188
+ describe('electronHostAppAllWindowsClosed', appLeaf('linux', 'allWindowsClosed'));
189
+ describe('electronHostAppBadge', appLeaf('linux', 'badge'));
190
+ describe('electronHostAppDock', appLeaf('macos', 'dock'));
191
+ describe('electronHostAppFocus', appLeaf('linux', 'focus'));
192
+ describe('electronHostAppHide', appLeaf('macos', 'hide'));
193
+ describe('electronHostAppLocale', appLeaf('linux', 'locale'));
194
+ describe('electronHostAppLoginItem', appLeaf('windows', 'loginItem'));
195
+ describe('electronHostAppName', appLeaf('linux', 'name'));
196
+ describe('electronHostAppNameWrite', appLeaf('linux', 'nameWrite'));
197
+ describe('electronHostAppOpenFile', appLeaf('macos', 'openFile'));
198
+ describe('electronHostAppPath', appLeaf('linux', 'path'));
199
+ describe('electronHostAppQuit', appLeaf('linux', 'quit'));
200
+ describe('electronHostAppQuitRequest', appLeaf('linux', 'quitRequest'));
201
+ describe('electronHostAppReady', appLeaf('linux', 'ready'));
202
+ describe('electronHostAppRecentDocuments', appLeaf('windows', 'recentDocuments'));
203
+ describe('electronHostAppRelaunch', appLeaf('linux', 'relaunch'));
204
+ describe('electronHostAppSecondInstance', appLeaf('linux', 'secondInstance'));
205
+ describe('electronHostAppShow', appLeaf('macos', 'show'));
206
+ describe('electronHostAppSingleInstance', appLeaf('linux', 'singleInstance'));
207
+ describe('electronHostAppUserModelId', appLeaf('windows', 'userModelId'));
208
+
209
+ describe('electronHostAppVersion', appLeaf('linux', 'version'));
210
+ describe('populateElectronHostAppActivate', () => {
211
+ it('is the construction initializer of electronHostAppActivate', () => {
212
+ expect(typeof populateElectronHostAppActivate).toBe('function');
186
213
  });
187
214
  });
188
215
 
189
- describe('initializeAppAllWindowsClosedBackend', () => {
190
- it('is the construction initializer of createAppAllWindowsClosedBackend', () => {
191
- expect(typeof initializeAppAllWindowsClosedBackend).toBe('function');
216
+ describe('populateElectronHostAppActivationPolicy', () => {
217
+ it('is the construction initializer of electronHostAppActivationPolicy', () => {
218
+ expect(typeof populateElectronHostAppActivationPolicy).toBe('function');
192
219
  });
193
220
  });
194
221
 
195
- describe('initializeAppBadgeBackend', () => {
196
- it('is the construction initializer of createAppBadgeBackend', () => {
197
- expect(typeof initializeAppBadgeBackend).toBe('function');
222
+ describe('populateElectronHostAppAllWindowsClosed', () => {
223
+ it('is the construction initializer of electronHostAppAllWindowsClosed', () => {
224
+ expect(typeof populateElectronHostAppAllWindowsClosed).toBe('function');
198
225
  });
199
226
  });
200
227
 
201
- describe('initializeAppDockBackend', () => {
202
- it('is the construction initializer of createAppDockBackend', () => {
203
- expect(typeof initializeAppDockBackend).toBe('function');
228
+ describe('populateElectronHostAppBadge', () => {
229
+ it('is the construction initializer of electronHostAppBadge', () => {
230
+ expect(typeof populateElectronHostAppBadge).toBe('function');
204
231
  });
205
232
  });
206
233
 
207
- describe('initializeAppFocusBackend', () => {
208
- it('is the construction initializer of createAppFocusBackend', () => {
209
- expect(typeof initializeAppFocusBackend).toBe('function');
234
+ describe('populateElectronHostAppCommon', () => {
235
+ it('is the construction initializer of electronHostApp', () => {
236
+ expect(typeof populateElectronHostAppCommon).toBe('function');
210
237
  });
211
238
  });
212
239
 
213
- describe('initializeAppHideBackend', () => {
214
- it('is the construction initializer of createAppHideBackend', () => {
215
- expect(typeof initializeAppHideBackend).toBe('function');
240
+ describe('populateElectronHostAppDock', () => {
241
+ it('is the construction initializer of electronHostAppDock', () => {
242
+ expect(typeof populateElectronHostAppDock).toBe('function');
216
243
  });
217
244
  });
218
245
 
219
- describe('initializeAppLocaleBackend', () => {
220
- it('is the construction initializer of createAppLocaleBackend', () => {
221
- expect(typeof initializeAppLocaleBackend).toBe('function');
246
+ describe('populateElectronHostAppFocus', () => {
247
+ it('is the construction initializer of electronHostAppFocus', () => {
248
+ expect(typeof populateElectronHostAppFocus).toBe('function');
222
249
  });
223
250
  });
224
251
 
225
- describe('initializeAppLoginItemBackend', () => {
226
- it('is the construction initializer of createAppLoginItemBackend', () => {
227
- expect(typeof initializeAppLoginItemBackend).toBe('function');
252
+ describe('populateElectronHostAppHide', () => {
253
+ it('is the construction initializer of electronHostAppHide', () => {
254
+ expect(typeof populateElectronHostAppHide).toBe('function');
228
255
  });
229
256
  });
230
257
 
231
- describe('initializeAppNameBackend', () => {
232
- it('is the construction initializer of createAppNameBackend', () => {
233
- expect(typeof initializeAppNameBackend).toBe('function');
258
+ describe('populateElectronHostAppLinux', () => {
259
+ it('is the construction initializer of electronHostApp', () => {
260
+ expect(typeof populateElectronHostAppLinux).toBe('function');
234
261
  });
235
262
  });
236
263
 
237
- describe('initializeAppNameWriteBackend', () => {
238
- it('is the construction initializer of createAppNameWriteBackend', () => {
239
- expect(typeof initializeAppNameWriteBackend).toBe('function');
264
+ describe('populateElectronHostAppLocale', () => {
265
+ it('is the construction initializer of electronHostAppLocale', () => {
266
+ expect(typeof populateElectronHostAppLocale).toBe('function');
240
267
  });
241
268
  });
242
269
 
243
- describe('initializeAppOpenFileBackend', () => {
244
- it('is the construction initializer of createAppOpenFileBackend', () => {
245
- expect(typeof initializeAppOpenFileBackend).toBe('function');
270
+ describe('populateElectronHostAppLoginItem', () => {
271
+ it('is the construction initializer of electronHostAppLoginItem', () => {
272
+ expect(typeof populateElectronHostAppLoginItem).toBe('function');
246
273
  });
247
274
  });
248
275
 
249
- describe('initializeAppPathBackend', () => {
250
- it('is the construction initializer of createAppPathBackend', () => {
251
- expect(typeof initializeAppPathBackend).toBe('function');
276
+ describe('populateElectronHostAppMacos', () => {
277
+ it('is the construction initializer of electronHostApp', () => {
278
+ expect(typeof populateElectronHostAppMacos).toBe('function');
252
279
  });
253
280
  });
254
281
 
255
- describe('initializeAppQuitBackend', () => {
256
- it('is the construction initializer of createAppQuitBackend', () => {
257
- expect(typeof initializeAppQuitBackend).toBe('function');
282
+ describe('populateElectronHostAppName', () => {
283
+ it('is the construction initializer of electronHostAppName', () => {
284
+ expect(typeof populateElectronHostAppName).toBe('function');
258
285
  });
259
286
  });
260
287
 
261
- describe('initializeAppQuitRequestBackend', () => {
262
- it('is the construction initializer of createAppQuitRequestBackend', () => {
263
- expect(typeof initializeAppQuitRequestBackend).toBe('function');
288
+ describe('populateElectronHostAppNameWrite', () => {
289
+ it('is the construction initializer of electronHostAppNameWrite', () => {
290
+ expect(typeof populateElectronHostAppNameWrite).toBe('function');
264
291
  });
265
292
  });
266
293
 
267
- describe('initializeAppReadyBackend', () => {
268
- it('is the construction initializer of createAppReadyBackend', () => {
269
- expect(typeof initializeAppReadyBackend).toBe('function');
294
+ describe('populateElectronHostAppOpenFile', () => {
295
+ it('is the construction initializer of electronHostAppOpenFile', () => {
296
+ expect(typeof populateElectronHostAppOpenFile).toBe('function');
270
297
  });
271
298
  });
272
299
 
273
- describe('initializeAppRecentDocumentsBackend', () => {
274
- it('is the construction initializer of createAppRecentDocumentsBackend', () => {
275
- expect(typeof initializeAppRecentDocumentsBackend).toBe('function');
300
+ describe('populateElectronHostAppPath', () => {
301
+ it('is the construction initializer of electronHostAppPath', () => {
302
+ expect(typeof populateElectronHostAppPath).toBe('function');
276
303
  });
277
304
  });
278
305
 
279
- describe('initializeAppRelaunchBackend', () => {
280
- it('is the construction initializer of createAppRelaunchBackend', () => {
281
- expect(typeof initializeAppRelaunchBackend).toBe('function');
306
+ describe('populateElectronHostAppQuit', () => {
307
+ it('is the construction initializer of electronHostAppQuit', () => {
308
+ expect(typeof populateElectronHostAppQuit).toBe('function');
282
309
  });
283
310
  });
284
311
 
285
- describe('initializeAppSecondInstanceBackend', () => {
286
- it('is the construction initializer of createAppSecondInstanceBackend', () => {
287
- expect(typeof initializeAppSecondInstanceBackend).toBe('function');
312
+ describe('populateElectronHostAppQuitRequest', () => {
313
+ it('is the construction initializer of electronHostAppQuitRequest', () => {
314
+ expect(typeof populateElectronHostAppQuitRequest).toBe('function');
288
315
  });
289
316
  });
290
317
 
291
- describe('initializeAppShowBackend', () => {
292
- it('is the construction initializer of createAppShowBackend', () => {
293
- expect(typeof initializeAppShowBackend).toBe('function');
318
+ describe('populateElectronHostAppReady', () => {
319
+ it('is the construction initializer of electronHostAppReady', () => {
320
+ expect(typeof populateElectronHostAppReady).toBe('function');
294
321
  });
295
322
  });
296
323
 
297
- describe('initializeAppSingleInstanceBackend', () => {
298
- it('is the construction initializer of createAppSingleInstanceBackend', () => {
299
- expect(typeof initializeAppSingleInstanceBackend).toBe('function');
324
+ describe('populateElectronHostAppRecentDocuments', () => {
325
+ it('is the construction initializer of electronHostAppRecentDocuments', () => {
326
+ expect(typeof populateElectronHostAppRecentDocuments).toBe('function');
300
327
  });
301
328
  });
302
329
 
303
- describe('initializeAppUserModelIdBackend', () => {
304
- it('is the construction initializer of createAppUserModelIdBackend', () => {
305
- expect(typeof initializeAppUserModelIdBackend).toBe('function');
330
+ describe('populateElectronHostAppRelaunch', () => {
331
+ it('is the construction initializer of electronHostAppRelaunch', () => {
332
+ expect(typeof populateElectronHostAppRelaunch).toBe('function');
306
333
  });
307
334
  });
308
335
 
309
- describe('initializeAppVersionBackend', () => {
310
- it('is the construction initializer of createAppVersionBackend', () => {
311
- expect(typeof initializeAppVersionBackend).toBe('function');
336
+ describe('populateElectronHostAppSecondInstance', () => {
337
+ it('is the construction initializer of electronHostAppSecondInstance', () => {
338
+ expect(typeof populateElectronHostAppSecondInstance).toBe('function');
312
339
  });
313
340
  });
314
341
 
315
- describe('initializeAppVisibilityQueryBackend', () => {
316
- it('is the construction initializer of createAppVisibilityQueryBackend', () => {
317
- expect(typeof initializeAppVisibilityQueryBackend).toBe('function');
342
+ describe('populateElectronHostAppShow', () => {
343
+ it('is the construction initializer of electronHostAppShow', () => {
344
+ expect(typeof populateElectronHostAppShow).toBe('function');
318
345
  });
319
346
  });
320
347
 
321
- describe('initializeElectronCommonAppCapabilities', () => {
322
- it('is the construction initializer of createElectronCommonAppCapabilities', () => {
323
- expect(typeof initializeElectronCommonAppCapabilities).toBe('function');
348
+ describe('populateElectronHostAppSingleInstance', () => {
349
+ it('is the construction initializer of electronHostAppSingleInstance', () => {
350
+ expect(typeof populateElectronHostAppSingleInstance).toBe('function');
324
351
  });
325
352
  });
326
353
 
327
- describe('initializeElectronLinuxAppCapabilities', () => {
328
- it('is the construction initializer of createElectronLinuxAppCapabilities', () => {
329
- expect(typeof initializeElectronLinuxAppCapabilities).toBe('function');
354
+ describe('populateElectronHostAppUserModelId', () => {
355
+ it('is the construction initializer of electronHostAppUserModelId', () => {
356
+ expect(typeof populateElectronHostAppUserModelId).toBe('function');
330
357
  });
331
358
  });
332
359
 
333
- describe('initializeElectronMacosAppCapabilities', () => {
334
- it('is the construction initializer of createElectronMacosAppCapabilities', () => {
335
- expect(typeof initializeElectronMacosAppCapabilities).toBe('function');
360
+ describe('populateElectronHostAppVersion', () => {
361
+ it('is the construction initializer of electronHostAppVersion', () => {
362
+ expect(typeof populateElectronHostAppVersion).toBe('function');
336
363
  });
337
364
  });
338
365
 
339
- describe('initializeElectronWindowsAppCapabilities', () => {
340
- it('is the construction initializer of createElectronWindowsAppCapabilities', () => {
341
- expect(typeof initializeElectronWindowsAppCapabilities).toBe('function');
366
+ describe('populateElectronHostAppWindows', () => {
367
+ it('is the construction initializer of electronHostApp', () => {
368
+ expect(typeof populateElectronHostAppWindows).toBe('function');
342
369
  });
343
370
  });
@@ -1,7 +1,16 @@
1
- import type { ElectronApi, ElectronNativeImage } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import {
2
+ electronHostClipboard,
3
+ electronHostClipboardBookmark,
4
+ electronHostClipboardFormats,
5
+ electronHostClipboardImage,
6
+ electronHostClipboardText,
7
+ } from './electronClipboard.ts';
8
+ import type { ElectronApi, ElectronNativeImage } from './types/index.ts';
3
9
 
4
- import { createElectronClipboardBackend, initializeElectronClipboardBackend } from './electronClipboard';
10
+ function clipboardProvider(electron: ElectronApi) {
11
+ const clipboard = electronHostClipboard(electron);
12
+ return Object.assign(clipboard.bookmark, clipboard.formats, clipboard.image, clipboard.text);
13
+ }
5
14
 
6
15
  function fakeElectron(): ElectronApi {
7
16
  const store = { text: '', html: '', rtf: '', imageDataUrl: '', bookmarkTitle: '', bookmarkUrl: '' };
@@ -49,17 +58,16 @@ function fakeElectron(): ElectronApi {
49
58
  } as unknown as ElectronApi;
50
59
  }
51
60
 
52
- describe('createElectronClipboardBackend', () => {
61
+ describe('electronHostClipboard', () => {
53
62
  it('round-trips text through the Electron clipboard', async () => {
54
- const backend = createElectronClipboardBackend(fakeElectron());
55
- expect(EntityRuntimeKey in backend).toBe(true);
63
+ const backend = clipboardProvider(fakeElectron());
56
64
  expect(await backend.writeText('hi')).toBe(true);
57
65
  expect(await backend.readText()).toBe('hi');
58
66
  expect(await backend.hasText()).toBe(true);
59
67
  });
60
68
 
61
69
  it('round-trips HTML and RTF', async () => {
62
- const backend = createElectronClipboardBackend(fakeElectron());
70
+ const backend = clipboardProvider(fakeElectron());
63
71
  await backend.writeHtml('<b>x</b>');
64
72
  await backend.writeRTF('{\\rtf1 x}');
65
73
  expect(await backend.readHtml()).toBe('<b>x</b>');
@@ -67,7 +75,7 @@ describe('createElectronClipboardBackend', () => {
67
75
  });
68
76
 
69
77
  it('round-trips an image as a data URL', async () => {
70
- const backend = createElectronClipboardBackend(fakeElectron());
78
+ const backend = clipboardProvider(fakeElectron());
71
79
  expect(await backend.hasImage()).toBe(false);
72
80
  await backend.writeImage('data:image/png;base64,AAAA');
73
81
  expect(await backend.readImage()).toBe('data:image/png;base64,AAAA');
@@ -75,21 +83,40 @@ describe('createElectronClipboardBackend', () => {
75
83
  });
76
84
 
77
85
  it('returns null for an empty bookmark and round-trips a set one', async () => {
78
- const backend = createElectronClipboardBackend(fakeElectron());
86
+ const backend = clipboardProvider(fakeElectron());
79
87
  expect(await backend.readBookmark()).toBeNull();
80
88
  await backend.writeBookmark('Flight', 'https://example.test');
81
89
  expect(await backend.readBookmark()).toEqual({ title: 'Flight', url: 'https://example.test' });
82
90
  });
83
91
 
84
92
  it('clears all formats', async () => {
85
- const backend = createElectronClipboardBackend(fakeElectron());
93
+ const backend = clipboardProvider(fakeElectron());
86
94
  await backend.writeText('x');
87
95
  expect(await backend.clear()).toBe(true);
88
96
  expect(await backend.readText()).toBe('');
89
97
  });
90
98
  });
91
- describe('initializeElectronClipboardBackend', () => {
92
- it('is the construction initializer of createElectronClipboardBackend', () => {
93
- expect(typeof initializeElectronClipboardBackend).toBe('function');
99
+
100
+ describe('electronHostClipboardBookmark', () => {
101
+ it('constructs a clipboard bookmark provider', () => {
102
+ expect(electronHostClipboardBookmark(fakeElectron())).toBeDefined();
103
+ });
104
+ });
105
+
106
+ describe('electronHostClipboardFormats', () => {
107
+ it('constructs a clipboard formats provider', () => {
108
+ expect(electronHostClipboardFormats(fakeElectron())).toBeDefined();
109
+ });
110
+ });
111
+
112
+ describe('electronHostClipboardImage', () => {
113
+ it('constructs a clipboard image provider', () => {
114
+ expect(electronHostClipboardImage(fakeElectron())).toBeDefined();
115
+ });
116
+ });
117
+
118
+ describe('electronHostClipboardText', () => {
119
+ it('constructs a clipboard text provider', () => {
120
+ expect(electronHostClipboardText(fakeElectron())).toBeDefined();
94
121
  });
95
122
  });