@ng-native/device 0.22.1 → 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/dock.js ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The app's Dock icon on macOS: a menu of the app's own above the standard one, and a bounce that
3
+ * asks for attention. Its badge is the Notifications badge count, from `@ng-native/expo`'s
4
+ * `Notifications.setBadge`, as an app icon's badge is on iOS. Absent on every other OS, where each
5
+ * call does nothing.
6
+ *
7
+ * The host contract, on the `NgNativeDock` module: `setMenu(entries)` takes the menu as
8
+ * `serializeMenu` makes it, or null for none; `bounce(critical)` answers an id that
9
+ * `cancelBounce(id)` takes; `{ type: 'menuSelect', id }` arrives on `ngNativeDock`.
10
+ */
11
+ import { InjectionToken, Service, inject, signal } from '@angular/core';
12
+ import { serializeMenu } from "./menus.js";
13
+ import { reactNative } from "./react-native.js";
14
+ import * as i0 from "@angular/core";
15
+ function dockSource() {
16
+ const native = reactNative();
17
+ const module = native?.TurboModuleRegistry?.get?.('NgNativeDock');
18
+ if (!module)
19
+ return null;
20
+ return {
21
+ setMenu: (entries) => module.setMenu?.(entries),
22
+ bounce: (critical) => module.bounce?.(critical) ?? -1,
23
+ cancelBounce: (id) => module.cancelBounce?.(id),
24
+ subscribe: (listener) => {
25
+ const subscription = native?.DeviceEventEmitter?.addListener('ngNativeDock', (event) => listener(event));
26
+ return () => subscription?.remove();
27
+ },
28
+ };
29
+ }
30
+ export class Dock {
31
+ /** Overridden in a test with a fake host. */
32
+ static SOURCE = new InjectionToken('angular-native.dockSource', {
33
+ factory: dockSource,
34
+ });
35
+ native = inject(Dock.SOURCE);
36
+ actions = new Map();
37
+ unsubscribe = this.native?.subscribe((event) => this.actions.get(event.id)?.()) ?? null;
38
+ /** Whether the app has a Dock icon: macOS. */
39
+ available = signal(this.native !== null).asReadonly();
40
+ /**
41
+ * Show `entries` in the Dock icon's menu, above the items macOS adds (Options, Show All Windows,
42
+ * Hide, Quit); an empty list or null takes them away. Items are `MenuItemModel`s, as a
43
+ * `<menu-item>` registers them.
44
+ */
45
+ setMenu(entries) {
46
+ const menu = serializeMenu(entries ?? [], 'macos');
47
+ this.actions = menu.actions;
48
+ this.native?.setMenu(menu.entries.length ? menu.entries : null);
49
+ }
50
+ /**
51
+ * Bounce the Dock icon until the app comes to the front: once, or with `critical` until then.
52
+ * Nothing while the app is in front. Answers the function that stops it.
53
+ */
54
+ bounce(options = {}) {
55
+ const native = this.native;
56
+ if (!native)
57
+ return () => { };
58
+ const id = native.bounce(options.critical === true);
59
+ return () => native.cancelBounce(id);
60
+ }
61
+ ngOnDestroy() {
62
+ this.unsubscribe?.();
63
+ }
64
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Dock, deps: [], target: i0.ɵɵFactoryTarget.Service });
65
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: Dock });
66
+ }
67
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Dock, decorators: [{
68
+ type: Service
69
+ }] });
70
+ //# sourceMappingURL=dock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dock.js","sourceRoot":"","sources":["../src/dock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAErF,OAAO,EAAE,aAAa,EAAwB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAehD,SAAS,UAAU;IACjB,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,cAAc,CAC5B,CAAC;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO;QACL,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC;QAC/C,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrD,YAAY,EAAE,CAAC,EAAE,EAAE,EA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C,UAAkC,EAAE;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM;YAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;QAC7B,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QACpD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAtCU,IAAI;wGAAJ,IAAI;;2FAAJ,IAAI;kBADhB,OAAO","sourcesContent":["/**\n * The app's Dock icon on macOS: a menu of the app's own above the standard one, and a bounce that\n * asks for attention. Its badge is the Notifications badge count, from `@ng-native/expo`'s\n * `Notifications.setBadge`, as an app icon's badge is on iOS. Absent on every other OS, where each\n * call does nothing.\n *\n * The host contract, on the `NgNativeDock` module: `setMenu(entries)` takes the menu as\n * `serializeMenu` makes it, or null for none; `bounce(critical)` answers an id that\n * `cancelBounce(id)` takes; `{ type: 'menuSelect', id }` arrives on `ngNativeDock`.\n */\nimport { InjectionToken, Service, inject, signal, type Signal } from '@angular/core';\nimport type { MenuEntry } from './menu-model.ts';\nimport { serializeMenu, type NativeMenuEntry } from './menus.ts';\nimport { reactNative } from './react-native.ts';\n\nexport interface NativeDock {\n setMenu(entries: readonly NativeMenuEntry[] | null): void;\n bounce(critical: boolean): number;\n cancelBounce(id: number): void;\n subscribe(listener: (event: { type: 'menuSelect'; id: string }) => void): () => void;\n}\n\ninterface DockTurboModule {\n setMenu?(entries: readonly NativeMenuEntry[] | null): void;\n bounce?(critical: boolean): number;\n cancelBounce?(id: number): void;\n}\n\nfunction dockSource(): NativeDock | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeDock') as\n DockTurboModule | null | undefined;\n if (!module) return null;\n return {\n setMenu: (entries) => module.setMenu?.(entries),\n bounce: (critical) => module.bounce?.(critical) ?? -1,\n cancelBounce: (id) => module.cancelBounce?.(id),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeDock', (event) =>\n listener(event as { type: 'menuSelect'; id: string }),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n@Service()\nexport class Dock {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeDock | null>('angular-native.dockSource', {\n factory: dockSource,\n });\n\n private readonly native = inject(Dock.SOURCE);\n private actions: ReadonlyMap<string, () => void> = new Map();\n private readonly unsubscribe =\n this.native?.subscribe((event) => this.actions.get(event.id)?.()) ?? null;\n\n /** Whether the app has a Dock icon: macOS. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n /**\n * Show `entries` in the Dock icon's menu, above the items macOS adds (Options, Show All Windows,\n * Hide, Quit); an empty list or null takes them away. Items are `MenuItemModel`s, as a\n * `<menu-item>` registers them.\n */\n setMenu(entries: readonly MenuEntry[] | null): void {\n const menu = serializeMenu(entries ?? [], 'macos');\n this.actions = menu.actions;\n this.native?.setMenu(menu.entries.length ? menu.entries : null);\n }\n\n /**\n * Bounce the Dock icon until the app comes to the front: once, or with `critical` until then.\n * Nothing while the app is in front. Answers the function that stops it.\n */\n bounce(options: { critical?: boolean } = {}): () => void {\n const native = this.native;\n if (!native) return () => {};\n const id = native.bounce(options.critical === true);\n return () => native.cancelBounce(id);\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Drag and drop as iPadOS's host takes it, for `(fileDrop)` and `[dragItem]` in
3
+ * `@ng-native/components`. React Native's iOS view keeps no prop it does not know and sends no
4
+ * event it does not know, so on iOS the directives reach a module by the view's `nativeID`, as
5
+ * `[contextMenu]` does. macOS's host reads the `fileDrop` and `dragItem` props instead.
6
+ *
7
+ * The host contract, on the `NgNativeDragAndDrop` module (iOS):
8
+ * - `setFileDrop(nativeID, takes)`: whether the view with `nativeID` takes drops
9
+ * (UIDropInteraction). iPhone takes none.
10
+ * - `setDragItem(nativeID, item)`: what the view offers when it is dragged out, `{ files, text, url }`
11
+ * with each file a `file://` url, or null for nothing (UIDragInteraction). iPhone offers none.
12
+ * - Events on `ngNativeDragAndDrop`: `{ type, nativeID, files, text, urls }`, with `type`
13
+ * `dropEnter`, `dropLeave` or `dropPerform`, in the form the view's `topDropEnter`,
14
+ * `topDropLeave` and `topDropPerform` carry on macOS.
15
+ * - The host finds the view by its `nativeID` once it is mounted, and lets it go as it unmounts.
16
+ */
17
+ import { InjectionToken, type Signal } from '@angular/core';
18
+ import * as i0 from "@angular/core";
19
+ /** What a view offers to a drag, as the host takes it. */
20
+ export interface NativeDragItem {
21
+ readonly files: readonly string[];
22
+ readonly text: string | null;
23
+ readonly url: string | null;
24
+ }
25
+ /** A drag over a view, or a drop on it, from the host. */
26
+ export interface NativeDropEvent {
27
+ readonly type: 'dropEnter' | 'dropLeave' | 'dropPerform';
28
+ readonly nativeID: string;
29
+ readonly files?: readonly {
30
+ readonly uri: string;
31
+ readonly name: string;
32
+ }[];
33
+ readonly text?: string | null;
34
+ readonly urls?: readonly string[];
35
+ }
36
+ /** The host's drag and drop module. */
37
+ export interface NativeDragAndDrop {
38
+ setFileDrop(nativeID: string, takes: boolean): void;
39
+ setDragItem(nativeID: string, item: NativeDragItem | null): void;
40
+ subscribe(listener: (event: NativeDropEvent) => void): () => void;
41
+ }
42
+ /**
43
+ * iOS's `NgNativeDragAndDrop` TurboModule, or null where it is not linked, as in Expo Go, and on an
44
+ * iPhone, where it ignores every view: no view is named for it there.
45
+ */
46
+ export declare function dragAndDropSource(): NativeDragAndDrop | null;
47
+ /**
48
+ * The views that take drops or offer drags by `nativeID`, sent to the host as they change.
49
+ * `(fileDrop)` and `[dragItem]` in `@ng-native/components` register here on iOS; an app rarely
50
+ * injects it.
51
+ */
52
+ export declare class DragAndDrop {
53
+ /** Overridden in a test with a fake host. */
54
+ static readonly SOURCE: InjectionToken<NativeDragAndDrop | null>;
55
+ private readonly native;
56
+ /** Whether the host has the module, so views take drops and drags by `nativeID`. */
57
+ readonly available: Signal<boolean>;
58
+ private readonly drops;
59
+ private readonly unsubscribe;
60
+ /** Let the view with `nativeID` take drops, each heard by `listener`, or null to stop. */
61
+ setFileDrop(nativeID: string, listener: ((event: NativeDropEvent) => void) | null): void;
62
+ /** What the view with `nativeID` offers when it is dragged out, or null for nothing. */
63
+ setDragItem(nativeID: string, item: NativeDragItem | null): void;
64
+ ngOnDestroy(): void;
65
+ static ɵfac: i0.ɵɵFactoryDeclaration<DragAndDrop, never>;
66
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
67
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Drag and drop as iPadOS's host takes it, for `(fileDrop)` and `[dragItem]` in
3
+ * `@ng-native/components`. React Native's iOS view keeps no prop it does not know and sends no
4
+ * event it does not know, so on iOS the directives reach a module by the view's `nativeID`, as
5
+ * `[contextMenu]` does. macOS's host reads the `fileDrop` and `dragItem` props instead.
6
+ *
7
+ * The host contract, on the `NgNativeDragAndDrop` module (iOS):
8
+ * - `setFileDrop(nativeID, takes)`: whether the view with `nativeID` takes drops
9
+ * (UIDropInteraction). iPhone takes none.
10
+ * - `setDragItem(nativeID, item)`: what the view offers when it is dragged out, `{ files, text, url }`
11
+ * with each file a `file://` url, or null for nothing (UIDragInteraction). iPhone offers none.
12
+ * - Events on `ngNativeDragAndDrop`: `{ type, nativeID, files, text, urls }`, with `type`
13
+ * `dropEnter`, `dropLeave` or `dropPerform`, in the form the view's `topDropEnter`,
14
+ * `topDropLeave` and `topDropPerform` carry on macOS.
15
+ * - The host finds the view by its `nativeID` once it is mounted, and lets it go as it unmounts.
16
+ */
17
+ import { InjectionToken, Service, inject, signal } from '@angular/core';
18
+ import { reactNative } from "./react-native.js";
19
+ import * as i0 from "@angular/core";
20
+ /**
21
+ * iOS's `NgNativeDragAndDrop` TurboModule, or null where it is not linked, as in Expo Go, and on an
22
+ * iPhone, where it ignores every view: no view is named for it there.
23
+ */
24
+ export function dragAndDropSource() {
25
+ const native = reactNative();
26
+ if (native?.Platform.OS === 'ios' && native.Platform.isPad !== true)
27
+ return null;
28
+ const module = native?.TurboModuleRegistry?.get?.('NgNativeDragAndDrop');
29
+ if (!module)
30
+ return null;
31
+ return {
32
+ setFileDrop: (nativeID, takes) => module.setFileDrop?.(nativeID, takes),
33
+ setDragItem: (nativeID, item) => module.setDragItem?.(nativeID, item),
34
+ subscribe: (listener) => {
35
+ const subscription = native?.DeviceEventEmitter?.addListener('ngNativeDragAndDrop', (event) => listener(event));
36
+ return () => subscription?.remove();
37
+ },
38
+ };
39
+ }
40
+ /**
41
+ * The views that take drops or offer drags by `nativeID`, sent to the host as they change.
42
+ * `(fileDrop)` and `[dragItem]` in `@ng-native/components` register here on iOS; an app rarely
43
+ * injects it.
44
+ */
45
+ export class DragAndDrop {
46
+ /** Overridden in a test with a fake host. */
47
+ static SOURCE = new InjectionToken('angular-native.dragAndDropSource', { factory: dragAndDropSource });
48
+ native = inject(DragAndDrop.SOURCE);
49
+ /** Whether the host has the module, so views take drops and drags by `nativeID`. */
50
+ available = signal(this.native !== null).asReadonly();
51
+ drops = new Map();
52
+ unsubscribe = this.native?.subscribe((event) => this.drops.get(event.nativeID)?.(event)) ?? null;
53
+ /** Let the view with `nativeID` take drops, each heard by `listener`, or null to stop. */
54
+ setFileDrop(nativeID, listener) {
55
+ if (listener)
56
+ this.drops.set(nativeID, listener);
57
+ else
58
+ this.drops.delete(nativeID);
59
+ this.native?.setFileDrop(nativeID, listener !== null);
60
+ }
61
+ /** What the view with `nativeID` offers when it is dragged out, or null for nothing. */
62
+ setDragItem(nativeID, item) {
63
+ this.native?.setDragItem(nativeID, item);
64
+ }
65
+ ngOnDestroy() {
66
+ this.unsubscribe?.();
67
+ }
68
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: DragAndDrop, deps: [], target: i0.ɵɵFactoryTarget.Service });
69
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: DragAndDrop });
70
+ }
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: DragAndDrop, decorators: [{
72
+ type: Service
73
+ }] });
74
+ //# sourceMappingURL=drag-and-drop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../src/drag-and-drop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AA8BhD;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACjF,MAAM,MAAM,GAAG,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,qBAAqB,CACjC,CAAC;IACvC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO;QACL,WAAW,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;QACvE,WAAW,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;QACrE,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,YAAY,GAAG,MAAM,EAAE,kBAAkB,EAAE,WAAW,CAAC,qBAAq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EAAE,CAAC;IACvB,CAAC;uGA/BU,WAAW;wGAAX,WAAW;;2FAAX,WAAW;kBADvB,OAAO","sourcesContent":["/**\n * Drag and drop as iPadOS's host takes it, for `(fileDrop)` and `[dragItem]` in\n * `@ng-native/components`. React Native's iOS view keeps no prop it does not know and sends no\n * event it does not know, so on iOS the directives reach a module by the view's `nativeID`, as\n * `[contextMenu]` does. macOS's host reads the `fileDrop` and `dragItem` props instead.\n *\n * The host contract, on the `NgNativeDragAndDrop` module (iOS):\n * - `setFileDrop(nativeID, takes)`: whether the view with `nativeID` takes drops\n * (UIDropInteraction). iPhone takes none.\n * - `setDragItem(nativeID, item)`: what the view offers when it is dragged out, `{ files, text, url }`\n * with each file a `file://` url, or null for nothing (UIDragInteraction). iPhone offers none.\n * - Events on `ngNativeDragAndDrop`: `{ type, nativeID, files, text, urls }`, with `type`\n * `dropEnter`, `dropLeave` or `dropPerform`, in the form the view's `topDropEnter`,\n * `topDropLeave` and `topDropPerform` carry on macOS.\n * - The host finds the view by its `nativeID` once it is mounted, and lets it go as it unmounts.\n */\nimport { InjectionToken, Service, inject, signal, type Signal } from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\n/** What a view offers to a drag, as the host takes it. */\nexport interface NativeDragItem {\n readonly files: readonly string[];\n readonly text: string | null;\n readonly url: string | null;\n}\n\n/** A drag over a view, or a drop on it, from the host. */\nexport interface NativeDropEvent {\n readonly type: 'dropEnter' | 'dropLeave' | 'dropPerform';\n readonly nativeID: string;\n readonly files?: readonly { readonly uri: string; readonly name: string }[];\n readonly text?: string | null;\n readonly urls?: readonly string[];\n}\n\n/** The host's drag and drop module. */\nexport interface NativeDragAndDrop {\n setFileDrop(nativeID: string, takes: boolean): void;\n setDragItem(nativeID: string, item: NativeDragItem | null): void;\n subscribe(listener: (event: NativeDropEvent) => void): () => void;\n}\n\ninterface DragAndDropModule {\n setFileDrop?(nativeID: string, takes: boolean): void;\n setDragItem?(nativeID: string, item: unknown): void;\n}\n\n/**\n * iOS's `NgNativeDragAndDrop` TurboModule, or null where it is not linked, as in Expo Go, and on an\n * iPhone, where it ignores every view: no view is named for it there.\n */\nexport function dragAndDropSource(): NativeDragAndDrop | null {\n const native = reactNative();\n if (native?.Platform.OS === 'ios' && native.Platform.isPad !== true) return null;\n const module = native?.TurboModuleRegistry?.get?.('NgNativeDragAndDrop') as\n DragAndDropModule | null | undefined;\n if (!module) return null;\n return {\n setFileDrop: (nativeID, takes) => module.setFileDrop?.(nativeID, takes),\n setDragItem: (nativeID, item) => module.setDragItem?.(nativeID, item),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeDragAndDrop', (event) =>\n listener(event as NativeDropEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n/**\n * The views that take drops or offer drags by `nativeID`, sent to the host as they change.\n * `(fileDrop)` and `[dragItem]` in `@ng-native/components` register here on iOS; an app rarely\n * injects it.\n */\n@Service()\nexport class DragAndDrop {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeDragAndDrop | null>(\n 'angular-native.dragAndDropSource',\n { factory: dragAndDropSource },\n );\n\n private readonly native = inject(DragAndDrop.SOURCE);\n\n /** Whether the host has the module, so views take drops and drags by `nativeID`. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n private readonly drops = new Map<string, (event: NativeDropEvent) => void>();\n\n private readonly unsubscribe =\n this.native?.subscribe((event) => this.drops.get(event.nativeID)?.(event)) ?? null;\n\n /** Let the view with `nativeID` take drops, each heard by `listener`, or null to stop. */\n setFileDrop(nativeID: string, listener: ((event: NativeDropEvent) => void) | null): void {\n if (listener) this.drops.set(nativeID, listener);\n else this.drops.delete(nativeID);\n this.native?.setFileDrop(nativeID, listener !== null);\n }\n\n /** What the view with `nativeID` offers when it is dragged out, or null for nothing. */\n setDragItem(nativeID: string, item: NativeDragItem | null): void {\n this.native?.setDragItem(nativeID, item);\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The Fabric component name for an Expo module's view, exactly as `requireNativeViewManager`
3
+ * computes it in `expo-modules-core`.
4
+ *
5
+ * The app identifier is the part that cannot be hardcoded. Expo Go runs many projects in one
6
+ * binary, so it namespaces every view name with a per-app suffix; a standalone build has no
7
+ * identifier and no suffix. Get it wrong and the view commits as `UnimplementedNativeView`
8
+ * with no error, which is the same failure mode as a misspelled name.
9
+ *
10
+ * A module with more than one view names the extra ones (`viewName`); the default view is the
11
+ * module itself.
12
+ *
13
+ * Internal: it lives here because `@ng-native/expo` and `@ng-native/router` both derive these
14
+ * names and cannot import each other. Apps use `expoViewName` from `@ng-native/expo`.
15
+ */
16
+ export declare function expoViewName(moduleName: string, viewName?: string): string;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The Fabric component name for an Expo module's view, exactly as `requireNativeViewManager`
3
+ * computes it in `expo-modules-core`.
4
+ *
5
+ * The app identifier is the part that cannot be hardcoded. Expo Go runs many projects in one
6
+ * binary, so it namespaces every view name with a per-app suffix; a standalone build has no
7
+ * identifier and no suffix. Get it wrong and the view commits as `UnimplementedNativeView`
8
+ * with no error, which is the same failure mode as a misspelled name.
9
+ *
10
+ * A module with more than one view names the extra ones (`viewName`); the default view is the
11
+ * module itself.
12
+ *
13
+ * Internal: it lives here because `@ng-native/expo` and `@ng-native/router` both derive these
14
+ * names and cannot import each other. Apps use `expoViewName` from `@ng-native/expo`.
15
+ */
16
+ export function expoViewName(moduleName, viewName) {
17
+ const identifier = globalThis.expo?.__expo_app_identifier__ ?? '';
18
+ const suffix = identifier ? `_${identifier}` : '';
19
+ const module = viewName ? `${moduleName}_${viewName}` : moduleName;
20
+ return `ViewManagerAdapter_${module}${suffix}`;
21
+ }
22
+ //# sourceMappingURL=expo-view-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo-view-name.js","sourceRoot":"","sources":["../src/expo-view-name.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,QAAiB;IAChE,MAAM,UAAU,GAAI,UAAoC,CAAC,IAAI,EAAE,uBAAuB,IAAI,EAAE,CAAC;IAC7F,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;IACnE,OAAO,sBAAsB,MAAM,GAAG,MAAM,EAAE,CAAC;AACjD,CAAC","sourcesContent":["/**\n * What Expo installs on the global when the app starts. Only the app identifier matters here;\n * `getViewConfig` is for React's renderer, which never runs.\n */\ninterface ExpoGlobal {\n readonly __expo_app_identifier__?: string;\n}\n\n/**\n * The Fabric component name for an Expo module's view, exactly as `requireNativeViewManager`\n * computes it in `expo-modules-core`.\n *\n * The app identifier is the part that cannot be hardcoded. Expo Go runs many projects in one\n * binary, so it namespaces every view name with a per-app suffix; a standalone build has no\n * identifier and no suffix. Get it wrong and the view commits as `UnimplementedNativeView`\n * with no error, which is the same failure mode as a misspelled name.\n *\n * A module with more than one view names the extra ones (`viewName`); the default view is the\n * module itself.\n *\n * Internal: it lives here because `@ng-native/expo` and `@ng-native/router` both derive these\n * names and cannot import each other. Apps use `expoViewName` from `@ng-native/expo`.\n */\nexport function expoViewName(moduleName: string, viewName?: string): string {\n const identifier = (globalThis as { expo?: ExpoGlobal }).expo?.__expo_app_identifier__ ?? '';\n const suffix = identifier ? `_${identifier}` : '';\n const module = viewName ? `${moduleName}_${viewName}` : moduleName;\n return `ViewManagerAdapter_${module}${suffix}`;\n}\n"]}
@@ -1,13 +1,4 @@
1
- /**
2
- * Android's hardware back button.
3
- *
4
- * Not a signal, because a press is a question rather than a state: the platform asks whether
5
- * anybody wants it, and the answer decides what happens next. A handler returns whether it
6
- * consumed the press, and returning false lets the platform do what it would have done - at the
7
- * bottom of a navigation stack that means backgrounding the app rather than closing it, so a user
8
- * who backs out of the first screen finds the app where they left it.
9
- */
10
- import { InjectionToken } from '@angular/core';
1
+ import { InjectionToken, type Signal } from '@angular/core';
11
2
  import * as i0 from "@angular/core";
12
3
  export interface HardwareBackSource {
13
4
  subscribe(listener: () => boolean): () => void;
@@ -17,6 +8,8 @@ export declare class HardwareBack {
17
8
  /** Overridden in a test to press the button without a device. */
18
9
  static readonly SOURCE: InjectionToken<HardwareBackSource>;
19
10
  private readonly source;
11
+ /** Whether there is a hardware back button: on Android alone. */
12
+ readonly available: Signal<boolean>;
20
13
  /**
21
14
  * Handle the back press. React Native runs the most recently added handler first, so a screen
22
15
  * that subscribes on mount outranks the one below it. Called in a screen's injection context, as
@@ -7,7 +7,8 @@
7
7
  * bottom of a navigation stack that means backgrounding the app rather than closing it, so a user
8
8
  * who backs out of the first screen finds the app where they left it.
9
9
  */
10
- import { InjectionToken, Service, inject } from '@angular/core';
10
+ import { injectOs } from "./os.js";
11
+ import { InjectionToken, Service, inject, signal } from '@angular/core';
11
12
  import { reactNative } from "./react-native.js";
12
13
  import { SCREEN_IN_FRONT } from "./screen-in-front.js";
13
14
  import * as i0 from "@angular/core";
@@ -28,6 +29,8 @@ export class HardwareBack {
28
29
  /** Overridden in a test to press the button without a device. */
29
30
  static SOURCE = new InjectionToken('angular-native.hardwareBackSource', { factory: hardwareBackSource });
30
31
  source = inject(HardwareBack.SOURCE);
32
+ /** Whether there is a hardware back button: on Android alone. */
33
+ available = signal(injectOs() === 'android').asReadonly();
31
34
  /**
32
35
  * Handle the back press. React Native runs the most recently added handler first, so a screen
33
36
  * that subscribes on mount outranks the one below it. Called in a screen's injection context, as
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-back.js","sourceRoot":"","sources":["../src/hardware-back.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC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,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA2B,CAAC,IAAI,KAAK,oBAAoB;YAAE,MAAM,KAAK,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["/**\n * Android's hardware back button.\n *\n * Not a signal, because a press is a question rather than a state: the platform asks whether\n * anybody wants it, and the answer decides what happens next. A handler returns whether it\n * consumed the press, and returning false lets the platform do what it would have done - at the\n * bottom of a navigation stack that means backgrounding the app rather than closing it, so a user\n * who backs out of the first screen finds the app where they left it.\n */\nimport { InjectionToken, Service, inject, type Signal } from '@angular/core';\nimport { reactNative } from './react-native.ts';\nimport { SCREEN_IN_FRONT } from './screen-in-front.ts';\n\n/** Angular's NG0203, `inject()` called outside an injection context. */\nconst NO_INJECTION_CONTEXT = -203;\n\nexport interface HardwareBackSource {\n subscribe(listener: () => boolean): () => void;\n}\n\nexport function hardwareBackSource(): HardwareBackSource {\n const native = reactNative();\n if (!native) return { subscribe: () => () => {} };\n\n return {\n subscribe: (listener) => {\n const subscription = native.BackHandler.addEventListener('hardwareBackPress', listener);\n return () => subscription.remove();\n },\n };\n}\n\n@Service()\nexport class HardwareBack {\n /** Overridden in a test to press the button without a device. */\n static readonly SOURCE = new InjectionToken<HardwareBackSource>(\n 'angular-native.hardwareBackSource',\n { factory: hardwareBackSource },\n );\n\n private readonly source = inject(HardwareBack.SOURCE);\n\n /**\n * Handle the back press. React Native runs the most recently added handler first, so a screen\n * that subscribes on mount outranks the one below it. Called in a screen's injection context, as\n * from its constructor, the handler is asked only while that screen is in front: a screen pushed\n * or presented over it gets the press. Returns an unsubscribe.\n */\n handle(handler: () => boolean): () => void {\n const inFront = callerInFront();\n return this.source.subscribe(() => (inFront?.() ?? true) && handler());\n }\n}\n\n/** Whether the screen the caller is on is in front, or null where nothing says: outside an injection context, or one with no screen. */\nfunction callerInFront(): Signal<boolean> | null {\n try {\n return inject(SCREEN_IN_FRONT, { optional: true });\n } catch (error) {\n if ((error as { code?: number }).code !== NO_INJECTION_CONTEXT) throw error;\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"hardware-back.js","sourceRoot":"","sources":["../src/hardware-back.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;;AAEvD,wEAAwE;AACxE,MAAM,oBAAoB,GAAG,CAAC,GAAG,CAAC;AAMlC,MAAM,UAAU,kBAAkB;IAChC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;IAElD,OAAO;QACL,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;YACxF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC;AAGD,MAAM,OAAO,YAAY;IACvB,iEAAiE;IACjE,MAAM,CAAU,MAAM,GAAG,IAAI,cAAc,CACzC,mCAAmC,EACnC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAChC,CAAC;IAEe,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAEtD,iEAAiE;IACxD,SAAS,GAAoB,MAAM,CAAC,QAAQ,EAAE,KAAK,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;IAEpF;;;;;OAKG;IACH,MAAM,CAAC,OAAsB;QAC3B,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;uGArBU,YAAY;wGAAZ,YAAY;;2FAAZ,YAAY;kBADxB,OAAO;;AAyBR,wIAAwI;AACxI,SAAS,aAAa;IACpB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA2B,CAAC,IAAI,KAAK,oBAAoB;YAAE,MAAM,KAAK,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["/**\n * Android's hardware back button.\n *\n * Not a signal, because a press is a question rather than a state: the platform asks whether\n * anybody wants it, and the answer decides what happens next. A handler returns whether it\n * consumed the press, and returning false lets the platform do what it would have done - at the\n * bottom of a navigation stack that means backgrounding the app rather than closing it, so a user\n * who backs out of the first screen finds the app where they left it.\n */\nimport { injectOs } from './os.ts';\nimport { InjectionToken, Service, inject, type Signal, signal } from '@angular/core';\nimport { reactNative } from './react-native.ts';\nimport { SCREEN_IN_FRONT } from './screen-in-front.ts';\n\n/** Angular's NG0203, `inject()` called outside an injection context. */\nconst NO_INJECTION_CONTEXT = -203;\n\nexport interface HardwareBackSource {\n subscribe(listener: () => boolean): () => void;\n}\n\nexport function hardwareBackSource(): HardwareBackSource {\n const native = reactNative();\n if (!native) return { subscribe: () => () => {} };\n\n return {\n subscribe: (listener) => {\n const subscription = native.BackHandler.addEventListener('hardwareBackPress', listener);\n return () => subscription.remove();\n },\n };\n}\n\n@Service()\nexport class HardwareBack {\n /** Overridden in a test to press the button without a device. */\n static readonly SOURCE = new InjectionToken<HardwareBackSource>(\n 'angular-native.hardwareBackSource',\n { factory: hardwareBackSource },\n );\n\n private readonly source = inject(HardwareBack.SOURCE);\n\n /** Whether there is a hardware back button: on Android alone. */\n readonly available: Signal<boolean> = signal(injectOs() === 'android').asReadonly();\n\n /**\n * Handle the back press. React Native runs the most recently added handler first, so a screen\n * that subscribes on mount outranks the one below it. Called in a screen's injection context, as\n * from its constructor, the handler is asked only while that screen is in front: a screen pushed\n * or presented over it gets the press. Returns an unsubscribe.\n */\n handle(handler: () => boolean): () => void {\n const inFront = callerInFront();\n return this.source.subscribe(() => (inFront?.() ?? true) && handler());\n }\n}\n\n/** Whether the screen the caller is on is in front, or null where nothing says: outside an injection context, or one with no screen. */\nfunction callerInFront(): Signal<boolean> | null {\n try {\n return inject(SCREEN_IN_FRONT, { optional: true });\n } catch (error) {\n if ((error as { code?: number }).code !== NO_INJECTION_CONTEXT) throw error;\n return null;\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  export { Accessibility, type AccessibilitySettings, type AccessibilitySource, } from './accessibility.ts';
9
9
  export { AppState, type AppStateSource, type AppStatus } from './app-state.ts';
10
10
  export { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';
11
- export { currentConditions, deviceTokens, watchConditions, type WatchOptions, } from './conditions.ts';
11
+ export { currentConditions, deviceTokens, hairlineTokens, watchConditions, type WatchOptions, } from './conditions.ts';
12
12
  export { DeepLinks, deepLinkSource, pathOf, type DeepLinkSource } from './deep-links.ts';
13
13
  export { Direction, type DirectionContext, type DirectionSource, type LayoutDirection, } from './direction.ts';
14
14
  export { androidPermission, type AndroidPermissions, type PermissionAnswer, } from './android-permissions.ts';
@@ -28,6 +28,30 @@ export { NavigationBar, navigationBarSource, type NavigationBarSource, type Navi
28
28
  export { SCREEN_IN_FRONT } from './screen-in-front.ts';
29
29
  export { SCREEN_SHOWN } from './screen-shown.ts';
30
30
  export { NATIVE_HISTORY } from './native-history.ts';
31
- export { OS } from './os.ts';
31
+ export { APPLE, DESKTOP, OS } from './os.ts';
32
+ export { MENU_MODEL, createMenuModel, defaultMenuBar, isSeparator, mergeMenuBar, menuModelInTreeOrder, treeOrder, type MenuEntry, type MenuGroupModel, type MenuGroupRole, type MenuItemModel, type MenuModel, type MenuRole, type MenuSeparator, } from './menu-model.ts';
33
+ export { isEditingShortcut, matchesShortcut, navigationShortcut, parseShortcut, shortcutFires, type KeyChord, type ParsedShortcut, type ShortcutOs, } from './shortcut.ts';
34
+ export { Processes, UndeclaredCapabilityError, type ChildProcess, type NativeProcesses, type ProcessEvent, type ProcessExit, type SpawnOptions, } from './processes.ts';
35
+ export { SEARCH_PATH, SpawnRuleError, compileCapability, filterEnvironment, matchArguments, matchSpawn, parseArgument, programProblem, resolveProgram, type ArgumentRule, type CompiledCapability, type PlaceholderValues, type ProgramLookup, type SpawnCapability, type SpawnMatch, } from './spawn-rules.ts';
36
+ export { desktopOptionProblems, pathAllowed, pathProblem, validateDesktopOptions, type DesktopCapabilities, type DesktopOptions, type DocumentType, type PathCapability, } from './desktop-options.ts';
37
+ export { macosPermissions, type ExpoPermissionConfig, type MacosPermissions, } from './desktop-permissions.ts';
38
+ export { Menus, menuActionId, menusSource, serializeMenu, type NativeMenuEntry, type NativeMenuEvent, type NativeMenus, type NativeWindowHistory, type NativeShortcut, type SerializedMenu, } from './menus.ts';
39
+ export { Dock, type NativeDock } from './dock.ts';
40
+ export { nativeSplitViews } from './split-views.ts';
41
+ export { DragAndDrop, dragAndDropSource, type NativeDragAndDrop, type NativeDragItem, type NativeDropEvent, } from './drag-and-drop.ts';
42
+ export { UndoStack, type NativeUndo, type NativeUndoEvent, type UndoAction } from './undo-stack.ts';
43
+ export { OS_SUPPORT, SUPPORT_OSES, platformsLine, supportRowOf, type OsSupportRow, type SupportOs, } from './os-support.ts';
44
+ export { Shell, type NativeShell } from './shell.ts';
45
+ export { Tray, type NativeTray, type NativeTrayEvent, type NativeTrayIcon, type TrayIconModel, } from './tray.ts';
46
+ export { SIDEBAR_SELECTION } from './sidebar-selection.ts';
47
+ export { expoViewName } from './expo-view-name.ts';
48
+ export { hostInputNames, ownHost } from './own-host.ts';
49
+ export { WINDOW_NAVIGATOR, type WindowNavigator } from './window-navigator.ts';
50
+ export { AppWindows, CURRENT_WINDOW, MAIN_WINDOW_OPTIONS, WINDOW_MOUNTER, provideMainWindow, type AppWindow, type CloseGuard, type ComponentWindowOptions, type MainWindowOptions, type NativeWindowEvent, type NativeWindowRequest, type NativeWindows, type RouteWindowOptions, type TitleBar, type WindowMount, type WindowMounter, type WindowOptions, windowsSource, } from './app-windows.ts';
51
+ export { APP_LIFECYCLE_OPTIONS, AppLifecycle, WILL_QUIT_DEADLINE_MS, provideAppLifecycle, quitsWithLastWindow, type AppLifecycleOptions, } from './app-lifecycle.ts';
32
52
  export { OS_VERSION } from './os-version.ts';
33
53
  export { injectToken, type InjectTokenOptions } from './inject-token.ts';
54
+ export { type ControlSize } from './control-size.ts';
55
+ export { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, provideRestorableWindows, type RestoredWindow, type WindowRestoreStore, } from './window-restore.ts';
56
+ export { buildMenuTemplate, type MenuTemplate } from './menu-template.ts';
57
+ export { INTERACTION_OBSERVERS, MAX_TEXT_LENGTH, describeElement, interactionObservers, notifyInteraction, provideInteractionObserver, textWithin, type InteractionDirection, type InteractionEvent, type InteractionGesture, type InteractionObserver, type InteractionType, } from './interaction-observer.ts';
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  export { Accessibility, } from "./accessibility.js";
9
9
  export { AppState } from "./app-state.js";
10
10
  export { ColorScheme } from "./color-scheme.js";
11
- export { currentConditions, deviceTokens, watchConditions, } from "./conditions.js";
11
+ export { currentConditions, deviceTokens, hairlineTokens, watchConditions, } from "./conditions.js";
12
12
  export { DeepLinks, deepLinkSource, pathOf } from "./deep-links.js";
13
13
  export { Direction, } from "./direction.js";
14
14
  export { androidPermission, } from "./android-permissions.js";
@@ -27,7 +27,31 @@ export { NavigationBar, navigationBarSource, } from "./navigation-bar.js";
27
27
  export { SCREEN_IN_FRONT } from "./screen-in-front.js";
28
28
  export { SCREEN_SHOWN } from "./screen-shown.js";
29
29
  export { NATIVE_HISTORY } from "./native-history.js";
30
- export { OS } from "./os.js";
30
+ export { APPLE, DESKTOP, OS } from "./os.js";
31
+ export { MENU_MODEL, createMenuModel, defaultMenuBar, isSeparator, mergeMenuBar, menuModelInTreeOrder, treeOrder, } from "./menu-model.js";
32
+ export { isEditingShortcut, matchesShortcut, navigationShortcut, parseShortcut, shortcutFires, } from "./shortcut.js";
33
+ export { Processes, UndeclaredCapabilityError, } from "./processes.js";
34
+ export { SEARCH_PATH, SpawnRuleError, compileCapability, filterEnvironment, matchArguments, matchSpawn, parseArgument, programProblem, resolveProgram, } from "./spawn-rules.js";
35
+ export { desktopOptionProblems, pathAllowed, pathProblem, validateDesktopOptions, } from "./desktop-options.js";
36
+ export { macosPermissions, } from "./desktop-permissions.js";
37
+ export { Menus, menuActionId, menusSource, serializeMenu, } from "./menus.js";
38
+ export { Dock } from "./dock.js";
39
+ export { nativeSplitViews } from "./split-views.js";
40
+ export { DragAndDrop, dragAndDropSource, } from "./drag-and-drop.js";
41
+ export { UndoStack } from "./undo-stack.js";
42
+ export { OS_SUPPORT, SUPPORT_OSES, platformsLine, supportRowOf, } from "./os-support.js";
43
+ export { Shell } from "./shell.js";
44
+ export { Tray, } from "./tray.js";
45
+ export { SIDEBAR_SELECTION } from "./sidebar-selection.js";
46
+ export { expoViewName } from "./expo-view-name.js";
47
+ export { hostInputNames, ownHost } from "./own-host.js";
48
+ export { WINDOW_NAVIGATOR } from "./window-navigator.js";
49
+ export { AppWindows, CURRENT_WINDOW, MAIN_WINDOW_OPTIONS, WINDOW_MOUNTER, provideMainWindow, windowsSource, } from "./app-windows.js";
50
+ export { APP_LIFECYCLE_OPTIONS, AppLifecycle, WILL_QUIT_DEADLINE_MS, provideAppLifecycle, quitsWithLastWindow, } from "./app-lifecycle.js";
31
51
  export { OS_VERSION } from "./os-version.js";
32
52
  export { injectToken } from "./inject-token.js";
53
+ export {} from "./control-size.js";
54
+ export { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, provideRestorableWindows, } from "./window-restore.js";
55
+ export { buildMenuTemplate } from "./menu-template.js";
56
+ export { INTERACTION_OBSERVERS, MAX_TEXT_LENGTH, describeElement, interactionObservers, notifyInteraction, provideInteractionObserver, textWithin, } from "./interaction-observer.js";
33
57
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAuC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAuC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAuB,MAAM,iBAAiB,CAAC;AACzF,OAAO,EACL,SAAS,GAIV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAA0C,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAmC,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAyC,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EACL,eAAe,EACf,QAAQ,EACR,cAAc,GAIf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,EAA4C,MAAM,aAAa,CAAC;AAC9F,OAAO,EACL,SAAS,EACT,eAAe,GAKhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,cAAc,GAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC","sourcesContent":["/**\n * The host: the device, the operating system, and the user's settings.\n *\n * Every capability here is a service with its own factory, so injecting one is the whole setup\n * and one nobody injects is never constructed. Off a device each falls back to doing nothing,\n * which is what makes the whole package importable by the test suite.\n */\nexport {\n Accessibility,\n type AccessibilitySettings,\n type AccessibilitySource,\n} from './accessibility.ts';\nexport { AppState, type AppStateSource, type AppStatus } from './app-state.ts';\nexport { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';\nexport {\n currentConditions,\n deviceTokens,\n watchConditions,\n type WatchOptions,\n} from './conditions.ts';\nexport { DeepLinks, deepLinkSource, pathOf, type DeepLinkSource } from './deep-links.ts';\nexport {\n Direction,\n type DirectionContext,\n type DirectionSource,\n type LayoutDirection,\n} from './direction.ts';\nexport {\n androidPermission,\n type AndroidPermissions,\n type PermissionAnswer,\n} from './android-permissions.ts';\nexport { DevMenu, type DevMenuSource, type NativeDevMenu } from './dev-menu.ts';\nexport { Dialogs, type Choice, type NativeDialogs } from './dialogs.ts';\nexport {\n LayoutAnimation,\n type LayoutChange,\n type LayoutEasing,\n type NativeLayoutAnimation,\n} from './layout-animation.ts';\nexport { Sharing, type NativeSharing, type ShareRequest } from './sharing.ts';\nexport { Vibration, type NativeVibration } from './vibration.ts';\nexport { HardwareBack, hardwareBackSource, type HardwareBackSource } from './hardware-back.ts';\nexport {\n KEYBOARD_MOTION,\n Keyboard,\n keyboardSource,\n type KeyboardMetrics,\n type KeyboardMotion,\n type KeyboardSource,\n} from './keyboard.ts';\nexport type { NativeKeyboardEvent } from './react-native.ts';\nexport { SafeArea, type Frame, type Insets } from './safe-area.ts';\nexport { COMPACT_WIDTH, Screen, type ScreenSource, type Size, type Sizes } from './screen.ts';\nexport {\n StatusBar,\n statusBarSource,\n type PlatformStatusBarStyle,\n type StatusBarSource,\n type StatusBarState,\n type StatusBarStyle,\n} from './status-bar.ts';\nexport {\n TopClaim,\n WindowClaims,\n onWindowFront,\n sharedBySource,\n type Claim,\n} from './window-claims.ts';\nexport {\n NavigationBar,\n navigationBarSource,\n type NavigationBarSource,\n type NavigationBarState,\n type NavigationBarStyle,\n} from './navigation-bar.ts';\nexport { SCREEN_IN_FRONT } from './screen-in-front.ts';\nexport { SCREEN_SHOWN } from './screen-shown.ts';\nexport { NATIVE_HISTORY } from './native-history.ts';\nexport { OS } from './os.ts';\nexport { OS_VERSION } from './os-version.ts';\nexport { injectToken, type InjectTokenOptions } from './inject-token.ts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAuC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAuC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAuB,MAAM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ACrB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,GAGzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAqB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,UAAU,GAMX,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * The host: the device, the operating system, and the user's settings.\n *\n * Every capability here is a service with its own factory, so injecting one is the whole setup\n * and one nobody injects is never constructed. Off a device each falls back to doing nothing,\n * which is what makes the whole package importable by the test suite.\n */\nexport {\n Accessibility,\n type AccessibilitySettings,\n type AccessibilitySource,\n} from './accessibility.ts';\nexport { AppState, type AppStateSource, type AppStatus } from './app-state.ts';\nexport { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';\nexport {\n currentConditions,\n deviceTokens,\n hairlineTokens,\n watchConditions,\n type WatchOptions,\n} from './conditions.ts';\nexport { DeepLinks, deepLinkSource, pathOf, type DeepLinkSource } from './deep-links.ts';\nexport {\n Direction,\n type DirectionContext,\n type DirectionSource,\n type LayoutDirection,\n} from './direction.ts';\nexport {\n androidPermission,\n type AndroidPermissions,\n type PermissionAnswer,\n} from './android-permissions.ts';\nexport { DevMenu, type DevMenuSource, type NativeDevMenu } from './dev-menu.ts';\nexport { Dialogs, type Choice, type NativeDialogs } from './dialogs.ts';\nexport {\n LayoutAnimation,\n type LayoutChange,\n type LayoutEasing,\n type NativeLayoutAnimation,\n} from './layout-animation.ts';\nexport { Sharing, type NativeSharing, type ShareRequest } from './sharing.ts';\nexport { Vibration, type NativeVibration } from './vibration.ts';\nexport { HardwareBack, hardwareBackSource, type HardwareBackSource } from './hardware-back.ts';\nexport {\n KEYBOARD_MOTION,\n Keyboard,\n keyboardSource,\n type KeyboardMetrics,\n type KeyboardMotion,\n type KeyboardSource,\n} from './keyboard.ts';\nexport type { NativeKeyboardEvent } from './react-native.ts';\nexport { SafeArea, type Frame, type Insets } from './safe-area.ts';\nexport { COMPACT_WIDTH, Screen, type ScreenSource, type Size, type Sizes } from './screen.ts';\nexport {\n StatusBar,\n statusBarSource,\n type PlatformStatusBarStyle,\n type StatusBarSource,\n type StatusBarState,\n type StatusBarStyle,\n} from './status-bar.ts';\nexport {\n TopClaim,\n WindowClaims,\n onWindowFront,\n sharedBySource,\n type Claim,\n} from './window-claims.ts';\nexport {\n NavigationBar,\n navigationBarSource,\n type NavigationBarSource,\n type NavigationBarState,\n type NavigationBarStyle,\n} from './navigation-bar.ts';\nexport { SCREEN_IN_FRONT } from './screen-in-front.ts';\nexport { SCREEN_SHOWN } from './screen-shown.ts';\nexport { NATIVE_HISTORY } from './native-history.ts';\nexport { APPLE, DESKTOP, OS } from './os.ts';\nexport {\n MENU_MODEL,\n createMenuModel,\n defaultMenuBar,\n isSeparator,\n mergeMenuBar,\n menuModelInTreeOrder,\n treeOrder,\n type MenuEntry,\n type MenuGroupModel,\n type MenuGroupRole,\n type MenuItemModel,\n type MenuModel,\n type MenuRole,\n type MenuSeparator,\n} from './menu-model.ts';\nexport {\n isEditingShortcut,\n matchesShortcut,\n navigationShortcut,\n parseShortcut,\n shortcutFires,\n type KeyChord,\n type ParsedShortcut,\n type ShortcutOs,\n} from './shortcut.ts';\nexport {\n Processes,\n UndeclaredCapabilityError,\n type ChildProcess,\n type NativeProcesses,\n type ProcessEvent,\n type ProcessExit,\n type SpawnOptions,\n} from './processes.ts';\nexport {\n SEARCH_PATH,\n SpawnRuleError,\n compileCapability,\n filterEnvironment,\n matchArguments,\n matchSpawn,\n parseArgument,\n programProblem,\n resolveProgram,\n type ArgumentRule,\n type CompiledCapability,\n type PlaceholderValues,\n type ProgramLookup,\n type SpawnCapability,\n type SpawnMatch,\n} from './spawn-rules.ts';\nexport {\n desktopOptionProblems,\n pathAllowed,\n pathProblem,\n validateDesktopOptions,\n type DesktopCapabilities,\n type DesktopOptions,\n type DocumentType,\n type PathCapability,\n} from './desktop-options.ts';\nexport {\n macosPermissions,\n type ExpoPermissionConfig,\n type MacosPermissions,\n} from './desktop-permissions.ts';\nexport {\n Menus,\n menuActionId,\n menusSource,\n serializeMenu,\n type NativeMenuEntry,\n type NativeMenuEvent,\n type NativeMenus,\n type NativeWindowHistory,\n type NativeShortcut,\n type SerializedMenu,\n} from './menus.ts';\nexport { Dock, type NativeDock } from './dock.ts';\nexport { nativeSplitViews } from './split-views.ts';\nexport {\n DragAndDrop,\n dragAndDropSource,\n type NativeDragAndDrop,\n type NativeDragItem,\n type NativeDropEvent,\n} from './drag-and-drop.ts';\nexport { UndoStack, type NativeUndo, type NativeUndoEvent, type UndoAction } from './undo-stack.ts';\nexport {\n OS_SUPPORT,\n SUPPORT_OSES,\n platformsLine,\n supportRowOf,\n type OsSupportRow,\n type SupportOs,\n} from './os-support.ts';\nexport { Shell, type NativeShell } from './shell.ts';\nexport {\n Tray,\n type NativeTray,\n type NativeTrayEvent,\n type NativeTrayIcon,\n type TrayIconModel,\n} from './tray.ts';\nexport { SIDEBAR_SELECTION } from './sidebar-selection.ts';\nexport { expoViewName } from './expo-view-name.ts';\nexport { hostInputNames, ownHost } from './own-host.ts';\nexport { WINDOW_NAVIGATOR, type WindowNavigator } from './window-navigator.ts';\nexport {\n AppWindows,\n CURRENT_WINDOW,\n MAIN_WINDOW_OPTIONS,\n WINDOW_MOUNTER,\n provideMainWindow,\n type AppWindow,\n type CloseGuard,\n type ComponentWindowOptions,\n type MainWindowOptions,\n type NativeWindowEvent,\n type NativeWindowRequest,\n type NativeWindows,\n type RouteWindowOptions,\n type TitleBar,\n type WindowMount,\n type WindowMounter,\n type WindowOptions,\n windowsSource,\n} from './app-windows.ts';\nexport {\n APP_LIFECYCLE_OPTIONS,\n AppLifecycle,\n WILL_QUIT_DEADLINE_MS,\n provideAppLifecycle,\n quitsWithLastWindow,\n type AppLifecycleOptions,\n} from './app-lifecycle.ts';\nexport { OS_VERSION } from './os-version.ts';\nexport { injectToken, type InjectTokenOptions } from './inject-token.ts';\nexport { type ControlSize } from './control-size.ts';\nexport {\n RESTORABLE_WINDOWS,\n WINDOW_RESTORE_STORE,\n provideRestorableWindows,\n type RestoredWindow,\n type WindowRestoreStore,\n} from './window-restore.ts';\nexport { buildMenuTemplate, type MenuTemplate } from './menu-template.ts';\nexport {\n INTERACTION_OBSERVERS,\n MAX_TEXT_LENGTH,\n describeElement,\n interactionObservers,\n notifyInteraction,\n provideInteractionObserver,\n textWithin,\n type InteractionDirection,\n type InteractionEvent,\n type InteractionGesture,\n type InteractionObserver,\n type InteractionType,\n} from './interaction-observer.ts';\n"]}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Interactions as plain events, for an analytics or monitoring tool to record.
3
+ *
4
+ * Such a tool usually learns about taps by wrapping React Native's own `Pressable` and
5
+ * `ScrollView`, which never render here: every control is a host view on the press machine in
6
+ * `@ng-native/components`, or a view the platform draws, such as an `@expo/ui` control or a native
7
+ * tab. So the control says what happened, and an app maps it to whatever its tool takes. Nothing is
8
+ * built while no observer is registered.
9
+ *
10
+ * Here rather than in `@ng-native/components` because `@ng-native/expo` and `@ng-native/router`
11
+ * report too, and the Angular-facing packages cannot import each other.
12
+ */
13
+ import { InjectionToken, type Injector, type Provider } from '@angular/core';
14
+ import { type HostEngine, type HostNode } from '@ng-native/fabric';
15
+ /**
16
+ * What the user did. `gesture` is a native gesture that is none of the others: a slow pan, a
17
+ * pinch, a rotation.
18
+ */
19
+ export type InteractionType = 'click' | 'long-press' | 'scroll' | 'swipe' | 'gesture';
20
+ /**
21
+ * Which way a scroll view's drag moved the content into view (`down` shows what is below), or
22
+ * which way a native gesture's finger moved (`down` is towards the bottom of the screen).
23
+ */
24
+ export type InteractionDirection = 'up' | 'down' | 'left' | 'right';
25
+ /**
26
+ * The native gesture an event came from: the builder's name, `Gesture.LongPress()` as
27
+ * `long-press`. A string, so a gesture added to the library later still has a name.
28
+ */
29
+ export type InteractionGesture = 'tap' | 'long-press' | 'pan' | 'fling' | 'pinch' | 'rotation' | 'manual' | (string & {});
30
+ /** One interaction, as an observer receives it. */
31
+ export interface InteractionEvent {
32
+ readonly type: InteractionType;
33
+ /** The element's name as written in the template: `pressable`, `text`, `scroll-view`, ... */
34
+ readonly element: string;
35
+ /**
36
+ * The selector of the nearest component the control is rendered inside, such as `app-button`
37
+ * for the `<pressable>` in its template, or for one projected into its `<ng-content>`. A
38
+ * component that is the control itself is named by `element` instead, and this is the component
39
+ * around it. A routed page is named the same way. A component matched by an attribute is named
40
+ * by its selector written out, such as `section[x-card]`. Absent for a control in the root
41
+ * component's own template, and in a component with no selector, such as a page that has none.
42
+ * A component's host can give another name with an `interactionName` attribute, or `''` to be
43
+ * passed over for the component around it.
44
+ */
45
+ readonly component?: string;
46
+ /** `accessibilityLabel`, or `aria-label`. */
47
+ readonly label?: string;
48
+ readonly testID?: string;
49
+ /** `nativeID`, or `id`. */
50
+ readonly nativeID?: string;
51
+ /** `role`, or `accessibilityRole`. */
52
+ readonly role?: string;
53
+ /**
54
+ * The text inside the control, joined with spaces and cut to `MAX_TEXT_LENGTH` characters. On a
55
+ * `click` and a `long-press`, never a `scroll` or `swipe`. It can hold what the user typed or was
56
+ * shown, so redact it before it leaves the device.
57
+ */
58
+ readonly text?: string;
59
+ /** The tag the control's own view was committed with, or null where the host has none. */
60
+ readonly nativeTag: number | null;
61
+ /** Where the touch landed in the window. Absent for a press that had no touch. */
62
+ readonly pageX?: number;
63
+ readonly pageY?: number;
64
+ /** Where the touch landed in the control. */
65
+ readonly locationX?: number;
66
+ readonly locationY?: number;
67
+ /** The control's size from its last layout, once it has had one. */
68
+ readonly width?: number;
69
+ readonly height?: number;
70
+ /** Scrolls, swipes and pans only. */
71
+ readonly direction?: InteractionDirection;
72
+ /** The native gesture this came from, if it came from one. */
73
+ readonly gesture?: InteractionGesture;
74
+ /** A pan's or fling's straight-line distance from where it started, in points. */
75
+ readonly distance?: number;
76
+ /** A pinch's scale as it ended: above 1 spread apart, below 1 pinched together. */
77
+ readonly scale?: number;
78
+ /**
79
+ * A touch, or a press with none: Android's click from a keyboard or TalkBack, or a control the
80
+ * platform draws, such as a `<switch>`, which reports no touch point.
81
+ */
82
+ readonly source: 'touch' | 'click';
83
+ /** Milliseconds since the epoch. */
84
+ readonly timestamp: number;
85
+ }
86
+ export type InteractionObserver = (event: InteractionEvent) => void;
87
+ /** Every observer the app registered. See `provideInteractionObserver`. */
88
+ export declare const INTERACTION_OBSERVERS: InjectionToken<readonly InteractionObserver[]>;
89
+ /**
90
+ * Hear every tap, long press, scroll and swipe in the app. Can be given more than once, and every
91
+ * observer hears every interaction, after the control's own `(press)` has run.
92
+ *
93
+ * ```ts
94
+ * providers: [
95
+ * provideInteractionObserver((event) => {
96
+ * if (event.type === 'click') analytics.tap(event.label ?? event.element);
97
+ * }),
98
+ * ]
99
+ * ```
100
+ */
101
+ export declare function provideInteractionObserver(observer: InteractionObserver): Provider;
102
+ /** How much of a control's text an event carries. */
103
+ export declare const MAX_TEXT_LENGTH = 100;
104
+ /** The observers an injector can see, or null. Read at the moment of an interaction, not before. */
105
+ export declare function interactionObservers(injector: Injector): readonly InteractionObserver[] | null;
106
+ /**
107
+ * Hand the event to each observer. One that throws is reported, and stops neither the others nor
108
+ * the app.
109
+ */
110
+ export declare function notifyInteraction(observers: readonly InteractionObserver[], event: InteractionEvent): void;
111
+ /**
112
+ * The parts of an event that come from the element: what it committed, so a label or role a
113
+ * component composed onto it, or implied, is the one reported, as a screen reader hears it.
114
+ */
115
+ export declare function describeElement(engine: HostEngine, node: HostNode): Pick<InteractionEvent, 'element' | 'component' | 'label' | 'testID' | 'nativeID' | 'role' | 'nativeTag'>;
116
+ /** The text under a node, in order, with runs of whitespace collapsed, or undefined if none. */
117
+ export declare function textWithin(node: HostNode): string | undefined;