@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
@@ -1,13 +1,12 @@
1
1
  import { readClipboardText } from '@flighthq/clipboard/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
3
- import type { CapacitorApi } from '@flighthq/types/contract';
2
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
4
3
 
5
- import { capacitorHost, initializeCapacitorHost, registerCapacitorBackends } from './capacitorRegister';
4
+ import { capacitorHost } from './capacitorHost.ts';
5
+ import type { CapacitorApi } from './types/index.ts';
6
6
 
7
- // A fake Capacitor API broad enough that every createCapacitor*Backend constructs without touching
8
- // missing members. Backends close over `capacitor` and only call in when their methods run (plus the
9
- // app/device/statusbar/connectivity prefetches), so a thin fake proves registration
10
- // routes the seams to the Capacitor backends.
7
+ // A fake Capacitor API broad enough that every provider constructs without touching missing members.
8
+ // Providers close over `capacitor` and only call in when their methods run (plus the app, device,
9
+ // status-bar, and connectivity prefetches), so a thin fake proves composition routes the seams.
11
10
  function fakeCapacitor(): CapacitorApi {
12
11
  const asyncNoop = async () => {};
13
12
  const asyncListener = async () => ({ async remove() {} });
@@ -62,17 +61,21 @@ describe('capacitor power slot coverage', () => {
62
61
  // honest and forward-compatible; the named gap lives in agents/upstream-host-requirements.md so an
63
62
  // examined absence stays distinguishable from an unexamined one.
64
63
  it('claims no power capability at all', () => {
65
- const host = registerCapacitorBackends(fakeCapacitor(), 'ios');
64
+ const host = capacitorHost(fakeCapacitor(), 'ios');
66
65
  expect(host.power).toEqual({});
67
66
  });
68
67
  });
69
68
 
70
69
  describe('capacitorHost', () => {
70
+ it('publishes every Host group and no parallel top-level surface', () => {
71
+ expect(Object.keys(capacitorHost(fakeCapacitor(), 'ios')).sort()).toEqual([...HOST_GROUP_NAMES]);
72
+ });
73
+
71
74
  it('exposes the real Capacitor haptics provider', () => {
72
75
  const host = capacitorHost(fakeCapacitor(), 'ios');
73
76
  expect(EntityRuntimeKey in host).toBe(true);
74
- expect(host.input.haptics).toBeDefined();
75
- expect(typeof host.input.haptics?.vibrate).toBe('function');
77
+ expect(host.haptics.engine).toBeDefined();
78
+ expect(typeof host.haptics.engine?.vibrate).toBe('function');
76
79
  });
77
80
 
78
81
  // An empty group means "not yet migrated off its package-local seam", NEVER "Capacitor cannot do
@@ -89,39 +92,32 @@ describe('capacitorHost', () => {
89
92
  expect('directoryOpen' in host.dialog).toBe(false);
90
93
  expect('fileOpen' in host.dialog).toBe(false);
91
94
  expect('fileSave' in host.dialog).toBe(false);
92
- expect(host.input.haptics).toBeDefined();
95
+ expect(host.haptics.engine).toBeDefined();
93
96
  expect(host.notification.delivery).toBeDefined();
94
97
  expect(host.share.content).toBeDefined();
95
- expect(host.storage.fileSystem).toBeDefined();
96
- expect(host.ui.statusBarColor).toBeDefined();
97
- expect(host.ui.statusBarInfo).toBeDefined();
98
- expect(host.system.device).toBeDefined();
99
- expect(host.media).toEqual({});
98
+ expect(host.fileSystem.access).toBeDefined();
99
+ expect(host.statusBar.color).toBeDefined();
100
+ expect(host.statusBar.info).toBeDefined();
101
+ expect(host.device.info).toBeDefined();
102
+ expect(host.audio).toEqual({});
103
+ expect(host.video).toEqual({});
100
104
  expect(host.shortcut).toEqual({});
101
105
  expect(host.updater).toEqual({});
102
106
  });
103
107
 
104
- // Every WindowBackend member is optional, so a backend carrying no operation is the honest claim for
105
- // a webview app with no native window operations of its own. Counted by own keys rather than compared
106
- // to {}, because the backend is an Entity and carries a runtime slot that is not an operation.
108
+ // A webview app has no native window operations of its own, so the whole window group is absent —
109
+ // an empty struct of capability slots rather than a live capability with inert methods.
107
110
  it('claims no native window operations', () => {
108
- expect(Object.keys(capacitorHost(fakeCapacitor(), 'ios').window)).toEqual([]);
111
+ expect(capacitorHost(fakeCapacitor(), 'ios').window).toEqual({});
109
112
  });
110
113
 
111
114
  it('names Shell as an exact empty capability group', () => {
112
115
  const host = capacitorHost(fakeCapacitor(), 'ios');
113
116
  expect(host.shell).toEqual({});
114
117
  });
115
- });
116
118
 
117
- describe('initializeCapacitorHost', () => {
118
- it('is the construction initializer of createCapacitorHost', () => {
119
- expect(typeof initializeCapacitorHost).toBe('function');
120
- });
121
- });
122
- describe('registerCapacitorBackends', () => {
123
- it('installs a backend for each covered capability', () => {
124
- const host = registerCapacitorBackends(fakeCapacitor(), 'ios');
119
+ it('installs a provider for each covered capability', () => {
120
+ const host = capacitorHost(fakeCapacitor(), 'ios');
125
121
  expect(EntityRuntimeKey in host).toBe(true);
126
122
  expect(host.dialog.message.confirm).toBeTypeOf('function');
127
123
  expect(host.dialog.prompt.prompt).toBeTypeOf('function');
@@ -131,29 +127,76 @@ describe('registerCapacitorBackends', () => {
131
127
  expect(host.protocol.open.subscribe).toBeTypeOf('function');
132
128
  expect(host.connectivity.status.getStatus).toBeTypeOf('function');
133
129
  expect(host.connectivity.change.subscribe).toBeTypeOf('function');
134
- expect(host.system.device).toBeDefined();
135
- expect(host.storage.fileSystem.readTextFile).toBeTypeOf('function');
136
- expect(host.system.geolocation).toBeDefined();
130
+ expect(host.device.info).toBeDefined();
131
+ expect(host.fileSystem.access.readTextFile).toBeTypeOf('function');
132
+ expect(host.geolocation.position).toBeDefined();
137
133
  expect(host.notification.delivery.notify).toBeTypeOf('function');
138
134
  expect(host.notification.scheduling.scheduleNotification).toBeTypeOf('function');
139
135
  expect(host.share.content.canShareContent({ text: 'ready' })).toBe(true);
140
- expect(host.input.softKeyboardInfo).toBeDefined();
141
- expect(host.input.softKeyboardVisibility).toBeDefined();
142
- expect(host.ui.statusBarColor.setBackgroundColor).toBeTypeOf('function');
143
- expect(host.ui.statusBarInfo.getInfo).toBeTypeOf('function');
144
- });
145
-
146
- // Haptics has migrated off the ambient seam: registerCapacitorBackends now RETURNS a Host carrying the
147
- // real Capacitor provider, so the capability is proven by what the host exposes rather than by what a
148
- // module-scoped variable happens to hold.
149
- it('returns a host exposing the real Capacitor haptics capability', () => {
150
- const host = registerCapacitorBackends(fakeCapacitor(), 'ios');
151
- expect(host.input.haptics).toBeDefined();
152
- expect(typeof host.input.haptics?.vibrate).toBe('function');
136
+ expect(host.softKeyboard.info).toBeDefined();
137
+ expect(host.softKeyboard.visibility).toBeDefined();
138
+ expect(host.statusBar.color.setBackgroundColor).toBeTypeOf('function');
139
+ expect(host.statusBar.info.getInfo).toBeTypeOf('function');
153
140
  });
154
141
 
155
- it('routes a capability call through to the Capacitor backend', async () => {
156
- const host = registerCapacitorBackends(fakeCapacitor(), 'ios');
157
- expect(await readClipboardText(host)).toBe('CAP-TEXT');
142
+ it('routes a capability call through to the Capacitor provider', async () => {
143
+ const host = capacitorHost(fakeCapacitor(), 'ios');
144
+ expect(await readClipboardText(host.clipboard.text)).toBe('CAP-TEXT');
158
145
  });
159
146
  });
147
+
148
+ // The capability groups every provider host carries (D26: each provider declares its own; there is no
149
+ // aggregate Host to read them from).
150
+ const HOST_GROUP_NAMES = [
151
+ 'accessibility',
152
+ 'app',
153
+ 'audio',
154
+ 'audioDecode',
155
+ 'bitmap',
156
+ 'canvas',
157
+ 'clipboard',
158
+ 'compress',
159
+ 'connectivity',
160
+ 'decompress',
161
+ 'device',
162
+ 'dialog',
163
+ 'fileSystem',
164
+ 'font',
165
+ 'fullscreen',
166
+ 'geolocation',
167
+ 'gl',
168
+ 'glyph',
169
+ 'haptics',
170
+ 'image',
171
+ 'imageDecode',
172
+ 'imageEncode',
173
+ 'input',
174
+ 'ipc',
175
+ 'lifecycle',
176
+ 'mediaSession',
177
+ 'menu',
178
+ 'midi',
179
+ 'net',
180
+ 'notification',
181
+ 'permissions',
182
+ 'platform',
183
+ 'power',
184
+ 'preferences',
185
+ 'protocol',
186
+ 'screen',
187
+ 'sensors',
188
+ 'share',
189
+ 'shell',
190
+ 'shortcut',
191
+ 'socket',
192
+ 'softKeyboard',
193
+ 'statusBar',
194
+ 'surface',
195
+ 'textSegment',
196
+ 'textShaper',
197
+ 'tray',
198
+ 'updater',
199
+ 'video',
200
+ 'wgpu',
201
+ 'window',
202
+ ];
@@ -0,0 +1,33 @@
1
+ import { capacitorHostHapticsGroup, capacitorHostSoftKeyboardGroup } from './capacitorInputHost.ts';
2
+ import type { CapacitorApi } from './types/index.ts';
3
+
4
+ function fakeCapacitor(): CapacitorApi {
5
+ return {
6
+ haptics: {},
7
+ keyboard: {
8
+ addListener: async () => ({ async remove() {} }),
9
+ },
10
+ } as unknown as CapacitorApi;
11
+ }
12
+
13
+ describe('capacitorHostHapticsGroup', () => {
14
+ it('publishes the Entity-backed haptics engine slot', () => {
15
+ const haptics = capacitorHostHapticsGroup(fakeCapacitor());
16
+ expect(Object.keys(haptics)).toEqual(['engine']);
17
+ });
18
+ });
19
+
20
+ describe('capacitorHostSoftKeyboardGroup', () => {
21
+ it('publishes the exact mobile soft-keyboard profile as Entity-backed providers', () => {
22
+ const softKeyboard = capacitorHostSoftKeyboardGroup(fakeCapacitor());
23
+ expect(Object.keys(softKeyboard).sort()).toEqual([
24
+ 'accessoryBar',
25
+ 'change',
26
+ 'info',
27
+ 'resizeModeWrite',
28
+ 'scrollAssist',
29
+ 'style',
30
+ 'visibility',
31
+ ]);
32
+ });
33
+ });
@@ -1,22 +1,17 @@
1
- import type { CapacitorApi, SoftKeyboardInfo } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey, SoftKeyboardResizeBodyKind } from '@flighthq/types/contract';
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
2
+ import { SoftKeyboardResizeBodyKind } from '@flighthq/keyboard/contract';
3
+ import type { SoftKeyboardInfo } from '@flighthq/keyboard/contract';
3
4
 
4
5
  import {
5
- createCapacitorSoftKeyboardAccessoryBarBackend,
6
- createCapacitorSoftKeyboardChangeBackend,
7
- createCapacitorSoftKeyboardInfoBackend,
8
- createCapacitorSoftKeyboardResizeModeWriteBackend,
9
- createCapacitorSoftKeyboardScrollAssistBackend,
10
- createCapacitorSoftKeyboardStyleBackend,
11
- createCapacitorSoftKeyboardVisibilityBackend,
12
- initializeCapacitorSoftKeyboardAccessoryBarBackend,
13
- initializeCapacitorSoftKeyboardChangeBackend,
14
- initializeCapacitorSoftKeyboardInfoBackend,
15
- initializeCapacitorSoftKeyboardResizeModeWriteBackend,
16
- initializeCapacitorSoftKeyboardScrollAssistBackend,
17
- initializeCapacitorSoftKeyboardStyleBackend,
18
- initializeCapacitorSoftKeyboardVisibilityBackend,
19
- } from './capacitorKeyboard';
6
+ capacitorHostSoftKeyboardAccessoryBar,
7
+ capacitorHostSoftKeyboardChange,
8
+ capacitorHostSoftKeyboardInfo,
9
+ capacitorHostSoftKeyboardResizeModeWrite,
10
+ capacitorHostSoftKeyboardScrollAssist,
11
+ capacitorHostSoftKeyboardStyle,
12
+ capacitorHostSoftKeyboardVisibility,
13
+ } from './capacitorKeyboard.ts';
14
+ import type { CapacitorApi } from './types/index.ts';
20
15
 
21
16
  function fakeCapacitor() {
22
17
  const calls: Array<{ method: string; arg?: unknown }> = [];
@@ -57,14 +52,10 @@ function blankInfo(): SoftKeyboardInfo {
57
52
  return { visible: false, height: 0, x: 0, y: 0, width: 0 };
58
53
  }
59
54
 
60
- describe('createCapacitorSoftKeyboardAccessoryBarBackend', () => {
61
- it('returns an Entity', () => {
62
- expect(EntityRuntimeKey in createCapacitorSoftKeyboardAccessoryBarBackend(fakeCapacitor().capacitor)).toBe(true);
63
- });
64
-
55
+ describe('capacitorHostSoftKeyboardAccessoryBar', () => {
65
56
  it('returns ok on success', async () => {
66
57
  const { capacitor, calls } = fakeCapacitor();
67
- const backend = createCapacitorSoftKeyboardAccessoryBarBackend(capacitor);
58
+ const backend = capacitorHostSoftKeyboardAccessoryBar(capacitor);
68
59
  expect(await backend.setAccessoryBarVisible(true)).toBe('ok');
69
60
  expect(calls[0].arg).toEqual({ isVisible: true });
70
61
  });
@@ -80,16 +71,16 @@ describe('createCapacitorSoftKeyboardAccessoryBarBackend', () => {
80
71
  },
81
72
  },
82
73
  } as unknown as CapacitorApi;
83
- expect(await createCapacitorSoftKeyboardAccessoryBarBackend(failCapacitor).setAccessoryBarVisible(true)).toBe(
74
+ expect(await capacitorHostSoftKeyboardAccessoryBar(failCapacitor).setAccessoryBarVisible(true)).toBe(
84
75
  'operation-failed',
85
76
  );
86
77
  });
87
78
  });
88
79
 
89
- describe('createCapacitorSoftKeyboardChangeBackend', () => {
80
+ describe('capacitorHostSoftKeyboardChange', () => {
90
81
  it('subscribe returns ok with unsubscribe and fires on will events', async () => {
91
82
  const { capacitor, fire } = fakeCapacitor();
92
- const backend = createCapacitorSoftKeyboardChangeBackend(capacitor);
83
+ const backend = capacitorHostSoftKeyboardChange(capacitor);
93
84
  let fires = 0;
94
85
  const subscription = await backend.subscribe(() => fires++);
95
86
  expect(subscription.result).toBe('ok');
@@ -108,34 +99,33 @@ describe('createCapacitorSoftKeyboardChangeBackend', () => {
108
99
  },
109
100
  },
110
101
  } as unknown as CapacitorApi;
111
- const subscription = await createCapacitorSoftKeyboardChangeBackend(failCapacitor).subscribe(() => {});
102
+ const subscription = await capacitorHostSoftKeyboardChange(failCapacitor).subscribe(() => {});
112
103
  expect(subscription.result).toBe('acquisition-failed');
113
104
  expect(subscription.unsubscribe).toBeNull();
114
105
  });
115
106
  });
116
107
 
117
- describe('createCapacitorSoftKeyboardInfoBackend', () => {
118
- it('returns an Entity', () => {
119
- expect(EntityRuntimeKey in createCapacitorSoftKeyboardInfoBackend(fakeCapacitor().capacitor)).toBe(true);
120
- });
121
-
108
+ describe('capacitorHostSoftKeyboardInfo', () => {
122
109
  it('tracks the keyboard mirror from will-show/will-hide events', async () => {
123
110
  const { capacitor, fire } = fakeCapacitor();
124
- const backend = createCapacitorSoftKeyboardInfoBackend(capacitor);
111
+ const backend = capacitorHostSoftKeyboardInfo(capacitor);
125
112
  await Promise.resolve();
126
113
  fire('keyboardWillShow', { keyboardHeight: 320 });
127
- const shown = backend.getInfo(blankInfo());
114
+ const shown = blankInfo();
115
+ backend.getInfo(shown);
128
116
  expect(shown.visible).toBe(true);
129
117
  expect(shown.height).toBe(320);
130
118
  fire('keyboardWillHide');
131
- expect(backend.getInfo(blankInfo()).visible).toBe(false);
119
+ const hidden = blankInfo();
120
+ backend.getInfo(hidden);
121
+ expect(hidden.visible).toBe(false);
132
122
  });
133
123
  });
134
124
 
135
- describe('createCapacitorSoftKeyboardResizeModeWriteBackend', () => {
125
+ describe('capacitorHostSoftKeyboardResizeModeWrite', () => {
136
126
  it('returns ok on success and maps the mode', async () => {
137
127
  const { capacitor, calls } = fakeCapacitor();
138
- const backend = createCapacitorSoftKeyboardResizeModeWriteBackend(capacitor);
128
+ const backend = capacitorHostSoftKeyboardResizeModeWrite(capacitor);
139
129
  expect(await backend.setResizeMode(SoftKeyboardResizeBodyKind)).toBe('ok');
140
130
  expect(calls[0].arg).toEqual({ mode: 'body' });
141
131
  });
@@ -151,16 +141,16 @@ describe('createCapacitorSoftKeyboardResizeModeWriteBackend', () => {
151
141
  },
152
142
  },
153
143
  } as unknown as CapacitorApi;
154
- expect(await createCapacitorSoftKeyboardResizeModeWriteBackend(failCapacitor).setResizeMode('None')).toBe(
144
+ expect(await capacitorHostSoftKeyboardResizeModeWrite(failCapacitor).setResizeMode('None')).toBe(
155
145
  'operation-failed',
156
146
  );
157
147
  });
158
148
  });
159
149
 
160
- describe('createCapacitorSoftKeyboardScrollAssistBackend', () => {
150
+ describe('capacitorHostSoftKeyboardScrollAssist', () => {
161
151
  it('returns ok on success', async () => {
162
152
  const { capacitor, calls } = fakeCapacitor();
163
- const backend = createCapacitorSoftKeyboardScrollAssistBackend(capacitor);
153
+ const backend = capacitorHostSoftKeyboardScrollAssist(capacitor);
164
154
  expect(await backend.setScrollAssistEnabled(false)).toBe('ok');
165
155
  expect(calls[0].arg).toEqual({ isDisabled: true });
166
156
  });
@@ -176,16 +166,16 @@ describe('createCapacitorSoftKeyboardScrollAssistBackend', () => {
176
166
  },
177
167
  },
178
168
  } as unknown as CapacitorApi;
179
- expect(await createCapacitorSoftKeyboardScrollAssistBackend(failCapacitor).setScrollAssistEnabled(true)).toBe(
169
+ expect(await capacitorHostSoftKeyboardScrollAssist(failCapacitor).setScrollAssistEnabled(true)).toBe(
180
170
  'operation-failed',
181
171
  );
182
172
  });
183
173
  });
184
174
 
185
- describe('createCapacitorSoftKeyboardStyleBackend', () => {
175
+ describe('capacitorHostSoftKeyboardStyle', () => {
186
176
  it('returns ok on success', async () => {
187
177
  const { capacitor, calls } = fakeCapacitor();
188
- const backend = createCapacitorSoftKeyboardStyleBackend(capacitor);
178
+ const backend = capacitorHostSoftKeyboardStyle(capacitor);
189
179
  expect(await backend.setStyle('Dark')).toBe('ok');
190
180
  expect(calls[0].arg).toEqual({ style: 'DARK' });
191
181
  });
@@ -201,14 +191,14 @@ describe('createCapacitorSoftKeyboardStyleBackend', () => {
201
191
  },
202
192
  },
203
193
  } as unknown as CapacitorApi;
204
- expect(await createCapacitorSoftKeyboardStyleBackend(failCapacitor).setStyle('Dark')).toBe('operation-failed');
194
+ expect(await capacitorHostSoftKeyboardStyle(failCapacitor).setStyle('Dark')).toBe('operation-failed');
205
195
  });
206
196
  });
207
197
 
208
- describe('createCapacitorSoftKeyboardVisibilityBackend', () => {
198
+ describe('capacitorHostSoftKeyboardVisibility', () => {
209
199
  it('returns ok when show/hide succeed', async () => {
210
200
  const { capacitor, calls } = fakeCapacitor();
211
- const backend = createCapacitorSoftKeyboardVisibilityBackend(capacitor);
201
+ const backend = capacitorHostSoftKeyboardVisibility(capacitor);
212
202
  expect(await backend.show()).toBe('ok');
213
203
  expect(await backend.hide()).toBe('ok');
214
204
  expect(calls.map((c) => c.method)).toEqual(['show', 'hide']);
@@ -226,7 +216,7 @@ describe('createCapacitorSoftKeyboardVisibilityBackend', () => {
226
216
  },
227
217
  },
228
218
  } as unknown as CapacitorApi;
229
- expect(await createCapacitorSoftKeyboardVisibilityBackend(failCapacitor).show()).toBe('operation-failed');
219
+ expect(await capacitorHostSoftKeyboardVisibility(failCapacitor).show()).toBe('operation-failed');
230
220
  });
231
221
 
232
222
  it('returns operation-failed when hide rejects', async () => {
@@ -241,47 +231,6 @@ describe('createCapacitorSoftKeyboardVisibilityBackend', () => {
241
231
  },
242
232
  },
243
233
  } as unknown as CapacitorApi;
244
- expect(await createCapacitorSoftKeyboardVisibilityBackend(failCapacitor).hide()).toBe('operation-failed');
245
- });
246
- });
247
- describe('initializeCapacitorSoftKeyboardAccessoryBarBackend', () => {
248
- it('is the construction initializer of createCapacitorSoftKeyboardAccessoryBarBackend', () => {
249
- expect(typeof initializeCapacitorSoftKeyboardAccessoryBarBackend).toBe('function');
250
- });
251
- });
252
-
253
- describe('initializeCapacitorSoftKeyboardChangeBackend', () => {
254
- it('is the construction initializer of createCapacitorSoftKeyboardChangeBackend', () => {
255
- expect(typeof initializeCapacitorSoftKeyboardChangeBackend).toBe('function');
256
- });
257
- });
258
-
259
- describe('initializeCapacitorSoftKeyboardInfoBackend', () => {
260
- it('is the construction initializer of createCapacitorSoftKeyboardInfoBackend', () => {
261
- expect(typeof initializeCapacitorSoftKeyboardInfoBackend).toBe('function');
262
- });
263
- });
264
-
265
- describe('initializeCapacitorSoftKeyboardResizeModeWriteBackend', () => {
266
- it('is the construction initializer of createCapacitorSoftKeyboardResizeModeWriteBackend', () => {
267
- expect(typeof initializeCapacitorSoftKeyboardResizeModeWriteBackend).toBe('function');
268
- });
269
- });
270
-
271
- describe('initializeCapacitorSoftKeyboardScrollAssistBackend', () => {
272
- it('is the construction initializer of createCapacitorSoftKeyboardScrollAssistBackend', () => {
273
- expect(typeof initializeCapacitorSoftKeyboardScrollAssistBackend).toBe('function');
274
- });
275
- });
276
-
277
- describe('initializeCapacitorSoftKeyboardStyleBackend', () => {
278
- it('is the construction initializer of createCapacitorSoftKeyboardStyleBackend', () => {
279
- expect(typeof initializeCapacitorSoftKeyboardStyleBackend).toBe('function');
280
- });
281
- });
282
-
283
- describe('initializeCapacitorSoftKeyboardVisibilityBackend', () => {
284
- it('is the construction initializer of createCapacitorSoftKeyboardVisibilityBackend', () => {
285
- expect(typeof initializeCapacitorSoftKeyboardVisibilityBackend).toBe('function');
234
+ expect(await capacitorHostSoftKeyboardVisibility(failCapacitor).hide()).toBe('operation-failed');
286
235
  });
287
236
  });
@@ -1,15 +1,20 @@
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
1
2
  import { cancelScheduledNotification } from '@flighthq/notification/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
3
+
4
+ import {
5
+ capacitorHostNotification,
6
+ capacitorHostNotificationAction,
7
+ capacitorHostNotificationClick,
8
+ capacitorHostNotificationDelivery,
9
+ capacitorHostNotificationLifecycle,
10
+ capacitorHostNotificationPermission,
11
+ capacitorHostNotificationScheduling,
12
+ } from './capacitorNotification.ts';
3
13
  import type {
4
14
  CapacitorApi,
5
15
  CapacitorLocalNotificationAction,
6
16
  CapacitorLocalNotificationSchema,
7
- } from '@flighthq/types/contract';
8
-
9
- import {
10
- createCapacitorNotificationCapabilities,
11
- initializeCapacitorNotificationCapabilities,
12
- } from './capacitorNotification';
17
+ } from './types/index.ts';
13
18
 
14
19
  function fakeCapacitor(display = 'granted') {
15
20
  const scheduled: CapacitorLocalNotificationSchema[] = [];
@@ -60,10 +65,10 @@ function fakeCapacitor(display = 'granted') {
60
65
  };
61
66
  }
62
67
 
63
- describe('createCapacitorNotificationCapabilities', () => {
68
+ describe('capacitorHostNotification', () => {
64
69
  it('constructs the exact Android/iOS common profile', () => {
65
- const capabilities = createCapacitorNotificationCapabilities(fakeCapacitor().capacitor);
66
- expect(EntityRuntimeKey in capabilities).toBe(true);
70
+ const capabilities = capacitorHostNotification(fakeCapacitor().capacitor);
71
+ expect(EntityRuntimeKey in capabilities).toBe(false);
67
72
  expect(Object.keys(capabilities).sort()).toEqual([
68
73
  'action',
69
74
  'click',
@@ -76,7 +81,7 @@ describe('createCapacitorNotificationCapabilities', () => {
76
81
 
77
82
  it('validates profile fields and native acquisition ids before publishing', async () => {
78
83
  const fixture = fakeCapacitor();
79
- const capabilities = createCapacitorNotificationCapabilities(fixture.capacitor);
84
+ const capabilities = capacitorHostNotification(fixture.capacitor);
80
85
  await expect(capabilities.delivery.notify({ icon: 'icon.png', title: 'No' })).resolves.toEqual({
81
86
  fields: ['icon'],
82
87
  reason: 'invalid-request',
@@ -89,7 +94,7 @@ describe('createCapacitorNotificationCapabilities', () => {
89
94
 
90
95
  it('keeps duplicate public ids as distinct private native resources', async () => {
91
96
  const fixture = fakeCapacitor();
92
- const capabilities = createCapacitorNotificationCapabilities(fixture.capacitor);
97
+ const capabilities = capacitorHostNotification(fixture.capacitor);
93
98
  const first = await capabilities.scheduling.scheduleNotification({ id: 'same', title: 'First' }, { at: 1 });
94
99
  const second = await capabilities.scheduling.scheduleNotification({ id: 'same', title: 'Second' }, { at: 2 });
95
100
  if (first.reason !== 'scheduled' || second.reason !== 'scheduled') throw new Error('fixture schedule failed');
@@ -100,7 +105,7 @@ describe('createCapacitorNotificationCapabilities', () => {
100
105
 
101
106
  it('reconciles repeated pending enumeration to stable Entity identity', async () => {
102
107
  const fixture = fakeCapacitor();
103
- const capabilities = createCapacitorNotificationCapabilities(fixture.capacitor);
108
+ const capabilities = capacitorHostNotification(fixture.capacitor);
104
109
  const scheduled = await capabilities.scheduling.scheduleNotification({ id: 'later', title: 'Later' }, { at: 1 });
105
110
  if (scheduled.reason !== 'scheduled') throw new Error('fixture schedule failed');
106
111
  const first = await capabilities.scheduling.getPendingNotifications();
@@ -118,7 +123,7 @@ describe('createCapacitorNotificationCapabilities', () => {
118
123
  fixture.localNotifications.getPending = async () => {
119
124
  throw new Error('failed');
120
125
  };
121
- const capabilities = createCapacitorNotificationCapabilities(fixture.capacitor);
126
+ const capabilities = capacitorHostNotification(fixture.capacitor);
122
127
  await expect(capabilities.permission.getPermission()).resolves.toEqual({
123
128
  reason: 'operation-failed',
124
129
  });
@@ -127,7 +132,7 @@ describe('createCapacitorNotificationCapabilities', () => {
127
132
 
128
133
  it('acquires independent click/action resources and releases their native handles', async () => {
129
134
  const fixture = fakeCapacitor();
130
- const capabilities = createCapacitorNotificationCapabilities(fixture.capacitor);
135
+ const capabilities = capacitorHostNotification(fixture.capacitor);
131
136
  const seen: string[] = [];
132
137
  const click = await capabilities.click.attach((notification) => seen.push(`click:${notification.id}`));
133
138
  const action = await capabilities.action.attach((notification, actionId) =>
@@ -141,8 +146,39 @@ describe('createCapacitorNotificationCapabilities', () => {
141
146
  expect(seen).toHaveLength(2);
142
147
  });
143
148
  });
144
- describe('initializeCapacitorNotificationCapabilities', () => {
145
- it('is the construction initializer of createCapacitorNotificationCapabilities', () => {
146
- expect(typeof initializeCapacitorNotificationCapabilities).toBe('function');
149
+
150
+ describe('capacitorHostNotificationAction', () => {
151
+ it('constructs the action provider', () => {
152
+ expect(capacitorHostNotificationAction(fakeCapacitor().capacitor).attach).toBeTypeOf('function');
153
+ });
154
+ });
155
+
156
+ describe('capacitorHostNotificationClick', () => {
157
+ it('constructs the click provider', () => {
158
+ expect(capacitorHostNotificationClick(fakeCapacitor().capacitor).attach).toBeTypeOf('function');
159
+ });
160
+ });
161
+
162
+ describe('capacitorHostNotificationDelivery', () => {
163
+ it('constructs the delivery provider', () => {
164
+ expect(capacitorHostNotificationDelivery(fakeCapacitor().capacitor).notify).toBeTypeOf('function');
165
+ });
166
+ });
167
+
168
+ describe('capacitorHostNotificationLifecycle', () => {
169
+ it('constructs the lifecycle provider', () => {
170
+ expect(capacitorHostNotificationLifecycle(fakeCapacitor().capacitor).destroy).toBeTypeOf('function');
171
+ });
172
+ });
173
+
174
+ describe('capacitorHostNotificationPermission', () => {
175
+ it('constructs the permission provider', () => {
176
+ expect(capacitorHostNotificationPermission(fakeCapacitor().capacitor).getPermission).toBeTypeOf('function');
177
+ });
178
+ });
179
+
180
+ describe('capacitorHostNotificationScheduling', () => {
181
+ it('constructs the scheduling provider', () => {
182
+ expect(capacitorHostNotificationScheduling(fakeCapacitor().capacitor).scheduleNotification).toBeTypeOf('function');
147
183
  });
148
184
  });
@@ -1,16 +1,15 @@
1
- import type { CapacitorApi } from '@flighthq/types/contract';
2
- import { EntityRuntimeKey } from '@flighthq/types/contract';
3
1
  import { describe, expect, it } from 'vitest';
4
2
 
5
- import { createCapacitorProtocolCapabilities, initializeCapacitorProtocolCapabilities } from './capacitorProtocol';
3
+ import { capacitorHostProtocol, capacitorHostProtocolOpen } from './capacitorProtocol.ts';
4
+ import type { CapacitorApi } from './types/index.ts';
6
5
 
7
6
  const flush = async () => {
8
7
  await Promise.resolve();
9
8
  await Promise.resolve();
10
9
  };
11
10
 
12
- describe('createCapacitorProtocolCapabilities', () => {
13
- it('publishes only a live-open Entity and adapts appUrlOpen', async () => {
11
+ describe('capacitorHostProtocol', () => {
12
+ it('publishes only a live-open slot and adapts appUrlOpen', async () => {
14
13
  let listener: ((event: { url: string }) => void) | undefined;
15
14
  let removed = 0;
16
15
  const capacitor = {
@@ -25,10 +24,8 @@ describe('createCapacitorProtocolCapabilities', () => {
25
24
  },
26
25
  },
27
26
  } as unknown as CapacitorApi;
28
- const protocol = createCapacitorProtocolCapabilities(capacitor);
29
- expect(EntityRuntimeKey in protocol).toBe(true);
27
+ const protocol = capacitorHostProtocol(capacitor);
30
28
  expect(Object.keys(protocol)).toEqual(['open']);
31
- expect(EntityRuntimeKey in protocol.open).toBe(true);
32
29
  let url = '';
33
30
  const off = protocol.open.subscribe((next) => (url = next));
34
31
  await flush();
@@ -39,8 +36,10 @@ describe('createCapacitorProtocolCapabilities', () => {
39
36
  expect(removed).toBe(1);
40
37
  });
41
38
  });
42
- describe('initializeCapacitorProtocolCapabilities', () => {
43
- it('is the construction initializer of createCapacitorProtocolCapabilities', () => {
44
- expect(typeof initializeCapacitorProtocolCapabilities).toBe('function');
39
+
40
+ describe('capacitorHostProtocolOpen', () => {
41
+ it('constructs the open provider', () => {
42
+ const capacitor = { app: { addListener: async () => ({ async remove() {} }) } } as unknown as CapacitorApi;
43
+ expect(capacitorHostProtocolOpen(capacitor)).toBeDefined();
45
44
  });
46
45
  });