@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
@@ -1,16 +1,13 @@
1
- import type { TauriApi, TauriDialogOpenOptions, TauriDialogSaveOptions } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
3
2
 
4
3
  import {
5
- createTauriDirectoryOpenDialogBackend,
6
- createTauriFileOpenDialogBackend,
7
- createTauriFileSaveDialogBackend,
8
- createTauriMessageDialogBackend,
9
- initializeTauriDirectoryOpenDialogBackend,
10
- initializeTauriFileOpenDialogBackend,
11
- initializeTauriFileSaveDialogBackend,
12
- initializeTauriMessageDialogBackend,
13
- } from './tauriDialog';
4
+ tauriHostDialog,
5
+ tauriHostDirectoryOpenDialog,
6
+ tauriHostFileOpenDialog,
7
+ tauriHostFileSaveDialog,
8
+ tauriHostMessageDialog,
9
+ } from './tauriDialog.ts';
10
+ import type { TauriApi, TauriDialogOpenOptions, TauriDialogSaveOptions } from './types.ts';
14
11
 
15
12
  interface DialogCalls {
16
13
  open: TauriDialogOpenOptions[];
@@ -48,30 +45,36 @@ function fakeTauri(openResult: string | string[] | null | Error, saveResult: str
48
45
  return { tauri, calls };
49
46
  }
50
47
 
51
- describe('createTauriDirectoryOpenDialogBackend', () => {
48
+ describe('tauriHostDialog', () => {
49
+ it('constructs exactly the four supported dialog leaves', () => {
50
+ const group = tauriHostDialog(fakeTauri(null, null).tauri);
51
+ expect(Object.keys(group).sort()).toEqual(['directoryOpen', 'fileOpen', 'fileSave', 'message']);
52
+ });
53
+ });
54
+
55
+ describe('tauriHostDirectoryOpenDialog', () => {
52
56
  it('uses a method-tight single-directory operation', async () => {
53
57
  const { tauri, calls } = fakeTauri('/docs', null);
54
- const result = await createTauriDirectoryOpenDialogBackend(tauri).open();
58
+ const result = await tauriHostDirectoryOpenDialog(tauri).open();
55
59
  expect(calls.open[0]).toEqual({ directory: true, multiple: false });
56
60
  expect(result.outcome === 'selected' ? result.handle.path : null).toBe('/docs');
57
61
  });
58
62
  });
59
63
 
60
- describe('createTauriFileOpenDialogBackend', () => {
61
- it('exposes independent Entity providers', () => {
64
+ describe('tauriHostFileOpenDialog', () => {
65
+ it('exposes independent providers', () => {
62
66
  const tauri = fakeTauri(null, null).tauri;
63
67
  const providers = [
64
- createTauriDirectoryOpenDialogBackend(tauri),
65
- createTauriFileOpenDialogBackend(tauri),
66
- createTauriFileSaveDialogBackend(tauri),
68
+ tauriHostDirectoryOpenDialog(tauri),
69
+ tauriHostFileOpenDialog(tauri),
70
+ tauriHostFileSaveDialog(tauri),
67
71
  ];
68
- expect(providers.every((provider) => EntityRuntimeKey in provider)).toBe(true);
69
72
  expect(new Set(providers).size).toBe(3);
70
73
  });
71
74
 
72
75
  it('returns selected nonempty file handles and maps common filters/multiple', async () => {
73
76
  const { tauri, calls } = fakeTauri(['/home/u/a.txt', '/home/u/b.md'], null);
74
- const result = await createTauriFileOpenDialogBackend(tauri).open({
77
+ const result = await tauriHostFileOpenDialog(tauri).open({
75
78
  filters: [{ accept: { 'text/plain': ['txt'], 'text/markdown': ['.md'] }, name: 'Text' }],
76
79
  multiple: true,
77
80
  });
@@ -89,17 +92,17 @@ describe('createTauriFileOpenDialogBackend', () => {
89
92
 
90
93
  it('uses the independent single-directory operation and preserves a root basename', async () => {
91
94
  const { tauri, calls } = fakeTauri('/', null);
92
- const result = await createTauriDirectoryOpenDialogBackend(tauri).open();
95
+ const result = await tauriHostDirectoryOpenDialog(tauri).open();
93
96
  expect(calls.open[0]).toEqual({ directory: true, multiple: false });
94
97
  expect(result.outcome === 'selected' ? result.handle.name : null).toBe('/');
95
98
  });
96
99
 
97
100
  it('distinguishes cancel, security denial, and operation failure', async () => {
98
- const cancelled = await createTauriFileOpenDialogBackend(fakeTauri(null, null).tauri).open({});
99
- const security = await createTauriFileOpenDialogBackend(
101
+ const cancelled = await tauriHostFileOpenDialog(fakeTauri(null, null).tauri).open({});
102
+ const security = await tauriHostFileOpenDialog(
100
103
  fakeTauri(Object.assign(new Error('denied'), { code: 'EPERM' }), null).tauri,
101
104
  ).open({});
102
- const failed = await createTauriFileOpenDialogBackend(fakeTauri(new Error('broken'), null).tauri).open({});
105
+ const failed = await tauriHostFileOpenDialog(fakeTauri(new Error('broken'), null).tauri).open({});
103
106
  expect(cancelled.outcome).toBe('cancelled');
104
107
  expect(security.outcome).toBe('security-denied');
105
108
  expect(failed.outcome).toBe('file-open-failed');
@@ -107,23 +110,23 @@ describe('createTauriFileOpenDialogBackend', () => {
107
110
 
108
111
  it('maps the common defaultName invariant and returns a selected save handle', async () => {
109
112
  const { tauri, calls } = fakeTauri(null, '/out.png');
110
- const result = await createTauriFileSaveDialogBackend(tauri).save({ defaultName: 'suggested.png' });
113
+ const result = await tauriHostFileSaveDialog(tauri).save({ defaultName: 'suggested.png' });
111
114
  expect(calls.save[0].defaultPath).toBe('suggested.png');
112
115
  expect(result.outcome === 'selected' ? result.handle.path : null).toBe('/out.png');
113
116
  });
114
117
 
115
118
  it('reports runtime-unavailable when a Tauri dialog method is absent', async () => {
116
119
  const tauri = { dialog: {} } as TauriApi;
117
- expect((await createTauriDirectoryOpenDialogBackend(tauri).open()).outcome).toBe('runtime-unavailable');
118
- expect((await createTauriFileOpenDialogBackend(tauri).open({})).outcome).toBe('runtime-unavailable');
119
- expect((await createTauriFileSaveDialogBackend(tauri).save({})).outcome).toBe('runtime-unavailable');
120
+ expect((await tauriHostDirectoryOpenDialog(tauri).open()).outcome).toBe('runtime-unavailable');
121
+ expect((await tauriHostFileOpenDialog(tauri).open({})).outcome).toBe('runtime-unavailable');
122
+ expect((await tauriHostFileSaveDialog(tauri).save({})).outcome).toBe('runtime-unavailable');
120
123
  });
121
124
 
122
125
  it('does not open a native picker when already aborted', async () => {
123
126
  const { tauri, calls } = fakeTauri('/ignored', null);
124
127
  const controller = new AbortController();
125
128
  controller.abort();
126
- await expect(createTauriFileOpenDialogBackend(tauri).open({ signal: controller.signal })).resolves.toEqual({
129
+ await expect(tauriHostFileOpenDialog(tauri).open({ signal: controller.signal })).resolves.toEqual({
127
130
  outcome: 'cancelled',
128
131
  });
129
132
  expect(calls.open).toEqual([]);
@@ -138,24 +141,24 @@ describe('createTauriFileOpenDialogBackend', () => {
138
141
  controller.abort(new Error('native picker already completed'));
139
142
  return result;
140
143
  };
141
- const result = await createTauriFileOpenDialogBackend(tauri).open({ signal: controller.signal });
144
+ const result = await tauriHostFileOpenDialog(tauri).open({ signal: controller.signal });
142
145
  expect(result.outcome).toBe('selected');
143
146
  });
144
147
  });
145
148
 
146
- describe('createTauriFileSaveDialogBackend', () => {
149
+ describe('tauriHostFileSaveDialog', () => {
147
150
  it('maps the common default name and returns one selected handle', async () => {
148
151
  const { tauri, calls } = fakeTauri(null, '/saved.txt');
149
- const result = await createTauriFileSaveDialogBackend(tauri).save({ defaultName: 'suggested.txt' });
152
+ const result = await tauriHostFileSaveDialog(tauri).save({ defaultName: 'suggested.txt' });
150
153
  expect(calls.save[0].defaultPath).toBe('suggested.txt');
151
154
  expect(result.outcome === 'selected' ? result.handle.path : null).toBe('/saved.txt');
152
155
  });
153
156
  });
154
157
 
155
- describe('createTauriMessageDialogBackend', () => {
158
+ describe('tauriHostMessageDialog', () => {
156
159
  it('maps message to an acknowledgement result and confirm to a boolean', async () => {
157
160
  const { tauri, calls } = fakeTauri(null, null);
158
- const backend = createTauriMessageDialogBackend(tauri);
161
+ const backend = tauriHostMessageDialog(tauri);
159
162
  const result = await backend.message({ message: 'Hi', kind: 'question' });
160
163
  expect(result).toEqual({ buttonIndex: 0, cancelled: false, checkboxChecked: false });
161
164
  expect(calls.message[0].kind).toBe('info');
@@ -163,26 +166,3 @@ describe('createTauriMessageDialogBackend', () => {
163
166
  expect(calls.confirm[0].kind).toBe('warning');
164
167
  });
165
168
  });
166
- describe('initializeTauriDirectoryOpenDialogBackend', () => {
167
- it('is the construction initializer of createTauriDirectoryOpenDialogBackend', () => {
168
- expect(typeof initializeTauriDirectoryOpenDialogBackend).toBe('function');
169
- });
170
- });
171
-
172
- describe('initializeTauriFileOpenDialogBackend', () => {
173
- it('is the construction initializer of createTauriFileOpenDialogBackend', () => {
174
- expect(typeof initializeTauriFileOpenDialogBackend).toBe('function');
175
- });
176
- });
177
-
178
- describe('initializeTauriFileSaveDialogBackend', () => {
179
- it('is the construction initializer of createTauriFileSaveDialogBackend', () => {
180
- expect(typeof initializeTauriFileSaveDialogBackend).toBe('function');
181
- });
182
- });
183
-
184
- describe('initializeTauriMessageDialogBackend', () => {
185
- it('is the construction initializer of createTauriMessageDialogBackend', () => {
186
- expect(typeof initializeTauriMessageDialogBackend).toBe('function');
187
- });
188
- });
@@ -0,0 +1,312 @@
1
+ import { readClipboardText } from '@flighthq/clipboard/contract';
2
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
3
+ import { getPlatformName } from '@flighthq/platform/contract';
4
+ import { spawnSync } from 'child_process';
5
+ import { resolve } from 'path';
6
+
7
+ import * as contractApi from './contract.ts';
8
+ import * as publicApi from './index.ts';
9
+ import type { TauriApi } from './types.ts';
10
+
11
+ const GROUPS = [
12
+ ['accessibility', 'tauriHostAccessibility'],
13
+ ['app', 'tauriHostApp'],
14
+ ['audio', 'tauriHostAudio'],
15
+ ['audioDecode', 'tauriHostAudioDecode'],
16
+ ['bitmap', 'tauriHostBitmap'],
17
+ ['clipboard', 'tauriHostClipboard'],
18
+ ['compress', 'tauriHostCompress'],
19
+ ['connectivity', 'tauriHostConnectivity'],
20
+ ['decompress', 'tauriHostDecompress'],
21
+ ['device', 'tauriHostDevice'],
22
+ ['dialog', 'tauriHostDialog'],
23
+ ['fileSystem', 'tauriHostFileSystem'],
24
+ ['font', 'tauriHostFont'],
25
+ ['fullscreen', 'tauriHostFullscreen'],
26
+ ['geolocation', 'tauriHostGeolocation'],
27
+ ['gl', 'tauriHostGl'],
28
+ ['glyph', 'tauriHostGlyph'],
29
+ ['haptics', 'tauriHostHaptics'],
30
+ ['image', 'tauriHostImage'],
31
+ ['imageDecode', 'tauriHostImageDecode'],
32
+ ['imageEncode', 'tauriHostImageEncode'],
33
+ ['input', 'tauriHostInput'],
34
+ ['ipc', 'tauriHostIpc'],
35
+ ['lifecycle', 'tauriHostLifecycle'],
36
+ ['mediaSession', 'tauriHostMediaSession'],
37
+ ['menu', 'tauriHostMenu'],
38
+ ['midi', 'tauriHostMidi'],
39
+ ['net', 'tauriHostNet'],
40
+ ['notification', 'tauriHostNotification'],
41
+ ['permissions', 'tauriHostPermissions'],
42
+ ['platform', 'tauriHostPlatformGroup'],
43
+ ['power', 'tauriHostPower'],
44
+ ['preferences', 'tauriHostPreferences'],
45
+ ['protocol', 'tauriHostProtocol'],
46
+ ['screen', 'tauriHostScreen'],
47
+ ['sensors', 'tauriHostSensors'],
48
+ ['share', 'tauriHostShare'],
49
+ ['shell', 'tauriHostShell'],
50
+ ['shortcut', 'tauriHostShortcut'],
51
+ ['socket', 'tauriHostSocket'],
52
+ ['softKeyboard', 'tauriHostSoftKeyboard'],
53
+ ['statusBar', 'tauriHostStatusBar'],
54
+ ['surface', 'tauriHostSurface'],
55
+ ['canvas', 'tauriHostCanvas'],
56
+ ['textSegment', 'tauriHostTextSegment'],
57
+ ['textShaper', 'tauriHostTextShaper'],
58
+ ['tray', 'tauriHostTray'],
59
+ ['updater', 'tauriHostUpdater'],
60
+ ['video', 'tauriHostVideo'],
61
+ ['wgpu', 'tauriHostWgpu'],
62
+ ['window', 'tauriHostWindow'],
63
+ ] as const;
64
+
65
+ const LEAVES = [
66
+ ['app', 'hide', 'tauriHostAppHide'],
67
+ ['app', 'locale', 'tauriHostAppLocale'],
68
+ ['app', 'name', 'tauriHostAppName'],
69
+ ['app', 'quit', 'tauriHostAppQuit'],
70
+ ['app', 'relaunch', 'tauriHostAppRelaunch'],
71
+ ['app', 'show', 'tauriHostAppShow'],
72
+ ['app', 'version', 'tauriHostAppVersion'],
73
+ ['clipboard', 'text', 'tauriHostClipboardText'],
74
+ ['dialog', 'directoryOpen', 'tauriHostDirectoryOpenDialog'],
75
+ ['dialog', 'fileOpen', 'tauriHostFileOpenDialog'],
76
+ ['dialog', 'fileSave', 'tauriHostFileSaveDialog'],
77
+ ['dialog', 'message', 'tauriHostMessageDialog'],
78
+ ['menu', 'application', 'tauriHostAppMenu'],
79
+ ['menu', 'popup', 'tauriHostMenuPopup'],
80
+ ['menu', 'select', 'tauriHostMenuSelect'],
81
+ ['notification', 'delivery', 'tauriHostNotificationDelivery'],
82
+ ['notification', 'lifecycle', 'tauriHostNotificationLifecycle'],
83
+ ['notification', 'permission', 'tauriHostNotificationPermission'],
84
+ ['shell', 'external', 'tauriHostShellExternal'],
85
+ ['shell', 'pathOpen', 'tauriHostShellPathOpen'],
86
+ ['shell', 'pathReveal', 'tauriHostShellPathReveal'],
87
+ ['shortcut', 'query', 'tauriHostShortcutQuery'],
88
+ ['shortcut', 'trigger', 'tauriHostShortcutTrigger'],
89
+ ['system', 'platform', 'tauriHostPlatform'],
90
+ ['tray', 'image', 'tauriHostTrayImage'],
91
+ ['tray', 'interactionEvents', 'tauriHostTrayInteractionEvents'],
92
+ ['tray', 'lifecycle', 'tauriHostTrayLifecycle'],
93
+ ['tray', 'menu', 'tauriHostTrayMenu'],
94
+ ['tray', 'menuSelectionEvents', 'tauriHostTrayMenuSelectionEvents'],
95
+ ['tray', 'templateImage', 'tauriHostTrayTemplateImage'],
96
+ ['tray', 'title', 'tauriHostTrayTitle'],
97
+ ['tray', 'tooltip', 'tauriHostTrayTooltip'],
98
+ ['window', '', 'tauriHostWindow'],
99
+ ] as const;
100
+
101
+ const UNSUPPORTED_GROUPS = [
102
+ 'accessibility',
103
+ 'audio',
104
+ 'bitmap',
105
+ 'canvas',
106
+ 'connectivity',
107
+ 'device',
108
+ 'fileSystem',
109
+ 'font',
110
+ 'fullscreen',
111
+ 'geolocation',
112
+ 'gl',
113
+ 'glyph',
114
+ 'haptics',
115
+ 'image',
116
+ 'input',
117
+ 'ipc',
118
+ 'lifecycle',
119
+ 'mediaSession',
120
+ 'midi',
121
+ 'net',
122
+ 'permissions',
123
+ 'power',
124
+ 'preferences',
125
+ 'protocol',
126
+ 'screen',
127
+ 'sensors',
128
+ 'share',
129
+ 'socket',
130
+ 'softKeyboard',
131
+ 'statusBar',
132
+ 'surface',
133
+ 'textSegment',
134
+ 'updater',
135
+ 'video',
136
+ 'wgpu',
137
+ ] as const;
138
+
139
+ function fakeTauri(): TauriApi {
140
+ const asyncNoop = async () => {};
141
+ return {
142
+ app: {
143
+ getName: async () => 'FlightApp',
144
+ getVersion: async () => '1.0.0',
145
+ hide: asyncNoop,
146
+ show: asyncNoop,
147
+ },
148
+ clipboard: {
149
+ readText: async () => 'TAURI-TEXT',
150
+ writeText: asyncNoop,
151
+ clear: asyncNoop,
152
+ },
153
+ dialog: {},
154
+ globalShortcut: {},
155
+ menu: {},
156
+ notification: {
157
+ isPermissionGranted: async () => true,
158
+ requestPermission: async () => 'granted',
159
+ sendNotification: () => {},
160
+ },
161
+ opener: {},
162
+ os: { arch: () => 'x86_64', locale: async () => 'en-US', platform: () => 'linux', version: () => '' },
163
+ process: {},
164
+ tray: {},
165
+ window: { getCurrentWindow: () => ({}), LogicalPosition: class {}, LogicalSize: class {} },
166
+ } as unknown as TauriApi;
167
+ }
168
+
169
+ describe('tauriHost', () => {
170
+ it('constructs one Entity with every Host group and exact supported slots', async () => {
171
+ const host = publicApi.tauriHost(fakeTauri(), 'linux');
172
+ const hostGroups = [...HOST_GROUP_NAMES];
173
+ expect(EntityRuntimeKey in host).toBe(true);
174
+ expect(GROUPS.map(([group]) => group).sort()).toEqual(hostGroups);
175
+ expect(Object.keys(host).sort()).toEqual(hostGroups);
176
+ for (const group of UNSUPPORTED_GROUPS) expect(host[group], group).toEqual({});
177
+ expect(Object.keys(host.app).sort()).toEqual(['hide', 'locale', 'name', 'quit', 'relaunch', 'show', 'version']);
178
+ expect(Object.keys(host.clipboard)).toEqual(['text']);
179
+ expect(Object.keys(host.dialog).sort()).toEqual(['directoryOpen', 'fileOpen', 'fileSave', 'message']);
180
+ expect(Object.keys(host.menu).sort()).toEqual(['app', 'popup', 'select']);
181
+ expect(Object.keys(host.notification).sort()).toEqual(['delivery', 'lifecycle', 'permission']);
182
+ expect(Object.keys(host.shell).sort()).toEqual(['external', 'pathOpen', 'pathReveal']);
183
+ expect(Object.keys(host.shortcut).sort()).toEqual(['query', 'trigger']);
184
+ expect(Object.keys(host.platform)).toEqual(['info']);
185
+ expect(Object.keys(host.tray).sort()).toEqual(['image', 'lifecycle', 'menu', 'menuSelectionEvents', 'title']);
186
+ expect(getPlatformName(host.platform.info)).toBe('linux');
187
+ expect(await readClipboardText(host.clipboard.text)).toBe('TAURI-TEXT');
188
+ });
189
+
190
+ it('publishes every full, group, and supported leaf constructor from both lanes', () => {
191
+ const expected = [
192
+ ...new Set(['tauriHost', ...GROUPS.map((entry) => entry[1]), ...LEAVES.map((entry) => entry[2])]),
193
+ ].sort();
194
+ const publicNames = Object.keys(publicApi).sort();
195
+ const contractNames = Object.keys(contractApi).sort();
196
+
197
+ expect(publicNames).toEqual(expected);
198
+ expect(contractNames).toEqual(expected);
199
+ for (const name of expected) {
200
+ expect(Reflect.get(publicApi, name), name).toBe(Reflect.get(contractApi, name));
201
+ expect(Reflect.get(publicApi, name), name).toBeTypeOf('function');
202
+ }
203
+ });
204
+
205
+ it('keeps profile-specific tray capabilities exact', () => {
206
+ const tauri = fakeTauri();
207
+ expect(Object.keys(publicApi.tauriHostTray(tauri, 'linux')).sort()).toEqual([
208
+ 'image',
209
+ 'lifecycle',
210
+ 'menu',
211
+ 'menuSelectionEvents',
212
+ 'title',
213
+ ]);
214
+ expect(Object.keys(publicApi.tauriHostTray(tauri, 'windows')).sort()).toEqual([
215
+ 'image',
216
+ 'interactionEvents',
217
+ 'lifecycle',
218
+ 'menu',
219
+ 'menuSelectionEvents',
220
+ 'tooltip',
221
+ ]);
222
+ expect(Object.keys(publicApi.tauriHostTray(tauri, 'macos')).sort()).toEqual([
223
+ 'image',
224
+ 'interactionEvents',
225
+ 'lifecycle',
226
+ 'menu',
227
+ 'menuSelectionEvents',
228
+ 'templateImage',
229
+ 'title',
230
+ 'tooltip',
231
+ ]);
232
+ });
233
+
234
+ it('contains no legacy Tauri constructor identifiers outside historical agent records', () => {
235
+ const root = resolve(__dirname, '../../..');
236
+ const result = spawnSync(
237
+ 'git',
238
+ [
239
+ 'grep',
240
+ '-n',
241
+ '-E',
242
+ '\\<(create|initialize|register|make)Tauri[A-Z][A-Za-z0-9]*\\>',
243
+ '--',
244
+ ':!agents/**',
245
+ '*.json',
246
+ '*.md',
247
+ '*.ts',
248
+ '*.tsx',
249
+ ],
250
+ { cwd: root, encoding: 'utf8' },
251
+ );
252
+ expect(result.error).toBeUndefined();
253
+ expect(result.status, result.stderr || result.stdout).toBe(1);
254
+ expect(result.stdout).toBe('');
255
+ });
256
+ });
257
+
258
+ // The capability groups every provider host carries (D26: each provider declares its own; there is no
259
+ // aggregate Host to read them from).
260
+ const HOST_GROUP_NAMES = [
261
+ 'accessibility',
262
+ 'app',
263
+ 'audio',
264
+ 'audioDecode',
265
+ 'bitmap',
266
+ 'canvas',
267
+ 'clipboard',
268
+ 'compress',
269
+ 'connectivity',
270
+ 'decompress',
271
+ 'device',
272
+ 'dialog',
273
+ 'fileSystem',
274
+ 'font',
275
+ 'fullscreen',
276
+ 'geolocation',
277
+ 'gl',
278
+ 'glyph',
279
+ 'haptics',
280
+ 'image',
281
+ 'imageDecode',
282
+ 'imageEncode',
283
+ 'input',
284
+ 'ipc',
285
+ 'lifecycle',
286
+ 'mediaSession',
287
+ 'menu',
288
+ 'midi',
289
+ 'net',
290
+ 'notification',
291
+ 'permissions',
292
+ 'platform',
293
+ 'power',
294
+ 'preferences',
295
+ 'protocol',
296
+ 'screen',
297
+ 'sensors',
298
+ 'share',
299
+ 'shell',
300
+ 'shortcut',
301
+ 'socket',
302
+ 'softKeyboard',
303
+ 'statusBar',
304
+ 'surface',
305
+ 'textSegment',
306
+ 'textShaper',
307
+ 'tray',
308
+ 'updater',
309
+ 'video',
310
+ 'wgpu',
311
+ 'window',
312
+ ];
@@ -1,8 +1,12 @@
1
- import type { MenuApplicationBackend, MenuPopupBackend, MenuSelectBackend } from '@flighthq/types/contract';
2
- import type { MenuItemTemplate, TauriApi, TauriMenuItemOptions } from '@flighthq/types/contract';
3
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import type {
2
+ HostAppMenuCapability,
3
+ HostMenuPopupCapability,
4
+ HostMenuSelectCapability,
5
+ MenuItemTemplate,
6
+ } from '@flighthq/menu/contract';
4
7
 
5
- import { createTauriMenuBackends, initializeTauriMenuBackends } from './tauriMenu';
8
+ import { tauriHostMenu, tauriHostAppMenu, tauriHostMenuPopup, tauriHostMenuSelect } from './tauriMenu.ts';
9
+ import type { TauriApi, TauriMenuItemOptions } from './types.ts';
6
10
 
7
11
  function fakeTauri() {
8
12
  const state = {
@@ -63,11 +67,15 @@ const template: MenuItemTemplate[] = [
63
67
  { label: 'More', submenu: [{ id: 'nested', label: 'Nested' }] },
64
68
  ];
65
69
 
66
- describe('createTauriMenuBackends', () => {
70
+ describe('tauriHostAppMenu', () => {
71
+ it('constructs the app menu provider', () => {
72
+ expect(tauriHostAppMenu(fakeTauri().tauri)).toBeDefined();
73
+ });
74
+ });
75
+
76
+ describe('tauriHostMenu', () => {
67
77
  it('returns an Entity-composed capability bundle and providers', () => {
68
- const capabilities = createTauriMenuBackends(fakeTauri().tauri);
69
- expect(EntityRuntimeKey in capabilities).toBe(true);
70
- for (const provider of Object.values(capabilities)) expect(EntityRuntimeKey in provider).toBe(true);
78
+ const capabilities = tauriHostMenu(fakeTauri().tauri);
71
79
  });
72
80
 
73
81
  it('installs an application menu and routes item clicks to the select listener', async () => {
@@ -75,7 +83,7 @@ describe('createTauriMenuBackends', () => {
75
83
  const backend = _slots(tauri);
76
84
  const selected: string[] = [];
77
85
  backend.subscribeSelect((id: string) => selected.push(id));
78
- expect(backend.setApplicationMenu(template)).toBe(true);
86
+ expect(backend.setAppMenu(template)).toBe(true);
79
87
  // Let the async build + setAsAppMenu settle.
80
88
  await flush();
81
89
  expect(state.appMenuSet).toBe(1);
@@ -97,7 +105,7 @@ describe('createTauriMenuBackends', () => {
97
105
  it('does not touch native menu on destroy (async API cannot clear synchronously)', async () => {
98
106
  const { tauri, state } = fakeTauri();
99
107
  const backend = _slots(tauri);
100
- backend.setApplicationMenu(template);
108
+ backend.setAppMenu(template);
101
109
  await flush();
102
110
  expect(state.appMenuSet).toBe(1);
103
111
  backend.destroy?.();
@@ -110,7 +118,7 @@ describe('createTauriMenuBackends', () => {
110
118
  const backend = _slots(tauri);
111
119
  const selected: string[] = [];
112
120
  backend.subscribeSelect((id: string) => selected.push(id));
113
- backend.setApplicationMenu(template);
121
+ backend.setAppMenu(template);
114
122
  await flush();
115
123
  backend.destroy?.();
116
124
  backend.destroy?.();
@@ -125,12 +133,12 @@ describe('createTauriMenuBackends', () => {
125
133
  it('outgoing destroy cannot overwrite successor menu in a controlled replacement race', async () => {
126
134
  const { tauri, state } = fakeTauri();
127
135
  const outgoing = _slots(tauri);
128
- outgoing.setApplicationMenu(template);
136
+ outgoing.setAppMenu(template);
129
137
  await flush();
130
138
  expect(state.appMenuSet).toBe(1);
131
139
  outgoing.destroy?.();
132
140
  const incoming = _slots(tauri);
133
- incoming.setApplicationMenu([{ id: 'save', label: 'Save' }]);
141
+ incoming.setAppMenu([{ id: 'save', label: 'Save' }]);
134
142
  await flush();
135
143
  expect(state.appMenuSet).toBe(2);
136
144
  });
@@ -141,7 +149,7 @@ describe('createTauriMenuBackends', () => {
141
149
  const backend = _slots(tauri);
142
150
  const selected: string[] = [];
143
151
  const unsubscribe = backend.subscribeSelect((id: string) => selected.push(id));
144
- backend.setApplicationMenu(template);
152
+ backend.setAppMenu(template);
145
153
  await flush();
146
154
  backend.destroy?.();
147
155
  expect(() => unsubscribe()).not.toThrow();
@@ -185,28 +193,35 @@ describe('createTauriMenuBackends', () => {
185
193
  });
186
194
  });
187
195
 
196
+ describe('tauriHostMenuPopup', () => {
197
+ it('constructs the popup provider', () => {
198
+ expect(tauriHostMenuPopup(fakeTauri().tauri)).toBeDefined();
199
+ });
200
+ });
201
+
202
+ describe('tauriHostMenuSelect', () => {
203
+ it('constructs the select provider', () => {
204
+ expect(tauriHostMenuSelect(fakeTauri().tauri)).toBeDefined();
205
+ });
206
+ });
207
+
188
208
  async function flush(): Promise<void> {
189
209
  for (let i = 0; i < 24; i++) await Promise.resolve();
190
210
  }
191
211
 
192
- // The merged MenuBackend is gone; these tests exercise the three slots that replaced it. This helper
212
+ // The merged menu provider is gone; these tests exercise the three slots that replaced it. This helper
193
213
  // recomposes the old surface so each assertion still names the operation it is really testing.
194
214
  function _slots(api: TauriApi): {
195
215
  destroy?: () => void;
196
- popupContextMenu: MenuPopupBackend['popup'];
197
- setApplicationMenu: MenuApplicationBackend['setApplicationMenu'];
198
- subscribeSelect: MenuSelectBackend['subscribe'];
216
+ popupContextMenu: HostMenuPopupCapability['popup'];
217
+ setAppMenu: HostAppMenuCapability['setAppMenu'];
218
+ subscribeSelect: HostMenuSelectCapability['subscribe'];
199
219
  } {
200
- const { application, popup, select } = createTauriMenuBackends(api);
220
+ const { app, popup, select } = tauriHostMenu(api);
201
221
  return {
202
- destroy: application.destroy?.bind(application),
222
+ destroy: app.destroy?.bind(app),
203
223
  popupContextMenu: popup.popup,
204
- setApplicationMenu: application.setApplicationMenu,
224
+ setAppMenu: app.setAppMenu,
205
225
  subscribeSelect: select.subscribe,
206
226
  };
207
227
  }
208
- describe('initializeTauriMenuBackends', () => {
209
- it('is the construction initializer of createTauriMenuBackends', () => {
210
- expect(typeof initializeTauriMenuBackends).toBe('function');
211
- });
212
- });