@flighthq/host-tauri 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 (84) hide show
  1. package/README.md +3 -3
  2. package/dist/contract.d.ts +12 -15
  3. package/dist/contract.d.ts.map +1 -1
  4. package/dist/contract.js +12 -15
  5. package/dist/contract.js.map +1 -1
  6. package/dist/index.d.ts +12 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +12 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/tauriApp.d.ts +10 -3
  11. package/dist/tauriApp.d.ts.map +1 -1
  12. package/dist/tauriApp.js +51 -34
  13. package/dist/tauriApp.js.map +1 -1
  14. package/dist/tauriClipboard.d.ts +4 -3
  15. package/dist/tauriClipboard.d.ts.map +1 -1
  16. package/dist/tauriClipboard.js +11 -11
  17. package/dist/tauriClipboard.js.map +1 -1
  18. package/dist/tauriDialog.d.ts +8 -9
  19. package/dist/tauriDialog.d.ts.map +1 -1
  20. package/dist/tauriDialog.js +32 -25
  21. package/dist/tauriDialog.js.map +1 -1
  22. package/dist/tauriHost.d.ts +4 -0
  23. package/dist/tauriHost.d.ts.map +1 -0
  24. package/dist/tauriHost.js +70 -0
  25. package/dist/tauriHost.js.map +1 -0
  26. package/dist/tauriHostGroups.d.ts +85 -0
  27. package/dist/tauriHostGroups.d.ts.map +1 -0
  28. package/dist/tauriHostGroups.js +2 -0
  29. package/dist/tauriHostGroups.js.map +1 -0
  30. package/dist/tauriMenu.d.ts +6 -3
  31. package/dist/tauriMenu.d.ts.map +1 -1
  32. package/dist/tauriMenu.js +42 -26
  33. package/dist/tauriMenu.js.map +1 -1
  34. package/dist/tauriNotification.d.ts +6 -3
  35. package/dist/tauriNotification.d.ts.map +1 -1
  36. package/dist/tauriNotification.js +35 -20
  37. package/dist/tauriNotification.js.map +1 -1
  38. package/dist/tauriPlatform.d.ts +4 -3
  39. package/dist/tauriPlatform.d.ts.map +1 -1
  40. package/dist/tauriPlatform.js +6 -10
  41. package/dist/tauriPlatform.js.map +1 -1
  42. package/dist/tauriShell.d.ts +6 -5
  43. package/dist/tauriShell.d.ts.map +1 -1
  44. package/dist/tauriShell.js +24 -24
  45. package/dist/tauriShell.js.map +1 -1
  46. package/dist/tauriShortcut.d.ts +5 -5
  47. package/dist/tauriShortcut.d.ts.map +1 -1
  48. package/dist/tauriShortcut.js +20 -19
  49. package/dist/tauriShortcut.js.map +1 -1
  50. package/dist/tauriTray.d.ts +11 -3
  51. package/dist/tauriTray.d.ts.map +1 -1
  52. package/dist/tauriTray.js +260 -227
  53. package/dist/tauriTray.js.map +1 -1
  54. package/dist/tauriUnsupportedHostGroups.d.ts +70 -0
  55. package/dist/tauriUnsupportedHostGroups.d.ts.map +1 -0
  56. package/dist/tauriUnsupportedHostGroups.js +127 -0
  57. package/dist/tauriUnsupportedHostGroups.js.map +1 -0
  58. package/dist/tauriWindow.d.ts +5 -3
  59. package/dist/tauriWindow.d.ts.map +1 -1
  60. package/dist/tauriWindow.js +209 -132
  61. package/dist/tauriWindow.js.map +1 -1
  62. package/dist/types.d.ts +251 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +2 -0
  65. package/dist/types.js.map +1 -0
  66. package/package.json +40 -16
  67. package/src/tauriApp.test.ts +55 -12
  68. package/src/tauriClipboard.test.ts +13 -14
  69. package/src/tauriDialog.test.ts +37 -57
  70. package/src/tauriHost.test.ts +312 -0
  71. package/src/tauriMenu.test.ts +41 -26
  72. package/src/tauriNotification.test.ts +31 -13
  73. package/src/tauriPackage.test.ts +295 -0
  74. package/src/tauriPlatform.test.ts +16 -11
  75. package/src/tauriShell.test.ts +31 -34
  76. package/src/tauriShortcut.test.ts +15 -29
  77. package/src/tauriTray.test.ts +108 -49
  78. package/src/tauriUnsupportedHostGroups.test.ts +125 -0
  79. package/src/tauriWindow.test.ts +98 -85
  80. package/dist/tauriRegister.d.ts +0 -4
  81. package/dist/tauriRegister.d.ts.map +0 -1
  82. package/dist/tauriRegister.js +0 -69
  83. package/dist/tauriRegister.js.map +0 -1
  84. package/src/tauriRegister.test.ts +0 -91
@@ -7,6 +7,20 @@ import {
7
7
  setTrayIconContextMenu,
8
8
  setTrayIconTemplate,
9
9
  } from '@flighthq/tray/contract';
10
+ import type { TrayIcon } from '@flighthq/tray/contract';
11
+ import { describe, expect, it, vi } from 'vitest';
12
+
13
+ import {
14
+ tauriHostTray,
15
+ tauriHostTrayImage,
16
+ tauriHostTrayInteractionEvents,
17
+ tauriHostTrayLifecycle,
18
+ tauriHostTrayMenu,
19
+ tauriHostTrayMenuSelectionEvents,
20
+ tauriHostTrayTemplateImage,
21
+ tauriHostTrayTitle,
22
+ tauriHostTrayTooltip,
23
+ } from './tauriTray.ts';
10
24
  import type {
11
25
  TauriApi,
12
26
  TauriMenu,
@@ -14,11 +28,7 @@ import type {
14
28
  TauriTrayIcon,
15
29
  TauriTrayIconEvent,
16
30
  TauriTrayIconOptions,
17
- TrayIconForHost,
18
- } from '@flighthq/types/contract';
19
- import { describe, expect, it, vi } from 'vitest';
20
-
21
- import { createTauriTrayCapabilities, initializeTauriTrayCapabilities } from './tauriTray';
31
+ } from './types.ts';
22
32
 
23
33
  interface FakeIcon extends TauriTrayIcon {
24
34
  closeFailures: number;
@@ -101,22 +111,18 @@ async function flushMicrotasks(): Promise<void> {
101
111
  for (let index = 0; index < 12; index++) await Promise.resolve();
102
112
  }
103
113
 
104
- async function acquire<
105
- Host extends { tray: { lifecycle: ReturnType<typeof createTauriTrayCapabilities>['lifecycle'] } },
106
- >(host: Host): Promise<TrayIconForHost<Host>> {
107
- const result = await createTrayIcon(host, { icon: 'icon.png' });
114
+ async function acquire(hostTrayLifecycle: ReturnType<typeof tauriHostTray>['lifecycle']): Promise<TrayIcon> {
115
+ const result = await createTrayIcon(hostTrayLifecycle, { icon: 'icon.png' });
108
116
  if (result.outcome !== 'created') throw new Error(result.outcome);
109
117
  return result.tray;
110
118
  }
111
119
 
112
- describe('createTauriTrayCapabilities', () => {
113
- it('exposes only the slots supported by the injected OS profile', () => {
120
+ describe('tauriHostTray', () => {
121
+ it('exposes the slots supported by the injected OS profile and none exclusive to another', () => {
114
122
  const { tauri } = fakeTauri();
115
- expect(Object.keys(createTauriTrayCapabilities(tauri, 'linux')).sort()).toEqual(
116
- ['image', 'lifecycle', 'menu', 'menuSelectionEvents', 'title'].sort(),
117
- );
118
- expect(Object.keys(createTauriTrayCapabilities(tauri, 'macos')).sort()).toEqual(
119
- [
123
+ const supported = {
124
+ linux: ['image', 'lifecycle', 'menu', 'menuSelectionEvents', 'title'],
125
+ macos: [
120
126
  'image',
121
127
  'interactionEvents',
122
128
  'lifecycle',
@@ -125,11 +131,21 @@ describe('createTauriTrayCapabilities', () => {
125
131
  'templateImage',
126
132
  'title',
127
133
  'tooltip',
128
- ].sort(),
129
- );
130
- expect(Object.keys(createTauriTrayCapabilities(tauri, 'windows')).sort()).toEqual(
131
- ['image', 'interactionEvents', 'lifecycle', 'menu', 'menuSelectionEvents', 'tooltip'].sort(),
132
- );
134
+ ],
135
+ windows: ['image', 'interactionEvents', 'lifecycle', 'menu', 'menuSelectionEvents', 'tooltip'],
136
+ } as const;
137
+ for (const profile of ['linux', 'macos', 'windows'] as const) {
138
+ const slots = Object.keys(tauriHostTray(tauri, profile));
139
+ const exclusiveElsewhere: readonly string[] = Object.entries(supported)
140
+ .filter(([other]) => other !== profile)
141
+ .flatMap(([, others]) => others)
142
+ .filter((slot) => !(supported[profile] as readonly string[]).includes(slot));
143
+ expect(slots, profile).toEqual(expect.arrayContaining([...supported[profile]]));
144
+ expect(
145
+ slots.filter((slot) => exclusiveElsewhere.includes(slot)),
146
+ profile,
147
+ ).toEqual([]);
148
+ }
133
149
  });
134
150
 
135
151
  it('publishes only after asynchronous native acquisition resolves', async () => {
@@ -139,8 +155,8 @@ describe('createTauriTrayCapabilities', () => {
139
155
  new Promise((accept) => {
140
156
  resolve = accept;
141
157
  });
142
- const host = { tray: createTauriTrayCapabilities(tauri, 'linux') };
143
- const pending = createTrayIcon(host, { icon: 'icon.png' });
158
+ const host = { tray: tauriHostTray(tauri, 'linux') };
159
+ const pending = createTrayIcon(host.tray.lifecycle, { icon: 'icon.png' });
144
160
  expect(host.tray.lifecycle.list()).toEqual([]);
145
161
  resolve({
146
162
  async close() {},
@@ -161,9 +177,9 @@ describe('createTauriTrayCapabilities', () => {
161
177
  new Promise((accept) => {
162
178
  resolve = accept;
163
179
  });
164
- const host = { tray: createTauriTrayCapabilities(tauri, 'linux') };
180
+ const host = { tray: tauriHostTray(tauri, 'linux') };
165
181
  const controller = new AbortController();
166
- const pending = createTrayIcon(host, { icon: 'icon.png', signal: controller.signal });
182
+ const pending = createTrayIcon(host.tray.lifecycle, { icon: 'icon.png', signal: controller.signal });
167
183
  controller.abort();
168
184
  const close = vi.fn(async () => {});
169
185
  resolve({
@@ -184,29 +200,29 @@ describe('createTauriTrayCapabilities', () => {
184
200
  tauri.tray.TrayIcon.new = async () => {
185
201
  throw new Error('rejected');
186
202
  };
187
- const host = { tray: createTauriTrayCapabilities(tauri, 'linux') };
188
- expect((await createTrayIcon(host, { icon: 'icon.png' })).outcome).toBe('tray-create-failed');
203
+ const host = { tray: tauriHostTray(tauri, 'linux') };
204
+ expect((await createTrayIcon(host.tray.lifecycle, { icon: 'icon.png' })).outcome).toBe('tray-create-failed');
189
205
  expect(host.tray.lifecycle.list()).toEqual([]);
190
206
  });
191
207
 
192
208
  it('delivers interaction payload through the profile-owned signal', async () => {
193
209
  const { action, tauri } = fakeTauri();
194
- const host = { tray: createTauriTrayCapabilities(tauri, 'macos') };
195
- const tray = await acquire(host);
210
+ const host = { tray: tauriHostTray(tauri, 'macos') };
211
+ const tray = await acquire(host.tray.lifecycle);
196
212
  const listener = vi.fn();
197
- onTrayInteraction(tray, listener);
213
+ onTrayInteraction(host.tray.interactionEvents, tray, listener);
198
214
  action()!({ button: 'Right', position: { x: 5, y: 6 }, type: 'Click' });
199
215
  expect(listener).toHaveBeenCalledWith(expect.objectContaining({ position: { x: 5, y: 6 }, type: 'rightClick' }));
200
216
  });
201
217
 
202
218
  it('routes menu selection per Tray and replaces the previous menu transactionally', async () => {
203
219
  const { icons, menuActions, menus, tauri } = fakeTauri();
204
- const host = { tray: createTauriTrayCapabilities(tauri, 'linux') };
205
- const tray = await acquire(host);
220
+ const host = { tray: tauriHostTray(tauri, 'linux') };
221
+ const tray = await acquire(host.tray.lifecycle);
206
222
  const selected: string[] = [];
207
- onTrayMenuSelection(tray, ({ id }) => selected.push(id));
208
- expect((await setTrayIconContextMenu(tray, [{ id: 'old', label: 'Old' }])).outcome).toBe('updated');
209
- expect((await setTrayIconContextMenu(tray, [{ id: 'new', label: 'New' }])).outcome).toBe('updated');
223
+ onTrayMenuSelection(host.tray.menuSelectionEvents, tray, ({ id }) => selected.push(id));
224
+ expect((await setTrayIconContextMenu(host.tray.menu, tray, [{ id: 'old', label: 'Old' }])).outcome).toBe('updated');
225
+ expect((await setTrayIconContextMenu(host.tray.menu, tray, [{ id: 'new', label: 'New' }])).outcome).toBe('updated');
210
226
  menuActions[1].action?.('new');
211
227
  expect(selected).toEqual(['new']);
212
228
  expect(icons[0].installed).toEqual([menus[0], menus[1]]);
@@ -218,10 +234,10 @@ describe('createTauriTrayCapabilities', () => {
218
234
  const { icons, tauri } = fakeTauri();
219
235
  const resolvers: Array<(menu: TauriMenu) => void> = [];
220
236
  tauri.menu.Menu.new = () => new Promise((resolve) => resolvers.push(resolve));
221
- const host = { tray: createTauriTrayCapabilities(tauri, 'linux') };
222
- const tray = await acquire(host);
223
- const old = setTrayIconContextMenu(tray, [{ id: 'old' }]);
224
- const newest = setTrayIconContextMenu(tray, [{ id: 'new' }]);
237
+ const host = { tray: tauriHostTray(tauri, 'linux') };
238
+ const tray = await acquire(host.tray.lifecycle);
239
+ const old = setTrayIconContextMenu(host.tray.menu, tray, [{ id: 'old' }]);
240
+ const newest = setTrayIconContextMenu(host.tray.menu, tray, [{ id: 'new' }]);
225
241
  await flushMicrotasks();
226
242
  const oldClose = vi.fn(async () => {});
227
243
  const newClose = vi.fn(async () => {});
@@ -235,18 +251,18 @@ describe('createTauriTrayCapabilities', () => {
235
251
 
236
252
  it('uses typed async updates and macOS template treatment', async () => {
237
253
  const { icons, tauri } = fakeTauri();
238
- const host = { tray: createTauriTrayCapabilities(tauri, 'macos') };
239
- const tray = await acquire(host);
240
- expect((await setTrayIcon(tray, 'next.png')).outcome).toBe('updated');
241
- expect((await setTrayIconTemplate(tray, true)).outcome).toBe('updated');
254
+ const host = { tray: tauriHostTray(tauri, 'macos') };
255
+ const tray = await acquire(host.tray.lifecycle);
256
+ expect((await setTrayIcon(host.tray.image, tray, 'next.png')).outcome).toBe('updated');
257
+ expect((await setTrayIconTemplate(host.tray.templateImage, tray, true)).outcome).toBe('updated');
242
258
  expect(icons[0].template).toBe(true);
243
259
  });
244
260
 
245
261
  it('attempts menu and native teardown and retries only failed native steps', async () => {
246
262
  const { icons, menus, tauri } = fakeTauri();
247
- const host = { tray: createTauriTrayCapabilities(tauri, 'linux') };
248
- const tray = await acquire(host);
249
- await setTrayIconContextMenu(tray, [{ id: 'quit' }]);
263
+ const host = { tray: tauriHostTray(tauri, 'linux') };
264
+ const tray = await acquire(host.tray.lifecycle);
265
+ await setTrayIconContextMenu(host.tray.menu, tray, [{ id: 'quit' }]);
250
266
  icons[0].closeFailures = 1;
251
267
  expect((await destroyTrayIcon(tray)).outcome).toBe('tray-destroy-failed');
252
268
  expect(menus[0].closed).toBe(1);
@@ -255,8 +271,51 @@ describe('createTauriTrayCapabilities', () => {
255
271
  expect(icons[0].closed).toBe(1);
256
272
  });
257
273
  });
258
- describe('initializeTauriTrayCapabilities', () => {
259
- it('is the construction initializer of createTauriTrayCapabilities', () => {
260
- expect(typeof initializeTauriTrayCapabilities).toBe('function');
274
+
275
+ describe('tauriHostTrayImage', () => {
276
+ it('constructs the image provider independently', () => {
277
+ expect(tauriHostTrayImage(fakeTauri().tauri, 'linux').set).toBeTypeOf('function');
278
+ });
279
+ });
280
+
281
+ describe('tauriHostTrayInteractionEvents', () => {
282
+ it('constructs the interaction-events provider independently', () => {
283
+ expect(tauriHostTrayInteractionEvents(fakeTauri().tauri, 'windows').getSignal).toBeTypeOf('function');
284
+ });
285
+ });
286
+
287
+ describe('tauriHostTrayLifecycle', () => {
288
+ it('constructs the lifecycle provider independently', () => {
289
+ expect(tauriHostTrayLifecycle(fakeTauri().tauri, 'linux').create).toBeTypeOf('function');
290
+ });
291
+ });
292
+
293
+ describe('tauriHostTrayMenu', () => {
294
+ it('constructs the menu provider independently', () => {
295
+ expect(tauriHostTrayMenu(fakeTauri().tauri, 'linux').set).toBeTypeOf('function');
296
+ });
297
+ });
298
+
299
+ describe('tauriHostTrayMenuSelectionEvents', () => {
300
+ it('constructs the menu-selection provider independently', () => {
301
+ expect(tauriHostTrayMenuSelectionEvents(fakeTauri().tauri, 'linux').getSignal).toBeTypeOf('function');
302
+ });
303
+ });
304
+
305
+ describe('tauriHostTrayTemplateImage', () => {
306
+ it('constructs the template-image provider independently', () => {
307
+ expect(tauriHostTrayTemplateImage(fakeTauri().tauri).set).toBeTypeOf('function');
308
+ });
309
+ });
310
+
311
+ describe('tauriHostTrayTitle', () => {
312
+ it('constructs the title provider independently', () => {
313
+ expect(tauriHostTrayTitle(fakeTauri().tauri, 'linux').get).toBeTypeOf('function');
314
+ });
315
+ });
316
+
317
+ describe('tauriHostTrayTooltip', () => {
318
+ it('constructs the tooltip provider independently', () => {
319
+ expect(tauriHostTrayTooltip(fakeTauri().tauri, 'windows').get).toBeTypeOf('function');
261
320
  });
262
321
  });
@@ -0,0 +1,125 @@
1
+ import {
2
+ webHostAudioDecode,
3
+ webHostImageDecode,
4
+ webHostImageEncode,
5
+ webHostTextShaper,
6
+ } from '@flighthq/host-web/contract';
7
+
8
+ import {
9
+ tauriHostAccessibility,
10
+ tauriHostAudio,
11
+ tauriHostBitmap,
12
+ tauriHostConnectivity,
13
+ tauriHostDevice,
14
+ tauriHostFileSystem,
15
+ tauriHostFont,
16
+ tauriHostFullscreen,
17
+ tauriHostGeolocation,
18
+ tauriHostGl,
19
+ tauriHostGlyph,
20
+ tauriHostHaptics,
21
+ tauriHostImage,
22
+ tauriHostAudioDecode,
23
+ tauriHostImageDecode,
24
+ tauriHostImageEncode,
25
+ tauriHostInput,
26
+ tauriHostIpc,
27
+ tauriHostLifecycle,
28
+ tauriHostMediaSession,
29
+ tauriHostMidi,
30
+ tauriHostNet,
31
+ tauriHostPermissions,
32
+ tauriHostPower,
33
+ tauriHostPreferences,
34
+ tauriHostProtocol,
35
+ tauriHostScreen,
36
+ tauriHostSensors,
37
+ tauriHostShare,
38
+ tauriHostSocket,
39
+ tauriHostSoftKeyboard,
40
+ tauriHostStatusBar,
41
+ tauriHostCanvas,
42
+ tauriHostSurface,
43
+ tauriHostTextSegment,
44
+ tauriHostCompress,
45
+ tauriHostDecompress,
46
+ tauriHostTextShaper,
47
+ tauriHostUpdater,
48
+ tauriHostVideo,
49
+ tauriHostWgpu,
50
+ } from './tauriUnsupportedHostGroups.ts';
51
+
52
+ function returnsEmptyGroup(constructor: () => object): () => void {
53
+ return () => {
54
+ it('constructs an explicit empty capability group', () => expect(constructor()).toEqual({}));
55
+ };
56
+ }
57
+
58
+ describe('tauriHostAccessibility', returnsEmptyGroup(tauriHostAccessibility));
59
+ describe('tauriHostAudio', returnsEmptyGroup(tauriHostAudio));
60
+ describe('tauriHostAudioDecode', () => {
61
+ it('delegates to the shared web audio decode capabilities', () => {
62
+ expect(tauriHostAudioDecode()).toBe(webHostAudioDecode);
63
+ });
64
+ });
65
+ describe('tauriHostBitmap', returnsEmptyGroup(tauriHostBitmap));
66
+ describe('tauriHostCanvas', () => {
67
+ it('claims no canvas slots', () => expect(tauriHostCanvas()).toEqual({}));
68
+ });
69
+ describe('tauriHostCompress', returnsEmptyGroup(tauriHostCompress));
70
+ describe('tauriHostConnectivity', returnsEmptyGroup(tauriHostConnectivity));
71
+ describe('tauriHostDecompress', returnsEmptyGroup(tauriHostDecompress));
72
+ describe('tauriHostDevice', returnsEmptyGroup(tauriHostDevice));
73
+ describe('tauriHostFileSystem', returnsEmptyGroup(tauriHostFileSystem));
74
+ describe('tauriHostFont', returnsEmptyGroup(tauriHostFont));
75
+ describe('tauriHostFullscreen', returnsEmptyGroup(tauriHostFullscreen));
76
+ describe('tauriHostGeolocation', returnsEmptyGroup(tauriHostGeolocation));
77
+ describe('tauriHostGl', returnsEmptyGroup(tauriHostGl));
78
+ describe('tauriHostGlyph', returnsEmptyGroup(tauriHostGlyph));
79
+ describe('tauriHostHaptics', returnsEmptyGroup(tauriHostHaptics));
80
+ describe('tauriHostImage', returnsEmptyGroup(tauriHostImage));
81
+ describe('tauriHostImageDecode', () => {
82
+ it('delegates to the shared web image decode capabilities', () => {
83
+ expect(tauriHostImageDecode()).toBe(webHostImageDecode);
84
+ });
85
+ });
86
+ describe('tauriHostImageEncode', () => {
87
+ it('delegates to the shared web image encode capabilities', () => {
88
+ expect(tauriHostImageEncode()).toBe(webHostImageEncode);
89
+ });
90
+ });
91
+ describe('tauriHostInput', returnsEmptyGroup(tauriHostInput));
92
+ describe('tauriHostIpc', returnsEmptyGroup(tauriHostIpc));
93
+ describe('tauriHostLifecycle', returnsEmptyGroup(tauriHostLifecycle));
94
+ describe('tauriHostMediaSession', returnsEmptyGroup(tauriHostMediaSession));
95
+ describe('tauriHostMidi', returnsEmptyGroup(tauriHostMidi));
96
+ describe('tauriHostNet', returnsEmptyGroup(tauriHostNet));
97
+ describe('tauriHostPermissions', returnsEmptyGroup(tauriHostPermissions));
98
+ describe('tauriHostPower', returnsEmptyGroup(tauriHostPower));
99
+ describe('tauriHostPreferences', returnsEmptyGroup(tauriHostPreferences));
100
+ describe('tauriHostProtocol', returnsEmptyGroup(tauriHostProtocol));
101
+ describe('tauriHostScreen', returnsEmptyGroup(tauriHostScreen));
102
+ describe('tauriHostSensors', returnsEmptyGroup(tauriHostSensors));
103
+ describe('tauriHostShare', returnsEmptyGroup(tauriHostShare));
104
+ describe('tauriHostSocket', returnsEmptyGroup(tauriHostSocket));
105
+ describe('tauriHostSoftKeyboard', returnsEmptyGroup(tauriHostSoftKeyboard));
106
+
107
+ describe('tauriHostStatusBar', returnsEmptyGroup(tauriHostStatusBar));
108
+ describe('tauriHostSurface', returnsEmptyGroup(tauriHostSurface));
109
+ describe('tauriHostTextSegment', returnsEmptyGroup(tauriHostTextSegment));
110
+ describe('tauriHostTextShaper', () => {
111
+ it('fills the shaper slot with the shared web text shaper', () => {
112
+ const group = tauriHostTextShaper();
113
+ expect(group.shaper).toBe(webHostTextShaper);
114
+ });
115
+
116
+ it('is plain data with no Entity runtime and no symbol keys', () => {
117
+ const group = tauriHostTextShaper();
118
+ expect(Symbol.for('EntityRuntime') in group).toBe(false);
119
+ expect(Object.getOwnPropertySymbols(group)).toEqual([]);
120
+ expect(Object.keys(group)).toEqual(['shaper']);
121
+ });
122
+ });
123
+ describe('tauriHostUpdater', returnsEmptyGroup(tauriHostUpdater));
124
+ describe('tauriHostVideo', returnsEmptyGroup(tauriHostVideo));
125
+ describe('tauriHostWgpu', returnsEmptyGroup(tauriHostWgpu));
@@ -1,9 +1,8 @@
1
- import { createApplicationWindow, openWindow } from '@flighthq/application/contract';
1
+ import { createAppWindow, openWindow } from '@flighthq/app';
2
2
  import { connectSignal } from '@flighthq/signals/contract';
3
- import { EntityRuntimeKey } from '@flighthq/types/contract';
4
- import type { TauriApi, TauriLogicalSizeLike, TauriPhysicalPositionLike } from '@flighthq/types/contract';
5
3
 
6
- import { createTauriWindowBackend, initializeTauriWindowBackend } from './tauriWindow';
4
+ import { tauriHostWindow } from './tauriWindow.ts';
5
+ import type { TauriApi, TauriLogicalSizeLike, TauriPhysicalPositionLike } from './types.ts';
7
6
 
8
7
  interface FakeWindowState {
9
8
  calls: { method: string; args: unknown[] }[];
@@ -97,49 +96,68 @@ function methods(state: FakeWindowState): string[] {
97
96
  return state.calls.map((c) => c.method);
98
97
  }
99
98
 
100
- describe('createTauriWindowBackend', () => {
101
- it('adapter-roster axis: publishes exactly 24 P1 operations and omits the four false members', () => {
99
+ describe('tauriHostWindow', () => {
100
+ it('adapter-roster axis: publishes the supported P1 operations and omits the four false members', () => {
102
101
  const { tauri } = fakeTauri();
103
- const backend = createTauriWindowBackend(tauri);
102
+ const backend = tauriHostWindow(tauri);
104
103
 
105
- expect(EntityRuntimeKey in backend).toBe(true);
106
- expect(
107
- Object.keys(backend)
108
- .filter((operation) => operation !== 'attach')
109
- .sort(),
110
- ).toEqual([
111
- 'center',
112
- 'close',
113
- 'flashWindowFrame',
104
+ expect(Object.keys(backend).sort()).toEqual([
105
+ 'appearance',
106
+ 'attach',
107
+ 'attention',
108
+ 'contentProtection',
114
109
  'focus',
115
- 'getBounds',
116
- 'hide',
117
- 'maximize',
118
- 'minimize',
119
- 'open',
120
- 'requestAttention',
121
- 'restore',
122
- 'setAlwaysOnTop',
123
- 'setContentProtection',
124
- 'setFullscreen',
125
- 'setHasShadow',
126
- 'setIcon',
127
- 'setMaximumSize',
128
- 'setMinimumSize',
129
- 'setPosition',
130
- 'setResizable',
131
- 'setSize',
132
- 'setSkipTaskbar',
133
- 'setTitle',
134
- 'show',
110
+ 'fullscreen',
111
+ 'geometry',
112
+ 'lifecycle',
113
+ 'shadow',
114
+ 'shell',
115
+ 'sizeConstraints',
116
+ 'state',
117
+ 'visibility',
118
+ 'zOrder',
135
119
  ]);
120
+ const operations = Object.values(backend).flatMap((capability) => Object.keys(capability ?? {}));
121
+ expect(operations).toEqual(
122
+ expect.arrayContaining([
123
+ 'center',
124
+ 'close',
125
+ 'flashWindowFrame',
126
+ 'focus',
127
+ 'getBounds',
128
+ 'hide',
129
+ 'maximize',
130
+ 'minimize',
131
+ 'open',
132
+ 'requestAttention',
133
+ 'restore',
134
+ 'setAlwaysOnTop',
135
+ 'setContentProtection',
136
+ 'setFullscreen',
137
+ 'setHasShadow',
138
+ 'setIcon',
139
+ 'setMaximumSize',
140
+ 'setMinimumSize',
141
+ 'setPosition',
142
+ 'setResizable',
143
+ 'setSize',
144
+ 'setSkipTaskbar',
145
+ 'setTitle',
146
+ 'show',
147
+ ]),
148
+ );
149
+ for (const falseMember of ['setMenuBarVisible', 'setOpacity', 'setParent', 'setProgress']) {
150
+ expect(operations, falseMember).not.toContain(falseMember);
151
+ }
136
152
  });
137
153
 
138
154
  it('opens the current window and applies options', () => {
139
155
  const { tauri, state } = fakeTauri();
140
- const backend = createTauriWindowBackend(tauri);
141
- const win = createApplicationWindow();
142
- expect(backend.open!(win, { title: 'Hi', width: 640, height: 480, resizable: false, visible: true })).toBe(true);
156
+ const backend = tauriHostWindow(tauri);
157
+ const win = createAppWindow();
158
+ expect(
159
+ backend.lifecycle!.open(win, { title: 'Hi', width: 640, height: 480, resizable: false, visible: true }),
160
+ ).toBe(true);
143
161
  expect(methods(state)).toContain('setTitle');
144
162
  expect(methods(state)).toContain('setSize');
145
163
  expect(methods(state)).toContain('setResizable');
@@ -148,11 +166,11 @@ describe('createTauriWindowBackend', () => {
148
166
 
149
167
  it('mirrors native move/resize/focus events onto the entity and its signals', () => {
150
168
  const { tauri, state } = fakeTauri();
151
- const backend = createTauriWindowBackend(tauri);
152
- const win = createApplicationWindow();
169
+ const backend = tauriHostWindow(tauri);
170
+ const win = createAppWindow();
153
171
  let moves = 0;
154
172
  connectSignal(win.onMove, () => moves++);
155
- backend.open!(win, {});
173
+ backend.lifecycle!.open(win, {});
156
174
  state.moved!({ payload: { x: 12, y: 34 } });
157
175
  expect(win.x).toBe(12);
158
176
  expect(win.y).toBe(34);
@@ -166,53 +184,53 @@ describe('createTauriWindowBackend', () => {
166
184
 
167
185
  it('routes control methods to the current window and no-ops before open', () => {
168
186
  const { tauri, state } = fakeTauri();
169
- const backend = createTauriWindowBackend(tauri);
170
- const win = createApplicationWindow();
187
+ const backend = tauriHostWindow(tauri);
188
+ const win = createAppWindow();
171
189
  // Not opened yet: nothing routes through.
172
- backend.setTitle!(win, 'ignored');
190
+ backend.appearance!.setTitle(win, 'ignored');
173
191
  expect(state.calls).toHaveLength(0);
174
- backend.open!(win, {});
192
+ backend.lifecycle!.open(win, {});
175
193
  state.calls.length = 0;
176
- backend.setTitle!(win, 'New');
177
- backend.minimize!(win);
178
- backend.setFullscreen!(win, true);
179
- backend.requestAttention!(win, true);
194
+ backend.appearance!.setTitle(win, 'New');
195
+ backend.state!.minimize(win);
196
+ backend.fullscreen!.setFullscreen(win, true);
197
+ backend.attention!.requestAttention(win, true);
180
198
  expect(methods(state)).toEqual(['setTitle', 'minimize', 'setFullscreen', 'requestUserAttention']);
181
199
  });
182
200
 
183
201
  it('reports mirrored bounds from the entity', () => {
184
202
  const { tauri } = fakeTauri();
185
- const backend = createTauriWindowBackend(tauri);
186
- const win = createApplicationWindow();
203
+ const backend = tauriHostWindow(tauri);
204
+ const win = createAppWindow();
187
205
  win.x = 5;
188
206
  win.y = 6;
189
207
  win.width = 100;
190
208
  win.height = 200;
191
- backend.open!(win, {});
209
+ backend.lifecycle!.open(win, {});
192
210
  const out = { x: 0, y: 0, width: 0, height: 0 };
193
- expect(backend.getBounds!(win, out)).toBe(out);
211
+ expect(backend.geometry!.getBounds(win, out)).toBe(out);
194
212
  expect(out).toEqual({ x: 5, y: 6, width: 100, height: 200 });
195
213
  });
196
214
 
197
215
  it('attaches the same existing window idempotently without duplicating event ingress', () => {
198
216
  const { tauri, state, window } = fakeTauri();
199
- const backend = createTauriWindowBackend(tauri);
200
- const win = createApplicationWindow();
217
+ const backend = tauriHostWindow(tauri);
218
+ const win = createAppWindow();
201
219
 
202
- expect(backend.attach?.(win, window, 'host')).toBe(true);
203
- expect(backend.attach?.(win, window, 'host')).toBe(true);
204
- expect(backend.attach?.(createApplicationWindow(), window, 'host')).toBe(false);
220
+ expect(backend.attach!.attach(win, window, 'host')).toBe(true);
221
+ expect(backend.attach!.attach(win, window, 'host')).toBe(true);
222
+ expect(backend.attach!.attach(createAppWindow(), window, 'host')).toBe(false);
205
223
  expect(state.subscriptions).toEqual(['moved', 'resized', 'focusChanged', 'closeRequested']);
206
224
  });
207
225
 
208
226
  it('detaches host-owned windows without closing them and releases all event ingress', async () => {
209
227
  const { tauri, state, window } = fakeTauri();
210
- const backend = createTauriWindowBackend(tauri);
211
- const win = createApplicationWindow();
212
- expect(backend.attach?.(win, window, 'host')).toBe(true);
228
+ const backend = tauriHostWindow(tauri);
229
+ const win = createAppWindow();
230
+ expect(backend.attach!.attach(win, window, 'host')).toBe(true);
213
231
 
214
- backend.close!(win);
215
- backend.close!(win);
232
+ backend.lifecycle!.close(win);
233
+ backend.lifecycle!.close(win);
216
234
  await Promise.resolve();
217
235
 
218
236
  expect(methods(state)).not.toContain('close');
@@ -221,23 +239,23 @@ describe('createTauriWindowBackend', () => {
221
239
 
222
240
  it('closes a Flight-owned attached window once', () => {
223
241
  const { tauri, state, window } = fakeTauri();
224
- const backend = createTauriWindowBackend(tauri);
225
- const win = createApplicationWindow();
226
- expect(backend.attach?.(win, window, 'flight')).toBe(true);
242
+ const backend = tauriHostWindow(tauri);
243
+ const win = createAppWindow();
244
+ expect(backend.attach!.attach(win, window, 'flight')).toBe(true);
227
245
 
228
- backend.close!(win);
229
- backend.close!(win);
246
+ backend.lifecycle!.close(win);
247
+ backend.lifecycle!.close(win);
230
248
 
231
249
  expect(methods(state).filter((method) => method === 'close')).toHaveLength(1);
232
250
  });
233
251
 
234
252
  it('routes native close requests through the terminal-close choke point exactly once', async () => {
235
253
  const { tauri, state, window } = fakeTauri();
236
- const backend = createTauriWindowBackend(tauri);
237
- const win = createApplicationWindow();
254
+ const backend = tauriHostWindow(tauri);
255
+ const win = createAppWindow();
238
256
  let closes = 0;
239
257
  connectSignal(win.onClose, () => closes++);
240
- expect(backend.attach?.(win, window, 'host')).toBe(true);
258
+ expect(backend.attach!.attach(win, window, 'host')).toBe(true);
241
259
 
242
260
  state.closeRequested!();
243
261
  state.closeRequested!();
@@ -249,9 +267,9 @@ describe('createTauriWindowBackend', () => {
249
267
 
250
268
  it('center-owner axis: lets application perform exactly one post-open center command', () => {
251
269
  const { tauri, state } = fakeTauri();
252
- const backend = createTauriWindowBackend(tauri);
270
+ const backend = tauriHostWindow(tauri);
253
271
 
254
- expect(openWindow({ window: backend }, createApplicationWindow(), { center: true })).toBe(true);
272
+ expect(openWindow(backend.lifecycle, backend.geometry!, createAppWindow(), { center: true })).toBe(true);
255
273
 
256
274
  expect(methods(state).filter((method) => method === 'center')).toHaveLength(1);
257
275
  });
@@ -260,7 +278,7 @@ describe('createTauriWindowBackend', () => {
260
278
  // ★ THE REJECTION AXIS. `close(win)` releases a Flight-owned window through `handle.close()`, a promise
261
279
  // the synchronous close path cannot await, so the `.catch` at the call site is the only thing keeping a
262
280
  // rejected close from escaping as an unhandled rejection. Nothing exercised it before.
263
- describe('createTauriWindowBackend close when the platform close rejects', () => {
281
+ describe('tauriHostWindow close when the platform close rejects', () => {
264
282
  it('still detaches the window and raises no unhandled rejection', async () => {
265
283
  const { tauri, window } = fakeTauri();
266
284
  window.close = () => Promise.reject(new Error('close refused by the platform'));
@@ -269,17 +287,17 @@ describe('createTauriWindowBackend close when the platform close rejects', () =>
269
287
  const onUnhandled = (reason: unknown): void => void unhandled.push(reason);
270
288
  process.on('unhandledRejection', onUnhandled);
271
289
  try {
272
- const backend = createTauriWindowBackend(tauri);
273
- const win = createApplicationWindow();
290
+ const backend = tauriHostWindow(tauri);
291
+ const win = createAppWindow();
274
292
  // ATTACHED AS 'flight', deliberately: `open` adopts the pre-existing window as 'host', and the
275
293
  // close path only calls the platform close for a window Flight itself owns. Driving this through
276
294
  // `open` exercises a branch that never calls `close()` at all, so the test would pass with the
277
295
  // `.catch` deleted — which is exactly what it did before this line was corrected.
278
- expect(backend.attach?.(win, window as never, 'flight')).toBe(true);
296
+ expect(backend.attach!.attach(win, window as never, 'flight')).toBe(true);
279
297
 
280
- expect(() => backend.close!(win)).not.toThrow();
298
+ expect(() => backend.lifecycle!.close(win)).not.toThrow();
281
299
  // Detached synchronously, so a rejected close cannot strand the window as still attached.
282
- expect(backend.attach?.(win, window as never, 'flight')).toBe(true);
300
+ expect(backend.attach!.attach(win, window as never, 'flight')).toBe(true);
283
301
 
284
302
  await new Promise((resolve) => setTimeout(resolve, 0));
285
303
  expect(unhandled).toEqual([]);
@@ -288,8 +306,3 @@ describe('createTauriWindowBackend close when the platform close rejects', () =>
288
306
  }
289
307
  });
290
308
  });
291
- describe('initializeTauriWindowBackend', () => {
292
- it('is the construction initializer of createTauriWindowBackend', () => {
293
- expect(typeof initializeTauriWindowBackend).toBe('function');
294
- });
295
- });