@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.
- package/README.md +2 -2
- package/dist/contract.d.ts +19 -24
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +18 -24
- package/dist/contract.js.map +1 -1
- package/dist/electronApp.d.ts +62 -34
- package/dist/electronApp.d.ts.map +1 -1
- package/dist/electronApp.js +175 -234
- package/dist/electronApp.js.map +1 -1
- package/dist/electronClipboard.d.ts +7 -5
- package/dist/electronClipboard.d.ts.map +1 -1
- package/dist/electronClipboard.js +91 -66
- package/dist/electronClipboard.js.map +1 -1
- package/dist/electronDefaultHostGroups.d.ts +59 -0
- package/dist/electronDefaultHostGroups.d.ts.map +1 -0
- package/dist/electronDefaultHostGroups.js +109 -0
- package/dist/electronDefaultHostGroups.js.map +1 -0
- package/dist/electronDialog.d.ts +12 -9
- package/dist/electronDialog.d.ts.map +1 -1
- package/dist/electronDialog.js +28 -21
- package/dist/electronDialog.js.map +1 -1
- package/dist/electronIpc.d.ts +13 -11
- package/dist/electronIpc.d.ts.map +1 -1
- package/dist/electronIpc.js +32 -26
- package/dist/electronIpc.js.map +1 -1
- package/dist/electronMenu.d.ts +12 -6
- package/dist/electronMenu.d.ts.map +1 -1
- package/dist/electronMenu.js +41 -30
- package/dist/electronMenu.js.map +1 -1
- package/dist/electronMenuTemplate.d.ts +2 -1
- package/dist/electronMenuTemplate.d.ts.map +1 -1
- package/dist/electronMenuTemplate.js.map +1 -1
- package/dist/electronNotification.d.ts +25 -7
- package/dist/electronNotification.d.ts.map +1 -1
- package/dist/electronNotification.js +39 -16
- package/dist/electronNotification.js.map +1 -1
- package/dist/electronPlatform.d.ts +5 -3
- package/dist/electronPlatform.d.ts.map +1 -1
- package/dist/electronPlatform.js +9 -7
- package/dist/electronPlatform.js.map +1 -1
- package/dist/electronPower.d.ts +22 -11
- package/dist/electronPower.d.ts.map +1 -1
- package/dist/electronPower.js +48 -59
- package/dist/electronPower.js.map +1 -1
- package/dist/electronProtocol.d.ts +16 -8
- package/dist/electronProtocol.d.ts.map +1 -1
- package/dist/electronProtocol.js +45 -28
- package/dist/electronProtocol.js.map +1 -1
- package/dist/electronRegister.d.ts +5 -7
- package/dist/electronRegister.d.ts.map +1 -1
- package/dist/electronRegister.js +72 -99
- package/dist/electronRegister.js.map +1 -1
- package/dist/electronScreen.d.ts +7 -6
- package/dist/electronScreen.d.ts.map +1 -1
- package/dist/electronScreen.js +17 -14
- package/dist/electronScreen.js.map +1 -1
- package/dist/electronShell.d.ts +16 -8
- package/dist/electronShell.d.ts.map +1 -1
- package/dist/electronShell.js +50 -43
- package/dist/electronShell.js.map +1 -1
- package/dist/electronShortcut.d.ts +6 -4
- package/dist/electronShortcut.d.ts.map +1 -1
- package/dist/electronShortcut.js +16 -10
- package/dist/electronShortcut.js.map +1 -1
- package/dist/electronStorage.d.ts +5 -3
- package/dist/electronStorage.d.ts.map +1 -1
- package/dist/electronStorage.js +9 -7
- package/dist/electronStorage.js.map +1 -1
- package/dist/electronTray.d.ts +38 -21
- package/dist/electronTray.d.ts.map +1 -1
- package/dist/electronTray.js +110 -76
- package/dist/electronTray.js.map +1 -1
- package/dist/electronUpdater.d.ts +6 -3
- package/dist/electronUpdater.d.ts.map +1 -1
- package/dist/electronUpdater.js +10 -7
- package/dist/electronUpdater.js.map +1 -1
- package/dist/electronWindow.d.ts +23 -7
- package/dist/electronWindow.d.ts.map +1 -1
- package/dist/electronWindow.js +234 -152
- package/dist/electronWindow.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/types/ElectronApi.d.ts +393 -0
- package/dist/types/ElectronApi.d.ts.map +1 -0
- package/dist/types/ElectronApi.js +20 -0
- package/dist/types/ElectronApi.js.map +1 -0
- package/dist/types/ElectronAppCapabilitiesFor.d.ts +8 -0
- package/dist/types/ElectronAppCapabilitiesFor.d.ts.map +1 -0
- package/dist/types/ElectronAppCapabilitiesFor.js +2 -0
- package/dist/types/ElectronAppCapabilitiesFor.js.map +1 -0
- package/dist/types/ElectronHost.d.ts +43 -0
- package/dist/types/ElectronHost.d.ts.map +1 -0
- package/dist/types/ElectronHost.js +2 -0
- package/dist/types/ElectronHost.js.map +1 -0
- package/dist/types/ElectronHostGroups.d.ts +85 -0
- package/dist/types/ElectronHostGroups.d.ts.map +1 -0
- package/dist/types/ElectronHostGroups.js +2 -0
- package/dist/types/ElectronHostGroups.js.map +1 -0
- package/dist/types/ElectronHostOptions.d.ts +7 -0
- package/dist/types/ElectronHostOptions.d.ts.map +1 -0
- package/dist/types/ElectronHostOptions.js +2 -0
- package/dist/types/ElectronHostOptions.js.map +1 -0
- package/dist/types/ElectronProtocolCapabilities.d.ts +3 -0
- package/dist/types/ElectronProtocolCapabilities.d.ts.map +1 -0
- package/dist/types/ElectronProtocolCapabilities.js +2 -0
- package/dist/types/ElectronProtocolCapabilities.js.map +1 -0
- package/dist/types/ElectronTrayCapabilitiesFor.d.ts +7 -0
- package/dist/types/ElectronTrayCapabilitiesFor.d.ts.map +1 -0
- package/dist/types/ElectronTrayCapabilitiesFor.js +2 -0
- package/dist/types/ElectronTrayCapabilitiesFor.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +42 -21
- package/src/electronApp.test.ts +158 -131
- package/src/electronClipboard.test.ts +40 -13
- package/src/electronDefaultHostGroups.test.ts +148 -0
- package/src/electronDialog.test.ts +55 -53
- package/src/electronHostTreeShaking.test.ts +51 -0
- package/src/electronIpc.test.ts +47 -66
- package/src/electronMenu.test.ts +61 -47
- package/src/electronMenuTemplate.test.ts +1 -1
- package/src/electronNotification.test.ts +71 -21
- package/src/electronPlatform.test.ts +17 -12
- package/src/electronPower.test.ts +112 -88
- package/src/electronProtocol.test.ts +68 -35
- package/src/electronRegister.test.ts +280 -26
- package/src/electronScreen.test.ts +34 -25
- package/src/electronShell.test.ts +99 -59
- package/src/electronShortcut.test.ts +22 -19
- package/src/electronStorage.test.ts +26 -24
- package/src/electronTray.test.ts +225 -109
- package/src/electronUpdater.test.ts +26 -19
- package/src/electronWindow.test.ts +229 -101
package/src/electronApp.test.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} from './
|
|
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
|
-
|
|
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 =
|
|
106
|
-
|
|
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,
|
|
142
|
+
it('publishes macOS-only dock, login, open-file, and activation slots', () => {
|
|
133
143
|
const fake = fakeElectron();
|
|
134
|
-
const app =
|
|
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 =
|
|
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 =
|
|
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(() =>
|
|
183
|
+
expect(() => electronHostApp(electron, 'macos')).toThrow('require app.dock');
|
|
175
184
|
});
|
|
176
185
|
});
|
|
177
|
-
describe('
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
describe('
|
|
184
|
-
|
|
185
|
-
|
|
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('
|
|
190
|
-
it('is the construction initializer of
|
|
191
|
-
expect(typeof
|
|
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('
|
|
196
|
-
it('is the construction initializer of
|
|
197
|
-
expect(typeof
|
|
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('
|
|
202
|
-
it('is the construction initializer of
|
|
203
|
-
expect(typeof
|
|
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('
|
|
208
|
-
it('is the construction initializer of
|
|
209
|
-
expect(typeof
|
|
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('
|
|
214
|
-
it('is the construction initializer of
|
|
215
|
-
expect(typeof
|
|
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('
|
|
220
|
-
it('is the construction initializer of
|
|
221
|
-
expect(typeof
|
|
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('
|
|
226
|
-
it('is the construction initializer of
|
|
227
|
-
expect(typeof
|
|
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('
|
|
232
|
-
it('is the construction initializer of
|
|
233
|
-
expect(typeof
|
|
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('
|
|
238
|
-
it('is the construction initializer of
|
|
239
|
-
expect(typeof
|
|
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('
|
|
244
|
-
it('is the construction initializer of
|
|
245
|
-
expect(typeof
|
|
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('
|
|
250
|
-
it('is the construction initializer of
|
|
251
|
-
expect(typeof
|
|
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('
|
|
256
|
-
it('is the construction initializer of
|
|
257
|
-
expect(typeof
|
|
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('
|
|
262
|
-
it('is the construction initializer of
|
|
263
|
-
expect(typeof
|
|
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('
|
|
268
|
-
it('is the construction initializer of
|
|
269
|
-
expect(typeof
|
|
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('
|
|
274
|
-
it('is the construction initializer of
|
|
275
|
-
expect(typeof
|
|
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('
|
|
280
|
-
it('is the construction initializer of
|
|
281
|
-
expect(typeof
|
|
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('
|
|
286
|
-
it('is the construction initializer of
|
|
287
|
-
expect(typeof
|
|
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('
|
|
292
|
-
it('is the construction initializer of
|
|
293
|
-
expect(typeof
|
|
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('
|
|
298
|
-
it('is the construction initializer of
|
|
299
|
-
expect(typeof
|
|
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('
|
|
304
|
-
it('is the construction initializer of
|
|
305
|
-
expect(typeof
|
|
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('
|
|
310
|
-
it('is the construction initializer of
|
|
311
|
-
expect(typeof
|
|
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('
|
|
316
|
-
it('is the construction initializer of
|
|
317
|
-
expect(typeof
|
|
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('
|
|
322
|
-
it('is the construction initializer of
|
|
323
|
-
expect(typeof
|
|
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('
|
|
328
|
-
it('is the construction initializer of
|
|
329
|
-
expect(typeof
|
|
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('
|
|
334
|
-
it('is the construction initializer of
|
|
335
|
-
expect(typeof
|
|
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('
|
|
340
|
-
it('is the construction initializer of
|
|
341
|
-
expect(typeof
|
|
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
|
|
2
|
-
|
|
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
|
-
|
|
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('
|
|
61
|
+
describe('electronHostClipboard', () => {
|
|
53
62
|
it('round-trips text through the Electron clipboard', async () => {
|
|
54
|
-
const backend =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
});
|