@legendapp/spark 0.0.1-next.7 → 0.0.1-next.9

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 (128) hide show
  1. package/package.json +8 -8
  2. package/schema.json +9 -0
  3. package/skills/spark/SKILL.md +1 -1
  4. package/skills/spark/UPGRADING.md +34 -0
  5. package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
  6. package/vendor/node_modules/@legendapp/spark-audio/package.json +2 -2
  7. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
  8. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +1 -1
  9. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +16 -4
  10. package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +16 -4
  11. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +2 -1
  12. package/vendor/node_modules/@legendapp/spark-cli/dist/macos-release.js +4 -0
  13. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager-config.js +3 -1
  14. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +10 -4
  15. package/vendor/node_modules/@legendapp/spark-cli/dist/release-driver.js +35 -0
  16. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +18 -18
  17. package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +18 -8
  18. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +1 -1
  19. package/vendor/node_modules/@legendapp/spark-cli/package.json +4 -4
  20. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/app.json +5 -1
  21. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/gitignore +2 -1
  22. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +8 -7
  23. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/app.json +5 -1
  24. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/gitignore +2 -1
  25. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +9 -8
  26. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/app.json +5 -1
  27. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/gitignore +2 -1
  28. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +9 -8
  29. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +2 -2
  30. package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +88 -76
  31. package/vendor/node_modules/@legendapp/spark-codex/package.json +2 -2
  32. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  33. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +2 -2
  34. package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +12 -1
  35. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +8 -1
  36. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +8 -0
  37. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +84 -21
  38. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.h +27 -0
  39. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.mm +207 -0
  40. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +44 -0
  41. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +349 -0
  42. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +3 -1
  43. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +1 -1
  44. package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +39 -6
  45. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +21 -7
  46. package/vendor/node_modules/@legendapp/spark-desktop-config/accessibility-state.cjs +50 -0
  47. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +9 -1
  48. package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +8 -1
  49. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +1 -1
  50. package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +7 -1
  51. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +4 -4
  52. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-scroll-view.cjs +144 -0
  53. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-alignment.cjs +60 -0
  54. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-input-alignment.cjs +112 -0
  55. package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +9 -0
  56. package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.cjs +11 -0
  57. package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.d.cts +2 -0
  58. package/vendor/node_modules/@legendapp/spark-desktop-config/text-input-accessibility.cjs +47 -0
  59. package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +4 -2
  60. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +2 -1
  61. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -1
  62. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +18 -6
  63. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  64. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +61 -15
  65. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/launch.inc +67 -0
  66. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +2 -2
  67. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +2 -2
  68. package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +3 -0
  69. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +5 -2
  70. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +22 -3
  71. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +3 -3
  72. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  73. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +2 -2
  74. package/vendor/node_modules/@legendapp/spark-file-dialog/RNFileDialog.podspec +1 -0
  75. package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +153 -64
  76. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +2 -2
  77. package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +19 -7
  78. package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +5 -1
  79. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +42 -4
  80. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +18 -2
  81. package/vendor/node_modules/@legendapp/spark-file-system/package.json +2 -2
  82. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +2 -2
  83. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  84. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  85. package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +2 -1
  86. package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +113 -12
  87. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +2 -2
  88. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +110 -14
  89. package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +116 -8
  90. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +2 -2
  91. package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +63 -18
  92. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +9 -3
  93. package/vendor/node_modules/@legendapp/spark-notifications/package.json +2 -2
  94. package/vendor/node_modules/@legendapp/spark-processes/package.json +2 -2
  95. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  96. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +2 -2
  97. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  98. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  99. package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +5 -2
  100. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  101. package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +13 -3
  102. package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.h +9 -0
  103. package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.mm +31 -0
  104. package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.h +24 -0
  105. package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.mm +101 -0
  106. package/vendor/node_modules/@legendapp/spark-system/package.json +2 -2
  107. package/vendor/node_modules/@legendapp/spark-system/src/index.ts +73 -7
  108. package/vendor/node_modules/@legendapp/spark-tray/package.json +2 -2
  109. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +2 -0
  110. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkLayoutDirection.h +17 -0
  111. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +6 -1
  112. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +55 -8
  113. package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +11 -7
  114. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +4 -0
  115. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +4 -0
  116. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -0
  117. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +77 -14
  118. package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +31 -7
  119. package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +25 -1
  120. package/vendor/node_modules/@legendapp/spark-ui/package.json +2 -2
  121. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +5 -0
  122. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +19 -8
  123. package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +25 -13
  124. package/vendor/node_modules/@legendapp/spark-updates/macos/SparkUpdateState.h +39 -0
  125. package/vendor/node_modules/@legendapp/spark-updates/package.json +2 -2
  126. package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +45 -9
  127. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  128. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
@@ -1,35 +1,70 @@
1
1
  import { NativeEventEmitter, Platform } from "react-native";
2
2
  import NativeMenu from "./NativeMenu";
3
3
  import { SparkError, asyncRegistration, invokeNative, type Availability, type AsyncRegistration } from "@legendapp/spark-desktop-app/src/contracts";
4
- import { menuItems, selectableMenuIds, type MenuItem as SharedMenuItem, type MenuItemTree, type MenuWireItem, type MenuAction as SharedMenuAction } from "@legendapp/spark-desktop-app/src/contracts/menu";
4
+ import { menuItems, selectableMenuIds, type MenuInputItem, type MenuWireItem, type MenuAction as SharedMenuAction } from "@legendapp/spark-desktop-app/src/contracts/menu";
5
5
  import { composeWindowsMenus } from "./windows-menus";
6
- type NativeMenuLeaf = Extract<SharedMenuItem, { type: "action" | "checkbox" | "separator" | "role" }>;
7
- export type MenuItem = MenuItemTree<NativeMenuLeaf>;
6
+ type MenuLeaf = Extract<MenuInputItem, { type: "separator" | "action" | "checkbox" | "role" }>;
7
+ export type MenuItem = MenuLeaf | (Omit<Extract<MenuInputItem, { type: "submenu" }>, "items"> & { items: readonly MenuItem[] });
8
+ export type MenuFeature = "alternates" | "lifecycle" | "helpSearch" | "mixedState" | "icons" | "hiddenItems";
9
+ export interface MenuLifecycleEvent { menuId: string }
8
10
  export type MenuAction = Extract<SharedMenuAction, { type: "action" }>;
9
11
  export type { MenuIcon, MenuRole, MenuTarget, MenuPlacement, MenuLocation } from "@legendapp/spark-desktop-app/src/contracts/menu";
10
12
  export type { AsyncRegistration } from "@legendapp/spark-desktop-app/src/contracts";
11
13
  export type MenuRootItem = Extract<MenuItem, { type: "submenu" }>;
12
14
  export interface MenuUpdate { items: readonly MenuRootItem[] }
13
- export interface MenuOptions extends MenuUpdate { id: string; onAction?: (action: MenuAction) => void }
15
+ export interface MenuOptions extends MenuUpdate { id: string; onAction?: (action: MenuAction) => void; onOpen?: (event: MenuLifecycleEvent) => void; onClose?: (event: MenuLifecycleEvent) => void }
14
16
  export interface Menu extends AsyncRegistration { readonly id: string; update(options: MenuUpdate): Promise<void> }
15
17
  interface Owner { id: string; token: string; items: MenuWireItem[] }
16
18
  let owners = new Map<string, Owner>();
17
19
  let sequence = 0, queue: Promise<unknown> = Promise.resolve();
18
20
  function serial<T>(operation: () => Promise<T>): Promise<T> { const result = queue.then(operation); queue = result.catch(() => {}); return result; }
19
- export function getMenuAvailability(): Availability {
21
+ export function getMenuAvailability(feature?: MenuFeature): Availability {
22
+ if (feature !== undefined && !["alternates", "lifecycle", "helpSearch", "mixedState", "icons", "hiddenItems"].includes(feature)) throw new SparkError("E_INVALID_ARGUMENT", "Unknown menu feature");
20
23
  if (Platform.OS !== "macos" && Platform.OS !== "windows") return { available: false, reason: "unsupported-platform" };
21
- return NativeMenu ? { available: true } : { available: false, reason: "missing-module" };
24
+ if (!NativeMenu) return { available: false, reason: "missing-module" };
25
+ if (Platform.OS === "windows" && feature !== undefined && feature !== "hiddenItems") return { available: false, reason: "host-restriction" };
26
+ return { available: true };
22
27
  }
23
28
  function available() {
24
29
  const availability = getMenuAvailability();
25
30
  if (!availability.available) throw new SparkError(availability.reason === "unsupported-platform" ? "E_UNSUPPORTED_PLATFORM" : "E_MODULE_UNAVAILABLE", "Application menus are unavailable");
26
31
  }
27
- function snapshot(value: MenuUpdate, token: string, creating = false): MenuWireItem[] {
32
+ function applicationItems(input: readonly MenuItem[]): MenuWireItem[] {
33
+ const macos = Platform.OS === "macos";
34
+ const items = menuItems(input, { types: macos ? ["action", "checkbox", "separator", "submenu", "role"] : ["action", "checkbox", "separator", "submenu"], shortcuts: true, targeting: true, icons: macos ? ["symbol", "image"] : [], alternates: macos, mixedState: macos }, macos ? "macos" : "windows");
35
+ validateAlternates(items);
36
+ return items;
37
+ }
38
+ /** AppKit folds an alternate only into the adjacent visible item with the same key equivalent and different modifiers. */
39
+ function validateAlternates(items: readonly MenuWireItem[]) {
40
+ const visible = items.filter(item => !item.hidden);
41
+ for (const item of items) if (item.items) validateAlternates(item.items);
42
+ visible.forEach((item, index) => {
43
+ if (!item.alternate) return;
44
+ const primary = visible[index - 1];
45
+ const invalid = (message: string) => new SparkError("E_INVALID_ARGUMENT", `Alternate menu item ${item.id} ${message}`);
46
+ if (!primary || primary.separator || primary.items || primary.alternate) throw invalid("must directly follow the visible non-alternate command it replaces");
47
+ if (item.target || item.placement || primary.target || primary.placement) throw invalid("and its primary cannot use target or placement");
48
+ if (primary.shortcut?.key !== item.shortcut?.key) throw invalid("must use the same shortcut key as its primary, or neither has a shortcut");
49
+ if (item.shortcut && primary.shortcut?.modifiers === item.shortcut.modifiers) throw invalid("must use different shortcut modifiers from its primary");
50
+ });
51
+ }
52
+ function submenuIds(items: MenuWireItem[]): Set<string> {
53
+ const ids = new Set<string>();
54
+ function visit(items: MenuWireItem[]) {
55
+ for (const item of items) if (item.items && item.enabled && !item.hidden) {
56
+ if (item.id) ids.add(item.id);
57
+ visit(item.items);
58
+ }
59
+ }
60
+ visit(items); return ids;
61
+ }
62
+ function snapshot(value: MenuUpdate, token: string, creating = false, lifecycle = false): MenuWireItem[] {
28
63
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new SparkError("E_INVALID_ARGUMENT", "Expected menu options");
29
- for (const key of Object.keys(value)) if (!["items", ...(creating ? ["id", "onAction"] : [])].includes(key)) throw new SparkError("E_UNSUPPORTED_OPTION", `Unsupported menu option: ${key}`);
30
- const items = menuItems(value.items, { types: Platform.OS === "macos" ? ["action", "checkbox", "separator", "submenu", "role"] : ["action", "checkbox", "separator", "submenu"], shortcuts: true, targeting: true, icons: Platform.OS === "macos" ? ["symbol", "image"] : [] }, Platform.OS === "windows" ? "windows" : "macos");
64
+ for (const key of Object.keys(value)) if (!["items", ...(creating ? ["id", "onAction", "onOpen", "onClose"] : [])].includes(key)) throw new SparkError("E_UNSUPPORTED_OPTION", `Unsupported menu option: ${key}`);
65
+ const items = applicationItems(value.items);
31
66
  if (items.some(item => !item.items)) throw new SparkError("E_INVALID_ARGUMENT", "Application menu roots must be submenus");
32
- function annotate(items: MenuWireItem[]) { for (const item of items) { item._sparkOwner = token; if (item.items) annotate(item.items); } }
67
+ function annotate(items: MenuWireItem[]) { for (const item of items) { item._sparkOwner = token; if (item.items) { if (lifecycle) item._sparkLifecycle = true; annotate(item.items); } } }
33
68
  annotate(items); return items;
34
69
  }
35
70
  async function publish(next: Map<string, Owner>): Promise<void> {
@@ -43,11 +78,14 @@ async function publish(next: Map<string, Owner>): Promise<void> {
43
78
  export async function createMenu(options: MenuOptions): Promise<Menu> {
44
79
  available();
45
80
  const token = `menu-${Date.now()}-${++sequence}`;
46
- const items = snapshot(options, token, true);
81
+ const items = snapshot(options, token, true, Boolean(options?.onOpen || options?.onClose));
82
+ for (const name of ["onAction", "onOpen", "onClose"] as const) {
83
+ if (options[name] !== undefined && typeof options[name] !== "function") throw new SparkError("E_INVALID_ARGUMENT", `Expected ${name} callback`);
84
+ }
85
+ if ((options.onOpen || options.onClose) && Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_OPTION", "Application menus do not support lifecycle callbacks on this platform");
47
86
  if (typeof options.id !== "string" || !/^[a-zA-Z0-9_-]{1,100}$/.test(options.id)) throw new SparkError("E_INVALID_ARGUMENT", "Expected a menu owner id");
48
- if (options.onAction !== undefined && typeof options.onAction !== "function") throw new SparkError("E_INVALID_ARGUMENT", "Expected onAction callback");
49
- const id = options.id, onAction = options.onAction;
50
- let stopped = false, ready = false, ids = selectableMenuIds(items);
87
+ const id = options.id, { onAction, onOpen, onClose } = options;
88
+ let stopped = false, ready = false, ids = selectableMenuIds(items), menus = submenuIds(items);
51
89
  const subscription = new NativeEventEmitter(NativeMenu as never).addListener("NativeMenuAction", event => {
52
90
  if (ready && !stopped && event && event.ownerId === token && typeof event.itemId === "string" && ids.has(event.itemId)) {
53
91
  // All owners share this emitter; one owner's throw must not swallow the other owners' actions.
@@ -55,11 +93,18 @@ export async function createMenu(options: MenuOptions): Promise<Menu> {
55
93
  catch (cause) { console.error(new SparkError("E_NATIVE", "Menu action handler failed", { cause })); }
56
94
  }
57
95
  });
96
+ const lifecycle = onOpen || onClose ? new NativeEventEmitter(NativeMenu as never).addListener("NativeMenuLifecycle", event => {
97
+ if (ready && !stopped && event?.ownerId === token && menus.has(event.itemId) && (event.type === "open" || event.type === "close")) {
98
+ try { (event.type === "open" ? onOpen : onClose)?.({ menuId: event.itemId }); }
99
+ catch (cause) { console.error(new SparkError("E_NATIVE", "Menu lifecycle handler failed", { cause })); }
100
+ }
101
+ }) : undefined;
102
+ function stop() { stopped = true; subscription.remove(); lifecycle?.remove(); }
58
103
  try { await serial(async () => {
59
104
  if (owners.has(id)) throw new SparkError("E_ALREADY_EXISTS", `Menu owner ${id} already exists`);
60
105
  const next = new Map(owners); next.set(id, { id, token, items }); await publish(next); ready = true;
61
- }); } catch (error) { subscription.remove(); throw error; }
62
- const registration = asyncRegistration(() => { stopped = true; subscription.remove(); }, () => serial(async () => {
106
+ }); } catch (error) { stop(); throw error; }
107
+ const registration = asyncRegistration(stop, () => serial(async () => {
63
108
  if (owners.get(id)?.token !== token) return;
64
109
  const next = new Map(owners); next.delete(id); await publish(next);
65
110
  }));
@@ -67,14 +112,14 @@ export async function createMenu(options: MenuOptions): Promise<Menu> {
67
112
  id,
68
113
  async update(options) {
69
114
  if (stopped) throw new SparkError("E_CLOSED", "Menu was removed");
70
- const items = snapshot(options, token);
115
+ const items = snapshot(options, token, false, Boolean(onOpen || onClose));
71
116
  await serial(async () => {
72
117
  // Callers commonly rebuild identical item literals each render; republishing the whole
73
118
  // bar would rebuild native menus for no visible change. Compare the wire trees first.
74
119
  const existing = owners.get(id);
75
120
  if (existing?.token === token && JSON.stringify(existing.items) === JSON.stringify(items)) return;
76
121
  const next = new Map(owners); next.delete(id); next.set(id, { id, token, items });
77
- await publish(next); ids = selectableMenuIds(items);
122
+ await publish(next); ids = selectableMenuIds(items); menus = submenuIds(items);
78
123
  });
79
124
  },
80
125
  remove: registration.remove,
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
2
- import { createMenu, type Menu, type MenuOptions, type MenuAction } from "./api";
2
+ import { createMenu, type Menu, type MenuOptions, type MenuAction, type MenuLifecycleEvent } from "./api";
3
3
  export interface UseMenuOptions extends MenuOptions { onError?: (error: unknown) => void; onCleanupError?: (error: unknown, menu: Menu) => void }
4
4
  export type MenuState = { status: "loading" } | { status: "ready"; menu: Menu } | { status: "error"; error: unknown };
5
5
  interface Lifetime { menu?: Menu; removing?: Promise<void>; blocker?: Lifetime; items: MenuOptions["items"]; disposed: boolean; completion: Promise<void> }
@@ -9,6 +9,7 @@ export function useMenu(options: UseMenuOptions): MenuState {
9
9
  const [state, setState] = useState<MenuState>({ status: "loading" });
10
10
  const callbacks = useRef(options);
11
11
  useLayoutEffect(() => { callbacks.current = options; });
12
+ const observesLifecycle = options.onOpen !== undefined || options.onClose !== undefined;
12
13
  const current = useRef<Lifetime | undefined>(undefined);
13
14
  useEffect(() => {
14
15
  const previous = lifetimes.get(options.id);
@@ -62,7 +63,12 @@ export function useMenu(options: UseMenuOptions): MenuState {
62
63
  const initial = owner.items;
63
64
  let menu: Menu;
64
65
  try {
65
- menu = await createMenu({ id: options.id, items: initial, onAction: (event: MenuAction) => { if (!owner.disposed) callbacks.current.onAction?.(event); } });
66
+ menu = await createMenu({ id: options.id, items: initial, onAction: (event: MenuAction) => { if (!owner.disposed) callbacks.current.onAction?.(event); },
67
+ ...(observesLifecycle ? {
68
+ onOpen: (event: MenuLifecycleEvent) => { if (!owner.disposed) callbacks.current.onOpen?.(event); },
69
+ onClose: (event: MenuLifecycleEvent) => { if (!owner.disposed) callbacks.current.onClose?.(event); },
70
+ } : {}),
71
+ });
66
72
  owner.menu = menu;
67
73
  } catch (error) {
68
74
  report(error);
@@ -77,7 +83,7 @@ export function useMenu(options: UseMenuOptions): MenuState {
77
83
  if (owner.disposed) await remove(owner).catch(() => {});
78
84
  }).catch(report);
79
85
  return () => { owner.disposed = true; end(); };
80
- }, [options.id]);
86
+ }, [options.id, observesLifecycle]);
81
87
  useEffect(() => {
82
88
  const owner = current.current;
83
89
  if (!owner || owner.disposed || owner.items === options.items) return;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-notifications",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -40,7 +40,7 @@
40
40
  ]
41
41
  },
42
42
  "dependencies": {
43
- "@legendapp/spark-desktop-app": "0.0.1-next.7"
43
+ "@legendapp/spark-desktop-app": "0.0.1-next.9"
44
44
  },
45
45
  "private": true
46
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-processes",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -41,7 +41,7 @@
41
41
  ]
42
42
  },
43
43
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.1-next.7"
44
+ "@legendapp/spark-desktop-app": "0.0.1-next.9"
45
45
  },
46
46
  "private": true
47
47
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-rich-text",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "main": "src/index.ts",
@@ -13,6 +13,6 @@
13
13
  "react-native": "0.81.6"
14
14
  },
15
15
  "dependencies": {
16
- "@legendapp/spark-desktop-shortcuts": "0.0.1-next.7"
16
+ "@legendapp/spark-desktop-shortcuts": "0.0.1-next.9"
17
17
  }
18
18
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-secure-storage",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -41,7 +41,7 @@
41
41
  ]
42
42
  },
43
43
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.1-next.7"
44
+ "@legendapp/spark-desktop-app": "0.0.1-next.9"
45
45
  },
46
46
  "peerDependenciesMeta": {
47
47
  "expo-secure-store": {
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@legendapp/spark-settings",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "files": [
7
7
  "src"
8
8
  ],
9
9
  "dependencies": {
10
- "@legendapp/spark-file-system": "0.0.1-next.7",
10
+ "@legendapp/spark-file-system": "0.0.1-next.9",
11
11
  "@legendapp/state": "^3.0.0-beta.42",
12
- "@legendapp/spark-desktop-app": "0.0.1-next.7"
12
+ "@legendapp/spark-desktop-app": "0.0.1-next.9"
13
13
  },
14
14
  "private": true,
15
15
  "spark": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-settings-ui",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "main": "src/index.tsx",
@@ -8,9 +8,9 @@
8
8
  "src"
9
9
  ],
10
10
  "dependencies": {
11
- "@legendapp/spark-ui": "0.0.1-next.7",
12
- "@legendapp/spark-desktop-windows": "0.0.1-next.7",
13
- "@legendapp/spark-desktop-app": "0.0.1-next.7"
11
+ "@legendapp/spark-ui": "0.0.1-next.9",
12
+ "@legendapp/spark-desktop-windows": "0.0.1-next.9",
13
+ "@legendapp/spark-desktop-app": "0.0.1-next.9"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": "^19.1.0",
@@ -10,6 +10,9 @@ const SETTINGS_TITLEBAR_CONTENT_INSET = 56;
10
10
  const settingsContentInset = { bottom: 0, left: 0, right: 0, top: SETTINGS_TITLEBAR_CONTENT_INSET };
11
11
  const settingsSidebarPressablePlatformProps = Platform.OS === "macos" ? { enableFocusRing: false } : {};
12
12
  const SettingsRowGroupContext = createContext(false);
13
+ // Load the windows API lazily, once, and share that import across every settings window.
14
+ let windowsApi: Promise<typeof import("@legendapp/spark-desktop-windows/src/api")> | undefined;
15
+ const loadWindowsApi = () => windowsApi ??= import("@legendapp/spark-desktop-windows/src/api");
13
16
  export * from "./options";
14
17
 
15
18
  export interface SettingsWindowPage<PageId extends string = string> {
@@ -78,7 +81,7 @@ function useSettingsWindow(windowId: string, title: string, appearance: SidebarS
78
81
  const showIfReady = useCallback(() => {
79
82
  if (!active.current || !contentReady.current || !splitReady.current || shown.current) return;
80
83
  shown.current = true;
81
- void import("@legendapp/spark-desktop-windows/src/api").then(async windows => {
84
+ void loadWindowsApi().then(async windows => {
82
85
  if (!active.current) { shown.current = false; return; }
83
86
  await windows.showWindow(windowId);
84
87
  }).catch(cause => { shown.current = false; report(cause); });
@@ -86,7 +89,7 @@ function useSettingsWindow(windowId: string, title: string, appearance: SidebarS
86
89
  useEffect(() => { active.current = true; showIfReady(); return () => { active.current = false; }; }, [showIfReady]);
87
90
  useEffect(() => {
88
91
  let current = true;
89
- void import("@legendapp/spark-desktop-windows/src/api").then(async windows => {
92
+ void loadWindowsApi().then(async windows => {
90
93
  if (current) await windows.setWindowOptions(windowId, { title, appearance });
91
94
  }).catch(cause => { if (current) report(cause); });
92
95
  return () => { current = false; };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-sqlite",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -9,8 +9,8 @@
9
9
  ],
10
10
  "dependencies": {
11
11
  "@op-engineering/op-sqlite": "18.2.1",
12
- "@legendapp/spark-desktop-app": "0.0.1-next.7",
13
- "@legendapp/spark-file-system": "0.0.1-next.7"
12
+ "@legendapp/spark-desktop-app": "0.0.1-next.9",
13
+ "@legendapp/spark-file-system": "0.0.1-next.9"
14
14
  },
15
15
  "private": true
16
16
  }
@@ -1,5 +1,7 @@
1
1
  #import "RNDesktopSystem.h"
2
2
  #import <RNDesktopApp/SparkDesktop.h>
3
+ #import "SparkDockTile.h"
4
+ #import "SparkAppearancePreferences.h"
3
5
  #import <ServiceManagement/ServiceManagement.h>
4
6
  #import <IOKit/pwr_mgt/IOPMLib.h>
5
7
  #import <IOKit/ps/IOPowerSources.h>
@@ -42,7 +44,9 @@ RCT_EXPORT_MODULE(NativeDesktopSystem)
42
44
  @[NSDistributedNotificationCenter.defaultCenter, @"com.apple.screenIsLocked", @"lock"],
43
45
  @[NSDistributedNotificationCenter.defaultCenter, @"com.apple.screenIsUnlocked", @"unlock"],
44
46
  @[NSDistributedNotificationCenter.defaultCenter, @"AppleInterfaceThemeChangedNotification", @"appearanceChanged"],
45
- @[NSNotificationCenter.defaultCenter, NSApplicationDidChangeScreenParametersNotification, @"displaysChanged"]
47
+ @[NSNotificationCenter.defaultCenter, NSApplicationDidChangeScreenParametersNotification, @"displaysChanged"],
48
+ @[NSNotificationCenter.defaultCenter, NSSystemColorsDidChangeNotification, @"systemColorsChanged"],
49
+ @[NSWorkspace.sharedWorkspace.notificationCenter, NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification, @"accessibilityDisplayChanged"]
46
50
  ];
47
51
  for (NSArray *definition in definitions) {
48
52
  NSNotificationCenter *center = definition[0]; NSString *type = definition[2];
@@ -89,6 +93,11 @@ RCT_EXPORT_MODULE(NativeDesktopSystem)
89
93
  @"idleSeconds": @(CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType)) }];
90
94
  resolve(SparkJSON(value)); return;
91
95
  }
96
+ if ([method isEqual:@"preferences"]) {
97
+ NSString *error; NSDictionary *preferences = SparkAppearancePreferences(&error);
98
+ if (preferences) resolve(SparkJSON(preferences)); else reject(@"E_NATIVE", error, nil);
99
+ return;
100
+ }
92
101
  if ([method isEqual:@"observe"]) { [self.subscriptions addObject:args[@"id"]]; [self observe]; }
93
102
  else if ([method isEqual:@"unobserve"]) { [self.subscriptions removeObject:args[@"id"]]; if (!self.subscriptions.count) [self stopObserving]; }
94
103
  else if ([method isEqual:@"loginStatus"] || [method isEqual:@"login"]) {
@@ -103,7 +112,8 @@ RCT_EXPORT_MODULE(NativeDesktopSystem)
103
112
  BOOL success = [args[@"enabled"] boolValue] ? [SMAppService.mainAppService registerAndReturnError:&error] : [SMAppService.mainAppService unregisterAndReturnError:&error];
104
113
  if (!success) { SparkReject(reject, error); return; }
105
114
  }
106
- else if ([method isEqual:@"badge"]) NSApp.dockTile.badgeLabel = args[@"label"];
115
+ else if ([method isEqual:@"badge"]) SparkSetDockBadge(NSApp.dockTile, args);
116
+ else if ([method isEqual:@"progress"]) SparkSetDockProgress(NSApp.dockTile, [args[@"state"] isEqual:@"none"] ? nil : args);
107
117
  else if ([method isEqual:@"attention"]) { NSInteger token = [NSApp requestUserAttention:[args[@"critical"] boolValue] ? NSCriticalRequest : NSInformationalRequest]; [self.attention addObject:@(token)]; resolve(SparkJSON(@(token))); return; }
108
118
  else if ([method isEqual:@"cancelAttention"]) { if ([self.attention containsObject:args[@"id"]]) [NSApp cancelUserAttentionRequest:[args[@"id"] integerValue]]; [self.attention removeObject:args[@"id"]]; }
109
119
  else if ([method isEqual:@"clearDockMenu"]) { if ([self.dockOwner isEqual:args[@"owner"]]) { SparkDockMenu = nil; self.dockOwner = nil; } }
@@ -127,7 +137,7 @@ RCT_EXPORT_MODULE(NativeDesktopSystem)
127
137
  [self stopObserving]; [self.subscriptions removeAllObjects];
128
138
  for (NSNumber *value in self.assertions) IOPMAssertionRelease(value.unsignedIntValue); [self.assertions removeAllObjects];
129
139
  for (NSNumber *value in self.attention) [NSApp cancelUserAttentionRequest:value.integerValue]; [self.attention removeAllObjects];
130
- SparkDockMenu = nil; NSApp.dockTile.badgeLabel = nil;
140
+ SparkDockMenu = nil; NSApp.dockTile.badgeLabel = nil; SparkSetDockProgress(NSApp.dockTile, nil);
131
141
  }); }
132
142
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params { return std::make_shared<facebook::react::NativeDesktopSystemSpecJSI>(params); }
133
143
  @end
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ // The user's appearance and accessibility display preferences (docs/system.md#appearance-preferences).
4
+ // Main thread only. Needs no React Native, so tests/appearance-preferences.native.mm runs it directly.
5
+
6
+ // { appearance, automaticAppearance, accentColor, highlightColor, increaseContrast, reduceTransparency, reduceMotion,
7
+ // differentiateWithoutColor, invertColors, keyboardNavigation }.
8
+ // nil, with `error` set, when a system color has no sRGB form.
9
+ FOUNDATION_EXPORT NSDictionary *SparkAppearancePreferences(NSString **error);
@@ -0,0 +1,31 @@
1
+ #import "SparkAppearancePreferences.h"
2
+ #import <AppKit/AppKit.h>
3
+
4
+ // sRGB #rrggbb of a dynamic system color, resolved in the app's effective appearance; nil without an sRGB form.
5
+ static NSString *Hex(NSColor *color) {
6
+ __block NSColor *rgb;
7
+ [NSApp.effectiveAppearance performAsCurrentDrawingAppearance:^{ rgb = [color colorUsingColorSpace:NSColorSpace.sRGBColorSpace]; }];
8
+ if (!rgb) return nil;
9
+ int (^byte)(CGFloat) = ^int(CGFloat component) { return (int)lround(fmin(1, fmax(0, component)) * 255); };
10
+ return [NSString stringWithFormat:@"#%02x%02x%02x", byte(rgb.redComponent), byte(rgb.greenComponent), byte(rgb.blueComponent)];
11
+ }
12
+
13
+ NSDictionary *SparkAppearancePreferences(NSString **error) {
14
+ NSString *accent = Hex(NSColor.controlAccentColor), *highlight = Hex(NSColor.selectedTextBackgroundColor);
15
+ if (!accent || !highlight) { *error = @"The accent or highlight color has no sRGB form"; return nil; }
16
+ NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
17
+ NSWorkspace *workspace = NSWorkspace.sharedWorkspace;
18
+ return @{
19
+ // System Settings > Appearance, not the app's own appearance: AppleInterfaceStyle is set only while dark.
20
+ @"appearance": [[defaults stringForKey:@"AppleInterfaceStyle"] isEqualToString:@"Dark"] ? @"dark" : @"light",
21
+ @"automaticAppearance": @([defaults boolForKey:@"AppleInterfaceStyleSwitchesAutomatically"]),
22
+ @"accentColor": accent,
23
+ @"highlightColor": highlight,
24
+ @"increaseContrast": @(workspace.accessibilityDisplayShouldIncreaseContrast),
25
+ @"reduceTransparency": @(workspace.accessibilityDisplayShouldReduceTransparency),
26
+ @"reduceMotion": @(workspace.accessibilityDisplayShouldReduceMotion),
27
+ @"differentiateWithoutColor": @(workspace.accessibilityDisplayShouldDifferentiateWithoutColor),
28
+ @"invertColors": @(workspace.accessibilityDisplayShouldInvertColors),
29
+ @"keyboardNavigation": @(NSApp.isFullKeyboardAccessEnabled),
30
+ };
31
+ }
@@ -0,0 +1,24 @@
1
+ // Dock tile progress without React Native, so native tests can render it directly.
2
+ #import <AppKit/AppKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+ /// The app icon with a progress bar along its lower edge. The Dock draws the tile's badgeLabel on
6
+ /// top of a custom content view, so the bar stays clear of the badge corner (top right).
7
+ @interface SparkDockProgressView : NSView
8
+ /// "normal", "paused", "error" or "indeterminate".
9
+ @property (nonatomic, copy) NSString *state;
10
+ /// The completed fraction from 0 to 1; indeterminate progress ignores it.
11
+ @property (nonatomic) double value;
12
+ /// Where the bar sits, in the view's coordinates.
13
+ @property (nonatomic, readonly) NSRect trackRect;
14
+ /// The bar's fill for the current state, resolved in the view's appearance.
15
+ @property (nonatomic, readonly) NSColor *fillColor;
16
+ @end
17
+
18
+ /// Shows `progress` ({ state, value }) on `tile`, reusing its progress view, or restores the tile's
19
+ /// previous content view for nil. The view follows the system appearance and accent color while installed.
20
+ FOUNDATION_EXPORT void SparkSetDockProgress(NSDockTile *tile, NSDictionary *_Nullable progress);
21
+ /// Shows `badge` ({ count } or { label }) on `tile`: a count in the user's locale, or the label as given.
22
+ /// A count of 0 or an empty label clears it.
23
+ FOUNDATION_EXPORT void SparkSetDockBadge(NSDockTile *tile, NSDictionary *badge);
24
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,101 @@
1
+ #import "SparkDockTile.h"
2
+
3
+ // The Dock follows the system appearance, not an app's NSApp.appearance override.
4
+ static NSAppearance *SystemAppearance(void) {
5
+ BOOL dark = [[NSUserDefaults.standardUserDefaults stringForKey:@"AppleInterfaceStyle"] isEqualToString:@"Dark"];
6
+ return [NSAppearance appearanceNamed:dark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua];
7
+ }
8
+ static NSColor *Dynamic(NSColor *light, NSColor *dark) {
9
+ return [NSColor colorWithName:nil dynamicProvider:^NSColor *(NSAppearance *appearance) {
10
+ return [[appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]] isEqualToString:NSAppearanceNameDarkAqua] ? dark : light;
11
+ }];
12
+ }
13
+
14
+ @interface SparkDockProgressView ()
15
+ /// The tile's view before progress (AppKit installs an image view for a custom applicationIconImage).
16
+ @property (nonatomic, readonly, nullable) NSView *previous;
17
+ @end
18
+
19
+ @implementation SparkDockProgressView {
20
+ __weak NSDockTile *_tile;
21
+ NSArray<NSArray *> *_observers;
22
+ }
23
+ - (instancetype)initWithTile:(NSDockTile *)tile {
24
+ if (!(self = [super initWithFrame:NSMakeRect(0, 0, tile.size.width, tile.size.height)])) return nil;
25
+ _tile = tile; _previous = tile.contentView; _state = @"normal";
26
+ self.appearance = SystemAppearance();
27
+ __weak SparkDockProgressView *weak = self;
28
+ void (^refresh)(NSNotification *) = ^(NSNotification *note) {
29
+ SparkDockProgressView *view = weak;
30
+ if (!view) return;
31
+ view.appearance = SystemAppearance();
32
+ [view->_tile display];
33
+ };
34
+ _observers = @[
35
+ @[NSDistributedNotificationCenter.defaultCenter, [NSDistributedNotificationCenter.defaultCenter addObserverForName:@"AppleInterfaceThemeChangedNotification" object:nil queue:NSOperationQueue.mainQueue usingBlock:refresh]],
36
+ @[NSNotificationCenter.defaultCenter, [NSNotificationCenter.defaultCenter addObserverForName:NSSystemColorsDidChangeNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:refresh]],
37
+ ];
38
+ return self;
39
+ }
40
+ - (void)dealloc { for (NSArray *entry in _observers) [entry[0] removeObserver:entry[1]]; }
41
+ - (NSRect)trackRect {
42
+ NSSize size = self.bounds.size;
43
+ // Inside the icon's body (macOS icons leave about 10% transparent margin), below its center.
44
+ return NSMakeRect(round(size.width * 0.17), round(size.height * 0.15), round(size.width * 0.66), round(size.height * 0.1));
45
+ }
46
+ - (NSColor *)fillColor {
47
+ __block NSColor *color;
48
+ [self.effectiveAppearance performAsCurrentDrawingAppearance:^{
49
+ NSColor *named = [self.state isEqualToString:@"paused"] ? NSColor.systemYellowColor : [self.state isEqualToString:@"error"] ? NSColor.systemRedColor : NSColor.controlAccentColor;
50
+ color = [named colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
51
+ }];
52
+ return color;
53
+ }
54
+ - (void)drawRect:(NSRect)dirty {
55
+ [NSApp.applicationIconImage drawInRect:self.bounds fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1];
56
+ NSRect track = self.trackRect;
57
+ CGFloat radius = NSHeight(track) / 2, line = MAX(1, NSHeight(self.bounds) / 128);
58
+ NSBezierPath *capsule = [NSBezierPath bezierPathWithRoundedRect:track xRadius:radius yRadius:radius];
59
+ [Dynamic([NSColor colorWithWhite:1 alpha:0.94], [NSColor colorWithWhite:0.12 alpha:0.9]) setFill];
60
+ [capsule fill];
61
+ [NSGraphicsContext saveGraphicsState];
62
+ [capsule addClip];
63
+ [self.fillColor setFill];
64
+ if ([self.state isEqualToString:@"indeterminate"]) {
65
+ NSRectFill(track);
66
+ // Static diagonal stripes: the Dock redraws a tile only when asked, so it is not animated.
67
+ [[NSColor colorWithWhite:1 alpha:0.45] setFill];
68
+ CGFloat height = NSHeight(track);
69
+ for (CGFloat x = NSMinX(track) - height; x < NSMaxX(track); x += height * 2) {
70
+ NSBezierPath *stripe = [NSBezierPath new];
71
+ [stripe moveToPoint:NSMakePoint(x, NSMinY(track))]; [stripe lineToPoint:NSMakePoint(x + height, NSMinY(track))];
72
+ [stripe lineToPoint:NSMakePoint(x + height * 2, NSMaxY(track))]; [stripe lineToPoint:NSMakePoint(x + height, NSMaxY(track))];
73
+ [stripe closePath]; [stripe fill];
74
+ }
75
+ } else {
76
+ CGFloat width = round(NSWidth(track) * MIN(MAX(self.value, 0), 1));
77
+ BOOL rtl = self.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionRightToLeft;
78
+ NSRectFill(NSMakeRect(rtl ? NSMaxX(track) - width : NSMinX(track), NSMinY(track), width, NSHeight(track)));
79
+ }
80
+ [NSGraphicsContext restoreGraphicsState];
81
+ [Dynamic([NSColor colorWithWhite:0 alpha:0.25], [NSColor colorWithWhite:1 alpha:0.3]) setStroke];
82
+ NSBezierPath *outline = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(track, line / 2, line / 2) xRadius:radius - line / 2 yRadius:radius - line / 2];
83
+ outline.lineWidth = line;
84
+ [outline stroke];
85
+ }
86
+ @end
87
+
88
+ void SparkSetDockProgress(NSDockTile *tile, NSDictionary *progress) {
89
+ SparkDockProgressView *view = [tile.contentView isKindOfClass:SparkDockProgressView.class] ? (SparkDockProgressView *)tile.contentView : nil;
90
+ if (!progress) { if (view) { tile.contentView = view.previous; [tile display]; } return; }
91
+ if (!view) { view = [[SparkDockProgressView alloc] initWithTile:tile]; tile.contentView = view; }
92
+ view.state = progress[@"state"];
93
+ view.value = [progress[@"value"] doubleValue];
94
+ [tile display];
95
+ }
96
+
97
+ void SparkSetDockBadge(NSDockTile *tile, NSDictionary *badge) {
98
+ NSNumber *count = badge[@"count"];
99
+ NSString *label = count ? (count.integerValue ? [NSNumberFormatter localizedStringFromNumber:count numberStyle:NSNumberFormatterDecimalStyle] : nil) : badge[@"label"];
100
+ tile.badgeLabel = label.length ? label : nil;
101
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-system",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -40,7 +40,7 @@
40
40
  ]
41
41
  },
42
42
  "dependencies": {
43
- "@legendapp/spark-desktop-app": "0.0.1-next.7"
43
+ "@legendapp/spark-desktop-app": "0.0.1-next.9"
44
44
  },
45
45
  "private": true
46
46
  }