@ng-native/device 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +2 -2
  2. package/dist/accessibility.js +3 -3
  3. package/dist/app-lifecycle.js +3 -3
  4. package/dist/app-state.js +3 -3
  5. package/dist/app-windows.d.ts +17 -3
  6. package/dist/app-windows.js +10 -7
  7. package/dist/app-windows.js.map +1 -1
  8. package/dist/color-scheme.js +3 -3
  9. package/dist/deep-links.js +3 -3
  10. package/dist/dev-menu.js +3 -3
  11. package/dist/dialogs.js +3 -3
  12. package/dist/direction.js +3 -3
  13. package/dist/dock.js +3 -3
  14. package/dist/drag-and-drop.js +3 -3
  15. package/dist/hardware-back.js +3 -3
  16. package/dist/in-form-sheet.d.ts +9 -0
  17. package/dist/in-form-sheet.js +12 -0
  18. package/dist/in-form-sheet.js.map +1 -0
  19. package/dist/index.d.ts +4 -0
  20. package/dist/index.js +4 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/keyboard-focus.d.ts +13 -0
  23. package/dist/keyboard-focus.js +22 -0
  24. package/dist/keyboard-focus.js.map +1 -0
  25. package/dist/keyboard.js +3 -3
  26. package/dist/layout-animation.js +3 -3
  27. package/dist/menu-model.d.ts +5 -0
  28. package/dist/menu-model.js.map +1 -1
  29. package/dist/menus.d.ts +44 -4
  30. package/dist/menus.js +77 -12
  31. package/dist/menus.js.map +1 -1
  32. package/dist/navigation-bar.js +3 -3
  33. package/dist/os-support.js +3 -0
  34. package/dist/os-support.js.map +1 -1
  35. package/dist/output-listened.d.ts +7 -0
  36. package/dist/output-listened.js +27 -0
  37. package/dist/output-listened.js.map +1 -0
  38. package/dist/processes.js +3 -3
  39. package/dist/safe-area.js +3 -3
  40. package/dist/screen.js +3 -3
  41. package/dist/sharing.js +3 -3
  42. package/dist/shell.js +3 -3
  43. package/dist/spawn-rules.d.ts +10 -4
  44. package/dist/spawn-rules.js +32 -16
  45. package/dist/spawn-rules.js.map +1 -1
  46. package/dist/status-bar.js +3 -3
  47. package/dist/svg-icon-renderer.d.ts +25 -0
  48. package/dist/svg-icon-renderer.js +17 -0
  49. package/dist/svg-icon-renderer.js.map +1 -0
  50. package/dist/tray.d.ts +9 -2
  51. package/dist/tray.js +5 -5
  52. package/dist/tray.js.map +1 -1
  53. package/dist/undo-stack.js +3 -3
  54. package/dist/vibration.js +3 -3
  55. package/package.json +5 -5
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";
@@ -37,6 +39,7 @@ export { macosPermissions, } from "./desktop-permissions.js";
37
39
  export { Menus, menuActionId, menusSource, serializeMenu, } from "./menus.js";
38
40
  export { Dock } from "./dock.js";
39
41
  export { nativeSplitViews } from "./split-views.js";
42
+ export { KEYBOARD_FOCUS, reportKeyboardFocusable } from "./keyboard-focus.js";
40
43
  export { DragAndDrop, dragAndDropSource, } from "./drag-and-drop.js";
41
44
  export { UndoStack } from "./undo-stack.js";
42
45
  export { OS_SUPPORT, SUPPORT_OSES, platformsLine, supportRowOf, } from "./os-support.js";
@@ -51,6 +54,7 @@ export { APP_LIFECYCLE_OPTIONS, AppLifecycle, WILL_QUIT_DEADLINE_MS, provideAppL
51
54
  export { OS_VERSION } from "./os-version.js";
52
55
  export { injectToken } from "./inject-token.js";
53
56
  export {} from "./control-size.js";
57
+ export { SVG_ICON_RENDERER } from "./svg-icon-renderer.js";
54
58
  export { RESTORABLE_WINDOWS, WINDOW_RESTORE_STORE, provideRestorableWindows, } from "./window-restore.js";
55
59
  export { buildMenuTemplate } from "./menu-template.js";
56
60
  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,EAAE,OAAO,EAA0C,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAmC,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAyC,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EACL,eAAe,EACf,QAAQ,EACR,cAAc,GAIf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AACnE,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E,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,WAAW,EACX,iBAAiB,GAIlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAA0D,MAAM,iBAAiB,CAAC;AACpG,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,GAGb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,EAAoB,MAAM,YAAY,CAAC;AACrD,OAAO,EACL,IAAI,GAKL,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EACL,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EAajB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,GAGzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAqB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,UAAU,GAMX,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * The host: the device, the operating system, and the user's settings.\n *\n * Every capability here is a service with its own factory, so injecting one is the whole setup\n * and one nobody injects is never constructed. Off a device each falls back to doing nothing,\n * which is what makes the whole package importable by the test suite.\n */\nexport {\n Accessibility,\n type AccessibilitySettings,\n type AccessibilitySource,\n} from './accessibility.ts';\nexport { AppState, type AppStateSource, type AppStatus } from './app-state.ts';\nexport { ColorScheme, type ColorSchemeSource, type Scheme } from './color-scheme.ts';\nexport {\n currentConditions,\n deviceTokens,\n hairlineTokens,\n watchConditions,\n type WatchOptions,\n} from './conditions.ts';\nexport { DeepLinks, deepLinkSource, pathOf, type DeepLinkSource } from './deep-links.ts';\nexport {\n Direction,\n type DirectionContext,\n type DirectionSource,\n type LayoutDirection,\n} from './direction.ts';\nexport {\n androidPermission,\n type AndroidPermissions,\n type PermissionAnswer,\n} from './android-permissions.ts';\nexport { DevMenu, type DevMenuSource, type NativeDevMenu } from './dev-menu.ts';\nexport { Dialogs, type Choice, type NativeDialogs } from './dialogs.ts';\nexport {\n LayoutAnimation,\n type LayoutChange,\n type LayoutEasing,\n type NativeLayoutAnimation,\n} from './layout-animation.ts';\nexport { Sharing, type NativeSharing, type ShareRequest } from './sharing.ts';\nexport { Vibration, type NativeVibration } from './vibration.ts';\nexport { HardwareBack, hardwareBackSource, type HardwareBackSource } from './hardware-back.ts';\nexport {\n KEYBOARD_MOTION,\n Keyboard,\n keyboardSource,\n type KeyboardMetrics,\n type KeyboardMotion,\n type KeyboardSource,\n} from './keyboard.ts';\nexport type { NativeKeyboardEvent } from './react-native.ts';\nexport { SafeArea, type Frame, type Insets } from './safe-area.ts';\nexport { COMPACT_WIDTH, Screen, type ScreenSource, type Size, type Sizes } from './screen.ts';\nexport {\n StatusBar,\n statusBarSource,\n type PlatformStatusBarStyle,\n type StatusBarSource,\n type StatusBarState,\n type StatusBarStyle,\n} from './status-bar.ts';\nexport {\n TopClaim,\n WindowClaims,\n onWindowFront,\n sharedBySource,\n type Claim,\n} from './window-claims.ts';\nexport {\n NavigationBar,\n navigationBarSource,\n type NavigationBarSource,\n type NavigationBarState,\n type NavigationBarStyle,\n} from './navigation-bar.ts';\nexport { SCREEN_IN_FRONT } from './screen-in-front.ts';\nexport { SCREEN_SHOWN } from './screen-shown.ts';\nexport { NATIVE_HISTORY } from './native-history.ts';\nexport { APPLE, DESKTOP, OS, 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,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EACL,eAAe,EACf,QAAQ,EACR,cAAc,GAIf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,EAA4C,MAAM,aAAa,CAAC;AAC9F,OAAO,EACL,SAAS,EACT,eAAe,GAKhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,cAAc,GAEf,MAAM,oBAAoB,CAAC;AA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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 { KEYBOARD_FOCUS, reportKeyboardFocusable } from './keyboard-focus.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"]}
@@ -0,0 +1,13 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ /**
3
+ * Tells `@ng-native/components`' pod whether the view with react tag `tag` takes the focus of an
4
+ * iPad's hardware keyboard, which React Native's iOS views never do: its iOS props have no
5
+ * `focusable`. The pod's `NgNativeKeyboardFocus` module lets the view be focused, draws the focus
6
+ * halo, and presses it on Space and Return. Nothing off iOS, in Expo Go, or without the pod.
7
+ */
8
+ export declare function reportKeyboardFocusable(tag: number, focusable: boolean): void;
9
+ /**
10
+ * Where a view says whether it takes an iPad hardware keyboard's focus: `reportKeyboardFocusable`,
11
+ * which a test replaces to hear what views report.
12
+ */
13
+ export declare const KEYBOARD_FOCUS: InjectionToken<(tag: number, focusable: boolean) => void>;
@@ -0,0 +1,22 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { platformOs } from "./os.js";
3
+ import { reactNative } from "./react-native.js";
4
+ /**
5
+ * Tells `@ng-native/components`' pod whether the view with react tag `tag` takes the focus of an
6
+ * iPad's hardware keyboard, which React Native's iOS views never do: its iOS props have no
7
+ * `focusable`. The pod's `NgNativeKeyboardFocus` module lets the view be focused, draws the focus
8
+ * halo, and presses it on Space and Return. Nothing off iOS, in Expo Go, or without the pod.
9
+ */
10
+ export function reportKeyboardFocusable(tag, focusable) {
11
+ // Only iOS has the module: asking elsewhere logs that it is missing.
12
+ if (platformOs() !== 'ios')
13
+ return;
14
+ const module = reactNative()?.TurboModuleRegistry?.get?.('NgNativeKeyboardFocus');
15
+ module?.setFocusable?.(tag, focusable);
16
+ }
17
+ /**
18
+ * Where a view says whether it takes an iPad hardware keyboard's focus: `reportKeyboardFocusable`,
19
+ * which a test replaces to hear what views report.
20
+ */
21
+ export const KEYBOARD_FOCUS = new InjectionToken('angular-native.keyboard-focus', { providedIn: 'root', factory: () => reportKeyboardFocusable });
22
+ //# sourceMappingURL=keyboard-focus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboard-focus.js","sourceRoot":"","sources":["../src/keyboard-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW,EAAE,SAAkB;IACrE,qEAAqE;IACrE,IAAI,UAAU,EAAE,KAAK,KAAK;QAAE,OAAO;IACnC,MAAM,MAAM,GAAG,WAAW,EAAE,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,uBAAuB,CACxC,CAAC;IACzC,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,CAC9C,+BAA+B,EAC/B,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,EAAE,CAC/D,CAAC","sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { platformOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\n\ninterface KeyboardFocusModule {\n setFocusable?(tag: number, focusable: boolean): void;\n}\n\n/**\n * Tells `@ng-native/components`' pod whether the view with react tag `tag` takes the focus of an\n * iPad's hardware keyboard, which React Native's iOS views never do: its iOS props have no\n * `focusable`. The pod's `NgNativeKeyboardFocus` module lets the view be focused, draws the focus\n * halo, and presses it on Space and Return. Nothing off iOS, in Expo Go, or without the pod.\n */\nexport function reportKeyboardFocusable(tag: number, focusable: boolean): void {\n // Only iOS has the module: asking elsewhere logs that it is missing.\n if (platformOs() !== 'ios') return;\n const module = reactNative()?.TurboModuleRegistry?.get?.('NgNativeKeyboardFocus') as\n KeyboardFocusModule | null | undefined;\n module?.setFocusable?.(tag, focusable);\n}\n\n/**\n * Where a view says whether it takes an iPad hardware keyboard's focus: `reportKeyboardFocusable`,\n * which a test replaces to hear what views report.\n */\nexport const KEYBOARD_FOCUS = new InjectionToken<(tag: number, focusable: boolean) => void>(\n 'angular-native.keyboard-focus',\n { providedIn: 'root', factory: () => reportKeyboardFocusable },\n);\n"]}
package/dist/keyboard.js CHANGED
@@ -218,10 +218,10 @@ export class Keyboard {
218
218
  this.engine?.blurFocused();
219
219
  this.source.dismiss();
220
220
  }
221
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Keyboard, deps: [], target: i0.ɵɵFactoryTarget.Service });
222
- static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: Keyboard });
221
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: Keyboard, deps: [], target: i0.ɵɵFactoryTarget.Service });
222
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.3.0", ngImport: i0, type: Keyboard });
223
223
  }
224
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Keyboard, decorators: [{
224
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: Keyboard, decorators: [{
225
225
  type: Service
226
226
  }], ctorParameters: () => [] });
227
227
  //# sourceMappingURL=keyboard.js.map
@@ -119,10 +119,10 @@ export class LayoutAnimation {
119
119
  return false;
120
120
  }
121
121
  }
122
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LayoutAnimation, deps: [], target: i0.ɵɵFactoryTarget.Service });
123
- static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: LayoutAnimation });
122
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: LayoutAnimation, deps: [], target: i0.ɵɵFactoryTarget.Service });
123
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.3.0", ngImport: i0, type: LayoutAnimation });
124
124
  }
125
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: LayoutAnimation, decorators: [{
125
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: LayoutAnimation, decorators: [{
126
126
  type: Service
127
127
  }] });
128
128
  /**
@@ -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,CAAC;AAE9F,MAAM,IAAI,GAAG,CAAC,KAAa,EA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AAC;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,KAAK,EAAE;gBACL,IAAI,CAAC,MAAM,EAAE,MAA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AE,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,10 @@
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
+ * keeps a menu a press opens for that view, and sends the item chosen as
22
+ * `{ type: 'pressMenuSelect', nativeID, id }`. From iOS 17.4, where its `opensPressMenus`
23
+ * constant is true, `openPressMenu(nativeID)` opens it from code too.
21
24
  * - Where it draws menus on a press, `popUpMenu(view, entries)` draws one under the view with that
22
25
  * tag now, and sends the item chosen as the view's `topContextMenuSelect`, as a context menu's
23
26
  * (the desktop host, and Android).
@@ -47,6 +50,7 @@ export type NativeMenuEntry = {
47
50
  readonly subtitle?: string;
48
51
  readonly sfSymbol?: string;
49
52
  readonly icon?: string;
53
+ readonly svgIcon?: string;
50
54
  readonly inline?: boolean;
51
55
  readonly items?: readonly NativeMenuEntry[];
52
56
  };
@@ -91,6 +95,12 @@ export type NativeMenuEvent = {
91
95
  readonly nativeID: string;
92
96
  readonly id: string;
93
97
  }
98
+ /** An item chosen in the press menu of the view with `nativeID` (iOS). */
99
+ | {
100
+ readonly type: 'pressMenuSelect';
101
+ readonly nativeID: string;
102
+ readonly id: string;
103
+ }
94
104
  /**
95
105
  * Back or forward, from whichever input the OS has for it: View > Back and Forward and their
96
106
  * keys, a two-finger swipe, mouse buttons 4 and 5, the toolbar's chevrons and their history
@@ -135,6 +145,16 @@ export interface NativeMenus {
135
145
  * `topContextMenuSelect`. The desktop host, and Android.
136
146
  */
137
147
  popUpMenu?(view: number, entries: readonly NativeMenuEntry[]): void;
148
+ /**
149
+ * The menu a press opens on the view with `nativeID`, or null to take it away. iOS, which opens
150
+ * one on a touch but has no way to open one from code.
151
+ */
152
+ setPressMenu?(nativeID: string, entries: readonly NativeMenuEntry[] | null): void;
153
+ /**
154
+ * Open the menu `setPressMenu` gave the view with `nativeID`, now, for a press its own touch did
155
+ * not open it on. iOS 17.4 and later.
156
+ */
157
+ openPressMenu?(nativeID: string): void;
138
158
  subscribe(listener: (event: NativeMenuEvent) => void): () => void;
139
159
  }
140
160
  /**
@@ -192,6 +212,25 @@ export declare class Menus {
192
212
  * so.
193
213
  */
194
214
  popUpMenu(view: number, entries: readonly NativeMenuEntry[]): void;
215
+ /**
216
+ * Whether the host takes a menu a press opens by the view's `nativeID` (`setPressMenu`), and
217
+ * opens it on a touch itself: iOS.
218
+ */
219
+ readonly pressMenuByNativeId: boolean;
220
+ /**
221
+ * Whether the host opens a press menu by `nativeID` from code (`openPressMenu`): iOS 17.4 and
222
+ * later.
223
+ */
224
+ readonly opensPressMenus: boolean;
225
+ /** Open the menu `setPressMenu` gave the view with `nativeID`, now. */
226
+ openPressMenu(nativeID: string): void;
227
+ /** What choosing an item does, by the `nativeID` of the view whose press menu it is in. */
228
+ private readonly pressMenuChoices;
229
+ /**
230
+ * Send the menu a press opens on the view with `nativeID`, or null to take it away. `choose`
231
+ * runs with the item's `id` as the host sends the choice.
232
+ */
233
+ setPressMenu(nativeID: string, entries: readonly NativeMenuEntry[] | null, choose: (id: string) => void): void;
195
234
  /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */
196
235
  private readonly contextMenuChoices;
197
236
  /**
@@ -226,9 +265,10 @@ export declare class Menus {
226
265
  addShortcut(shortcut: Signal<string>, label: Signal<string>, press: () => void): () => void;
227
266
  private readonly navigators;
228
267
  /**
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.
268
+ * Hear the OS's back and forward commands. Apps with their own history can listen here.
269
+ * `@ng-native/router` listens and moves through the history of the window each was in,
270
+ * `steps` entries (one, but for a pick from a chevron's history menu). Returns a function to
271
+ * stop listening.
232
272
  */
233
273
  onNavigate(listener: (direction: 'back' | 'forward', surface?: number, steps?: number) => void): () => void;
234
274
  /**
package/dist/menus.js CHANGED
@@ -17,7 +17,10 @@
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
+ * keeps a menu a press opens for that view, and sends the item chosen as
22
+ * `{ type: 'pressMenuSelect', nativeID, id }`. From iOS 17.4, where its `opensPressMenus`
23
+ * constant is true, `openPressMenu(nativeID)` opens it from code too.
21
24
  * - Where it draws menus on a press, `popUpMenu(view, entries)` draws one under the view with that
22
25
  * tag now, and sends the item chosen as the view's `topContextMenuSelect`, as a context menu's
23
26
  * (the desktop host, and Android).
@@ -31,7 +34,7 @@ import { InjectionToken, Service, computed, effect, inject, signal, } from '@ang
31
34
  import { defaultMenuBar, isSeparator, mergeMenuBar, unmergedGroups, } from "./menu-model.js";
32
35
  import { injectOs } from "./os.js";
33
36
  import { reactNative } from "./react-native.js";
34
- import { isEditingShortcut, navigationShortcut, parseShortcut, } from "./shortcut.js";
37
+ import { isEditingShortcut, matchesShortcut, navigationShortcut, parseShortcut, } from "./shortcut.js";
35
38
  import * as i0 from "@angular/core";
36
39
  const actionIds = new WeakMap();
37
40
  let actionsNamed = 0;
@@ -77,6 +80,29 @@ export function serializeMenu(entries, os, prefix = '') {
77
80
  });
78
81
  return { entries: walk(entries, prefix), actions };
79
82
  }
83
+ /** Whether an enabled app menu item, including one in a submenu, takes this chord. */
84
+ function hasMacMenuAction(entries, chord) {
85
+ return entries.some((entry) => {
86
+ if (isSeparator(entry) || entry.disabled)
87
+ return false;
88
+ if (entry.items)
89
+ return hasMacMenuAction(entry.items, chord);
90
+ return Boolean(entry.select && entry.shortcut && matchesShortcut(entry.shortcut, chord, 'macos'));
91
+ });
92
+ }
93
+ /** Keep the built-in navigation commands clickable when an app item takes their keys. */
94
+ function releaseMacNavigationKeys(entries, groups) {
95
+ return entries.map((entry) => {
96
+ if ('separator' in entry || entry.handled)
97
+ return entry;
98
+ if (entry.menuRole !== 'back' && entry.menuRole !== 'forward')
99
+ return entry;
100
+ const { shortcut, ...item } = entry;
101
+ return shortcut && groups.some((group) => hasMacMenuAction(group.items, shortcut))
102
+ ? item
103
+ : entry;
104
+ });
105
+ }
80
106
  /** Android's `NgNativeMenus`, an Expo module, where React Native has no TurboModule of the name. */
81
107
  function expoMenusModule() {
82
108
  const modules = globalThis.expo?.modules;
@@ -104,7 +130,7 @@ export function menusSource() {
104
130
  setMenuBar: (groups) => module.setMenuBar?.(groups),
105
131
  setShortcuts: (shortcuts) => module.setShortcuts?.(shortcuts),
106
132
  setHistory: (surface, history) => module.setHistory?.(surface, history),
107
- ...contextMenuMethods(module),
133
+ ...contextMenuMethods(module, constants.opensPressMenus === true),
108
134
  subscribe: (listener) => {
109
135
  const subscription = listen((event) => listener(event));
110
136
  return () => subscription?.remove();
@@ -113,16 +139,21 @@ export function menusSource() {
113
139
  }
114
140
  /**
115
141
  * 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)`.
142
+ * ones reads props, and one without `popUpMenu` or `setPressMenu` leaves a press to `(press)`.
143
+ * `openPressMenu` only where the module says it opens one (`opens`): iOS 17.4 and later.
117
144
  */
118
- function contextMenuMethods(module) {
145
+ function contextMenuMethods(module, opens) {
119
146
  const setContextMenu = module.setContextMenu?.bind(module);
120
147
  const setTakesLongPress = module.setTakesLongPress?.bind(module);
121
148
  const popUpMenu = module.popUpMenu?.bind(module);
149
+ const setPressMenu = module.setPressMenu?.bind(module);
150
+ const openPressMenu = opens ? module.openPressMenu?.bind(module) : undefined;
122
151
  return {
123
152
  ...(setContextMenu && { setContextMenu }),
124
153
  ...(setTakesLongPress && { setTakesLongPress }),
125
154
  ...(popUpMenu && { popUpMenu }),
155
+ ...(setPressMenu && { setPressMenu }),
156
+ ...(openPressMenu && { openPressMenu }),
126
157
  };
127
158
  }
128
159
  /**
@@ -195,6 +226,33 @@ export class Menus {
195
226
  popUpMenu(view, entries) {
196
227
  this.native?.popUpMenu?.(view, entries);
197
228
  }
229
+ /**
230
+ * Whether the host takes a menu a press opens by the view's `nativeID` (`setPressMenu`), and
231
+ * opens it on a touch itself: iOS.
232
+ */
233
+ pressMenuByNativeId = this.native?.setPressMenu !== undefined;
234
+ /**
235
+ * Whether the host opens a press menu by `nativeID` from code (`openPressMenu`): iOS 17.4 and
236
+ * later.
237
+ */
238
+ opensPressMenus = this.native?.openPressMenu !== undefined;
239
+ /** Open the menu `setPressMenu` gave the view with `nativeID`, now. */
240
+ openPressMenu(nativeID) {
241
+ this.native?.openPressMenu?.(nativeID);
242
+ }
243
+ /** What choosing an item does, by the `nativeID` of the view whose press menu it is in. */
244
+ pressMenuChoices = new Map();
245
+ /**
246
+ * Send the menu a press opens on the view with `nativeID`, or null to take it away. `choose`
247
+ * runs with the item's `id` as the host sends the choice.
248
+ */
249
+ setPressMenu(nativeID, entries, choose) {
250
+ if (entries)
251
+ this.pressMenuChoices.set(nativeID, choose);
252
+ else
253
+ this.pressMenuChoices.delete(nativeID);
254
+ this.native?.setPressMenu?.(nativeID, entries);
255
+ }
198
256
  /** What choosing an item does, by the `nativeID` of the view whose menu it is in. */
199
257
  contextMenuChoices = new Map();
200
258
  /**
@@ -241,7 +299,9 @@ export class Menus {
241
299
  return {
242
300
  label: group.label,
243
301
  ...(group.menuRole && { menuRole: group.menuRole }),
244
- items: menu.entries,
302
+ items: this.os === 'macos' && group.menuRole === 'view'
303
+ ? releaseMacNavigationKeys(menu.entries, groups)
304
+ : menu.entries,
245
305
  };
246
306
  });
247
307
  return { sent, actions };
@@ -328,9 +388,10 @@ export class Menus {
328
388
  }
329
389
  navigators = new Set();
330
390
  /**
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.
391
+ * Hear the OS's back and forward commands. Apps with their own history can listen here.
392
+ * `@ng-native/router` listens and moves through the history of the window each was in,
393
+ * `steps` entries (one, but for a pick from a chevron's history menu). Returns a function to
394
+ * stop listening.
334
395
  */
335
396
  onNavigate(listener) {
336
397
  this.navigators.add(listener);
@@ -358,6 +419,10 @@ export class Menus {
358
419
  this.contextMenuChoices.get(event.nativeID)?.(event.id);
359
420
  return;
360
421
  }
422
+ if (event.type === 'pressMenuSelect') {
423
+ this.pressMenuChoices.get(event.nativeID)?.(event.id);
424
+ return;
425
+ }
361
426
  const { presses, editing } = this.sentShortcuts();
362
427
  // The editing keys belong to a focused text input: the app's shortcut on one waits.
363
428
  if (event.textInputFocused && editing.has(event.id))
@@ -367,10 +432,10 @@ export class Menus {
367
432
  ngOnDestroy() {
368
433
  this.unsubscribe?.();
369
434
  }
370
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Menus, deps: [], target: i0.ɵɵFactoryTarget.Service });
371
- static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: Menus });
435
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: Menus, deps: [], target: i0.ɵɵFactoryTarget.Service });
436
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.3.0", ngImport: i0, type: Menus });
372
437
  }
373
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Menus, decorators: [{
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: Menus, decorators: [{
374
439
  type: Service
375
440
  }], ctorParameters: () => [] });
376
441
  //# sourceMappingURL=menus.js.map