@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
@@ -29,11 +29,18 @@ export interface AccessibilitySource {
29
29
  subscribe(listener: (settings: Partial<AccessibilitySettings>) => void): () => void;
30
30
  announce(message: string): void;
31
31
  }
32
+ /**
33
+ * The system text size, as a multiplier: `PixelRatio.getFontScale()`. One off a device, and on a
34
+ * Mac, where nothing resizes an app: it reaches Mac sizes with `macos:` variants instead.
35
+ */
36
+ export declare function systemFontScale(native?: import("./react-native.ts").ReactNative | null): number;
32
37
  export declare function accessibilitySource(): AccessibilitySource;
33
38
  export declare class Accessibility {
34
39
  /** Overridden in a test to turn a setting on. */
35
40
  static readonly SOURCE: InjectionToken<AccessibilitySource>;
36
41
  private readonly source;
42
+ /** Whether the service is here: on every OS, where it answers what the OS reports. */
43
+ readonly available: Signal<boolean>;
37
44
  private readonly settings;
38
45
  /** VoiceOver or TalkBack is running. */
39
46
  readonly screenReader: Signal<boolean>;
@@ -10,8 +10,18 @@
10
10
  * React Native reports all three asynchronously. A first paint therefore assumes nothing is on.
11
11
  */
12
12
  import { DestroyRef, InjectionToken, Service, computed, inject, signal, } from '@angular/core';
13
+ import { platformOs } from "./os.js";
13
14
  import { reactNative } from "./react-native.js";
14
15
  import * as i0 from "@angular/core";
16
+ /**
17
+ * The system text size, as a multiplier: `PixelRatio.getFontScale()`. One off a device, and on a
18
+ * Mac, where nothing resizes an app: it reaches Mac sizes with `macos:` variants instead.
19
+ */
20
+ export function systemFontScale(native = reactNative()) {
21
+ if (platformOs() === 'macos')
22
+ return 1;
23
+ return native?.PixelRatio.getFontScale() ?? 1;
24
+ }
15
25
  export function accessibilitySource() {
16
26
  const native = reactNative();
17
27
  if (!native) {
@@ -43,7 +53,7 @@ export function accessibilitySource() {
43
53
  read(() => info.isReduceMotionEnabled()),
44
54
  read(() => info.isBoldTextEnabled()),
45
55
  ]);
46
- return { screenReader, reduceMotion, boldText, fontScale: native.PixelRatio.getFontScale() };
56
+ return { screenReader, reduceMotion, boldText, fontScale: systemFontScale(native) };
47
57
  },
48
58
  subscribe: (listener) => {
49
59
  const subscriptions = [
@@ -54,7 +64,7 @@ export function accessibilitySource() {
54
64
  // so the app coming back to the foreground is what stands in for one.
55
65
  native.AppState.addEventListener('change', (state) => {
56
66
  if (state === 'active')
57
- listener({ fontScale: native.PixelRatio.getFontScale() });
67
+ listener({ fontScale: systemFontScale(native) });
58
68
  }),
59
69
  ];
60
70
  return () => subscriptions.forEach((subscription) => subscription.remove());
@@ -66,6 +76,8 @@ export class Accessibility {
66
76
  /** Overridden in a test to turn a setting on. */
67
77
  static SOURCE = new InjectionToken('angular-native.accessibilitySource', { factory: accessibilitySource });
68
78
  source = inject(Accessibility.SOURCE);
79
+ /** Whether the service is here: on every OS, where it answers what the OS reports. */
80
+ available = signal(true).asReadonly();
69
81
  settings = signal({
70
82
  screenReader: false,
71
83
  reduceMotion: false,
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.js","sourceRoot":"","sources":["../src/accessibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAsBhD,MAAM,UAAU,mBAAmB;IACjC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,CACZ,OAAO,CAAC,OAAO,CAAC;gBACd,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,KAAK;gBACnB,QAAQ,EAAE,KAAK;gBACf,SAAS,EAAE,CAAC;aACb,CAAC;YACJ,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC;YACzB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;SACnB,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACtC,6EAA6E;IAC7E,MAAM,IAAI,GAAG,KAAK,EAAE,GAA2B,EAAE,EAAE;QACjD,IAAI,CAAC;YACH,OAAO,MAAM,GAAG,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CA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C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,CAAC,EAC1D,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5C,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,OAAe;QACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;uGAlDU,aAAa;wGAAb,aAAa;;2FAAb,aAAa;kBADzB,OAAO","sourcesContent":["/**\n * What the user has turned on in the system's accessibility settings.\n *\n * The components apply the defaults React Native's wrappers do - roles, labels, whether a view is\n * an element at all - without anything being injected. This is for the decisions those defaults\n * cannot make: not animating when the user asked for less motion, announcing something that\n * changed off screen, giving a screen reader a different affordance than a finger gets.\n *\n * Every value starts at its neutral setting and is corrected once the platform answers, because\n * React Native reports all three asynchronously. A first paint therefore assumes nothing is on.\n */\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\nexport interface AccessibilitySettings {\n readonly screenReader: boolean;\n readonly reduceMotion: boolean;\n readonly boldText: boolean;\n /**\n * The user's text size, as a multiplier of the default.\n *\n * Not an event: it is read at startup and again when the app comes back, because changing it\n * means leaving for Settings. Text scales natively without anything here, so this is for the\n * layouts that have to give way to it - a row height, a line clamp, an icon beside a label.\n */\n readonly fontScale: number;\n}\n\nexport interface AccessibilitySource {\n current(): Promise<AccessibilitySettings>;\n subscribe(listener: (settings: Partial<AccessibilitySettings>) => void): () => void;\n announce(message: string): void;\n}\n\nexport function accessibilitySource(): AccessibilitySource {\n const native = reactNative();\n if (!native) {\n return {\n current: () =>\n Promise.resolve({\n screenReader: false,\n reduceMotion: false,\n boldText: false,\n fontScale: 1,\n }),\n subscribe: () => () => {},\n announce: () => {},\n };\n }\n\n const info = native.AccessibilityInfo;\n // A read that fails is the neutral setting, so the other three still arrive.\n const read = async (ask: () => Promise<boolean>) => {\n try {\n return await ask();\n } catch {\n return false;\n }\n };\n return {\n current: async () => {\n const [screenReader, reduceMotion, boldText] = await Promise.all([\n read(() => info.isScreenReaderEnabled()),\n read(() => info.isReduceMotionEnabled()),\n read(() => info.isBoldTextEnabled()),\n ]);\n return { screenReader, reduceMotion, boldText, fontScale: native.PixelRatio.getFontScale() };\n },\n subscribe: (listener) => {\n const subscriptions = [\n info.addEventListener('screenReaderChanged', (screenReader) => listener({ screenReader })),\n info.addEventListener('reduceMotionChanged', (reduceMotion) => listener({ reduceMotion })),\n info.addEventListener('boldTextChanged', (boldText) => listener({ boldText })),\n // `fontScale` has no change event of its own - changing it means leaving for Settings -\n // so the app coming back to the foreground is what stands in for one.\n native.AppState.addEventListener('change', (state) => {\n if (state === 'active') listener({ fontScale: native.PixelRatio.getFontScale() });\n }),\n ];\n return () => subscriptions.forEach((subscription) => subscription.remove());\n },\n announce: (message) => info.announceForAccessibility(message),\n };\n}\n\n@Service()\nexport class Accessibility {\n /** Overridden in a test to turn a setting on. */\n static readonly SOURCE = new InjectionToken<AccessibilitySource>(\n 'angular-native.accessibilitySource',\n { factory: accessibilitySource },\n );\n\n private readonly source = inject(Accessibility.SOURCE);\n private readonly settings = signal<AccessibilitySettings>({\n screenReader: false,\n reduceMotion: false,\n boldText: false,\n fontScale: 1,\n });\n\n /** VoiceOver or TalkBack is running. */\n readonly screenReader: Signal<boolean> = computed(() => this.settings().screenReader);\n /**\n * The user asked for less animation. `@media (prefers-reduced-motion: reduce)` reads the same\n * setting and is the better answer wherever the motion is styling rather than logic.\n */\n readonly reduceMotion: Signal<boolean> = computed(() => this.settings().reduceMotion);\n /** The system font is heavier, so hand-tuned weights may need to give way. */\n readonly boldText: Signal<boolean> = computed(() => this.settings().boldText);\n /**\n * How much larger the user has asked text to be. One is the default; the largest accessibility\n * sizes are past three, which is where a row built for one line stops working.\n */\n readonly fontScale: Signal<number> = computed(() => this.settings().fontScale);\n\n constructor() {\n let heard: Partial<AccessibilitySettings> = {};\n // A read that fails leaves the neutral settings, which the change events still correct.\n this.source.current().then(\n (settings) => this.settings.set({ ...settings, ...heard }),\n () => {},\n );\n const stop = this.source.subscribe((change) => {\n heard = { ...heard, ...change };\n this.settings.update((current) => ({ ...current, ...change }));\n });\n inject(DestroyRef).onDestroy(stop);\n }\n\n /**\n * Say something to a screen reader that no focus change would have said. A list that reordered,\n * a search that returned nothing: changes a sighted user sees and a screen reader would miss.\n */\n announce(message: string): void {\n this.source.announce(message);\n }\n}\n"]}
1
+ {"version":3,"file":"accessibility.js","sourceRoot":"","sources":["../src/accessibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAsBhD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAM,GAAG,WAAW,EAAE;IACpD,IAAI,UAAU,EAAE,KAAK,OAAO;QAAE,OAAO,CAAC,CAAC;IACvC,OAAO,MAAM,EAAE,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,M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,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;uGArDU,aAAa;wGAAb,aAAa;;2FAAb,aAAa;kBADzB,OAAO","sourcesContent":["/**\n * What the user has turned on in the system's accessibility settings.\n *\n * The components apply the defaults React Native's wrappers do - roles, labels, whether a view is\n * an element at all - without anything being injected. This is for the decisions those defaults\n * cannot make: not animating when the user asked for less motion, announcing something that\n * changed off screen, giving a screen reader a different affordance than a finger gets.\n *\n * Every value starts at its neutral setting and is corrected once the platform answers, because\n * React Native reports all three asynchronously. A first paint therefore assumes nothing is on.\n */\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport { platformOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\n\nexport interface AccessibilitySettings {\n readonly screenReader: boolean;\n readonly reduceMotion: boolean;\n readonly boldText: boolean;\n /**\n * The user's text size, as a multiplier of the default.\n *\n * Not an event: it is read at startup and again when the app comes back, because changing it\n * means leaving for Settings. Text scales natively without anything here, so this is for the\n * layouts that have to give way to it - a row height, a line clamp, an icon beside a label.\n */\n readonly fontScale: number;\n}\n\nexport interface AccessibilitySource {\n current(): Promise<AccessibilitySettings>;\n subscribe(listener: (settings: Partial<AccessibilitySettings>) => void): () => void;\n announce(message: string): void;\n}\n\n/**\n * The system text size, as a multiplier: `PixelRatio.getFontScale()`. One off a device, and on a\n * Mac, where nothing resizes an app: it reaches Mac sizes with `macos:` variants instead.\n */\nexport function systemFontScale(native = reactNative()): number {\n if (platformOs() === 'macos') return 1;\n return native?.PixelRatio.getFontScale() ?? 1;\n}\n\nexport function accessibilitySource(): AccessibilitySource {\n const native = reactNative();\n if (!native) {\n return {\n current: () =>\n Promise.resolve({\n screenReader: false,\n reduceMotion: false,\n boldText: false,\n fontScale: 1,\n }),\n subscribe: () => () => {},\n announce: () => {},\n };\n }\n\n const info = native.AccessibilityInfo;\n // A read that fails is the neutral setting, so the other three still arrive.\n const read = async (ask: () => Promise<boolean>) => {\n try {\n return await ask();\n } catch {\n return false;\n }\n };\n return {\n current: async () => {\n const [screenReader, reduceMotion, boldText] = await Promise.all([\n read(() => info.isScreenReaderEnabled()),\n read(() => info.isReduceMotionEnabled()),\n read(() => info.isBoldTextEnabled()),\n ]);\n return { screenReader, reduceMotion, boldText, fontScale: systemFontScale(native) };\n },\n subscribe: (listener) => {\n const subscriptions = [\n info.addEventListener('screenReaderChanged', (screenReader) => listener({ screenReader })),\n info.addEventListener('reduceMotionChanged', (reduceMotion) => listener({ reduceMotion })),\n info.addEventListener('boldTextChanged', (boldText) => listener({ boldText })),\n // `fontScale` has no change event of its own - changing it means leaving for Settings -\n // so the app coming back to the foreground is what stands in for one.\n native.AppState.addEventListener('change', (state) => {\n if (state === 'active') listener({ fontScale: systemFontScale(native) });\n }),\n ];\n return () => subscriptions.forEach((subscription) => subscription.remove());\n },\n announce: (message) => info.announceForAccessibility(message),\n };\n}\n\n@Service()\nexport class Accessibility {\n /** Overridden in a test to turn a setting on. */\n static readonly SOURCE = new InjectionToken<AccessibilitySource>(\n 'angular-native.accessibilitySource',\n { factory: accessibilitySource },\n );\n\n private readonly source = inject(Accessibility.SOURCE);\n\n /** Whether the service is here: on every OS, where it answers what the OS reports. */\n readonly available: Signal<boolean> = signal(true).asReadonly();\n private readonly settings = signal<AccessibilitySettings>({\n screenReader: false,\n reduceMotion: false,\n boldText: false,\n fontScale: 1,\n });\n\n /** VoiceOver or TalkBack is running. */\n readonly screenReader: Signal<boolean> = computed(() => this.settings().screenReader);\n /**\n * The user asked for less animation. `@media (prefers-reduced-motion: reduce)` reads the same\n * setting and is the better answer wherever the motion is styling rather than logic.\n */\n readonly reduceMotion: Signal<boolean> = computed(() => this.settings().reduceMotion);\n /** The system font is heavier, so hand-tuned weights may need to give way. */\n readonly boldText: Signal<boolean> = computed(() => this.settings().boldText);\n /**\n * How much larger the user has asked text to be. One is the default; the largest accessibility\n * sizes are past three, which is where a row built for one line stops working.\n */\n readonly fontScale: Signal<number> = computed(() => this.settings().fontScale);\n\n constructor() {\n let heard: Partial<AccessibilitySettings> = {};\n // A read that fails leaves the neutral settings, which the change events still correct.\n this.source.current().then(\n (settings) => this.settings.set({ ...settings, ...heard }),\n () => {},\n );\n const stop = this.source.subscribe((change) => {\n heard = { ...heard, ...change };\n this.settings.update((current) => ({ ...current, ...change }));\n });\n inject(DestroyRef).onDestroy(stop);\n }\n\n /**\n * Say something to a screen reader that no focus change would have said. A list that reordered,\n * a search that returned nothing: changes a sighted user sees and a screen reader would miss.\n */\n announce(message: string): void {\n this.source.announce(message);\n }\n}\n"]}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * How a desktop app lives and ends: whether it survives its last window, and what runs before it
3
+ * quits. Configured in code with `provideAppLifecycle`, each value defaulting to the OS's own
4
+ * convention. On iOS and Android the OS ends an app, so nothing here runs there.
5
+ */
6
+ import { InjectionToken, type EnvironmentProviders } from '@angular/core';
7
+ import * as i0 from "@angular/core";
8
+ export interface AppLifecycleOptions {
9
+ /**
10
+ * Whether closing the last window quits the app. Defaults to the OS's convention: false on
11
+ * macOS, where an app stays running in the Dock and a click there opens its main window again.
12
+ */
13
+ readonly quitWhenLastWindowCloses?: boolean;
14
+ }
15
+ /** What `provideAppLifecycle` was given; nothing where it was not called. */
16
+ export declare const APP_LIFECYCLE_OPTIONS: InjectionToken<AppLifecycleOptions>;
17
+ /** Configure how the app lives on a desktop OS. Each option left out follows the OS. */
18
+ export declare function provideAppLifecycle(options: AppLifecycleOptions): EnvironmentProviders;
19
+ /**
20
+ * Whether an app on `os` quits when its last window closes, unless it says otherwise. macOS keeps
21
+ * it running. A desktop OS added later quits, as Windows and Linux apps do; on a phone or tablet
22
+ * OS the question does not arise.
23
+ */
24
+ export declare const quitsWithLastWindow: (os: string) => boolean;
25
+ /** How long `willQuit` handlers have, together, before the app quits without them. */
26
+ export declare const WILL_QUIT_DEADLINE_MS = 5000;
27
+ type WillQuit = () => void | Promise<void>;
28
+ export declare class AppLifecycle {
29
+ private readonly options;
30
+ private readonly os;
31
+ private readonly handlers;
32
+ /** Whether closing the last window quits the app: the option given, or the OS's convention. */
33
+ readonly quitWhenLastWindowCloses: boolean;
34
+ /**
35
+ * Run `handler` when the app is about to quit, after every window's `canClose` guard has agreed.
36
+ * The app waits for what it returns, for at most five seconds across every handler. Answers the
37
+ * function that removes it.
38
+ */
39
+ willQuit(handler: WillQuit): () => void;
40
+ /**
41
+ * Run every `willQuit` handler, together, and settle once each has or the deadline has passed.
42
+ * A handler that throws or rejects does not keep the app from quitting. What `AppWindows` runs
43
+ * as the host asks to quit.
44
+ */
45
+ runWillQuit(deadline?: number): Promise<void>;
46
+ static ɵfac: i0.ɵɵFactoryDeclaration<AppLifecycle, never>;
47
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
48
+ }
49
+ export {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * How a desktop app lives and ends: whether it survives its last window, and what runs before it
3
+ * quits. Configured in code with `provideAppLifecycle`, each value defaulting to the OS's own
4
+ * convention. On iOS and Android the OS ends an app, so nothing here runs there.
5
+ */
6
+ import { InjectionToken, Service, inject, makeEnvironmentProviders, } from '@angular/core';
7
+ import { injectOs } from "./os.js";
8
+ import * as i0 from "@angular/core";
9
+ /** What `provideAppLifecycle` was given; nothing where it was not called. */
10
+ export const APP_LIFECYCLE_OPTIONS = new InjectionToken('angular-native.appLifecycleOptions', { factory: () => ({}) });
11
+ /** Configure how the app lives on a desktop OS. Each option left out follows the OS. */
12
+ export function provideAppLifecycle(options) {
13
+ return makeEnvironmentProviders([{ provide: APP_LIFECYCLE_OPTIONS, useValue: options }]);
14
+ }
15
+ /**
16
+ * Whether an app on `os` quits when its last window closes, unless it says otherwise. macOS keeps
17
+ * it running. A desktop OS added later quits, as Windows and Linux apps do; on a phone or tablet
18
+ * OS the question does not arise.
19
+ */
20
+ export const quitsWithLastWindow = (os) => os !== 'macos' && os !== 'ios';
21
+ /** How long `willQuit` handlers have, together, before the app quits without them. */
22
+ export const WILL_QUIT_DEADLINE_MS = 5000;
23
+ export class AppLifecycle {
24
+ options = inject(APP_LIFECYCLE_OPTIONS);
25
+ os = injectOs();
26
+ handlers = new Set();
27
+ /** Whether closing the last window quits the app: the option given, or the OS's convention. */
28
+ quitWhenLastWindowCloses = this.options.quitWhenLastWindowCloses ?? quitsWithLastWindow(this.os);
29
+ /**
30
+ * Run `handler` when the app is about to quit, after every window's `canClose` guard has agreed.
31
+ * The app waits for what it returns, for at most five seconds across every handler. Answers the
32
+ * function that removes it.
33
+ */
34
+ willQuit(handler) {
35
+ this.handlers.add(handler);
36
+ return () => void this.handlers.delete(handler);
37
+ }
38
+ /**
39
+ * Run every `willQuit` handler, together, and settle once each has or the deadline has passed.
40
+ * A handler that throws or rejects does not keep the app from quitting. What `AppWindows` runs
41
+ * as the host asks to quit.
42
+ */
43
+ async runWillQuit(deadline = WILL_QUIT_DEADLINE_MS) {
44
+ const running = [...this.handlers].map(async (handler) => {
45
+ try {
46
+ await handler();
47
+ }
48
+ catch (error) {
49
+ console.error('[angular-native] A willQuit handler failed:', error);
50
+ }
51
+ });
52
+ let timer;
53
+ const late = new Promise((resolve) => (timer = setTimeout(resolve, deadline)));
54
+ try {
55
+ await Promise.race([Promise.all(running), late]);
56
+ }
57
+ finally {
58
+ clearTimeout(timer);
59
+ }
60
+ }
61
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: AppLifecycle, deps: [], target: i0.ɵɵFactoryTarget.Service });
62
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: AppLifecycle });
63
+ }
64
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: AppLifecycle, decorators: [{
65
+ type: Service
66
+ }] });
67
+ //# sourceMappingURL=app-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-lifecycle.js","sourceRoot":"","sources":["../src/app-lifecycle.ts"],"names":[],"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D,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACvD,IAAI,CAAC;gBACH,MAAM,OAAO,EAAE,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;YACtE,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,KAAgD,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrF,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;uGAvCU,YAAY;wGAAZ,YAAY;;2FAAZ,YAAY;kBADxB,OAAO","sourcesContent":["/**\n * How a desktop app lives and ends: whether it survives its last window, and what runs before it\n * quits. Configured in code with `provideAppLifecycle`, each value defaulting to the OS's own\n * convention. On iOS and Android the OS ends an app, so nothing here runs there.\n */\nimport {\n InjectionToken,\n Service,\n inject,\n makeEnvironmentProviders,\n type EnvironmentProviders,\n} from '@angular/core';\nimport { injectOs } from './os.ts';\n\nexport interface AppLifecycleOptions {\n /**\n * Whether closing the last window quits the app. Defaults to the OS's convention: false on\n * macOS, where an app stays running in the Dock and a click there opens its main window again.\n */\n readonly quitWhenLastWindowCloses?: boolean;\n}\n\n/** What `provideAppLifecycle` was given; nothing where it was not called. */\nexport const APP_LIFECYCLE_OPTIONS = new InjectionToken<AppLifecycleOptions>(\n 'angular-native.appLifecycleOptions',\n { factory: () => ({}) },\n);\n\n/** Configure how the app lives on a desktop OS. Each option left out follows the OS. */\nexport function provideAppLifecycle(options: AppLifecycleOptions): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: APP_LIFECYCLE_OPTIONS, useValue: options }]);\n}\n\n/**\n * Whether an app on `os` quits when its last window closes, unless it says otherwise. macOS keeps\n * it running. A desktop OS added later quits, as Windows and Linux apps do; on a phone or tablet\n * OS the question does not arise.\n */\nexport const quitsWithLastWindow = (os: string): boolean => os !== 'macos' && os !== 'ios';\n\n/** How long `willQuit` handlers have, together, before the app quits without them. */\nexport const WILL_QUIT_DEADLINE_MS = 5000;\n\ntype WillQuit = () => void | Promise<void>;\n\n@Service()\nexport class AppLifecycle {\n private readonly options = inject(APP_LIFECYCLE_OPTIONS);\n private readonly os = injectOs();\n private readonly handlers = new Set<WillQuit>();\n\n /** Whether closing the last window quits the app: the option given, or the OS's convention. */\n readonly quitWhenLastWindowCloses: boolean =\n this.options.quitWhenLastWindowCloses ?? quitsWithLastWindow(this.os);\n\n /**\n * Run `handler` when the app is about to quit, after every window's `canClose` guard has agreed.\n * The app waits for what it returns, for at most five seconds across every handler. Answers the\n * function that removes it.\n */\n willQuit(handler: WillQuit): () => void {\n this.handlers.add(handler);\n return () => void this.handlers.delete(handler);\n }\n\n /**\n * Run every `willQuit` handler, together, and settle once each has or the deadline has passed.\n * A handler that throws or rejects does not keep the app from quitting. What `AppWindows` runs\n * as the host asks to quit.\n */\n async runWillQuit(deadline: number = WILL_QUIT_DEADLINE_MS): Promise<void> {\n const running = [...this.handlers].map(async (handler) => {\n try {\n await handler();\n } catch (error) {\n console.error('[angular-native] A willQuit handler failed:', error);\n }\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const late = new Promise<void>((resolve) => (timer = setTimeout(resolve, deadline)));\n try {\n await Promise.race([Promise.all(running), late]);\n } finally {\n clearTimeout(timer);\n }\n }\n}\n"]}
@@ -17,6 +17,8 @@ export declare class AppState {
17
17
  /** Overridden in a test to send the app to the background. */
18
18
  static readonly SOURCE: InjectionToken<AppStateSource>;
19
19
  private readonly source;
20
+ /** Whether the service is here: on every OS, where it answers what the OS reports. */
21
+ readonly available: Signal<boolean>;
20
22
  private readonly state;
21
23
  readonly current: Signal<AppStatus>;
22
24
  /** In front of the user and taking input. */
package/dist/app-state.js CHANGED
@@ -27,6 +27,8 @@ export class AppState {
27
27
  factory: appStateSource,
28
28
  });
29
29
  source = inject(AppState.SOURCE);
30
+ /** Whether the service is here: on every OS, where it answers what the OS reports. */
31
+ available = signal(true).asReadonly();
30
32
  state = signal(this.source.current(), /* @ts-ignore */
31
33
  ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
32
34
  current = this.state.asReadonly();
@@ -1 +1 @@
1
- {"version":3,"file":"app-state.js","sourceRoot":"","sources":["../src/app-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAShD,MAAM,KAAK,GAAG,CAAC,KAAgC,EAAa,EAAE,CAC5D,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAEpE,MAAM,UAAU,cAAc;IAC5B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;IAE3E,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CACxE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CACvB,CAAC;YACF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC;AAGD,MAAM,OAAO,QAAQ;IACnB,8DAA8D;IAC9D,MAAM,CAAU,MAAM,GAAG,IAAI,cAAc,CAAiB,+BAA+B,EAAE;QAC3F,OAAO,EAAE,cAAc;KACxB,CAAC,CAAC;IAEc,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,KAAK,GAAG,MAAM,CAAY,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;8EAAC,CAAC;IAEzD,OAAO,GAAsB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAC9D,6CAA6C;IACpC,MAAM,GAAoB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,QAAQ;+EAAC,CAAC;IAE7E;QACE,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;uGAfU,QAAQ;wGAAR,QAAQ;;2FAAR,QAAQ;kBADpB,OAAO","sourcesContent":["/**\n * Whether the app is in front of the user.\n *\n * `inactive` is iOS only and means the transitional state: the app switcher is open, a call is\n * coming in, the notification shade is down. Anything that should stop when the user is not\n * looking - a poll, a video, a timer - wants `active`, not the absence of `background`.\n */\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\nexport type AppStatus = 'active' | 'background' | 'inactive';\n\nexport interface AppStateSource {\n current(): AppStatus;\n subscribe(listener: (state: AppStatus) => void): () => void;\n}\n\nconst known = (state: string | null | undefined): AppStatus =>\n state === 'background' || state === 'inactive' ? state : 'active';\n\nexport function appStateSource(): AppStateSource {\n const native = reactNative();\n if (!native) return { current: () => 'active', subscribe: () => () => {} };\n\n return {\n current: () => known(native.AppState.currentState),\n subscribe: (listener) => {\n const subscription = native.AppState.addEventListener('change', (state) =>\n listener(known(state)),\n );\n return () => subscription.remove();\n },\n };\n}\n\n@Service()\nexport class AppState {\n /** Overridden in a test to send the app to the background. */\n static readonly SOURCE = new InjectionToken<AppStateSource>('angular-native.appStateSource', {\n factory: appStateSource,\n });\n\n private readonly source = inject(AppState.SOURCE);\n private readonly state = signal<AppStatus>(this.source.current());\n\n readonly current: Signal<AppStatus> = this.state.asReadonly();\n /** In front of the user and taking input. */\n readonly active: Signal<boolean> = computed(() => this.state() === 'active');\n\n constructor() {\n inject(DestroyRef).onDestroy(this.source.subscribe((state) => this.state.set(state)));\n }\n}\n"]}
1
+ {"version":3,"file":"app-state.js","sourceRoot":"","sources":["../src/app-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAShD,MAAM,KAAK,GAAG,CAAC,KAAgC,EAAa,EAAE,CAC5D,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAEpE,MAAM,UAAU,cAAc;IAC5B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,C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["/**\n * Whether the app is in front of the user.\n *\n * `inactive` is iOS only and means the transitional state: the app switcher is open, a call is\n * coming in, the notification shade is down. Anything that should stop when the user is not\n * looking - a poll, a video, a timer - wants `active`, not the absence of `background`.\n */\nimport {\n DestroyRef,\n InjectionToken,\n Service,\n computed,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\nexport type AppStatus = 'active' | 'background' | 'inactive';\n\nexport interface AppStateSource {\n current(): AppStatus;\n subscribe(listener: (state: AppStatus) => void): () => void;\n}\n\nconst known = (state: string | null | undefined): AppStatus =>\n state === 'background' || state === 'inactive' ? state : 'active';\n\nexport function appStateSource(): AppStateSource {\n const native = reactNative();\n if (!native) return { current: () => 'active', subscribe: () => () => {} };\n\n return {\n current: () => known(native.AppState.currentState),\n subscribe: (listener) => {\n const subscription = native.AppState.addEventListener('change', (state) =>\n listener(known(state)),\n );\n return () => subscription.remove();\n },\n };\n}\n\n@Service()\nexport class AppState {\n /** Overridden in a test to send the app to the background. */\n static readonly SOURCE = new InjectionToken<AppStateSource>('angular-native.appStateSource', {\n factory: appStateSource,\n });\n\n private readonly source = inject(AppState.SOURCE);\n\n /** Whether the service is here: on every OS, where it answers what the OS reports. */\n readonly available: Signal<boolean> = signal(true).asReadonly();\n private readonly state = signal<AppStatus>(this.source.current());\n\n readonly current: Signal<AppStatus> = this.state.asReadonly();\n /** In front of the user and taking input. */\n readonly active: Signal<boolean> = computed(() => this.state() === 'active');\n\n constructor() {\n inject(DestroyRef).onDestroy(this.source.subscribe((state) => this.state.set(state)));\n }\n}\n"]}
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Several windows from one Angular app: desktop windows on macOS and scenes on iPadOS.
3
+ *
4
+ * Every window is a root view on its own native surface, joined to the one app: root services, the
5
+ * one Router and one change detection are shared, and each window has an element injector that
6
+ * provides `CURRENT_WINDOW`. A route window renders a named outlet of the app's Router, which
7
+ * `WINDOW_NAVIGATOR` navigates; a component window renders a component with its inputs.
8
+ * `@ng-native/platform` mounts each through `WINDOW_MOUNTER`.
9
+ *
10
+ * On iPhone and Android `available()` is false and `open` resolves to null, as an inert call does.
11
+ *
12
+ * The host contract is `NativeWindows`, below: the host opens and closes surfaces when asked, and
13
+ * reports what the user does to them. The rules (guards, the last window, a Dock reopen, quitting)
14
+ * are here, so every OS that has windows follows the same ones.
15
+ */
16
+ import { InjectionToken, type Binding, type EnvironmentProviders, type Provider, type Signal, type Type } from '@angular/core';
17
+ import * as i0 from "@angular/core";
18
+ export type TitleBar = 'default' | 'transparent' | 'hidden';
19
+ /** How a window opens. Sizes are in points; each left out is the host's default. */
20
+ export interface WindowOptions {
21
+ readonly title?: string;
22
+ readonly width?: number;
23
+ readonly height?: number;
24
+ readonly minWidth?: number;
25
+ readonly minHeight?: number;
26
+ readonly maxWidth?: number;
27
+ readonly maxHeight?: number;
28
+ readonly resizable?: boolean;
29
+ /** `transparent` draws content under the title bar; `hidden` also hides the title. */
30
+ readonly titleBar?: TitleBar;
31
+ readonly fullScreen?: boolean;
32
+ /**
33
+ * Whether the window's frame is saved and restored on the next launch. On by default, keyed by
34
+ * the route outlet, the `restoreKey`, or `main`; a component window without a `restoreKey` has
35
+ * no key and is not saved.
36
+ */
37
+ readonly autosave?: boolean;
38
+ }
39
+ /** A window rendering a component. */
40
+ export interface ComponentWindowOptions extends WindowOptions {
41
+ /** Set on the component before its first change detection. */
42
+ readonly inputs?: Readonly<Record<string, unknown>>;
43
+ /**
44
+ * What the window is restored by, after a reload or a relaunch: on macOS and iPadOS it opens
45
+ * again with the same `inputs`, which must then survive `JSON.stringify`, where
46
+ * `provideRestorableWindows` names its component. Without one, a reload closes the window. One key is one window: opening
47
+ * a key that is open brings that window to the front.
48
+ */
49
+ readonly restoreKey?: string;
50
+ }
51
+ /** A window rendering the named outlet `outlet` of the app's Router, at `path`. */
52
+ export interface RouteWindowOptions extends WindowOptions {
53
+ readonly outlet: string;
54
+ readonly path: string;
55
+ }
56
+ /** The main window's options, as `provideMainWindow` takes them. */
57
+ export interface MainWindowOptions extends WindowOptions {
58
+ /**
59
+ * Whether the main window opens at launch. True by default; false for an app that lives in the
60
+ * menu bar or the tray, which opens it with `AppWindows.openMain()`.
61
+ */
62
+ readonly autoOpen?: boolean;
63
+ }
64
+ /** One open window. */
65
+ export interface AppWindow {
66
+ /** The surface the window renders on. */
67
+ readonly surface: number;
68
+ /** `main`, the outlet's name for a route window, or the `restoreKey`; null otherwise. */
69
+ readonly key: string | null;
70
+ readonly title: Signal<string>;
71
+ setTitle(title: string): void;
72
+ /** Whether it is the key window. */
73
+ readonly focused: Signal<boolean>;
74
+ focus(): void;
75
+ /** Close it, as the user would: every `canClose` guard is asked first. Resolves whether it closed. */
76
+ close(): Promise<boolean>;
77
+ /**
78
+ * Ask `guard` before the window closes, by the user or by `close()`, and before the app quits.
79
+ * Answers the function that removes it; a component removes its guard as it is destroyed.
80
+ */
81
+ canClose(guard: CloseGuard): () => void;
82
+ /** Settles when the window has closed. */
83
+ readonly closed: Promise<void>;
84
+ }
85
+ export type CloseGuard = () => boolean | Promise<boolean>;
86
+ /**
87
+ * What the host is asked to open. `key` is what the frame autosaves under, or null for none.
88
+ */
89
+ export interface NativeWindowRequest extends Omit<WindowOptions, 'title' | 'autosave'> {
90
+ readonly key: string | null;
91
+ readonly title: string;
92
+ }
93
+ /**
94
+ * What the host tells the app. A `resize` for a surface `open` has not resolved to a mounted window
95
+ * yet is kept for the window made on it. The host never closes a window or quits on its own: it sends
96
+ * `closeRequest` for the close button and Cmd-W, and `quitRequest` for Cmd-Q, a logout or an
97
+ * update's relaunch, and waits for `close` or `answerQuit`. `closed` reports a window the OS
98
+ * closed itself (an iPadOS scene swiped away), which no guard can keep.
99
+ */
100
+ export type NativeWindowEvent = {
101
+ readonly type: 'focus';
102
+ readonly surface: number | null;
103
+ } | {
104
+ readonly type: 'resize';
105
+ readonly surface: number;
106
+ readonly width: number;
107
+ readonly height: number;
108
+ readonly scale?: number;
109
+ } | {
110
+ readonly type: 'closeRequest';
111
+ readonly surface: number;
112
+ } | {
113
+ readonly type: 'closed';
114
+ readonly surface: number;
115
+ }
116
+ /**
117
+ * Cmd-Q, a logout or an update's relaunch. `terminate` is a SIGTERM: run only the `willQuit`
118
+ * handlers, ask no `canClose` guard, and answer true. The host ends after two seconds anyway.
119
+ */
120
+ | {
121
+ readonly type: 'quitRequest';
122
+ readonly terminate?: boolean;
123
+ }
124
+ /** A Dock click, or the app opened again, with no window visible. */
125
+ | {
126
+ readonly type: 'reopen';
127
+ }
128
+ /**
129
+ * iPadOS: a window the user made from the system (New Window, or the app opened again with none
130
+ * open). The app opens the main window in it, or brings the main window forward, and the host
131
+ * then closes the window the user made.
132
+ */
133
+ | {
134
+ readonly type: 'newWindow';
135
+ };
136
+ /**
137
+ * The host's windows: the desktop host on macOS, and on iPadOS the components pod, whose windows
138
+ * are scenes. iPadOS asks no app before it closes a scene, so it sends `closed` and never
139
+ * `closeRequest`, and it has no quitting, so never `quitRequest`. The module is
140
+ * `NgNativeWindows`, whose constant `multipleWindows` says whether the OS has windows at all,
141
+ * and whose events arrive as `ngNativeWindows` on `DeviceEventEmitter`.
142
+ */
143
+ export interface NativeWindows {
144
+ /**
145
+ * Open a window with its own surface, shown when the surface's first frame commits so it never
146
+ * shows at the wrong size. Resolves the surface's id, or null where the host would not.
147
+ */
148
+ open(request: NativeWindowRequest): Promise<number | null>;
149
+ /** Close the window on `surface` and stop its surface. */
150
+ close(surface: number): void;
151
+ focus(surface: number): void;
152
+ setTitle(surface: number, title: string): void;
153
+ /** Start quitting, as Cmd-Q does: the host answers with a `quitRequest`. */
154
+ quit(): void;
155
+ /** Answer a `quitRequest`: true quits, after which the host tears the runtime down in order. */
156
+ answerQuit(proceed: boolean): void;
157
+ subscribe(listener: (event: NativeWindowEvent) => void): () => void;
158
+ }
159
+ /**
160
+ * The host's module, or null where the OS has one window: phones, Android, Expo Go, an older
161
+ * host. Registers the windows' runnable where there is one.
162
+ */
163
+ export declare function windowsSource(): NativeWindows | null;
164
+ /** One window's mount, as `WINDOW_MOUNTER` answers it. */
165
+ export interface WindowMount {
166
+ /** Tell the window's engine its new size, which its media queries resolve against. */
167
+ resize(size: {
168
+ width: number;
169
+ height: number;
170
+ scale?: number;
171
+ }): void;
172
+ /** Destroy what the window renders, and stop its engine taking events. */
173
+ destroy(): void;
174
+ }
175
+ /**
176
+ * How a window's root is rendered on its surface. `@ng-native/platform` provides it: the
177
+ * component is created in the app's environment injector, under an element injector with the
178
+ * window's renderer, engine and `providers` (which hold `CURRENT_WINDOW`), and attached to the
179
+ * app's one change detection. `main` is the app's root component, which the app's bootstrap
180
+ * listeners (the Router's initial navigation) are told of the first time it mounts.
181
+ */
182
+ export interface WindowMounter {
183
+ mount(surface: number, component: Type<unknown>, options: {
184
+ readonly inputs?: Readonly<Record<string, unknown>>;
185
+ /** The main window's: what `mount` was given for the root component. */
186
+ readonly bindings?: Binding[];
187
+ readonly providers: Provider[];
188
+ readonly main?: boolean;
189
+ }): WindowMount;
190
+ }
191
+ /** The platform's `WindowMounter`, or null where nothing can mount a window: a test with none. */
192
+ export declare const WINDOW_MOUNTER: InjectionToken<WindowMounter | null>;
193
+ /** The window a component is rendered in, or null outside one: every app with one surface. */
194
+ export declare const CURRENT_WINDOW: InjectionToken<AppWindow | null>;
195
+ /** What `provideMainWindow` was given. */
196
+ export declare const MAIN_WINDOW_OPTIONS: InjectionToken<MainWindowOptions>;
197
+ /**
198
+ * Configure the main window, which renders the app's root component: its size and title bar, and
199
+ * with `autoOpen: false` that the app starts with no window. Where the OS has one window, only
200
+ * `autoOpen` is read, and it is ignored there: the app's one surface is its window.
201
+ */
202
+ export declare function provideMainWindow(options: MainWindowOptions): EnvironmentProviders;
203
+ export declare class AppWindows {
204
+ /** Overridden in a test with a fake host. */
205
+ static readonly SOURCE: InjectionToken<NativeWindows | null>;
206
+ private readonly native;
207
+ private readonly mounter;
208
+ private readonly navigator;
209
+ private readonly lifecycle;
210
+ private readonly mainOptions;
211
+ private readonly store;
212
+ private readonly restorable;
213
+ /**
214
+ * Whether the OS has windows the app can open: macOS, and iPadOS with the components pod and the
215
+ * config plugin's `ios.multipleWindows`.
216
+ */
217
+ readonly available: Signal<boolean>;
218
+ private readonly open$;
219
+ private readonly focusedSurface;
220
+ /** Every open window, in the order they opened. */
221
+ readonly windows: Signal<readonly AppWindow[]>;
222
+ /** The key window, or null when none is: the app is in the background, or has no window. */
223
+ readonly focused: Signal<AppWindow | null>;
224
+ private main;
225
+ /**
226
+ * The last size the host sent for a surface no window is on yet. iPadOS sends a reclaimed
227
+ * window's size as it answers `open`, which can be heard before the window is mounted; the mount
228
+ * takes it once it is made. Gone when the surface closes, or a window is made on it.
229
+ */
230
+ private readonly earlySizes;
231
+ /** The open in flight for each key, so a second open of the key waits for it. */
232
+ private readonly opening;
233
+ /**
234
+ * The quit being decided or finished: `finishing` is set once its `willQuit` handlers run, by its
235
+ * guards agreeing or by a SIGTERM that arrived while they decided.
236
+ */
237
+ private quitting;
238
+ private readonly unsubscribe;
239
+ /**
240
+ * Start the app on an OS with windows: `component` is the app's root, which the main window
241
+ * renders, and which opens now unless `provideMainWindow({ autoOpen: false })`. What
242
+ * `@ng-native/platform`'s `mount` calls in place of rendering the root on the app's surface,
243
+ * with the `inputs` and `bindings` it was given for the root.
244
+ */
245
+ launch(component: Type<unknown>, inputs?: Readonly<Record<string, unknown>>, bindings?: Binding[]): void;
246
+ /**
247
+ * Open again the windows the app had open when it last stopped: the host keeps them through a
248
+ * reload until their keys are opened again, and closes them otherwise.
249
+ */
250
+ private reopen;
251
+ /** Write down which windows open again, in the order they opened. */
252
+ private remember;
253
+ /** How a component window opens again, or null where it cannot: no name, or inputs JSON drops. */
254
+ private restoreFor;
255
+ /**
256
+ * Open the main window, or bring it to the front where it is open. Null where the OS has no
257
+ * windows, or before the app has launched.
258
+ */
259
+ openMain(): Promise<AppWindow | null>;
260
+ /**
261
+ * Run `opening` once every open of `key` already in flight has settled, so that it finds the
262
+ * window they opened rather than opening a second one for the key.
263
+ */
264
+ private reserve;
265
+ /**
266
+ * Open a window. With a component, a window rendering it, as many as are asked for. With a
267
+ * route, the window for that outlet, navigated to `path`; the outlet's window is brought to the
268
+ * front and navigated where it is open already, since a route window is one of a kind
269
+ * (Preferences). Resolves null where the OS has no windows, or the host would not open one.
270
+ * Rejects once a quit has passed every window's guards and runs `willQuit`.
271
+ */
272
+ open(component: Type<unknown>, options?: ComponentWindowOptions): Promise<AppWindow | null>;
273
+ open(route: RouteWindowOptions): Promise<AppWindow | null>;
274
+ /**
275
+ * Start quitting the app, as Cmd-Q does: every window's `canClose` guard, then the `willQuit`
276
+ * handlers, then the app quits. One guard that says no keeps the app running. Does nothing where
277
+ * the OS has no windows, since iOS and Android end an app themselves.
278
+ */
279
+ quit(): void;
280
+ private openWindow;
281
+ /**
282
+ * Render `component` in the window. Where it throws, the mounter has taken down what it made,
283
+ * and the window goes too, forgotten for a reload, before the error goes on.
284
+ */
285
+ private mountIn;
286
+ /** Make the handle for a window that has opened on `surface`, and list it. */
287
+ private track;
288
+ private byKey;
289
+ private front;
290
+ private find;
291
+ private hostSaid;
292
+ /** Ask a window's guards, and close it if every one agrees. */
293
+ private closeAsked;
294
+ private guardsAgree;
295
+ /**
296
+ * Take a window down: what it renders, its outlet, the host's window where the app is closing
297
+ * it, then the app itself where that was the last window and the app quits with it.
298
+ */
299
+ private closeNow;
300
+ /**
301
+ * The host asks to quit: every window's guards, in the order the windows opened, then the
302
+ * `willQuit` handlers, then the answer. One guard that says no keeps the app, and every window.
303
+ * A SIGTERM (`terminate`) skips the guards, and one that arrives while a quit's guards decide
304
+ * finishes that quit, whatever they answer.
305
+ */
306
+ private quitAsked;
307
+ /**
308
+ * Ask each window's guards in turn, including a window that opened while an earlier one's guard
309
+ * decided. False at the first that says no.
310
+ */
311
+ private everyWindowAgrees;
312
+ private unasked;
313
+ private finishQuit;
314
+ /** Whether a quit has passed its guards and is running `willQuit`: no window opens then. */
315
+ private closing;
316
+ private refuseWhileQuitting;
317
+ /** Stop listening to the host: for a test that makes the service more than once. */
318
+ ngOnDestroy(): void;
319
+ static ɵfac: i0.ɵɵFactoryDeclaration<AppWindows, never>;
320
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
321
+ }