@ng-native/device 0.22.2 → 0.23.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 (132) hide show
  1. package/dist/accessibility.d.ts +7 -0
  2. package/dist/accessibility.js +14 -2
  3. package/dist/accessibility.js.map +1 -1
  4. package/dist/app-lifecycle.d.ts +49 -0
  5. package/dist/app-lifecycle.js +67 -0
  6. package/dist/app-lifecycle.js.map +1 -0
  7. package/dist/app-state.d.ts +2 -0
  8. package/dist/app-state.js +2 -0
  9. package/dist/app-state.js.map +1 -1
  10. package/dist/app-windows.d.ts +321 -0
  11. package/dist/app-windows.js +526 -0
  12. package/dist/app-windows.js.map +1 -0
  13. package/dist/color-scheme.d.ts +2 -0
  14. package/dist/color-scheme.js +2 -0
  15. package/dist/color-scheme.js.map +1 -1
  16. package/dist/conditions.d.ts +11 -3
  17. package/dist/conditions.js +42 -9
  18. package/dist/conditions.js.map +1 -1
  19. package/dist/control-size.d.ts +6 -0
  20. package/dist/control-size.js +2 -0
  21. package/dist/control-size.js.map +1 -0
  22. package/dist/deep-links.d.ts +3 -1
  23. package/dist/deep-links.js +3 -1
  24. package/dist/deep-links.js.map +1 -1
  25. package/dist/desktop-options.d.ts +73 -0
  26. package/dist/desktop-options.js +182 -0
  27. package/dist/desktop-options.js.map +1 -0
  28. package/dist/desktop-permissions.d.ts +30 -0
  29. package/dist/desktop-permissions.js +169 -0
  30. package/dist/desktop-permissions.js.map +1 -0
  31. package/dist/dev-menu.d.ts +2 -2
  32. package/dist/dev-menu.js +3 -5
  33. package/dist/dev-menu.js.map +1 -1
  34. package/dist/dialogs.d.ts +9 -7
  35. package/dist/dialogs.js +15 -10
  36. package/dist/dialogs.js.map +1 -1
  37. package/dist/direction.d.ts +2 -0
  38. package/dist/direction.js +2 -0
  39. package/dist/direction.js.map +1 -1
  40. package/dist/dock.d.ts +48 -0
  41. package/dist/dock.js +70 -0
  42. package/dist/dock.js.map +1 -0
  43. package/dist/drag-and-drop.d.ts +67 -0
  44. package/dist/drag-and-drop.js +74 -0
  45. package/dist/drag-and-drop.js.map +1 -0
  46. package/dist/expo-view-name.d.ts +16 -0
  47. package/dist/expo-view-name.js +22 -0
  48. package/dist/expo-view-name.js.map +1 -0
  49. package/dist/hardware-back.d.ts +3 -10
  50. package/dist/hardware-back.js +4 -1
  51. package/dist/hardware-back.js.map +1 -1
  52. package/dist/index.d.ts +26 -2
  53. package/dist/index.js +26 -2
  54. package/dist/index.js.map +1 -1
  55. package/dist/interaction-observer.d.ts +117 -0
  56. package/dist/interaction-observer.js +241 -0
  57. package/dist/interaction-observer.js.map +1 -0
  58. package/dist/keyboard.d.ts +2 -8
  59. package/dist/keyboard.js +3 -0
  60. package/dist/keyboard.js.map +1 -1
  61. package/dist/layout-animation.d.ts +3 -1
  62. package/dist/layout-animation.js +3 -1
  63. package/dist/layout-animation.js.map +1 -1
  64. package/dist/menu-model.d.ts +108 -0
  65. package/dist/menu-model.js +259 -0
  66. package/dist/menu-model.js.map +1 -0
  67. package/dist/menu-template.d.ts +19 -0
  68. package/dist/menu-template.js +31 -0
  69. package/dist/menu-template.js.map +1 -0
  70. package/dist/menus.d.ts +225 -0
  71. package/dist/menus.js +341 -0
  72. package/dist/menus.js.map +1 -0
  73. package/dist/navigation-bar.d.ts +2 -12
  74. package/dist/navigation-bar.js +4 -1
  75. package/dist/navigation-bar.js.map +1 -1
  76. package/dist/os-support.d.ts +42 -0
  77. package/dist/os-support.js +207 -0
  78. package/dist/os-support.js.map +1 -0
  79. package/dist/os.d.ts +26 -5
  80. package/dist/os.js +35 -7
  81. package/dist/os.js.map +1 -1
  82. package/dist/own-host.d.ts +27 -0
  83. package/dist/own-host.js +79 -0
  84. package/dist/own-host.js.map +1 -0
  85. package/dist/processes.d.ts +116 -0
  86. package/dist/processes.js +177 -0
  87. package/dist/processes.js.map +1 -0
  88. package/dist/react-native.d.ts +19 -0
  89. package/dist/react-native.js.map +1 -1
  90. package/dist/safe-area.d.ts +12 -1
  91. package/dist/safe-area.js +16 -2
  92. package/dist/safe-area.js.map +1 -1
  93. package/dist/screen.d.ts +2 -0
  94. package/dist/screen.js +2 -0
  95. package/dist/screen.js.map +1 -1
  96. package/dist/sharing.d.ts +3 -1
  97. package/dist/sharing.js +8 -1
  98. package/dist/sharing.js.map +1 -1
  99. package/dist/shell.d.ts +33 -0
  100. package/dist/shell.js +73 -0
  101. package/dist/shell.js.map +1 -0
  102. package/dist/shortcut.d.ts +49 -0
  103. package/dist/shortcut.js +92 -0
  104. package/dist/shortcut.js.map +1 -0
  105. package/dist/sidebar-selection.d.ts +8 -0
  106. package/dist/sidebar-selection.js +9 -0
  107. package/dist/sidebar-selection.js.map +1 -0
  108. package/dist/spawn-rules.d.ts +108 -0
  109. package/dist/spawn-rules.js +313 -0
  110. package/dist/spawn-rules.js.map +1 -0
  111. package/dist/split-views.d.ts +7 -0
  112. package/dist/split-views.js +21 -0
  113. package/dist/split-views.js.map +1 -0
  114. package/dist/status-bar.d.ts +2 -12
  115. package/dist/status-bar.js +3 -0
  116. package/dist/status-bar.js.map +1 -1
  117. package/dist/tray.d.ts +63 -0
  118. package/dist/tray.js +76 -0
  119. package/dist/tray.js.map +1 -0
  120. package/dist/undo-stack.d.ts +64 -0
  121. package/dist/undo-stack.js +110 -0
  122. package/dist/undo-stack.js.map +1 -0
  123. package/dist/vibration.d.ts +3 -14
  124. package/dist/vibration.js +4 -1
  125. package/dist/vibration.js.map +1 -1
  126. package/dist/window-navigator.d.ts +25 -0
  127. package/dist/window-navigator.js +7 -0
  128. package/dist/window-navigator.js.map +1 -0
  129. package/dist/window-restore.d.ts +45 -0
  130. package/dist/window-restore.js +66 -0
  131. package/dist/window-restore.js.map +1 -0
  132. package/package.json +10 -2
package/dist/menus.js ADDED
@@ -0,0 +1,341 @@
1
+ /**
2
+ * Menus and keyboard shortcuts as the host receives them: the menu bar, the shortcuts that are in
3
+ * no menu, and the form a menu takes on its way to native, which a context menu shares.
4
+ *
5
+ * The host contract, on the `NgNativeMenus` module:
6
+ * - `setMenuBar(groups)`: the whole merged menu bar, each time it changes. The desktop host draws
7
+ * it as the main menu, iPadOS through UIMenuBuilder. Each item has an `id`; an item with a
8
+ * `menuRole` and no `id`'s action is the OS's own (Copy, Quit).
9
+ * - `setShortcuts(shortcuts)`: every shortcut the app listens for outside the menu bar, each with
10
+ * its `id`, its chord read for the OS, and a `label` and `group` for Android's Keyboard Shortcuts
11
+ * helper. On iPhone and Android the menu bar's own shortcuts are in it too, since no bar is drawn.
12
+ * - It sends `ngNativeMenus` events on `DeviceEventEmitter`: `{ type: 'menuSelect', id }` for a menu
13
+ * bar item, and `{ type: 'shortcut', id, textInputFocused }` for a chord pressed.
14
+ * - Its constants say whether it draws a menu bar (`menuBar`) and the app's name (`appName`).
15
+ * - On Android it is an Expo module: the constants are properties, it sends the same events through
16
+ * its own `addListener('ngNativeMenus', ...)`, and it has `setContextMenu(nativeID, entries)`,
17
+ * since React Native's Android view drops a `contextMenu` prop it does not know.
18
+ * - On iOS it is a TurboModule with `setContextMenu(nativeID, entries)` too, for the same reason.
19
+ * React Native's iOS view sends no event it does not know either, so the module sends the item
20
+ * chosen as `{ type: 'contextMenuSelect', nativeID, id }`.
21
+ * - Where it draws context menus, `setTakesLongPress(nativeID, takes)` names a view inside one
22
+ * whose own `(longPress)` takes a long press first: a long press there opens no menu around it,
23
+ * as the innermost handler wins in a native app. A right-click still opens the menu on Android.
24
+ * iOS tells a long press from a secondary click only by the gesture, so an iPad pointer's
25
+ * secondary click there opens none either.
26
+ */
27
+ import { InjectionToken, Service, computed, effect, inject, signal, } from '@angular/core';
28
+ import { defaultMenuBar, isSeparator, mergeMenuBar, } from "./menu-model.js";
29
+ import { injectOs } from "./os.js";
30
+ import { reactNative } from "./react-native.js";
31
+ import { isEditingShortcut, navigationShortcut, parseShortcut, } from "./shortcut.js";
32
+ import * as i0 from "@angular/core";
33
+ const actionIds = new WeakMap();
34
+ let actionsNamed = 0;
35
+ /**
36
+ * The id a menu item with `select` is sent under: the same for as long as the handler is, and no
37
+ * other handler's. `<menu-item>` keeps one handler for its life, so a host that reports a choice
38
+ * from a menu it drew before the items changed still runs that item, or nothing once it has gone,
39
+ * never the item that has taken its place.
40
+ */
41
+ export function menuActionId(select) {
42
+ let id = actionIds.get(select);
43
+ if (id === undefined)
44
+ actionIds.set(select, (id = `a${++actionsNamed}`));
45
+ return id;
46
+ }
47
+ /**
48
+ * `entries` as the host takes them: an id for each item, its shortcut read for `os`, and the
49
+ * handlers by id. An item with a handler is named by it (`menuActionId`); one without, which the
50
+ * app never runs, by its place (`2.0.1`).
51
+ */
52
+ export function serializeMenu(entries, os, prefix = '') {
53
+ const actions = new Map();
54
+ const walk = (list, at) => list.map((entry, index) => {
55
+ if (isSeparator(entry))
56
+ return { separator: true };
57
+ const place = `${at}${index}`;
58
+ const { select, shortcut, items, group: _group, ...rest } = entry;
59
+ const id = select ? menuActionId(select) : place;
60
+ if (select)
61
+ actions.set(id, select);
62
+ return {
63
+ id,
64
+ ...rest,
65
+ // A role item the app handles: the host sends its select rather than doing the role.
66
+ ...(select && entry.menuRole && { handled: true }),
67
+ ...(shortcut
68
+ ? { shortcut: parseShortcut(shortcut, os) }
69
+ : (entry.menuRole === 'back' || entry.menuRole === 'forward') && {
70
+ shortcut: navigationShortcut(entry.menuRole, os),
71
+ }),
72
+ ...(items && { items: walk(items, `${place}.`) }),
73
+ };
74
+ });
75
+ return { entries: walk(entries, prefix), actions };
76
+ }
77
+ /** Android's `NgNativeMenus`, an Expo module, where React Native has no TurboModule of the name. */
78
+ function expoMenusModule() {
79
+ const modules = globalThis.expo?.modules;
80
+ return modules?.['NgNativeMenus'];
81
+ }
82
+ /**
83
+ * The host's menu module: a TurboModule (the desktop host, iOS), or else Android's Expo module.
84
+ * Null where there is neither, as in Expo Go.
85
+ */
86
+ export function menusSource() {
87
+ const native = reactNative();
88
+ const turbo = native?.TurboModuleRegistry?.get?.('NgNativeMenus');
89
+ const expo = turbo ? undefined : expoMenusModule();
90
+ const module = turbo ?? expo;
91
+ if (!module)
92
+ return null;
93
+ const constants = module.getConstants?.() ?? module;
94
+ // An Expo module sends its events itself; a TurboModule's come through DeviceEventEmitter.
95
+ const listen = (hear) => expo
96
+ ? expo.addListener?.('ngNativeMenus', hear)
97
+ : native?.DeviceEventEmitter?.addListener('ngNativeMenus', hear);
98
+ return {
99
+ menuBar: constants.menuBar === true,
100
+ appName: constants.appName ?? '',
101
+ setMenuBar: (groups) => module.setMenuBar?.(groups),
102
+ setShortcuts: (shortcuts) => module.setShortcuts?.(shortcuts),
103
+ setHistory: (surface, history) => module.setHistory?.(surface, history),
104
+ ...contextMenuMethods(module),
105
+ subscribe: (listener) => {
106
+ const subscription = listen((event) => listener(event));
107
+ return () => subscription?.remove();
108
+ },
109
+ };
110
+ }
111
+ /** The context menu methods a module has, bound, and none it lacks: a host without them reads props. */
112
+ function contextMenuMethods(module) {
113
+ const setContextMenu = module.setContextMenu?.bind(module);
114
+ const setTakesLongPress = module.setTakesLongPress?.bind(module);
115
+ return {
116
+ ...(setContextMenu && { setContextMenu }),
117
+ ...(setTakesLongPress && { setTakesLongPress }),
118
+ };
119
+ }
120
+ /** The `ShortcutOs` an `OS` reads shortcuts as. */
121
+ const shortcutOs = (os) => os === 'android' || os === 'macos' || os === 'web' ? os : 'ios';
122
+ /**
123
+ * The menus and shortcuts an app has, sent to the host as they change. `<menu-bar>` and
124
+ * `[shortcut]` in `@ng-native/components` register here; an app rarely injects it.
125
+ */
126
+ export class Menus {
127
+ /** Overridden in a test with a fake host. */
128
+ static SOURCE = new InjectionToken('angular-native.menusSource', {
129
+ factory: menusSource,
130
+ });
131
+ native = inject(Menus.SOURCE);
132
+ os = shortcutOs(injectOs());
133
+ /** Whether the host has the module: shortcuts from a hardware keyboard, and menus. */
134
+ available = signal(this.native !== null).asReadonly();
135
+ /** Whether the menu bar is drawn: macOS and iPadOS. Elsewhere its shortcuts still work. */
136
+ menuBarShown = signal(this.native?.menuBar === true).asReadonly();
137
+ /**
138
+ * Whether the host takes a `[contextMenu]` by the view's `nativeID` through `setContextMenu`
139
+ * (Android and iOS) rather than as the view's `contextMenu` prop. Where it does, it draws the
140
+ * menu on a long press.
141
+ */
142
+ contextMenuByNativeId = this.native?.setContextMenu !== undefined;
143
+ /**
144
+ * Whether the host, which draws context menus on a long press, can be told which views inside
145
+ * one take a long press themselves (`setTakesLongPress`).
146
+ */
147
+ longPressByNativeId = this.contextMenuByNativeId && this.native?.setTakesLongPress !== undefined;
148
+ /**
149
+ * Say whether the view with `nativeID` takes a long press itself: one there then opens no
150
+ * context menu around it.
151
+ */
152
+ setTakesLongPress(nativeID, takes) {
153
+ if (takes)
154
+ this.longPressTakers.add(nativeID);
155
+ else
156
+ this.longPressTakers.delete(nativeID);
157
+ this.native?.setTakesLongPress?.(nativeID, takes);
158
+ }
159
+ /** The `nativeID`s sent with a context menu, and with a long press of their own. */
160
+ withContextMenu = new Set();
161
+ longPressTakers = new Set();
162
+ /**
163
+ * Whether the host opens a context menu on a long press of the view whose `nativeID`s, from it
164
+ * outwards, are `chain`: as it decides, the nearest view with a menu, unless one on the way takes
165
+ * the long press itself. A `(longPress)` around that view leaves the hold to the menu, which the
166
+ * host opens after its own long-press timeout.
167
+ */
168
+ opensContextMenu(chain) {
169
+ for (const nativeID of chain) {
170
+ if (nativeID === null)
171
+ continue;
172
+ if (this.withContextMenu.has(nativeID))
173
+ return true;
174
+ if (this.longPressTakers.has(nativeID))
175
+ return false;
176
+ }
177
+ return false;
178
+ }
179
+ /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */
180
+ contextMenuChoices = new Map();
181
+ /**
182
+ * Send the context menu of the view with `nativeID`, or null to take it away. `choose` runs with
183
+ * the item's `id` where the host sends the choice itself (iOS) rather than through the view.
184
+ */
185
+ setContextMenu(nativeID, entries, choose) {
186
+ if (entries && choose)
187
+ this.contextMenuChoices.set(nativeID, choose);
188
+ else
189
+ this.contextMenuChoices.delete(nativeID);
190
+ if (entries?.length)
191
+ this.withContextMenu.add(nativeID);
192
+ else
193
+ this.withContextMenu.delete(nativeID);
194
+ this.native?.setContextMenu?.(nativeID, entries);
195
+ }
196
+ bars = signal([], /* @ts-ignore */
197
+ ...(ngDevMode ? [{ debugName: "bars" }] : /* istanbul ignore next */ []));
198
+ shortcuts = signal([], /* @ts-ignore */
199
+ ...(ngDevMode ? [{ debugName: "shortcuts" }] : /* istanbul ignore next */ []));
200
+ /** The app's groups, from every `<menu-bar>`, in the order they registered. */
201
+ appGroups = computed(() => this.bars()
202
+ .flatMap((bar) => bar())
203
+ .flatMap((entry) => isSeparator(entry)
204
+ ? []
205
+ : [
206
+ {
207
+ label: entry.label,
208
+ ...(entry.group && { menuRole: entry.group }),
209
+ items: entry.items ?? [],
210
+ },
211
+ ]), /* @ts-ignore */
212
+ ...(ngDevMode ? [{ debugName: "appGroups" }] : /* istanbul ignore next */ []));
213
+ /** The menu bar as it is drawn: the OS's defaults with the app's merged in. */
214
+ menuBar = computed(() => mergeMenuBar(defaultMenuBar(this.native?.appName || 'App'), this.appGroups()), /* @ts-ignore */
215
+ ...(ngDevMode ? [{ debugName: "menuBar" }] : /* istanbul ignore next */ []));
216
+ sentBar = computed(() => {
217
+ const groups = this.menuBar();
218
+ const actions = new Map();
219
+ const sent = groups.map((group, index) => {
220
+ const menu = serializeMenu(group.items, this.os, `${index}.`);
221
+ menu.actions.forEach((action, id) => actions.set(id, action));
222
+ return {
223
+ label: group.label,
224
+ ...(group.menuRole && { menuRole: group.menuRole }),
225
+ items: menu.entries,
226
+ };
227
+ });
228
+ return { sent, actions };
229
+ }, /* @ts-ignore */
230
+ ...(ngDevMode ? [{ debugName: "sentBar" }] : /* istanbul ignore next */ []));
231
+ /**
232
+ * The shortcuts sent to the host: every `[shortcut]`, and where no menu bar is drawn, every
233
+ * menu bar item the app gave a shortcut and a handler, so a hardware keyboard still has them.
234
+ */
235
+ sentShortcuts = computed(() => {
236
+ const presses = new Map();
237
+ const editing = new Set();
238
+ const sent = [];
239
+ const add = (id, shortcut, label, group, press) => {
240
+ presses.set(id, press);
241
+ if (isEditingShortcut(shortcut, this.os))
242
+ editing.add(id);
243
+ sent.push({ id, chord: parseShortcut(shortcut, this.os), label, group });
244
+ };
245
+ this.shortcuts().forEach((one, index) => add(`s${index}`, one.shortcut(), one.label(), this.native?.appName || 'App', one.press));
246
+ if (!this.menuBarShown()) {
247
+ const walk = (entries, group, at) => entries.forEach((entry, index) => {
248
+ if (isSeparator(entry))
249
+ return;
250
+ if (entry.shortcut && entry.select && !entry.disabled) {
251
+ add(`m${at}${index}`, entry.shortcut, entry.label, group, entry.select);
252
+ }
253
+ if (entry.items)
254
+ walk(entry.items, group, `${at}${index}.`);
255
+ });
256
+ this.appGroups().forEach((group, index) => walk(group.items, group.label, `${index}.`));
257
+ }
258
+ return { sent, presses, editing };
259
+ }, /* @ts-ignore */
260
+ ...(ngDevMode ? [{ debugName: "sentShortcuts" }] : /* istanbul ignore next */ []));
261
+ unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;
262
+ constructor() {
263
+ const native = this.native;
264
+ if (!native) {
265
+ // Read for nothing, so a shortcut the app gets wrong throws where there is no host too, and
266
+ // not first on a device that has one.
267
+ effect(() => this.sentShortcuts());
268
+ return;
269
+ }
270
+ effect(() => {
271
+ if (this.menuBarShown())
272
+ native.setMenuBar(this.sentBar().sent);
273
+ });
274
+ effect(() => native.setShortcuts(this.sentShortcuts().sent));
275
+ }
276
+ /**
277
+ * Add a `<menu-bar>`'s groups, each a `MenuItemModel` with `items` and its `group` role. Answers
278
+ * the function that takes them out again, as the `<menu-bar>` goes.
279
+ */
280
+ addMenuBar(groups) {
281
+ this.bars.update((all) => [...all, groups]);
282
+ return () => this.bars.update((all) => all.filter((one) => one !== groups));
283
+ }
284
+ /**
285
+ * Listen for `shortcut`, pressed anywhere in the app: `mod+k`, as `parseShortcut` reads it.
286
+ * `label` is what Android's Keyboard Shortcuts helper lists it as. Answers the function that
287
+ * stops listening.
288
+ */
289
+ addShortcut(shortcut, label, press) {
290
+ const registered = { shortcut, label, press };
291
+ this.shortcuts.update((all) => [...all, registered]);
292
+ return () => this.shortcuts.update((all) => all.filter((one) => one !== registered));
293
+ }
294
+ navigators = new Set();
295
+ /**
296
+ * Hear the OS's back and forward commands. `@ng-native/router` listens, and moves through the
297
+ * history of the window each was in, `steps` entries (one, but for a pick from a chevron's
298
+ * history menu). Answers the function that stops listening.
299
+ */
300
+ onNavigate(listener) {
301
+ this.navigators.add(listener);
302
+ return () => void this.navigators.delete(listener);
303
+ }
304
+ /**
305
+ * Tell the host the history of the window on `surface`, which its toolbar's back and forward
306
+ * chevrons and their menus show. `@ng-native/router` calls it. Does nothing where the host has
307
+ * no chevrons.
308
+ */
309
+ setHistory(surface, history) {
310
+ this.native?.setHistory?.(surface, history);
311
+ }
312
+ hostSaid(event) {
313
+ if (event.type === 'navigate') {
314
+ const steps = event.steps ?? 1;
315
+ this.navigators.forEach((listener) => listener(event.direction, event.surface, steps));
316
+ return;
317
+ }
318
+ if (event.type === 'menuSelect') {
319
+ this.sentBar().actions.get(event.id)?.();
320
+ return;
321
+ }
322
+ if (event.type === 'contextMenuSelect') {
323
+ this.contextMenuChoices.get(event.nativeID)?.(event.id);
324
+ return;
325
+ }
326
+ const { presses, editing } = this.sentShortcuts();
327
+ // The editing keys belong to a focused text input: the app's shortcut on one waits.
328
+ if (event.textInputFocused && editing.has(event.id))
329
+ return;
330
+ presses.get(event.id)?.();
331
+ }
332
+ ngOnDestroy() {
333
+ this.unsubscribe?.();
334
+ }
335
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Menus, deps: [], target: i0.ɵɵFactoryTarget.Service });
336
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: Menus });
337
+ }
338
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Menus, decorators: [{
339
+ type: Service
340
+ }], ctorParameters: () => [] });
341
+ //# sourceMappingURL=menus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menus.js","sourceRoot":"","sources":["../src/menus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GAGb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,GAGd,MAAM,eAAe,CAAC;;AA4BvB,MAAM,SAAS,GAAG,IAAI,OAAO,EAAsB,CAAC;AACpD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,IAAI,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,EAAE,KAAK,SAAS;QAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IACzE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA6B,EAC7B,EAAc,EACd,MAAM,GAAG,EAAE;IAEX,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC9C,MAAM,IAAI,GAAG,CAAC,IAA0B,EAAE,EAAU,EAAqB,EAAE,CACzE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACxB,IAAI,WAAW,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,SAA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CAAC;QACD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAClD,oFAAoF;QACpF,IAAI,KAAK,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAAE,OAAO;QAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAtOU,KAAK;wGAAL,KAAK;;2FAAL,KAAK;kBADjB,OAAO","sourcesContent":["/**\n * Menus and keyboard shortcuts as the host receives them: the menu bar, the shortcuts that are in\n * no menu, and the form a menu takes on its way to native, which a context menu shares.\n *\n * The host contract, on the `NgNativeMenus` module:\n * - `setMenuBar(groups)`: the whole merged menu bar, each time it changes. The desktop host draws\n * it as the main menu, iPadOS through UIMenuBuilder. Each item has an `id`; an item with a\n * `menuRole` and no `id`'s action is the OS's own (Copy, Quit).\n * - `setShortcuts(shortcuts)`: every shortcut the app listens for outside the menu bar, each with\n * its `id`, its chord read for the OS, and a `label` and `group` for Android's Keyboard Shortcuts\n * helper. On iPhone and Android the menu bar's own shortcuts are in it too, since no bar is drawn.\n * - It sends `ngNativeMenus` events on `DeviceEventEmitter`: `{ type: 'menuSelect', id }` for a menu\n * bar item, and `{ type: 'shortcut', id, textInputFocused }` for a chord pressed.\n * - Its constants say whether it draws a menu bar (`menuBar`) and the app's name (`appName`).\n * - On Android it is an Expo module: the constants are properties, it sends the same events through\n * its own `addListener('ngNativeMenus', ...)`, and it has `setContextMenu(nativeID, entries)`,\n * since React Native's Android view drops a `contextMenu` prop it does not know.\n * - On iOS it is a TurboModule with `setContextMenu(nativeID, entries)` too, for the same reason.\n * React Native's iOS view sends no event it does not know either, so the module sends the item\n * chosen as `{ type: 'contextMenuSelect', nativeID, id }`.\n * - Where it draws context menus, `setTakesLongPress(nativeID, takes)` names a view inside one\n * whose own `(longPress)` takes a long press first: a long press there opens no menu around it,\n * as the innermost handler wins in a native app. A right-click still opens the menu on Android.\n * iOS tells a long press from a secondary click only by the gesture, so an iPad pointer's\n * secondary click there opens none either.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n effect,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport {\n defaultMenuBar,\n isSeparator,\n mergeMenuBar,\n type MenuEntry,\n type MenuGroupModel,\n} from './menu-model.ts';\nimport { injectOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\nimport {\n isEditingShortcut,\n navigationShortcut,\n parseShortcut,\n type ParsedShortcut,\n type ShortcutOs,\n} from './shortcut.ts';\n\n/** A menu entry as the host receives it. */\nexport type NativeMenuEntry =\n | { readonly separator: true }\n | {\n readonly id: string;\n readonly label: string;\n readonly menuRole?: string;\n /** On an item with a `menuRole`: the app handles it, and the OS does not. */\n readonly handled?: true;\n readonly shortcut?: ParsedShortcut;\n readonly disabled?: boolean;\n readonly checked?: boolean;\n readonly destructive?: boolean;\n readonly subtitle?: string;\n readonly sfSymbol?: string;\n readonly icon?: string;\n readonly inline?: boolean;\n readonly items?: readonly NativeMenuEntry[];\n };\n\n/** A menu ready for the host, and what each id it was given does. */\nexport interface SerializedMenu {\n readonly entries: NativeMenuEntry[];\n readonly actions: ReadonlyMap<string, () => void>;\n}\n\nconst actionIds = new WeakMap<() => void, string>();\nlet actionsNamed = 0;\n\n/**\n * The id a menu item with `select` is sent under: the same for as long as the handler is, and no\n * other handler's. `<menu-item>` keeps one handler for its life, so a host that reports a choice\n * from a menu it drew before the items changed still runs that item, or nothing once it has gone,\n * never the item that has taken its place.\n */\nexport function menuActionId(select: () => void): string {\n let id = actionIds.get(select);\n if (id === undefined) actionIds.set(select, (id = `a${++actionsNamed}`));\n return id;\n}\n\n/**\n * `entries` as the host takes them: an id for each item, its shortcut read for `os`, and the\n * handlers by id. An item with a handler is named by it (`menuActionId`); one without, which the\n * app never runs, by its place (`2.0.1`).\n */\nexport function serializeMenu(\n entries: readonly MenuEntry[],\n os: ShortcutOs,\n prefix = '',\n): SerializedMenu {\n const actions = new Map<string, () => void>();\n const walk = (list: readonly MenuEntry[], at: string): NativeMenuEntry[] =>\n list.map((entry, index) => {\n if (isSeparator(entry)) return { separator: true };\n const place = `${at}${index}`;\n const { select, shortcut, items, group: _group, ...rest } = entry;\n const id = select ? menuActionId(select) : place;\n if (select) actions.set(id, select);\n return {\n id,\n ...rest,\n // A role item the app handles: the host sends its select rather than doing the role.\n ...(select && entry.menuRole && { handled: true }),\n ...(shortcut\n ? { shortcut: parseShortcut(shortcut, os) }\n : (entry.menuRole === 'back' || entry.menuRole === 'forward') && {\n shortcut: navigationShortcut(entry.menuRole, os),\n }),\n ...(items && { items: walk(items, `${place}.`) }),\n };\n });\n return { entries: walk(entries, prefix), actions };\n}\n\n/** A shortcut as the host receives it. */\nexport interface NativeShortcut {\n readonly id: string;\n readonly chord: ParsedShortcut;\n /** What Android's Keyboard Shortcuts helper lists it as. */\n readonly label: string;\n /** The heading it is listed under there: its menu's label, or the app's name. */\n readonly group: string;\n}\n\nexport type NativeMenuEvent =\n | { readonly type: 'menuSelect'; readonly id: string }\n | { readonly type: 'shortcut'; readonly id: string; readonly textInputFocused?: boolean }\n /** An item chosen in the context menu of the view with `nativeID` (iOS). */\n | { readonly type: 'contextMenuSelect'; readonly nativeID: string; readonly id: string }\n /**\n * Back or forward, from whichever input the OS has for it: View > Back and Forward and their\n * keys, a two-finger swipe, mouse buttons 4 and 5, the toolbar's chevrons and their history\n * menus. `surface` is the window it was in, and `steps` how many entries (one where absent).\n */\n | {\n readonly type: 'navigate';\n readonly direction: 'back' | 'forward';\n readonly surface?: number;\n readonly steps?: number;\n };\n\n/** A window's history as the host draws it: the titles behind and ahead, nearest first. */\nexport interface NativeWindowHistory {\n readonly back: readonly string[];\n readonly forward: readonly string[];\n}\n\n/** The host's menu module. */\nexport interface NativeMenus {\n /** Whether the host draws a menu bar: macOS, and iPadOS. */\n readonly menuBar: boolean;\n readonly appName: string;\n setMenuBar(\n groups: readonly { label: string; menuRole?: string; items: NativeMenuEntry[] }[],\n ): void;\n setShortcuts(shortcuts: readonly NativeShortcut[]): void;\n /** The history of the window on `surface`, for its back and forward chevrons. Desktop only. */\n setHistory?(surface: number, history: NativeWindowHistory): void;\n /**\n * The context menu of the view with `nativeID`, or null to take it away. Android and iOS, whose\n * views read no `contextMenu` prop: the host finds the view by its `nativeID`.\n */\n setContextMenu?(nativeID: string, entries: readonly NativeMenuEntry[] | null): void;\n /**\n * Whether the view with `nativeID` takes a long press itself, so a context menu around it does\n * not open on one there. Android and iOS, beside `setContextMenu`.\n */\n setTakesLongPress?(nativeID: string, takes: boolean): void;\n subscribe(listener: (event: NativeMenuEvent) => void): () => void;\n}\n\ninterface MenusModule {\n getConstants?(): { menuBar?: boolean; appName?: string };\n /** An Expo module's constants, which are its properties. */\n readonly menuBar?: boolean;\n readonly appName?: string;\n setMenuBar?(groups: unknown): void;\n setShortcuts?(shortcuts: unknown): void;\n setHistory?(surface: number, history: unknown): void;\n setContextMenu?(nativeID: string, entries: unknown): void;\n setTakesLongPress?(nativeID: string, takes: boolean): void;\n /** An Expo module's own events. */\n addListener?(event: string, listener: (event: unknown) => void): { remove(): void };\n}\n\n/** Android's `NgNativeMenus`, an Expo module, where React Native has no TurboModule of the name. */\nfunction expoMenusModule(): MenusModule | undefined {\n const modules = (globalThis as { expo?: { modules?: Record<string, unknown> } }).expo?.modules;\n return modules?.['NgNativeMenus'] as MenusModule | undefined;\n}\n\n/**\n * The host's menu module: a TurboModule (the desktop host, iOS), or else Android's Expo module.\n * Null where there is neither, as in Expo Go.\n */\nexport function menusSource(): NativeMenus | null {\n const native = reactNative();\n const turbo = native?.TurboModuleRegistry?.get?.('NgNativeMenus') as\n MenusModule | null | undefined;\n const expo = turbo ? undefined : expoMenusModule();\n const module = turbo ?? expo;\n if (!module) return null;\n const constants = module.getConstants?.() ?? module;\n // An Expo module sends its events itself; a TurboModule's come through DeviceEventEmitter.\n const listen = (hear: (event: unknown) => void) =>\n expo\n ? expo.addListener?.('ngNativeMenus', hear)\n : native?.DeviceEventEmitter?.addListener('ngNativeMenus', hear);\n return {\n menuBar: constants.menuBar === true,\n appName: constants.appName ?? '',\n setMenuBar: (groups) => module.setMenuBar?.(groups),\n setShortcuts: (shortcuts) => module.setShortcuts?.(shortcuts),\n setHistory: (surface, history) => module.setHistory?.(surface, history),\n ...contextMenuMethods(module),\n subscribe: (listener) => {\n const subscription = listen((event) => listener(event as NativeMenuEvent));\n return () => subscription?.remove();\n },\n };\n}\n\n/** The context menu methods a module has, bound, and none it lacks: a host without them reads props. */\nfunction contextMenuMethods(\n module: MenusModule,\n): Pick<NativeMenus, 'setContextMenu' | 'setTakesLongPress'> {\n const setContextMenu = module.setContextMenu?.bind(module);\n const setTakesLongPress = module.setTakesLongPress?.bind(module);\n return {\n ...(setContextMenu && { setContextMenu }),\n ...(setTakesLongPress && { setTakesLongPress }),\n };\n}\n\n/** The `ShortcutOs` an `OS` reads shortcuts as. */\nconst shortcutOs = (os: string): ShortcutOs =>\n os === 'android' || os === 'macos' || os === 'web' ? os : 'ios';\n\n/** A `[shortcut]` registered with `KeyboardShortcuts`. */\ninterface Registered {\n readonly shortcut: Signal<string>;\n readonly label: Signal<string>;\n readonly press: () => void;\n}\n\n/**\n * The menus and shortcuts an app has, sent to the host as they change. `<menu-bar>` and\n * `[shortcut]` in `@ng-native/components` register here; an app rarely injects it.\n */\n@Service()\nexport class Menus {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeMenus | null>('angular-native.menusSource', {\n factory: menusSource,\n });\n\n private readonly native = inject(Menus.SOURCE);\n private readonly os = shortcutOs(injectOs());\n\n /** Whether the host has the module: shortcuts from a hardware keyboard, and menus. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n /** Whether the menu bar is drawn: macOS and iPadOS. Elsewhere its shortcuts still work. */\n readonly menuBarShown: Signal<boolean> = signal(this.native?.menuBar === true).asReadonly();\n\n /**\n * Whether the host takes a `[contextMenu]` by the view's `nativeID` through `setContextMenu`\n * (Android and iOS) rather than as the view's `contextMenu` prop. Where it does, it draws the\n * menu on a long press.\n */\n readonly contextMenuByNativeId: boolean = this.native?.setContextMenu !== undefined;\n\n /**\n * Whether the host, which draws context menus on a long press, can be told which views inside\n * one take a long press themselves (`setTakesLongPress`).\n */\n readonly longPressByNativeId: boolean =\n this.contextMenuByNativeId && this.native?.setTakesLongPress !== undefined;\n\n /**\n * Say whether the view with `nativeID` takes a long press itself: one there then opens no\n * context menu around it.\n */\n setTakesLongPress(nativeID: string, takes: boolean): void {\n if (takes) this.longPressTakers.add(nativeID);\n else this.longPressTakers.delete(nativeID);\n this.native?.setTakesLongPress?.(nativeID, takes);\n }\n\n /** The `nativeID`s sent with a context menu, and with a long press of their own. */\n private readonly withContextMenu = new Set<string>();\n private readonly longPressTakers = new Set<string>();\n\n /**\n * Whether the host opens a context menu on a long press of the view whose `nativeID`s, from it\n * outwards, are `chain`: as it decides, the nearest view with a menu, unless one on the way takes\n * the long press itself. A `(longPress)` around that view leaves the hold to the menu, which the\n * host opens after its own long-press timeout.\n */\n opensContextMenu(chain: Iterable<string | null>): boolean {\n for (const nativeID of chain) {\n if (nativeID === null) continue;\n if (this.withContextMenu.has(nativeID)) return true;\n if (this.longPressTakers.has(nativeID)) return false;\n }\n return false;\n }\n\n /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */\n private readonly contextMenuChoices = new Map<string, (id: string) => void>();\n\n /**\n * Send the context menu of the view with `nativeID`, or null to take it away. `choose` runs with\n * the item's `id` where the host sends the choice itself (iOS) rather than through the view.\n */\n setContextMenu(\n nativeID: string,\n entries: readonly NativeMenuEntry[] | null,\n choose?: (id: string) => void,\n ): void {\n if (entries && choose) this.contextMenuChoices.set(nativeID, choose);\n else this.contextMenuChoices.delete(nativeID);\n if (entries?.length) this.withContextMenu.add(nativeID);\n else this.withContextMenu.delete(nativeID);\n this.native?.setContextMenu?.(nativeID, entries);\n }\n\n private readonly bars = signal<readonly Signal<readonly MenuEntry[]>[]>([]);\n private readonly shortcuts = signal<readonly Registered[]>([]);\n\n /** The app's groups, from every `<menu-bar>`, in the order they registered. */\n private readonly appGroups = computed<MenuGroupModel[]>(() =>\n this.bars()\n .flatMap((bar) => bar())\n .flatMap((entry) =>\n isSeparator(entry)\n ? []\n : [\n {\n label: entry.label,\n ...(entry.group && { menuRole: entry.group }),\n items: entry.items ?? [],\n },\n ],\n ),\n );\n\n /** The menu bar as it is drawn: the OS's defaults with the app's merged in. */\n readonly menuBar: Signal<MenuGroupModel[]> = computed(() =>\n mergeMenuBar(defaultMenuBar(this.native?.appName || 'App'), this.appGroups()),\n );\n\n private readonly sentBar = computed(() => {\n const groups = this.menuBar();\n const actions = new Map<string, () => void>();\n const sent = groups.map((group, index) => {\n const menu = serializeMenu(group.items, this.os, `${index}.`);\n menu.actions.forEach((action, id) => actions.set(id, action));\n return {\n label: group.label,\n ...(group.menuRole && { menuRole: group.menuRole }),\n items: menu.entries,\n };\n });\n return { sent, actions };\n });\n\n /**\n * The shortcuts sent to the host: every `[shortcut]`, and where no menu bar is drawn, every\n * menu bar item the app gave a shortcut and a handler, so a hardware keyboard still has them.\n */\n private readonly sentShortcuts = computed(() => {\n const presses = new Map<string, () => void>();\n const editing = new Set<string>();\n const sent: NativeShortcut[] = [];\n const add = (id: string, shortcut: string, label: string, group: string, press: () => void) => {\n presses.set(id, press);\n if (isEditingShortcut(shortcut, this.os)) editing.add(id);\n sent.push({ id, chord: parseShortcut(shortcut, this.os), label, group });\n };\n this.shortcuts().forEach((one, index) =>\n add(`s${index}`, one.shortcut(), one.label(), this.native?.appName || 'App', one.press),\n );\n if (!this.menuBarShown()) {\n const walk = (entries: readonly MenuEntry[], group: string, at: string) =>\n entries.forEach((entry, index) => {\n if (isSeparator(entry)) return;\n if (entry.shortcut && entry.select && !entry.disabled) {\n add(`m${at}${index}`, entry.shortcut, entry.label, group, entry.select);\n }\n if (entry.items) walk(entry.items, group, `${at}${index}.`);\n });\n this.appGroups().forEach((group, index) => walk(group.items, group.label, `${index}.`));\n }\n return { sent, presses, editing };\n });\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n constructor() {\n const native = this.native;\n if (!native) {\n // Read for nothing, so a shortcut the app gets wrong throws where there is no host too, and\n // not first on a device that has one.\n effect(() => this.sentShortcuts());\n return;\n }\n effect(() => {\n if (this.menuBarShown()) native.setMenuBar(this.sentBar().sent);\n });\n effect(() => native.setShortcuts(this.sentShortcuts().sent));\n }\n\n /**\n * Add a `<menu-bar>`'s groups, each a `MenuItemModel` with `items` and its `group` role. Answers\n * the function that takes them out again, as the `<menu-bar>` goes.\n */\n addMenuBar(groups: Signal<readonly MenuEntry[]>): () => void {\n this.bars.update((all) => [...all, groups]);\n return () => this.bars.update((all) => all.filter((one) => one !== groups));\n }\n\n /**\n * Listen for `shortcut`, pressed anywhere in the app: `mod+k`, as `parseShortcut` reads it.\n * `label` is what Android's Keyboard Shortcuts helper lists it as. Answers the function that\n * stops listening.\n */\n addShortcut(shortcut: Signal<string>, label: Signal<string>, press: () => void): () => void {\n const registered: Registered = { shortcut, label, press };\n this.shortcuts.update((all) => [...all, registered]);\n return () => this.shortcuts.update((all) => all.filter((one) => one !== registered));\n }\n\n private readonly navigators = new Set<\n (direction: 'back' | 'forward', surface?: number, steps?: number) => void\n >();\n\n /**\n * Hear the OS's back and forward commands. `@ng-native/router` listens, and moves through the\n * history of the window each was in, `steps` entries (one, but for a pick from a chevron's\n * history menu). Answers the function that stops listening.\n */\n onNavigate(\n listener: (direction: 'back' | 'forward', surface?: number, steps?: number) => void,\n ): () => void {\n this.navigators.add(listener);\n return () => void this.navigators.delete(listener);\n }\n\n /**\n * Tell the host the history of the window on `surface`, which its toolbar's back and forward\n * chevrons and their menus show. `@ng-native/router` calls it. Does nothing where the host has\n * no chevrons.\n */\n setHistory(surface: number, history: NativeWindowHistory): void {\n this.native?.setHistory?.(surface, history);\n }\n\n private hostSaid(event: NativeMenuEvent): void {\n if (event.type === 'navigate') {\n const steps = event.steps ?? 1;\n this.navigators.forEach((listener) => listener(event.direction, event.surface, steps));\n return;\n }\n if (event.type === 'menuSelect') {\n this.sentBar().actions.get(event.id)?.();\n return;\n }\n if (event.type === 'contextMenuSelect') {\n this.contextMenuChoices.get(event.nativeID)?.(event.id);\n return;\n }\n const { presses, editing } = this.sentShortcuts();\n // The editing keys belong to a focused text input: the app's shortcut on one waits.\n if (event.textInputFocused && editing.has(event.id)) return;\n presses.get(event.id)?.();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
@@ -1,15 +1,3 @@
1
- /**
2
- * Android's navigation bar: the colour of its buttons, and whether it is there at all.
3
- *
4
- * The same stack of claims as `StatusBar`, so a video player can hide the bar while it is open and
5
- * the screen behind gets the bar back when it closes. `style: 'auto'` follows `ColorScheme`, a
6
- * theme the app sets included, and a fixed style holds through a scheme change.
7
- *
8
- * Driven through `expo-navigation-bar`'s native module, reached by name so nothing here imports the
9
- * package. Expo Go carries it; a development build has it once the app installs
10
- * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept
11
- * but changes nothing.
12
- */
13
1
  import { InjectionToken, type Signal } from '@angular/core';
14
2
  import * as i0 from "@angular/core";
15
3
  /**
@@ -45,6 +33,8 @@ export declare class NavigationBar {
45
33
  /** Overridden in a test to watch the bar without one on screen. */
46
34
  static readonly SOURCE: InjectionToken<NavigationBarSource>;
47
35
  private readonly source;
36
+ /** Whether there is a navigation bar to style: on Android alone. */
37
+ readonly available: Signal<boolean>;
48
38
  /** This app, among the apps claiming the bar: its scheme is what an `auto` style it claims follows. */
49
39
  private readonly owner;
50
40
  /** Every app's claims on this bar: the window is the runtime's, not an app's. */
@@ -10,7 +10,8 @@
10
10
  * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept
11
11
  * but changes nothing.
12
12
  */
13
- import { DestroyRef, InjectionToken, Service, computed, inject, untracked, } from '@angular/core';
13
+ import { injectOs } from "./os.js";
14
+ import { DestroyRef, InjectionToken, Service, computed, inject, untracked, signal, } from '@angular/core';
14
15
  import { ColorScheme } from "./color-scheme.js";
15
16
  import { mergeClaims } from "./merge-claims.js";
16
17
  import { reactNative } from "./react-native.js";
@@ -43,6 +44,8 @@ export class NavigationBar {
43
44
  /** Overridden in a test to watch the bar without one on screen. */
44
45
  static SOURCE = new InjectionToken('angular-native.navigationBarSource', { factory: navigationBarSource });
45
46
  source = inject(NavigationBar.SOURCE);
47
+ /** Whether there is a navigation bar to style: on Android alone. */
48
+ available = signal(injectOs() === 'android').asReadonly();
46
49
  /** This app, among the apps claiming the bar: its scheme is what an `auto` style it claims follows. */
47
50
  owner = { scheme: inject(ColorScheme) };
48
51
  /** Every app's claims on this bar: the window is the runtime's, not an app's. */
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-bar.js","sourceRoot":"","sources":["../src/navigation-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,GAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;;AAmCjF,MAAM,IAAI,GAAwB,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;AAE9E,MAAM,UAAU,mBAAmB;IACjC,yDAAyD;IACzD,IAAI,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,SAAS;QAAE,OAAO,EAAE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CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,yFAAyF;AACzF,SAAS,OAAO,CAAC,KAAyB,EAAE,MAAc;IACxD,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Android's navigation bar: the colour of its buttons, and whether it is there at all.\n *\n * The same stack of claims as `StatusBar`, so a video player can hide the bar while it is open and\n * the screen behind gets the bar back when it closes. `style: 'auto'` follows `ColorScheme`, a\n * theme the app sets included, and a fixed style holds through a scheme change.\n *\n * Driven through `expo-navigation-bar`'s native module, reached by name so nothing here imports the\n * package. Expo Go carries it; a development build has it once the app installs\n * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept\n * but changes nothing.\n */\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n untracked,\n type Signal,\n} from '@angular/core';\nimport { ColorScheme, type Scheme } from './color-scheme.ts';\nimport { mergeClaims } from './merge-claims.ts';\nimport { reactNative } from './react-native.ts';\nimport { WindowClaims, onWindowFront, sharedBySource } from './window-claims.ts';\n\n/**\n * The colour of the bar's buttons. `dark` is dark buttons, for a light screen behind them, and\n * `light` light ones, as `StatusBarStyle` names its text. `auto` is dark buttons in the light\n * colour scheme and light ones in the dark one, and follows `ColorScheme`.\n */\nexport type NavigationBarStyle = 'light' | 'dark' | 'auto';\n\n/** What a claim asks for. Anything absent is left as whatever the claim underneath said. */\nexport interface NavigationBarState {\n readonly style?: NavigationBarStyle;\n /** Hide the bar until a swipe from the edge of the screen shows it for a moment. */\n readonly hidden?: boolean;\n}\n\n/** Where the bar actually is. A fake stands in for the platform in tests. */\nexport interface NavigationBarSource {\n setStyle(style: Exclude<NavigationBarStyle, 'auto'>): void;\n setHidden(hidden: boolean): void;\n /**\n * react-native-screens shows or hides the bar each time a screen appears, from that screen's own\n * `navigationBarHidden`, once any screen has set one. So a hidden claim rides on every screen too.\n */\n readonly screensSetBar?: boolean;\n /** Calls `listener` when a window comes to the front, to be given the whole bar again. */\n onWindowFront?(listener: () => void): () => void;\n}\n\n/** `expo-navigation-bar`'s native module, as much of it as this uses. */\ninterface NativeNavigationBar {\n setStyle?(style: 'light' | 'dark'): Promise<void>;\n setHidden?(hidden: boolean): Promise<void>;\n}\n\nconst NONE: NavigationBarSource = { setStyle: () => {}, setHidden: () => {} };\n\nexport function navigationBarSource(): NavigationBarSource {\n // Copies: with no bar to share, each app claims its own.\n if (reactNative()?.Platform?.OS !== 'android') return { ...NONE };\n const modules = (globalThis as { expo?: { modules?: Record<string, unknown> } }).expo?.modules;\n const native = modules?.['ExpoNavigationBar'] as NativeNavigationBar | undefined;\n // Without the module a claim changes nothing, so it does not ride on the screens either, where\n // react-native-screens would hide the bar the next time one appears.\n if (!native) return { ...NONE };\n // One per module, so every app the runtime mounts claims the same bar.\n return sharedBySource(navigationBarSource, native, () => ({\n setStyle: (style) => void native.setStyle?.(style)?.catch(() => {}),\n setHidden: (hidden) => void native.setHidden?.(hidden)?.catch(() => {}),\n screensSetBar: true,\n onWindowFront,\n }));\n}\n\n/**\n * A stack, not a setter, for the same reason as `StatusBar`'s: whatever hid the bar has to give it\n * back to whatever was there before. `push` returns the function that drops the claim.\n */\n@Service()\nexport class NavigationBar {\n /** Overridden in a test to watch the bar without one on screen. */\n static readonly SOURCE = new InjectionToken<NavigationBarSource>(\n 'angular-native.navigationBarSource',\n { factory: navigationBarSource },\n );\n\n private readonly source = inject(NavigationBar.SOURCE);\n /** This app, among the apps claiming the bar: its scheme is what an `auto` style it claims follows. */\n private readonly owner: Owner = { scheme: inject(ColorScheme) };\n /** Every app's claims on this bar: the window is the runtime's, not an app's. */\n private readonly window = sharedBySource(\n NavigationBarWindow,\n this.source,\n () => new NavigationBarWindow(this.source),\n );\n\n /** What is actually showing: every claim in order, later ones winning per property. */\n readonly state: Signal<NavigationBarState> = this.window.state;\n\n /**\n * What a screen with no `navigationBarHidden` of its own carries, so the claim still holds when\n * it appears. Empty but on Android. The router passes it on.\n */\n readonly forScreens: Signal<{ readonly hidden?: boolean }> = computed(() =>\n this.source.screensSetBar ? { hidden: this.state().hidden } : {},\n );\n\n constructor() {\n // Straight from the source, as `StatusBar` does, so the buttons change in the same turn as the\n // scheme.\n const stop = inject(ColorScheme.SOURCE).subscribe((scheme) =>\n this.window.schemeChanged(this.owner, scheme),\n );\n inject(DestroyRef).onDestroy(() => {\n stop();\n // An app that goes takes its claims with it, and leaves the bar to the apps still here.\n this.window.claims.drop(this.owner);\n this.window.apply();\n });\n }\n\n /** The base claim, for an app that sets the bar once at startup. */\n set(state: NavigationBarState): void {\n this.window.claims.setBase(this.owner, state);\n this.window.apply();\n }\n\n /** A claim on top of whatever is there. Call the returned function to drop it. */\n push(state: NavigationBarState): () => void {\n const drop = this.window.claims.push(this.owner, { ...state });\n this.window.apply();\n return () => {\n drop();\n this.window.apply();\n };\n }\n}\n\ninterface Owner {\n readonly scheme: ColorScheme;\n}\n\n/** The bar, as every app on one source claims it. */\nclass NavigationBarWindow {\n readonly claims = new WindowClaims<NavigationBarState, Owner>();\n readonly state: Signal<NavigationBarState> = computed(() =>\n mergeClaims(this.claims.all().map((claim) => claim.value)),\n );\n\n /** The properties a claim has had the platform change, which no claim names any more. */\n private readonly changed = new Set<keyof NavigationBarState>();\n\n /** Whether a claim has ever set the style, after which an unclaimed bar follows the scheme. */\n private styled = false;\n\n private readonly source: NavigationBarSource;\n\n constructor(source: NavigationBarSource) {\n this.source = source;\n // Lives as long as the source, which is the runtime's.\n source.onWindowFront?.(() => this.apply(true));\n }\n\n /**\n * Android puts the buttons back to the new scheme's own on a scheme change, so a fixed style is\n * sent again too. A bar no style claim names any more is `auto`, once one has named a style, and\n * follows the scheme the listener heard.\n */\n schemeChanged(owner: Owner, scheme: Scheme): void {\n const claimed = untracked(() => this.styleOwner());\n if (claimed && claimed.owner !== owner) return;\n const style = claimed?.style ?? (this.styled ? 'auto' : undefined);\n if (style !== undefined) this.source.setStyle(resolve(style, scheme));\n }\n\n /**\n * Push the merged state at the platform. A property the last claim to name it has dropped goes\n * back, once: the style to `auto`, which then keeps following the scheme, and the bar to shown.\n * A window come to the front is given what is claimed, and an `auto` style once one was named.\n */\n apply(front = false): void {\n const { style, hidden } = untracked(this.state);\n if (this.changes('style', style) || (front && this.styled)) {\n this.styled = true;\n this.source.setStyle(\n resolve(\n style ?? 'auto',\n untracked(() => this.scheme()),\n ),\n );\n }\n if (this.changes('hidden', hidden)) this.source.setHidden(hidden ?? false);\n }\n\n /** The scheme of the app whose style is in force, or of the app that claimed last. */\n private scheme(): Scheme {\n const owner = this.styleOwner()?.owner ?? this.claims.owners().at(-1);\n return owner?.scheme.current() ?? 'light';\n }\n\n /** The style in force and the app whose claim it is. */\n private styleOwner(): { style: NavigationBarStyle; owner: Owner } | undefined {\n const claim = this.claims.last((state) => state.style !== undefined);\n return claim && { style: claim.value.style!, owner: claim.owner };\n }\n\n private changes(property: keyof NavigationBarState, value: unknown): boolean {\n if (value === undefined) return this.changed.delete(property);\n this.changed.add(property);\n return true;\n }\n}\n\n/** Dark buttons on the light scheme's light background, light ones on the dark one's. */\nfunction resolve(style: NavigationBarStyle, scheme: Scheme): 'light' | 'dark' {\n if (style !== 'auto') return style;\n return scheme === 'dark' ? 'light' : 'dark';\n}\n"]}
1
+ {"version":3,"file":"navigation-bar.js","sourceRoot":"","sources":["../src/navigation-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EAET,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAm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C,CAAC;IAED,wDAAwD;IAChD,UAAU;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QACrE,OAAO,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACpE,CAAC;IAEO,OAAO,CAAC,QAAkC,EAAE,KAAc;QAChE,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,yFAAyF;AACzF,SAAS,OAAO,CAAC,KAAyB,EAAE,MAAc;IACxD,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Android's navigation bar: the colour of its buttons, and whether it is there at all.\n *\n * The same stack of claims as `StatusBar`, so a video player can hide the bar while it is open and\n * the screen behind gets the bar back when it closes. `style: 'auto'` follows `ColorScheme`, a\n * theme the app sets included, and a fixed style holds through a scheme change.\n *\n * Driven through `expo-navigation-bar`'s native module, reached by name so nothing here imports the\n * package. Expo Go carries it; a development build has it once the app installs\n * `expo-navigation-bar`. Without it, and on iOS, which has no navigation bar, every claim is kept\n * but changes nothing.\n */\nimport { injectOs } from './os.ts';\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n untracked,\n type Signal,\n signal,\n} from '@angular/core';\nimport { ColorScheme, type Scheme } from './color-scheme.ts';\nimport { mergeClaims } from './merge-claims.ts';\nimport { reactNative } from './react-native.ts';\nimport { WindowClaims, onWindowFront, sharedBySource } from './window-claims.ts';\n\n/**\n * The colour of the bar's buttons. `dark` is dark buttons, for a light screen behind them, and\n * `light` light ones, as `StatusBarStyle` names its text. `auto` is dark buttons in the light\n * colour scheme and light ones in the dark one, and follows `ColorScheme`.\n */\nexport type NavigationBarStyle = 'light' | 'dark' | 'auto';\n\n/** What a claim asks for. Anything absent is left as whatever the claim underneath said. */\nexport interface NavigationBarState {\n readonly style?: NavigationBarStyle;\n /** Hide the bar until a swipe from the edge of the screen shows it for a moment. */\n readonly hidden?: boolean;\n}\n\n/** Where the bar actually is. A fake stands in for the platform in tests. */\nexport interface NavigationBarSource {\n setStyle(style: Exclude<NavigationBarStyle, 'auto'>): void;\n setHidden(hidden: boolean): void;\n /**\n * react-native-screens shows or hides the bar each time a screen appears, from that screen's own\n * `navigationBarHidden`, once any screen has set one. So a hidden claim rides on every screen too.\n */\n readonly screensSetBar?: boolean;\n /** Calls `listener` when a window comes to the front, to be given the whole bar again. */\n onWindowFront?(listener: () => void): () => void;\n}\n\n/** `expo-navigation-bar`'s native module, as much of it as this uses. */\ninterface NativeNavigationBar {\n setStyle?(style: 'light' | 'dark'): Promise<void>;\n setHidden?(hidden: boolean): Promise<void>;\n}\n\nconst NONE: NavigationBarSource = { setStyle: () => {}, setHidden: () => {} };\n\nexport function navigationBarSource(): NavigationBarSource {\n // Copies: with no bar to share, each app claims its own.\n if (reactNative()?.Platform?.OS !== 'android') return { ...NONE };\n const modules = (globalThis as { expo?: { modules?: Record<string, unknown> } }).expo?.modules;\n const native = modules?.['ExpoNavigationBar'] as NativeNavigationBar | undefined;\n // Without the module a claim changes nothing, so it does not ride on the screens either, where\n // react-native-screens would hide the bar the next time one appears.\n if (!native) return { ...NONE };\n // One per module, so every app the runtime mounts claims the same bar.\n return sharedBySource(navigationBarSource, native, () => ({\n setStyle: (style) => void native.setStyle?.(style)?.catch(() => {}),\n setHidden: (hidden) => void native.setHidden?.(hidden)?.catch(() => {}),\n screensSetBar: true,\n onWindowFront,\n }));\n}\n\n/**\n * A stack, not a setter, for the same reason as `StatusBar`'s: whatever hid the bar has to give it\n * back to whatever was there before. `push` returns the function that drops the claim.\n */\n@Service()\nexport class NavigationBar {\n /** Overridden in a test to watch the bar without one on screen. */\n static readonly SOURCE = new InjectionToken<NavigationBarSource>(\n 'angular-native.navigationBarSource',\n { factory: navigationBarSource },\n );\n\n private readonly source = inject(NavigationBar.SOURCE);\n\n /** Whether there is a navigation bar to style: on Android alone. */\n readonly available: Signal<boolean> = signal(injectOs() === 'android').asReadonly();\n /** This app, among the apps claiming the bar: its scheme is what an `auto` style it claims follows. */\n private readonly owner: Owner = { scheme: inject(ColorScheme) };\n /** Every app's claims on this bar: the window is the runtime's, not an app's. */\n private readonly window = sharedBySource(\n NavigationBarWindow,\n this.source,\n () => new NavigationBarWindow(this.source),\n );\n\n /** What is actually showing: every claim in order, later ones winning per property. */\n readonly state: Signal<NavigationBarState> = this.window.state;\n\n /**\n * What a screen with no `navigationBarHidden` of its own carries, so the claim still holds when\n * it appears. Empty but on Android. The router passes it on.\n */\n readonly forScreens: Signal<{ readonly hidden?: boolean }> = computed(() =>\n this.source.screensSetBar ? { hidden: this.state().hidden } : {},\n );\n\n constructor() {\n // Straight from the source, as `StatusBar` does, so the buttons change in the same turn as the\n // scheme.\n const stop = inject(ColorScheme.SOURCE).subscribe((scheme) =>\n this.window.schemeChanged(this.owner, scheme),\n );\n inject(DestroyRef).onDestroy(() => {\n stop();\n // An app that goes takes its claims with it, and leaves the bar to the apps still here.\n this.window.claims.drop(this.owner);\n this.window.apply();\n });\n }\n\n /** The base claim, for an app that sets the bar once at startup. */\n set(state: NavigationBarState): void {\n this.window.claims.setBase(this.owner, state);\n this.window.apply();\n }\n\n /** A claim on top of whatever is there. Call the returned function to drop it. */\n push(state: NavigationBarState): () => void {\n const drop = this.window.claims.push(this.owner, { ...state });\n this.window.apply();\n return () => {\n drop();\n this.window.apply();\n };\n }\n}\n\ninterface Owner {\n readonly scheme: ColorScheme;\n}\n\n/** The bar, as every app on one source claims it. */\nclass NavigationBarWindow {\n readonly claims = new WindowClaims<NavigationBarState, Owner>();\n readonly state: Signal<NavigationBarState> = computed(() =>\n mergeClaims(this.claims.all().map((claim) => claim.value)),\n );\n\n /** The properties a claim has had the platform change, which no claim names any more. */\n private readonly changed = new Set<keyof NavigationBarState>();\n\n /** Whether a claim has ever set the style, after which an unclaimed bar follows the scheme. */\n private styled = false;\n\n private readonly source: NavigationBarSource;\n\n constructor(source: NavigationBarSource) {\n this.source = source;\n // Lives as long as the source, which is the runtime's.\n source.onWindowFront?.(() => this.apply(true));\n }\n\n /**\n * Android puts the buttons back to the new scheme's own on a scheme change, so a fixed style is\n * sent again too. A bar no style claim names any more is `auto`, once one has named a style, and\n * follows the scheme the listener heard.\n */\n schemeChanged(owner: Owner, scheme: Scheme): void {\n const claimed = untracked(() => this.styleOwner());\n if (claimed && claimed.owner !== owner) return;\n const style = claimed?.style ?? (this.styled ? 'auto' : undefined);\n if (style !== undefined) this.source.setStyle(resolve(style, scheme));\n }\n\n /**\n * Push the merged state at the platform. A property the last claim to name it has dropped goes\n * back, once: the style to `auto`, which then keeps following the scheme, and the bar to shown.\n * A window come to the front is given what is claimed, and an `auto` style once one was named.\n */\n apply(front = false): void {\n const { style, hidden } = untracked(this.state);\n if (this.changes('style', style) || (front && this.styled)) {\n this.styled = true;\n this.source.setStyle(\n resolve(\n style ?? 'auto',\n untracked(() => this.scheme()),\n ),\n );\n }\n if (this.changes('hidden', hidden)) this.source.setHidden(hidden ?? false);\n }\n\n /** The scheme of the app whose style is in force, or of the app that claimed last. */\n private scheme(): Scheme {\n const owner = this.styleOwner()?.owner ?? this.claims.owners().at(-1);\n return owner?.scheme.current() ?? 'light';\n }\n\n /** The style in force and the app whose claim it is. */\n private styleOwner(): { style: NavigationBarStyle; owner: Owner } | undefined {\n const claim = this.claims.last((state) => state.style !== undefined);\n return claim && { style: claim.value.style!, owner: claim.owner };\n }\n\n private changes(property: keyof NavigationBarState, value: unknown): boolean {\n if (value === undefined) return this.changed.delete(property);\n this.changed.add(property);\n return true;\n }\n}\n\n/** Dark buttons on the light scheme's light background, light ones on the dark one's. */\nfunction resolve(style: NavigationBarStyle, scheme: Scheme): 'light' | 'dark' {\n if (style !== 'auto') return style;\n return scheme === 'dark' ? 'light' : 'dark';\n}\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * What each desktop API and each macOS-only input does on each OS: the one source the support
3
+ * table on the documentation site is drawn from, and that `os-support.test.ts` holds the code to.
4
+ *
5
+ * A cell is `yes`; `absent`, where `available()` is false and every call is inert; `ignored`, where
6
+ * the input has no effect; `inert`, where an element draws nothing and calls nothing; or a few
7
+ * words on what the OS does instead. It has no imports, so a build script can read it.
8
+ */
9
+ /** The OSes the table has a column for, iPadOS and iPhone apart. */
10
+ export type SupportOs = 'macos' | 'ipados' | 'iphone' | 'android' | 'web';
11
+ export interface OsSupportRow {
12
+ /** The row's name in the table, as Markdown. */
13
+ readonly feature: string;
14
+ /**
15
+ * What the row covers: exported classes and functions, inputs by name, and events as
16
+ * `(dblclick)`. Every one exists.
17
+ */
18
+ readonly covers: readonly string[];
19
+ /**
20
+ * The services whose `available()` follows the row, each with the host module it is made from:
21
+ * true where the row is not `absent` and the module is there, false where it is `absent`.
22
+ */
23
+ readonly services?: Readonly<Record<string, string>>;
24
+ /**
25
+ * Services with no host module of their own, whose `available()` follows the row: absent where the
26
+ * row says `absent`, which `every-service.test.ts` checks call by call.
27
+ */
28
+ readonly inert?: readonly string[];
29
+ /** The services have no `available()`, such as a view: where absent, the row says only that. */
30
+ readonly withoutAvailable?: true;
31
+ readonly on: Readonly<Record<SupportOs, string>>;
32
+ }
33
+ export declare const SUPPORT_OSES: Readonly<Record<SupportOs, string>>;
34
+ export declare const OS_SUPPORT: readonly OsSupportRow[];
35
+ /** The row a service's `available()` follows, or undefined where the table has none for it. */
36
+ export declare function supportRowOf(service: string): OsSupportRow | undefined;
37
+ /**
38
+ * One line for a service's documentation page, drawn from its row: where it is available, with
39
+ * the row's words where it is not a plain `yes`, and where it is absent. The documentation site
40
+ * writes it under `<!-- platforms: Service -->`, so the page cannot disagree with the table.
41
+ */
42
+ export declare function platformsLine(service: string): string | undefined;