@ng-native/device 0.27.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.
- package/dist/app-windows.d.ts +8 -3
- package/dist/app-windows.js +7 -4
- package/dist/app-windows.js.map +1 -1
- package/dist/in-form-sheet.d.ts +9 -0
- package/dist/in-form-sheet.js +12 -0
- package/dist/in-form-sheet.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/menu-model.d.ts +5 -0
- package/dist/menu-model.js.map +1 -1
- package/dist/menus.d.ts +50 -4
- package/dist/menus.js +80 -7
- package/dist/menus.js.map +1 -1
- package/dist/output-listened.d.ts +7 -0
- package/dist/output-listened.js +27 -0
- package/dist/output-listened.js.map +1 -0
- package/dist/shortcut.d.ts +2 -2
- package/dist/shortcut.js +37 -2
- package/dist/shortcut.js.map +1 -1
- package/dist/svg-icon-renderer.d.ts +25 -0
- package/dist/svg-icon-renderer.js +17 -0
- package/dist/svg-icon-renderer.js.map +1 -0
- package/dist/tray.d.ts +9 -2
- package/dist/tray.js +2 -2
- package/dist/tray.js.map +1 -1
- package/package.json +2 -2
|
@@ -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`
|
|
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`
|
|
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
CHANGED
|
@@ -1 +1 @@
|
|
|
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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AAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,uEAAuE;IACvE,GAAG,CAAC,KAA4B;QAC9B,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, 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.
|
|
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.
|
|
20
|
+
"@ng-native/fabric": "0.29.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@angular/core": "^22.0.0",
|