@flighthq/host-capacitor 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 (124) hide show
  1. package/README.md +3 -3
  2. package/dist/capacitorApp.d.ts +11 -7
  3. package/dist/capacitorApp.d.ts.map +1 -1
  4. package/dist/capacitorApp.js +35 -25
  5. package/dist/capacitorApp.js.map +1 -1
  6. package/dist/capacitorClipboard.d.ts +5 -5
  7. package/dist/capacitorClipboard.d.ts.map +1 -1
  8. package/dist/capacitorClipboard.js +15 -6
  9. package/dist/capacitorClipboard.js.map +1 -1
  10. package/dist/capacitorConnectivity.d.ts +6 -5
  11. package/dist/capacitorConnectivity.d.ts.map +1 -1
  12. package/dist/capacitorConnectivity.js +15 -6
  13. package/dist/capacitorConnectivity.js.map +1 -1
  14. package/dist/capacitorDefaultHostGroups.d.ts +66 -0
  15. package/dist/capacitorDefaultHostGroups.d.ts.map +1 -0
  16. package/dist/capacitorDefaultHostGroups.js +119 -0
  17. package/dist/capacitorDefaultHostGroups.js.map +1 -0
  18. package/dist/capacitorDevice.d.ts +3 -3
  19. package/dist/capacitorDevice.d.ts.map +1 -1
  20. package/dist/capacitorDevice.js +8 -9
  21. package/dist/capacitorDevice.js.map +1 -1
  22. package/dist/capacitorDialog.d.ts +6 -5
  23. package/dist/capacitorDialog.d.ts.map +1 -1
  24. package/dist/capacitorDialog.js +16 -11
  25. package/dist/capacitorDialog.js.map +1 -1
  26. package/dist/capacitorFileSystem.d.ts +3 -3
  27. package/dist/capacitorFileSystem.d.ts.map +1 -1
  28. package/dist/capacitorFileSystem.js +6 -7
  29. package/dist/capacitorFileSystem.js.map +1 -1
  30. package/dist/capacitorGeolocation.d.ts +3 -3
  31. package/dist/capacitorGeolocation.d.ts.map +1 -1
  32. package/dist/capacitorGeolocation.js +13 -13
  33. package/dist/capacitorGeolocation.js.map +1 -1
  34. package/dist/capacitorHaptics.d.ts +3 -3
  35. package/dist/capacitorHaptics.d.ts.map +1 -1
  36. package/dist/capacitorHaptics.js +7 -8
  37. package/dist/capacitorHaptics.js.map +1 -1
  38. package/dist/capacitorHost.d.ts +4 -0
  39. package/dist/capacitorHost.d.ts.map +1 -0
  40. package/dist/capacitorHost.js +71 -0
  41. package/dist/capacitorHost.js.map +1 -0
  42. package/dist/capacitorInputHost.d.ts +6 -0
  43. package/dist/capacitorInputHost.d.ts.map +1 -0
  44. package/dist/capacitorInputHost.js +20 -0
  45. package/dist/capacitorInputHost.js.map +1 -0
  46. package/dist/capacitorKeyboard.d.ts +9 -15
  47. package/dist/capacitorKeyboard.d.ts.map +1 -1
  48. package/dist/capacitorKeyboard.js +36 -37
  49. package/dist/capacitorKeyboard.js.map +1 -1
  50. package/dist/capacitorNotification.d.ts +9 -3
  51. package/dist/capacitorNotification.d.ts.map +1 -1
  52. package/dist/capacitorNotification.js +171 -154
  53. package/dist/capacitorNotification.js.map +1 -1
  54. package/dist/capacitorProtocol.d.ts +4 -3
  55. package/dist/capacitorProtocol.d.ts.map +1 -1
  56. package/dist/capacitorProtocol.js +6 -9
  57. package/dist/capacitorProtocol.js.map +1 -1
  58. package/dist/capacitorShare.d.ts +7 -3
  59. package/dist/capacitorShare.d.ts.map +1 -1
  60. package/dist/capacitorShare.js +8 -6
  61. package/dist/capacitorShare.js.map +1 -1
  62. package/dist/capacitorStatusBar.d.ts +8 -5
  63. package/dist/capacitorStatusBar.d.ts.map +1 -1
  64. package/dist/capacitorStatusBar.js +51 -38
  65. package/dist/capacitorStatusBar.js.map +1 -1
  66. package/dist/capacitorStorageHost.d.ts +4 -0
  67. package/dist/capacitorStorageHost.d.ts.map +1 -0
  68. package/dist/capacitorStorageHost.js +5 -0
  69. package/dist/capacitorStorageHost.js.map +1 -0
  70. package/dist/capacitorSystemHost.d.ts +6 -0
  71. package/dist/capacitorSystemHost.d.ts.map +1 -0
  72. package/dist/capacitorSystemHost.js +9 -0
  73. package/dist/capacitorSystemHost.js.map +1 -0
  74. package/dist/contract.d.ts +19 -23
  75. package/dist/contract.d.ts.map +1 -1
  76. package/dist/contract.js +18 -23
  77. package/dist/contract.js.map +1 -1
  78. package/dist/index.d.ts +19 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +18 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/types/CapacitorApi.d.ts +308 -0
  83. package/dist/types/CapacitorApi.d.ts.map +1 -0
  84. package/dist/types/CapacitorApi.js +35 -0
  85. package/dist/types/CapacitorApi.js.map +1 -0
  86. package/dist/types/CapacitorAppCapabilitiesFor.d.ts +6 -0
  87. package/dist/types/CapacitorAppCapabilitiesFor.d.ts.map +1 -0
  88. package/dist/types/CapacitorAppCapabilitiesFor.js +2 -0
  89. package/dist/types/CapacitorAppCapabilitiesFor.js.map +1 -0
  90. package/dist/types/CapacitorHost.d.ts +94 -0
  91. package/dist/types/CapacitorHost.d.ts.map +1 -0
  92. package/dist/types/CapacitorHost.js +2 -0
  93. package/dist/types/CapacitorHost.js.map +1 -0
  94. package/dist/types/CapacitorProtocolCapabilities.d.ts +3 -0
  95. package/dist/types/CapacitorProtocolCapabilities.d.ts.map +1 -0
  96. package/dist/types/CapacitorProtocolCapabilities.js +2 -0
  97. package/dist/types/CapacitorProtocolCapabilities.js.map +1 -0
  98. package/dist/types/index.d.ts +5 -0
  99. package/dist/types/index.d.ts.map +1 -0
  100. package/dist/types/index.js +5 -0
  101. package/dist/types/index.js.map +1 -0
  102. package/package.json +46 -15
  103. package/src/capacitorApp.test.ts +38 -19
  104. package/src/capacitorClipboard.test.ts +30 -28
  105. package/src/capacitorConnectivity.test.ts +34 -23
  106. package/src/capacitorDefaultHostGroups.test.ts +214 -0
  107. package/src/capacitorDevice.test.ts +18 -30
  108. package/src/capacitorDialog.test.ts +13 -33
  109. package/src/capacitorFileSystem.test.ts +30 -37
  110. package/src/capacitorGeolocation.test.ts +8 -17
  111. package/src/capacitorHaptics.test.ts +9 -13
  112. package/src/{capacitorRegister.test.ts → capacitorHost.test.ts} +91 -48
  113. package/src/capacitorInputHost.test.ts +33 -0
  114. package/src/capacitorKeyboard.test.ts +38 -89
  115. package/src/capacitorNotification.test.ts +54 -18
  116. package/src/capacitorProtocol.test.ts +10 -11
  117. package/src/capacitorShare.test.ts +15 -17
  118. package/src/capacitorStatusBar.test.ts +53 -16
  119. package/src/capacitorStorageHost.test.ts +10 -0
  120. package/src/capacitorSystemHost.test.ts +28 -0
  121. package/dist/capacitorRegister.d.ts +0 -5
  122. package/dist/capacitorRegister.d.ts.map +0 -1
  123. package/dist/capacitorRegister.js +0 -81
  124. package/dist/capacitorRegister.js.map +0 -1
@@ -0,0 +1,214 @@
1
+ import {
2
+ webHostAudioDecode,
3
+ webHostImageDecode,
4
+ webHostImageEncode,
5
+ webHostTextShaper,
6
+ } from '@flighthq/host-web/contract';
7
+
8
+ import {
9
+ capacitorHostAccessibility,
10
+ capacitorHostAudio,
11
+ capacitorHostBitmap,
12
+ capacitorHostFont,
13
+ capacitorHostFullscreen,
14
+ capacitorHostGl,
15
+ capacitorHostGlyph,
16
+ capacitorHostImage,
17
+ capacitorHostAudioDecode,
18
+ capacitorHostImageDecode,
19
+ capacitorHostImageEncode,
20
+ capacitorHostInput,
21
+ capacitorHostIpc,
22
+ capacitorHostLifecycle,
23
+ capacitorHostMediaSession,
24
+ capacitorHostMenu,
25
+ capacitorHostMidi,
26
+ capacitorHostNet,
27
+ capacitorHostPermissions,
28
+ capacitorHostPlatform,
29
+ capacitorHostPower,
30
+ capacitorHostPreferences,
31
+ capacitorHostScreen,
32
+ capacitorHostSensors,
33
+ capacitorHostShell,
34
+ capacitorHostShortcut,
35
+ capacitorHostSocket,
36
+ capacitorHostCanvas,
37
+ capacitorHostSurface,
38
+ capacitorHostTextSegment,
39
+ capacitorHostCompress,
40
+ capacitorHostDecompress,
41
+ capacitorHostTextShaper,
42
+ capacitorHostTray,
43
+ capacitorHostUpdater,
44
+ capacitorHostVideo,
45
+ capacitorHostWgpu,
46
+ capacitorHostWindow,
47
+ } from './capacitorDefaultHostGroups.ts';
48
+
49
+ describe('capacitorHostAccessibility', () => {
50
+ it('claims no accessibility slots', () => expect(capacitorHostAccessibility()).toEqual({}));
51
+ });
52
+
53
+ describe('capacitorHostAudio', () => {
54
+ it('claims no audio slots', () => expect(capacitorHostAudio()).toEqual({}));
55
+ });
56
+
57
+ describe('capacitorHostAudioDecode', () => {
58
+ it('delegates to the shared web audio decode capabilities', () => {
59
+ expect(capacitorHostAudioDecode()).toBe(webHostAudioDecode);
60
+ });
61
+ });
62
+
63
+ describe('capacitorHostBitmap', () => {
64
+ it('claims no bitmap slots', () => expect(capacitorHostBitmap()).toEqual({}));
65
+ });
66
+
67
+ describe('capacitorHostCanvas', () => {
68
+ it('claims no canvas slots', () => expect(capacitorHostCanvas()).toEqual({}));
69
+ });
70
+
71
+ describe('capacitorHostCompress', () => {
72
+ it('claims no compression slots', () => expect(capacitorHostCompress()).toEqual({}));
73
+ });
74
+
75
+ describe('capacitorHostDecompress', () => {
76
+ it('claims no decompression slots', () => expect(capacitorHostDecompress()).toEqual({}));
77
+ });
78
+
79
+ describe('capacitorHostFont', () => {
80
+ it('claims no font slots', () => expect(capacitorHostFont()).toEqual({}));
81
+ });
82
+
83
+ describe('capacitorHostFullscreen', () => {
84
+ it('claims no fullscreen slots', () => expect(capacitorHostFullscreen()).toEqual({}));
85
+ });
86
+
87
+ describe('capacitorHostGl', () => {
88
+ it('claims no GL slots', () => expect(capacitorHostGl()).toEqual({}));
89
+ });
90
+
91
+ describe('capacitorHostGlyph', () => {
92
+ it('claims no glyph slots', () => expect(capacitorHostGlyph()).toEqual({}));
93
+ });
94
+
95
+ describe('capacitorHostImage', () => {
96
+ it('claims no image slots', () => expect(capacitorHostImage()).toEqual({}));
97
+ });
98
+ describe('capacitorHostImageDecode', () => {
99
+ it('delegates to the shared web image decode capabilities', () => {
100
+ expect(capacitorHostImageDecode()).toBe(webHostImageDecode);
101
+ });
102
+ });
103
+
104
+ describe('capacitorHostImageEncode', () => {
105
+ it('delegates to the shared web image encode capabilities', () => {
106
+ expect(capacitorHostImageEncode()).toBe(webHostImageEncode);
107
+ });
108
+ });
109
+
110
+ describe('capacitorHostInput', () => {
111
+ it('claims no input slots', () => expect(capacitorHostInput()).toEqual({}));
112
+ });
113
+
114
+ describe('capacitorHostIpc', () => {
115
+ it('claims no IPC slots', () => expect(capacitorHostIpc()).toEqual({}));
116
+ });
117
+
118
+ describe('capacitorHostLifecycle', () => {
119
+ it('claims no lifecycle slots', () => expect(capacitorHostLifecycle()).toEqual({}));
120
+ });
121
+
122
+ describe('capacitorHostMediaSession', () => {
123
+ it('claims no media-session slots', () => expect(capacitorHostMediaSession()).toEqual({}));
124
+ });
125
+
126
+ describe('capacitorHostMenu', () => {
127
+ it('claims no menu slots', () => expect(capacitorHostMenu()).toEqual({}));
128
+ });
129
+
130
+ describe('capacitorHostMidi', () => {
131
+ it('claims no MIDI slots', () => expect(capacitorHostMidi()).toEqual({}));
132
+ });
133
+
134
+ describe('capacitorHostNet', () => {
135
+ it('claims no net slots', () => expect(capacitorHostNet()).toEqual({}));
136
+ });
137
+
138
+ describe('capacitorHostPermissions', () => {
139
+ it('claims no permission slots', () => expect(capacitorHostPermissions()).toEqual({}));
140
+ });
141
+
142
+ describe('capacitorHostPlatform', () => {
143
+ it('claims no platform slots', () => expect(capacitorHostPlatform()).toEqual({}));
144
+ });
145
+
146
+ describe('capacitorHostPower', () => {
147
+ it('claims no power slots', () => expect(capacitorHostPower()).toEqual({}));
148
+ });
149
+
150
+ describe('capacitorHostPreferences', () => {
151
+ it('claims no preference slots', () => expect(capacitorHostPreferences()).toEqual({}));
152
+ });
153
+
154
+ describe('capacitorHostScreen', () => {
155
+ it('claims no screen slots', () => expect(capacitorHostScreen()).toEqual({}));
156
+ });
157
+
158
+ describe('capacitorHostSensors', () => {
159
+ it('claims no sensor slots', () => expect(capacitorHostSensors()).toEqual({}));
160
+ });
161
+
162
+ describe('capacitorHostShell', () => {
163
+ it('claims no shell slots', () => expect(capacitorHostShell()).toEqual({}));
164
+ });
165
+
166
+ describe('capacitorHostShortcut', () => {
167
+ it('claims no shortcut slots', () => expect(capacitorHostShortcut()).toEqual({}));
168
+ });
169
+
170
+ describe('capacitorHostSocket', () => {
171
+ it('claims no socket slots', () => expect(capacitorHostSocket()).toEqual({}));
172
+ });
173
+
174
+ describe('capacitorHostSurface', () => {
175
+ it('claims no surface slots', () => expect(capacitorHostSurface()).toEqual({}));
176
+ });
177
+
178
+ describe('capacitorHostTextSegment', () => {
179
+ it('claims no text-segment slots', () => expect(capacitorHostTextSegment()).toEqual({}));
180
+ });
181
+
182
+ describe('capacitorHostTextShaper', () => {
183
+ it('fills the shaper slot with the shared web text shaper', () => {
184
+ const group = capacitorHostTextShaper();
185
+ expect(group.shaper).toBe(webHostTextShaper);
186
+ });
187
+
188
+ it('is plain data with no Entity runtime and no symbol keys', () => {
189
+ const group = capacitorHostTextShaper();
190
+ expect(Symbol.for('EntityRuntime') in group).toBe(false);
191
+ expect(Object.getOwnPropertySymbols(group)).toEqual([]);
192
+ expect(Object.keys(group)).toEqual(['shaper']);
193
+ });
194
+ });
195
+
196
+ describe('capacitorHostTray', () => {
197
+ it('claims no tray slots', () => expect(capacitorHostTray()).toEqual({}));
198
+ });
199
+
200
+ describe('capacitorHostUpdater', () => {
201
+ it('claims no updater slots', () => expect(capacitorHostUpdater()).toEqual({}));
202
+ });
203
+
204
+ describe('capacitorHostVideo', () => {
205
+ it('claims no video slots', () => expect(capacitorHostVideo()).toEqual({}));
206
+ });
207
+
208
+ describe('capacitorHostWgpu', () => {
209
+ it('claims no WGPU slots', () => expect(capacitorHostWgpu()).toEqual({}));
210
+ });
211
+
212
+ describe('capacitorHostWindow', () => {
213
+ it('claims no window capabilities', () => expect(capacitorHostWindow()).toEqual({}));
214
+ });
@@ -1,13 +1,7 @@
1
- import type {
2
- DeviceCapabilities,
3
- DeviceDisplayMetrics,
4
- DeviceInfo,
5
- SafeAreaInsets,
6
- CapacitorApi,
7
- } from '@flighthq/types/contract';
8
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import type { DeviceCapabilities, DeviceDisplayMetrics, DeviceInfo, SafeAreaInsets } from '@flighthq/device/contract';
9
2
 
10
- import { createCapacitorDeviceBackend, initializeCapacitorDeviceBackend } from './capacitorDevice';
3
+ import { capacitorHostDevice } from './capacitorDevice.ts';
4
+ import type { CapacitorApi } from './types/index.ts';
11
5
 
12
6
  const flush = async () => {
13
7
  await Promise.resolve();
@@ -39,7 +33,6 @@ function fakeCapacitor() {
39
33
 
40
34
  function blankInfo(): DeviceInfo {
41
35
  return {
42
- [EntityRuntimeKey]: undefined,
43
36
  arch: 'z',
44
37
  availableMemory: 1,
45
38
  boardName: 'z',
@@ -68,17 +61,16 @@ function blankInfo(): DeviceInfo {
68
61
  };
69
62
  }
70
63
 
71
- describe('createCapacitorDeviceBackend', () => {
72
- it('returns an Entity', () => {
73
- expect(EntityRuntimeKey in createCapacitorDeviceBackend(fakeCapacitor().capacitor)).toBe(true);
74
- });
75
-
64
+ describe('capacitorHostDevice', () => {
76
65
  it('fills DeviceInfo from the prefetched Capacitor info once it resolves', async () => {
77
- const backend = createCapacitorDeviceBackend(fakeCapacitor().capacitor);
66
+ const backend = capacitorHostDevice(fakeCapacitor().capacitor);
78
67
  // Sentinels until the construction-time prefetch settles.
79
- expect(backend.getInfo(blankInfo()).model).toBe('');
68
+ const pendingInfo = blankInfo();
69
+ backend.getInfo(pendingInfo);
70
+ expect(pendingInfo.model).toBe('');
80
71
  await flush();
81
- const info = backend.getInfo(blankInfo());
72
+ const info = blankInfo();
73
+ backend.getInfo(info);
82
74
  expect(info.model).toBe('iPhone15,2');
83
75
  expect(info.manufacturer).toBe('Apple');
84
76
  expect(info.osName).toBe('ios');
@@ -91,9 +83,8 @@ describe('createCapacitorDeviceBackend', () => {
91
83
  });
92
84
 
93
85
  it('reports sentinels for metrics, capabilities, and safe-area insets', () => {
94
- const backend = createCapacitorDeviceBackend(fakeCapacitor().capacitor);
86
+ const backend = capacitorHostDevice(fakeCapacitor().capacitor);
95
87
  const metrics: DeviceDisplayMetrics = {
96
- [EntityRuntimeKey]: undefined,
97
88
  colorDepth: 1,
98
89
  densityDpi: 1,
99
90
  logicalHeight: 1,
@@ -102,20 +93,17 @@ describe('createCapacitorDeviceBackend', () => {
102
93
  physicalWidth: 1,
103
94
  pixelRatio: 1,
104
95
  };
105
- expect(backend.getDisplayMetrics(metrics).pixelRatio).toBe(-1);
96
+ backend.getDisplayMetrics(metrics);
97
+ expect(metrics.pixelRatio).toBe(-1);
106
98
  const caps: DeviceCapabilities = {
107
- [EntityRuntimeKey]: undefined,
108
99
  hasKeyboard: true,
109
100
  hasMouse: true,
110
101
  hasStylus: true,
111
102
  };
112
- expect(backend.getCapabilities(caps)).toMatchObject({ hasKeyboard: false, hasMouse: false, hasStylus: false });
113
- const insets: SafeAreaInsets = { [EntityRuntimeKey]: undefined, top: 9, right: 9, bottom: 9, left: 9 };
114
- expect(backend.getSafeAreaInsets(insets)).toMatchObject({ top: 0, right: 0, bottom: 0, left: 0 });
115
- });
116
- });
117
- describe('initializeCapacitorDeviceBackend', () => {
118
- it('is the construction initializer of createCapacitorDeviceBackend', () => {
119
- expect(typeof initializeCapacitorDeviceBackend).toBe('function');
103
+ backend.getCapabilities(caps);
104
+ expect(caps).toMatchObject({ hasKeyboard: false, hasMouse: false, hasStylus: false });
105
+ const insets: SafeAreaInsets = { top: 9, right: 9, bottom: 9, left: 9 };
106
+ backend.getSafeAreaInsets(insets);
107
+ expect(insets).toMatchObject({ top: 0, right: 0, bottom: 0, left: 0 });
120
108
  });
121
109
  });
@@ -1,12 +1,5 @@
1
- import type { CapacitorApi } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
3
-
4
- import {
5
- createCapacitorMessageDialogBackend,
6
- createCapacitorPromptDialogBackend,
7
- initializeCapacitorMessageDialogBackend,
8
- initializeCapacitorPromptDialogBackend,
9
- } from './capacitorDialog';
1
+ import { capacitorHostDialog, capacitorHostMessageDialog, capacitorHostPromptDialog } from './capacitorDialog.ts';
2
+ import type { CapacitorApi } from './types/index.ts';
10
3
 
11
4
  function fakeCapacitor(promptResult = { value: 'typed', cancelled: false }) {
12
5
  const calls: string[] = [];
@@ -28,37 +21,35 @@ function fakeCapacitor(promptResult = { value: 'typed', cancelled: false }) {
28
21
  return { capacitor, calls };
29
22
  }
30
23
 
31
- describe('createCapacitorMessageDialogBackend', () => {
32
- it('returns an Entity', () => {
33
- expect(EntityRuntimeKey in createCapacitorMessageDialogBackend(fakeCapacitor().capacitor)).toBe(true);
24
+ describe('capacitorHostDialog', () => {
25
+ it('composes exactly the supported dialog slots', () => {
26
+ expect(Object.keys(capacitorHostDialog(fakeCapacitor().capacitor)).sort()).toEqual(['message', 'prompt']);
34
27
  });
28
+ });
35
29
 
30
+ describe('capacitorHostMessageDialog', () => {
36
31
  it('maps message onto a single-button alert', async () => {
37
32
  const { capacitor, calls } = fakeCapacitor();
38
- const backend = createCapacitorMessageDialogBackend(capacitor);
33
+ const backend = capacitorHostMessageDialog(capacitor);
39
34
  const result = await backend.message({ message: 'hello' });
40
35
  expect(result).toEqual({ buttonIndex: 0, cancelled: false, checkboxChecked: false });
41
36
  expect(calls).toContain('alert');
42
37
  });
43
38
 
44
39
  it('maps confirm', async () => {
45
- const message = createCapacitorMessageDialogBackend(fakeCapacitor().capacitor);
40
+ const message = capacitorHostMessageDialog(fakeCapacitor().capacitor);
46
41
  expect(await message.confirm({ message: 'ok?' })).toBe(true);
47
42
  });
48
43
  });
49
44
 
50
- describe('createCapacitorPromptDialogBackend', () => {
51
- it('returns an Entity', () => {
52
- expect(EntityRuntimeKey in createCapacitorPromptDialogBackend(fakeCapacitor().capacitor)).toBe(true);
53
- });
54
-
45
+ describe('capacitorHostPromptDialog', () => {
55
46
  it('maps prompt', async () => {
56
- const prompt = createCapacitorPromptDialogBackend(fakeCapacitor().capacitor);
47
+ const prompt = capacitorHostPromptDialog(fakeCapacitor().capacitor);
57
48
  expect(await prompt.prompt({ message: 'name?' })).toBe('typed');
58
49
  });
59
50
 
60
51
  it('resolves the null sentinel for a cancelled prompt', async () => {
61
- const backend = createCapacitorPromptDialogBackend(fakeCapacitor({ value: '', cancelled: true }).capacitor);
52
+ const backend = capacitorHostPromptDialog(fakeCapacitor({ value: '', cancelled: true }).capacitor);
62
53
  expect(await backend.prompt({ message: 'name?' })).toBeNull();
63
54
  });
64
55
 
@@ -66,19 +57,8 @@ describe('createCapacitorPromptDialogBackend', () => {
66
57
  const { capacitor, calls } = fakeCapacitor();
67
58
  const controller = new AbortController();
68
59
  controller.abort();
69
- const backend = createCapacitorPromptDialogBackend(capacitor);
60
+ const backend = capacitorHostPromptDialog(capacitor);
70
61
  await expect(backend.prompt({ message: 'name?', signal: controller.signal })).resolves.toBeNull();
71
62
  expect(calls).toEqual([]);
72
63
  });
73
64
  });
74
- describe('initializeCapacitorMessageDialogBackend', () => {
75
- it('is the construction initializer of createCapacitorMessageDialogBackend', () => {
76
- expect(typeof initializeCapacitorMessageDialogBackend).toBe('function');
77
- });
78
- });
79
-
80
- describe('initializeCapacitorPromptDialogBackend', () => {
81
- it('is the construction initializer of createCapacitorPromptDialogBackend', () => {
82
- expect(typeof initializeCapacitorPromptDialogBackend).toBe('function');
83
- });
84
- });
@@ -1,7 +1,7 @@
1
- import type { CapacitorApi } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
3
2
 
4
- import { createCapacitorFileSystemBackend, initializeCapacitorFileSystemBackend } from './capacitorFileSystem';
3
+ import { capacitorHostFileSystem } from './capacitorFileSystem.ts';
4
+ import type { CapacitorApi } from './types/index.ts';
5
5
 
6
6
  function fakeCapacitor() {
7
7
  const files = new Map<string, { data: string; type: string }>();
@@ -48,24 +48,20 @@ function fakeCapacitor() {
48
48
  return { capacitor, files };
49
49
  }
50
50
 
51
- describe('createCapacitorFileSystemBackend', () => {
52
- it('returns an Entity', () => {
53
- expect(EntityRuntimeKey in createCapacitorFileSystemBackend(fakeCapacitor().capacitor)).toBe(true);
54
- });
55
-
51
+ describe('capacitorHostFileSystem', () => {
56
52
  it('round-trips a text file', async () => {
57
- const backend = createCapacitorFileSystemBackend(fakeCapacitor().capacitor);
58
- expect(await backend.writeTextFile('/a.txt', 'hello')).toBe(true);
59
- expect(await backend.readTextFile('/a.txt')).toBe('hello');
60
- expect(await backend.appendTextFile('/a.txt', '!')).toBe(true);
61
- expect(await backend.readTextFile('/a.txt')).toBe('hello!');
53
+ const backend = capacitorHostFileSystem(fakeCapacitor().capacitor);
54
+ expect(await backend.writeTextFile?.('/a.txt', 'hello')).toBe(true);
55
+ expect(await backend.readTextFile?.('/a.txt')).toBe('hello');
56
+ expect(await backend.appendTextFile?.('/a.txt', '!')).toBe(true);
57
+ expect(await backend.readTextFile?.('/a.txt')).toBe('hello!');
62
58
  });
63
59
 
64
60
  it('round-trips a binary file through Base64', async () => {
65
- const backend = createCapacitorFileSystemBackend(fakeCapacitor().capacitor);
61
+ const backend = capacitorHostFileSystem(fakeCapacitor().capacitor);
66
62
  const bytes = new Uint8Array([0, 1, 2, 254, 255]);
67
- expect(await backend.writeBinaryFile('/b.bin', bytes)).toBe(true);
68
- const read = await backend.readBinaryFile('/b.bin');
63
+ expect(await backend.writeBinaryFile?.('/b.bin', bytes)).toBe(true);
64
+ const read = await backend.readBinaryFile?.('/b.bin');
69
65
  expect(read).not.toBeNull();
70
66
  expect([...read!]).toEqual([0, 1, 2, 254, 255]);
71
67
  });
@@ -79,9 +75,11 @@ describe('createCapacitorFileSystemBackend', () => {
79
75
  text: { value: async () => 'Flight' },
80
76
  });
81
77
  capacitor.filesystem.readFile = async () => ({ data: blob });
82
- const backend = createCapacitorFileSystemBackend(capacitor);
83
- expect(await backend.readTextFile('/blob.txt')).toBe('Flight');
84
- expect([...(await backend.readBinaryFile('/blob.bin'))!]).toEqual([70, 108, 105, 103, 104, 116]);
78
+ const backend = capacitorHostFileSystem(capacitor);
79
+ expect(await backend.readTextFile?.('/blob.txt')).toBe('Flight');
80
+ const binary = await backend.readBinaryFile?.('/blob.bin');
81
+ expect(binary).not.toBeNull();
82
+ expect([...binary!]).toEqual([70, 108, 105, 103, 104, 116]);
85
83
  });
86
84
 
87
85
  it('rejects pre-aborted reads before calling the plugin', async () => {
@@ -90,8 +88,8 @@ describe('createCapacitorFileSystemBackend', () => {
90
88
  const controller = new AbortController();
91
89
  const reason = new Error('cancel Capacitor read');
92
90
  controller.abort(reason);
93
- const backend = createCapacitorFileSystemBackend(capacitor);
94
- await expect(backend.readTextFile('/a.txt', controller.signal)).rejects.toBe(reason);
91
+ const backend = capacitorHostFileSystem(capacitor);
92
+ await expect(backend.readTextFile?.('/a.txt', controller.signal)).rejects.toBe(reason);
95
93
  expect(readFile).not.toHaveBeenCalled();
96
94
  });
97
95
 
@@ -104,25 +102,25 @@ describe('createCapacitorFileSystemBackend', () => {
104
102
  controller.abort(new Error('after native write'));
105
103
  return result;
106
104
  };
107
- const backend = createCapacitorFileSystemBackend(capacitor);
108
- await expect(backend.writeTextFile('/complete.txt', 'saved', controller.signal)).resolves.toBe(true);
105
+ const backend = capacitorHostFileSystem(capacitor);
106
+ await expect(backend.writeTextFile?.('/complete.txt', 'saved', controller.signal)).resolves.toBe(true);
109
107
  expect(files.get('/complete.txt')?.data).toBe('saved');
110
108
  });
111
109
 
112
110
  it('maps exists/stat/remove and reports null for a missing file', async () => {
113
- const backend = createCapacitorFileSystemBackend(fakeCapacitor().capacitor);
114
- await backend.writeTextFile('/c.txt', 'x');
115
- expect(await backend.fileExists('/c.txt')).toBe(true);
116
- expect(await backend.directoryExists('/c.txt')).toBe(false);
117
- const stat = await backend.statFile('/c.txt');
111
+ const backend = capacitorHostFileSystem(fakeCapacitor().capacitor);
112
+ await backend.writeTextFile?.('/c.txt', 'x');
113
+ expect(await backend.fileExists?.('/c.txt')).toBe(true);
114
+ expect(await backend.directoryExists?.('/c.txt')).toBe(false);
115
+ const stat = await backend.statFile?.('/c.txt');
118
116
  expect(stat).toMatchObject({ size: 1, isDirectory: false, createdTime: 50 });
119
- expect(await backend.removeFile('/c.txt')).toBe(true);
120
- expect(await backend.readTextFile('/c.txt')).toBeNull();
121
- expect(await backend.statFile('/missing')).toBeNull();
117
+ expect(await backend.removeFile?.('/c.txt')).toBe(true);
118
+ expect(await backend.readTextFile?.('/c.txt')).toBeNull();
119
+ expect(await backend.statFile?.('/missing')).toBeNull();
122
120
  });
123
121
 
124
122
  it('omits operations the Capacitor plugin cannot perform', () => {
125
- const backend = createCapacitorFileSystemBackend(fakeCapacitor().capacitor);
123
+ const backend = capacitorHostFileSystem(fakeCapacitor().capacitor);
126
124
  expect(Object.keys(backend)).not.toEqual(
127
125
  expect.arrayContaining([
128
126
  'canAccessFile',
@@ -135,8 +133,3 @@ describe('createCapacitorFileSystemBackend', () => {
135
133
  );
136
134
  });
137
135
  });
138
- describe('initializeCapacitorFileSystemBackend', () => {
139
- it('is the construction initializer of createCapacitorFileSystemBackend', () => {
140
- expect(typeof initializeCapacitorFileSystemBackend).toBe('function');
141
- });
142
- });
@@ -1,7 +1,7 @@
1
- import type { CapacitorApi, CapacitorPosition } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
3
2
 
4
- import { createCapacitorGeolocationBackend, initializeCapacitorGeolocationBackend } from './capacitorGeolocation';
3
+ import { capacitorHostGeolocation } from './capacitorGeolocation.ts';
4
+ import type { CapacitorApi, CapacitorPosition } from './types/index.ts';
5
5
 
6
6
  const flush = async () => {
7
7
  await Promise.resolve();
@@ -49,25 +49,21 @@ function fakeCapacitor(permission = 'granted') {
49
49
  return { capacitor, cleared, fire: (p: CapacitorPosition) => watchCallback?.(p) };
50
50
  }
51
51
 
52
- describe('createCapacitorGeolocationBackend', () => {
53
- it('returns an Entity', () => {
54
- expect(EntityRuntimeKey in createCapacitorGeolocationBackend(fakeCapacitor().capacitor)).toBe(true);
55
- });
56
-
52
+ describe('capacitorHostGeolocation', () => {
57
53
  it('reports an installed Capacitor geolocation provider as available', () => {
58
- const backend = createCapacitorGeolocationBackend(fakeCapacitor().capacitor);
54
+ const backend = capacitorHostGeolocation(fakeCapacitor().capacitor);
59
55
  expect(backend.isAvailable()).toBe(true);
60
56
  });
61
57
 
62
- it('maps a Capacitor position onto a GeoPosition', async () => {
63
- const backend = createCapacitorGeolocationBackend(fakeCapacitor().capacitor);
58
+ it('maps a Capacitor position onto a GeolocationPosition', async () => {
59
+ const backend = capacitorHostGeolocation(fakeCapacitor().capacitor);
64
60
  const position = await backend.getCurrentPosition({});
65
61
  expect(position).toMatchObject({ latitude: 37.5, longitude: -122.3, accuracy: 5, heading: 90, floorLevel: 0 });
66
62
  });
67
63
 
68
64
  it('bridges the numeric watch id and clears the resolved string id', async () => {
69
65
  const { capacitor, cleared, fire } = fakeCapacitor();
70
- const backend = createCapacitorGeolocationBackend(capacitor);
66
+ const backend = capacitorHostGeolocation(capacitor);
71
67
  let received = 0;
72
68
  const id = backend.watchPosition(() => received++, {});
73
69
  expect(typeof id).toBe('number');
@@ -78,8 +74,3 @@ describe('createCapacitorGeolocationBackend', () => {
78
74
  expect(cleared).toContain('watch-abc');
79
75
  });
80
76
  });
81
- describe('initializeCapacitorGeolocationBackend', () => {
82
- it('is the construction initializer of createCapacitorGeolocationBackend', () => {
83
- expect(typeof initializeCapacitorGeolocationBackend).toBe('function');
84
- });
85
- });
@@ -1,6 +1,7 @@
1
- import type { HapticsCapabilities, CapacitorApi } from '@flighthq/types/contract';
1
+ import type { HapticsCapabilities } from '@flighthq/haptics/contract';
2
2
 
3
- import { createCapacitorHapticsBackend, initializeCapacitorHapticsBackend } from './capacitorHaptics';
3
+ import { capacitorHostHaptics } from './capacitorHaptics.ts';
4
+ import type { CapacitorApi } from './types/index.ts';
4
5
 
5
6
  function fakeCapacitor() {
6
7
  const calls: Array<{ method: string; arg?: unknown }> = [];
@@ -29,19 +30,19 @@ function fakeCapacitor() {
29
30
  return { capacitor, calls };
30
31
  }
31
32
 
32
- describe('createCapacitorHapticsBackend', () => {
33
+ describe('capacitorHostHaptics', () => {
33
34
  it('maps impact styles onto Capacitor enums', () => {
34
35
  const { capacitor, calls } = fakeCapacitor();
35
- const backend = createCapacitorHapticsBackend(capacitor);
36
- expect(backend.impact('soft')).toBe(true);
37
- expect(backend.impact('rigid')).toBe(true);
36
+ const backend = capacitorHostHaptics(capacitor);
37
+ expect(backend.impact('soft', undefined)).toBe(true);
38
+ expect(backend.impact('rigid', undefined)).toBe(true);
38
39
  expect(calls[0].arg).toEqual({ style: 'LIGHT' });
39
40
  expect(calls[1].arg).toEqual({ style: 'HEAVY' });
40
41
  });
41
42
 
42
43
  it('maps notification, selection, and vibrate', () => {
43
44
  const { capacitor, calls } = fakeCapacitor();
44
- const backend = createCapacitorHapticsBackend(capacitor);
45
+ const backend = capacitorHostHaptics(capacitor);
45
46
  expect(backend.notification('success')).toBe(true);
46
47
  expect(backend.selection()).toBe(true);
47
48
  expect(backend.vibrate(200)).toBe(true);
@@ -51,7 +52,7 @@ describe('createCapacitorHapticsBackend', () => {
51
52
  });
52
53
 
53
54
  it('reports capabilities and unsupported operations', () => {
54
- const backend = createCapacitorHapticsBackend(fakeCapacitor().capacitor);
55
+ const backend = capacitorHostHaptics(fakeCapacitor().capacitor);
55
56
  const out: HapticsCapabilities = {
56
57
  amplitudeControl: true,
57
58
  customEvents: true,
@@ -72,8 +73,3 @@ describe('createCapacitorHapticsBackend', () => {
72
73
  expect(backend.isSupported()).toBe(true);
73
74
  });
74
75
  });
75
- describe('initializeCapacitorHapticsBackend', () => {
76
- it('is the construction initializer of createCapacitorHapticsBackend', () => {
77
- expect(typeof initializeCapacitorHapticsBackend).toBe('function');
78
- });
79
- });