@ng-native/device 0.28.0 → 0.29.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.
@@ -30,9 +30,8 @@ export interface WindowOptions {
30
30
  readonly titleBar?: TitleBar;
31
31
  readonly fullScreen?: boolean;
32
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.
33
+ * Whether the window's frame is saved and restored on the next launch. On by default for the
34
+ * main window, route windows and component windows with a `restoreKey`.
36
35
  */
37
36
  readonly autosave?: boolean;
38
37
  }
@@ -55,6 +54,11 @@ export interface RouteWindowOptions extends WindowOptions {
55
54
  }
56
55
  /** The main window's options, as `provideMainWindow` takes them. */
57
56
  export interface MainWindowOptions extends WindowOptions {
57
+ /**
58
+ * The main window's saved frame key on macOS and Linux. Defaults to `main`. Use a key distinct
59
+ * from the app's other windows, and change it to start with a fresh frame on the next launch.
60
+ */
61
+ readonly restoreKey?: string;
58
62
  /**
59
63
  * Whether the main window opens at launch. True by default; false for an app that lives in the
60
64
  * menu bar or the tray, which opens it with `AppWindows.openMain()`.
@@ -208,6 +212,7 @@ export declare class AppWindows {
208
212
  private readonly navigator;
209
213
  private readonly lifecycle;
210
214
  private readonly mainOptions;
215
+ private readonly desktop;
211
216
  private readonly store;
212
217
  private readonly restorable;
213
218
  /**
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { InjectionToken, Service, computed, inject, makeEnvironmentProviders, signal, } from '@angular/core';
17
17
  import { AppLifecycle } from "./app-lifecycle.js";
18
+ import { injectOs, isDesktopOs } from "./os.js";
18
19
  import { reactNative } from "./react-native.js";
19
20
  import { WINDOW_NAVIGATOR } from "./window-navigator.js";
20
21
  import { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE } from "./window-restore.js";
@@ -71,6 +72,7 @@ export class AppWindows {
71
72
  navigator = inject(WINDOW_NAVIGATOR);
72
73
  lifecycle = inject(AppLifecycle);
73
74
  mainOptions = inject(MAIN_WINDOW_OPTIONS);
75
+ desktop = isDesktopOs(injectOs());
74
76
  store = inject(WINDOW_RESTORE_STORE);
75
77
  restorable = new Map((inject(RESTORABLE_WINDOWS, { optional: true }) ?? []).flatMap((components) => Object.entries(components)));
76
78
  /**
@@ -181,10 +183,11 @@ export class AppWindows {
181
183
  return this.front(existing);
182
184
  if (!this.main)
183
185
  return null;
184
- const { autoOpen: _autoOpen, ...options } = this.mainOptions;
186
+ const { autoOpen: _autoOpen, restoreKey, ...options } = this.mainOptions;
185
187
  return this.openWindow(this.main.component, {
186
188
  ...options,
187
189
  key: 'main',
190
+ frameKey: this.desktop ? restoreKey : undefined,
188
191
  inputs: this.main.inputs,
189
192
  ...(this.main.bindings && { bindings: this.main.bindings }),
190
193
  main: true,
@@ -273,10 +276,10 @@ export class AppWindows {
273
276
  if (!native || !mounter)
274
277
  return null;
275
278
  this.refuseWhileQuitting();
276
- const { key, inputs, bindings, outlet, providers, main, autosave, title = '', restore, ...frame } = options;
279
+ const { key, frameKey = key, inputs, bindings, outlet, providers, main, autosave, title = '', restore, ...frame } = options;
277
280
  const surface = await native.open({
278
281
  ...frame,
279
- key: autosave === false ? null : key,
282
+ key: autosave === false ? null : frameKey,
280
283
  title,
281
284
  });
282
285
  if (surface === null)
@@ -288,7 +291,7 @@ export class AppWindows {
288
291
  native.close(surface);
289
292
  this.refuseWhileQuitting();
290
293
  }
291
- const open = this.track(surface, key, outlet ?? null, title);
294
+ const open = this.track(surface, key, outlet, title);
292
295
  open.restore = restore?.() ?? null;
293
296
  this.remember();
294
297
  this.mountIn(open, mounter, component, { inputs, bindings, providers, main });
@@ -1 +1 @@
1
- {"version":3,"file":"app-windows.js","sourceRoot":"","sources":["../src/app-windows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,wBAAwB,EACxB,MA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,GAAG,CAAC,IAAI,CAAC,CAAC;YAChB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACpD,CAAC;QACD,iGAAiG;QACjG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,OAAO,CAAC,KAAwB;QACtC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAEO,KAAK,CAAC,UAAU;QACtB,oFAAoF;QACpF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,yFAAyF;YACzF,kDAAkD;YAClD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,4FAA4F;IACpF,OAAO,GAAG,KAAK,CAAC;IAEhB,mBAAmB;QACzB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAjhBU,UAAU;wGAAV,UAAU;;2FAAV,UAAU;kBADtB,OAAO","sourcesContent":["/**\n * Several windows from one Angular app: desktop windows on macOS and scenes on iPadOS.\n *\n * Every window is a root view on its own native surface, joined to the one app: root services, the\n * one Router and one change detection are shared, and each window has an element injector that\n * provides `CURRENT_WINDOW`. A route window renders a named outlet of the app's Router, which\n * `WINDOW_NAVIGATOR` navigates; a component window renders a component with its inputs.\n * `@ng-native/platform` mounts each through `WINDOW_MOUNTER`.\n *\n * On iPhone and Android `available()` is false and `open` resolves to null, as an inert call does.\n *\n * The host contract is `NativeWindows`, below: the host opens and closes surfaces when asked, and\n * reports what the user does to them. The rules (guards, the last window, a Dock reopen, quitting)\n * are here, so every OS that has windows follows the same ones.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n inject,\n makeEnvironmentProviders,\n signal,\n type Binding,\n type EnvironmentProviders,\n type Provider,\n type Signal,\n type Type,\n} from '@angular/core';\nimport { AppLifecycle } from './app-lifecycle.ts';\nimport { reactNative } from './react-native.ts';\nimport { WINDOW_NAVIGATOR } from './window-navigator.ts';\nimport { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, type RestoredWindow } from './window-restore.ts';\n\nexport type TitleBar = 'default' | 'transparent' | 'hidden';\n\n/** How a window opens. Sizes are in points; each left out is the host's default. */\nexport interface WindowOptions {\n readonly title?: string;\n readonly width?: number;\n readonly height?: number;\n readonly minWidth?: number;\n readonly minHeight?: number;\n readonly maxWidth?: number;\n readonly maxHeight?: number;\n readonly resizable?: boolean;\n /** `transparent` draws content under the title bar; `hidden` also hides the title. */\n readonly titleBar?: TitleBar;\n readonly fullScreen?: boolean;\n /**\n * Whether the window's frame is saved and restored on the next launch. On by default, keyed by\n * the route outlet, the `restoreKey`, or `main`; a component window without a `restoreKey` has\n * no key and is not saved.\n */\n readonly autosave?: boolean;\n}\n\n/** A window rendering a component. */\nexport interface ComponentWindowOptions extends WindowOptions {\n /** Set on the component before its first change detection. */\n readonly inputs?: Readonly<Record<string, unknown>>;\n /**\n * What the window is restored by, after a reload or a relaunch: on macOS and iPadOS it opens\n * again with the same `inputs`, which must then survive `JSON.stringify`, where\n * `provideRestorableWindows` names its component. Without one, a reload closes the window. One key is one window: opening\n * a key that is open brings that window to the front.\n */\n readonly restoreKey?: string;\n}\n\n/** A window rendering the named outlet `outlet` of the app's Router, at `path`. */\nexport interface RouteWindowOptions extends WindowOptions {\n readonly outlet: string;\n readonly path: string;\n}\n\n/** The main window's options, as `provideMainWindow` takes them. */\nexport interface MainWindowOptions extends WindowOptions {\n /**\n * Whether the main window opens at launch. True by default; false for an app that lives in the\n * menu bar or the tray, which opens it with `AppWindows.openMain()`.\n */\n readonly autoOpen?: boolean;\n}\n\n/** One open window. */\nexport interface AppWindow {\n /** The surface the window renders on. */\n readonly surface: number;\n /** `main`, the outlet's name for a route window, or the `restoreKey`; null otherwise. */\n readonly key: string | null;\n readonly title: Signal<string>;\n setTitle(title: string): void;\n /** Whether it is the key window. */\n readonly focused: Signal<boolean>;\n focus(): void;\n /** Close it, as the user would: every `canClose` guard is asked first. Resolves whether it closed. */\n close(): Promise<boolean>;\n /**\n * Ask `guard` before the window closes, by the user or by `close()`, and before the app quits.\n * Answers the function that removes it; a component removes its guard as it is destroyed.\n */\n canClose(guard: CloseGuard): () => void;\n /** Settles when the window has closed. */\n readonly closed: Promise<void>;\n}\n\nexport type CloseGuard = () => boolean | Promise<boolean>;\n\n/**\n * What the host is asked to open. `key` is what the frame autosaves under, or null for none.\n */\nexport interface NativeWindowRequest extends Omit<WindowOptions, 'title' | 'autosave'> {\n readonly key: string | null;\n readonly title: string;\n}\n\n/**\n * What the host tells the app. A `resize` for a surface `open` has not resolved to a mounted window\n * yet is kept for the window made on it. The host never closes a window or quits on its own: it sends\n * `closeRequest` for the close button and Cmd-W, and `quitRequest` for Cmd-Q, a logout or an\n * update's relaunch, and waits for `close` or `answerQuit`. `closed` reports a window the OS\n * closed itself (an iPadOS scene swiped away), which no guard can keep.\n */\nexport type NativeWindowEvent =\n | { readonly type: 'focus'; readonly surface: number | null }\n | {\n readonly type: 'resize';\n readonly surface: number;\n readonly width: number;\n readonly height: number;\n readonly scale?: number;\n }\n | { readonly type: 'closeRequest'; readonly surface: number }\n | { readonly type: 'closed'; readonly surface: number }\n /**\n * Cmd-Q, a logout or an update's relaunch. `terminate` is a SIGTERM: run only the `willQuit`\n * handlers, ask no `canClose` guard, and answer true. The host ends after two seconds anyway.\n */\n | { readonly type: 'quitRequest'; readonly terminate?: boolean }\n /** A Dock click, or the app opened again, with no window visible. */\n | { readonly type: 'reopen' }\n /**\n * iPadOS: a window the user made from the system (New Window, or the app opened again with none\n * open). The app opens the main window in it, or brings the main window forward, and the host\n * then closes the window the user made.\n */\n | { readonly type: 'newWindow' };\n\n/**\n * The host's windows: the desktop host on macOS, and on iPadOS the components pod, whose windows\n * are scenes. iPadOS asks no app before it closes a scene, so it sends `closed` and never\n * `closeRequest`, and it has no quitting, so never `quitRequest`. The module is\n * `NgNativeWindows`, whose constant `multipleWindows` says whether the OS has windows at all,\n * and whose events arrive as `ngNativeWindows` on `DeviceEventEmitter`.\n */\nexport interface NativeWindows {\n /**\n * Open a window with its own surface, shown when the surface's first frame commits so it never\n * shows at the wrong size. Resolves the surface's id, or null where the host would not.\n */\n open(request: NativeWindowRequest): Promise<number | null>;\n /** Close the window on `surface` and stop its surface. */\n close(surface: number): void;\n focus(surface: number): void;\n setTitle(surface: number, title: string): void;\n /** Start quitting, as Cmd-Q does: the host answers with a `quitRequest`. */\n quit(): void;\n /** Answer a `quitRequest`: true quits, after which the host tears the runtime down in order. */\n answerQuit(proceed: boolean): void;\n subscribe(listener: (event: NativeWindowEvent) => void): () => void;\n}\n\ninterface WindowsTurboModule {\n getConstants?(): { multipleWindows?: boolean };\n open?(request: NativeWindowRequest): Promise<number | null>;\n close?(surface: number): void;\n focus?(surface: number): void;\n setTitle?(surface: number, title: string): void;\n quit?(): void;\n answerQuit?(proceed: boolean): void;\n}\n\n/**\n * The runnable each window's surface runs on an iPad, where the host makes the surface through\n * React Native's own host: it renders nothing, as the window's root is mounted from the app.\n */\nconst WINDOW_RUNNABLE = 'NgNativeWindow';\n\n/**\n * The host's module, or null where the OS has one window: phones, Android, Expo Go, an older\n * host. Registers the windows' runnable where there is one.\n */\nexport function windowsSource(): NativeWindows | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeWindows') as\n WindowsTurboModule | null | undefined;\n if (!module?.getConstants?.().multipleWindows) return null;\n native?.AppRegistry?.registerRunnable(WINDOW_RUNNABLE, () => {});\n return {\n open: async (request) => (await module.open?.(request)) ?? null,\n close: (surface) => module.close?.(surface),\n focus: (surface) => module.focus?.(surface),\n setTitle: (surface, title) => module.setTitle?.(surface, title),\n quit: () => module.quit?.(),\n answerQuit: (proceed) => module.answerQuit?.(proceed),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeWindows', (event) =>\n listener(event as NativeWindowEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n/** One window's mount, as `WINDOW_MOUNTER` answers it. */\nexport interface WindowMount {\n /** Tell the window's engine its new size, which its media queries resolve against. */\n resize(size: { width: number; height: number; scale?: number }): void;\n /** Destroy what the window renders, and stop its engine taking events. */\n destroy(): void;\n}\n\n/**\n * How a window's root is rendered on its surface. `@ng-native/platform` provides it: the\n * component is created in the app's environment injector, under an element injector with the\n * window's renderer, engine and `providers` (which hold `CURRENT_WINDOW`), and attached to the\n * app's one change detection. `main` is the app's root component, which the app's bootstrap\n * listeners (the Router's initial navigation) are told of the first time it mounts.\n */\nexport interface WindowMounter {\n mount(\n surface: number,\n component: Type<unknown>,\n options: {\n readonly inputs?: Readonly<Record<string, unknown>>;\n /** The main window's: what `mount` was given for the root component. */\n readonly bindings?: Binding[];\n readonly providers: Provider[];\n readonly main?: boolean;\n },\n ): WindowMount;\n}\n\n/** The platform's `WindowMounter`, or null where nothing can mount a window: a test with none. */\nexport const WINDOW_MOUNTER = new InjectionToken<WindowMounter | null>(\n 'angular-native.windowMounter',\n { factory: () => null },\n);\n\n/** The window a component is rendered in, or null outside one: every app with one surface. */\nexport const CURRENT_WINDOW = new InjectionToken<AppWindow | null>('angular-native.currentWindow', {\n factory: () => null,\n});\n\n/** What `provideMainWindow` was given. */\nexport const MAIN_WINDOW_OPTIONS = new InjectionToken<MainWindowOptions>(\n 'angular-native.mainWindowOptions',\n { factory: () => ({}) },\n);\n\n/**\n * Configure the main window, which renders the app's root component: its size and title bar, and\n * with `autoOpen: false` that the app starts with no window. Where the OS has one window, only\n * `autoOpen` is read, and it is ignored there: the app's one surface is its window.\n */\nexport function provideMainWindow(options: MainWindowOptions): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: MAIN_WINDOW_OPTIONS, useValue: options }]);\n}\n\n/** An open window and what it needs to close. */\ninterface Open {\n readonly handle: AppWindow;\n /** How it opens again after a reload, or null where it does not. */\n restore: RestoredWindow | null;\n readonly guards: Set<CloseGuard>;\n readonly outlet: string | null;\n readonly closedNow: () => void;\n mount: WindowMount | null;\n closing: boolean;\n}\n\n@Service()\nexport class AppWindows {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeWindows | null>(\n 'angular-native.windowsSource',\n { factory: windowsSource },\n );\n\n private readonly native = inject(AppWindows.SOURCE);\n private readonly mounter = inject(WINDOW_MOUNTER);\n private readonly navigator = inject(WINDOW_NAVIGATOR);\n private readonly lifecycle = inject(AppLifecycle);\n private readonly mainOptions = inject(MAIN_WINDOW_OPTIONS);\n private readonly store = inject(WINDOW_RESTORE_STORE);\n private readonly restorable = new Map(\n (inject(RESTORABLE_WINDOWS, { optional: true }) ?? []).flatMap((components) =>\n Object.entries(components),\n ),\n );\n\n /**\n * Whether the OS has windows the app can open: macOS, and iPadOS with the components pod and the\n * config plugin's `ios.multipleWindows`.\n */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n private readonly open$ = signal<readonly Open[]>([]);\n private readonly focusedSurface = signal<number | null>(null);\n\n /** Every open window, in the order they opened. */\n readonly windows: Signal<readonly AppWindow[]> = computed(() =>\n this.open$().map((open) => open.handle),\n );\n\n /** The key window, or null when none is: the app is in the background, or has no window. */\n readonly focused: Signal<AppWindow | null> = computed(\n () => this.windows().find((one) => one.surface === this.focusedSurface()) ?? null,\n );\n\n private main: {\n component: Type<unknown>;\n inputs?: Readonly<Record<string, unknown>>;\n bindings?: Binding[];\n } | null = null;\n\n /**\n * The last size the host sent for a surface no window is on yet. iPadOS sends a reclaimed\n * window's size as it answers `open`, which can be heard before the window is mounted; the mount\n * takes it once it is made. Gone when the surface closes, or a window is made on it.\n */\n private readonly earlySizes = new Map<\n number,\n { width: number; height: number; scale?: number | undefined }\n >();\n\n /** The open in flight for each key, so a second open of the key waits for it. */\n private readonly opening = new Map<string, Promise<unknown>>();\n\n /**\n * The quit being decided or finished: `finishing` is set once its `willQuit` handlers run, by its\n * guards agreeing or by a SIGTERM that arrived while they decided.\n */\n private quitting: { finishing: Promise<void> | null } | null = null;\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n /**\n * Start the app on an OS with windows: `component` is the app's root, which the main window\n * renders, and which opens now unless `provideMainWindow({ autoOpen: false })`. What\n * `@ng-native/platform`'s `mount` calls in place of rendering the root on the app's surface,\n * with the `inputs` and `bindings` it was given for the root.\n */\n launch(\n component: Type<unknown>,\n inputs?: Readonly<Record<string, unknown>>,\n bindings?: Binding[],\n ): void {\n this.main = { component, ...(inputs && { inputs }), ...(bindings && { bindings }) };\n const restoring = this.store?.read() ?? [];\n const autoOpen = this.mainOptions.autoOpen !== false;\n if (autoOpen) void this.openMain();\n // The main window opens anyway where it opens by itself.\n void this.reopen(restoring.filter((window) => !autoOpen || window.kind !== 'main'));\n }\n\n /**\n * Open again the windows the app had open when it last stopped: the host keeps them through a\n * reload until their keys are opened again, and closes them otherwise.\n */\n private async reopen(windows: readonly RestoredWindow[]): Promise<void> {\n for (const window of windows) {\n try {\n if (window.kind === 'main') {\n await this.openMain();\n } else if (window.kind === 'route') {\n await this.open({ ...window.options, outlet: window.outlet, path: window.path });\n } else {\n const component = this.restorable.get(window.component);\n if (!component) continue;\n await this.open(component, {\n ...window.options,\n restoreKey: window.key,\n ...(window.inputs && { inputs: window.inputs }),\n });\n }\n } catch (error) {\n console.error('[angular-native] A window could not open again after a reload:', error);\n }\n }\n }\n\n /** Write down which windows open again, in the order they opened. */\n private remember(): void {\n this.store?.write(this.open$().flatMap((open) => (open.restore ? [open.restore] : [])));\n }\n\n /** How a component window opens again, or null where it cannot: no name, or inputs JSON drops. */\n private restoreFor(\n component: Type<unknown>,\n key: string,\n inputs: Readonly<Record<string, unknown>> | undefined,\n options: WindowOptions,\n ): RestoredWindow | null {\n const name = [...this.restorable].find(([, one]) => one === component)?.[0];\n if (name === undefined) {\n console.warn(\n `[angular-native] The window '${key}' will not open again after a reload: name its ` +\n 'component with provideRestorableWindows({ ... }).',\n );\n return null;\n }\n let copied: Readonly<Record<string, unknown>> | undefined;\n try {\n copied = inputs && (JSON.parse(JSON.stringify(inputs)) as Record<string, unknown>);\n } catch {\n console.warn(\n `[angular-native] The window '${key}' will not open again after a reload: its inputs ` +\n 'cannot be written as JSON.',\n );\n return null;\n }\n return { kind: 'component', key, component: name, ...(copied && { inputs: copied }), options };\n }\n\n /**\n * Open the main window, or bring it to the front where it is open. Null where the OS has no\n * windows, or before the app has launched.\n */\n openMain(): Promise<AppWindow | null> {\n return this.reserve('main', async () => {\n const existing = this.byKey('main');\n if (existing) return this.front(existing);\n if (!this.main) return null;\n const { autoOpen: _autoOpen, ...options } = this.mainOptions;\n return this.openWindow(this.main.component, {\n ...options,\n key: 'main',\n inputs: this.main.inputs,\n ...(this.main.bindings && { bindings: this.main.bindings }),\n main: true,\n restore: () => ({ kind: 'main' }),\n });\n });\n }\n\n /**\n * Run `opening` once every open of `key` already in flight has settled, so that it finds the\n * window they opened rather than opening a second one for the key.\n */\n private async reserve<T>(key: string, opening: () => Promise<T>): Promise<T> {\n for (let pending = this.opening.get(key); pending; pending = this.opening.get(key)) {\n await pending.catch(() => undefined);\n }\n const running = opening();\n this.opening.set(key, running);\n try {\n return await running;\n } finally {\n if (this.opening.get(key) === running) this.opening.delete(key);\n }\n }\n\n /**\n * Open a window. With a component, a window rendering it, as many as are asked for. With a\n * route, the window for that outlet, navigated to `path`; the outlet's window is brought to the\n * front and navigated where it is open already, since a route window is one of a kind\n * (Preferences). Resolves null where the OS has no windows, or the host would not open one.\n * Rejects once a quit has passed every window's guards and runs `willQuit`.\n */\n open(component: Type<unknown>, options?: ComponentWindowOptions): Promise<AppWindow | null>;\n open(route: RouteWindowOptions): Promise<AppWindow | null>;\n async open(\n target: Type<unknown> | RouteWindowOptions,\n options: ComponentWindowOptions = {},\n ): Promise<AppWindow | null> {\n if (typeof target === 'function') {\n const { inputs, restoreKey, ...rest } = options;\n const opening = () =>\n this.openWindow(target, {\n ...rest,\n key: restoreKey ?? null,\n ...(inputs && { inputs }),\n restore: () =>\n restoreKey === undefined ? null : this.restoreFor(target, restoreKey, inputs, rest),\n });\n if (restoreKey === undefined) return opening();\n return this.reserve(restoreKey, async () => {\n const existing = this.byKey(restoreKey);\n return existing ? this.front(existing) : opening();\n });\n }\n const { outlet, path, ...rest } = target;\n const navigator = this.navigator;\n if (!navigator) {\n console.error(\n `[angular-native] A route window for '${outlet}' needs the native router: ` +\n 'provideNativeRouter() provides what navigates its outlet.',\n );\n return null;\n }\n const restore: RestoredWindow = { kind: 'route', outlet, path, options: rest };\n return this.reserve(outlet, async () => {\n const existing = this.byKey(outlet);\n if (existing) {\n // A refused navigation leaves the window where it was, and so what it restores to.\n if (await navigator.navigate(outlet, path)) {\n const open = this.find(existing.surface);\n if (open) open.restore = restore;\n this.remember();\n }\n return this.front(existing);\n }\n const window = navigator.window(outlet);\n const opened = await this.openWindow(window.component, {\n ...rest,\n key: outlet,\n outlet,\n providers: window.providers,\n restore: () => restore,\n });\n if (opened) await navigator.navigate(outlet, path);\n return opened;\n });\n }\n\n /**\n * Start quitting the app, as Cmd-Q does: every window's `canClose` guard, then the `willQuit`\n * handlers, then the app quits. One guard that says no keeps the app running. Does nothing where\n * the OS has no windows, since iOS and Android end an app themselves.\n */\n quit(): void {\n this.native?.quit();\n }\n\n private async openWindow(\n component: Type<unknown>,\n options: WindowOptions & {\n key: string | null;\n inputs?: Readonly<Record<string, unknown>> | undefined;\n bindings?: Binding[];\n outlet?: string;\n providers?: Provider[];\n main?: boolean;\n /** How the window opens again after a reload, worked out once it has opened. */\n restore?: () => RestoredWindow | null;\n },\n ): Promise<AppWindow | null> {\n const native = this.native;\n const mounter = this.mounter;\n if (!native || !mounter) return null;\n this.refuseWhileQuitting();\n const {\n key,\n inputs,\n bindings,\n outlet,\n providers,\n main,\n autosave,\n title = '',\n restore,\n ...frame\n } = options;\n const surface = await native.open({\n ...frame,\n key: autosave === false ? null : key,\n title,\n });\n if (surface === null) return null;\n const early = this.earlySizes.get(surface);\n this.earlySizes.delete(surface);\n // One the host opened as the quit began goes again.\n if (this.closing) {\n native.close(surface);\n this.refuseWhileQuitting();\n }\n const open = this.track(surface, key, outlet ?? null, title);\n open.restore = restore?.() ?? null;\n this.remember();\n this.mountIn(open, mounter, component, { inputs, bindings, providers, main });\n if (early) open.mount?.resize(early);\n return open.handle;\n }\n\n /**\n * Render `component` in the window. Where it throws, the mounter has taken down what it made,\n * and the window goes too, forgotten for a reload, before the error goes on.\n */\n private mountIn(\n open: Open,\n mounter: WindowMounter,\n component: Type<unknown>,\n options: {\n inputs?: Readonly<Record<string, unknown>> | undefined;\n bindings?: Binding[] | undefined;\n providers?: Provider[] | undefined;\n main?: boolean | undefined;\n },\n ): void {\n const { inputs, bindings, providers = [], main } = options;\n try {\n open.mount = mounter.mount(open.handle.surface, component, {\n ...(inputs && { inputs }),\n ...(bindings && { bindings }),\n providers: [{ provide: CURRENT_WINDOW, useValue: open.handle }, ...providers],\n ...(main && { main }),\n });\n } catch (error) {\n this.closeNow(open.handle.surface, true);\n throw error;\n }\n }\n\n /** Make the handle for a window that has opened on `surface`, and list it. */\n private track(surface: number, key: string | null, outlet: string | null, title: string): Open {\n const native = this.native!;\n const guards = new Set<CloseGuard>();\n const titleSignal = signal(title);\n let closedNow!: () => void;\n const closed = new Promise<void>((resolve) => (closedNow = resolve));\n const handle: AppWindow = {\n surface,\n key,\n title: titleSignal.asReadonly(),\n setTitle: (next) => {\n titleSignal.set(next);\n native.setTitle(surface, next);\n },\n focused: computed(() => this.focusedSurface() === surface),\n focus: () => native.focus(surface),\n close: () => this.closeAsked(surface),\n canClose: (guard) => {\n guards.add(guard);\n return () => void guards.delete(guard);\n },\n closed,\n };\n const open: Open = {\n handle,\n restore: null,\n guards,\n outlet,\n closedNow,\n mount: null,\n closing: false,\n };\n this.open$.update((all) => [...all, open]);\n return open;\n }\n\n private byKey(key: string): AppWindow | null {\n return this.open$().find((open) => open.handle.key === key)?.handle ?? null;\n }\n\n private front(window: AppWindow): AppWindow {\n window.focus();\n return window;\n }\n\n private find(surface: number): Open | undefined {\n return this.open$().find((open) => open.handle.surface === surface);\n }\n\n private hostSaid(event: NativeWindowEvent): void {\n switch (event.type) {\n case 'focus':\n this.focusedSurface.set(event.surface);\n return;\n case 'resize': {\n const open = this.find(event.surface);\n if (open) open.mount?.resize(event);\n else this.earlySizes.set(event.surface, event);\n return;\n }\n case 'closeRequest':\n void this.closeAsked(event.surface);\n return;\n case 'closed':\n this.earlySizes.delete(event.surface);\n this.closeNow(event.surface, false);\n return;\n case 'quitRequest':\n void this.quitAsked(event.terminate === true);\n return;\n case 'reopen':\n if (!this.open$().length) void this.openMain();\n return;\n case 'newWindow':\n void this.openMain();\n return;\n }\n }\n\n /** Ask a window's guards, and close it if every one agrees. */\n private async closeAsked(surface: number): Promise<boolean> {\n const open = this.find(surface);\n if (!open || open.closing) return false;\n open.closing = true;\n const allowed = await this.guardsAgree(open);\n open.closing = false;\n if (!allowed || !this.find(surface)) return false;\n this.closeNow(surface, true);\n return true;\n }\n\n private async guardsAgree(open: Open): Promise<boolean> {\n for (const guard of [...open.guards]) {\n try {\n if (!(await guard())) return false;\n } catch (error) {\n // A guard that fails keeps the window, rather than losing what it was guarding.\n console.error('[angular-native] A canClose guard failed:', error);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Take a window down: what it renders, its outlet, the host's window where the app is closing\n * it, then the app itself where that was the last window and the app quits with it.\n */\n private closeNow(surface: number, tellHost: boolean): void {\n const open = this.find(surface);\n if (!open) return;\n this.open$.update((all) => all.filter((one) => one !== open));\n if (open.restore) this.remember();\n if (this.focusedSurface() === surface) this.focusedSurface.set(null);\n open.mount?.destroy();\n open.mount = null;\n if (open.outlet) void this.navigator?.clear(open.outlet);\n if (tellHost) this.native?.close(surface);\n open.closedNow();\n if (!this.open$().length && this.lifecycle.quitWhenLastWindowCloses) this.native?.quit();\n }\n\n /**\n * The host asks to quit: every window's guards, in the order the windows opened, then the\n * `willQuit` handlers, then the answer. One guard that says no keeps the app, and every window.\n * A SIGTERM (`terminate`) skips the guards, and one that arrives while a quit's guards decide\n * finishes that quit, whatever they answer.\n */\n private async quitAsked(terminate: boolean): Promise<void> {\n const current = this.quitting;\n if (current) {\n // One quit at a time: its answer is the host's. A SIGTERM no longer waits for its guards.\n if (terminate) current.finishing ??= this.finishQuit();\n return;\n }\n const quit: { finishing: Promise<void> | null } = { finishing: null };\n this.quitting = quit;\n try {\n // A SIGTERM is no one's choice to veto: no guard is asked, so a dialog cannot hold it.\n const agreed = terminate || (await this.everyWindowAgrees());\n if (!agreed && !quit.finishing) {\n this.native?.answerQuit(false);\n return;\n }\n quit.finishing ??= this.finishQuit();\n await quit.finishing;\n } finally {\n this.quitting = null;\n }\n }\n\n /**\n * Ask each window's guards in turn, including a window that opened while an earlier one's guard\n * decided. False at the first that says no.\n */\n private async everyWindowAgrees(): Promise<boolean> {\n const asked = new Set<Open>();\n for (let open = this.unasked(asked); open; open = this.unasked(asked)) {\n asked.add(open);\n if (!(await this.guardsAgree(open))) return false;\n }\n // In the same turn as the last check, so a window the host finishes opening after it is refused.\n this.closing = true;\n return true;\n }\n\n private unasked(asked: ReadonlySet<Open>): Open | undefined {\n return this.open$().find((open) => !asked.has(open));\n }\n\n private async finishQuit(): Promise<void> {\n // From here the app is quitting: a window opened now would have guards no one asks.\n this.closing = true;\n try {\n await this.lifecycle.runWillQuit();\n this.native?.answerQuit(true);\n } catch (error) {\n // Approved and answered, the app stays closed to new windows until it exits. Only a quit\n // that did not get that far lets them open again.\n this.closing = false;\n throw error;\n }\n }\n\n /** Whether a quit has passed its guards and is running `willQuit`: no window opens then. */\n private closing = false;\n\n private refuseWhileQuitting(): void {\n if (this.closing) {\n throw new Error('[angular-native] A window cannot open while the app is quitting.');\n }\n }\n\n /** Stop listening to the host: for a test that makes the service more than once. */\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
1
+ {"version":3,"file":"app-windows.js","sourceRoot":"","sources":["../src/app-windows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,wBAAwB,EACxB,MAAM,GAMP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAuB,MAAM,qBAAqB,CAAC;;AA2JpG;;;GAGG;AACH,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAC5B,CAAC;IACxC,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,EAAE,WAAW,EAAE,gBAAgB,CAAC,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACjE,OAAO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AC;YACH,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,yFAAyF;YACzF,kDAAkD;YAClD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,4FAA4F;IACpF,OAAO,GAAG,KAAK,CAAC;IAEhB,mBAAmB;QACzB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGA1hBU,UAAU;wGAAV,UAAU;;2FAAV,UAAU;kBADtB,OAAO","sourcesContent":["/**\n * Several windows from one Angular app: desktop windows on macOS and scenes on iPadOS.\n *\n * Every window is a root view on its own native surface, joined to the one app: root services, the\n * one Router and one change detection are shared, and each window has an element injector that\n * provides `CURRENT_WINDOW`. A route window renders a named outlet of the app's Router, which\n * `WINDOW_NAVIGATOR` navigates; a component window renders a component with its inputs.\n * `@ng-native/platform` mounts each through `WINDOW_MOUNTER`.\n *\n * On iPhone and Android `available()` is false and `open` resolves to null, as an inert call does.\n *\n * The host contract is `NativeWindows`, below: the host opens and closes surfaces when asked, and\n * reports what the user does to them. The rules (guards, the last window, a Dock reopen, quitting)\n * are here, so every OS that has windows follows the same ones.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n inject,\n makeEnvironmentProviders,\n signal,\n type Binding,\n type EnvironmentProviders,\n type Provider,\n type Signal,\n type Type,\n} from '@angular/core';\nimport { AppLifecycle } from './app-lifecycle.ts';\nimport { injectOs, isDesktopOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\nimport { WINDOW_NAVIGATOR } from './window-navigator.ts';\nimport { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, type RestoredWindow } from './window-restore.ts';\n\nexport type TitleBar = 'default' | 'transparent' | 'hidden';\n\n/** How a window opens. Sizes are in points; each left out is the host's default. */\nexport interface WindowOptions {\n readonly title?: string;\n readonly width?: number;\n readonly height?: number;\n readonly minWidth?: number;\n readonly minHeight?: number;\n readonly maxWidth?: number;\n readonly maxHeight?: number;\n readonly resizable?: boolean;\n /** `transparent` draws content under the title bar; `hidden` also hides the title. */\n readonly titleBar?: TitleBar;\n readonly fullScreen?: boolean;\n /**\n * Whether the window's frame is saved and restored on the next launch. On by default for the\n * main window, route windows and component windows with a `restoreKey`.\n */\n readonly autosave?: boolean;\n}\n\n/** A window rendering a component. */\nexport interface ComponentWindowOptions extends WindowOptions {\n /** Set on the component before its first change detection. */\n readonly inputs?: Readonly<Record<string, unknown>>;\n /**\n * What the window is restored by, after a reload or a relaunch: on macOS and iPadOS it opens\n * again with the same `inputs`, which must then survive `JSON.stringify`, where\n * `provideRestorableWindows` names its component. Without one, a reload closes the window. One key is one window: opening\n * a key that is open brings that window to the front.\n */\n readonly restoreKey?: string;\n}\n\n/** A window rendering the named outlet `outlet` of the app's Router, at `path`. */\nexport interface RouteWindowOptions extends WindowOptions {\n readonly outlet: string;\n readonly path: string;\n}\n\n/** The main window's options, as `provideMainWindow` takes them. */\nexport interface MainWindowOptions extends WindowOptions {\n /**\n * The main window's saved frame key on macOS and Linux. Defaults to `main`. Use a key distinct\n * from the app's other windows, and change it to start with a fresh frame on the next launch.\n */\n readonly restoreKey?: string;\n /**\n * Whether the main window opens at launch. True by default; false for an app that lives in the\n * menu bar or the tray, which opens it with `AppWindows.openMain()`.\n */\n readonly autoOpen?: boolean;\n}\n\n/** One open window. */\nexport interface AppWindow {\n /** The surface the window renders on. */\n readonly surface: number;\n /** `main`, the outlet's name for a route window, or the `restoreKey`; null otherwise. */\n readonly key: string | null;\n readonly title: Signal<string>;\n setTitle(title: string): void;\n /** Whether it is the key window. */\n readonly focused: Signal<boolean>;\n focus(): void;\n /** Close it, as the user would: every `canClose` guard is asked first. Resolves whether it closed. */\n close(): Promise<boolean>;\n /**\n * Ask `guard` before the window closes, by the user or by `close()`, and before the app quits.\n * Answers the function that removes it; a component removes its guard as it is destroyed.\n */\n canClose(guard: CloseGuard): () => void;\n /** Settles when the window has closed. */\n readonly closed: Promise<void>;\n}\n\nexport type CloseGuard = () => boolean | Promise<boolean>;\n\n/**\n * What the host is asked to open. `key` is what the frame autosaves under, or null for none.\n */\nexport interface NativeWindowRequest extends Omit<WindowOptions, 'title' | 'autosave'> {\n readonly key: string | null;\n readonly title: string;\n}\n\n/**\n * What the host tells the app. A `resize` for a surface `open` has not resolved to a mounted window\n * yet is kept for the window made on it. The host never closes a window or quits on its own: it sends\n * `closeRequest` for the close button and Cmd-W, and `quitRequest` for Cmd-Q, a logout or an\n * update's relaunch, and waits for `close` or `answerQuit`. `closed` reports a window the OS\n * closed itself (an iPadOS scene swiped away), which no guard can keep.\n */\nexport type NativeWindowEvent =\n | { readonly type: 'focus'; readonly surface: number | null }\n | {\n readonly type: 'resize';\n readonly surface: number;\n readonly width: number;\n readonly height: number;\n readonly scale?: number;\n }\n | { readonly type: 'closeRequest'; readonly surface: number }\n | { readonly type: 'closed'; readonly surface: number }\n /**\n * Cmd-Q, a logout or an update's relaunch. `terminate` is a SIGTERM: run only the `willQuit`\n * handlers, ask no `canClose` guard, and answer true. The host ends after two seconds anyway.\n */\n | { readonly type: 'quitRequest'; readonly terminate?: boolean }\n /** A Dock click, or the app opened again, with no window visible. */\n | { readonly type: 'reopen' }\n /**\n * iPadOS: a window the user made from the system (New Window, or the app opened again with none\n * open). The app opens the main window in it, or brings the main window forward, and the host\n * then closes the window the user made.\n */\n | { readonly type: 'newWindow' };\n\n/**\n * The host's windows: the desktop host on macOS, and on iPadOS the components pod, whose windows\n * are scenes. iPadOS asks no app before it closes a scene, so it sends `closed` and never\n * `closeRequest`, and it has no quitting, so never `quitRequest`. The module is\n * `NgNativeWindows`, whose constant `multipleWindows` says whether the OS has windows at all,\n * and whose events arrive as `ngNativeWindows` on `DeviceEventEmitter`.\n */\nexport interface NativeWindows {\n /**\n * Open a window with its own surface, shown when the surface's first frame commits so it never\n * shows at the wrong size. Resolves the surface's id, or null where the host would not.\n */\n open(request: NativeWindowRequest): Promise<number | null>;\n /** Close the window on `surface` and stop its surface. */\n close(surface: number): void;\n focus(surface: number): void;\n setTitle(surface: number, title: string): void;\n /** Start quitting, as Cmd-Q does: the host answers with a `quitRequest`. */\n quit(): void;\n /** Answer a `quitRequest`: true quits, after which the host tears the runtime down in order. */\n answerQuit(proceed: boolean): void;\n subscribe(listener: (event: NativeWindowEvent) => void): () => void;\n}\n\ninterface WindowsTurboModule {\n getConstants?(): { multipleWindows?: boolean };\n open?(request: NativeWindowRequest): Promise<number | null>;\n close?(surface: number): void;\n focus?(surface: number): void;\n setTitle?(surface: number, title: string): void;\n quit?(): void;\n answerQuit?(proceed: boolean): void;\n}\n\n/**\n * The runnable each window's surface runs on an iPad, where the host makes the surface through\n * React Native's own host: it renders nothing, as the window's root is mounted from the app.\n */\nconst WINDOW_RUNNABLE = 'NgNativeWindow';\n\n/**\n * The host's module, or null where the OS has one window: phones, Android, Expo Go, an older\n * host. Registers the windows' runnable where there is one.\n */\nexport function windowsSource(): NativeWindows | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeWindows') as\n WindowsTurboModule | null | undefined;\n if (!module?.getConstants?.().multipleWindows) return null;\n native?.AppRegistry?.registerRunnable(WINDOW_RUNNABLE, () => {});\n return {\n open: async (request) => (await module.open?.(request)) ?? null,\n close: (surface) => module.close?.(surface),\n focus: (surface) => module.focus?.(surface),\n setTitle: (surface, title) => module.setTitle?.(surface, title),\n quit: () => module.quit?.(),\n answerQuit: (proceed) => module.answerQuit?.(proceed),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeWindows', (event) =>\n listener(event as NativeWindowEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n/** One window's mount, as `WINDOW_MOUNTER` answers it. */\nexport interface WindowMount {\n /** Tell the window's engine its new size, which its media queries resolve against. */\n resize(size: { width: number; height: number; scale?: number }): void;\n /** Destroy what the window renders, and stop its engine taking events. */\n destroy(): void;\n}\n\n/**\n * How a window's root is rendered on its surface. `@ng-native/platform` provides it: the\n * component is created in the app's environment injector, under an element injector with the\n * window's renderer, engine and `providers` (which hold `CURRENT_WINDOW`), and attached to the\n * app's one change detection. `main` is the app's root component, which the app's bootstrap\n * listeners (the Router's initial navigation) are told of the first time it mounts.\n */\nexport interface WindowMounter {\n mount(\n surface: number,\n component: Type<unknown>,\n options: {\n readonly inputs?: Readonly<Record<string, unknown>>;\n /** The main window's: what `mount` was given for the root component. */\n readonly bindings?: Binding[];\n readonly providers: Provider[];\n readonly main?: boolean;\n },\n ): WindowMount;\n}\n\n/** The platform's `WindowMounter`, or null where nothing can mount a window: a test with none. */\nexport const WINDOW_MOUNTER = new InjectionToken<WindowMounter | null>(\n 'angular-native.windowMounter',\n { factory: () => null },\n);\n\n/** The window a component is rendered in, or null outside one: every app with one surface. */\nexport const CURRENT_WINDOW = new InjectionToken<AppWindow | null>('angular-native.currentWindow', {\n factory: () => null,\n});\n\n/** What `provideMainWindow` was given. */\nexport const MAIN_WINDOW_OPTIONS = new InjectionToken<MainWindowOptions>(\n 'angular-native.mainWindowOptions',\n { factory: () => ({}) },\n);\n\n/**\n * Configure the main window, which renders the app's root component: its size and title bar, and\n * with `autoOpen: false` that the app starts with no window. Where the OS has one window, only\n * `autoOpen` is read, and it is ignored there: the app's one surface is its window.\n */\nexport function provideMainWindow(options: MainWindowOptions): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: MAIN_WINDOW_OPTIONS, useValue: options }]);\n}\n\n/** An open window and what it needs to close. */\ninterface Open {\n readonly handle: AppWindow;\n /** How it opens again after a reload, or null where it does not. */\n restore: RestoredWindow | null;\n readonly guards: Set<CloseGuard>;\n readonly outlet: string | undefined;\n readonly closedNow: () => void;\n mount: WindowMount | null;\n closing: boolean;\n}\n\n@Service()\nexport class AppWindows {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeWindows | null>(\n 'angular-native.windowsSource',\n { factory: windowsSource },\n );\n\n private readonly native = inject(AppWindows.SOURCE);\n private readonly mounter = inject(WINDOW_MOUNTER);\n private readonly navigator = inject(WINDOW_NAVIGATOR);\n private readonly lifecycle = inject(AppLifecycle);\n private readonly mainOptions = inject(MAIN_WINDOW_OPTIONS);\n private readonly desktop = isDesktopOs(injectOs());\n private readonly store = inject(WINDOW_RESTORE_STORE);\n private readonly restorable = new Map(\n (inject(RESTORABLE_WINDOWS, { optional: true }) ?? []).flatMap((components) =>\n Object.entries(components),\n ),\n );\n\n /**\n * Whether the OS has windows the app can open: macOS, and iPadOS with the components pod and the\n * config plugin's `ios.multipleWindows`.\n */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n private readonly open$ = signal<readonly Open[]>([]);\n private readonly focusedSurface = signal<number | null>(null);\n\n /** Every open window, in the order they opened. */\n readonly windows: Signal<readonly AppWindow[]> = computed(() =>\n this.open$().map((open) => open.handle),\n );\n\n /** The key window, or null when none is: the app is in the background, or has no window. */\n readonly focused: Signal<AppWindow | null> = computed(\n () => this.windows().find((one) => one.surface === this.focusedSurface()) ?? null,\n );\n\n private main: {\n component: Type<unknown>;\n inputs?: Readonly<Record<string, unknown>>;\n bindings?: Binding[];\n } | null = null;\n\n /**\n * The last size the host sent for a surface no window is on yet. iPadOS sends a reclaimed\n * window's size as it answers `open`, which can be heard before the window is mounted; the mount\n * takes it once it is made. Gone when the surface closes, or a window is made on it.\n */\n private readonly earlySizes = new Map<\n number,\n { width: number; height: number; scale?: number | undefined }\n >();\n\n /** The open in flight for each key, so a second open of the key waits for it. */\n private readonly opening = new Map<string, Promise<unknown>>();\n\n /**\n * The quit being decided or finished: `finishing` is set once its `willQuit` handlers run, by its\n * guards agreeing or by a SIGTERM that arrived while they decided.\n */\n private quitting: { finishing: Promise<void> | null } | null = null;\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n /**\n * Start the app on an OS with windows: `component` is the app's root, which the main window\n * renders, and which opens now unless `provideMainWindow({ autoOpen: false })`. What\n * `@ng-native/platform`'s `mount` calls in place of rendering the root on the app's surface,\n * with the `inputs` and `bindings` it was given for the root.\n */\n launch(\n component: Type<unknown>,\n inputs?: Readonly<Record<string, unknown>>,\n bindings?: Binding[],\n ): void {\n this.main = { component, ...(inputs && { inputs }), ...(bindings && { bindings }) };\n const restoring = this.store?.read() ?? [];\n const autoOpen = this.mainOptions.autoOpen !== false;\n if (autoOpen) void this.openMain();\n // The main window opens anyway where it opens by itself.\n void this.reopen(restoring.filter((window) => !autoOpen || window.kind !== 'main'));\n }\n\n /**\n * Open again the windows the app had open when it last stopped: the host keeps them through a\n * reload until their keys are opened again, and closes them otherwise.\n */\n private async reopen(windows: readonly RestoredWindow[]): Promise<void> {\n for (const window of windows) {\n try {\n if (window.kind === 'main') {\n await this.openMain();\n } else if (window.kind === 'route') {\n await this.open({ ...window.options, outlet: window.outlet, path: window.path });\n } else {\n const component = this.restorable.get(window.component);\n if (!component) continue;\n await this.open(component, {\n ...window.options,\n restoreKey: window.key,\n ...(window.inputs && { inputs: window.inputs }),\n });\n }\n } catch (error) {\n console.error('[angular-native] A window could not open again after a reload:', error);\n }\n }\n }\n\n /** Write down which windows open again, in the order they opened. */\n private remember(): void {\n this.store?.write(this.open$().flatMap((open) => (open.restore ? [open.restore] : [])));\n }\n\n /** How a component window opens again, or null where it cannot: no name, or inputs JSON drops. */\n private restoreFor(\n component: Type<unknown>,\n key: string,\n inputs: Readonly<Record<string, unknown>> | undefined,\n options: WindowOptions,\n ): RestoredWindow | null {\n const name = [...this.restorable].find(([, one]) => one === component)?.[0];\n if (name === undefined) {\n console.warn(\n `[angular-native] The window '${key}' will not open again after a reload: name its ` +\n 'component with provideRestorableWindows({ ... }).',\n );\n return null;\n }\n let copied: Readonly<Record<string, unknown>> | undefined;\n try {\n copied = inputs && (JSON.parse(JSON.stringify(inputs)) as Record<string, unknown>);\n } catch {\n console.warn(\n `[angular-native] The window '${key}' will not open again after a reload: its inputs ` +\n 'cannot be written as JSON.',\n );\n return null;\n }\n return { kind: 'component', key, component: name, ...(copied && { inputs: copied }), options };\n }\n\n /**\n * Open the main window, or bring it to the front where it is open. Null where the OS has no\n * windows, or before the app has launched.\n */\n openMain(): Promise<AppWindow | null> {\n return this.reserve('main', async () => {\n const existing = this.byKey('main');\n if (existing) return this.front(existing);\n if (!this.main) return null;\n const { autoOpen: _autoOpen, restoreKey, ...options } = this.mainOptions;\n return this.openWindow(this.main.component, {\n ...options,\n key: 'main',\n frameKey: this.desktop ? restoreKey : undefined,\n inputs: this.main.inputs,\n ...(this.main.bindings && { bindings: this.main.bindings }),\n main: true,\n restore: () => ({ kind: 'main' }),\n });\n });\n }\n\n /**\n * Run `opening` once every open of `key` already in flight has settled, so that it finds the\n * window they opened rather than opening a second one for the key.\n */\n private async reserve<T>(key: string, opening: () => Promise<T>): Promise<T> {\n for (let pending = this.opening.get(key); pending; pending = this.opening.get(key)) {\n await pending.catch(() => undefined);\n }\n const running = opening();\n this.opening.set(key, running);\n try {\n return await running;\n } finally {\n if (this.opening.get(key) === running) this.opening.delete(key);\n }\n }\n\n /**\n * Open a window. With a component, a window rendering it, as many as are asked for. With a\n * route, the window for that outlet, navigated to `path`; the outlet's window is brought to the\n * front and navigated where it is open already, since a route window is one of a kind\n * (Preferences). Resolves null where the OS has no windows, or the host would not open one.\n * Rejects once a quit has passed every window's guards and runs `willQuit`.\n */\n open(component: Type<unknown>, options?: ComponentWindowOptions): Promise<AppWindow | null>;\n open(route: RouteWindowOptions): Promise<AppWindow | null>;\n async open(\n target: Type<unknown> | RouteWindowOptions,\n options: ComponentWindowOptions = {},\n ): Promise<AppWindow | null> {\n if (typeof target === 'function') {\n const { inputs, restoreKey, ...rest } = options;\n const opening = () =>\n this.openWindow(target, {\n ...rest,\n key: restoreKey ?? null,\n ...(inputs && { inputs }),\n restore: () =>\n restoreKey === undefined ? null : this.restoreFor(target, restoreKey, inputs, rest),\n });\n if (restoreKey === undefined) return opening();\n return this.reserve(restoreKey, async () => {\n const existing = this.byKey(restoreKey);\n return existing ? this.front(existing) : opening();\n });\n }\n const { outlet, path, ...rest } = target;\n const navigator = this.navigator;\n if (!navigator) {\n console.error(\n `[angular-native] A route window for '${outlet}' needs the native router: ` +\n 'provideNativeRouter() provides what navigates its outlet.',\n );\n return null;\n }\n const restore: RestoredWindow = { kind: 'route', outlet, path, options: rest };\n return this.reserve(outlet, async () => {\n const existing = this.byKey(outlet);\n if (existing) {\n // A refused navigation leaves the window where it was, and so what it restores to.\n if (await navigator.navigate(outlet, path)) {\n const open = this.find(existing.surface);\n if (open) open.restore = restore;\n this.remember();\n }\n return this.front(existing);\n }\n const window = navigator.window(outlet);\n const opened = await this.openWindow(window.component, {\n ...rest,\n key: outlet,\n outlet,\n providers: window.providers,\n restore: () => restore,\n });\n if (opened) await navigator.navigate(outlet, path);\n return opened;\n });\n }\n\n /**\n * Start quitting the app, as Cmd-Q does: every window's `canClose` guard, then the `willQuit`\n * handlers, then the app quits. One guard that says no keeps the app running. Does nothing where\n * the OS has no windows, since iOS and Android end an app themselves.\n */\n quit(): void {\n this.native?.quit();\n }\n\n private async openWindow(\n component: Type<unknown>,\n options: WindowOptions & {\n key: string | null;\n frameKey?: string | undefined;\n inputs?: Readonly<Record<string, unknown>> | undefined;\n bindings?: Binding[];\n outlet?: string;\n providers?: Provider[];\n main?: boolean;\n /** How the window opens again after a reload, worked out once it has opened. */\n restore?: () => RestoredWindow | null;\n },\n ): Promise<AppWindow | null> {\n const native = this.native;\n const mounter = this.mounter;\n if (!native || !mounter) return null;\n this.refuseWhileQuitting();\n const {\n key,\n frameKey = key,\n inputs,\n bindings,\n outlet,\n providers,\n main,\n autosave,\n title = '',\n restore,\n ...frame\n } = options;\n const surface = await native.open({\n ...frame,\n key: autosave === false ? null : frameKey,\n title,\n });\n if (surface === null) return null;\n const early = this.earlySizes.get(surface);\n this.earlySizes.delete(surface);\n // One the host opened as the quit began goes again.\n if (this.closing) {\n native.close(surface);\n this.refuseWhileQuitting();\n }\n const open = this.track(surface, key, outlet, title);\n open.restore = restore?.() ?? null;\n this.remember();\n this.mountIn(open, mounter, component, { inputs, bindings, providers, main });\n if (early) open.mount?.resize(early);\n return open.handle;\n }\n\n /**\n * Render `component` in the window. Where it throws, the mounter has taken down what it made,\n * and the window goes too, forgotten for a reload, before the error goes on.\n */\n private mountIn(\n open: Open,\n mounter: WindowMounter,\n component: Type<unknown>,\n options: {\n inputs?: Readonly<Record<string, unknown>> | undefined;\n bindings?: Binding[] | undefined;\n providers?: Provider[] | undefined;\n main?: boolean | undefined;\n },\n ): void {\n const { inputs, bindings, providers = [], main } = options;\n try {\n open.mount = mounter.mount(open.handle.surface, component, {\n ...(inputs && { inputs }),\n ...(bindings && { bindings }),\n providers: [{ provide: CURRENT_WINDOW, useValue: open.handle }, ...providers],\n ...(main && { main }),\n });\n } catch (error) {\n this.closeNow(open.handle.surface, true);\n throw error;\n }\n }\n\n /** Make the handle for a window that has opened on `surface`, and list it. */\n private track(\n surface: number,\n key: string | null,\n outlet: string | undefined,\n title: string,\n ): Open {\n const native = this.native!;\n const guards = new Set<CloseGuard>();\n const titleSignal = signal(title);\n let closedNow!: () => void;\n const closed = new Promise<void>((resolve) => (closedNow = resolve));\n const handle: AppWindow = {\n surface,\n key,\n title: titleSignal.asReadonly(),\n setTitle: (next) => {\n titleSignal.set(next);\n native.setTitle(surface, next);\n },\n focused: computed(() => this.focusedSurface() === surface),\n focus: () => native.focus(surface),\n close: () => this.closeAsked(surface),\n canClose: (guard) => {\n guards.add(guard);\n return () => void guards.delete(guard);\n },\n closed,\n };\n const open: Open = {\n handle,\n restore: null,\n guards,\n outlet,\n closedNow,\n mount: null,\n closing: false,\n };\n this.open$.update((all) => [...all, open]);\n return open;\n }\n\n private byKey(key: string): AppWindow | null {\n return this.open$().find((open) => open.handle.key === key)?.handle ?? null;\n }\n\n private front(window: AppWindow): AppWindow {\n window.focus();\n return window;\n }\n\n private find(surface: number): Open | undefined {\n return this.open$().find((open) => open.handle.surface === surface);\n }\n\n private hostSaid(event: NativeWindowEvent): void {\n switch (event.type) {\n case 'focus':\n this.focusedSurface.set(event.surface);\n return;\n case 'resize': {\n const open = this.find(event.surface);\n if (open) open.mount?.resize(event);\n else this.earlySizes.set(event.surface, event);\n return;\n }\n case 'closeRequest':\n void this.closeAsked(event.surface);\n return;\n case 'closed':\n this.earlySizes.delete(event.surface);\n this.closeNow(event.surface, false);\n return;\n case 'quitRequest':\n void this.quitAsked(event.terminate === true);\n return;\n case 'reopen':\n if (!this.open$().length) void this.openMain();\n return;\n case 'newWindow':\n void this.openMain();\n return;\n }\n }\n\n /** Ask a window's guards, and close it if every one agrees. */\n private async closeAsked(surface: number): Promise<boolean> {\n const open = this.find(surface);\n if (!open || open.closing) return false;\n open.closing = true;\n const allowed = await this.guardsAgree(open);\n open.closing = false;\n if (!allowed || !this.find(surface)) return false;\n this.closeNow(surface, true);\n return true;\n }\n\n private async guardsAgree(open: Open): Promise<boolean> {\n for (const guard of [...open.guards]) {\n try {\n if (!(await guard())) return false;\n } catch (error) {\n // A guard that fails keeps the window, rather than losing what it was guarding.\n console.error('[angular-native] A canClose guard failed:', error);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Take a window down: what it renders, its outlet, the host's window where the app is closing\n * it, then the app itself where that was the last window and the app quits with it.\n */\n private closeNow(surface: number, tellHost: boolean): void {\n const open = this.find(surface);\n if (!open) return;\n this.open$.update((all) => all.filter((one) => one !== open));\n if (open.restore) this.remember();\n if (this.focusedSurface() === surface) this.focusedSurface.set(null);\n open.mount?.destroy();\n open.mount = null;\n if (open.outlet) void this.navigator?.clear(open.outlet);\n if (tellHost) this.native?.close(surface);\n open.closedNow();\n if (!this.open$().length && this.lifecycle.quitWhenLastWindowCloses) this.native?.quit();\n }\n\n /**\n * The host asks to quit: every window's guards, in the order the windows opened, then the\n * `willQuit` handlers, then the answer. One guard that says no keeps the app, and every window.\n * A SIGTERM (`terminate`) skips the guards, and one that arrives while a quit's guards decide\n * finishes that quit, whatever they answer.\n */\n private async quitAsked(terminate: boolean): Promise<void> {\n const current = this.quitting;\n if (current) {\n // One quit at a time: its answer is the host's. A SIGTERM no longer waits for its guards.\n if (terminate) current.finishing ??= this.finishQuit();\n return;\n }\n const quit: { finishing: Promise<void> | null } = { finishing: null };\n this.quitting = quit;\n try {\n // A SIGTERM is no one's choice to veto: no guard is asked, so a dialog cannot hold it.\n const agreed = terminate || (await this.everyWindowAgrees());\n if (!agreed && !quit.finishing) {\n this.native?.answerQuit(false);\n return;\n }\n quit.finishing ??= this.finishQuit();\n await quit.finishing;\n } finally {\n this.quitting = null;\n }\n }\n\n /**\n * Ask each window's guards in turn, including a window that opened while an earlier one's guard\n * decided. False at the first that says no.\n */\n private async everyWindowAgrees(): Promise<boolean> {\n const asked = new Set<Open>();\n for (let open = this.unasked(asked); open; open = this.unasked(asked)) {\n asked.add(open);\n if (!(await this.guardsAgree(open))) return false;\n }\n // In the same turn as the last check, so a window the host finishes opening after it is refused.\n this.closing = true;\n return true;\n }\n\n private unasked(asked: ReadonlySet<Open>): Open | undefined {\n return this.open$().find((open) => !asked.has(open));\n }\n\n private async finishQuit(): Promise<void> {\n // From here the app is quitting: a window opened now would have guards no one asks.\n this.closing = true;\n try {\n await this.lifecycle.runWillQuit();\n this.native?.answerQuit(true);\n } catch (error) {\n // Approved and answered, the app stays closed to new windows until it exits. Only a quit\n // that did not get that far lets them open again.\n this.closing = false;\n throw error;\n }\n }\n\n /** Whether a quit has passed its guards and is running `willQuit`: no window opens then. */\n private closing = false;\n\n private refuseWhileQuitting(): void {\n if (this.closing) {\n throw new Error('[angular-native] A window cannot open while the app is quitting.');\n }\n }\n\n /** Stop listening to the host: for a test that makes the service more than once. */\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ /**
3
+ * Whether the screen something is on was presented as a form sheet, directly or as a screen of a
4
+ * stack in one. A navigation outlet provides it for each screen it shows; outside one it is false.
5
+ *
6
+ * For Android's defaults that assume a screen fills the window: a sheet never reaches the status
7
+ * bar, and its drag only gives way to a scroll view with nested scrolling on.
8
+ */
9
+ export declare const IN_FORM_SHEET: InjectionToken<boolean>;
@@ -0,0 +1,12 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ /**
3
+ * Whether the screen something is on was presented as a form sheet, directly or as a screen of a
4
+ * stack in one. A navigation outlet provides it for each screen it shows; outside one it is false.
5
+ *
6
+ * For Android's defaults that assume a screen fills the window: a sheet never reaches the status
7
+ * bar, and its drag only gives way to a scroll view with nested scrolling on.
8
+ */
9
+ export const IN_FORM_SHEET = new InjectionToken('angular-native.inFormSheet', {
10
+ factory: () => false,
11
+ });
12
+ //# sourceMappingURL=in-form-sheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-form-sheet.js","sourceRoot":"","sources":["../src/in-form-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,cAAc,CAAU,4BAA4B,EAAE;IACrF,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK;CACrB,CAAC,CAAC","sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/**\n * Whether the screen something is on was presented as a form sheet, directly or as a screen of a\n * stack in one. A navigation outlet provides it for each screen it shows; outside one it is false.\n *\n * For Android's defaults that assume a screen fills the window: a sheet never reaches the status\n * bar, and its drag only gives way to a scroll view with nested scrolling on.\n */\nexport const IN_FORM_SHEET = new InjectionToken<boolean>('angular-native.inFormSheet', {\n factory: () => false,\n});\n"]}
package/dist/index.d.ts CHANGED
@@ -27,6 +27,8 @@ export { TopClaim, WindowClaims, onWindowFront, sharedBySource, type Claim, } fr
27
27
  export { NavigationBar, navigationBarSource, type NavigationBarSource, type NavigationBarState, type NavigationBarStyle, } from './navigation-bar.ts';
28
28
  export { SCREEN_IN_FRONT } from './screen-in-front.ts';
29
29
  export { SCREEN_SHOWN } from './screen-shown.ts';
30
+ export { IN_FORM_SHEET } from './in-form-sheet.ts';
31
+ export { outputListened } from './output-listened.ts';
30
32
  export { NATIVE_HISTORY } from './native-history.ts';
31
33
  export { APPLE, DESKTOP, OS, OS_NAMES, type OsName } from './os.ts';
32
34
  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';
@@ -52,6 +54,7 @@ export { APP_LIFECYCLE_OPTIONS, AppLifecycle, WILL_QUIT_DEADLINE_MS, provideAppL
52
54
  export { OS_VERSION } from './os-version.ts';
53
55
  export { injectToken, type InjectTokenOptions } from './inject-token.ts';
54
56
  export { type ControlSize } from './control-size.ts';
57
+ export { SVG_ICON_RENDERER, type SvgIconRenderer } from './svg-icon-renderer.ts';
55
58
  export { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, provideRestorableWindows, type RestoredWindow, type WindowRestoreStore, } from './window-restore.ts';
56
59
  export { buildMenuTemplate, type MenuTemplate } from './menu-template.ts';
57
60
  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
@@ -26,6 +26,8 @@ export { TopClaim, WindowClaims, onWindowFront, sharedBySource, } from "./window
26
26
  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
+ export { IN_FORM_SHEET } from "./in-form-sheet.js";
30
+ export { outputListened } from "./output-listened.js";
29
31
  export { NATIVE_HISTORY } from "./native-history.js";
30
32
  export { APPLE, DESKTOP, OS, OS_NAMES } from "./os.js";
31
33
  export { MENU_MODEL, createMenuModel, defaultMenuBar, isSeparator, mergeMenuBar, menuModelInTreeOrder, treeOrder, } from "./menu-model.js";
@@ -51,6 +53,7 @@ export { APP_LIFECYCLE_OPTIONS, AppLifecycle, WILL_QUIT_DEADLINE_MS, provideAppL
51
53
  export { OS_VERSION } from "./os-version.js";
52
54
  export { injectToken } from "./inject-token.js";
53
55
  export {} from "./control-size.js";
56
+ export { SVG_ICON_RENDERER } from "./svg-icon-renderer.js";
54
57
  export { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, provideRestorableWindows, } from "./window-restore.js";
55
58
  export { buildMenuTemplate } from "./menu-template.js";
56
59
  export { INTERACTION_OBSERVERS, MAX_TEXT_LENGTH, describeElement, interactionObservers, notifyInteraction, provideInteractionObserver, textWithin, } from "./interaction-observer.js";
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,cAAc,EACd,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,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,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, OS_NAMES, type OsName } 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"]}
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,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,EAA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AAC;AACrD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,wBAAwB,CAAC;AACjF,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 { IN_FORM_SHEET } from './in-form-sheet.ts';\nexport { outputListened } from './output-listened.ts';\nexport { NATIVE_HISTORY } from './native-history.ts';\nexport { APPLE, DESKTOP, OS, OS_NAMES, type OsName } 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 { SVG_ICON_RENDERER, type SvgIconRenderer } from './svg-icon-renderer.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"]}
@@ -32,6 +32,11 @@ export interface MenuItemModel {
32
32
  readonly sfSymbol?: string;
33
33
  /** A drawable resource's name, shown on Android. */
34
34
  readonly icon?: string;
35
+ /**
36
+ * An icon's SVG markup, such as an `@ng-icons` icon, shown on macOS where there is no `sfSymbol`,
37
+ * and in a Linux tray icon's menu.
38
+ */
39
+ readonly svgIcon?: string;
35
40
  /**
36
41
  * The standard menu a top-level `<menu-group menuRole>` adds its items to, for a group written
37
42
  * in a `<menu-bar>`: what becomes `MenuGroupModel.menuRole`.
@@ -1 +1 @@
1
- {"version":3,"file":"menu-model.js","sourceRoot":"","sources":["../src/menu-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AA8E9E,MAAM,SAAS,GAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAgB,EAA0B,EAAE,CAAC,WAAW,IAAI,KAAK,CA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MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAc,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,cAAc,CAAY,0BAA0B,CAAC,CAAC","sourcesContent":["/**\n * Menus as data, shared by every OS: the menu bar every desktop app gets, how an app's\n * `<menu-bar>` merges into it, and the token a `<menu-item>` registers itself through.\n *\n * `@ng-native/components` builds this from `<menu-group>` and `<menu-item>`, a\n * `<native-header-item [menu]>` reads it, and each OS draws it: the desktop host as the menu bar,\n * iPadOS through UIMenuBuilder. The rules live here, in TypeScript, so every OS follows the same\n * ones; only what AppKit adds itself (Services' contents, Spelling, Substitutions, Dictation and\n * Emoji) is left to the desktop host.\n */\nimport { InjectionToken, computed, signal, type Signal } from '@angular/core';\nimport type { OsName } from './os.ts';\n\n/** A standard menu a `<menu-group menuRole>` adds its items to. */\nexport type MenuGroupRole = 'app' | 'file' | 'edit' | 'view' | 'window' | 'help';\n\n/**\n * What an item is for, where the OS has a standard one: an item with a `menuRole` replaces that\n * role's default item, and without a handler does what the OS does for it.\n */\nexport type MenuRole =\n | 'about'\n | 'settings'\n | 'services'\n | 'hide'\n | 'hideOthers'\n | 'showAll'\n | 'quit'\n | 'undo'\n | 'redo'\n | 'cut'\n | 'copy'\n | 'paste'\n | 'selectAll'\n | 'find'\n | 'toggleSidebar'\n | 'toggleFullScreen'\n | 'back'\n | 'forward'\n | 'minimize'\n | 'zoom'\n | 'bringAllToFront'\n | 'close'\n | 'print'\n | 'keyboardShortcuts'\n | 'help';\n\n/** One item in a menu. */\nexport interface MenuItemModel {\n readonly label: string;\n readonly menuRole?: MenuRole;\n /** `mod+s`, as `parseShortcut` reads it. */\n readonly shortcut?: string;\n readonly disabled?: boolean;\n /** A check mark, where the item is a toggle. */\n readonly checked?: boolean;\n readonly destructive?: boolean;\n readonly subtitle?: string;\n /** An SF Symbol, shown on Apple's OSes. */\n readonly sfSymbol?: string;\n /** A drawable resource's name, shown on Android. */\n readonly icon?: string;\n /**\n * The standard menu a top-level `<menu-group menuRole>` adds its items to, for a group written\n * in a `<menu-bar>`: what becomes `MenuGroupModel.menuRole`.\n */\n readonly group?: MenuGroupRole;\n /** A submenu, or with `inline` a section of the menu the item is in. */\n readonly items?: readonly MenuEntry[];\n readonly inline?: boolean;\n /** What choosing it does. Left out on an item with a `menuRole`, the OS does it. */\n readonly select?: () => void;\n}\n\n/** A line between items. */\nexport interface MenuSeparator {\n readonly separator: true;\n}\n\nexport type MenuEntry = MenuItemModel | MenuSeparator;\n\n/** One menu in the menu bar. */\nexport interface MenuGroupModel {\n readonly label: string;\n readonly menuRole?: MenuGroupRole;\n readonly items: readonly MenuEntry[];\n}\n\nconst SEPARATOR: MenuSeparator = { separator: true };\n\nexport const isSeparator = (entry: MenuEntry): entry is MenuSeparator => 'separator' in entry;\n\nconst item = (label: string, menuRole: MenuRole, shortcut?: string): MenuItemModel =>\n shortcut ? { label, menuRole, shortcut } : { label, menuRole };\n\n/**\n * Linux's bar, as GNOME's and KDE's apps have theirs: File (Close Window, Print...), Edit, View\n * (Back, Forward, Show Sidebar on F9, Full Screen on F11), the app's own groups after View, and a\n * menu named for the app last, with Preferences and Help on F1 (each kept only with the app's\n * handler), Keyboard Shortcuts (a window the host draws, unless the app handles it), About and\n * Quit. None of macOS's Services, Hide, Minimize, Zoom or window list.\n */\nfunction linuxMenuBar(appName: string): MenuGroupModel[] {\n return [\n {\n label: 'File',\n menuRole: 'file',\n items: [\n item('Close Window', 'close', 'mod+w'),\n SEPARATOR,\n item('Print...', 'print', 'mod+p'),\n ],\n },\n {\n label: 'Edit',\n menuRole: 'edit',\n items: [\n item('Undo', 'undo', 'mod+z'),\n item('Redo', 'redo', 'mod+shift+z'),\n SEPARATOR,\n item('Cut', 'cut', 'mod+x'),\n item('Copy', 'copy', 'mod+c'),\n item('Paste', 'paste', 'mod+v'),\n item('Select All', 'selectAll', 'mod+a'),\n SEPARATOR,\n item('Find', 'find', 'mod+f'),\n ],\n },\n {\n label: 'View',\n menuRole: 'view',\n items: [\n item('Back', 'back'),\n item('Forward', 'forward'),\n SEPARATOR,\n item('Show Sidebar', 'toggleSidebar', 'F9'),\n item('Full Screen', 'toggleFullScreen', 'F11'),\n ],\n },\n {\n label: appName,\n menuRole: 'app',\n items: [\n item('Preferences', 'settings', 'mod+,'),\n item('Keyboard Shortcuts', 'keyboardShortcuts', 'mod+shift+?'),\n item('Help', 'help', 'F1'),\n SEPARATOR,\n item(`About ${appName}`, 'about'),\n SEPARATOR,\n item('Quit', 'quit', 'mod+q'),\n ],\n },\n ];\n}\n\n/**\n * The groups of a merged menu bar (`mergeMenuBar`) that have no `menuRole` and are named as one\n * of the default menus is: each is drawn as a second menu of that name beside the default one,\n * since only a role merges a group into its menu.\n */\nexport function unmergedGroups(\n defaults: readonly MenuGroupModel[],\n merged: readonly MenuGroupModel[],\n): string[] {\n const named = new Set(defaults.map((group) => group.label.toLowerCase()));\n return merged\n .filter((group) => !group.menuRole && named.has(group.label.toLowerCase()))\n .map((group) => group.label);\n}\n\n/**\n * The menu bar every desktop app gets on `os`. On macOS: App, File, Edit, View, Window and Help,\n * each item with its role and standard shortcut. `Settings...` is in it until the merge, which\n * keeps it only when the app gives it a handler. File holds Print... (`mod+p`), which prints the\n * key window unless the app gives a `print` item a handler. On Linux: linuxMenuBar's.\n */\nexport function defaultMenuBar(appName: string, os: OsName = 'macos'): MenuGroupModel[] {\n if (os === 'linux') return linuxMenuBar(appName);\n return [\n {\n label: appName,\n menuRole: 'app',\n items: [\n item(`About ${appName}`, 'about'),\n SEPARATOR,\n item('Settings...', 'settings', 'mod+,'),\n SEPARATOR,\n item('Services', 'services'),\n SEPARATOR,\n item(`Hide ${appName}`, 'hide', 'mod+h'),\n item('Hide Others', 'hideOthers', 'mod+alt+h'),\n item('Show All', 'showAll'),\n SEPARATOR,\n item(`Quit ${appName}`, 'quit', 'mod+q'),\n ],\n },\n { label: 'File', menuRole: 'file', items: [item('Print...', 'print', 'mod+p')] },\n {\n label: 'Edit',\n menuRole: 'edit',\n items: [\n item('Undo', 'undo', 'mod+z'),\n item('Redo', 'redo', 'mod+shift+z'),\n SEPARATOR,\n item('Cut', 'cut', 'mod+x'),\n item('Copy', 'copy', 'mod+c'),\n item('Paste', 'paste', 'mod+v'),\n item('Select All', 'selectAll', 'mod+a'),\n SEPARATOR,\n item('Find', 'find', 'mod+f'),\n ],\n },\n {\n label: 'View',\n menuRole: 'view',\n items: [\n // Their keys are each OS's own, which `navigationShortcut` gives: not a `mod` chord.\n item('Back', 'back'),\n item('Forward', 'forward'),\n SEPARATOR,\n item('Show Sidebar', 'toggleSidebar', 'ctrl+mod+s'),\n item('Enter Full Screen', 'toggleFullScreen', 'ctrl+mod+f'),\n ],\n },\n {\n label: 'Window',\n menuRole: 'window',\n items: [\n // An app with a File menu has it at the end of that menu instead, as a Mac app does.\n item('Close Window', 'close', 'mod+w'),\n item('Minimize', 'minimize', 'mod+m'),\n item('Zoom', 'zoom'),\n SEPARATOR,\n item('Bring All to Front', 'bringAllToFront'),\n ],\n },\n { label: 'Help', menuRole: 'help', items: [] },\n ];\n}\n\n/** Every item with a `menuRole`, by role, read through submenus and sections. */\nfunction byRole(groups: readonly MenuGroupModel[]): Map<MenuRole, MenuItemModel> {\n const found = new Map<MenuRole, MenuItemModel>();\n const walk = (entries: readonly MenuEntry[]) => {\n for (const entry of entries) {\n if (isSeparator(entry)) continue;\n if (entry.menuRole && !found.has(entry.menuRole)) found.set(entry.menuRole, entry);\n if (entry.items) walk(entry.items);\n }\n };\n for (const group of groups) walk(group.items);\n return found;\n}\n\n/** `entries` without the items `drop` names, and with no separator leading, trailing or doubled. */\nfunction tidy(entries: readonly MenuEntry[], drop: (item: MenuItemModel) => boolean): MenuEntry[] {\n const kept: MenuEntry[] = [];\n for (const entry of entries) {\n if (isSeparator(entry)) {\n if (kept.length && !isSeparator(kept[kept.length - 1]!)) kept.push(entry);\n continue;\n }\n if (drop(entry)) continue;\n kept.push(entry.items ? { ...entry, items: tidy(entry.items, drop) } : entry);\n }\n while (kept.length && isSeparator(kept[kept.length - 1]!)) kept.pop();\n return kept;\n}\n\ntype MergedGroup = { label: string; menuRole?: MenuGroupRole; items: MenuEntry[] };\n\n/**\n * The app's groups, each added to the default menu it names or set aside to go after App (a\n * `file` group with no default File menu) or after View. The items for the default File menu are\n * kept apart, to go before its own.\n */\nfunction placeAppGroups(\n merged: MergedGroup[],\n app: readonly MenuGroupModel[],\n defaultFile: MergedGroup | undefined,\n moved: (item: MenuItemModel) => boolean,\n): { afterApp: MergedGroup[]; afterView: MergedGroup[]; fileItems: MenuEntry[] } {\n const afterApp: MergedGroup[] = [];\n const afterView: MergedGroup[] = [];\n let fileItems: MenuEntry[] = [];\n for (const group of app) {\n const items = tidy(group.items, moved);\n const standard = merged.find((one) => group.menuRole && one.menuRole === group.menuRole);\n if (standard && standard === defaultFile) fileItems = joined(fileItems, items);\n else if (standard) standard.items = joined(standard.items, items);\n // A group whose items all replaced defaults: an empty menu is not worth a place in the bar.\n else if (items.length)\n (group.menuRole === 'file' ? afterApp : afterView).push({ ...group, items });\n }\n return { afterApp, afterView, fileItems };\n}\n\n/** `items` after `entries`, with a separator between when both have any. */\nfunction joined(entries: readonly MenuEntry[], items: readonly MenuEntry[]): MenuEntry[] {\n return entries.length && items.length\n ? [...entries, SEPARATOR, ...items]\n : [...entries, ...items];\n}\n\n/**\n * The File menu: the app's items, then Close Window when it moved there, then the defaults\n * (Print...), each part apart.\n */\nfunction fileMenu(\n own: readonly MenuEntry[],\n close: MenuItemModel | undefined,\n defaults: readonly MenuEntry[],\n): MenuEntry[] {\n return tidy([...own, SEPARATOR, ...(close ? [close, SEPARATOR] : []), ...defaults], () => false);\n}\n\n/** The Window menu's Close Window (or the app's `close` item), taken out of it. */\nfunction takeClose(\n groups: { menuRole?: MenuGroupRole; items: MenuEntry[] }[],\n): MenuItemModel | undefined {\n const window = groups.find((group) => group.menuRole === 'window');\n const close = window?.items.find((entry) => !isSeparator(entry) && entry.menuRole === 'close');\n if (!window || !close || isSeparator(close)) return undefined;\n window.items = tidy(window.items, (item) => item === close);\n return close;\n}\n\n/**\n * The menu bar an app ends up with, from the defaults and its `<menu-bar>`:\n *\n * - An app item with a `menuRole` replaces the default item with that role, where the default is,\n * and leaves the group it was written in.\n * - `Settings...` (Preferences on Linux) and Linux's Help show only when the app gives a `settings`\n * or `help` item a handler.\n * - A group whose `menuRole` names a default menu adds its items to the end of that menu; a `file`\n * group's go before Print..., which stays last, as on a Mac.\n * - A `file` group with no default File menu goes after the App menu, and any other group after\n * View, in the order the app wrote them. A group left with no items is left out.\n * - With a `file` group, the Window menu's Close Window (or the app's own `close` item) moves to\n * the File menu, after the app's items and before the defaults.\n */\nexport function mergeMenuBar(\n defaults: readonly MenuGroupModel[],\n app: readonly MenuGroupModel[],\n): MenuGroupModel[] {\n const replacing = byRole(app);\n const defaultRoles = byRole(defaults);\n // Preferences (Settings... on macOS) and Help show only with the app's handler: the OS has none.\n const handled = (role: MenuRole) => Boolean(replacing.get(role)?.select);\n const replace = (entries: readonly MenuEntry[]): MenuEntry[] =>\n entries.map((entry) => {\n if (isSeparator(entry)) return entry;\n const own = entry.menuRole && replacing.get(entry.menuRole);\n if (own) return own;\n return entry.items ? { ...entry, items: replace(entry.items) } : entry;\n });\n const merged: MergedGroup[] = defaults.map((group) => ({\n ...group,\n items: tidy(\n replace(group.items),\n (item) =>\n (item.menuRole === 'settings' || item.menuRole === 'help') && !handled(item.menuRole),\n ),\n }));\n const moved = (item: MenuItemModel) => Boolean(item.menuRole && defaultRoles.has(item.menuRole));\n const defaultFile = merged.find((group) => group.menuRole === 'file');\n const { afterApp, afterView, fileItems } = placeAppGroups(merged, app, defaultFile, moved);\n const file = defaultFile ?? afterApp[0];\n if (file) {\n const close = app.some((group) => group.menuRole === 'file') ? takeClose(merged) : undefined;\n file.items = fileMenu(defaultFile ? fileItems : file.items, close, defaultFile?.items ?? []);\n }\n const at = (role: MenuGroupRole) => merged.findIndex((group) => group.menuRole === role) + 1;\n merged.splice(at('view'), 0, ...afterView);\n merged.splice(at('app'), 0, ...afterApp);\n return merged;\n}\n\n/**\n * The entries a menu's `<menu-item>`s registered, in the order they registered. Each item\n * registers a signal of itself, so a changed label or a toggled check reaches the menu, and the\n * function `register` answers takes it out again as the item goes.\n */\nexport interface MenuModel {\n readonly entries: Signal<readonly MenuEntry[]>;\n /**\n * Add `entry`, at `place` where the container can order places: an item an `@if` shows later\n * takes its place in the template, not the end.\n */\n register(entry: Signal<MenuEntry>, place?: unknown): () => void;\n}\n\n/**\n * A menu model for a container to provide as `MENU_MODEL`. `order` compares two places, negative\n * for the first one earlier; places it cannot compare keep the order they registered in.\n */\nexport function createMenuModel(order?: (a: unknown, b: unknown) => number): MenuModel {\n type Registered = { entry: Signal<MenuEntry>; place: unknown };\n const registered = signal<readonly Registered[]>([]);\n return {\n entries: computed(() => {\n const all = registered();\n const sorted = order ? [...all].sort((a, b) => order(a.place, b.place)) : all;\n return sorted.map((one) => one.entry());\n }),\n register(entry, place) {\n const one: Registered = { entry, place };\n registered.update((all) => [...all, one]);\n return () => registered.update((all) => all.filter((each) => each !== one));\n },\n };\n}\n\n/** Just enough of a node to find its place: its parent, and the parent's children in order. */\ninterface TreeNode {\n readonly parent: TreeNode | null;\n readonly childList: readonly TreeNode[];\n}\n\n/** Where a node is in its tree: each ancestor's index in its parent, from the root down. */\nfunction placeOf(node: TreeNode): { root: TreeNode; path: number[] } {\n const path: number[] = [];\n let at = node;\n while (at.parent) {\n path.unshift(at.parent.childList.indexOf(at));\n at = at.parent;\n }\n return { root: at, path };\n}\n\n/**\n * Which of two elements comes first in the tree: negative for `a`. Elements in different trees, or\n * not in one yet, compare equal, and keep the order they registered in.\n */\nexport function treeOrder(a: unknown, b: unknown): number {\n if (!a || !b) return 0;\n const first = placeOf(a as TreeNode);\n const second = placeOf(b as TreeNode);\n if (first.root !== second.root) return 0;\n for (let i = 0; i < Math.min(first.path.length, second.path.length); i++) {\n const step = first.path[i]! - second.path[i]!;\n if (step) return step;\n }\n return first.path.length - second.path.length;\n}\n\n/** A menu model whose entries keep their places in the template. */\nexport const menuModelInTreeOrder = (): MenuModel => createMenuModel(treeOrder);\n\n/**\n * Where a `<menu-item>` registers itself: the menu it is written in, which a `<menu-group>`, a\n * submenu or a `<native-header-item [menu]>` template provides. There is none at the root, so an\n * item outside a menu is told so by its own injection.\n */\nexport const MENU_MODEL = new InjectionToken<MenuModel>('angular-native.menuModel');\n"]}
1
+ {"version":3,"file":"menu-model.js","sourceRoot":"","sources":["../src/menu-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAmF9E,MAAM,SAAS,GAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAgB,EAA0B,EAAE,CAAC,WAAW,IAAI,KAAK,CAAC;AAE9F,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,QAAkB,EAAE,QAAiB,EAAiB,EAAE,CACnF,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAEjE;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO;QACL;YACE,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE;gBACL,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC;gBACtC,SAAS;gBACT,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC;aACnC;SACF;QACD;YACE,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,MAAM;YAChB,KA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GAGG;AACH,MAAM,UAAU,SAAS,CAAC,CAAU,EAAE,CAAU;IAC9C,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACvB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAa,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAa,CAAC,CAAC;IACtC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC;QAC9C,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAc,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,cAAc,CAAY,0BAA0B,CAAC,CAAC","sourcesContent":["/**\n * Menus as data, shared by every OS: the menu bar every desktop app gets, how an app's\n * `<menu-bar>` merges into it, and the token a `<menu-item>` registers itself through.\n *\n * `@ng-native/components` builds this from `<menu-group>` and `<menu-item>`, a\n * `<native-header-item [menu]>` reads it, and each OS draws it: the desktop host as the menu bar,\n * iPadOS through UIMenuBuilder. The rules live here, in TypeScript, so every OS follows the same\n * ones; only what AppKit adds itself (Services' contents, Spelling, Substitutions, Dictation and\n * Emoji) is left to the desktop host.\n */\nimport { InjectionToken, computed, signal, type Signal } from '@angular/core';\nimport type { OsName } from './os.ts';\n\n/** A standard menu a `<menu-group menuRole>` adds its items to. */\nexport type MenuGroupRole = 'app' | 'file' | 'edit' | 'view' | 'window' | 'help';\n\n/**\n * What an item is for, where the OS has a standard one: an item with a `menuRole` replaces that\n * role's default item, and without a handler does what the OS does for it.\n */\nexport type MenuRole =\n | 'about'\n | 'settings'\n | 'services'\n | 'hide'\n | 'hideOthers'\n | 'showAll'\n | 'quit'\n | 'undo'\n | 'redo'\n | 'cut'\n | 'copy'\n | 'paste'\n | 'selectAll'\n | 'find'\n | 'toggleSidebar'\n | 'toggleFullScreen'\n | 'back'\n | 'forward'\n | 'minimize'\n | 'zoom'\n | 'bringAllToFront'\n | 'close'\n | 'print'\n | 'keyboardShortcuts'\n | 'help';\n\n/** One item in a menu. */\nexport interface MenuItemModel {\n readonly label: string;\n readonly menuRole?: MenuRole;\n /** `mod+s`, as `parseShortcut` reads it. */\n readonly shortcut?: string;\n readonly disabled?: boolean;\n /** A check mark, where the item is a toggle. */\n readonly checked?: boolean;\n readonly destructive?: boolean;\n readonly subtitle?: string;\n /** An SF Symbol, shown on Apple's OSes. */\n readonly sfSymbol?: string;\n /** A drawable resource's name, shown on Android. */\n readonly icon?: string;\n /**\n * An icon's SVG markup, such as an `@ng-icons` icon, shown on macOS where there is no `sfSymbol`,\n * and in a Linux tray icon's menu.\n */\n readonly svgIcon?: string;\n /**\n * The standard menu a top-level `<menu-group menuRole>` adds its items to, for a group written\n * in a `<menu-bar>`: what becomes `MenuGroupModel.menuRole`.\n */\n readonly group?: MenuGroupRole;\n /** A submenu, or with `inline` a section of the menu the item is in. */\n readonly items?: readonly MenuEntry[];\n readonly inline?: boolean;\n /** What choosing it does. Left out on an item with a `menuRole`, the OS does it. */\n readonly select?: () => void;\n}\n\n/** A line between items. */\nexport interface MenuSeparator {\n readonly separator: true;\n}\n\nexport type MenuEntry = MenuItemModel | MenuSeparator;\n\n/** One menu in the menu bar. */\nexport interface MenuGroupModel {\n readonly label: string;\n readonly menuRole?: MenuGroupRole;\n readonly items: readonly MenuEntry[];\n}\n\nconst SEPARATOR: MenuSeparator = { separator: true };\n\nexport const isSeparator = (entry: MenuEntry): entry is MenuSeparator => 'separator' in entry;\n\nconst item = (label: string, menuRole: MenuRole, shortcut?: string): MenuItemModel =>\n shortcut ? { label, menuRole, shortcut } : { label, menuRole };\n\n/**\n * Linux's bar, as GNOME's and KDE's apps have theirs: File (Close Window, Print...), Edit, View\n * (Back, Forward, Show Sidebar on F9, Full Screen on F11), the app's own groups after View, and a\n * menu named for the app last, with Preferences and Help on F1 (each kept only with the app's\n * handler), Keyboard Shortcuts (a window the host draws, unless the app handles it), About and\n * Quit. None of macOS's Services, Hide, Minimize, Zoom or window list.\n */\nfunction linuxMenuBar(appName: string): MenuGroupModel[] {\n return [\n {\n label: 'File',\n menuRole: 'file',\n items: [\n item('Close Window', 'close', 'mod+w'),\n SEPARATOR,\n item('Print...', 'print', 'mod+p'),\n ],\n },\n {\n label: 'Edit',\n menuRole: 'edit',\n items: [\n item('Undo', 'undo', 'mod+z'),\n item('Redo', 'redo', 'mod+shift+z'),\n SEPARATOR,\n item('Cut', 'cut', 'mod+x'),\n item('Copy', 'copy', 'mod+c'),\n item('Paste', 'paste', 'mod+v'),\n item('Select All', 'selectAll', 'mod+a'),\n SEPARATOR,\n item('Find', 'find', 'mod+f'),\n ],\n },\n {\n label: 'View',\n menuRole: 'view',\n items: [\n item('Back', 'back'),\n item('Forward', 'forward'),\n SEPARATOR,\n item('Show Sidebar', 'toggleSidebar', 'F9'),\n item('Full Screen', 'toggleFullScreen', 'F11'),\n ],\n },\n {\n label: appName,\n menuRole: 'app',\n items: [\n item('Preferences', 'settings', 'mod+,'),\n item('Keyboard Shortcuts', 'keyboardShortcuts', 'mod+shift+?'),\n item('Help', 'help', 'F1'),\n SEPARATOR,\n item(`About ${appName}`, 'about'),\n SEPARATOR,\n item('Quit', 'quit', 'mod+q'),\n ],\n },\n ];\n}\n\n/**\n * The groups of a merged menu bar (`mergeMenuBar`) that have no `menuRole` and are named as one\n * of the default menus is: each is drawn as a second menu of that name beside the default one,\n * since only a role merges a group into its menu.\n */\nexport function unmergedGroups(\n defaults: readonly MenuGroupModel[],\n merged: readonly MenuGroupModel[],\n): string[] {\n const named = new Set(defaults.map((group) => group.label.toLowerCase()));\n return merged\n .filter((group) => !group.menuRole && named.has(group.label.toLowerCase()))\n .map((group) => group.label);\n}\n\n/**\n * The menu bar every desktop app gets on `os`. On macOS: App, File, Edit, View, Window and Help,\n * each item with its role and standard shortcut. `Settings...` is in it until the merge, which\n * keeps it only when the app gives it a handler. File holds Print... (`mod+p`), which prints the\n * key window unless the app gives a `print` item a handler. On Linux: linuxMenuBar's.\n */\nexport function defaultMenuBar(appName: string, os: OsName = 'macos'): MenuGroupModel[] {\n if (os === 'linux') return linuxMenuBar(appName);\n return [\n {\n label: appName,\n menuRole: 'app',\n items: [\n item(`About ${appName}`, 'about'),\n SEPARATOR,\n item('Settings...', 'settings', 'mod+,'),\n SEPARATOR,\n item('Services', 'services'),\n SEPARATOR,\n item(`Hide ${appName}`, 'hide', 'mod+h'),\n item('Hide Others', 'hideOthers', 'mod+alt+h'),\n item('Show All', 'showAll'),\n SEPARATOR,\n item(`Quit ${appName}`, 'quit', 'mod+q'),\n ],\n },\n { label: 'File', menuRole: 'file', items: [item('Print...', 'print', 'mod+p')] },\n {\n label: 'Edit',\n menuRole: 'edit',\n items: [\n item('Undo', 'undo', 'mod+z'),\n item('Redo', 'redo', 'mod+shift+z'),\n SEPARATOR,\n item('Cut', 'cut', 'mod+x'),\n item('Copy', 'copy', 'mod+c'),\n item('Paste', 'paste', 'mod+v'),\n item('Select All', 'selectAll', 'mod+a'),\n SEPARATOR,\n item('Find', 'find', 'mod+f'),\n ],\n },\n {\n label: 'View',\n menuRole: 'view',\n items: [\n // Their keys are each OS's own, which `navigationShortcut` gives: not a `mod` chord.\n item('Back', 'back'),\n item('Forward', 'forward'),\n SEPARATOR,\n item('Show Sidebar', 'toggleSidebar', 'ctrl+mod+s'),\n item('Enter Full Screen', 'toggleFullScreen', 'ctrl+mod+f'),\n ],\n },\n {\n label: 'Window',\n menuRole: 'window',\n items: [\n // An app with a File menu has it at the end of that menu instead, as a Mac app does.\n item('Close Window', 'close', 'mod+w'),\n item('Minimize', 'minimize', 'mod+m'),\n item('Zoom', 'zoom'),\n SEPARATOR,\n item('Bring All to Front', 'bringAllToFront'),\n ],\n },\n { label: 'Help', menuRole: 'help', items: [] },\n ];\n}\n\n/** Every item with a `menuRole`, by role, read through submenus and sections. */\nfunction byRole(groups: readonly MenuGroupModel[]): Map<MenuRole, MenuItemModel> {\n const found = new Map<MenuRole, MenuItemModel>();\n const walk = (entries: readonly MenuEntry[]) => {\n for (const entry of entries) {\n if (isSeparator(entry)) continue;\n if (entry.menuRole && !found.has(entry.menuRole)) found.set(entry.menuRole, entry);\n if (entry.items) walk(entry.items);\n }\n };\n for (const group of groups) walk(group.items);\n return found;\n}\n\n/** `entries` without the items `drop` names, and with no separator leading, trailing or doubled. */\nfunction tidy(entries: readonly MenuEntry[], drop: (item: MenuItemModel) => boolean): MenuEntry[] {\n const kept: MenuEntry[] = [];\n for (const entry of entries) {\n if (isSeparator(entry)) {\n if (kept.length && !isSeparator(kept[kept.length - 1]!)) kept.push(entry);\n continue;\n }\n if (drop(entry)) continue;\n kept.push(entry.items ? { ...entry, items: tidy(entry.items, drop) } : entry);\n }\n while (kept.length && isSeparator(kept[kept.length - 1]!)) kept.pop();\n return kept;\n}\n\ntype MergedGroup = { label: string; menuRole?: MenuGroupRole; items: MenuEntry[] };\n\n/**\n * The app's groups, each added to the default menu it names or set aside to go after App (a\n * `file` group with no default File menu) or after View. The items for the default File menu are\n * kept apart, to go before its own.\n */\nfunction placeAppGroups(\n merged: MergedGroup[],\n app: readonly MenuGroupModel[],\n defaultFile: MergedGroup | undefined,\n moved: (item: MenuItemModel) => boolean,\n): { afterApp: MergedGroup[]; afterView: MergedGroup[]; fileItems: MenuEntry[] } {\n const afterApp: MergedGroup[] = [];\n const afterView: MergedGroup[] = [];\n let fileItems: MenuEntry[] = [];\n for (const group of app) {\n const items = tidy(group.items, moved);\n const standard = merged.find((one) => group.menuRole && one.menuRole === group.menuRole);\n if (standard && standard === defaultFile) fileItems = joined(fileItems, items);\n else if (standard) standard.items = joined(standard.items, items);\n // A group whose items all replaced defaults: an empty menu is not worth a place in the bar.\n else if (items.length)\n (group.menuRole === 'file' ? afterApp : afterView).push({ ...group, items });\n }\n return { afterApp, afterView, fileItems };\n}\n\n/** `items` after `entries`, with a separator between when both have any. */\nfunction joined(entries: readonly MenuEntry[], items: readonly MenuEntry[]): MenuEntry[] {\n return entries.length && items.length\n ? [...entries, SEPARATOR, ...items]\n : [...entries, ...items];\n}\n\n/**\n * The File menu: the app's items, then Close Window when it moved there, then the defaults\n * (Print...), each part apart.\n */\nfunction fileMenu(\n own: readonly MenuEntry[],\n close: MenuItemModel | undefined,\n defaults: readonly MenuEntry[],\n): MenuEntry[] {\n return tidy([...own, SEPARATOR, ...(close ? [close, SEPARATOR] : []), ...defaults], () => false);\n}\n\n/** The Window menu's Close Window (or the app's `close` item), taken out of it. */\nfunction takeClose(\n groups: { menuRole?: MenuGroupRole; items: MenuEntry[] }[],\n): MenuItemModel | undefined {\n const window = groups.find((group) => group.menuRole === 'window');\n const close = window?.items.find((entry) => !isSeparator(entry) && entry.menuRole === 'close');\n if (!window || !close || isSeparator(close)) return undefined;\n window.items = tidy(window.items, (item) => item === close);\n return close;\n}\n\n/**\n * The menu bar an app ends up with, from the defaults and its `<menu-bar>`:\n *\n * - An app item with a `menuRole` replaces the default item with that role, where the default is,\n * and leaves the group it was written in.\n * - `Settings...` (Preferences on Linux) and Linux's Help show only when the app gives a `settings`\n * or `help` item a handler.\n * - A group whose `menuRole` names a default menu adds its items to the end of that menu; a `file`\n * group's go before Print..., which stays last, as on a Mac.\n * - A `file` group with no default File menu goes after the App menu, and any other group after\n * View, in the order the app wrote them. A group left with no items is left out.\n * - With a `file` group, the Window menu's Close Window (or the app's own `close` item) moves to\n * the File menu, after the app's items and before the defaults.\n */\nexport function mergeMenuBar(\n defaults: readonly MenuGroupModel[],\n app: readonly MenuGroupModel[],\n): MenuGroupModel[] {\n const replacing = byRole(app);\n const defaultRoles = byRole(defaults);\n // Preferences (Settings... on macOS) and Help show only with the app's handler: the OS has none.\n const handled = (role: MenuRole) => Boolean(replacing.get(role)?.select);\n const replace = (entries: readonly MenuEntry[]): MenuEntry[] =>\n entries.map((entry) => {\n if (isSeparator(entry)) return entry;\n const own = entry.menuRole && replacing.get(entry.menuRole);\n if (own) return own;\n return entry.items ? { ...entry, items: replace(entry.items) } : entry;\n });\n const merged: MergedGroup[] = defaults.map((group) => ({\n ...group,\n items: tidy(\n replace(group.items),\n (item) =>\n (item.menuRole === 'settings' || item.menuRole === 'help') && !handled(item.menuRole),\n ),\n }));\n const moved = (item: MenuItemModel) => Boolean(item.menuRole && defaultRoles.has(item.menuRole));\n const defaultFile = merged.find((group) => group.menuRole === 'file');\n const { afterApp, afterView, fileItems } = placeAppGroups(merged, app, defaultFile, moved);\n const file = defaultFile ?? afterApp[0];\n if (file) {\n const close = app.some((group) => group.menuRole === 'file') ? takeClose(merged) : undefined;\n file.items = fileMenu(defaultFile ? fileItems : file.items, close, defaultFile?.items ?? []);\n }\n const at = (role: MenuGroupRole) => merged.findIndex((group) => group.menuRole === role) + 1;\n merged.splice(at('view'), 0, ...afterView);\n merged.splice(at('app'), 0, ...afterApp);\n return merged;\n}\n\n/**\n * The entries a menu's `<menu-item>`s registered, in the order they registered. Each item\n * registers a signal of itself, so a changed label or a toggled check reaches the menu, and the\n * function `register` answers takes it out again as the item goes.\n */\nexport interface MenuModel {\n readonly entries: Signal<readonly MenuEntry[]>;\n /**\n * Add `entry`, at `place` where the container can order places: an item an `@if` shows later\n * takes its place in the template, not the end.\n */\n register(entry: Signal<MenuEntry>, place?: unknown): () => void;\n}\n\n/**\n * A menu model for a container to provide as `MENU_MODEL`. `order` compares two places, negative\n * for the first one earlier; places it cannot compare keep the order they registered in.\n */\nexport function createMenuModel(order?: (a: unknown, b: unknown) => number): MenuModel {\n type Registered = { entry: Signal<MenuEntry>; place: unknown };\n const registered = signal<readonly Registered[]>([]);\n return {\n entries: computed(() => {\n const all = registered();\n const sorted = order ? [...all].sort((a, b) => order(a.place, b.place)) : all;\n return sorted.map((one) => one.entry());\n }),\n register(entry, place) {\n const one: Registered = { entry, place };\n registered.update((all) => [...all, one]);\n return () => registered.update((all) => all.filter((each) => each !== one));\n },\n };\n}\n\n/** Just enough of a node to find its place: its parent, and the parent's children in order. */\ninterface TreeNode {\n readonly parent: TreeNode | null;\n readonly childList: readonly TreeNode[];\n}\n\n/** Where a node is in its tree: each ancestor's index in its parent, from the root down. */\nfunction placeOf(node: TreeNode): { root: TreeNode; path: number[] } {\n const path: number[] = [];\n let at = node;\n while (at.parent) {\n path.unshift(at.parent.childList.indexOf(at));\n at = at.parent;\n }\n return { root: at, path };\n}\n\n/**\n * Which of two elements comes first in the tree: negative for `a`. Elements in different trees, or\n * not in one yet, compare equal, and keep the order they registered in.\n */\nexport function treeOrder(a: unknown, b: unknown): number {\n if (!a || !b) return 0;\n const first = placeOf(a as TreeNode);\n const second = placeOf(b as TreeNode);\n if (first.root !== second.root) return 0;\n for (let i = 0; i < Math.min(first.path.length, second.path.length); i++) {\n const step = first.path[i]! - second.path[i]!;\n if (step) return step;\n }\n return first.path.length - second.path.length;\n}\n\n/** A menu model whose entries keep their places in the template. */\nexport const menuModelInTreeOrder = (): MenuModel => createMenuModel(treeOrder);\n\n/**\n * Where a `<menu-item>` registers itself: the menu it is written in, which a `<menu-group>`, a\n * submenu or a `<native-header-item [menu]>` template provides. There is none at the root, so an\n * item outside a menu is told so by its own injection.\n */\nexport const MENU_MODEL = new InjectionToken<MenuModel>('angular-native.menuModel');\n"]}
package/dist/menus.d.ts CHANGED
@@ -17,7 +17,9 @@
17
17
  * since React Native's Android view drops a `contextMenu` prop it does not know.
18
18
  * - On iOS it is a TurboModule with `setContextMenu(nativeID, entries)` too, for the same reason.
19
19
  * React Native's iOS view sends no event it does not know either, so the module sends the item
20
- * chosen as `{ type: 'contextMenuSelect', nativeID, id }`.
20
+ * chosen as `{ type: 'contextMenuSelect', nativeID, id }`. Its `setPressMenu(nativeID, entries)`
21
+ * lays a menu a press opens over that view, and sends the item chosen as
22
+ * `{ type: 'pressMenuSelect', nativeID, id }`: UIKit opens a menu on a touch, but not from code.
21
23
  * - Where it draws menus on a press, `popUpMenu(view, entries)` draws one under the view with that
22
24
  * tag now, and sends the item chosen as the view's `topContextMenuSelect`, as a context menu's
23
25
  * (the desktop host, and Android).
@@ -47,6 +49,7 @@ export type NativeMenuEntry = {
47
49
  readonly subtitle?: string;
48
50
  readonly sfSymbol?: string;
49
51
  readonly icon?: string;
52
+ readonly svgIcon?: string;
50
53
  readonly inline?: boolean;
51
54
  readonly items?: readonly NativeMenuEntry[];
52
55
  };
@@ -91,6 +94,12 @@ export type NativeMenuEvent = {
91
94
  readonly nativeID: string;
92
95
  readonly id: string;
93
96
  }
97
+ /** An item chosen in the press menu of the view with `nativeID` (iOS). */
98
+ | {
99
+ readonly type: 'pressMenuSelect';
100
+ readonly nativeID: string;
101
+ readonly id: string;
102
+ }
94
103
  /**
95
104
  * Back or forward, from whichever input the OS has for it: View > Back and Forward and their
96
105
  * keys, a two-finger swipe, mouse buttons 4 and 5, the toolbar's chevrons and their history
@@ -135,6 +144,11 @@ export interface NativeMenus {
135
144
  * `topContextMenuSelect`. The desktop host, and Android.
136
145
  */
137
146
  popUpMenu?(view: number, entries: readonly NativeMenuEntry[]): void;
147
+ /**
148
+ * The menu a press opens on the view with `nativeID`, or null to take it away. iOS, which opens
149
+ * one on a touch but has no way to open one from code.
150
+ */
151
+ setPressMenu?(nativeID: string, entries: readonly NativeMenuEntry[] | null): void;
138
152
  subscribe(listener: (event: NativeMenuEvent) => void): () => void;
139
153
  }
140
154
  /**
@@ -192,6 +206,18 @@ export declare class Menus {
192
206
  * so.
193
207
  */
194
208
  popUpMenu(view: number, entries: readonly NativeMenuEntry[]): void;
209
+ /**
210
+ * Whether the host takes a menu a press opens by the view's `nativeID` (`setPressMenu`), and
211
+ * opens it on a touch itself: iOS.
212
+ */
213
+ readonly pressMenuByNativeId: boolean;
214
+ /** What choosing an item does, by the `nativeID` of the view whose press menu it is in. */
215
+ private readonly pressMenuChoices;
216
+ /**
217
+ * Send the menu a press opens on the view with `nativeID`, or null to take it away. `choose`
218
+ * runs with the item's `id` as the host sends the choice.
219
+ */
220
+ setPressMenu(nativeID: string, entries: readonly NativeMenuEntry[] | null, choose: (id: string) => void): void;
195
221
  /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */
196
222
  private readonly contextMenuChoices;
197
223
  /**
@@ -226,9 +252,10 @@ export declare class Menus {
226
252
  addShortcut(shortcut: Signal<string>, label: Signal<string>, press: () => void): () => void;
227
253
  private readonly navigators;
228
254
  /**
229
- * Hear the OS's back and forward commands. `@ng-native/router` listens, and moves through the
230
- * history of the window each was in, `steps` entries (one, but for a pick from a chevron's
231
- * history menu). Answers the function that stops listening.
255
+ * Hear the OS's back and forward commands. Apps with their own history can listen here.
256
+ * `@ng-native/router` listens and moves through the history of the window each was in,
257
+ * `steps` entries (one, but for a pick from a chevron's history menu). Returns a function to
258
+ * stop listening.
232
259
  */
233
260
  onNavigate(listener: (direction: 'back' | 'forward', surface?: number, steps?: number) => void): () => void;
234
261
  /**
package/dist/menus.js CHANGED
@@ -17,7 +17,9 @@
17
17
  * since React Native's Android view drops a `contextMenu` prop it does not know.
18
18
  * - On iOS it is a TurboModule with `setContextMenu(nativeID, entries)` too, for the same reason.
19
19
  * React Native's iOS view sends no event it does not know either, so the module sends the item
20
- * chosen as `{ type: 'contextMenuSelect', nativeID, id }`.
20
+ * chosen as `{ type: 'contextMenuSelect', nativeID, id }`. Its `setPressMenu(nativeID, entries)`
21
+ * lays a menu a press opens over that view, and sends the item chosen as
22
+ * `{ type: 'pressMenuSelect', nativeID, id }`: UIKit opens a menu on a touch, but not from code.
21
23
  * - Where it draws menus on a press, `popUpMenu(view, entries)` draws one under the view with that
22
24
  * tag now, and sends the item chosen as the view's `topContextMenuSelect`, as a context menu's
23
25
  * (the desktop host, and Android).
@@ -31,7 +33,7 @@ import { InjectionToken, Service, computed, effect, inject, signal, } from '@ang
31
33
  import { defaultMenuBar, isSeparator, mergeMenuBar, unmergedGroups, } from "./menu-model.js";
32
34
  import { injectOs } from "./os.js";
33
35
  import { reactNative } from "./react-native.js";
34
- import { isEditingShortcut, navigationShortcut, parseShortcut, } from "./shortcut.js";
36
+ import { isEditingShortcut, matchesShortcut, navigationShortcut, parseShortcut, } from "./shortcut.js";
35
37
  import * as i0 from "@angular/core";
36
38
  const actionIds = new WeakMap();
37
39
  let actionsNamed = 0;
@@ -77,6 +79,29 @@ export function serializeMenu(entries, os, prefix = '') {
77
79
  });
78
80
  return { entries: walk(entries, prefix), actions };
79
81
  }
82
+ /** Whether an enabled app menu item, including one in a submenu, takes this chord. */
83
+ function hasMacMenuAction(entries, chord) {
84
+ return entries.some((entry) => {
85
+ if (isSeparator(entry) || entry.disabled)
86
+ return false;
87
+ if (entry.items)
88
+ return hasMacMenuAction(entry.items, chord);
89
+ return Boolean(entry.select && entry.shortcut && matchesShortcut(entry.shortcut, chord, 'macos'));
90
+ });
91
+ }
92
+ /** Keep the built-in navigation commands clickable when an app item takes their keys. */
93
+ function releaseMacNavigationKeys(entries, groups) {
94
+ return entries.map((entry) => {
95
+ if ('separator' in entry || entry.handled)
96
+ return entry;
97
+ if (entry.menuRole !== 'back' && entry.menuRole !== 'forward')
98
+ return entry;
99
+ const { shortcut, ...item } = entry;
100
+ return shortcut && groups.some((group) => hasMacMenuAction(group.items, shortcut))
101
+ ? item
102
+ : entry;
103
+ });
104
+ }
80
105
  /** Android's `NgNativeMenus`, an Expo module, where React Native has no TurboModule of the name. */
81
106
  function expoMenusModule() {
82
107
  const modules = globalThis.expo?.modules;
@@ -113,16 +138,18 @@ export function menusSource() {
113
138
  }
114
139
  /**
115
140
  * The menu methods a module may lack, bound, and none it lacks: a host without the context menu
116
- * ones reads props, and one without `popUpMenu` leaves a press to `(press)`.
141
+ * ones reads props, and one without `popUpMenu` or `setPressMenu` leaves a press to `(press)`.
117
142
  */
118
143
  function contextMenuMethods(module) {
119
144
  const setContextMenu = module.setContextMenu?.bind(module);
120
145
  const setTakesLongPress = module.setTakesLongPress?.bind(module);
121
146
  const popUpMenu = module.popUpMenu?.bind(module);
147
+ const setPressMenu = module.setPressMenu?.bind(module);
122
148
  return {
123
149
  ...(setContextMenu && { setContextMenu }),
124
150
  ...(setTakesLongPress && { setTakesLongPress }),
125
151
  ...(popUpMenu && { popUpMenu }),
152
+ ...(setPressMenu && { setPressMenu }),
126
153
  };
127
154
  }
128
155
  /**
@@ -195,6 +222,24 @@ export class Menus {
195
222
  popUpMenu(view, entries) {
196
223
  this.native?.popUpMenu?.(view, entries);
197
224
  }
225
+ /**
226
+ * Whether the host takes a menu a press opens by the view's `nativeID` (`setPressMenu`), and
227
+ * opens it on a touch itself: iOS.
228
+ */
229
+ pressMenuByNativeId = this.native?.setPressMenu !== undefined;
230
+ /** What choosing an item does, by the `nativeID` of the view whose press menu it is in. */
231
+ pressMenuChoices = new Map();
232
+ /**
233
+ * Send the menu a press opens on the view with `nativeID`, or null to take it away. `choose`
234
+ * runs with the item's `id` as the host sends the choice.
235
+ */
236
+ setPressMenu(nativeID, entries, choose) {
237
+ if (entries)
238
+ this.pressMenuChoices.set(nativeID, choose);
239
+ else
240
+ this.pressMenuChoices.delete(nativeID);
241
+ this.native?.setPressMenu?.(nativeID, entries);
242
+ }
198
243
  /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */
199
244
  contextMenuChoices = new Map();
200
245
  /**
@@ -241,7 +286,9 @@ export class Menus {
241
286
  return {
242
287
  label: group.label,
243
288
  ...(group.menuRole && { menuRole: group.menuRole }),
244
- items: menu.entries,
289
+ items: this.os === 'macos' && group.menuRole === 'view'
290
+ ? releaseMacNavigationKeys(menu.entries, groups)
291
+ : menu.entries,
245
292
  };
246
293
  });
247
294
  return { sent, actions };
@@ -328,9 +375,10 @@ export class Menus {
328
375
  }
329
376
  navigators = new Set();
330
377
  /**
331
- * Hear the OS's back and forward commands. `@ng-native/router` listens, and moves through the
332
- * history of the window each was in, `steps` entries (one, but for a pick from a chevron's
333
- * history menu). Answers the function that stops listening.
378
+ * Hear the OS's back and forward commands. Apps with their own history can listen here.
379
+ * `@ng-native/router` listens and moves through the history of the window each was in,
380
+ * `steps` entries (one, but for a pick from a chevron's history menu). Returns a function to
381
+ * stop listening.
334
382
  */
335
383
  onNavigate(listener) {
336
384
  this.navigators.add(listener);
@@ -358,6 +406,10 @@ export class Menus {
358
406
  this.contextMenuChoices.get(event.nativeID)?.(event.id);
359
407
  return;
360
408
  }
409
+ if (event.type === 'pressMenuSelect') {
410
+ this.pressMenuChoices.get(event.nativeID)?.(event.id);
411
+ return;
412
+ }
361
413
  const { presses, editing } = this.sentShortcuts();
362
414
  // The editing keys belong to a focused text input: the app's shortcut on one waits.
363
415
  if (event.textInputFocused && editing.has(event.id))
package/dist/menus.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"menus.js","sourceRoot":"","sources":["../src/menus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,EACZ,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,GAGd,MAAM,eAA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Q,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YACvF,OAAO;QACT,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,OAAO;QACT,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACvC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACxD,OAAO;QACT,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAClD,oFAAoF;QACpF,IAAI,KAAK,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAAE,OAAO;QAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAvQU,KAAK;wGAAL,KAAK;;2FAAL,KAAK;kBADjB,OAAO","sourcesContent":["/**\n * Menus and keyboard shortcuts as the host receives them: the menu bar, the shortcuts that are in\n * no menu, and the form a menu takes on its way to native, which a context menu shares.\n *\n * The host contract, on the `NgNativeMenus` module:\n * - `setMenuBar(groups)`: the whole merged menu bar, each time it changes. The desktop host draws\n * it as the main menu, iPadOS through UIMenuBuilder. Each item has an `id`; an item with a\n * `menuRole` and no `id`'s action is the OS's own (Copy, Quit).\n * - `setShortcuts(shortcuts)`: every shortcut the app listens for outside the menu bar, each with\n * its `id`, its chord read for the OS, and a `label` and `group` for Android's Keyboard Shortcuts\n * helper. On iPhone and Android the menu bar's own shortcuts are in it too, since no bar is drawn.\n * - It sends `ngNativeMenus` events on `DeviceEventEmitter`: `{ type: 'menuSelect', id }` for a menu\n * bar item, and `{ type: 'shortcut', id, textInputFocused }` for a chord pressed.\n * - Its constants say whether it draws a menu bar (`menuBar`) and the app's name (`appName`).\n * - On Android it is an Expo module: the constants are properties, it sends the same events through\n * its own `addListener('ngNativeMenus', ...)`, and it has `setContextMenu(nativeID, entries)`,\n * since React Native's Android view drops a `contextMenu` prop it does not know.\n * - On iOS it is a TurboModule with `setContextMenu(nativeID, entries)` too, for the same reason.\n * React Native's iOS view sends no event it does not know either, so the module sends the item\n * chosen as `{ type: 'contextMenuSelect', nativeID, id }`.\n * - Where it draws menus on a press, `popUpMenu(view, entries)` draws one under the view with that\n * tag now, and sends the item chosen as the view's `topContextMenuSelect`, as a context menu's\n * (the desktop host, and Android).\n * - Where it draws context menus, `setTakesLongPress(nativeID, takes)` names a view inside one\n * whose own `(longPress)` takes a long press first: a long press there opens no menu around it,\n * as the innermost handler wins in a native app. A right-click still opens the menu on Android.\n * iOS tells a long press from a secondary click only by the gesture, so an iPad pointer's\n * secondary click there opens none either.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n effect,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport {\n defaultMenuBar,\n isSeparator,\n mergeMenuBar,\n unmergedGroups,\n type MenuEntry,\n type MenuGroupModel,\n} from './menu-model.ts';\nimport { injectOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\nimport {\n isEditingShortcut,\n navigationShortcut,\n parseShortcut,\n type ParsedShortcut,\n type ShortcutOs,\n} from './shortcut.ts';\n\n/** A menu entry as the host receives it. */\nexport type NativeMenuEntry =\n | { readonly separator: true }\n | {\n readonly id: string;\n readonly label: string;\n readonly menuRole?: string;\n /** On an item with a `menuRole`: the app handles it, and the OS does not. */\n readonly handled?: true;\n readonly shortcut?: ParsedShortcut;\n readonly disabled?: boolean;\n readonly checked?: boolean;\n readonly destructive?: boolean;\n readonly subtitle?: string;\n readonly sfSymbol?: string;\n readonly icon?: string;\n readonly inline?: boolean;\n readonly items?: readonly NativeMenuEntry[];\n };\n\n/** A menu ready for the host, and what each id it was given does. */\nexport interface SerializedMenu {\n readonly entries: NativeMenuEntry[];\n readonly actions: ReadonlyMap<string, () => void>;\n}\n\nconst actionIds = new WeakMap<() => void, string>();\nlet actionsNamed = 0;\n\n/**\n * The id a menu item with `select` is sent under: the same for as long as the handler is, and no\n * other handler's. `<menu-item>` keeps one handler for its life, so a host that reports a choice\n * from a menu it drew before the items changed still runs that item, or nothing once it has gone,\n * never the item that has taken its place.\n */\nexport function menuActionId(select: () => void): string {\n let id = actionIds.get(select);\n if (id === undefined) actionIds.set(select, (id = `a${++actionsNamed}`));\n return id;\n}\n\n/**\n * `entries` as the host takes them: an id for each item, its shortcut read for `os`, and the\n * handlers by id. An item with a handler is named by it (`menuActionId`); one without, which the\n * app never runs, by its place (`2.0.1`).\n */\nexport function serializeMenu(\n entries: readonly MenuEntry[],\n os: ShortcutOs,\n prefix = '',\n): SerializedMenu {\n const actions = new Map<string, () => void>();\n const walk = (list: readonly MenuEntry[], at: string): NativeMenuEntry[] =>\n list.map((entry, index) => {\n if (isSeparator(entry)) return { separator: true };\n const place = `${at}${index}`;\n const { select, shortcut, items, group: _group, ...rest } = entry;\n const id = select ? menuActionId(select) : place;\n if (select) actions.set(id, select);\n return {\n id,\n ...rest,\n // A role item the app handles: the host sends its select rather than doing the role.\n ...(select && entry.menuRole && { handled: true }),\n ...(shortcut\n ? { shortcut: parseShortcut(shortcut, os) }\n : (entry.menuRole === 'back' || entry.menuRole === 'forward') && {\n shortcut: navigationShortcut(entry.menuRole, os),\n }),\n ...(items && { items: walk(items, `${place}.`) }),\n };\n });\n return { entries: walk(entries, prefix), actions };\n}\n\n/** A shortcut as the host receives it. */\nexport interface NativeShortcut {\n readonly id: string;\n readonly chord: ParsedShortcut;\n /** What Android's Keyboard Shortcuts helper lists it as. */\n readonly label: string;\n /** The heading it is listed under there: its menu's label, or the app's name. */\n readonly group: string;\n}\n\nexport type NativeMenuEvent =\n | { readonly type: 'menuSelect'; readonly id: string }\n | { readonly type: 'shortcut'; readonly id: string; readonly textInputFocused?: boolean }\n /** An item chosen in the context menu of the view with `nativeID` (iOS). */\n | { readonly type: 'contextMenuSelect'; readonly nativeID: string; readonly id: string }\n /**\n * Back or forward, from whichever input the OS has for it: View > Back and Forward and their\n * keys, a two-finger swipe, mouse buttons 4 and 5, the toolbar's chevrons and their history\n * menus. `surface` is the window it was in, and `steps` how many entries (one where absent).\n */\n | {\n readonly type: 'navigate';\n readonly direction: 'back' | 'forward';\n readonly surface?: number;\n readonly steps?: number;\n };\n\n/** A window's history as the host draws it: the titles behind and ahead, nearest first. */\nexport interface NativeWindowHistory {\n readonly back: readonly string[];\n readonly forward: readonly string[];\n}\n\n/** The host's menu module. */\nexport interface NativeMenus {\n /** Whether the host draws a menu bar: macOS, and iPadOS. */\n readonly menuBar: boolean;\n readonly appName: string;\n setMenuBar(\n groups: readonly { label: string; menuRole?: string; items: NativeMenuEntry[] }[],\n ): void;\n setShortcuts(shortcuts: readonly NativeShortcut[]): void;\n /** The history of the window on `surface`, for its back and forward chevrons. Desktop only. */\n setHistory?(surface: number, history: NativeWindowHistory): void;\n /**\n * The context menu of the view with `nativeID`, or null to take it away. Android and iOS, whose\n * views read no `contextMenu` prop: the host finds the view by its `nativeID`.\n */\n setContextMenu?(nativeID: string, entries: readonly NativeMenuEntry[] | null): void;\n /**\n * Whether the view with `nativeID` takes a long press itself, so a context menu around it does\n * not open on one there. Android and iOS, beside `setContextMenu`.\n */\n setTakesLongPress?(nativeID: string, takes: boolean): void;\n /**\n * Draw `entries` under the view with tag `view` now, and send the item chosen as its\n * `topContextMenuSelect`. The desktop host, and Android.\n */\n popUpMenu?(view: number, entries: readonly NativeMenuEntry[]): void;\n subscribe(listener: (event: NativeMenuEvent) => void): () => void;\n}\n\ninterface MenusModule {\n getConstants?(): { menuBar?: boolean; appName?: string };\n /** An Expo module's constants, which are its properties. */\n readonly menuBar?: boolean;\n readonly appName?: string;\n setMenuBar?(groups: unknown): void;\n setShortcuts?(shortcuts: unknown): void;\n setHistory?(surface: number, history: unknown): void;\n setContextMenu?(nativeID: string, entries: unknown): void;\n setTakesLongPress?(nativeID: string, takes: boolean): void;\n popUpMenu?(view: number, entries: unknown): void;\n /** An Expo module's own events. */\n addListener?(event: string, listener: (event: unknown) => void): { remove(): void };\n}\n\n/** Android's `NgNativeMenus`, an Expo module, where React Native has no TurboModule of the name. */\nfunction expoMenusModule(): MenusModule | undefined {\n const modules = (globalThis as { expo?: { modules?: Record<string, unknown> } }).expo?.modules;\n return modules?.['NgNativeMenus'] as MenusModule | undefined;\n}\n\n/**\n * The host's menu module: a TurboModule (the desktop host, iOS), or else Android's Expo module.\n * Null where there is neither, as in Expo Go.\n */\nexport function menusSource(): NativeMenus | null {\n const native = reactNative();\n const turbo = native?.TurboModuleRegistry?.get?.('NgNativeMenus') as\n MenusModule | null | undefined;\n const expo = turbo ? undefined : expoMenusModule();\n const module = turbo ?? expo;\n if (!module) return null;\n const constants = module.getConstants?.() ?? module;\n // An Expo module sends its events itself; a TurboModule's come through DeviceEventEmitter.\n const listen = (hear: (event: unknown) => void) =>\n expo\n ? expo.addListener?.('ngNativeMenus', hear)\n : native?.DeviceEventEmitter?.addListener('ngNativeMenus', hear);\n return {\n menuBar: constants.menuBar === true,\n appName: constants.appName ?? '',\n setMenuBar: (groups) => module.setMenuBar?.(groups),\n setShortcuts: (shortcuts) => module.setShortcuts?.(shortcuts),\n setHistory: (surface, history) => module.setHistory?.(surface, history),\n ...contextMenuMethods(module),\n subscribe: (listener) => {\n const subscription = listen((event) => listener(event as NativeMenuEvent));\n return () => subscription?.remove();\n },\n };\n}\n\n/**\n * The menu methods a module may lack, bound, and none it lacks: a host without the context menu\n * ones reads props, and one without `popUpMenu` leaves a press to `(press)`.\n */\nfunction contextMenuMethods(\n module: MenusModule,\n): Pick<NativeMenus, 'setContextMenu' | 'setTakesLongPress' | 'popUpMenu'> {\n const setContextMenu = module.setContextMenu?.bind(module);\n const setTakesLongPress = module.setTakesLongPress?.bind(module);\n const popUpMenu = module.popUpMenu?.bind(module);\n return {\n ...(setContextMenu && { setContextMenu }),\n ...(setTakesLongPress && { setTakesLongPress }),\n ...(popUpMenu && { popUpMenu }),\n };\n}\n\n/** A `[shortcut]` registered with `KeyboardShortcuts`. */\ninterface Registered {\n readonly shortcut: Signal<string>;\n readonly label: Signal<string>;\n readonly press: () => void;\n}\n\n/**\n * The menus and shortcuts an app has, sent to the host as they change. `<menu-bar>` and\n * `[shortcut]` in `@ng-native/components` register here; an app rarely injects it.\n */\n@Service()\nexport class Menus {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeMenus | null>('angular-native.menusSource', {\n factory: menusSource,\n });\n\n private readonly native = inject(Menus.SOURCE);\n private readonly os: ShortcutOs = injectOs();\n\n /** Whether the host has the module: shortcuts from a hardware keyboard, and menus. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n /** Whether the menu bar is drawn: macOS and iPadOS. Elsewhere its shortcuts still work. */\n readonly menuBarShown: Signal<boolean> = signal(this.native?.menuBar === true).asReadonly();\n\n /**\n * Whether the host takes a `[contextMenu]` by the view's `nativeID` through `setContextMenu`\n * (Android and iOS) rather than as the view's `contextMenu` prop. Where it does, it draws the\n * menu on a long press.\n */\n readonly contextMenuByNativeId: boolean = this.native?.setContextMenu !== undefined;\n\n /**\n * Whether the host, which draws context menus on a long press, can be told which views inside\n * one take a long press themselves (`setTakesLongPress`).\n */\n readonly longPressByNativeId: boolean =\n this.contextMenuByNativeId && this.native?.setTakesLongPress !== undefined;\n\n /**\n * Say whether the view with `nativeID` takes a long press itself: one there then opens no\n * context menu around it.\n */\n setTakesLongPress(nativeID: string, takes: boolean): void {\n if (takes) this.longPressTakers.add(nativeID);\n else this.longPressTakers.delete(nativeID);\n this.native?.setTakesLongPress?.(nativeID, takes);\n }\n\n /** The `nativeID`s sent with a context menu, and with a long press of their own. */\n private readonly withContextMenu = new Set<string>();\n private readonly longPressTakers = new Set<string>();\n\n /**\n * Whether the host opens a context menu on a long press of the view whose `nativeID`s, from it\n * outwards, are `chain`: as it decides, the nearest view with a menu, unless one on the way takes\n * the long press itself. A `(longPress)` around that view leaves the hold to the menu, which the\n * host opens after its own long-press timeout.\n */\n opensContextMenu(chain: Iterable<string | null>): boolean {\n for (const nativeID of chain) {\n if (nativeID === null) continue;\n if (this.withContextMenu.has(nativeID)) return true;\n if (this.longPressTakers.has(nativeID)) return false;\n }\n return false;\n }\n\n /**\n * Whether the host draws a menu under a view on a press (`popUpMenu`): the desktop host, and\n * Android.\n */\n readonly popsUpMenus: boolean = this.native?.popUpMenu !== undefined;\n\n /**\n * Draw `entries` under the view with tag `view` now. The host sends the item chosen as the\n * view's `topContextMenuSelect`. It draws nothing for a view it is not showing, and does not say\n * so.\n */\n popUpMenu(view: number, entries: readonly NativeMenuEntry[]): void {\n this.native?.popUpMenu?.(view, entries);\n }\n\n /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */\n private readonly contextMenuChoices = new Map<string, (id: string) => void>();\n\n /**\n * Send the context menu of the view with `nativeID`, or null to take it away. `choose` runs with\n * the item's `id` where the host sends the choice itself (iOS) rather than through the view.\n */\n setContextMenu(\n nativeID: string,\n entries: readonly NativeMenuEntry[] | null,\n choose?: (id: string) => void,\n ): void {\n if (entries && choose) this.contextMenuChoices.set(nativeID, choose);\n else this.contextMenuChoices.delete(nativeID);\n if (entries?.length) this.withContextMenu.add(nativeID);\n else this.withContextMenu.delete(nativeID);\n this.native?.setContextMenu?.(nativeID, entries);\n }\n\n private readonly bars = signal<readonly Signal<readonly MenuEntry[]>[]>([]);\n private readonly shortcuts = signal<readonly Registered[]>([]);\n\n /** The app's groups, from every `<menu-bar>`, in the order they registered. */\n private readonly appGroups = computed<MenuGroupModel[]>(() =>\n this.bars()\n .flatMap((bar) => bar())\n .flatMap((entry) =>\n isSeparator(entry)\n ? []\n : [\n {\n label: entry.label,\n ...(entry.group && { menuRole: entry.group }),\n items: entry.items ?? [],\n },\n ],\n ),\n );\n\n /** The menu bar as it is drawn: the OS's defaults with the app's merged in. */\n readonly menuBar: Signal<MenuGroupModel[]> = computed(() =>\n mergeMenuBar(defaultMenuBar(this.native?.appName || 'App', this.os), this.appGroups()),\n );\n\n private readonly sentBar = computed(() => {\n const groups = this.menuBar();\n const actions = new Map<string, () => void>();\n const sent = groups.map((group, index) => {\n const menu = serializeMenu(group.items, this.os, `${index}.`);\n menu.actions.forEach((action, id) => actions.set(id, action));\n return {\n label: group.label,\n ...(group.menuRole && { menuRole: group.menuRole }),\n items: menu.entries,\n };\n });\n return { sent, actions };\n });\n\n /**\n * The shortcuts sent to the host: every `[shortcut]`, and where no menu bar is drawn, every\n * menu bar item the app gave a shortcut and a handler, so a hardware keyboard still has them.\n */\n private readonly sentShortcuts = computed(() => {\n const presses = new Map<string, () => void>();\n const editing = new Set<string>();\n const sent: NativeShortcut[] = [];\n const add = (id: string, shortcut: string, label: string, group: string, press: () => void) => {\n presses.set(id, press);\n if (isEditingShortcut(shortcut, this.os)) editing.add(id);\n sent.push({ id, chord: parseShortcut(shortcut, this.os), label, group });\n };\n this.shortcuts().forEach((one, index) =>\n add(`s${index}`, one.shortcut(), one.label(), this.native?.appName || 'App', one.press),\n );\n if (!this.menuBarShown()) {\n const walk = (entries: readonly MenuEntry[], group: string, at: string) =>\n entries.forEach((entry, index) => {\n if (isSeparator(entry)) return;\n if (entry.shortcut && entry.select && !entry.disabled) {\n add(`m${at}${index}`, entry.shortcut, entry.label, group, entry.select);\n }\n if (entry.items) walk(entry.items, group, `${at}${index}.`);\n });\n this.appGroups().forEach((group, index) => walk(group.items, group.label, `${index}.`));\n }\n return { sent, presses, editing };\n });\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n constructor() {\n // Once a label: a `<menu-group label=\"File\">` with no role that is still a group of its own\n // once merged is drawn as a second File menu, on a host that draws a menu bar.\n const warned = new Set<string>();\n effect(() => {\n if (!this.menuBarShown()) return;\n const defaults = defaultMenuBar(this.native?.appName || 'App', this.os);\n for (const label of unmergedGroups(defaults, this.menuBar())) {\n if (warned.has(label)) continue;\n warned.add(label);\n const role = defaults.find(\n (group) => group.label.toLowerCase() === label.toLowerCase(),\n )?.menuRole;\n console.warn(\n `[angular-native] <menu-group label=\"${label}\"> has no menuRole, so it shows as a second ` +\n `${label} menu. Give it menuRole=\"${role}\" to add its items to the ${label} menu.`,\n );\n }\n });\n const native = this.native;\n if (!native) {\n // Read for nothing, so a shortcut the app gets wrong throws where there is no host too, and\n // not first on a device that has one.\n effect(() => this.sentShortcuts());\n return;\n }\n effect(() => {\n if (this.menuBarShown()) native.setMenuBar(this.sentBar().sent);\n });\n effect(() => native.setShortcuts(this.sentShortcuts().sent));\n }\n\n /**\n * Add a `<menu-bar>`'s groups, each a `MenuItemModel` with `items` and its `group` role. Answers\n * the function that takes them out again, as the `<menu-bar>` goes.\n */\n addMenuBar(groups: Signal<readonly MenuEntry[]>): () => void {\n this.bars.update((all) => [...all, groups]);\n return () => this.bars.update((all) => all.filter((one) => one !== groups));\n }\n\n /**\n * Listen for `shortcut`, pressed anywhere in the app: `mod+k`, as `parseShortcut` reads it.\n * `label` is what Android's Keyboard Shortcuts helper lists it as. Answers the function that\n * stops listening.\n */\n addShortcut(shortcut: Signal<string>, label: Signal<string>, press: () => void): () => void {\n const registered: Registered = { shortcut, label, press };\n this.shortcuts.update((all) => [...all, registered]);\n return () => this.shortcuts.update((all) => all.filter((one) => one !== registered));\n }\n\n private readonly navigators = new Set<\n (direction: 'back' | 'forward', surface?: number, steps?: number) => void\n >();\n\n /**\n * Hear the OS's back and forward commands. `@ng-native/router` listens, and moves through the\n * history of the window each was in, `steps` entries (one, but for a pick from a chevron's\n * history menu). Answers the function that stops listening.\n */\n onNavigate(\n listener: (direction: 'back' | 'forward', surface?: number, steps?: number) => void,\n ): () => void {\n this.navigators.add(listener);\n return () => void this.navigators.delete(listener);\n }\n\n /**\n * Tell the host the history of the window on `surface`, which its toolbar's back and forward\n * chevrons and their menus show. `@ng-native/router` calls it. Does nothing where the host has\n * no chevrons.\n */\n setHistory(surface: number, history: NativeWindowHistory): void {\n this.native?.setHistory?.(surface, history);\n }\n\n private hostSaid(event: NativeMenuEvent): void {\n if (event.type === 'navigate') {\n const steps = event.steps ?? 1;\n this.navigators.forEach((listener) => listener(event.direction, event.surface, steps));\n return;\n }\n if (event.type === 'menuSelect') {\n this.sentBar().actions.get(event.id)?.();\n return;\n }\n if (event.type === 'contextMenuSelect') {\n this.contextMenuChoices.get(event.nativeID)?.(event.id);\n return;\n }\n const { presses, editing } = this.sentShortcuts();\n // The editing keys belong to a focused text input: the app's shortcut on one waits.\n if (event.textInputFocused && editing.has(event.id)) return;\n presses.get(event.id)?.();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
1
+ {"version":3,"file":"menus.js","sourceRoot":"","sources":["../src/menus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,EACZ,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,aAAa,GAGd,MAAM,eAAe,CAAC;;AA6BvB,MAAM,SAAS,GAAG,IAAI,OAAO,EAAsB,CAAC;AACpD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,I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gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAAE,OAAO;QAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAtSU,KAAK;wGAAL,KAAK;;2FAAL,KAAK;kBADjB,OAAO","sourcesContent":["/**\n * Menus and keyboard shortcuts as the host receives them: the menu bar, the shortcuts that are in\n * no menu, and the form a menu takes on its way to native, which a context menu shares.\n *\n * The host contract, on the `NgNativeMenus` module:\n * - `setMenuBar(groups)`: the whole merged menu bar, each time it changes. The desktop host draws\n * it as the main menu, iPadOS through UIMenuBuilder. Each item has an `id`; an item with a\n * `menuRole` and no `id`'s action is the OS's own (Copy, Quit).\n * - `setShortcuts(shortcuts)`: every shortcut the app listens for outside the menu bar, each with\n * its `id`, its chord read for the OS, and a `label` and `group` for Android's Keyboard Shortcuts\n * helper. On iPhone and Android the menu bar's own shortcuts are in it too, since no bar is drawn.\n * - It sends `ngNativeMenus` events on `DeviceEventEmitter`: `{ type: 'menuSelect', id }` for a menu\n * bar item, and `{ type: 'shortcut', id, textInputFocused }` for a chord pressed.\n * - Its constants say whether it draws a menu bar (`menuBar`) and the app's name (`appName`).\n * - On Android it is an Expo module: the constants are properties, it sends the same events through\n * its own `addListener('ngNativeMenus', ...)`, and it has `setContextMenu(nativeID, entries)`,\n * since React Native's Android view drops a `contextMenu` prop it does not know.\n * - On iOS it is a TurboModule with `setContextMenu(nativeID, entries)` too, for the same reason.\n * React Native's iOS view sends no event it does not know either, so the module sends the item\n * chosen as `{ type: 'contextMenuSelect', nativeID, id }`. Its `setPressMenu(nativeID, entries)`\n * lays a menu a press opens over that view, and sends the item chosen as\n * `{ type: 'pressMenuSelect', nativeID, id }`: UIKit opens a menu on a touch, but not from code.\n * - Where it draws menus on a press, `popUpMenu(view, entries)` draws one under the view with that\n * tag now, and sends the item chosen as the view's `topContextMenuSelect`, as a context menu's\n * (the desktop host, and Android).\n * - Where it draws context menus, `setTakesLongPress(nativeID, takes)` names a view inside one\n * whose own `(longPress)` takes a long press first: a long press there opens no menu around it,\n * as the innermost handler wins in a native app. A right-click still opens the menu on Android.\n * iOS tells a long press from a secondary click only by the gesture, so an iPad pointer's\n * secondary click there opens none either.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n effect,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport {\n defaultMenuBar,\n isSeparator,\n mergeMenuBar,\n unmergedGroups,\n type MenuEntry,\n type MenuGroupModel,\n} from './menu-model.ts';\nimport { injectOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\nimport {\n isEditingShortcut,\n matchesShortcut,\n navigationShortcut,\n parseShortcut,\n type ParsedShortcut,\n type ShortcutOs,\n} from './shortcut.ts';\n\n/** A menu entry as the host receives it. */\nexport type NativeMenuEntry =\n | { readonly separator: true }\n | {\n readonly id: string;\n readonly label: string;\n readonly menuRole?: string;\n /** On an item with a `menuRole`: the app handles it, and the OS does not. */\n readonly handled?: true;\n readonly shortcut?: ParsedShortcut;\n readonly disabled?: boolean;\n readonly checked?: boolean;\n readonly destructive?: boolean;\n readonly subtitle?: string;\n readonly sfSymbol?: string;\n readonly icon?: string;\n readonly svgIcon?: string;\n readonly inline?: boolean;\n readonly items?: readonly NativeMenuEntry[];\n };\n\n/** A menu ready for the host, and what each id it was given does. */\nexport interface SerializedMenu {\n readonly entries: NativeMenuEntry[];\n readonly actions: ReadonlyMap<string, () => void>;\n}\n\nconst actionIds = new WeakMap<() => void, string>();\nlet actionsNamed = 0;\n\n/**\n * The id a menu item with `select` is sent under: the same for as long as the handler is, and no\n * other handler's. `<menu-item>` keeps one handler for its life, so a host that reports a choice\n * from a menu it drew before the items changed still runs that item, or nothing once it has gone,\n * never the item that has taken its place.\n */\nexport function menuActionId(select: () => void): string {\n let id = actionIds.get(select);\n if (id === undefined) actionIds.set(select, (id = `a${++actionsNamed}`));\n return id;\n}\n\n/**\n * `entries` as the host takes them: an id for each item, its shortcut read for `os`, and the\n * handlers by id. An item with a handler is named by it (`menuActionId`); one without, which the\n * app never runs, by its place (`2.0.1`).\n */\nexport function serializeMenu(\n entries: readonly MenuEntry[],\n os: ShortcutOs,\n prefix = '',\n): SerializedMenu {\n const actions = new Map<string, () => void>();\n const walk = (list: readonly MenuEntry[], at: string): NativeMenuEntry[] =>\n list.map((entry, index) => {\n if (isSeparator(entry)) return { separator: true };\n const place = `${at}${index}`;\n const { select, shortcut, items, group: _group, ...rest } = entry;\n const id = select ? menuActionId(select) : place;\n if (select) actions.set(id, select);\n return {\n id,\n ...rest,\n // A role item the app handles: the host sends its select rather than doing the role.\n ...(select && entry.menuRole && { handled: true }),\n ...(shortcut\n ? { shortcut: parseShortcut(shortcut, os) }\n : (entry.menuRole === 'back' || entry.menuRole === 'forward') && {\n shortcut: navigationShortcut(entry.menuRole, os),\n }),\n ...(items && { items: walk(items, `${place}.`) }),\n };\n });\n return { entries: walk(entries, prefix), actions };\n}\n\n/** Whether an enabled app menu item, including one in a submenu, takes this chord. */\nfunction hasMacMenuAction(entries: readonly MenuEntry[], chord: ParsedShortcut): boolean {\n return entries.some((entry) => {\n if (isSeparator(entry) || entry.disabled) return false;\n if (entry.items) return hasMacMenuAction(entry.items, chord);\n return Boolean(\n entry.select && entry.shortcut && matchesShortcut(entry.shortcut, chord, 'macos'),\n );\n });\n}\n\n/** Keep the built-in navigation commands clickable when an app item takes their keys. */\nfunction releaseMacNavigationKeys(\n entries: NativeMenuEntry[],\n groups: readonly MenuGroupModel[],\n): NativeMenuEntry[] {\n return entries.map((entry) => {\n if ('separator' in entry || entry.handled) return entry;\n if (entry.menuRole !== 'back' && entry.menuRole !== 'forward') return entry;\n const { shortcut, ...item } = entry;\n return shortcut && groups.some((group) => hasMacMenuAction(group.items, shortcut))\n ? item\n : entry;\n });\n}\n\n/** A shortcut as the host receives it. */\nexport interface NativeShortcut {\n readonly id: string;\n readonly chord: ParsedShortcut;\n /** What Android's Keyboard Shortcuts helper lists it as. */\n readonly label: string;\n /** The heading it is listed under there: its menu's label, or the app's name. */\n readonly group: string;\n}\n\nexport type NativeMenuEvent =\n | { readonly type: 'menuSelect'; readonly id: string }\n | { readonly type: 'shortcut'; readonly id: string; readonly textInputFocused?: boolean }\n /** An item chosen in the context menu of the view with `nativeID` (iOS). */\n | { readonly type: 'contextMenuSelect'; readonly nativeID: string; readonly id: string }\n /** An item chosen in the press menu of the view with `nativeID` (iOS). */\n | { readonly type: 'pressMenuSelect'; readonly nativeID: string; readonly id: string }\n /**\n * Back or forward, from whichever input the OS has for it: View > Back and Forward and their\n * keys, a two-finger swipe, mouse buttons 4 and 5, the toolbar's chevrons and their history\n * menus. `surface` is the window it was in, and `steps` how many entries (one where absent).\n */\n | {\n readonly type: 'navigate';\n readonly direction: 'back' | 'forward';\n readonly surface?: number;\n readonly steps?: number;\n };\n\n/** A window's history as the host draws it: the titles behind and ahead, nearest first. */\nexport interface NativeWindowHistory {\n readonly back: readonly string[];\n readonly forward: readonly string[];\n}\n\n/** The host's menu module. */\nexport interface NativeMenus {\n /** Whether the host draws a menu bar: macOS, and iPadOS. */\n readonly menuBar: boolean;\n readonly appName: string;\n setMenuBar(\n groups: readonly { label: string; menuRole?: string; items: NativeMenuEntry[] }[],\n ): void;\n setShortcuts(shortcuts: readonly NativeShortcut[]): void;\n /** The history of the window on `surface`, for its back and forward chevrons. Desktop only. */\n setHistory?(surface: number, history: NativeWindowHistory): void;\n /**\n * The context menu of the view with `nativeID`, or null to take it away. Android and iOS, whose\n * views read no `contextMenu` prop: the host finds the view by its `nativeID`.\n */\n setContextMenu?(nativeID: string, entries: readonly NativeMenuEntry[] | null): void;\n /**\n * Whether the view with `nativeID` takes a long press itself, so a context menu around it does\n * not open on one there. Android and iOS, beside `setContextMenu`.\n */\n setTakesLongPress?(nativeID: string, takes: boolean): void;\n /**\n * Draw `entries` under the view with tag `view` now, and send the item chosen as its\n * `topContextMenuSelect`. The desktop host, and Android.\n */\n popUpMenu?(view: number, entries: readonly NativeMenuEntry[]): void;\n /**\n * The menu a press opens on the view with `nativeID`, or null to take it away. iOS, which opens\n * one on a touch but has no way to open one from code.\n */\n setPressMenu?(nativeID: string, entries: readonly NativeMenuEntry[] | null): void;\n subscribe(listener: (event: NativeMenuEvent) => void): () => void;\n}\n\ninterface MenusModule {\n getConstants?(): { menuBar?: boolean; appName?: string };\n /** An Expo module's constants, which are its properties. */\n readonly menuBar?: boolean;\n readonly appName?: string;\n setMenuBar?(groups: unknown): void;\n setShortcuts?(shortcuts: unknown): void;\n setHistory?(surface: number, history: unknown): void;\n setContextMenu?(nativeID: string, entries: unknown): void;\n setTakesLongPress?(nativeID: string, takes: boolean): void;\n popUpMenu?(view: number, entries: unknown): void;\n setPressMenu?(nativeID: string, entries: unknown): void;\n /** An Expo module's own events. */\n addListener?(event: string, listener: (event: unknown) => void): { remove(): void };\n}\n\n/** Android's `NgNativeMenus`, an Expo module, where React Native has no TurboModule of the name. */\nfunction expoMenusModule(): MenusModule | undefined {\n const modules = (globalThis as { expo?: { modules?: Record<string, unknown> } }).expo?.modules;\n return modules?.['NgNativeMenus'] as MenusModule | undefined;\n}\n\n/**\n * The host's menu module: a TurboModule (the desktop host, iOS), or else Android's Expo module.\n * Null where there is neither, as in Expo Go.\n */\nexport function menusSource(): NativeMenus | null {\n const native = reactNative();\n const turbo = native?.TurboModuleRegistry?.get?.('NgNativeMenus') as\n MenusModule | null | undefined;\n const expo = turbo ? undefined : expoMenusModule();\n const module = turbo ?? expo;\n if (!module) return null;\n const constants = module.getConstants?.() ?? module;\n // An Expo module sends its events itself; a TurboModule's come through DeviceEventEmitter.\n const listen = (hear: (event: unknown) => void) =>\n expo\n ? expo.addListener?.('ngNativeMenus', hear)\n : native?.DeviceEventEmitter?.addListener('ngNativeMenus', hear);\n return {\n menuBar: constants.menuBar === true,\n appName: constants.appName ?? '',\n setMenuBar: (groups) => module.setMenuBar?.(groups),\n setShortcuts: (shortcuts) => module.setShortcuts?.(shortcuts),\n setHistory: (surface, history) => module.setHistory?.(surface, history),\n ...contextMenuMethods(module),\n subscribe: (listener) => {\n const subscription = listen((event) => listener(event as NativeMenuEvent));\n return () => subscription?.remove();\n },\n };\n}\n\n/**\n * The menu methods a module may lack, bound, and none it lacks: a host without the context menu\n * ones reads props, and one without `popUpMenu` or `setPressMenu` leaves a press to `(press)`.\n */\nfunction contextMenuMethods(\n module: MenusModule,\n): Pick<NativeMenus, 'setContextMenu' | 'setTakesLongPress' | 'popUpMenu' | 'setPressMenu'> {\n const setContextMenu = module.setContextMenu?.bind(module);\n const setTakesLongPress = module.setTakesLongPress?.bind(module);\n const popUpMenu = module.popUpMenu?.bind(module);\n const setPressMenu = module.setPressMenu?.bind(module);\n return {\n ...(setContextMenu && { setContextMenu }),\n ...(setTakesLongPress && { setTakesLongPress }),\n ...(popUpMenu && { popUpMenu }),\n ...(setPressMenu && { setPressMenu }),\n };\n}\n\n/** A `[shortcut]` registered with `KeyboardShortcuts`. */\ninterface Registered {\n readonly shortcut: Signal<string>;\n readonly label: Signal<string>;\n readonly press: () => void;\n}\n\n/**\n * The menus and shortcuts an app has, sent to the host as they change. `<menu-bar>` and\n * `[shortcut]` in `@ng-native/components` register here; an app rarely injects it.\n */\n@Service()\nexport class Menus {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeMenus | null>('angular-native.menusSource', {\n factory: menusSource,\n });\n\n private readonly native = inject(Menus.SOURCE);\n private readonly os: ShortcutOs = injectOs();\n\n /** Whether the host has the module: shortcuts from a hardware keyboard, and menus. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n /** Whether the menu bar is drawn: macOS and iPadOS. Elsewhere its shortcuts still work. */\n readonly menuBarShown: Signal<boolean> = signal(this.native?.menuBar === true).asReadonly();\n\n /**\n * Whether the host takes a `[contextMenu]` by the view's `nativeID` through `setContextMenu`\n * (Android and iOS) rather than as the view's `contextMenu` prop. Where it does, it draws the\n * menu on a long press.\n */\n readonly contextMenuByNativeId: boolean = this.native?.setContextMenu !== undefined;\n\n /**\n * Whether the host, which draws context menus on a long press, can be told which views inside\n * one take a long press themselves (`setTakesLongPress`).\n */\n readonly longPressByNativeId: boolean =\n this.contextMenuByNativeId && this.native?.setTakesLongPress !== undefined;\n\n /**\n * Say whether the view with `nativeID` takes a long press itself: one there then opens no\n * context menu around it.\n */\n setTakesLongPress(nativeID: string, takes: boolean): void {\n if (takes) this.longPressTakers.add(nativeID);\n else this.longPressTakers.delete(nativeID);\n this.native?.setTakesLongPress?.(nativeID, takes);\n }\n\n /** The `nativeID`s sent with a context menu, and with a long press of their own. */\n private readonly withContextMenu = new Set<string>();\n private readonly longPressTakers = new Set<string>();\n\n /**\n * Whether the host opens a context menu on a long press of the view whose `nativeID`s, from it\n * outwards, are `chain`: as it decides, the nearest view with a menu, unless one on the way takes\n * the long press itself. A `(longPress)` around that view leaves the hold to the menu, which the\n * host opens after its own long-press timeout.\n */\n opensContextMenu(chain: Iterable<string | null>): boolean {\n for (const nativeID of chain) {\n if (nativeID === null) continue;\n if (this.withContextMenu.has(nativeID)) return true;\n if (this.longPressTakers.has(nativeID)) return false;\n }\n return false;\n }\n\n /**\n * Whether the host draws a menu under a view on a press (`popUpMenu`): the desktop host, and\n * Android.\n */\n readonly popsUpMenus: boolean = this.native?.popUpMenu !== undefined;\n\n /**\n * Draw `entries` under the view with tag `view` now. The host sends the item chosen as the\n * view's `topContextMenuSelect`. It draws nothing for a view it is not showing, and does not say\n * so.\n */\n popUpMenu(view: number, entries: readonly NativeMenuEntry[]): void {\n this.native?.popUpMenu?.(view, entries);\n }\n\n /**\n * Whether the host takes a menu a press opens by the view's `nativeID` (`setPressMenu`), and\n * opens it on a touch itself: iOS.\n */\n readonly pressMenuByNativeId: boolean = this.native?.setPressMenu !== undefined;\n\n /** What choosing an item does, by the `nativeID` of the view whose press menu it is in. */\n private readonly pressMenuChoices = new Map<string, (id: string) => void>();\n\n /**\n * Send the menu a press opens on the view with `nativeID`, or null to take it away. `choose`\n * runs with the item's `id` as the host sends the choice.\n */\n setPressMenu(\n nativeID: string,\n entries: readonly NativeMenuEntry[] | null,\n choose: (id: string) => void,\n ): void {\n if (entries) this.pressMenuChoices.set(nativeID, choose);\n else this.pressMenuChoices.delete(nativeID);\n this.native?.setPressMenu?.(nativeID, entries);\n }\n\n /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */\n private readonly contextMenuChoices = new Map<string, (id: string) => void>();\n\n /**\n * Send the context menu of the view with `nativeID`, or null to take it away. `choose` runs with\n * the item's `id` where the host sends the choice itself (iOS) rather than through the view.\n */\n setContextMenu(\n nativeID: string,\n entries: readonly NativeMenuEntry[] | null,\n choose?: (id: string) => void,\n ): void {\n if (entries && choose) this.contextMenuChoices.set(nativeID, choose);\n else this.contextMenuChoices.delete(nativeID);\n if (entries?.length) this.withContextMenu.add(nativeID);\n else this.withContextMenu.delete(nativeID);\n this.native?.setContextMenu?.(nativeID, entries);\n }\n\n private readonly bars = signal<readonly Signal<readonly MenuEntry[]>[]>([]);\n private readonly shortcuts = signal<readonly Registered[]>([]);\n\n /** The app's groups, from every `<menu-bar>`, in the order they registered. */\n private readonly appGroups = computed<MenuGroupModel[]>(() =>\n this.bars()\n .flatMap((bar) => bar())\n .flatMap((entry) =>\n isSeparator(entry)\n ? []\n : [\n {\n label: entry.label,\n ...(entry.group && { menuRole: entry.group }),\n items: entry.items ?? [],\n },\n ],\n ),\n );\n\n /** The menu bar as it is drawn: the OS's defaults with the app's merged in. */\n readonly menuBar: Signal<MenuGroupModel[]> = computed(() =>\n mergeMenuBar(defaultMenuBar(this.native?.appName || 'App', this.os), this.appGroups()),\n );\n\n private readonly sentBar = computed(() => {\n const groups = this.menuBar();\n const actions = new Map<string, () => void>();\n const sent = groups.map((group, index) => {\n const menu = serializeMenu(group.items, this.os, `${index}.`);\n menu.actions.forEach((action, id) => actions.set(id, action));\n return {\n label: group.label,\n ...(group.menuRole && { menuRole: group.menuRole }),\n items:\n this.os === 'macos' && group.menuRole === 'view'\n ? releaseMacNavigationKeys(menu.entries, groups)\n : menu.entries,\n };\n });\n return { sent, actions };\n });\n\n /**\n * The shortcuts sent to the host: every `[shortcut]`, and where no menu bar is drawn, every\n * menu bar item the app gave a shortcut and a handler, so a hardware keyboard still has them.\n */\n private readonly sentShortcuts = computed(() => {\n const presses = new Map<string, () => void>();\n const editing = new Set<string>();\n const sent: NativeShortcut[] = [];\n const add = (id: string, shortcut: string, label: string, group: string, press: () => void) => {\n presses.set(id, press);\n if (isEditingShortcut(shortcut, this.os)) editing.add(id);\n sent.push({ id, chord: parseShortcut(shortcut, this.os), label, group });\n };\n this.shortcuts().forEach((one, index) =>\n add(`s${index}`, one.shortcut(), one.label(), this.native?.appName || 'App', one.press),\n );\n if (!this.menuBarShown()) {\n const walk = (entries: readonly MenuEntry[], group: string, at: string) =>\n entries.forEach((entry, index) => {\n if (isSeparator(entry)) return;\n if (entry.shortcut && entry.select && !entry.disabled) {\n add(`m${at}${index}`, entry.shortcut, entry.label, group, entry.select);\n }\n if (entry.items) walk(entry.items, group, `${at}${index}.`);\n });\n this.appGroups().forEach((group, index) => walk(group.items, group.label, `${index}.`));\n }\n return { sent, presses, editing };\n });\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n constructor() {\n // Once a label: a `<menu-group label=\"File\">` with no role that is still a group of its own\n // once merged is drawn as a second File menu, on a host that draws a menu bar.\n const warned = new Set<string>();\n effect(() => {\n if (!this.menuBarShown()) return;\n const defaults = defaultMenuBar(this.native?.appName || 'App', this.os);\n for (const label of unmergedGroups(defaults, this.menuBar())) {\n if (warned.has(label)) continue;\n warned.add(label);\n const role = defaults.find(\n (group) => group.label.toLowerCase() === label.toLowerCase(),\n )?.menuRole;\n console.warn(\n `[angular-native] <menu-group label=\"${label}\"> has no menuRole, so it shows as a second ` +\n `${label} menu. Give it menuRole=\"${role}\" to add its items to the ${label} menu.`,\n );\n }\n });\n const native = this.native;\n if (!native) {\n // Read for nothing, so a shortcut the app gets wrong throws where there is no host too, and\n // not first on a device that has one.\n effect(() => this.sentShortcuts());\n return;\n }\n effect(() => {\n if (this.menuBarShown()) native.setMenuBar(this.sentBar().sent);\n });\n effect(() => native.setShortcuts(this.sentShortcuts().sent));\n }\n\n /**\n * Add a `<menu-bar>`'s groups, each a `MenuItemModel` with `items` and its `group` role. Answers\n * the function that takes them out again, as the `<menu-bar>` goes.\n */\n addMenuBar(groups: Signal<readonly MenuEntry[]>): () => void {\n this.bars.update((all) => [...all, groups]);\n return () => this.bars.update((all) => all.filter((one) => one !== groups));\n }\n\n /**\n * Listen for `shortcut`, pressed anywhere in the app: `mod+k`, as `parseShortcut` reads it.\n * `label` is what Android's Keyboard Shortcuts helper lists it as. Answers the function that\n * stops listening.\n */\n addShortcut(shortcut: Signal<string>, label: Signal<string>, press: () => void): () => void {\n const registered: Registered = { shortcut, label, press };\n this.shortcuts.update((all) => [...all, registered]);\n return () => this.shortcuts.update((all) => all.filter((one) => one !== registered));\n }\n\n private readonly navigators = new Set<\n (direction: 'back' | 'forward', surface?: number, steps?: number) => void\n >();\n\n /**\n * Hear the OS's back and forward commands. Apps with their own history can listen here.\n * `@ng-native/router` listens and moves through the history of the window each was in,\n * `steps` entries (one, but for a pick from a chevron's history menu). Returns a function to\n * stop listening.\n */\n onNavigate(\n listener: (direction: 'back' | 'forward', surface?: number, steps?: number) => void,\n ): () => void {\n this.navigators.add(listener);\n return () => void this.navigators.delete(listener);\n }\n\n /**\n * Tell the host the history of the window on `surface`, which its toolbar's back and forward\n * chevrons and their menus show. `@ng-native/router` calls it. Does nothing where the host has\n * no chevrons.\n */\n setHistory(surface: number, history: NativeWindowHistory): void {\n this.native?.setHistory?.(surface, history);\n }\n\n private hostSaid(event: NativeMenuEvent): void {\n if (event.type === 'navigate') {\n const steps = event.steps ?? 1;\n this.navigators.forEach((listener) => listener(event.direction, event.surface, steps));\n return;\n }\n if (event.type === 'menuSelect') {\n this.sentBar().actions.get(event.id)?.();\n return;\n }\n if (event.type === 'contextMenuSelect') {\n this.contextMenuChoices.get(event.nativeID)?.(event.id);\n return;\n }\n if (event.type === 'pressMenuSelect') {\n this.pressMenuChoices.get(event.nativeID)?.(event.id);\n return;\n }\n const { presses, editing } = this.sentShortcuts();\n // The editing keys belong to a focused text input: the app's shortcut on one waits.\n if (event.textInputFocused && editing.has(event.id)) return;\n presses.get(event.id)?.();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { type OutputEmitterRef, type Signal } from '@angular/core';
2
+ /**
3
+ * Whether an output has a listener, as a signal, so an element can follow one added or removed
4
+ * after it first rendered: a template binding, or a subscription from code. For a native prop
5
+ * React Native's components set from whether a handler was passed.
6
+ */
7
+ export declare function outputListened<T>(emitter: OutputEmitterRef<T>): Signal<boolean>;
@@ -0,0 +1,27 @@
1
+ import { computed, signal } from '@angular/core';
2
+ /**
3
+ * Whether an output has a listener, as a signal, so an element can follow one added or removed
4
+ * after it first rendered: a template binding, or a subscription from code. For a native prop
5
+ * React Native's components set from whether a handler was passed.
6
+ */
7
+ export function outputListened(emitter) {
8
+ const listeners = signal(0, /* @ts-ignore */
9
+ ...(ngDevMode ? [{ debugName: "listeners" }] : /* istanbul ignore next */ []));
10
+ const subscribe = emitter.subscribe.bind(emitter);
11
+ emitter.subscribe = (callback) => {
12
+ listeners.update((count) => count + 1);
13
+ const subscription = subscribe(callback);
14
+ let stopped = false;
15
+ return {
16
+ unsubscribe: () => {
17
+ if (stopped)
18
+ return;
19
+ stopped = true;
20
+ listeners.update((count) => count - 1);
21
+ subscription.unsubscribe();
22
+ },
23
+ };
24
+ };
25
+ return computed(() => listeners() > 0);
26
+ }
27
+ //# sourceMappingURL=output-listened.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-listened.js","sourceRoot":"","sources":["../src/output-listened.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAsC,MAAM,eAAe,CAAC;AAErF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAI,OAA4B;IAC5D,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC;kFAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,SAAS,GAAG,CAAC,QAAQ,EAAE,EAAE;QAC/B,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACvC,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,OAAO;YACL,WAAW,EAAE,GAAG,EAAE;gBAChB,IAAI,OAAO;oBAAE,OAAO;gBACpB,OAAO,GAAG,IAAI,CAAC;gBACf,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACvC,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { computed, signal, type OutputEmitterRef, type Signal } from '@angular/core';\n\n/**\n * Whether an output has a listener, as a signal, so an element can follow one added or removed\n * after it first rendered: a template binding, or a subscription from code. For a native prop\n * React Native's components set from whether a handler was passed.\n */\nexport function outputListened<T>(emitter: OutputEmitterRef<T>): Signal<boolean> {\n const listeners = signal(0);\n const subscribe = emitter.subscribe.bind(emitter);\n emitter.subscribe = (callback) => {\n listeners.update((count) => count + 1);\n const subscription = subscribe(callback);\n let stopped = false;\n return {\n unsubscribe: () => {\n if (stopped) return;\n stopped = true;\n listeners.update((count) => count - 1);\n subscription.unsubscribe();\n },\n };\n };\n return computed(() => listeners() > 0);\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * What draws an icon's SVG markup as an image, for a place on iOS and Android that takes an image
3
+ * and not a view: a `<native-tab>` icon and a `<native-button>` icon. Neither platform draws SVG
4
+ * there, so the app provides a renderer, `SvgImages` from `@ng-native/icons`, through
5
+ * `withSvgIcons` in `provideNativeRouter` or this token. The packages that draw an icon import no
6
+ * renderer: drawing SVG is the icons package's, and it imports neither of them.
7
+ */
8
+ import { InjectionToken, type ViewContainerRef } from '@angular/core';
9
+ /** Draws SVG markup as an image. `SvgImages` from `@ng-native/icons` is one. */
10
+ export interface SvgIconRenderer {
11
+ /**
12
+ * The markup drawn `size` points square, as an image source native can show, such as a
13
+ * `{ uri, scale }`. It may draw the markup into a view it creates in `at`, which is on screen.
14
+ * Null when it could not be drawn.
15
+ */
16
+ render(svg: string, size: number, at: ViewContainerRef): Promise<unknown>;
17
+ }
18
+ /**
19
+ * The app's renderer, or null when it provides none:
20
+ *
21
+ * ```ts
22
+ * providers: [{ provide: SVG_ICON_RENDERER, useClass: SvgImages }];
23
+ * ```
24
+ */
25
+ export declare const SVG_ICON_RENDERER: InjectionToken<SvgIconRenderer | null>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * What draws an icon's SVG markup as an image, for a place on iOS and Android that takes an image
3
+ * and not a view: a `<native-tab>` icon and a `<native-button>` icon. Neither platform draws SVG
4
+ * there, so the app provides a renderer, `SvgImages` from `@ng-native/icons`, through
5
+ * `withSvgIcons` in `provideNativeRouter` or this token. The packages that draw an icon import no
6
+ * renderer: drawing SVG is the icons package's, and it imports neither of them.
7
+ */
8
+ import { InjectionToken } from '@angular/core';
9
+ /**
10
+ * The app's renderer, or null when it provides none:
11
+ *
12
+ * ```ts
13
+ * providers: [{ provide: SVG_ICON_RENDERER, useClass: SvgImages }];
14
+ * ```
15
+ */
16
+ export const SVG_ICON_RENDERER = new InjectionToken('angular-native.svgIconRenderer', { factory: () => null });
17
+ //# sourceMappingURL=svg-icon-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-icon-renderer.js","sourceRoot":"","sources":["../src/svg-icon-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAyB,MAAM,eAAe,CAAC;AAYtE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,cAAc,CACjD,gCAAgC,EAChC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CACxB,CAAC","sourcesContent":["/**\n * What draws an icon's SVG markup as an image, for a place on iOS and Android that takes an image\n * and not a view: a `<native-tab>` icon and a `<native-button>` icon. Neither platform draws SVG\n * there, so the app provides a renderer, `SvgImages` from `@ng-native/icons`, through\n * `withSvgIcons` in `provideNativeRouter` or this token. The packages that draw an icon import no\n * renderer: drawing SVG is the icons package's, and it imports neither of them.\n */\nimport { InjectionToken, type ViewContainerRef } from '@angular/core';\n\n/** Draws SVG markup as an image. `SvgImages` from `@ng-native/icons` is one. */\nexport interface SvgIconRenderer {\n /**\n * The markup drawn `size` points square, as an image source native can show, such as a\n * `{ uri, scale }`. It may draw the markup into a view it creates in `at`, which is on screen.\n * Null when it could not be drawn.\n */\n render(svg: string, size: number, at: ViewContainerRef): Promise<unknown>;\n}\n\n/**\n * The app's renderer, or null when it provides none:\n *\n * ```ts\n * providers: [{ provide: SVG_ICON_RENDERER, useClass: SvgImages }];\n * ```\n */\nexport const SVG_ICON_RENDERER = new InjectionToken<SvgIconRenderer | null>(\n 'angular-native.svgIconRenderer',\n { factory: () => null },\n);\n"]}
package/dist/tray.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * iOS and Android, and on a Linux desktop with no StatusNotifierWatcher, where nothing is drawn.
5
5
  *
6
6
  * The host contract, on the `NgNativeTray` module: `setIcons(icons)` takes every icon each time one
7
- * changes, as `{ id, title, sfSymbol, image, tooltip, menu }`, `menu` as `serializeMenu` makes it
8
- * (null for an icon with a press instead). It sends `{ type: 'press', icon }` and
7
+ * changes, as `{ id, title, sfSymbol, svgIcon, image, tooltip, menu }`, `menu` as `serializeMenu`
8
+ * makes it (null for an icon with a press instead). It sends `{ type: 'press', icon }` and
9
9
  * `{ type: 'menuSelect', icon, id }` on `ngNativeTray`.
10
10
  */
11
11
  import { InjectionToken, type Signal } from '@angular/core';
@@ -17,6 +17,12 @@ export interface TrayIconModel {
17
17
  readonly title?: string;
18
18
  /** An SF Symbol, drawn as a template image that follows the menu bar's appearance. */
19
19
  readonly sfSymbol?: string;
20
+ /**
21
+ * An icon's SVG markup, such as an `@ng-icons` icon, where there is no `sfSymbol`: on macOS a
22
+ * template image that follows the menu bar's appearance, and on Linux a picture in a colour for
23
+ * the panel.
24
+ */
25
+ readonly svgIcon?: string;
20
26
  /** An image asset's name, for an icon of the app's own. */
21
27
  readonly image?: string;
22
28
  readonly tooltip?: string;
@@ -28,6 +34,7 @@ export interface NativeTrayIcon {
28
34
  readonly id: string;
29
35
  readonly title?: string;
30
36
  readonly sfSymbol?: string;
37
+ readonly svgIcon?: string;
31
38
  readonly image?: string;
32
39
  readonly tooltip?: string;
33
40
  readonly menu: readonly NativeMenuEntry[] | null;
package/dist/tray.js CHANGED
@@ -4,8 +4,8 @@
4
4
  * iOS and Android, and on a Linux desktop with no StatusNotifierWatcher, where nothing is drawn.
5
5
  *
6
6
  * The host contract, on the `NgNativeTray` module: `setIcons(icons)` takes every icon each time one
7
- * changes, as `{ id, title, sfSymbol, image, tooltip, menu }`, `menu` as `serializeMenu` makes it
8
- * (null for an icon with a press instead). It sends `{ type: 'press', icon }` and
7
+ * changes, as `{ id, title, sfSymbol, svgIcon, image, tooltip, menu }`, `menu` as `serializeMenu`
8
+ * makes it (null for an icon with a press instead). It sends `{ type: 'press', icon }` and
9
9
  * `{ type: 'menuSelect', icon, id }` on `ngNativeTray`.
10
10
  */
11
11
  import { InjectionToken, Service, computed, effect, inject, signal, } from '@angular/core';
package/dist/tray.js.map CHANG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MAAM,GAAG,GAAG,EAAE,EAAE,EAAE,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC1C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,QAAQ,CAAC,KAAsB;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;YACrC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACvC,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAjDU,IAAI;wGAAJ,IAAI;;2FAAJ,IAAI;kBADhB,OAAO","sourcesContent":["/**\n * Icons in the macOS menu bar's status area, or a Linux panel's as StatusNotifierItems, each with\n * a menu or a press of its own. `<tray-icon>` in `@ng-native/components` registers here. Absent on\n * iOS and Android, and on a Linux desktop with no StatusNotifierWatcher, where nothing is drawn.\n *\n * The host contract, on the `NgNativeTray` module: `setIcons(icons)` takes every icon each time one\n * changes, as `{ id, title, sfSymbol, image, tooltip, menu }`, `menu` as `serializeMenu` makes it\n * (null for an icon with a press instead). It sends `{ type: 'press', icon }` and\n * `{ type: 'menuSelect', icon, id }` on `ngNativeTray`.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n effect,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport type { MenuEntry } from './menu-model.ts';\nimport { serializeMenu, type NativeMenuEntry } from './menus.ts';\nimport { injectOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\n\n/** One icon as an app describes it. */\nexport interface TrayIconModel {\n readonly title?: string;\n /** An SF Symbol, drawn as a template image that follows the menu bar's appearance. */\n readonly sfSymbol?: string;\n /** An image asset's name, for an icon of the app's own. */\n readonly image?: string;\n readonly tooltip?: string;\n /** The menu a click opens; with none, a click is a press. */\n readonly menu: readonly MenuEntry[];\n readonly press: () => void;\n}\n\nexport interface NativeTrayIcon {\n readonly id: string;\n readonly title?: string;\n readonly sfSymbol?: string;\n readonly image?: string;\n readonly tooltip?: string;\n readonly menu: readonly NativeMenuEntry[] | null;\n}\n\nexport type NativeTrayEvent =\n | { readonly type: 'press'; readonly icon: string }\n | { readonly type: 'menuSelect'; readonly icon: string; readonly id: string };\n\nexport interface NativeTray {\n setIcons(icons: readonly NativeTrayIcon[]): void;\n subscribe(listener: (event: NativeTrayEvent) => void): () => void;\n}\n\ninterface TrayTurboModule {\n setIcons?(icons: readonly NativeTrayIcon[]): void;\n}\n\nfunction traySource(): NativeTray | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeTray') as\n TrayTurboModule | null | undefined;\n if (!module) return null;\n return {\n setIcons: (icons) => module.setIcons?.(icons),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeTray', (event) =>\n listener(event as NativeTrayEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n@Service()\nexport class Tray {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeTray | null>('angular-native.traySource', {\n factory: traySource,\n });\n\n private readonly native = inject(Tray.SOURCE);\n /** The desktop OS whose shortcuts the menus show: Linux's own, else a Mac's. */\n private readonly menuOs = injectOs() === 'linux' ? 'linux' : 'macos';\n private readonly icons = signal<readonly { id: string; model: Signal<TrayIconModel> }[]>([]);\n private next = 0;\n\n /** Whether the OS has a status area for the app: macOS, and Linux with a StatusNotifierWatcher. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n private readonly sent = computed(() =>\n this.icons().map(({ id, model }) => {\n const { menu, press, ...icon } = model();\n const serialized = serializeMenu(menu, this.menuOs);\n return {\n icon: { id, ...icon, menu: serialized.entries.length ? serialized.entries : null },\n actions: serialized.actions,\n press,\n };\n }),\n );\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n constructor() {\n const native = this.native;\n if (native) effect(() => native.setIcons(this.sent().map((one) => one.icon)));\n }\n\n /** Show an icon for as long as the function answered is not called. */\n add(model: Signal<TrayIconModel>): () => void {\n const one = { id: `tray-${this.next++}`, model };\n this.icons.update((all) => [...all, one]);\n return () => this.icons.update((all) => all.filter((each) => each !== one));\n }\n\n private hostSaid(event: NativeTrayEvent): void {\n const icon = this.sent().find((one) => one.icon.id === event.icon);\n if (event.type === 'press') icon?.press();\n else icon?.actions.get(event.id)?.();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
1
+ {"version":3,"file":"tray.js","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAwB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AA4ChD,SAAS,UAAU;IACjB,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAA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IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;YACrC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACvC,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAjDU,IAAI;wGAAJ,IAAI;;2FAAJ,IAAI;kBADhB,OAAO","sourcesContent":["/**\n * Icons in the macOS menu bar's status area, or a Linux panel's as StatusNotifierItems, each with\n * a menu or a press of its own. `<tray-icon>` in `@ng-native/components` registers here. Absent on\n * iOS and Android, and on a Linux desktop with no StatusNotifierWatcher, where nothing is drawn.\n *\n * The host contract, on the `NgNativeTray` module: `setIcons(icons)` takes every icon each time one\n * changes, as `{ id, title, sfSymbol, svgIcon, image, tooltip, menu }`, `menu` as `serializeMenu`\n * makes it (null for an icon with a press instead). It sends `{ type: 'press', icon }` and\n * `{ type: 'menuSelect', icon, id }` on `ngNativeTray`.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n effect,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport type { MenuEntry } from './menu-model.ts';\nimport { serializeMenu, type NativeMenuEntry } from './menus.ts';\nimport { injectOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\n\n/** One icon as an app describes it. */\nexport interface TrayIconModel {\n readonly title?: string;\n /** An SF Symbol, drawn as a template image that follows the menu bar's appearance. */\n readonly sfSymbol?: string;\n /**\n * An icon's SVG markup, such as an `@ng-icons` icon, where there is no `sfSymbol`: on macOS a\n * template image that follows the menu bar's appearance, and on Linux a picture in a colour for\n * the panel.\n */\n readonly svgIcon?: string;\n /** An image asset's name, for an icon of the app's own. */\n readonly image?: string;\n readonly tooltip?: string;\n /** The menu a click opens; with none, a click is a press. */\n readonly menu: readonly MenuEntry[];\n readonly press: () => void;\n}\n\nexport interface NativeTrayIcon {\n readonly id: string;\n readonly title?: string;\n readonly sfSymbol?: string;\n readonly svgIcon?: string;\n readonly image?: string;\n readonly tooltip?: string;\n readonly menu: readonly NativeMenuEntry[] | null;\n}\n\nexport type NativeTrayEvent =\n | { readonly type: 'press'; readonly icon: string }\n | { readonly type: 'menuSelect'; readonly icon: string; readonly id: string };\n\nexport interface NativeTray {\n setIcons(icons: readonly NativeTrayIcon[]): void;\n subscribe(listener: (event: NativeTrayEvent) => void): () => void;\n}\n\ninterface TrayTurboModule {\n setIcons?(icons: readonly NativeTrayIcon[]): void;\n}\n\nfunction traySource(): NativeTray | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeTray') as\n TrayTurboModule | null | undefined;\n if (!module) return null;\n return {\n setIcons: (icons) => module.setIcons?.(icons),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeTray', (event) =>\n listener(event as NativeTrayEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n@Service()\nexport class Tray {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeTray | null>('angular-native.traySource', {\n factory: traySource,\n });\n\n private readonly native = inject(Tray.SOURCE);\n /** The desktop OS whose shortcuts the menus show: Linux's own, else a Mac's. */\n private readonly menuOs = injectOs() === 'linux' ? 'linux' : 'macos';\n private readonly icons = signal<readonly { id: string; model: Signal<TrayIconModel> }[]>([]);\n private next = 0;\n\n /** Whether the OS has a status area for the app: macOS, and Linux with a StatusNotifierWatcher. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n private readonly sent = computed(() =>\n this.icons().map(({ id, model }) => {\n const { menu, press, ...icon } = model();\n const serialized = serializeMenu(menu, this.menuOs);\n return {\n icon: { id, ...icon, menu: serialized.entries.length ? serialized.entries : null },\n actions: serialized.actions,\n press,\n };\n }),\n );\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n constructor() {\n const native = this.native;\n if (native) effect(() => native.setIcons(this.sent().map((one) => one.icon)));\n }\n\n /** Show an icon for as long as the function answered is not called. */\n add(model: Signal<TrayIconModel>): () => void {\n const one = { id: `tray-${this.next++}`, model };\n this.icons.update((all) => [...all, one]);\n return () => this.icons.update((all) => all.filter((each) => each !== one));\n }\n\n private hostSaid(event: NativeTrayEvent): void {\n const icon = this.sent().find((one) => one.icon.id === event.icon);\n if (event.type === 'press') icon?.press();\n else icon?.actions.get(event.id)?.();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/device",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Angular Native device services: keyboard, screen, color scheme, app state, accessibility, hardware back and deep links.",
5
5
  "keywords": [
6
6
  "angular",
@@ -17,7 +17,7 @@
17
17
  "type": "module",
18
18
  "main": "dist/index.js",
19
19
  "dependencies": {
20
- "@ng-native/fabric": "0.28.0"
20
+ "@ng-native/fabric": "0.29.0"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@angular/core": "^22.0.0",